/** * Cost / token accumulation helpers for RunHandleImpl. * * Pure functions extracted so the main run-handle implementation stays * focused on orchestration (state machine, iterators, thenable). No behavior * change — these are the exact mutations previously inlined in * RunHandleImpl._accumulate and RunHandleImpl._buildResult. */ import type { CostEvent, TokenUsageEvent } from './events.js'; import type { TokenUsageSummary } from './run-handle.js'; export interface CostAccumulator { totalUsd: number; inputTokens: number; outputTokens: number; thinkingTokens: number; cachedTokens: number; cacheCreationTokens: number; cacheReadTokens: number; } export interface TokenAccumulator { inputTokens: number; outputTokens: number; thinkingTokens: number; cachedTokens: number; cacheCreationTokens: number; cacheReadTokens: number; } /** Fold a `token_usage` event into the running accumulator. */ export declare function accumulateTokenUsage(acc: TokenAccumulator, event: TokenUsageEvent): void; /** * Fold a `cost` event into the running accumulator. Returns the new * accumulator (which may be a freshly allocated record on the first call). */ export declare function accumulateCost(current: CostAccumulator | null, event: CostEvent): CostAccumulator; /** Build the token usage summary, or null when no usage was seen. */ export declare function buildTokenUsageSummary(acc: TokenAccumulator): TokenUsageSummary | null;