/** * Redact sensitive substrings from tool responses before they leave the * MCP boundary. * * Tool outputs frequently include filesystem paths (with the user's home * directory in them), token-shaped strings, hostnames, IP addresses, and * bundle identifiers. None of those are useful to an AI agent reasoning * about an iOS leak, and all of them are footguns when the output ends * up in a Slack message, a PR comment, or a screenshot. This module * scrubs them at the formatter boundary so by-default outputs are safe * to share without manual sweeping. * * Three modes are selected via the `MEMORYDETECTIVE_REDACTION` env var: * * - `balanced` (default): home-directory absolute paths become `~/...`, * common secret-shaped tokens (AWS keys, GitHub PATs, Stripe secrets, * Slack tokens, Bearer auth) are masked. Hostnames, IPs, bundle IDs, * process names, and class names are preserved (they are usually * useful for debugging). * * - `strict`: everything in `balanced`, plus hostnames, IPv4 addresses, * and bundle identifiers. Use when the output is going to be pasted * into a public artifact (issue tracker, blog post, social) and you * want a wide safety margin. * * - `off`: no redaction. Default behavior is preserved for legacy * workflows and for local-only debugging where the noise is genuinely * helpful. The startup banner logs the active mode so an operator * running `off` knows the responses are unfiltered. * * Redaction is structural: the value passed in keeps its shape (same * object keys, same array lengths, same scalar types), only string * leaves are rewritten. Numbers, booleans, null/undefined, and dates * pass through unchanged. */ export type RedactionMode = "balanced" | "strict" | "off"; /** * Pure: read the active redaction mode from an env-like object. * Defaults to `balanced` when unset or set to an unrecognized value. * * Threaded as a parameter for testability; production callers omit it * and get `process.env`. */ export declare function getRedactionMode(env?: Readonly>): RedactionMode; /** * Pure: scrub a single string per the active mode. `off` returns the * input unchanged; the other modes apply the rules described in the * module doc. * * Threaded `homeDir` for testability so unit tests can pass a fake * `/Users/test/` without depending on the real home directory. */ export declare function redactString(input: string, mode: RedactionMode, homeDir?: string): string; /** * Pure: recursively redact strings inside an arbitrary JSON-shaped * value. Object key names are preserved unchanged (they are part of * the schema, not data); only string VALUES and string ARRAY items * are scrubbed. * * Non-string scalars (number, boolean, null) pass through. Functions, * symbols, and other non-JSON values are returned as-is. */ export declare function redact(value: unknown, mode: RedactionMode, homeDir?: string): unknown; export declare function maybeLogRedactionModeOnce(mode: RedactionMode, writer?: (line: string) => void): void; /** Test-only: reset the once-per-instance log flag. */ export declare function resetRedactionAdvisoryFlagForTests(): void;