Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(tool-summary): a failed call's error keeps the key-name redaction, also inside JSON text
milind-soniaf317f79fc13
diff --git a/server/tool-summary.test.ts b/server/tool-summary.test.tsindex 94002ab462..f72fd80fd3 100644--- a/server/tool-summary.test.ts+++ b/server/tool-summary.test.ts@@ -51,6 +51,9 @@ describe("toolDetailPreview", () => {const long = JSON.parse(toolDetailPreview({ ok: false, error: `${"cause ".repeat(200)}` })!);expect(long.error.length).toBeLessThanOrEqual(500);expect(toolDetailPreview({ ok: false, error: `boom ghp_${"a".repeat(36)}` })).not.toContain("ghp_");+ expect(toolDetailPreview({ ok: false, error: { message: "denied", password: "tiny" } })).not.toContain("tiny");+ expect(toolDetailPreview({ ok: false, error: JSON.stringify({ message: "denied", password: "tiny" }) })).not.toContain("tiny");+ expect(toolDetailPreview({ ok: false, errorToken: "tiny" })).not.toContain("tiny");});it("scrubs structured JSON inside native text results without changing ordinary prose", () => {const preview = toolDetailPreview([{ type: "text", text: JSON.stringify({ message: "request completed", password: "tiny", headers: { Cookie: "sid=x" }, env: [{ name: "API_KEY", value: "small" }] }) }]);diff --git a/server/tool-summary.ts b/server/tool-summary.tsindex bb82d806a6..714bec7059 100644--- a/server/tool-summary.ts+++ b/server/tool-summary.ts@@ -10,10 +10,15 @@ export function toolDetailPreview(value: unknown): string | undefined {const ERROR_KEY = /^error/i;const ERROR_TEXT_MAX = 500;const errorText = (value: unknown): string => {+ let parsed = value;+ if (typeof value === "string" && /^\s*[[{]/.test(value)) {+ try { parsed = JSON.parse(value); }+ catch {}+ }let text: string;- if (typeof value === "string") text = value;+ if (typeof parsed === "string") text = parsed;else {- try { text = JSON.stringify(redactSecrets(value)) ?? ""; }+ try { text = JSON.stringify(redactSecrets(parsed)) ?? ""; }catch { return "[error not serializable]"; }}// Redact before the cut, like commandSummary, so a sliced credential cannot slip through.@@ -59,10 +64,10 @@ export function toolDetailPreview(value: unknown): string | undefined {const entries = Object.entries(item);const result: Record<string, unknown> = Object.create(null);for (const [key, child] of entries.slice(0, 40)) {- result[key] = ERROR_KEY.test(key) && isErrorValue(child)- ? errorText(child)- : /token|secret|password|passwd|cookie|authorization|api.?key|(^|[_.-])keys?$/i.test(key)+ result[key] = /token|secret|password|passwd|cookie|authorization|api.?key|(^|[_.-])keys?$/i.test(key)? "[redacted]"+ : ERROR_KEY.test(key) && isErrorValue(child)+ ? errorText(child): /^(data|base64|blob)$/i.test(key) && typeof child === "string"? "[binary content omitted]": bounded(child, depth + 1);