mirror of
https://github.com/anomalyco/opencode.git
synced 2026-02-01 14:44:46 +00:00
wip: zen (#11343)
This commit is contained in:
@@ -133,6 +133,8 @@ const ZEN_MODELS = [
|
|||||||
new sst.Secret("ZEN_MODELS6"),
|
new sst.Secret("ZEN_MODELS6"),
|
||||||
new sst.Secret("ZEN_MODELS7"),
|
new sst.Secret("ZEN_MODELS7"),
|
||||||
new sst.Secret("ZEN_MODELS8"),
|
new sst.Secret("ZEN_MODELS8"),
|
||||||
|
new sst.Secret("ZEN_MODELS9"),
|
||||||
|
new sst.Secret("ZEN_MODELS10"),
|
||||||
]
|
]
|
||||||
const STRIPE_SECRET_KEY = new sst.Secret("STRIPE_SECRET_KEY")
|
const STRIPE_SECRET_KEY = new sst.Secret("STRIPE_SECRET_KEY")
|
||||||
const STRIPE_PUBLISHABLE_KEY = new sst.Secret("STRIPE_PUBLISHABLE_KEY")
|
const STRIPE_PUBLISHABLE_KEY = new sst.Secret("STRIPE_PUBLISHABLE_KEY")
|
||||||
|
|||||||
@@ -2,20 +2,21 @@
|
|||||||
|
|
||||||
import { $ } from "bun"
|
import { $ } from "bun"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
|
import os from "os"
|
||||||
import { ZenData } from "../src/model"
|
import { ZenData } from "../src/model"
|
||||||
|
|
||||||
const stage = process.argv[2]
|
const stage = process.argv[2]
|
||||||
if (!stage) throw new Error("Stage is required")
|
if (!stage) throw new Error("Stage is required")
|
||||||
|
|
||||||
const root = path.resolve(process.cwd(), "..", "..", "..")
|
const root = path.resolve(process.cwd(), "..", "..", "..")
|
||||||
const PARTS = 8
|
const PARTS = 10
|
||||||
|
|
||||||
// read the secret
|
// read the secret
|
||||||
const ret = await $`bun sst secret list`.cwd(root).text()
|
const ret = await $`bun sst secret list`.cwd(root).text()
|
||||||
const lines = ret.split("\n")
|
const lines = ret.split("\n")
|
||||||
const values = Array.from({ length: PARTS }, (_, i) => {
|
const values = Array.from({ length: PARTS }, (_, i) => {
|
||||||
const value = lines
|
const value = lines
|
||||||
.find((line) => line.startsWith(`ZEN_MODELS${i + 1}`))
|
.find((line) => line.startsWith(`ZEN_MODELS${i + 1}=`))
|
||||||
?.split("=")
|
?.split("=")
|
||||||
.slice(1)
|
.slice(1)
|
||||||
.join("=")
|
.join("=")
|
||||||
@@ -27,6 +28,6 @@ const values = Array.from({ length: PARTS }, (_, i) => {
|
|||||||
ZenData.validate(JSON.parse(values.join("")))
|
ZenData.validate(JSON.parse(values.join("")))
|
||||||
|
|
||||||
// update the secret
|
// update the secret
|
||||||
for (let i = 0; i < PARTS; i++) {
|
const envFile = Bun.file(path.join(os.tmpdir(), `models-${Date.now()}.env`))
|
||||||
await $`bun sst secret set ZEN_MODELS${i + 1} --stage ${stage} -- ${values[i]}`
|
await envFile.write(values.map((v, i) => `ZEN_MODELS${i + 1}=${v}`).join("\n"))
|
||||||
}
|
await $`bun sst secret load ${envFile.name} --stage ${stage}`.cwd(root)
|
||||||
|
|||||||
@@ -2,20 +2,21 @@
|
|||||||
|
|
||||||
import { $ } from "bun"
|
import { $ } from "bun"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
|
import os from "os"
|
||||||
import { ZenData } from "../src/model"
|
import { ZenData } from "../src/model"
|
||||||
|
|
||||||
const stage = process.argv[2]
|
const stage = process.argv[2]
|
||||||
if (!stage) throw new Error("Stage is required")
|
if (!stage) throw new Error("Stage is required")
|
||||||
|
|
||||||
const root = path.resolve(process.cwd(), "..", "..", "..")
|
const root = path.resolve(process.cwd(), "..", "..", "..")
|
||||||
const PARTS = 8
|
const PARTS = 10
|
||||||
|
|
||||||
// read the secret
|
// read the secret
|
||||||
const ret = await $`bun sst secret list --stage ${stage}`.cwd(root).text()
|
const ret = await $`bun sst secret list --stage ${stage}`.cwd(root).text()
|
||||||
const lines = ret.split("\n")
|
const lines = ret.split("\n")
|
||||||
const values = Array.from({ length: PARTS }, (_, i) => {
|
const values = Array.from({ length: PARTS }, (_, i) => {
|
||||||
const value = lines
|
const value = lines
|
||||||
.find((line) => line.startsWith(`ZEN_MODELS${i + 1}`))
|
.find((line) => line.startsWith(`ZEN_MODELS${i + 1}=`))
|
||||||
?.split("=")
|
?.split("=")
|
||||||
.slice(1)
|
.slice(1)
|
||||||
.join("=")
|
.join("=")
|
||||||
@@ -27,6 +28,6 @@ const values = Array.from({ length: PARTS }, (_, i) => {
|
|||||||
ZenData.validate(JSON.parse(values.join("")))
|
ZenData.validate(JSON.parse(values.join("")))
|
||||||
|
|
||||||
// update the secret
|
// update the secret
|
||||||
for (let i = 0; i < PARTS; i++) {
|
const envFile = Bun.file(path.join(os.tmpdir(), `models-${Date.now()}.env`))
|
||||||
await $`bun sst secret set ZEN_MODELS${i + 1} -- ${values[i]}`
|
await envFile.write(values.map((v, i) => `ZEN_MODELS${i + 1}=${v}`).join("\n"))
|
||||||
}
|
await $`bun sst secret load ${envFile.name}`.cwd(root)
|
||||||
|
|||||||
@@ -7,18 +7,20 @@ import { ZenData } from "../src/model"
|
|||||||
|
|
||||||
const root = path.resolve(process.cwd(), "..", "..", "..")
|
const root = path.resolve(process.cwd(), "..", "..", "..")
|
||||||
const models = await $`bun sst secret list`.cwd(root).text()
|
const models = await $`bun sst secret list`.cwd(root).text()
|
||||||
const PARTS = 8
|
const PARTS = 10
|
||||||
|
|
||||||
// read the line starting with "ZEN_MODELS"
|
// read the line starting with "ZEN_MODELS"
|
||||||
const lines = models.split("\n")
|
const lines = models.split("\n")
|
||||||
const oldValues = Array.from({ length: PARTS }, (_, i) => {
|
const oldValues = Array.from({ length: PARTS }, (_, i) => {
|
||||||
const value = lines
|
const value = lines
|
||||||
.find((line) => line.startsWith(`ZEN_MODELS${i + 1}`))
|
.find((line) => line.startsWith(`ZEN_MODELS${i + 1}=`))
|
||||||
?.split("=")
|
?.split("=")
|
||||||
.slice(1)
|
.slice(1)
|
||||||
.join("=")
|
.join("=")
|
||||||
if (!value) throw new Error(`ZEN_MODELS${i + 1} not found`)
|
// TODO
|
||||||
return value
|
//if (!value) throw new Error(`ZEN_MODELS${i + 1} not found`)
|
||||||
|
//return value
|
||||||
|
return value ?? ""
|
||||||
})
|
})
|
||||||
|
|
||||||
// store the prettified json to a temp file
|
// store the prettified json to a temp file
|
||||||
@@ -38,6 +40,6 @@ const newValues = Array.from({ length: PARTS }, (_, i) =>
|
|||||||
newValue.slice(chunk * i, i === PARTS - 1 ? undefined : chunk * (i + 1)),
|
newValue.slice(chunk * i, i === PARTS - 1 ? undefined : chunk * (i + 1)),
|
||||||
)
|
)
|
||||||
|
|
||||||
for (let i = 0; i < PARTS; i++) {
|
const envFile = Bun.file(path.join(os.tmpdir(), `models-${Date.now()}.env`))
|
||||||
await $`bun sst secret set ZEN_MODELS${i + 1} -- ${newValues[i]}`
|
await envFile.write(newValues.map((v, i) => `ZEN_MODELS${i + 1}=${v}`).join("\n"))
|
||||||
}
|
await $`bun sst secret load ${envFile.name}`.cwd(root)
|
||||||
|
|||||||
@@ -75,7 +75,9 @@ export namespace ZenData {
|
|||||||
Resource.ZEN_MODELS5.value +
|
Resource.ZEN_MODELS5.value +
|
||||||
Resource.ZEN_MODELS6.value +
|
Resource.ZEN_MODELS6.value +
|
||||||
Resource.ZEN_MODELS7.value +
|
Resource.ZEN_MODELS7.value +
|
||||||
Resource.ZEN_MODELS8.value,
|
Resource.ZEN_MODELS8.value +
|
||||||
|
Resource.ZEN_MODELS9.value +
|
||||||
|
Resource.ZEN_MODELS10.value,
|
||||||
)
|
)
|
||||||
return ModelsSchema.parse(json)
|
return ModelsSchema.parse(json)
|
||||||
})
|
})
|
||||||
|
|||||||
8
packages/console/core/sst-env.d.ts
vendored
8
packages/console/core/sst-env.d.ts
vendored
@@ -133,6 +133,10 @@ declare module "sst" {
|
|||||||
"type": "sst.sst.Secret"
|
"type": "sst.sst.Secret"
|
||||||
"value": string
|
"value": string
|
||||||
}
|
}
|
||||||
|
"ZEN_MODELS10": {
|
||||||
|
"type": "sst.sst.Secret"
|
||||||
|
"value": string
|
||||||
|
}
|
||||||
"ZEN_MODELS2": {
|
"ZEN_MODELS2": {
|
||||||
"type": "sst.sst.Secret"
|
"type": "sst.sst.Secret"
|
||||||
"value": string
|
"value": string
|
||||||
@@ -161,6 +165,10 @@ declare module "sst" {
|
|||||||
"type": "sst.sst.Secret"
|
"type": "sst.sst.Secret"
|
||||||
"value": string
|
"value": string
|
||||||
}
|
}
|
||||||
|
"ZEN_MODELS9": {
|
||||||
|
"type": "sst.sst.Secret"
|
||||||
|
"value": string
|
||||||
|
}
|
||||||
"ZEN_SESSION_SECRET": {
|
"ZEN_SESSION_SECRET": {
|
||||||
"type": "sst.sst.Secret"
|
"type": "sst.sst.Secret"
|
||||||
"value": string
|
"value": string
|
||||||
|
|||||||
8
packages/console/function/sst-env.d.ts
vendored
8
packages/console/function/sst-env.d.ts
vendored
@@ -133,6 +133,10 @@ declare module "sst" {
|
|||||||
"type": "sst.sst.Secret"
|
"type": "sst.sst.Secret"
|
||||||
"value": string
|
"value": string
|
||||||
}
|
}
|
||||||
|
"ZEN_MODELS10": {
|
||||||
|
"type": "sst.sst.Secret"
|
||||||
|
"value": string
|
||||||
|
}
|
||||||
"ZEN_MODELS2": {
|
"ZEN_MODELS2": {
|
||||||
"type": "sst.sst.Secret"
|
"type": "sst.sst.Secret"
|
||||||
"value": string
|
"value": string
|
||||||
@@ -161,6 +165,10 @@ declare module "sst" {
|
|||||||
"type": "sst.sst.Secret"
|
"type": "sst.sst.Secret"
|
||||||
"value": string
|
"value": string
|
||||||
}
|
}
|
||||||
|
"ZEN_MODELS9": {
|
||||||
|
"type": "sst.sst.Secret"
|
||||||
|
"value": string
|
||||||
|
}
|
||||||
"ZEN_SESSION_SECRET": {
|
"ZEN_SESSION_SECRET": {
|
||||||
"type": "sst.sst.Secret"
|
"type": "sst.sst.Secret"
|
||||||
"value": string
|
"value": string
|
||||||
|
|||||||
8
packages/console/resource/sst-env.d.ts
vendored
8
packages/console/resource/sst-env.d.ts
vendored
@@ -133,6 +133,10 @@ declare module "sst" {
|
|||||||
"type": "sst.sst.Secret"
|
"type": "sst.sst.Secret"
|
||||||
"value": string
|
"value": string
|
||||||
}
|
}
|
||||||
|
"ZEN_MODELS10": {
|
||||||
|
"type": "sst.sst.Secret"
|
||||||
|
"value": string
|
||||||
|
}
|
||||||
"ZEN_MODELS2": {
|
"ZEN_MODELS2": {
|
||||||
"type": "sst.sst.Secret"
|
"type": "sst.sst.Secret"
|
||||||
"value": string
|
"value": string
|
||||||
@@ -161,6 +165,10 @@ declare module "sst" {
|
|||||||
"type": "sst.sst.Secret"
|
"type": "sst.sst.Secret"
|
||||||
"value": string
|
"value": string
|
||||||
}
|
}
|
||||||
|
"ZEN_MODELS9": {
|
||||||
|
"type": "sst.sst.Secret"
|
||||||
|
"value": string
|
||||||
|
}
|
||||||
"ZEN_SESSION_SECRET": {
|
"ZEN_SESSION_SECRET": {
|
||||||
"type": "sst.sst.Secret"
|
"type": "sst.sst.Secret"
|
||||||
"value": string
|
"value": string
|
||||||
|
|||||||
8
packages/enterprise/sst-env.d.ts
vendored
8
packages/enterprise/sst-env.d.ts
vendored
@@ -133,6 +133,10 @@ declare module "sst" {
|
|||||||
"type": "sst.sst.Secret"
|
"type": "sst.sst.Secret"
|
||||||
"value": string
|
"value": string
|
||||||
}
|
}
|
||||||
|
"ZEN_MODELS10": {
|
||||||
|
"type": "sst.sst.Secret"
|
||||||
|
"value": string
|
||||||
|
}
|
||||||
"ZEN_MODELS2": {
|
"ZEN_MODELS2": {
|
||||||
"type": "sst.sst.Secret"
|
"type": "sst.sst.Secret"
|
||||||
"value": string
|
"value": string
|
||||||
@@ -161,6 +165,10 @@ declare module "sst" {
|
|||||||
"type": "sst.sst.Secret"
|
"type": "sst.sst.Secret"
|
||||||
"value": string
|
"value": string
|
||||||
}
|
}
|
||||||
|
"ZEN_MODELS9": {
|
||||||
|
"type": "sst.sst.Secret"
|
||||||
|
"value": string
|
||||||
|
}
|
||||||
"ZEN_SESSION_SECRET": {
|
"ZEN_SESSION_SECRET": {
|
||||||
"type": "sst.sst.Secret"
|
"type": "sst.sst.Secret"
|
||||||
"value": string
|
"value": string
|
||||||
|
|||||||
8
packages/function/sst-env.d.ts
vendored
8
packages/function/sst-env.d.ts
vendored
@@ -133,6 +133,10 @@ declare module "sst" {
|
|||||||
"type": "sst.sst.Secret"
|
"type": "sst.sst.Secret"
|
||||||
"value": string
|
"value": string
|
||||||
}
|
}
|
||||||
|
"ZEN_MODELS10": {
|
||||||
|
"type": "sst.sst.Secret"
|
||||||
|
"value": string
|
||||||
|
}
|
||||||
"ZEN_MODELS2": {
|
"ZEN_MODELS2": {
|
||||||
"type": "sst.sst.Secret"
|
"type": "sst.sst.Secret"
|
||||||
"value": string
|
"value": string
|
||||||
@@ -161,6 +165,10 @@ declare module "sst" {
|
|||||||
"type": "sst.sst.Secret"
|
"type": "sst.sst.Secret"
|
||||||
"value": string
|
"value": string
|
||||||
}
|
}
|
||||||
|
"ZEN_MODELS9": {
|
||||||
|
"type": "sst.sst.Secret"
|
||||||
|
"value": string
|
||||||
|
}
|
||||||
"ZEN_SESSION_SECRET": {
|
"ZEN_SESSION_SECRET": {
|
||||||
"type": "sst.sst.Secret"
|
"type": "sst.sst.Secret"
|
||||||
"value": string
|
"value": string
|
||||||
|
|||||||
8
sst-env.d.ts
vendored
8
sst-env.d.ts
vendored
@@ -159,6 +159,10 @@ declare module "sst" {
|
|||||||
"type": "sst.sst.Secret"
|
"type": "sst.sst.Secret"
|
||||||
"value": string
|
"value": string
|
||||||
}
|
}
|
||||||
|
"ZEN_MODELS10": {
|
||||||
|
"type": "sst.sst.Secret"
|
||||||
|
"value": string
|
||||||
|
}
|
||||||
"ZEN_MODELS2": {
|
"ZEN_MODELS2": {
|
||||||
"type": "sst.sst.Secret"
|
"type": "sst.sst.Secret"
|
||||||
"value": string
|
"value": string
|
||||||
@@ -187,6 +191,10 @@ declare module "sst" {
|
|||||||
"type": "sst.sst.Secret"
|
"type": "sst.sst.Secret"
|
||||||
"value": string
|
"value": string
|
||||||
}
|
}
|
||||||
|
"ZEN_MODELS9": {
|
||||||
|
"type": "sst.sst.Secret"
|
||||||
|
"value": string
|
||||||
|
}
|
||||||
"ZEN_SESSION_SECRET": {
|
"ZEN_SESSION_SECRET": {
|
||||||
"type": "sst.sst.Secret"
|
"type": "sst.sst.Secret"
|
||||||
"value": string
|
"value": string
|
||||||
|
|||||||
Reference in New Issue
Block a user