/** * Trace types for workflow execution data. * * These types represent the structure of trace files generated during workflow execution, * used for debugging, visualization, and analysis of workflow runs. */ /** Node kind values for trace events */ export type NodeKind = 'workflow' | 'activity' | 'step' | 'internal_step' | string; /** Phase of a trace event lifecycle */ export type NodePhase = 'start' | 'end' | 'error' | string; /** Execution status of a node */ export type NodeStatus = 'completed' | 'failed' | 'running' | string; /** * Details associated with a trace event. * Contains input/output data and identifying information for the event. */ export interface TraceDetails { /** Input data passed to the step/activity */ input?: unknown; /** Output data returned from the step/activity */ output?: unknown; /** Name of the activity (for activity events) */ activityName?: string; /** Name of the step (for step events) */ stepName?: string; /** Generic name field */ name?: string; } /** * A trace event representing a point in workflow execution. * Used for timeline display and event-based analysis. */ export interface TraceEvent { /** The type of event (workflow, activity, step, etc.) */ kind: NodeKind; /** The lifecycle phase of the event */ phase: NodePhase; /** Unix timestamp when the event occurred */ timestamp: number; /** Unique identifier for the workflow run */ workflowId: string; /** Name of the workflow being executed */ workflowName: string; /** Additional event details including input/output */ details?: TraceDetails; /** Child events for nested executions */ children?: TraceEvent[]; /** Error information if the event represents a failure */ error?: unknown; /** Duration of the event in milliseconds */ duration?: number; } /** * A node in the debug tree representation of workflow execution. * Contains more detailed timing and state information than TraceEvent. */ export interface DebugNode { /** The type of node (workflow, activity, step, internal_step) */ kind?: NodeKind; /** Alternative type field */ type?: string; /** The name of the step or activity */ name?: string; /** Name of the workflow (for workflow nodes) */ workflowName?: string; /** Name of the step (for step nodes) */ stepName?: string; /** Name of the activity (for activity nodes) */ activityName?: string; /** The lifecycle phase of the node */ phase?: NodePhase; /** Execution status (completed, failed, running) */ status?: NodeStatus; /** Unix timestamp or ISO string when execution started */ startedAt?: number | string; /** Unix timestamp when the event occurred */ timestamp?: number | string; /** Unix timestamp or ISO string when execution ended */ endedAt?: number | string; /** Unix timestamp when execution started (alternative field) */ startTime?: number; /** Unix timestamp when execution ended (alternative field) */ endTime?: number; /** Execution duration in milliseconds */ duration?: number; /** Input data passed to the step/activity */ input?: unknown; /** Output data returned from the step/activity */ output?: unknown; /** Additional execution details */ details?: Record; /** Error information if the node failed */ error?: unknown; /** Child nodes representing nested executions */ children?: DebugNode[]; } /** * Root structure of a workflow trace. * Contains the execution tree and optional flat event list. */ export interface TraceStructure { /** Root node of the execution tree */ root?: TraceEvent | DebugNode; /** Flat list of execution events for timeline display */ events?: TraceEvent[]; /** Hierarchical tree of execution nodes (alternative to root.children) */ children?: DebugNode[]; } /** * The structure of a workflow trace file generated by Output.ai workflow runs. * This file is written to the local filesystem during workflow execution and contains * the complete execution history including timing, inputs, outputs, and any errors. */ export interface TraceData { /** Root workflow execution information */ root: { /** The name of the workflow that was executed */ workflowName: string; /** Unique identifier for this workflow run */ workflowId: string; /** Unix timestamp when the workflow started */ startTime: number; /** Unix timestamp when the workflow ended */ endTime?: number; /** Total workflow duration in milliseconds */ duration?: number; /** Final workflow status */ status?: string; /** Error information if the workflow failed */ error?: unknown; }; /** Flat list of execution events for timeline display */ events?: Array<{ name: string; phase: string; timestamp: number; details?: unknown; }>; /** Hierarchical tree of execution nodes */ children?: DebugNode[]; } /** * Extracted node information for display formatting. * Used internally by the trace formatter. */ export interface NodeInfo { /** Display name for the node */ name: string; /** Formatted phase indicator */ phase: string; /** Formatted duration string */ duration: string; } /** * Type guard to check if a node is a TraceEvent. */ export declare const isTraceEvent: (node: TraceEvent | DebugNode) => node is TraceEvent; /** * Type guard to check if a value is a valid timestamp. */ export declare const isValidTimestamp: (value: unknown) => value is number | string;