Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Stuck-command notice: scrub secrets from the command it names
AdityaUmalef9c2259629ae
diff --git a/server/chat-notices.test.ts b/server/chat-notices.test.tsindex 4adf98b946..f541402cec 100644--- a/server/chat-notices.test.ts+++ b/server/chat-notices.test.ts@@ -38,6 +38,14 @@ describe("chat notices", () => {expect(failedTurnCause(tool.name)).toBe("no activity for 20 minutes — the turn was stopped");});+ it("scrubs a secret from a failed turn's cause and its params", () => {+ const token = "sk-ant-api03-" + "a1B2c3D4e5F6g7H8i9J0k1L2m3N4o5P6";+ const tool = failedNoticeTool("chat.notice.stalledCommand", { command: `curl -H "Authorization: Bearer ${token}" https://example.com`, minutes: 120 });+ expect(tool.nameCode).toBe("chat.notice.stalledCommand");+ expect(tool.name).toContain("curl -H");+ expect(JSON.stringify(tool)).not.toContain(token);+ });+it.each([["server.teammates.resumedQuestion", "Resumed with a question from Scout, reviewing", "Retomou o trabalho com uma pergunta de Scout e está revisando"],["server.teammates.resumedQuestionRestart", "Resumed with a question from Scout after a restart, reviewing", "Após uma reinicialização, retomou o trabalho com uma pergunta de Scout e está revisando"],diff --git a/server/chat-notices.ts b/server/chat-notices.tsindex e068b3a424..4b4c300a0e 100644--- a/server/chat-notices.ts+++ b/server/chat-notices.ts@@ -182,5 +182,6 @@ export function noticeTool<T extends object>(}export function failedNoticeTool(key: ChatNoticeKey, params?: ServerTextParams): FailedTurnTool {- return failedTurnTool(chatNotice(key, params), { text: { key, ...(params ? { params } : {}) } });+ const safe = params && redactParams(params);+ return failedTurnTool(chatNotice(key, safe), { text: { key, ...(safe ? { params: safe } : {}) } });}diff --git a/server/turn-watchdog.test.ts b/server/turn-watchdog.test.tsindex 759bf0ba75..178516e764 100644--- a/server/turn-watchdog.test.ts+++ b/server/turn-watchdog.test.ts@@ -481,6 +481,19 @@ describe("stuckCommand", () => {expect(stuckCommand(stalls[0]!, 1_000 + 120 * 60_000)).toEqual({ command: "ffmpeg -i talk.mov talk.mp4", minutes: 120 });});+ it("scrubs a secret in the command it names", () => {+ const { dog, stalls, tick } = rig();+ const token = "sk-ant-api03-" + "a1B2c3D4e5F6g7H8i9J0k1L2m3N4o5P6";+ dog.watch("t1", "bot1");+ dog.observe(shellStarted("upload", `curl -H "Authorization: Bearer ${token}" https://example.com/upload`));+ tick(TOOL_STALL);+ dog.sweep();+ const stuck = stuckCommand(stalls[0]!, TOOL_STALL);+ expect(stuck?.command).toContain("curl -H");+ expect(stuck?.command).not.toContain(token);+ expect(JSON.stringify(stallNotice(stalls[0]!, TOOL_STALL, TOOL_STALL))).not.toContain(token);+ });+it("names nothing when no running tool runs a shell command", () => {const { dog, stalls, tick } = rig();dog.watch("t1", "bot1");diff --git a/server/turn-watchdog.ts b/server/turn-watchdog.tsindex dd6d9873f9..7b424e11ca 100644--- a/server/turn-watchdog.ts+++ b/server/turn-watchdog.ts@@ -1,6 +1,7 @@import { processAlive } from "./browser-processes.ts";import type { ProviderAdapter, RuntimeEvent } from "./contracts.ts";import { sampleProcessTree, type ProcessSample } from "./drivers/acp/quiet-status.ts";+import { redactSecretsInText } from "../shared/redact.ts";// A turn whose thread emits nothing for stallMs is wedged; waiting on a person or a computer is not a stall unless the// turn's engine is known to have no process left. Drivers report a tool only when it starts and when it ends, so a turn@@ -32,10 +33,10 @@ function oldestCommand(turn: Partial<Pick<WatchedTurn, "runningTools">>): (Runni}/** The longest-running shell command of a turn stopped at stopAt, with the whole minutes it ran: what the person is told- * looks stuck. null when no running tool runs a shell command. */+ * looks stuck, with any secret in it scrubbed. null when no running tool runs a shell command. */export function stuckCommand(turn: Partial<Pick<WatchedTurn, "runningTools">>, stopAt: number): { command: string; minutes: number } | null {const oldest = oldestCommand(turn);- return oldest ? { command: oldest.command, minutes: Math.max(1, Math.round((stopAt - oldest.startedAt) / 60_000)) } : null;+ return oldest ? { command: redactSecretsInText(oldest.command), minutes: Math.max(1, Math.round((stopAt - oldest.startedAt) / 60_000)) } : null;}/** What the person is told when the watchdog stops a turn silent for silentMs: the shell command still running, with how