Beceriyi İçe Aktar
SKILL.md dosyasından veya zip arşivinden bir Beceri oluşturun veya güncelleyin
SKILL.md dosyasından veya zip arşivinden bir Beceriyi içe aktarır. Depo tarafından yönetilen Becerileri ajan ile senkronize etmek için bu uç noktayı kullanın.
Temel URL
https://api.ajan.io/skills/v1/importÖzel dağıtımlar Tüm isteklerde
api.ajan.com'yi/api/publicile değiştirin.
Gerekli Kapsamlar
Bu uç nokta SKILL_API kapsamını gerektirir.
Yeni bir Beceri oluşturmak,
createSkillsçalışma alanı iznini gerektirir. Mevcut bir Becerininmode: "upsert"ile güncellenmesi, eşleşen Yeteneğe editör erişimi gerektirir.
Talep Formatı
İsteği multipart/form-data olarak gönderin.
| Alan | Tür | Gerekli | Açıklama |
|---|---|---|---|
file | dosya | Evet | SKILL.md, .zip veya .skill dosya içeriği. |
fileType | dize | Evet | Kullanılacak dosya ayrıştırıcı: md veya zip. .zip ve .skill arşivleri için zip kullanın. |
mode | dize | Hayır | İçe aktarma modu: create veya upsert. Varsayılan: create. |
integrationIds | dize | Hayır | Eklenecek JSON kodlu entegrasyon UUID dizisi, örneğin ["550e8400-e29b-41d4-a716-446655440000"]. |
SKILL.md Formatı
İçe aktarılan Beceri, YAML ön maddesini ve ardından talimatları içermelidir:
---
name: Support Reply Style
slug: support-reply-style
description: Applies the support team's tone and escalation rules.
---
Write concise replies, include the next best action, and escalate billing issues to the account owner.| Ön Madde Alanı | Gerekli | Açıklama |
|---|---|---|
name | Evet | Beceri adı. Maksimum: 64 karakter. |
slug | Hayır | Kararlı Beceri sümüklüböceği. Atlanırsa ajan addan bir tane oluşturur. |
description | Hayır | Açıklama, Becerinin ne zaman uygulanması gerektiğini açıklamak için kullanılır. Maksimum: 1024 karakter. |
license | Hayır | İsteğe bağlı lisans meta verileri. |
Zip arşivi kuralları
Zip arşivleri kökte veya bir üst düzey dizinin içinde bir SKILL.md dosyası içermelidir. ajan, Skill ile destekleyici dosyalara izin verir ve desteklenmeyen dosya türlerini atlar.
| Sınırı | Değer |
|---|---|
| Yükleme boyutu | 25MB |
| Toplam sıkıştırılmamış boyut | 20MB |
| Bireysel dosya boyutu | 5 MB |
| Arşiv başına dosyalar | 200 |
Desteklenen destekleyici dosya türleri arasında Markdown, metin, Python, kabuk, JavaScript, TypeScript, JSON, YAML, TOML, CSV, XML, HTML, CSS, SVG, PDF, Office dosyaları, yazı tipleri ve yaygın görüntü formatları bulunur.
İçe Aktarma Modları
| Modu | Davranış |
|---|---|
create | İçe aktarmadan yeni bir Beceri oluşturur. Bilgi zaten mevcutsa istek başarısız olur. |
upsert | Düzenlenebilir bir Beceriyi aynı bilgiyle günceller veya mevcut değilse yeni bir Beceri oluşturur. Birden fazla düzenlenebilir Beceri aynı bilgiyi kullanıyorsa istek başarısız olur. |
Bir upsert mevcut bir Beceriyi güncellediğinde, içe aktarılan dosyalar Becerinin mevcut depolanan dosyalarının yerini alır.
Örnek
const axios = require("axios");
const FormData = require("form-data");
const fs = require("fs");
async function importSkill() {
const form = new FormData();
form.append("file", fs.createReadStream("./support-reply-style.zip"));
form.append("fileType", "zip");
form.append("mode", "upsert");
form.append("integrationIds", JSON.stringify([]));
const response = await axios.post(
"https://api.ajan.io/skills/v1/import",
form,
{
headers: {
Authorization: "Bearer YOUR_API_KEY",
...form.getHeaders()
}
}
);
console.log("Imported Skill:", response.data.skill.id);
}
importSkill();Yanıt Formatı
Başarılı Yanıt (200 Tamam veya 201 Oluşturuldu)
{
skill: {
id: string;
name: string;
slug: string;
description: string;
instructions: string;
integrationIds: string[];
createdAt: string;
updatedAt: string;
};
files: Array<{
path: string;
sizeBytes: number;
extension: string;
hasScript: boolean;
}>;
}200 OK mevcut bir Becerinin upsert aracılığıyla güncellendiği anlamına gelir. 201 Created yeni bir Becerinin oluşturulduğu anlamına gelir.
Hata İşleme
| Durum Kodu | Açıklama |
|---|---|
| 400 | Geçersiz form verileri, geçersiz SKILL.md, geçersiz zip arşivi veya erişilemez integrationIds |
| 401 | Geçersiz veya eksik API anahtarı |
| 403 | Eksik SKILL_API kapsamı, Beceri ürün erişimi, oluşturma izni veya düzenleyici erişimi |
| 409 | Mevcut bilgi çakışması veya belirsiz üst bilgi sorunu |
| 413 | Yüklenen dosya çok büyük |
| 429 | Oran sınırı aşıldı |
| 500 | Dahili sunucu hatası |
ajan, API anahtarınızı korumak ve uygulamalarınızın güvende kalmasını sağlamak için tarayıcı kaynaklı istekleri kasıtlı olarak engeller. Daha fazla bilgi için lütfen API Key Best Practices hakkındaki kılavuzumuza bakın.
OpenAPI
openapi: 3.0.0
info:
title: ajan API
version: 3.0.0
servers:
- url: https://api.ajan.io
description: Production
security:
- bearerAuth: []
paths:
/skills/v1/import:
post:
tags:
- Skills
summary: Import a Skill
description: Creates or updates a Skill from a SKILL.md file or zip archive.
operationId: importSkill
requestBody:
required: true
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/ImportSkillRequest'
responses:
'200':
description: Existing Skill updated successfully
content:
application/json:
schema:
$ref: '#/components/schemas/ImportSkillResponse'
'201':
description: Skill created successfully
content:
application/json:
schema:
$ref: '#/components/schemas/ImportSkillResponse'
'400':
description: Invalid form data or zip archive
'401':
description: Invalid or missing API key
'403':
description: Missing required scope or Skill permission
'409':
description: Existing slug conflict or ambiguous upsert slug
'413':
description: Uploaded file is too large
'429':
description: Rate limit exceeded
'500':
description: Internal server error
components:
schemas:
ImportSkillRequest:
type: object
required:
- file
- fileType
properties:
file:
type: string
format: binary
description: SKILL.md, .zip, or .skill file content.
fileType:
type: string
enum:
- md
- zip
description: File parser to use.
mode:
type: string
enum:
- create
- upsert
default: create
description: >-
Whether to create a Skill or update an editable Skill with the same
slug.
integrationIds:
type: string
description: JSON-encoded array of integration UUIDs.
ImportSkillResponse:
type: object
required:
- skill
- files
properties:
skill:
$ref: '#/components/schemas/Skill'
files:
type: array
items:
$ref: '#/components/schemas/ImportedSkillFile'
Skill:
type: object
required:
- id
- name
- slug
- description
- instructions
- integrationIds
- createdAt
- updatedAt
properties:
id:
type: string
format: uuid
description: Unique identifier for the Skill.
name:
type: string
maxLength: 64
description: Skill name.
slug:
type: string
maxLength: 100
pattern: ^[a-z0-9-]+$
description: Stable Skill slug.
description:
type: string
maxLength: 1024
description: Description used to explain when the Skill should apply.
instructions:
type: string
maxLength: 50000
description: Skill instructions.
integrationIds:
type: array
items:
type: string
format: uuid
description: >-
Integration IDs attached to the Skill. Each integration must be
enabled in your workspace.
createdAt:
type: string
format: date-time
description: ISO 8601 timestamp for Skill creation.
updatedAt:
type: string
format: date-time
description: ISO 8601 timestamp for the latest Skill update.
ImportedSkillFile:
type: object
required:
- path
- sizeBytes
- extension
- hasScript
properties:
path:
type: string
description: File path inside the imported Skill.
sizeBytes:
type: integer
description: File size in bytes.
extension:
type: string
description: File extension.
hasScript:
type: boolean
description: Whether the file is a script file.
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: API Key
description: API key as Bearer token. Format "Bearer YOUR_API_KEY"