awaitly-visualizer 18.0.0 → 19.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.cjs +10 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +10 -9
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";var Zt=Object.create;var Me=Object.defineProperty;var Qt=Object.getOwnPropertyDescriptor;var er=Object.getOwnPropertyNames;var tr=Object.getPrototypeOf,rr=Object.prototype.hasOwnProperty;var nr=(e,t)=>{for(var r in t)Me(e,r,{get:t[r],enumerable:!0})},it=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of er(t))!rr.call(e,a)&&a!==r&&Me(e,a,{get:()=>t[a],enumerable:!(o=Qt(t,a))||o.enumerable});return e};var or=(e,t,r)=>(r=e!=null?Zt(tr(e)):{},it(t||!e||!e.__esModule?Me(r,"default",{value:e,enumerable:!0}):r,e)),ar=e=>it(Me({},"__esModule",{value:!0}),e);var In={};nr(In,{asciiRenderer:()=>ae,buildMermaidInkUrl:()=>Ee,combineEventHandlers:()=>kn,createEventCollector:()=>Sn,createIRBuilder:()=>de,createLiveVisualizer:()=>Kt,createMermaidInkGenerator:()=>Ct,createParallelDetector:()=>st,createPerformanceAnalyzer:()=>ft,createTimeTravelController:()=>Gt,createUrlGenerator:()=>Et,createVisualizer:()=>Ke,defaultColorScheme:()=>z,detectParallelGroups:()=>xe,encodeForMermaidInk:()=>et,escapeHtml:()=>ve,flowchartRenderer:()=>me,generateInteractiveHTML:()=>Yt,getHeatLevel:()=>he,hasChildren:()=>dr,htmlRenderer:()=>Ut,isDecisionNode:()=>J,isParallelNode:()=>G,isRaceNode:()=>U,isSequenceNode:()=>je,isStepNode:()=>j,isStreamNode:()=>re,loggerRenderer:()=>Re,mermaidRenderer:()=>ie,renderToHTML:()=>zt,toExportUrl:()=>we,toKrokiPngUrl:()=>Rt,toKrokiSvgUrl:()=>It,toKrokiUrl:()=>ce,toMermaidInkJpegUrl:()=>Nt,toMermaidInkPdfUrl:()=>Dt,toMermaidInkPngUrl:()=>Tt,toMermaidInkSvgUrl:()=>Mt,toMermaidInkUrl:()=>Y,toMermaidInkWebpUrl:()=>Ot,trackDecision:()=>ze,trackIf:()=>jt,trackSwitch:()=>Vt,visualizeEvents:()=>xn});module.exports=ar(In);function H(e){if(e<1e3)return`${Math.round(e)}ms`;if(e<6e4)return`${(e/1e3).toFixed(1).replace(/\.0$/,"")}s`;let t=Math.floor(e/6e4),r=Math.round(e%6e4/1e3);return r>=60&&(t+=1,r=0),r===0?`${t}m`:`${t}m ${r}s`}function Te(){return`node_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function ir(e){for(let t of e)if((t.type==="parallel"||t.type==="race"||t.type==="sequence")&&!t.id.startsWith("detected_")||t.type==="decision")return!0;return!1}function xe(e,t={}){if(ir(e))return e;let{minOverlapMs:r=0,maxGapMs:o=5}=t,a=[],n=[];for(let d=0;d<e.length;d++){let l=e[d];l.type==="step"&&l.startTs!==void 0?a.push({node:l,startTs:l.startTs,endTs:l.endTs??l.startTs+(l.durationMs??0),originalIndex:d}):n.push({node:l,originalIndex:d})}if(a.length<=1)return e;a.sort((d,l)=>d.startTs-l.startTs);let i=[],s=[a[0]];for(let d=1;d<a.length;d++){let l=a[d],p=Math.min(...s.map(M=>M.startTs)),f=Math.max(...s.map(M=>M.endTs)),m=l.startTs<=p+o,w=l.startTs<f;if(!m&&!w){i.push(s),s=[l];continue}let k=w?Math.min(l.endTs,f)-l.startTs:0;m||k>=r?s.push(l):(i.push(s),s=[l])}i.push(s);let u=[];for(let d of i){let l=Math.min(...d.map(p=>p.originalIndex));if(d.length===1)u.push({node:d[0].node,position:l});else{let p=d.map(k=>k.node),f=Math.min(...d.map(k=>k.startTs)),m=Math.max(...d.map(k=>k.endTs)),w={type:"parallel",id:`detected_parallel_${f}`,name:`${p.length} parallel steps`,state:sr(p),mode:"all",children:p,startTs:f,endTs:m,durationMs:m-f};u.push({node:w,position:l})}}for(let{node:d,originalIndex:l}of n)u.push({node:d,position:l});return u.sort((d,l)=>d.position-l.position),u.map(d=>d.node)}function sr(e){return e.some(n=>n.state==="error")?"error":e.some(n=>n.state==="running")?"running":e.some(n=>n.state==="pending")?"pending":(e.every(n=>n.state==="success"||n.state==="cached"),"success")}function st(e={}){return{detect:t=>xe(t,e)}}function de(e={}){let{detectParallel:t=!0,parallelDetection:r,enableSnapshots:o=!1,maxSnapshots:a=1e3}=e,n=o,i=Te(),s,u,d,l="pending",p,f,m=new Map,w=[],k=[],M=new Map,$=[],T=Date.now(),I=T,S={onAfterStep:new Map},x,g=[],y=0;function E(c){return c.stepId??c.stepKey??c.name??Te()}function C(c){if(w.length>0){w[w.length-1].children.push(c),I=Date.now();return}if(k.length>0){let b=k[k.length-1];for(let h of b.branches.values())if(h.taken){h.children.push(c),I=Date.now();return}b.pendingChildren.push(c),I=Date.now();return}$.push(c),I=Date.now()}function N(c){if(!n)return;let b=q(),h=new Map;for(let[W,X]of m)h.set(W,{id:X.id,name:X.name,key:X.key,startTs:X.startTs,retryCount:X.retryCount,timedOut:X.timedOut,timeoutMs:X.timeoutMs});let F={id:`snapshot_${y}`,eventIndex:y,event:structuredClone(c),ir:structuredClone(b),timestamp:Date.now(),activeSteps:h};g.push(F),g.length>a&&g.shift(),y++}function L(c){switch(c.type){case"workflow_start":{$=[],d=void 0,f=void 0,p=void 0,m.clear(),w.length=0,k.length=0,M.clear(),s=c.workflowId,u=c.ts,l="running",T=Date.now(),I=T,x!==void 0&&x!==c.workflowId&&(S.shouldRun=void 0,S.onBeforeStart=void 0),x=c.workflowId,S.onAfterStep=new Map;break}case"workflow_success":l="success",d=c.ts,f=c.durationMs,I=Date.now();break;case"workflow_error":l="error",d=c.ts,p=c.error,f=c.durationMs,I=Date.now();break;case"workflow_cancelled":l="aborted",d=c.ts,f=c.durationMs,I=Date.now();break;case"step_start":{let b=E(c);m.set(b,{id:b,name:c.name,key:c.stepKey,startTs:c.ts,retryCount:0,timedOut:!1}),I=Date.now();break}case"step_success":{let b=E(c),h=m.get(b);if(h){let F={type:"step",id:h.id,name:h.name,key:h.key,state:"success",startTs:h.startTs,endTs:c.ts,durationMs:c.durationMs,...h.retryCount>0&&{retryCount:h.retryCount},...h.timedOut&&{timedOut:!0,timeoutMs:h.timeoutMs}};C(F),m.delete(b)}break}case"step_error":{let b=E(c),h=m.get(b);if(h){let F={type:"step",id:h.id,name:h.name,key:h.key,state:"error",startTs:h.startTs,endTs:c.ts,durationMs:c.durationMs,error:c.error,...h.retryCount>0&&{retryCount:h.retryCount},...h.timedOut&&{timedOut:!0,timeoutMs:h.timeoutMs}};C(F),m.delete(b)}break}case"step_aborted":{let b=E(c),h=m.get(b);if(h){let F={type:"step",id:h.id,name:h.name,key:h.key,state:"aborted",startTs:h.startTs,endTs:c.ts,durationMs:c.durationMs,...h.retryCount>0&&{retryCount:h.retryCount},...h.timedOut&&{timedOut:!0,timeoutMs:h.timeoutMs}};C(F),m.delete(b)}break}case"step_cache_hit":{let h={type:"step",id:E(c),name:c.name,key:c.stepKey,state:"cached",startTs:c.ts,endTs:c.ts,durationMs:0};C(h);break}case"step_cache_miss":break;case"step_complete":break;case"step_timeout":{let b=E(c),h=m.get(b);h&&(h.timedOut=!0,h.timeoutMs=c.timeoutMs),I=Date.now();break}case"step_retry":{let b=E(c),h=m.get(b);h&&(h.retryCount=(c.attempt??1)-1),I=Date.now();break}case"step_retries_exhausted":I=Date.now();break;case"step_skipped":{let h={type:"step",id:E(c),name:c.name,key:c.stepKey,state:"skipped",startTs:c.ts,endTs:c.ts,durationMs:0};C(h);break}case"hook_should_run":{let b={type:"shouldRun",state:"success",ts:c.ts,durationMs:c.durationMs,context:{result:c.result,skipped:c.skipped}};S.shouldRun=b,x=c.workflowId,I=Date.now();break}case"hook_should_run_error":{let b={type:"shouldRun",state:"error",ts:c.ts,durationMs:c.durationMs,error:c.error};S.shouldRun=b,x=c.workflowId,I=Date.now();break}case"hook_before_start":{let b={type:"onBeforeStart",state:"success",ts:c.ts,durationMs:c.durationMs,context:{result:c.result,skipped:c.skipped}};S.onBeforeStart=b,x=c.workflowId,I=Date.now();break}case"hook_before_start_error":{let b={type:"onBeforeStart",state:"error",ts:c.ts,durationMs:c.durationMs,error:c.error};S.onBeforeStart=b,x=c.workflowId,I=Date.now();break}case"hook_after_step":{let b={type:"onAfterStep",state:"success",ts:c.ts,durationMs:c.durationMs,context:{stepKey:c.stepKey}};S.onAfterStep.set(c.stepKey,b),I=Date.now();break}case"hook_after_step_error":{let b={type:"onAfterStep",state:"error",ts:c.ts,durationMs:c.durationMs,error:c.error,context:{stepKey:c.stepKey}};S.onAfterStep.set(c.stepKey,b),I=Date.now();break}case"stream_created":{let b=`${c.workflowId}:${c.namespace}`;M.set(b,{id:Te(),namespace:c.namespace,startTs:c.ts,writeCount:0,readCount:0,streamState:"active",backpressureOccurred:!1,finalPosition:0}),I=Date.now();break}case"stream_write":{let b=`${c.workflowId}:${c.namespace}`,h=M.get(b);h&&(h.writeCount++,h.finalPosition=Math.max(h.finalPosition,c.position)),I=Date.now();break}case"stream_read":{let b=`${c.workflowId}:${c.namespace}`,h=M.get(b);h&&h.readCount++,I=Date.now();break}case"stream_close":{let b=`${c.workflowId}:${c.namespace}`,h=M.get(b);if(h){h.streamState="closed",h.finalPosition=c.finalPosition;let F={type:"stream",id:h.id,namespace:h.namespace,state:"success",startTs:h.startTs,endTs:c.ts,durationMs:c.ts-h.startTs,writeCount:h.writeCount,readCount:h.readCount,finalPosition:c.finalPosition,streamState:"closed",backpressureOccurred:h.backpressureOccurred};C(F),M.delete(b)}I=Date.now();break}case"stream_error":{let b=`${c.workflowId}:${c.namespace}`,h=M.get(b);if(h){h.streamState="error";let F={type:"stream",id:h.id,namespace:h.namespace,state:"error",error:c.error,startTs:h.startTs,endTs:c.ts,durationMs:c.ts-h.startTs,writeCount:h.writeCount,readCount:h.readCount,finalPosition:c.position,streamState:"error",backpressureOccurred:h.backpressureOccurred};C(F),M.delete(b)}I=Date.now();break}case"stream_backpressure":{let b=`${c.workflowId}:${c.namespace}`,h=M.get(b);h&&(h.backpressureOccurred=!0),I=Date.now();break}}N(c)}function P(c){if(c.type==="scope_start")w.push({id:c.scopeId,name:c.name,type:c.scopeType,startTs:c.ts,children:[]}),I=Date.now();else if(c.type==="scope_end"){let b=w.findIndex(W=>W.id===c.scopeId);if(b===-1)return;for(;w.length>b+1;){let W=w.pop(),X=W.type==="race"?{type:"race",id:W.id,name:W.name,state:v(W.children),startTs:W.startTs,endTs:c.ts,children:W.children}:{type:"parallel",id:W.id,name:W.name,state:v(W.children),startTs:W.startTs,endTs:c.ts,children:W.children,mode:W.type==="allSettled"?"allSettled":"all"};w[w.length-1].children.push(X)}let[h]=w.splice(b,1),F=h.type==="race"?{type:"race",id:h.id,name:h.name,state:v(h.children),startTs:h.startTs,endTs:c.ts,durationMs:c.durationMs,children:h.children,winnerId:c.winnerId}:{type:"parallel",id:h.id,name:h.name,state:v(h.children),startTs:h.startTs,endTs:c.ts,durationMs:c.durationMs,children:h.children,mode:h.type==="allSettled"?"allSettled":"all"};C(F)}}function D(c){if(c.type==="decision_start")k.push({id:c.decisionId,name:c.name,condition:c.condition,decisionValue:c.decisionValue,startTs:c.ts,branches:new Map,pendingChildren:[]}),I=Date.now();else if(c.type==="decision_branch"){let b=k.find(h=>h.id===c.decisionId);if(b){let h=c.branchLabel,F=b.branches.get(h);if(F)F.taken=c.taken,c.taken&&b.pendingChildren.length>0&&(F.children.unshift(...b.pendingChildren),b.pendingChildren=[]);else{let W=c.taken?[...b.pendingChildren]:[];c.taken&&(b.pendingChildren=[]),b.branches.set(h,{label:c.branchLabel,condition:c.condition,taken:c.taken,children:W})}I=Date.now()}}else if(c.type==="decision_end"){let b=k.findIndex(h=>h.id===c.decisionId);if(b!==-1){let[h]=k.splice(b,1),F=k.splice(b),W=Array.from(h.branches.values());W.length===0&&h.pendingChildren.length>0&&(W=[{label:"default",taken:!0,children:[...h.pendingChildren]}]);let X=W.find($e=>$e.taken)?.label,Xt={type:"decision",id:h.id,name:h.name,state:v(W.flatMap($e=>$e.taken?$e.children:[])),startTs:h.startTs,endTs:c.ts,durationMs:c.durationMs,condition:h.condition,decisionValue:h.decisionValue,branchTaken:c.branchTaken??X,branches:W};C(Xt),k.push(...F),I=Date.now()}}}function v(c){return c.length===0?"success":c.some(W=>W.state==="error")?"error":c.every(W=>W.state==="success"||W.state==="cached")?"success":c.some(W=>W.state==="running")?"running":"pending"}function O(){let c=[...$];for(let[,b]of m)c.push({type:"step",id:b.id,name:b.name,key:b.key,state:"running",startTs:b.startTs,...b.retryCount>0&&{retryCount:b.retryCount},...b.timedOut&&{timedOut:!0,timeoutMs:b.timeoutMs}});for(let[,b]of M)c.push({type:"stream",id:b.id,namespace:b.namespace,state:"running",startTs:b.startTs,writeCount:b.writeCount,readCount:b.readCount,finalPosition:b.finalPosition,streamState:b.streamState,backpressureOccurred:b.backpressureOccurred});return c}function q(){let c=O();t&&(c=xe(c,r));let b={type:"workflow",id:s??i,workflowId:s??i,state:l,startTs:u,endTs:d,durationMs:f,children:c,error:p},h=S.shouldRun!==void 0||S.onBeforeStart!==void 0||S.onAfterStep.size>0;return{root:b,metadata:{createdAt:T,lastUpdatedAt:I},...h&&{hooks:S}}}function oe(){s=void 0,u=void 0,d=void 0,l="pending",p=void 0,f=void 0,m.clear(),w.length=0,k.length=0,M.clear(),$=[],T=Date.now(),I=T,S={onAfterStep:new Map},x=void 0,g.length=0,y=0}function at(){return[...g]}function ke(c){return g[c]}function Jt(c){return g[c]?.ir}function qt(){g.length=0,y=0}return{handleEvent:L,handleScopeEvent:P,handleDecisionEvent:D,getIR:q,reset:oe,getSnapshots:at,getSnapshotAt:ke,getIRAt:Jt,clearSnapshots:qt,get hasActiveSteps(){return m.size>0},get state(){return l},get snapshotCount(){return g.length},get snapshotsEnabled(){return n},setSnapshotsEnabled(c){n=c}}}var Oe=require("awaitly");function j(e){return e.type==="step"}function je(e){return e.type==="sequence"}function G(e){return e.type==="parallel"}function U(e){return e.type==="race"}function J(e){return e.type==="decision"}function re(e){return e.type==="stream"}function dr(e){return"children"in e||e.type==="decision"&&"branches"in e}var Ve="\x1B[0m",cr="\x1B[1m",ct="\x1B[2m",lr="\x1B[31m",ur="\x1B[32m",pr="\x1B[33m",mr="\x1B[34m",dt="\x1B[90m",fr="\x1B[37m";function Z(e,t){return t?`${t}${e}${Ve}`:e}function Se(e){return`${cr}${e}${Ve}`}function _(e){return`${ct}${e}${Ve}`}var z={pending:fr,running:pr,success:ur,error:lr,aborted:dt,cached:mr,skipped:ct+dt};function hr(e){switch(e){case"pending":return"\u25CB";case"running":return"\u27F3";case"success":return"\u2713";case"error":return"\u2717";case"aborted":return"\u2298";case"cached":return"\u21BA";case"skipped":return"\u2298"}}function Ie(e,t){let r=hr(e);return Z(r,t[e])}function Ne(e,t,r){return Z(e,r[t])}function ne(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}var R={topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502",teeRight:"\u251C",teeLeft:"\u2524",teeDown:"\u252C",teeUp:"\u2534",cross:"\u253C"},fe={cold:"\x1B[34m",cool:"\x1B[36m",neutral:"",warm:"\x1B[33m",hot:"\x1B[31m",critical:"\x1B[41m"},gr="\x1B[0m";function br(e){return e<.2?fe.cold:e<.4?fe.cool:e<.6?fe.neutral:e<.8?fe.warm:e<.95?fe.hot:fe.critical}function lt(e,t){let r=br(t);return r?`${r}${e}${gr}`:e}function wr(e){try{return(0,Oe.ok)(JSON.stringify(e,(r,o)=>{if(typeof o!="bigint")return o;let a=Number(o);return Number.isSafeInteger(a)?a:o.toString()}))}catch{return(0,Oe.err)("STRINGIFY_ERROR")}}function ut(e){let t=wr(e);return t.ok?t.value:"[unserializable]"}var pt="\u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588";function Ye(e,t=10){if(e.length===0)return"";let r=e.slice(-t),o=Math.min(...r),n=Math.max(...r)-o||1;return r.map(i=>{let s=(i-o)/n,u=Math.floor(s*(pt.length-1));return pt[u]}).join("")}function Ge(e,t){let r=ne(e).length,o=Math.max(0,t-r);return e+" ".repeat(o)}function yr(e,t){if(!t)return R.horizontal.repeat(e);let r=` ${t} `,o=ne(r).length,a=e-o;if(a<4)return R.horizontal.repeat(e);let n=2,i=a-n;return R.horizontal.repeat(n)+r+R.horizontal.repeat(i)}function mt(e,t,r){let o=e.state==="success"?Z("\u2699",r.success):Z("\u26A0",r.error),a=e.durationMs!==void 0?_(` [${H(e.durationMs)}]`):"",n="";e.type==="shouldRun"&&e.context?.skipped?n=_(" \u2192 workflow skipped"):e.type==="shouldRun"&&e.context?.result===!0?n=_(" \u2192 proceed"):e.type==="onBeforeStart"&&e.context?.skipped?n=_(" \u2192 workflow skipped"):e.type==="onAfterStep"&&e.context?.stepKey&&(n=_(` (${e.context.stepKey})`));let i=e.state==="error"&&e.error?_(` error: ${String(e.error)}`):"";return`${o} ${_(t)}${n}${a}${i}`}function vr(e,t){let r=[];return e.shouldRun&&r.push(mt(e.shouldRun,"shouldRun",t)),e.onBeforeStart&&r.push(mt(e.onBeforeStart,"onBeforeStart",t)),r.length>0&&r.push(_("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),r}function ae(){return{name:"ascii",supportsLive:!0,render(e,t){let r={...z,...t.colors},o=Math.max(t.terminalWidth??60,5),a=o-4,n=[],i=e.root.name??"workflow",s=Se(i);if(n.push(`${R.topLeft}${yr(o-2,s)}${R.topRight}`),n.push(`${R.vertical}${" ".repeat(o-2)}${R.vertical}`),e.hooks){let d=vr(e.hooks,r);for(let l of d)n.push(`${R.vertical} ${Ge(l,a)}${R.vertical}`)}let u=De(e.root.children,t,r,0,e.hooks);for(let d of u)n.push(`${R.vertical} ${Ge(d,a)}${R.vertical}`);if(n.push(`${R.vertical}${" ".repeat(o-2)}${R.vertical}`),e.root.durationMs!==void 0&&t.showTimings){let d=e.root.state==="success"?"Completed":e.root.state==="aborted"?"Cancelled":"Failed",p=`${Ne(d,e.root.state,r)} in ${H(e.root.durationMs)}`;n.push(`${R.vertical} ${Ge(p,a)}${R.vertical}`),n.push(`${R.vertical}${" ".repeat(o-2)}${R.vertical}`)}return n.push(`${R.bottomLeft}${R.horizontal.repeat(o-2)}${R.bottomRight}`),n.join(`
|
|
2
|
-
`)}}}function De(e,t,r,o,a){let n=[];for(let i of e)j(i)?n.push(Je(i,t,r,a)):G(i)?n.push(...xr(i,t,r,o,a)):U(i)?n.push(...Sr(i,t,r,o,a)):J(i)?n.push(...Ir(i,t,r,o,a)):re(i)&&n.push(kr(i,t,r));return n}function Je(e,t,r,o){let a=Ie(e.state,r),n=e.name??e.key??"step",i=t,s=i.showHeatmap&&i.heatmapData?i.heatmapData.heat.get(e.key??"")??i.heatmapData.heat.get(e.name??"")??i.heatmapData.heat.get(e.id):void 0,u;s!==void 0?u=lt(n,s):u=Ne(n,e.state,r);let d=`${a} ${u}`;if(t.showKeys&&e.key&&e.name&&(d+=_(` [key: ${e.key}]`)),e.input!==void 0){let p=typeof e.input=="string"?e.input:ut(e.input).slice(0,30);d+=_(` [in: ${p}${p.length>=30?"...":""}]`)}if(e.output!==void 0&&e.state==="success"){let p=typeof e.output=="string"?e.output:ut(e.output).slice(0,30);d+=_(` [out: ${p}${p.length>=30?"...":""}]`)}if(t.showTimings&&e.durationMs!==void 0){let p=H(e.durationMs),f=s!==void 0?lt(`[${p}]`,s):_(`[${p}]`);d+=` ${f}`}if(i.showSparklines&&i.timingHistory){let p=i.timingHistory.get(e.key??"")??i.timingHistory.get(e.name??"")??i.timingHistory.get(e.id);p&&p.length>1&&(d+=` ${_(Ye(p))}`)}if(e.retryCount!==void 0&&e.retryCount>0&&(d+=_(` [${e.retryCount} ${e.retryCount===1?"retry":"retries"}]`)),e.timedOut){let p=e.timeoutMs!==void 0?` ${e.timeoutMs}ms`:"";d+=_(` [timeout${p}]`)}let l=e.key??e.id;if(o&&l&&o.onAfterStep.has(l)){let p=o.onAfterStep.get(l),f=p.state==="success"?Z("\u2699",r.success):Z("\u26A0",r.error),m=p.durationMs!==void 0?_(` ${H(p.durationMs)}`):"";d+=` ${f}${m}`}return d}function kr(e,t,r){let o=e.streamState==="active"?Z("\u27F3",r.running):e.streamState==="closed"?Z("\u2713",r.success):Z("\u2717",r.error),a=`stream:${e.namespace}`,n=Ne(a,e.state,r),i=_(`[W:${e.writeCount} R:${e.readCount}]`),s=`${o} ${n} ${i}`;return t.showTimings&&e.durationMs!==void 0&&(s+=` ${_(`[${H(e.durationMs)}]`)}`),e.backpressureOccurred&&(s+=_(" [backpressure]")),e.streamState==="closed"&&(s+=_(` pos:${e.finalPosition}`)),s}function xr(e,t,r,o,a){let n=[],i=" ".repeat(o),s=Ie(e.state,r),u=e.name??"parallel",d=e.mode==="allSettled"?" (allSettled)":"";if(n.push(`${i}${R.teeRight}${R.teeDown}${R.horizontal} ${s} ${Se(u)}${d}`),e.children.length===0)n.push(`${i}${R.vertical} ${_("(operations not individually tracked)")}`),n.push(`${i}${R.vertical} ${_("(wrap each operation with step() to see individual steps)")}`);else for(let l=0;l<e.children.length;l++){let p=e.children[l],m=l===e.children.length-1?`${i}${R.vertical} ${R.bottomLeft}`:`${i}${R.vertical} ${R.teeRight}`;if(j(p))n.push(`${m} ${Je(p,t,r,a)}`);else{let w=De([p],t,r,o+1,a);for(let k of w)n.push(`${i}${R.vertical} ${k}`)}}return t.showTimings&&e.durationMs!==void 0&&n.push(`${i}${R.bottomLeft}${R.horizontal}${R.horizontal} ${_(`[${H(e.durationMs)}]`)}`),n}function Sr(e,t,r,o,a){let n=[],i=" ".repeat(o),s=Ie(e.state,r),u=e.name??"race";if(n.push(`${i}${R.teeRight}\u26A1 ${s} ${Se(u)}`),e.children.length===0)n.push(`${i}${R.vertical} ${_("(operations not individually tracked)")}`),n.push(`${i}${R.vertical} ${_("(wrap each operation with step() to see individual steps)")}`);else for(let d=0;d<e.children.length;d++){let l=e.children[d],f=d===e.children.length-1?`${i}${R.vertical} ${R.bottomLeft}`:`${i}${R.vertical} ${R.teeRight}`,w=e.winnerId&&l.id===e.winnerId?_(" (winner)"):"";if(j(l))n.push(`${f} ${Je(l,t,r,a)}${w}`);else{let k=De([l],t,r,o+1,a);for(let M of k)n.push(`${i}${R.vertical} ${M}`)}}return t.showTimings&&e.durationMs!==void 0&&n.push(`${i}${R.bottomLeft}${R.horizontal}${R.horizontal} ${_(`[${H(e.durationMs)}]`)}`),n}function Ir(e,t,r,o,a){let n=[],i=" ".repeat(o),s=Ie(e.state,r),u=e.name??"decision",d=e.condition?_(` (${e.condition})`):"",l=e.decisionValue!==void 0?_(` = ${String(e.decisionValue)}`):"",p=e.branchTaken!==void 0?_(` \u2192 ${String(e.branchTaken)}`):"";n.push(`${i}${R.teeRight}${R.teeDown}${R.horizontal} ${s} ${Se(u)}${d}${l}${p}`);for(let f=0;f<e.branches.length;f++){let m=e.branches[f],k=f===e.branches.length-1?`${i}${R.vertical} ${R.bottomLeft}`:`${i}${R.vertical} ${R.teeRight}`,M=m.taken?"\u2713":"\u2298",$=m.taken?r.success:r.skipped,T=Z(`${M} ${m.label}`,$),I=m.condition?_(` (${m.condition})`):"";if(n.push(`${k} ${T}${I}`),m.children.length>0){let S=De(m.children,t,r,o+1,a);for(let x of S)n.push(`${i}${R.vertical} ${x}`)}else m.taken||n.push(`${i}${R.vertical} ${_("(skipped)")}`)}return t.showTimings&&e.durationMs!==void 0&&n.push(`${i}${R.bottomLeft}${R.horizontal}${R.horizontal} ${_(`[${H(e.durationMs)}]`)}`),n}var We=require("awaitly");function qe(e){let t=[];for(let r of e)if(t.push(r),"children"in r&&Array.isArray(r.children)&&t.push(...qe(r.children)),"branches"in r)for(let o of r.branches)t.push(...qe(o.children));return t}function Ce(e,t){if(e.length===0)return 0;let r=Math.floor(e.length*t);return e[Math.min(r,e.length-1)]}function he(e){return e<.2?"cold":e<.4?"cool":e<.6?"neutral":e<.8?"warm":e<.95?"hot":"critical"}function ft(){let e=new Map,t=new Map,r=new Map,o=new Map,a=[];function n(S){return S.stepKey??S.stepId??S.name??"unknown"}function i(S){let x=new Map;for(let g of S)switch(g.type){case"step_start":{let y=n(g);x.set(y,{retried:!1,timedOut:!1});break}case"step_retry":{let y=n(g),E=x.get(y);E&&(E.retried=!0);break}case"step_timeout":{let y=n(g),E=x.get(y);E&&(E.timedOut=!0);break}case"step_success":{let y=n(g),E=x.get(y),C=e.get(y)??[];C.push(g.durationMs),e.set(y,C);let N=t.get(y)??{retried:0,total:0};N.total++,E?.retried&&N.retried++,t.set(y,N);let L=o.get(y)??{timedOut:0,total:0};L.total++,E?.timedOut&&L.timedOut++,o.set(y,L);let P=r.get(y)??{errors:0,total:0};P.total++,r.set(y,P),x.delete(y);break}case"step_error":{let y=n(g),E=x.get(y),C=e.get(y)??[];C.push(g.durationMs),e.set(y,C);let N=t.get(y)??{retried:0,total:0};N.total++,E?.retried&&N.retried++,t.set(y,N);let L=o.get(y)??{timedOut:0,total:0};L.total++,E?.timedOut&&L.timedOut++,o.set(y,L);let P=r.get(y)??{errors:0,total:0};P.total++,P.errors++,r.set(y,P),x.delete(y);break}}}function s(S){i(S.events)}function u(S){a.push(S)}function d(S){a.length>0&&(i(a),a=[])}function l(S){let x=e.get(S);if(!x||x.length===0)return;let g=[...x].sort((D,v)=>D-v),E=g.reduce((D,v)=>D+v,0)/g.length,C=g.reduce((D,v)=>D+(v-E)**2,0)/g.length,N=t.get(S)??{retried:0,total:1},L=r.get(S)??{errors:0,total:1},P=o.get(S)??{timedOut:0,total:1};return{nodeId:S,avgDurationMs:E,minDurationMs:g[0],maxDurationMs:g[g.length-1],stdDevMs:Math.sqrt(C),samples:g.length,retryRate:N.total>0?N.retried/N.total:0,timeoutRate:P.total>0?P.timedOut/P.total:0,errorRate:L.total>0?L.errors/L.total:0,percentiles:{p50:Ce(g,.5),p90:Ce(g,.9),p95:Ce(g,.95),p99:Ce(g,.99)}}}function p(S){return l(S)}function f(S,x="duration"){let g=new Map,y=qe(S.root.children),E=[];for(let v of y){let O=("key"in v?v.key:void 0)??v.id??v.name,q=l(O);if(q){let oe;switch(x){case"duration":oe=q.avgDurationMs;break;case"retryRate":oe=q.retryRate;break;case"errorRate":oe=q.errorRate;break}E.push({id:v.id,value:oe})}}if(E.length===0)return{heat:g,metric:x,stats:{min:0,max:0,mean:0,threshold:0}};let C=E.map(v=>v.value),N=Math.min(...C),L=Math.max(...C),P=C.reduce((v,O)=>v+O,0)/C.length,D=L-N||1;for(let{id:v,value:O}of E)g.set(v,(O-N)/D);return{heat:g,metric:x,stats:{min:N,max:L,mean:P,threshold:P+(L-P)*.5}}}function m(){let S=new Map;for(let x of e.keys()){let g=l(x);g&&S.set(x,g)}return S}function w(S=10){return[...m().values()].sort((g,y)=>y.avgDurationMs-g.avgDurationMs).slice(0,S)}function k(S=10){return[...m().values()].filter(g=>g.errorRate>0).sort((g,y)=>y.errorRate-g.errorRate).slice(0,S)}function M(S=10){return[...m().values()].filter(g=>g.retryRate>0).sort((g,y)=>y.retryRate-g.retryRate).slice(0,S)}function $(){return JSON.stringify({timingData:Object.fromEntries(e),retryData:Object.fromEntries(t),errorData:Object.fromEntries(r),timeoutData:Object.fromEntries(o)})}function T(S){let x=JSON.parse(S);e.clear(),t.clear(),r.clear(),o.clear();for(let[g,y]of Object.entries(x.timingData??{}))e.set(g,y);for(let[g,y]of Object.entries(x.retryData??{}))t.set(g,y);for(let[g,y]of Object.entries(x.errorData??{}))r.set(g,y);for(let[g,y]of Object.entries(x.timeoutData??{}))o.set(g,y)}function I(){e.clear(),t.clear(),r.clear(),o.clear(),a=[]}return{addRun:s,addEvent:u,finalizeRun:d,getNodePerformance:p,getHeatmap:f,getSlowestNodes:w,getErrorProneNodes:k,getRetryProneNodes:M,getAllPerformance:m,exportData:$,importData:T,clear:I}}function Rr(){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 Er(){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 $r(e){return`heat_${e}`}function Mr(){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 Tr(e){try{return(0,We.ok)(JSON.stringify(e,(r,o)=>{if(typeof o!="bigint")return o;let a=Number(o);return Number.isSafeInteger(a)?a:o.toString()}))}catch{return(0,We.err)("STRINGIFY_ERROR")}}function ht(e){let t=Tr(e);return t.ok?t.value:"[unserializable]"}function Nr(e,t,r){let o;if(e.shouldRun){let a="hook_shouldRun",n=e.shouldRun.state==="success"?"hook_success":"hook_error",i=e.shouldRun.state==="success"?"\u2699":"\u26A0",s=r.showTimings&&e.shouldRun.durationMs!==void 0?` ${H(e.shouldRun.durationMs)}`:"",u=e.shouldRun.context?.skipped?"\\nskipped workflow":e.shouldRun.context?.result===!0?"\\nproceed":"";t.push(` ${a}[["${i} shouldRun${u}${s}"]]:::${n}`),o=a}if(e.onBeforeStart){let a="hook_beforeStart",n=e.onBeforeStart.state==="success"?"hook_success":"hook_error",i=e.onBeforeStart.state==="success"?"\u2699":"\u26A0",s=r.showTimings&&e.onBeforeStart.durationMs!==void 0?` ${H(e.onBeforeStart.durationMs)}`:"",u=e.onBeforeStart.context?.skipped?"\\nskipped workflow":"";t.push(` ${a}[["${i} onBeforeStart${u}${s}"]]:::${n}`),o&&t.push(` ${o} --> ${a}`),o=a}return{lastHookId:o}}var gt=0,Le=new Set,_e=new Set;function ge(e="node"){return`${e}_${++gt}`}function Or(){gt=0,Le.clear(),_e.clear()}function V(e){return e.replace(/"/g,"#quot;").replace(/</g,"<").replace(/>/g,">").trim()}function bt(e){return V(e).replace(/[{}[\]()]/g,"")}function ie(){return{name:"mermaid",supportsLive:!1,render(e,t){Or();let r=[],o=t;r.push("flowchart TD");let a;e.hooks&&(a=Nr(e.hooks,r,t).lastHookId);let n="start";r.push(` ${n}(("\u25B6 Start"))`),a&&r.push(` ${a} --> ${n}`);let i=n;for(let u of e.root.children){let d=Be(u,t,r,o,e.hooks);r.push(` ${i} --> ${d.entryId}`),i=d.exitId}if(["success","error","aborted"].includes(e.root.state)){let u="finish",d=e.root.state==="success"?"\u2713":e.root.state==="error"?"\u2717":"\u2298",l=e.root.state==="success"?"Done":e.root.state==="error"?"Failed":"Cancelled",p=`(("${d} ${l}"))`,f=e.root.state==="success"?":::success":e.root.state==="error"?":::error":":::aborted";r.push(` ${u}${p}${f}`),r.push(` ${i} --> ${u}`)}return r.push(""),r.push(...Rr()),o.showHeatmap&&r.push(...Er()),e.hooks&&r.push(...Mr()),r.join(`
|
|
3
|
-
`)}}}function Be(e,t,r,o,a){if(j(e))return Dr(e,t,r,o,a);if(G(e))return Cr(e,t,r,o,a);if(U(e))return Lr(e,t,r,o,a);if(J(e))return _r(e,t,r,o,a);if(re(e))return Wr(e,t,r);let n=ge("unknown");return r.push(` ${n}["Unknown Node"]`),{entryId:n,exitId:n}}function Dr(e,t,r,o,a){let n=t,i=n.showRetryEdges??!0,s=n.showErrorEdges??!0,u=n.showTimeoutEdges??!0,d=e.key?`step_${e.key.replace(/[^a-zA-Z0-9]/g,"_")}`:ge("step");if(_e.has(d)){let g=2;for(;_e.has(`${d}_${g}`);)g++;d=`${d}_${g}`}_e.add(d);let l=e.name??e.key??"Step",p=t.showKeys&&e.key&&e.name?`${l} [${e.key}]`:l,f=V(p),m=t.showTimings&&e.durationMs!==void 0?` ${H(e.durationMs)}`:"",w="";switch(e.state){case"success":w="\u2713 ";break;case"error":w="\u2717 ";break;case"cached":w="\u{1F4BE} ";break;case"running":w="\u23F3 ";break;case"skipped":w="\u2298 ";break}let k="";if(e.input!==void 0){let g=typeof e.input=="string"?V(e.input):V(ht(e.input).slice(0,20));k+=`\\nin: ${g}`}if(e.output!==void 0&&e.state==="success"){let g=typeof e.output=="string"?V(e.output):V(ht(e.output).slice(0,20));k+=`\\nout: ${g}`}let
|
|
4
|
-
`)}var Q=11,ee=2,be=2,Ae=3;function Ze(e,t){if(e.length<=t)return[e];let r=e.split(" "),o=[],a="";for(let n of r)a?a.length+1+n.length<=t?a+=" "+n:(o.push(a),a=n):a=n;if(a&&o.push(a),o.length===0)for(let n=0;n<e.length;n+=t)o.push(e.slice(n,n+t));return o}function kt(e){switch(e){case"success":return"\u2713";case"error":return"\u2717";case"running":return"\u27F3";case"pending":return"\u25CB";case"aborted":case"skipped":return"\u2298";case"cached":return"\u21BA";default:return"\u25CB"}}function Ur(e,t,r){let o=t.showStartEnd??!0,a=t,n=Math.floor(r/2),i=[],s=0;if(o){let d=Pe("start","start",["\u25B6 Start"],"success",n,s);i.push(d),s=d.bottomY+be}for(let d of e.root.children){let l=He(d,n,s,r-4,t,a);i.push(l.node),s=l.bottomY+be}if(o&&["success","error","aborted"].includes(e.root.state)){let d=e.root.state==="success"?"\u2713 Done":e.root.state==="error"?"\u2717 Failed":"\u2298 Cancelled",l=Pe("end","end",[d],e.root.state,n,s);i.push(l),s=l.bottomY}return{nodes:i,totalHeight:s+2}}function Pe(e,t,r,o,a,n){let i=Math.max(...r.map(l=>ne(l).length)),s=Math.max(Q,i+ee*2),u=r.length+2,d=a-Math.floor(s/2);return{id:e,type:t,label:r,state:o,x:d,y:n,width:s,height:u,centerX:a,bottomY:n+u-1}}function He(e,t,r,o,a,n){if(j(e))return zr(e,t,r,o,a,n);if(G(e)||U(e))return jr(e,t,r,o,a,n);if(J(e))return Vr(e,t,r,o,a,n);if(re(e))return Kr(e,t,r,o,a,n);let i=Pe(e.id,"step",["?"],e.state,t,r);return{node:i,bottomY:i.bottomY}}function zr(e,t,r,o,a,n){let i=e.name??e.key??"step",s=kt(e.state),u=[],d=`${s} ${i}`;a.showKeys&&e.key&&e.name&&(d+=` [${e.key}]`);let l=Math.min(o-ee*2,40);if(u.push(...Ze(d,l)),a.showTimings&&e.durationMs!==void 0&&u.push(`[${H(e.durationMs)}]`),e.retryCount&&e.retryCount>0&&u.push(`${e.retryCount}x retry`),e.timedOut&&u.push("timeout"),n?.showSparklines&&n.timingHistory){let $=n.timingHistory.get(e.key??"")??n.timingHistory.get(e.name??"")??n.timingHistory.get(e.id);$&&$.length>1&&u.push(Ye($,8))}let p=Math.max(...u.map($=>ne($).length)),f=Math.max(Q,p+ee*2),m=u.length+2,w=t-Math.floor(f/2),k;if(n?.showHeatmap&&n.heatmapData){let $=e.key??e.name??e.id;k=n.heatmapData.heat.get(e.id)??n.heatmapData.heat.get($)}let M={id:e.id,type:"step",label:u,state:e.state,x:w,y:r,width:f,height:m,centerX:t,bottomY:r+m-1,metadata:k!==void 0?{heat:k}:void 0};return{node:M,bottomY:M.bottomY}}function Kr(e,t,r,o,a,n){let i=`stream:${e.namespace}`,s=e.streamState==="active"?"\u27F3":e.streamState==="closed"?"\u2713":"\u2717",u=[],d=`${s} ${i}`,l=Math.min(o-ee*2,40);u.push(...Ze(d,l)),u.push(`W:${e.writeCount} R:${e.readCount}`),a.showTimings&&e.durationMs!==void 0&&u.push(`[${H(e.durationMs)}]`),e.backpressureOccurred&&u.push("backpressure");let p=Math.max(...u.map(M=>ne(M).length)),f=Math.max(Q,p+ee*2),m=u.length+2,w=t-Math.floor(f/2),k={id:e.id,type:"stream",label:u,state:e.state,x:w,y:r,width:f,height:m,centerX:t,bottomY:r+m-1,metadata:{streamState:e.streamState,backpressureOccurred:e.backpressureOccurred}};return{node:k,bottomY:k.bottomY}}function jr(e,t,r,o,a,n){let i=U(e),s=e.name??(i?"race":"parallel"),d=`${i?"\u26A1":"\u2AD8"} ${s}`;if(e.children.length===0){let y=[d,"(not tracked)"],E=Pe(e.id,i?"race":"parallel",y,e.state,t,r);return{node:E,bottomY:E.bottomY}}let l=Math.floor((o-Ae*(e.children.length-1))/e.children.length),p=[];for(let y of e.children){let E=Xe(y,Math.max(l,Q),a,n);p.push(E.width)}let f=p.reduce((y,E)=>y+E,0)+Ae*(e.children.length-1),m=f>o&&e.children.length>1,w=Math.max(Q,d.length+ee*2),k=3,M=t-Math.floor(w/2),$=r;$+=k,$+=1,$+=1;let T=[];if(m)for(let y=0;y<e.children.length;y++){let E=e.children[y],C=He(E,t,$,o,a,n);i&&U(e)&&e.winnerId===E.id&&(C.node.metadata={...C.node.metadata,isWinner:!0}),T.push(C.node),$=C.bottomY+be}else{let y=t-Math.floor(f/2);for(let E=0;E<e.children.length;E++){let C=e.children[E],N=y+Math.floor(p[E]/2),L=He(C,N,$,p[E],a,n);i&&U(e)&&e.winnerId===C.id&&(L.node.metadata={...L.node.metadata,isWinner:!0}),T.push(L.node),y+=p[E]+Ae}}let I=Math.max(...T.map(y=>y.bottomY)),x=!m&&T.length>1?I+2:I;return{node:{id:e.id,type:i?"race":"parallel",label:[d],state:e.state,x:M,y:r,width:w,height:k,centerX:t,bottomY:x,children:T,metadata:{verticalLayout:m}},bottomY:x}}function Vr(e,t,r,o,a,n){let i=e.name??"decision",s=e.condition?` (${e.condition.slice(0,20)})`:"",u=`\u25C7 ${i}${s}`,d=Math.min(o-ee*2,40),l=Ze(u,d),p=Math.max(...l.map(x=>ne(x).length)),f=Math.max(Q,p+ee*2),m=l.length+2,w=t-Math.floor(f/2),k=e.branches.find(x=>x.taken),M=k&&k.children.length>0?k:e.branches.find(x=>x.children.length>0);if(!M||M.children.length===0){let x={id:e.id,type:"decision",label:l,state:e.state,x:w,y:r,width:f,height:m,centerX:t,bottomY:r+m-1};return{node:x,bottomY:x.bottomY}}let $=r+m+be,T=[];for(let x of M.children){let g=He(x,t,$,o,a,n);T.push(g.node),$=g.bottomY+be}let I=T.length>0?T[T.length-1].bottomY:r+m-1;return{node:{id:e.id,type:"decision",label:l,state:e.state,x:w,y:r,width:f,height:m,centerX:t,bottomY:I,children:T},bottomY:I}}function Xe(e,t,r,o){if(j(e)){let a=e.name??e.key??"step",n=kt(e.state),i=1;r.showTimings&&e.durationMs!==void 0&&i++,e.retryCount&&e.retryCount>0&&i++,e.timedOut&&i++,o?.showSparklines&&(o.timingHistory?.has(e.key??"")||o.timingHistory?.has(e.name??"")||o.timingHistory?.has(e.id))&&i++;let s=`${n} ${a}`;r.showKeys&&e.key&&e.name&&(s+=` [${e.key}]`);let u=Math.min(t,Math.max(Q,s.length+ee*2)),d=i+2;return{width:u,height:d}}if(G(e)||U(e)){if(e.children.length===0)return{width:Q+4,height:4};let a=Math.floor(t/e.children.length),n=0,i=0;for(let s of e.children){let u=Xe(s,a,r,o);n+=u.width,i=Math.max(i,u.height)}return n+=Ae*(e.children.length-1),{width:Math.max(n,Q),height:5+i+2}}if(J(e)){let a=e.branches.find(i=>i.taken),n=0;if(a)for(let i of a.children){let s=Xe(i,t,r,o);n+=s.height+be}return{width:Math.min(t,30),height:3+n}}if(re(e)){let a=`stream:${e.namespace}`,n=2;r.showTimings&&e.durationMs!==void 0&&n++,e.backpressureOccurred&&n++;let i=Math.min(t,Math.max(Q,a.length+ee*2+4)),s=n+2;return{width:i,height:s}}return{width:Q,height:3}}function Gr(e,t,r){let o={...z,...r.colors};for(let a=0;a<t.length;a++){let n=t[a],i=a===t.length-1;if(Fe(e,n,o),!i){let s=t[a+1],u=n.centerX,d=n.bottomY+1,l=s.centerX,p=s.y-1;se(e,u,d,p-1),pe(e,l,p)}}}function Fe(e,t,r){let o=t.type!=="start",a=t.type!=="end"&&(!t.children||t.children.length===0);Hr(e,t.x,t.y,t.width,t.height),o&&A(e,t.centerX,t.y,B.teeUp),(a||t.children&&t.children.length>0)&&A(e,t.centerX,t.y+t.height-1,B.teeDown);let n=t.width-ee*2,i=Xr(t,r);for(let s=0;s<t.label.length;s++){let u=t.label[s],d=t.x+1+Math.floor((n-ne(u).length)/2),l=t.y+1+s;wt(e,d,l,u,i)}t.metadata?.isWinner&&wt(e,t.x+t.width-2,t.y,"\u{1F3C6}"),t.children&&t.children.length>0&&(t.type==="parallel"||t.type==="race"?Yr(e,t,r):Jr(e,t,r))}function Yr(e,t,r){let o=t.children;if(o.length===0)return;let a=t.y+t.height,n=t.centerX;if(t.metadata?.verticalLayout===!0){let s=o[0];se(e,n,a,s.y-2),pe(e,s.centerX,s.y-1);for(let u=0;u<o.length;u++){let d=o[u];if(Fe(e,d,r),u<o.length-1){let l=o[u+1];se(e,d.centerX,d.bottomY+1,l.y-2),pe(e,l.centerX,l.y-1)}}return}if(o.length===1)se(e,n,a,o[0].y-2),pe(e,o[0].centerX,o[0].y-1);else{let s=o.map(l=>l.centerX),u=Math.min(...s),d=Math.max(...s);se(e,n,a,a+1),yt(e,a+1,u,d),A(e,n,a+1,B.teeUp);for(let l of o){let p=l.centerX;p===u?A(e,p,a+1,B.topLeft):p===d?A(e,p,a+1,B.topRight):p!==n&&A(e,p,a+1,B.teeDown),se(e,p,a+2,l.y-2),pe(e,p,l.y-1)}}for(let s of o)Fe(e,s,r);if(o.length>1){let s=o.map(m=>m.bottomY),u=Math.max(...s),d=u+1,l=o.map(m=>m.centerX),p=Math.min(...l),f=Math.max(...l);for(let m of o)m.bottomY<u&&se(e,m.centerX,m.bottomY+1,d-1);yt(e,d,p,f);for(let m of o){let w=m.centerX;w===p?A(e,w,d,B.bottomLeft):w===f?A(e,w,d,B.bottomRight):A(e,w,d,B.teeUp)}A(e,t.centerX,d,B.teeDown),A(e,t.centerX,d+1,B.vertical)}}function Jr(e,t,r){let o=t.children;if(o.length===0)return;let a=t.y+t.height,n=o[0];se(e,t.centerX,a,n.y-2),pe(e,n.centerX,n.y-1);for(let i=0;i<o.length;i++){let s=o[i];if(Fe(e,s,r),i<o.length-1){let u=o[i+1];se(e,s.centerX,s.bottomY+1,u.y-2),pe(e,u.centerX,u.y-1)}}}var qr={active:"\x1B[36m",closed:"\x1B[32m",error:"\x1B[31m"};function Xr(e,t){if(e.metadata?.heat!==void 0){let r=he(e.metadata.heat);return Br[r]||void 0}return e.type==="stream"&&e.metadata?.streamState?qr[e.metadata.streamState]||void 0:t[e.state]||void 0}function me(){return{name:"flowchart",supportsLive:!1,render(e,t){let r=t.terminalWidth??80,{nodes:o,totalHeight:a}=Ur(e,t,r),n=Pr(r,a);return Gr(n,o,t),Fr(n)}}}function Zr(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}function Qr(e){let t=[];function r(o){for(let a of o)if(j(a))t.push(a);else if(je(a))r(a.children);else if(G(a)||U(a))r(a.children);else if(J(a))for(let n of a.branches)n.taken&&r(n.children)}return r(e),t}function en(e){let t={id:e.id,name:e.name??e.key??e.id,state:e.state};return e.key&&(t.key=e.key),e.durationMs!==void 0&&(t.durationMs=e.durationMs),e.startTs!==void 0&&(t.startTs=e.startTs),e.endTs!==void 0&&(t.endTs=e.endTs),e.retryCount!==void 0&&e.retryCount>0&&(t.retryCount=e.retryCount),e.timedOut&&(t.timedOut=!0,e.timeoutMs!==void 0&&(t.timeoutMs=e.timeoutMs)),e.error!==void 0&&(t.error=typeof e.error=="string"?e.error:String(e.error)),t}function tn(e){let t=0,r=0,o=0,a=0,n=0,i;for(let s of e)s.state==="success"&&t++,s.state==="error"&&r++,s.state==="cached"&&o++,s.state==="skipped"&&a++,s.retryCount!==void 0&&(n+=s.retryCount),s.durationMs!==void 0&&(!i||s.durationMs>i.durationMs)&&(i={name:s.name??s.key??s.id,durationMs:s.durationMs});return{totalSteps:e.length,successCount:t,errorCount:r,cacheHits:o,skippedCount:a,totalRetries:n,slowestStep:i}}function rn(e){let t={};if(e.shouldRun&&(t.shouldRun={result:e.shouldRun.context?.result,durationMs:e.shouldRun.durationMs},e.shouldRun.error!==void 0&&e.shouldRun.error!==null&&(t.shouldRun.error=String(e.shouldRun.error))),e.onBeforeStart&&(t.onBeforeStart={durationMs:e.onBeforeStart.durationMs},e.onBeforeStart.error!==void 0&&e.onBeforeStart.error!==null&&(t.onBeforeStart.error=String(e.onBeforeStart.error))),e.onAfterStep.size>0){t.onAfterStep=[];for(let[r,o]of e.onAfterStep){let a={stepKey:r};o.durationMs!==void 0&&(a.durationMs=o.durationMs),o.error!==void 0&&o.error!==null&&(a.error=String(o.error)),t.onAfterStep.push(a)}}return t}function nn(e,t){let r=e.root,o=Qr(r.children),a=t.includeDiagram??!0,n=t.stripAnsiColors??!0,i={workflow:{id:r.workflowId,name:r.name,state:r.state,durationMs:r.durationMs,startedAt:r.startTs,completedAt:r.endTs},steps:o.map(en),summary:tn(o)};if(e.hooks){let s=rn(e.hooks);Object.keys(s).length>0&&(i.hooks=s)}if(a){let d=((t.diagramFormat??"ascii")==="flowchart"?me():ae()).render(e,t);n&&(d=Zr(d)),i.diagram=d}return i}function Re(){return{name:"logger",supportsLive:!1,render(e,t){let o=nn(e,t);return JSON.stringify(o)}}}var te=require("awaitly");var xt=or(require("pako"),1),on=typeof globalThis<"u"&&"Buffer"in globalThis&&typeof globalThis.Buffer=="function";function an(e){let t;if(on)t=globalThis.Buffer.from(e).toString("base64");else{let r="";for(let o=0;o<e.length;o++)r+=String.fromCharCode(e[o]);t=btoa(r)}return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Ue(e){let r=new TextEncoder().encode(e),o=xt.default.deflate(r);return an(o)}var St="https://kroki.io";function Qe(e,t,r,o={}){let a=o.baseUrl??St,n=Ue(r);return`${a}/${e}/${t}/${n}`}function ce(e,t="svg",r={}){let o=ie(),a={showTimings:!0,showKeys:!1,terminalWidth:80,colors:z},n=o.render(e,a);return Qe("mermaid",t,n,r)}function It(e,t={}){return ce(e,"svg",t)}function Rt(e,t={}){return ce(e,"png",t)}function Et(e={}){let t=e.baseUrl??St;return{toUrl(r,o){return ce(r,o,{baseUrl:t})},toSvgUrl(r){return ce(r,"svg",{baseUrl:t})},toPngUrl(r){return ce(r,"png",{baseUrl:t})},toPdfUrl(r){return ce(r,"pdf",{baseUrl:t})},getBaseUrl(){return t}}}var $t="https://mermaid.ink";function et(e){return`pako:${Ue(e)}`}function sn(e){if("provider"in e){let t=e;return{theme:t.mermaidTheme,bgColor:t.background,scale:t.scale,fit:t.fit,width:t.width,height:t.height,paper:t.paper,imageType:"png"}}return e}function dn(e,t){let r=[];return t.bgColor&&r.push(`bgColor=${encodeURIComponent(t.bgColor)}`),t.theme&&r.push(`theme=${t.theme}`),t.width!==void 0&&r.push(`width=${t.width}`),t.height!==void 0&&r.push(`height=${t.height}`),t.scale!==void 0&&(t.width!==void 0||t.height!==void 0)&&r.push(`scale=${t.scale}`),e==="img"&&t.imageType&&t.imageType!=="jpeg"&&r.push(`type=${t.imageType}`),e==="pdf"&&(t.fit&&r.push("fit"),t.paper&&!t.fit&&r.push(`paper=${t.paper}`),t.landscape&&!t.fit&&r.push("landscape")),r.length>0?`?${r.join("&")}`:""}function Ee(e,t,r={}){let o=sn(r),a=o.baseUrl??$t,n=et(t),i=dn(e,o);return`${a}/${e}/${n}${i}`}function Y(e,t="svg",r={}){let o=ie(),a={showTimings:!0,showKeys:!1,terminalWidth:80,colors:z},n=o.render(e,a);return Ee(t,n,r)}function Mt(e,t={}){return Y(e,"svg",t)}function Tt(e,t={}){return Y(e,"img",{...t,imageType:"png"})}function Nt(e,t={}){return Y(e,"img",{...t,imageType:"jpeg"})}function Ot(e,t={}){return Y(e,"img",{...t,imageType:"webp"})}function Dt(e,t={}){return Y(e,"pdf",t)}function Ct(e={}){let t=e.baseUrl??$t;return{toUrl(r,o){return Y(r,o,e)},toSvgUrl(r){return Y(r,"svg",e)},toPngUrl(r){return Y(r,"img",{...e,imageType:"png"})},toJpegUrl(r){return Y(r,"img",{...e,imageType:"jpeg"})},toWebpUrl(r){return Y(r,"img",{...e,imageType:"webp"})},toPdfUrl(r){return Y(r,"pdf",e)},getBaseUrl(){return t},getOptions(){return{...e}}}}function cn(e,t,r){return e==="mermaid-ink"&&t==="mermaid"?(0,te.ok)(void 0):e==="kroki"&&t==="mermaid"?r==="pdf"?(0,te.err)("UNSUPPORTED_FORMAT"):(0,te.ok)(void 0):(0,te.err)("UNSUPPORTED_FORMAT")}function ln(e){switch(e){case"mermaid":return"mermaid";case"graphviz":return"graphviz";case"plantuml":return"plantuml"}}function un(e){switch(e){case"svg":return"svg";case"png":return"img";case"pdf":return"pdf"}}function we(e,t,r,o={}){switch(e.kind){case"mermaid":break;case"graphviz":case"plantuml":return(0,te.err)("UNSUPPORTED_DIAGRAM_KIND");default:{let n=e;return(0,te.err)("UNSUPPORTED_DIAGRAM_KIND")}}let a=cn(r.provider,e.kind,t);if(!a.ok)return a;switch(r.provider){case"kroki":return(0,te.ok)(Qe(ln(e.kind),t,e.source,r));case"mermaid-ink":return(0,te.ok)(Ee(un(t),e.source,r));default:{let n=r;return(0,te.err)("UNKNOWN_PROVIDER")}}}function Lt(e){let t={bg:"#ffffff",bgSecondary:"#f8f9fa",text:"#212529",textMuted:"#6c757d",border:"#dee2e6",primary:"#0d6efd",success:"#198754",error:"#dc3545",warning:"#ffc107",info:"#0dcaf0",muted:"#6c757d",nodePending:"#e9ecef",nodeRunning:"#fff3cd",nodeSuccess:"#d1e7dd",nodeError:"#f8d7da",nodeAborted:"#e9ecef",nodeCached:"#cfe2ff",nodeSkipped:"#f8f9fa",heatCold:"#0d6efd",heatCool:"#0dcaf0",heatNeutral:"#6c757d",heatWarm:"#ffc107",heatHot:"#fd7e14",heatCritical:"#dc3545"},r={bg:"#212529",bgSecondary:"#343a40",text:"#f8f9fa",textMuted:"#adb5bd",border:"#495057",primary:"#0d6efd",success:"#198754",error:"#dc3545",warning:"#ffc107",info:"#0dcaf0",muted:"#6c757d",nodePending:"#495057",nodeRunning:"#664d03",nodeSuccess:"#0f5132",nodeError:"#842029",nodeAborted:"#495057",nodeCached:"#084298",nodeSkipped:"#343a40",heatCold:"#0d6efd",heatCool:"#0dcaf0",heatNeutral:"#6c757d",heatWarm:"#ffc107",heatHot:"#fd7e14",heatCritical:"#dc3545"},o=n=>`
|
|
1
|
+
"use strict";var Zt=Object.create;var Te=Object.defineProperty;var Qt=Object.getOwnPropertyDescriptor;var er=Object.getOwnPropertyNames;var tr=Object.getPrototypeOf,rr=Object.prototype.hasOwnProperty;var nr=(e,t)=>{for(var r in t)Te(e,r,{get:t[r],enumerable:!0})},it=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of er(t))!rr.call(e,a)&&a!==r&&Te(e,a,{get:()=>t[a],enumerable:!(o=Qt(t,a))||o.enumerable});return e};var or=(e,t,r)=>(r=e!=null?Zt(tr(e)):{},it(t||!e||!e.__esModule?Te(r,"default",{value:e,enumerable:!0}):r,e)),ar=e=>it(Te({},"__esModule",{value:!0}),e);var In={};nr(In,{asciiRenderer:()=>ae,buildMermaidInkUrl:()=>Ee,combineEventHandlers:()=>kn,createEventCollector:()=>Sn,createIRBuilder:()=>de,createLiveVisualizer:()=>Kt,createMermaidInkGenerator:()=>Ct,createParallelDetector:()=>st,createPerformanceAnalyzer:()=>ft,createTimeTravelController:()=>Gt,createUrlGenerator:()=>Et,createVisualizer:()=>Ke,defaultColorScheme:()=>z,detectParallelGroups:()=>xe,encodeForMermaidInk:()=>et,escapeHtml:()=>ve,flowchartRenderer:()=>me,generateInteractiveHTML:()=>Yt,getHeatLevel:()=>he,hasChildren:()=>dr,htmlRenderer:()=>Ut,isDecisionNode:()=>J,isParallelNode:()=>G,isRaceNode:()=>U,isSequenceNode:()=>je,isStepNode:()=>j,isStreamNode:()=>re,loggerRenderer:()=>Re,mermaidRenderer:()=>ie,renderToHTML:()=>zt,toExportUrl:()=>we,toKrokiPngUrl:()=>Rt,toKrokiSvgUrl:()=>It,toKrokiUrl:()=>ce,toMermaidInkJpegUrl:()=>Nt,toMermaidInkPdfUrl:()=>Dt,toMermaidInkPngUrl:()=>Mt,toMermaidInkSvgUrl:()=>Tt,toMermaidInkUrl:()=>Y,toMermaidInkWebpUrl:()=>Ot,trackDecision:()=>ze,trackIf:()=>jt,trackSwitch:()=>Vt,visualizeEvents:()=>xn});module.exports=ar(In);function H(e){if(e<1e3)return`${Math.round(e)}ms`;if(e<6e4)return`${(e/1e3).toFixed(1).replace(/\.0$/,"")}s`;let t=Math.floor(e/6e4),r=Math.round(e%6e4/1e3);return r>=60&&(t+=1,r=0),r===0?`${t}m`:`${t}m ${r}s`}function Me(){return`node_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function ir(e){for(let t of e)if((t.type==="parallel"||t.type==="race"||t.type==="sequence")&&!t.id.startsWith("detected_")||t.type==="decision")return!0;return!1}function xe(e,t={}){if(ir(e))return e;let{minOverlapMs:r=0,maxGapMs:o=5}=t,a=[],n=[];for(let d=0;d<e.length;d++){let l=e[d];l.type==="step"&&l.startTs!==void 0?a.push({node:l,startTs:l.startTs,endTs:l.endTs??l.startTs+(l.durationMs??0),originalIndex:d}):n.push({node:l,originalIndex:d})}if(a.length<=1)return e;a.sort((d,l)=>d.startTs-l.startTs);let i=[],s=[a[0]];for(let d=1;d<a.length;d++){let l=a[d],p=Math.min(...s.map(T=>T.startTs)),f=Math.max(...s.map(T=>T.endTs)),m=l.startTs<=p+o,w=l.startTs<f;if(!m&&!w){i.push(s),s=[l];continue}let k=w?Math.min(l.endTs,f)-l.startTs:0;m||k>=r?s.push(l):(i.push(s),s=[l])}i.push(s);let u=[];for(let d of i){let l=Math.min(...d.map(p=>p.originalIndex));if(d.length===1)u.push({node:d[0].node,position:l});else{let p=d.map(k=>k.node),f=Math.min(...d.map(k=>k.startTs)),m=Math.max(...d.map(k=>k.endTs)),w={type:"parallel",id:`detected_parallel_${f}`,name:`${p.length} parallel steps`,state:sr(p),mode:"all",children:p,startTs:f,endTs:m,durationMs:m-f};u.push({node:w,position:l})}}for(let{node:d,originalIndex:l}of n)u.push({node:d,position:l});return u.sort((d,l)=>d.position-l.position),u.map(d=>d.node)}function sr(e){return e.some(n=>n.state==="error")?"error":e.some(n=>n.state==="running")?"running":e.some(n=>n.state==="pending")?"pending":(e.every(n=>n.state==="success"||n.state==="cached"),"success")}function st(e={}){return{detect:t=>xe(t,e)}}function de(e={}){let{detectParallel:t=!0,parallelDetection:r,enableSnapshots:o=!1,maxSnapshots:a=1e3}=e,n=o,i=Me(),s,u,d,l="pending",p,f,m=new Map,w=[],k=[],T=new Map,$=[],M=Date.now(),I=M,S={onAfterStep:new Map},x,g=[],y=0;function E(c){return c.stepId??c.stepKey??c.name??Me()}function C(c){if(w.length>0){w[w.length-1].children.push(c),I=Date.now();return}if(k.length>0){let b=k[k.length-1];for(let h of b.branches.values())if(h.taken){h.children.push(c),I=Date.now();return}b.pendingChildren.push(c),I=Date.now();return}$.push(c),I=Date.now()}function N(c){if(!n)return;let b=q(),h=new Map;for(let[W,X]of m)h.set(W,{id:X.id,name:X.name,key:X.key,startTs:X.startTs,retryCount:X.retryCount,timedOut:X.timedOut,timeoutMs:X.timeoutMs});let F={id:`snapshot_${y}`,eventIndex:y,event:structuredClone(c),ir:structuredClone(b),timestamp:Date.now(),activeSteps:h};g.push(F),g.length>a&&g.shift(),y++}function L(c){switch(c.type){case"workflow_start":{$=[],d=void 0,f=void 0,p=void 0,m.clear(),w.length=0,k.length=0,T.clear(),s=c.workflowId,u=c.ts,l="running",M=Date.now(),I=M,x!==void 0&&x!==c.workflowId&&(S.shouldRun=void 0,S.onBeforeStart=void 0),x=c.workflowId,S.onAfterStep=new Map;break}case"workflow_success":l="success",d=c.ts,f=c.durationMs,I=Date.now();break;case"workflow_error":l="error",d=c.ts,p=c.error,f=c.durationMs,I=Date.now();break;case"workflow_cancelled":l="aborted",d=c.ts,f=c.durationMs,I=Date.now();break;case"step_start":{let b=E(c);m.set(b,{id:b,name:c.name,key:c.stepKey,startTs:c.ts,retryCount:0,timedOut:!1}),I=Date.now();break}case"step_success":{let b=E(c),h=m.get(b);if(h){let F={type:"step",id:h.id,name:h.name,key:h.key,state:"success",startTs:h.startTs,endTs:c.ts,durationMs:c.durationMs,...h.retryCount>0&&{retryCount:h.retryCount},...h.timedOut&&{timedOut:!0,timeoutMs:h.timeoutMs}};C(F),m.delete(b)}break}case"step_error":{let b=E(c),h=m.get(b);if(h){let F={type:"step",id:h.id,name:h.name,key:h.key,state:"error",startTs:h.startTs,endTs:c.ts,durationMs:c.durationMs,error:c.error,...h.retryCount>0&&{retryCount:h.retryCount},...h.timedOut&&{timedOut:!0,timeoutMs:h.timeoutMs}};C(F),m.delete(b)}break}case"step_aborted":{let b=E(c),h=m.get(b);if(h){let F={type:"step",id:h.id,name:h.name,key:h.key,state:"aborted",startTs:h.startTs,endTs:c.ts,durationMs:c.durationMs,...h.retryCount>0&&{retryCount:h.retryCount},...h.timedOut&&{timedOut:!0,timeoutMs:h.timeoutMs}};C(F),m.delete(b)}break}case"step_cache_hit":{let h={type:"step",id:E(c),name:c.name,key:c.stepKey,state:"cached",startTs:c.ts,endTs:c.ts,durationMs:0};C(h);break}case"step_cache_miss":break;case"step_complete":break;case"step_timeout":{let b=E(c),h=m.get(b);h&&(h.timedOut=!0,h.timeoutMs=c.timeoutMs),I=Date.now();break}case"step_retry":{let b=E(c),h=m.get(b);h&&(h.retryCount=(c.attempt??1)-1),I=Date.now();break}case"step_retries_exhausted":I=Date.now();break;case"step_skipped":{let h={type:"step",id:E(c),name:c.name,key:c.stepKey,state:"skipped",startTs:c.ts,endTs:c.ts,durationMs:0};C(h);break}case"hook_should_run":{let b={type:"shouldRun",state:"success",ts:c.ts,durationMs:c.durationMs,context:{result:c.result,skipped:c.skipped}};S.shouldRun=b,x=c.workflowId,I=Date.now();break}case"hook_should_run_error":{let b={type:"shouldRun",state:"error",ts:c.ts,durationMs:c.durationMs,error:c.error};S.shouldRun=b,x=c.workflowId,I=Date.now();break}case"hook_before_start":{let b={type:"onBeforeStart",state:"success",ts:c.ts,durationMs:c.durationMs,context:{result:c.result,skipped:c.skipped}};S.onBeforeStart=b,x=c.workflowId,I=Date.now();break}case"hook_before_start_error":{let b={type:"onBeforeStart",state:"error",ts:c.ts,durationMs:c.durationMs,error:c.error};S.onBeforeStart=b,x=c.workflowId,I=Date.now();break}case"hook_after_step":{let b={type:"onAfterStep",state:"success",ts:c.ts,durationMs:c.durationMs,context:{stepKey:c.stepKey}};S.onAfterStep.set(c.stepKey,b),I=Date.now();break}case"hook_after_step_error":{let b={type:"onAfterStep",state:"error",ts:c.ts,durationMs:c.durationMs,error:c.error,context:{stepKey:c.stepKey}};S.onAfterStep.set(c.stepKey,b),I=Date.now();break}case"stream_created":{let b=`${c.workflowId}:${c.namespace}`;T.set(b,{id:Me(),namespace:c.namespace,startTs:c.ts,writeCount:0,readCount:0,streamState:"active",backpressureOccurred:!1,finalPosition:0}),I=Date.now();break}case"stream_write":{let b=`${c.workflowId}:${c.namespace}`,h=T.get(b);h&&(h.writeCount++,h.finalPosition=Math.max(h.finalPosition,c.position)),I=Date.now();break}case"stream_read":{let b=`${c.workflowId}:${c.namespace}`,h=T.get(b);h&&h.readCount++,I=Date.now();break}case"stream_close":{let b=`${c.workflowId}:${c.namespace}`,h=T.get(b);if(h){h.streamState="closed",h.finalPosition=c.finalPosition;let F={type:"stream",id:h.id,namespace:h.namespace,state:"success",startTs:h.startTs,endTs:c.ts,durationMs:c.ts-h.startTs,writeCount:h.writeCount,readCount:h.readCount,finalPosition:c.finalPosition,streamState:"closed",backpressureOccurred:h.backpressureOccurred};C(F),T.delete(b)}I=Date.now();break}case"stream_error":{let b=`${c.workflowId}:${c.namespace}`,h=T.get(b);if(h){h.streamState="error";let F={type:"stream",id:h.id,namespace:h.namespace,state:"error",error:c.error,startTs:h.startTs,endTs:c.ts,durationMs:c.ts-h.startTs,writeCount:h.writeCount,readCount:h.readCount,finalPosition:c.position,streamState:"error",backpressureOccurred:h.backpressureOccurred};C(F),T.delete(b)}I=Date.now();break}case"stream_backpressure":{let b=`${c.workflowId}:${c.namespace}`,h=T.get(b);h&&(h.backpressureOccurred=!0),I=Date.now();break}}N(c)}function P(c){if(c.type==="scope_start")w.push({id:c.scopeId,name:c.name,type:c.scopeType,startTs:c.ts,children:[]}),I=Date.now();else if(c.type==="scope_end"){let b=w.findIndex(W=>W.id===c.scopeId);if(b===-1)return;for(;w.length>b+1;){let W=w.pop(),X=W.type==="race"?{type:"race",id:W.id,name:W.name,state:v(W.children),startTs:W.startTs,endTs:c.ts,children:W.children}:{type:"parallel",id:W.id,name:W.name,state:v(W.children),startTs:W.startTs,endTs:c.ts,children:W.children,mode:W.type==="allSettled"?"allSettled":"all"};w[w.length-1].children.push(X)}let[h]=w.splice(b,1),F=h.type==="race"?{type:"race",id:h.id,name:h.name,state:v(h.children),startTs:h.startTs,endTs:c.ts,durationMs:c.durationMs,children:h.children,winnerId:c.winnerId}:{type:"parallel",id:h.id,name:h.name,state:v(h.children),startTs:h.startTs,endTs:c.ts,durationMs:c.durationMs,children:h.children,mode:h.type==="allSettled"?"allSettled":"all"};C(F)}}function D(c){if(c.type==="decision_start")k.push({id:c.decisionId,name:c.name,condition:c.condition,decisionValue:c.decisionValue,startTs:c.ts,branches:new Map,pendingChildren:[]}),I=Date.now();else if(c.type==="decision_branch"){let b=k.find(h=>h.id===c.decisionId);if(b){let h=c.branchLabel,F=b.branches.get(h);if(F)F.taken=c.taken,c.taken&&b.pendingChildren.length>0&&(F.children.unshift(...b.pendingChildren),b.pendingChildren=[]);else{let W=c.taken?[...b.pendingChildren]:[];c.taken&&(b.pendingChildren=[]),b.branches.set(h,{label:c.branchLabel,condition:c.condition,taken:c.taken,children:W})}I=Date.now()}}else if(c.type==="decision_end"){let b=k.findIndex(h=>h.id===c.decisionId);if(b!==-1){let[h]=k.splice(b,1),F=k.splice(b),W=Array.from(h.branches.values());W.length===0&&h.pendingChildren.length>0&&(W=[{label:"default",taken:!0,children:[...h.pendingChildren]}]);let X=W.find($e=>$e.taken)?.label,Xt={type:"decision",id:h.id,name:h.name,state:v(W.flatMap($e=>$e.taken?$e.children:[])),startTs:h.startTs,endTs:c.ts,durationMs:c.durationMs,condition:h.condition,decisionValue:h.decisionValue,branchTaken:c.branchTaken??X,branches:W};C(Xt),k.push(...F),I=Date.now()}}}function v(c){return c.length===0?"success":c.some(W=>W.state==="error")?"error":c.every(W=>W.state==="success"||W.state==="cached")?"success":c.some(W=>W.state==="running")?"running":"pending"}function O(){let c=[...$];for(let[,b]of m)c.push({type:"step",id:b.id,name:b.name,key:b.key,state:"running",startTs:b.startTs,...b.retryCount>0&&{retryCount:b.retryCount},...b.timedOut&&{timedOut:!0,timeoutMs:b.timeoutMs}});for(let[,b]of T)c.push({type:"stream",id:b.id,namespace:b.namespace,state:"running",startTs:b.startTs,writeCount:b.writeCount,readCount:b.readCount,finalPosition:b.finalPosition,streamState:b.streamState,backpressureOccurred:b.backpressureOccurred});return c}function q(){let c=O();t&&(c=xe(c,r));let b={type:"workflow",id:s??i,workflowId:s??i,state:l,startTs:u,endTs:d,durationMs:f,children:c,error:p},h=S.shouldRun!==void 0||S.onBeforeStart!==void 0||S.onAfterStep.size>0;return{root:b,metadata:{createdAt:M,lastUpdatedAt:I},...h&&{hooks:S}}}function oe(){s=void 0,u=void 0,d=void 0,l="pending",p=void 0,f=void 0,m.clear(),w.length=0,k.length=0,T.clear(),$=[],M=Date.now(),I=M,S={onAfterStep:new Map},x=void 0,g.length=0,y=0}function at(){return[...g]}function ke(c){return g[c]}function Jt(c){return g[c]?.ir}function qt(){g.length=0,y=0}return{handleEvent:L,handleScopeEvent:P,handleDecisionEvent:D,getIR:q,reset:oe,getSnapshots:at,getSnapshotAt:ke,getIRAt:Jt,clearSnapshots:qt,get hasActiveSteps(){return m.size>0},get state(){return l},get snapshotCount(){return g.length},get snapshotsEnabled(){return n},setSnapshotsEnabled(c){n=c}}}var Oe=require("awaitly");function j(e){return e.type==="step"}function je(e){return e.type==="sequence"}function G(e){return e.type==="parallel"}function U(e){return e.type==="race"}function J(e){return e.type==="decision"}function re(e){return e.type==="stream"}function dr(e){return"children"in e||e.type==="decision"&&"branches"in e}var Ve="\x1B[0m",cr="\x1B[1m",ct="\x1B[2m",lr="\x1B[31m",ur="\x1B[32m",pr="\x1B[33m",mr="\x1B[34m",dt="\x1B[90m",fr="\x1B[37m";function Z(e,t){return t?`${t}${e}${Ve}`:e}function Se(e){return`${cr}${e}${Ve}`}function _(e){return`${ct}${e}${Ve}`}var z={pending:fr,running:pr,success:ur,error:lr,aborted:dt,cached:mr,skipped:ct+dt};function hr(e){switch(e){case"pending":return"\u25CB";case"running":return"\u27F3";case"success":return"\u2713";case"error":return"\u2717";case"aborted":return"\u2298";case"cached":return"\u21BA";case"skipped":return"\u2298"}}function Ie(e,t){let r=hr(e);return Z(r,t[e])}function Ne(e,t,r){return Z(e,r[t])}function ne(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}var R={topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502",teeRight:"\u251C",teeLeft:"\u2524",teeDown:"\u252C",teeUp:"\u2534",cross:"\u253C"},fe={cold:"\x1B[34m",cool:"\x1B[36m",neutral:"",warm:"\x1B[33m",hot:"\x1B[31m",critical:"\x1B[41m"},gr="\x1B[0m";function br(e){return e<.2?fe.cold:e<.4?fe.cool:e<.6?fe.neutral:e<.8?fe.warm:e<.95?fe.hot:fe.critical}function lt(e,t){let r=br(t);return r?`${r}${e}${gr}`:e}function wr(e){try{return(0,Oe.ok)(JSON.stringify(e,(r,o)=>{if(typeof o!="bigint")return o;let a=Number(o);return Number.isSafeInteger(a)?a:o.toString()}))}catch{return(0,Oe.err)("STRINGIFY_ERROR")}}function ut(e){let t=wr(e);return t.ok?t.value:"[unserializable]"}var pt="\u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588";function Ye(e,t=10){if(e.length===0)return"";let r=e.slice(-t),o=Math.min(...r),n=Math.max(...r)-o||1;return r.map(i=>{let s=(i-o)/n,u=Math.floor(s*(pt.length-1));return pt[u]}).join("")}function Ge(e,t){let r=ne(e).length,o=Math.max(0,t-r);return e+" ".repeat(o)}function yr(e,t){if(!t)return R.horizontal.repeat(e);let r=` ${t} `,o=ne(r).length,a=e-o;if(a<4)return R.horizontal.repeat(e);let n=2,i=a-n;return R.horizontal.repeat(n)+r+R.horizontal.repeat(i)}function mt(e,t,r){let o=e.state==="success"?Z("\u2699",r.success):Z("\u26A0",r.error),a=e.durationMs!==void 0?_(` [${H(e.durationMs)}]`):"",n="";e.type==="shouldRun"&&e.context?.skipped?n=_(" \u2192 workflow skipped"):e.type==="shouldRun"&&e.context?.result===!0?n=_(" \u2192 proceed"):e.type==="onBeforeStart"&&e.context?.skipped?n=_(" \u2192 workflow skipped"):e.type==="onAfterStep"&&e.context?.stepKey&&(n=_(` (${e.context.stepKey})`));let i=e.state==="error"&&e.error?_(` error: ${String(e.error)}`):"";return`${o} ${_(t)}${n}${a}${i}`}function vr(e,t){let r=[];return e.shouldRun&&r.push(mt(e.shouldRun,"shouldRun",t)),e.onBeforeStart&&r.push(mt(e.onBeforeStart,"onBeforeStart",t)),r.length>0&&r.push(_("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),r}function ae(){return{name:"ascii",supportsLive:!0,render(e,t){let r={...z,...t.colors},o=Math.max(t.terminalWidth??60,5),a=o-4,n=[],i=e.root.name??"workflow",s=Se(i);if(n.push(`${R.topLeft}${yr(o-2,s)}${R.topRight}`),n.push(`${R.vertical}${" ".repeat(o-2)}${R.vertical}`),e.hooks){let d=vr(e.hooks,r);for(let l of d)n.push(`${R.vertical} ${Ge(l,a)}${R.vertical}`)}let u=De(e.root.children,t,r,0,e.hooks);for(let d of u)n.push(`${R.vertical} ${Ge(d,a)}${R.vertical}`);if(n.push(`${R.vertical}${" ".repeat(o-2)}${R.vertical}`),e.root.durationMs!==void 0&&t.showTimings){let d=e.root.state==="success"?"Completed":e.root.state==="aborted"?"Cancelled":"Failed",p=`${Ne(d,e.root.state,r)} in ${H(e.root.durationMs)}`;n.push(`${R.vertical} ${Ge(p,a)}${R.vertical}`),n.push(`${R.vertical}${" ".repeat(o-2)}${R.vertical}`)}return n.push(`${R.bottomLeft}${R.horizontal.repeat(o-2)}${R.bottomRight}`),n.join(`
|
|
2
|
+
`)}}}function De(e,t,r,o,a){let n=[];for(let i of e)j(i)?n.push(Je(i,t,r,a)):G(i)?n.push(...xr(i,t,r,o,a)):U(i)?n.push(...Sr(i,t,r,o,a)):J(i)?n.push(...Ir(i,t,r,o,a)):re(i)&&n.push(kr(i,t,r));return n}function Je(e,t,r,o){let a=Ie(e.state,r),n=e.name??e.key??"step",i=t,s=i.showHeatmap&&i.heatmapData?i.heatmapData.heat.get(e.key??"")??i.heatmapData.heat.get(e.name??"")??i.heatmapData.heat.get(e.id):void 0,u;s!==void 0?u=lt(n,s):u=Ne(n,e.state,r);let d=`${a} ${u}`;if(t.showKeys&&e.key&&e.name&&(d+=_(` [key: ${e.key}]`)),e.input!==void 0){let p=typeof e.input=="string"?e.input:ut(e.input).slice(0,30);d+=_(` [in: ${p}${p.length>=30?"...":""}]`)}if(e.output!==void 0&&e.state==="success"){let p=typeof e.output=="string"?e.output:ut(e.output).slice(0,30);d+=_(` [out: ${p}${p.length>=30?"...":""}]`)}if(t.showTimings&&e.durationMs!==void 0){let p=H(e.durationMs),f=s!==void 0?lt(`[${p}]`,s):_(`[${p}]`);d+=` ${f}`}if(i.showSparklines&&i.timingHistory){let p=i.timingHistory.get(e.key??"")??i.timingHistory.get(e.name??"")??i.timingHistory.get(e.id);p&&p.length>1&&(d+=` ${_(Ye(p))}`)}if(e.retryCount!==void 0&&e.retryCount>0&&(d+=_(` [${e.retryCount} ${e.retryCount===1?"retry":"retries"}]`)),e.timedOut){let p=e.timeoutMs!==void 0?` ${e.timeoutMs}ms`:"";d+=_(` [timeout${p}]`)}let l=e.key??e.id;if(o&&l&&o.onAfterStep.has(l)){let p=o.onAfterStep.get(l),f=p.state==="success"?Z("\u2699",r.success):Z("\u26A0",r.error),m=p.durationMs!==void 0?_(` ${H(p.durationMs)}`):"";d+=` ${f}${m}`}return d}function kr(e,t,r){let o=e.streamState==="active"?Z("\u27F3",r.running):e.streamState==="closed"?Z("\u2713",r.success):Z("\u2717",r.error),a=`stream:${e.namespace}`,n=Ne(a,e.state,r),i=_(`[W:${e.writeCount} R:${e.readCount}]`),s=`${o} ${n} ${i}`;return t.showTimings&&e.durationMs!==void 0&&(s+=` ${_(`[${H(e.durationMs)}]`)}`),e.backpressureOccurred&&(s+=_(" [backpressure]")),e.streamState==="closed"&&(s+=_(` pos:${e.finalPosition}`)),s}function xr(e,t,r,o,a){let n=[],i=" ".repeat(o),s=Ie(e.state,r),u=e.name??"parallel",d=e.mode==="allSettled"?" (allSettled)":"";if(n.push(`${i}${R.teeRight}${R.teeDown}${R.horizontal} ${s} ${Se(u)}${d}`),e.children.length===0)n.push(`${i}${R.vertical} ${_("(operations not individually tracked)")}`),n.push(`${i}${R.vertical} ${_("(wrap each operation with step() to see individual steps)")}`);else for(let l=0;l<e.children.length;l++){let p=e.children[l],m=l===e.children.length-1?`${i}${R.vertical} ${R.bottomLeft}`:`${i}${R.vertical} ${R.teeRight}`;if(j(p))n.push(`${m} ${Je(p,t,r,a)}`);else{let w=De([p],t,r,o+1,a);for(let k of w)n.push(`${i}${R.vertical} ${k}`)}}return t.showTimings&&e.durationMs!==void 0&&n.push(`${i}${R.bottomLeft}${R.horizontal}${R.horizontal} ${_(`[${H(e.durationMs)}]`)}`),n}function Sr(e,t,r,o,a){let n=[],i=" ".repeat(o),s=Ie(e.state,r),u=e.name??"race";if(n.push(`${i}${R.teeRight}\u26A1 ${s} ${Se(u)}`),e.children.length===0)n.push(`${i}${R.vertical} ${_("(operations not individually tracked)")}`),n.push(`${i}${R.vertical} ${_("(wrap each operation with step() to see individual steps)")}`);else for(let d=0;d<e.children.length;d++){let l=e.children[d],f=d===e.children.length-1?`${i}${R.vertical} ${R.bottomLeft}`:`${i}${R.vertical} ${R.teeRight}`,w=e.winnerId&&l.id===e.winnerId?_(" (winner)"):"";if(j(l))n.push(`${f} ${Je(l,t,r,a)}${w}`);else{let k=De([l],t,r,o+1,a);for(let T of k)n.push(`${i}${R.vertical} ${T}`)}}return t.showTimings&&e.durationMs!==void 0&&n.push(`${i}${R.bottomLeft}${R.horizontal}${R.horizontal} ${_(`[${H(e.durationMs)}]`)}`),n}function Ir(e,t,r,o,a){let n=[],i=" ".repeat(o),s=Ie(e.state,r),u=e.name??"decision",d=e.condition?_(` (${e.condition})`):"",l=e.decisionValue!==void 0?_(` = ${String(e.decisionValue)}`):"",p=e.branchTaken!==void 0?_(` \u2192 ${String(e.branchTaken)}`):"";n.push(`${i}${R.teeRight}${R.teeDown}${R.horizontal} ${s} ${Se(u)}${d}${l}${p}`);for(let f=0;f<e.branches.length;f++){let m=e.branches[f],k=f===e.branches.length-1?`${i}${R.vertical} ${R.bottomLeft}`:`${i}${R.vertical} ${R.teeRight}`,T=m.taken?"\u2713":"\u2298",$=m.taken?r.success:r.skipped,M=Z(`${T} ${m.label}`,$),I=m.condition?_(` (${m.condition})`):"";if(n.push(`${k} ${M}${I}`),m.children.length>0){let S=De(m.children,t,r,o+1,a);for(let x of S)n.push(`${i}${R.vertical} ${x}`)}else m.taken||n.push(`${i}${R.vertical} ${_("(skipped)")}`)}return t.showTimings&&e.durationMs!==void 0&&n.push(`${i}${R.bottomLeft}${R.horizontal}${R.horizontal} ${_(`[${H(e.durationMs)}]`)}`),n}var We=require("awaitly");function qe(e){let t=[];for(let r of e)if(t.push(r),"children"in r&&Array.isArray(r.children)&&t.push(...qe(r.children)),"branches"in r)for(let o of r.branches)t.push(...qe(o.children));return t}function Ce(e,t){if(e.length===0)return 0;let r=Math.floor(e.length*t);return e[Math.min(r,e.length-1)]}function he(e){return e<.2?"cold":e<.4?"cool":e<.6?"neutral":e<.8?"warm":e<.95?"hot":"critical"}function ft(){let e=new Map,t=new Map,r=new Map,o=new Map,a=[];function n(S){return S.stepKey??S.stepId??S.name??"unknown"}function i(S){let x=new Map;for(let g of S)switch(g.type){case"step_start":{let y=n(g);x.set(y,{retried:!1,timedOut:!1});break}case"step_retry":{let y=n(g),E=x.get(y);E&&(E.retried=!0);break}case"step_timeout":{let y=n(g),E=x.get(y);E&&(E.timedOut=!0);break}case"step_success":{let y=n(g),E=x.get(y),C=e.get(y)??[];C.push(g.durationMs),e.set(y,C);let N=t.get(y)??{retried:0,total:0};N.total++,E?.retried&&N.retried++,t.set(y,N);let L=o.get(y)??{timedOut:0,total:0};L.total++,E?.timedOut&&L.timedOut++,o.set(y,L);let P=r.get(y)??{errors:0,total:0};P.total++,r.set(y,P),x.delete(y);break}case"step_error":{let y=n(g),E=x.get(y),C=e.get(y)??[];C.push(g.durationMs),e.set(y,C);let N=t.get(y)??{retried:0,total:0};N.total++,E?.retried&&N.retried++,t.set(y,N);let L=o.get(y)??{timedOut:0,total:0};L.total++,E?.timedOut&&L.timedOut++,o.set(y,L);let P=r.get(y)??{errors:0,total:0};P.total++,P.errors++,r.set(y,P),x.delete(y);break}}}function s(S){i(S.events)}function u(S){a.push(S)}function d(S){a.length>0&&(i(a),a=[])}function l(S){let x=e.get(S);if(!x||x.length===0)return;let g=[...x].sort((D,v)=>D-v),E=g.reduce((D,v)=>D+v,0)/g.length,C=g.reduce((D,v)=>D+(v-E)**2,0)/g.length,N=t.get(S)??{retried:0,total:1},L=r.get(S)??{errors:0,total:1},P=o.get(S)??{timedOut:0,total:1};return{nodeId:S,avgDurationMs:E,minDurationMs:g[0],maxDurationMs:g[g.length-1],stdDevMs:Math.sqrt(C),samples:g.length,retryRate:N.total>0?N.retried/N.total:0,timeoutRate:P.total>0?P.timedOut/P.total:0,errorRate:L.total>0?L.errors/L.total:0,percentiles:{p50:Ce(g,.5),p90:Ce(g,.9),p95:Ce(g,.95),p99:Ce(g,.99)}}}function p(S){return l(S)}function f(S,x="duration"){let g=new Map,y=qe(S.root.children),E=[];for(let v of y){let O=("key"in v?v.key:void 0)??v.id??v.name,q=l(O);if(q){let oe;switch(x){case"duration":oe=q.avgDurationMs;break;case"retryRate":oe=q.retryRate;break;case"errorRate":oe=q.errorRate;break}E.push({id:v.id,value:oe})}}if(E.length===0)return{heat:g,metric:x,stats:{min:0,max:0,mean:0,threshold:0}};let C=E.map(v=>v.value),N=Math.min(...C),L=Math.max(...C),P=C.reduce((v,O)=>v+O,0)/C.length,D=L-N||1;for(let{id:v,value:O}of E)g.set(v,(O-N)/D);return{heat:g,metric:x,stats:{min:N,max:L,mean:P,threshold:P+(L-P)*.5}}}function m(){let S=new Map;for(let x of e.keys()){let g=l(x);g&&S.set(x,g)}return S}function w(S=10){return[...m().values()].sort((g,y)=>y.avgDurationMs-g.avgDurationMs).slice(0,S)}function k(S=10){return[...m().values()].filter(g=>g.errorRate>0).sort((g,y)=>y.errorRate-g.errorRate).slice(0,S)}function T(S=10){return[...m().values()].filter(g=>g.retryRate>0).sort((g,y)=>y.retryRate-g.retryRate).slice(0,S)}function $(){return JSON.stringify({timingData:Object.fromEntries(e),retryData:Object.fromEntries(t),errorData:Object.fromEntries(r),timeoutData:Object.fromEntries(o)})}function M(S){let x=JSON.parse(S);e.clear(),t.clear(),r.clear(),o.clear();for(let[g,y]of Object.entries(x.timingData??{}))e.set(g,y);for(let[g,y]of Object.entries(x.retryData??{}))t.set(g,y);for(let[g,y]of Object.entries(x.errorData??{}))r.set(g,y);for(let[g,y]of Object.entries(x.timeoutData??{}))o.set(g,y)}function I(){e.clear(),t.clear(),r.clear(),o.clear(),a=[]}return{addRun:s,addEvent:u,finalizeRun:d,getNodePerformance:p,getHeatmap:f,getSlowestNodes:w,getErrorProneNodes:k,getRetryProneNodes:T,getAllPerformance:m,exportData:$,importData:M,clear:I}}function Rr(){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 Er(){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 $r(e){return`heat_${e}`}function Tr(){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 Mr(e){try{return(0,We.ok)(JSON.stringify(e,(r,o)=>{if(typeof o!="bigint")return o;let a=Number(o);return Number.isSafeInteger(a)?a:o.toString()}))}catch{return(0,We.err)("STRINGIFY_ERROR")}}function ht(e){let t=Mr(e);return t.ok?t.value:"[unserializable]"}function Nr(e,t,r){let o;if(e.shouldRun){let a="hook_shouldRun",n=e.shouldRun.state==="success"?"hook_success":"hook_error",i=e.shouldRun.state==="success"?"\u2699":"\u26A0",s=r.showTimings&&e.shouldRun.durationMs!==void 0?` ${H(e.shouldRun.durationMs)}`:"",u=e.shouldRun.context?.skipped?"\\nskipped workflow":e.shouldRun.context?.result===!0?"\\nproceed":"";t.push(` ${a}[["${i} shouldRun${u}${s}"]]:::${n}`),o=a}if(e.onBeforeStart){let a="hook_beforeStart",n=e.onBeforeStart.state==="success"?"hook_success":"hook_error",i=e.onBeforeStart.state==="success"?"\u2699":"\u26A0",s=r.showTimings&&e.onBeforeStart.durationMs!==void 0?` ${H(e.onBeforeStart.durationMs)}`:"",u=e.onBeforeStart.context?.skipped?"\\nskipped workflow":"";t.push(` ${a}[["${i} onBeforeStart${u}${s}"]]:::${n}`),o&&t.push(` ${o} --> ${a}`),o=a}return{lastHookId:o}}var gt=0,Le=new Set,_e=new Set;function ge(e="node"){return`${e}_${++gt}`}function Or(){gt=0,Le.clear(),_e.clear()}function V(e){return e.replace(/"/g,"#quot;").replace(/</g,"<").replace(/>/g,">").trim()}function bt(e){return V(e).replace(/[{}[\]()]/g,"")}function ie(){return{name:"mermaid",supportsLive:!1,render(e,t){Or();let r=[],o=t;r.push("flowchart TD");let a;e.hooks&&(a=Nr(e.hooks,r,t).lastHookId);let n="start";r.push(` ${n}(("\u25B6 Start"))`),a&&r.push(` ${a} --> ${n}`);let i=n;for(let u of e.root.children){let d=Be(u,t,r,o,e.hooks);r.push(` ${i} --> ${d.entryId}`),i=d.exitId}if(["success","error","aborted"].includes(e.root.state)){let u="finish",d=e.root.state==="success"?"\u2713":e.root.state==="error"?"\u2717":"\u2298",l=e.root.state==="success"?"Done":e.root.state==="error"?"Failed":"Cancelled",p=`(("${d} ${l}"))`,f=e.root.state==="success"?":::success":e.root.state==="error"?":::error":":::aborted";r.push(` ${u}${p}${f}`),r.push(` ${i} --> ${u}`)}return r.push(""),r.push(...Rr()),o.showHeatmap&&r.push(...Er()),e.hooks&&r.push(...Tr()),r.join(`
|
|
3
|
+
`)}}}function Be(e,t,r,o,a){if(j(e))return Dr(e,t,r,o,a);if(G(e))return Cr(e,t,r,o,a);if(U(e))return Lr(e,t,r,o,a);if(J(e))return _r(e,t,r,o,a);if(re(e))return Wr(e,t,r);let n=ge("unknown");return r.push(` ${n}["Unknown Node"]`),{entryId:n,exitId:n}}function Dr(e,t,r,o,a){let n=t,i=n.showRetryEdges??!0,s=n.showErrorEdges??!0,u=n.showTimeoutEdges??!0,d=e.key?`step_${e.key.replace(/[^a-zA-Z0-9]/g,"_")}`:ge("step");if(_e.has(d)){let g=2;for(;_e.has(`${d}_${g}`);)g++;d=`${d}_${g}`}_e.add(d);let l=e.name??e.key??"Step",p=t.showKeys&&e.key&&e.name?`${l} [${e.key}]`:l,f=V(p),m=t.showTimings&&e.durationMs!==void 0?` ${H(e.durationMs)}`:"",w="";switch(e.state){case"success":w="\u2713 ";break;case"error":w="\u2717 ";break;case"cached":w="\u{1F4BE} ";break;case"running":w="\u23F3 ";break;case"skipped":w="\u2298 ";break}let k="";if(e.input!==void 0){let g=typeof e.input=="string"?V(e.input):V(ht(e.input).slice(0,20));k+=`\\nin: ${g}`}if(e.output!==void 0&&e.state==="success"){let g=typeof e.output=="string"?V(e.output):V(ht(e.output).slice(0,20));k+=`\\nout: ${g}`}let T="",$=e.key??e.id;if(a&&$&&a.onAfterStep.has($)){let g=a.onAfterStep.get($),y=g.state==="success"?"\u2699":"\u26A0",E=t.showTimings&&g.durationMs!==void 0?` ${H(g.durationMs)}`:"";T=`\\n${y} hook${E}`}let M=(w+f+k+T+m).trim(),I,S=o?.showHeatmap&&o.heatmapData?o.heatmapData.heat.get(e.key??"")??o.heatmapData.heat.get(e.name??"")??o.heatmapData.heat.get(e.id):void 0;if(S!==void 0){let g=he(S);I=$r(g)}else I=e.state;let x;switch(e.state){case"error":x=`{{"${M}"}}`;break;case"cached":x=`[("${M}")]`;break;case"skipped":x=`["${M}"]`;break;default:x=`["${M}"]`}if(r.push(` ${d}${x}:::${I}`),i&&e.retryCount!==void 0&&e.retryCount>0){let g=`\u21BB ${e.retryCount} retr${e.retryCount===1?"y":"ies"}`;r.push(` ${d} -.->|"${g}"| ${d}`)}if(s&&e.state==="error"&&e.error!==void 0){let g=`ERR_${d}`,y=V(String(e.error)).slice(0,30);r.push(` ${g}{{"${y}"}}`),r.push(` ${d} -->|error| ${g}`),r.push(` style ${g} fill:#fee2e2,stroke:#dc2626`)}if(u&&e.timedOut){let g=`TO_${d}`,y=e.timeoutMs!==void 0?`${e.timeoutMs}ms`:"";r.push(` ${g}{{"\u23F1 Timeout ${y}"}}`),r.push(` ${d} -.->|timeout| ${g}`),r.push(` style ${g} fill:#fef3c7,stroke:#f59e0b`)}return{entryId:d,exitId:d}}function Cr(e,t,r,o,a){let n=ge("parallel"),i=`${n}_fork`,s=`${n}_join`,u=bt(e.name??"Parallel"),d=e.mode==="allSettled"?" (allSettled)":"";if(e.children.length===0){let f=n,m=V(`${u}${d}`),w="operations not individually tracked",k=t.showTimings&&e.durationMs!==void 0?` ${H(e.durationMs)}`:"";return r.push(` ${f}["${m}${k}\\n${w}"]:::${e.state}`),{entryId:f,exitId:f}}r.push(` subgraph ${n}["${u}${d}"]`),r.push(" direction TB"),r.push(` ${i}{"\u26A1 Fork"}`);let l=[];for(let f of e.children){let m=Be(f,t,r,o,a);r.push(` ${i} --> ${m.entryId}`),l.push(m.exitId)}r.push(` ${s}{"\u2713 Join"}`);for(let f of l)r.push(` ${f} --> ${s}`);r.push(" end");let p=e.state;return r.push(` class ${n} ${p}`),{entryId:i,exitId:s}}function Lr(e,t,r,o,a){let n=ge("race"),i=`${n}_start`,s=`${n}_end`,u=bt(e.name??"Race");if(e.children.length===0){let f=n,m=V(u),w="operations not individually tracked",k=t.showTimings&&e.durationMs!==void 0?` ${H(e.durationMs)}`:"";return r.push(` ${f}["\u26A1 ${m}${k}\\n${w}"]:::${e.state}`),{entryId:f,exitId:f}}r.push(` subgraph ${n}["\u26A1 ${u}"]`),r.push(" direction TB"),r.push(` ${i}(("\u{1F3C1} Start"))`);let d=[],l;for(let f of e.children){let m=Be(f,t,r,o,a),w=e.winnerId===f.id;r.push(` ${i} --> ${m.entryId}`),w&&(l=m.exitId),d.push({exitId:m.exitId,isWinner:w})}r.push(` ${s}(("\u2713 First"))`);for(let{exitId:f,isWinner:m}of d)m&&l?r.push(` ${f} ==>|\u{1F3C6} Winner| ${s}`):e.winnerId?r.push(` ${f} -. cancelled .-> ${s}`):r.push(` ${f} --> ${s}`);r.push(" end");let p=e.state;return r.push(` class ${n} ${p}`),{entryId:i,exitId:s}}function _r(e,t,r,o,a){let n=e.key?`decision_${e.key.replace(/[^a-zA-Z0-9]/g,"_")}`:ge("decision");if(Le.has(n)){let f=2;for(;Le.has(`${n}_${f}`);)f++;n=`${n}_${f}`}Le.add(n);let i=V(e.condition??"condition"),s=e.decisionValue!==void 0?` = ${V(String(e.decisionValue)).slice(0,30)}`:"",u=`${i}${s}`.trim();r.push(` ${n}{"${u}"}`);let d=[],l,p=new Set;for(let f of e.branches){let m=`${n}_${f.label.replace(/[^a-zA-Z0-9]/g,"_")}`;if(p.has(m)){let M=2;for(;p.has(`${m}_${M}`);)M++;m=`${m}_${M}`}p.add(m);let w=V(f.label),k=f.taken?`${w} \u2713`:`${w} skipped`,T=f.taken?":::success":":::skipped";r.push(` ${m}["${k}"]${T}`);let $=f.condition?`|${V(f.condition).replace(/\|/g,"")}|`:"";if(r.push(` ${n} -->${$} ${m}`),f.children.length>0){let M=m;for(let I of f.children){let S=Be(I,t,r,o,a);r.push(` ${M} --> ${S.entryId}`),M=S.exitId}d.push(M),f.taken&&(l=M)}else d.push(m),f.taken&&(l=m)}return l?{entryId:n,exitId:l}:{entryId:n,exitId:n}}function Wr(e,t,r){let o=`stream_${e.namespace.replace(/[^a-zA-Z0-9]/g,"_")}_${ge("")}`,a=`W:${e.writeCount} R:${e.readCount}`,n="";switch(e.streamState){case"active":n="\u27F3 ";break;case"closed":n="\u2713 ";break;case"error":n="\u2717 ";break}let i=t.showTimings&&e.durationMs!==void 0?` ${H(e.durationMs)}`:"",s=e.backpressureOccurred?"\\nbackpressure":"",u=`${n}stream:${V(e.namespace)}\\n${a}${s}${i}`,d;return e.streamState==="error"?d="streamError":e.streamState==="active"?d="streamActive":d="stream",r.push(` ${o}{{"${u}"}}:::${d}`),{entryId:o,exitId:o}}var B={topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502",teeDown:"\u252C",teeUp:"\u2534",teeRight:"\u251C",teeLeft:"\u2524",cross:"\u253C",arrowDown:"\u25BC",arrowUp:"\u25B2"},Br={cold:"\x1B[34m",cool:"\x1B[36m",neutral:"",warm:"\x1B[33m",hot:"\x1B[31m",critical:"\x1B[41m"},Ar="\x1B[0m";function Pr(e,t){let r=[],o=[];for(let a=0;a<t;a++)r.push(Array(e).fill(" ")),o.push(Array(e).fill(void 0));return{cells:r,colors:o,width:e,height:t}}function A(e,t,r,o,a){t>=0&&t<e.width&&r>=0&&r<e.height&&(e.cells[r][t]=o,a&&(e.colors[r][t]=a))}function vt(e,t,r){return t>=0&&t<e.width&&r>=0&&r<e.height?e.cells[r][t]:" "}function Hr(e,t,r,o,a){A(e,t,r,B.topLeft);for(let n=1;n<o-1;n++)A(e,t+n,r,B.horizontal);A(e,t+o-1,r,B.topRight);for(let n=1;n<a-1;n++)A(e,t,r+n,B.vertical),A(e,t+o-1,r+n,B.vertical);A(e,t,r+a-1,B.bottomLeft);for(let n=1;n<o-1;n++)A(e,t+n,r+a-1,B.horizontal);A(e,t+o-1,r+a-1,B.bottomRight)}function wt(e,t,r,o,a){let n=ne(o).split("");for(let i=0;i<n.length;i++)A(e,t+i,r,n[i],a)}function se(e,t,r,o){let a=Math.min(r,o),n=Math.max(r,o);for(let i=a;i<=n;i++){let s=vt(e,t,i);s===B.horizontal?A(e,t,i,B.cross):(s===" "||s===B.vertical)&&A(e,t,i,B.vertical)}}function yt(e,t,r,o){let a=Math.min(r,o),n=Math.max(r,o);for(let i=a;i<=n;i++){let s=vt(e,i,t);s===B.vertical?A(e,i,t,B.cross):(s===" "||s===B.horizontal)&&A(e,i,t,B.horizontal)}}function pe(e,t,r){A(e,t,r,B.arrowDown)}function Fr(e){let t=[];for(let r=0;r<e.height;r++){let o="";for(let a=0;a<e.width;a++){let n=e.colors[r][a],i=e.cells[r][a];n?o+=n+i+Ar:o+=i}t.push(o.trimEnd())}for(;t.length>0&&t[t.length-1]==="";)t.pop();return t.join(`
|
|
4
|
+
`)}var Q=11,ee=2,be=2,Ae=3;function Ze(e,t){if(e.length<=t)return[e];let r=e.split(" "),o=[],a="";for(let n of r)a?a.length+1+n.length<=t?a+=" "+n:(o.push(a),a=n):a=n;if(a&&o.push(a),o.length===0)for(let n=0;n<e.length;n+=t)o.push(e.slice(n,n+t));return o}function kt(e){switch(e){case"success":return"\u2713";case"error":return"\u2717";case"running":return"\u27F3";case"pending":return"\u25CB";case"aborted":case"skipped":return"\u2298";case"cached":return"\u21BA";default:return"\u25CB"}}function Ur(e,t,r){let o=t.showStartEnd??!0,a=t,n=Math.floor(r/2),i=[],s=0;if(o){let d=Pe("start","start",["\u25B6 Start"],"success",n,s);i.push(d),s=d.bottomY+be}for(let d of e.root.children){let l=He(d,n,s,r-4,t,a);i.push(l.node),s=l.bottomY+be}if(o&&["success","error","aborted"].includes(e.root.state)){let d=e.root.state==="success"?"\u2713 Done":e.root.state==="error"?"\u2717 Failed":"\u2298 Cancelled",l=Pe("end","end",[d],e.root.state,n,s);i.push(l),s=l.bottomY}return{nodes:i,totalHeight:s+2}}function Pe(e,t,r,o,a,n){let i=Math.max(...r.map(l=>ne(l).length)),s=Math.max(Q,i+ee*2),u=r.length+2,d=a-Math.floor(s/2);return{id:e,type:t,label:r,state:o,x:d,y:n,width:s,height:u,centerX:a,bottomY:n+u-1}}function He(e,t,r,o,a,n){if(j(e))return zr(e,t,r,o,a,n);if(G(e)||U(e))return jr(e,t,r,o,a,n);if(J(e))return Vr(e,t,r,o,a,n);if(re(e))return Kr(e,t,r,o,a,n);let i=Pe(e.id,"step",["?"],e.state,t,r);return{node:i,bottomY:i.bottomY}}function zr(e,t,r,o,a,n){let i=e.name??e.key??"step",s=kt(e.state),u=[],d=`${s} ${i}`;a.showKeys&&e.key&&e.name&&(d+=` [${e.key}]`);let l=Math.min(o-ee*2,40);if(u.push(...Ze(d,l)),a.showTimings&&e.durationMs!==void 0&&u.push(`[${H(e.durationMs)}]`),e.retryCount&&e.retryCount>0&&u.push(`${e.retryCount}x retry`),e.timedOut&&u.push("timeout"),n?.showSparklines&&n.timingHistory){let $=n.timingHistory.get(e.key??"")??n.timingHistory.get(e.name??"")??n.timingHistory.get(e.id);$&&$.length>1&&u.push(Ye($,8))}let p=Math.max(...u.map($=>ne($).length)),f=Math.max(Q,p+ee*2),m=u.length+2,w=t-Math.floor(f/2),k;if(n?.showHeatmap&&n.heatmapData){let $=e.key??e.name??e.id;k=n.heatmapData.heat.get(e.id)??n.heatmapData.heat.get($)}let T={id:e.id,type:"step",label:u,state:e.state,x:w,y:r,width:f,height:m,centerX:t,bottomY:r+m-1,metadata:k!==void 0?{heat:k}:void 0};return{node:T,bottomY:T.bottomY}}function Kr(e,t,r,o,a,n){let i=`stream:${e.namespace}`,s=e.streamState==="active"?"\u27F3":e.streamState==="closed"?"\u2713":"\u2717",u=[],d=`${s} ${i}`,l=Math.min(o-ee*2,40);u.push(...Ze(d,l)),u.push(`W:${e.writeCount} R:${e.readCount}`),a.showTimings&&e.durationMs!==void 0&&u.push(`[${H(e.durationMs)}]`),e.backpressureOccurred&&u.push("backpressure");let p=Math.max(...u.map(T=>ne(T).length)),f=Math.max(Q,p+ee*2),m=u.length+2,w=t-Math.floor(f/2),k={id:e.id,type:"stream",label:u,state:e.state,x:w,y:r,width:f,height:m,centerX:t,bottomY:r+m-1,metadata:{streamState:e.streamState,backpressureOccurred:e.backpressureOccurred}};return{node:k,bottomY:k.bottomY}}function jr(e,t,r,o,a,n){let i=U(e),s=e.name??(i?"race":"parallel"),d=`${i?"\u26A1":"\u2AD8"} ${s}`;if(e.children.length===0){let y=[d,"(not tracked)"],E=Pe(e.id,i?"race":"parallel",y,e.state,t,r);return{node:E,bottomY:E.bottomY}}let l=Math.floor((o-Ae*(e.children.length-1))/e.children.length),p=[];for(let y of e.children){let E=Xe(y,Math.max(l,Q),a,n);p.push(E.width)}let f=p.reduce((y,E)=>y+E,0)+Ae*(e.children.length-1),m=f>o&&e.children.length>1,w=Math.max(Q,d.length+ee*2),k=3,T=t-Math.floor(w/2),$=r;$+=k,$+=1,$+=1;let M=[];if(m)for(let y=0;y<e.children.length;y++){let E=e.children[y],C=He(E,t,$,o,a,n);i&&U(e)&&e.winnerId===E.id&&(C.node.metadata={...C.node.metadata,isWinner:!0}),M.push(C.node),$=C.bottomY+be}else{let y=t-Math.floor(f/2);for(let E=0;E<e.children.length;E++){let C=e.children[E],N=y+Math.floor(p[E]/2),L=He(C,N,$,p[E],a,n);i&&U(e)&&e.winnerId===C.id&&(L.node.metadata={...L.node.metadata,isWinner:!0}),M.push(L.node),y+=p[E]+Ae}}let I=Math.max(...M.map(y=>y.bottomY)),x=!m&&M.length>1?I+2:I;return{node:{id:e.id,type:i?"race":"parallel",label:[d],state:e.state,x:T,y:r,width:w,height:k,centerX:t,bottomY:x,children:M,metadata:{verticalLayout:m}},bottomY:x}}function Vr(e,t,r,o,a,n){let i=e.name??"decision",s=e.condition?` (${e.condition.slice(0,20)})`:"",u=`\u25C7 ${i}${s}`,d=Math.min(o-ee*2,40),l=Ze(u,d),p=Math.max(...l.map(x=>ne(x).length)),f=Math.max(Q,p+ee*2),m=l.length+2,w=t-Math.floor(f/2),k=e.branches.find(x=>x.taken),T=k&&k.children.length>0?k:e.branches.find(x=>x.children.length>0);if(!T||T.children.length===0){let x={id:e.id,type:"decision",label:l,state:e.state,x:w,y:r,width:f,height:m,centerX:t,bottomY:r+m-1};return{node:x,bottomY:x.bottomY}}let $=r+m+be,M=[];for(let x of T.children){let g=He(x,t,$,o,a,n);M.push(g.node),$=g.bottomY+be}let I=M.length>0?M[M.length-1].bottomY:r+m-1;return{node:{id:e.id,type:"decision",label:l,state:e.state,x:w,y:r,width:f,height:m,centerX:t,bottomY:I,children:M},bottomY:I}}function Xe(e,t,r,o){if(j(e)){let a=e.name??e.key??"step",n=kt(e.state),i=1;r.showTimings&&e.durationMs!==void 0&&i++,e.retryCount&&e.retryCount>0&&i++,e.timedOut&&i++,o?.showSparklines&&(o.timingHistory?.has(e.key??"")||o.timingHistory?.has(e.name??"")||o.timingHistory?.has(e.id))&&i++;let s=`${n} ${a}`;r.showKeys&&e.key&&e.name&&(s+=` [${e.key}]`);let u=Math.min(t,Math.max(Q,s.length+ee*2)),d=i+2;return{width:u,height:d}}if(G(e)||U(e)){if(e.children.length===0)return{width:Q+4,height:4};let a=Math.floor(t/e.children.length),n=0,i=0;for(let s of e.children){let u=Xe(s,a,r,o);n+=u.width,i=Math.max(i,u.height)}return n+=Ae*(e.children.length-1),{width:Math.max(n,Q),height:5+i+2}}if(J(e)){let a=e.branches.find(i=>i.taken),n=0;if(a)for(let i of a.children){let s=Xe(i,t,r,o);n+=s.height+be}return{width:Math.min(t,30),height:3+n}}if(re(e)){let a=`stream:${e.namespace}`,n=2;r.showTimings&&e.durationMs!==void 0&&n++,e.backpressureOccurred&&n++;let i=Math.min(t,Math.max(Q,a.length+ee*2+4)),s=n+2;return{width:i,height:s}}return{width:Q,height:3}}function Gr(e,t,r){let o={...z,...r.colors};for(let a=0;a<t.length;a++){let n=t[a],i=a===t.length-1;if(Fe(e,n,o),!i){let s=t[a+1],u=n.centerX,d=n.bottomY+1,l=s.centerX,p=s.y-1;se(e,u,d,p-1),pe(e,l,p)}}}function Fe(e,t,r){let o=t.type!=="start",a=t.type!=="end"&&(!t.children||t.children.length===0);Hr(e,t.x,t.y,t.width,t.height),o&&A(e,t.centerX,t.y,B.teeUp),(a||t.children&&t.children.length>0)&&A(e,t.centerX,t.y+t.height-1,B.teeDown);let n=t.width-ee*2,i=Xr(t,r);for(let s=0;s<t.label.length;s++){let u=t.label[s],d=t.x+1+Math.floor((n-ne(u).length)/2),l=t.y+1+s;wt(e,d,l,u,i)}t.metadata?.isWinner&&wt(e,t.x+t.width-2,t.y,"\u{1F3C6}"),t.children&&t.children.length>0&&(t.type==="parallel"||t.type==="race"?Yr(e,t,r):Jr(e,t,r))}function Yr(e,t,r){let o=t.children;if(o.length===0)return;let a=t.y+t.height,n=t.centerX;if(t.metadata?.verticalLayout===!0){let s=o[0];se(e,n,a,s.y-2),pe(e,s.centerX,s.y-1);for(let u=0;u<o.length;u++){let d=o[u];if(Fe(e,d,r),u<o.length-1){let l=o[u+1];se(e,d.centerX,d.bottomY+1,l.y-2),pe(e,l.centerX,l.y-1)}}return}if(o.length===1)se(e,n,a,o[0].y-2),pe(e,o[0].centerX,o[0].y-1);else{let s=o.map(l=>l.centerX),u=Math.min(...s),d=Math.max(...s);se(e,n,a,a+1),yt(e,a+1,u,d),A(e,n,a+1,B.teeUp);for(let l of o){let p=l.centerX;p===u?A(e,p,a+1,B.topLeft):p===d?A(e,p,a+1,B.topRight):p!==n&&A(e,p,a+1,B.teeDown),se(e,p,a+2,l.y-2),pe(e,p,l.y-1)}}for(let s of o)Fe(e,s,r);if(o.length>1){let s=o.map(m=>m.bottomY),u=Math.max(...s),d=u+1,l=o.map(m=>m.centerX),p=Math.min(...l),f=Math.max(...l);for(let m of o)m.bottomY<u&&se(e,m.centerX,m.bottomY+1,d-1);yt(e,d,p,f);for(let m of o){let w=m.centerX;w===p?A(e,w,d,B.bottomLeft):w===f?A(e,w,d,B.bottomRight):A(e,w,d,B.teeUp)}A(e,t.centerX,d,B.teeDown),A(e,t.centerX,d+1,B.vertical)}}function Jr(e,t,r){let o=t.children;if(o.length===0)return;let a=t.y+t.height,n=o[0];se(e,t.centerX,a,n.y-2),pe(e,n.centerX,n.y-1);for(let i=0;i<o.length;i++){let s=o[i];if(Fe(e,s,r),i<o.length-1){let u=o[i+1];se(e,s.centerX,s.bottomY+1,u.y-2),pe(e,u.centerX,u.y-1)}}}var qr={active:"\x1B[36m",closed:"\x1B[32m",error:"\x1B[31m"};function Xr(e,t){if(e.metadata?.heat!==void 0){let r=he(e.metadata.heat);return Br[r]||void 0}return e.type==="stream"&&e.metadata?.streamState?qr[e.metadata.streamState]||void 0:t[e.state]||void 0}function me(){return{name:"flowchart",supportsLive:!1,render(e,t){let r=t.terminalWidth??80,{nodes:o,totalHeight:a}=Ur(e,t,r),n=Pr(r,a);return Gr(n,o,t),Fr(n)}}}function Zr(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}function Qr(e){let t=[];function r(o){for(let a of o)if(j(a))t.push(a);else if(je(a))r(a.children);else if(G(a)||U(a))r(a.children);else if(J(a))for(let n of a.branches)n.taken&&r(n.children)}return r(e),t}function en(e){let t={id:e.id,name:e.name??e.key??e.id,state:e.state};return e.key&&(t.key=e.key),e.durationMs!==void 0&&(t.durationMs=e.durationMs),e.startTs!==void 0&&(t.startTs=e.startTs),e.endTs!==void 0&&(t.endTs=e.endTs),e.retryCount!==void 0&&e.retryCount>0&&(t.retryCount=e.retryCount),e.timedOut&&(t.timedOut=!0,e.timeoutMs!==void 0&&(t.timeoutMs=e.timeoutMs)),e.error!==void 0&&(t.error=typeof e.error=="string"?e.error:String(e.error)),t}function tn(e){let t=0,r=0,o=0,a=0,n=0,i;for(let s of e)s.state==="success"&&t++,s.state==="error"&&r++,s.state==="cached"&&o++,s.state==="skipped"&&a++,s.retryCount!==void 0&&(n+=s.retryCount),s.durationMs!==void 0&&(!i||s.durationMs>i.durationMs)&&(i={name:s.name??s.key??s.id,durationMs:s.durationMs});return{totalSteps:e.length,successCount:t,errorCount:r,cacheHits:o,skippedCount:a,totalRetries:n,slowestStep:i}}function rn(e){let t={};if(e.shouldRun&&(t.shouldRun={result:e.shouldRun.context?.result,durationMs:e.shouldRun.durationMs},e.shouldRun.error!==void 0&&e.shouldRun.error!==null&&(t.shouldRun.error=String(e.shouldRun.error))),e.onBeforeStart&&(t.onBeforeStart={durationMs:e.onBeforeStart.durationMs},e.onBeforeStart.error!==void 0&&e.onBeforeStart.error!==null&&(t.onBeforeStart.error=String(e.onBeforeStart.error))),e.onAfterStep.size>0){t.onAfterStep=[];for(let[r,o]of e.onAfterStep){let a={stepKey:r};o.durationMs!==void 0&&(a.durationMs=o.durationMs),o.error!==void 0&&o.error!==null&&(a.error=String(o.error)),t.onAfterStep.push(a)}}return t}function nn(e,t){let r=e.root,o=Qr(r.children),a=t.includeDiagram??!0,n=t.stripAnsiColors??!0,i={workflow:{id:r.workflowId,name:r.name,state:r.state,durationMs:r.durationMs,startedAt:r.startTs,completedAt:r.endTs},steps:o.map(en),summary:tn(o)};if(e.hooks){let s=rn(e.hooks);Object.keys(s).length>0&&(i.hooks=s)}if(a){let d=((t.diagramFormat??"ascii")==="flowchart"?me():ae()).render(e,t);n&&(d=Zr(d)),i.diagram=d}return i}function Re(){return{name:"logger",supportsLive:!1,render(e,t){let o=nn(e,t);return JSON.stringify(o)}}}var te=require("awaitly");var xt=or(require("pako"),1),on=typeof globalThis<"u"&&"Buffer"in globalThis&&typeof globalThis.Buffer=="function";function an(e){let t;if(on)t=globalThis.Buffer.from(e).toString("base64");else{let r="";for(let o=0;o<e.length;o++)r+=String.fromCharCode(e[o]);t=btoa(r)}return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Ue(e){let r=new TextEncoder().encode(e),o=xt.default.deflate(r);return an(o)}var St="https://kroki.io";function Qe(e,t,r,o={}){let a=o.baseUrl??St,n=Ue(r);return`${a}/${e}/${t}/${n}`}function ce(e,t="svg",r={}){let o=ie(),a={showTimings:!0,showKeys:!1,terminalWidth:80,colors:z},n=o.render(e,a);return Qe("mermaid",t,n,r)}function It(e,t={}){return ce(e,"svg",t)}function Rt(e,t={}){return ce(e,"png",t)}function Et(e={}){let t=e.baseUrl??St;return{toUrl(r,o){return ce(r,o,{baseUrl:t})},toSvgUrl(r){return ce(r,"svg",{baseUrl:t})},toPngUrl(r){return ce(r,"png",{baseUrl:t})},toPdfUrl(r){return ce(r,"pdf",{baseUrl:t})},getBaseUrl(){return t}}}var $t="https://mermaid.ink";function et(e){return`pako:${Ue(e)}`}function sn(e){if("provider"in e){let t=e;return{theme:t.mermaidTheme,bgColor:t.background,scale:t.scale,fit:t.fit,width:t.width,height:t.height,paper:t.paper,imageType:"png"}}return e}function dn(e,t){let r=[];return t.bgColor&&r.push(`bgColor=${encodeURIComponent(t.bgColor)}`),t.theme&&r.push(`theme=${t.theme}`),t.width!==void 0&&r.push(`width=${t.width}`),t.height!==void 0&&r.push(`height=${t.height}`),t.scale!==void 0&&(t.width!==void 0||t.height!==void 0)&&r.push(`scale=${t.scale}`),e==="img"&&t.imageType&&t.imageType!=="jpeg"&&r.push(`type=${t.imageType}`),e==="pdf"&&(t.fit&&r.push("fit"),t.paper&&!t.fit&&r.push(`paper=${t.paper}`),t.landscape&&!t.fit&&r.push("landscape")),r.length>0?`?${r.join("&")}`:""}function Ee(e,t,r={}){let o=sn(r),a=o.baseUrl??$t,n=et(t),i=dn(e,o);return`${a}/${e}/${n}${i}`}function Y(e,t="svg",r={}){let o=ie(),a={showTimings:!0,showKeys:!1,terminalWidth:80,colors:z},n=o.render(e,a);return Ee(t,n,r)}function Tt(e,t={}){return Y(e,"svg",t)}function Mt(e,t={}){return Y(e,"img",{...t,imageType:"png"})}function Nt(e,t={}){return Y(e,"img",{...t,imageType:"jpeg"})}function Ot(e,t={}){return Y(e,"img",{...t,imageType:"webp"})}function Dt(e,t={}){return Y(e,"pdf",t)}function Ct(e={}){let t=e.baseUrl??$t;return{toUrl(r,o){return Y(r,o,e)},toSvgUrl(r){return Y(r,"svg",e)},toPngUrl(r){return Y(r,"img",{...e,imageType:"png"})},toJpegUrl(r){return Y(r,"img",{...e,imageType:"jpeg"})},toWebpUrl(r){return Y(r,"img",{...e,imageType:"webp"})},toPdfUrl(r){return Y(r,"pdf",e)},getBaseUrl(){return t},getOptions(){return{...e}}}}function cn(e,t,r){return e==="mermaid-ink"&&t==="mermaid"?(0,te.ok)(void 0):e==="kroki"&&t==="mermaid"?r==="pdf"?(0,te.err)("UNSUPPORTED_FORMAT"):(0,te.ok)(void 0):(0,te.err)("UNSUPPORTED_FORMAT")}function ln(e){switch(e){case"mermaid":return"mermaid";case"graphviz":return"graphviz";case"plantuml":return"plantuml"}}function un(e){switch(e){case"svg":return"svg";case"png":return"img";case"pdf":return"pdf"}}function we(e,t,r,o={}){switch(e.kind){case"mermaid":break;case"graphviz":case"plantuml":return(0,te.err)("UNSUPPORTED_DIAGRAM_KIND");default:{let n=e;return(0,te.err)("UNSUPPORTED_DIAGRAM_KIND")}}let a=cn(r.provider,e.kind,t);if(!a.ok)return a;switch(r.provider){case"kroki":return(0,te.ok)(Qe(ln(e.kind),t,e.source,r));case"mermaid-ink":return(0,te.ok)(Ee(un(t),e.source,r));default:{let n=r;return(0,te.err)("UNKNOWN_PROVIDER")}}}function Lt(e){let t={bg:"#ffffff",bgSecondary:"#f8f9fa",text:"#212529",textMuted:"#6c757d",border:"#dee2e6",primary:"#0d6efd",success:"#198754",error:"#dc3545",warning:"#ffc107",info:"#0dcaf0",muted:"#6c757d",nodePending:"#e9ecef",nodeRunning:"#fff3cd",nodeSuccess:"#d1e7dd",nodeError:"#f8d7da",nodeAborted:"#e9ecef",nodeCached:"#cfe2ff",nodeSkipped:"#f8f9fa",heatCold:"#0d6efd",heatCool:"#0dcaf0",heatNeutral:"#6c757d",heatWarm:"#ffc107",heatHot:"#fd7e14",heatCritical:"#dc3545"},r={bg:"#212529",bgSecondary:"#343a40",text:"#f8f9fa",textMuted:"#adb5bd",border:"#495057",primary:"#0d6efd",success:"#198754",error:"#dc3545",warning:"#ffc107",info:"#0dcaf0",muted:"#6c757d",nodePending:"#495057",nodeRunning:"#664d03",nodeSuccess:"#0f5132",nodeError:"#842029",nodeAborted:"#495057",nodeCached:"#084298",nodeSkipped:"#343a40",heatCold:"#0d6efd",heatCool:"#0dcaf0",heatNeutral:"#6c757d",heatWarm:"#ffc107",heatHot:"#fd7e14",heatCritical:"#dc3545"},o=n=>`
|
|
5
5
|
--bg: ${n.bg};
|
|
6
6
|
--bg-secondary: ${n.bgSecondary};
|
|
7
7
|
--text: ${n.text};
|
|
@@ -1673,10 +1673,10 @@ body {
|
|
|
1673
1673
|
</script>
|
|
1674
1674
|
<script>${d}</script>
|
|
1675
1675
|
</body>
|
|
1676
|
-
</html>`}function ot(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ht(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function bn(e,t){return e.length<=t?e:e.slice(0,t-1)+"\u2026"}function wn(e){if(!e.hooks)return e;let t=e.hooks.onAfterStep instanceof Map?Object.fromEntries(e.hooks.onAfterStep):e.hooks.onAfterStep;return{...e,hooks:{...e.hooks,onAfterStep:t}}}function Wt(e){let t=new WeakSet;return JSON.stringify(e,(o,a)=>{if(typeof a=="bigint")return a.toString();if(o==="error"&&a!==void 0&&a!==null)return String(a);if(typeof a=="object"&&a!==null){if(t.has(a))return"[Circular]";t.add(a)}return a}).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}var Ft={interactive:!0,timeTravel:!0,heatmap:!0,animationDuration:200,theme:"auto",layout:"TB"};function Ut(){return{name:"html",supportsLive:!0,render(e,t){let r={...t,...Ft,...t};return Pt(e,r)}}}function zt(e,t={}){let r={showTimings:!0,showKeys:!1,colors:{pending:"#6c757d",running:"#ffc107",success:"#198754",error:"#dc3545",aborted:"#6c757d",cached:"#0dcaf0",skipped:"#adb5bd"},...Ft,...t};return Pt(e,r)}var ue={clearToEnd:"\x1B[J",cursorUp:e=>`\x1B[${e}A`,cursorToStart:"\x1B[G",hideCursor:"\x1B[?25l",showCursor:"\x1B[?25h",saveCursor:"\x1B[s",restoreCursor:"\x1B[u"};function Kt(e={}){let{workflowName:t,detectParallel:r=!0,showTimings:o=!0,showKeys:a=!1,colors:n,stream:i=process.stdout,updateInterval:s=100}=e,u=de({detectParallel:r}),d=ae(),l,p={showTimings:o,showKeys:a,terminalWidth:i.columns??80,colors:{...z,...n}},f=!1,m="",w=0,k=null,
|
|
1676
|
+
</html>`}function ot(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ht(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function bn(e,t){return e.length<=t?e:e.slice(0,t-1)+"\u2026"}function wn(e){if(!e.hooks)return e;let t=e.hooks.onAfterStep instanceof Map?Object.fromEntries(e.hooks.onAfterStep):e.hooks.onAfterStep;return{...e,hooks:{...e.hooks,onAfterStep:t}}}function Wt(e){let t=new WeakSet;return JSON.stringify(e,(o,a)=>{if(typeof a=="bigint")return a.toString();if(o==="error"&&a!==void 0&&a!==null)return String(a);if(typeof a=="object"&&a!==null){if(t.has(a))return"[Circular]";t.add(a)}return a}).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}var Ft={interactive:!0,timeTravel:!0,heatmap:!0,animationDuration:200,theme:"auto",layout:"TB"};function Ut(){return{name:"html",supportsLive:!0,render(e,t){let r={...t,...Ft,...t};return Pt(e,r)}}}function zt(e,t={}){let r={showTimings:!0,showKeys:!1,colors:{pending:"#6c757d",running:"#ffc107",success:"#198754",error:"#dc3545",aborted:"#6c757d",cached:"#0dcaf0",skipped:"#adb5bd"},...Ft,...t};return Pt(e,r)}var ue={clearToEnd:"\x1B[J",cursorUp:e=>`\x1B[${e}A`,cursorToStart:"\x1B[G",hideCursor:"\x1B[?25l",showCursor:"\x1B[?25h",saveCursor:"\x1B[s",restoreCursor:"\x1B[u"};function Kt(e={}){let{workflowName:t,detectParallel:r=!0,showTimings:o=!0,showKeys:a=!1,colors:n,stream:i=process.stdout,updateInterval:s=100}=e,u=de({detectParallel:r}),d=ae(),l,p={showTimings:o,showKeys:a,terminalWidth:i.columns??80,colors:{...z,...n}},f=!1,m="",w=0,k=null,T=!1;function $(D){i.writable&&i.write(D)}function M(){if(!f)return;let D=y(),v=d.render(D,p);v!==m&&(w>0&&($(ue.cursorUp(w)),$(ue.cursorToStart),$(ue.clearToEnd)),$(v),$(`
|
|
1677
1677
|
`),m=v,w=v.split(`
|
|
1678
|
-
`).length)}function I(){f&&(
|
|
1679
|
-
`),$(ue.showCursor)}function L(){k!==null&&(clearTimeout(k),k=null),
|
|
1678
|
+
`).length)}function I(){f&&(T=!0,k===null&&(k=setTimeout(()=>{k=null,T&&(T=!1,M())},s)))}function S(D){if(D.type==="scope_start"||D.type==="scope_end"){x(D);return}u.handleEvent(D),"workflowName"in D&&typeof D.workflowName=="string"&&(l=D.workflowName),f&&(D.type==="workflow_start"||D.type==="workflow_success"||D.type==="workflow_error"?M():I())}function x(D){u.handleScopeEvent(D),f&&I()}function g(D){u.handleDecisionEvent(D),f&&I()}function y(){let D=u.getIR(),v=t??l??D.root.name;return v&&(D.root.name=v),D}function E(){return d.render(y(),p)}function C(){f||(f=!0,m="",w=0,$(ue.hideCursor),M())}function N(){if(!f)return;f=!1,k!==null&&(clearTimeout(k),k=null);let D=y(),v=d.render(D,p);w>0&&($(ue.cursorUp(w)),$(ue.cursorToStart),$(ue.clearToEnd)),$(v),$(`
|
|
1679
|
+
`),$(ue.showCursor)}function L(){k!==null&&(clearTimeout(k),k=null),T=!1,M()}function P(){u.reset(),m="",w=0}return{handleEvent:S,handleScopeEvent:x,handleDecisionEvent:g,getIR:y,render:E,start:C,stop:N,refresh:L,reset:P}}function ze(e,t={}){let{condition:r,value:o,name:a,workflowId:n=crypto.randomUUID(),emit:i}=t,s=Date.now(),u,d=[];function l(f,m,w){d.push({label:f,condition:w,taken:m}),m&&(u=f),i?.({type:"decision_branch",workflowId:n,decisionId:e,branchLabel:f,condition:w,taken:m,ts:Date.now()})}function p(){let f=Date.now()-s;i?.({type:"decision_end",workflowId:n,decisionId:e,branchTaken:u,ts:Date.now(),durationMs:f})}return i?.({type:"decision_start",workflowId:n,decisionId:e,condition:r,decisionValue:o,name:a,ts:s}),{takeBranch:l,end:p,getBranchTaken:()=>u,getBranches:()=>[...d]}}function jt(e,t,r={}){let o=ze(e,{...r,condition:r.condition??String(t),value:r.value??t}),a=!1;return{...o,condition:t,then:()=>{a||(a=!0,o.takeBranch("if",!0),o.takeBranch("else",!1))},else:()=>{a||(a=!0,o.takeBranch("if",!1),o.takeBranch("else",!0))}}}function Vt(e,t,r={}){let o=ze(e,{...r,condition:r.condition??`switch(${String(t)})`,value:t});return{...o,value:t,case:(a,n)=>{o.takeBranch(`case '${a}'`,n,`value === '${a}'`)},default:a=>{o.takeBranch("default",a)}}}function Gt(e={}){let{maxSnapshots:t=1e3,autoRecord:r=!0,builderOptions:o={}}=e,a=de({detectParallel:!1,...o,enableSnapshots:r,maxSnapshots:t}),n={snapshots:[],currentIndex:-1,isPlaying:!1,playbackSpeed:1,isRecording:r},i=new Set,s=null;function u(){let N=S();for(let L of i)L(N)}function d(){n.snapshots=a.getSnapshots(),n.isRecording&&n.snapshots.length>0&&(n.currentIndex=n.snapshots.length-1)}function l(N){a.handleEvent(N),n.isRecording&&(d(),u())}function p(N){let L=a.getSnapshots();if(!(N<0||N>=L.length))return n.currentIndex=N,n.snapshots=L,u(),L[N].ir}function f(){return p(n.currentIndex+1)}function m(){return p(n.currentIndex-1)}function w(N=1){let L=a.getSnapshots();if(L.length===0)return;n.currentIndex===-1&&(n.currentIndex=0,n.snapshots=L),n.playbackSpeed=N,n.isPlaying=!0,u();let P=()=>{if(!n.isPlaying)return;let D=a.getSnapshots();if(n.currentIndex<D.length-1){let v=D[n.currentIndex],oe=(D[n.currentIndex+1].timestamp-v.timestamp)/n.playbackSpeed;s=setTimeout(()=>{f(),P()},Math.max(16,oe))}else k()};P()}function k(){n.isPlaying=!1,s&&(clearTimeout(s),s=null),u()}function T(){let N=a.getSnapshots();return n.currentIndex>=0&&n.currentIndex<N.length?N[n.currentIndex].ir:a.getIR()}function $(N){return a.getIRAt(N)}function M(){return a.getSnapshots()}function I(N){return a.getSnapshotAt(N)}function S(){return{snapshots:a.getSnapshots(),currentIndex:n.currentIndex,isPlaying:n.isPlaying,playbackSpeed:n.playbackSpeed,isRecording:n.isRecording}}function x(N){return i.add(N),()=>i.delete(N)}function g(){n.isRecording=!0,a.setSnapshotsEnabled(!0),d(),u()}function y(){n.isRecording=!1,a.setSnapshotsEnabled(!1),u()}function E(){k(),a.reset(),a.setSnapshotsEnabled(r),n={snapshots:[],currentIndex:-1,isPlaying:!1,playbackSpeed:1,isRecording:r},u()}function C(){return a}return{handleEvent:l,seek:p,stepForward:f,stepBackward:m,play:w,pause:k,getCurrentIR:T,getIRAt:$,getSnapshots:M,getSnapshotAt:I,getState:S,onStateChange:x,startRecording:g,stopRecording:y,reset:E,getBuilder:C}}function Yt(e,t,r={}){let{title:o=t.workflowName,theme:a,mermaidCdnUrl:n="https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.min.js"}=r,i=JSON.stringify(t,null,2);return`<!DOCTYPE html>
|
|
1680
1680
|
<html lang="en">
|
|
1681
1681
|
<head>
|
|
1682
1682
|
<meta charset="UTF-8">
|
|
@@ -2523,10 +2523,11 @@ ${vn()}
|
|
|
2523
2523
|
html += '<div class="inspector-code">' + esc(meta.description) + '</div></div>';
|
|
2524
2524
|
}
|
|
2525
2525
|
|
|
2526
|
-
if (meta.inputType || meta.outputType) {
|
|
2526
|
+
if (meta.inputType || meta.outputType || meta.errorType) {
|
|
2527
2527
|
html += '<div class="inspector-section"><h3>Types</h3>';
|
|
2528
2528
|
if (meta.inputType) html += row('Input', meta.inputType);
|
|
2529
2529
|
if (meta.outputType) html += row('Output', meta.outputType);
|
|
2530
|
+
if (meta.errorType) html += row('Error type', meta.errorType);
|
|
2530
2531
|
html += '</div>';
|
|
2531
2532
|
}
|
|
2532
2533
|
|
|
@@ -2648,5 +2649,5 @@ ${vn()}
|
|
|
2648
2649
|
var initialTheme = resolveTheme();
|
|
2649
2650
|
applyTheme(initialTheme);
|
|
2650
2651
|
})();
|
|
2651
|
-
`}function ve(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Ke(e={}){let{workflowName:t,detectParallel:r=!0,showTimings:o=!0,showKeys:a=!1,colors:n,export:i}=e,s=de({detectParallel:r}),u=new Set,d,l=ae(),p=ie(),f=Re(),m=me(),w={showTimings:o,showKeys:a,terminalWidth:process.stdout?.columns??80,colors:{...z,...n}};function k(){if(u.size>0){let v=I();for(let O of u)O(v)}}function
|
|
2652
|
+
`}function ve(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Ke(e={}){let{workflowName:t,detectParallel:r=!0,showTimings:o=!0,showKeys:a=!1,colors:n,export:i}=e,s=de({detectParallel:r}),u=new Set,d,l=ae(),p=ie(),f=Re(),m=me(),w={showTimings:o,showKeys:a,terminalWidth:process.stdout?.columns??80,colors:{...z,...n}};function k(){if(u.size>0){let v=I();for(let O of u)O(v)}}function T(v){if(v.type==="scope_start"||v.type==="scope_end"){$(v);return}s.handleEvent(v),"workflowName"in v&&typeof v.workflowName=="string"&&(d=v.workflowName),k()}function $(v){s.handleScopeEvent(v),k()}function M(v){s.handleDecisionEvent(v),k()}function I(){let v=s.getIR(),O=t??d??v.root.name;return O&&(v.root.name=O),v}function S(){let v=I();return l.render(v,w)}function x(v){let O=I();switch(v){case"ascii":return l.render(O,w);case"mermaid":return p.render(O,w);case"json":{let q=O.hooks?{...O,hooks:{...O.hooks,onAfterStep:O.hooks.onAfterStep instanceof Map?Object.fromEntries(O.hooks.onAfterStep):O.hooks.onAfterStep??{}}}:O;return JSON.stringify(q,(at,ke)=>typeof ke=="bigint"?ke.toString():ke,2)}case"logger":return f.render(O,w);case"flowchart":return m.render(O,w);default:throw new Error(`Unknown format: ${v}`)}}function g(){s.reset(),k()}function y(v){return u.add(v),()=>u.delete(v)}function E(v,O){if(v)return v;if(i?.default)return i.default;throw new Error(`${O}(): No export provider configured. Pass { provider: 'kroki' } or { provider: 'mermaid-ink' }, or set export.default in createVisualizer().`)}function C(){let v=I();return{kind:"mermaid",source:p.render(v,w)}}function N(v){let O=we(C(),"svg",E(v,"toSvgUrl"),{caller:"toSvgUrl"});if(!O.ok)throw new Error(`toSvgUrl: Export failed - ${O.error}`);return O.value}function L(v){let O=we(C(),"png",E(v,"toPngUrl"),{caller:"toPngUrl"});if(!O.ok)throw new Error(`toPngUrl: Export failed - ${O.error}`);return O.value}function P(v){let O=we(C(),"pdf",E(v,"toPdfUrl"),{caller:"toPdfUrl"});if(!O.ok)throw new Error(`toPdfUrl: Export failed - ${O.error}`);return O.value}function D(v,O){switch(v){case"svg":return N(O);case"png":return L(O);case"pdf":return P(O);default:return v}}return{handleEvent:T,handleScopeEvent:$,handleDecisionEvent:M,getIR:I,render:S,renderAs:x,reset:g,onUpdate:y,toUrl:D,toSvgUrl:N,toPngUrl:L,toPdfUrl:P}}function kn(...e){return(t,r)=>{for(let o of e)o(t,r)}}function xn(e,t={}){let r=Ke(t);for(let o of e)o.type.startsWith("decision_")?r.handleDecisionEvent(o):r.handleEvent(o);return r.render()}function Sn(e={}){let t=[];return{handleEvent:r=>{t.push(r)},handleDecisionEvent:r=>{t.push(r)},getEvents:()=>[...t],getWorkflowEvents:()=>t.filter(r=>!r.type.startsWith("decision_")),getDecisionEvents:()=>t.filter(r=>r.type.startsWith("decision_")),clear:()=>{t.length=0},visualize:()=>{let r=Ke(e);for(let o of t)o.type.startsWith("decision_")?r.handleDecisionEvent(o):r.handleEvent(o);return r.render()},visualizeAs:r=>{let o=Ke(e);for(let a of t)a.type.startsWith("decision_")?o.handleDecisionEvent(a):o.handleEvent(a);return o.renderAs(r)}}}0&&(module.exports={asciiRenderer,buildMermaidInkUrl,combineEventHandlers,createEventCollector,createIRBuilder,createLiveVisualizer,createMermaidInkGenerator,createParallelDetector,createPerformanceAnalyzer,createTimeTravelController,createUrlGenerator,createVisualizer,defaultColorScheme,detectParallelGroups,encodeForMermaidInk,escapeHtml,flowchartRenderer,generateInteractiveHTML,getHeatLevel,hasChildren,htmlRenderer,isDecisionNode,isParallelNode,isRaceNode,isSequenceNode,isStepNode,isStreamNode,loggerRenderer,mermaidRenderer,renderToHTML,toExportUrl,toKrokiPngUrl,toKrokiSvgUrl,toKrokiUrl,toMermaidInkJpegUrl,toMermaidInkPdfUrl,toMermaidInkPngUrl,toMermaidInkSvgUrl,toMermaidInkUrl,toMermaidInkWebpUrl,trackDecision,trackIf,trackSwitch,visualizeEvents});
|
|
2652
2653
|
//# sourceMappingURL=index.cjs.map
|