Skip to content

v2.0.0 — OpenCode SDK v2 Migration

Choose a tag to compare

@ben-vargas ben-vargas released this 13 Feb 20:46
· 6 commits to main since this release
64deb75

What's Changed

Migrates the provider from OpenCode SDK v1 to v2 (@opencode-ai/sdk/v2), adding support for new v2 capabilities and hardening the implementation.

Core Migration

  • SDK v2 API style: All SDK calls migrated from nested { path, body } to v2 flat parameter style ({ sessionID, directory, ... })
  • Import path: @opencode-ai/sdk@opencode-ai/sdk/v2
  • Dependency bumps: @ai-sdk/provider ^3.0.8, @ai-sdk/provider-utils ^4.0.15, ai ^6.0.85

New Features

  • Permission/tool approval flow: Emits tool-approval-request stream parts from permission.asked events; handles tool-approval-response parts via permission.reply() API
  • Native structured output: JSON mode uses OpenCode's native json_schema format with retryCount instead of prompt-based instructions
  • File/source content streaming: handleFilePart() fully implemented — handles data URLs, HTTP URLs, and source metadata
  • New settings: permission (ruleset), variant, directory (per-request routing), outputFormatRetryCount
  • New error types: ContextOverflowError"length", StructuredOutputError"error"

Hardening

  • Question events: question.asked emits a stream error part with warning; related events are known no-ops
  • Known v2 events/parts: All new v2 event and part types explicitly handled (no "Unknown" debug spam)
  • Safe tool input serialization: safeStringifyToolInput() with try/catch fallback
  • Typed approval client: ApprovalClient interface replaces loose typing
  • File part diagnostics: Debug logs when file parts are skipped
  • Non-prefix tool input delta: Prevents data loss on non-incremental input changes

Deprecations

  • tools setting → use permission ruleset
  • cwd setting → use directory

Tests

  • 283 tests passing (up from 278)

Full Changelog: v1.0.0...v2.0.0