Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(agents): mask secrets in every teammate result, short ones too
luishron123e89e75c83ee9
diff --git a/server/runtime/runtime.test.ts b/server/runtime/runtime.test.tsindex c391909f4a..ed75eb52e9 100644--- a/server/runtime/runtime.test.ts+++ b/server/runtime/runtime.test.ts@@ -830,6 +830,20 @@ describe("access rechecked while work runs", () => {invariants(w);});+ it("masks a secret in a short result too, before it is kept", async () => {+ const w = world(() => "hold");+ const root = w.runtime.begin(beginReq());+ const child = ok(w.runtime.enqueue(toBot("builder", root.id)));+ w.runtime.tick();+ const secret = "sk-ant-abcdefghijklmnopqrstuvwxyz012345";+ await w.runner.release(child.id, { kind: "completed", text: `Done. The key is ${secret}.` });+ const row = w.store.get(child.id)!;+ expect(row.result).not.toContain(secret);+ expect(row.result).toMatch(/^Done\. The key is /);+ expect(row.resultChars).toBeUndefined();+ invariants(w);+ });+it("drops a kept long result once the record's own result is short again", async () => {const w = world(() => "hold");const root = w.runtime.begin(beginReq());diff --git a/server/runtime/runtime.ts b/server/runtime/runtime.tsindex a27e872356..60b17f6d68 100644--- a/server/runtime/runtime.ts+++ b/server/runtime/runtime.ts@@ -949,8 +949,8 @@ export class Runtime {/** The record holds a result's head; a longer one is kept whole beside it, so its end is never lost. A failed keep* leaves resultChars set with nothing beside it, which the reader reports as cut, never as the whole text. */private keepResult(n: Assignment, said: string, saidChars?: number): void {- // A long result is masked before the cut, as an answer is, so a secret is never kept half shown at the record's edge.- const text = said.length > RESULT_MAX || (saidChars ?? 0) > said.length ? redactSecretsInText(said) : said;+ // Every result is masked, short or long, before it is cut or kept, so a secret is never stored or shown half kept.+ const text = redactSecretsInText(said);// saidChars: the reply was already cut before it got here (handoffReply); the reader must still say its end is lost.const whole = Math.max(text.length, saidChars !== undefined && saidChars > said.length ? text.length + saidChars - said.length : 0);const long = whole > RESULT_MAX;