Skip to content

Commit 43bb7ba

Browse files
fix(core): let v1 npm config target built-in provider routes (#55254)
Co-authored-by: rekram1-node <[email protected]>
1 parent 7b33bce commit 43bb7ba

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

‎packages/core/src/v1/config/migrate.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function migrateStandardProvider(info: ConfigProviderV1.Info) {
116116
return {
117117
name: info.name,
118118
env: info.env,
119-
package: info.npm ? Provider.aisdk(info.npm) : undefined,
119+
package: info.npm ? packageSpecifier(info.npm) : undefined,
120120
compatibility: setCacheKey === undefined ? undefined : { supportsPromptCacheKey: setCacheKey },
121121
settings: info.api ? { ...options.settings, baseURL: info.api } : info.options ? options.settings : undefined,
122122
headers: info.options && options.headers,
@@ -162,6 +162,12 @@ function migrateGoogleVertexAnthropicProvider(info: ConfigProviderV1.Info) {
162162
}
163163
}
164164

165+
// Built-in provider routes are already native package specifiers; only npm packages load through the AI SDK.
166+
function packageSpecifier(npm: string) {
167+
const name = Provider.packageName(npm)
168+
return name.startsWith("@opencode/ai/") ? name : Provider.aisdk(npm)
169+
}
170+
165171
// Renames retired provider IDs in V1 fields and the shared top-level model.
166172
export function providerID(input: string) {
167173
if (input === "azure-cognitive-services") return "azure"
@@ -229,7 +235,7 @@ function migrateModel(info: typeof ConfigProviderV1.Model.Type, npm: string | un
229235
compatibility: disableThinkingBlockBinding
230236
? { ...compatibility, supportsThinkingBlockBinding: false }
231237
: compatibility,
232-
package: info.provider?.npm ? Provider.aisdk(info.provider.npm) : undefined,
238+
package: info.provider?.npm ? packageSpecifier(info.provider.npm) : undefined,
233239
settings: info.provider?.api ? { ...settings, baseURL: info.provider.api } : settings,
234240
capabilities,
235241
headers: info.headers,

‎packages/core/test/config/provider.test.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,21 @@ describe("ConfigProviderPlugin.Plugin", () => {
586586
},
587587
},
588588
},
589+
{
590+
name: "built-in provider routes",
591+
legacy: {
592+
npm: "@opencode/ai/providers/google-vertex",
593+
options: { project: "my-project", location: "europe-west4" },
594+
models: {
595+
chat: { provider: { npm: "@opencode-ai/ai/providers/google-vertex/mistral" } },
596+
},
597+
},
598+
native: {
599+
package: "@opencode/ai/providers/google-vertex",
600+
settings: { project: "my-project", location: "europe-west4" },
601+
models: { chat: { package: "@opencode/ai/providers/google-vertex/mistral" } },
602+
},
603+
},
589604
{
590605
name: "zero costs and omitted cache costs",
591606
legacy: { models: { chat: { cost: { input: 0, output: 0 } } } },

0 commit comments

Comments
 (0)