Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Cursor installs on demand from its card, not in the Cloud image; a wrong saved CLI path heals itself
milind-soni2a5856ed80e7
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.ymlindex cd37742160..dfa2506adc 100644--- a/.github/workflows/docker.yml+++ b/.github/workflows/docker.yml@@ -357,14 +357,14 @@ jobs:# Caddy must not carry the privileged-port capability (it runs as maus# on :8080), which Docker's default capabilities would hide at runtime.# Its Grok is one root-owned binary, with nothing from the installer's- # throwaway home left in the image, and Cursor's build is root's alone.+ # throwaway home left in the image.run: |set -euo pipefaildocker save openmausbot:ci -o "$RUNNER_TEMP/server.tar"docker save omb-cloud-home:ci -o "$RUNNER_TEMP/home.tar"python3 - "$RUNNER_TEMP/server.tar" "$RUNNER_TEMP/home.tar" <<'PY'import json, re, sys, tarfile- cache = re.compile(r"^(root/\.npm|tmp/(npm-cache|omb-build-home|node-compile-cache|grok-install|cursor-install))/")+ cache = re.compile(r"^(root/\.npm|tmp/(npm-cache|omb-build-home|node-compile-cache|grok-install))/")for path in sys.argv[1:]:files = {}with tarfile.open(path) as image:@@ -388,12 +388,6 @@ jobs:assert len(grok) == 1 and grok[0].uid == 0 and grok[0].mode & 0o7777 == 0o755, "Grok is not one root-owned 0755 binary"installer = sorted(name for name in files if re.match(r"(data|root)/\.grok/|usr/local/bin/agent$", name))assert not installer, f"Grok's installer left files behind: {installer[:5]}"- cursor = files["usr/local/bin/cursor-agent"]- assert len(cursor) == 1 and cursor[0].issym() and cursor[0].linkname.startswith("/opt/cursor-agent/"), "Cursor's CLI is not one link into /opt"- owned = [name for name in files if name.startswith("opt/cursor-agent/") and (files[name][-1].uid != 0 or files[name][-1].mode & 0o022)]- assert not owned, f"Cursor's files are not root's alone: {owned[:5]}"- leftover = sorted(name for name in files if re.match(r"(data|root)/\.(cursor|local)/|tmp/cursor-agent-logs", name))- assert not leftover, f"Cursor's version check left files behind: {leftover[:5]}"print(f"{path}: {len(files)} files, each once; no build cache; {native[0]}")PYdiff --git a/Dockerfile b/Dockerfileindex 58bf7e90f7..f429fbb563 100644--- a/Dockerfile+++ b/Dockerfile@@ -151,31 +151,6 @@ RUN if [ -n "$GROK_VERSION" ]; then \&& HOME=/tmp/grok-install grok --version | grep -qF "grok $GROK_VERSION " \&& rm -rf /tmp/grok-install; \fi-# Cursor, the cursor.com subscription engine: Cursor's own build of its CLI-# (what https://cursor.com/install downloads), pinned to the version the-# Cursor driver is verified against (server/drivers/acp/cursor.ts) and checked-# against its SHA-256, measured on two downloads. A Cloud has no terminal, so-# without it Cursor's setup card could only offer an install nobody can run.-# People sign it in from the app with a link (cursor-agent login); the login-# lands in their home on the volume. The build is root's, under /opt, which-# every bot's box sees read-only; only the launcher's link goes on PATH.-# CURSOR_VERSION= (empty) leaves Cursor out on purpose.-ARG CURSOR_VERSION=2026.10.22-27dcf5f-ARG CURSOR_SHA256_X64=85296944e4600a83c4b764f578d1502bf9c416db200d33a593e8f3ecabfdc294-ARG CURSOR_SHA256_ARM64=22a36df9720830668ccd4d707e5190204ab9c8a0efb2f068cc914895f804d3ec-ARG TARGETARCH-RUN if [ -n "$CURSOR_VERSION" ]; then \- arch=x64 && sum=$CURSOR_SHA256_X64 \- && if [ "$TARGETARCH" = arm64 ]; then arch=arm64 && sum=$CURSOR_SHA256_ARM64; fi \- && mkdir -p /tmp/cursor-install "/opt/cursor-agent/$CURSOR_VERSION" \- && curl -fsSL "https://downloads.cursor.com/lab/$CURSOR_VERSION/linux/$arch/agent-cli-package.tar.gz" -o /tmp/cursor-install/cli.tar.gz \- && echo "$sum /tmp/cursor-install/cli.tar.gz" | sha256sum -c - \- && tar -xzf /tmp/cursor-install/cli.tar.gz -C "/opt/cursor-agent/$CURSOR_VERSION" --strip-components=1 --no-same-owner \- && chmod -R u=rwX,go=rX /opt/cursor-agent \- && ln -s "/opt/cursor-agent/$CURSOR_VERSION/cursor-agent" /usr/local/bin/cursor-agent \- && test "$(HOME=/tmp/cursor-install TMPDIR=/tmp/cursor-install cursor-agent --version)" = "$CURSOR_VERSION" \- && rm -rf /tmp/cursor-install; \- fi# Engine CLIs baked into the image (space-separated npm packages). The publish# job passes each one's current version, or names only and today's date as# ENGINES_CACHE_TAG when it cannot look them up. Build-time CLI caches mustdiff --git a/docs/cursor.md b/docs/cursor.mdindex c722fbd8db..8d3f219ab0 100644--- a/docs/cursor.md+++ b/docs/cursor.md@@ -38,21 +38,32 @@ key.The engine stays unavailable until the `cursor-agent` executable is found, anduntil it answers `--version` with Cursor's own build number (`2026.10.22-27dcf5f`).-A CLI path that runs another program is reported as not Cursor's CLI, with Reset-as the fix: an install command pasted as the path (`curl https://cursor.com/install--fsS | bash`) runs curl, which answers `--version` with its own banner. Settings'-CLI test refuses such a path the same way. A missing login shows as+A CLI path that runs another program is reported as not Cursor's CLI: an install+command pasted as the path (`curl https://cursor.com/install -fsS | bash`) runs curl,+which answers `--version` with its own banner. Settings' CLI test refuses such a path+the same way. A missing login shows asunauthenticated rather than crashing the fleet.## MausBot Cloud-A Cloud has no terminal, so the Cloud image ships Cursor's own build, pinned to-the version above and checked against its SHA-256 (`Dockerfile`, `CURSOR_VERSION`),-root's under `/opt/cursor-agent` with `/usr/local/bin/cursor-agent` linking to it.-Every bot's box sees `/opt` read-only. Cursor is signed in from its card, as above;-the login lands in the Cloud's home on its volume. Cursor runs on the Cloud itself,-so signing in on the person's own computer, or on their cloud computer, never signs-in the Cursor their bots use; the Cloud's bots are told so.+A Cloud has no terminal, so on Linux Cursor's card installs Cursor's own build itself+(**Install Cursor here**): the build `https://cursor.com/install` downloads, pinned to the+version above and checked against its SHA-256 (`server/drivers/acp/cursor-release.ts`). It goes+into the app's own folder on the data volume (`tools/standalone/cursor-agent/<version>`, about+560 MB; every bot's box sees it read-only), and `bin/cursor-agent` there is a link to its+launcher, which runs the node and scripts beside it. That `bin/` goes last on PATH, at start-up+too, only while the link and the launcher are the pinned ones, so a Cursor the person installs+themselves comes first. Nothing is added to the Cloud image.++A saved CLI path that answers `--version` as another program gives way by itself to Cursor's own+CLI once one is installed (the app's copy or one on PATH), as Set CLI would; until then the card+offers the install. Cursor is then signed in from its card, as above; the login lands in the+Cloud's home on its volume. Cursor runs on the Cloud itself, so signing in on the person's own+computer, or on their cloud computer, never signs in the Cursor their bots use; the Cloud's bots+are told so.++On a Cloud, a card never offers a command to copy or a CLI path to set: an engine the Cloud can't+install says so in one line.## Modelsdiff --git a/server/contracts.ts b/server/contracts.tsindex a42d5ad348..5f5aa4d744 100644--- a/server/contracts.ts+++ b/server/contracts.ts@@ -342,6 +342,8 @@ export interface ProviderSnapshot {state: "available" | "unavailable";reason?: string;authenticated?: boolean;+ /** The CLI path runs another program: it answered --version as something other than this engine's own CLI. */+ notEngineCli?: true;/** Display identity from the provider CLI, never credentials; `method` is a personal login or the workspace API key. */account?: { email?: string; organization?: string; method?: "login" | "api-key" };version?: string | null;@@ -431,6 +433,9 @@ export interface StandaloneRelease {/** Environment for the app's own copy only, such as turning off the vendor's self-updater. */runEnv?: Readonly<Record<string, string>>;assets: Partial<Record<StandalonePlatform, StandaloneAsset>>;+ /** The program is a launcher that runs the rest of its folder (Cursor's runs a node and scripts beside it), so bin/+ * holds a link to it rather than a copy. POSIX only. */+ launcher?: true;/** Program SHA-256s of earlier pinned versions, per platform: a copy of one of those stays usable after the pin moves* on, until it is updated. Nothing in the data folder can add to this list. */previousPrograms?: Partial<Record<StandalonePlatform, readonly string[]>>;diff --git a/server/drivers/acp/core.ts b/server/drivers/acp/core.tsindex a92ff5dcf3..b6b218506e 100644--- a/server/drivers/acp/core.ts+++ b/server/drivers/acp/core.ts@@ -1588,7 +1588,7 @@ export function createAcpDriver(support: AcpSupport): ProviderDriver<AcpConfig>const snapshot = async (): Promise<ProviderSnapshot> => {const env = childEnv();if (support.snapshot) return support.snapshot(env, config, instanceId);- const probe = await new Promise<{ version?: string; reason?: string }>((resolve) => {+ const probe = await new Promise<{ version?: string; reason?: string; other?: true }>((resolve) => {execCli(config.cli, ["--version"], { timeout: 8000, env }, (err, stdout, stderr) => {if (err) {const failure = err as NodeJS.ErrnoException & { killed?: boolean };@@ -1605,10 +1605,10 @@ export function createAcpDriver(support: AcpSupport): ProviderDriver<AcpConfig>}const version = versionFromProbe(stdout, stderr);resolve(!version ? { reason: `\`${config.cli}\` returned no version. Check the configured executable with --version, then try again.` }- : support.cliVersion && !support.cliVersion.test(version) ? { reason: notThisCli(config.cli, support.displayName) } : { version });+ : support.cliVersion && !support.cliVersion.test(version) ? { reason: notThisCli(config.cli, support.displayName), other: true } : { version });});});- if (!probe.version) return { state: "unavailable", reason: probe.reason };+ if (!probe.version) return { state: "unavailable", reason: probe.reason, ...(probe.other ? { notEngineCli: true } : {}) };return { state: "available", version: probe.version, authenticated: await support.isAuthenticated(env, config, instanceId) };};diff --git a/server/drivers/acp/cursor-release.ts b/server/drivers/acp/cursor-release.tsnew file mode 100644index 0000000000..ad5660e287--- /dev/null+++ b/server/drivers/acp/cursor-release.ts@@ -0,0 +1,27 @@+// Cursor's own build of its CLI, for installing it where there is no terminal (a Cloud): the build+// https://cursor.com/install downloads for version 2026.10.22-27dcf5f (the version the Cursor driver is verified against).+// Cursor publishes no checksum file. Each archive SHA-256 below was measured on 2026-11-04 by downloading the asset twice+// and running `shasum -a 256` on each download (the two agreed); each size is the byte count both agree on. The program+// SHA-256 is `shasum -a 256` of `dist-package/cursor-agent` unpacked from that same archive (`tar -xzO`), the same file in+// both builds; the app checks it after unpacking, before reusing an installed copy and at every start.+// Each archive holds one folder, dist-package/: `cursor-agent` is a bash launcher that runs the node and scripts beside it,+// found from where it really is, so the build is a launcher release (its bin/ entry is a link into that folder). Linux+// only: a Mac or PC has a terminal for Cursor's installer.+import type { StandaloneRelease } from "../../contracts.ts";++const VERSION = "2026.10.22-27dcf5f";+const BUILD = `https://downloads.cursor.com/lab/${VERSION}/linux`;+const LAUNCHER_SHA256 = "2ccc9a8e167797641448b5e5c936f006ba137a2555f117f38c5eb76a5238a233";++export const CURSOR_STANDALONE: StandaloneRelease = {+ name: "Cursor",+ engine: "cursor-agent",+ version: VERSION,+ hosts: ["downloads.cursor.com"],+ launcher: true,+ previousPrograms: {},+ assets: {+ "linux-x64": { url: `${BUILD}/x64/agent-cli-package.tar.gz`, archive: "tar.gz", executable: "dist-package/cursor-agent", approxBytes: 184_859_176, sha256: "85296944e4600a83c4b764f578d1502bf9c416db200d33a593e8f3ecabfdc294", executableSha256: LAUNCHER_SHA256 },+ "linux-arm64": { url: `${BUILD}/arm64/agent-cli-package.tar.gz`, archive: "tar.gz", executable: "dist-package/cursor-agent", approxBytes: 182_799_294, sha256: "22a36df9720830668ccd4d707e5190204ab9c8a0efb2f068cc914895f804d3ec", executableSha256: LAUNCHER_SHA256 },+ },+};diff --git a/server/drivers/acp/cursor-sign-in.test.ts b/server/drivers/acp/cursor-sign-in.test.tsindex 5287031c7d..12b9b29df8 100644--- a/server/drivers/acp/cursor-sign-in.test.ts+++ b/server/drivers/acp/cursor-sign-in.test.ts@@ -11,6 +11,11 @@ import type { ProviderInstance } from "../../contracts.ts";import { removeTempDir } from "../../testing/cleanup.ts";import { DeviceAuthController } from "../device-auth.ts";import { CURSOR_CLI_VERSION, CURSOR_SIGN_IN, CursorAgentDriver, readCursorStatus } from "./cursor.ts";+import { CURSOR_STANDALONE } from "./cursor-release.ts";+import { clientInstall } from "../../contracts.ts";+import { serverInstallFor } from "../../engine-install.ts";+import { standaloneAssetFor } from "../../engine-standalone.ts";+import { STANDALONE_RELEASES } from "../../standalone-releases.ts";const FAKE_CURSOR = fileURLToPath(new URL("../../testing/fake-cursor-login-cli.ts", import.meta.url));const LINK = "https://cursor.com/loginDeepControl?challenge=Jx1fQ3-Vq8kP0Yb_5rT2aWm7nC4dE6gH9iL0oS1uZ2y&uuid=3f2b8c1d-4e5a-4b6c-8d7e-9f0a1b2c3d4e&mode=login&redirectTarget=cli&supportsSelectedTeamLogin=true";@@ -56,7 +61,8 @@ describe.skipIf(process.platform === "win32")("Cursor's CLI path", () => {expect(snapshot.state).toBe("unavailable");expect(snapshot).not.toHaveProperty("version");expect(snapshot.reason).toContain("is not Cursor's CLI");- expect(snapshot.reason).toContain("Reset");+ // Marked, so the registry can give the path up for Cursor's own CLI once one is installed.+ expect(snapshot.notEngineCli).toBe(true);});it("is available, signed out until the sign-in, when the path runs Cursor's CLI", async () => {@@ -75,6 +81,23 @@ describe.skipIf(process.platform === "win32")("Cursor's CLI path", () => {});});+describe("installing Cursor where there is no terminal", () => {+ it("offers Cursor's own pinned build from Settings on Linux, with its pins kept on the server", () => {+ expect(STANDALONE_RELEASES).toContain(CURSOR_STANDALONE);+ expect(CursorAgentDriver.install?.standalone).toBe(CURSOR_STANDALONE);+ expect(CURSOR_STANDALONE).toMatchObject({ engine: "cursor-agent", version: "2026.10.22-27dcf5f", hosts: ["downloads.cursor.com"], launcher: true });+ for (const key of ["linux-x64", "linux-arm64"]) {+ expect(standaloneAssetFor(CURSOR_STANDALONE, key)).toMatchObject({ archive: "tar.gz", executable: "dist-package/cursor-agent" });+ }+ // A Mac or PC has a terminal for Cursor's own installer.+ for (const key of ["darwin-arm64", "darwin-x64", "win32-x64"]) expect(standaloneAssetFor(CURSOR_STANDALONE, key)).toBeNull();+ expect(clientInstall(CursorAgentDriver.install)).not.toHaveProperty("standalone");+ // Without npm, Settings offers exactly that build where this computer has one, and nothing otherwise.+ const here = standaloneAssetFor(CURSOR_STANDALONE);+ expect(serverInstallFor(CursorAgentDriver.install, false)).toEqual(here ? { standalone: { version: "2026.10.22-27dcf5f", downloadBytes: here.approxBytes } } : null);+ });+});+describe("Cursor's sign-in link", () => {it("reads the one link Cursor prints, with no code to enter", () => {expect(deviceSignInHasCode("cursor")).toBe(false);diff --git a/server/drivers/acp/cursor.ts b/server/drivers/acp/cursor.tsindex da419a60f9..e8e946a34f 100644--- a/server/drivers/acp/cursor.ts+++ b/server/drivers/acp/cursor.ts@@ -5,6 +5,7 @@ import type { ModelCatalog, ProviderErrorCode } from "../../contracts.ts";import { titleCaseModelId } from "../../contracts.ts";import { execCli } from "../../procs.ts";import { createAcpDriver, type AcpSupport } from "./core.ts";+import { CURSOR_STANDALONE } from "./cursor-release.ts";import type { DeviceSignIn, DeviceSignInState } from "../device-auth.ts";import { discoverAcpModels } from "./custom-model-catalog.ts";import type { AcpQuestionRequest } from "./question-requests.ts";@@ -490,6 +491,8 @@ const support = (run: typeof execCli): AcpSupport => ({},docsUrl: "https://cursor.com/docs/cli/installation",signInCommand: "cursor-agent login",+ // On Linux, Settings installs Cursor's own pinned build: a Cloud has no terminal for its installer.+ standalone: CURSOR_STANDALONE,},// Global flags precede `acp`; `--force` is the documented auto-approve switch.diff --git a/server/drivers/acp/version-probe.ts b/server/drivers/acp/version-probe.tsindex e3e2c658af..0ca5493840 100644--- a/server/drivers/acp/version-probe.ts+++ b/server/drivers/acp/version-probe.ts@@ -9,9 +9,10 @@ export function versionFromProbe(stdout: string | undefined, stderr: string | un}/** A CLI path that runs another program answers --version as that program: an install command pasted as the path- * (`curl https://cursor.com/install -fsS | bash`) runs curl, whose `--version` wins over its other arguments. */+ * (`curl https://cursor.com/install -fsS | bash`) runs curl, whose `--version` wins over its other arguments. The+ * registry drops such a path once the engine's own CLI is installed, so the person never has to. */export function notThisCli(cli: string, name: string): string {- return `\`${cli}\` is not ${name}'s CLI: it answered --version as another program. Choose Reset beside its CLI path in Settings → Model providers and accounts, or set the path to ${name}'s own CLI.`;+ return `\`${cli}\` is not ${name}'s CLI: it answered --version as another program.`;}export type VersionTriple = readonly [number, number, number];diff --git a/server/engine-standalone.test.ts b/server/engine-standalone.test.tsindex 9e910ff410..0e3e9d7718 100644--- a/server/engine-standalone.test.ts+++ b/server/engine-standalone.test.ts@@ -1,6 +1,7 @@// A local HTTP server stands in for the vendor's download host: the test fetch maps https://<host>/<path> onto it, so the// installer's own HTTPS, host and redirect checks run unchanged. Nothing here reaches the internet.import { createHash } from "node:crypto";+import { spawnSync } from "node:child_process";import { createServer, type Server } from "node:http";import {chmodSync, existsSync, linkSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, symlinkSync, writeFileSync,@@ -268,6 +269,51 @@ describe.skipIf(process.platform === "win32")("installing a standalone engine",expect(leftovers()).toEqual([VERSION, "bin", "current.json"]);});+ // Cursor's build: a launcher that runs the node and scripts beside it, found from where the launcher really is.+ describe("a launcher release", () => {+ const launcher = () => `#!/bin/sh\nhere="$(dirname "$(realpath "$0")")"\n[ -f "$here/runtime.js" ] || { echo 'no runtime beside me' >&2; exit 3; }\necho "$* launched" >> '${log}'\necho 'fake-engine ${VERSION}'\n`;+ async function launcherRelease(): Promise<StandaloneRelease> {+ const program = launcher();+ const data = await tarGz({ "pkg/fake-engine": { data: program, mode: 0o755 }, "pkg/runtime.js": { data: "// the rest of the build\n", mode: 0o644 } });+ return fixtureRelease({ [standalonePlatformKey()]: serve(data, "tar.gz", "pkg/fake-engine", program) }, { launcher: true });+ }++ it("puts a link to the launcher in bin/, which runs from inside its own folder", async () => {+ const installed = await install(await launcherRelease());+ expect(installed).toEqual({ version: VERSION, executablePath: binPath(), binDir: binDir() });+ expect(lstatSync(binPath()).isSymbolicLink()).toBe(true);+ expect(realpathSync(binPath())).toBe(realpathSync(join(engineDir(), VERSION, "pkg", "fake-engine")));+ expect(readdirSync(binDir())).toEqual(["fake-engine"]);+ expect(findCliCandidates("fake-engine")).toEqual([binPath()]);+ expect(spawnSync(binPath(), ["--version"], { encoding: "utf8" }).stdout.trim()).toBe(`fake-engine ${VERSION}`);+ });++ it("goes back on PATH at start-up only while bin/ links to exactly this version's launcher, unchanged", async () => {+ const release = await launcherRelease();+ await install(release);+ resetPathCacheForTests();+ registerStandaloneBinDirs(base, [release]);+ expect(findCliCandidates("fake-engine")).toEqual([binPath()]);++ // A link to anything else is not the app's.+ const elsewhere = join(scratch, "elsewhere");+ writeFileSync(elsewhere, launcher(), { mode: 0o755 });+ rmSync(binPath());+ symlinkSync(elsewhere, binPath());+ resetPathCacheForTests();+ registerStandaloneBinDirs(base, [release]);+ expect(findCliCandidates("fake-engine")).toEqual([]);++ // Nor is the right link to a launcher that changed.+ rmSync(binPath());+ symlinkSync(join("..", VERSION, "pkg", "fake-engine"), binPath());+ writeFileSync(join(engineDir(), VERSION, "pkg", "fake-engine"), "#!/bin/sh\necho changed\n");+ resetPathCacheForTests();+ registerStandaloneBinDirs(base, [release]);+ expect(findCliCandidates("fake-engine")).toEqual([]);+ });+ });+it("clears anything else out of bin/ when it installs, so only the program is on PATH", async () => {mkdirSync(binDir(), { recursive: true });writeFileSync(join(binDir(), "codex"), "#!/bin/sh\necho planted\n", { mode: 0o755 });diff --git a/server/engine-standalone.ts b/server/engine-standalone.tsindex f3004032e7..e6a85f56ac 100644--- a/server/engine-standalone.ts+++ b/server/engine-standalone.ts@@ -5,15 +5,16 @@//// tools/standalone/<engine>/// <version>/ what the archive held, plus its install record-// bin/<program> the only thing on PATH: a hard link to (or copy of) the current version's program+// bin/<program> the only thing on PATH: a hard link to (or copy of) the current version's program, or for a launcher+// (a program that runs the rest of its folder) a link to it inside that folder// current.json which version bin/ holds// bin/ goes on PATH after the person's own PATH and the vendors' default folders, so their own copy always wins.import { execFile } from "node:child_process";import { createHash, randomUUID } from "node:crypto";import {- closeSync, createReadStream, existsSync, lstatSync, openSync, readdirSync, readFileSync, readSync, realpathSync, renameSync, rmSync, unlinkSync,+ closeSync, createReadStream, existsSync, lstatSync, openSync, readdirSync, readFileSync, readlinkSync, readSync, realpathSync, renameSync, rmSync, unlinkSync,} from "node:fs";-import { chmod, copyFile, link, lstat, mkdir, open, readdir, rename, rm, stat, unlink, writeFile, type FileHandle } from "node:fs/promises";+import { chmod, copyFile, link, lstat, mkdir, open, readdir, rename, rm, stat, symlink, unlink, writeFile, type FileHandle } from "node:fs/promises";import { dirname, extname, isAbsolute, join, relative, resolve } from "node:path";import { stripVTControlCharacters } from "node:util";@@ -275,15 +276,31 @@ function verifiedCurrent(engineDir: string, release: StandaloneRelease): Standal// Nothing but the program goes on PATH; a rename Windows could not finish (.old-) is never a command anyone types.if (readdirSync(binDir).some((entry) => entry !== name && !entry.startsWith(OLD_PREFIX))) return null;const executablePath = join(binDir, name);- if (!realFile(executablePath)) return null;+ const program = release.launcher ? launcherTarget(executablePath, pointer.version, asset.executable) : executablePath;+ if (!program || !realFile(program)) return null;try {- if (hashFileSync(executablePath) !== expected) return null;+ if (hashFileSync(program) !== expected) return null;} catch {return null;}return { version: pointer.version, executablePath, binDir };}+/** bin/'s entry for a launcher is a link to exactly this version's program, written relative to bin/: anything else is+ * not the app's (a link elsewhere is never followed). */+function launcherLink(version: string, executable: string): string {+ return join("..", version, ...executable.split("/"));+}++function launcherTarget(entry: string, version: string, executable: string): string | null {+ try {+ if (!lstatSync(entry).isSymbolicLink() || readlinkSync(entry) !== launcherLink(version, executable)) return null;+ } catch {+ return null;+ }+ return join(dirname(entry), launcherLink(version, executable));+}+/** At boot: the bin/ folder of each engine this app pins, once its program is checked, goes on PATH after everything else. */export function registerStandaloneBinDirs(baseDir = DATA_DIR, releases: readonly StandaloneRelease[] = []): void {// Never through a link: a linked folder could lead to the person's own files.@@ -612,7 +629,10 @@ async function activate(engineDir: string, release: StandaloneRelease, asset: Stconst target = join(binDir, name);const fresh = join(binDir, `${NEW_PREFIX}${randomUUID()}${extname(name)}`);try {- try {+ if (release.launcher) {+ // A launcher finds the rest of its folder from where it really is, so bin/ links to it rather than holding a copy.+ await symlink(launcherLink(release.version, asset.executable), fresh);+ } else try {await link(source, fresh);} catch {// A file system without hard links gets a copy.diff --git a/server/harness/registry.test.ts b/server/harness/registry.test.tsindex 7a03e48ccb..872d8f0522 100644--- a/server/harness/registry.test.ts+++ b/server/harness/registry.test.ts@@ -668,6 +668,65 @@ process.exit(0);expect(await registry.installRuntime("a")).toBe(true);});+ // An install command pasted as the CLI path runs curl, which answers --version as curl: not the engine, not the person's+ // choice of copy. On a Cloud nobody could find Reset; the engine's own CLI takes over once it is installed.+ it("points a saved CLI path that runs another program at the app's own copy once it's installed", async () => {+ withFakeNpm(false);+ const base = join(scratch, "data");+ const bin = join(base, "tools", "standalone", "fake-engine", "bin");+ const fake = makeFakeDriver();+ fake.driver.defaultConfig = () => ({ cli: "fakebin" });+ Object.assign(fake.driver, { install: { standalone: standaloneRelease(standalonePlatformKey()) } });+ const registry = new ProviderRegistry([fake.driver], {+ enginesBaseDir: base,+ npmAvailable: () => false,+ installStandalone: async () => {+ mkdirSync(bin, { recursive: true });+ writeFileSync(join(bin, "fakebin"), "#!/bin/sh\necho 2.0.0\n", { mode: 0o755 });+ registerFallbackPathDir(bin);+ return { version: "2.0.0", executablePath: join(bin, "fakebin"), binDir: bin };+ },+ });+ await registry.load({ pasted: { driver: "fake", config: { cli: "curl https://example.test/install -fsS | bash" } } });+ Object.assign(registry.get("pasted")!, { snapshot: async () => ({ state: "unavailable", reason: "not fakebin's CLI", notEngineCli: true }) });+ expect(await registry.installRuntime("pasted")).toEqual({ useCli: join(bin, "fakebin") });+ });++ it("gives a saved CLI path that runs another program up for the engine's own installed CLI by itself, once", async () => {+ const own = withFakeNpm(false);+ const fake = makeFakeDriver();+ fake.driver.defaultConfig = () => ({ cli: "fakebin" });+ const healed: Array<[string, string]> = [];+ let release: () => void = () => {};+ const registry = new ProviderRegistry([fake.driver], { enginesBaseDir: join(scratch, "data"), npmAvailable: () => false });+ registry.onWrongCli((instanceId, cli) => { healed.push([instanceId, cli]); return new Promise<void>((resolve) => { release = resolve; }); });+ const notEngine = { state: "unavailable" as const, reason: "not fakebin's CLI", notEngineCli: true as const };+ await registry.load({ pasted: { driver: "fake", config: { cli: "curl https://example.test/install -fsS | bash" } }, missing: { driver: "fake" } });+ for (const id of ["pasted", "missing"]) Object.assign(registry.get(id)!, { snapshot: async () => notEngine });++ // Nothing of the engine's own is installed: the card offers the install instead.+ await registry.describe();+ expect(healed).toEqual([]);++ writeFileSync(join(own, "fakebin"), "#!/bin/sh\necho 2.0.0\n", { mode: 0o755 });+ resetPathCache();+ await registry.describe();+ await registry.describe({ reuse: { ms: 0, changed: () => {} } });+ // Only the saved path gives way, once while it runs; the default name has nothing to give way to.+ expect(healed).toEqual([["pasted", join(own, "fakebin")]]);+ release();+ // The healer reloads it with that CLI, as Set CLI would.+ await registry.dispose("pasted");++ // A path that answered for another reason (it did not start) stays the person's, and so does the very path the+ // engine's own name finds: giving it up for itself would only go round again.+ await registry.load({ broken: { driver: "fake", config: { cli: "/opt/elsewhere/fakebin" } }, found: { driver: "fake", config: { cli: join(own, "fakebin") } } });+ Object.assign(registry.get("broken")!, { snapshot: async () => ({ state: "unavailable", reason: "fakebin does not start" }) });+ Object.assign(registry.get("found")!, { snapshot: async () => notEngine });+ await registry.describe();+ expect(healed.map(([id]) => id)).toEqual(["pasted"]);+ });+it("lets a driver's own installer go first", async () => {withFakeNpm(false);const fake = makeFakeDriver();diff --git a/server/harness/registry.ts b/server/harness/registry.tsindex ce7f6eadcc..f689119b2a 100644--- a/server/harness/registry.ts+++ b/server/harness/registry.ts@@ -381,18 +381,42 @@ export class ProviderRegistry {private async appCopyAdvice(instanceId: InstanceId, driver: AnyProviderDriver, installed: StandaloneInstalled): Promise<{ useCli: string } | null> {const live = this.get(instanceId);const cli = cliDefaultOf(driver);- // A CLI the person set with Set CLI is theirs to change; only the default name gets pointed elsewhere.+ // A CLI the person set with Set CLI is theirs to change, unless it runs another program altogether (an install+ // command pasted as the path); otherwise only the default name gets pointed elsewhere.const configured = this.cliByInstance.get(instanceId);- if (configured !== undefined && configured !== cli) return null;- if (!live || !cli || !installed.executablePath || this.appStandaloneCopy(driver, cli)) return null;+ const theirs = configured !== undefined && configured !== cli;+ if (!live || !cli || !installed.executablePath || (!theirs && this.appStandaloneCopy(driver, cli))) return null;this.forgetSnapshots();- let state: ProviderSnapshot["state"];+ let snapshot: ProviderSnapshot;try {- state = (await live.snapshot()).state;+ snapshot = await live.snapshot();} catch {- state = "unavailable";+ snapshot = { state: "unavailable" };}- return state === "available" ? null : { useCli: installed.executablePath };+ if (snapshot.state === "available" || (theirs && snapshot.notEngineCli !== true)) return null;+ return { useCli: installed.executablePath };+ }++ /** Set by the instance routes: points an engine whose saved CLI path runs another program at its own installed CLI, as+ * Set CLI would, and reloads it. */+ private cliHealer: ((instanceId: InstanceId, cli: string) => Promise<unknown>) | null = null;+ private healing = new Set<InstanceId>();+ onWrongCli(heal: (instanceId: InstanceId, cli: string) => Promise<unknown>): void {+ this.cliHealer = heal;+ }++ /** A saved CLI path that answered as another program, while the engine's own CLI is installed (the app's copy, or one+ * on PATH): the engine runs its own instead, with nobody having to Reset the path. */+ private healWrongCli(instanceId: InstanceId, snapshot: ProviderSnapshot): void {+ const driver = this.driversByKind.get(this.byId.get(instanceId)?.live?.driverKind ?? "");+ const cli = cliDefaultOf(driver);+ const saved = this.cliByInstance.get(instanceId);+ if (snapshot.notEngineCli !== true || !this.cliHealer || !cli || saved === undefined || saved === cli || this.healing.has(instanceId)) return;+ const own = findCliCandidates(cli, driver?.install?.standalone ? standaloneLookupPath(this.enginesBaseDir) : undefined)[0];+ // The path found is the one already saved: it is that one that answers as another program.+ if (!own || own === saved) return;+ this.healing.add(instanceId);+ void this.cliHealer(instanceId, own).catch(() => {}).finally(() => this.healing.delete(instanceId));}/** Whether this engine's CLI runs the app's own standalone copy, looked up the way its spawns look it up. */@@ -431,6 +455,7 @@ export class ProviderRegistry {this.lastSnapshots.set(instance.instanceId, snapshot);this.unread?.delete(instance.instanceId);this.saveStatus();+ this.healWrongCli(instance.instanceId, snapshot);}return snapshot;}diff --git a/server/routes/instances.ts b/server/routes/instances.tsindex d1292f2f85..6d75c577e1 100644--- a/server/routes/instances.ts+++ b/server/routes/instances.ts@@ -28,7 +28,7 @@ import { PASS, type RouteHandler } from "./table.ts";export interface InstanceRouteDeps {store: Pick<Store, "bots" | "tasks">;cfg: AppConfig;- registry: Pick<ProviderRegistry, "get" | "refreshModels" | "installRuntime" | "cliTarget" | "forgetSnapshots">;+ registry: Pick<ProviderRegistry, "get" | "refreshModels" | "installRuntime" | "cliTarget" | "forgetSnapshots" | "onWrongCli">;sessions: Pick<SessionRegistry, "isLive">;providerAuthSessions: Pick<ProviderAuthSessions, "status" | "start" | "revokeOwner" | "signOut" | "complete" | "cancel">;hostedModels: boolean;@@ -81,6 +81,9 @@ export function createInstanceRoutes(deps: InstanceRouteDeps): RouteHandler {providerConfigBusy.set(false);}};+ // A saved CLI path that runs another program (an install command pasted as the path) gives way to the engine's own CLI+ // once one is installed, by itself: nobody has to find Reset.+ registry?.onWrongCli?.((instanceId, cli) => useAppCopy(instanceId, cli));// One updater per executable: Claude instances can share an install, and two self-updates would race its files.const claudeUpdatesInFlight = new Set<string>();return async ({ req, res, url, path, method, auth, json, readBody }) => {diff --git a/server/standalone-releases.ts b/server/standalone-releases.tsindex 1566c7dbcb..d47549de43 100644--- a/server/standalone-releases.ts+++ b/server/standalone-releases.ts@@ -1,6 +1,7 @@// Every AI build the app can install itself. Only these are put on PATH at start-up: a folder under tools/standalone// that no release here names is never trusted.import type { StandaloneRelease } from "./contracts.ts";+import { CURSOR_STANDALONE } from "./drivers/acp/cursor-release.ts";import { OPENCODE_STANDALONE } from "./drivers/acp/opencode-release.ts";-export const STANDALONE_RELEASES: readonly StandaloneRelease[] = [OPENCODE_STANDALONE];+export const STANDALONE_RELEASES: readonly StandaloneRelease[] = [OPENCODE_STANDALONE, CURSOR_STANDALONE];diff --git a/src/components/EngineSetup.cursor.test.ts b/src/components/EngineSetup.cursor.test.tsnew file mode 100644index 0000000000..b0dc3ade9c--- /dev/null+++ b/src/components/EngineSetup.cursor.test.ts@@ -0,0 +1,88 @@+// @vitest-environment happy-dom+// Cursor's card, and any engine's, on a Cloud: no terminal there, so nothing to copy and no CLI path to set; the app+// installs Cursor itself, then signs it in with a link.+import { createElement } from "react";+import { flushSync } from "react-dom";+import { createRoot, type Root } from "react-dom/client";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";++import { setLocale } from "@/lib/i18n";+import { BotEditorStore, type InstanceInfo, type useStore } from "@/state/store";+import { EngineSetup } from "./EngineSetup";++const CURL = "curl https://cursor.com/install -fsS | bash";+const cursor = (snapshot: InstanceInfo["snapshot"], server = true): InstanceInfo => ({+ instanceId: "cursor", driverKind: "cursorAgent", displayName: "Cursor",+ models: { default: "auto", options: [] }, snapshot,+ authentication: { method: "device-code", signOut: false },+ install: {+ command: { darwin: CURL, linux: CURL }, signInCommand: "cursor-agent login", platform: "linux", docsUrl: "https://cursor.com/docs/cli/installation",+ ...(server ? { server: { standalone: { version: "2026.10.22-27dcf5f", downloadBytes: 184_859_176 } } } : {}),+ },+});+const missing = { state: "unavailable" as const, reason: "`cursor-agent` isn't installed, or isn't on this app's PATH. Install it for the user running OpenMausBot or use Set CLI, then check again." };+const pasted = { state: "unavailable" as const, reason: `\`${CURL}\` is not Cursor's CLI: it answered --version as another program.`, notEngineCli: true as const };++let host: HTMLDivElement;+let root: Root;+function render(engine: InstanceInfo, cloudHome: boolean): string {+ vi.stubGlobal("ogb", undefined);+ const store = { state: { config: cloudHome ? { cloudHome: true } : {} }, dispatch: vi.fn(), refreshInstances: vi.fn(), refreshModels: vi.fn() } as unknown as ReturnType<typeof useStore>;+ flushSync(() => root.render(createElement(BotEditorStore, { value: store, children: createElement(EngineSetup, { instance: engine }) })));+ return host.innerHTML;+}++beforeEach(() => {+ setLocale("en");+ host = document.createElement("div");+ document.body.append(host);+ root = createRoot(host);+});+afterEach(() => {+ flushSync(() => root.unmount());+ host.remove();+ vi.unstubAllGlobals();+});++describe("Cursor on a Cloud", () => {+ it.each([["not installed", missing], ["a CLI path that runs another program", pasted]] as const)("offers the app's own install when %s, never a command or a CLI path", (_case, snapshot) => {+ const html = render(cursor(snapshot), true);+ expect(html).toContain("Install Cursor here");+ expect(html).toContain("About 185 MB download.");+ // The pasted path is named once, in why it isn't Cursor; never as a command to copy.+ expect(html.split(CURL).length - 1).toBe("notEngineCli" in snapshot ? 1 : 0);+ expect(html).not.toContain("Set CLI");+ expect(html).not.toContain("Copy command");+ expect(html).not.toContain("computer running");+ });++ it("says the CLI path runs another program, so the person knows why, without asking them to fix it by hand", () => {+ const html = render(cursor(pasted), true);+ expect(html).toContain("is not Cursor's CLI");+ expect(html).not.toContain("Reset");+ });++ it("signs in with Cursor's link once installed", () => {+ const html = render(cursor({ state: "available", authenticated: false, version: "2026.10.22-27dcf5f" }), true);+ expect(html).toContain("Sign in to Cursor");+ expect(html).not.toContain("cursor-agent login");+ });+});++describe("an engine a Cloud can't install", () => {+ it("says so in one line: no command to copy, no CLI path to set, no terminal guide", () => {+ const html = render(cursor(missing, false), true);+ expect(html).toContain("Cursor can’t be installed on your Cloud yet. Choose another AI in the model picker.");+ expect(html).not.toContain(CURL);+ expect(html).not.toContain("Set CLI");+ expect(html).not.toContain("computer running");+ expect(html).not.toContain("View setup guide");+ });++ it("keeps the command and the hints on a computer with a terminal", () => {+ const html = render(cursor(missing, false), false);+ expect(html).toContain(CURL);+ expect(html).toContain("Set CLI");+ expect(html).not.toContain("can’t be installed on your Cloud");+ });+});diff --git a/src/components/EngineSetup.tsx b/src/components/EngineSetup.tsxindex e078f11307..9da0ea7da4 100644--- a/src/components/EngineSetup.tsx+++ b/src/components/EngineSetup.tsx@@ -525,6 +525,10 @@ export function EngineSetup({const installCommand = installCommandFor(install);const signInCommand = install?.signInCommand;const signInOnly = intent === "cloud" && needsSignIn(instance);+ /** On a Cloud, an engine the app can't install there and that isn't installed: nothing the person can run will. */+ const cloudCantInstall = cloudHome && !signInOnly && needsCli(instance) && !install?.server && !install?.managed;+ /** A Cloud's "not installed" reason only says to install it in a terminal or use Set CLI; the card says what to do instead. */+ const cloudReasonHidden = cloudCantInstall || (cloudHome && !signInOnly && Boolean(install?.server) && instance.snapshot.notEngineCli !== true);const deviceSignIn = signInOnly && instance.authentication?.method === "device-code";const browserSignIn = signInOnly && instance.authentication?.method === "browser-pkce";const pasteSignIn = signInOnly && instance.authentication?.method === "paste-code";@@ -599,7 +603,7 @@ export function EngineSetup({</div></div>- {instance.snapshot.state === "unavailable" && instance.snapshot.reason && (quiet ? (+ {instance.snapshot.state === "unavailable" && instance.snapshot.reason && !cloudReasonHidden && (quiet ? (<details data-engine-setup-reason className="mt-2 text-[12px] leading-4 text-ink-tertiary"><summary className="cursor-pointer select-none hover:text-ink-secondary">{t("engineSetup.details")}</summary><p className="mt-1 whitespace-pre-wrap">{instance.snapshot.reason}</p>@@ -626,6 +630,11 @@ export function EngineSetup({<ServerEngineInstall instance={instance} mode="install" command={installCommand} />) : install.managed ? (<ManagedEngineSetup instance={instance} signInOnly={signInOnly} />+ ) : cloudCantInstall ? (+ // A Cloud has no terminal: a command to copy, or a path to set, only invites pasting it where it can't run.+ <p data-cloud-cant-install className="mt-3 rounded-lg bg-inset px-2.5 py-2 text-[12px] leading-relaxed text-ink-secondary">+ {t("engineSetup.cloudCantInstall", { name: instance.displayName })}+ </p>) : command ? (<CommandRowcommand={command}@@ -650,13 +659,13 @@ export function EngineSetup({{(install.command || signInCommand) && !deviceSignIn && !browserSignIn && !pasteSignIn && !install.managed && (<div className="mt-3 border-t border-hairline/40 pt-2">- <p className="mb-1 text-[12px] leading-relaxed text-ink-secondary">{t("engineSetup.sameMachine")}</p>- {needsCli(instance) && <p className="mb-1 text-[12px] leading-relaxed text-ink-secondary">{t("engineSetup.pathHint")}</p>}+ {!cloudHome && <p className="mb-1 text-[12px] leading-relaxed text-ink-secondary">{t("engineSetup.sameMachine")}</p>}+ {!cloudHome && needsCli(instance) && <p className="mb-1 text-[12px] leading-relaxed text-ink-secondary">{t("engineSetup.pathHint")}</p>}<RefreshEngines key={instance.instanceId} /></div>)}- {install.docsUrl && (+ {install.docsUrl && !cloudCantInstall && (<ahref={install.docsUrl}target="_blank"diff --git a/src/locales/en.json b/src/locales/en.jsonindex e7e4477921..d9cb38261f 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -3249,6 +3249,7 @@"engineSetup.setupTitle": "Set up {name}","engineSetup.terminalSignInCheck": "Installed. Finish signing in to your account in Terminal, then choose Check again.","engineSetup.sameMachine": "Install and sign in on the computer running {app}, as the same user. On a remote connection, that means the machine it runs on, not this device. Then choose Check again. No app restart needed.",+ "engineSetup.cloudCantInstall": "{name} can’t be installed on your Cloud yet. Choose another AI in the model picker.","engineSetup.pathHint": "Already installed but still not detected? In Settings → Model providers and accounts, expand CLI path and updates and use Set CLI to choose the executable.","engineSetup.checkFailed": "Could not refresh provider status. The previous status is still shown. {reason}","engineSetup.checked": "Provider status refreshed.",diff --git a/src/state/store.tsx b/src/state/store.tsxindex 771c9a8e3f..52fd4822f4 100644--- a/src/state/store.tsx+++ b/src/state/store.tsx@@ -467,7 +467,7 @@ export interface InstanceInfo {snapshot: {state: "available" | "unavailable";reason?: string;- authenticated?: boolean;+ authenticated?: boolean; /** The CLI path runs another program, not this engine's CLI. */ notEngineCli?: true;chatgptPlan?: boolean;/** Ready only through OpenCode's free no-login models: a backup, never "an AI already works". */freeFallback?: boolean;