Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Cursor: ask the CLI before the proactive authenticate instead of clearing its login
skygunner73f557e0689a
diff --git a/server/drivers/acp/core.ts b/server/drivers/acp/core.tsindex 21d6a96a32..7c13ece257 100644--- a/server/drivers/acp/core.ts+++ b/server/drivers/acp/core.ts@@ -235,6 +235,7 @@ export interface AcpSupport extends AcpDriverHooks {config: AcpConfig,instanceId: string, allowEnv?: readonly string[],): boolean | Promise<boolean>;+ skipAuthenticateWhenAuthenticated?: boolean;/** Refuse a first-party cloud turn before spawning when snapshot auth is* false. Local injected models deliberately bypass this subscription gate. */requireAuthenticationBeforeSpawn?: boolean;@@ -1090,11 +1091,10 @@ export function createAcpDriver(support: AcpSupport): ProviderDriver<AcpConfig>));}if (!skipSubscriptionAuthForLocalInject(turn.model) && !session.authenticated && !support.skipsAuthenticate?.(instanceId)) {- const methods: Array<{ id?: string }> = Array.isArray(session.initResult?.authMethods)- ? session.initResult.authMethods- : [];- const methodId = support.pickAuthMethod(methods, spawnEnv);- if (methodId) {+ const methods = Array.isArray(session.initResult?.authMethods) ? session.initResult.authMethods : [];+ const methodId = support.pickAuthMethod(methods, spawnEnv), skip = methodId && support.skipAuthenticateWhenAuthenticated === true && await support.isAuthenticated(spawnEnv, turnConfig, instanceId, instanceEnvNames(input.environment, spawnEnv));+ if (skip) session.authenticated = true;+ else if (methodId) {try {await session.host.once("authenticate", () => retryTransient(request, "authenticate", { methodId }, INIT_TIMEOUT));session.authenticated = true;diff --git a/server/drivers/acp/cursor.test.ts b/server/drivers/acp/cursor.test.tsindex 481f71ee30..af42aa5cc4 100644--- a/server/drivers/acp/cursor.test.ts+++ b/server/drivers/acp/cursor.test.ts@@ -437,12 +437,13 @@ describe("CursorAgentDriver", () => {}});- it("sends cursor_login only when no Cursor key is in the agent's env", async () => {+ it("sends cursor_login once when the CLI reports no login and no Cursor key is in the agent's env", async () => {ensureDirs();chmodSync(FAKE_CLI, 0o755);const scratch = mkdtempSync(join(tmpdir(), "omb-cursor-auth-"));scratchDirs.push(scratch);process.env.FAKE_ACP_AUTH_METHOD = "cursor_login";+ process.env.FAKE_ACP_AUTH = "0";const authenticateCalls = async (environment: Record<string, string>) => {const rpcFile = join(scratch, `rpc-${Object.keys(environment).join("-") || "none"}.jsonl`);process.env.FAKE_ACP_RPC_APPEND_FILE = rpcFile;@@ -469,6 +470,36 @@ describe("CursorAgentDriver", () => {expect(await authenticateCalls({})).toBe(1);expect(await authenticateCalls({ CURSOR_API_KEY: "key-from-env" })).toBe(0);expect(await authenticateCalls({ CURSOR_AUTH_TOKEN: "token-from-env" })).toBe(0);+ delete process.env.FAKE_ACP_AUTH;+ });++ it("skips cursor_login when the CLI already holds a login", async () => {+ ensureDirs();+ chmodSync(FAKE_CLI, 0o755);+ const scratch = mkdtempSync(join(tmpdir(), "omb-cursor-auth-signed-in-"));+ scratchDirs.push(scratch);+ process.env.FAKE_ACP_AUTH_METHOD = "cursor_login";+ process.env.FAKE_ACP_AUTH = "1";+ const rpcFile = join(scratch, "rpc.jsonl");+ process.env.FAKE_ACP_RPC_APPEND_FILE = rpcFile;+ const instance = await CursorAgentDriver.create({+ instanceId: "cursor-auth-signed-in",+ displayName: "Cursor",+ environment: {},+ enabled: true,+ config: { cli: FAKE_CLI, fullAuto: false },+ });+ const recorder = recordEvents(instance.adapter);+ try {+ await instance.adapter.sendTurn({ threadId: "t-cursor-auth-signed-in", text: "hi" });+ expect(await recorder.until((e) => e.type === "turn.completed")).toMatchObject({ ok: true });+ const methods = readFileSync(rpcFile, "utf8").trim().split("\n").map((line) => JSON.parse(line).method);+ expect(methods).not.toContain("authenticate");+ } finally {+ recorder.stop();+ await instance.dispose();+ delete process.env.FAKE_ACP_AUTH;+ }});it("omits --force when fullAuto is off, still approves MCP, and completes a turn", async () => {diff --git a/server/drivers/acp/cursor.ts b/server/drivers/acp/cursor.tsindex fc60d73298..295ede8678 100644--- a/server/drivers/acp/cursor.ts+++ b/server/drivers/acp/cursor.ts@@ -521,6 +521,8 @@ const support = (run: typeof execCli): AcpSupport => ({: methods.some((m) => m.id === "cursor_login") ? "cursor_login" : null,authFailure: "continue",isAuthenticated: (env, config) => probeCursorAuth(config.cli || "cursor-agent", env, run),+ // cursor_login re-run clears the CLI's stored login and opens a browser, so the handshake asks the CLI first.+ skipAuthenticateWhenAuthenticated: true,classifyError: classifyCursorError,replyFailure: cursorReplyFailure,