import { WorkflowEvent } from 'awaitly'; import { D as DecisionStartEvent, a as DecisionBranchEvent, b as DecisionEndEvent, O as OutputFormat, V as VisualizerOptions } from './url-CKfrOJ3y.js'; import { CollectableEvent } from './index.js'; import './performance-analyzer-DC60uCY-.js'; import './types-DjSWix07.js'; /** * awaitly/devtools * * Developer tools for workflow debugging, visualization, and analysis. * Provides timeline rendering, run diffing, and live visualization. */ /** * A recorded workflow run with events and metadata. */ interface WorkflowRun { /** Unique identifier for this run */ id: string; /** Workflow name */ name?: string; /** Start timestamp */ startTime: number; /** End timestamp (undefined if still running) */ endTime?: number; /** Duration in milliseconds */ durationMs?: number; /** Whether the workflow succeeded */ success?: boolean; /** Error if the workflow failed */ error?: unknown; /** All events from this run */ events: CollectableEvent[]; /** Custom metadata */ metadata?: Record; } /** * Difference between two workflow runs. */ interface RunDiff { /** Steps that were added in the new run */ added: StepDiff[]; /** Steps that were removed from the new run */ removed: StepDiff[]; /** Steps that changed between runs */ changed: StepDiff[]; /** Steps that are identical */ unchanged: string[]; /** Overall status change */ statusChange?: { from: "success" | "error" | "running"; to: "success" | "error" | "running"; }; /** Duration change in milliseconds */ durationChange?: number; } /** * Information about a step difference. */ interface StepDiff { /** Step name or key */ step: string; /** Type of change */ type: "added" | "removed" | "status" | "duration" | "error"; /** Previous value (for changes) */ from?: unknown; /** New value (for changes) */ to?: unknown; } /** * Timeline entry for a step. */ interface TimelineEntry { /** Step name */ name: string; /** Step key (if any) */ key?: string; /** Start time (relative to workflow start) */ startMs: number; /** End time (relative to workflow start) */ endMs?: number; /** Duration in milliseconds */ durationMs?: number; /** Step status */ status: "pending" | "running" | "success" | "error" | "skipped" | "cached"; /** Error if failed */ error?: unknown; /** Parent scope (for nested steps) */ parent?: string; /** Retry attempt number */ attempt?: number; } /** * Devtools configuration options. */ interface DevtoolsOptions extends VisualizerOptions { /** Enable console logging of events */ logEvents?: boolean; /** Maximum number of runs to keep in history */ maxHistory?: number; /** Custom logger function */ logger?: (message: string) => void; } /** * Devtools instance for workflow debugging. */ interface Devtools { /** Handle a workflow event */ handleEvent: (event: WorkflowEvent) => void; /** Handle a decision event */ handleDecisionEvent: (event: DecisionStartEvent | DecisionBranchEvent | DecisionEndEvent) => void; /** Get the current run */ getCurrentRun: () => WorkflowRun | undefined; /** Get run history */ getHistory: () => WorkflowRun[]; /** Get a specific run by ID */ getRun: (id: string) => WorkflowRun | undefined; /** Compare two runs */ diff: (runId1: string, runId2: string) => RunDiff | undefined; /** Compare current run with a previous run */ diffWithPrevious: () => RunDiff | undefined; /** Render current state */ render: () => string; /** Render to a specific format */ renderAs: (format: OutputFormat) => string; /** Render as Mermaid diagram */ renderMermaid: () => string; /** Render as ASCII timeline */ renderTimeline: () => string; /** Get timeline data for current run */ getTimeline: () => TimelineEntry[]; /** Clear all history */ clearHistory: () => void; /** Reset current run */ reset: () => void; /** Export run data as JSON */ exportRun: (runId?: string) => string; /** Import run data from JSON */ importRun: (json: string) => WorkflowRun; } /** * Create a devtools instance for workflow debugging. * * @example * ```typescript * const devtools = createDevtools({ workflowName: 'checkout' }); * * const workflow = createWorkflow(deps, { * onEvent: devtools.handleEvent, * }); * * await workflow.run(async ({ step }) => { ... }); * * // Visualize * console.log(devtools.render()); * console.log(devtools.renderMermaid()); * * // Compare with previous run * const diff = devtools.diffWithPrevious(); * ``` */ declare function createDevtools(options?: DevtoolsOptions): Devtools; /** * Render a run diff as a string. */ declare function renderDiff(diff: RunDiff): string; /** * Quick visualization helper for a single workflow run. */ declare function quickVisualize(workflowFn: (handleEvent: (event: WorkflowEvent) => void) => Promise, options?: DevtoolsOptions): Promise; /** * Create an event handler that logs to console with pretty formatting. */ declare function createConsoleLogger(options?: { prefix?: string; colors?: boolean; }): (event: WorkflowEvent) => void; export { type Devtools, type DevtoolsOptions, type RunDiff, type StepDiff, type TimelineEntry, type WorkflowRun, createConsoleLogger, createDevtools, quickVisualize, renderDiff };