Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Cursor on a Cloud: its CLI path must run Cursor, and it signs in from the card with a link
milind-soni18910a105c9c
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.ymlindex dfa2506adc..cd37742160 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.+ # throwaway home left in the image, and Cursor's build is root's alone.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))/")+ cache = re.compile(r"^(root/\.npm|tmp/(npm-cache|omb-build-home|node-compile-cache|grok-install|cursor-install))/")for path in sys.argv[1:]:files = {}with tarfile.open(path) as image:@@ -388,6 +388,12 @@ 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 f429fbb563..58bf7e90f7 100644--- a/Dockerfile+++ b/Dockerfile@@ -151,6 +151,31 @@ 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 cd93634e5b..c722fbd8db 100644--- a/docs/cursor.md+++ b/docs/cursor.md@@ -21,8 +21,13 @@ key.On Windows, OpenMausBot does not spawn cursor-agent.cmd (Node rejects a .cmd). It starts the powershell.exe -File launch from that shim’s sibling cursor-agent.ps1. After installing from the terminal, use Refresh engines so the version check runs again.-2. Sign in with `cursor-agent login`, or set `CURSOR_API_KEY` / `CURSOR_AUTH_TOKEN`- in the environment of the Cursor instance.+2. Sign in from Cursor's card in the app (**Sign in to Cursor**), or with `cursor-agent login`+ in a terminal, or set `CURSOR_API_KEY` / `CURSOR_AUTH_TOKEN` in the environment of the+ Cursor instance. The card runs `cursor-agent login` where OpenMausBot runs, with+ `NO_OPEN_BROWSER` set, and shows the one link Cursor prints+ (`https://cursor.com/loginDeepControl?…`): open it on any device and sign in, and the+ CLI where the bots run finishes the sign-in. Only a cursor.com sign-in link carrying+ Cursor's request (`challenge`, `uuid` and its own flags) is ever shown.3. Confirm `cursor-agent --version` works. Cursor's docs call the command `agent`;the installer adds `cursor-agent` beside it, and OpenMausBot runs that name,@@ -31,8 +36,23 @@ key.OpenMausBot already looks in both, so a CLI installed while the app is openis found without restarting.-The engine stays unavailable until the `cursor-agent` executable is found. A-missing login shows as unauthenticated rather than crashing the fleet.+The engine stays unavailable until the `cursor-agent` executable is found, and+until 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+unauthenticated 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.## Modelsdiff --git a/server/cli-probe.ts b/server/cli-probe.tsindex 26c771ba95..499227bab5 100644--- a/server/cli-probe.ts+++ b/server/cli-probe.ts@@ -2,6 +2,7 @@import { PROVIDER_CREDENTIAL_ENV, stripWorkspaceCredentialEnv } from "./config.ts";import { clientInstall } from "./contracts.ts";import type { BUILT_IN_DRIVERS } from "./drivers/builtIn.ts";+import { notThisCli } from "./drivers/acp/version-probe.ts";import { augmentedPath } from "./env-path.ts";import { describeSpawnFailure, execCli } from "./procs.ts";@@ -36,7 +37,11 @@ export async function testCliBinary(resolve({ ok: false, message, ...(driver?.install && isSpawnError ? { install: clientInstall(driver.install) } : {}) });return;}- resolve({ ok: true, version: stdout.trim().split("\n")[0] });+ const version = stdout.trim().split("\n")[0];+ // An install command pasted as the path runs curl, which answers --version too: that is not this engine.+ const expected = driver?.metadata.cliVersion;+ if (expected && !expected.test(version)) return resolve({ ok: false, message: notThisCli(cli, driver.metadata.displayName) });+ resolve({ ok: true, version });},);});diff --git a/server/contracts.ts b/server/contracts.tsindex f20594f396..a42d5ad348 100644--- a/server/contracts.ts+++ b/server/contracts.ts@@ -574,6 +574,8 @@ export interface ProviderDriver<Config = unknown> {displayName: string;supportsMultipleInstances?: boolean;access?: EngineAccess;+ /** What the engine's own CLI answers to `--version`; another answer means the CLI path runs another program. */+ cliVersion?: RegExp;};/** Omit for engines that need no local binary (API-key drivers). */readonly install?: EngineInstall;diff --git a/server/drivers/acp/core.ts b/server/drivers/acp/core.tsindex aea8e2d8f0..a92ff5dcf3 100644--- a/server/drivers/acp/core.ts+++ b/server/drivers/acp/core.ts@@ -26,7 +26,7 @@ import {} from "./quiet-status.ts";import { readSessionReport } from "./session-reports.ts";import { pickSessionModel, SessionModelControls, type AcpModelSelection } from "./session-model-controls.ts";-import { versionFromProbe } from "./version-probe.ts"; import { engineHomes } from "../../engine-homes/engine-homes.ts";+import { notThisCli, versionFromProbe } from "./version-probe.ts"; import { engineHomes } from "../../engine-homes/engine-homes.ts";export function skipSubscriptionAuthForLocalInject(model: string | undefined): boolean {return Boolean(decodeInjectId(model));@@ -92,7 +92,7 @@ export interface AcpSupport {/** Existing native restrictions also participate in scoped session reuse. */toolScopeCacheKey?(context: { config: AcpConfig; env: Record<string, string | undefined>; cwd: string }): string;driverKind: string;- displayName: string;+ displayName: string; /** What this CLI's own `--version` looks like: any other answer is another program behind the CLI path. */ cliVersion?: RegExp;/** Omit for subscription CLIs. Custom-only CLIs have no first-party cloud catalog. */access?: "subscription" | "custom";models: ModelCatalog;@@ -314,7 +314,7 @@ export function createAcpDriver(support: AcpSupport): ProviderDriver<AcpConfig>metadata: {displayName: support.displayName,supportsMultipleInstances: true,- access: support.access ?? "subscription",+ access: support.access ?? "subscription", ...(support.cliVersion ? { cliVersion: support.cliVersion } : {}),},install: support.install,models: support.models,@@ -1604,7 +1604,8 @@ export function createAcpDriver(support: AcpSupport): ProviderDriver<AcpConfig>return;}const version = versionFromProbe(stdout, stderr);- resolve(version ? { version } : { reason: `\`${config.cli}\` returned no version. Check the configured executable with --version, then try again.` });+ 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 });});});if (!probe.version) return { state: "unavailable", reason: probe.reason };diff --git a/server/drivers/acp/cursor-sign-in.test.ts b/server/drivers/acp/cursor-sign-in.test.tsnew file mode 100644index 0000000000..5287031c7d--- /dev/null+++ b/server/drivers/acp/cursor-sign-in.test.ts@@ -0,0 +1,182 @@+// Cursor on a server with no terminal (a Cloud): the CLI path must really run Cursor's CLI, and the sign-in runs where the+// bots run, from the app, with the link Cursor prints. Every process here is the offline fake in a disposable HOME.+import { chmodSync, existsSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";+import { tmpdir } from "node:os";+import { join } from "node:path";+import { fileURLToPath } from "node:url";+import { afterEach, beforeEach, describe, expect, it } from "vitest";+import { deviceSignInHasCode, deviceSignInLink, deviceSignInPrompt, isDeviceSignInCode } from "../../../shared/device-sign-in.ts";+import { testCliBinary } from "../../cli-probe.ts";+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";++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";+// cursor-agent 2026.10.22's own stdout for `login` with NO_OPEN_BROWSER.+const printed = (link: string) => ["Starting login process...", "Authenticating with Cursor...", "Waiting for browser authentication...", `Open a browser and navigate to this link: ${link}`, ""].join("\n");+// What curl 7.88.1 on the Cloud image prints for `curl https://cursor.com/install -fsS | bash --version`, which is what an+// install command pasted as the CLI path runs: curl's own --version wins over its other arguments.+const CURL = "curl 7.88.1 (x86_64-pc-linux-gnu) libcurl/7.88.1 OpenSSL/3.0.22 zlib/1.2.13 brotli/1.0.9 zstd/1.5.4\nRelease-Date: 2023-02-20, security patched: 7.88.1-10+deb12u15";++describe("which program answers as Cursor", () => {+ it("knows Cursor's own build number from curl's banner and other programs", () => {+ expect(CURSOR_CLI_VERSION.test("2026.10.22-27dcf5f")).toBe(true);+ expect(CURSOR_CLI_VERSION.test("2025.08.25-896bbe1\n")).toBe(true);+ for (const other of [CURL, "grok 1.0.41 (4220f3b224a6)", "2.1.284 (Claude Code)", "codex-cli 0.130.0", ""]) expect(CURSOR_CLI_VERSION.test(other), other).toBe(false);+ });+});++describe.skipIf(process.platform === "win32")("Cursor's CLI path", () => {+ let home: string;+ const instances: ProviderInstance[] = [];+ beforeEach(() => {+ chmodSync(FAKE_CURSOR, 0o755);+ home = mkdtempSync(join(tmpdir(), "omb-cursor-path-"));+ });+ afterEach(async () => {+ await Promise.all(instances.splice(0).map((instance) => instance.dispose()));+ await removeTempDir(home);+ });+ const cursor = async (cli: string, mode = "approve") => {+ const instance = await CursorAgentDriver.create({+ instanceId: "cursor", displayName: "Cursor", enabled: true, config: CursorAgentDriver.decodeConfig({ cli }),+ environment: { HOME: home, USERPROFILE: home, OMB_DEVICE_AUTH_FIXTURE: "1", FAKE_CURSOR_MODE: mode },+ });+ instances.push(instance);+ return instance;+ };++ it("is unavailable, and says why, when the path runs another program that answers --version", async () => {+ // A script that prints curl's banner stands in for curl, which an install command pasted as the path runs.+ const pasted = join(home, "curl-banner.sh");+ writeFileSync(pasted, `#!/bin/sh\nprintf '%s\\n' ${JSON.stringify(CURL)}\n`, { mode: 0o755 });+ const snapshot = await (await cursor(pasted)).snapshot();+ expect(snapshot.state).toBe("unavailable");+ expect(snapshot).not.toHaveProperty("version");+ expect(snapshot.reason).toContain("is not Cursor's CLI");+ expect(snapshot.reason).toContain("Reset");+ });++ it("is available, signed out until the sign-in, when the path runs Cursor's CLI", async () => {+ expect(await (await cursor(FAKE_CURSOR)).snapshot()).toEqual({ state: "available", version: "2026.10.22-27dcf5f", authenticated: false });+ });++ it("does not pass Settings' CLI test with another program's version", async () => {+ const pasted = join(home, "curl-banner.sh");+ writeFileSync(pasted, `#!/bin/sh\nprintf '%s\\n' ${JSON.stringify(CURL)}\n`, { mode: 0o755 });+ const result = await testCliBinary(pasted, CursorAgentDriver);+ expect(result.ok).toBe(false);+ expect(result.message).toContain("is not Cursor's CLI");+ const real = join(home, "cursor-agent");+ writeFileSync(real, "#!/bin/sh\necho 2026.10.22-27dcf5f\n", { mode: 0o755 });+ expect(await testCliBinary(real, CursorAgentDriver)).toEqual({ ok: true, version: "2026.10.22-27dcf5f" });+ });+});++describe("Cursor's sign-in link", () => {+ it("reads the one link Cursor prints, with no code to enter", () => {+ expect(deviceSignInHasCode("cursor")).toBe(false);+ expect(deviceSignInPrompt("cursor", printed(LINK))).toEqual({ authorizationUrl: LINK });+ expect(deviceSignInLink("cursor", LINK)).toBe(LINK);+ expect(isDeviceSignInCode("cursor", "QKXP-7M4D")).toBe(false);+ });++ it("waits for the link line to arrive whole", () => {+ expect(deviceSignInPrompt("cursor", printed(LINK).trimEnd())).toBeNull();+ });++ it.each([+ "http://cursor.com/loginDeepControl?challenge=Jx1fQ3-Vq8kP0Yb_5rT2aWm7nC4dE6gH9iL0oS1uZ2y&uuid=3f2b8c1d-4e5a-4b6c-8d7e-9f0a1b2c3d4e",+ "https://cursor.com.evil.test/loginDeepControl?challenge=Jx1fQ3-Vq8kP0Yb_5rT2aWm7nC4dE6gH9iL0oS1uZ2y&uuid=3f2b8c1d-4e5a-4b6c-8d7e-9f0a1b2c3d4e",+ "https://[email protected]/loginDeepControl?challenge=Jx1fQ3-Vq8kP0Yb_5rT2aWm7nC4dE6gH9iL0oS1uZ2y&uuid=3f2b8c1d-4e5a-4b6c-8d7e-9f0a1b2c3d4e",+ "https://cursor.com/settings?challenge=Jx1fQ3-Vq8kP0Yb_5rT2aWm7nC4dE6gH9iL0oS1uZ2y&uuid=3f2b8c1d-4e5a-4b6c-8d7e-9f0a1b2c3d4e",+ "https://cursor.com/loginDeepControl?challenge=Jx1fQ3-Vq8kP0Yb_5rT2aWm7nC4dE6gH9iL0oS1uZ2y&uuid=3f2b8c1d-4e5a-4b6c-8d7e-9f0a1b2c3d4e&token=secret-token",+ "https://cursor.com/loginDeepControl?mode=login",+ "https://cursor.com/loginDeepControl?challenge=Jx1fQ3-Vq8kP0Yb_5rT2aWm7nC4dE6gH9iL0oS1uZ2y&uuid=3f2b8c1d-4e5a-4b6c-8d7e-9f0a1b2c3d4e#frag",+ ])("never turns another address into a sign-in link: %s", (link) => {+ expect(deviceSignInPrompt("cursor", printed(link))).toBeNull();+ expect(deviceSignInLink("cursor", link)).toBeNull();+ });++ it("reads Cursor's status answer", () => {+ expect(readCursorStatus(0, '{\n "status": "unauthenticated",\n "isAuthenticated": false\n}\n')).toBe("signed-out");+ expect(readCursorStatus(0, '{"status":"authenticated","isAuthenticated":true}')).toBe("signed-in");+ expect(readCursorStatus(1, '{"isAuthenticated":true}')).toBe("unknown");+ expect(readCursorStatus(0, "something else")).toBe("unknown");+ });+});++describe.skipIf(process.platform === "win32")("Cursor sign-in from the app, where the bots run", () => {+ let home: string;+ let instance: ProviderInstance;+ const calls = () => readFileSync(join(home, "fake-cursor-calls.jsonl"), "utf8").trim().split("\n").map((line) => JSON.parse(line));+ const pid = () => Number(readFileSync(join(home, "fake-cursor-login.pid"), "utf8"));+ const alive = (target: number) => { try { process.kill(target, 0); return true; } catch { return false; } };+ beforeEach(async () => {+ chmodSync(FAKE_CURSOR, 0o755);+ home = mkdtempSync(join(tmpdir(), "omb-cursor-sign-in-"));+ instance = await CursorAgentDriver.create({+ instanceId: "cursor", displayName: "Cursor", enabled: true, config: CursorAgentDriver.decodeConfig({ cli: FAKE_CURSOR }),+ environment: { HOME: home, USERPROFILE: home, OMB_DEVICE_AUTH_FIXTURE: "1", FAKE_CURSOR_MODE: "approve" },+ });+ });+ afterEach(async () => {+ await instance.dispose();+ await removeTempDir(home);+ });++ it("offers it as a sign-in from the app, with no terminal", () => {+ expect(instance.startAuthentication).toBeTypeOf("function");+ expect(instance.getAuthentication).toBeTypeOf("function");+ expect(instance.completeAuthentication).toBeUndefined();+ });++ it("shows Cursor's link, then confirms the sign-in the driver's own check reads once the person finishes it", async () => {+ expect((await instance.snapshot()).authenticated).toBe(false);+ const start = await instance.startAuthentication!();+ expect(start).toEqual({ phase: "waiting", flowId: expect.stringMatching(/^[0-9a-f-]{36}$/), authorizationUrl: LINK, expiresAt: expect.any(String) });+ // The login never tries to open a browser on the server.+ expect(calls().find((call) => call.args[0] === "login")).toEqual({ args: ["login"], noOpenBrowser: "1" });+ expect(await instance.getAuthentication!(start.flowId!)).toMatchObject({ phase: "waiting", authorizationUrl: LINK });+ writeFileSync(join(home, ".omb-fake-cursor-approved"), "");+ await expect.poll(async () => (await instance.getAuthentication!(start.flowId!)).phase, { timeout: 5_000 }).toBe("succeeded");+ expect(existsSync(join(home, ".config", "cursor", "auth.json"))).toBe(true);+ expect((await instance.snapshot()).authenticated).toBe(true);+ });++ it("cancels: the login stops and the link is gone", async () => {+ const start = await instance.startAuthentication!();+ expect(alive(pid())).toBe(true);+ await instance.cancelAuthentication!();+ expect(alive(pid())).toBe(false);+ expect(await instance.getAuthentication!(start.flowId!)).toMatchObject({ phase: "cancelled", authorizationUrl: null });+ });++ it.each([["evil"], ["extra"]])("shows no link from a %s address, and gives up waiting for one", async (mode) => {+ const controller = new DeviceAuthController(CURSOR_SIGN_IN, {+ cli: FAKE_CURSOR, startupTimeoutMs: 1_000, terminateTimeoutMs: 50,+ environment: () => ({ ...process.env, HOME: home, OMB_DEVICE_AUTH_FIXTURE: "1", FAKE_CURSOR_MODE: mode }),+ });+ try {+ await expect(controller.start()).rejects.toThrow("Cursor did not provide a sign-in code in time");+ await controller.cancel();+ expect(alive(pid())).toBe(false);+ } finally { await controller.dispose(); }+ });++ it("never repeats the CLI's own words when the login fails", async () => {+ const controller = new DeviceAuthController(CURSOR_SIGN_IN, {+ cli: FAKE_CURSOR, startupTimeoutMs: 2_000, terminateTimeoutMs: 50,+ environment: () => ({ ...process.env, HOME: home, OMB_DEVICE_AUTH_FIXTURE: "1", FAKE_CURSOR_MODE: "crash" }),+ });+ try {+ const start = await controller.start();+ await expect.poll(async () => (await controller.get(start.flowId!)).phase, { timeout: 5_000 }).toBe("failed");+ const status = await controller.get(start.flowId!);+ expect(status.message).toBe("Cursor sign-in did not finish. Check the server's connection, then try again.");+ expect(JSON.stringify(status)).not.toContain("secret-token");+ } finally { await controller.dispose(); }+ });+});diff --git a/server/drivers/acp/cursor.test.ts b/server/drivers/acp/cursor.test.tsindex 5e3dc4912e..7733cf06f1 100644--- a/server/drivers/acp/cursor.test.ts+++ b/server/drivers/acp/cursor.test.ts@@ -2,7 +2,7 @@ import { chmodSync, existsSync, mkdtempSync, readFileSync } from "node:fs";import { tmpdir } from "node:os";import { dirname, join } from "node:path";import { fileURLToPath } from "node:url";-import { afterEach, describe, expect, it, vi } from "vitest";+import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from "vitest";import type { RuntimeEvent } from "../../contracts.ts";import { ensureDirs } from "../../config.ts";@@ -135,6 +135,9 @@ describe("classifyCursorError", () => {describe("CursorAgentDriver", () => {const scratchDirs: string[] = [];+ // The fake answers --version the way cursor-agent does: another answer is another program behind the CLI path.+ beforeAll(() => { process.env.FAKE_ACP_VERSION = "2026.10.22-27dcf5f"; });+ afterAll(() => { delete process.env.FAKE_ACP_VERSION; });afterEach(async () => {delete process.env.FAKE_ACP_DUMP;diff --git a/server/drivers/acp/cursor.ts b/server/drivers/acp/cursor.tsindex 7978922c32..da419a60f9 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 type { DeviceSignIn, DeviceSignInState } from "../device-auth.ts";import { discoverAcpModels } from "./custom-model-catalog.ts";import type { AcpQuestionRequest } from "./question-requests.ts";import {@@ -313,6 +314,38 @@ export async function probeCursorAuth(return false;}+/** `cursor-agent --version` prints its build alone (`2026.10.22-27dcf5f`); curl, run by an install command pasted as+ * the CLI path, answers `curl 7.88.1 (x86_64-pc-linux-gnu) …`. */+export const CURSOR_CLI_VERSION = /^\d{4}\.\d{1,2}\.\d{1,2}(?:-[0-9a-z]+)?\s*$/i;++/** `cursor-agent status --format json` (2026.10.22): `{"status":"unauthenticated","isAuthenticated":false,…}`. */+export function readCursorStatus(code: number | null, output: string): DeviceSignInState {+ const signedIn = code === 0 ? decodeCursorAuthStatus(firstJsonValue(output)) : null;+ return signedIn === true ? "signed-in" : signedIn === false ? "signed-out" : "unknown";+}++/** Never the CLI's own words: its output carries the sign-in request. */+function cursorLoginFailure(output: string): string {+ if (/expired|timed? ?out/i.test(output)) return "The Cursor sign-in link expired. Start sign-in again for a new link.";+ return "Cursor sign-in did not finish. Check the server's connection, then try again.";+}++/** `cursor-agent login` where the bots run: on a server it cannot open a browser, so it prints the link that finishes+ * the sign-in (NO_OPEN_BROWSER keeps it from trying) and waits; the person opens that link on any device. The login lands+ * in the server account's own Cursor home, which turns read. */+export const CURSOR_SIGN_IN: DeviceSignIn = {+ provider: "cursor",+ product: "Cursor",+ account: "Cursor",+ homeEnv: "CURSOR_CONFIG_DIR",+ homeDir: ".cursor",+ loginArgs: ["login"],+ env: { NO_OPEN_BROWSER: "1" },+ install: "Install Cursor's CLI (https://cursor.com/docs/cli/installation) for the user running OpenMausBot, then try again.",+ failure: cursorLoginFailure,+ status: { args: ["status", "--format", "json"], read: readCursorStatus },+};+export function cursorCatalogFromSession(advertised: ModelCatalog["options"]): ModelCatalog | null {const discovered: ModelCatalog["options"] = [];const bases = new Set<string>();@@ -440,11 +473,14 @@ const support = (run: typeof execCli): AcpSupport => ({driverKind: "cursorAgent",questionRequests: { "cursor/ask_question": CURSOR_ASK_QUESTION }, askTool: "AskQuestion",displayName: "Cursor",+ cliVersion: CURSOR_CLI_VERSION,models: STATIC_CURSOR_MODELS,// Other coding agents can install a generic `agent` shim; `cursor-agent` is unambiguous.defaultCli: "cursor-agent",nativeSource: "cursor.acp",- loginNote: "Cursor CLI is not signed in — run `cursor-agent login` in a terminal, or set CURSOR_API_KEY",+ // Turns read this too: the sign-in runs where the bots run, from the app, never on the person's own computer.+ loginNote: "Cursor is not signed in where your bots run. Choose Cursor in the model picker and sign in from its card, or set CURSOR_API_KEY.",+ deviceSignIn: CURSOR_SIGN_IN,install: {command: {diff --git a/server/drivers/acp/version-probe.ts b/server/drivers/acp/version-probe.tsindex 3989c90378..e3e2c658af 100644--- a/server/drivers/acp/version-probe.ts+++ b/server/drivers/acp/version-probe.ts@@ -8,6 +8,12 @@ export function versionFromProbe(stdout: string | undefined, stderr: string | unreturn err || null;}+/** 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. */+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.`;+}+export type VersionTriple = readonly [number, number, number];export function parseVersionTriple(value: string): VersionTriple | null {diff --git a/server/drivers/codex-device-auth.ts b/server/drivers/codex-device-auth.tsindex 5944649d73..2448cbb4f3 100644--- a/server/drivers/codex-device-auth.ts+++ b/server/drivers/codex-device-auth.ts@@ -5,7 +5,8 @@ import { DeviceAuthController, type DeviceAuthOptions, type DeviceSignIn } fromimport { codexReportsLogin } from "./codex-login.ts";export function codexDevicePrompt(output: string): { authorizationUrl: string; userCode: string } | null {- return deviceSignInPrompt("codex", stripVTControlCharacters(output));+ const prompt = deviceSignInPrompt("codex", stripVTControlCharacters(output));+ return prompt?.userCode ? { authorizationUrl: prompt.authorizationUrl, userCode: prompt.userCode } : null;}function loginFailure(output: string): string {diff --git a/server/drivers/device-auth.ts b/server/drivers/device-auth.tsindex 7d6c0228b9..3f1be7fa15 100644--- a/server/drivers/device-auth.ts+++ b/server/drivers/device-auth.ts@@ -1,5 +1,6 @@-// Device-code CLI sign-in from the app (`codex login --device-auth`, `grok login --device-auth`),-// confirmed the way turns will see it; a DeviceSignIn holds the per-CLI parts.+// Device-code CLI sign-in from the app (`codex login --device-auth`, `grok login --device-auth`), or a CLI's own login+// that prints one link to finish it (`cursor-agent login`), confirmed the way turns will see it; a DeviceSignIn holds the+// per-CLI parts.import type { ChildProcess } from "node:child_process";import { randomUUID } from "node:crypto";import { realpathSync } from "node:fs";@@ -34,6 +35,8 @@ export interface DeviceSignIn {homeEnv: string;homeDir: string;loginArgs: readonly string[];+ /** Set for every command of this sign-in, such as a CLI's switch that keeps it from opening a browser on the server. */+ env?: Readonly<Record<string, string>>;install: string;/** One safe sentence for a failed login command; never the CLI's own words, which may carry tokens. */failure(output: string): string;@@ -239,7 +242,7 @@ export class DeviceAuthController {}let child: ReturnType<typeof spawnCli>;try {- child = spawnCli(this.options.cli, args, { env: { ...env, NO_COLOR: "1" }, cwd, stdio: ["pipe", "pipe", "pipe"] });+ child = spawnCli(this.options.cli, args, { env: { ...env, NO_COLOR: "1", ...this.spec.env }, cwd, stdio: ["pipe", "pipe", "pipe"] });} catch {rejectExec(new Error(`${product} could not start on this server. Install or update the configured ${product} CLI, then try again.`));return;@@ -277,7 +280,7 @@ export class DeviceAuthController {if (flow.status.phase !== "waiting") return;let child: ReturnType<typeof spawnCli>;try {- child = spawnCli(this.options.cli, args, { env: { ...env, NO_COLOR: "1" }, cwd, stdio: ["pipe", "pipe", "pipe"] });+ child = spawnCli(this.options.cli, args, { env: { ...env, NO_COLOR: "1", ...this.spec.env }, cwd, stdio: ["pipe", "pipe", "pipe"] });} catch {this.finish(flow, "failed", `${product} could not start on this server. Install or update the configured ${product} CLI, then try again.`);return;diff --git a/server/system-prompt.test.ts b/server/system-prompt.test.tsindex 86a33fb913..d08595568a 100644--- a/server/system-prompt.test.ts+++ b/server/system-prompt.test.ts@@ -7,6 +7,7 @@ import {buildSystemPrompt,CONVERSATIONAL_STYLE_PROMPT,CLOUD_HOME_PLACE,+ CLOUD_ENGINES_HERE,cloudHomePrompt,userProfileSystemPrompt,computerPrompt,@@ -397,6 +398,17 @@ describe("cloudHomePrompt", () => {});});+// A Cloud's bot told its person to run `cursor-agent login` on their PC, then ran it on the cloud computer: neither signs+// in the Cursor the bots run on, which is on the Cloud itself.+it("tells Cloud bots that their AIs run on the Cloud and are signed in from the app, never on another computer", () => {+ for (const text of [cloudHomePrompt(true), cloudHomePrompt(false), cloudHomePrompt(true, [], [{ name: "ASH-PC", platform: "win32" }], true)]) {+ expect(text).toContain(CLOUD_ENGINES_HERE);+ expect(text).toContain("run here, on My Cloud, not on their computer or their cloud computer");+ expect(text).toContain("tell them to choose it in the model picker: its card does that here, with a sign-in link they open on any device");+ expect(text).toContain("Never tell them to run an AI's install or sign-in command on their own computer, and never run one on their cloud computer yourself");+ }+});+describe("longCommandsPrompt", () => {it("names Bash's limit everywhere and vm_exec's own limit only with a Local VM", () => {for (const kind of [null, "local", "vps", "box"] as const) {diff --git a/server/system-prompt.ts b/server/system-prompt.tsindex 7ed2cb8a14..ddfc9e58fb 100644--- a/server/system-prompt.ts+++ b/server/system-prompt.ts@@ -147,6 +147,11 @@ function theirComputer(lent: ReadonlyArray<{ name: string; platform: "darwin" |return { theirs: `their ${device} (${name})`, device };}+/** The AIs a Cloud's bots run on run on the Cloud itself: a sign-in or install anywhere else never reaches them. */+export const CLOUD_ENGINES_HERE = " The AIs bots run on (Claude, Codex, Cursor and the rest) run here, on My Cloud, not on their computer or their cloud computer."+ + " If one needs installing or signing in, tell them to choose it in the model picker: its card does that here, with a sign-in link they open on any device."+ + " Never tell them to run an AI's install or sign-in command on their own computer, and never run one on their cloud computer yourself: neither signs in the AIs here.";+/** `asks`: the person's own Cloud, whose bots ask them to turn on what their computer doesn't give now (ask_for_computer). */export function cloudHomePrompt(sharedComputerTools: boolean, synced: ReadonlyArray<{ computerName: string; pcPath: string; cloudPath: string }> = [],lent: ReadonlyArray<{ name: string; platform: "darwin" | "win32" | "linux" | null }> = [], asks = false): string {@@ -160,6 +165,7 @@ export function cloudHomePrompt(sharedComputerTools: boolean, synced: ReadonlyAr: ` You cannot see or use ${theirs}, its screen or its files from here. If they ask for something on it, say so in one sentence.`)+ (asks ? " For work that doesn't need their own computer, use what works here:" : " Offer what works here:")+ " the built-in browser and their cloud computer, a desktop in the cloud. Call it their cloud computer, as the app does. Never ask them to set up this computer or a Local VM; neither exists here."+ + CLOUD_ENGINES_HERE+ syncedFoldersPrompt(synced);}diff --git a/server/testing/fake-acp-cli.ts b/server/testing/fake-acp-cli.tsindex 6e4e5bf2a4..01f3a64537 100755--- a/server/testing/fake-acp-cli.ts+++ b/server/testing/fake-acp-cli.ts@@ -28,6 +28,7 @@// FAKE_ACP_PERMISSION_OPTIONS JSON options override in permission mode// FAKE_ACP_DUMP path for {argv, env}; with FAKE_ACP_MODES or FAKE_ACP_MODELS also <dump>.prompts.jsonl// FAKE_ACP_LAUNCH_COUNT_FILE process counter incremented at startup+// FAKE_ACP_VERSION what `--version` prints (default "fake-acp 1.0.0"); a CLI the driver checks the shape of needs its own// FAKE_ACP_RPC_DUMP this process's method list, rewritten after every request// FAKE_ACP_RPC_APPEND_FILE one {"pid","method","cwd"} line appended per request// FAKE_ACP_RPC_FAILURE_FILE JSON-RPC error for session/prompt; once read the process stays poisoned@@ -286,7 +287,7 @@ if (process.env.FAKE_ACP_LAUNCH_COUNT_FILE) {} catch {}}if (argv.includes("--version")) {- console.log("fake-acp 1.0.0");+ console.log(process.env.FAKE_ACP_VERSION ?? "fake-acp 1.0.0");process.exit(0);}// Cursor's driver probes `agent status` / `agent models` on the binary it spawns for ACP.diff --git a/server/testing/fake-cursor-login-cli.ts b/server/testing/fake-cursor-login-cli.tsnew file mode 100755index 0000000000..6caafac5ef--- /dev/null+++ b/server/testing/fake-cursor-login-cli.ts@@ -0,0 +1,47 @@+#!/usr/bin/env node+// Offline stand-in for Cursor's `cursor-agent` sign-in commands, printing what cursor-agent 2026.10.22 prints: no+// network, no real credential; needs explicit opt-in and a disposable HOME.+// FAKE_CURSOR_MODE approve (signed in once HOME/.omb-fake-cursor-approved exists, as when the person finishes in their+// browser) | evil (a link on another host) | extra (a link carrying a token) | crash | curl (answers --version as+// curl does, as an install command pasted as the CLI path runs)+import { appendFileSync, existsSync, mkdirSync, writeFileSync } from "node:fs";+import { isAbsolute, join } from "node:path";++const home = process.env.HOME;+if (process.env.OMB_DEVICE_AUTH_FIXTURE !== "1" || !home || !isAbsolute(home)) {+ process.stderr.write("This fake CLI requires OMB_DEVICE_AUTH_FIXTURE=1 and an isolated HOME.\n");+ process.exit(2);+}+const mode = process.env.FAKE_CURSOR_MODE || "approve";+const args = process.argv.slice(2);+const auth = join(home, ".config", "cursor", "auth.json");+appendFileSync(join(home, "fake-cursor-calls.jsonl"), `${JSON.stringify({ args, noOpenBrowser: process.env.NO_OPEN_BROWSER ?? null })}\n`);++const CHALLENGE = "Jx1fQ3-Vq8kP0Yb_5rT2aWm7nC4dE6gH9iL0oS1uZ2y";+const UUID = "3f2b8c1d-4e5a-4b6c-8d7e-9f0a1b2c3d4e";+const link = mode === "evil" ? `https://cursor.com.evil.test/loginDeepControl?challenge=${CHALLENGE}&uuid=${UUID}`+ : mode === "extra" ? `https://cursor.com/loginDeepControl?challenge=${CHALLENGE}&uuid=${UUID}&mode=login&token=secret-token`+ : `https://cursor.com/loginDeepControl?challenge=${CHALLENGE}&uuid=${UUID}&mode=login&redirectTarget=cli&supportsSelectedTeamLogin=true`;++if (args.join(" ") === "--version") {+ process.stdout.write(mode === "curl" ? "curl 7.88.1 (x86_64-pc-linux-gnu) libcurl/7.88.1 OpenSSL/3.0.22\nRelease-Date: 2023-02-20\n" : "2026.10.22-27dcf5f\n");+} else if (args.join(" ") === "status --format json") {+ const signedIn = existsSync(auth);+ process.stdout.write(`${JSON.stringify({ status: signedIn ? "authenticated" : "unauthenticated", isAuthenticated: signedIn, hasAccessToken: signedIn, hasRefreshToken: signedIn }, null, 2)}\n`);+} else if (args.join(" ") === "status") {+ process.stdout.write(existsSync(auth) ? "Logged in\n" : "Not logged in\n");+} else if (args.join(" ") === "login") {+ writeFileSync(join(home, "fake-cursor-login.pid"), String(process.pid));+ process.stdout.write(["Starting login process...", "Authenticating with Cursor...", "Waiting for browser authentication...", `Open a browser and navigate to this link: ${link}`, ""].join("\n"));+ if (mode === "crash") setTimeout(() => { process.stderr.write("access_token=secret-token\n"); process.exit(1); }, 80);+ else setInterval(() => {+ if (!existsSync(join(home, ".omb-fake-cursor-approved"))) return;+ mkdirSync(join(home, ".config", "cursor"), { recursive: true });+ writeFileSync(auth, "{\"fixture\":\"offline, not a credential\"}\n", { mode: 0o600 });+ process.stdout.write("Login successful!\n");+ process.exit(0);+ }, 50);+} else {+ process.stderr.write("Unsupported offline fixture command.\n");+ process.exitCode = 2;+}diff --git a/shared/device-sign-in.ts b/shared/device-sign-in.tsindex 9d3c3fc7d2..9b97259809 100644--- a/shared/device-sign-in.ts+++ b/shared/device-sign-in.ts@@ -1,11 +1,12 @@// Where a person enters the one-time code that signs an engine's CLI in on// the machine running OpenMausBot (`codex login --device-auth`, `grok login-// --device-auth`, `kimi login`). The server reads the page and the code from-// the CLI's output with these rules, and the app checks them again before it-// shows a link. Neither ever turns arbitrary output into a link, or lets a-// token ride along in one.+// --device-auth`, `kimi login`), or, for a CLI that prints no code (`cursor-agent+// login`), the one link that finishes its sign-in. The server reads the page and+// the code from the CLI's output with these rules, and the app checks them again+// before it shows a link. Neither ever turns arbitrary output into a link, or lets+// a token ride along in one.-export type DeviceSignInProvider = "codex" | "grok" | "kimi";+export type DeviceSignInProvider = "codex" | "grok" | "kimi" | "cursor";const CODEX_PAGE = "https://auth.openai.com/codex/device";@@ -19,7 +20,8 @@ function providerPage(value: string, hosts: RegExp): URL | null {const RULES: Record<DeviceSignInProvider, {page(value: string): string | null;- code: RegExp;+ /** null: the link alone finishes the sign-in, and no code is shown. */+ code: RegExp | null;/** The words a CLI prints before the page or the code on the same line. */label?: RegExp;}> = {@@ -52,19 +54,41 @@ const RULES: Record<DeviceSignInProvider, {code: /^[A-Z0-9]{4,12}(?:-[A-Z0-9]{2,12}){0,3}$/,label: /^[^:]*\b(?:login|code):\s+/i,},+ cursor: {+ // cursor-agent 2026.10.22 prints "Open a browser and navigate to this link: https://cursor.com/loginDeepControl?…"+ // and waits for that sign-in. Its query names the sign-in request (a PKCE challenge and a request id) the CLI then+ // collects, never a token; only those and Cursor's own flags may ride in it.+ page: (value) => {+ const url = providerPage(value, /^(www\.)?cursor\.com$/);+ if (!url || url.pathname !== "/loginDeepControl") return null;+ const keys = [...url.searchParams.keys()];+ const known = keys.every((key) => ["challenge", "uuid", "mode", "redirectTarget", "supportsSelectedTeamLogin"].includes(key));+ const request = /^[\w-]{16,128}$/.test(url.searchParams.get("challenge") ?? "") && /^[\w-]{8,64}$/.test(url.searchParams.get("uuid") ?? "");+ return known && request && new Set(keys).size === keys.length ? url.href : null;+ },+ code: null,+ label: /^[^:]*\blink:\s+/i,+ },};+/** Whether this provider's CLI prints a code to enter, or only a link that finishes the sign-in. */+export function deviceSignInHasCode(provider: DeviceSignInProvider): boolean {+ return RULES[provider].code !== null;+}+/** The provider's own page for entering `userCode`, or null for anything* else. A code carried in the page's link must be that same code. */export function deviceSignInLink(provider: DeviceSignInProvider, value: string | null | undefined, userCode?: string): string | null {const page = value ? RULES[provider].page(value) : null;if (!page) return null;+ if (!deviceSignInHasCode(provider)) return userCode === undefined ? page : null;return [...new URL(page).searchParams.values()].every((carried) => carried === userCode) ? page : null;}/** A one-time code as this provider formats it. */export function isDeviceSignInCode(provider: DeviceSignInProvider, value: string | null | undefined): value is string {- return typeof value === "string" && RULES[provider].code.test(value);+ const code = RULES[provider].code;+ return typeof value === "string" && code !== null && code.test(value);}/** The newest page and code from a CLI's output, once both lines have@@ -72,12 +96,16 @@ export function isDeviceSignInCode(provider: DeviceSignInProvider, value: string* code, so the last, unfinished line is never read. A CLI can print a new* pair when its code expires (kimi-code 2.4.1 does). `text` is already free* of terminal styling. */-export function deviceSignInPrompt(provider: DeviceSignInProvider, text: string): { authorizationUrl: string; userCode: string } | null {+export function deviceSignInPrompt(provider: DeviceSignInProvider, text: string): { authorizationUrl: string; userCode?: string } | null {const { page, label } = RULES[provider];const lines = text.split(/\r?\n/).slice(0, -1).map((line) => (label ? line.trim().replace(label, "") : line.trim()));- let prompt: { authorizationUrl: string; userCode: string } | null = null;+ let prompt: { authorizationUrl: string; userCode?: string } | null = null;for (const [at, line] of lines.entries()) {if (page(line) === null) continue;+ if (!deviceSignInHasCode(provider)) {+ prompt = { authorizationUrl: page(line)! };+ continue;+ }const userCode = lines.slice(at + 1).map((next) => next.replace(/^code:\s*/i, "")).find((next) => isDeviceSignInCode(provider, next));const authorizationUrl = userCode ? deviceSignInLink(provider, line, userCode) : null;if (authorizationUrl && userCode) prompt = { authorizationUrl, userCode };diff --git a/src/components/DeviceSignIn.test.ts b/src/components/DeviceSignIn.test.tsindex 0e9321760f..b48063318b 100644--- a/src/components/DeviceSignIn.test.ts+++ b/src/components/DeviceSignIn.test.ts@@ -157,3 +157,32 @@ describe("Grok Build device sign-in UI", () => {expect(html).not.toContain("href=");});});++describe("Cursor sign-in, which prints only a link", () => {+ const link = "https://cursor.com/loginDeepControl?challenge=Jx1fQ3-Vq8kP0Yb_5rT2aWm7nC4dE6gH9iL0oS1uZ2y&uuid=3f2b8c1d-4e5a-4b6c-8d7e-9f0a1b2c3d4e&mode=login&redirectTarget=cli&supportsSelectedTeamLogin=true";+ const cursor: DeviceSignInStatus = { phase: "waiting", flowId: "fixture-flow", authorizationUrl: link, expiresAt: "2030-01-01T12:00:00.000Z" };+ const renderCursor = (auth: DeviceSignInStatus) => renderToStaticMarkup(createElement(DeviceSignInProgress, { auth, provider: "cursor" }));++ it("is Cursor's own sign-in for the Cursor engine", () => {+ expect(deviceSignInProvider("cursorAgent")).toBe("cursor");+ });++ it("shows Cursor's link to open on any device, with no code and no terminal command", () => {+ const html = renderCursor(cursor);+ expect(html).toContain(`href="${link.replaceAll("&", "&")}"`);+ expect(html).toContain("Open Cursor sign-in");+ expect(html).not.toContain("Copy sign-in code");+ expect(html).not.toContain("cursor-agent login");+ expect(html).not.toContain('role="alert"');+ });++ it.each([+ "https://cursor.com.evil.test/loginDeepControl?challenge=Jx1fQ3-Vq8kP0Yb_5rT2aWm7nC4dE6gH9iL0oS1uZ2y&uuid=3f2b8c1d-4e5a-4b6c-8d7e-9f0a1b2c3d4e",+ `${link}&token=secret`,+ "javascript:alert(1)",+ ])("does not expose an unexpected Cursor sign-in URL: %s", (url) => {+ const html = renderCursor({ ...cursor, authorizationUrl: url });+ expect(html).toContain("Cursor did not return a valid sign-in link");+ expect(html).not.toContain("href=");+ });+});diff --git a/src/components/DeviceSignIn.tsx b/src/components/DeviceSignIn.tsxindex e383119baf..e1f7b21a75 100644--- a/src/components/DeviceSignIn.tsx+++ b/src/components/DeviceSignIn.tsx@@ -6,7 +6,7 @@ import { openExternalLink } from "@/lib/app-links";import { useCopyFeedback } from "@/lib/copy-text";import { engineSignedIn } from "@/lib/product-events";import type { LocaleKey } from "@/locales";-import { deviceSignInLink, isDeviceSignInCode, type DeviceSignInProvider } from "../../shared/device-sign-in";+import { deviceSignInHasCode, deviceSignInLink, isDeviceSignInCode, type DeviceSignInProvider } from "../../shared/device-sign-in";import { CodexMark } from "./ProviderIcons";export interface DeviceSignInStatus {@@ -22,6 +22,7 @@ export function deviceSignInProvider(driverKind: string): DeviceSignInProvider {switch (driverKind) {case "grokAgent": return "grok";case "kimiAgent": return "kimi";+ case "cursorAgent": return "cursor";default: return "codex";}}@@ -60,6 +61,18 @@ export const DEVICE_SIGN_IN_COPY: Record<DeviceSignInProvider, Record<"descriptifailed: "engineSetup.kimi.failed",invalidChallenge: "engineSetup.kimi.invalidChallenge",},+ cursor: {+ description: "engineSetup.cursor.description",+ start: "engineSetup.cursor.start",+ // Cursor prints no code: its link alone finishes the sign-in.+ enterCode: "engineSetup.cursor.open",+ open: "engineSetup.cursor.open",+ security: "engineSetup.cursor.security",+ connected: "engineSetup.cursor.connected",+ connectedAccount: "engineSetup.cursor.connectedAccount",+ failed: "engineSetup.cursor.failed",+ invalidChallenge: "engineSetup.cursor.invalidChallenge",+ },};export function deviceFlowUnavailable(cause: unknown): boolean {@@ -100,13 +113,14 @@ export function DeviceSignInProgress({ auth, browserPkce = false, provider = "coreturn <p role="status" className={auth.phase === "succeeded" ? "text-[12px] text-success" : "text-[12px] text-ink-secondary"}>{label}</p>;}- if (!link || (!browserPkce && !isDeviceSignInCode(provider, auth.userCode))) {+ const codeShown = !browserPkce && deviceSignInHasCode(provider);+ if (!link || (codeShown && !isDeviceSignInCode(provider, auth.userCode))) {return <p role="alert" className="text-[12px] text-danger">{t(browserPkce ? "engineSetup.chatgpt.invalidChallenge" : copy.invalidChallenge)}</p>;}return (<div className="space-y-2 rounded-lg border border-hairline/50 bg-app p-3">- {!browserPkce && <><p className="text-[12px] text-ink-secondary">{t(copy.enterCode)}</p>+ {codeShown && <><p className="text-[12px] text-ink-secondary">{t(copy.enterCode)}</p><div className="flex items-center justify-between gap-2 rounded-lg bg-inset px-3 py-2"><code className="select-all font-mono text-lg font-semibold tracking-widest text-ink">{auth.userCode}</code><button@@ -129,7 +143,7 @@ export function DeviceSignInProgress({ auth, browserPkce = false, provider = "co<Loader2 size={12} className="animate-spin" /> {t("engineSetup.device.waiting")}</p>{auth.expiresAt && Number.isFinite(Date.parse(auth.expiresAt)) && (- <p className="text-[11px] text-ink-secondary">{t(browserPkce ? "engineSetup.chatgpt.expires" : "engineSetup.device.expires", { time: new Date(auth.expiresAt).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) })}</p>+ <p className="text-[11px] text-ink-secondary">{t(!codeShown ? "engineSetup.chatgpt.expires" : "engineSetup.device.expires", { time: new Date(auth.expiresAt).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) })}</p>)}<p className="text-[11px] leading-relaxed text-ink-secondary">{t(browserPkce ? "engineSetup.chatgpt.security" : copy.security)}</p></div>diff --git a/src/lib/analytics-allowlist.ts b/src/lib/analytics-allowlist.tsindex 519c6dd2ad..16e2afd6e5 100644--- a/src/lib/analytics-allowlist.ts+++ b/src/lib/analytics-allowlist.ts@@ -68,7 +68,7 @@ export const KEY_VIA = ["settings", "computer_panel", "chat_request", "apps", "mexport type KeyVia = (typeof KEY_VIA)[number];export const KEY_RESULT = ["ok", "rejected", "unverified", "error"] as const;export type KeyResult = (typeof KEY_RESULT)[number];-export const SIGN_IN_ENGINE = ["claude", "codex", "grok", "kimi"] as const;+export const SIGN_IN_ENGINE = ["claude", "codex", "grok", "kimi", "cursor"] as const;export const SIGN_IN_METHOD = ["code", "device_code", "browser"] as const;export type SignInMethod = (typeof SIGN_IN_METHOD)[number];export const BOT_SOURCE = ["blank", "template", "preset"] as const;diff --git a/src/locales/en.json b/src/locales/en.jsonindex 6454005cd9..e7e4477921 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -5617,6 +5617,14 @@"engineSetup.kimi.connectedAccount": "Kimi connected","engineSetup.kimi.failed": "Sign-in could not be completed. Try again, or check the Kimi installation.","engineSetup.kimi.invalidChallenge": "Kimi did not return a valid sign-in link and code. Cancel and try again.",+ "engineSetup.cursor.description": "Sign in with your Cursor account so your bots can use Cursor. You finish in your own browser, on any device; no terminal or password sharing needed.",+ "engineSetup.cursor.start": "Sign in to Cursor",+ "engineSetup.cursor.open": "Open Cursor sign-in",+ "engineSetup.cursor.security": "Only open a link you requested here. This signs Cursor in for your bots with your Cursor plan and its limits. Your password stays with Cursor, and the sign-in stays where your bots run.",+ "engineSetup.cursor.connected": "Cursor connected. Your models are being refreshed.",+ "engineSetup.cursor.connectedAccount": "Cursor connected",+ "engineSetup.cursor.failed": "Sign-in could not be completed. Try again, or check the Cursor installation.",+ "engineSetup.cursor.invalidChallenge": "Cursor did not return a valid sign-in link. Cancel and try again.","settings.domain.title": "Connect your domain","settings.domain.subtitle": "Enter your address, then copy the DNS record to your domain provider.","settings.domain.loading": "Loading server address…",