Skip to content

Commit 4fb2bc5

Browse files
author
Andrew Maguire
authored
Merge branch 'sst:dev' into dev
2 parents 7c544e7 + 7ec48df commit 4fb2bc5

67 files changed

Lines changed: 745 additions & 284 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

github/action.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,29 @@ inputs:
2020
runs:
2121
using: "composite"
2222
steps:
23+
- name: Get opencode version
24+
id: version
25+
shell: bash
26+
run: |
27+
VERSION=$(curl -sf https://api.github.com/repos/sst/opencode/releases/latest | grep -o '"tag_name": *"[^"]*"' | cut -d'"' -f4)
28+
echo "version=${VERSION:-latest}" >> $GITHUB_OUTPUT
29+
30+
- name: Cache opencode
31+
id: cache
32+
uses: actions/cache@v4
33+
with:
34+
path: ~/.opencode/bin
35+
key: opencode-${{ runner.os }}-${{ runner.arch }}-${{ steps.version.outputs.version }}
36+
2337
- name: Install opencode
38+
if: steps.cache.outputs.cache-hit != 'true'
2439
shell: bash
2540
run: curl -fsSL https://opencode.ai/install | bash
2641

42+
- name: Add opencode to PATH
43+
shell: bash
44+
run: echo "$HOME/.opencode/bin" >> $GITHUB_PATH
45+
2746
- name: Run opencode
2847
shell: bash
2948
id: run_opencode

infra/console.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ const ZEN_MODELS = [
102102
new sst.Secret("ZEN_MODELS2"),
103103
new sst.Secret("ZEN_MODELS3"),
104104
new sst.Secret("ZEN_MODELS4"),
105+
new sst.Secret("ZEN_MODELS5"),
105106
]
106107
const STRIPE_SECRET_KEY = new sst.Secret("STRIPE_SECRET_KEY")
107108
const AUTH_API_URL = new sst.Linkable("AUTH_API_URL", {

packages/console/app/src/routes/download/index.tsx

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import "./index.css"
22
import { Title, Meta, Link } from "@solidjs/meta"
3-
import { A } from "@solidjs/router"
3+
import { A, createAsync, query } from "@solidjs/router"
44
import { Header } from "~/component/header"
55
import { Footer } from "~/component/footer"
66
import { IconCopy, IconCheck } from "~/component/icon"
@@ -9,6 +9,13 @@ import desktopAppIcon from "../../asset/lander/opencode-desktop-icon.png"
99
import { Legal } from "~/component/legal"
1010
import { config } from "~/config"
1111

12+
const getLatestRelease = query(async () => {
13+
const response = await fetch("https://api.github.com/repos/sst/opencode/releases/latest")
14+
if (!response.ok) return null
15+
const data = await response.json()
16+
return data.tag_name as string
17+
}, "latest-release")
18+
1219
function CopyStatus() {
1320
return (
1421
<span data-component="copy-status">
@@ -19,6 +26,14 @@ function CopyStatus() {
1926
}
2027

2128
export default function Download() {
29+
const release = createAsync(() => getLatestRelease(), {
30+
deferStream: true,
31+
})
32+
const download = () => {
33+
const version = release()
34+
if (!version) return null
35+
return `https://github.com/sst/opencode/releases/download/${version}`
36+
}
2237
const handleCopyClick = (command: string) => (event: Event) => {
2338
const button = event.currentTarget as HTMLButtonElement
2439
navigator.clipboard.writeText(command)
@@ -43,17 +58,6 @@ export default function Download() {
4358
<div data-component="hero-text">
4459
<h1>Download OpenCode</h1>
4560
<p>Available in Beta for macOS, Windows, and Linux</p>
46-
<button data-component="download-button">
47-
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
48-
<path
49-
d="M13.9583 10.6247L10 14.583L6.04167 10.6247M10 2.08301V13.958M16.25 17.9163H3.75"
50-
stroke="currentColor"
51-
stroke-width="1.5"
52-
stroke-linecap="square"
53-
/>
54-
</svg>
55-
Download for macOS
56-
</button>
5761
</div>
5862
</section>
5963

@@ -117,7 +121,7 @@ export default function Download() {
117121
macOS (<span data-slot="hide-narrow">Apple </span>Silicon)
118122
</span>
119123
</div>
120-
<a href="#" data-component="action-button">
124+
<a href={download() + "/opencode-desktop-darwin-aarch64.dmg"} data-component="action-button">
121125
Download
122126
</a>
123127
</div>
@@ -133,7 +137,7 @@ export default function Download() {
133137
</span>
134138
<span>macOS (Intel)</span>
135139
</div>
136-
<a href="#" data-component="action-button">
140+
<a href={download() + "/opencode-desktop-darwin-x64.dmg"} data-component="action-button">
137141
Download
138142
</a>
139143
</div>
@@ -156,30 +160,23 @@ export default function Download() {
156160
</span>
157161
<span>Windows (x64)</span>
158162
</div>
159-
<a href="#" data-component="action-button">
163+
<a href={download() + "/opencode-desktop-windows-x64.exe"} data-component="action-button">
160164
Download
161165
</a>
162166
</div>
163167
<div data-component="download-row">
164168
<div data-component="download-info">
165169
<span data-slot="icon">
166170
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
167-
<g clip-path="url(#clip0_2614_159729)">
168-
<path
169-
d="M2 2H11.481V11.4769H2V2ZM12.519 2H22V11.4769H12.519V2ZM2 12.519H11.481V22H2V12.519ZM12.519 12.519H22V22H12.519"
170-
fill="currentColor"
171-
/>
172-
</g>
173-
<defs>
174-
<clipPath id="clip0_2614_159729">
175-
<rect width="20" height="20" fill="white" transform="translate(2 2)" />
176-
</clipPath>
177-
</defs>
171+
<path
172+
d="M4.34591 22.7088C5.61167 22.86 7.03384 23.6799 8.22401 23.8247C9.42058 23.9758 9.79086 23.0098 9.79086 23.0098C9.79086 23.0098 11.1374 22.7088 12.553 22.6741C13.97 22.6344 15.3113 22.9688 15.3113 22.9688C15.3113 22.9688 15.5714 23.5646 16.057 23.8247C16.5426 24.0898 17.588 24.1257 18.258 23.4198C18.9293 22.7088 20.7204 21.8132 21.7261 21.2533C22.7382 20.6922 22.5525 19.8364 21.917 19.5763C21.2816 19.3163 20.7614 18.9063 20.8011 18.1196C20.8357 17.3394 20.24 16.8193 20.24 16.8193C20.24 16.8193 20.7614 15.1025 20.2759 13.6805C19.7903 12.2648 18.1889 9.98819 16.9577 8.27657C15.7266 6.55985 16.7719 4.5779 15.651 2.04503C14.5299 -0.491656 11.623 -0.341713 10.0562 0.739505C8.4893 1.8208 8.96968 4.50225 9.04526 5.77447C9.12084 7.04022 9.07985 7.94598 8.93509 8.27146C8.79033 8.60198 7.77951 9.80243 7.1082 10.8081C6.43818 11.819 5.95254 13.906 5.46187 14.7669C4.98142 15.6228 5.31711 16.403 5.31711 16.403C5.31711 16.403 4.98149 16.5182 4.71628 17.0795C4.45616 17.6342 3.93601 17.8993 2.99948 18.0801C2.06934 18.2709 2.06934 18.8705 2.29357 19.5419C2.51902 20.2119 2.29357 20.5873 2.03346 21.4431C1.77342 22.2988 3.07506 22.5588 4.34591 22.7088ZM17.5034 18.805C18.1683 19.0958 19.124 18.691 19.4149 18.4001C19.7045 18.1106 19.9094 17.6801 19.9094 17.6801C19.9094 17.6801 20.2002 17.8249 20.1707 18.2848C20.14 18.7512 20.3706 19.4161 20.8062 19.6467C21.2418 19.876 21.9067 20.1963 21.5621 20.5166C21.211 20.8369 19.2688 21.6183 18.6885 22.2282C18.1132 22.8341 17.3573 23.33 16.8974 23.1839C16.4324 23.0391 16.0262 22.4037 16.2261 21.4736C16.4324 20.5473 16.6066 19.5313 16.5771 18.951C16.5464 18.3707 16.4324 17.5892 16.5771 17.4738C16.7219 17.3598 16.9525 17.4148 16.9525 17.4148C16.9525 17.4148 16.8371 18.5156 17.5034 18.805ZM13.1885 3.12632C13.829 3.12632 14.3454 3.76175 14.3454 4.54324C14.3454 5.09798 14.0853 5.57844 13.7048 5.80906C13.6087 5.76937 13.5087 5.72449 13.3986 5.67832C13.6292 5.56434 13.7893 5.27352 13.7893 4.93783C13.7893 4.49844 13.519 4.13714 13.1794 4.13714C12.8489 4.13714 12.5734 4.49836 12.5734 4.93783C12.5734 5.09806 12.6132 5.25813 12.6785 5.38369C12.4786 5.30293 12.298 5.23383 12.1532 5.17874C12.0776 4.98781 12.0328 4.77257 12.0328 4.54331C12.0328 3.76183 12.5478 3.12632 13.1885 3.12632ZM11.6024 5.56823C11.9176 5.62331 12.7835 5.9987 13.1039 6.11398C13.4242 6.22415 13.7791 6.4291 13.7445 6.63413C13.7048 6.84548 13.5395 6.84548 13.1039 7.1107C12.6735 7.37082 11.7331 7.95116 11.432 7.99085C11.1322 8.03055 10.9618 7.86141 10.6415 7.65516C10.3211 7.44503 9.72039 6.95436 9.87147 6.69432C9.87147 6.69432 10.3416 6.33432 10.5467 6.14986C10.7517 5.95893 11.2821 5.50925 11.6024 5.56823ZM10.2213 3.35185C10.726 3.35185 11.1373 3.95268 11.1373 4.69318C11.1373 4.82773 11.1219 4.95322 11.0976 5.07878C10.972 5.11847 10.8466 5.18385 10.726 5.28891C10.6671 5.33889 10.612 5.38369 10.5621 5.43367C10.6415 5.28381 10.6722 5.06857 10.6363 4.84305C10.5672 4.44335 10.2968 4.14743 10.0316 4.18712C9.76511 4.232 9.60625 4.5984 9.67033 5.00327C9.74081 5.41325 10.0059 5.7091 10.2763 5.6643C10.2917 5.6592 10.3058 5.65409 10.3211 5.64891C10.1918 5.77447 10.0713 5.88464 9.94576 5.97432C9.58065 5.80388 9.31033 5.29402 9.31033 4.69318C9.31041 3.94758 9.71521 3.35185 10.2213 3.35185ZM7.40915 13.045C7.9293 12.2251 8.26492 10.4328 8.78507 9.83702C9.31041 9.24259 9.71521 7.97554 9.53075 7.41569C9.53075 7.41569 10.6517 8.75702 11.432 8.53668C12.2135 8.31116 13.97 7.00571 14.23 7.22994C14.4901 7.45539 16.727 12.375 16.9525 13.9419C17.178 15.5074 16.8026 16.7041 16.8026 16.7041C16.8026 16.7041 15.9468 16.4785 15.8366 16.9987C15.7264 17.524 15.7264 19.4265 15.7264 19.4265C15.7264 19.4265 14.5695 21.0279 12.7784 21.2931C10.9874 21.5532 10.0905 21.3636 10.0905 21.3636L9.08481 20.2118C9.08481 20.2118 9.86637 20.0965 9.75612 19.3112C9.64595 18.531 7.36801 17.4496 6.95803 16.4785C6.5482 15.5073 6.8826 13.8662 7.40915 13.045ZM2.9802 18.9204C3.06988 18.5361 4.23056 18.5361 4.67643 18.2657C5.12229 17.9954 5.21189 17.219 5.57197 17.0141C5.92679 16.804 6.58279 17.5496 6.85311 17.9697C7.11833 18.3797 8.13433 20.1721 8.54942 20.6179C8.96961 21.0676 9.35528 21.6633 9.23483 22.1988C9.12084 22.7343 8.48923 23.1251 8.48923 23.1251C7.92427 23.2993 6.34843 22.619 5.63231 22.3192C4.9162 22.0182 3.09433 21.9284 2.8599 21.6633C2.61906 21.393 2.97517 20.7972 3.06995 20.2322C3.15445 19.6609 2.8893 19.306 2.9802 18.9204Z"
173+
fill="currentColor"
174+
/>
178175
</svg>
179176
</span>
180-
<span>Windows (Arm)</span>
177+
<span>Linux (.deb)</span>
181178
</div>
182-
<a href="#" data-component="action-button">
179+
<a href={download() + "/opencode-desktop-linux-amd64.deb"} data-component="action-button">
183180
Download
184181
</a>
185182
</div>
@@ -193,9 +190,9 @@ export default function Download() {
193190
/>
194191
</svg>
195192
</span>
196-
<span>Linux</span>
193+
<span>Linux (.rpm)</span>
197194
</div>
198-
<a href="#" data-component="action-button">
195+
<a href={download() + "/opencode-desktop-linux-x86_64.rpm"} data-component="action-button">
199196
Download
200197
</a>
201198
</div>

packages/console/app/src/routes/index.tsx

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -652,13 +652,21 @@ export default function Home() {
652652
</li>
653653
<li>
654654
<Faq question="Do I need extra AI subscriptions to use OpenCode?">
655-
Not necessarily, but probably. You’ll need an AI subscription if you want to connect OpenCode to a
656-
paid provider, although you can work with{" "}
655+
Not necessarily, OpenCode comes with a set of free models that you can use without creating an
656+
account. Aside from these, you can use any of the popular coding models by creating a{" "}
657+
<A href="/zen">Zen</A> account. While we encourage users to use Zen, OpenCode also works with all
658+
popular providers such as OpenAI, Anthropic, xAI etc. You can even connect your{" "}
657659
<a href="/docs/providers/#lm-studio" target="_blank">
658660
local models
659-
</a>{" "}
660-
for free. While we encourage users to use <A href="/zen">Zen</A>, OpenCode works with all popular
661-
providers such as OpenAI, Anthropic, xAI etc.
661+
</a>
662+
.
663+
</Faq>
664+
</li>
665+
<li>
666+
<Faq question="Can I use my existing AI subscriptions with OpenCode?">
667+
Yes, OpenCode supports subscription plans from all major providers. You can use your Claude Pro/Max,
668+
ChatGPT Plus/Pro, or GitHub Copilot subscriptions. <a href="/docs/providers/#directory">Learn more</a>
669+
.
662670
</Faq>
663671
</li>
664672
<li>
@@ -668,13 +676,14 @@ export default function Home() {
668676
</li>
669677
<li>
670678
<Faq question="How much does OpenCode cost?">
671-
OpenCode is 100% free to use. Any additional costs will come from your subscription to a model
672-
provider. While OpenCode works with any model provider, we recommend using <A href="/zen">Zen</A>.
679+
OpenCode is 100% free to use. It also comes with a set of free models. There might be additional costs
680+
if you connect any other provider.
673681
</Faq>
674682
</li>
675683
<li>
676684
<Faq question="What about data and privacy?">
677-
Your data and information is only stored when you create sharable links in OpenCode. Learn more about{" "}
685+
Your data and information is only stored when you use our free models or create sharable links. Learn
686+
more about <a href="/docs/zen/#privacy">our models</a> and{" "}
678687
<a href="/docs/share/#privacy">share pages</a>.
679688
</Faq>
680689
</li>

packages/console/app/src/routes/workspace/[id]/model-section.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@ const getModelsInfo = query(async (workspaceID: string) => {
4343
const pA = getPriority(idA)
4444
const pB = getPriority(idB)
4545
if (pA !== pB) return pA - pB
46-
return modelA.name.localeCompare(modelB.name)
46+
47+
const modelAName = Array.isArray(modelA) ? modelA[0].name : modelA.name
48+
const modelBName = Array.isArray(modelB) ? modelB[0].name : modelB.name
49+
return modelAName.localeCompare(modelBName)
4750
})
48-
.map(([id, model]) => ({ id, name: model.name })),
51+
.map(([id, model]) => ({ id, name: Array.isArray(model) ? model[0].name : model.name })),
4952
disabled: await Model.listDisabled(),
5053
}
5154
}, workspaceID)

packages/console/app/src/routes/zen/util/handler.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,17 @@ export async function handler(
5757
const sessionId = input.request.headers.get("x-opencode-session") ?? ""
5858
const requestId = input.request.headers.get("x-opencode-request") ?? ""
5959
const projectId = input.request.headers.get("x-opencode-project") ?? ""
60+
const ocClient = input.request.headers.get("x-opencode-client") ?? ""
6061
logger.metric({
6162
is_tream: isStream,
6263
session: sessionId,
6364
request: requestId,
65+
client: ocClient,
6466
})
6567
const zenData = ZenData.list()
6668
const modelInfo = validateModel(zenData, model)
6769
const dataDumper = createDataDumper(sessionId, requestId, projectId)
68-
const trialLimiter = createTrialLimiter(modelInfo.trial?.limit, ip)
70+
const trialLimiter = createTrialLimiter(modelInfo.trial, ip, ocClient)
6971
const isTrial = await trialLimiter?.isTrial()
7072
const rateLimiter = createRateLimiter(modelInfo.id, modelInfo.rateLimit, ip)
7173
await rateLimiter?.check()
@@ -286,11 +288,14 @@ export async function handler(
286288
}
287289

288290
function validateModel(zenData: ZenData, reqModel: string) {
289-
if (!(reqModel in zenData.models)) {
290-
throw new ModelError(`Model ${reqModel} not supported`)
291-
}
291+
if (!(reqModel in zenData.models)) throw new ModelError(`Model ${reqModel} not supported`)
292+
292293
const modelId = reqModel as keyof typeof zenData.models
293-
const modelData = zenData.models[modelId]
294+
const modelData = Array.isArray(zenData.models[modelId])
295+
? zenData.models[modelId].find((model) => opts.format === model.formatFilter)
296+
: zenData.models[modelId]
297+
298+
if (!modelData) throw new ModelError(`Model ${reqModel} not supported for format ${opts.format}`)
294299

295300
logger.metric({ model: modelId })
296301

packages/console/app/src/routes/zen/util/trialLimiter.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import { Database, eq, sql } from "@opencode-ai/console-core/drizzle/index.js"
22
import { IpTable } from "@opencode-ai/console-core/schema/ip.sql.js"
33
import { UsageInfo } from "./provider/provider"
4+
import { ZenData } from "@opencode-ai/console-core/model.js"
45

5-
export function createTrialLimiter(limit: number | undefined, ip: string) {
6-
if (!limit) return
6+
export function createTrialLimiter(trial: ZenData.Trial | undefined, ip: string, client: string) {
7+
if (!trial) return
78
if (!ip) return
89

9-
let trial: boolean
10+
const limit =
11+
trial.limits.find((limit) => limit.client === client)?.limit ??
12+
trial.limits.find((limit) => limit.client === undefined)?.limit
13+
if (!limit) return
14+
15+
let _isTrial: boolean
1016

1117
return {
1218
isTrial: async () => {
@@ -20,11 +26,11 @@ export function createTrialLimiter(limit: number | undefined, ip: string) {
2026
.then((rows) => rows[0]),
2127
)
2228

23-
trial = (data?.usage ?? 0) < limit
24-
return trial
29+
_isTrial = (data?.usage ?? 0) < limit
30+
return _isTrial
2531
},
2632
track: async (usageInfo: UsageInfo) => {
27-
if (!trial) return
33+
if (!_isTrial) return
2834
const usage =
2935
usageInfo.inputTokens +
3036
usageInfo.outputTokens +

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,19 @@ const value1 = lines.find((line) => line.startsWith("ZEN_MODELS1"))?.split("=")[
1616
const value2 = lines.find((line) => line.startsWith("ZEN_MODELS2"))?.split("=")[1]
1717
const value3 = lines.find((line) => line.startsWith("ZEN_MODELS3"))?.split("=")[1]
1818
const value4 = lines.find((line) => line.startsWith("ZEN_MODELS4"))?.split("=")[1]
19+
const value5 = lines.find((line) => line.startsWith("ZEN_MODELS5"))?.split("=")[1]
1920
if (!value1) throw new Error("ZEN_MODELS1 not found")
2021
if (!value2) throw new Error("ZEN_MODELS2 not found")
2122
if (!value3) throw new Error("ZEN_MODELS3 not found")
2223
if (!value4) throw new Error("ZEN_MODELS4 not found")
24+
if (!value5) throw new Error("ZEN_MODELS5 not found")
2325

2426
// validate value
25-
ZenData.validate(JSON.parse(value1 + value2 + value3 + value4))
27+
ZenData.validate(JSON.parse(value1 + value2 + value3 + value4 + value5))
2628

2729
// update the secret
2830
await $`bun sst secret set ZEN_MODELS1 ${value1} --stage ${stage}`
2931
await $`bun sst secret set ZEN_MODELS2 ${value2} --stage ${stage}`
3032
await $`bun sst secret set ZEN_MODELS3 ${value3} --stage ${stage}`
3133
await $`bun sst secret set ZEN_MODELS4 ${value4} --stage ${stage}`
34+
await $`bun sst secret set ZEN_MODELS5 ${value5} --stage ${stage}`

packages/console/core/script/pull-models.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,19 @@ const value1 = lines.find((line) => line.startsWith("ZEN_MODELS1"))?.split("=")[
1616
const value2 = lines.find((line) => line.startsWith("ZEN_MODELS2"))?.split("=")[1]
1717
const value3 = lines.find((line) => line.startsWith("ZEN_MODELS3"))?.split("=")[1]
1818
const value4 = lines.find((line) => line.startsWith("ZEN_MODELS4"))?.split("=")[1]
19+
const value5 = lines.find((line) => line.startsWith("ZEN_MODELS5"))?.split("=")[1]
1920
if (!value1) throw new Error("ZEN_MODELS1 not found")
2021
if (!value2) throw new Error("ZEN_MODELS2 not found")
2122
if (!value3) throw new Error("ZEN_MODELS3 not found")
2223
if (!value4) throw new Error("ZEN_MODELS4 not found")
24+
if (!value5) throw new Error("ZEN_MODELS5 not found")
2325

2426
// validate value
25-
ZenData.validate(JSON.parse(value1 + value2 + value3 + value4))
27+
ZenData.validate(JSON.parse(value1 + value2 + value3 + value4 + value5))
2628

2729
// update the secret
2830
await $`bun sst secret set ZEN_MODELS1 ${value1}`
2931
await $`bun sst secret set ZEN_MODELS2 ${value2}`
3032
await $`bun sst secret set ZEN_MODELS3 ${value3}`
3133
await $`bun sst secret set ZEN_MODELS4 ${value4}`
34+
await $`bun sst secret set ZEN_MODELS5 ${value5}`

0 commit comments

Comments
 (0)