Skip to content

An agentic browser harness: an AI side panel & orb in your own logged-in Chrome, Edge, Arc, Brave or even Firefox run by the agent/subscription you already use (Claude Code, Codex, Antigravity). Free, open source, no API key. Also an MCP server.

fix(sessions): redact tool inputs before they are persisted

Shahriard94ef53b7cd9
diff --git a/lib/bridge/redact.ts b/lib/bridge/redact.ts
new file mode 100644
index 0000000..bf3c922
--- /dev/null
+++ b/lib/bridge/redact.ts
@@ -0,0 +1,34 @@
+import { isSensitiveField } from '@/lib/recordings/events';
+
+const REDACTED = '[redacted]';
+const MAX_STRING = 200;
+const MAX_ITEMS = 20;
+const MAX_DEPTH = 4;
+
+function redactValue(key: string, value: unknown, depth: number): unknown {
+ if (typeof value === 'string') {
+ if (isSensitiveField({ name: key, id: key, value })) return REDACTED;
+ return value.length > MAX_STRING ? `${value.slice(0, MAX_STRING)}…` : value;
+ }
+ if (typeof value === 'number' || typeof value === 'boolean' || value === null) return value;
+ if (depth >= MAX_DEPTH) return '[…]';
+ if (Array.isArray(value)) {
+ const items = value.slice(0, MAX_ITEMS).map((item) => redactValue(key, item, depth + 1));
+ return value.length > MAX_ITEMS ? [...items, '…'] : items;
+ }
+ if (typeof value === 'object') {
+ const out: Record<string, unknown> = {};
+ for (const [name, nested] of Object.entries(value as Record<string, unknown>)) {
+ out[name] = isSensitiveField({ name, id: name }) ? REDACTED : redactValue(name, nested, depth + 1);
+ }
+ return out;
+ }
+ return null;
+}
+
+export function redactInput(action: string, input: unknown): unknown {
+ if (!input || typeof input !== 'object') return redactValue('', input, 0);
+ const redacted = redactValue('', input, 0) as Record<string, unknown>;
+ if (action === 'page.fillInput' && 'value' in redacted) redacted.value = REDACTED;
+ return redacted;
+}
diff --git a/lib/bridge/use-run.ts b/lib/bridge/use-run.ts
index 9e3a996..e666c22 100644
--- a/lib/bridge/use-run.ts
+++ b/lib/bridge/use-run.ts
@@ -3,6 +3,7 @@ import { browser, type Browser } from 'wxt/browser';
import { BRIDGE_CHANNEL, type RunEvent } from '@/lib/actions/protocol';
import type { RecordingState } from '@/lib/recordings/events';
import { SITE_MAPPER_SKILL, type SiteMapDraft } from '@/lib/skills/site-map';
+import { redactInput } from './redact';
import { RUN_PORT, type RunCommand, type RunMessage } from './run-port';
import { isNaming, listSessions, putSession, readTranscript, titleDueAt, type SessionFields } from './session-store';
@@ -22,7 +23,7 @@ export type RunItem =
summary?: string;
ok?: boolean;
awaiting?: boolean;
- source?: 'local';
+ source?: 'local' | 'external';
};
export interface Run {
@@ -314,7 +315,13 @@ function reduce(items: RunItem[], event: RunEvent): RunItem[] {
case 'tool':
return [
...items,
- { kind: 'tool', id: event.toolId, action: event.action, input: event.input, source: event.source },
+ {
+ kind: 'tool',
+ id: event.toolId,
+ action: event.action,
+ input: redactInput(event.action, event.input),
+ source: event.source,
+ },
];
case 'approval':