Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/opencode/src/provider/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand All @@ -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 ?? {}
Expand Down
15 changes: 15 additions & 0 deletions packages/opencode/test/provider/provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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* () {
Expand Down
Loading