/** * Which tools were used, rolled up the same way the proxy's requests are. * * THE MCP SURFACE WAS THE BLIND SPOT. `rollup.ts` counts what passes through * the proxy, and a user who never runs the proxy -- which is most of them, * since the tools are the product -- reported nothing at all. Every tool call * already goes out through one function, so a single call from there covers * the whole catalog and no tool can be added later without being counted. * * THE TOOL NAME IS A KEY, NOT A VALUE, and that is the only reason it can be * sent at all. `sanitiseProperties` drops strings, so a name in a value would * vanish silently and the event would say a call happened without saying what * ran. Keys are not sanitised, so this module does that job itself, and it * does it by refusing rather than by escaping: a name the server did not * advertise, or one that is not lower-case ascii, or one arriving after this * window already holds MAX_TOOL_KEYS distinct tools, is counted under * `unknown`. The request names the tool, so an unfiltered name would be a * string channel running from the caller straight into the payload. * * ELAPSED TIME IS A SUM, NOT A LIST. Total milliseconds over total calls is a * mean, which is what a field report can act on; a distribution would need * either per-call rows -- the thing a rollup exists to avoid -- or buckets * nobody has yet had a reason to choose. * * CONSENT IS NOT DECIDED HERE. Counting happens in memory whatever the policy * says; `record` is the gate and checks it on every call. See `rollup.ts`. */ import { record } from './recorder.js'; /** Tool calls per rollup. Matches the proxy's window, for the same reasons. */ export declare const TOOL_ROLLUP_EVERY = 200; /** * How many distinct tools one window may name. * * A bound on the event's size that holds even if a caller ever passes * `advertised` as true when it should not. The catalog is under a hundred * tools and a session touches a handful, so this is not reached in practice. */ export declare const MAX_TOOL_KEYS = 64; /** * Count one tool call, and emit a rollup when the window is full. * * `advertised` is the server's own answer to whether it offers this tool, and * it is required rather than defaulted: which value is the safe one depends on * what the caller knows, and a default would pick one on behalf of a call site * that had not thought about it. */ export declare function noteToolCall(name: string, elapsedMs: number, ok: boolean, advertised: boolean, env?: NodeJS.ProcessEnv): ReturnType; /** Write what has accumulated, if anything has. Called at shutdown. */ export declare function flushToolRollup(env?: NodeJS.ProcessEnv): ReturnType; /** The counts not yet emitted. For `doctor` and for tests. */ export declare function pendingToolCounts(): Readonly>; /** Drop everything counted so far without writing it. Tests, and `emit`. */ export declare function resetToolRollup(): void; //# sourceMappingURL=tool-rollup.d.ts.map