import { type DecisionTelemetryIdSource } from './context.js'; import type { DecisionBatchReceipt } from '../batch-receipts/types.js'; import { type DecisionSpanName, type DecisionTelemetryContext, type DecisionTelemetryLink, type DecisionTelemetrySpan, type DecisionTelemetryTrace, type TelemetryAttributes, type TelemetryProvenance } from './types.js'; export interface StartSpanOptions { parent?: DecisionTelemetryContext; attributes?: TelemetryAttributes; provenance?: Record; links?: DecisionTelemetryLink[]; startTimeUnixMs?: number; } export declare class DecisionTraceBuilder { private readonly ids?; private readonly now; private readonly spans; private readonly batchUsage; private root?; constructor(ids?: DecisionTelemetryIdSource | undefined, now?: () => number); startSpan(name: DecisionSpanName, options?: StartSpanOptions): DecisionTelemetrySpan; /** Merge allowlisted metadata into a recorded span; unknown or protected keys are dropped. */ annotate(span: DecisionTelemetrySpan, attributes: TelemetryAttributes, provenance?: Record): void; /** Spans that were started but not yet ended, in start order. */ openSpans(): DecisionTelemetrySpan[]; endSpan(span: DecisionTelemetrySpan, status?: DecisionTelemetrySpan['status'], endTimeUnixMs?: number): void; /** Shared provider usage belongs to exactly one batch request span. */ recordBatchUsage(span: DecisionTelemetrySpan, batchId: string, usage: { inputTokens: number | null; outputTokens: number | null; costUsd: number | null; }, provider?: { requestId?: string | null; actualModel?: string | null; }, options?: { accountingKey?: string; costProvenance?: TelemetryProvenance; }): void; build(): DecisionTelemetryTrace; } /** * Emit transport-attempt spans from the durable accounting authority. Each * consumed provider attempt owns its usage exactly once, including failed * retry/fallback attempts. Per-answer allocations remain off these spans. * * `started` holds live `decision.batch.request` spans keyed by attempt ordinal. * The evaluator opens them before dispatch, so the propagated `traceparent` * and the live start time belong to the span that later receives the receipt's * accounting. Attempts without a live span are reconstructed from the receipt. */ export declare function recordBatchReceiptTrace(builder: DecisionTraceBuilder, receipt: DecisionBatchReceipt, parent: DecisionTelemetryContext, started?: ReadonlyMap): DecisionTelemetrySpan[]; export declare function estimatedUsageAllocation(total: number, weights: readonly number[], method: string, version: string): Array<{ value: number; provenance: 'estimate'; method: string; version: string; }>; //# sourceMappingURL=trace.d.ts.map