export declare const SECRET_SWAP_ENABLED_SETTING = "ELIZA_SECRET_SWAP_ENABLED"; export declare const SECRET_SWAP_EXEMPT_VALUES_SETTING = "ELIZA_SECRET_SWAP_EXEMPT_VALUES"; /** * Honest model-param graphs are a handful of objects deep. JSON.parse still * admits a 20k-deep nest that then RangeError'd `substituteInValue` on * origin develop. */ export declare const MAX_SECRET_SWAP_WALK_DEPTH = 64; export declare const MAX_SECRET_SWAP_WALK_NODES = 100000; export declare const SECRET_SWAP_UNBOUNDED = "SECRET_SWAP_UNBOUNDED"; export declare function isSecretSwapUnbounded(error: unknown): boolean; export declare class SecretSwapUnresolvedPlaceholderError extends Error { readonly placeholders: string[]; constructor(placeholders: string[]); } export type SecretSwapEntry = { placeholder: string; value: string; kind: string; }; export type SecretSwapSessionOptions = { knownSecrets?: Record; exemptValues?: Iterable; /** * PII/token detector classes to disable (false-positive opt-out by class, * e.g. `["phone", "ipv4"]`). Complements `exemptValues` (opt-out by value). */ disabledKinds?: Iterable; }; export declare class SecretSwapSession { private readonly replyProtectedValues; private readonly valueToEntry; private readonly placeholderToEntry; private readonly exemptValues; private readonly disabledKinds; /** * Longest token (secret value or minted placeholder) the session holds, * maintained incrementally as entries are added. The streaming guard * ({@link./guarded-stream}) reads this to size its carry-over window: a known * secret that arrives split across two chunks must be held whole, so the guard * never emits a chunk shorter than the longest value it might straddle. */ private maxToken; /** Per-session nonce woven into every placeholder so it is unforgeable. */ private readonly nonce; /** Restores only placeholders minted for this session. Other or absent nonces remain text; unresolved current-session placeholders fail explicitly. */ private readonly placeholderPattern; /** Per-value compiled patterns, scoped to the session so secret values never outlive it. */ private readonly replacePatterns; private readonly containsPatterns; constructor(options?: SecretSwapSessionOptions); get entries(): SecretSwapEntry[]; /** Length of the longest value/placeholder held (0 when empty). */ get maxTokenLength(): number; /** * Learn every secret and PII value in `text` without rewriting it. Returns * the credential capture spans that {@link substituteText} splices first. */ private learnText; substituteText(text: string): string; /** * Replace every known value with its placeholder, longest first so a value * that is a substring of another does not corrupt the longer placeholder. */ private replaceKnownValues; private containsValue; substituteInValue(value: T): T; /** Restore personal data only at the local user-reply boundary, never credentials. */ restoreUserReplyText(text: string): string; /** * Apply the user-reply policy to text whose values were already restored * (tool-call sends: the execution boundary restores handler args). Known * values go back to placeholders, then {@link restoreUserReplyText} decides * what stays readable, so both reply paths share one policy. */ redactRestoredSecretValues(text: string): string; /** True when `value` overlaps (either contains or is contained in) a reply-protected value. */ private isReplyProtected; restoreText(text: string, options?: { failOnUnresolved?: boolean; }): string; restoreInValue(value: T, options?: { failOnUnresolved?: boolean; }): T; assertNoUnresolvedPlaceholders(value: unknown): void; private entryForValue; } export declare function parseSecretSwapExemptValues(value: unknown): string[];