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,350 @@
1
+ import { AsyncResult } from 'awaitly';
2
+ import { WorkflowEvent } from 'awaitly/workflow';
3
+ import { W as WorkflowIR, M as MermaidInkExportOptions, U as UrlGeneratorOptions, S as ScopeStartEvent, e as ScopeEndEvent, b as DecisionStartEvent, c as DecisionBranchEvent, d as DecisionEndEvent } from './url-PkfQz4V5.js';
4
+
5
+ /**
6
+ * Mermaid.ink URL Generation
7
+ *
8
+ * Generates shareable URLs for mermaid.ink diagram rendering service.
9
+ * Alternative to Kroki with additional features like themes, background colors, and sizing.
10
+ *
11
+ * @see https://mermaid.ink/
12
+ */
13
+
14
+ /**
15
+ * Supported mermaid.ink output formats.
16
+ */
17
+ type MermaidInkFormat = "svg" | "img" | "pdf";
18
+ /**
19
+ * Image type for /img endpoint.
20
+ */
21
+ type MermaidInkImageType = "jpeg" | "png" | "webp";
22
+ /**
23
+ * Mermaid.ink built-in themes.
24
+ */
25
+ type MermaidInkTheme = "default" | "neutral" | "dark" | "forest";
26
+ /**
27
+ * PDF paper sizes.
28
+ */
29
+ type MermaidInkPaperSize = "letter" | "legal" | "tabloid" | "ledger" | "a0" | "a1" | "a2" | "a3" | "a4" | "a5" | "a6";
30
+ /**
31
+ * Options for mermaid.ink URL generation.
32
+ */
33
+ interface MermaidInkOptions {
34
+ /** Base URL for mermaid.ink service (default: https://mermaid.ink) */
35
+ baseUrl?: string;
36
+ /**
37
+ * Background color.
38
+ * - Hex color without #: "FF0000" for red
39
+ * - Named color with ! prefix: "!white", "!black"
40
+ */
41
+ bgColor?: string;
42
+ /** Mermaid theme */
43
+ theme?: MermaidInkTheme;
44
+ /** Image width in pixels */
45
+ width?: number;
46
+ /** Image height in pixels */
47
+ height?: number;
48
+ /** Image scale (1-3). Only applies if width or height is set */
49
+ scale?: number;
50
+ /** Image type for /img endpoint (default: jpeg) */
51
+ imageType?: MermaidInkImageType;
52
+ /** Fit PDF size to diagram size */
53
+ fit?: boolean;
54
+ /** Paper size for PDF (default: a4) */
55
+ paper?: MermaidInkPaperSize;
56
+ /** Landscape orientation for PDF */
57
+ landscape?: boolean;
58
+ }
59
+ /**
60
+ * Encode text for mermaid.ink URL.
61
+ * Uses pako deflate compression + base64 encoding with "pako:" prefix.
62
+ *
63
+ * @param text - The Mermaid diagram text
64
+ * @returns Encoded string with "pako:" prefix
65
+ */
66
+ declare function encodeForMermaidInk(text: string): string;
67
+ /**
68
+ * Build a mermaid.ink URL for the given Mermaid diagram text.
69
+ *
70
+ * @param format - Output format (svg, img, pdf)
71
+ * @param text - The Mermaid diagram text
72
+ * @param options - Optional mermaid.ink options (MermaidInkOptions or MermaidInkExportOptions)
73
+ * @returns The mermaid.ink URL
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * const url = buildMermaidInkUrl('svg', 'flowchart TD\n A-->B');
78
+ * // => "https://mermaid.ink/svg/pako:eNpLzs8tyc9NTgQADsMDmA"
79
+ *
80
+ * const darkUrl = buildMermaidInkUrl('svg', 'flowchart TD\n A-->B', {
81
+ * theme: 'dark',
82
+ * bgColor: '1b1b1f'
83
+ * });
84
+ * // => "https://mermaid.ink/svg/pako:eNp...?theme=dark&bgColor=1b1b1f"
85
+ *
86
+ * // With MermaidInkExportOptions
87
+ * const exportUrl = buildMermaidInkUrl('svg', 'flowchart TD\n A-->B', {
88
+ * provider: 'mermaid-ink',
89
+ * mermaidTheme: 'dark',
90
+ * background: '1b1b1f'
91
+ * });
92
+ * ```
93
+ */
94
+ declare function buildMermaidInkUrl(format: MermaidInkFormat, text: string, options?: MermaidInkOptions | MermaidInkExportOptions): string;
95
+ /**
96
+ * Generate a mermaid.ink URL from workflow IR.
97
+ *
98
+ * @param ir - Workflow intermediate representation
99
+ * @param format - Output format (default: 'svg')
100
+ * @param options - Optional mermaid.ink options
101
+ * @returns The mermaid.ink URL
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * const url = toMermaidInkUrl(workflowIR, 'svg');
106
+ * // Share this URL - image renders when viewed
107
+ *
108
+ * const darkUrl = toMermaidInkUrl(workflowIR, 'svg', { theme: 'dark' });
109
+ * ```
110
+ */
111
+ declare function toMermaidInkUrl(ir: WorkflowIR, format?: MermaidInkFormat, options?: MermaidInkOptions): string;
112
+ /**
113
+ * Generate a mermaid.ink SVG URL from workflow IR.
114
+ *
115
+ * @param ir - Workflow intermediate representation
116
+ * @param options - Optional mermaid.ink options
117
+ * @returns The mermaid.ink SVG URL
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * const svgUrl = toMermaidInkSvgUrl(workflowIR);
122
+ * // => "https://mermaid.ink/svg/pako:eNp..."
123
+ *
124
+ * const darkSvg = toMermaidInkSvgUrl(workflowIR, { theme: 'dark' });
125
+ * ```
126
+ */
127
+ declare function toMermaidInkSvgUrl(ir: WorkflowIR, options?: MermaidInkOptions): string;
128
+ /**
129
+ * Generate a mermaid.ink PNG URL from workflow IR.
130
+ *
131
+ * @param ir - Workflow intermediate representation
132
+ * @param options - Optional mermaid.ink options
133
+ * @returns The mermaid.ink PNG URL
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * const pngUrl = toMermaidInkPngUrl(workflowIR);
138
+ * // => "https://mermaid.ink/img/pako:eNp...?type=png"
139
+ *
140
+ * const scaledPng = toMermaidInkPngUrl(workflowIR, { width: 800, scale: 2 });
141
+ * ```
142
+ */
143
+ declare function toMermaidInkPngUrl(ir: WorkflowIR, options?: MermaidInkOptions): string;
144
+ /**
145
+ * Generate a mermaid.ink JPEG URL from workflow IR.
146
+ *
147
+ * @param ir - Workflow intermediate representation
148
+ * @param options - Optional mermaid.ink options
149
+ * @returns The mermaid.ink JPEG URL
150
+ */
151
+ declare function toMermaidInkJpegUrl(ir: WorkflowIR, options?: MermaidInkOptions): string;
152
+ /**
153
+ * Generate a mermaid.ink WebP URL from workflow IR.
154
+ *
155
+ * @param ir - Workflow intermediate representation
156
+ * @param options - Optional mermaid.ink options
157
+ * @returns The mermaid.ink WebP URL
158
+ */
159
+ declare function toMermaidInkWebpUrl(ir: WorkflowIR, options?: MermaidInkOptions): string;
160
+ /**
161
+ * Generate a mermaid.ink PDF URL from workflow IR.
162
+ *
163
+ * @param ir - Workflow intermediate representation
164
+ * @param options - Optional mermaid.ink options (fit, paper, landscape)
165
+ * @returns The mermaid.ink PDF URL
166
+ *
167
+ * @example
168
+ * ```typescript
169
+ * // Fit PDF to diagram size
170
+ * const fitPdf = toMermaidInkPdfUrl(workflowIR, { fit: true });
171
+ *
172
+ * // A3 landscape
173
+ * const a3Pdf = toMermaidInkPdfUrl(workflowIR, { paper: 'a3', landscape: true });
174
+ * ```
175
+ */
176
+ declare function toMermaidInkPdfUrl(ir: WorkflowIR, options?: MermaidInkOptions): string;
177
+ /**
178
+ * Mermaid.ink URL Generator interface.
179
+ */
180
+ interface MermaidInkGenerator {
181
+ /** Generate URL with specified format */
182
+ toUrl(ir: WorkflowIR, format: MermaidInkFormat): string;
183
+ /** Generate SVG URL */
184
+ toSvgUrl(ir: WorkflowIR): string;
185
+ /** Generate PNG URL */
186
+ toPngUrl(ir: WorkflowIR): string;
187
+ /** Generate JPEG URL */
188
+ toJpegUrl(ir: WorkflowIR): string;
189
+ /** Generate WebP URL */
190
+ toWebpUrl(ir: WorkflowIR): string;
191
+ /** Generate PDF URL */
192
+ toPdfUrl(ir: WorkflowIR): string;
193
+ /** Get the configured base URL */
194
+ getBaseUrl(): string;
195
+ /** Get the configured options */
196
+ getOptions(): MermaidInkOptions;
197
+ }
198
+ /**
199
+ * Create a mermaid.ink URL generator with default options.
200
+ * Useful for consistent theming across all generated URLs.
201
+ *
202
+ * @param options - Default mermaid.ink options applied to all URLs
203
+ * @returns A mermaid.ink URL generator instance
204
+ *
205
+ * @example
206
+ * ```typescript
207
+ * // Create generator with dark theme defaults
208
+ * const generator = createMermaidInkGenerator({
209
+ * theme: 'dark',
210
+ * bgColor: '1b1b1f',
211
+ * });
212
+ *
213
+ * // All URLs will use dark theme
214
+ * const svgUrl = generator.toSvgUrl(workflowIR);
215
+ * const pngUrl = generator.toPngUrl(workflowIR);
216
+ *
217
+ * // Self-hosted mermaid.ink
218
+ * const privateGenerator = createMermaidInkGenerator({
219
+ * baseUrl: 'https://mermaid.internal.company.com',
220
+ * });
221
+ * ```
222
+ */
223
+ declare function createMermaidInkGenerator(options?: MermaidInkOptions): MermaidInkGenerator;
224
+
225
+ /**
226
+ * Notifier Types
227
+ *
228
+ * Interfaces for notification systems that push workflow visualizations
229
+ * to external services like Slack, Discord, or custom webhooks.
230
+ */
231
+
232
+ /**
233
+ * Extended event types that the live session can handle.
234
+ * Includes both core WorkflowEvent and visualizer-specific events.
235
+ */
236
+ type LiveSessionEvent = WorkflowEvent<unknown> | ScopeStartEvent | ScopeEndEvent | DecisionStartEvent | DecisionBranchEvent | DecisionEndEvent;
237
+ /**
238
+ * Error types for notifier operations.
239
+ */
240
+ type NotifyError = "SEND_FAILED" | "INVALID_CONFIG";
241
+ /**
242
+ * Diagram rendering provider.
243
+ */
244
+ type DiagramProvider = "kroki" | "mermaid-ink";
245
+ /**
246
+ * Options for Kroki provider.
247
+ */
248
+ interface KrokiProviderOptions extends UrlGeneratorOptions {
249
+ /** Provider type */
250
+ provider: "kroki";
251
+ }
252
+ /**
253
+ * Options for mermaid.ink provider.
254
+ */
255
+ interface MermaidInkProviderOptions extends MermaidInkOptions {
256
+ /** Provider type */
257
+ provider: "mermaid-ink";
258
+ }
259
+ /**
260
+ * Combined provider options.
261
+ */
262
+ type ProviderOptions = KrokiProviderOptions | MermaidInkProviderOptions;
263
+ /**
264
+ * Status of a workflow when finalized.
265
+ */
266
+ type WorkflowStatus = "completed" | "failed" | "cancelled";
267
+ /**
268
+ * Options for creating a live session.
269
+ */
270
+ interface LiveSessionOptions {
271
+ /** Title for the notification (e.g., "Order #123 Processing") */
272
+ title: string;
273
+ /** Debounce interval in milliseconds (default: 500) */
274
+ debounceMs?: number;
275
+ /** Max time between posts even during constant updates (default: 5000) */
276
+ maxWaitMs?: number;
277
+ /** Additional metadata to include in notifications */
278
+ metadata?: Record<string, unknown>;
279
+ }
280
+ /**
281
+ * Live session for real-time workflow updates.
282
+ *
283
+ * Behavior:
284
+ * - First `update()`: Posts new message with Kroki URL
285
+ * - Subsequent `update()`: Edits same message (debounced)
286
+ * - `finalize()`: Posts final state, marks session complete
287
+ * - `cancel()`: Aborts session, optionally deletes partial message
288
+ */
289
+ interface LiveSession {
290
+ /** Update the visualization (debounced) */
291
+ update(eventOrIr: LiveSessionEvent | WorkflowIR): void;
292
+ /** Finalize the session with final status */
293
+ finalize(status?: WorkflowStatus): Promise<void>;
294
+ /** Cancel the session, optionally deleting the message */
295
+ cancel(): void;
296
+ /** Get the current session ID (e.g., message timestamp for Slack) */
297
+ getSessionId(): string | undefined;
298
+ /** Check if the session is still active */
299
+ isActive(): boolean;
300
+ }
301
+ /**
302
+ * Notifier interface for pushing workflow visualizations.
303
+ */
304
+ interface Notifier {
305
+ /** Send a one-time notification with the current workflow state */
306
+ notify(ir: WorkflowIR, options?: NotifyOptions): AsyncResult<string | undefined, NotifyError>;
307
+ /** Create a live session for real-time updates */
308
+ createLive(options: LiveSessionOptions): LiveSession;
309
+ /** Get the notifier type (e.g., "slack", "discord", "webhook") */
310
+ getType(): string;
311
+ }
312
+ /**
313
+ * Options for one-time notifications.
314
+ */
315
+ interface NotifyOptions {
316
+ /** Title for the notification */
317
+ title?: string;
318
+ /** Additional text content */
319
+ text?: string;
320
+ /** Additional metadata */
321
+ metadata?: Record<string, unknown>;
322
+ }
323
+ /**
324
+ * Base options for all notifiers.
325
+ */
326
+ interface BaseNotifierOptions {
327
+ /** Debounce interval in milliseconds for live sessions (default: 500) */
328
+ debounceMs?: number;
329
+ /** Max wait between updates during constant churn (default: 5000) */
330
+ maxWaitMs?: number;
331
+ /**
332
+ * Diagram rendering provider configuration.
333
+ * REQUIRED - no silent default to prevent surprise network calls.
334
+ *
335
+ * @example
336
+ * ```typescript
337
+ * // Use Kroki
338
+ * { provider: 'kroki' }
339
+ *
340
+ * // Use mermaid.ink with dark theme
341
+ * { provider: 'mermaid-ink', theme: 'dark', bgColor: '1b1b1f' }
342
+ *
343
+ * // Use self-hosted Kroki
344
+ * { provider: 'kroki', baseUrl: 'https://kroki.internal' }
345
+ * ```
346
+ */
347
+ diagramProvider: ProviderOptions;
348
+ }
349
+
350
+ export { type BaseNotifierOptions as B, type DiagramProvider as D, type KrokiProviderOptions as K, type MermaidInkFormat as M, type Notifier as N, type ProviderOptions as P, type WorkflowStatus as W, type MermaidInkGenerator as a, type MermaidInkImageType as b, type MermaidInkOptions as c, type MermaidInkPaperSize as d, type MermaidInkProviderOptions as e, type MermaidInkTheme as f, buildMermaidInkUrl as g, createMermaidInkGenerator as h, encodeForMermaidInk as i, toMermaidInkPdfUrl as j, toMermaidInkPngUrl as k, toMermaidInkSvgUrl as l, toMermaidInkUrl as m, toMermaidInkWebpUrl as n, toMermaidInkJpegUrl as t };
@@ -0,0 +1,350 @@
1
+ import { AsyncResult } from 'awaitly';
2
+ import { WorkflowEvent } from 'awaitly/workflow';
3
+ import { W as WorkflowIR, M as MermaidInkExportOptions, U as UrlGeneratorOptions, S as ScopeStartEvent, e as ScopeEndEvent, b as DecisionStartEvent, c as DecisionBranchEvent, d as DecisionEndEvent } from './url-PkfQz4V5.cjs';
4
+
5
+ /**
6
+ * Mermaid.ink URL Generation
7
+ *
8
+ * Generates shareable URLs for mermaid.ink diagram rendering service.
9
+ * Alternative to Kroki with additional features like themes, background colors, and sizing.
10
+ *
11
+ * @see https://mermaid.ink/
12
+ */
13
+
14
+ /**
15
+ * Supported mermaid.ink output formats.
16
+ */
17
+ type MermaidInkFormat = "svg" | "img" | "pdf";
18
+ /**
19
+ * Image type for /img endpoint.
20
+ */
21
+ type MermaidInkImageType = "jpeg" | "png" | "webp";
22
+ /**
23
+ * Mermaid.ink built-in themes.
24
+ */
25
+ type MermaidInkTheme = "default" | "neutral" | "dark" | "forest";
26
+ /**
27
+ * PDF paper sizes.
28
+ */
29
+ type MermaidInkPaperSize = "letter" | "legal" | "tabloid" | "ledger" | "a0" | "a1" | "a2" | "a3" | "a4" | "a5" | "a6";
30
+ /**
31
+ * Options for mermaid.ink URL generation.
32
+ */
33
+ interface MermaidInkOptions {
34
+ /** Base URL for mermaid.ink service (default: https://mermaid.ink) */
35
+ baseUrl?: string;
36
+ /**
37
+ * Background color.
38
+ * - Hex color without #: "FF0000" for red
39
+ * - Named color with ! prefix: "!white", "!black"
40
+ */
41
+ bgColor?: string;
42
+ /** Mermaid theme */
43
+ theme?: MermaidInkTheme;
44
+ /** Image width in pixels */
45
+ width?: number;
46
+ /** Image height in pixels */
47
+ height?: number;
48
+ /** Image scale (1-3). Only applies if width or height is set */
49
+ scale?: number;
50
+ /** Image type for /img endpoint (default: jpeg) */
51
+ imageType?: MermaidInkImageType;
52
+ /** Fit PDF size to diagram size */
53
+ fit?: boolean;
54
+ /** Paper size for PDF (default: a4) */
55
+ paper?: MermaidInkPaperSize;
56
+ /** Landscape orientation for PDF */
57
+ landscape?: boolean;
58
+ }
59
+ /**
60
+ * Encode text for mermaid.ink URL.
61
+ * Uses pako deflate compression + base64 encoding with "pako:" prefix.
62
+ *
63
+ * @param text - The Mermaid diagram text
64
+ * @returns Encoded string with "pako:" prefix
65
+ */
66
+ declare function encodeForMermaidInk(text: string): string;
67
+ /**
68
+ * Build a mermaid.ink URL for the given Mermaid diagram text.
69
+ *
70
+ * @param format - Output format (svg, img, pdf)
71
+ * @param text - The Mermaid diagram text
72
+ * @param options - Optional mermaid.ink options (MermaidInkOptions or MermaidInkExportOptions)
73
+ * @returns The mermaid.ink URL
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * const url = buildMermaidInkUrl('svg', 'flowchart TD\n A-->B');
78
+ * // => "https://mermaid.ink/svg/pako:eNpLzs8tyc9NTgQADsMDmA"
79
+ *
80
+ * const darkUrl = buildMermaidInkUrl('svg', 'flowchart TD\n A-->B', {
81
+ * theme: 'dark',
82
+ * bgColor: '1b1b1f'
83
+ * });
84
+ * // => "https://mermaid.ink/svg/pako:eNp...?theme=dark&bgColor=1b1b1f"
85
+ *
86
+ * // With MermaidInkExportOptions
87
+ * const exportUrl = buildMermaidInkUrl('svg', 'flowchart TD\n A-->B', {
88
+ * provider: 'mermaid-ink',
89
+ * mermaidTheme: 'dark',
90
+ * background: '1b1b1f'
91
+ * });
92
+ * ```
93
+ */
94
+ declare function buildMermaidInkUrl(format: MermaidInkFormat, text: string, options?: MermaidInkOptions | MermaidInkExportOptions): string;
95
+ /**
96
+ * Generate a mermaid.ink URL from workflow IR.
97
+ *
98
+ * @param ir - Workflow intermediate representation
99
+ * @param format - Output format (default: 'svg')
100
+ * @param options - Optional mermaid.ink options
101
+ * @returns The mermaid.ink URL
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * const url = toMermaidInkUrl(workflowIR, 'svg');
106
+ * // Share this URL - image renders when viewed
107
+ *
108
+ * const darkUrl = toMermaidInkUrl(workflowIR, 'svg', { theme: 'dark' });
109
+ * ```
110
+ */
111
+ declare function toMermaidInkUrl(ir: WorkflowIR, format?: MermaidInkFormat, options?: MermaidInkOptions): string;
112
+ /**
113
+ * Generate a mermaid.ink SVG URL from workflow IR.
114
+ *
115
+ * @param ir - Workflow intermediate representation
116
+ * @param options - Optional mermaid.ink options
117
+ * @returns The mermaid.ink SVG URL
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * const svgUrl = toMermaidInkSvgUrl(workflowIR);
122
+ * // => "https://mermaid.ink/svg/pako:eNp..."
123
+ *
124
+ * const darkSvg = toMermaidInkSvgUrl(workflowIR, { theme: 'dark' });
125
+ * ```
126
+ */
127
+ declare function toMermaidInkSvgUrl(ir: WorkflowIR, options?: MermaidInkOptions): string;
128
+ /**
129
+ * Generate a mermaid.ink PNG URL from workflow IR.
130
+ *
131
+ * @param ir - Workflow intermediate representation
132
+ * @param options - Optional mermaid.ink options
133
+ * @returns The mermaid.ink PNG URL
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * const pngUrl = toMermaidInkPngUrl(workflowIR);
138
+ * // => "https://mermaid.ink/img/pako:eNp...?type=png"
139
+ *
140
+ * const scaledPng = toMermaidInkPngUrl(workflowIR, { width: 800, scale: 2 });
141
+ * ```
142
+ */
143
+ declare function toMermaidInkPngUrl(ir: WorkflowIR, options?: MermaidInkOptions): string;
144
+ /**
145
+ * Generate a mermaid.ink JPEG URL from workflow IR.
146
+ *
147
+ * @param ir - Workflow intermediate representation
148
+ * @param options - Optional mermaid.ink options
149
+ * @returns The mermaid.ink JPEG URL
150
+ */
151
+ declare function toMermaidInkJpegUrl(ir: WorkflowIR, options?: MermaidInkOptions): string;
152
+ /**
153
+ * Generate a mermaid.ink WebP URL from workflow IR.
154
+ *
155
+ * @param ir - Workflow intermediate representation
156
+ * @param options - Optional mermaid.ink options
157
+ * @returns The mermaid.ink WebP URL
158
+ */
159
+ declare function toMermaidInkWebpUrl(ir: WorkflowIR, options?: MermaidInkOptions): string;
160
+ /**
161
+ * Generate a mermaid.ink PDF URL from workflow IR.
162
+ *
163
+ * @param ir - Workflow intermediate representation
164
+ * @param options - Optional mermaid.ink options (fit, paper, landscape)
165
+ * @returns The mermaid.ink PDF URL
166
+ *
167
+ * @example
168
+ * ```typescript
169
+ * // Fit PDF to diagram size
170
+ * const fitPdf = toMermaidInkPdfUrl(workflowIR, { fit: true });
171
+ *
172
+ * // A3 landscape
173
+ * const a3Pdf = toMermaidInkPdfUrl(workflowIR, { paper: 'a3', landscape: true });
174
+ * ```
175
+ */
176
+ declare function toMermaidInkPdfUrl(ir: WorkflowIR, options?: MermaidInkOptions): string;
177
+ /**
178
+ * Mermaid.ink URL Generator interface.
179
+ */
180
+ interface MermaidInkGenerator {
181
+ /** Generate URL with specified format */
182
+ toUrl(ir: WorkflowIR, format: MermaidInkFormat): string;
183
+ /** Generate SVG URL */
184
+ toSvgUrl(ir: WorkflowIR): string;
185
+ /** Generate PNG URL */
186
+ toPngUrl(ir: WorkflowIR): string;
187
+ /** Generate JPEG URL */
188
+ toJpegUrl(ir: WorkflowIR): string;
189
+ /** Generate WebP URL */
190
+ toWebpUrl(ir: WorkflowIR): string;
191
+ /** Generate PDF URL */
192
+ toPdfUrl(ir: WorkflowIR): string;
193
+ /** Get the configured base URL */
194
+ getBaseUrl(): string;
195
+ /** Get the configured options */
196
+ getOptions(): MermaidInkOptions;
197
+ }
198
+ /**
199
+ * Create a mermaid.ink URL generator with default options.
200
+ * Useful for consistent theming across all generated URLs.
201
+ *
202
+ * @param options - Default mermaid.ink options applied to all URLs
203
+ * @returns A mermaid.ink URL generator instance
204
+ *
205
+ * @example
206
+ * ```typescript
207
+ * // Create generator with dark theme defaults
208
+ * const generator = createMermaidInkGenerator({
209
+ * theme: 'dark',
210
+ * bgColor: '1b1b1f',
211
+ * });
212
+ *
213
+ * // All URLs will use dark theme
214
+ * const svgUrl = generator.toSvgUrl(workflowIR);
215
+ * const pngUrl = generator.toPngUrl(workflowIR);
216
+ *
217
+ * // Self-hosted mermaid.ink
218
+ * const privateGenerator = createMermaidInkGenerator({
219
+ * baseUrl: 'https://mermaid.internal.company.com',
220
+ * });
221
+ * ```
222
+ */
223
+ declare function createMermaidInkGenerator(options?: MermaidInkOptions): MermaidInkGenerator;
224
+
225
+ /**
226
+ * Notifier Types
227
+ *
228
+ * Interfaces for notification systems that push workflow visualizations
229
+ * to external services like Slack, Discord, or custom webhooks.
230
+ */
231
+
232
+ /**
233
+ * Extended event types that the live session can handle.
234
+ * Includes both core WorkflowEvent and visualizer-specific events.
235
+ */
236
+ type LiveSessionEvent = WorkflowEvent<unknown> | ScopeStartEvent | ScopeEndEvent | DecisionStartEvent | DecisionBranchEvent | DecisionEndEvent;
237
+ /**
238
+ * Error types for notifier operations.
239
+ */
240
+ type NotifyError = "SEND_FAILED" | "INVALID_CONFIG";
241
+ /**
242
+ * Diagram rendering provider.
243
+ */
244
+ type DiagramProvider = "kroki" | "mermaid-ink";
245
+ /**
246
+ * Options for Kroki provider.
247
+ */
248
+ interface KrokiProviderOptions extends UrlGeneratorOptions {
249
+ /** Provider type */
250
+ provider: "kroki";
251
+ }
252
+ /**
253
+ * Options for mermaid.ink provider.
254
+ */
255
+ interface MermaidInkProviderOptions extends MermaidInkOptions {
256
+ /** Provider type */
257
+ provider: "mermaid-ink";
258
+ }
259
+ /**
260
+ * Combined provider options.
261
+ */
262
+ type ProviderOptions = KrokiProviderOptions | MermaidInkProviderOptions;
263
+ /**
264
+ * Status of a workflow when finalized.
265
+ */
266
+ type WorkflowStatus = "completed" | "failed" | "cancelled";
267
+ /**
268
+ * Options for creating a live session.
269
+ */
270
+ interface LiveSessionOptions {
271
+ /** Title for the notification (e.g., "Order #123 Processing") */
272
+ title: string;
273
+ /** Debounce interval in milliseconds (default: 500) */
274
+ debounceMs?: number;
275
+ /** Max time between posts even during constant updates (default: 5000) */
276
+ maxWaitMs?: number;
277
+ /** Additional metadata to include in notifications */
278
+ metadata?: Record<string, unknown>;
279
+ }
280
+ /**
281
+ * Live session for real-time workflow updates.
282
+ *
283
+ * Behavior:
284
+ * - First `update()`: Posts new message with Kroki URL
285
+ * - Subsequent `update()`: Edits same message (debounced)
286
+ * - `finalize()`: Posts final state, marks session complete
287
+ * - `cancel()`: Aborts session, optionally deletes partial message
288
+ */
289
+ interface LiveSession {
290
+ /** Update the visualization (debounced) */
291
+ update(eventOrIr: LiveSessionEvent | WorkflowIR): void;
292
+ /** Finalize the session with final status */
293
+ finalize(status?: WorkflowStatus): Promise<void>;
294
+ /** Cancel the session, optionally deleting the message */
295
+ cancel(): void;
296
+ /** Get the current session ID (e.g., message timestamp for Slack) */
297
+ getSessionId(): string | undefined;
298
+ /** Check if the session is still active */
299
+ isActive(): boolean;
300
+ }
301
+ /**
302
+ * Notifier interface for pushing workflow visualizations.
303
+ */
304
+ interface Notifier {
305
+ /** Send a one-time notification with the current workflow state */
306
+ notify(ir: WorkflowIR, options?: NotifyOptions): AsyncResult<string | undefined, NotifyError>;
307
+ /** Create a live session for real-time updates */
308
+ createLive(options: LiveSessionOptions): LiveSession;
309
+ /** Get the notifier type (e.g., "slack", "discord", "webhook") */
310
+ getType(): string;
311
+ }
312
+ /**
313
+ * Options for one-time notifications.
314
+ */
315
+ interface NotifyOptions {
316
+ /** Title for the notification */
317
+ title?: string;
318
+ /** Additional text content */
319
+ text?: string;
320
+ /** Additional metadata */
321
+ metadata?: Record<string, unknown>;
322
+ }
323
+ /**
324
+ * Base options for all notifiers.
325
+ */
326
+ interface BaseNotifierOptions {
327
+ /** Debounce interval in milliseconds for live sessions (default: 500) */
328
+ debounceMs?: number;
329
+ /** Max wait between updates during constant churn (default: 5000) */
330
+ maxWaitMs?: number;
331
+ /**
332
+ * Diagram rendering provider configuration.
333
+ * REQUIRED - no silent default to prevent surprise network calls.
334
+ *
335
+ * @example
336
+ * ```typescript
337
+ * // Use Kroki
338
+ * { provider: 'kroki' }
339
+ *
340
+ * // Use mermaid.ink with dark theme
341
+ * { provider: 'mermaid-ink', theme: 'dark', bgColor: '1b1b1f' }
342
+ *
343
+ * // Use self-hosted Kroki
344
+ * { provider: 'kroki', baseUrl: 'https://kroki.internal' }
345
+ * ```
346
+ */
347
+ diagramProvider: ProviderOptions;
348
+ }
349
+
350
+ export { type BaseNotifierOptions as B, type DiagramProvider as D, type KrokiProviderOptions as K, type MermaidInkFormat as M, type Notifier as N, type ProviderOptions as P, type WorkflowStatus as W, type MermaidInkGenerator as a, type MermaidInkImageType as b, type MermaidInkOptions as c, type MermaidInkPaperSize as d, type MermaidInkProviderOptions as e, type MermaidInkTheme as f, buildMermaidInkUrl as g, createMermaidInkGenerator as h, encodeForMermaidInk as i, toMermaidInkPdfUrl as j, toMermaidInkPngUrl as k, toMermaidInkSvgUrl as l, toMermaidInkUrl as m, toMermaidInkWebpUrl as n, toMermaidInkJpegUrl as t };