/** * Aggregates recorded token and cost evidence per trace. Missing evidence remains distinct * from measured zero. */ import type { RecordedTrajectory } from "./trajectory-recorder.js"; /** The token/cost totals for one trajectory, or a group of them. */ export interface TrajectoryUsageTotals { promptTokens: number; completionTokens: number; cacheReadTokens: number; cacheCreationTokens: number; /** Sum of per-trajectory reasoning tokens (thinking/chain-of-thought spend), * mirroring `cacheCreationTokens`. Reported separately from * `totalTokens` because reasoning tokens are billed independently and * must be attributable. */ reasoningTokens: number; /** prompt + completion (cache tokens reported separately, mirroring the * orchestrator's `TaskUsageSummary.totalTokens` convention). */ totalTokens: number; costUsd: number; /** How many trajectory files contributed to these totals. */ trajectoryCount: number; } /** * Per-trace buckets and grand totals. Records without traceId form their own trajectory * bucket. */ export interface TrajectoryUsageRollup extends TrajectoryUsageTotals { byTrace: Array<{ traceId: string; } & TrajectoryUsageTotals>; } /** * Sum a set of recorded trajectories into a per-trace roll-up plus a grand * total. Trajectories are grouped by `traceId` (empty string when unset) so a * caller can attribute spend to a single logical run that fanned out across * parent + sub-agents. Additive and null-safe: a missing `metrics` block is * treated as zero, so a `running`/errored trajectory contributes nothing but * its presence. */ export declare function rollUpTrajectoryUsage(trajectories: readonly RecordedTrajectory[]): TrajectoryUsageRollup;