an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions
HTML agent-harnessagent-orchestrationagentsai-agentsautonomous-agentsclaude-codecodexcoding-agentsdesktop-appdeveloper-toolselectrongemini-cliharnessharness-engineeringlocal-firstmemorymulti-agentopencodeorchestrationtypescript
fix(realtime): rt-10 nits N1 + N3-seam — regex-escape confirm word, sanitize completion summary
Chaitanya Giri55a5007a25e9
diff --git a/src/main/realtimeActions.ts b/src/main/realtimeActions.tsindex a1086cac..3fba8580 100644--- a/src/main/realtimeActions.ts+++ b/src/main/realtimeActions.ts@@ -116,6 +116,9 @@ const BARE_AFFIRMATIONS = new Set([const str = (x: unknown): string => (typeof x === 'string' ? x : '');const norm = (s: string): string => s.toLowerCase().replace(/[.!?,;:'"]/g, ' ').replace(/\s+/g, ' ').trim();+/** N1 (rt-10 hardening): escape regex metachars before interpolating a verb word into+ * `new RegExp`. Safe with today's verb vocab (plain words) — defense in depth. */+const escapeRegExp = (s: string): string => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');function shortId(): string {// app code (not a Workflow script) — Math.random is fine here.@@ -179,7 +182,7 @@ function confirmAccepted(phrase: string, confirmWord: string): boolean {if (!p) return false;if (BARE_AFFIRMATIONS.has(p)) return false;if (/\bconfirm(ed|s)?\b/.test(p)) return true;- if (new RegExp(`\\b${confirmWord}\\b`).test(p)) return true;+ if (new RegExp(`\\b${escapeRegExp(confirmWord)}\\b`).test(p)) return true;return false;}diff --git a/src/renderer/src/realtime/session.ts b/src/renderer/src/realtime/session.tsindex a80d2eec..ac3e6e2e 100644--- a/src/renderer/src/realtime/session.ts+++ b/src/renderer/src/realtime/session.ts@@ -105,6 +105,25 @@ let costGuardTimer: ReturnType<typeof setInterval> | null = null;const IDLE_DISCONNECT_MS = 45_000;const COST_GUARD_TICK_MS = 10_000;+/** N3-seam (rt-10 hardening): a completion summary carries dispatch objective text.+ * It CANNOT escalate — MAIN independently gates every destructive/forbidden op+ * (Pam confirmed) — but neutralize it before injecting into the model as a system+ * notification (defense in depth): collapse newlines, strip the parens that frame+ * my notification, drop role markers + classic prompt-injection lead-ins, and cap+ * length. Jim does the matching watcher-side half on the summary it emits. */+function sanitizeForVoice(s: string): string {+ return (s || '')+ .replace(/[\r\n]+/g, ' ')+ .replace(/[()]/g, '')+ .replace(/\b(?:ignore|disregard|forget|override)\b[^.!?]*\b(?:previous|above|prior|instruction|system|prompt)\b[^.!?]*/gi, '')+ .replace(/\b(?:system|assistant|developer|user)\s*:/gi, '')+ .replace(/\bnew instructions?\b[^.!?]*/gi, '')+ .replace(/\byou are (?:now )?[^.!?]*/gi, '')+ .replace(/\s+/g, ' ')+ .trim()+ .slice(0, 300);+}+function setState(patch: Partial<RealtimeMichaelState>): void {state = { ...state, ...patch };for (const l of listeners) l();@@ -332,8 +351,9 @@ export async function connect(): Promise<void> {try {// Feed it as a system-framed notification so the model relays it rather than// treating it as a user request; semantic_vad won't interrupt an active turn.+ // N3-seam: sanitize the summary before injection (defense in depth).session?.sendMessage(- `(System notification — a task you dispatched just finished: ${c.summary}) Briefly let the user know, and offer details if they want them.`+ `(System notification — a task you dispatched just finished: ${sanitizeForVoice(c.summary)}) Briefly let the user know, and offer details if they want them.`);} catch {/* session may be tearing down */