awaitly-visualizer 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/index.browser.cjs +1677 -0
  2. package/dist/index.browser.cjs.map +1 -0
  3. package/dist/index.browser.d.cts +166 -0
  4. package/dist/index.browser.d.ts +166 -0
  5. package/dist/index.browser.js +1677 -0
  6. package/dist/index.browser.js.map +1 -0
  7. package/dist/index.cjs +1680 -0
  8. package/dist/index.cjs.map +1 -0
  9. package/dist/index.d.cts +242 -0
  10. package/dist/index.d.ts +242 -0
  11. package/dist/index.js +1680 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/kroki/fetch.cjs +3 -0
  14. package/dist/kroki/fetch.cjs.map +1 -0
  15. package/dist/kroki/fetch.d.cts +86 -0
  16. package/dist/kroki/fetch.d.ts +86 -0
  17. package/dist/kroki/fetch.js +3 -0
  18. package/dist/kroki/fetch.js.map +1 -0
  19. package/dist/notifiers/discord.cjs +3 -0
  20. package/dist/notifiers/discord.cjs.map +1 -0
  21. package/dist/notifiers/discord.d.cts +70 -0
  22. package/dist/notifiers/discord.d.ts +70 -0
  23. package/dist/notifiers/discord.js +3 -0
  24. package/dist/notifiers/discord.js.map +1 -0
  25. package/dist/notifiers/slack.cjs +38 -0
  26. package/dist/notifiers/slack.cjs.map +1 -0
  27. package/dist/notifiers/slack.d.cts +95 -0
  28. package/dist/notifiers/slack.d.ts +95 -0
  29. package/dist/notifiers/slack.js +38 -0
  30. package/dist/notifiers/slack.js.map +1 -0
  31. package/dist/notifiers/webhook.cjs +3 -0
  32. package/dist/notifiers/webhook.cjs.map +1 -0
  33. package/dist/notifiers/webhook.d.cts +115 -0
  34. package/dist/notifiers/webhook.d.ts +115 -0
  35. package/dist/notifiers/webhook.js +3 -0
  36. package/dist/notifiers/webhook.js.map +1 -0
  37. package/dist/performance-analyzer-B5VF5b1F.d.ts +663 -0
  38. package/dist/performance-analyzer-BNwE4AiO.d.cts +663 -0
  39. package/dist/types-BIZSmXif.d.ts +350 -0
  40. package/dist/types-BnWc9Wlr.d.cts +350 -0
  41. package/dist/url-PkfQz4V5.d.cts +750 -0
  42. package/dist/url-PkfQz4V5.d.ts +750 -0
  43. package/package.json +105 -0
