تخطَّ إلى المحتوى

SDK

تحكّم في OpenCode من سكربتاتك ومهام CI وأدواتك. يشغّل SDK OpenCode داخل عمليتك، بإعداداتك ونماذجك، وينشئ عميله المُنمّط الجلسات ويرسل المطالبات ويبث كل حدث.

الميزات

أصلح CI من الكود

سكربت قصير يطلب من OpenCode إصلاح الاختبارات الفاشلة، ثم يشغّلها من جديد.

تابع كل خطوة

ابثّ الأحداث لترى كل أداة يستدعيها الوكيل لحظة استدعائها.

ابنِ أدواتك

اربط OpenCode بالروبوتات ولوحات المعلومات وسير العمل ببضعة أسطر.

داخل عمليتك

يشغّل OpenCode داخل عمليتك، بإعداداتك ونماذجك.

  • عميل TypeScriptطلبات وأحداث مُنمّطة، بنفس قيم @opencode/client.
  • جلسات من الكودأنشئ الجلسات وأرسل المطالبات من أي سكربت.
  • أي نموذجيستخدم النماذج المضبوطة في إعداد OpenCode لديك.
  • npm أو bunثبّته عبر npm i @opencode/sdk أو bun add @opencode/sdk.
  • مضيف داخل العمليةيشغّل OpenCode في الذاكرة، دون المرور بالشبكة.
  • ملحقاتكمرّر ملحقاتك عند إنشاء المضيف داخل العملية.
  • Promise أو Effectواجهة Promise API وواجهة Effect API بنفس القيم.
  • Cloudflare Workersشغّل OpenCode داخل Cloudflare Durable Object على Workers.

  • npmnpm i @opencode/sdk
  • bunbun add @opencode/sdk
اقرأ وثائق SDK

سجل التغييرات

  1. v2.2.4

    Publish Interactive Artifacts

    Enable "experimental": { "artifacts": true } in opencode.json to let agents publish, update, and serve HTML or static artifacts through the built-in local provider or plugin-provided storage.#60351

    تحسينات

    • SDKExtended client.experimental.persistentPty.update to rename terminals or clear a user title, and exposed userTitle plus persistent-pty.updated events.#60329
  2. v2.2.3

    Added lazy loading for stored image references when experimental.media_blob is enabled

    Added lazy loading for stored image references when experimental.media_blob is enabled. Images are downloaded only for previews, while undo, revert, fork, and prompt recall restore referenced attachments safely.#60116

    تحسينات

    • SDKPreserved partial LLMResponse output on AIError.partial when generation, object generation, or a tool loop fails.#60477
    • SDKUnified Effect and Promise tool declarations around tool(...), with optional output schemas and executable or declaration-only tools.#60407
    • SDKAdded typed OpenRouter debug, models, plugins, provider, and user options to the Responses route.#60044

    إصلاحات

    • SDKMatched the Promise AI client more closely to the Effect API and accepted typed tools in loops.#60465#60390
    • SDKKept tools whose execute handler can throw available to the AI client.#60431
    • SDKContinued polling queued media generations when providers return unknown intermediate statuses.#59988
    • SDKStopped sending an incompatible filename alongside file_url on OpenAI Responses requests.#60382
  3. v2.2.2

    Exposed SessionInfo.time.busy for the latest execution’s start time

    تحسينات

    • SDKAdded if and until inputs for client.experimental.schedule.create, plus schedule check results and output fields.#60137
    • SDKAdded optional source metadata to prompt file attachments.
كل التحديثات