Vai al contenuto

SDK

Controlla OpenCode dai tuoi script, job di CI e strumenti. L'SDK esegue OpenCode nel tuo processo, con la tua configurazione e i tuoi modelli, e il suo client tipizzato crea sessioni, invia prompt e trasmette ogni evento.

Funzionalità

Correggi la CI da codice

Un breve script chiede a OpenCode di correggere i test non riusciti, poi li esegue di nuovo.

Segui ogni passo

Ricevi gli eventi in streaming e vedi in tempo reale ogni strumento che l'agente chiama.

Crea i tuoi strumenti

Integra OpenCode in bot, dashboard e flussi di lavoro con poche righe.

Nel tuo processo

Esegue OpenCode nel tuo processo, con la tua configurazione e i tuoi modelli.

  • Client TypeScriptRichieste ed eventi tipizzati, con gli stessi valori di @opencode/client.
  • Sessioni da codiceCrea sessioni e invia prompt da qualsiasi script.
  • Qualsiasi modelloUsa i modelli configurati nel tuo OpenCode.
  • npm o BunInstallalo con npm i @opencode/sdk o bun add @opencode/sdk.
  • Host in-processEsegue OpenCode in memoria, senza passare dalla rete.
  • I tuoi pluginPassa i tuoi plugin al momento di creare l'host in-process.
  • Promise o EffectUn'API Promise e un'API Effect con gli stessi valori.
  • Cloudflare WorkersEsegui OpenCode in un Durable Object di Cloudflare su Workers.

  • npmnpm i @opencode/sdk
  • bunbun add @opencode/sdk
Leggi la documentazione dell'SDK

Changelog

  1. v2.4.5

    Run an Automation Now

    Click Run now next to Pause on an active timer automation in Desktop to run it right away. It counts as a normal run, and its schedule doesn't move.#68034

    Vedi tutte le novità principali di v2.4.5

    Miglioramenti

    • SDKServer plugins can list, create, read, answer and cancel session forms through session.form.#67863
    • SDKExperimental: run a timer automation now with client.experimental.automation.run, and filter the blob list by mime type with mime.#68034#68315
    • SDKExperimental push callbacks accept any https relay. The SDK's experimental.push.relays option and OPENCODE_EXPERIMENTAL_PUSH_RELAYS were removed.#68153

    Correzioni

    • SDKA duplicate permission request ID returns 409 Conflict instead of 500, and importing a session with existing message IDs returns 409.#68073#68074
    • SDKThe client reports server startup failures even when a child process keeps stderr open.#68281
  2. v2.4.3

    Improvements and fixes

    Vedi tutte le novità principali di v2.4.3

    Miglioramenti

    • SDKOpenCodeWorkerd (@opencode/sdk/workerd and @opencode/sdk/workerd/effect) now exposes fetch, password, cors, workspace, machine-link WebSocket upgrades, Durable Object WebSocket hibernation handlers, and a host imageResizer hook, with demand-driven background timers so Durable Objects can hibernate.#67022#67023#67026#67037

    Correzioni

    • SDKTreated an empty XDG_STATE_HOME environment variable as unset in @opencode/client, and fixed @opencode/client/solid dropping location-less catalog *.updated events. Thanks @JorgeRojas2712.#61288#66813
  3. v2.4.2

    @opencode/sdk/workerd

    @opencode/sdk/workerd: forward your Durable Object's alarm() to opencode.alarm() so idle remote workspaces suspend.#66183#66240

    Vedi tutte le novità principali di v2.4.2
Vedi tutti gli aggiornamenti