import type { TraceLocation, TraceLocationType } from './trace_location'; import type { TraceState } from './trace_state'; /** * Interface for token usage information */ export interface TokenUsage { input_tokens: number; output_tokens: number; total_tokens: number; } /** * Metadata about a trace, such as its ID, location, timestamp, etc. */ export declare class TraceInfo { /** * The primary identifier for the trace */ traceId: string; /** * The location where the trace is stored */ traceLocation: TraceLocation; /** * Start time of the trace, in milliseconds */ requestTime: number; /** * State of the trace */ state: TraceState; /** * Request to the model/agent (JSON-encoded, may be truncated) */ requestPreview?: string; /** * Response from the model/agent (JSON-encoded, may be truncated) */ responsePreview?: string; /** * Client supplied request ID associated with the trace */ clientRequestId?: string; /** * Duration of the trace, in milliseconds */ executionDuration?: number; /** * Key-value pairs associated with the trace (immutable) */ traceMetadata: Record; /** * Tags associated with the trace (mutable) */ tags: Record; /** * List of assessments associated with the trace. * TODO: Assessments are not yet supported in the TypeScript SDK. */ assessments: any[]; /** * Create a new TraceInfo instance * @param params TraceInfo parameters */ constructor(params: { traceId: string; traceLocation: TraceLocation; requestTime: number; state: TraceState; requestPreview?: string; responsePreview?: string; clientRequestId?: string; executionDuration?: number; traceMetadata?: Record; tags?: Record; assessments?: any[]; }); /** * Convert this TraceInfo instance to JSON format * @returns JSON object representation of the TraceInfo */ toJson(): SerializedTraceInfo; /** * Get aggregated token usage information for this trace. * Returns null if no token usage data is available. * @returns Token usage object or null */ get tokenUsage(): TokenUsage | null; /** * Create a TraceInfo instance from JSON data * @param json JSON object containing trace info data * @returns TraceInfo instance */ static fromJson(json: SerializedTraceInfo): TraceInfo; } export interface SerializedTraceInfo { trace_id: string; client_request_id?: string; trace_location: { type: TraceLocationType; mlflow_experiment?: { experiment_id: string; }; inference_table?: { full_table_name: string; }; }; request_preview?: string; response_preview?: string; request_time: string; execution_duration?: string; state: TraceState; trace_metadata: Record; tags: Record; assessments: any[]; }