fix(copilot): handle zero billing batch size (#36123)

This commit is contained in:
Aiden Cline
2026-07-09 13:14:33 -05:00
committed by GitHub
parent b4665a8bf8
commit b8374b5a7c
4 changed files with 92 additions and 6 deletions
@@ -99,7 +99,7 @@ function build(key: string, remote: SelectableItem, url: string, prev?: Model):
: undefined
const prices = remote.billing?.token_prices
// Copilot prices are AIC per billing batch; OpenCode stores USD per million tokens.
const usdPerMillion = prices ? 10_000 / prices.batch_size : 0
const usdPerMillion = prices && prices.batch_size > 0 ? 10_000 / prices.batch_size : 0
const model: CopilotModel = {
id: key,
+11 -5
View File
@@ -1071,11 +1071,17 @@ export type ConfigProvidersResult = Types.DeepMutable<Schema.Schema.Type<typeof
export function toPublicInfo(provider: Info): Info {
return JSON.parse(
JSON.stringify(provider, (_, value) => {
if (typeof value === "function" || typeof value === "symbol" || value === undefined) return undefined
if (typeof value === "bigint") return value.toString()
return value
}),
JSON.stringify(
{
...provider,
models: Object.fromEntries(Object.entries(provider.models).filter(([, model]) => Schema.is(Model)(model))),
},
(_, value) => {
if (typeof value === "function" || typeof value === "symbol" || value === undefined) return undefined
if (typeof value === "bigint") return value.toString()
return value
},
),
)
}