@@ -0,0 +1,663 @@
1
+ import { F as FlowNode, S as ScopeStartEvent, e as ScopeEndEvent, b as DecisionStartEvent, c as DecisionBranchEvent, d as DecisionEndEvent, W as WorkflowIR, I as IRSnapshot, z as StepState, C as ColorScheme, t as Renderer, s as RenderOptions, H as HTMLRenderOptions, q as LiveVisualizerOptions, T as TimeTravelState, N as NodePerformance, m as HeatmapData, l as HeatLevel } from './url-PkfQz4V5.cjs';
2
+ import { WorkflowEvent } from 'awaitly/workflow';
3
+
4
+ /**
5
+ * Parallel Detection - Heuristic detection of parallel execution from timing.
6
+ *
7
+ * When steps overlap in time (one starts before another ends), they are
8
+ * likely running in parallel. This module detects such patterns and
9
+ * groups overlapping steps into ParallelNode structures.
10
+ */
11
+
12
+ /**
13
+ * Options for parallel detection.
14
+ */
15
+ interface ParallelDetectorOptions {
16
+ /**
17
+ * Minimum overlap in milliseconds to consider steps parallel.
18
+ * Default: 0 (any overlap counts)
19
+ */
20
+ minOverlapMs?: number;
21
+ /**
22
+ * Maximum gap in milliseconds to still consider steps as part of same parallel group.
23
+ * Default: 5 (steps starting within 5ms are grouped)
24
+ */
25
+ maxGapMs?: number;
26
+ }
27
+ /**
28
+ * Group overlapping steps into parallel nodes.
29
+ *
30
+ * Algorithm:
31
+ * 1. Sort steps by start time
32
+ * 2. For each step, check if it overlaps with existing parallel groups
33
+ * 3. If it overlaps, add to group; otherwise start new sequence
34
+ * 4. Merge overlapping groups when step bridges them
35
+ *
36
+ * Note: If real scope nodes (from scope_start/scope_end) are present,
37
+ * heuristic detection is skipped to avoid conflicts.
38
+ */
39
+ declare function detectParallelGroups(nodes: FlowNode[], options?: ParallelDetectorOptions): FlowNode[];
40
+ /**
41
+ * Create a parallel detector that processes nodes.
42
+ */
43
+ declare function createParallelDetector(options?: ParallelDetectorOptions): {
44
+ /**
45
+ * Process nodes and group overlapping ones into parallel nodes.
46
+ */
47
+ detect: (nodes: FlowNode[]) => FlowNode[];
48
+ };
49
+
50
+ /**
51
+ * IR Builder - Converts workflow events to Intermediate Representation.
52
+ *
53
+ * The builder maintains state as events arrive, constructing a tree
54
+ * representation of the workflow execution that can be rendered.
55
+ */
56
+
57
+ /**
58
+ * Options for the IR builder.
59
+ */
60
+ interface IRBuilderOptions {
61
+ /**
62
+ * Enable heuristic parallel detection based on timing.
63
+ * When true, overlapping steps are grouped into ParallelNodes.
64
+ * Default: true
65
+ */
66
+ detectParallel?: boolean;
67
+ /**
68
+ * Options for parallel detection.
69
+ */
70
+ parallelDetection?: ParallelDetectorOptions;
71
+ /**
72
+ * Enable snapshot recording for time-travel debugging.
73
+ * When true, the builder captures IR state after each event.
74
+ * Default: false
75
+ */
76
+ enableSnapshots?: boolean;
77
+ /**
78
+ * Maximum number of snapshots to keep (ring buffer behavior).
79
+ * When exceeded, oldest snapshots are discarded.
80
+ * Default: 1000
81
+ */
82
+ maxSnapshots?: number;
83
+ }
84
+ /**
85
+ * Creates an IR builder that processes workflow events.
86
+ */
87
+ declare function createIRBuilder(options?: IRBuilderOptions): {
88
+ handleEvent: (event: WorkflowEvent<unknown>) => void;
89
+ handleScopeEvent: (event: ScopeStartEvent | ScopeEndEvent) => void;
90
+ handleDecisionEvent: (event: DecisionStartEvent | DecisionBranchEvent | DecisionEndEvent) => void;
91
+ getIR: () => WorkflowIR;
92
+ reset: () => void;
93
+ getSnapshots: () => IRSnapshot[];
94
+ getSnapshotAt: (index: number) => IRSnapshot | undefined;
95
+ getIRAt: (index: number) => WorkflowIR | undefined;
96
+ clearSnapshots: () => void;
97
+ /** Check if there are active (running) steps */
98
+ readonly hasActiveSteps: boolean;
99
+ /** Get the current workflow state */
100
+ readonly state: StepState;
101
+ /** Get the number of recorded snapshots */
102
+ readonly snapshotCount: number;
103
+ /** Check if snapshot recording is enabled */
104
+ readonly snapshotsEnabled: boolean;
105
+ /** Enable or disable snapshot recording (e.g. for time-travel stop/start) */
106
+ setSnapshotsEnabled(enabled: boolean): void;
107
+ };
108
+ /**
109
+ * Type for the IR builder instance.
110
+ */
111
+ type IRBuilder = ReturnType<typeof createIRBuilder>;
112
+
113
+ /**
114
+ * ANSI color utilities for terminal output.
115
+ */
116
+
117
+ /**
118
+ * Default ANSI color scheme for step states.
119
+ */
120
+ declare const defaultColorScheme: ColorScheme;
121
+
122
+ /**
123
+ * ASCII Terminal Renderer
124
+ *
125
+ * Renders the workflow IR as ASCII art with box-drawing characters
126
+ * and ANSI colors for terminal display.
127
+ */
128
+
129
+ /**
130
+ * Create the ASCII terminal renderer.
131
+ */
132
+ declare function asciiRenderer(): Renderer;
133
+
134
+ /**
135
+ * Mermaid Diagram Renderer
136
+ *
137
+ * Renders the workflow IR as a Mermaid flowchart diagram.
138
+ * Supports sequential flows, parallel (subgraph), and race patterns.
139
+ */
140
+
141
+ /**
142
+ * Create the Mermaid diagram renderer.
143
+ */
144
+ declare function mermaidRenderer(): Renderer;
145
+
146
+ /**
147
+ * Logger Renderer - Outputs structured JSON optimized for logging systems.
148
+ *
149
+ * Works with any structured logger (Pino, Winston, Bunyan, console).
150
+ * Includes workflow summary, step details, and optional ASCII diagram.
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * const logData = JSON.parse(viz.renderAs('logger'));
155
+ * logger.info(logData, 'Workflow completed');
156
+ * ```
157
+ */
158
+
159
+ /**
160
+ * Step log entry with execution details.
161
+ */
162
+ interface StepLog {
163
+ id: string;
164
+ name: string;
165
+ key?: string;
166
+ state: string;
167
+ durationMs?: number;
168
+ startTs?: number;
169
+ endTs?: number;
170
+ retryCount?: number;
171
+ timedOut?: boolean;
172
+ timeoutMs?: number;
173
+ error?: string;
174
+ }
175
+ /**
176
+ * Hook execution log entry.
177
+ */
178
+ interface HookLog {
179
+ shouldRun?: {
180
+ result?: boolean;
181
+ durationMs?: number;
182
+ error?: string;
183
+ };
184
+ onBeforeStart?: {
185
+ durationMs?: number;
186
+ error?: string;
187
+ };
188
+ onAfterStep?: Array<{
189
+ stepKey: string;
190
+ durationMs?: number;
191
+ error?: string;
192
+ }>;
193
+ }
194
+ /**
195
+ * Summary statistics for the workflow.
196
+ */
197
+ interface WorkflowSummary {
198
+ totalSteps: number;
199
+ successCount: number;
200
+ errorCount: number;
201
+ cacheHits: number;
202
+ skippedCount: number;
203
+ totalRetries: number;
204
+ slowestStep?: {
205
+ name: string;
206
+ durationMs: number;
207
+ };
208
+ }
209
+ /**
210
+ * Complete logger output structure.
211
+ */
212
+ interface LoggerOutput {
213
+ workflow: {
214
+ id: string;
215
+ name?: string;
216
+ state: string;
217
+ durationMs?: number;
218
+ startedAt?: number;
219
+ completedAt?: number;
220
+ };
221
+ steps: StepLog[];
222
+ summary: WorkflowSummary;
223
+ hooks?: HookLog;
224
+ diagram?: string;
225
+ }
226
+ /**
227
+ * Extended render options for logger renderer.
228
+ */
229
+ interface LoggerRenderOptions extends RenderOptions {
230
+ /** Include ASCII diagram in output (default: true) */
231
+ includeDiagram?: boolean;
232
+ /** Strip ANSI color codes from diagram (default: true) */
233
+ stripAnsiColors?: boolean;
234
+ /** Diagram format: 'ascii' (tree-style) or 'flowchart' (boxes/arrows) (default: 'ascii') */
235
+ diagramFormat?: "ascii" | "flowchart";
236
+ }
237
+ /**
238
+ * Create a logger renderer that outputs structured JSON.
239
+ *
240
+ * @example
241
+ * ```typescript
242
+ * const viz = createVisualizer({ workflowName: 'checkout' });
243
+ * // ... run workflow ...
244
+ *
245
+ * const logData = JSON.parse(viz.renderAs('logger'));
246
+ * logger.info(logData, 'Workflow completed');
247
+ * ```
248
+ */
249
+ declare function loggerRenderer(): Renderer;
250
+
251
+ /**
252
+ * Flowchart ASCII Renderer
253
+ *
254
+ * Renders workflow IR as a proper flowchart with boxes and arrows.
255
+ * Uses a 2D canvas approach for spatial layout with proper fork/join patterns.
256
+ */
257
+
258
+ declare function flowchartRenderer(): Renderer;
259
+
260
+ /**
261
+ * HTML Renderer
262
+ *
263
+ * Renders the workflow IR as an interactive HTML page with:
264
+ * - SVG-based workflow diagram
265
+ * - Zoom and pan
266
+ * - Node inspection
267
+ * - Time-travel controls
268
+ * - Performance heatmap overlay
269
+ */
270
+
271
+ /**
272
+ * Create the HTML renderer.
273
+ */
274
+ declare function htmlRenderer(): Renderer;
275
+ /**
276
+ * Render workflow IR to HTML with custom options.
277
+ */
278
+ declare function renderToHTML(ir: WorkflowIR, options?: Partial<HTMLRenderOptions>): string;
279
+
280
+ /**
281
+ * Live Visualizer - Real-time terminal updates during workflow execution.
282
+ *
283
+ * Uses ANSI escape codes to update the terminal in-place, showing
284
+ * workflow progress as it happens.
285
+ */
286
+
287
+ /**
288
+ * Live visualizer with real-time terminal updates.
289
+ */
290
+ interface LiveVisualizer {
291
+ /** Process a workflow event */
292
+ handleEvent: (event: WorkflowEvent<unknown>) => void;
293
+ /** Process a scope event */
294
+ handleScopeEvent: (event: ScopeStartEvent | ScopeEndEvent) => void;
295
+ /** Process a decision event */
296
+ handleDecisionEvent: (event: DecisionStartEvent | DecisionBranchEvent | DecisionEndEvent) => void;
297
+ /** Get current IR state */
298
+ getIR: () => WorkflowIR;
299
+ /** Render current state to string (without terminal output) */
300
+ render: () => string;
301
+ /** Start live rendering to terminal */
302
+ start: () => void;
303
+ /** Stop live rendering */
304
+ stop: () => void;
305
+ /** Force an immediate redraw */
306
+ refresh: () => void;
307
+ /** Reset state for a new workflow */
308
+ reset: () => void;
309
+ }
310
+ /**
311
+ * Create a live visualizer for real-time terminal updates.
312
+ *
313
+ * @example
314
+ * ```typescript
315
+ * const live = createLiveVisualizer({ workflowName: 'my-workflow' });
316
+ * const workflow = createWorkflow(deps, { onEvent: live.handleEvent });
317
+ *
318
+ * live.start();
319
+ * await workflow(async (step) => { ... });
320
+ * live.stop();
321
+ * ```
322
+ */
323
+ declare function createLiveVisualizer(options?: LiveVisualizerOptions): LiveVisualizer;
324
+
325
+ /**
326
+ * Decision Tracker - Helper for tracking conditional logic in workflows.
327
+ *
328
+ * This module provides utilities to track decision points (if/switch statements)
329
+ * so they can be visualized in workflow diagrams.
330
+ *
331
+ * @example
332
+ * ```typescript
333
+ * import { trackDecision } from 'awaitly-visualizer';
334
+ *
335
+ * const workflow = createWorkflow(deps, {
336
+ * onEvent: (event) => {
337
+ * // Pass events to visualizer
338
+ * viz.handleEvent(event);
339
+ * }
340
+ * });
341
+ *
342
+ * await workflow(async (step) => {
343
+ * const user = await step(fetchUser(id));
344
+ *
345
+ * // Track a decision point
346
+ * const decision = trackDecision('user-role-check', {
347
+ * condition: 'user.role === "admin"',
348
+ * value: user.role
349
+ * });
350
+ *
351
+ * if (user.role === 'admin') {
352
+ * decision.takeBranch('admin', true);
353
+ * await step(processAdminAction(user));
354
+ * } else {
355
+ * decision.takeBranch('user', false);
356
+ * await step(processUserAction(user));
357
+ * }
358
+ *
359
+ * decision.end();
360
+ * });
361
+ * ```
362
+ */
363
+
364
+ /**
365
+ * Options for creating a decision tracker.
366
+ */
367
+ interface DecisionTrackerOptions {
368
+ /** Condition being evaluated (e.g., "user.role === 'admin'") */
369
+ condition?: string;
370
+ /** Value being evaluated */
371
+ value?: unknown;
372
+ /** Name/label for this decision point */
373
+ name?: string;
374
+ /** Workflow ID (auto-generated if not provided) */
375
+ workflowId?: string;
376
+ /** Event emitter function */
377
+ emit?: (event: DecisionStartEvent | DecisionBranchEvent | DecisionEndEvent) => void;
378
+ }
379
+ /**
380
+ * Track a decision point in your workflow.
381
+ *
382
+ * Use this to annotate conditional logic (if/switch) so it appears
383
+ * in workflow visualizations.
384
+ *
385
+ * @param decisionId - Unique identifier for this decision
386
+ * @param options - Decision tracking options
387
+ * @returns A tracker object with methods to track branches
388
+ *
389
+ * @example
390
+ * ```typescript
391
+ * const decision = trackDecision('check-role', {
392
+ * condition: 'user.role === "admin"',
393
+ * value: user.role,
394
+ * emit: (event) => viz.handleDecisionEvent(event)
395
+ * });
396
+ *
397
+ * if (user.role === 'admin') {
398
+ * decision.takeBranch('admin', true);
399
+ * // ... admin logic
400
+ * } else {
401
+ * decision.takeBranch('user', false);
402
+ * // ... user logic
403
+ * }
404
+ *
405
+ * decision.end();
406
+ * ```
407
+ */
408
+ declare function trackDecision(decisionId: string, options?: DecisionTrackerOptions): DecisionTracker;
409
+ /**
410
+ * Decision tracker instance.
411
+ */
412
+ interface DecisionTracker {
413
+ /**
414
+ * Mark that a branch was taken or skipped.
415
+ * @param label - Label for this branch (e.g., "if", "else", "case 'admin'")
416
+ * @param taken - Whether this branch was executed
417
+ * @param branchCondition - Optional condition for this specific branch
418
+ */
419
+ takeBranch(label: string, taken: boolean, branchCondition?: string): void;
420
+ /**
421
+ * End the decision tracking.
422
+ * Call this after all branches have been evaluated.
423
+ */
424
+ end(): void;
425
+ /**
426
+ * Get which branch was taken.
427
+ */
428
+ getBranchTaken(): string | boolean | undefined;
429
+ /**
430
+ * Get all branches (taken and skipped).
431
+ */
432
+ getBranches(): Array<{
433
+ label: string;
434
+ condition?: string;
435
+ taken: boolean;
436
+ }>;
437
+ }
438
+ /**
439
+ * Track a simple if/else decision.
440
+ *
441
+ * @example
442
+ * ```typescript
443
+ * const decision = trackIf('check-admin', user.role === 'admin', {
444
+ * condition: 'user.role === "admin"',
445
+ * value: user.role,
446
+ * emit: (e) => viz.handleDecisionEvent(e)
447
+ * });
448
+ *
449
+ * if (decision.condition) {
450
+ * decision.then();
451
+ * // admin logic
452
+ * } else {
453
+ * decision.else();
454
+ * // user logic
455
+ * }
456
+ *
457
+ * decision.end();
458
+ * ```
459
+ */
460
+ declare function trackIf(decisionId: string, condition: boolean, options?: Omit<DecisionTrackerOptions, "value"> & {
461
+ value?: unknown;
462
+ }): IfTracker;
463
+ /**
464
+ * If tracker with convenience methods.
465
+ */
466
+ interface IfTracker extends DecisionTracker {
467
+ /** The condition value */
468
+ condition: boolean;
469
+ /** Mark the "if" branch as taken */
470
+ then(): void;
471
+ /** Mark the "else" branch as taken */
472
+ else(): void;
473
+ }
474
+ /**
475
+ * Track a switch statement decision.
476
+ *
477
+ * @example
478
+ * ```typescript
479
+ * const decision = trackSwitch('process-type', user.type, {
480
+ * emit: (e) => viz.handleDecisionEvent(e)
481
+ * });
482
+ *
483
+ * switch (user.type) {
484
+ * case 'admin':
485
+ * decision.case('admin', true);
486
+ * // admin logic
487
+ * break;
488
+ * case 'user':
489
+ * decision.case('user', true);
490
+ * // user logic
491
+ * break;
492
+ * default:
493
+ * decision.default(true);
494
+ * // default logic
495
+ * }
496
+ *
497
+ * decision.end();
498
+ * ```
499
+ */
500
+ declare function trackSwitch(decisionId: string, value: unknown, options?: Omit<DecisionTrackerOptions, "value">): SwitchTracker;
501
+ /**
502
+ * Switch tracker with convenience methods.
503
+ */
504
+ interface SwitchTracker extends DecisionTracker {
505
+ /** The value being switched on */
506
+ value: unknown;
507
+ /** Mark a case branch */
508
+ case(caseValue: string | number, taken: boolean): void;
509
+ /** Mark the default branch */
510
+ default(taken: boolean): void;
511
+ }
512
+
513
+ /**
514
+ * Time Travel Debugger
515
+ *
516
+ * Records IR snapshots at each event, enabling:
517
+ * - Step-by-step forward/backward navigation
518
+ * - Seeking to any point in execution
519
+ * - Playback at various speeds
520
+ * - State inspection at any moment
521
+ */
522
+
523
+ /**
524
+ * Options for the time-travel controller.
525
+ */
526
+ interface TimeTravelOptions {
527
+ /** Maximum snapshots to store (ring buffer) */
528
+ maxSnapshots?: number;
529
+ /** Automatically record snapshots on each event */
530
+ autoRecord?: boolean;
531
+ /** IR builder options (passed through) */
532
+ builderOptions?: Omit<IRBuilderOptions, "enableSnapshots" | "maxSnapshots">;
533
+ }
534
+ /**
535
+ * Time-travel controller interface.
536
+ */
537
+ interface TimeTravelController {
538
+ /** Handle a workflow event (records snapshot if recording) */
539
+ handleEvent: (event: WorkflowEvent<unknown>) => void;
540
+ /** Navigate to specific snapshot index */
541
+ seek: (index: number) => WorkflowIR | undefined;
542
+ /** Move one step forward */
543
+ stepForward: () => WorkflowIR | undefined;
544
+ /** Move one step backward */
545
+ stepBackward: () => WorkflowIR | undefined;
546
+ /** Start playback at given speed (1.0 = realtime) */
547
+ play: (speed?: number) => void;
548
+ /** Pause playback */
549
+ pause: () => void;
550
+ /** Get current IR state */
551
+ getCurrentIR: () => WorkflowIR;
552
+ /** Get IR at specific snapshot index */
553
+ getIRAt: (index: number) => WorkflowIR | undefined;
554
+ /** Get all snapshots */
555
+ getSnapshots: () => IRSnapshot[];
556
+ /** Get snapshot at specific index */
557
+ getSnapshotAt: (index: number) => IRSnapshot | undefined;
558
+ /** Get current time-travel state */
559
+ getState: () => TimeTravelState;
560
+ /** Subscribe to state changes */
561
+ onStateChange: (callback: (state: TimeTravelState) => void) => () => void;
562
+ /** Start/resume recording */
563
+ startRecording: () => void;
564
+ /** Stop recording */
565
+ stopRecording: () => void;
566
+ /** Reset to initial state */
567
+ reset: () => void;
568
+ /** Get the underlying IR builder */
569
+ getBuilder: () => IRBuilder;
570
+ }
571
+ /**
572
+ * Create a time-travel controller for workflow debugging.
573
+ *
574
+ * @example
575
+ * ```typescript
576
+ * const controller = createTimeTravelController();
577
+ *
578
+ * // Feed events from workflow execution
579
+ * workflow.onEvent(event => controller.handleEvent(event));
580
+ *
581
+ * // After execution, explore the timeline
582
+ * controller.seek(0); // Go to start
583
+ * controller.stepForward(); // Step through
584
+ * controller.play(2); // Playback at 2x speed
585
+ * ```
586
+ */
587
+ declare function createTimeTravelController(options?: TimeTravelOptions): TimeTravelController;
588
+
589
+ /**
590
+ * Performance Analyzer
591
+ *
592
+ * Analyzes workflow execution data to identify:
593
+ * - Slow steps (bottlenecks)
594
+ * - Retry patterns
595
+ * - Error-prone steps
596
+ * - Timing anomalies
597
+ *
598
+ * Aggregates metrics across multiple workflow runs to provide
599
+ * statistical insights and heatmap visualization data.
600
+ */
601
+
602
+ /**
603
+ * A recorded workflow run for analysis.
604
+ */
605
+ interface WorkflowRun {
606
+ /** Unique identifier for this run */
607
+ id: string;
608
+ /** Workflow start timestamp */
609
+ startTime: number;
610
+ /** All events from the workflow execution */
611
+ events: WorkflowEvent<unknown>[];
612
+ }
613
+ /**
614
+ * Performance analyzer interface.
615
+ */
616
+ interface PerformanceAnalyzer {
617
+ /** Add a completed workflow run for analysis */
618
+ addRun: (run: WorkflowRun) => void;
619
+ /** Add events incrementally (alternative to addRun) */
620
+ addEvent: (event: WorkflowEvent<unknown>) => void;
621
+ /** Finalize current run (when using addEvent) */
622
+ finalizeRun: (runId: string) => void;
623
+ /** Get performance stats for a specific node */
624
+ getNodePerformance: (nodeId: string) => NodePerformance | undefined;
625
+ /** Get heatmap data for an IR */
626
+ getHeatmap: (ir: WorkflowIR, metric?: "duration" | "retryRate" | "errorRate") => HeatmapData;
627
+ /** Get slowest nodes */
628
+ getSlowestNodes: (limit?: number) => NodePerformance[];
629
+ /** Get error-prone nodes */
630
+ getErrorProneNodes: (limit?: number) => NodePerformance[];
631
+ /** Get retry-prone nodes */
632
+ getRetryProneNodes: (limit?: number) => NodePerformance[];
633
+ /** Get all performance data */
634
+ getAllPerformance: () => Map<string, NodePerformance>;
635
+ /** Export performance data as JSON */
636
+ exportData: () => string;
637
+ /** Import performance data from JSON */
638
+ importData: (json: string) => void;
639
+ /** Clear all collected data */
640
+ clear: () => void;
641
+ }
642
+ /**
643
+ * Get heat level from normalized value (0-1).
644
+ */
645
+ declare function getHeatLevel(heat: number): HeatLevel;
646
+ /**
647
+ * Create a performance analyzer for workflow metrics.
648
+ *
649
+ * @example
650
+ * ```typescript
651
+ * const analyzer = createPerformanceAnalyzer();
652
+ *
653
+ * // Add completed runs
654
+ * analyzer.addRun({ id: 'run-1', startTime: Date.now(), events });
655
+ *
656
+ * // Get insights
657
+ * const slowest = analyzer.getSlowestNodes(5);
658
+ * const heatmap = analyzer.getHeatmap(ir, 'duration');
659
+ * ```
660
+ */
661
+ declare function createPerformanceAnalyzer(): PerformanceAnalyzer;
662
+
663
+ export { type DecisionTracker as D, type HookLog as H, type IRBuilderOptions as I, type LiveVisualizer as L, type ParallelDetectorOptions as P, type StepLog as S, type TimeTravelController as T, type WorkflowRun as W, type IfTracker as a, type LoggerOutput as b, type LoggerRenderOptions as c, type PerformanceAnalyzer as d, type SwitchTracker as e, type TimeTravelOptions as f, type WorkflowSummary as g, asciiRenderer as h, createIRBuilder as i, createLiveVisualizer as j, createParallelDetector as k, createPerformanceAnalyzer as l, createTimeTravelController as m, defaultColorScheme as n, detectParallelGroups as o, flowchartRenderer as p, getHeatLevel as q, htmlRenderer as r, loggerRenderer as s, mermaidRenderer as t, renderToHTML as u, trackDecision as v, trackIf as w, trackSwitch as x };