İçeriğe geç
ajan.io

Belgeler menüsü

Bu sayfada

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/public ile 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 Becerinin mode: "upsert" ile güncellenmesi, eşleşen Yeteneğe editör erişimi gerektirir.

Talep Formatı

İsteği multipart/form-data olarak gönderin.

AlanTürGerekliAçıklama
filedosyaEvetSKILL.md, .zip veya .skill dosya içeriği.
fileTypedizeEvetKullanılacak dosya ayrıştırıcı: md veya zip. .zip ve .skill arşivleri için zip kullanın.
modedizeHayırİçe aktarma modu: create veya upsert. Varsayılan: create.
integrationIdsdizeHayırEklenecek 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:

mdx
---
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ıGerekliAçıklama
nameEvetBeceri adı. Maksimum: 64 karakter.
slugHayırKararlı Beceri sümüklüböceği. Atlanırsa ajan addan bir tane oluşturur.
descriptionHayırAçıklama, Becerinin ne zaman uygulanması gerektiğini açıklamak için kullanılır. Maksimum: 1024 karakter.
licenseHayı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 boyutu25MB
Toplam sıkıştırılmamış boyut20MB
Bireysel dosya boyutu5 MB
Arşiv başına dosyalar200

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ı

ModuDavranış
createİçe aktarmadan yeni bir Beceri oluşturur. Bilgi zaten mevcutsa istek başarısız olur.
upsertDü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

javascript
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)

typescript
{
  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 KoduAçıklama
400Geçersiz form verileri, geçersiz SKILL.md, geçersiz zip arşivi veya erişilemez integrationIds
401Geçersiz veya eksik API anahtarı
403Eksik SKILL_API kapsamı, Beceri ürün erişimi, oluşturma izni veya düzenleyici erişimi
409Mevcut bilgi çakışması veya belirsiz üst bilgi sorunu
413Yüklenen dosya çok büyük
429Oran sınırı aşıldı
500Dahili 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"