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