До вмісту

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 або EffectPromise API та Effect API з однаковими значеннями.
  • Cloudflare WorkersЗапускайте OpenCode у Cloudflare Durable Object на Workers.

  • npmnpm i @opencode/sdk
  • bunbun add @opencode/sdk
Документація SDK

Журнал змін

  1. v2.2.7

    session.generate returns tokens and cost along with text

    Усі головні зміни v2.2.7

    Несумісні зміни

    SDK: fewer endpoints wait for plugins to load

    On a Location that is still loading plugins, agent.list returns the agents loaded so far, and integration.list, usage.limits, vcs.init, rpc.call and artifact.* no longer wait up to 5 seconds. Entries and actions that a plugin provides appear when it finishes loading, so refresh on the matching *.updated event. Model, provider, generate.*, voice.* and websearch.query endpoints still wait.

    #62796#63040

    Покращення

    • SDKcredential.updated includes the integrationID and credentialID of the login that changed.#62762
    • SDKPredicate questions in client.experimental.generate.decisions accept optional criteria: { true?, false? }.#62819
  2. v2.2.6

    Improvements

    Усі головні зміни v2.2.6

    Покращення

    • SDKAdded client.experimental.job.list() and its Effect equivalent for listing background shell, subagent, and image jobs, with session, descendant, kind, and status filters.#60698
    • SDKServer embedders can provide a custom fetch implementation for OpenCode HTTP, model, web, and remote MCP traffic.#61582
  3. 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

    Усі головні зміни v2.2.4

    Покращення

    • SDKExtended client.experimental.persistentPty.update to rename terminals or clear a user title, and exposed userTitle plus persistent-pty.updated events.#60329
Усі оновлення