mirror of
https://github.com/sst/opencode.git
synced 2025-07-07 16:14:59 +00:00
feat(gemini): use env variable instead of hardcoded api key
This commit is contained in:
parent
8d3b2fb821
commit
bab7bad80c
2 changed files with 12 additions and 1 deletions
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue