import type { EventEnvelope } from "./wireTypes.js"; /** Thin accessor layer over the wire format. Every place that reads * `ev.data.foo` directly is a leak of the wire format into consumer * code; if the runtime renames `usage.inputTokens` → `usage.promptTokens` * tomorrow (provider libraries do this constantly), we don't want to * chase the rename through every helper. Confine wire-format * knowledge to this one module. * * Rule for `lib/eval/`: no helper reads `ev.data.foo` directly — add * an accessor here first, then use it. Enforce in code review. */ /** Group events by their `data.type`. One pass; produces a plain * object (per AGENTS.md: prefer objects over Maps). */ export declare function groupByType(events: EventEnvelope[]): Record; /** Convenience: filter to one event type. Prefer `groupByType` when * you need multiple types in one pass. */ export declare function byType(events: EventEnvelope[], type: string): EventEnvelope[]; /** Epoch milliseconds for an event's timestamp. */ export declare function timestampMs(ev: EventEnvelope): number; /** Thread id stamped on a promptCompletion / toolCall / toolCallStart * by Task 0. Null for legacy traces (pre-prereq). */ export declare function threadIdOf(ev: EventEnvelope): string | null; /** Tool name on a toolCall / toolCallStart. */ export declare function toolNameOf(ev: EventEnvelope): string; /** Input-token count from a promptCompletion's `data.usage`. Returns * 0 if absent. The key name is locked here — if the runtime starts * using a different shape (`prompt_tokens`, `input_tokens`, …), * update this one site rather than chasing every consumer. */ export declare function tokensIn(ev: EventEnvelope): number; export declare function tokensOut(ev: EventEnvelope): number; /** USD cost on a promptCompletion. Reads `cost.totalCost` (TokenCost * shape from lib/statelogClient.ts). */ export declare function cost(ev: EventEnvelope): number; /** Model name on a promptCompletion. Strips wrapping quotes — call * sites in `lib/runtime/prompt.ts` pass `JSON.stringify(modelName)`, * which surrounds the string with quotes. */ export declare function modelOf(ev: EventEnvelope): string; /** Tools array advertised to the LLM on a promptCompletion. */ export declare function toolsOf(ev: EventEnvelope): string[]; /** Last user-role message content from a promptCompletion's * `data.messages` array. Returns null if no user message exists. * The "user message" is appended to the message thread after any * system prompt(s), so the LAST user-role entry in the first-turn * messages is the prompt the user just typed. */ export declare function userMessageOf(promptCompletion: EventEnvelope): string | null; /** Assistant's reply text on a promptCompletion. Returns null when * the completion is empty or absent. */ export declare function completionOf(promptCompletion: EventEnvelope): string | null;