Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Antigravity authenticate retry: import classifyError, keep the existing rpc-error tests
milind-soni6216d8bd16e9
diff --git a/server/drivers/acp/rpc-error.test.ts b/server/drivers/acp/rpc-error.test.tsindex b48edeebab..2096a88f3e 100644--- a/server/drivers/acp/rpc-error.test.ts+++ b/server/drivers/acp/rpc-error.test.ts@@ -1,5 +1,57 @@import { describe, expect, it } from "vitest";-import { acpRpcError, retryTransient } from "./rpc-error.ts";+import { addHeldSecretScrubber } from "../../redact.ts";+import { acpMissingSession, acpRpcError, retryTransient } from "./rpc-error.ts";++describe("acpMissingSession", () => {+ const cursor = "a09518ea-61e5-4534-8575-afbdb784a4b5";++ it("accepts OpenCode's invalidParams that carry only the rejected session id", () => {+ expect(acpMissingSession({ data: { sessionId: cursor } }, cursor)).toBe(true);+ expect(acpMissingSession({ data: { sessionId: cursor, model: "gone" } }, cursor)).toBe(false);+ });++ it("accepts Cursor's session/load message, which names the id and not a data field", () => {+ const error = acpRpcError({ code: -32602, message: `Invalid params: Session "${cursor}" not found` }, "session/load");+ expect(acpMissingSession(error, cursor)).toBe(true);+ });++ it("does not treat a bare invalidParams or another missing id as this session", () => {+ expect(acpMissingSession(acpRpcError({ code: -32602, message: "Invalid params" }, "session/load"), cursor)).toBe(false);+ expect(acpMissingSession(acpRpcError({ code: -32602, message: "Invalid params: model not found" }, "session/load"), cursor)).toBe(false);+ expect(acpMissingSession(acpRpcError({ code: -32602, message: `model gone not found for session "${cursor}"` }, "session/load"), cursor)).toBe(false);+ expect(acpMissingSession(acpRpcError({ code: -32602, message: `Invalid params: Session "${cursor}" not found` }, "session/prompt"), cursor)).toBe(false);+ expect(acpMissingSession(acpRpcError({ code: -32602, message: "Invalid params: Session \"session-10\" not found" }, "session/load"), "session-1")).toBe(false);+ });++ it("matches the original message when redaction removes the session id from what is shown", () => {+ const remove = addHeldSecretScrubber((text) => text.split(cursor).join("«secret»"));+ try {+ const error = acpRpcError({ code: -32602, message: `Invalid params: Session "${cursor}" not found` }, "session/load");+ const shown = error as Error & { acpDiagnostic?: string };+ expect(shown.message.includes(cursor)).toBe(false);+ expect(shown.acpDiagnostic?.includes(cursor)).toBe(false);+ expect(acpMissingSession(error, cursor)).toBe(true);+ } finally {+ remove();+ }+ });++ it("compares the session id as written, and still accepts either case in the surrounding words", () => {+ const upper = cursor.toUpperCase();+ const error = acpRpcError({ code: -32602, message: `invalid params: SESSION "${upper}" NOT FOUND` }, "session/load");+ expect(acpMissingSession(error, upper)).toBe(true);+ expect(acpMissingSession(error, cursor)).toBe(false);+ });++ it("does not treat an earlier missing-session line quoted inside another error as this failure", () => {+ const error = acpRpcError({+ code: -32602,+ message: "Invalid params: model not found",+ data: { details: `Session "${cursor}" not found (session/load)` },+ }, "session/load");+ expect(acpMissingSession(error, cursor)).toBe(false);+ });+});describe("retryTransient", () => {const ok = async <T>(value: T) => value;diff --git a/server/drivers/acp/rpc-error.ts b/server/drivers/acp/rpc-error.tsindex bcd7af2cbd..c3266af22c 100644--- a/server/drivers/acp/rpc-error.ts+++ b/server/drivers/acp/rpc-error.ts@@ -1,4 +1,5 @@import { redactSecretsInText } from "../../redact.ts";+import { classifyError } from "../retry.ts";/** The vendor's own message and the method we called, before redaction or any attached detail. */const vendorFailures = new WeakMap<object, { message: string; method: string }>();