opencode/packages/console/core/script/promote-models.ts

31 lines
858 B
TypeScript
Raw Normal View History

2025-09-27 03:18:22 +08:00
#!/usr/bin/env bun
import { $ } from "bun"
import path from "path"
2025-10-17 03:58:49 +08:00
import { ZenData } from "../src/model"
2025-09-27 03:18:22 +08:00
const stage = process.argv[2]
if (!stage) throw new Error("Stage is required")
const root = path.resolve(process.cwd(), "..", "..", "..")
// read the secret
const ret = await $`bun sst secret list`.cwd(root).text()
2025-11-04 04:43:52 +08:00
const value1 = ret
2025-09-27 03:18:22 +08:00
.split("\n")
2025-11-04 04:43:52 +08:00
.find((line) => line.startsWith("ZEN_MODELS1"))
2025-09-27 03:18:22 +08:00
?.split("=")[1]
2025-11-04 04:43:52 +08:00
const value2 = ret
.split("\n")
.find((line) => line.startsWith("ZEN_MODELS2"))
?.split("=")[1]
if (!value1) throw new Error("ZEN_MODELS1 not found")
if (!value2) throw new Error("ZEN_MODELS2 not found")
2025-09-27 03:18:22 +08:00
// validate value
2025-11-04 04:43:52 +08:00
ZenData.validate(JSON.parse(value1 + value2))
2025-09-27 03:18:22 +08:00
// update the secret
2025-11-04 04:43:52 +08:00
await $`bun sst secret set ZEN_MODELS1 ${value1} --stage ${stage}`
await $`bun sst secret set ZEN_MODELS2 ${value2} --stage ${stage}`