/** User-visible browser cowork lines for the Oo's thread context (German product copy is applied in UI). */ export type BrowserUserActionKind = "navigate" | "click" | "type" | "scroll" | "page_change"; export function maskBrowserUserDetail(detail: string, passwordField = false): string { if (passwordField) return "••••••"; const trimmed = detail.trim(); if (!trimmed) return trimmed; if (/password|passwort|pin|secret|token|api[_-]?key/i.test(trimmed)) return "••••••"; return trimmed.slice(0, 500); } export function browserUserContextLine( kind: BrowserUserActionKind, detail: string, passwordField = false, ): string { const safe = maskBrowserUserDetail(detail, passwordField); switch (kind) { case "navigate": return `User navigated to ${safe}`; case "click": return `User clicked ${safe}`; case "type": return passwordField ? "User typed in a password field" : `User typed ${safe}`; case "scroll": return `User scrolled ${safe}`; case "page_change": return `User page changed to ${safe}`; default: { const _exhaustive: never = kind; return _exhaustive; } } }