/** * Local JSON storage for ZPL history, watchlist, and reports. * Stores in ~/.zpl-engine/ directory. */ export interface HistoryEntry { id: string; timestamp: string; tool: string; question?: string; options?: string[]; domain?: string; results: Record; ain_scores: Record; } /** * Redact secret-shaped strings from any input. Same regex set as * addHistory() previously inlined — extracted here in v4.1.0 so the SAME * patterns can also be applied to tool error responses (index.ts) and to * any future place an engine response body might echo a key back. * * Patterns: * - ZPL keys (legacy + wizard prefix variants): `zpl_[us]_(?:[a-z]+_)?<20+ hex>` * - Bearer tokens (Authorization header echoes) * - Anthropic / OpenAI sk-* (and sk-ant-* — note hyphens INSIDE the body) * - Stripe sk_live_* / sk_test_* * - Groq gsk_* * * Returns the input unchanged if it contains no matches. Idempotent. */ export declare function sanitizeSecrets(input: string): string; export declare function getHistory(limit?: number): HistoryEntry[]; export declare function addHistory(entry: Omit): HistoryEntry; export declare function clearHistory(): number; /** * Best-effort token estimate for a single history entry. * Engine returns `tokens_used` per call — when tools persist that to * `results`, we use it directly. When they don't, we guess from tool * shape so quota/alert estimates aren't catastrophically wrong. * * Pre-v3.7.2 this was hardcoded `+= 5` everywhere, which under-counted * by 3-100x depending on dimension. Going forward, tools should save * `tokens_used` (or `totalTokens` for multi-call tools) in their history * results so this helper can return real numbers. */ export declare function estimateOpTokens(entry: HistoryEntry): number; export interface WatchlistItem { id: string; name: string; domain: string; input: Record; last_ain?: number; last_check?: string; added: string; notes?: string; } export declare function getWatchlist(): WatchlistItem[]; export declare function addToWatchlist(item: Omit): WatchlistItem; export declare function removeFromWatchlist(id: string): boolean; export declare function updateWatchlistItem(id: string, ain: number): void;