/** * Audit log — append-only forensic record of every LLM call. * * Lives at ~/.blockrun/franklin-audit.jsonl. One line per call, JSONL. * Unlike franklin-stats.json (aggregates), this file lets you answer * "what was I actually doing when $1.50 disappeared on Apr 12?". * * Fields kept intentionally small (truncated prompt, no tool args) so the * file stays readable and doesn't leak large tool outputs to disk. */ export interface AuditEntry { ts: number; sessionId?: string; model: string; inputTokens: number; outputTokens: number; /** * Anthropic prompt-cache fields, captured when the model reports them * in `usage.cache_creation_input_tokens` / `usage.cache_read_input_tokens`. * `inputTokens` above is the *uncached* portion; the cache fields are * additional billed input the gateway charges for separately. Without * these, vision and cache-heavy sessions show a wildly inconsistent * cost-per-token ratio in audit dashboards — verified 2026-05-11 from * an Opus 4.7 call with inputTokens=3653 but costUsd=$0.567 (implies * ~113K real billed tokens once cache_creation is counted). */ cacheCreationInputTokens?: number; cacheReadInputTokens?: number; costUsd: number; latencyMs?: number; fallback?: boolean; source: 'agent' | 'proxy' | 'subagent' | 'moa' | 'plugin'; workDir?: string; prompt?: string; toolCalls?: string[]; routingTier?: string; } export declare function appendAudit(entry: AuditEntry): void; /** * Trim the audit log to the last MAX_AUDIT_ENTRIES lines if it has grown * past the cap. Exported so admin/debug tooling (and tests) can force a * compaction without waiting for the next interval probe. */ export declare function enforceRetention(): void; export declare function getAuditFilePath(): string; export declare function readAudit(): AuditEntry[]; /** Pull the last user message from a Dialogue history, flatten, and strip newlines. */ export declare function extractLastUserPrompt(history: Array<{ role: string; content: unknown; }>): string | undefined;