mirror of
https://github.com/sst/opencode.git
synced 2025-07-08 00:25:00 +00:00
Merge bab7bad80c
into d87922c0eb
This commit is contained in:
commit
cd29284ac0
2 changed files with 12 additions and 1 deletions
|
@ -16,7 +16,12 @@ export namespace Auth {
|
||||||
key: z.string(),
|
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>
|
export type Info = z.infer<typeof Info>
|
||||||
|
|
||||||
const filepath = path.join(Global.Path.data, "auth.json")
|
const filepath = path.join(Global.Path.data, "auth.json")
|
||||||
|
|
|
@ -330,6 +330,12 @@ export namespace Provider {
|
||||||
if (provider.type === "api") {
|
if (provider.type === "api") {
|
||||||
mergeProvider(providerID, { apiKey: provider.key }, "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
|
// load custom
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue