summaryrefslogtreecommitdiffhomepage
path: root/packages/console/core
diff options
context:
space:
mode:
authorDavid Hill <[email protected]>2025-12-12 09:44:06 +0000
committerDavid Hill <[email protected]>2025-12-12 09:44:06 +0000
commit99158e736bd983ee5c62bfc43032da1bafc45d71 (patch)
tree59b1afc0fff72a8c47ca76c90a767aafae7a5f45 /packages/console/core
parent4c02d515a1e15a99fc009587e821087e042bd45b (diff)
parentf9d5e1879056dd9507bb1a1645da5b5ede87fcca (diff)
downloadopencode-99158e736bd983ee5c62bfc43032da1bafc45d71.tar.gz
opencode-99158e736bd983ee5c62bfc43032da1bafc45d71.zip
Merge branch 'dev' of https://github.com/sst/opencode into dev
Diffstat (limited to 'packages/console/core')
-rw-r--r--packages/console/core/package.json2
-rwxr-xr-xpackages/console/core/script/promote-models.ts5
-rwxr-xr-xpackages/console/core/script/pull-models.ts5
-rwxr-xr-xpackages/console/core/script/update-models.ts11
-rw-r--r--packages/console/core/src/model.ts25
-rw-r--r--packages/console/core/sst-env.d.ts12
6 files changed, 42 insertions, 18 deletions
diff --git a/packages/console/core/package.json b/packages/console/core/package.json
index a1cb40797..86a59d6bb 100644
--- a/packages/console/core/package.json
+++ b/packages/console/core/package.json
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "@opencode-ai/console-core",
- "version": "1.0.149",
+ "version": "1.0.150",
"private": true,
"type": "module",
"dependencies": {
diff --git a/packages/console/core/script/promote-models.ts b/packages/console/core/script/promote-models.ts
index 0ff859df8..bebef5cfb 100755
--- a/packages/console/core/script/promote-models.ts
+++ b/packages/console/core/script/promote-models.ts
@@ -16,16 +16,19 @@ const value1 = lines.find((line) => line.startsWith("ZEN_MODELS1"))?.split("=")[
const value2 = lines.find((line) => line.startsWith("ZEN_MODELS2"))?.split("=")[1]
const value3 = lines.find((line) => line.startsWith("ZEN_MODELS3"))?.split("=")[1]
const value4 = lines.find((line) => line.startsWith("ZEN_MODELS4"))?.split("=")[1]
+const value5 = lines.find((line) => line.startsWith("ZEN_MODELS5"))?.split("=")[1]
if (!value1) throw new Error("ZEN_MODELS1 not found")
if (!value2) throw new Error("ZEN_MODELS2 not found")
if (!value3) throw new Error("ZEN_MODELS3 not found")
if (!value4) throw new Error("ZEN_MODELS4 not found")
+if (!value5) throw new Error("ZEN_MODELS5 not found")
// validate value
-ZenData.validate(JSON.parse(value1 + value2 + value3 + value4))
+ZenData.validate(JSON.parse(value1 + value2 + value3 + value4 + value5))
// update the secret
await $`bun sst secret set ZEN_MODELS1 ${value1} --stage ${stage}`
await $`bun sst secret set ZEN_MODELS2 ${value2} --stage ${stage}`
await $`bun sst secret set ZEN_MODELS3 ${value3} --stage ${stage}`
await $`bun sst secret set ZEN_MODELS4 ${value4} --stage ${stage}`
+await $`bun sst secret set ZEN_MODELS5 ${value5} --stage ${stage}`
diff --git a/packages/console/core/script/pull-models.ts b/packages/console/core/script/pull-models.ts
index a89e3951c..afa865625 100755
--- a/packages/console/core/script/pull-models.ts
+++ b/packages/console/core/script/pull-models.ts
@@ -16,16 +16,19 @@ const value1 = lines.find((line) => line.startsWith("ZEN_MODELS1"))?.split("=")[
const value2 = lines.find((line) => line.startsWith("ZEN_MODELS2"))?.split("=")[1]
const value3 = lines.find((line) => line.startsWith("ZEN_MODELS3"))?.split("=")[1]
const value4 = lines.find((line) => line.startsWith("ZEN_MODELS4"))?.split("=")[1]
+const value5 = lines.find((line) => line.startsWith("ZEN_MODELS5"))?.split("=")[1]
if (!value1) throw new Error("ZEN_MODELS1 not found")
if (!value2) throw new Error("ZEN_MODELS2 not found")
if (!value3) throw new Error("ZEN_MODELS3 not found")
if (!value4) throw new Error("ZEN_MODELS4 not found")
+if (!value5) throw new Error("ZEN_MODELS5 not found")
// validate value
-ZenData.validate(JSON.parse(value1 + value2 + value3 + value4))
+ZenData.validate(JSON.parse(value1 + value2 + value3 + value4 + value5))
// update the secret
await $`bun sst secret set ZEN_MODELS1 ${value1}`
await $`bun sst secret set ZEN_MODELS2 ${value2}`
await $`bun sst secret set ZEN_MODELS3 ${value3}`
await $`bun sst secret set ZEN_MODELS4 ${value4}`
+await $`bun sst secret set ZEN_MODELS5 ${value5}`
diff --git a/packages/console/core/script/update-models.ts b/packages/console/core/script/update-models.ts
index a8523a5f2..5d40b4d5a 100755
--- a/packages/console/core/script/update-models.ts
+++ b/packages/console/core/script/update-models.ts
@@ -14,15 +14,17 @@ const oldValue1 = lines.find((line) => line.startsWith("ZEN_MODELS1"))?.split("=
const oldValue2 = lines.find((line) => line.startsWith("ZEN_MODELS2"))?.split("=")[1]
const oldValue3 = lines.find((line) => line.startsWith("ZEN_MODELS3"))?.split("=")[1]
const oldValue4 = lines.find((line) => line.startsWith("ZEN_MODELS4"))?.split("=")[1]
+const oldValue5 = lines.find((line) => line.startsWith("ZEN_MODELS5"))?.split("=")[1]
if (!oldValue1) throw new Error("ZEN_MODELS1 not found")
if (!oldValue2) throw new Error("ZEN_MODELS2 not found")
if (!oldValue3) throw new Error("ZEN_MODELS3 not found")
if (!oldValue4) throw new Error("ZEN_MODELS4 not found")
+if (!oldValue5) throw new Error("ZEN_MODELS5 not found")
// store the prettified json to a temp file
const filename = `models-${Date.now()}.json`
const tempFile = Bun.file(path.join(os.tmpdir(), filename))
-await tempFile.write(JSON.stringify(JSON.parse(oldValue1 + oldValue2 + oldValue3 + oldValue4), null, 2))
+await tempFile.write(JSON.stringify(JSON.parse(oldValue1 + oldValue2 + oldValue3 + oldValue4 + oldValue5), null, 2))
console.log("tempFile", tempFile.name)
// open temp file in vim and read the file on close
@@ -31,12 +33,15 @@ const newValue = JSON.stringify(JSON.parse(await tempFile.text()))
ZenData.validate(JSON.parse(newValue))
// update the secret
-const chunk = Math.ceil(newValue.length / 4)
+const chunk = Math.ceil(newValue.length / 5)
const newValue1 = newValue.slice(0, chunk)
const newValue2 = newValue.slice(chunk, chunk * 2)
const newValue3 = newValue.slice(chunk * 2, chunk * 3)
-const newValue4 = newValue.slice(chunk * 3)
+const newValue4 = newValue.slice(chunk * 3, chunk * 4)
+const newValue5 = newValue.slice(chunk * 4)
+
await $`bun sst secret set ZEN_MODELS1 ${newValue1}`
await $`bun sst secret set ZEN_MODELS2 ${newValue2}`
await $`bun sst secret set ZEN_MODELS3 ${newValue3}`
await $`bun sst secret set ZEN_MODELS4 ${newValue4}`
+await $`bun sst secret set ZEN_MODELS5 ${newValue5}`
diff --git a/packages/console/core/src/model.ts b/packages/console/core/src/model.ts
index 47ba3e9d8..55d6c895c 100644
--- a/packages/console/core/src/model.ts
+++ b/packages/console/core/src/model.ts
@@ -9,7 +9,17 @@ import { Resource } from "@opencode-ai/console-resource"
export namespace ZenData {
const FormatSchema = z.enum(["anthropic", "google", "openai", "oa-compat"])
+ const TrialSchema = z.object({
+ provider: z.string(),
+ limits: z.array(
+ z.object({
+ limit: z.number(),
+ client: z.enum(["cli", "desktop"]).optional(),
+ }),
+ ),
+ })
export type Format = z.infer<typeof FormatSchema>
+ export type Trial = z.infer<typeof TrialSchema>
const ModelCostSchema = z.object({
input: z.number(),
@@ -26,12 +36,7 @@ export namespace ZenData {
allowAnonymous: z.boolean().optional(),
byokProvider: z.enum(["openai", "anthropic", "google"]).optional(),
stickyProvider: z.boolean().optional(),
- trial: z
- .object({
- limit: z.number(),
- provider: z.string(),
- })
- .optional(),
+ trial: TrialSchema.optional(),
rateLimit: z.number().optional(),
fallbackProvider: z.string().optional(),
providers: z.array(
@@ -53,7 +58,7 @@ export namespace ZenData {
})
const ModelsSchema = z.object({
- models: z.record(z.string(), ModelSchema),
+ models: z.record(z.string(), z.union([ModelSchema, z.array(ModelSchema.extend({ formatFilter: FormatSchema }))])),
providers: z.record(z.string(), ProviderSchema),
})
@@ -63,7 +68,11 @@ export namespace ZenData {
export const list = fn(z.void(), () => {
const json = JSON.parse(
- Resource.ZEN_MODELS1.value + Resource.ZEN_MODELS2.value + Resource.ZEN_MODELS3.value + Resource.ZEN_MODELS4.value,
+ Resource.ZEN_MODELS1.value +
+ Resource.ZEN_MODELS2.value +
+ Resource.ZEN_MODELS3.value +
+ Resource.ZEN_MODELS4.value +
+ Resource.ZEN_MODELS5.value,
)
return ModelsSchema.parse(json)
})
diff --git a/packages/console/core/sst-env.d.ts b/packages/console/core/sst-env.d.ts
index 0b09bfd0c..632ea3fbe 100644
--- a/packages/console/core/sst-env.d.ts
+++ b/packages/console/core/sst-env.d.ts
@@ -50,10 +50,6 @@ declare module "sst" {
"type": "sst.sst.Secret"
"value": string
}
- "Enterprise": {
- "type": "sst.cloudflare.SolidStart"
- "url": string
- }
"GITHUB_APP_ID": {
"type": "sst.sst.Secret"
"value": string
@@ -94,6 +90,10 @@ declare module "sst" {
"type": "sst.sst.Linkable"
"value": string
}
+ "Teams": {
+ "type": "sst.cloudflare.SolidStart"
+ "url": string
+ }
"Web": {
"type": "sst.cloudflare.Astro"
"url": string
@@ -114,6 +114,10 @@ declare module "sst" {
"type": "sst.sst.Secret"
"value": string
}
+ "ZEN_MODELS5": {
+ "type": "sst.sst.Secret"
+ "value": string
+ }
}
}
// cloudflare