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.
- package/dist/index.browser.cjs +1677 -0
- package/dist/index.browser.cjs.map +1 -0
- package/dist/index.browser.d.cts +166 -0
- package/dist/index.browser.d.ts +166 -0
- package/dist/index.browser.js +1677 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.cjs +1680 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +242 -0
- package/dist/index.d.ts +242 -0
- package/dist/index.js +1680 -0
- package/dist/index.js.map +1 -0
- package/dist/kroki/fetch.cjs +3 -0
- package/dist/kroki/fetch.cjs.map +1 -0
- package/dist/kroki/fetch.d.cts +86 -0
- package/dist/kroki/fetch.d.ts +86 -0
- package/dist/kroki/fetch.js +3 -0
- package/dist/kroki/fetch.js.map +1 -0
- package/dist/notifiers/discord.cjs +3 -0
- package/dist/notifiers/discord.cjs.map +1 -0
- package/dist/notifiers/discord.d.cts +70 -0
- package/dist/notifiers/discord.d.ts +70 -0
- package/dist/notifiers/discord.js +3 -0
- package/dist/notifiers/discord.js.map +1 -0
- package/dist/notifiers/slack.cjs +38 -0
- package/dist/notifiers/slack.cjs.map +1 -0
- package/dist/notifiers/slack.d.cts +95 -0
- package/dist/notifiers/slack.d.ts +95 -0
- package/dist/notifiers/slack.js +38 -0
- package/dist/notifiers/slack.js.map +1 -0
- package/dist/notifiers/webhook.cjs +3 -0
- package/dist/notifiers/webhook.cjs.map +1 -0
- package/dist/notifiers/webhook.d.cts +115 -0
- package/dist/notifiers/webhook.d.ts +115 -0
- package/dist/notifiers/webhook.js +3 -0
- package/dist/notifiers/webhook.js.map +1 -0
- package/dist/performance-analyzer-B5VF5b1F.d.ts +663 -0
- package/dist/performance-analyzer-BNwE4AiO.d.cts +663 -0
- package/dist/types-BIZSmXif.d.ts +350 -0
- package/dist/types-BnWc9Wlr.d.cts +350 -0
- package/dist/url-PkfQz4V5.d.cts +750 -0
- package/dist/url-PkfQz4V5.d.ts +750 -0
- package/package.json +105 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { W as WorkflowStatus, B as BaseNotifierOptions, P as ProviderOptions, N as Notifier } from '../types-BnWc9Wlr.cjs';
|
|
2
|
+
import { W as WorkflowIR } from '../url-PkfQz4V5.cjs';
|
|
3
|
+
import 'awaitly';
|
|
4
|
+
import 'awaitly/workflow';
|
|
5
|
+
import 'awaitly/core';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Webhook Adapter
|
|
9
|
+
*
|
|
10
|
+
* Platform-specific adapter for generic HTTP webhooks.
|
|
11
|
+
* Handles only webhook-specific payload formatting and API calls.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Webhook payload structure.
|
|
16
|
+
*/
|
|
17
|
+
interface WebhookPayload {
|
|
18
|
+
/** Event type (e.g., "workflow.update", "workflow.complete") */
|
|
19
|
+
event: string;
|
|
20
|
+
/** Timestamp of the event */
|
|
21
|
+
timestamp: string;
|
|
22
|
+
/** Workflow title */
|
|
23
|
+
title: string;
|
|
24
|
+
/** Workflow status (for finalize events) */
|
|
25
|
+
status?: WorkflowStatus | "running";
|
|
26
|
+
/** Diagram SVG URL (from Kroki or mermaid.ink) */
|
|
27
|
+
diagramUrl?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Kroki SVG URL for visualization
|
|
30
|
+
* @deprecated Use diagramUrl instead
|
|
31
|
+
*/
|
|
32
|
+
krokiUrl?: string;
|
|
33
|
+
/** Diagram provider used ("kroki" or "mermaid-ink") */
|
|
34
|
+
diagramProvider?: string;
|
|
35
|
+
/** Raw Mermaid diagram text */
|
|
36
|
+
mermaid?: string;
|
|
37
|
+
/** The workflow IR */
|
|
38
|
+
ir: WorkflowIR;
|
|
39
|
+
/** Additional metadata */
|
|
40
|
+
metadata?: Record<string, unknown>;
|
|
41
|
+
/** Message ID for updates */
|
|
42
|
+
messageId?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Webhook Notifier
|
|
47
|
+
*
|
|
48
|
+
* Generic HTTP webhook notifier for pushing workflow visualizations
|
|
49
|
+
* to custom dashboards or services.
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Options for webhook notifier.
|
|
54
|
+
*/
|
|
55
|
+
interface WebhookNotifierOptions extends BaseNotifierOptions {
|
|
56
|
+
/** Webhook URL to POST to */
|
|
57
|
+
url: string;
|
|
58
|
+
/** Optional headers to include in requests */
|
|
59
|
+
headers?: Record<string, string>;
|
|
60
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
61
|
+
timeout?: number;
|
|
62
|
+
/** Whether to include raw mermaid text (default: false) */
|
|
63
|
+
includeMermaid?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Whether to include diagram URL (default: true).
|
|
66
|
+
* @deprecated Use includeDiagramUrl instead
|
|
67
|
+
*/
|
|
68
|
+
includeKrokiUrl?: boolean;
|
|
69
|
+
/** Whether to include diagram URL (default: true) */
|
|
70
|
+
includeDiagramUrl?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Diagram rendering provider configuration.
|
|
73
|
+
* REQUIRED - no silent default to prevent surprise network calls.
|
|
74
|
+
*/
|
|
75
|
+
diagramProvider: ProviderOptions;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Create a webhook notifier.
|
|
79
|
+
*
|
|
80
|
+
* @param options - Webhook configuration
|
|
81
|
+
* @returns A Notifier instance
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* import { createWebhookNotifier } from 'awaitly-visualizer/notifiers/webhook';
|
|
86
|
+
*
|
|
87
|
+
* // Using Kroki (default)
|
|
88
|
+
* const webhook = createWebhookNotifier({
|
|
89
|
+
* url: 'https://my-dashboard.com/workflow-events',
|
|
90
|
+
* headers: { 'X-API-Key': 'secret' },
|
|
91
|
+
* diagramProvider: { provider: 'kroki' },
|
|
92
|
+
* });
|
|
93
|
+
*
|
|
94
|
+
* // Using mermaid.ink with dark theme
|
|
95
|
+
* const webhookDark = createWebhookNotifier({
|
|
96
|
+
* url: 'https://my-dashboard.com/workflow-events',
|
|
97
|
+
* diagramProvider: {
|
|
98
|
+
* provider: 'mermaid-ink',
|
|
99
|
+
* theme: 'dark',
|
|
100
|
+
* bgColor: '1b1b1f',
|
|
101
|
+
* },
|
|
102
|
+
* });
|
|
103
|
+
*
|
|
104
|
+
* // One-time notification
|
|
105
|
+
* await webhook.notify(workflowIR, { title: 'Order Processing' });
|
|
106
|
+
*
|
|
107
|
+
* // Live updates
|
|
108
|
+
* const live = webhook.createLive({ title: 'Order #123' });
|
|
109
|
+
* workflow.on('event', (e) => live.update(e));
|
|
110
|
+
* await live.finalize();
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
declare function createWebhookNotifier(options: WebhookNotifierOptions): Notifier;
|
|
114
|
+
|
|
115
|
+
export { type WebhookNotifierOptions, type WebhookPayload, createWebhookNotifier };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { W as WorkflowStatus, B as BaseNotifierOptions, P as ProviderOptions, N as Notifier } from '../types-BIZSmXif.js';
|
|
2
|
+
import { W as WorkflowIR } from '../url-PkfQz4V5.js';
|
|
3
|
+
import 'awaitly';
|
|
4
|
+
import 'awaitly/workflow';
|
|
5
|
+
import 'awaitly/core';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Webhook Adapter
|
|
9
|
+
*
|
|
10
|
+
* Platform-specific adapter for generic HTTP webhooks.
|
|
11
|
+
* Handles only webhook-specific payload formatting and API calls.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Webhook payload structure.
|
|
16
|
+
*/
|
|
17
|
+
interface WebhookPayload {
|
|
18
|
+
/** Event type (e.g., "workflow.update", "workflow.complete") */
|
|
19
|
+
event: string;
|
|
20
|
+
/** Timestamp of the event */
|
|
21
|
+
timestamp: string;
|
|
22
|
+
/** Workflow title */
|
|
23
|
+
title: string;
|
|
24
|
+
/** Workflow status (for finalize events) */
|
|
25
|
+
status?: WorkflowStatus | "running";
|
|
26
|
+
/** Diagram SVG URL (from Kroki or mermaid.ink) */
|
|
27
|
+
diagramUrl?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Kroki SVG URL for visualization
|
|
30
|
+
* @deprecated Use diagramUrl instead
|
|
31
|
+
*/
|
|
32
|
+
krokiUrl?: string;
|
|
33
|
+
/** Diagram provider used ("kroki" or "mermaid-ink") */
|
|
34
|
+
diagramProvider?: string;
|
|
35
|
+
/** Raw Mermaid diagram text */
|
|
36
|
+
mermaid?: string;
|
|
37
|
+
/** The workflow IR */
|
|
38
|
+
ir: WorkflowIR;
|
|
39
|
+
/** Additional metadata */
|
|
40
|
+
metadata?: Record<string, unknown>;
|
|
41
|
+
/** Message ID for updates */
|
|
42
|
+
messageId?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Webhook Notifier
|
|
47
|
+
*
|
|
48
|
+
* Generic HTTP webhook notifier for pushing workflow visualizations
|
|
49
|
+
* to custom dashboards or services.
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Options for webhook notifier.
|
|
54
|
+
*/
|
|
55
|
+
interface WebhookNotifierOptions extends BaseNotifierOptions {
|
|
56
|
+
/** Webhook URL to POST to */
|
|
57
|
+
url: string;
|
|
58
|
+
/** Optional headers to include in requests */
|
|
59
|
+
headers?: Record<string, string>;
|
|
60
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
61
|
+
timeout?: number;
|
|
62
|
+
/** Whether to include raw mermaid text (default: false) */
|
|
63
|
+
includeMermaid?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Whether to include diagram URL (default: true).
|
|
66
|
+
* @deprecated Use includeDiagramUrl instead
|
|
67
|
+
*/
|
|
68
|
+
includeKrokiUrl?: boolean;
|
|
69
|
+
/** Whether to include diagram URL (default: true) */
|
|
70
|
+
includeDiagramUrl?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Diagram rendering provider configuration.
|
|
73
|
+
* REQUIRED - no silent default to prevent surprise network calls.
|
|
74
|
+
*/
|
|
75
|
+
diagramProvider: ProviderOptions;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Create a webhook notifier.
|
|
79
|
+
*
|
|
80
|
+
* @param options - Webhook configuration
|
|
81
|
+
* @returns A Notifier instance
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* import { createWebhookNotifier } from 'awaitly-visualizer/notifiers/webhook';
|
|
86
|
+
*
|
|
87
|
+
* // Using Kroki (default)
|
|
88
|
+
* const webhook = createWebhookNotifier({
|
|
89
|
+
* url: 'https://my-dashboard.com/workflow-events',
|
|
90
|
+
* headers: { 'X-API-Key': 'secret' },
|
|
91
|
+
* diagramProvider: { provider: 'kroki' },
|
|
92
|
+
* });
|
|
93
|
+
*
|
|
94
|
+
* // Using mermaid.ink with dark theme
|
|
95
|
+
* const webhookDark = createWebhookNotifier({
|
|
96
|
+
* url: 'https://my-dashboard.com/workflow-events',
|
|
97
|
+
* diagramProvider: {
|
|
98
|
+
* provider: 'mermaid-ink',
|
|
99
|
+
* theme: 'dark',
|
|
100
|
+
* bgColor: '1b1b1f',
|
|
101
|
+
* },
|
|
102
|
+
* });
|
|
103
|
+
*
|
|
104
|
+
* // One-time notification
|
|
105
|
+
* await webhook.notify(workflowIR, { title: 'Order Processing' });
|
|
106
|
+
*
|
|
107
|
+
* // Live updates
|
|
108
|
+
* const live = webhook.createLive({ title: 'Order #123' });
|
|
109
|
+
* workflow.on('event', (e) => live.update(e));
|
|
110
|
+
* await live.finalize();
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
declare function createWebhookNotifier(options: WebhookNotifierOptions): Notifier;
|
|
114
|
+
|
|
115
|
+
export { type WebhookNotifierOptions, type WebhookPayload, createWebhookNotifier };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{ok as at,err as ct}from"awaitly";function V(e){function r(n){let c=0;for(let u of n)if(u.type==="step")c++;else if(u.type==="decision"&&u.branches)for(let s of u.branches)s.taken&&(c+=r(s.children));else"children"in u&&u.children&&(c+=r(u.children));return c}return r(e.root.children)}import{ok as St,err as $t}from"awaitly";function q(e){return e.type==="step"}function J(e){return e.type==="parallel"}function Y(e){return e.type==="race"}function Z(e){return e.type==="decision"}function X(e){return e.type==="stream"}function W(e){if(e<1e3)return`${Math.round(e)}ms`;if(e<6e4)return`${(e/1e3).toFixed(1).replace(/\.0$/,"")}s`;let r=Math.floor(e/6e4),n=Math.round(e%6e4/1e3);return n>=60&&(r+=1,n=0),n===0?`${r}m`:`${r}m ${n}s`}function A(){return`node_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}var Re="\x1B[2m",Ie="\x1B[31m",Ne="\x1B[32m",Me="\x1B[33m",Ee="\x1B[34m",Q="\x1B[90m",Te="\x1B[37m";var _={pending:Te,running:Me,success:Ne,error:Ie,aborted:Q,cached:Ee,skipped:Re+Q};import{ok as Oe,err as De}from"awaitly";function ee(e){return e<.2?"cold":e<.4?"cool":e<.6?"neutral":e<.8?"warm":e<.95?"hot":"critical"}function ve(){return[" classDef pending fill:#f3f4f6,stroke:#9ca3af,stroke-width:2px,color:#374151"," classDef running fill:#fef3c7,stroke:#f59e0b,stroke-width:3px,color:#92400e"," classDef success fill:#d1fae5,stroke:#10b981,stroke-width:3px,color:#065f46"," classDef error fill:#fee2e2,stroke:#ef4444,stroke-width:3px,color:#991b1b"," classDef aborted fill:#f3f4f6,stroke:#6b7280,stroke-width:2px,color:#4b5563,stroke-dasharray: 5 5"," classDef cached fill:#dbeafe,stroke:#3b82f6,stroke-width:3px,color:#1e40af"," classDef skipped fill:#f9fafb,stroke:#d1d5db,stroke-width:2px,color:#6b7280,stroke-dasharray: 5 5"," classDef stream fill:#ede9fe,stroke:#8b5cf6,stroke-width:3px,color:#5b21b6"," classDef streamActive fill:#ddd6fe,stroke:#7c3aed,stroke-width:3px,color:#4c1d95"," classDef streamError fill:#fce7f3,stroke:#db2777,stroke-width:3px,color:#9d174d"]}function We(){return[" classDef heat_cold fill:#dbeafe,stroke:#3b82f6,stroke-width:2px,color:#1e40af"," classDef heat_cool fill:#ccfbf1,stroke:#14b8a6,stroke-width:2px,color:#0f766e"," classDef heat_neutral fill:#f3f4f6,stroke:#6b7280,stroke-width:2px,color:#374151"," classDef heat_warm fill:#fef3c7,stroke:#f59e0b,stroke-width:2px,color:#92400e"," classDef heat_hot fill:#fed7aa,stroke:#f97316,stroke-width:3px,color:#c2410c"," classDef heat_critical fill:#fecaca,stroke:#ef4444,stroke-width:3px,color:#b91c1c"]}function _e(e){return`heat_${e}`}function Ce(){return[" classDef hook_success fill:#e0f2fe,stroke:#0284c7,stroke-width:2px,color:#0c4a6e"," classDef hook_error fill:#fef2f2,stroke:#dc2626,stroke-width:2px,color:#7f1d1d"]}function Pe(e){try{return Oe(JSON.stringify(e,(n,c)=>{if(typeof c!="bigint")return c;let u=Number(c);return Number.isSafeInteger(u)?u:c.toString()}))}catch{return De("STRINGIFY_ERROR")}}function te(e){let r=Pe(e);return r.ok?r.value:"[unserializable]"}function Le(e,r,n){let c;if(e.shouldRun){let u="hook_shouldRun",s=e.shouldRun.state==="success"?"hook_success":"hook_error",h=e.shouldRun.state==="success"?"\u2699":"\u26A0",m=n.showTimings&&e.shouldRun.durationMs!==void 0?` ${W(e.shouldRun.durationMs)}`:"",g=e.shouldRun.context?.skipped?"\\nskipped workflow":e.shouldRun.context?.result===!0?"\\nproceed":"";r.push(` ${u}[["${h} shouldRun${g}${m}"]]:::${s}`),c=u}if(e.onBeforeStart){let u="hook_beforeStart",s=e.onBeforeStart.state==="success"?"hook_success":"hook_error",h=e.onBeforeStart.state==="success"?"\u2699":"\u26A0",m=n.showTimings&&e.onBeforeStart.durationMs!==void 0?` ${W(e.onBeforeStart.durationMs)}`:"",g=e.onBeforeStart.context?.skipped?"\\nskipped workflow":"";r.push(` ${u}[["${h} onBeforeStart${g}${m}"]]:::${s}`),c&&r.push(` ${c} --> ${u}`),c=u}return{lastHookId:c}}var re=0,F=new Set,B=new Set;function P(e="node"){return`${e}_${++re}`}function Ue(){re=0,F.clear(),B.clear()}function O(e){return e.replace(/"/g,"#quot;").replace(/</g,"<").replace(/>/g,">").trim()}function ne(e){return O(e).replace(/[{}[\]()]/g,"")}function C(){return{name:"mermaid",supportsLive:!1,render(e,r){Ue();let n=[],c=r;n.push("flowchart TD");let u;e.hooks&&(u=Le(e.hooks,n,r).lastHookId);let s="start";n.push(` ${s}(("\u25B6 Start"))`),u&&n.push(` ${u} --> ${s}`);let h=s;for(let g of e.root.children){let i=H(g,r,n,c,e.hooks);n.push(` ${h} --> ${i.entryId}`),h=i.exitId}if(["success","error","aborted"].includes(e.root.state)){let g="finish",i=e.root.state==="success"?"\u2713":e.root.state==="error"?"\u2717":"\u2298",d=e.root.state==="success"?"Done":e.root.state==="error"?"Failed":"Cancelled",b=`(("${i} ${d}"))`,l=e.root.state==="success"?":::success":e.root.state==="error"?":::error":":::aborted";n.push(` ${g}${b}${l}`),n.push(` ${h} --> ${g}`)}return n.push(""),n.push(...ve()),c.showHeatmap&&n.push(...We()),e.hooks&&n.push(...Ce()),n.join(`
|
|
2
|
+
`)}}}function H(e,r,n,c,u){if(q(e))return Ae(e,r,n,c,u);if(J(e))return Fe(e,r,n,c,u);if(Y(e))return Be(e,r,n,c,u);if(Z(e))return He(e,r,n,c,u);if(X(e))return Ke(e,r,n);let s=P("unknown");return n.push(` ${s}["Unknown Node"]`),{entryId:s,exitId:s}}function Ae(e,r,n,c,u){let s=r,h=s.showRetryEdges??!0,m=s.showErrorEdges??!0,g=s.showTimeoutEdges??!0,i=e.key?`step_${e.key.replace(/[^a-zA-Z0-9]/g,"_")}`:P("step");if(B.has(i)){let y=2;for(;B.has(`${i}_${y}`);)y++;i=`${i}_${y}`}B.add(i);let d=e.name??e.key??"Step",b=r.showKeys&&e.key&&e.name?`${d} [${e.key}]`:d,l=O(b),p=r.showTimings&&e.durationMs!==void 0?` ${W(e.durationMs)}`:"",f="";switch(e.state){case"success":f="\u2713 ";break;case"error":f="\u2717 ";break;case"cached":f="\u{1F4BE} ";break;case"running":f="\u23F3 ";break;case"skipped":f="\u2298 ";break}let w="";if(e.input!==void 0){let y=typeof e.input=="string"?O(e.input):O(te(e.input).slice(0,20));w+=`\\nin: ${y}`}if(e.output!==void 0&&e.state==="success"){let y=typeof e.output=="string"?O(e.output):O(te(e.output).slice(0,20));w+=`\\nout: ${y}`}let S="",R=e.key??e.id;if(u&&R&&u.onAfterStep.has(R)){let y=u.onAfterStep.get(R),N=y.state==="success"?"\u2699":"\u26A0",M=r.showTimings&&y.durationMs!==void 0?` ${W(y.durationMs)}`:"";S=`\\n${N} hook${M}`}let x=(f+l+w+S+p).trim(),k,I=c?.showHeatmap&&c.heatmapData?c.heatmapData.heat.get(e.key??"")??c.heatmapData.heat.get(e.name??"")??c.heatmapData.heat.get(e.id):void 0;if(I!==void 0){let y=ee(I);k=_e(y)}else k=e.state;let T;switch(e.state){case"error":T=`{{"${x}"}}`;break;case"cached":T=`[("${x}")]`;break;case"skipped":T=`["${x}"]`;break;default:T=`["${x}"]`}if(n.push(` ${i}${T}:::${k}`),h&&e.retryCount!==void 0&&e.retryCount>0){let y=`\u21BB ${e.retryCount} retr${e.retryCount===1?"y":"ies"}`;n.push(` ${i} -.->|"${y}"| ${i}`)}if(m&&e.state==="error"&&e.error!==void 0){let y=`ERR_${i}`,N=O(String(e.error)).slice(0,30);n.push(` ${y}{{"${N}"}}`),n.push(` ${i} -->|error| ${y}`),n.push(` style ${y} fill:#fee2e2,stroke:#dc2626`)}if(g&&e.timedOut){let y=`TO_${i}`,N=e.timeoutMs!==void 0?`${e.timeoutMs}ms`:"";n.push(` ${y}{{"\u23F1 Timeout ${N}"}}`),n.push(` ${i} -.->|timeout| ${y}`),n.push(` style ${y} fill:#fef3c7,stroke:#f59e0b`)}return{entryId:i,exitId:i}}function Fe(e,r,n,c,u){let s=P("parallel"),h=`${s}_fork`,m=`${s}_join`,g=ne(e.name??"Parallel"),i=e.mode==="allSettled"?" (allSettled)":"";if(e.children.length===0){let l=s,p=O(`${g}${i}`),f="operations not individually tracked",w=r.showTimings&&e.durationMs!==void 0?` ${W(e.durationMs)}`:"";return n.push(` ${l}["${p}${w}\\n${f}"]:::${e.state}`),{entryId:l,exitId:l}}n.push(` subgraph ${s}["${g}${i}"]`),n.push(" direction TB"),n.push(` ${h}{"\u26A1 Fork"}`);let d=[];for(let l of e.children){let p=H(l,r,n,c,u);n.push(` ${h} --> ${p.entryId}`),d.push(p.exitId)}n.push(` ${m}{"\u2713 Join"}`);for(let l of d)n.push(` ${l} --> ${m}`);n.push(" end");let b=e.state;return n.push(` class ${s} ${b}`),{entryId:h,exitId:m}}function Be(e,r,n,c,u){let s=P("race"),h=`${s}_start`,m=`${s}_end`,g=ne(e.name??"Race");if(e.children.length===0){let l=s,p=O(g),f="operations not individually tracked",w=r.showTimings&&e.durationMs!==void 0?` ${W(e.durationMs)}`:"";return n.push(` ${l}["\u26A1 ${p}${w}\\n${f}"]:::${e.state}`),{entryId:l,exitId:l}}n.push(` subgraph ${s}["\u26A1 ${g}"]`),n.push(" direction TB"),n.push(` ${h}(("\u{1F3C1} Start"))`);let i=[],d;for(let l of e.children){let p=H(l,r,n,c,u),f=e.winnerId===l.id;n.push(` ${h} --> ${p.entryId}`),f&&(d=p.exitId),i.push({exitId:p.exitId,isWinner:f})}n.push(` ${m}(("\u2713 First"))`);for(let{exitId:l,isWinner:p}of i)p&&d?n.push(` ${l} ==>|\u{1F3C6} Winner| ${m}`):e.winnerId?n.push(` ${l} -. cancelled .-> ${m}`):n.push(` ${l} --> ${m}`);n.push(" end");let b=e.state;return n.push(` class ${s} ${b}`),{entryId:h,exitId:m}}function He(e,r,n,c,u){let s=e.key?`decision_${e.key.replace(/[^a-zA-Z0-9]/g,"_")}`:P("decision");if(F.has(s)){let l=2;for(;F.has(`${s}_${l}`);)l++;s=`${s}_${l}`}F.add(s);let h=O(e.condition??"condition"),m=e.decisionValue!==void 0?` = ${O(String(e.decisionValue)).slice(0,30)}`:"",g=`${h}${m}`.trim();n.push(` ${s}{"${g}"}`);let i=[],d,b=new Set;for(let l of e.branches){let p=`${s}_${l.label.replace(/[^a-zA-Z0-9]/g,"_")}`;if(b.has(p)){let x=2;for(;b.has(`${p}_${x}`);)x++;p=`${p}_${x}`}b.add(p);let f=O(l.label),w=l.taken?`${f} \u2713`:`${f} skipped`,S=l.taken?":::success":":::skipped";n.push(` ${p}["${w}"]${S}`);let R=l.condition?`|${O(l.condition).replace(/\|/g,"")}|`:"";if(n.push(` ${s} -->${R} ${p}`),l.children.length>0){let x=p;for(let k of l.children){let I=H(k,r,n,c,u);n.push(` ${x} --> ${I.entryId}`),x=I.exitId}i.push(x),l.taken&&(d=x)}else i.push(p),l.taken&&(d=p)}return d?{entryId:s,exitId:d}:{entryId:s,exitId:s}}function Ke(e,r,n){let c=`stream_${e.namespace.replace(/[^a-zA-Z0-9]/g,"_")}_${P("")}`,u=`W:${e.writeCount} R:${e.readCount}`,s="";switch(e.streamState){case"active":s="\u27F3 ";break;case"closed":s="\u2713 ";break;case"error":s="\u2717 ";break}let h=r.showTimings&&e.durationMs!==void 0?` ${W(e.durationMs)}`:"",m=e.backpressureOccurred?"\\nbackpressure":"",g=`${s}stream:${O(e.namespace)}\\n${u}${m}${h}`,i;return e.streamState==="error"?i="streamError":e.streamState==="active"?i="streamActive":i="stream",n.push(` ${c}{{"${g}"}}:::${i}`),{entryId:c,exitId:c}}import ze from"pako";var Ge=typeof globalThis<"u"&&"Buffer"in globalThis&&typeof globalThis.Buffer=="function";function je(e){let r;if(Ge)r=globalThis.Buffer.from(e).toString("base64");else{let n="";for(let c=0;c<e.length;c++)n+=String.fromCharCode(e[c]);r=btoa(n)}return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function K(e){let n=new TextEncoder().encode(e),c=ze.deflate(n);return je(c)}var Ve="https://kroki.io";function qe(e,r,n,c={}){let u=c.baseUrl??Ve,s=K(n);return`${u}/${e}/${r}/${s}`}function Je(e,r="svg",n={}){let c=C(),u={showTimings:!0,showKeys:!1,terminalWidth:80,colors:_},s=c.render(e,u);return qe("mermaid",r,s,n)}function oe(e,r={}){return Je(e,"svg",r)}var Ye="https://mermaid.ink";function Ze(e){return`pako:${K(e)}`}function Xe(e){if("provider"in e){let r=e;return{theme:r.mermaidTheme,bgColor:r.background,scale:r.scale,fit:r.fit,width:r.width,height:r.height,paper:r.paper,imageType:"png"}}return e}function Qe(e,r){let n=[];return r.bgColor&&n.push(`bgColor=${encodeURIComponent(r.bgColor)}`),r.theme&&n.push(`theme=${r.theme}`),r.width!==void 0&&n.push(`width=${r.width}`),r.height!==void 0&&n.push(`height=${r.height}`),r.scale!==void 0&&(r.width!==void 0||r.height!==void 0)&&n.push(`scale=${r.scale}`),e==="img"&&r.imageType&&r.imageType!=="jpeg"&&n.push(`type=${r.imageType}`),e==="pdf"&&(r.fit&&n.push("fit"),r.paper&&!r.fit&&n.push(`paper=${r.paper}`),r.landscape&&!r.fit&&n.push("landscape")),n.length>0?`?${n.join("&")}`:""}function et(e,r,n={}){let c=Xe(n),u=c.baseUrl??Ye,s=Ze(r),h=Qe(e,c);return`${u}/${e}/${s}${h}`}function tt(e,r="svg",n={}){let c=C(),u={showTimings:!0,showKeys:!1,terminalWidth:80,colors:_},s=c.render(e,u);return et(r,s,n)}function se(e,r={}){return tt(e,"svg",r)}function ie(e){return{getDiagramUrl(r){if(e.provider==="mermaid-ink"){let{provider:n,...c}=e;return se(r,c)}return oe(r,{baseUrl:e.baseUrl})},countSteps(r){return V(r)},formatDuration(r){return r.root.endTs!==void 0&&r.root.startTs!==void 0?`${r.root.endTs-r.root.startTs}ms`:r.root.durationMs!==void 0?`${r.root.durationMs}ms`:"In progress"}}}import{ok as z,err as ot}from"awaitly";function rt(e){for(let r of e)if((r.type==="parallel"||r.type==="race"||r.type==="sequence")&&!r.id.startsWith("detected_")||r.type==="decision")return!0;return!1}function ae(e,r={}){if(rt(e))return e;let{minOverlapMs:n=0,maxGapMs:c=5}=r,u=[],s=[];for(let i=0;i<e.length;i++){let d=e[i];d.type==="step"&&d.startTs!==void 0?u.push({node:d,startTs:d.startTs,endTs:d.endTs??d.startTs+(d.durationMs??0),originalIndex:i}):s.push({node:d,originalIndex:i})}if(u.length<=1)return e;u.sort((i,d)=>i.startTs-d.startTs);let h=[],m=[u[0]];for(let i=1;i<u.length;i++){let d=u[i],b=Math.min(...m.map(S=>S.startTs)),l=Math.max(...m.map(S=>S.endTs)),p=d.startTs<=b+c,f=d.startTs<l;if(!p&&!f){h.push(m),m=[d];continue}let w=f?Math.min(d.endTs,l)-d.startTs:0;p||w>=n?m.push(d):(h.push(m),m=[d])}h.push(m);let g=[];for(let i of h){let d=Math.min(...i.map(b=>b.originalIndex));if(i.length===1)g.push({node:i[0].node,position:d});else{let b=i.map(w=>w.node),l=Math.min(...i.map(w=>w.startTs)),p=Math.max(...i.map(w=>w.endTs)),f={type:"parallel",id:`detected_parallel_${l}`,name:`${b.length} parallel steps`,state:nt(b),mode:"all",children:b,startTs:l,endTs:p,durationMs:p-l};g.push({node:f,position:d})}}for(let{node:i,originalIndex:d}of s)g.push({node:i,position:d});return g.sort((i,d)=>i.position-d.position),g.map(i=>i.node)}function nt(e){return e.some(s=>s.state==="error")?"error":e.some(s=>s.state==="running")?"running":e.some(s=>s.state==="pending")?"pending":(e.every(s=>s.state==="success"||s.state==="cached"),"success")}function ce(e={}){let{detectParallel:r=!0,parallelDetection:n,enableSnapshots:c=!1,maxSnapshots:u=1e3}=e,s=c,h=A(),m,g,i,d="pending",b,l,p=new Map,f=[],w=[],S=new Map,R=[],x=Date.now(),k=x,I={onAfterStep:new Map},T,y=[],N=0;function M(t){return t.stepId??t.stepKey??t.name??A()}function D(t){if(f.length>0){f[f.length-1].children.push(t),k=Date.now();return}if(w.length>0){let a=w[w.length-1];for(let o of a.branches.values())if(o.taken){o.children.push(t),k=Date.now();return}a.pendingChildren.push(t),k=Date.now();return}R.push(t),k=Date.now()}function fe(t){if(!s)return;let a=j(),o=new Map;for(let[$,v]of p)o.set($,{id:v.id,name:v.name,key:v.key,startTs:v.startTs,retryCount:v.retryCount,timedOut:v.timedOut,timeoutMs:v.timeoutMs});let E={id:`snapshot_${N}`,eventIndex:N,event:structuredClone(t),ir:structuredClone(a),timestamp:Date.now(),activeSteps:o};y.push(E),y.length>u&&y.shift(),N++}function me(t){switch(t.type){case"workflow_start":{R=[],i=void 0,l=void 0,b=void 0,p.clear(),f.length=0,w.length=0,S.clear(),m=t.workflowId,g=t.ts,d="running",x=Date.now(),k=x,T!==void 0&&T!==t.workflowId&&(I.shouldRun=void 0,I.onBeforeStart=void 0),T=t.workflowId,I.onAfterStep=new Map;break}case"workflow_success":d="success",i=t.ts,l=t.durationMs,k=Date.now();break;case"workflow_error":d="error",i=t.ts,b=t.error,l=t.durationMs,k=Date.now();break;case"workflow_cancelled":d="aborted",i=t.ts,l=t.durationMs,k=Date.now();break;case"step_start":{let a=M(t);p.set(a,{id:a,name:t.name,key:t.stepKey,startTs:t.ts,retryCount:0,timedOut:!1}),k=Date.now();break}case"step_success":{let a=M(t),o=p.get(a);if(o){let E={type:"step",id:o.id,name:o.name,key:o.key,state:"success",startTs:o.startTs,endTs:t.ts,durationMs:t.durationMs,...o.retryCount>0&&{retryCount:o.retryCount},...o.timedOut&&{timedOut:!0,timeoutMs:o.timeoutMs}};D(E),p.delete(a)}break}case"step_error":{let a=M(t),o=p.get(a);if(o){let E={type:"step",id:o.id,name:o.name,key:o.key,state:"error",startTs:o.startTs,endTs:t.ts,durationMs:t.durationMs,error:t.error,...o.retryCount>0&&{retryCount:o.retryCount},...o.timedOut&&{timedOut:!0,timeoutMs:o.timeoutMs}};D(E),p.delete(a)}break}case"step_aborted":{let a=M(t),o=p.get(a);if(o){let E={type:"step",id:o.id,name:o.name,key:o.key,state:"aborted",startTs:o.startTs,endTs:t.ts,durationMs:t.durationMs,...o.retryCount>0&&{retryCount:o.retryCount},...o.timedOut&&{timedOut:!0,timeoutMs:o.timeoutMs}};D(E),p.delete(a)}break}case"step_cache_hit":{let o={type:"step",id:M(t),name:t.name,key:t.stepKey,state:"cached",startTs:t.ts,endTs:t.ts,durationMs:0};D(o);break}case"step_cache_miss":break;case"step_complete":break;case"step_timeout":{let a=M(t),o=p.get(a);o&&(o.timedOut=!0,o.timeoutMs=t.timeoutMs),k=Date.now();break}case"step_retry":{let a=M(t),o=p.get(a);o&&(o.retryCount=(t.attempt??1)-1),k=Date.now();break}case"step_retries_exhausted":k=Date.now();break;case"step_skipped":{let o={type:"step",id:M(t),name:t.name,key:t.stepKey,state:"skipped",startTs:t.ts,endTs:t.ts,durationMs:0};D(o);break}case"hook_should_run":{let a={type:"shouldRun",state:"success",ts:t.ts,durationMs:t.durationMs,context:{result:t.result,skipped:t.skipped}};I.shouldRun=a,T=t.workflowId,k=Date.now();break}case"hook_should_run_error":{let a={type:"shouldRun",state:"error",ts:t.ts,durationMs:t.durationMs,error:t.error};I.shouldRun=a,T=t.workflowId,k=Date.now();break}case"hook_before_start":{let a={type:"onBeforeStart",state:"success",ts:t.ts,durationMs:t.durationMs,context:{result:t.result,skipped:t.skipped}};I.onBeforeStart=a,T=t.workflowId,k=Date.now();break}case"hook_before_start_error":{let a={type:"onBeforeStart",state:"error",ts:t.ts,durationMs:t.durationMs,error:t.error};I.onBeforeStart=a,T=t.workflowId,k=Date.now();break}case"hook_after_step":{let a={type:"onAfterStep",state:"success",ts:t.ts,durationMs:t.durationMs,context:{stepKey:t.stepKey}};I.onAfterStep.set(t.stepKey,a),k=Date.now();break}case"hook_after_step_error":{let a={type:"onAfterStep",state:"error",ts:t.ts,durationMs:t.durationMs,error:t.error,context:{stepKey:t.stepKey}};I.onAfterStep.set(t.stepKey,a),k=Date.now();break}case"stream_created":{let a=`${t.workflowId}:${t.namespace}`;S.set(a,{id:A(),namespace:t.namespace,startTs:t.ts,writeCount:0,readCount:0,streamState:"active",backpressureOccurred:!1,finalPosition:0}),k=Date.now();break}case"stream_write":{let a=`${t.workflowId}:${t.namespace}`,o=S.get(a);o&&(o.writeCount++,o.finalPosition=Math.max(o.finalPosition,t.position)),k=Date.now();break}case"stream_read":{let a=`${t.workflowId}:${t.namespace}`,o=S.get(a);o&&o.readCount++,k=Date.now();break}case"stream_close":{let a=`${t.workflowId}:${t.namespace}`,o=S.get(a);if(o){o.streamState="closed",o.finalPosition=t.finalPosition;let E={type:"stream",id:o.id,namespace:o.namespace,state:"success",startTs:o.startTs,endTs:t.ts,durationMs:t.ts-o.startTs,writeCount:o.writeCount,readCount:o.readCount,finalPosition:t.finalPosition,streamState:"closed",backpressureOccurred:o.backpressureOccurred};D(E),S.delete(a)}k=Date.now();break}case"stream_error":{let a=`${t.workflowId}:${t.namespace}`,o=S.get(a);if(o){o.streamState="error";let E={type:"stream",id:o.id,namespace:o.namespace,state:"error",error:t.error,startTs:o.startTs,endTs:t.ts,durationMs:t.ts-o.startTs,writeCount:o.writeCount,readCount:o.readCount,finalPosition:t.position,streamState:"error",backpressureOccurred:o.backpressureOccurred};D(E),S.delete(a)}k=Date.now();break}case"stream_backpressure":{let a=`${t.workflowId}:${t.namespace}`,o=S.get(a);o&&(o.backpressureOccurred=!0),k=Date.now();break}}fe(t)}function ge(t){if(t.type==="scope_start")f.push({id:t.scopeId,name:t.name,type:t.scopeType,startTs:t.ts,children:[]}),k=Date.now();else if(t.type==="scope_end"){let a=f.findIndex($=>$.id===t.scopeId);if(a===-1)return;for(;f.length>a+1;){let $=f.pop(),v=$.type==="race"?{type:"race",id:$.id,name:$.name,state:L($.children),startTs:$.startTs,endTs:t.ts,children:$.children}:{type:"parallel",id:$.id,name:$.name,state:L($.children),startTs:$.startTs,endTs:t.ts,children:$.children,mode:$.type==="allSettled"?"allSettled":"all"};f[f.length-1].children.push(v)}let[o]=f.splice(a,1),E=o.type==="race"?{type:"race",id:o.id,name:o.name,state:L(o.children),startTs:o.startTs,endTs:t.ts,durationMs:t.durationMs,children:o.children,winnerId:t.winnerId}:{type:"parallel",id:o.id,name:o.name,state:L(o.children),startTs:o.startTs,endTs:t.ts,durationMs:t.durationMs,children:o.children,mode:o.type==="allSettled"?"allSettled":"all"};D(E)}}function he(t){if(t.type==="decision_start")w.push({id:t.decisionId,name:t.name,condition:t.condition,decisionValue:t.decisionValue,startTs:t.ts,branches:new Map,pendingChildren:[]}),k=Date.now();else if(t.type==="decision_branch"){let a=w.find(o=>o.id===t.decisionId);if(a){let o=t.branchLabel,E=a.branches.get(o);if(E)E.taken=t.taken,t.taken&&a.pendingChildren.length>0&&(E.children.unshift(...a.pendingChildren),a.pendingChildren=[]);else{let $=t.taken?[...a.pendingChildren]:[];t.taken&&(a.pendingChildren=[]),a.branches.set(o,{label:t.branchLabel,condition:t.condition,taken:t.taken,children:$})}k=Date.now()}}else if(t.type==="decision_end"){let a=w.findIndex(o=>o.id===t.decisionId);if(a!==-1){let[o]=w.splice(a,1),E=w.splice(a),$=Array.from(o.branches.values());$.length===0&&o.pendingChildren.length>0&&($=[{label:"default",taken:!0,children:[...o.pendingChildren]}]);let v=$.find(U=>U.taken)?.label,xe={type:"decision",id:o.id,name:o.name,state:L($.flatMap(U=>U.taken?U.children:[])),startTs:o.startTs,endTs:t.ts,durationMs:t.durationMs,condition:o.condition,decisionValue:o.decisionValue,branchTaken:t.branchTaken??v,branches:$};D(xe),w.push(...E),k=Date.now()}}}function L(t){return t.length===0?"success":t.some($=>$.state==="error")?"error":t.every($=>$.state==="success"||$.state==="cached")?"success":t.some($=>$.state==="running")?"running":"pending"}function ke(){let t=[...R];for(let[,a]of p)t.push({type:"step",id:a.id,name:a.name,key:a.key,state:"running",startTs:a.startTs,...a.retryCount>0&&{retryCount:a.retryCount},...a.timedOut&&{timedOut:!0,timeoutMs:a.timeoutMs}});for(let[,a]of S)t.push({type:"stream",id:a.id,namespace:a.namespace,state:"running",startTs:a.startTs,writeCount:a.writeCount,readCount:a.readCount,finalPosition:a.finalPosition,streamState:a.streamState,backpressureOccurred:a.backpressureOccurred});return t}function j(){let t=ke();r&&(t=ae(t,n));let a={type:"workflow",id:m??h,workflowId:m??h,state:d,startTs:g,endTs:i,durationMs:l,children:t,error:b},o=I.shouldRun!==void 0||I.onBeforeStart!==void 0||I.onAfterStep.size>0;return{root:a,metadata:{createdAt:x,lastUpdatedAt:k},...o&&{hooks:I}}}function we(){m=void 0,g=void 0,i=void 0,d="pending",b=void 0,l=void 0,p.clear(),f.length=0,w.length=0,S.clear(),R=[],x=Date.now(),k=x,I={onAfterStep:new Map},T=void 0,y.length=0,N=0}function be(){return[...y]}function ye(t){return y[t]}function Se(t){return y[t]?.ir}function $e(){y.length=0,N=0}return{handleEvent:me,handleScopeEvent:ge,handleDecisionEvent:he,getIR:j,reset:we,getSnapshots:be,getSnapshotAt:ye,getIRAt:Se,clearSnapshots:$e,get hasActiveSteps(){return p.size>0},get state(){return d},get snapshotCount(){return y.length},get snapshotsEnabled(){return s},setSnapshotsEnabled(t){s=t}}}var st=500,it=5e3;function de(e,r){let{title:n,debounceMs:c=st,maxWaitMs:u=it}=e,s,h=!0,m,g,i,d,b,l,p=z(void 0),f=ce({detectParallel:!0});function w(){i&&(clearTimeout(i),i=void 0),d&&(clearTimeout(d),d=void 0)}async function S(){if(!m||!h)return z(void 0);let N=m;g=N,m=void 0,w();try{return s?await r.updateExisting(s,N,n):s=await r.postNew(N,n),b=Date.now(),p=z(void 0),p}catch{return p=ot("CALLBACK_ERROR"),p}}function R(){i&&clearTimeout(i),i=setTimeout(()=>{S()},c);let N=b??l;if(!d&&N!==void 0){let M=Date.now()-N,D=Math.max(0,u-M);d=setTimeout(()=>{d=void 0,S()},D)}}function x(N){if(h){if(l===void 0&&(l=Date.now()),"root"in N)m=N,g=N;else{let M=N;M.type==="scope_start"||M.type==="scope_end"?f.handleScopeEvent(M):M.type==="decision_start"||M.type==="decision_branch"||M.type==="decision_end"?f.handleDecisionEvent(M):f.handleEvent(M),m=f.getIR(),g=m}R()}}async function k(N="completed"){if(!h)return;h=!1,w();let M=m??g??f.getIR();await r.finalize(s,M,n,N)}function I(){h&&(h=!1,w(),s&&r.cancel&&r.cancel(s))}function T(){return s}function y(){return h}return{update:x,finalize:k,cancel:I,getSessionId:T,isActive:y}}function dt(e){switch(e.root.state){case"success":return"completed";case"error":return"failed";case"aborted":return"cancelled";default:return"running"}}function le(e,r){let{diagramProvider:n,debounceMs:c=500,maxWaitMs:u=5e3}=e;if(!n)throw new Error(`${r.name}Notifier: diagramProvider is required. Pass { provider: 'kroki' } or { provider: 'mermaid-ink' }.`);let s=ie(n);async function h(g,i={}){let d=i.title??"Workflow",b=dt(g);try{let l=r.buildMessage({ir:g,title:d,status:b},s),p=await r.sendNew(l);return at(p?.toString())}catch{return ct("SEND_FAILED")}}function m(g){return de({...g,debounceMs:g.debounceMs??c,maxWaitMs:g.maxWaitMs??u},{async postNew(i,d){let b=r.buildMessage({ir:i,title:d,status:"running"},s);return(await r.sendNew(b))?.toString()},async updateExisting(i,d,b){let l=r.buildMessage({ir:d,title:b,status:"running"},s);await r.sendUpdate(i,l)},async finalize(i,d,b,l){let p=r.buildMessage({ir:d,title:b,status:l},s);i?await r.sendUpdate(i,p):await r.sendNew(p)},async cancel(i){r.sendCancel&&i&&await r.sendCancel(i)}})}return{notify:h,createLive:m,getType:()=>r.name.toLowerCase()}}import{ok as ue,err as G}from"awaitly";function pe(e){let{url:r,headers:n={},timeout:c=3e4,includeMermaid:u=!1,includeKrokiUrl:s,includeDiagramUrl:h=s??!0,providerName:m="kroki",metadata:g}=e,i=C(),d={showTimings:!0,showKeys:!1,terminalWidth:80,colors:_},b=0;async function l(f){let w=new AbortController,S=setTimeout(()=>w.abort(),c);try{let R=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json",...n},body:JSON.stringify(f),signal:w.signal});if(!R.ok)return G("SEND_FAILED");try{let x=await R.json();return ue(x.messageId??x.id??f.messageId??"")}catch{return ue(f.messageId??"")}}catch(R){return R instanceof Error&&R.name==="AbortError"?G("TIMEOUT"):G("SEND_FAILED")}finally{clearTimeout(S)}}function p(){return`webhook-${++b}-${Date.now()}`}return{name:"Webhook",buildMessage({ir:f,title:w,status:S},R){let x;S==="running"?x="workflow.update":x="workflow.complete";let k={event:x,timestamp:new Date().toISOString(),title:w,status:S,ir:f,metadata:g};if(h){let I=R.getDiagramUrl(f);k.diagramUrl=I,k.diagramProvider=m,k.krokiUrl=I}return u&&(k.mermaid=i.render(f,d)),{payload:k}},async sendNew(f){let{payload:w}=f,S=p();w.messageId=S;let R=await l(w);if(!R.ok)throw new Error(`Webhook send failed: ${R.error}`);return S},async sendUpdate(f,w){let{payload:S}=w;S.messageId=f;let R=await l(S);if(!R.ok)throw new Error(`Webhook update failed: ${R.error}`)}}}function lr(e){let{url:r,headers:n,timeout:c,includeMermaid:u,includeKrokiUrl:s,includeDiagramUrl:h,diagramProvider:m,...g}=e,i=pe({url:r,headers:n,timeout:c,includeMermaid:u,includeKrokiUrl:s,includeDiagramUrl:h,providerName:m?.provider??"kroki"});return le({...g,diagramProvider:m},i)}export{lr as createWebhookNotifier};
|
|
3
|
+
//# sourceMappingURL=webhook.js.map
|