From 78d4f32d79457ec5adee03b016c6dca41de2945f Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Thu, 11 Dec 2025 19:35:36 +0000 Subject: chore: format code --- packages/console/app/src/routes/index.tsx | 2 -- 1 file changed, 2 deletions(-) (limited to 'packages/console/app/src/routes') diff --git a/packages/console/app/src/routes/index.tsx b/packages/console/app/src/routes/index.tsx index fb3d0f9dc..4bfd8b80c 100644 --- a/packages/console/app/src/routes/index.tsx +++ b/packages/console/app/src/routes/index.tsx @@ -52,8 +52,6 @@ export default function Home() {
- -
{/* Date: Thu, 11 Dec 2025 16:26:38 -0500 Subject: docs: lander copy --- packages/console/app/src/routes/index.tsx | 20 ++++++++--------- packages/web/src/content/docs/github.mdx | 36 +++++++++++++++---------------- packages/web/src/content/docs/gitlab.mdx | 28 ++++++++++++------------ 3 files changed, 41 insertions(+), 43 deletions(-) (limited to 'packages/console/app/src/routes') diff --git a/packages/console/app/src/routes/index.tsx b/packages/console/app/src/routes/index.tsx index 4bfd8b80c..618de3c78 100644 --- a/packages/console/app/src/routes/index.tsx +++ b/packages/console/app/src/routes/index.tsx @@ -652,13 +652,13 @@ export default function Home() {
  • - Not necessarily, but probably. You’ll need an AI subscription if you want to connect OpenCode to a - paid provider, although you can work with{" "} - - local models - {" "} - for free. While we encourage users to use Zen, OpenCode works with all popular - providers such as OpenAI, Anthropic, xAI etc. + Not necessarily, OpenCode comes with a set of free models that you + can use without creating an account. Aside from these, you can use any of the popular coding models by creating a Zen account. While we encourage users to use Zen, OpenCode also works with all popular providers such as OpenAI, Anthropic, xAI etc. You can even connect your local models. + +
  • +
  • + + Yes, OpenCode supports subscription plans from all major providers. You can use your Claude Pro/Max, ChatGPT Plus/Pro, or GitHub Copilot subscriptions. Learn more.
  • @@ -668,14 +668,12 @@ export default function Home() {
  • - OpenCode is 100% free to use. Any additional costs will come from your subscription to a model - provider. While OpenCode works with any model provider, we recommend using Zen. + OpenCode is 100% free to use. It also comes with a set of free models. There might be additional costs if you connect any other provider.
  • - Your data and information is only stored when you create sharable links in OpenCode. Learn more about{" "} - share pages. + Your data and information is only stored when you use our free models or create sharable links. Learn more about our models and share pages.
  • diff --git a/packages/web/src/content/docs/github.mdx b/packages/web/src/content/docs/github.mdx index b0e0397e1..a38df68f4 100644 --- a/packages/web/src/content/docs/github.mdx +++ b/packages/web/src/content/docs/github.mdx @@ -1,17 +1,17 @@ --- title: GitHub -description: Use opencode in GitHub issues and pull-requests. +description: Use OpenCode in GitHub issues and pull-requests. --- -opencode integrates with your GitHub workflow. Mention `/opencode` or `/oc` in your comment, and opencode will execute tasks within your GitHub Actions runner. +OpenCode integrates with your GitHub workflow. Mention `/opencode` or `/oc` in your comment, and OpenCode will execute tasks within your GitHub Actions runner. --- ## Features -- **Triage issues**: Ask opencode to look into an issue and explain it to you. -- **Fix and implement**: Ask opencode to fix an issue or implement a feature. And it will work in a new branch and submits a PR with all the changes. -- **Secure**: opencode runs inside your GitHub's runners. +- **Triage issues**: Ask OpenCode to look into an issue and explain it to you. +- **Fix and implement**: Ask OpenCode to fix an issue or implement a feature. And it will work in a new branch and submits a PR with all the changes. +- **Secure**: OpenCode runs inside your GitHub's runners. --- @@ -62,7 +62,7 @@ Or you can set it up manually. with: fetch-depth: 1 - - name: Run opencode + - name: Run OpenCode uses: sst/opencode/github@latest env: ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} @@ -80,12 +80,12 @@ Or you can set it up manually. ## Configuration -- `model`: The model to use with opencode. Takes the format of `provider/model`. This is **required**. -- `share`: Whether to share the opencode session. Defaults to **true** for public repositories. -- `prompt`: Optional custom prompt to override the default behavior. Use this to customize how opencode processes requests. -- `token`: Optional GitHub access token for performing operations such as creating comments, committing changes, and opening pull requests. By default, opencode uses the installation access token from the opencode GitHub App, so commits, comments, and pull requests appear as coming from the app. +- `model`: The model to use with OpenCode. Takes the format of `provider/model`. This is **required**. +- `share`: Whether to share the OpenCode session. Defaults to **true** for public repositories. +- `prompt`: Optional custom prompt to override the default behavior. Use this to customize how OpenCode processes requests. +- `token`: Optional GitHub access token for performing operations such as creating comments, committing changes, and opening pull requests. By default, OpenCode uses the installation access token from the OpenCode GitHub App, so commits, comments, and pull requests appear as coming from the app. - Alternatively, you can use the GitHub Action runner's [built-in `GITHUB_TOKEN`](https://docs.github.com/en/actions/tutorials/authenticate-with-github_token) without installing the opencode GitHub App. Just make sure to grant the required permissions in your workflow: + Alternatively, you can use the GitHub Action runner's [built-in `GITHUB_TOKEN`](https://docs.github.com/en/actions/tutorials/authenticate-with-github_token) without installing the OpenCode GitHub App. Just make sure to grant the required permissions in your workflow: ```yaml permissions: @@ -101,7 +101,7 @@ Or you can set it up manually. ## Custom prompts -Override the default prompt to customize opencode's behavior for your workflow. +Override the default prompt to customize OpenCode's behavior for your workflow. ```yaml title=".github/workflows/opencode.yml" - uses: sst/opencode/github@latest @@ -120,7 +120,7 @@ This is useful for enforcing specific review criteria, coding standards, or focu ## Examples -Here are some examples of how you can use opencode in GitHub. +Here are some examples of how you can use OpenCode in GitHub. - **Explain an issue** @@ -130,7 +130,7 @@ Here are some examples of how you can use opencode in GitHub. /opencode explain this issue ``` - opencode will read the entire thread, including all comments, and reply with a clear explanation. + OpenCode will read the entire thread, including all comments, and reply with a clear explanation. - **Fix an issue** @@ -140,7 +140,7 @@ Here are some examples of how you can use opencode in GitHub. /opencode fix this ``` - And opencode will create a new branch, implement the changes, and open a PR with the changes. + And OpenCode will create a new branch, implement the changes, and open a PR with the changes. - **Review PRs and make changes** @@ -150,18 +150,18 @@ Here are some examples of how you can use opencode in GitHub. Delete the attachment from S3 when the note is removed /oc ``` - opencode will implement the requested change and commit it to the same PR. + OpenCode will implement the requested change and commit it to the same PR. - **Review specific code lines** - Leave a comment directly on code lines in the PR's "Files" tab. opencode automatically detects the file, line numbers, and diff context to provide precise responses. + Leave a comment directly on code lines in the PR's "Files" tab. OpenCode automatically detects the file, line numbers, and diff context to provide precise responses. ``` [Comment on specific lines in Files tab] /oc add error handling here ``` - When commenting on specific lines, opencode receives: + When commenting on specific lines, OpenCode receives: - The exact file being reviewed - The specific lines of code - The surrounding diff context diff --git a/packages/web/src/content/docs/gitlab.mdx b/packages/web/src/content/docs/gitlab.mdx index 2490e5963..66c006c80 100644 --- a/packages/web/src/content/docs/gitlab.mdx +++ b/packages/web/src/content/docs/gitlab.mdx @@ -1,25 +1,25 @@ --- title: GitLab -description: Use opencode in GitLab issues and merge requests. +description: Use OpenCode in GitLab issues and merge requests. --- -opencode integrates with your GitLab workflow. -Mention `@opencode` in a comment, and opencode will execute tasks within your GitLab CI pipeline. +OpenCode integrates with your GitLab workflow. +Mention `@opencode` in a comment, and OpenCode will execute tasks within your GitLab CI pipeline. --- ## Features -- **Triage issues**: Ask opencode to look into an issue and explain it to you. -- **Fix and implement**: Ask opencode to fix an issue or implement a feature. +- **Triage issues**: Ask OpenCode to look into an issue and explain it to you. +- **Fix and implement**: Ask OpenCode to fix an issue or implement a feature. It will work create a new branch and raised a merge request with the changes. -- **Secure**: opencode runs on your GitLab runners. +- **Secure**: OpenCode runs on your GitLab runners. --- ## Setup -opencode runs in your GitLab CI/CD pipeline, here's what you'll need to set it up: +OpenCode runs in your GitLab CI/CD pipeline, here's what you'll need to set it up: :::tip Check out the [**GitLab docs**](https://docs.gitlab.com/user/duo_agent_platform/agent_assistant/) for up to date instructions. @@ -48,7 +48,7 @@ Check out the [**GitLab docs**](https://docs.gitlab.com/user/duo_agent_platform/ - apt-get install --yes glab - echo "Configuring glab" - echo $GITLAB_HOST - - echo "Creating opencode auth configuration" + - echo "Creating OpenCode auth configuration" - mkdir --parents ~/.local/share/opencode - | cat > ~/.local/share/opencode/auth.json << EOF @@ -61,10 +61,10 @@ Check out the [**GitLab docs**](https://docs.gitlab.com/user/duo_agent_platform/ EOF - echo "Configuring git" - git config --global user.email "opencode@gitlab.com" - - git config --global user.name "Opencode" + - git config --global user.name "OpenCode" - echo "Testing glab" - glab issue list - - echo "Running Opencode" + - echo "Running OpenCode" - | opencode run " You are an AI assistant helping with GitLab operations. @@ -115,7 +115,7 @@ You can refer to the [GitLab CLI agents docs](https://docs.gitlab.com/user/duo_a ## Examples -Here are some examples of how you can use opencode in GitLab. +Here are some examples of how you can use OpenCode in GitLab. :::tip You can configure to use a different trigger phrase than `@opencode`. @@ -129,7 +129,7 @@ You can configure to use a different trigger phrase than `@opencode`. @opencode explain this issue ``` - opencode will read the issue and reply with a clear explanation. + OpenCode will read the issue and reply with a clear explanation. - **Fix an issue** @@ -139,7 +139,7 @@ You can configure to use a different trigger phrase than `@opencode`. @opencode fix this ``` - opencode will create a new branch, implement the changes, and open a merge request with the changes. + OpenCode will create a new branch, implement the changes, and open a merge request with the changes. - **Review merge requests** @@ -149,4 +149,4 @@ You can configure to use a different trigger phrase than `@opencode`. @opencode review this merge request ``` - opencode will review the merge request and provide feedback. + OpenCode will review the merge request and provide feedback. -- cgit v1.2.3 From 55957b2ac7edab619dc447d49bb05777ff0fb044 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Thu, 11 Dec 2025 21:34:17 +0000 Subject: chore: format code --- packages/console/app/src/routes/index.tsx | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'packages/console/app/src/routes') diff --git a/packages/console/app/src/routes/index.tsx b/packages/console/app/src/routes/index.tsx index 618de3c78..9948551e4 100644 --- a/packages/console/app/src/routes/index.tsx +++ b/packages/console/app/src/routes/index.tsx @@ -652,13 +652,21 @@ export default function Home() {
  • - Not necessarily, OpenCode comes with a set of free models that you - can use without creating an account. Aside from these, you can use any of the popular coding models by creating a Zen account. While we encourage users to use Zen, OpenCode also works with all popular providers such as OpenAI, Anthropic, xAI etc. You can even connect your local models. + Not necessarily, OpenCode comes with a set of free models that you can use without creating an + account. Aside from these, you can use any of the popular coding models by creating a{" "} + Zen account. While we encourage users to use Zen, OpenCode also works with all + popular providers such as OpenAI, Anthropic, xAI etc. You can even connect your{" "} + + local models + + .
  • - Yes, OpenCode supports subscription plans from all major providers. You can use your Claude Pro/Max, ChatGPT Plus/Pro, or GitHub Copilot subscriptions. Learn more. + Yes, OpenCode supports subscription plans from all major providers. You can use your Claude Pro/Max, + ChatGPT Plus/Pro, or GitHub Copilot subscriptions. Learn more + .
  • @@ -668,12 +676,15 @@ export default function Home() {
  • - OpenCode is 100% free to use. It also comes with a set of free models. There might be additional costs if you connect any other provider. + OpenCode is 100% free to use. It also comes with a set of free models. There might be additional costs + if you connect any other provider.
  • - Your data and information is only stored when you use our free models or create sharable links. Learn more about our models and share pages. + Your data and information is only stored when you use our free models or create sharable links. Learn + more about our models and{" "} + share pages.
  • -- cgit v1.2.3 From 9d4ed5b04a437a50db8acde885740765978961e4 Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Thu, 11 Dec 2025 16:49:12 -0500 Subject: console: fix download links to use dynamic GitHub release version --- packages/console/app/src/routes/download/index.tsx | 55 ++++++++++------------ 1 file changed, 25 insertions(+), 30 deletions(-) (limited to 'packages/console/app/src/routes') diff --git a/packages/console/app/src/routes/download/index.tsx b/packages/console/app/src/routes/download/index.tsx index 311b641c6..eb1d38fa5 100644 --- a/packages/console/app/src/routes/download/index.tsx +++ b/packages/console/app/src/routes/download/index.tsx @@ -1,6 +1,6 @@ import "./index.css" import { Title, Meta, Link } from "@solidjs/meta" -import { A } from "@solidjs/router" +import { A, createAsync, query } from "@solidjs/router" import { Header } from "~/component/header" import { Footer } from "~/component/footer" import { IconCopy, IconCheck } from "~/component/icon" @@ -9,6 +9,13 @@ import desktopAppIcon from "../../asset/lander/opencode-desktop-icon.png" import { Legal } from "~/component/legal" import { config } from "~/config" +const getLatestRelease = query(async () => { + const response = await fetch("https://api.github.com/repos/sst/opencode/releases/latest") + if (!response.ok) return null + const data = await response.json() + return data.tag_name as string +}, "latest-release") + function CopyStatus() { return ( @@ -19,6 +26,12 @@ function CopyStatus() { } export default function Download() { + const release = createAsync(() => getLatestRelease()) + const download = () => { + const version = release() + if (!version) return null + return `https://github.com/sst/opencode/releases/download/${version}` + } const handleCopyClick = (command: string) => (event: Event) => { const button = event.currentTarget as HTMLButtonElement navigator.clipboard.writeText(command) @@ -43,17 +56,6 @@ export default function Download() {

    Download OpenCode

    Available in Beta for macOS, Windows, and Linux

    -
  • @@ -117,7 +119,7 @@ export default function Download() { macOS (Apple Silicon)
    - + Download @@ -133,7 +135,7 @@ export default function Download() { macOS (Intel) - + Download @@ -156,7 +158,7 @@ export default function Download() { Windows (x64) - + Download @@ -164,22 +166,15 @@ export default function Download() {
    - - - - - - - - + - Windows (Arm) + Linux (.deb)
    - + Download @@ -193,9 +188,9 @@ export default function Download() { /> - Linux + Linux (.rpm) - + Download -- cgit v1.2.3 From 6f8746ab9474921840c6123847fc65c84ffeb557 Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Thu, 11 Dec 2025 16:55:23 -0500 Subject: console: fix download route async handling --- packages/console/app/src/routes/download/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'packages/console/app/src/routes') diff --git a/packages/console/app/src/routes/download/index.tsx b/packages/console/app/src/routes/download/index.tsx index eb1d38fa5..2616b7ea1 100644 --- a/packages/console/app/src/routes/download/index.tsx +++ b/packages/console/app/src/routes/download/index.tsx @@ -26,7 +26,9 @@ function CopyStatus() { } export default function Download() { - const release = createAsync(() => getLatestRelease()) + const release = createAsync(() => getLatestRelease(), { + deferStream: true, + }) const download = () => { const version = release() if (!version) return null -- cgit v1.2.3 From 57120e69edadb5dd6a03538ee8dfb85a228d5173 Mon Sep 17 00:00:00 2001 From: Frank Date: Thu, 11 Dec 2025 23:41:04 -0500 Subject: Zen: sync --- infra/console.ts | 1 + .../src/routes/workspace/[id]/model-section.tsx | 7 ++++-- .../console/app/src/routes/zen/util/handler.ts | 15 ++++++++----- .../app/src/routes/zen/util/trialLimiter.ts | 18 ++++++++++------ packages/console/core/script/promote-models.ts | 5 ++++- packages/console/core/script/pull-models.ts | 5 ++++- packages/console/core/script/update-models.ts | 11 +++++++--- packages/console/core/src/model.ts | 25 +++++++++++++++------- packages/console/core/sst-env.d.ts | 12 +++++++---- packages/console/function/sst-env.d.ts | 12 +++++++---- packages/console/resource/sst-env.d.ts | 12 +++++++---- packages/enterprise/sst-env.d.ts | 12 +++++++---- packages/function/sst-env.d.ts | 12 +++++++---- sst-env.d.ts | 12 +++++++---- 14 files changed, 109 insertions(+), 50 deletions(-) (limited to 'packages/console/app/src/routes') diff --git a/infra/console.ts b/infra/console.ts index 0a98ab072..8f54823f8 100644 --- a/infra/console.ts +++ b/infra/console.ts @@ -102,6 +102,7 @@ const ZEN_MODELS = [ new sst.Secret("ZEN_MODELS2"), new sst.Secret("ZEN_MODELS3"), new sst.Secret("ZEN_MODELS4"), + new sst.Secret("ZEN_MODELS5"), ] const STRIPE_SECRET_KEY = new sst.Secret("STRIPE_SECRET_KEY") const AUTH_API_URL = new sst.Linkable("AUTH_API_URL", { diff --git a/packages/console/app/src/routes/workspace/[id]/model-section.tsx b/packages/console/app/src/routes/workspace/[id]/model-section.tsx index 30815336d..e760ccea2 100644 --- a/packages/console/app/src/routes/workspace/[id]/model-section.tsx +++ b/packages/console/app/src/routes/workspace/[id]/model-section.tsx @@ -43,9 +43,12 @@ const getModelsInfo = query(async (workspaceID: string) => { const pA = getPriority(idA) const pB = getPriority(idB) if (pA !== pB) return pA - pB - return modelA.name.localeCompare(modelB.name) + + const modelAName = Array.isArray(modelA) ? modelA[0].name : modelA.name + const modelBName = Array.isArray(modelB) ? modelB[0].name : modelB.name + return modelAName.localeCompare(modelBName) }) - .map(([id, model]) => ({ id, name: model.name })), + .map(([id, model]) => ({ id, name: Array.isArray(model) ? model[0].name : model.name })), disabled: await Model.listDisabled(), } }, workspaceID) diff --git a/packages/console/app/src/routes/zen/util/handler.ts b/packages/console/app/src/routes/zen/util/handler.ts index 7d7767b8d..5e9c877cc 100644 --- a/packages/console/app/src/routes/zen/util/handler.ts +++ b/packages/console/app/src/routes/zen/util/handler.ts @@ -57,15 +57,17 @@ export async function handler( const sessionId = input.request.headers.get("x-opencode-session") ?? "" const requestId = input.request.headers.get("x-opencode-request") ?? "" const projectId = input.request.headers.get("x-opencode-project") ?? "" + const ocClient = input.request.headers.get("x-opencode-client") ?? "" logger.metric({ is_tream: isStream, session: sessionId, request: requestId, + client: ocClient, }) const zenData = ZenData.list() const modelInfo = validateModel(zenData, model) const dataDumper = createDataDumper(sessionId, requestId, projectId) - const trialLimiter = createTrialLimiter(modelInfo.trial?.limit, ip) + const trialLimiter = createTrialLimiter(modelInfo.trial, ip, ocClient) const isTrial = await trialLimiter?.isTrial() const rateLimiter = createRateLimiter(modelInfo.id, modelInfo.rateLimit, ip) await rateLimiter?.check() @@ -286,11 +288,14 @@ export async function handler( } function validateModel(zenData: ZenData, reqModel: string) { - if (!(reqModel in zenData.models)) { - throw new ModelError(`Model ${reqModel} not supported`) - } + if (!(reqModel in zenData.models)) throw new ModelError(`Model ${reqModel} not supported`) + const modelId = reqModel as keyof typeof zenData.models - const modelData = zenData.models[modelId] + const modelData = Array.isArray(zenData.models[modelId]) + ? zenData.models[modelId].find((model) => opts.format === model.formatFilter) + : zenData.models[modelId] + + if (!modelData) throw new ModelError(`Model ${reqModel} not supported for format ${opts.format}`) logger.metric({ model: modelId }) diff --git a/packages/console/app/src/routes/zen/util/trialLimiter.ts b/packages/console/app/src/routes/zen/util/trialLimiter.ts index 15561c9f6..531e5cf0c 100644 --- a/packages/console/app/src/routes/zen/util/trialLimiter.ts +++ b/packages/console/app/src/routes/zen/util/trialLimiter.ts @@ -1,12 +1,18 @@ import { Database, eq, sql } from "@opencode-ai/console-core/drizzle/index.js" import { IpTable } from "@opencode-ai/console-core/schema/ip.sql.js" import { UsageInfo } from "./provider/provider" +import { ZenData } from "@opencode-ai/console-core/model.js" -export function createTrialLimiter(limit: number | undefined, ip: string) { - if (!limit) return +export function createTrialLimiter(trial: ZenData.Trial | undefined, ip: string, client: string) { + if (!trial) return if (!ip) return - let trial: boolean + const limit = + trial.limits.find((limit) => limit.client === client)?.limit ?? + trial.limits.find((limit) => limit.client === undefined)?.limit + if (!limit) return + + let _isTrial: boolean return { isTrial: async () => { @@ -20,11 +26,11 @@ export function createTrialLimiter(limit: number | undefined, ip: string) { .then((rows) => rows[0]), ) - trial = (data?.usage ?? 0) < limit - return trial + _isTrial = (data?.usage ?? 0) < limit + return _isTrial }, track: async (usageInfo: UsageInfo) => { - if (!trial) return + if (!_isTrial) return const usage = usageInfo.inputTokens + usageInfo.outputTokens + 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 + export type Trial = z.infer 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 diff --git a/packages/console/function/sst-env.d.ts b/packages/console/function/sst-env.d.ts index 0b09bfd0c..632ea3fbe 100644 --- a/packages/console/function/sst-env.d.ts +++ b/packages/console/function/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 diff --git a/packages/console/resource/sst-env.d.ts b/packages/console/resource/sst-env.d.ts index 0b09bfd0c..632ea3fbe 100644 --- a/packages/console/resource/sst-env.d.ts +++ b/packages/console/resource/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 diff --git a/packages/enterprise/sst-env.d.ts b/packages/enterprise/sst-env.d.ts index 0b09bfd0c..632ea3fbe 100644 --- a/packages/enterprise/sst-env.d.ts +++ b/packages/enterprise/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 diff --git a/packages/function/sst-env.d.ts b/packages/function/sst-env.d.ts index 0b09bfd0c..632ea3fbe 100644 --- a/packages/function/sst-env.d.ts +++ b/packages/function/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 diff --git a/sst-env.d.ts b/sst-env.d.ts index 247b0ba81..2c182ec35 100644 --- a/sst-env.d.ts +++ b/sst-env.d.ts @@ -65,10 +65,6 @@ declare module "sst" { "type": "sst.sst.Secret" "value": string } - "Enterprise": { - "type": "sst.cloudflare.SolidStart" - "url": string - } "EnterpriseStorage": { "name": string "type": "sst.cloudflare.Bucket" @@ -120,6 +116,10 @@ declare module "sst" { "type": "sst.sst.Linkable" "value": string } + "Teams": { + "type": "sst.cloudflare.SolidStart" + "url": string + } "Web": { "type": "sst.cloudflare.Astro" "url": string @@ -140,6 +140,10 @@ declare module "sst" { "type": "sst.sst.Secret" "value": string } + "ZEN_MODELS5": { + "type": "sst.sst.Secret" + "value": string + } "ZenData": { "name": string "type": "sst.cloudflare.Bucket" -- cgit v1.2.3