From 83a35449b2330cdb397e8d74854af55667b17b84 Mon Sep 17 00:00:00 2001 From: Carmelo Campos Date: Thu, 24 Sep 2026 14:28:48 +0000 Subject: [PATCH] fix: use a bundled provider package for the responses protocol OpenCode imports provider packages from its own compiled bundle, so the openai-compatible/responses subpath the plugin referenced is not reachable. Every responses request failed at model init with: Cannot initialize /: Cannot find package '@opencode/ai' imported from /$bunfs/root/chunk-6mdchvy2.js Register @opencode/ai/providers/openai/responses instead, which the bundle does provide, and cover it with the existing package-selection test. Fixes the reported responses-protocol failure. --- CHANGELOG.md | 9 +++++++++ src/index.test.ts | 2 +- src/index.ts | 8 +++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54d52e3..fac4935 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,15 @@ and this project follows [Semantic Versioning](https://semver.org/). ## [Unreleased] +### Fixed + +- Point the `responses` protocol at `@opencode/ai/providers/openai/responses`. + The previous `@opencode/ai/providers/openai-compatible/responses` path is not + part of OpenCode's bundled provider modules, so every request failed at model + init with `Cannot initialize /: Cannot find package + '@opencode/ai' imported from /$bunfs/root/chunk-*.js`, even though the model + was listed in `/models`. + ## [0.2.1] - 2026-09-16 ### Fixed diff --git a/src/index.test.ts b/src/index.test.ts index b4d90f9..bf182b4 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -131,7 +131,7 @@ describe("plugin", () => { await plugin.setup(ctx) expect(registered[0]?.info.package).toBe( - "@opencode/ai/providers/openai-compatible/responses", + "@opencode/ai/providers/openai/responses", ) } finally { globalThis.fetch = originalFetch diff --git a/src/index.ts b/src/index.ts index 4e3b33d..4aa2849 100644 --- a/src/index.ts +++ b/src/index.ts @@ -16,7 +16,13 @@ const DEFAULT_MODEL_METADATA_URL = "https://models.dev/api.json" const DEFAULT_REFRESH_MS = 5 * 60_000 const CHAT_PACKAGE = "@opencode/ai/providers/openai-compatible" -const RESPONSES_PACKAGE = "@opencode/ai/providers/openai-compatible/responses" +// OpenCode resolves these package names from inside its own compiled bundle, not +// from `node_modules`. Only the subpaths the bundle itself contains can be +// imported, so Responses must use the OpenAI facade; the sibling +// `openai-compatible-responses` module (and the `openai-compatible/responses` +// subpath) are not bundled and fail at model init with `Cannot find package +// '@opencode/ai' imported from /$bunfs/root/chunk-*.js`. +const RESPONSES_PACKAGE = "@opencode/ai/providers/openai/responses" const MESSAGES_PACKAGE = "@opencode/ai/providers/anthropic" const ANTHROPIC_NPM = "@ai-sdk/anthropic" const DEFAULT_ANTHROPIC_EFFORTS = ["low", "medium", "high"] as const