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,750 @@
1
+ import { ScopeType, WorkflowOptions, WorkflowEvent } from 'awaitly/workflow';
2
+ import { UnexpectedError } from 'awaitly/core';
3
+
4
+ /**
5
+ * Workflow Visualization - Intermediate Representation Types
6
+ *
7
+ * The IR (Intermediate Representation) is a DSL that represents workflow
8
+ * execution structure. Events are converted to IR, which can then be
9
+ * rendered to various output formats (ASCII, Mermaid, JSON, etc.).
10
+ */
11
+ /**
12
+ * Execution state of a step with semantic meaning for visualization.
13
+ *
14
+ * Color mapping:
15
+ * - pending → white/clear (not started)
16
+ * - running → yellow (currently executing)
17
+ * - success → green (completed successfully)
18
+ * - error → red (failed with error)
19
+ * - aborted → gray (cancelled, e.g., in race)
20
+ * - cached → blue (served from cache)
21
+ * - skipped → dim gray (not executed due to conditional logic)
22
+ */
23
+ type StepState = "pending" | "running" | "success" | "error" | "aborted" | "cached" | "skipped";
24
+ /**
25
+ * Base properties shared by all IR nodes.
26
+ */
27
+ interface BaseNode {
28
+ /** Unique identifier for this node */
29
+ id: string;
30
+ /** Human-readable name (from step options or inferred) */
31
+ name?: string;
32
+ /** Cache key if this is a keyed step */
33
+ key?: string;
34
+ /** Current execution state */
35
+ state: StepState;
36
+ /** Timestamp when execution started */
37
+ startTs?: number;
38
+ /** Timestamp when execution ended */
39
+ endTs?: number;
40
+ /** Duration in milliseconds */
41
+ durationMs?: number;
42
+ /** Error value if state is 'error' */
43
+ error?: unknown;
44
+ /** Input value that triggered this step (for decision understanding) */
45
+ input?: unknown;
46
+ /** Output value from this step (for decision understanding) */
47
+ output?: unknown;
48
+ /** Number of retry attempts made (0 = no retries, 1 = one retry, etc.) */
49
+ retryCount?: number;
50
+ /** Whether this step experienced a timeout (may have retried after) */
51
+ timedOut?: boolean;
52
+ /** Timeout duration in ms (if timed out) */
53
+ timeoutMs?: number;
54
+ }
55
+ /**
56
+ * A single step execution node.
57
+ */
58
+ interface StepNode extends BaseNode {
59
+ type: "step";
60
+ }
61
+ /**
62
+ * Sequential execution - steps run one after another.
63
+ * This is the implicit structure when steps are awaited in sequence.
64
+ */
65
+ interface SequenceNode extends BaseNode {
66
+ type: "sequence";
67
+ children: FlowNode[];
68
+ }
69
+ /**
70
+ * Parallel execution - all branches run simultaneously.
71
+ * Created by allAsync() or allSettledAsync().
72
+ */
73
+ interface ParallelNode extends BaseNode {
74
+ type: "parallel";
75
+ children: FlowNode[];
76
+ /**
77
+ * Execution mode:
78
+ * - 'all': Fails on first error (allAsync)
79
+ * - 'allSettled': Collects all results (allSettledAsync)
80
+ */
81
+ mode: "all" | "allSettled";
82
+ }
83
+ /**
84
+ * Race execution - first to complete wins.
85
+ * Created by anyAsync().
86
+ */
87
+ interface RaceNode extends BaseNode {
88
+ type: "race";
89
+ children: FlowNode[];
90
+ /** ID of the winning branch (first to succeed) */
91
+ winnerId?: string;
92
+ }
93
+ /**
94
+ * Stream operation node.
95
+ * Tracks streaming events (write, read, close, error, backpressure).
96
+ */
97
+ interface StreamNode extends BaseNode {
98
+ type: "stream";
99
+ /** Stream namespace identifier */
100
+ namespace: string;
101
+ /** Total number of write operations */
102
+ writeCount: number;
103
+ /** Total number of read operations */
104
+ readCount: number;
105
+ /** Final position when stream closed */
106
+ finalPosition: number;
107
+ /** Current stream state */
108
+ streamState: "active" | "closed" | "error";
109
+ /** Whether backpressure was encountered during streaming */
110
+ backpressureOccurred: boolean;
111
+ }
112
+ /**
113
+ * Decision point - conditional branch (if/switch).
114
+ * Shows which branch was taken and why.
115
+ */
116
+ interface DecisionNode extends BaseNode {
117
+ type: "decision";
118
+ /** Condition that was evaluated (e.g., "user.role === 'admin'") */
119
+ condition?: string;
120
+ /** Value that was evaluated (the input to the decision) */
121
+ decisionValue?: unknown;
122
+ /** Which branch was taken (true/false, or the matched case) */
123
+ branchTaken?: string | boolean;
124
+ /** All possible branches (including skipped ones) */
125
+ branches: DecisionBranch[];
126
+ }
127
+ /**
128
+ * A branch in a decision node.
129
+ */
130
+ interface DecisionBranch {
131
+ /** Label for this branch (e.g., "if", "else", "case 'admin'") */
132
+ label: string;
133
+ /** Condition that would trigger this branch */
134
+ condition?: string;
135
+ /** Whether this branch was taken */
136
+ taken: boolean;
137
+ /** Steps in this branch */
138
+ children: FlowNode[];
139
+ }
140
+ /**
141
+ * Union of all flow node types.
142
+ */
143
+ type FlowNode = StepNode | SequenceNode | ParallelNode | RaceNode | DecisionNode | StreamNode;
144
+ /**
145
+ * Root node representing the entire workflow.
146
+ */
147
+ interface WorkflowNode extends BaseNode {
148
+ type: "workflow";
149
+ /** Correlation ID from the workflow execution */
150
+ workflowId: string;
151
+ /** Child nodes (steps, parallel blocks, etc.) */
152
+ children: FlowNode[];
153
+ }
154
+ /**
155
+ * Complete workflow intermediate representation.
156
+ * This is the main data structure produced by the IR builder.
157
+ */
158
+ interface WorkflowIR {
159
+ /** Root workflow node */
160
+ root: WorkflowNode;
161
+ /** Metadata about the IR */
162
+ metadata: {
163
+ /** When the IR was first created */
164
+ createdAt: number;
165
+ /** When the IR was last updated */
166
+ lastUpdatedAt: number;
167
+ };
168
+ /** Hook executions (if any hooks are configured) */
169
+ hooks?: WorkflowHooks;
170
+ }
171
+
172
+ /**
173
+ * Event emitted when entering a parallel/race scope.
174
+ * This matches the scope_start event in WorkflowEvent.
175
+ */
176
+ interface ScopeStartEvent {
177
+ type: "scope_start";
178
+ workflowId: string;
179
+ scopeId: string;
180
+ scopeType: ScopeType;
181
+ name?: string;
182
+ ts: number;
183
+ }
184
+ /**
185
+ * Event emitted when exiting a parallel/race scope.
186
+ */
187
+ interface ScopeEndEvent {
188
+ type: "scope_end";
189
+ workflowId: string;
190
+ scopeId: string;
191
+ ts: number;
192
+ durationMs: number;
193
+ /** For race scopes, the ID of the winning branch */
194
+ winnerId?: string;
195
+ }
196
+ /**
197
+ * Event emitted when a decision point is encountered.
198
+ * Use this to track conditional logic (if/switch).
199
+ */
200
+ interface DecisionStartEvent {
201
+ type: "decision_start";
202
+ workflowId: string;
203
+ decisionId: string;
204
+ /** Condition being evaluated (e.g., "user.role === 'admin'") */
205
+ condition?: string;
206
+ /** Value being evaluated */
207
+ decisionValue?: unknown;
208
+ /** Name/label for this decision point */
209
+ name?: string;
210
+ ts: number;
211
+ }
212
+ /**
213
+ * Event emitted when a decision branch is taken.
214
+ */
215
+ interface DecisionBranchEvent {
216
+ type: "decision_branch";
217
+ workflowId: string;
218
+ decisionId: string;
219
+ /** Label for this branch (e.g., "if", "else", "case 'admin'") */
220
+ branchLabel: string;
221
+ /** Condition for this branch */
222
+ condition?: string;
223
+ /** Whether this branch was taken */
224
+ taken: boolean;
225
+ ts: number;
226
+ }
227
+ /**
228
+ * Event emitted when a decision point completes.
229
+ */
230
+ interface DecisionEndEvent {
231
+ type: "decision_end";
232
+ workflowId: string;
233
+ decisionId: string;
234
+ /** Which branch was taken */
235
+ branchTaken?: string | boolean;
236
+ ts: number;
237
+ durationMs: number;
238
+ }
239
+ /**
240
+ * Event emitted when a step is skipped due to conditional logic.
241
+ */
242
+ interface StepSkippedEvent {
243
+ type: "step_skipped";
244
+ workflowId: string;
245
+ stepKey?: string;
246
+ name?: string;
247
+ /** Reason why this step was skipped (e.g., "condition was false") */
248
+ reason?: string;
249
+ /** The decision that caused this skip */
250
+ decisionId?: string;
251
+ ts: number;
252
+ }
253
+ /**
254
+ * Union of scope-related events.
255
+ */
256
+ type ScopeEvent = ScopeStartEvent | ScopeEndEvent;
257
+ /**
258
+ * Union of decision-related events.
259
+ */
260
+ type DecisionEvent = DecisionStartEvent | DecisionBranchEvent | DecisionEndEvent;
261
+ /**
262
+ * Color scheme for rendering step states.
263
+ */
264
+ interface ColorScheme {
265
+ pending: string;
266
+ running: string;
267
+ success: string;
268
+ error: string;
269
+ aborted: string;
270
+ cached: string;
271
+ skipped: string;
272
+ }
273
+ /**
274
+ * Options passed to renderers.
275
+ */
276
+ interface RenderOptions {
277
+ /** Show timing information (duration) */
278
+ showTimings: boolean;
279
+ /** Show step cache keys */
280
+ showKeys: boolean;
281
+ /** Terminal width for ASCII renderer */
282
+ terminalWidth?: number;
283
+ /** Color scheme */
284
+ colors: ColorScheme;
285
+ }
286
+ /**
287
+ * Extended options for Mermaid renderer.
288
+ * Controls how edges are displayed for retries, errors, and timeouts.
289
+ */
290
+ interface MermaidRenderOptions extends RenderOptions {
291
+ /** Show retry as self-loop edge (default: true) */
292
+ showRetryEdges?: boolean;
293
+ /** Show error flow to error node (default: true) */
294
+ showErrorEdges?: boolean;
295
+ /** Show timeout as alternative path (default: true) */
296
+ showTimeoutEdges?: boolean;
297
+ }
298
+ /**
299
+ * Renderer interface - transforms IR to output format.
300
+ */
301
+ interface Renderer {
302
+ /** Unique identifier for this renderer */
303
+ readonly name: string;
304
+ /** Render IR to string output */
305
+ render(ir: WorkflowIR, options: RenderOptions): string;
306
+ /** Whether this renderer supports live (incremental) updates */
307
+ supportsLive?: boolean;
308
+ /** Render incremental update (optional) */
309
+ renderUpdate?(ir: WorkflowIR, changedNodes: FlowNode[], options: RenderOptions): string;
310
+ }
311
+ /**
312
+ * Output format for rendering.
313
+ */
314
+ type OutputFormat = "ascii" | "mermaid" | "json" | "logger" | "flowchart";
315
+ /**
316
+ * Options for creating a visualizer.
317
+ */
318
+ interface VisualizerOptions {
319
+ /** Name for the workflow in visualizations */
320
+ workflowName?: string;
321
+ /** Enable parallel detection heuristics (default: true) */
322
+ detectParallel?: boolean;
323
+ /** Show timing information (default: true) */
324
+ showTimings?: boolean;
325
+ /** Show step keys (default: false) */
326
+ showKeys?: boolean;
327
+ /** Custom color scheme */
328
+ colors?: Partial<ColorScheme>;
329
+ /**
330
+ * Export configuration for URL generation methods.
331
+ * Note: Treated as immutable after creation - do not mutate.
332
+ */
333
+ export?: {
334
+ /** Default export provider (opt-in). If not set, export methods require explicit provider. */
335
+ default?: ExportOptions;
336
+ };
337
+ }
338
+ /**
339
+ * Options for createVisualizingWorkflow convenience factory.
340
+ * Combines WorkflowOptions with VisualizerOptions.
341
+ *
342
+ * @example
343
+ * ```typescript
344
+ * const { workflow, visualizer } = createVisualizingWorkflow(deps, {
345
+ * workflowName: 'checkout',
346
+ * showTimings: true,
347
+ * forwardTo: (event) => console.log(event.type),
348
+ * });
349
+ * ```
350
+ */
351
+ interface VisualizingWorkflowOptions<E, C = void> extends Omit<WorkflowOptions<E, C>, "onEvent">, VisualizerOptions {
352
+ /** Forward events to additional handler (runs after visualization) */
353
+ forwardTo?: (event: WorkflowEvent<E | UnexpectedError, C>, ctx: C) => void;
354
+ }
355
+ /**
356
+ * Options for live visualization.
357
+ */
358
+ interface LiveVisualizerOptions extends VisualizerOptions {
359
+ /** Output stream (default: process.stdout) */
360
+ stream?: NodeJS.WriteStream;
361
+ /** Update interval in ms (default: 100) */
362
+ updateInterval?: number;
363
+ }
364
+ /**
365
+ * Check if a node is a StepNode.
366
+ */
367
+ declare function isStepNode(node: FlowNode): node is StepNode;
368
+ /**
369
+ * Check if a node is a SequenceNode.
370
+ */
371
+ declare function isSequenceNode(node: FlowNode): node is SequenceNode;
372
+ /**
373
+ * Check if a node is a ParallelNode.
374
+ */
375
+ declare function isParallelNode(node: FlowNode): node is ParallelNode;
376
+ /**
377
+ * Check if a node is a RaceNode.
378
+ */
379
+ declare function isRaceNode(node: FlowNode): node is RaceNode;
380
+ /**
381
+ * Check if a node is a DecisionNode.
382
+ */
383
+ declare function isDecisionNode(node: FlowNode): node is DecisionNode;
384
+ /**
385
+ * Check if a node is a StreamNode.
386
+ */
387
+ declare function isStreamNode(node: FlowNode): node is StreamNode;
388
+ /**
389
+ * Check if a node has children.
390
+ */
391
+ declare function hasChildren(node: FlowNode): node is SequenceNode | ParallelNode | RaceNode | DecisionNode;
392
+ /**
393
+ * Snapshot of an active step's state at a point in time.
394
+ */
395
+ interface ActiveStepSnapshot {
396
+ id: string;
397
+ name?: string;
398
+ key?: string;
399
+ startTs: number;
400
+ retryCount: number;
401
+ timedOut: boolean;
402
+ timeoutMs?: number;
403
+ }
404
+ /**
405
+ * A snapshot of the complete IR state at a specific point in time.
406
+ * Used for time-travel debugging - each event creates a snapshot.
407
+ */
408
+ interface IRSnapshot {
409
+ /** Unique identifier for this snapshot */
410
+ id: string;
411
+ /** Index in the event sequence (0-based) */
412
+ eventIndex: number;
413
+ /** The event that triggered this snapshot */
414
+ event: unknown;
415
+ /** Complete IR state at this moment */
416
+ ir: WorkflowIR;
417
+ /** Timestamp when snapshot was taken */
418
+ timestamp: number;
419
+ /** Active step states at this moment (for debugging) */
420
+ activeSteps: Map<string, ActiveStepSnapshot>;
421
+ }
422
+ /**
423
+ * State of the time-travel controller.
424
+ */
425
+ interface TimeTravelState {
426
+ /** All recorded snapshots */
427
+ snapshots: IRSnapshot[];
428
+ /** Current snapshot index (for playback position) */
429
+ currentIndex: number;
430
+ /** Whether playback is active */
431
+ isPlaying: boolean;
432
+ /** Playback speed multiplier (1.0 = realtime, 2.0 = 2x speed) */
433
+ playbackSpeed: number;
434
+ /** Whether recording is active */
435
+ isRecording: boolean;
436
+ }
437
+ /**
438
+ * Performance metrics for a single node across multiple runs.
439
+ */
440
+ interface NodePerformance {
441
+ /** Node identifier (name or step ID) */
442
+ nodeId: string;
443
+ /** Average duration across all samples */
444
+ avgDurationMs: number;
445
+ /** Minimum duration observed */
446
+ minDurationMs: number;
447
+ /** Maximum duration observed */
448
+ maxDurationMs: number;
449
+ /** Standard deviation of durations */
450
+ stdDevMs: number;
451
+ /** Number of timing samples collected */
452
+ samples: number;
453
+ /** Retry frequency (0-1, where 1 = always retries) */
454
+ retryRate: number;
455
+ /** Timeout frequency (0-1) */
456
+ timeoutRate: number;
457
+ /** Error rate (0-1) */
458
+ errorRate: number;
459
+ /** Percentile data for distribution analysis */
460
+ percentiles: {
461
+ p50: number;
462
+ p90: number;
463
+ p95: number;
464
+ p99: number;
465
+ };
466
+ }
467
+ /**
468
+ * Heatmap data for visualizing performance across nodes.
469
+ */
470
+ interface HeatmapData {
471
+ /** Map of node ID to heat level (0-1, where 1 is hottest/slowest) */
472
+ heat: Map<string, number>;
473
+ /** The metric used for heat calculation */
474
+ metric: "duration" | "retryRate" | "errorRate";
475
+ /** Statistics used to compute heat values */
476
+ stats: {
477
+ /** Minimum value in the dataset */
478
+ min: number;
479
+ /** Maximum value in the dataset */
480
+ max: number;
481
+ /** Mean value */
482
+ mean: number;
483
+ /** Threshold above which a node is considered "hot" */
484
+ threshold: number;
485
+ };
486
+ }
487
+ /**
488
+ * Heat level for visual styling.
489
+ */
490
+ type HeatLevel = "cold" | "cool" | "neutral" | "warm" | "hot" | "critical";
491
+ /**
492
+ * Theme for the HTML visualizer.
493
+ */
494
+ type HTMLTheme = "light" | "dark" | "auto";
495
+ /**
496
+ * Layout direction for the workflow diagram.
497
+ */
498
+ type LayoutDirection = "TB" | "LR" | "BT" | "RL";
499
+ /**
500
+ * Options for the HTML renderer.
501
+ */
502
+ interface HTMLRenderOptions extends RenderOptions {
503
+ /** Enable interactive features (click to inspect, zoom/pan) */
504
+ interactive: boolean;
505
+ /** Include time-travel controls */
506
+ timeTravel: boolean;
507
+ /** Include performance heatmap overlay */
508
+ heatmap: boolean;
509
+ /** Animation duration for transitions (ms) */
510
+ animationDuration: number;
511
+ /** Color theme */
512
+ theme: HTMLTheme;
513
+ /** Diagram layout direction */
514
+ layout: LayoutDirection;
515
+ /** Heatmap data (if heatmap is enabled) */
516
+ heatmapData?: HeatmapData;
517
+ /** WebSocket URL for live updates (if streaming) */
518
+ wsUrl?: string;
519
+ }
520
+ /**
521
+ * Message sent from the web visualizer to the dev server.
522
+ */
523
+ interface WebVisualizerMessage {
524
+ type: "time_travel_seek" | "time_travel_play" | "time_travel_pause" | "time_travel_step_forward" | "time_travel_step_backward" | "request_snapshots" | "toggle_heatmap" | "set_heatmap_metric";
525
+ payload?: unknown;
526
+ }
527
+ /**
528
+ * Message sent from the dev server to the web visualizer.
529
+ */
530
+ interface ServerMessage {
531
+ type: "ir_update" | "snapshot" | "snapshots_list" | "performance_data" | "workflow_complete" | "time_travel_state";
532
+ payload: unknown;
533
+ }
534
+ /**
535
+ * Extended render options for the enhanced ASCII renderer.
536
+ */
537
+ interface EnhancedRenderOptions extends RenderOptions {
538
+ /** Show performance heatmap coloring */
539
+ showHeatmap?: boolean;
540
+ /** Heatmap data for coloring nodes */
541
+ heatmapData?: HeatmapData;
542
+ /** Show timing sparklines (requires historical data) */
543
+ showSparklines?: boolean;
544
+ /** Historical timing data for sparklines: nodeId → array of durations */
545
+ timingHistory?: Map<string, number[]>;
546
+ }
547
+ /**
548
+ * Options for the flowchart ASCII renderer.
549
+ * Renders workflow as a proper flowchart with boxes and arrows.
550
+ */
551
+ interface FlowchartRenderOptions extends EnhancedRenderOptions {
552
+ /** Show start and end nodes (default: true) */
553
+ showStartEnd?: boolean;
554
+ /** Reduce vertical spacing between nodes (default: false) */
555
+ compact?: boolean;
556
+ /** Box border style (default: 'single') */
557
+ boxStyle?: "single" | "double" | "rounded";
558
+ }
559
+ /**
560
+ * State of a hook execution.
561
+ */
562
+ type HookState = "pending" | "running" | "success" | "error";
563
+ /**
564
+ * Execution record for a workflow hook.
565
+ */
566
+ interface HookExecution {
567
+ /** Hook type identifier */
568
+ type: "shouldRun" | "onBeforeStart" | "onAfterStep";
569
+ /** Execution state */
570
+ state: HookState;
571
+ /** Timestamp when hook started */
572
+ ts: number;
573
+ /** Duration in milliseconds */
574
+ durationMs?: number;
575
+ /** Error if hook failed */
576
+ error?: unknown;
577
+ /** Additional context (e.g., stepKey for onAfterStep) */
578
+ context?: {
579
+ /** Step key for onAfterStep hooks */
580
+ stepKey?: string;
581
+ /** Result of shouldRun hook */
582
+ result?: boolean;
583
+ /** Whether workflow was skipped due to shouldRun returning false */
584
+ skipped?: boolean;
585
+ };
586
+ }
587
+ /**
588
+ * Hook execution summary for the workflow.
589
+ */
590
+ interface WorkflowHooks {
591
+ /** shouldRun hook execution (if configured) */
592
+ shouldRun?: HookExecution;
593
+ /** onBeforeStart hook execution (if configured) */
594
+ onBeforeStart?: HookExecution;
595
+ /** onAfterStep hook executions (keyed by stepKey) */
596
+ onAfterStep: Map<string, HookExecution>;
597
+ }
598
+ /**
599
+ * Export format for diagram URLs.
600
+ */
601
+ type ExportFormat = "svg" | "png" | "pdf";
602
+ /**
603
+ * Diagram source - future-proof union for multiple diagram types.
604
+ * Uses "kind" internally, maps to "diagramType" for Kroki API.
605
+ */
606
+ type DiagramSource = {
607
+ kind: "mermaid";
608
+ source: string;
609
+ } | {
610
+ kind: "graphviz";
611
+ source: string;
612
+ } | {
613
+ kind: "plantuml";
614
+ source: string;
615
+ };
616
+ /**
617
+ * Kroki-specific export options.
618
+ * Note: No background/scale - Kroki doesn't support them for mermaid diagrams.
619
+ */
620
+ interface KrokiExportOptions {
621
+ /** Provider identifier */
622
+ provider: "kroki";
623
+ /** Base URL for self-hosted Kroki (default: https://kroki.io) */
624
+ baseUrl?: string;
625
+ }
626
+ /**
627
+ * Mermaid.ink-specific export options.
628
+ * Supports additional styling options like background, scale, and theme.
629
+ */
630
+ interface MermaidInkExportOptions {
631
+ /** Provider identifier */
632
+ provider: "mermaid-ink";
633
+ /** Mermaid theme */
634
+ mermaidTheme?: "default" | "dark" | "forest" | "neutral";
635
+ /** Background color: "transparent" or hex color (e.g., "1b1b1f") */
636
+ background?: "transparent" | string;
637
+ /** Image scale (1-3) */
638
+ scale?: number;
639
+ /** Fit PDF to diagram size */
640
+ fit?: boolean;
641
+ /** Image width in pixels */
642
+ width?: number;
643
+ /** Image height in pixels */
644
+ height?: number;
645
+ /** Paper size for PDF */
646
+ paper?: "a4" | "letter";
647
+ }
648
+ /**
649
+ * Discriminated union of export options.
650
+ * Provider is the discriminant - no implicit defaults.
651
+ */
652
+ type ExportOptions = KrokiExportOptions | MermaidInkExportOptions;
653
+
654
+ /**
655
+ * Kroki URL Generation
656
+ *
657
+ * Generates shareable URLs for Kroki diagram rendering service.
658
+ * Works in both browser and Node.js environments.
659
+ */
660
+
661
+ /**
662
+ * Supported Kroki output formats.
663
+ */
664
+ type KrokiFormat = "svg" | "png" | "pdf" | "jpeg";
665
+ /**
666
+ * Options for URL generator.
667
+ */
668
+ interface UrlGeneratorOptions {
669
+ /** Base URL for Kroki service (default: https://kroki.io) */
670
+ baseUrl?: string;
671
+ }
672
+ /**
673
+ * Generate a Kroki URL from workflow IR.
674
+ *
675
+ * @param ir - Workflow intermediate representation
676
+ * @param format - Output format (default: 'svg')
677
+ * @param options - Optional URL generator options
678
+ * @returns The Kroki URL
679
+ *
680
+ * @example
681
+ * ```typescript
682
+ * const url = toKrokiUrl(workflowIR, 'svg');
683
+ * // Share this URL - image renders when viewed
684
+ * ```
685
+ */
686
+ declare function toKrokiUrl(ir: WorkflowIR, format?: KrokiFormat, options?: UrlGeneratorOptions): string;
687
+ /**
688
+ * Generate a Kroki SVG URL from workflow IR.
689
+ *
690
+ * @param ir - Workflow intermediate representation
691
+ * @param options - Optional URL generator options
692
+ * @returns The Kroki SVG URL
693
+ *
694
+ * @example
695
+ * ```typescript
696
+ * const svgUrl = toKrokiSvgUrl(workflowIR);
697
+ * // => "https://kroki.io/mermaid/svg/eNp..."
698
+ * ```
699
+ */
700
+ declare function toKrokiSvgUrl(ir: WorkflowIR, options?: UrlGeneratorOptions): string;
701
+ /**
702
+ * Generate a Kroki PNG URL from workflow IR.
703
+ *
704
+ * @param ir - Workflow intermediate representation
705
+ * @param options - Optional URL generator options
706
+ * @returns The Kroki PNG URL
707
+ *
708
+ * @example
709
+ * ```typescript
710
+ * const pngUrl = toKrokiPngUrl(workflowIR);
711
+ * // => "https://kroki.io/mermaid/png/eNp..."
712
+ * ```
713
+ */
714
+ declare function toKrokiPngUrl(ir: WorkflowIR, options?: UrlGeneratorOptions): string;
715
+ /**
716
+ * URL Generator with configured base URL.
717
+ */
718
+ interface UrlGenerator {
719
+ /** Generate URL with specified format */
720
+ toUrl(ir: WorkflowIR, format: KrokiFormat): string;
721
+ /** Generate SVG URL */
722
+ toSvgUrl(ir: WorkflowIR): string;
723
+ /** Generate PNG URL */
724
+ toPngUrl(ir: WorkflowIR): string;
725
+ /** Generate PDF URL */
726
+ toPdfUrl(ir: WorkflowIR): string;
727
+ /** Get the configured base URL */
728
+ getBaseUrl(): string;
729
+ }
730
+ /**
731
+ * Create a URL generator with a custom base URL.
732
+ * Useful for self-hosted Kroki instances.
733
+ *
734
+ * @param options - URL generator options
735
+ * @returns A URL generator instance
736
+ *
737
+ * @example
738
+ * ```typescript
739
+ * // Use self-hosted Kroki
740
+ * const generator = createUrlGenerator({ baseUrl: 'https://my-kroki.internal' });
741
+ * const url = generator.toSvgUrl(workflowIR);
742
+ *
743
+ * // Default public Kroki
744
+ * const defaultGenerator = createUrlGenerator();
745
+ * const publicUrl = defaultGenerator.toSvgUrl(workflowIR);
746
+ * ```
747
+ */
748
+ declare function createUrlGenerator(options?: UrlGeneratorOptions): UrlGenerator;
749
+
750
+ export { isDecisionNode as $, type ActiveStepSnapshot as A, type BaseNode as B, type ColorScheme as C, type DiagramSource as D, type ExportFormat as E, type FlowNode as F, type StreamNode as G, type HTMLRenderOptions as H, type IRSnapshot as I, type VisualizingWorkflowOptions as J, type KrokiExportOptions as K, type LayoutDirection as L, type MermaidInkExportOptions as M, type NodePerformance as N, type OutputFormat as O, type ParallelNode as P, type WebVisualizerMessage as Q, type RaceNode as R, type ScopeStartEvent as S, type TimeTravelState as T, type UrlGeneratorOptions as U, type VisualizerOptions as V, type WorkflowIR as W, type WorkflowHooks as X, type WorkflowNode as Y, createUrlGenerator as Z, hasChildren as _, type ExportOptions as a, isParallelNode as a0, isRaceNode as a1, isSequenceNode as a2, isStepNode as a3, isStreamNode as a4, toKrokiPngUrl as a5, toKrokiSvgUrl as a6, toKrokiUrl as a7, type UrlGenerator as a8, type DecisionStartEvent as b, type DecisionBranchEvent as c, type DecisionEndEvent as d, type ScopeEndEvent as e, type DecisionBranch as f, type DecisionEvent as g, type DecisionNode as h, type EnhancedRenderOptions as i, type FlowchartRenderOptions as j, type HTMLTheme as k, type HeatLevel as l, type HeatmapData as m, type HookExecution as n, type HookState as o, type KrokiFormat as p, type LiveVisualizerOptions as q, type MermaidRenderOptions as r, type RenderOptions as s, type Renderer as t, type ScopeEvent as u, type SequenceNode as v, type ServerMessage as w, type StepNode as x, type StepSkippedEvent as y, type StepState as z };