/** * Utility functions for working with ExecutionTrace. * * Provides factory functions, timing helpers, and trace aggregation utilities. */ import { ExecutionTrace } from "./execution-trace.js"; import type { ExecutionTraceData } from "./types.js"; /** * Create a new execution trace for a strategy. * * @param strategyName - Name of the strategy * @param strategyVersion - Version of the strategy * @returns New ExecutionTrace instance */ export declare function createTrace(strategyName: string, strategyVersion: string): ExecutionTrace; /** * Merge multiple traces into a summary. * * Useful for aggregating traces from sub-strategies or parallel execution. */ export declare function mergeTraces(traces: ExecutionTraceData[]): { totalDuration: number; totalDecisions: number; totalErrors: number; metrics: Record; }; /** * Create a timing helper for measuring durations. * * @param trace - Trace to record timing to * @param metricName - Name of the timing metric * @returns Function to call when operation completes * * @example * ```typescript * const endTiming = startTiming(trace, 'generation_time_ms'); * await generateDocument(); * endTiming(); // Records duration to trace * ``` */ export declare function startTiming(trace: ExecutionTrace, metricName: string): () => number; /** * Wrap an async operation with automatic error tracing. * * @param trace - Trace to record to * @param operation - Async operation to wrap * @param context - Context to include if error occurs * * @example * ```typescript * const result = await withErrorTracing( * trace, * () => fetchData(url), * { url, operation: 'fetch-data' } * ); * ``` */ export declare function withErrorTracing(trace: ExecutionTrace, operation: () => Promise, context?: Record): Promise; //# sourceMappingURL=trace-utils.d.ts.map