본문으로 건너뛰기

SDK

직접 만든 스크립트, CI 작업, 도구에서 OpenCode를 제어하세요. SDK는 기존 설정과 모델을 그대로 써서 작업 중인 프로세스 안에서 OpenCode를 실행합니다. 타입을 제공하는 클라이언트로 세션을 만들고 프롬프트를 보내며 모든 이벤트를 스트리밍할 수 있습니다.

기능

코드로 CI 고치기

짧은 스크립트가 OpenCode에게 실패한 테스트를 고치게 한 뒤 다시 실행합니다.

모든 단계 추적

이벤트를 스트리밍해 에이전트가 호출하는 도구를 실시간으로 확인하세요.

나만의 도구 만들기

몇 줄의 코드로 OpenCode를 봇, 대시보드, 워크플로에 연결하세요.

내 프로세스 안에서

기존 설정과 모델을 그대로 써서 작업 중인 프로세스 안에서 OpenCode를 실행합니다.

  • TypeScript 클라이언트요청과 이벤트에 타입을 제공하며 @opencode/client와 같은 값을 사용합니다.
  • 코드로 세션 생성어떤 스크립트에서든 세션을 만들고 프롬프트를 보내세요.
  • 모든 모델OpenCode 설정에 있는 모델을 그대로 사용합니다.
  • npm 또는 bunnpm i @opencode/sdk 또는 bun add @opencode/sdk로 설치하세요.
  • 인프로세스 호스트네트워크를 거치지 않고 메모리에서 OpenCode를 실행합니다.
  • 내 플러그인인프로세스 호스트를 만들 때 직접 만든 플러그인을 넘기세요.
  • Promise 또는 Effect같은 값을 돌려주는 Promise API와 Effect API.
  • Cloudflare WorkersWorkers의 Cloudflare Durable Object 안에서 OpenCode를 실행하세요.

  • npmnpm i @opencode/sdk
  • bunbun add @opencode/sdk
SDK 문서 읽기

변경 내역

  1. 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

    v2.4.2의 하이라이트 모두 보기
  2. v2.4.1

    Fixes

    v2.4.1의 하이라이트 모두 보기

    수정 사항

    • SDKAn aborted shared event subscription now stops immediately even when the source has already completed or failed with buffered events remaining. Thanks @chirag127.#65441
  3. v2.4.0

    Automations

    Ask the agent to run a prompt, a script or a shell command on a timer, on a cron schedule or when an MCP server sends an event, and manage them with /automation. Set "automations": false in your config if you don't want them.#65296#65186

    Generate Videos

    When a connected provider has a video model, the agent can make videos with generate_video. It keeps working while the video renders and saves the files into your workspace when they're ready.#63666#65664

    v2.4.0의 하이라이트 모두 보기

    개선 사항

    • SDKAdded experimental.job.cancel to cancel a running background job, and an experimental.job.updated event when a job starts, moves to the background or ends. @opencode/client/solid's createData has a job slice.#64790#65266#64956
    • SDKThe video endpoints (experimental.generate.video.create and .get) no longer need a flag. Video jobs survive a server restart, can return more than one video, and stay readable for 24 hours after they finish.#65664#64546
전체 업데이트 보기