Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

feat: installers ship only the new engine

ogsamrat4979162bd951
diff --git a/apps/desktop/electron-builder.base.yml b/apps/desktop/electron-builder.base.yml
index 3b850504..b3a9d86e 100644
--- a/apps/desktop/electron-builder.base.yml
+++ b/apps/desktop/electron-builder.base.yml
@@ -74,9 +74,7 @@ mac:
- from: resources/sidecars
to: sidecars
filter:
- - opencode-aarch64-apple-darwin
- opencode2-aarch64-apple-darwin
- - opencode-x86_64-apple-darwin
- opencode2-x86_64-apple-darwin
- versions.json
- versions.json-aarch64-apple-darwin
@@ -106,9 +104,7 @@ linux:
- from: resources/sidecars
to: sidecars
filter:
- - opencode-aarch64-unknown-linux-gnu
- opencode2-aarch64-unknown-linux-gnu
- - opencode-x86_64-unknown-linux-gnu
- opencode2-x86_64-unknown-linux-gnu
- versions.json
- versions.json-aarch64-unknown-linux-gnu
@@ -151,9 +147,7 @@ win:
- from: resources/sidecars
to: sidecars
filter:
- - opencode-aarch64-pc-windows-msvc.exe
- opencode2-aarch64-pc-windows-msvc.exe
- - opencode-x86_64-pc-windows-msvc.exe
- opencode2-x86_64-pc-windows-msvc.exe
- versions.json
- versions.json-aarch64-pc-windows-msvc.exe
diff --git a/apps/desktop/electron/automation-runner.test.mjs b/apps/desktop/electron/automation-runner.test.mjs
index 3956bcdd..baf7235a 100644
--- a/apps/desktop/electron/automation-runner.test.mjs
+++ b/apps/desktop/electron/automation-runner.test.mjs
@@ -3,14 +3,91 @@ import test from "node:test"
import {
classifyAutomationExecutionError,
- createDesktopAutomationRunner,
- executeDesktopAutomation,
- executeDesktopRemoteSession,
+ createDesktopAutomationRunner as createRunnerOn2,
+ executeDesktopAutomation as executeAutomationOn2,
+ executeDesktopRemoteSession as executeRemoteSessionOn2,
normalizeRunnerBaseUrl,
resolveAssignmentWorkspace,
runnerTokenAudience,
} from "./automation-runner.mjs"
+// The runner talks to the 2.x engine (/opencode2/api, headless-threads). These tests keep their 1.x-shaped fake
+// engine: this shim answers each 2.x request from the fake's 1.x route and shape (the 2.x wire itself is covered by
+// headless-threads' own tests and its real-engine e2e).
+function throughV2(fetchImpl) {
+ if (!fetchImpl) return fetchImpl
+ const models = new Map()
+ const v1 = (url, path) => { const next = new URL(url); next.pathname = path; next.search = ""; return next.toString() }
+ const passFailure = (response) => !response.ok
+ const json = async (response) => { const text = await response.text(); return text ? JSON.parse(text) : null }
+ const v2Message = (message) => {
+ const info = message?.info ?? {}
+ const parts = Array.isArray(message?.parts) ? message.parts : []
+ if (info.role === "user") return { id: info.id, type: "user", time: info.time, text: parts.filter((part) => part.type === "text").map((part) => part.text ?? "").join("") }
+ return {
+ id: info.id, type: "assistant", time: info.time, ...(info.error !== undefined ? { error: info.error } : {}),
+ ...(info.tokens ? { tokens: info.tokens } : {}), ...(info.cost !== undefined ? { cost: info.cost } : {}),
+ content: parts.map((part) => (part.type === "tool" ? { type: "tool", id: part.callID ?? part.id, name: part.tool, state: part.state ?? {} } : { type: part.type, text: part.text })),
+ }
+ }
+ return async (url, options = {}) => {
+ const parsed = new URL(url)
+ const match = /^(\/workspace\/[^/]+)\/opencode2\/api\/session(?:\/([^/]+)(?:\/(.+))?)?$/.exec(parsed.pathname)
+ if (!match) return fetchImpl(url, options)
+ const [, workspace, sessionId, rest] = match
+ const base = `${workspace}/opencode/session`
+ const method = options.method ?? "GET"
+ const body = typeof options.body === "string" && options.body ? JSON.parse(options.body) : {}
+ if (!sessionId && method === "POST") {
+ const response = await fetchImpl(v1(url, base), { ...options, body: JSON.stringify({ title: body.title }) })
+ if (passFailure(response)) return response
+ const session = await json(response)
+ if (body.model && session?.id) models.set(session.id, body.model)
+ return Response.json({ data: session }, { status: response.status })
+ }
+ if (sessionId === "active") {
+ const response = await fetchImpl(v1(url, `${base}/status`), options)
+ if (passFailure(response)) return response
+ const statuses = (await json(response)) ?? {}
+ return Response.json({ data: Object.fromEntries(Object.entries(statuses).filter(([, status]) => status?.type === "busy" || status?.type === "retry").map(([id]) => [id, { type: "running" }])) })
+ }
+ const session = `${base}/${sessionId}`
+ if (!rest) {
+ const response = await fetchImpl(v1(url, session), options)
+ if (passFailure(response)) return response
+ const info = await json(response)
+ return Response.json({ data: { ...info, location: { directory: info?.directory ?? "/workspace" } } })
+ }
+ if (rest === "model") { models.set(decodeURIComponent(sessionId), body.model); return Response.json({ data: {} }) }
+ if (rest === "message") {
+ const limit = parsed.searchParams.get("limit")
+ const response = await fetchImpl(`${v1(url, `${session}/message`)}${limit ? `?limit=${limit}` : ""}`, options)
+ if (passFailure(response)) return response
+ const messages = (await json(response)) ?? []
+ return Response.json({ data: messages.map(v2Message).reverse(), cursor: {} })
+ }
+ if (rest === "prompt") {
+ const model = models.get(decodeURIComponent(sessionId))
+ const v1Body = {
+ parts: [{ type: "text", text: body.text }],
+ ...(body.id ? { messageID: body.id } : {}),
+ ...(model ? { model: { providerID: model.providerID, modelID: model.id } } : {}),
+ ...(model?.variant ? { variant: model.variant } : {}),
+ }
+ return fetchImpl(v1(url, `${session}/prompt_async`), { ...options, body: JSON.stringify(v1Body) })
+ }
+ if (rest === "interrupt") {
+ const response = await fetchImpl(v1(url, `${session}/abort`), options)
+ if (passFailure(response)) return response
+ return Response.json({ data: { interrupted: await json(response) } })
+ }
+ return fetchImpl(url, options)
+ }
+}
+const createDesktopAutomationRunner = (options) => createRunnerOn2({ ...options, fetchImpl: throughV2(options.fetchImpl) })
+const executeDesktopAutomation = (assignment, options) => executeAutomationOn2(assignment, { ...options, fetchImpl: throughV2(options.fetchImpl) })
+const executeDesktopRemoteSession = (assignment, options) => executeRemoteSessionOn2(assignment, { ...options, fetchImpl: throughV2(options.fetchImpl) })
+
function runnerTokenFor(audience, organizationId = "org-1") {
const payload = Buffer.from(JSON.stringify({
v: 2,
@@ -796,7 +873,8 @@ test("waking during an active run keeps its lease and starts no second claim loo
await flushTasks()
assert.equal(paths.filter((path) => path === "/v1/automation-runner/work").length, 1)
assert.equal(paths.filter((path) => path.endsWith("/claim")).length, 1)
- assert.ok([sessionPaths.get, sessionPaths.messages, sessionPaths.todo, sessionPaths.status]
+ // The 2.x engine has no todos: the snapshot reads the session, its messages and the running sessions.
+ assert.ok([sessionPaths.get, sessionPaths.messages, sessionPaths.status]
.every((path) => paths.includes(path)), "snapshot endpoints did not start in parallel")
// The wake joins the reconcile cycle that is already executing run-1 rather
@@ -1127,7 +1205,7 @@ test("desktop Automation execution creates a normal visible local OmniRush.ai th
},
},
])
- for (const path of [sessionPaths.get, sessionPaths.messages, sessionPaths.todo, sessionPaths.status]) {
+ for (const path of [sessionPaths.get, sessionPaths.messages, sessionPaths.status]) {
assert.equal(requests.filter((request) => request.path === path).length, 2)
}
assert.deepEqual(
@@ -1379,7 +1457,7 @@ test("cancellation during execution preserves the local thread and reaches a ter
const abortRequest = localRequests.find((request) => request.path === sessionPaths.abort)
assert.equal(abortRequest?.method, "POST")
assert.equal(abortRequest?.authorization, "Bearer local-client-token")
- assert.equal(abortRequest?.signal?.aborted, false)
+ assert.equal(abortRequest?.signal?.aborted ?? false, false)
})
test("an explicit assistant provider failure terminates immediately with its local thread", async () => {
@@ -1756,6 +1834,10 @@ test("a snapshot poll left hanging by a suspended machine still honors the assig
// The timer can fire before the wall clock reaches the computed deadline.
// Hold that clock still to exercise the abort source deterministically.
t.mock.method(Date, "now", () => 1_000)
+ // The hanging fetches hold no timer (as in the app, whose event loop stays up): this one keeps the test's alive
+ // until the assignment's own timeout fires.
+ const keepAlive = setInterval(() => {}, 50)
+ t.after(() => clearInterval(keepAlive))
const snapshotSignals = []
const sessionPaths = opencodeSessionPaths("workspace-1", "session-1")
const local = localExecutionRoutes(sessionPaths, (parsed, options) => {
diff --git a/apps/desktop/electron/electron-builder-config.test.mjs b/apps/desktop/electron/electron-builder-config.test.mjs
index fa0a52c2..0f81c30a 100644
--- a/apps/desktop/electron/electron-builder-config.test.mjs
+++ b/apps/desktop/electron/electron-builder-config.test.mjs
@@ -56,9 +56,6 @@ describe("Electron distribution configs", () => {
it("ships only architecture-specific sidecars for every desktop OS", async () => {
const config = await readConfig("electron-builder.base.yml");
const cases = [
- ["mac", "opencode", "opencode-aarch64-apple-darwin", "opencode-x86_64-apple-darwin"],
- ["linux", "opencode", "opencode-aarch64-unknown-linux-gnu", "opencode-x86_64-unknown-linux-gnu"],
- ["win", "opencode.exe", "opencode-aarch64-pc-windows-msvc.exe", "opencode-x86_64-pc-windows-msvc.exe"],
["mac", "opencode2", "opencode2-aarch64-apple-darwin", "opencode2-x86_64-apple-darwin"],
["linux", "opencode2", "opencode2-aarch64-unknown-linux-gnu", "opencode2-x86_64-unknown-linux-gnu"],
["win", "opencode2.exe", "opencode2-aarch64-pc-windows-msvc.exe", "opencode2-x86_64-pc-windows-msvc.exe"],
diff --git a/apps/desktop/scripts/electron-after-pack.cjs b/apps/desktop/scripts/electron-after-pack.cjs
index 2e947775..9f447256 100644
--- a/apps/desktop/scripts/electron-after-pack.cjs
+++ b/apps/desktop/scripts/electron-after-pack.cjs
@@ -8,7 +8,6 @@ const { signLimactl } = require("./sign-lima.cjs");
const computerUseHelperAppName = "OmniRush.ai Computer Use.app";
const sidecarBases = [
- "opencode",
"opencode2",
];
diff --git a/apps/desktop/scripts/electron-build.mjs b/apps/desktop/scripts/electron-build.mjs
index c35742b0..6d28eea1 100644
--- a/apps/desktop/scripts/electron-build.mjs
+++ b/apps/desktop/scripts/electron-build.mjs
@@ -48,8 +48,9 @@ function writeSentryBuildConfig() {
writeFileSync(sentryBuildConfigPath, `${JSON.stringify(config, null, 2)}\n`, "utf8");
}
-run(nodeCmd, [resolve(__dirname, "prepare-sidecar.mjs"), "--force", "--outdir", electronSidecarDir], desktopRoot);
+// The 2.x engine only: the 1.x engine no longer ships (its sandbox helpers are prepared on their own).
run(nodeCmd, [resolve(__dirname, "prepare-sidecar.mjs"), "--force", "--engine", "v2", "--outdir", electronSidecarDir], desktopRoot);
+run(nodeCmd, [resolve(__dirname, "prepare-box-helpers.mjs"), "--outdir", electronSidecarDir], desktopRoot);
run(nodeCmd, [resolve(__dirname, "prepare-computer-use-helper.mjs"), "--force", "--outdir", electronHelperDir], desktopRoot);
run(nodeCmd, [resolve(__dirname, "prepare-runtime-node-modules.mjs"), "--outdir", packagedRuntimeRoot], desktopRoot);
// The built-in UI-control MCP ships inside the app as one bundled module and
diff --git a/apps/desktop/scripts/electron-dev.mjs b/apps/desktop/scripts/electron-dev.mjs
index 12f2ad78..ae7102e5 100644
--- a/apps/desktop/scripts/electron-dev.mjs
+++ b/apps/desktop/scripts/electron-dev.mjs
@@ -230,8 +230,8 @@ process.once("SIGINT", () => void stopAll(130));
process.once("SIGTERM", () => void stopAll(143));
if (process.env.OMNIRUSH_ELECTRON_SKIP_SHARED_PREPARE !== "1") {
- runSync(nodeCmd, [resolve(__dirname, "prepare-sidecar.mjs"), "--force", "--outdir", electronSidecarDir], { cwd: desktopRoot });
runSync(nodeCmd, [resolve(__dirname, "prepare-sidecar.mjs"), "--force", "--engine", "v2", "--outdir", electronSidecarDir], { cwd: desktopRoot });
+ runSync(nodeCmd, [resolve(__dirname, "prepare-box-helpers.mjs"), "--outdir", electronSidecarDir], { cwd: desktopRoot });
runSync(nodeCmd, [resolve(__dirname, "prepare-computer-use-helper.mjs"), "--force", "--outdir", electronHelperDir], { cwd: desktopRoot });
}
diff --git a/apps/desktop/scripts/packaged-smoke.mjs b/apps/desktop/scripts/packaged-smoke.mjs
index 82073a28..34eb97b9 100644
--- a/apps/desktop/scripts/packaged-smoke.mjs
+++ b/apps/desktop/scripts/packaged-smoke.mjs
@@ -41,12 +41,9 @@ try {
const targetTriple = process.arch === "arm64"
? "aarch64-unknown-linux-gnu"
: "x86_64-unknown-linux-gnu";
- const sidecar = join(resources, `sidecars/opencode-${targetTriple}`);
- accessSync(sidecar, constants.X_OK);
- if (existsSync(join(resources, "sidecars/opencode"))) {
- throw new Error("Packaged sidecar unexpectedly contains the generic opencode alias");
+ for (const name of ["opencode", "opencode2", `opencode-${targetTriple}`]) {
+ if (existsSync(join(resources, "sidecars", name))) throw new Error(`Packaged sidecars unexpectedly contain ${name} (only opencode2-<triple> ships)`);
}
- run("sidecar", sidecar, ["--version"], 10_000, {}, output);
const sidecarV2 = join(resources, `sidecars/opencode2-${targetTriple}`);
accessSync(sidecarV2, constants.X_OK);
run("sidecar-v2", sidecarV2, ["--version"], 10_000, {}, output);