From ae93d4afb3e414a541f520e062be924573b126e1 Mon Sep 17 00:00:00 2001 From: "opencode-agent[bot]" <219766164+opencode-agent[bot]@users.noreply.github.com> Date: Sat, 19 Sep 2026 09:01:25 +0000 Subject: [PATCH] fix(console): use v2 desktop downloads (#49931) Co-authored-by: Brendonovich <14191578+Brendonovich@users.noreply.github.com> --- .../routes/download/[channel]/[platform].ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/console/app/src/routes/download/[channel]/[platform].ts b/packages/console/app/src/routes/download/[channel]/[platform].ts index 4a4be13f4bd..da5b0733bc4 100644 --- a/packages/console/app/src/routes/download/[channel]/[platform].ts +++ b/packages/console/app/src/routes/download/[channel]/[platform].ts @@ -31,11 +31,11 @@ export async function GET({ params: { platform, channel } }: APIEvent) { const assetName = channel === "stable" ? prodAssetNames[platform] : betaAssetNames[platform] if (!assetName) return new Response(null, { status: 404 }) - const latest = await fetch( - `https://github.com/anomalyco/${channel === "stable" ? "opencode" : "opencode-beta"}/releases/latest/download/${assetName}`, - { redirect: "manual" }, + const release = await fetch( + `https://opencode.ai/update/api/${channel === "stable" ? "latest" : "beta"}/desktop/opencode`, ) - const location = latest.headers.get("location") + if (!release.ok) return new Response(null, { status: release.status }) + const location = getAssetUrl(await release.json(), assetName) if (!location) return new Response(null, { status: 502 }) const key = new Request(location) @@ -62,3 +62,14 @@ function download(resp: Response, platform: string, cache: "HIT" | "MISS") { return new Response(resp.body, { status: resp.status, statusText: resp.statusText, headers }) } + +function getAssetUrl(input: unknown, assetName: string) { + if (!isRecord(input) || !isRecord(input.metadata) || !isRecord(input.metadata.files)) return + const asset = input.metadata.files[assetName] + if (!isRecord(asset) || typeof asset.url !== "string") return + return asset.url +} + +function isRecord(input: unknown): input is Record { + return typeof input === "object" && input !== null && !Array.isArray(input) +}