Skip to content
Closed
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: 6 additions & 1 deletion packages/opencode/src/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ export namespace Auth {
key: z.string(),
})

export const Info = z.discriminatedUnion("type", [Oauth, Api])
export const Env = z.object({
type: z.literal("env"),
env: z.string(),
})

export const Info = z.discriminatedUnion("type", [Oauth, Api, Env])
export type Info = z.infer<typeof Info>

const filepath = path.join(Global.Path.data, "auth.json")
Expand Down
6 changes: 6 additions & 0 deletions packages/opencode/src/provider/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ export namespace Provider {
if (provider.type === "api") {
mergeProvider(providerID, { apiKey: provider.key }, "api")
}
if (provider.type === "env") {
const envValue = process.env[provider.env]
if (envValue) {
mergeProvider(providerID, { apiKey: envValue }, "env")
}
}
}

// load custom
Expand Down