awaitly-visualizer 20.0.0 → 20.0.2
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/binding.gyp +9 -0
- package/dist/devtools.cjs +5 -5
- package/dist/devtools.cjs.map +1 -1
- package/dist/devtools.d.cts +3 -3
- package/dist/devtools.d.ts +3 -3
- package/dist/devtools.js +5 -5
- package/dist/devtools.js.map +1 -1
- package/dist/index.browser.cjs +17 -17
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +4 -4
- package/dist/index.browser.d.ts +4 -4
- package/dist/index.browser.js +19 -19
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +20 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +22 -22
- package/dist/index.js.map +1 -1
- package/dist/kroki/fetch.cjs.map +1 -1
- package/dist/kroki/fetch.d.cts +2 -2
- package/dist/kroki/fetch.d.ts +2 -2
- package/dist/kroki/fetch.js.map +1 -1
- package/dist/notifiers/discord.cjs +2 -2
- package/dist/notifiers/discord.cjs.map +1 -1
- package/dist/notifiers/discord.d.cts +2 -2
- package/dist/notifiers/discord.d.ts +2 -2
- package/dist/notifiers/discord.js +2 -2
- package/dist/notifiers/discord.js.map +1 -1
- package/dist/notifiers/slack.cjs +12 -12
- package/dist/notifiers/slack.cjs.map +1 -1
- package/dist/notifiers/slack.d.cts +2 -2
- package/dist/notifiers/slack.d.ts +2 -2
- package/dist/notifiers/slack.js +12 -12
- package/dist/notifiers/slack.js.map +1 -1
- package/dist/notifiers/webhook.cjs +1 -1
- package/dist/notifiers/webhook.cjs.map +1 -1
- package/dist/notifiers/webhook.d.cts +2 -2
- package/dist/notifiers/webhook.d.ts +2 -2
- package/dist/notifiers/webhook.js +2 -2
- package/dist/notifiers/webhook.js.map +1 -1
- package/dist/{performance-analyzer-MwxDr6ej.d.ts → performance-analyzer-C9WFkUSa.d.cts} +16 -1
- package/dist/{performance-analyzer-DyIZZ2rA.d.cts → performance-analyzer-ffmMicjZ.d.ts} +16 -1
- package/dist/{types-fuxEig2j.d.ts → types-Bmb5LpD-.d.ts} +1 -1
- package/dist/{types-CgO2me2s.d.cts → types-BmktN16n.d.cts} +1 -1
- package/dist/{url-BskfOf3W.d.cts → url-CxqaR2K3.d.cts} +6 -1
- package/dist/{url-BskfOf3W.d.ts → url-CxqaR2K3.d.ts} +6 -1
- package/index.js +1 -0
- package/package.json +4 -4
package/dist/index.browser.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";var jt=Object.create;var xe=Object.defineProperty;var Vt=Object.getOwnPropertyDescriptor;var Gt=Object.getOwnPropertyNames;var Yt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var Xt=(e,t)=>{for(var r in t)xe(e,r,{get:t[r],enumerable:!0})},Qe=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Gt(t))!Jt.call(e,i)&&i!==r&&xe(e,i,{get:()=>t[i],enumerable:!(o=Vt(t,i))||o.enumerable});return e};var qt=(e,t,r)=>(r=e!=null?jt(Yt(e)):{},Qe(t||!e||!e.__esModule?xe(r,"default",{value:e,enumerable:!0}):r,e)),Zt=e=>Qe(xe({},"__esModule",{value:!0}),e);var mn={};Xt(mn,{asciiRenderer:()=>ce,buildMermaidInkUrl:()=>Ze,combineEventHandlers:()=>un,createEventCollector:()=>fn,createIRBuilder:()=>ue,createLiveVisualizer:()=>ln,createMermaidInkGenerator:()=>Pt,createParallelDetector:()=>et,createPerformanceAnalyzer:()=>st,createTimeTravelController:()=>Et,createUrlGenerator:()=>Dt,createVisualizer:()=>Ae,defaultColorScheme:()=>V,detectParallelGroups:()=>we,encodeForMermaidInk:()=>qe,flowchartRenderer:()=>le,getHeatLevel:()=>fe,hasChildren:()=>tr,htmlRenderer:()=>St,isDecisionNode:()=>Y,isParallelNode:()=>j,isRaceNode:()=>H,isSequenceNode:()=>Pe,isStepNode:()=>z,isStreamNode:()=>Q,loggerRenderer:()=>ke,mermaidRenderer:()=>te,renderToHTML:()=>Rt,toKrokiPngUrl:()=>Ot,toKrokiSvgUrl:()=>Tt,toKrokiUrl:()=>se,toMermaidInkJpegUrl:()=>Wt,toMermaidInkPdfUrl:()=>At,toMermaidInkPngUrl:()=>_t,toMermaidInkSvgUrl:()=>Lt,toMermaidInkUrl:()=>G,toMermaidInkWebpUrl:()=>Bt,trackDecision:()=>We,trackIf:()=>It,trackSwitch:()=>$t,visualizeEvents:()=>pn});module.exports=Zt(mn);function A(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 Se(){return`node_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function Qt(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 we(e,t={}){if(Qt(e))return e;let{minOverlapMs:r=0,maxGapMs:o=5}=t,i=[],n=[];for(let c=0;c<e.length;c++){let l=e[c];l.type==="step"&&l.startTs!==void 0?i.push({node:l,startTs:l.startTs,endTs:l.endTs??l.startTs+(l.durationMs??0),originalIndex:c}):n.push({node:l,originalIndex:c})}if(i.length<=1)return e;i.sort((c,l)=>c.startTs-l.startTs);let a=[],s=[i[0]];for(let c=1;c<i.length;c++){let l=i[c],f=Math.min(...s.map($=>$.startTs)),h=Math.max(...s.map($=>$.endTs)),p=l.startTs<=f+o,y=l.startTs<h;if(!p&&!y){a.push(s),s=[l];continue}let v=y?Math.min(l.endTs,h)-l.startTs:0;p||v>=r?s.push(l):(a.push(s),s=[l])}a.push(s);let u=[];for(let c of a){let l=Math.min(...c.map(f=>f.originalIndex));if(c.length===1)u.push({node:c[0].node,position:l});else{let f=c.map(v=>v.node),h=Math.min(...c.map(v=>v.startTs)),p=Math.max(...c.map(v=>v.endTs)),y={type:"parallel",id:`detected_parallel_${h}`,name:`${f.length} parallel steps`,state:er(f),mode:"all",children:f,startTs:h,endTs:p,durationMs:p-h};u.push({node:y,position:l})}}for(let{node:c,originalIndex:l}of n)u.push({node:c,position:l});return u.sort((c,l)=>c.position-l.position),u.map(c=>c.node)}function er(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 et(e={}){return{detect:t=>we(t,e)}}function ue(e={}){let{detectParallel:t=!0,parallelDetection:r,enableSnapshots:o=!1,maxSnapshots:i=1e3}=e,n=o,a=Se(),s,u,c,l="pending",f,h,p=new Map,y=[],v=[],$=new Map,M=[],E=Date.now(),I=E,x={onAfterStep:new Map},S,w=[],g=0;function k(d){return d.stepId??d.stepKey??d.name??Se()}function T(d){if(y.length>0){y[y.length-1].children.push(d),I=Date.now();return}if(v.length>0){let b=v[v.length-1];for(let m of b.branches.values())if(m.taken){m.children.push(d),I=Date.now();return}b.pendingChildren.push(d),I=Date.now();return}M.push(d),I=Date.now()}function N(d){if(!n)return;let b=oe(),m=new Map;for(let[C,J]of p)m.set(C,{id:J.id,name:J.name,key:J.key,startTs:J.startTs,retryCount:J.retryCount,timedOut:J.timedOut,timeoutMs:J.timeoutMs});let P={id:`snapshot_${g}`,eventIndex:g,event:structuredClone(d),ir:structuredClone(b),timestamp:Date.now(),activeSteps:m};w.push(P),w.length>i&&w.shift(),g++}function D(d){switch(d.type){case"workflow_start":{M=[],c=void 0,h=void 0,f=void 0,p.clear(),y.length=0,v.length=0,$.clear(),s=d.workflowId,u=d.ts,l="running",E=Date.now(),I=E,S!==void 0&&S!==d.workflowId&&(x.shouldRun=void 0,x.onBeforeStart=void 0),S=d.workflowId,x.onAfterStep=new Map;break}case"workflow_success":l="success",c=d.ts,h=d.durationMs,I=Date.now();break;case"workflow_error":l="error",c=d.ts,f=d.error,h=d.durationMs,I=Date.now();break;case"workflow_cancelled":l="aborted",c=d.ts,h=d.durationMs,I=Date.now();break;case"step_start":{let b=k(d);p.set(b,{id:b,name:d.name,key:d.stepKey,startTs:d.ts,retryCount:0,timedOut:!1}),I=Date.now();break}case"step_success":{let b=k(d),m=p.get(b);if(m){let P={type:"step",id:m.id,name:m.name,key:m.key,state:"success",startTs:m.startTs,endTs:d.ts,durationMs:d.durationMs,...m.retryCount>0&&{retryCount:m.retryCount},...m.timedOut&&{timedOut:!0,timeoutMs:m.timeoutMs}};T(P),p.delete(b)}break}case"step_error":{let b=k(d),m=p.get(b);if(m){let P={type:"step",id:m.id,name:m.name,key:m.key,state:"error",startTs:m.startTs,endTs:d.ts,durationMs:d.durationMs,error:d.error,...m.retryCount>0&&{retryCount:m.retryCount},...m.timedOut&&{timedOut:!0,timeoutMs:m.timeoutMs}};T(P),p.delete(b)}break}case"step_aborted":{let b=k(d),m=p.get(b);if(m){let P={type:"step",id:m.id,name:m.name,key:m.key,state:"aborted",startTs:m.startTs,endTs:d.ts,durationMs:d.durationMs,...m.retryCount>0&&{retryCount:m.retryCount},...m.timedOut&&{timedOut:!0,timeoutMs:m.timeoutMs}};T(P),p.delete(b)}break}case"step_cache_hit":{let m={type:"step",id:k(d),name:d.name,key:d.stepKey,state:"cached",startTs:d.ts,endTs:d.ts,durationMs:0};T(m);break}case"step_cache_miss":break;case"step_complete":break;case"step_timeout":{let b=k(d),m=p.get(b);m&&(m.timedOut=!0,m.timeoutMs=d.timeoutMs),I=Date.now();break}case"step_retry":{let b=k(d),m=p.get(b);m&&(m.retryCount=(d.attempt??1)-1),I=Date.now();break}case"step_retries_exhausted":I=Date.now();break;case"step_skipped":{let m={type:"step",id:k(d),name:d.name,key:d.stepKey,state:"skipped",startTs:d.ts,endTs:d.ts,durationMs:0};T(m);break}case"hook_should_run":{let b={type:"shouldRun",state:"success",ts:d.ts,durationMs:d.durationMs,context:{result:d.result,skipped:d.skipped}};x.shouldRun=b,S=d.workflowId,I=Date.now();break}case"hook_should_run_error":{let b={type:"shouldRun",state:"error",ts:d.ts,durationMs:d.durationMs,error:d.error};x.shouldRun=b,S=d.workflowId,I=Date.now();break}case"hook_before_start":{let b={type:"onBeforeStart",state:"success",ts:d.ts,durationMs:d.durationMs,context:{result:d.result,skipped:d.skipped}};x.onBeforeStart=b,S=d.workflowId,I=Date.now();break}case"hook_before_start_error":{let b={type:"onBeforeStart",state:"error",ts:d.ts,durationMs:d.durationMs,error:d.error};x.onBeforeStart=b,S=d.workflowId,I=Date.now();break}case"hook_after_step":{let b={type:"onAfterStep",state:"success",ts:d.ts,durationMs:d.durationMs,context:{stepKey:d.stepKey}};x.onAfterStep.set(d.stepKey,b),I=Date.now();break}case"hook_after_step_error":{let b={type:"onAfterStep",state:"error",ts:d.ts,durationMs:d.durationMs,error:d.error,context:{stepKey:d.stepKey}};x.onAfterStep.set(d.stepKey,b),I=Date.now();break}case"stream_created":{let b=`${d.workflowId}:${d.namespace}`;$.set(b,{id:Se(),namespace:d.namespace,startTs:d.ts,writeCount:0,readCount:0,streamState:"active",backpressureOccurred:!1,finalPosition:0}),I=Date.now();break}case"stream_write":{let b=`${d.workflowId}:${d.namespace}`,m=$.get(b);m&&(m.writeCount++,m.finalPosition=Math.max(m.finalPosition,d.position)),I=Date.now();break}case"stream_read":{let b=`${d.workflowId}:${d.namespace}`,m=$.get(b);m&&m.readCount++,I=Date.now();break}case"stream_close":{let b=`${d.workflowId}:${d.namespace}`,m=$.get(b);if(m){m.streamState="closed",m.finalPosition=d.finalPosition;let P={type:"stream",id:m.id,namespace:m.namespace,state:"success",startTs:m.startTs,endTs:d.ts,durationMs:d.ts-m.startTs,writeCount:m.writeCount,readCount:m.readCount,finalPosition:d.finalPosition,streamState:"closed",backpressureOccurred:m.backpressureOccurred};T(P),$.delete(b)}I=Date.now();break}case"stream_error":{let b=`${d.workflowId}:${d.namespace}`,m=$.get(b);if(m){m.streamState="error";let P={type:"stream",id:m.id,namespace:m.namespace,state:"error",error:d.error,startTs:m.startTs,endTs:d.ts,durationMs:d.ts-m.startTs,writeCount:m.writeCount,readCount:m.readCount,finalPosition:d.position,streamState:"error",backpressureOccurred:m.backpressureOccurred};T(P),$.delete(b)}I=Date.now();break}case"stream_backpressure":{let b=`${d.workflowId}:${d.namespace}`,m=$.get(b);m&&(m.backpressureOccurred=!0),I=Date.now();break}}N(d)}function B(d){if(d.type==="scope_start")y.push({id:d.scopeId,name:d.name,type:d.scopeType,startTs:d.ts,children:[]}),I=Date.now();else if(d.type==="scope_end"){let b=y.findIndex(C=>C.id===d.scopeId);if(b===-1)return;for(;y.length>b+1;){let C=y.pop(),J=C.type==="race"?{type:"race",id:C.id,name:C.name,state:_(C.children),startTs:C.startTs,endTs:d.ts,children:C.children}:{type:"parallel",id:C.id,name:C.name,state:_(C.children),startTs:C.startTs,endTs:d.ts,children:C.children,mode:C.type==="allSettled"?"allSettled":"all"};y[y.length-1].children.push(J)}let[m]=y.splice(b,1),P=m.type==="race"?{type:"race",id:m.id,name:m.name,state:_(m.children),startTs:m.startTs,endTs:d.ts,durationMs:d.durationMs,children:m.children,winnerId:d.winnerId}:{type:"parallel",id:m.id,name:m.name,state:_(m.children),startTs:m.startTs,endTs:d.ts,durationMs:d.durationMs,children:m.children,mode:m.type==="allSettled"?"allSettled":"all"};T(P)}}function K(d){if(d.type==="decision_start")v.push({id:d.decisionId,name:d.name,condition:d.condition,decisionValue:d.decisionValue,startTs:d.ts,branches:new Map,pendingChildren:[]}),I=Date.now();else if(d.type==="decision_branch"){let b=v.find(m=>m.id===d.decisionId);if(b){let m=d.branchLabel,P=b.branches.get(m);if(P)P.taken=d.taken,d.taken&&b.pendingChildren.length>0&&(P.children.unshift(...b.pendingChildren),b.pendingChildren=[]);else{let C=d.taken?[...b.pendingChildren]:[];d.taken&&(b.pendingChildren=[]),b.branches.set(m,{label:d.branchLabel,condition:d.condition,taken:d.taken,children:C})}I=Date.now()}}else if(d.type==="decision_end"){let b=v.findIndex(m=>m.id===d.decisionId);if(b!==-1){let[m]=v.splice(b,1),P=v.splice(b),C=Array.from(m.branches.values());C.length===0&&m.pendingChildren.length>0&&(C=[{label:"default",taken:!0,children:[...m.pendingChildren]}]);let J=C.find(ve=>ve.taken)?.label,Kt={type:"decision",id:m.id,name:m.name,state:_(C.flatMap(ve=>ve.taken?ve.children:[])),startTs:m.startTs,endTs:d.ts,durationMs:d.durationMs,condition:m.condition,decisionValue:m.decisionValue,branchTaken:d.branchTaken??J,branches:C};T(Kt),v.push(...P),I=Date.now()}}}function _(d){return d.length===0?"success":d.some(C=>C.state==="error")?"error":d.every(C=>C.state==="success"||C.state==="cached")?"success":d.some(C=>C.state==="running")?"running":"pending"}function ne(){let d=[...M];for(let[,b]of p)d.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 $)d.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 d}function oe(){let d=ne();t&&(d=we(d,r));let b={type:"workflow",id:s??a,workflowId:s??a,state:l,startTs:u,endTs:c,durationMs:h,children:d,error:f},m=x.shouldRun!==void 0||x.onBeforeStart!==void 0||x.onAfterStep.size>0;return{root:b,metadata:{createdAt:E,lastUpdatedAt:I},...m&&{hooks:x}}}function ie(){s=void 0,u=void 0,c=void 0,l="pending",f=void 0,h=void 0,p.clear(),y.length=0,v.length=0,$.clear(),M=[],E=Date.now(),I=E,x={onAfterStep:new Map},S=void 0,w.length=0,g=0}function Ht(){return[...w]}function Ft(d){return w[d]}function zt(d){return w[d]?.ir}function Ut(){w.length=0,g=0}return{handleEvent:D,handleScopeEvent:B,handleDecisionEvent:K,getIR:oe,reset:ie,getSnapshots:Ht,getSnapshotAt:Ft,getIRAt:zt,clearSnapshots:Ut,get hasActiveSteps(){return p.size>0},get state(){return l},get snapshotCount(){return w.length},get snapshotsEnabled(){return n},setSnapshotsEnabled(d){n=d}}}var Ie=require("awaitly");function z(e){return e.type==="step"}function Pe(e){return e.type==="sequence"}function j(e){return e.type==="parallel"}function H(e){return e.type==="race"}function Y(e){return e.type==="decision"}function Q(e){return e.type==="stream"}function tr(e){return"children"in e||e.type==="decision"&&"branches"in e}var He="\x1B[0m",rr="\x1B[1m",rt="\x1B[2m",nr="\x1B[31m",or="\x1B[32m",ir="\x1B[33m",ar="\x1B[34m",tt="\x1B[90m",sr="\x1B[37m";function X(e,t){return t?`${t}${e}${He}`:e}function be(e){return`${rr}${e}${He}`}function O(e){return`${rt}${e}${He}`}var V={pending:sr,running:ir,success:or,error:nr,aborted:tt,cached:ar,skipped:rt+tt};function cr(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 ye(e,t){let r=cr(e);return X(r,t[e])}function Re(e,t,r){return X(e,r[t])}function ee(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"},pe={cold:"\x1B[34m",cool:"\x1B[36m",neutral:"",warm:"\x1B[33m",hot:"\x1B[31m",critical:"\x1B[41m"},dr="\x1B[0m";function lr(e){return e<.2?pe.cold:e<.4?pe.cool:e<.6?pe.neutral:e<.8?pe.warm:e<.95?pe.hot:pe.critical}function nt(e,t){let r=lr(t);return r?`${r}${e}${dr}`:e}function ur(e){try{return(0,Ie.ok)(JSON.stringify(e,(r,o)=>{if(typeof o!="bigint")return o;let i=Number(o);return Number.isSafeInteger(i)?i:o.toString()}))}catch{return(0,Ie.err)("STRINGIFY_ERROR")}}function ot(e){let t=ur(e);return t.ok?t.value:"[unserializable]"}var it="\u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588";function ze(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(a=>{let s=(a-o)/n,u=Math.floor(s*(it.length-1));return it[u]}).join("")}function Fe(e,t){let r=ee(e).length,o=Math.max(0,t-r);return e+" ".repeat(o)}function pr(e,t){if(!t)return R.horizontal.repeat(e);let r=` ${t} `,o=ee(r).length,i=e-o;if(i<4)return R.horizontal.repeat(e);let n=2,a=i-n;return R.horizontal.repeat(n)+r+R.horizontal.repeat(a)}function at(e,t,r){let o=e.state==="success"?X("\u2699",r.success):X("\u26A0",r.error),i=e.durationMs!==void 0?O(` [${A(e.durationMs)}]`):"",n="";e.type==="shouldRun"&&e.context?.skipped?n=O(" \u2192 workflow skipped"):e.type==="shouldRun"&&e.context?.result===!0?n=O(" \u2192 proceed"):e.type==="onBeforeStart"&&e.context?.skipped?n=O(" \u2192 workflow skipped"):e.type==="onAfterStep"&&e.context?.stepKey&&(n=O(` (${e.context.stepKey})`));let a=e.state==="error"&&e.error?O(` error: ${String(e.error)}`):"";return`${o} ${O(t)}${n}${i}${a}`}function fr(e,t){let r=[];return e.shouldRun&&r.push(at(e.shouldRun,"shouldRun",t)),e.onBeforeStart&&r.push(at(e.onBeforeStart,"onBeforeStart",t)),r.length>0&&r.push(O("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),r}function ce(){return{name:"ascii",supportsLive:!0,render(e,t){let r={...V,...t.colors},o=Math.max(t.terminalWidth??60,5),i=o-4,n=[],a=e.root.name??"workflow",s=be(a);if(n.push(`${R.topLeft}${pr(o-2,s)}${R.topRight}`),n.push(`${R.vertical}${" ".repeat(o-2)}${R.vertical}`),e.hooks){let c=fr(e.hooks,r);for(let l of c)n.push(`${R.vertical} ${Fe(l,i)}${R.vertical}`)}let u=$e(e.root.children,t,r,0,e.hooks);for(let c of u)n.push(`${R.vertical} ${Fe(c,i)}${R.vertical}`);if(n.push(`${R.vertical}${" ".repeat(o-2)}${R.vertical}`),e.root.durationMs!==void 0&&t.showTimings){let c=e.root.state==="success"?"Completed":e.root.state==="aborted"?"Cancelled":"Failed",f=`${Re(c,e.root.state,r)} in ${A(e.root.durationMs)}`;n.push(`${R.vertical} ${Fe(f,i)}${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 $e(e,t,r,o,i){let n=[];for(let a of e)z(a)?n.push(Ue(a,t,r,i)):j(a)?n.push(...hr(a,t,r,o,i)):H(a)?n.push(...gr(a,t,r,o,i)):Y(a)?n.push(...wr(a,t,r,o,i)):Q(a)&&n.push(mr(a,t,r));return n}function Ue(e,t,r,o){let i=ye(e.state,r),n=e.name??e.key??"step",a=t,s=a.showHeatmap&&a.heatmapData?a.heatmapData.heat.get(e.key??"")??a.heatmapData.heat.get(e.name??"")??a.heatmapData.heat.get(e.id):void 0,u;s!==void 0?u=nt(n,s):u=Re(n,e.state,r);let c=`${i} ${u}`;if(t.showKeys&&e.key&&e.name&&(c+=O(` [key: ${e.key}]`)),e.input!==void 0){let f=typeof e.input=="string"?e.input:ot(e.input).slice(0,30);c+=O(` [in: ${f}${f.length>=30?"...":""}]`)}if(e.output!==void 0&&e.state==="success"){let f=typeof e.output=="string"?e.output:ot(e.output).slice(0,30);c+=O(` [out: ${f}${f.length>=30?"...":""}]`)}if(t.showTimings&&e.durationMs!==void 0){let f=A(e.durationMs),h=s!==void 0?nt(`[${f}]`,s):O(`[${f}]`);c+=` ${h}`}if(a.showSparklines&&a.timingHistory){let f=a.timingHistory.get(e.key??"")??a.timingHistory.get(e.name??"")??a.timingHistory.get(e.id);f&&f.length>1&&(c+=` ${O(ze(f))}`)}if(e.retryCount!==void 0&&e.retryCount>0&&(c+=O(` [${e.retryCount} ${e.retryCount===1?"retry":"retries"}]`)),e.timedOut){let f=e.timeoutMs!==void 0?` ${e.timeoutMs}ms`:"";c+=O(` [timeout${f}]`)}let l=e.key??e.id;if(o&&l&&o.onAfterStep.has(l)){let f=o.onAfterStep.get(l),h=f.state==="success"?X("\u2699",r.success):X("\u26A0",r.error),p=f.durationMs!==void 0?O(` ${A(f.durationMs)}`):"";c+=` ${h}${p}`}return c}function mr(e,t,r){let o=e.streamState==="active"?X("\u27F3",r.running):e.streamState==="closed"?X("\u2713",r.success):X("\u2717",r.error),i=`stream:${e.namespace}`,n=Re(i,e.state,r),a=O(`[W:${e.writeCount} R:${e.readCount}]`),s=`${o} ${n} ${a}`;return t.showTimings&&e.durationMs!==void 0&&(s+=` ${O(`[${A(e.durationMs)}]`)}`),e.backpressureOccurred&&(s+=O(" [backpressure]")),e.streamState==="closed"&&(s+=O(` pos:${e.finalPosition}`)),s}function hr(e,t,r,o,i){let n=[],a=" ".repeat(o),s=ye(e.state,r),u=e.name??"parallel",c=e.mode==="allSettled"?" (allSettled)":"";if(n.push(`${a}${R.teeRight}${R.teeDown}${R.horizontal} ${s} ${be(u)}${c}`),e.children.length===0)n.push(`${a}${R.vertical} ${O("(operations not individually tracked)")}`),n.push(`${a}${R.vertical} ${O("(wrap each operation with step() to see individual steps)")}`);else for(let l=0;l<e.children.length;l++){let f=e.children[l],p=l===e.children.length-1?`${a}${R.vertical} ${R.bottomLeft}`:`${a}${R.vertical} ${R.teeRight}`;if(z(f))n.push(`${p} ${Ue(f,t,r,i)}`);else{let y=$e([f],t,r,o+1,i);for(let v of y)n.push(`${a}${R.vertical} ${v}`)}}return t.showTimings&&e.durationMs!==void 0&&n.push(`${a}${R.bottomLeft}${R.horizontal}${R.horizontal} ${O(`[${A(e.durationMs)}]`)}`),n}function gr(e,t,r,o,i){let n=[],a=" ".repeat(o),s=ye(e.state,r),u=e.name??"race";if(n.push(`${a}${R.teeRight}\u26A1 ${s} ${be(u)}`),e.children.length===0)n.push(`${a}${R.vertical} ${O("(operations not individually tracked)")}`),n.push(`${a}${R.vertical} ${O("(wrap each operation with step() to see individual steps)")}`);else for(let c=0;c<e.children.length;c++){let l=e.children[c],h=c===e.children.length-1?`${a}${R.vertical} ${R.bottomLeft}`:`${a}${R.vertical} ${R.teeRight}`,y=e.winnerId&&l.id===e.winnerId?O(" (winner)"):"";if(z(l))n.push(`${h} ${Ue(l,t,r,i)}${y}`);else{let v=$e([l],t,r,o+1,i);for(let $ of v)n.push(`${a}${R.vertical} ${$}`)}}return t.showTimings&&e.durationMs!==void 0&&n.push(`${a}${R.bottomLeft}${R.horizontal}${R.horizontal} ${O(`[${A(e.durationMs)}]`)}`),n}function wr(e,t,r,o,i){let n=[],a=" ".repeat(o),s=ye(e.state,r),u=e.name??"decision",c=e.condition?O(` (${e.condition})`):"",l=e.decisionValue!==void 0?O(` = ${String(e.decisionValue)}`):"",f=e.branchTaken!==void 0?O(` \u2192 ${String(e.branchTaken)}`):"";n.push(`${a}${R.teeRight}${R.teeDown}${R.horizontal} ${s} ${be(u)}${c}${l}${f}`);for(let h=0;h<e.branches.length;h++){let p=e.branches[h],v=h===e.branches.length-1?`${a}${R.vertical} ${R.bottomLeft}`:`${a}${R.vertical} ${R.teeRight}`,$=p.taken?"\u2713":"\u2298",M=p.taken?r.success:r.skipped,E=X(`${$} ${p.label}`,M),I=p.condition?O(` (${p.condition})`):"";if(n.push(`${v} ${E}${I}`),p.children.length>0){let x=$e(p.children,t,r,o+1,i);for(let S of x)n.push(`${a}${R.vertical} ${S}`)}else p.taken||n.push(`${a}${R.vertical} ${O("(skipped)")}`)}return t.showTimings&&e.durationMs!==void 0&&n.push(`${a}${R.bottomLeft}${R.horizontal}${R.horizontal} ${O(`[${A(e.durationMs)}]`)}`),n}var Te=require("awaitly");function Ke(e){let t=[];for(let r of e)if(t.push(r),"children"in r&&Array.isArray(r.children)&&t.push(...Ke(r.children)),"branches"in r)for(let o of r.branches)t.push(...Ke(o.children));return t}function Ee(e,t){if(e.length===0)return 0;let r=Math.floor(e.length*t);return e[Math.min(r,e.length-1)]}function fe(e){return e<.2?"cold":e<.4?"cool":e<.6?"neutral":e<.8?"warm":e<.95?"hot":"critical"}function st(){let e=new Map,t=new Map,r=new Map,o=new Map,i=[];function n(x){return x.stepKey??x.stepId??x.name??"unknown"}function a(x){let S=new Map;for(let w of x)switch(w.type){case"step_start":{let g=n(w);S.set(g,{retried:!1,timedOut:!1});break}case"step_retry":{let g=n(w),k=S.get(g);k&&(k.retried=!0);break}case"step_timeout":{let g=n(w),k=S.get(g);k&&(k.timedOut=!0);break}case"step_success":{let g=n(w),k=S.get(g),T=e.get(g)??[];T.push(w.durationMs),e.set(g,T);let N=t.get(g)??{retried:0,total:0};N.total++,k?.retried&&N.retried++,t.set(g,N);let D=o.get(g)??{timedOut:0,total:0};D.total++,k?.timedOut&&D.timedOut++,o.set(g,D);let B=r.get(g)??{errors:0,total:0};B.total++,r.set(g,B),S.delete(g);break}case"step_error":{let g=n(w),k=S.get(g),T=e.get(g)??[];T.push(w.durationMs),e.set(g,T);let N=t.get(g)??{retried:0,total:0};N.total++,k?.retried&&N.retried++,t.set(g,N);let D=o.get(g)??{timedOut:0,total:0};D.total++,k?.timedOut&&D.timedOut++,o.set(g,D);let B=r.get(g)??{errors:0,total:0};B.total++,B.errors++,r.set(g,B),S.delete(g);break}}}function s(x){a(x.events)}function u(x){i.push(x)}function c(x){i.length>0&&(a(i),i=[])}function l(x){let S=e.get(x);if(!S||S.length===0)return;let w=[...S].sort((K,_)=>K-_),k=w.reduce((K,_)=>K+_,0)/w.length,T=w.reduce((K,_)=>K+(_-k)**2,0)/w.length,N=t.get(x)??{retried:0,total:1},D=r.get(x)??{errors:0,total:1},B=o.get(x)??{timedOut:0,total:1};return{nodeId:x,avgDurationMs:k,minDurationMs:w[0],maxDurationMs:w[w.length-1],stdDevMs:Math.sqrt(T),samples:w.length,retryRate:N.total>0?N.retried/N.total:0,timeoutRate:B.total>0?B.timedOut/B.total:0,errorRate:D.total>0?D.errors/D.total:0,percentiles:{p50:Ee(w,.5),p90:Ee(w,.9),p95:Ee(w,.95),p99:Ee(w,.99)}}}function f(x){return l(x)}function h(x,S="duration"){let w=new Map,g=Ke(x.root.children),k=[];for(let _ of g){let ne=("key"in _?_.key:void 0)??_.id??_.name,oe=l(ne);if(oe){let ie;switch(S){case"duration":ie=oe.avgDurationMs;break;case"retryRate":ie=oe.retryRate;break;case"errorRate":ie=oe.errorRate;break}k.push({id:_.id,value:ie})}}if(k.length===0)return{heat:w,metric:S,stats:{min:0,max:0,mean:0,threshold:0}};let T=k.map(_=>_.value),N=Math.min(...T),D=Math.max(...T),B=T.reduce((_,ne)=>_+ne,0)/T.length,K=D-N||1;for(let{id:_,value:ne}of k)w.set(_,(ne-N)/K);return{heat:w,metric:S,stats:{min:N,max:D,mean:B,threshold:B+(D-B)*.5}}}function p(){let x=new Map;for(let S of e.keys()){let w=l(S);w&&x.set(S,w)}return x}function y(x=10){return[...p().values()].sort((w,g)=>g.avgDurationMs-w.avgDurationMs).slice(0,x)}function v(x=10){return[...p().values()].filter(w=>w.errorRate>0).sort((w,g)=>g.errorRate-w.errorRate).slice(0,x)}function $(x=10){return[...p().values()].filter(w=>w.retryRate>0).sort((w,g)=>g.retryRate-w.retryRate).slice(0,x)}function M(){return JSON.stringify({timingData:Object.fromEntries(e),retryData:Object.fromEntries(t),errorData:Object.fromEntries(r),timeoutData:Object.fromEntries(o)})}function E(x){let S=JSON.parse(x);e.clear(),t.clear(),r.clear(),o.clear();for(let[w,g]of Object.entries(S.timingData??{}))e.set(w,g);for(let[w,g]of Object.entries(S.retryData??{}))t.set(w,g);for(let[w,g]of Object.entries(S.errorData??{}))r.set(w,g);for(let[w,g]of Object.entries(S.timeoutData??{}))o.set(w,g)}function I(){e.clear(),t.clear(),r.clear(),o.clear(),i=[]}return{addRun:s,addEvent:u,finalizeRun:c,getNodePerformance:f,getHeatmap:h,getSlowestNodes:y,getErrorProneNodes:v,getRetryProneNodes:$,getAllPerformance:p,exportData:M,importData:E,clear:I}}function br(){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 yr(){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 kr(e){return`heat_${e}`}function vr(){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 xr(e){try{return(0,Te.ok)(JSON.stringify(e,(r,o)=>{if(typeof o!="bigint")return o;let i=Number(o);return Number.isSafeInteger(i)?i:o.toString()}))}catch{return(0,Te.err)("STRINGIFY_ERROR")}}function ct(e){let t=xr(e);return t.ok?t.value:"[unserializable]"}function Sr(e,t,r){let o;if(e.shouldRun){let i="hook_shouldRun",n=e.shouldRun.state==="success"?"hook_success":"hook_error",a=e.shouldRun.state==="success"?"\u2699":"\u26A0",s=r.showTimings&&e.shouldRun.durationMs!==void 0?` ${A(e.shouldRun.durationMs)}`:"",u=e.shouldRun.context?.skipped?"\\nskipped workflow":e.shouldRun.context?.result===!0?"\\nproceed":"";t.push(` ${i}[["${a} shouldRun${u}${s}"]]:::${n}`),o=i}if(e.onBeforeStart){let i="hook_beforeStart",n=e.onBeforeStart.state==="success"?"hook_success":"hook_error",a=e.onBeforeStart.state==="success"?"\u2699":"\u26A0",s=r.showTimings&&e.onBeforeStart.durationMs!==void 0?` ${A(e.onBeforeStart.durationMs)}`:"",u=e.onBeforeStart.context?.skipped?"\\nskipped workflow":"";t.push(` ${i}[["${a} onBeforeStart${u}${s}"]]:::${n}`),o&&t.push(` ${o} --> ${i}`),o=i}return{lastHookId:o}}var dt=0,Ne=new Set,Me=new Set;function me(e="node"){return`${e}_${++dt}`}function Rr(){dt=0,Ne.clear(),Me.clear()}function U(e){return e.replace(/"/g,"#quot;").replace(/</g,"<").replace(/>/g,">").trim()}function lt(e){return U(e).replace(/[{}[\]()]/g,"")}function te(){return{name:"mermaid",supportsLive:!1,render(e,t){Rr();let r=[],o=t;r.push("flowchart TD");let i;e.hooks&&(i=Sr(e.hooks,r,t).lastHookId);let n="start";r.push(` ${n}(("\u25B6 Start"))`),i&&r.push(` ${i} --> ${n}`);let a=n;for(let u of e.root.children){let c=Oe(u,t,r,o,e.hooks);r.push(` ${a} --> ${c.entryId}`),a=c.exitId}if(["success","error","aborted"].includes(e.root.state)){let u="finish",c=e.root.state==="success"?"\u2713":e.root.state==="error"?"\u2717":"\u2298",l=e.root.state==="success"?"Done":e.root.state==="error"?"Failed":"Cancelled",f=`(("${c} ${l}"))`,h=e.root.state==="success"?":::success":e.root.state==="error"?":::error":":::aborted";r.push(` ${u}${f}${h}`),r.push(` ${a} --> ${u}`)}return r.push(""),r.push(...br()),o.showHeatmap&&r.push(...yr()),e.hooks&&r.push(...vr()),r.join(`
|
|
3
|
-
`)}}}function
|
|
4
|
-
`)}var q=11,Z=2,he=2,De=3;function Ve(e,t){if(e.length<=t)return[e];let r=e.split(" "),o=[],i="";for(let n of r)i?i.length+1+n.length<=t?i+=" "+n:(o.push(i),i=n):i=n;if(i&&o.push(i),o.length===0)for(let n=0;n<e.length;n+=t)o.push(e.slice(n,n+t));return o}function mt(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 _r(e,t,r){let o=t.showStartEnd??!0,i=t,n=Math.floor(r/2),a=[],s=0;if(o){let c=Ce("start","start",["\u25B6 Start"],"success",n,s);a.push(c),s=c.bottomY+he}for(let c of e.root.children){let l=Le(c,n,s,r-4,t,i);a.push(l.node),s=l.bottomY+he}if(o&&["success","error","aborted"].includes(e.root.state)){let c=e.root.state==="success"?"\u2713 Done":e.root.state==="error"?"\u2717 Failed":"\u2298 Cancelled",l=Ce("end","end",[c],e.root.state,n,s);a.push(l),s=l.bottomY}return{nodes:a,totalHeight:s+2}}function Ce(e,t,r,o,i,n){let a=Math.max(...r.map(l=>ee(l).length)),s=Math.max(q,a+Z*2),u=r.length+2,c=i-Math.floor(s/2);return{id:e,type:t,label:r,state:o,x:c,y:n,width:s,height:u,centerX:i,bottomY:n+u-1}}function Le(e,t,r,o,i,n){if(z(e))return Wr(e,t,r,o,i,n);if(j(e)||H(e))return Ar(e,t,r,o,i,n);if(Y(e))return Pr(e,t,r,o,i,n);if(Q(e))return Br(e,t,r,o,i,n);let a=Ce(e.id,"step",["?"],e.state,t,r);return{node:a,bottomY:a.bottomY}}function Wr(e,t,r,o,i,n){let a=e.name??e.key??"step",s=mt(e.state),u=[],c=`${s} ${a}`;i.showKeys&&e.key&&e.name&&(c+=` [${e.key}]`);let l=Math.min(o-Z*2,40);if(u.push(...Ve(c,l)),i.showTimings&&e.durationMs!==void 0&&u.push(`[${A(e.durationMs)}]`),e.retryCount&&e.retryCount>0&&u.push(`${e.retryCount}x retry`),e.timedOut&&u.push("timeout"),n?.showSparklines&&n.timingHistory){let M=n.timingHistory.get(e.key??"")??n.timingHistory.get(e.name??"")??n.timingHistory.get(e.id);M&&M.length>1&&u.push(ze(M,8))}let f=Math.max(...u.map(M=>ee(M).length)),h=Math.max(q,f+Z*2),p=u.length+2,y=t-Math.floor(h/2),v;if(n?.showHeatmap&&n.heatmapData){let M=e.key??e.name??e.id;v=n.heatmapData.heat.get(e.id)??n.heatmapData.heat.get(M)}let $={id:e.id,type:"step",label:u,state:e.state,x:y,y:r,width:h,height:p,centerX:t,bottomY:r+p-1,metadata:v!==void 0?{heat:v}:void 0};return{node:$,bottomY:$.bottomY}}function Br(e,t,r,o,i,n){let a=`stream:${e.namespace}`,s=e.streamState==="active"?"\u27F3":e.streamState==="closed"?"\u2713":"\u2717",u=[],c=`${s} ${a}`,l=Math.min(o-Z*2,40);u.push(...Ve(c,l)),u.push(`W:${e.writeCount} R:${e.readCount}`),i.showTimings&&e.durationMs!==void 0&&u.push(`[${A(e.durationMs)}]`),e.backpressureOccurred&&u.push("backpressure");let f=Math.max(...u.map($=>ee($).length)),h=Math.max(q,f+Z*2),p=u.length+2,y=t-Math.floor(h/2),v={id:e.id,type:"stream",label:u,state:e.state,x:y,y:r,width:h,height:p,centerX:t,bottomY:r+p-1,metadata:{streamState:e.streamState,backpressureOccurred:e.backpressureOccurred}};return{node:v,bottomY:v.bottomY}}function Ar(e,t,r,o,i,n){let a=H(e),s=e.name??(a?"race":"parallel"),c=`${a?"\u26A1":"\u2AD8"} ${s}`;if(e.children.length===0){let g=[c,"(not tracked)"],k=Ce(e.id,a?"race":"parallel",g,e.state,t,r);return{node:k,bottomY:k.bottomY}}let l=Math.floor((o-De*(e.children.length-1))/e.children.length),f=[];for(let g of e.children){let k=je(g,Math.max(l,q),i,n);f.push(k.width)}let h=f.reduce((g,k)=>g+k,0)+De*(e.children.length-1),p=h>o&&e.children.length>1,y=Math.max(q,c.length+Z*2),v=3,$=t-Math.floor(y/2),M=r;M+=v,M+=1,M+=1;let E=[];if(p)for(let g=0;g<e.children.length;g++){let k=e.children[g],T=Le(k,t,M,o,i,n);a&&H(e)&&e.winnerId===k.id&&(T.node.metadata={...T.node.metadata,isWinner:!0}),E.push(T.node),M=T.bottomY+he}else{let g=t-Math.floor(h/2);for(let k=0;k<e.children.length;k++){let T=e.children[k],N=g+Math.floor(f[k]/2),D=Le(T,N,M,f[k],i,n);a&&H(e)&&e.winnerId===T.id&&(D.node.metadata={...D.node.metadata,isWinner:!0}),E.push(D.node),g+=f[k]+De}}let I=Math.max(...E.map(g=>g.bottomY)),S=!p&&E.length>1?I+2:I;return{node:{id:e.id,type:a?"race":"parallel",label:[c],state:e.state,x:$,y:r,width:y,height:v,centerX:t,bottomY:S,children:E,metadata:{verticalLayout:p}},bottomY:S}}function Pr(e,t,r,o,i,n){let a=e.name??"decision",s=e.condition?` (${e.condition.slice(0,20)})`:"",u=`\u25C7 ${a}${s}`,c=Math.min(o-Z*2,40),l=Ve(u,c),f=Math.max(...l.map(S=>ee(S).length)),h=Math.max(q,f+Z*2),p=l.length+2,y=t-Math.floor(h/2),v=e.branches.find(S=>S.taken),$=v&&v.children.length>0?v:e.branches.find(S=>S.children.length>0);if(!$||$.children.length===0){let S={id:e.id,type:"decision",label:l,state:e.state,x:y,y:r,width:h,height:p,centerX:t,bottomY:r+p-1};return{node:S,bottomY:S.bottomY}}let M=r+p+he,E=[];for(let S of $.children){let w=Le(S,t,M,o,i,n);E.push(w.node),M=w.bottomY+he}let I=E.length>0?E[E.length-1].bottomY:r+p-1;return{node:{id:e.id,type:"decision",label:l,state:e.state,x:y,y:r,width:h,height:p,centerX:t,bottomY:I,children:E},bottomY:I}}function je(e,t,r,o){if(z(e)){let i=e.name??e.key??"step",n=mt(e.state),a=1;r.showTimings&&e.durationMs!==void 0&&a++,e.retryCount&&e.retryCount>0&&a++,e.timedOut&&a++,o?.showSparklines&&(o.timingHistory?.has(e.key??"")||o.timingHistory?.has(e.name??"")||o.timingHistory?.has(e.id))&&a++;let s=`${n} ${i}`;r.showKeys&&e.key&&e.name&&(s+=` [${e.key}]`);let u=Math.min(t,Math.max(q,s.length+Z*2)),c=a+2;return{width:u,height:c}}if(j(e)||H(e)){if(e.children.length===0)return{width:q+4,height:4};let i=Math.floor(t/e.children.length),n=0,a=0;for(let s of e.children){let u=je(s,i,r,o);n+=u.width,a=Math.max(a,u.height)}return n+=De*(e.children.length-1),{width:Math.max(n,q),height:5+a+2}}if(Y(e)){let i=e.branches.find(a=>a.taken),n=0;if(i)for(let a of i.children){let s=je(a,t,r,o);n+=s.height+he}return{width:Math.min(t,30),height:3+n}}if(Q(e)){let i=`stream:${e.namespace}`,n=2;r.showTimings&&e.durationMs!==void 0&&n++,e.backpressureOccurred&&n++;let a=Math.min(t,Math.max(q,i.length+Z*2+4)),s=n+2;return{width:a,height:s}}return{width:q,height:3}}function Hr(e,t,r){let o={...V,...r.colors};for(let i=0;i<t.length;i++){let n=t[i],a=i===t.length-1;if(_e(e,n,o),!a){let s=t[i+1],u=n.centerX,c=n.bottomY+1,l=s.centerX,f=s.y-1;re(e,u,c,f-1),de(e,l,f)}}}function _e(e,t,r){let o=t.type!=="start",i=t.type!=="end"&&(!t.children||t.children.length===0);Cr(e,t.x,t.y,t.width,t.height),o&&W(e,t.centerX,t.y,L.teeUp),(i||t.children&&t.children.length>0)&&W(e,t.centerX,t.y+t.height-1,L.teeDown);let n=t.width-Z*2,a=Kr(t,r);for(let s=0;s<t.label.length;s++){let u=t.label[s],c=t.x+1+Math.floor((n-ee(u).length)/2),l=t.y+1+s;ut(e,c,l,u,a)}t.metadata?.isWinner&&ut(e,t.x+t.width-2,t.y,"\u{1F3C6}"),t.children&&t.children.length>0&&(t.type==="parallel"||t.type==="race"?Fr(e,t,r):zr(e,t,r))}function Fr(e,t,r){let o=t.children;if(o.length===0)return;let i=t.y+t.height,n=t.centerX;if(t.metadata?.verticalLayout===!0){let s=o[0];re(e,n,i,s.y-2),de(e,s.centerX,s.y-1);for(let u=0;u<o.length;u++){let c=o[u];if(_e(e,c,r),u<o.length-1){let l=o[u+1];re(e,c.centerX,c.bottomY+1,l.y-2),de(e,l.centerX,l.y-1)}}return}if(o.length===1)re(e,n,i,o[0].y-2),de(e,o[0].centerX,o[0].y-1);else{let s=o.map(l=>l.centerX),u=Math.min(...s),c=Math.max(...s);re(e,n,i,i+1),pt(e,i+1,u,c),W(e,n,i+1,L.teeUp);for(let l of o){let f=l.centerX;f===u?W(e,f,i+1,L.topLeft):f===c?W(e,f,i+1,L.topRight):f!==n&&W(e,f,i+1,L.teeDown),re(e,f,i+2,l.y-2),de(e,f,l.y-1)}}for(let s of o)_e(e,s,r);if(o.length>1){let s=o.map(p=>p.bottomY),u=Math.max(...s),c=u+1,l=o.map(p=>p.centerX),f=Math.min(...l),h=Math.max(...l);for(let p of o)p.bottomY<u&&re(e,p.centerX,p.bottomY+1,c-1);pt(e,c,f,h);for(let p of o){let y=p.centerX;y===f?W(e,y,c,L.bottomLeft):y===h?W(e,y,c,L.bottomRight):W(e,y,c,L.teeUp)}W(e,t.centerX,c,L.teeDown),W(e,t.centerX,c+1,L.vertical)}}function zr(e,t,r){let o=t.children;if(o.length===0)return;let i=t.y+t.height,n=o[0];re(e,t.centerX,i,n.y-2),de(e,n.centerX,n.y-1);for(let a=0;a<o.length;a++){let s=o[a];if(_e(e,s,r),a<o.length-1){let u=o[a+1];re(e,s.centerX,s.bottomY+1,u.y-2),de(e,u.centerX,u.y-1)}}}var Ur={active:"\x1B[36m",closed:"\x1B[32m",error:"\x1B[31m"};function Kr(e,t){if(e.metadata?.heat!==void 0){let r=fe(e.metadata.heat);return Tr[r]||void 0}return e.type==="stream"&&e.metadata?.streamState?Ur[e.metadata.streamState]||void 0:t[e.state]||void 0}function le(){return{name:"flowchart",supportsLive:!1,render(e,t){let r=t.terminalWidth??80,{nodes:o,totalHeight:i}=_r(e,t,r),n=Dr(r,i);return Hr(n,o,t),Lr(n)}}}function jr(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}function Vr(e){let t=[];function r(o){for(let i of o)if(z(i))t.push(i);else if(Pe(i))r(i.children);else if(j(i)||H(i))r(i.children);else if(Y(i))for(let n of i.branches)n.taken&&r(n.children)}return r(e),t}function Gr(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 Yr(e){let t=0,r=0,o=0,i=0,n=0,a;for(let s of e)s.state==="success"&&t++,s.state==="error"&&r++,s.state==="cached"&&o++,s.state==="skipped"&&i++,s.retryCount!==void 0&&(n+=s.retryCount),s.durationMs!==void 0&&(!a||s.durationMs>a.durationMs)&&(a={name:s.name??s.key??s.id,durationMs:s.durationMs});return{totalSteps:e.length,successCount:t,errorCount:r,cacheHits:o,skippedCount:i,totalRetries:n,slowestStep:a}}function Jr(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 i={stepKey:r};o.durationMs!==void 0&&(i.durationMs=o.durationMs),o.error!==void 0&&o.error!==null&&(i.error=String(o.error)),t.onAfterStep.push(i)}}return t}function Xr(e,t){let r=e.root,o=Vr(r.children),i=t.includeDiagram??!0,n=t.stripAnsiColors??!0,a={workflow:{id:r.workflowId,name:r.name,state:r.state,durationMs:r.durationMs,startedAt:r.startTs,completedAt:r.endTs},steps:o.map(Gr),summary:Yr(o)};if(e.hooks){let s=Jr(e.hooks);Object.keys(s).length>0&&(a.hooks=s)}if(i){let c=((t.diagramFormat??"ascii")==="flowchart"?le():ce()).render(e,t);n&&(c=jr(c)),a.diagram=c}return a}function ke(){return{name:"logger",supportsLive:!1,render(e,t){let o=Xr(e,t);return JSON.stringify(o)}}}function ht(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 jt=Object.create;var xe=Object.defineProperty;var Vt=Object.getOwnPropertyDescriptor;var Gt=Object.getOwnPropertyNames;var Yt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var Xt=(e,t)=>{for(var r in t)xe(e,r,{get:t[r],enumerable:!0})},Qe=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Gt(t))!Jt.call(e,i)&&i!==r&&xe(e,i,{get:()=>t[i],enumerable:!(o=Vt(t,i))||o.enumerable});return e};var qt=(e,t,r)=>(r=e!=null?jt(Yt(e)):{},Qe(t||!e||!e.__esModule?xe(r,"default",{value:e,enumerable:!0}):r,e)),Zt=e=>Qe(xe({},"__esModule",{value:!0}),e);var mn={};Xt(mn,{asciiRenderer:()=>ce,buildMermaidInkUrl:()=>Ze,combineEventHandlers:()=>un,createEventCollector:()=>fn,createIRBuilder:()=>ue,createLiveVisualizer:()=>ln,createMermaidInkGenerator:()=>Pt,createParallelDetector:()=>et,createPerformanceAnalyzer:()=>st,createTimeTravelController:()=>Et,createUrlGenerator:()=>Ot,createVisualizer:()=>Ae,defaultColorScheme:()=>V,detectParallelGroups:()=>we,encodeForMermaidInk:()=>qe,flowchartRenderer:()=>le,getHeatLevel:()=>fe,hasChildren:()=>tr,htmlRenderer:()=>St,isDecisionNode:()=>Y,isParallelNode:()=>j,isRaceNode:()=>H,isSequenceNode:()=>Pe,isStepNode:()=>z,isStreamNode:()=>Q,loggerRenderer:()=>ke,mermaidRenderer:()=>te,renderToHTML:()=>Rt,toKrokiPngUrl:()=>Dt,toKrokiSvgUrl:()=>Tt,toKrokiUrl:()=>se,toMermaidInkJpegUrl:()=>Wt,toMermaidInkPdfUrl:()=>At,toMermaidInkPngUrl:()=>_t,toMermaidInkSvgUrl:()=>Lt,toMermaidInkUrl:()=>G,toMermaidInkWebpUrl:()=>Bt,trackDecision:()=>We,trackIf:()=>It,trackSwitch:()=>$t,visualizeEvents:()=>pn});module.exports=Zt(mn);function A(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 Se(){return`node_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function Qt(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 we(e,t={}){if(Qt(e))return e;let{minOverlapMs:r=0,maxGapMs:o=5}=t,i=[],n=[];for(let s=0;s<e.length;s++){let l=e[s];l.type==="step"&&l.startTs!==void 0?i.push({node:l,startTs:l.startTs,endTs:l.endTs??l.startTs+(l.durationMs??0),originalIndex:s}):n.push({node:l,originalIndex:s})}if(i.length<=1)return e;i.sort((s,l)=>s.startTs-l.startTs);let a=[],d=[i[0]];for(let s=1;s<i.length;s++){let l=i[s],p=Math.min(...d.map($=>$.startTs)),h=Math.max(...d.map($=>$.endTs)),m=l.startTs<=p+o,y=l.startTs<h;if(!m&&!y){a.push(d),d=[l];continue}let v=y?Math.min(l.endTs,h)-l.startTs:0;m||v>=r?d.push(l):(a.push(d),d=[l])}a.push(d);let u=[];for(let s of a){let l=Math.min(...s.map(p=>p.originalIndex));if(s.length===1)u.push({node:s[0].node,position:l});else{let p=s.map(v=>v.node),h=Math.min(...s.map(v=>v.startTs)),m=Math.max(...s.map(v=>v.endTs)),y={type:"parallel",id:`detected_parallel_${h}`,name:`${p.length} parallel steps`,state:er(p),mode:"all",children:p,startTs:h,endTs:m,durationMs:m-h};u.push({node:y,position:l})}}for(let{node:s,originalIndex:l}of n)u.push({node:s,position:l});return u.sort((s,l)=>s.position-l.position),u.map(s=>s.node)}function er(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 et(e={}){return{detect:t=>we(t,e)}}function ue(e={}){let{detectParallel:t=!0,parallelDetection:r,enableSnapshots:o=!1,maxSnapshots:i=1e3}=e,n=o,a=Se(),d,u,s,l="pending",p,h,m=new Map,y=[],v=[],$=new Map,N=[],E=Date.now(),I=E,x={onAfterStep:new Map},S,w=[],g=0;function k(c){return c.stepId??c.stepKey??c.name??Se()}function T(c){if(y.length>0){y[y.length-1].children.push(c),I=Date.now();return}if(v.length>0){let b=v[v.length-1];for(let f of b.branches.values())if(f.taken){f.children.push(c),I=Date.now();return}b.pendingChildren.push(c),I=Date.now();return}N.push(c),I=Date.now()}function M(c){if(!n)return;let b=oe(),f=new Map;for(let[C,J]of m)f.set(C,{id:J.id,name:J.name,key:J.key,startTs:J.startTs,retryCount:J.retryCount,timedOut:J.timedOut,timeoutMs:J.timeoutMs});let P={id:`snapshot_${g}`,eventIndex:g,event:structuredClone(c),ir:structuredClone(b),timestamp:Date.now(),activeSteps:f};w.push(P),w.length>i&&w.shift(),g++}function O(c){switch(c.type){case"workflow_start":{N=[],s=void 0,h=void 0,p=void 0,m.clear(),y.length=0,v.length=0,$.clear(),d=c.workflowId,u=c.ts,l="running",E=Date.now(),I=E,S!==void 0&&S!==c.workflowId&&(x.shouldRun=void 0,x.onBeforeStart=void 0),S=c.workflowId,x.onAfterStep=new Map;break}case"workflow_success":l="success",s=c.ts,h=c.durationMs,I=Date.now();break;case"workflow_error":l="error",s=c.ts,p=c.error,h=c.durationMs,I=Date.now();break;case"workflow_cancelled":l="aborted",s=c.ts,h=c.durationMs,I=Date.now();break;case"step_start":{let b=k(c);m.set(b,{id:b,name:c.name,key:c.stepKey,startTs:c.ts,retryCount:0,timedOut:!1,metadata:c.metadata}),I=Date.now();break}case"step_success":{let b=k(c),f=m.get(b);if(f){let P={type:"step",id:f.id,name:f.name,key:f.key,state:"success",startTs:f.startTs,endTs:c.ts,durationMs:c.durationMs,...f.retryCount>0&&{retryCount:f.retryCount},...f.timedOut&&{timedOut:!0,timeoutMs:f.timeoutMs},...f.metadata&&{metadata:f.metadata}};T(P),m.delete(b)}break}case"step_error":{let b=k(c),f=m.get(b);if(f){let P={type:"step",id:f.id,name:f.name,key:f.key,state:"error",startTs:f.startTs,endTs:c.ts,durationMs:c.durationMs,error:c.error,...f.retryCount>0&&{retryCount:f.retryCount},...f.timedOut&&{timedOut:!0,timeoutMs:f.timeoutMs},...f.metadata&&{metadata:f.metadata},...c.diagnostics&&{errorDiagnostics:c.diagnostics}};T(P),m.delete(b)}break}case"step_aborted":{let b=k(c),f=m.get(b);if(f){let P={type:"step",id:f.id,name:f.name,key:f.key,state:"aborted",startTs:f.startTs,endTs:c.ts,durationMs:c.durationMs,...f.retryCount>0&&{retryCount:f.retryCount},...f.timedOut&&{timedOut:!0,timeoutMs:f.timeoutMs},...f.metadata&&{metadata:f.metadata}};T(P),m.delete(b)}break}case"step_cache_hit":{let f={type:"step",id:k(c),name:c.name,key:c.stepKey,state:"cached",startTs:c.ts,endTs:c.ts,durationMs:0};T(f);break}case"step_cache_miss":break;case"step_complete":break;case"step_timeout":{let b=k(c),f=m.get(b);f&&(f.timedOut=!0,f.timeoutMs=c.timeoutMs),I=Date.now();break}case"step_retry":{let b=k(c),f=m.get(b);f&&(f.retryCount=(c.attempt??1)-1),I=Date.now();break}case"step_retries_exhausted":I=Date.now();break;case"step_skipped":{let f={type:"step",id:k(c),name:c.name,key:c.stepKey,state:"skipped",startTs:c.ts,endTs:c.ts,durationMs:0,...c.metadata&&{metadata:c.metadata}};T(f);break}case"hook_should_run":{let b={type:"shouldRun",state:"success",ts:c.ts,durationMs:c.durationMs,context:{result:c.result,skipped:c.skipped}};x.shouldRun=b,S=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};x.shouldRun=b,S=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}};x.onBeforeStart=b,S=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};x.onBeforeStart=b,S=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}};x.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}};x.onAfterStep.set(c.stepKey,b),I=Date.now();break}case"stream_created":{let b=`${c.workflowId}:${c.namespace}`;$.set(b,{id:Se(),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}`,f=$.get(b);f&&(f.writeCount++,f.finalPosition=Math.max(f.finalPosition,c.position)),I=Date.now();break}case"stream_read":{let b=`${c.workflowId}:${c.namespace}`,f=$.get(b);f&&f.readCount++,I=Date.now();break}case"stream_close":{let b=`${c.workflowId}:${c.namespace}`,f=$.get(b);if(f){f.streamState="closed",f.finalPosition=c.finalPosition;let P={type:"stream",id:f.id,namespace:f.namespace,state:"success",startTs:f.startTs,endTs:c.ts,durationMs:c.ts-f.startTs,writeCount:f.writeCount,readCount:f.readCount,finalPosition:c.finalPosition,streamState:"closed",backpressureOccurred:f.backpressureOccurred};T(P),$.delete(b)}I=Date.now();break}case"stream_error":{let b=`${c.workflowId}:${c.namespace}`,f=$.get(b);if(f){f.streamState="error";let P={type:"stream",id:f.id,namespace:f.namespace,state:"error",error:c.error,startTs:f.startTs,endTs:c.ts,durationMs:c.ts-f.startTs,writeCount:f.writeCount,readCount:f.readCount,finalPosition:c.position,streamState:"error",backpressureOccurred:f.backpressureOccurred};T(P),$.delete(b)}I=Date.now();break}case"stream_backpressure":{let b=`${c.workflowId}:${c.namespace}`,f=$.get(b);f&&(f.backpressureOccurred=!0),I=Date.now();break}}M(c)}function B(c){if(c.type==="scope_start")y.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=y.findIndex(C=>C.id===c.scopeId);if(b===-1)return;for(;y.length>b+1;){let C=y.pop(),J=C.type==="race"?{type:"race",id:C.id,name:C.name,state:_(C.children),startTs:C.startTs,endTs:c.ts,children:C.children}:{type:"parallel",id:C.id,name:C.name,state:_(C.children),startTs:C.startTs,endTs:c.ts,children:C.children,mode:C.type==="allSettled"?"allSettled":"all"};y[y.length-1].children.push(J)}let[f]=y.splice(b,1),P=f.type==="race"?{type:"race",id:f.id,name:f.name,state:_(f.children),startTs:f.startTs,endTs:c.ts,durationMs:c.durationMs,children:f.children,winnerId:c.winnerId}:{type:"parallel",id:f.id,name:f.name,state:_(f.children),startTs:f.startTs,endTs:c.ts,durationMs:c.durationMs,children:f.children,mode:f.type==="allSettled"?"allSettled":"all"};T(P)}}function K(c){if(c.type==="decision_start")v.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=v.find(f=>f.id===c.decisionId);if(b){let f=c.branchLabel,P=b.branches.get(f);if(P)P.taken=c.taken,c.taken&&b.pendingChildren.length>0&&(P.children.unshift(...b.pendingChildren),b.pendingChildren=[]);else{let C=c.taken?[...b.pendingChildren]:[];c.taken&&(b.pendingChildren=[]),b.branches.set(f,{label:c.branchLabel,condition:c.condition,taken:c.taken,children:C})}I=Date.now()}}else if(c.type==="decision_end"){let b=v.findIndex(f=>f.id===c.decisionId);if(b!==-1){let[f]=v.splice(b,1),P=v.splice(b),C=Array.from(f.branches.values());C.length===0&&f.pendingChildren.length>0&&(C=[{label:"default",taken:!0,children:[...f.pendingChildren]}]);let J=C.find(ve=>ve.taken)?.label,Kt={type:"decision",id:f.id,name:f.name,state:_(C.flatMap(ve=>ve.taken?ve.children:[])),startTs:f.startTs,endTs:c.ts,durationMs:c.durationMs,condition:f.condition,decisionValue:f.decisionValue,branchTaken:c.branchTaken??J,branches:C};T(Kt),v.push(...P),I=Date.now()}}}function _(c){return c.length===0?"success":c.some(C=>C.state==="error")?"error":c.every(C=>C.state==="success"||C.state==="cached")?"success":c.some(C=>C.state==="running")?"running":"pending"}function ne(){let c=[...N];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 $)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 oe(){let c=ne();t&&(c=we(c,r));let b={type:"workflow",id:d??a,workflowId:d??a,state:l,startTs:u,endTs:s,durationMs:h,children:c,error:p},f=x.shouldRun!==void 0||x.onBeforeStart!==void 0||x.onAfterStep.size>0;return{root:b,metadata:{createdAt:E,lastUpdatedAt:I},...f&&{hooks:x}}}function ie(){d=void 0,u=void 0,s=void 0,l="pending",p=void 0,h=void 0,m.clear(),y.length=0,v.length=0,$.clear(),N=[],E=Date.now(),I=E,x={onAfterStep:new Map},S=void 0,w.length=0,g=0}function Ht(){return[...w]}function Ft(c){return w[c]}function zt(c){return w[c]?.ir}function Ut(){w.length=0,g=0}return{handleEvent:O,handleScopeEvent:B,handleDecisionEvent:K,getIR:oe,reset:ie,getSnapshots:Ht,getSnapshotAt:Ft,getIRAt:zt,clearSnapshots:Ut,get hasActiveSteps(){return m.size>0},get state(){return l},get snapshotCount(){return w.length},get snapshotsEnabled(){return n},setSnapshotsEnabled(c){n=c}}}var Ie=require("awaitly");function z(e){return e.type==="step"}function Pe(e){return e.type==="sequence"}function j(e){return e.type==="parallel"}function H(e){return e.type==="race"}function Y(e){return e.type==="decision"}function Q(e){return e.type==="stream"}function tr(e){return"children"in e||e.type==="decision"&&"branches"in e}var He="\x1B[0m",rr="\x1B[1m",rt="\x1B[2m",nr="\x1B[31m",or="\x1B[32m",ir="\x1B[33m",ar="\x1B[34m",tt="\x1B[90m",sr="\x1B[37m";function X(e,t){return t?`${t}${e}${He}`:e}function be(e){return`${rr}${e}${He}`}function D(e){return`${rt}${e}${He}`}var V={pending:sr,running:ir,success:or,error:nr,aborted:tt,cached:ar,skipped:rt+tt};function cr(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 ye(e,t){let r=cr(e);return X(r,t[e])}function Re(e,t,r){return X(e,r[t])}function ee(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"},pe={cold:"\x1B[34m",cool:"\x1B[36m",neutral:"",warm:"\x1B[33m",hot:"\x1B[31m",critical:"\x1B[41m"},dr="\x1B[0m";function lr(e){return e<.2?pe.cold:e<.4?pe.cool:e<.6?pe.neutral:e<.8?pe.warm:e<.95?pe.hot:pe.critical}function nt(e,t){let r=lr(t);return r?`${r}${e}${dr}`:e}function ur(e){try{return(0,Ie.ok)(JSON.stringify(e,(r,o)=>{if(typeof o!="bigint")return o;let i=Number(o);return Number.isSafeInteger(i)?i:o.toString()}))}catch{return(0,Ie.err)("STRINGIFY_ERROR")}}function ot(e){let t=ur(e);return t.ok?t.value:"[unserializable]"}var it="\u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588";function ze(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(a=>{let d=(a-o)/n,u=Math.floor(d*(it.length-1));return it[u]}).join("")}function Fe(e,t){let r=ee(e).length,o=Math.max(0,t-r);return e+" ".repeat(o)}function pr(e,t){if(!t)return R.horizontal.repeat(e);let r=` ${t} `,o=ee(r).length,i=e-o;if(i<4)return R.horizontal.repeat(e);let n=2,a=i-n;return R.horizontal.repeat(n)+r+R.horizontal.repeat(a)}function at(e,t,r){let o=e.state==="success"?X("\u2699",r.success):X("\u26A0",r.error),i=e.durationMs!==void 0?D(` [${A(e.durationMs)}]`):"",n="";e.type==="shouldRun"&&e.context?.skipped?n=D(" \u2192 workflow skipped"):e.type==="shouldRun"&&e.context?.result===!0?n=D(" \u2192 proceed"):e.type==="onBeforeStart"&&e.context?.skipped?n=D(" \u2192 workflow skipped"):e.type==="onAfterStep"&&e.context?.stepKey&&(n=D(` (${e.context.stepKey})`));let a=e.state==="error"&&e.error?D(` error: ${String(e.error)}`):"";return`${o} ${D(t)}${n}${i}${a}`}function fr(e,t){let r=[];return e.shouldRun&&r.push(at(e.shouldRun,"shouldRun",t)),e.onBeforeStart&&r.push(at(e.onBeforeStart,"onBeforeStart",t)),r.length>0&&r.push(D("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),r}function ce(){return{name:"ascii",supportsLive:!0,render(e,t){let r={...V,...t.colors},o=Math.max(t.terminalWidth??60,5),i=o-4,n=[],a=e.root.name??"workflow",d=be(a);if(n.push(`${R.topLeft}${pr(o-2,d)}${R.topRight}`),n.push(`${R.vertical}${" ".repeat(o-2)}${R.vertical}`),e.hooks){let s=fr(e.hooks,r);for(let l of s)n.push(`${R.vertical} ${Fe(l,i)}${R.vertical}`)}let u=$e(e.root.children,t,r,0,e.hooks);for(let s of u)n.push(`${R.vertical} ${Fe(s,i)}${R.vertical}`);if(n.push(`${R.vertical}${" ".repeat(o-2)}${R.vertical}`),e.root.durationMs!==void 0&&t.showTimings){let s=e.root.state==="success"?"Completed":e.root.state==="aborted"?"Cancelled":"Failed",p=`${Re(s,e.root.state,r)} in ${A(e.root.durationMs)}`;n.push(`${R.vertical} ${Fe(p,i)}${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 $e(e,t,r,o,i){let n=[];for(let a of e)z(a)?n.push(Ue(a,t,r,i)):j(a)?n.push(...hr(a,t,r,o,i)):H(a)?n.push(...gr(a,t,r,o,i)):Y(a)?n.push(...wr(a,t,r,o,i)):Q(a)&&n.push(mr(a,t,r));return n}function Ue(e,t,r,o){let i=ye(e.state,r),n=e.name??e.key??"step",a=t,d=a.showHeatmap&&a.heatmapData?a.heatmapData.heat.get(e.key??"")??a.heatmapData.heat.get(e.name??"")??a.heatmapData.heat.get(e.id):void 0,u;d!==void 0?u=nt(n,d):u=Re(n,e.state,r);let s=`${i} ${u}`;if(t.showKeys&&e.key&&e.name&&(s+=D(` [key: ${e.key}]`)),e.input!==void 0){let p=typeof e.input=="string"?e.input:ot(e.input).slice(0,30);s+=D(` [in: ${p}${p.length>=30?"...":""}]`)}if(e.output!==void 0&&e.state==="success"){let p=typeof e.output=="string"?e.output:ot(e.output).slice(0,30);s+=D(` [out: ${p}${p.length>=30?"...":""}]`)}if(t.showTimings&&e.durationMs!==void 0){let p=A(e.durationMs),h=d!==void 0?nt(`[${p}]`,d):D(`[${p}]`);s+=` ${h}`}if(a.showSparklines&&a.timingHistory){let p=a.timingHistory.get(e.key??"")??a.timingHistory.get(e.name??"")??a.timingHistory.get(e.id);p&&p.length>1&&(s+=` ${D(ze(p))}`)}if(e.retryCount!==void 0&&e.retryCount>0&&(s+=D(` [${e.retryCount} ${e.retryCount===1?"retry":"retries"}]`)),e.timedOut){let p=e.timeoutMs!==void 0?` ${e.timeoutMs}ms`:"";s+=D(` [timeout${p}]`)}let l=e.key??e.id;if(o&&l&&o.onAfterStep.has(l)){let p=o.onAfterStep.get(l),h=p.state==="success"?X("\u2699",r.success):X("\u26A0",r.error),m=p.durationMs!==void 0?D(` ${A(p.durationMs)}`):"";s+=` ${h}${m}`}return s}function mr(e,t,r){let o=e.streamState==="active"?X("\u27F3",r.running):e.streamState==="closed"?X("\u2713",r.success):X("\u2717",r.error),i=`stream:${e.namespace}`,n=Re(i,e.state,r),a=D(`[W:${e.writeCount} R:${e.readCount}]`),d=`${o} ${n} ${a}`;return t.showTimings&&e.durationMs!==void 0&&(d+=` ${D(`[${A(e.durationMs)}]`)}`),e.backpressureOccurred&&(d+=D(" [backpressure]")),e.streamState==="closed"&&(d+=D(` pos:${e.finalPosition}`)),d}function hr(e,t,r,o,i){let n=[],a=" ".repeat(o),d=ye(e.state,r),u=e.name??"parallel",s=e.mode==="allSettled"?" (allSettled)":"";if(n.push(`${a}${R.teeRight}${R.teeDown}${R.horizontal} ${d} ${be(u)}${s}`),e.children.length===0)n.push(`${a}${R.vertical} ${D("(operations not individually tracked)")}`),n.push(`${a}${R.vertical} ${D("(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?`${a}${R.vertical} ${R.bottomLeft}`:`${a}${R.vertical} ${R.teeRight}`;if(z(p))n.push(`${m} ${Ue(p,t,r,i)}`);else{let y=$e([p],t,r,o+1,i);for(let v of y)n.push(`${a}${R.vertical} ${v}`)}}return t.showTimings&&e.durationMs!==void 0&&n.push(`${a}${R.bottomLeft}${R.horizontal}${R.horizontal} ${D(`[${A(e.durationMs)}]`)}`),n}function gr(e,t,r,o,i){let n=[],a=" ".repeat(o),d=ye(e.state,r),u=e.name??"race";if(n.push(`${a}${R.teeRight}\u26A1 ${d} ${be(u)}`),e.children.length===0)n.push(`${a}${R.vertical} ${D("(operations not individually tracked)")}`),n.push(`${a}${R.vertical} ${D("(wrap each operation with step() to see individual steps)")}`);else for(let s=0;s<e.children.length;s++){let l=e.children[s],h=s===e.children.length-1?`${a}${R.vertical} ${R.bottomLeft}`:`${a}${R.vertical} ${R.teeRight}`,y=e.winnerId&&l.id===e.winnerId?D(" (winner)"):"";if(z(l))n.push(`${h} ${Ue(l,t,r,i)}${y}`);else{let v=$e([l],t,r,o+1,i);for(let $ of v)n.push(`${a}${R.vertical} ${$}`)}}return t.showTimings&&e.durationMs!==void 0&&n.push(`${a}${R.bottomLeft}${R.horizontal}${R.horizontal} ${D(`[${A(e.durationMs)}]`)}`),n}function wr(e,t,r,o,i){let n=[],a=" ".repeat(o),d=ye(e.state,r),u=e.name??"decision",s=e.condition?D(` (${e.condition})`):"",l=e.decisionValue!==void 0?D(` = ${String(e.decisionValue)}`):"",p=e.branchTaken!==void 0?D(` \u2192 ${String(e.branchTaken)}`):"";n.push(`${a}${R.teeRight}${R.teeDown}${R.horizontal} ${d} ${be(u)}${s}${l}${p}`);for(let h=0;h<e.branches.length;h++){let m=e.branches[h],v=h===e.branches.length-1?`${a}${R.vertical} ${R.bottomLeft}`:`${a}${R.vertical} ${R.teeRight}`,$=m.taken?"\u2713":"\u2298",N=m.taken?r.success:r.skipped,E=X(`${$} ${m.label}`,N),I=m.condition?D(` (${m.condition})`):"";if(n.push(`${v} ${E}${I}`),m.children.length>0){let x=$e(m.children,t,r,o+1,i);for(let S of x)n.push(`${a}${R.vertical} ${S}`)}else m.taken||n.push(`${a}${R.vertical} ${D("(skipped)")}`)}return t.showTimings&&e.durationMs!==void 0&&n.push(`${a}${R.bottomLeft}${R.horizontal}${R.horizontal} ${D(`[${A(e.durationMs)}]`)}`),n}var Te=require("awaitly");function Ke(e){let t=[];for(let r of e)if(t.push(r),"children"in r&&Array.isArray(r.children)&&t.push(...Ke(r.children)),"branches"in r)for(let o of r.branches)t.push(...Ke(o.children));return t}function Ee(e,t){if(e.length===0)return 0;let r=Math.floor(e.length*t);return e[Math.min(r,e.length-1)]}function fe(e){return e<.2?"cold":e<.4?"cool":e<.6?"neutral":e<.8?"warm":e<.95?"hot":"critical"}function st(){let e=new Map,t=new Map,r=new Map,o=new Map,i=[];function n(x){return x.stepKey??x.stepId??x.name??"unknown"}function a(x){let S=new Map;for(let w of x)switch(w.type){case"step_start":{let g=n(w);S.set(g,{retried:!1,timedOut:!1});break}case"step_retry":{let g=n(w),k=S.get(g);k&&(k.retried=!0);break}case"step_timeout":{let g=n(w),k=S.get(g);k&&(k.timedOut=!0);break}case"step_success":{let g=n(w),k=S.get(g),T=e.get(g)??[];T.push(w.durationMs),e.set(g,T);let M=t.get(g)??{retried:0,total:0};M.total++,k?.retried&&M.retried++,t.set(g,M);let O=o.get(g)??{timedOut:0,total:0};O.total++,k?.timedOut&&O.timedOut++,o.set(g,O);let B=r.get(g)??{errors:0,total:0};B.total++,r.set(g,B),S.delete(g);break}case"step_error":{let g=n(w),k=S.get(g),T=e.get(g)??[];T.push(w.durationMs),e.set(g,T);let M=t.get(g)??{retried:0,total:0};M.total++,k?.retried&&M.retried++,t.set(g,M);let O=o.get(g)??{timedOut:0,total:0};O.total++,k?.timedOut&&O.timedOut++,o.set(g,O);let B=r.get(g)??{errors:0,total:0};B.total++,B.errors++,r.set(g,B),S.delete(g);break}}}function d(x){a(x.events)}function u(x){i.push(x)}function s(x){i.length>0&&(a(i),i=[])}function l(x){let S=e.get(x);if(!S||S.length===0)return;let w=[...S].sort((K,_)=>K-_),k=w.reduce((K,_)=>K+_,0)/w.length,T=w.reduce((K,_)=>K+(_-k)**2,0)/w.length,M=t.get(x)??{retried:0,total:1},O=r.get(x)??{errors:0,total:1},B=o.get(x)??{timedOut:0,total:1};return{nodeId:x,avgDurationMs:k,minDurationMs:w[0],maxDurationMs:w[w.length-1],stdDevMs:Math.sqrt(T),samples:w.length,retryRate:M.total>0?M.retried/M.total:0,timeoutRate:B.total>0?B.timedOut/B.total:0,errorRate:O.total>0?O.errors/O.total:0,percentiles:{p50:Ee(w,.5),p90:Ee(w,.9),p95:Ee(w,.95),p99:Ee(w,.99)}}}function p(x){return l(x)}function h(x,S="duration"){let w=new Map,g=Ke(x.root.children),k=[];for(let _ of g){let ne=("key"in _?_.key:void 0)??_.id??_.name,oe=l(ne);if(oe){let ie;switch(S){case"duration":ie=oe.avgDurationMs;break;case"retryRate":ie=oe.retryRate;break;case"errorRate":ie=oe.errorRate;break}k.push({id:_.id,value:ie})}}if(k.length===0)return{heat:w,metric:S,stats:{min:0,max:0,mean:0,threshold:0}};let T=k.map(_=>_.value),M=Math.min(...T),O=Math.max(...T),B=T.reduce((_,ne)=>_+ne,0)/T.length,K=O-M||1;for(let{id:_,value:ne}of k)w.set(_,(ne-M)/K);return{heat:w,metric:S,stats:{min:M,max:O,mean:B,threshold:B+(O-B)*.5}}}function m(){let x=new Map;for(let S of e.keys()){let w=l(S);w&&x.set(S,w)}return x}function y(x=10){return[...m().values()].sort((w,g)=>g.avgDurationMs-w.avgDurationMs).slice(0,x)}function v(x=10){return[...m().values()].filter(w=>w.errorRate>0).sort((w,g)=>g.errorRate-w.errorRate).slice(0,x)}function $(x=10){return[...m().values()].filter(w=>w.retryRate>0).sort((w,g)=>g.retryRate-w.retryRate).slice(0,x)}function N(){return JSON.stringify({timingData:Object.fromEntries(e),retryData:Object.fromEntries(t),errorData:Object.fromEntries(r),timeoutData:Object.fromEntries(o)})}function E(x){let S=JSON.parse(x);e.clear(),t.clear(),r.clear(),o.clear();for(let[w,g]of Object.entries(S.timingData??{}))e.set(w,g);for(let[w,g]of Object.entries(S.retryData??{}))t.set(w,g);for(let[w,g]of Object.entries(S.errorData??{}))r.set(w,g);for(let[w,g]of Object.entries(S.timeoutData??{}))o.set(w,g)}function I(){e.clear(),t.clear(),r.clear(),o.clear(),i=[]}return{addRun:d,addEvent:u,finalizeRun:s,getNodePerformance:p,getHeatmap:h,getSlowestNodes:y,getErrorProneNodes:v,getRetryProneNodes:$,getAllPerformance:m,exportData:N,importData:E,clear:I}}function br(){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 yr(){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 kr(e){return`heat_${e}`}function vr(){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 xr(e){try{return(0,Te.ok)(JSON.stringify(e,(r,o)=>{if(typeof o!="bigint")return o;let i=Number(o);return Number.isSafeInteger(i)?i:o.toString()}))}catch{return(0,Te.err)("STRINGIFY_ERROR")}}function ct(e){let t=xr(e);return t.ok?t.value:"[unserializable]"}function Sr(e,t,r){let o;if(e.shouldRun){let i="hook_shouldRun",n=e.shouldRun.state==="success"?"hook_success":"hook_error",a=e.shouldRun.state==="success"?"\u2699":"\u26A0",d=r.showTimings&&e.shouldRun.durationMs!==void 0?` ${A(e.shouldRun.durationMs)}`:"",u=e.shouldRun.context?.skipped?"\\nskipped workflow":e.shouldRun.context?.result===!0?"\\nproceed":"";t.push(` ${i}[["${a} shouldRun${u}${d}"]]:::${n}`),o=i}if(e.onBeforeStart){let i="hook_beforeStart",n=e.onBeforeStart.state==="success"?"hook_success":"hook_error",a=e.onBeforeStart.state==="success"?"\u2699":"\u26A0",d=r.showTimings&&e.onBeforeStart.durationMs!==void 0?` ${A(e.onBeforeStart.durationMs)}`:"",u=e.onBeforeStart.context?.skipped?"\\nskipped workflow":"";t.push(` ${i}[["${a} onBeforeStart${u}${d}"]]:::${n}`),o&&t.push(` ${o} --> ${i}`),o=i}return{lastHookId:o}}var dt=0,Me=new Set,Ne=new Set;function me(e="node"){return`${e}_${++dt}`}function Rr(){dt=0,Me.clear(),Ne.clear()}function U(e){return e.replace(/"/g,"#quot;").replace(/</g,"<").replace(/>/g,">").trim()}function lt(e){return U(e).replace(/[{}[\]()]/g,"")}function te(){return{name:"mermaid",supportsLive:!1,render(e,t){Rr();let r=[],o=t;r.push("flowchart TD");let i;e.hooks&&(i=Sr(e.hooks,r,t).lastHookId);let n="start";r.push(` ${n}(("\u25B6 Start"))`),i&&r.push(` ${i} --> ${n}`);let a=n;for(let u of e.root.children){let s=De(u,t,r,o,e.hooks);r.push(` ${a} --> ${s.entryId}`),a=s.exitId}if(["success","error","aborted"].includes(e.root.state)){let u="finish",s=e.root.state==="success"?"\u2713":e.root.state==="error"?"\u2717":"\u2298",l=e.root.state==="success"?"Done":e.root.state==="error"?"Failed":"Cancelled",p=`(("${s} ${l}"))`,h=e.root.state==="success"?":::success":e.root.state==="error"?":::error":":::aborted";r.push(` ${u}${p}${h}`),r.push(` ${a} --> ${u}`)}return r.push(""),r.push(...br()),o.showHeatmap&&r.push(...yr()),e.hooks&&r.push(...vr()),r.join(`
|
|
3
|
+
`)}}}function De(e,t,r,o,i){if(z(e))return Ir(e,t,r,o,i);if(j(e))return $r(e,t,r,o,i);if(H(e))return Er(e,t,r,o,i);if(Y(e))return Mr(e,t,r,o,i);if(Q(e))return Nr(e,t,r);let n=me("unknown");return r.push(` ${n}["Unknown Node"]`),{entryId:n,exitId:n}}function Ir(e,t,r,o,i){let n=t,a=n.showRetryEdges??!0,d=n.showErrorEdges??!0,u=n.showTimeoutEdges??!0,s=e.key?`step_${e.key.replace(/[^a-zA-Z0-9]/g,"_")}`:me("step");if(Ne.has(s)){let w=2;for(;Ne.has(`${s}_${w}`);)w++;s=`${s}_${w}`}Ne.add(s);let l=e.name??e.key??"Step",p=t.showKeys&&e.key&&e.name?`${l} [${e.key}]`:l,h=U(p),m=t.showTimings&&e.durationMs!==void 0?` ${A(e.durationMs)}`:"",y="";switch(e.state){case"success":y="\u2713 ";break;case"error":y="\u2717 ";break;case"cached":y="\u{1F4BE} ";break;case"running":y="\u23F3 ";break;case"skipped":y="\u2298 ";break}let v="";if(e.input!==void 0){let w=typeof e.input=="string"?U(e.input):U(ct(e.input).slice(0,20));v+=`\\nin: ${w}`}if(e.output!==void 0&&e.state==="success"){let w=typeof e.output=="string"?U(e.output):U(ct(e.output).slice(0,20));v+=`\\nout: ${w}`}let $="",N=e.key??e.id;if(i&&N&&i.onAfterStep.has(N)){let w=i.onAfterStep.get(N),g=w.state==="success"?"\u2699":"\u26A0",k=t.showTimings&&w.durationMs!==void 0?` ${A(w.durationMs)}`:"";$=`\\n${g} hook${k}`}let E=(y+h+v+$+m).trim(),I,x=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(x!==void 0){let w=fe(x);I=kr(w)}else I=e.state;let S;switch(e.state){case"error":S=`{{"${E}"}}`;break;case"cached":S=`[("${E}")]`;break;case"skipped":S=`["${E}"]`;break;default:S=`["${E}"]`}if(r.push(` ${s}${S}:::${I}`),a&&e.retryCount!==void 0&&e.retryCount>0){let w=`\u21BB ${e.retryCount} retr${e.retryCount===1?"y":"ies"}`;r.push(` ${s} -.->|"${w}"| ${s}`)}if(d&&e.state==="error"&&e.error!==void 0){let w=`ERR_${s}`,g=U(String(e.error)).slice(0,30);r.push(` ${w}{{"${g}"}}`),r.push(` ${s} -->|error| ${w}`),r.push(` style ${w} fill:#fee2e2,stroke:#dc2626`)}if(u&&e.timedOut){let w=`TO_${s}`,g=e.timeoutMs!==void 0?`${e.timeoutMs}ms`:"";r.push(` ${w}{{"\u23F1 Timeout ${g}"}}`),r.push(` ${s} -.->|timeout| ${w}`),r.push(` style ${w} fill:#fef3c7,stroke:#f59e0b`)}return{entryId:s,exitId:s}}function $r(e,t,r,o,i){let n=me("parallel"),a=`${n}_fork`,d=`${n}_join`,u=lt(e.name??"Parallel"),s=e.mode==="allSettled"?" (allSettled)":"";if(e.children.length===0){let h=n,m=U(`${u}${s}`),y="operations not individually tracked",v=t.showTimings&&e.durationMs!==void 0?` ${A(e.durationMs)}`:"";return r.push(` ${h}["${m}${v}\\n${y}"]:::${e.state}`),{entryId:h,exitId:h}}r.push(` subgraph ${n}["${u}${s}"]`),r.push(" direction TB"),r.push(` ${a}{"\u26A1 Fork"}`);let l=[];for(let h of e.children){let m=De(h,t,r,o,i);r.push(` ${a} --> ${m.entryId}`),l.push(m.exitId)}r.push(` ${d}{"\u2713 Join"}`);for(let h of l)r.push(` ${h} --> ${d}`);r.push(" end");let p=e.state;return r.push(` class ${n} ${p}`),{entryId:a,exitId:d}}function Er(e,t,r,o,i){let n=me("race"),a=`${n}_start`,d=`${n}_end`,u=lt(e.name??"Race");if(e.children.length===0){let h=n,m=U(u),y="operations not individually tracked",v=t.showTimings&&e.durationMs!==void 0?` ${A(e.durationMs)}`:"";return r.push(` ${h}["\u26A1 ${m}${v}\\n${y}"]:::${e.state}`),{entryId:h,exitId:h}}r.push(` subgraph ${n}["\u26A1 ${u}"]`),r.push(" direction TB"),r.push(` ${a}(("\u{1F3C1} Start"))`);let s=[],l;for(let h of e.children){let m=De(h,t,r,o,i),y=e.winnerId===h.id;r.push(` ${a} --> ${m.entryId}`),y&&(l=m.exitId),s.push({exitId:m.exitId,isWinner:y})}r.push(` ${d}(("\u2713 First"))`);for(let{exitId:h,isWinner:m}of s)m&&l?r.push(` ${h} ==>|\u{1F3C6} Winner| ${d}`):e.winnerId?r.push(` ${h} -. cancelled .-> ${d}`):r.push(` ${h} --> ${d}`);r.push(" end");let p=e.state;return r.push(` class ${n} ${p}`),{entryId:a,exitId:d}}function Mr(e,t,r,o,i){let n=e.key?`decision_${e.key.replace(/[^a-zA-Z0-9]/g,"_")}`:me("decision");if(Me.has(n)){let h=2;for(;Me.has(`${n}_${h}`);)h++;n=`${n}_${h}`}Me.add(n);let a=U(e.condition??"condition"),d=e.decisionValue!==void 0?` = ${U(String(e.decisionValue)).slice(0,30)}`:"",u=`${a}${d}`.trim();r.push(` ${n}{"${u}"}`);let s=[],l,p=new Set;for(let h of e.branches){let m=`${n}_${h.label.replace(/[^a-zA-Z0-9]/g,"_")}`;if(p.has(m)){let E=2;for(;p.has(`${m}_${E}`);)E++;m=`${m}_${E}`}p.add(m);let y=U(h.label),v=h.taken?`${y} \u2713`:`${y} skipped`,$=h.taken?":::success":":::skipped";r.push(` ${m}["${v}"]${$}`);let N=h.condition?`|${U(h.condition).replace(/\|/g,"")}|`:"";if(r.push(` ${n} -->${N} ${m}`),h.children.length>0){let E=m;for(let I of h.children){let x=De(I,t,r,o,i);r.push(` ${E} --> ${x.entryId}`),E=x.exitId}s.push(E),h.taken&&(l=E)}else s.push(m),h.taken&&(l=m)}return l?{entryId:n,exitId:l}:{entryId:n,exitId:n}}function Nr(e,t,r){let o=`stream_${e.namespace.replace(/[^a-zA-Z0-9]/g,"_")}_${me("")}`,i=`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 a=t.showTimings&&e.durationMs!==void 0?` ${A(e.durationMs)}`:"",d=e.backpressureOccurred?"\\nbackpressure":"",u=`${n}stream:${U(e.namespace)}\\n${i}${d}${a}`,s;return e.streamState==="error"?s="streamError":e.streamState==="active"?s="streamActive":s="stream",r.push(` ${o}{{"${u}"}}:::${s}`),{entryId:o,exitId:o}}var L={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"},Tr={cold:"\x1B[34m",cool:"\x1B[36m",neutral:"",warm:"\x1B[33m",hot:"\x1B[31m",critical:"\x1B[41m"},Dr="\x1B[0m";function Or(e,t){let r=[],o=[];for(let i=0;i<t;i++)r.push(Array(e).fill(" ")),o.push(Array(e).fill(void 0));return{cells:r,colors:o,width:e,height:t}}function W(e,t,r,o,i){t>=0&&t<e.width&&r>=0&&r<e.height&&(e.cells[r][t]=o,i&&(e.colors[r][t]=i))}function ft(e,t,r){return t>=0&&t<e.width&&r>=0&&r<e.height?e.cells[r][t]:" "}function Cr(e,t,r,o,i){W(e,t,r,L.topLeft);for(let n=1;n<o-1;n++)W(e,t+n,r,L.horizontal);W(e,t+o-1,r,L.topRight);for(let n=1;n<i-1;n++)W(e,t,r+n,L.vertical),W(e,t+o-1,r+n,L.vertical);W(e,t,r+i-1,L.bottomLeft);for(let n=1;n<o-1;n++)W(e,t+n,r+i-1,L.horizontal);W(e,t+o-1,r+i-1,L.bottomRight)}function ut(e,t,r,o,i){let n=ee(o).split("");for(let a=0;a<n.length;a++)W(e,t+a,r,n[a],i)}function re(e,t,r,o){let i=Math.min(r,o),n=Math.max(r,o);for(let a=i;a<=n;a++){let d=ft(e,t,a);d===L.horizontal?W(e,t,a,L.cross):(d===" "||d===L.vertical)&&W(e,t,a,L.vertical)}}function pt(e,t,r,o){let i=Math.min(r,o),n=Math.max(r,o);for(let a=i;a<=n;a++){let d=ft(e,a,t);d===L.vertical?W(e,a,t,L.cross):(d===" "||d===L.horizontal)&&W(e,a,t,L.horizontal)}}function de(e,t,r){W(e,t,r,L.arrowDown)}function Lr(e){let t=[];for(let r=0;r<e.height;r++){let o="";for(let i=0;i<e.width;i++){let n=e.colors[r][i],a=e.cells[r][i];n?o+=n+a+Dr:o+=a}t.push(o.trimEnd())}for(;t.length>0&&t[t.length-1]==="";)t.pop();return t.join(`
|
|
4
|
+
`)}var q=11,Z=2,he=2,Oe=3;function Ve(e,t){if(e.length<=t)return[e];let r=e.split(" "),o=[],i="";for(let n of r)i?i.length+1+n.length<=t?i+=" "+n:(o.push(i),i=n):i=n;if(i&&o.push(i),o.length===0)for(let n=0;n<e.length;n+=t)o.push(e.slice(n,n+t));return o}function mt(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 _r(e,t,r){let o=t.showStartEnd??!0,i=t,n=Math.floor(r/2),a=[],d=0;if(o){let s=Ce("start","start",["\u25B6 Start"],"success",n,d);a.push(s),d=s.bottomY+he}for(let s of e.root.children){let l=Le(s,n,d,r-4,t,i);a.push(l.node),d=l.bottomY+he}if(o&&["success","error","aborted"].includes(e.root.state)){let s=e.root.state==="success"?"\u2713 Done":e.root.state==="error"?"\u2717 Failed":"\u2298 Cancelled",l=Ce("end","end",[s],e.root.state,n,d);a.push(l),d=l.bottomY}return{nodes:a,totalHeight:d+2}}function Ce(e,t,r,o,i,n){let a=Math.max(...r.map(l=>ee(l).length)),d=Math.max(q,a+Z*2),u=r.length+2,s=i-Math.floor(d/2);return{id:e,type:t,label:r,state:o,x:s,y:n,width:d,height:u,centerX:i,bottomY:n+u-1}}function Le(e,t,r,o,i,n){if(z(e))return Wr(e,t,r,o,i,n);if(j(e)||H(e))return Ar(e,t,r,o,i,n);if(Y(e))return Pr(e,t,r,o,i,n);if(Q(e))return Br(e,t,r,o,i,n);let a=Ce(e.id,"step",["?"],e.state,t,r);return{node:a,bottomY:a.bottomY}}function Wr(e,t,r,o,i,n){let a=e.name??e.key??"step",d=mt(e.state),u=[],s=`${d} ${a}`;i.showKeys&&e.key&&e.name&&(s+=` [${e.key}]`);let l=Math.min(o-Z*2,40);if(u.push(...Ve(s,l)),i.showTimings&&e.durationMs!==void 0&&u.push(`[${A(e.durationMs)}]`),e.retryCount&&e.retryCount>0&&u.push(`${e.retryCount}x retry`),e.timedOut&&u.push("timeout"),n?.showSparklines&&n.timingHistory){let N=n.timingHistory.get(e.key??"")??n.timingHistory.get(e.name??"")??n.timingHistory.get(e.id);N&&N.length>1&&u.push(ze(N,8))}let p=Math.max(...u.map(N=>ee(N).length)),h=Math.max(q,p+Z*2),m=u.length+2,y=t-Math.floor(h/2),v;if(n?.showHeatmap&&n.heatmapData){let N=e.key??e.name??e.id;v=n.heatmapData.heat.get(e.id)??n.heatmapData.heat.get(N)}let $={id:e.id,type:"step",label:u,state:e.state,x:y,y:r,width:h,height:m,centerX:t,bottomY:r+m-1,metadata:v!==void 0?{heat:v}:void 0};return{node:$,bottomY:$.bottomY}}function Br(e,t,r,o,i,n){let a=`stream:${e.namespace}`,d=e.streamState==="active"?"\u27F3":e.streamState==="closed"?"\u2713":"\u2717",u=[],s=`${d} ${a}`,l=Math.min(o-Z*2,40);u.push(...Ve(s,l)),u.push(`W:${e.writeCount} R:${e.readCount}`),i.showTimings&&e.durationMs!==void 0&&u.push(`[${A(e.durationMs)}]`),e.backpressureOccurred&&u.push("backpressure");let p=Math.max(...u.map($=>ee($).length)),h=Math.max(q,p+Z*2),m=u.length+2,y=t-Math.floor(h/2),v={id:e.id,type:"stream",label:u,state:e.state,x:y,y:r,width:h,height:m,centerX:t,bottomY:r+m-1,metadata:{streamState:e.streamState,backpressureOccurred:e.backpressureOccurred}};return{node:v,bottomY:v.bottomY}}function Ar(e,t,r,o,i,n){let a=H(e),d=e.name??(a?"race":"parallel"),s=`${a?"\u26A1":"\u2AD8"} ${d}`;if(e.children.length===0){let g=[s,"(not tracked)"],k=Ce(e.id,a?"race":"parallel",g,e.state,t,r);return{node:k,bottomY:k.bottomY}}let l=Math.floor((o-Oe*(e.children.length-1))/e.children.length),p=[];for(let g of e.children){let k=je(g,Math.max(l,q),i,n);p.push(k.width)}let h=p.reduce((g,k)=>g+k,0)+Oe*(e.children.length-1),m=h>o&&e.children.length>1,y=Math.max(q,s.length+Z*2),v=3,$=t-Math.floor(y/2),N=r;N+=v,N+=1,N+=1;let E=[];if(m)for(let g=0;g<e.children.length;g++){let k=e.children[g],T=Le(k,t,N,o,i,n);a&&H(e)&&e.winnerId===k.id&&(T.node.metadata={...T.node.metadata,isWinner:!0}),E.push(T.node),N=T.bottomY+he}else{let g=t-Math.floor(h/2);for(let k=0;k<e.children.length;k++){let T=e.children[k],M=g+Math.floor(p[k]/2),O=Le(T,M,N,p[k],i,n);a&&H(e)&&e.winnerId===T.id&&(O.node.metadata={...O.node.metadata,isWinner:!0}),E.push(O.node),g+=p[k]+Oe}}let I=Math.max(...E.map(g=>g.bottomY)),S=!m&&E.length>1?I+2:I;return{node:{id:e.id,type:a?"race":"parallel",label:[s],state:e.state,x:$,y:r,width:y,height:v,centerX:t,bottomY:S,children:E,metadata:{verticalLayout:m}},bottomY:S}}function Pr(e,t,r,o,i,n){let a=e.name??"decision",d=e.condition?` (${e.condition.slice(0,20)})`:"",u=`\u25C7 ${a}${d}`,s=Math.min(o-Z*2,40),l=Ve(u,s),p=Math.max(...l.map(S=>ee(S).length)),h=Math.max(q,p+Z*2),m=l.length+2,y=t-Math.floor(h/2),v=e.branches.find(S=>S.taken),$=v&&v.children.length>0?v:e.branches.find(S=>S.children.length>0);if(!$||$.children.length===0){let S={id:e.id,type:"decision",label:l,state:e.state,x:y,y:r,width:h,height:m,centerX:t,bottomY:r+m-1};return{node:S,bottomY:S.bottomY}}let N=r+m+he,E=[];for(let S of $.children){let w=Le(S,t,N,o,i,n);E.push(w.node),N=w.bottomY+he}let I=E.length>0?E[E.length-1].bottomY:r+m-1;return{node:{id:e.id,type:"decision",label:l,state:e.state,x:y,y:r,width:h,height:m,centerX:t,bottomY:I,children:E},bottomY:I}}function je(e,t,r,o){if(z(e)){let i=e.name??e.key??"step",n=mt(e.state),a=1;r.showTimings&&e.durationMs!==void 0&&a++,e.retryCount&&e.retryCount>0&&a++,e.timedOut&&a++,o?.showSparklines&&(o.timingHistory?.has(e.key??"")||o.timingHistory?.has(e.name??"")||o.timingHistory?.has(e.id))&&a++;let d=`${n} ${i}`;r.showKeys&&e.key&&e.name&&(d+=` [${e.key}]`);let u=Math.min(t,Math.max(q,d.length+Z*2)),s=a+2;return{width:u,height:s}}if(j(e)||H(e)){if(e.children.length===0)return{width:q+4,height:4};let i=Math.floor(t/e.children.length),n=0,a=0;for(let d of e.children){let u=je(d,i,r,o);n+=u.width,a=Math.max(a,u.height)}return n+=Oe*(e.children.length-1),{width:Math.max(n,q),height:5+a+2}}if(Y(e)){let i=e.branches.find(a=>a.taken),n=0;if(i)for(let a of i.children){let d=je(a,t,r,o);n+=d.height+he}return{width:Math.min(t,30),height:3+n}}if(Q(e)){let i=`stream:${e.namespace}`,n=2;r.showTimings&&e.durationMs!==void 0&&n++,e.backpressureOccurred&&n++;let a=Math.min(t,Math.max(q,i.length+Z*2+4)),d=n+2;return{width:a,height:d}}return{width:q,height:3}}function Hr(e,t,r){let o={...V,...r.colors};for(let i=0;i<t.length;i++){let n=t[i],a=i===t.length-1;if(_e(e,n,o),!a){let d=t[i+1],u=n.centerX,s=n.bottomY+1,l=d.centerX,p=d.y-1;re(e,u,s,p-1),de(e,l,p)}}}function _e(e,t,r){let o=t.type!=="start",i=t.type!=="end"&&(!t.children||t.children.length===0);Cr(e,t.x,t.y,t.width,t.height),o&&W(e,t.centerX,t.y,L.teeUp),(i||t.children&&t.children.length>0)&&W(e,t.centerX,t.y+t.height-1,L.teeDown);let n=t.width-Z*2,a=Kr(t,r);for(let d=0;d<t.label.length;d++){let u=t.label[d],s=t.x+1+Math.floor((n-ee(u).length)/2),l=t.y+1+d;ut(e,s,l,u,a)}t.metadata?.isWinner&&ut(e,t.x+t.width-2,t.y,"\u{1F3C6}"),t.children&&t.children.length>0&&(t.type==="parallel"||t.type==="race"?Fr(e,t,r):zr(e,t,r))}function Fr(e,t,r){let o=t.children;if(o.length===0)return;let i=t.y+t.height,n=t.centerX;if(t.metadata?.verticalLayout===!0){let d=o[0];re(e,n,i,d.y-2),de(e,d.centerX,d.y-1);for(let u=0;u<o.length;u++){let s=o[u];if(_e(e,s,r),u<o.length-1){let l=o[u+1];re(e,s.centerX,s.bottomY+1,l.y-2),de(e,l.centerX,l.y-1)}}return}if(o.length===1)re(e,n,i,o[0].y-2),de(e,o[0].centerX,o[0].y-1);else{let d=o.map(l=>l.centerX),u=Math.min(...d),s=Math.max(...d);re(e,n,i,i+1),pt(e,i+1,u,s),W(e,n,i+1,L.teeUp);for(let l of o){let p=l.centerX;p===u?W(e,p,i+1,L.topLeft):p===s?W(e,p,i+1,L.topRight):p!==n&&W(e,p,i+1,L.teeDown),re(e,p,i+2,l.y-2),de(e,p,l.y-1)}}for(let d of o)_e(e,d,r);if(o.length>1){let d=o.map(m=>m.bottomY),u=Math.max(...d),s=u+1,l=o.map(m=>m.centerX),p=Math.min(...l),h=Math.max(...l);for(let m of o)m.bottomY<u&&re(e,m.centerX,m.bottomY+1,s-1);pt(e,s,p,h);for(let m of o){let y=m.centerX;y===p?W(e,y,s,L.bottomLeft):y===h?W(e,y,s,L.bottomRight):W(e,y,s,L.teeUp)}W(e,t.centerX,s,L.teeDown),W(e,t.centerX,s+1,L.vertical)}}function zr(e,t,r){let o=t.children;if(o.length===0)return;let i=t.y+t.height,n=o[0];re(e,t.centerX,i,n.y-2),de(e,n.centerX,n.y-1);for(let a=0;a<o.length;a++){let d=o[a];if(_e(e,d,r),a<o.length-1){let u=o[a+1];re(e,d.centerX,d.bottomY+1,u.y-2),de(e,u.centerX,u.y-1)}}}var Ur={active:"\x1B[36m",closed:"\x1B[32m",error:"\x1B[31m"};function Kr(e,t){if(e.metadata?.heat!==void 0){let r=fe(e.metadata.heat);return Tr[r]||void 0}return e.type==="stream"&&e.metadata?.streamState?Ur[e.metadata.streamState]||void 0:t[e.state]||void 0}function le(){return{name:"flowchart",supportsLive:!1,render(e,t){let r=t.terminalWidth??80,{nodes:o,totalHeight:i}=_r(e,t,r),n=Or(r,i);return Hr(n,o,t),Lr(n)}}}function jr(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}function Vr(e){let t=[];function r(o){for(let i of o)if(z(i))t.push(i);else if(Pe(i))r(i.children);else if(j(i)||H(i))r(i.children);else if(Y(i))for(let n of i.branches)n.taken&&r(n.children)}return r(e),t}function Gr(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)),e.metadata&&(e.metadata.domain&&(t.domain=e.metadata.domain),e.metadata.owner&&(t.owner=e.metadata.owner),e.metadata.intent&&(t.intent=e.metadata.intent),e.metadata.calls?.length&&(t.calls=e.metadata.calls)),e.errorDiagnostics&&(t.errorDiagnostics={tag:e.errorDiagnostics.tag,origin:e.errorDiagnostics.origin},e.errorDiagnostics.classification?.severity&&(t.errorDiagnostics.severity=e.errorDiagnostics.classification.severity),e.errorDiagnostics.classification?.retryable!==void 0&&(t.errorDiagnostics.retryable=e.errorDiagnostics.classification.retryable)),t}function Yr(e){let t=0,r=0,o=0,i=0,n=0,a;for(let s of e)s.state==="success"&&t++,s.state==="error"&&r++,s.state==="cached"&&o++,s.state==="skipped"&&i++,s.retryCount!==void 0&&(n+=s.retryCount),s.durationMs!==void 0&&(!a||s.durationMs>a.durationMs)&&(a={name:s.name??s.key??s.id,durationMs:s.durationMs});let d=new Map;for(let s of e){let l=s.metadata?.domain;if(l&&(s.state==="success"||s.state==="error")){let p=d.get(l)??{total:0,errors:0,totalDuration:0};p.total++,s.state==="error"&&p.errors++,s.durationMs!==void 0&&(p.totalDuration+=s.durationMs),d.set(l,p)}}let u;if(d.size>0){u={};for(let[s,l]of d)u[s]={total:l.total,errors:l.errors,avgDurationMs:l.total>0?Math.round(l.totalDuration/l.total):0}}return{totalSteps:e.length,successCount:t,errorCount:r,cacheHits:o,skippedCount:i,totalRetries:n,slowestStep:a,...u&&{byDomain:u}}}function Jr(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 i={stepKey:r};o.durationMs!==void 0&&(i.durationMs=o.durationMs),o.error!==void 0&&o.error!==null&&(i.error=String(o.error)),t.onAfterStep.push(i)}}return t}function Xr(e,t){let r=e.root,o=Vr(r.children),i=t.includeDiagram??!0,n=t.stripAnsiColors??!0,a={workflow:{id:r.workflowId,name:r.name,state:r.state,durationMs:r.durationMs,startedAt:r.startTs,completedAt:r.endTs},steps:o.map(Gr),summary:Yr(o)};if(e.hooks){let d=Jr(e.hooks);Object.keys(d).length>0&&(a.hooks=d)}if(i){let s=((t.diagramFormat??"ascii")==="flowchart"?le():ce()).render(e,t);n&&(s=jr(s)),a.diagram=s}return a}function ke(){return{name:"logger",supportsLive:!1,render(e,t){let o=Xr(e,t);return JSON.stringify(o)}}}function ht(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};
|
|
@@ -1475,7 +1475,7 @@ body {
|
|
|
1475
1475
|
return min + 'm ' + sec + 's';
|
|
1476
1476
|
}
|
|
1477
1477
|
})();
|
|
1478
|
-
`}var ae=160,ge=50,Ge=40,qr=30,F=20;function Zr(e,t="TB",r){let o=t==="TB"||t==="BT",i=t==="RL"||t==="BT",n=[],a=F,
|
|
1478
|
+
`}var ae=160,ge=50,Ge=40,qr=30,F=20;function Zr(e,t="TB",r){let o=t==="TB"||t==="BT",i=t==="RL"||t==="BT",n=[],a=F,d=F,u=0,s=0;for(let h of e){let m=Ye(h,a,d,o,r);n.push(m.node),o?(d+=m.height+qr,u=Math.max(u,m.width),s=d):(a+=m.width+Ge,s=Math.max(s,m.height),u=a)}let l=u+F,p=s+F;if(i)for(let h of n)bt(h,l,p,o);return{nodes:n,width:l,height:p}}function bt(e,t,r,o){if(o?e.y=r-e.y-e.height:e.x=t-e.x-e.width,e.children)for(let i of e.children)bt(i,t,r,o)}function Ye(e,t,r,o,i){if(z(e)){let n=e.name??e.key??"step",a=i?.showKeys&&e.key&&e.name?`${n} [key: ${e.key}]`:n;return{node:{id:e.id,name:a,type:"step",state:e.state,x:t,y:r,width:ae,height:ge,durationMs:e.durationMs},width:ae,height:ge}}if(Q(e)){let n=e.streamState==="active"?`stream:${e.namespace} \u27F3`:e.streamState==="error"?`stream:${e.namespace} \u2717`:`stream:${e.namespace} \u2713`;return{node:{id:e.id,name:n,type:"stream",state:e.state,x:t,y:r,width:ae,height:ge,durationMs:e.durationMs},width:ae,height:ge}}if(j(e)||H(e)){let n=j(e)?"parallel":"race",a=e.name??n,d=[],u=t+F,s=r+F+20,l=0;for(let y of e.children){let v=Ye(y,u,s,!0,i);d.push(v.node),u+=v.width+Ge,l=Math.max(l,v.height)}let p=u-t-F,h=Math.max(p+F,ae+F*2),m=l+F*2+20;return{node:{id:e.id,name:a,type:n,state:e.state,x:t,y:r,width:h,height:m,durationMs:e.durationMs,children:d,containerType:n,containerLabel:n==="parallel"?"PARALLEL":"RACE"},width:h,height:m}}if(Y(e)){let n=e.name??"decision",a=[],d=t+F,u=r+F+20,s=0;for(let h of e.branches)for(let m of h.children){let y=Ye(m,d,u,!0,i);a.push(y.node),d+=y.width+Ge,s=Math.max(s,y.height)}let l=Math.max(d-t,ae+F*2),p=s+F*2+20;return{node:{id:e.id,name:n,type:"decision",state:e.state,x:t,y:r,width:l,height:p,durationMs:e.durationMs,children:a,containerType:"decision",containerLabel:"DECISION"},width:l,height:p}}return{node:{id:e.id,name:e.name??"unknown",type:e.type,state:e.state,x:t,y:r,width:ae,height:ge},width:ae,height:ge}}function yt(e,t){return e.containerType?en(e,t):Qr(e,t)}function Qr(e,t){let o=t&&e.durationMs!==void 0?A(e.durationMs):"";return`
|
|
1479
1479
|
<g class="wv-node wv-node--${e.state}" data-node-id="${vt(e.id)}" transform="translate(${e.x}, ${e.y})">
|
|
1480
1480
|
<rect width="${e.width}" height="${e.height}" rx="8" ry="8" />
|
|
1481
1481
|
<text x="${e.width/2}" y="${e.height/2-(o?4:0)}">${Xe(rn(e.name,e.name.includes("[key:")?40:20))}</text>
|
|
@@ -1490,26 +1490,26 @@ body {
|
|
|
1490
1490
|
${o}
|
|
1491
1491
|
</g>
|
|
1492
1492
|
</g>
|
|
1493
|
-
`}function Je(e,t){for(let r of e){if(r.id===t)return r;if("children"in r&&r.children){let o=Je(r.children,t);if(o)return o}if("branches"in r&&r.branches)for(let o of r.branches){let i=Je(o.children,t);if(i)return i}}}function tn(e,t){let r=[];function o(n,a){if(Math.abs(n.y-a.y)<n.height){let u=n.x+n.width,
|
|
1494
|
-
<path class="wv-edge" d="M ${u} ${
|
|
1495
|
-
<polygon class="wv-edge-arrow" points="${l-8},${
|
|
1496
|
-
`)}else{let u=n.x+n.width/2,
|
|
1497
|
-
<path class="wv-edge" d="M ${u} ${
|
|
1498
|
-
<polygon class="wv-edge-arrow" points="${l-4},${
|
|
1499
|
-
`)}}function i(n){for(let a=0;a<n.length-1;a++)o(n[a],n[a+1]);for(let a of n)if(a.children&&a.children.length>0)if(a.containerType==="decision"){let
|
|
1493
|
+
`}function Je(e,t){for(let r of e){if(r.id===t)return r;if("children"in r&&r.children){let o=Je(r.children,t);if(o)return o}if("branches"in r&&r.branches)for(let o of r.branches){let i=Je(o.children,t);if(i)return i}}}function tn(e,t){let r=[];function o(n,a){if(Math.abs(n.y-a.y)<n.height){let u=n.x+n.width,s=n.y+n.height/2,l=a.x,p=a.y+a.height/2;r.push(`
|
|
1494
|
+
<path class="wv-edge" d="M ${u} ${s} L ${l-8} ${p}" />
|
|
1495
|
+
<polygon class="wv-edge-arrow" points="${l-8},${p-4} ${l-8},${p+4} ${l},${p}" />
|
|
1496
|
+
`)}else{let u=n.x+n.width/2,s=n.y+n.height,l=a.x+a.width/2,p=a.y;r.push(`
|
|
1497
|
+
<path class="wv-edge" d="M ${u} ${s} L ${l} ${p-8}" />
|
|
1498
|
+
<polygon class="wv-edge-arrow" points="${l-4},${p-8} ${l+4},${p-8} ${l},${p}" />
|
|
1499
|
+
`)}}function i(n){for(let a=0;a<n.length-1;a++)o(n[a],n[a+1]);for(let a of n)if(a.children&&a.children.length>0)if(a.containerType==="decision"){let d=Je(t.root.children,a.id);if(d&&d.type==="decision"&&d.branches){let u=0;for(let s of d.branches){let l=s.children.length;l>0&&o(a,a.children[u]);for(let p=0;p<l-1;p++)o(a.children[u+p],a.children[u+p+1]);u+=l}}}else if(a.containerType==="parallel"||a.containerType==="race")for(let d of a.children)d.children&&d.children.length>0&&i([d]);else i(a.children)}return i(e),r.join(`
|
|
1500
1500
|
`)}function kt(e,t){let r=Zr(e.root.children,t.layout,t),o=Math.max(r.width,400),i=Math.max(r.height,300),n=r.nodes.map(l=>yt(l,t.showTimings)).join(`
|
|
1501
|
-
`),a=tn(r.nodes,e),
|
|
1501
|
+
`),a=tn(r.nodes,e),d=e.root.name??"Workflow",u=ht(t.theme),s=gt({wsUrl:t.wsUrl,interactive:t.interactive,timeTravel:t.timeTravel,heatmap:t.heatmap});return`<!DOCTYPE html>
|
|
1502
1502
|
<html lang="en">
|
|
1503
1503
|
<head>
|
|
1504
1504
|
<meta charset="UTF-8">
|
|
1505
1505
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
1506
|
-
<title>${Xe(
|
|
1506
|
+
<title>${Xe(d)} - Workflow Visualizer</title>
|
|
1507
1507
|
<style>${u}</style>
|
|
1508
1508
|
</head>
|
|
1509
1509
|
<body>
|
|
1510
1510
|
<div class="workflow-visualizer">
|
|
1511
1511
|
<header class="wv-header">
|
|
1512
|
-
<h1>${Xe(
|
|
1512
|
+
<h1>${Xe(d)}</h1>
|
|
1513
1513
|
<div class="wv-controls">
|
|
1514
1514
|
${t.interactive?`
|
|
1515
1515
|
<button id="load-json-btn" class="wv-btn" title="Load workflow state from JSON">Load JSON</button>
|
|
@@ -1671,7 +1671,7 @@ body {
|
|
|
1671
1671
|
${t.heatmapData?`window.__PERFORMANCE_DATA__ = ${wt({heat:Object.fromEntries(t.heatmapData.heat),metric:t.heatmapData.metric,stats:t.heatmapData.stats})};`:""}
|
|
1672
1672
|
})();
|
|
1673
1673
|
</script>
|
|
1674
|
-
<script>${
|
|
1674
|
+
<script>${s}</script>
|
|
1675
1675
|
</body>
|
|
1676
|
-
</html>`}function Xe(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function vt(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function rn(e,t){return e.length<=t?e:e.slice(0,t-1)+"\u2026"}function nn(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,i)=>{if(typeof i=="bigint")return i.toString();if(o==="error"&&i!==void 0&&i!==null)return String(i);if(typeof i=="object"&&i!==null){if(t.has(i))return"[Circular]";t.add(i)}return i}).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}var xt={interactive:!0,timeTravel:!0,heatmap:!0,animationDuration:200,theme:"auto",layout:"TB"};function St(){return{name:"html",supportsLive:!0,render(e,t){let r={...t,...xt,...t};return kt(e,r)}}}function Rt(e,t={}){let r={showTimings:!0,showKeys:!1,colors:{pending:"#6c757d",running:"#ffc107",success:"#198754",error:"#dc3545",aborted:"#6c757d",cached:"#0dcaf0",skipped:"#adb5bd"},...xt,...t};return kt(e,r)}function We(e,t={}){let{condition:r,value:o,name:i,workflowId:n=crypto.randomUUID(),emit:a}=t,
|
|
1676
|
+
</html>`}function Xe(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function vt(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function rn(e,t){return e.length<=t?e:e.slice(0,t-1)+"\u2026"}function nn(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,i)=>{if(typeof i=="bigint")return i.toString();if(o==="error"&&i!==void 0&&i!==null)return String(i);if(typeof i=="object"&&i!==null){if(t.has(i))return"[Circular]";t.add(i)}return i}).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}var xt={interactive:!0,timeTravel:!0,heatmap:!0,animationDuration:200,theme:"auto",layout:"TB"};function St(){return{name:"html",supportsLive:!0,render(e,t){let r={...t,...xt,...t};return kt(e,r)}}}function Rt(e,t={}){let r={showTimings:!0,showKeys:!1,colors:{pending:"#6c757d",running:"#ffc107",success:"#198754",error:"#dc3545",aborted:"#6c757d",cached:"#0dcaf0",skipped:"#adb5bd"},...xt,...t};return kt(e,r)}function We(e,t={}){let{condition:r,value:o,name:i,workflowId:n=crypto.randomUUID(),emit:a}=t,d=Date.now(),u,s=[];function l(h,m,y){s.push({label:h,condition:y,taken:m}),m&&(u=h),a?.({type:"decision_branch",workflowId:n,decisionId:e,branchLabel:h,condition:y,taken:m,ts:Date.now()})}function p(){let h=Date.now()-d;a?.({type:"decision_end",workflowId:n,decisionId:e,branchTaken:u,ts:Date.now(),durationMs:h})}return a?.({type:"decision_start",workflowId:n,decisionId:e,condition:r,decisionValue:o,name:i,ts:d}),{takeBranch:l,end:p,getBranchTaken:()=>u,getBranches:()=>[...s]}}function It(e,t,r={}){let o=We(e,{...r,condition:r.condition??String(t),value:r.value??t}),i=!1;return{...o,condition:t,then:()=>{i||(i=!0,o.takeBranch("if",!0),o.takeBranch("else",!1))},else:()=>{i||(i=!0,o.takeBranch("if",!1),o.takeBranch("else",!0))}}}function $t(e,t,r={}){let o=We(e,{...r,condition:r.condition??`switch(${String(t)})`,value:t});return{...o,value:t,case:(i,n)=>{o.takeBranch(`case '${i}'`,n,`value === '${i}'`)},default:i=>{o.takeBranch("default",i)}}}function Et(e={}){let{maxSnapshots:t=1e3,autoRecord:r=!0,builderOptions:o={}}=e,i=ue({detectParallel:!1,...o,enableSnapshots:r,maxSnapshots:t}),n={snapshots:[],currentIndex:-1,isPlaying:!1,playbackSpeed:1,isRecording:r},a=new Set,d=null;function u(){let M=x();for(let O of a)O(M)}function s(){n.snapshots=i.getSnapshots(),n.isRecording&&n.snapshots.length>0&&(n.currentIndex=n.snapshots.length-1)}function l(M){i.handleEvent(M),n.isRecording&&(s(),u())}function p(M){let O=i.getSnapshots();if(!(M<0||M>=O.length))return n.currentIndex=M,n.snapshots=O,u(),O[M].ir}function h(){return p(n.currentIndex+1)}function m(){return p(n.currentIndex-1)}function y(M=1){let O=i.getSnapshots();if(O.length===0)return;n.currentIndex===-1&&(n.currentIndex=0,n.snapshots=O),n.playbackSpeed=M,n.isPlaying=!0,u();let B=()=>{if(!n.isPlaying)return;let K=i.getSnapshots();if(n.currentIndex<K.length-1){let _=K[n.currentIndex],ie=(K[n.currentIndex+1].timestamp-_.timestamp)/n.playbackSpeed;d=setTimeout(()=>{h(),B()},Math.max(16,ie))}else v()};B()}function v(){n.isPlaying=!1,d&&(clearTimeout(d),d=null),u()}function $(){let M=i.getSnapshots();return n.currentIndex>=0&&n.currentIndex<M.length?M[n.currentIndex].ir:i.getIR()}function N(M){return i.getIRAt(M)}function E(){return i.getSnapshots()}function I(M){return i.getSnapshotAt(M)}function x(){return{snapshots:i.getSnapshots(),currentIndex:n.currentIndex,isPlaying:n.isPlaying,playbackSpeed:n.playbackSpeed,isRecording:n.isRecording}}function S(M){return a.add(M),()=>a.delete(M)}function w(){n.isRecording=!0,i.setSnapshotsEnabled(!0),s(),u()}function g(){n.isRecording=!1,i.setSnapshotsEnabled(!1),u()}function k(){v(),i.reset(),i.setSnapshotsEnabled(r),n={snapshots:[],currentIndex:-1,isPlaying:!1,playbackSpeed:1,isRecording:r},u()}function T(){return i}return{handleEvent:l,seek:p,stepForward:h,stepBackward:m,play:y,pause:v,getCurrentIR:$,getIRAt:N,getSnapshots:E,getSnapshotAt:I,getState:x,onStateChange:S,startRecording:w,stopRecording:g,reset:k,getBuilder:T}}var Mt=qt(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 Be(e){let r=new TextEncoder().encode(e),o=Mt.default.deflate(r);return an(o)}var Nt="https://kroki.io";function sn(e,t,r,o={}){let i=o.baseUrl??Nt,n=Be(r);return`${i}/${e}/${t}/${n}`}function se(e,t="svg",r={}){let o=te(),i={showTimings:!0,showKeys:!1,terminalWidth:80,colors:V},n=o.render(e,i);return sn("mermaid",t,n,r)}function Tt(e,t={}){return se(e,"svg",t)}function Dt(e,t={}){return se(e,"png",t)}function Ot(e={}){let t=e.baseUrl??Nt;return{toUrl(r,o){return se(r,o,{baseUrl:t})},toSvgUrl(r){return se(r,"svg",{baseUrl:t})},toPngUrl(r){return se(r,"png",{baseUrl:t})},toPdfUrl(r){return se(r,"pdf",{baseUrl:t})},getBaseUrl(){return t}}}var Ct="https://mermaid.ink";function qe(e){return`pako:${Be(e)}`}function cn(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 Ze(e,t,r={}){let o=cn(r),i=o.baseUrl??Ct,n=qe(t),a=dn(e,o);return`${i}/${e}/${n}${a}`}function G(e,t="svg",r={}){let o=te(),i={showTimings:!0,showKeys:!1,terminalWidth:80,colors:V},n=o.render(e,i);return Ze(t,n,r)}function Lt(e,t={}){return G(e,"svg",t)}function _t(e,t={}){return G(e,"img",{...t,imageType:"png"})}function Wt(e,t={}){return G(e,"img",{...t,imageType:"jpeg"})}function Bt(e,t={}){return G(e,"img",{...t,imageType:"webp"})}function At(e,t={}){return G(e,"pdf",t)}function Pt(e={}){let t=e.baseUrl??Ct;return{toUrl(r,o){return G(r,o,e)},toSvgUrl(r){return G(r,"svg",e)},toPngUrl(r){return G(r,"img",{...e,imageType:"png"})},toJpegUrl(r){return G(r,"img",{...e,imageType:"jpeg"})},toWebpUrl(r){return G(r,"img",{...e,imageType:"webp"})},toPdfUrl(r){return G(r,"pdf",e)},getBaseUrl(){return t},getOptions(){return{...e}}}}var ln=()=>{throw new Error("createLiveVisualizer is not available in browser. It requires Node.js process.stdout.")};function Ae(e={}){let{workflowName:t,detectParallel:r=!0,showTimings:o=!0,showKeys:i=!1,colors:n}=e,a=ue({detectParallel:r}),d=new Set,u,s=ce(),l=te(),p=ke(),h=le(),m={showTimings:o,showKeys:i,terminalWidth:80,colors:{...V,...n}};function y(){if(d.size>0){let g=a.getIR();for(let k of d)k(g)}}function v(g){if(g.type==="scope_start"||g.type==="scope_end"){$(g);return}a.handleEvent(g),"workflowName"in g&&typeof g.workflowName=="string"&&(u=g.workflowName),y()}function $(g){a.handleScopeEvent(g),y()}function N(g){a.handleDecisionEvent(g),y()}function E(){let g=a.getIR(),k=t??u??g.root.name;return k&&(g.root.name=k),g}function I(){let g=E();return s.render(g,m)}function x(g){let k=E();switch(g){case"ascii":return s.render(k,m);case"mermaid":return l.render(k,m);case"json":{let T=k.hooks?{...k,hooks:{...k.hooks,onAfterStep:k.hooks.onAfterStep instanceof Map?Object.fromEntries(k.hooks.onAfterStep):k.hooks.onAfterStep??{}}}:k;return JSON.stringify(T,(O,B)=>typeof B=="bigint"?B.toString():B,2)}case"logger":return p.render(k,m);case"flowchart":return h.render(k,m);default:throw new Error(`Unknown format: ${g}`)}}function S(){a.reset(),y()}function w(g){return d.add(g),()=>d.delete(g)}return{handleEvent:v,handleScopeEvent:$,handleDecisionEvent:N,getIR:E,render:I,renderAs:x,reset:S,onUpdate:w}}function un(...e){return(t,r)=>{for(let o of e)o(t,r)}}function pn(e,t={}){let r=Ae(t);for(let o of e)o.type.startsWith("decision_")?r.handleDecisionEvent(o):r.handleEvent(o);return r.render()}function fn(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=Ae(e);for(let o of t)o.type.startsWith("decision_")?r.handleDecisionEvent(o):r.handleEvent(o);return r.render()},visualizeAs:r=>{let o=Ae(e);for(let i of t)i.type.startsWith("decision_")?o.handleDecisionEvent(i):o.handleEvent(i);return o.renderAs(r)}}}0&&(module.exports={asciiRenderer,buildMermaidInkUrl,combineEventHandlers,createEventCollector,createIRBuilder,createLiveVisualizer,createMermaidInkGenerator,createParallelDetector,createPerformanceAnalyzer,createTimeTravelController,createUrlGenerator,createVisualizer,defaultColorScheme,detectParallelGroups,encodeForMermaidInk,flowchartRenderer,getHeatLevel,hasChildren,htmlRenderer,isDecisionNode,isParallelNode,isRaceNode,isSequenceNode,isStepNode,isStreamNode,loggerRenderer,mermaidRenderer,renderToHTML,toKrokiPngUrl,toKrokiSvgUrl,toKrokiUrl,toMermaidInkJpegUrl,toMermaidInkPdfUrl,toMermaidInkPngUrl,toMermaidInkSvgUrl,toMermaidInkUrl,toMermaidInkWebpUrl,trackDecision,trackIf,trackSwitch,visualizeEvents});
|
|
1677
1677
|
//# sourceMappingURL=index.browser.cjs.map
|