diff --git a/packages/opencode/src/provider/provider.ts b/packages/opencode/src/provider/provider.ts index a0ab5eb3474d..0c53142e2cf3 100644 --- a/packages/opencode/src/provider/provider.ts +++ b/packages/opencode/src/provider/provider.ts @@ -1395,6 +1395,7 @@ const layer = Layer.effect( if (!p || !models) continue const providerID = ProviderV2.ID.make(p.id) + if (enabled && !enabled.has(providerID)) continue if (disabled.has(providerID)) continue const provider = database[providerID] @@ -1544,7 +1545,9 @@ const layer = Layer.effect( for (const plugin of plugins) { if (!plugin.auth) continue const providerID = ProviderV2.ID.make(plugin.auth.provider) - if (disabled.has(providerID)) continue + if (!isProviderAllowed(providerID)) continue + const data = database[providerID] + if (!data) continue const stored = yield* auth.get(providerID).pipe(Effect.orDie) if (!stored) continue @@ -1553,7 +1556,7 @@ const layer = Layer.effect( const options = yield* Effect.promise(() => plugin.auth!.loader!( () => bridge.promise(auth.get(providerID).pipe(Effect.orDie)) as any, - toPublicInfo(database[plugin.auth!.provider]), + toPublicInfo(data), ), ) const opts = options ?? {} diff --git a/packages/opencode/test/provider/provider.test.ts b/packages/opencode/test/provider/provider.test.ts index 058bad23a1c6..4829f33748c4 100644 --- a/packages/opencode/test/provider/provider.test.ts +++ b/packages/opencode/test/provider/provider.test.ts @@ -152,6 +152,21 @@ it.instance( { config: { enabled_providers: ["anthropic"] } }, ) +it.instance( + "enabled_providers skips auth loaders for filtered providers", + Effect.gen(function* () { + yield* setProcessEnv( + "OPENCODE_AUTH_CONTENT", + JSON.stringify({ + google: { type: "oauth", refresh: "dummy", access: "dummy", expires: 9999999999999 }, + }), + ) + const providers = yield* list + expect(providers[ProviderV2.ID.google]).toBeUndefined() + }), + { config: { enabled_providers: ["anthropic"] } }, +) + it.instance( "model whitelist filters models for provider", Effect.gen(function* () {