/** * MCP call records at rest (DES-MCP-TOOLS-001 §5, D-3): `/mcp/calls.ndjson`, one OTel * span-shaped record per brokered call. Arguments and results are never captured. * * The broker writes a record for every call it judged, whatever the outcome, and a call whose * record cannot be written is refused (`guard_error`): its result is withheld. Appends are * serialized on one promise chain so two concurrent calls never interleave a line. * * The usage slice (S7) reads the records back on the same chain. A read first folds every record * that started more than {@link MCP_CALLS_RAW_DAYS} days ago into `calls-daily.ndjson` (one row per * UTC day × subject × seat × decision: calls, errors, total ms) and rewrites `calls.ndjson` without * them (write a temp file, then rename). The fold runs on demand, never on a timer. */ import type { McpCallDecision, McpCallRecord } from '../core/types.js'; export declare const MCP_CALLS_FILENAME = "calls.ndjson"; export declare const MCP_CALLS_DAILY_FILENAME = "calls-daily.ndjson"; /** Records stay raw this long; older ones are folded into the daily file. */ export declare const MCP_CALLS_RAW_DAYS = 30; export interface McpCallRecordSink { append(record: McpCallRecord): Promise; } /** One row of `calls-daily.ndjson`. */ export interface McpCallDailyRow { day: string; subject: string; seat: string | null; decision: McpCallDecision; calls: number; errors: number; msTotal: number; } export interface McpCallRecordsRead { records: McpCallRecord[]; /** Lines that did not parse as a call record (kept in the file, left out of every fold). */ skipped: number; /** Records this read folded into the daily file. */ folded: number; } /** The records the usage fold reads. */ export interface McpCallRecordSource { read(now: number): Promise; } /** A parsed line when it has the fields the usage fold reads; otherwise `null`. */ export declare function parseCallRecord(line: string): McpCallRecord | null; /** Fold records into daily rows, sorted by day, subject, seat, decision. */ export declare function foldDaily(records: readonly McpCallRecord[]): McpCallDailyRow[]; export declare class McpCallRecordFile implements McpCallRecordSink, McpCallRecordSource { private readonly dir; private tail; constructor(dir?: string); get path(): string; get dailyPath(): string; append(record: McpCallRecord): Promise; /** * Every record of the last {@link MCP_CALLS_RAW_DAYS} days, after folding older ones into the * daily file. Serialized with the appends, so no call's line is lost to the rewrite. */ read(now: number): Promise; private serialize; } //# sourceMappingURL=call-records.d.ts.map