awaitly-visualizer 24.0.0 → 26.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/devtools.cjs +6 -6
- package/dist/devtools.cjs.map +1 -1
- package/dist/devtools.d.cts +3 -4
- package/dist/devtools.d.ts +3 -4
- package/dist/devtools.js +4 -4
- package/dist/devtools.js.map +1 -1
- package/dist/index.browser.cjs +14 -14
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +4 -5
- package/dist/index.browser.d.ts +4 -5
- package/dist/index.browser.js +14 -14
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +24 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -6
- package/dist/index.d.ts +25 -6
- package/dist/index.js +24 -24
- package/dist/index.js.map +1 -1
- package/dist/kroki/fetch.cjs +2 -2
- package/dist/kroki/fetch.cjs.map +1 -1
- package/dist/kroki/fetch.d.cts +1 -2
- package/dist/kroki/fetch.d.ts +1 -2
- package/dist/kroki/fetch.js +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 -3
- package/dist/notifiers/discord.d.ts +2 -3
- 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 -3
- package/dist/notifiers/slack.d.ts +2 -3
- package/dist/notifiers/slack.js +13 -13
- package/dist/notifiers/slack.js.map +1 -1
- package/dist/notifiers/webhook.cjs +2 -2
- package/dist/notifiers/webhook.cjs.map +1 -1
- package/dist/notifiers/webhook.d.cts +2 -3
- package/dist/notifiers/webhook.d.ts +2 -3
- package/dist/notifiers/webhook.js +2 -2
- package/dist/notifiers/webhook.js.map +1 -1
- package/dist/{performance-analyzer-ffmMicjZ.d.ts → performance-analyzer-BCzSirud.d.ts} +1 -1
- package/dist/{performance-analyzer-C9WFkUSa.d.cts → performance-analyzer-dTsqap8v.d.cts} +1 -1
- package/dist/{types-BmktN16n.d.cts → types-Cxa5QZ0j.d.cts} +1 -1
- package/dist/{types-Bmb5LpD-.d.ts → types-J_mgQ3lz.d.ts} +1 -1
- package/dist/{url-CxqaR2K3.d.cts → url-DD8-D8H4.d.cts} +4 -4
- package/dist/{url-CxqaR2K3.d.ts → url-DD8-D8H4.d.ts} +4 -4
- 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:()=>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(
|
|
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=>`
|
|
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:()=>F,isSequenceNode:()=>Pe,isStepNode:()=>U,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],f=Math.min(...d.map($=>$.startTs)),g=Math.max(...d.map($=>$.endTs)),h=l.startTs<=f+o,y=l.startTs<g;if(!h&&!y){a.push(d),d=[l];continue}let v=y?Math.min(l.endTs,g)-l.startTs:0;h||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(f=>f.originalIndex));if(s.length===1)u.push({node:s[0].node,position:l});else{let f=s.map(v=>v.node),g=Math.min(...s.map(v=>v.startTs)),h=Math.max(...s.map(v=>v.endTs)),y={type:"parallel",id:`detected_parallel_${g}`,name:`${f.length} parallel steps`,state:er(f),mode:"all",children:f,startTs:g,endTs:h,durationMs:h-g};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",f,g,h=new Map,y=[],v=[],$=new Map,N=[],E=Date.now(),I=E,x={onAfterStep:new Map},S,b=[],w=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 m=v[v.length-1];for(let p of m.branches.values())if(p.taken){p.children.push(c),I=Date.now();return}m.pendingChildren.push(c),I=Date.now();return}N.push(c),I=Date.now()}function M(c){if(!n)return;let m=oe(),p=new Map;for(let[C,J]of h)p.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_${w}`,eventIndex:w,event:structuredClone(c),ir:structuredClone(m),timestamp:Date.now(),activeSteps:p};b.push(P),b.length>i&&b.shift(),w++}function O(c){switch(c.type){case"workflow_start":{N=[],s=void 0,g=void 0,f=void 0,h.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,g=c.durationMs,I=Date.now();break;case"workflow_error":l="error",s=c.ts,f=c.error,g=c.durationMs,I=Date.now();break;case"workflow_cancelled":l="aborted",s=c.ts,g=c.durationMs,I=Date.now();break;case"step_start":{let m=k(c);h.set(m,{id:m,name:c.name,key:c.stepKey,startTs:c.ts,retryCount:0,timedOut:!1,metadata:c.metadata}),I=Date.now();break}case"step_success":{let m=k(c),p=h.get(m);if(p){let P={type:"step",id:p.id,name:p.name,key:p.key,state:"success",startTs:p.startTs,endTs:c.ts,durationMs:c.durationMs,...p.retryCount>0&&{retryCount:p.retryCount},...p.timedOut&&{timedOut:!0,timeoutMs:p.timeoutMs},...p.metadata&&{metadata:p.metadata}};T(P),h.delete(m)}break}case"step_error":{let m=k(c),p=h.get(m);if(p){let P={type:"step",id:p.id,name:p.name,key:p.key,state:"error",startTs:p.startTs,endTs:c.ts,durationMs:c.durationMs,error:c.error,...p.retryCount>0&&{retryCount:p.retryCount},...p.timedOut&&{timedOut:!0,timeoutMs:p.timeoutMs},...p.metadata&&{metadata:p.metadata},...c.diagnostics&&{errorDiagnostics:c.diagnostics}};T(P),h.delete(m)}break}case"step_aborted":{let m=k(c),p=h.get(m);if(p){let P={type:"step",id:p.id,name:p.name,key:p.key,state:"aborted",startTs:p.startTs,endTs:c.ts,durationMs:c.durationMs,...p.retryCount>0&&{retryCount:p.retryCount},...p.timedOut&&{timedOut:!0,timeoutMs:p.timeoutMs},...p.metadata&&{metadata:p.metadata}};T(P),h.delete(m)}break}case"step_cache_hit":{let p={type:"step",id:k(c),name:c.name,key:c.stepKey,state:"cached",startTs:c.ts,endTs:c.ts,durationMs:0};T(p);break}case"step_cache_miss":break;case"step_complete":break;case"step_timeout":{let m=k(c),p=h.get(m);p&&(p.timedOut=!0,p.timeoutMs=c.timeoutMs),I=Date.now();break}case"step_retry":{let m=k(c),p=h.get(m);p&&(p.retryCount=(c.attempt??1)-1),I=Date.now();break}case"step_retries_exhausted":I=Date.now();break;case"step_skipped":{let p={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(p);break}case"decision":{let m=c;if(m.phase==="start"){H({type:"decision_start",workflowId:c.workflowId,decisionId:m.decisionId,name:m.label??m.decisionId,condition:m.label,decisionValue:m.value,ts:m.ts}),H({type:"decision_branch",workflowId:c.workflowId,decisionId:m.decisionId,branchLabel:"then",condition:m.label,taken:m.branch==="then",ts:m.ts}),H({type:"decision_branch",workflowId:c.workflowId,decisionId:m.decisionId,branchLabel:"else",taken:m.branch==="else",ts:m.ts});break}if(m.phase==="end"){H({type:"decision_end",workflowId:c.workflowId,decisionId:m.decisionId,branchTaken:m.branch,ts:m.ts,durationMs:m.durationMs??0});break}let p={type:"decision",id:m.decisionId,name:m.label??m.decisionId,state:"success",startTs:m.ts,endTs:m.ts,durationMs:0,condition:m.label,decisionValue:m.value,branchTaken:m.branch,branches:[{label:"then",condition:m.label,taken:m.branch==="then",children:[]},{label:"else",taken:m.branch==="else",children:[]}]};T(p),I=Date.now();break}case"hook_should_run":{let m={type:"shouldRun",state:"success",ts:c.ts,durationMs:c.durationMs,context:{result:c.result,skipped:c.skipped}};x.shouldRun=m,S=c.workflowId,I=Date.now();break}case"hook_should_run_error":{let m={type:"shouldRun",state:"error",ts:c.ts,durationMs:c.durationMs,error:c.error};x.shouldRun=m,S=c.workflowId,I=Date.now();break}case"hook_before_start":{let m={type:"onBeforeStart",state:"success",ts:c.ts,durationMs:c.durationMs,context:{result:c.result,skipped:c.skipped}};x.onBeforeStart=m,S=c.workflowId,I=Date.now();break}case"hook_before_start_error":{let m={type:"onBeforeStart",state:"error",ts:c.ts,durationMs:c.durationMs,error:c.error};x.onBeforeStart=m,S=c.workflowId,I=Date.now();break}case"hook_after_step":{let m={type:"onAfterStep",state:"success",ts:c.ts,durationMs:c.durationMs,context:{stepKey:c.stepKey}};x.onAfterStep.set(c.stepKey,m),I=Date.now();break}case"hook_after_step_error":{let m={type:"onAfterStep",state:"error",ts:c.ts,durationMs:c.durationMs,error:c.error,context:{stepKey:c.stepKey}};x.onAfterStep.set(c.stepKey,m),I=Date.now();break}case"stream_created":{let m=`${c.workflowId}:${c.namespace}`;$.set(m,{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 m=`${c.workflowId}:${c.namespace}`,p=$.get(m);p&&(p.writeCount++,p.finalPosition=Math.max(p.finalPosition,c.position)),I=Date.now();break}case"stream_read":{let m=`${c.workflowId}:${c.namespace}`,p=$.get(m);p&&p.readCount++,I=Date.now();break}case"stream_close":{let m=`${c.workflowId}:${c.namespace}`,p=$.get(m);if(p){p.streamState="closed",p.finalPosition=c.finalPosition;let P={type:"stream",id:p.id,namespace:p.namespace,state:"success",startTs:p.startTs,endTs:c.ts,durationMs:c.ts-p.startTs,writeCount:p.writeCount,readCount:p.readCount,finalPosition:c.finalPosition,streamState:"closed",backpressureOccurred:p.backpressureOccurred};T(P),$.delete(m)}I=Date.now();break}case"stream_error":{let m=`${c.workflowId}:${c.namespace}`,p=$.get(m);if(p){p.streamState="error";let P={type:"stream",id:p.id,namespace:p.namespace,state:"error",error:c.error,startTs:p.startTs,endTs:c.ts,durationMs:c.ts-p.startTs,writeCount:p.writeCount,readCount:p.readCount,finalPosition:c.position,streamState:"error",backpressureOccurred:p.backpressureOccurred};T(P),$.delete(m)}I=Date.now();break}case"stream_backpressure":{let m=`${c.workflowId}:${c.namespace}`,p=$.get(m);p&&(p.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 m=y.findIndex(C=>C.id===c.scopeId);if(m===-1)return;for(;y.length>m+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[p]=y.splice(m,1),P=p.type==="race"?{type:"race",id:p.id,name:p.name,state:_(p.children),startTs:p.startTs,endTs:c.ts,durationMs:c.durationMs,children:p.children,winnerId:c.winnerId}:{type:"parallel",id:p.id,name:p.name,state:_(p.children),startTs:p.startTs,endTs:c.ts,durationMs:c.durationMs,children:p.children,mode:p.type==="allSettled"?"allSettled":"all"};T(P)}}function H(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 m=v.find(p=>p.id===c.decisionId);if(m){let p=c.branchLabel,P=m.branches.get(p);if(P)P.taken=c.taken,c.taken&&m.pendingChildren.length>0&&(P.children.unshift(...m.pendingChildren),m.pendingChildren=[]);else{let C=c.taken?[...m.pendingChildren]:[];c.taken&&(m.pendingChildren=[]),m.branches.set(p,{label:c.branchLabel,condition:c.condition,taken:c.taken,children:C})}I=Date.now()}}else if(c.type==="decision_end"){let m=v.findIndex(p=>p.id===c.decisionId);if(m!==-1){let[p]=v.splice(m,1),P=v.splice(m),C=Array.from(p.branches.values());C.length===0&&p.pendingChildren.length>0&&(C=[{label:"default",taken:!0,children:[...p.pendingChildren]}]);let J=C.find(ve=>ve.taken)?.label,Kt={type:"decision",id:p.id,name:p.name,state:_(C.flatMap(ve=>ve.taken?ve.children:[])),startTs:p.startTs,endTs:c.ts,durationMs:c.durationMs,condition:p.condition,decisionValue:p.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[,m]of h)c.push({type:"step",id:m.id,name:m.name,key:m.key,state:"running",startTs:m.startTs,...m.retryCount>0&&{retryCount:m.retryCount},...m.timedOut&&{timedOut:!0,timeoutMs:m.timeoutMs}});for(let[,m]of $)c.push({type:"stream",id:m.id,namespace:m.namespace,state:"running",startTs:m.startTs,writeCount:m.writeCount,readCount:m.readCount,finalPosition:m.finalPosition,streamState:m.streamState,backpressureOccurred:m.backpressureOccurred});return c}function oe(){let c=ne();t&&(c=we(c,r));let m={type:"workflow",id:d??a,workflowId:d??a,state:l,startTs:u,endTs:s,durationMs:g,children:c,error:f},p=x.shouldRun!==void 0||x.onBeforeStart!==void 0||x.onAfterStep.size>0;return{root:m,metadata:{createdAt:E,lastUpdatedAt:I},...p&&{hooks:x}}}function ie(){d=void 0,u=void 0,s=void 0,l="pending",f=void 0,g=void 0,h.clear(),y.length=0,v.length=0,$.clear(),N=[],E=Date.now(),I=E,x={onAfterStep:new Map},S=void 0,b.length=0,w=0}function Ht(){return[...b]}function Ft(c){return b[c]}function zt(c){return b[c]?.ir}function Ut(){b.length=0,w=0}return{handleEvent:O,handleScopeEvent:B,handleDecisionEvent:H,getIR:oe,reset:ie,getSnapshots:Ht,getSnapshotAt:Ft,getIRAt:zt,clearSnapshots:Ut,get hasActiveSteps(){return h.size>0},get state(){return l},get snapshotCount(){return b.length},get snapshotsEnabled(){return n},setSnapshotsEnabled(c){n=c}}}var Ie=require("awaitly");function U(e){return e.type==="step"}function Pe(e){return e.type==="sequence"}function j(e){return e.type==="parallel"}function F(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",f=`${Re(s,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)U(a)?n.push(Ue(a,t,r,i)):j(a)?n.push(...hr(a,t,r,o,i)):F(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 f=typeof e.input=="string"?e.input:ot(e.input).slice(0,30);s+=D(` [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);s+=D(` [out: ${f}${f.length>=30?"...":""}]`)}if(t.showTimings&&e.durationMs!==void 0){let f=A(e.durationMs),g=d!==void 0?nt(`[${f}]`,d):D(`[${f}]`);s+=` ${g}`}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&&(s+=` ${D(ze(f))}`)}if(e.retryCount!==void 0&&e.retryCount>0&&(s+=D(` [${e.retryCount} ${e.retryCount===1?"retry":"retries"}]`)),e.timedOut){let f=e.timeoutMs!==void 0?` ${e.timeoutMs}ms`:"";s+=D(` [timeout${f}]`)}let l=e.key??e.id;if(o&&l&&o.onAfterStep.has(l)){let f=o.onAfterStep.get(l),g=f.state==="success"?X("\u2699",r.success):X("\u26A0",r.error),h=f.durationMs!==void 0?D(` ${A(f.durationMs)}`):"";s+=` ${g}${h}`}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 f=e.children[l],h=l===e.children.length-1?`${a}${R.vertical} ${R.bottomLeft}`:`${a}${R.vertical} ${R.teeRight}`;if(U(f))n.push(`${h} ${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} ${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],g=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(U(l))n.push(`${g} ${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)}`):"",f=e.branchTaken!==void 0?D(` \u2192 ${String(e.branchTaken)}`):"";n.push(`${a}${R.teeRight}${R.teeDown}${R.horizontal} ${d} ${be(u)}${s}${l}${f}`);for(let g=0;g<e.branches.length;g++){let h=e.branches[g],v=g===e.branches.length-1?`${a}${R.vertical} ${R.bottomLeft}`:`${a}${R.vertical} ${R.teeRight}`,$=h.taken?"\u2713":"\u2298",N=h.taken?r.success:r.skipped,E=X(`${$} ${h.label}`,N),I=h.condition?D(` (${h.condition})`):"";if(n.push(`${v} ${E}${I}`),h.children.length>0){let x=$e(h.children,t,r,o+1,i);for(let S of x)n.push(`${a}${R.vertical} ${S}`)}else h.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 b of x)switch(b.type){case"step_start":{let w=n(b);S.set(w,{retried:!1,timedOut:!1});break}case"step_retry":{let w=n(b),k=S.get(w);k&&(k.retried=!0);break}case"step_timeout":{let w=n(b),k=S.get(w);k&&(k.timedOut=!0);break}case"step_success":{let w=n(b),k=S.get(w),T=e.get(w)??[];T.push(b.durationMs),e.set(w,T);let M=t.get(w)??{retried:0,total:0};M.total++,k?.retried&&M.retried++,t.set(w,M);let O=o.get(w)??{timedOut:0,total:0};O.total++,k?.timedOut&&O.timedOut++,o.set(w,O);let B=r.get(w)??{errors:0,total:0};B.total++,r.set(w,B),S.delete(w);break}case"step_error":{let w=n(b),k=S.get(w),T=e.get(w)??[];T.push(b.durationMs),e.set(w,T);let M=t.get(w)??{retried:0,total:0};M.total++,k?.retried&&M.retried++,t.set(w,M);let O=o.get(w)??{timedOut:0,total:0};O.total++,k?.timedOut&&O.timedOut++,o.set(w,O);let B=r.get(w)??{errors:0,total:0};B.total++,B.errors++,r.set(w,B),S.delete(w);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 b=[...S].sort((H,_)=>H-_),k=b.reduce((H,_)=>H+_,0)/b.length,T=b.reduce((H,_)=>H+(_-k)**2,0)/b.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:b[0],maxDurationMs:b[b.length-1],stdDevMs:Math.sqrt(T),samples:b.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(b,.5),p90:Ee(b,.9),p95:Ee(b,.95),p99:Ee(b,.99)}}}function f(x){return l(x)}function g(x,S="duration"){let b=new Map,w=Ke(x.root.children),k=[];for(let _ of w){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:b,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,H=O-M||1;for(let{id:_,value:ne}of k)b.set(_,(ne-M)/H);return{heat:b,metric:S,stats:{min:M,max:O,mean:B,threshold:B+(O-B)*.5}}}function h(){let x=new Map;for(let S of e.keys()){let b=l(S);b&&x.set(S,b)}return x}function y(x=10){return[...h().values()].sort((b,w)=>w.avgDurationMs-b.avgDurationMs).slice(0,x)}function v(x=10){return[...h().values()].filter(b=>b.errorRate>0).sort((b,w)=>w.errorRate-b.errorRate).slice(0,x)}function $(x=10){return[...h().values()].filter(b=>b.retryRate>0).sort((b,w)=>w.retryRate-b.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[b,w]of Object.entries(S.timingData??{}))e.set(b,w);for(let[b,w]of Object.entries(S.retryData??{}))t.set(b,w);for(let[b,w]of Object.entries(S.errorData??{}))r.set(b,w);for(let[b,w]of Object.entries(S.timeoutData??{}))o.set(b,w)}function I(){e.clear(),t.clear(),r.clear(),o.clear(),i=[]}return{addRun:d,addEvent:u,finalizeRun:s,getNodePerformance:f,getHeatmap:g,getSlowestNodes:y,getErrorProneNodes:v,getRetryProneNodes:$,getAllPerformance:h,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 K(e){return e.replace(/"/g,"#quot;").replace(/</g,"<").replace(/>/g,">").trim()}function lt(e){return K(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",f=`(("${s} ${l}"))`,g=e.root.state==="success"?":::success":e.root.state==="error"?":::error":":::aborted";r.push(` ${u}${f}${g}`),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(U(e))return Ir(e,t,r,o,i);if(j(e))return $r(e,t,r,o,i);if(F(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 b=2;for(;Ne.has(`${s}_${b}`);)b++;s=`${s}_${b}`}Ne.add(s);let l=e.name??e.key??"Step",f=t.showKeys&&e.key&&e.name?`${l} [${e.key}]`:l,g=K(f),h=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 b=typeof e.input=="string"?K(e.input):K(ct(e.input).slice(0,20));v+=`\\nin: ${b}`}if(e.output!==void 0&&e.state==="success"){let b=typeof e.output=="string"?K(e.output):K(ct(e.output).slice(0,20));v+=`\\nout: ${b}`}let $="",N=e.key??e.id;if(i&&N&&i.onAfterStep.has(N)){let b=i.onAfterStep.get(N),w=b.state==="success"?"\u2699":"\u26A0",k=t.showTimings&&b.durationMs!==void 0?` ${A(b.durationMs)}`:"";$=`\\n${w} hook${k}`}let E=(y+g+v+$+h).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 b=fe(x);I=kr(b)}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 b=`\u21BB ${e.retryCount} retr${e.retryCount===1?"y":"ies"}`;r.push(` ${s} -.->|"${b}"| ${s}`)}if(d&&e.state==="error"&&e.error!==void 0){let b=`ERR_${s}`,w=K(String(e.error)).slice(0,30);r.push(` ${b}{{"${w}"}}`),r.push(` ${s} -->|error| ${b}`),r.push(` style ${b} fill:#fee2e2,stroke:#dc2626`)}if(u&&e.timedOut){let b=`TO_${s}`,w=e.timeoutMs!==void 0?`${e.timeoutMs}ms`:"";r.push(` ${b}{{"\u23F1 Timeout ${w}"}}`),r.push(` ${s} -.->|timeout| ${b}`),r.push(` style ${b} 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 g=n,h=K(`${u}${s}`),y="operations not individually tracked",v=t.showTimings&&e.durationMs!==void 0?` ${A(e.durationMs)}`:"";return r.push(` ${g}["${h}${v}\\n${y}"]:::${e.state}`),{entryId:g,exitId:g}}r.push(` subgraph ${n}["${u}${s}"]`),r.push(" direction TB"),r.push(` ${a}{"\u26A1 Fork"}`);let l=[];for(let g of e.children){let h=De(g,t,r,o,i);r.push(` ${a} --> ${h.entryId}`),l.push(h.exitId)}r.push(` ${d}{"\u2713 Join"}`);for(let g of l)r.push(` ${g} --> ${d}`);r.push(" end");let f=e.state;return r.push(` class ${n} ${f}`),{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 g=n,h=K(u),y="operations not individually tracked",v=t.showTimings&&e.durationMs!==void 0?` ${A(e.durationMs)}`:"";return r.push(` ${g}["\u26A1 ${h}${v}\\n${y}"]:::${e.state}`),{entryId:g,exitId:g}}r.push(` subgraph ${n}["\u26A1 ${u}"]`),r.push(" direction TB"),r.push(` ${a}(("\u{1F3C1} Start"))`);let s=[],l;for(let g of e.children){let h=De(g,t,r,o,i),y=e.winnerId===g.id;r.push(` ${a} --> ${h.entryId}`),y&&(l=h.exitId),s.push({exitId:h.exitId,isWinner:y})}r.push(` ${d}(("\u2713 First"))`);for(let{exitId:g,isWinner:h}of s)h&&l?r.push(` ${g} ==>|\u{1F3C6} Winner| ${d}`):e.winnerId?r.push(` ${g} -. cancelled .-> ${d}`):r.push(` ${g} --> ${d}`);r.push(" end");let f=e.state;return r.push(` class ${n} ${f}`),{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 g=2;for(;Me.has(`${n}_${g}`);)g++;n=`${n}_${g}`}Me.add(n);let a=K(e.condition??"condition"),d=e.decisionValue!==void 0?` = ${K(String(e.decisionValue)).slice(0,30)}`:"",u=`${a}${d}`.trim();r.push(` ${n}{"${u}"}`);let s=[],l,f=new Set;for(let g of e.branches){let h=`${n}_${g.label.replace(/[^a-zA-Z0-9]/g,"_")}`;if(f.has(h)){let E=2;for(;f.has(`${h}_${E}`);)E++;h=`${h}_${E}`}f.add(h);let y=K(g.label),v=g.taken?`${y} \u2713`:`${y} skipped`,$=g.taken?":::success":":::skipped";r.push(` ${h}["${v}"]${$}`);let N=g.condition?`|${K(g.condition).replace(/\|/g,"")}|`:"";if(r.push(` ${n} -->${N} ${h}`),g.children.length>0){let E=h;for(let I of g.children){let x=De(I,t,r,o,i);r.push(` ${E} --> ${x.entryId}`),E=x.exitId}s.push(E),g.taken&&(l=E)}else s.push(h),g.taken&&(l=h)}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:${K(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(U(e))return Wr(e,t,r,o,i,n);if(j(e)||F(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 f=Math.max(...u.map(N=>ee(N).length)),g=Math.max(q,f+Z*2),h=u.length+2,y=t-Math.floor(g/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:g,height:h,centerX:t,bottomY:r+h-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 f=Math.max(...u.map($=>ee($).length)),g=Math.max(q,f+Z*2),h=u.length+2,y=t-Math.floor(g/2),v={id:e.id,type:"stream",label:u,state:e.state,x:y,y:r,width:g,height:h,centerX:t,bottomY:r+h-1,metadata:{streamState:e.streamState,backpressureOccurred:e.backpressureOccurred}};return{node:v,bottomY:v.bottomY}}function Ar(e,t,r,o,i,n){let a=F(e),d=e.name??(a?"race":"parallel"),s=`${a?"\u26A1":"\u2AD8"} ${d}`;if(e.children.length===0){let w=[s,"(not tracked)"],k=Ce(e.id,a?"race":"parallel",w,e.state,t,r);return{node:k,bottomY:k.bottomY}}let l=Math.floor((o-Oe*(e.children.length-1))/e.children.length),f=[];for(let w of e.children){let k=je(w,Math.max(l,q),i,n);f.push(k.width)}let g=f.reduce((w,k)=>w+k,0)+Oe*(e.children.length-1),h=g>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(h)for(let w=0;w<e.children.length;w++){let k=e.children[w],T=Le(k,t,N,o,i,n);a&&F(e)&&e.winnerId===k.id&&(T.node.metadata={...T.node.metadata,isWinner:!0}),E.push(T.node),N=T.bottomY+he}else{let w=t-Math.floor(g/2);for(let k=0;k<e.children.length;k++){let T=e.children[k],M=w+Math.floor(f[k]/2),O=Le(T,M,N,f[k],i,n);a&&F(e)&&e.winnerId===T.id&&(O.node.metadata={...O.node.metadata,isWinner:!0}),E.push(O.node),w+=f[k]+Oe}}let I=Math.max(...E.map(w=>w.bottomY)),S=!h&&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:h}},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),f=Math.max(...l.map(S=>ee(S).length)),g=Math.max(q,f+Z*2),h=l.length+2,y=t-Math.floor(g/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:g,height:h,centerX:t,bottomY:r+h-1};return{node:S,bottomY:S.bottomY}}let N=r+h+he,E=[];for(let S of $.children){let b=Le(S,t,N,o,i,n);E.push(b.node),N=b.bottomY+he}let I=E.length>0?E[E.length-1].bottomY:r+h-1;return{node:{id:e.id,type:"decision",label:l,state:e.state,x:y,y:r,width:g,height:h,centerX:t,bottomY:I,children:E},bottomY:I}}function je(e,t,r,o){if(U(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)||F(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,f=d.y-1;re(e,u,s,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 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 f=l.centerX;f===u?W(e,f,i+1,L.topLeft):f===s?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 d of o)_e(e,d,r);if(o.length>1){let d=o.map(h=>h.bottomY),u=Math.max(...d),s=u+1,l=o.map(h=>h.centerX),f=Math.min(...l),g=Math.max(...l);for(let h of o)h.bottomY<u&&re(e,h.centerX,h.bottomY+1,s-1);pt(e,s,f,g);for(let h of o){let y=h.centerX;y===f?W(e,y,s,L.bottomLeft):y===g?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(U(i))t.push(i);else if(Pe(i))r(i.children);else if(j(i)||F(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 f=d.get(l)??{total:0,errors:0,totalDuration:0};f.total++,s.state==="error"&&f.errors++,s.durationMs!==void 0&&(f.totalDuration+=s.durationMs),d.set(l,f)}}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,
|
|
1478
|
+
`}var ae=160,ge=50,Ge=40,qr=30,z=20;function Zr(e,t="TB",r){let o=t==="TB"||t==="BT",i=t==="RL"||t==="BT",n=[],a=z,d=z,u=0,s=0;for(let g of e){let h=Ye(g,a,d,o,r);n.push(h.node),o?(d+=h.height+qr,u=Math.max(u,h.width),s=d):(a+=h.width+Ge,s=Math.max(s,h.height),u=a)}let l=u+z,f=s+z;if(i)for(let g of n)bt(g,l,f,o);return{nodes:n,width:l,height:f}}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(U(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)||F(e)){let n=j(e)?"parallel":"race",a=e.name??n,d=[],u=t+z,s=r+z+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 f=u-t-z,g=Math.max(f+z,ae+z*2),h=l+z*2+20;return{node:{id:e.id,name:a,type:n,state:e.state,x:t,y:r,width:g,height:h,durationMs:e.durationMs,children:d,containerType:n,containerLabel:n==="parallel"?"PARALLEL":"RACE"},width:g,height:h}}if(Y(e)){let n=e.name??"decision",a=[],d=t+z,u=r+z+20,s=0;for(let g of e.branches)for(let h of g.children){let y=Ye(h,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+z*2),f=s+z*2+20;return{node:{id:e.id,name:n,type:"decision",state:e.state,x:t,y:r,width:l,height:f,durationMs:e.durationMs,children:a,containerType:"decision",containerLabel:"DECISION"},width:l,height:f}}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>
|
|
@@ -1485,18 +1485,18 @@ body {
|
|
|
1485
1485
|
`)??"";return`
|
|
1486
1486
|
<g class="wv-container wv-container--${e.containerType}" data-node-id="${vt(e.id)}" transform="translate(${e.x}, ${e.y})">
|
|
1487
1487
|
<rect width="${e.width}" height="${e.height}" rx="12" ry="12" />
|
|
1488
|
-
<text class="wv-container-label" x="${
|
|
1488
|
+
<text class="wv-container-label" x="${z}" y="16">${e.containerLabel}</text>
|
|
1489
1489
|
<g transform="translate(${-e.x}, ${-e.y})">
|
|
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,s=n.y+n.height/2,l=a.x,
|
|
1494
|
-
<path class="wv-edge" d="M ${u} ${s} L ${l-8} ${
|
|
1495
|
-
<polygon class="wv-edge-arrow" points="${l-8},${
|
|
1496
|
-
`)}else{let u=n.x+n.width/2,s=n.y+n.height,l=a.x+a.width/2,
|
|
1497
|
-
<path class="wv-edge" d="M ${u} ${s} L ${l} ${
|
|
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 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
|
|
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,f=a.y+a.height/2;r.push(`
|
|
1494
|
+
<path class="wv-edge" d="M ${u} ${s} L ${l-8} ${f}" />
|
|
1495
|
+
<polygon class="wv-edge-arrow" points="${l-8},${f-4} ${l-8},${f+4} ${l},${f}" />
|
|
1496
|
+
`)}else{let u=n.x+n.width/2,s=n.y+n.height,l=a.x+a.width/2,f=a.y;r.push(`
|
|
1497
|
+
<path class="wv-edge" d="M ${u} ${s} L ${l} ${f-8}" />
|
|
1498
|
+
<polygon class="wv-edge-arrow" points="${l-4},${f-8} ${l+4},${f-8} ${l},${f}" />
|
|
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 f=0;f<l-1;f++)o(a.children[u+f],a.children[u+f+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
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">
|
|
@@ -1673,5 +1673,5 @@ body {
|
|
|
1673
1673
|
</script>
|
|
1674
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,d=Date.now(),u,s=[];function l(h,
|
|
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(g,h,y){s.push({label:g,condition:y,taken:h}),h&&(u=g),a?.({type:"decision_branch",workflowId:n,decisionId:e,branchLabel:g,condition:y,taken:h,ts:Date.now()})}function f(){let g=Date.now()-d;a?.({type:"decision_end",workflowId:n,decisionId:e,branchTaken:u,ts:Date.now(),durationMs:g})}return a?.({type:"decision_start",workflowId:n,decisionId:e,condition:r,decisionValue:o,name:i,ts:d}),{takeBranch:l,end:f,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 f(M){let O=i.getSnapshots();if(!(M<0||M>=O.length))return n.currentIndex=M,n.snapshots=O,u(),O[M].ir}function g(){return f(n.currentIndex+1)}function h(){return f(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 H=i.getSnapshots();if(n.currentIndex<H.length-1){let _=H[n.currentIndex],ie=(H[n.currentIndex+1].timestamp-_.timestamp)/n.playbackSpeed;d=setTimeout(()=>{g(),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 b(){n.isRecording=!0,i.setSnapshotsEnabled(!0),s(),u()}function w(){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:f,stepForward:g,stepBackward:h,play:y,pause:v,getCurrentIR:$,getIRAt:N,getSnapshots:E,getSnapshotAt:I,getState:x,onStateChange:S,startRecording:b,stopRecording:w,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(),f=ke(),g=le(),h={showTimings:o,showKeys:i,terminalWidth:80,colors:{...V,...n}};function y(){if(d.size>0){let w=a.getIR();for(let k of d)k(w)}}function v(w){if(w.type==="scope_start"||w.type==="scope_end"){$(w);return}a.handleEvent(w),"workflowName"in w&&typeof w.workflowName=="string"&&(u=w.workflowName),y()}function $(w){a.handleScopeEvent(w),y()}function N(w){a.handleDecisionEvent(w),y()}function E(){let w=a.getIR(),k=t??u??w.root.name;return k&&(w.root.name=k),w}function I(){let w=E();return s.render(w,h)}function x(w){let k=E();switch(w){case"ascii":return s.render(k,h);case"mermaid":return l.render(k,h);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 f.render(k,h);case"flowchart":return g.render(k,h);default:throw new Error(`Unknown format: ${w}`)}}function S(){a.reset(),y()}function b(w){return d.add(w),()=>d.delete(w)}return{handleEvent:v,handleScopeEvent:$,handleDecisionEvent:N,getIR:E,render:I,renderAs:x,reset:S,onUpdate:b}}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
|