@exaudeus/workrail 3.59.5 → 3.59.6

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.
@@ -25,4 +25,4 @@ Error generating stack: `+e.message+`
25
25
  `});++r<e.length;)r&&n.push({type:`text`,value:`
26
26
  `}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
27
27
  `}),n}function VT(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function HT(e,t){let n=IT(e,t),r=n.one(e,void 0),i=xT(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
28
- `},i)),a}function UT(e,t){return e&&`run`in e?async function(n,r){let i=HT(n,{file:r,...t});await e.run(i,r)}:function(n,r){return HT(n,{file:r,...e||t})}}function WT(e){if(e)throw e}var GT=o(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function KT(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function qT(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?JT(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function JT(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var YT={basename:XT,dirname:ZT,extname:QT,join:$T,sep:`/`};function XT(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);nE(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function ZT(e){if(nE(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function QT(e){nE(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function $T(...e){let t=-1,n;for(;++t<e.length;)nE(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:eE(n)}function eE(e){nE(e);let t=e.codePointAt(0)===47,n=tE(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function tE(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function nE(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var rE={cwd:iE};function iE(){return`/`}function aE(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function oE(e){if(typeof e==`string`)e=new URL(e);else if(!aE(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return sE(e)}function sE(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var cE=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],lE=class{constructor(e){let t;t=e?aE(e)?{path:e}:typeof e==`string`||pE(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:rE.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<cE.length;){let e=cE[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)cE.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?YT.basename(this.path):void 0}set basename(e){dE(e,`basename`),uE(e,`basename`),this.path=YT.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?YT.dirname(this.path):void 0}set dirname(e){fE(this.basename,`dirname`),this.path=YT.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?YT.extname(this.path):void 0}set extname(e){if(uE(e,`extname`),fE(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=YT.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){aE(e)&&(e=oE(e)),dE(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?YT.basename(this.path,this.extname):void 0}set stem(e){dE(e,`stem`),uE(e,`stem`),this.path=YT.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new Qb(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function uE(e,t){if(e&&e.includes(YT.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+YT.sep+"`")}function dE(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function fE(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function pE(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var mE=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),hE=l(GT(),1),gE={}.hasOwnProperty,_E=new class e extends mE{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=qT()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,hE.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(bE(`data`,this.frozen),this.namespace[e]=t,this):gE.call(this.namespace,e)&&this.namespace[e]||void 0:e?(bE(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=CE(e),n=this.parser||this.Parser;return vE(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),vE(`process`,this.parser||this.Parser),yE(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=CE(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);TE(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),vE(`processSync`,this.parser||this.Parser),yE(`processSync`,this.compiler||this.Compiler),this.process(e,r),SE(`processSync`,`process`,t),n;function r(e,r){t=!0,WT(e),n=r}}run(e,t,n){xE(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=CE(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),SE(`runSync`,`run`,n),r;function i(e,t){WT(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=CE(t),r=this.compiler||this.Compiler;return yE(`stringify`,r),xE(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(bE(`use`,this.frozen),e!=null)if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`)if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e);else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,hE.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null)if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];KT(o)&&KT(r)&&(r=(0,hE.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function vE(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function yE(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function bE(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function xE(e){if(!KT(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function SE(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function CE(e){return wE(e)?e:new lE(e)}function wE(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function TE(e){return typeof e==`string`||EE(e)}function EE(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var DE=[],OE={allowDangerousHtml:!0},kE=/^(https?|ircs?|mailto|xmpp)$/i,AE=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function jE(e){let t=ME(e),n=NE(e);return PE(t.runSync(t.parse(n),n),e)}function ME(e){let t=e.rehypePlugins||DE,n=e.remarkPlugins||DE,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...OE}:OE;return _E().use(kw).use(n).use(UT,r).use(t)}function NE(e){let t=e.children||``,n=new lE;return typeof t==`string`?n.value=t:``+t,n}function PE(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||FE;for(let e of AE)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return NT(e,l),ox(e,{Fragment:H.Fragment,components:i,ignoreInvalidStyle:!0,jsx:H.jsx,jsxs:H.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in Ox)if(Object.hasOwn(Ox,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=Ox[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function FE(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||kE.test(e.slice(0,t))?e:``}function IE({children:e,className:t}){return(0,H.jsx)(`div`,{className:`markdown-view ${t??``}`,children:(0,H.jsx)(jE,{children:e})})}function LE({sessionId:e,nodeId:t,runStatus:n=`complete`,currentNodeId:r=null,executionTraceSummary:i=null}){let{data:a,isLoading:o,error:s}=Wy(e,t);return t?(0,H.jsxs)(`div`,{children:[(0,H.jsx)(RE,{stepLabel:a?.stepLabel??null,nodeId:t}),(0,H.jsxs)(`div`,{className:`p-4 space-y-4`,children:[o&&(0,H.jsx)(`div`,{className:`text-[var(--text-secondary)] text-sm`,children:`Loading...`}),s&&(0,H.jsx)(`div`,{className:`text-[var(--error)] text-sm bg-[var(--bg-primary)] border border-[var(--border)] px-4 py-3`,children:s.message}),a&&(0,H.jsx)(UE,{detail:a,runStatus:n,currentNodeId:r,executionTraceSummary:i})]})]}):(0,H.jsx)(`div`,{className:`px-5 py-8 text-sm text-[var(--text-secondary)]`,children:`Select a node in the lineage to inspect its recap, validations, gaps, and artifacts.`})}function RE({stepLabel:e,nodeId:t}){return(0,H.jsxs)(`div`,{className:`px-5 py-4 border-b border-[var(--border)] console-blueprint-grid`,children:[(0,H.jsx)(`div`,{className:`text-base font-semibold text-[var(--text-primary)] leading-tight`,children:e??`Untitled node`}),(0,H.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-[var(--text-muted)] truncate`,children:t})]})}function zE({item:e}){return(0,H.jsxs)(`div`,{className:`flex items-start gap-2 text-xs py-1`,children:[(0,H.jsx)(`span`,{className:`flex-1 text-[var(--text-secondary)] leading-relaxed`,children:e.summary}),(0,H.jsxs)(`span`,{className:`font-mono text-[10px] text-[var(--text-muted)] shrink-0`,children:[`#`,e.recordedAtEventIndex]})]})}function BE({nodeId:e,nodeKind:t,executionTraceSummary:n}){let{whySelected:r,conditions:i,loops:a,divergences:o,forks:s}=dy(n,e);return n.items.some(t=>t.kind!==`context_fact`&&t.refs.some(t=>t.kind===`node_id`&&t.value===e))?(0,H.jsx)(iD,{title:`Routing context`,children:(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(r.length>0||t===`blocked_attempt`)&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`mb-1.5 flex items-center gap-2`,children:(0,H.jsx)(My,{label:`WHY SELECTED`,color:`var(--accent)`,bgColor:`rgba(244,196,48,0.10)`})}),r.length>0?(0,H.jsx)(`div`,{className:`space-y-1 pl-2 border-l border-[var(--border)]`,children:r.map((e,t)=>(0,H.jsx)(zE,{item:e},t))}):t===`blocked_attempt`?(0,H.jsx)(`div`,{className:`pl-2 border-l border-[var(--border)]`,children:(0,H.jsx)(`span`,{className:`text-xs text-[var(--text-muted)]`,children:`This step was attempted but not selected as the preferred path.`})}):null]}),i.length>0&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`mb-1.5`,children:(0,H.jsx)(My,{label:`CONDITIONS EVALUATED`,color:`var(--text-secondary)`,bgColor:`rgba(168,159,140,0.10)`})}),(0,H.jsx)(`div`,{className:`space-y-1 pl-2 border-l border-[var(--border)]`,children:[...i.filter(e=>!ay(e)),...i.filter(e=>ay(e))].map((e,t)=>{let n=ay(e);return(0,H.jsxs)(`div`,{className:`flex items-start gap-2 text-xs py-0.5`,children:[(0,H.jsx)(My,{label:n?`PASS`:`SKIP`,color:n?`var(--success)`:`var(--warning)`,bgColor:n?`rgba(34,197,94,0.10)`:`rgba(251,191,36,0.10)`}),(0,H.jsx)(`span`,{className:`flex-1 text-[var(--text-secondary)] leading-relaxed`,children:e.summary})]},t)})})]}),a.length>0&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`mb-1.5`,children:(0,H.jsx)(My,{label:`LOOP`,color:`var(--accent-strong)`,bgColor:`rgba(0,240,255,0.10)`})}),(0,H.jsx)(`div`,{className:`space-y-1 pl-2 border-l border-[var(--border)]`,children:a.map((e,t)=>(0,H.jsx)(zE,{item:e},t))})]}),o.length>0&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`mb-1.5`,children:(0,H.jsx)(My,{label:`DIVERGENCE`,color:`var(--error)`,bgColor:`rgba(255,107,107,0.10)`})}),(0,H.jsx)(`div`,{className:`space-y-1 pl-2 border-l border-[var(--border)]`,children:o.map((e,t)=>(0,H.jsx)(zE,{item:e},t))})]}),s.length>0&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`mb-1.5`,children:(0,H.jsx)(My,{label:`FORK`,color:`var(--warning)`,bgColor:`rgba(251,191,36,0.10)`})}),(0,H.jsx)(`div`,{className:`space-y-1 pl-2 border-l border-[var(--border)]`,children:s.map((e,t)=>(0,H.jsx)(zE,{item:e},t))})]})]})}):(0,H.jsx)(iD,{title:`Routing context`,children:t===`blocked_attempt`&&r.length===0?(0,H.jsxs)(`div`,{className:`flex items-start gap-2 py-1`,children:[(0,H.jsx)(My,{label:`WHY SELECTED`,color:`var(--text-muted)`,bgColor:`rgba(123,141,167,0.08)`}),(0,H.jsx)(`span`,{className:`text-xs text-[var(--text-muted)] leading-relaxed`,children:`This step was attempted but not selected as the preferred path.`})]}):(0,H.jsx)(`span`,{className:`font-mono text-xs text-[var(--text-muted)]`,children:`// no routing trace for this node`})})}function VE({items:e}){let[t,n]=(0,V.useState)(!1);return(0,H.jsx)(iD,{title:`Run routing`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`button`,{type:`button`,"aria-expanded":t,onClick:()=>n(e=>!e),className:`flex items-center gap-2 font-mono text-[10px] uppercase tracking-[0.20em] text-[var(--text-muted)] hover:text-[var(--text-secondary)] transition-colors`,children:[(0,H.jsx)(My,{label:`RUN ROUTING`,color:`var(--text-muted)`,bgColor:`rgba(123,141,167,0.08)`}),(0,H.jsxs)(`span`,{className:`text-[var(--text-muted)]`,children:[`// `,e.length,` ambient items`]}),(0,H.jsx)(`span`,{children:t?`[-]`:`[+]`})]}),t&&(0,H.jsx)(`div`,{className:`mt-2 space-y-1 pl-2 border-l border-[var(--border)]`,children:e.map((e,t)=>(0,H.jsxs)(`div`,{className:`flex items-start gap-2 text-xs py-0.5`,children:[(0,H.jsx)(`span`,{className:`shrink-0 inline-flex items-center px-2 py-0.5 font-mono text-[10px] uppercase tracking-[0.16em]`,style:{color:`var(--text-muted)`,backgroundColor:`rgba(123,141,167,0.08)`,border:`1px solid rgba(123,141,167,0.20)`},children:e.kind.replace(/_/g,` `).toUpperCase()}),(0,H.jsx)(`span`,{className:`flex-1 text-[var(--text-secondary)] leading-relaxed`,children:e.summary}),(0,H.jsxs)(`span`,{className:`font-mono text-[10px] text-[var(--text-muted)] shrink-0`,children:[`#`,e.recordedAtEventIndex]})]},t))})]})})}var HE=[{id:`routing`,column:`primary`,render:({detail:e,executionTraceSummary:t})=>t===null?null:(0,H.jsx)(BE,{nodeId:e.nodeId,nodeKind:e.nodeKind,executionTraceSummary:t},`routing`)},{id:`run_routing`,column:`primary`,render:({executionTraceSummary:e})=>{if(e===null)return null;let t=e.items.filter(e=>!e.refs.some(e=>e.kind===`node_id`));return t.length===0?null:(0,H.jsx)(VE,{items:t},`run_routing`)}},{id:`recap`,column:`primary`,render:({detail:e,runStatus:t,currentNodeId:n})=>e.recapMarkdown?(0,H.jsx)(YE,{markdown:e.recapMarkdown},`recap`):t===`in_progress`&&e.nodeId===n&&!e.recapMarkdown?(0,H.jsx)(WE,{detail:e},`recap-in-progress`):null},{id:`validations`,column:`primary`,render:({detail:e})=>e.validations.length>0?(0,H.jsx)(ZE,{validations:e.validations},`validations`):null},{id:`gaps`,column:`primary`,render:({detail:e})=>e.gaps.length>0?(0,H.jsx)($E,{gaps:e.gaps},`gaps`):null},{id:`advance-outcome`,column:`primary`,render:({detail:e})=>e.advanceOutcome?(0,H.jsx)(XE,{outcome:e.advanceOutcome},`advance-outcome`):null},{id:`artifacts`,column:`primary`,render:({detail:e})=>e.artifacts.length>0?(0,H.jsx)(rD,{artifacts:e.artifacts},`artifacts`):null},{id:`node-meta`,column:`primary`,render:({detail:e})=>(0,H.jsx)(JE,{detail:e},`node-meta`)}];function UE(e){return(0,H.jsx)(`div`,{className:`space-y-4`,children:HE.map(t=>t.render(e))})}function WE({detail:e}){return(0,H.jsx)(iD,{title:`Recap`,children:(0,H.jsxs)(`div`,{className:`space-y-4 text-sm text-[var(--text-secondary)]`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(GE,{children:`In progress`}),(0,H.jsxs)(`span`,{className:`font-mono text-xs text-[var(--text-muted)]`,children:[`event #`,e.createdAtEventIndex]})]}),(0,H.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]`,children:[(0,H.jsx)(KE,{label:`Current focus`,value:e.stepLabel??`Current workflow step`,supportingText:`This step is still running, so the recap will appear once execution finishes.`}),(0,H.jsx)(KE,{label:`Current state`,value:`Waiting for step completion`,supportingText:`The node has been created and selected as the current workflow position.`,mono:!0})]}),(0,H.jsxs)(`div`,{className:`bg-[var(--bg-primary)] border border-[var(--border)] overflow-hidden`,children:[(0,H.jsx)(`div`,{className:`px-4 py-3 border-b border-[var(--border)]`,children:(0,H.jsx)(Uo,{children:`What lands here next`})}),(0,H.jsxs)(`div`,{className:`p-4 grid gap-3 md:grid-cols-3`,children:[(0,H.jsx)(qE,{title:`Recap`,description:`A step summary is written when this node completes.`}),(0,H.jsx)(qE,{title:`Validations`,description:`Validation results appear if this step records contract checks.`}),(0,H.jsx)(qE,{title:`Artifacts`,description:`Generated outputs show up here after the step produces them.`})]})]})]})})}function GE({children:e}){return(0,H.jsx)(`span`,{className:`inline-flex items-center px-2 py-1 font-medium text-xs`,style:{backgroundColor:`rgba(0, 219, 233, 0.12)`,color:`var(--accent-strong)`},children:e})}function KE({label:e,value:t,supportingText:n,mono:r=!1}){return(0,H.jsxs)(`div`,{className:`bg-[var(--bg-primary)] border border-[var(--border)] px-4 py-3 space-y-2`,children:[(0,H.jsx)(Uo,{children:e}),(0,H.jsx)(`div`,{className:r?`font-mono text-sm text-[var(--text-primary)]`:`text-[var(--text-primary)]`,children:t}),(0,H.jsx)(`div`,{className:`text-xs text-[var(--text-muted)] leading-relaxed`,children:n})]})}function qE({title:e,description:t}){return(0,H.jsxs)(`div`,{className:`border border-[var(--border)] bg-[rgba(255,255,255,0.02)] px-3 py-3 space-y-2`,children:[(0,H.jsx)(Uo,{color:`var(--text-secondary)`,children:e}),(0,H.jsx)(`div`,{className:`text-xs text-[var(--text-muted)] leading-relaxed`,children:t})]})}function JE({detail:e}){return(0,H.jsx)(iD,{title:`Node details`,children:(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsx)(aD,{label:`Kind`,value:(0,H.jsx)(sD,{kind:e.nodeKind})}),(0,H.jsx)(aD,{label:`Event index`,value:String(e.createdAtEventIndex),mono:!0}),(0,H.jsx)(aD,{label:`Parent`,value:e.parentNodeId??`Root`,mono:!0}),(0,H.jsx)(aD,{label:`Tip state`,value:e.isTip?e.isPreferredTip?`Preferred tip`:`Tip`:`Historical`})]})})}function YE({markdown:e}){return(0,H.jsx)(iD,{title:`Recap`,children:(0,H.jsx)(IE,{children:e})})}function XE({outcome:e}){let t=e.kind===`advanced`;return(0,H.jsx)(iD,{title:`Advance outcome`,children:(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-xs`,children:[(0,H.jsx)(`span`,{className:`inline-flex items-center px-2 py-1 font-medium`,style:{backgroundColor:t?`var(--success)20`:`var(--blocked)20`,color:t?`var(--success)`:`var(--blocked)`},children:t?`Advanced`:`Blocked`}),(0,H.jsxs)(`span`,{className:`text-[var(--text-muted)]`,children:[`attempt `,e.attemptId.slice(-8),` at event #`,e.recordedAtEventIndex]})]})})}function ZE({validations:e}){return(0,H.jsx)(iD,{title:`Validations (${e.length})`,children:(0,H.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,H.jsx)(QE,{validation:e},e.validationId))})})}function QE({validation:e}){let t=e.outcome===`pass`;return(0,H.jsxs)(`div`,{className:`bg-[var(--bg-primary)] border border-[var(--border)] px-4 py-3 text-xs space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`inline-flex items-center px-2 py-1 font-medium`,style:{backgroundColor:t?`var(--success)20`:`var(--error)20`,color:t?`var(--success)`:`var(--error)`},children:t?`Pass`:`Fail`}),(0,H.jsx)(`span`,{className:`text-[var(--text-muted)] font-mono`,children:e.contractRef})]}),e.issues.length>0&&(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`div`,{className:`text-[var(--text-muted)] mb-1`,children:`Issues`}),(0,H.jsx)(`ul`,{className:`list-disc list-inside text-[var(--error)] space-y-0.5`,children:e.issues.map((e,t)=>(0,H.jsx)(`li`,{children:e},t))})]}),e.suggestions.length>0&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-[var(--text-muted)] mb-1`,children:`Suggestions`}),(0,H.jsx)(`ul`,{className:`list-disc list-inside text-[var(--text-secondary)] space-y-0.5`,children:e.suggestions.map((e,t)=>(0,H.jsx)(`li`,{children:e},t))})]})]})}function $E({gaps:e}){return(0,H.jsx)(iD,{title:`Gaps (${e.length})`,children:(0,H.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,H.jsxs)(`div`,{className:`flex items-start gap-3 text-xs bg-[var(--bg-primary)] border border-[var(--border)] px-3 py-3`,children:[(0,H.jsx)(`span`,{className:`shrink-0 inline-flex items-center px-2 py-1 font-medium`,style:{backgroundColor:e.isResolved?`var(--success)20`:e.severity===`critical`?`var(--error)20`:`var(--warning)20`,color:e.isResolved?`var(--success)`:e.severity===`critical`?`var(--error)`:`var(--warning)`},children:e.isResolved?`Resolved`:e.severity===`critical`?`Critical`:`Non-critical`}),(0,H.jsx)(`span`,{className:`text-[var(--text-secondary)] leading-relaxed`,children:e.summary})]},e.gapId))})})}var eD=1e5,tD=[{prefix:`text/`,render:e=>(0,H.jsx)(`pre`,{className:`text-[var(--text-secondary)] whitespace-pre-wrap break-words font-mono max-h-40 overflow-y-auto`,children:typeof e==`string`?e:String(e)})},{prefix:`application/json`,render:e=>(0,H.jsx)(`pre`,{className:`text-[var(--text-secondary)] whitespace-pre-wrap break-words font-mono max-h-40 overflow-y-auto`,children:typeof e==`string`?e:JSON.stringify(e,null,2)})}];function nD(e){if(e.byteLength>eD)return(0,H.jsxs)(`div`,{className:`text-[var(--text-muted)] italic`,children:[`Content too large to display (`,cD(e.byteLength),` -- limit `,cD(eD),`)`]});let t=tD.find(t=>e.contentType.startsWith(t.prefix));return t?t.render(e.content):(0,H.jsx)(`pre`,{className:`text-[var(--text-secondary)] whitespace-pre-wrap break-words font-mono max-h-40 overflow-y-auto`,children:typeof e.content==`string`?e.content:JSON.stringify(e.content,null,2)})}function rD({artifacts:e}){return(0,H.jsx)(iD,{title:`Artifacts (${e.length})`,children:(0,H.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,H.jsxs)(`div`,{className:`bg-[var(--bg-primary)] border border-[var(--border)] px-4 py-3 text-xs space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[var(--text-muted)]`,children:[(0,H.jsx)(`span`,{children:e.contentType}),(0,H.jsx)(`span`,{children:`//`}),(0,H.jsx)(`span`,{children:cD(e.byteLength)})]}),nD(e)]},e.sha256))})})}function iD({title:e,children:t}){return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`mb-2`,children:(0,H.jsx)(Uo,{children:e})}),t]})}function aD({label:e,value:t,mono:n=!1}){return(0,H.jsxs)(`div`,{className:`bg-[var(--bg-primary)] border border-[var(--border)] px-4 py-3`,children:[(0,H.jsx)(Uo,{children:e}),(0,H.jsx)(`div`,{className:n?`mt-2 font-mono text-sm text-[var(--text-secondary)] truncate`:`mt-2 text-sm text-[var(--text-primary)]`,children:t})]})}var oD={step:{label:`Step`,color:`var(--accent)`},checkpoint:{label:`Checkpoint`,color:`var(--success)`},blocked_attempt:{label:`Blocked`,color:`var(--error)`}};function sD({kind:e}){let t=oD[e];return(0,H.jsx)(`span`,{className:`inline-flex items-center px-2 py-1 font-medium`,style:{backgroundColor:`${t.color}20`,color:t.color},children:t.label})}function cD(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function lD(e){return e.length>16?`\u2026${e.slice(-16)}`:e}function uD({data:e}){let t=e.runs[0]??null,n=t?.workflowName??t?.workflowId??`--`,r=t?.workflowHash?.slice(0,12)??`--`;return(0,H.jsxs)(`div`,{className:`bg-[var(--bg-card)] border border-[var(--border)] px-5 py-4 corner-brackets`,style:{backdropFilter:`blur(12px)`,WebkitBackdropFilter:`blur(12px)`},children:[e.sessionTitle&&(0,H.jsx)(`h2`,{className:`text-base font-medium text-[var(--text-primary)] mb-3`,children:e.sessionTitle}),(0,H.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-8 gap-y-2`,children:[(0,H.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)] self-center`,children:`Session`}),(0,H.jsx)(`dd`,{className:`font-mono text-xs text-[var(--text-secondary)] self-center`,children:lD(e.sessionId)}),(0,H.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)] self-center`,children:`Workflow`}),(0,H.jsx)(`dd`,{className:`text-sm text-[var(--text-primary)] self-center`,children:n}),(0,H.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)] self-center`,children:`Hash`}),(0,H.jsx)(`dd`,{className:`font-mono text-xs text-[var(--text-secondary)] self-center`,children:r}),(0,H.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)] self-center`,children:`Status`}),(0,H.jsxs)(`dd`,{className:`self-center flex items-center gap-2`,children:[(0,H.jsx)(no,{health:e.health}),e.health===`healthy`&&(0,H.jsx)(`span`,{className:`text-sm text-[var(--text-primary)]`,children:`Healthy`})]}),(0,H.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)] self-center`,children:`Runs`}),(0,H.jsxs)(`dd`,{className:`text-sm text-[var(--text-primary)] self-center`,children:[e.runs.length,` run`,e.runs.length===1?``:`s`]})]})]})}function dD({runs:e}){let t=e.some(e=>e.preferredTipNodeId!==null),n=e.some(e=>e.executionTraceSummary!==null);return(0,H.jsxs)(`div`,{className:`border border-[var(--border)] px-4 py-3 text-xs text-[var(--text-muted)] space-y-1`,children:[(0,H.jsx)(`p`,{children:t?`Nodes with a gold border are the current execution tips — click any node to inspect its execution detail.`:`Click any node in the DAG to inspect its execution detail.`}),n&&(0,H.jsxs)(`p`,{children:[`This run has execution trace data. Click`,` `,(0,H.jsx)(`span`,{className:`font-mono uppercase tracking-[0.16em]`,children:`[ TRACE ]`}),` `,`to see why certain steps ran, were skipped, or repeated.`]})]})}function fD({viewModel:e}){let{state:t,onSelectNode:n,onCloseNode:r}=e;if(t.kind===`loading`)return(0,H.jsx)(`div`,{className:`text-[var(--text-secondary)]`,children:`Loading session...`});if(t.kind===`error`)return(0,H.jsxs)(`div`,{className:`text-[var(--error)] bg-[var(--bg-card)] rounded-lg p-4`,children:[`Failed to load session: `,t.message]});let{sessionId:i,data:a,selectedNode:o,selectedRun:s}=t;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsx)(uD,{data:a}),a.runs.length===0?(0,H.jsx)(`div`,{className:`text-center py-16 text-[var(--text-secondary)]`,children:`No runs in this session`}):(0,H.jsxs)(H.Fragment,{children:[o===null&&(0,H.jsx)(dD,{runs:a.runs}),(0,H.jsx)(`div`,{className:`space-y-6`,children:a.runs.map(e=>(0,H.jsx)(pD,{run:e,selectedNodeId:o?.runId===e.runId?o.nodeId:null,onNodeClick:n},e.runId))})]})]}),(0,H.jsxs)(oo,{cut:18,borderColor:`rgba(244, 196, 48, 0.35)`,background:`rgba(27, 31, 44, 0.78)`,dropShadow:`drop-shadow(0 16px 48px rgba(0,0,0,0.9)) drop-shadow(0 2px 12px rgba(244,196,48,0.15))`,backdropFilter:`blur(16px)`,className:`fixed top-3 right-3 bottom-3 w-[560px] max-w-[calc(92vw-12px)] transition-transform duration-200 ease-out`,style:{zIndex:40,transform:o?`translateX(0)`:`translateX(calc(100% + 12px))`},children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-[var(--border)] shrink-0 console-blueprint-grid`,children:[(0,H.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)]`,children:`Node detail`}),(0,H.jsx)(`button`,{onClick:r,className:`text-[var(--text-muted)] hover:text-[var(--text-primary)] transition-colors text-xl leading-none px-1`,"aria-label":`Close`,children:`×`})]}),(0,H.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,H.jsx)(LE,{sessionId:i,nodeId:o?.nodeId??null,runStatus:s?.status??`complete`,currentNodeId:s?.preferredTipNodeId??null,executionTraceSummary:s?.executionTraceSummary??null})})]})]})}function pD({run:e,selectedNodeId:t,onNodeClick:n}){let r=e.executionTraceSummary!==null,[i,a]=(0,V.useState)(`dag`);return(0,H.jsxs)(oo,{cut:10,background:`rgba(27, 31, 44, 0.72)`,backdropFilter:`blur(8px)`,className:`relative`,style:{height:r?`542px`:`506px`},children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-[var(--border)] shrink-0`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-[var(--text-primary)]`,children:e.workflowName??e.workflowId??`Run`}),(0,H.jsx)(`span`,{className:`font-mono text-xs text-[var(--text-muted)]`,children:e.runId}),(0,H.jsxs)(`span`,{className:`font-mono text-xs text-[var(--text-muted)]`,children:[e.nodes.length,` nodes · `,e.tipNodeIds.length,` tip`,e.tipNodeIds.length===1?``:`s`]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.hasUnresolvedCriticalGaps&&(0,H.jsx)(`span`,{className:`text-xs text-[var(--warning)]`,children:`Critical gaps`}),(0,H.jsx)(to,{status:e.status})]})]}),r&&(0,H.jsxs)(`div`,{role:`tablist`,"aria-label":`Run view mode`,className:`flex items-center border-b border-[var(--border)] shrink-0 h-9 px-2 gap-0.5`,onKeyDown:e=>{e.key===`ArrowRight`&&(e.preventDefault(),a(`trace`)),e.key===`ArrowLeft`&&(e.preventDefault(),a(`dag`))},children:[(0,H.jsxs)(`button`,{type:`button`,id:`tab-dag`,role:`tab`,tabIndex:i===`dag`?0:-1,"aria-selected":i===`dag`,onClick:()=>a(`dag`),className:[`tab-btn px-3 py-1.5 font-mono text-[10px] uppercase tracking-[0.25em] transition-colors duration-150`,i===`dag`?`tab-btn--active text-[var(--accent)]`:`text-[var(--text-secondary)] hover:text-[var(--text-primary)]`].join(` `),style:i===`dag`?{backgroundColor:`rgba(244, 196, 48, 0.06)`}:void 0,children:[(0,H.jsx)(`span`,{className:`tab-corner tab-corner--tl`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--tr`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--bl`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--br`,"aria-hidden":`true`}),`DAG`]}),(0,H.jsxs)(`button`,{type:`button`,id:`tab-trace`,role:`tab`,tabIndex:i===`trace`?0:-1,"aria-selected":i===`trace`,onClick:()=>a(`trace`),className:[`tab-btn px-3 py-1.5 font-mono text-[10px] uppercase tracking-[0.25em] transition-colors duration-150`,i===`trace`?`tab-btn--active text-[var(--accent)]`:`text-[var(--text-secondary)] hover:text-[var(--text-primary)]`].join(` `),style:i===`trace`?{backgroundColor:`rgba(244, 196, 48, 0.06)`}:void 0,children:[(0,H.jsx)(`span`,{className:`tab-corner tab-corner--tl`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--tr`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--bl`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--br`,"aria-hidden":`true`}),`TRACE`]})]}),(0,H.jsx)(`div`,{role:`tabpanel`,"aria-labelledby":i===`dag`?`tab-dag`:`tab-trace`,className:`flex-1`,children:i===`trace`&&e.executionTraceSummary!==null?(0,H.jsx)(Ry,{summary:e.executionTraceSummary,runStatus:e.status}):(0,H.jsx)(fy,{run:e,selectedNodeId:t,onNodeClick:t=>n(e.runId,t)})})]})}function mD(){let[e,t]=(0,V.useState)(0),[n,r]=(0,V.useState)(0),[i,a]=(0,V.useState)(38),[o,s]=(0,V.useState)(62),[c,l]=(0,V.useState)(3),[u,d]=(0,V.useState)(2),[f,p]=(0,V.useState)(``),[m,h]=(0,V.useState)(!1),g=(0,V.useRef)(!1),_=(0,V.useRef)(null),v=(0,V.useRef)(null),y=(0,V.useRef)(null),b=(e,n,i,o,c,u)=>{g.current=!0,h(!0),t(e=>e+1),r(Math.floor(Math.random()*4)),a(5+Math.floor(Math.random()*80)),s(5+Math.floor(Math.random()*80)),l(2+Math.floor(Math.random()*40)),d(2+Math.floor(Math.random()*25)),p(i===`horizontal`?n===`next`?`modal-content--exit-h-next`:`modal-content--exit-h-prev`:n===`next`?`modal-content--exit-v-next`:`modal-content--exit-v-prev`),c.current&&(c.current.scrollTop=0);let f=u[e].id;setTimeout(()=>{o(f),p(i===`horizontal`?n===`next`?`modal-content--enter-h-next`:`modal-content--enter-h-prev`:n===`next`?`modal-content--enter-v-next`:`modal-content--enter-v-prev`),h(!1)},80),setTimeout(()=>{if(p(``),g.current=!1,_.current!==null){let e=_.current;_.current=null;let t=e>u.findIndex(e=>e.id===v.current)?`next`:`prev`;y.current?.(e,t,`horizontal`,o,c,u)}},240)};return y.current=b,{state:{isAnimating:g.current,contentAnimClass:f,borderFlashing:m,scanline:e>0?{key:e,crtOffset:n,glitchY:i,glitchY2:o,glitchW:c,glitchW2:u}:null},startTransition:b,navigate:(e,t,n,r,i,a)=>{if(t.length<=1)return;let o=t.findIndex(t=>t.id===e);if(o===-1)return;let s=n===`next`?(o+1)%t.length:(o-1+t.length)%t.length;if(g.current){_.current=s;return}b(s,n,r,i,a,t)},selectedWorkflowIdRef:v}}var hD=[{id:`coding`,label:`Coding`},{id:`review_audit`,label:`Review & Audit`},{id:`investigation`,label:`Investigation`},{id:`design`,label:`Design`},{id:`documentation`,label:`Documentation`},{id:`tickets`,label:`Tickets`},{id:`learning`,label:`Learning`},{id:`authoring`,label:`Workflow Authoring`}],gD=Object.fromEntries(hD.map(e=>[e.id,e.label]));function _D({label:e,count:t,countLabel:n=`workflow`,showRule:r=!0,separator:i=`//`}){return(0,H.jsxs)(`div`,{className:`flex items-center gap-3 mb-3 mt-2`,children:[(0,H.jsxs)(`span`,{className:`font-mono text-[11px] uppercase tracking-[0.30em] text-[var(--text-secondary)] shrink-0`,children:[e,t==null?``:` ${i} ${t} ${n}${t===1?``:`s`}`]}),r&&(0,H.jsx)(`div`,{className:`flex-1 h-px bg-[var(--border)]`})]})}function vD({segments:e,className:t=``}){return(0,H.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:`flex items-center gap-0 ${t}`,children:e.map((t,n)=>{let r=n===e.length-1,i=!!t.onClick;return(0,H.jsxs)(`span`,{className:`flex items-center`,children:[(0,H.jsx)(`span`,{className:`font-mono text-[10px] tracking-[0.25em] text-[var(--text-muted)] mx-1`,children:`//`}),i?(0,H.jsx)(`button`,{type:`button`,onClick:t.onClick,className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] hover:text-[var(--accent)] transition-colors cursor-pointer`,children:t.label.toUpperCase()}):(0,H.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] ${r?`text-[var(--text-secondary)]`:`text-[var(--text-muted)]`}`,"aria-current":r?`page`:void 0,children:t.label.toUpperCase()})]},n)})})}function yD({viewModel:e}){let{state:t}=e;if(t.kind===`not_found`)return(0,H.jsx)(`div`,{className:`space-y-5 max-w-3xl`,children:(0,H.jsx)(TD,{message:``,is404:!0,onRetry:()=>void 0,onBack:t.onBack})});if(t.kind===`error`)return(0,H.jsx)(`div`,{className:`space-y-5 max-w-3xl`,children:(0,H.jsx)(TD,{message:t.message,is404:!1,onRetry:t.onRetry,onBack:t.onBack})});if(t.kind===`loading`){let{cached:e,activeTagLabel:n,onBack:r}=t;return(0,H.jsxs)(`div`,{className:`space-y-5 max-w-3xl`,children:[(0,H.jsx)(vD,{segments:n?[{label:`Workflows`,onClick:r},{label:n}]:[{label:`Workflows`,onClick:r}]}),e?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(bD,{name:e.name,description:e.description,tags:e.tags,source:e.source,stepCount:void 0}),(0,H.jsx)(`div`,{className:`space-y-4`,children:(0,H.jsx)(CD,{})})]}):(0,H.jsx)(wD,{})]})}let{workflow:n,name:r,description:i,tags:a,source:o,activeTagLabel:s,onPrev:c,onNext:l,onBack:u}=t;return(0,H.jsxs)(`div`,{className:`space-y-5 max-w-3xl`,children:[(0,H.jsx)(vD,{segments:s?[{label:`Workflows`,onClick:u},{label:s}]:[{label:`Workflows`,onClick:u}]}),(0,H.jsx)(bD,{name:r,description:i,tags:a,source:o,stepCount:n.stepCount}),(c??l)&&(0,H.jsxs)(`div`,{className:`flex items-center gap-4`,children:[c&&(0,H.jsxs)(`button`,{type:`button`,onClick:c,className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] hover:text-[var(--accent)] transition-colors`,children:[`<`,` PREV`]}),l&&(0,H.jsxs)(`button`,{type:`button`,onClick:l,className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] hover:text-[var(--accent)] transition-colors`,children:[`NEXT `,`>`]})]}),(0,H.jsx)(xD,{detail:n,name:r}),(0,H.jsx)(vD,{segments:[{label:`Workflows`,onClick:u}]})]})}function bD({name:e,description:t,tags:n,source:r,stepCount:i}){return(0,H.jsxs)(`div`,{className:`border border-[var(--border)] px-5 py-5 console-blueprint-grid`,children:[(0,H.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-[0.35em] text-[var(--text-muted)] mb-2`,children:`// Workflow`}),(0,H.jsx)(`h2`,{className:`font-mono text-xl font-bold uppercase tracking-[0.08em] leading-tight mb-3`,style:{color:`var(--accent)`,textShadow:`0 0 24px rgba(244,196,48,0.45), 0 0 48px rgba(244,196,48,0.15)`},children:e}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i!=null&&i>0&&(0,H.jsxs)(`span`,{className:`font-mono text-[10px] px-1.5 py-0.5 border border-[var(--border)] text-[var(--text-secondary)]`,children:[i,` step`,i===1?``:`s`]}),n.filter(e=>e!==`routines`).map(e=>(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`font-mono text-[10px] px-1.5 py-0.5 bg-[var(--bg-secondary)] text-[var(--text-muted)]`,children:e},e)),r&&(0,H.jsxs)(`span`,{"aria-hidden":`true`,className:`font-mono text-[10px] px-1.5 py-0.5 border border-[var(--border)] text-[var(--text-muted)]`,children:[`src: `,r.displayName]})]}),t&&(0,H.jsx)(`p`,{className:`text-sm text-[var(--text-secondary)] leading-relaxed mt-3`,children:t})]})}function xD({detail:e,name:t}){let n=e.about!==void 0&&e.about.length>0,r=e.examples!==void 0&&e.examples.length>0,i=e.preconditions!==void 0&&e.preconditions.length>0;return n||r||i?(0,H.jsxs)(`div`,{className:`space-y-6`,children:[n&&(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h3`,{className:`text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider mb-3`,children:`About`}),(0,H.jsx)(IE,{children:e.about})]}),r&&(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h3`,{className:`text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider mb-3`,children:`Try it with:`}),(0,H.jsx)(`ul`,{className:`space-y-2`,children:e.examples.map(e=>(0,H.jsxs)(`li`,{className:`flex items-start gap-3 bg-[var(--bg-card)] border border-[var(--border)] rounded-none px-4 py-3`,children:[(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`w-0.5 shrink-0 self-stretch rounded-full`,style:{backgroundColor:`var(--accent)`}}),(0,H.jsxs)(`span`,{className:`text-sm text-[var(--text-secondary)] leading-relaxed`,children:[`"`,e,`"`]})]},e))})]}),i&&(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h3`,{className:`text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider mb-3`,children:`Before you start:`}),(0,H.jsx)(`ul`,{className:`space-y-1.5`,children:e.preconditions.map(e=>(0,H.jsxs)(`li`,{className:`flex items-start gap-2 text-sm text-[var(--text-secondary)]`,children:[(0,H.jsx)(`span`,{className:`shrink-0 text-[var(--text-muted)] mt-0.5`,children:`•`}),(0,H.jsx)(`span`,{children:e})]},e))})]}),(0,H.jsx)(SD,{name:t})]}):(0,H.jsx)(`p`,{className:`text-sm text-[var(--text-muted)] italic`,children:`No additional documentation available.`})}function SD({name:e}){let[t,n]=(0,V.useState)(!1),r=`Use the ${e} to [your goal]`;return(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h3`,{className:`text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider mb-3`,children:`Start with this prompt`}),(0,H.jsxs)(`div`,{className:`flex items-center gap-3 border border-[var(--border)] px-4 py-3`,children:[(0,H.jsxs)(`span`,{className:`flex-1 text-sm text-[var(--text-secondary)] font-mono truncate`,children:[`"`,r,`"`]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>{navigator.clipboard.writeText(r).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})},className:`shrink-0 text-xs font-mono text-[var(--accent)] hover:text-[var(--text-primary)] transition-colors`,children:t?`Copied!`:`Copy`})]})]})}function CD(){return(0,H.jsxs)(`div`,{className:`space-y-3 motion-safe:animate-pulse`,children:[(0,H.jsx)(`div`,{className:`h-3 w-16 rounded bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`h-4 w-full rounded bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`h-4 w-5/6 rounded bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`h-4 w-4/6 rounded bg-[var(--bg-tertiary)]`})]})}function wD(){return(0,H.jsxs)(`div`,{className:`space-y-6 motion-safe:animate-pulse`,children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`div`,{className:`h-6 w-1/2 rounded bg-[var(--bg-tertiary)]`}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(`div`,{className:`h-5 w-16 rounded bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`h-5 w-24 rounded bg-[var(--bg-tertiary)]`})]}),(0,H.jsx)(`div`,{className:`h-4 w-full rounded bg-[var(--bg-tertiary)]`})]}),(0,H.jsx)(CD,{})]})}function TD({message:e,is404:t,onRetry:n,onBack:r}){return(0,H.jsxs)(`div`,{className:`space-y-4 bg-[var(--bg-card)] border border-[var(--border)] p-4`,children:[(0,H.jsx)(`p`,{className:`text-sm text-[var(--error)]`,children:t?`Workflow not found.`:e}),(0,H.jsxs)(`div`,{className:`flex gap-3`,children:[!t&&(0,H.jsx)(`button`,{type:`button`,onClick:n,className:`text-sm text-[var(--accent)] hover:text-[var(--accent-hover)] transition-colors`,children:`Try again`}),(0,H.jsxs)(`button`,{type:`button`,onClick:r,"aria-label":`Back to workflows list`,className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] hover:text-[var(--accent)] transition-colors`,children:[`<`,` WORKFLOWS`]})]})]})}function ED(e){if(e.size<2)return 1;let t=new Set;for(let n of e.values())t.add(Math.round(n.getBoundingClientRect().top));if(t.size<2){let t=Math.round(e.get(0)?.getBoundingClientRect().top??0),n=0;for(let r of e.values())Math.round(r.getBoundingClientRect().top)===t&&n++;return Math.max(1,n)}let n=Math.round(e.get(0)?.getBoundingClientRect().top??0),r=0;for(let t of e.values())Math.round(t.getBoundingClientRect().top)===n&&r++;return Math.max(1,r)}function DD(e,t,n,r){if(n===0)return 0;let i=(e??(t>0?-1:n))+t;return r?(i%n+n)%n:Math.max(0,Math.min(n-1,i))}function OD(e,t,n,r,i){if(n===0)return 0;let a=e??0,o=a%r,s=Math.floor(a/r),c=Math.ceil(n/r),l=s+t;l=i?(l%c+c)%c:Math.max(0,Math.min(c-1,l));let u=l*r+o;return Math.min(u,n-1)}function kD({count:e,cols:t=`auto`,onActivate:n,loop:r=!0}){let[i,a]=(0,V.useState)(null),o=(0,V.useRef)(new Map),s=(0,V.useCallback)(e=>{a(e),e!==null&&o.current.get(e)?.focus()},[]),c=(0,V.useCallback)(()=>t===`auto`?ED(o.current):Math.max(1,t),[t]);return{focusedIndex:i,setFocusedIndex:s,getItemProps:(0,V.useCallback)(t=>({tabIndex:i===null?t===0?0:-1:i===t?0:-1,onFocus:()=>{a(t)},onKeyDown:i=>{let a=c(),o=null;switch(i.key){case`ArrowRight`:case`d`:case`D`:o=DD(t,1,e,r);break;case`ArrowLeft`:case`a`:case`A`:o=DD(t,-1,e,r);break;case`ArrowDown`:case`s`:case`S`:o=OD(t,1,e,a,r);break;case`ArrowUp`:case`w`:case`W`:o=OD(t,-1,e,a,r);break;case`Home`:o=0;break;case`End`:o=e-1;break;case`Enter`:case` `:i.preventDefault(),n?.(t);return;default:return}o!==null&&(i.preventDefault(),s(o))},ref:e=>{e?o.current.set(t,e):o.current.delete(t)}}),[i,e,r,c,n,s]),containerProps:{role:`grid`}}}function AD(e){let t=Jy(e),n=()=>{t.refetch()};return t.isLoading?{kind:`loading`}:t.error?t.error instanceof By&&t.error.status===404?{kind:`not_found`}:{kind:`error`,message:t.error instanceof Error?t.error.message:`Could not load workflow details.`,refetch:n}:t.data?{kind:`ready`,detail:t.data,refetch:n}:{kind:`loading`}}function jD(){let e=Ky();return{workflows:e.data?.workflows.filter(e=>!e.tags.includes(`routines`)),isLoading:e.isLoading,error:e.error instanceof Error?e.error:null,refetch:e.refetch}}function MD(e,t){if(!e)return{prevWorkflow:null,nextWorkflow:null};let n=t.findIndex(t=>t.id===e);return n===-1?{prevWorkflow:null,nextWorkflow:null}:{prevWorkflow:n>0?t[n-1]??null:null,nextWorkflow:n<t.length-1?t[n+1]??null:null}}function ND({workflowId:e,activeTag:t,onBack:n,onNavigateToWorkflow:r}){let i=AD(e),a=jD().workflows,o=(0,V.useRef)(null),s=(0,V.useRef)(null),c=(0,V.useRef)(r);c.current=r;let l=a??[],{prevWorkflow:u,nextWorkflow:d}=(0,V.useMemo)(()=>MD(e,l),[e,l]),f=u?()=>c.current(u.id):null,p=d?()=>c.current(d.id):null;o.current=f,s.current=p;let m=i.kind===`ready`;return(0,V.useEffect)(()=>{if(!m)return;function e(e){e.metaKey||e.ctrlKey||e.altKey||(e.key===`ArrowLeft`?(e.preventDefault(),o.current?.()):e.key===`ArrowRight`&&(e.preventDefault(),s.current?.()))}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[m]),{state:(0,V.useMemo)(()=>{let r=a?.find(t=>t.id===e)??void 0,o=t?gD[t]??t:null;if(i.kind===`not_found`)return{kind:`not_found`,onBack:n};if(i.kind===`error`)return{kind:`error`,message:i.message,onBack:n,onRetry:i.refetch};if(i.kind===`ready`){let t=i.detail;return{kind:`ready`,workflow:t,name:t.name??r?.name??e??``,description:t.description??r?.description??null,tags:t.tags??r?.tags??[],source:t.source??r?.source??null,activeTagLabel:o,adjacentWorkflows:l,onPrev:f,onNext:p,onBack:n}}return{kind:`loading`,cached:r??null,activeTagLabel:o,onBack:n}},[i,a,e,t,l,f,p,n])}}function PD(e){let t=new Set(hD.map(e=>e.id)),n=new Map,r=[];for(let i of e){let e=i.tags.find(e=>e!==`routines`&&t.has(e));if(e){let t=n.get(e)??[];t.push(i),n.set(e,t)}else r.push(i)}let i=hD.filter(e=>n.has(e.id)).map(e=>({tagId:e.id,label:e.label,workflows:n.get(e.id)}));return r.length>0&&i.push({tagId:null,label:`Other`,workflows:r}),i}function FD({viewModel:e}){let{state:t,dispatch:n,triggerRef:r,onCardSelect:i}=e,a=(0,V.useRef)(null),o=(0,V.useRef)(null),s=mD(),c=t.kind===`ready`?t.selectedWorkflowId:null;if((0,V.useEffect)(()=>{if(c){let e=requestAnimationFrame(()=>a.current?.focus());return()=>cancelAnimationFrame(e)}},[c]),t.kind===`loading`)return(0,H.jsx)(zD,{});if(t.kind===`error`)return(0,H.jsx)(BD,{message:t.message,onRetry:t.onRetry});let{selectedTag:l,selectedSource:u,hintVisible:d,filteredWorkflows:f,flatWorkflows:p,availableSources:m,sourceFilteredWorkflows:h,tagFilteredWorkflows:g}=t,_=new Set(hD.map(e=>e.id)),v=new Set(h.flatMap(e=>e.tags)),y=new Map(hD.map(e=>[e.id,h.filter(t=>t.tags.includes(e.id)).length])),b=h.filter(e=>!e.tags.some(e=>e!==`routines`&&_.has(e))).length,x=h.length,S=g.length;return(0,H.jsx)(ID,{selectedWorkflowId:c,selectedTag:l,selectedSource:u,hintVisible:d,filteredWorkflows:f,flatWorkflows:p,availableSources:m,tagsWithWorkflows:v,countByTag:y,otherCount:b,allTagCount:x,allSourceCount:S,countBySource:new Map(m.map(e=>[e.displayName,g.filter(t=>t.source.displayName===e.displayName).length])),currentIndex:p.findIndex(e=>e.id===c),dispatch:n,onCardSelect:i,triggerRef:r,modalPanelRef:a,scrollRef:o,modalTransition:s})}function ID({selectedWorkflowId:e,selectedTag:t,selectedSource:n,hintVisible:r,filteredWorkflows:i,flatWorkflows:a,availableSources:o,tagsWithWorkflows:s,countByTag:c,otherCount:l,allTagCount:u,allSourceCount:d,countBySource:f,currentIndex:p,dispatch:m,onCardSelect:h,modalPanelRef:g,scrollRef:_,modalTransition:v}){let y=ND({workflowId:e,activeTag:t,onBack:()=>m({type:`modal_closed`}),onNavigateToWorkflow:e=>m({type:`workflow_selected`,id:e})}),b=(0,V.useCallback)((t,n)=>{v.navigate(e,a,t,n,e=>{m({type:`workflow_selected`,id:e}),v.selectedWorkflowIdRef.current=e},_)},[a,e,v,m,_]);(0,V.useEffect)(()=>{if(!e)return;let t=[`ArrowLeft`,`ArrowRight`,`a`,`A`,`d`,`D`],n=[`ArrowUp`,`ArrowDown`,`w`,`W`,`s`,`S`],r=e=>{if(n.includes(e.key)){e.preventDefault(),e.stopPropagation();return}t.includes(e.key)&&(e.preventDefault(),e.stopPropagation(),b([`ArrowLeft`,`a`,`A`].includes(e.key)?`prev`:`next`,`horizontal`))};return document.addEventListener(`keydown`,r,{capture:!0}),()=>{document.removeEventListener(`keydown`,r,{capture:!0})}},[e,b]);let{getItemProps:x,containerProps:S}=kD({count:a.length,cols:`auto`,onActivate:(0,V.useCallback)(e=>{let t=a[e];if(!t)return;let n=document.activeElement;n instanceof HTMLButtonElement&&h(t.id,n)},[a,h])});return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`font-mono text-2xl font-bold uppercase tracking-[0.12em] leading-none`,style:{color:`var(--accent)`,textShadow:`0 0 28px rgba(244,196,48,0.35)`},children:`Workflows`}),(0,H.jsxs)(`p`,{className:`font-mono text-[10px] tracking-[0.25em] text-[var(--text-muted)] mt-1.5`,children:[`// `,i.length,` available`]})]}),(0,H.jsxs)(`div`,{role:`group`,"aria-label":`Filter workflows by category`,className:`flex flex-wrap gap-1.5`,children:[(0,H.jsx)(LD,{label:`All`,count:u,isActive:t===null,disabled:!1,onClick:()=>m({type:`tag_changed`,tag:null})}),hD.filter(e=>s.has(e.id)).map(e=>(0,H.jsx)(LD,{label:e.label,count:c.get(e.id)??0,isActive:t===e.id,disabled:!1,onClick:()=>m({type:`tag_changed`,tag:t===e.id?null:e.id})},e.id)),l>0&&(0,H.jsx)(LD,{label:`Other`,count:l,isActive:t===`__other__`,disabled:!1,onClick:()=>m({type:`tag_changed`,tag:t===`__other__`?null:`__other__`})})]}),o.length>1&&(0,H.jsxs)(`div`,{role:`group`,"aria-label":`Filter workflows by source`,className:`flex flex-wrap gap-1.5`,children:[(0,H.jsx)(LD,{label:`All Sources`,count:d,isActive:n===null,disabled:!1,onClick:()=>m({type:`source_changed`,source:null})}),o.map(e=>(0,H.jsx)(LD,{label:e.displayName,count:f.get(e.displayName)??0,isActive:n===e.displayName,disabled:!1,onClick:()=>m({type:`source_changed`,source:n===e.displayName?null:e.displayName})},e.id))]}),i.length===0?(0,H.jsxs)(`div`,{className:`py-8 text-center space-y-3`,children:[(0,H.jsx)(`p`,{className:`text-sm text-[var(--text-muted)]`,children:`No workflows in this category.`}),t!==null&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>m({type:`tag_changed`,tag:null}),className:`text-sm text-[var(--accent)] hover:text-[var(--accent-hover)] transition-colors`,children:`Clear filter`})]}):t===null?(0,H.jsx)(`div`,{className:`space-y-6`,children:(()=>{let t=0;return PD(i).map(n=>(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(_D,{label:n.label,count:n.workflows.length,showRule:!0}),(0,H.jsx)(`div`,{...S,className:`grid grid-cols-2 lg:grid-cols-3 gap-3`,children:n.workflows.map(n=>(0,H.jsx)(RD,{workflow:n,onSelect:e=>h(n.id,e),navProps:x(t++),isActive:n.id===e},n.id))})]},n.tagId??`__other__`))})()}):(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(_D,{label:t===`__other__`?`Other`:gD[t]??t,count:i.length,showRule:!0}),(0,H.jsx)(`div`,{...S,className:`grid grid-cols-2 lg:grid-cols-3 gap-3`,children:i.map((t,n)=>(0,H.jsx)(RD,{workflow:t,onSelect:e=>h(t.id,e),navProps:x(n),isActive:t.id===e},t.id))})]}),(0,H.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-end justify-center p-4 pointer-events-none`,"aria-hidden":!e,children:[e&&(0,H.jsx)(`div`,{className:`absolute inset-0 pointer-events-auto`,style:{background:`rgba(0,0,0,0.22)`,backdropFilter:`blur(2px)`},onClick:()=>m({type:`modal_closed`})}),(0,H.jsx)(`div`,{ref:g,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":`Workflow detail${e?`: ${a.find(t=>t.id===e)?.name??``}`:``}`,className:`relative w-full max-w-3xl ${e?`pointer-events-auto`:`pointer-events-none`}${v.state.borderFlashing?` modal-border-flashing`:``}`,style:{height:`85vh`,transform:e?`translateY(0) scale(1)`:`translateY(24px) scale(0.97)`,opacity:+!!e,transition:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`opacity 150ms ease-out`:`transform 250ms ease-out, opacity 250ms ease-out`,backdropFilter:`blur(2px)`,WebkitBackdropFilter:`blur(2px)`},children:(0,H.jsxs)(oo,{cut:20,borderColor:`rgba(244, 196, 48, 0.45)`,background:`rgba(15, 19, 31, 0.50)`,dropShadow:`drop-shadow(0 4px 24px rgba(244,196,48,0.15))`,className:`h-full flex flex-col`,children:[v.state.scanline!==null&&(0,H.jsx)(`div`,{className:`modal-scanline`,"aria-hidden":`true`,style:{"--crt-offset":`${v.state.scanline.crtOffset}px`,"--glitch-y":`${v.state.scanline.glitchY}%`,"--glitch-y2":`${v.state.scanline.glitchY2}%`,"--glitch-w":`${v.state.scanline.glitchW}px`,"--glitch-w2":`${v.state.scanline.glitchW2}px`,clipPath:ao(20)}},v.state.scanline.key),(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-[var(--border)] shrink-0 console-blueprint-grid`,style:{background:`rgba(15, 19, 31, 0.55)`},children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,H.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-secondary)]`,children:`Workflow`}),p>=0&&(0,H.jsxs)(`span`,{className:`font-mono text-[10px] tracking-[0.20em] text-[var(--text-secondary)]`,children:[`[ `,p+1,` / `,a.length,` ]`]}),(0,H.jsx)(`span`,{className:`font-mono text-[9px] tracking-[0.15em] text-[var(--text-secondary)] transition-opacity duration-600`,style:{opacity:r?.5:0},"aria-hidden":`true`,children:`[ A / D ] NAV`})]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>m({type:`modal_closed`}),className:`text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors text-xl leading-none`,"aria-label":`Close`,children:`×`})]}),(0,H.jsxs)(`div`,{ref:_,className:`flex-1 overflow-auto overscroll-contain px-6 py-5 ${v.state.contentAnimClass}`,style:{"--text-muted":`var(--text-secondary)`},children:[(0,H.jsx)(`div`,{"aria-live":`polite`,"aria-atomic":`true`,className:`sr-only`,children:a.find(t=>t.id===e)?.name??``}),e&&(0,H.jsx)(yD,{viewModel:y})]})]})})]})]})}function LD({label:e,count:t,isActive:n,disabled:r,onClick:i}){return(0,H.jsxs)(`button`,{type:`button`,onClick:i,disabled:r,"aria-pressed":n,className:[`px-3 py-2 min-w-[44px] min-h-[44px] rounded-none text-xs font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--accent)] focus-visible:ring-offset-2`,`disabled:opacity-50 disabled:cursor-not-allowed`,n?`border border-[var(--accent)] text-[var(--accent)] bg-transparent`:`text-[var(--text-muted)] hover:text-[var(--text-secondary)] hover:bg-[var(--bg-card)]`].join(` `),children:[e,` · `,t,n&&(0,H.jsx)(`span`,{className:`sr-only`,children:`(selected)`})]})}function RD({workflow:e,onSelect:t,navProps:n,isActive:r}){let i=e.tags.filter(e=>e!==`routines`).map(e=>gD[e]??e);return(0,H.jsx)(so,{variant:`grid`,onClick:e=>t(e.currentTarget),"aria-label":[e.name,e.description,i.length>0?`Tag: ${i.join(`, `)}`:null,`Source: ${e.source.displayName}`].filter(Boolean).join(`. `),style:r?{borderColor:`var(--accent)`,boxShadow:`0 0 0 1px rgba(244,196,48,0.4), 0 0 16px rgba(244,196,48,0.12)`}:void 0,...n,children:(0,H.jsxs)(`div`,{className:`flex flex-col flex-1 p-4 gap-2 min-w-0`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-[var(--text-primary)] group-hover:text-[var(--accent)] transition-colors leading-snug line-clamp-2`,children:e.name}),(0,H.jsx)(`p`,{className:`text-xs text-[var(--text-secondary)] line-clamp-3 leading-relaxed flex-1`,children:e.description}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mt-auto pt-2 border-t border-[var(--border)]`,children:[(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:i.slice(0,1).map(e=>(0,H.jsx)(`span`,{className:`font-mono text-[9px] px-1.5 py-0.5 bg-[var(--bg-secondary)] text-[var(--text-muted)]`,children:e},e))}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e.stepCount!=null&&e.stepCount>0&&(0,H.jsxs)(`span`,{className:`font-mono text-[9px] text-[var(--text-muted)]`,children:[e.stepCount,`s`]}),(0,H.jsxs)(`span`,{className:`font-mono text-[9px] text-[var(--text-muted)] max-w-[80px] truncate`,children:[`src: `,e.source.displayName]})]})]})]})})}function zD(){return(0,H.jsx)(`div`,{className:`space-y-6 motion-safe:animate-pulse`,children:[0,1].map(e=>(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(`div`,{className:`h-3 w-24 bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`flex-1 h-px bg-[var(--bg-tertiary)]`})]}),(0,H.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-3 gap-3`,children:[0,1,2,3,4,5].map(e=>(0,H.jsxs)(`div`,{className:`min-h-[160px] bg-[var(--bg-card)] border border-[var(--border)] flex flex-col`,children:[(0,H.jsx)(`div`,{className:`h-[3px] bg-[var(--bg-tertiary)]`}),(0,H.jsxs)(`div`,{className:`p-4 flex flex-col gap-2 flex-1`,children:[(0,H.jsx)(`div`,{className:`h-4 w-3/4 bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`h-3 w-full bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`h-3 w-5/6 bg-[var(--bg-tertiary)]`}),(0,H.jsxs)(`div`,{className:`mt-auto pt-2 border-t border-[var(--border)] flex justify-between`,children:[(0,H.jsx)(`div`,{className:`h-3 w-12 bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`h-3 w-16 bg-[var(--bg-tertiary)]`})]})]})]},e))})]},e))})}function BD({message:e,onRetry:t}){return(0,H.jsxs)(`div`,{className:`space-y-3 py-8 text-center`,children:[(0,H.jsx)(`p`,{className:`text-sm text-[var(--error)]`,children:e}),(0,H.jsx)(`button`,{type:`button`,onClick:t,className:`text-sm text-[var(--accent)] hover:text-[var(--accent-hover)] transition-colors`,children:`Try again`})]})}var VD=[{value:`recent`,label:`Recent first`,compareFn:(e,t)=>t.startedAtMs-e.startedAtMs},{value:`slowest`,label:`Slowest first`,compareFn:(e,t)=>t.durationMs-e.durationMs}],HD={success:{color:`var(--success)`,label:`OK`,isError:!1},error:{color:`var(--error)`,label:`Error`,isError:!0},unknown_tool:{color:`var(--warning)`,label:`Unknown`,isError:!0}};function UD(e,t){let n=VD.find(e=>e.value===t);return[...e].sort(n.compareFn)}function WD(e){return e.reduce((e,t)=>Math.max(e,t.durationMs),0)}function GD(e){return e.filter(e=>HD[e.outcome].isError).length}function KD(e){return e.length===0?null:Math.round(e.reduce((e,t)=>e+t.durationMs,0)/e.length)}function qD(e){return e.length===0?null:e.reduce((e,t)=>Math.max(e,t.startedAtMs),0)}function JD(e,t){return t>0?Math.round(e/t*120):0}function YD(e){return`${e} recorded`}var XD=[{key:`tool`,label:`Tool`,minWidth:`180px`},{key:`duration`,label:`Duration`,width:`220px`},{key:`started`,label:`Started`,width:`100px`},{key:`outcome`,label:`Outcome`}];function ZD({viewModel:e}){let{state:t}=e;if(t.kind===`loading`)return(0,H.jsx)(tO,{});if(t.kind===`devModeOff`)return(0,H.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,H.jsx)(`p`,{className:`text-sm text-[var(--text-muted)] text-center`,children:`nothing to see here`})});if(t.kind===`error`)return(0,H.jsxs)(`div`,{className:`space-y-3 py-8 text-center`,children:[(0,H.jsx)(`p`,{className:`text-sm text-[var(--error)]`,children:t.message}),(0,H.jsx)(`button`,{type:`button`,onClick:t.retry,className:`text-sm text-[var(--accent)] hover:text-[var(--accent-hover)] transition-colors`,children:`Try again`})]});let{sorted:n,maxDuration:r,errorCount:i,avgMs:a,lastCallMs:o,countLabel:s,sortOrder:c,onSortChange:l}=t;return(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsxs)(`p`,{className:`text-sm text-[var(--text-secondary)]`,children:[s,` | `,(0,H.jsxs)(`span`,{style:{color:i>0?`var(--error)`:`var(--text-muted)`},children:[i,` errors`]}),` | `,`avg `,a===null?`--`:`${a}ms`,` | `,`last call `,o===null?`no calls yet`:W(o)]}),(0,H.jsx)(`div`,{role:`radiogroup`,"aria-label":`Sort order`,className:`flex items-center gap-1`,children:VD.map(e=>(0,H.jsx)(eO,{label:e.label,isActive:c===e.value,onClick:()=>l(e.value)},e.value))}),(0,H.jsxs)(`table`,{className:`w-full text-sm border-collapse`,children:[(0,H.jsx)(`thead`,{children:(0,H.jsx)(`tr`,{className:`text-xs text-[var(--text-muted)] border-b border-[var(--border)]`,children:XD.map(e=>(0,H.jsx)(`th`,{scope:`col`,className:`text-left py-2 pr-4 font-medium`,style:{width:e.width,minWidth:e.minWidth},children:e.label},e.key))})}),(0,H.jsx)(`tbody`,{children:n.length===0?(0,H.jsx)(`tr`,{children:(0,H.jsx)(`td`,{colSpan:XD.length,className:`py-8 text-center text-sm text-[var(--text-muted)]`,children:`No tool calls recorded yet. Run a workflow to see timing data.`})}):n.map((e,t)=>(0,H.jsx)(QD,{obs:e,maxDuration:r},`${e.startedAtMs}-${e.toolName}-${t}`))})]})]})}function QD({obs:e,maxDuration:t}){let n=HD[e.outcome].isError,r=JD(e.durationMs,t);return(0,H.jsxs)(`tr`,{className:`border-b border-[var(--border)] hover:bg-[var(--bg-card)] transition-colors`,style:{borderLeft:n?`2px solid var(--error)`:`2px solid transparent`},children:[(0,H.jsx)(`td`,{className:`py-2 pr-4 font-mono text-[var(--text-primary)] overflow-hidden text-ellipsis`,title:e.toolName,style:{minWidth:`180px`,maxWidth:`240px`},children:(0,H.jsx)(`span`,{className:`block truncate`,children:e.toolName})}),(0,H.jsxs)(`td`,{className:`py-2 pr-4`,style:{width:`220px`},children:[(0,H.jsxs)(`span`,{className:`font-mono text-[var(--text-primary)]`,children:[e.durationMs,`ms`]}),(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`h-1 rounded mt-1`,style:{backgroundColor:`var(--accent)`,width:`${r}px`,maxWidth:`120px`}})]}),(0,H.jsx)(`td`,{className:`py-2 pr-4 text-[var(--text-secondary)]`,style:{width:`100px`},children:W(e.startedAtMs)}),(0,H.jsx)(`td`,{className:`py-2`,children:(0,H.jsx)($D,{outcome:e.outcome})})]})}function $D({outcome:e}){let t=HD[e];return(0,H.jsx)(`span`,{className:`inline-block px-2 py-0.5 rounded text-xs font-medium`,style:{color:t.color,backgroundColor:`color-mix(in srgb, ${t.color} 12%, transparent)`},children:t.label})}function eO({label:e,isActive:t,onClick:n}){return(0,H.jsx)(`button`,{type:`button`,role:`radio`,onClick:n,"aria-checked":t,className:[`px-3 py-2 rounded text-xs font-medium min-w-[44px] transition-colors`,t?`text-[var(--text-primary)]`:`text-[var(--text-muted)] hover:text-[var(--text-secondary)]`].join(` `),children:e})}function tO(){return(0,H.jsxs)(`div`,{className:`space-y-3 animate-pulse`,"aria-busy":`true`,"aria-label":`Loading performance data`,children:[(0,H.jsx)(`div`,{className:`h-4 w-64 rounded bg-[var(--bg-tertiary)]`}),(0,H.jsxs)(`div`,{className:`flex gap-1`,children:[(0,H.jsx)(`div`,{className:`h-8 w-24 rounded bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`h-8 w-24 rounded bg-[var(--bg-tertiary)]`})]}),(0,H.jsxs)(`div`,{className:`flex gap-4 border-b border-[var(--border)] pb-2`,children:[(0,H.jsx)(`div`,{className:`h-3 w-20 rounded bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`h-3 w-16 rounded bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`h-3 w-14 rounded bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`h-3 w-14 rounded bg-[var(--bg-tertiary)]`})]}),Array.from({length:8}).map((e,t)=>(0,H.jsxs)(`div`,{className:`flex gap-4 py-2`,children:[(0,H.jsx)(`div`,{className:`h-4 rounded bg-[var(--bg-tertiary)]`,style:{minWidth:`180px`,width:`180px`}}),(0,H.jsxs)(`div`,{className:`space-y-1`,style:{width:`220px`},children:[(0,H.jsx)(`div`,{className:`h-4 w-16 rounded bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`h-1 w-20 rounded bg-[var(--bg-tertiary)]`})]}),(0,H.jsx)(`div`,{className:`h-4 w-16 rounded bg-[var(--bg-tertiary)]`,style:{width:`100px`}}),(0,H.jsx)(`div`,{className:`h-5 w-12 rounded bg-[var(--bg-tertiary)]`})]},t))]})}var nO=`workrail:auto:mru-workflow`;function rO(){try{return localStorage.getItem(nO)}catch{return null}}function iO(e){try{localStorage.setItem(nO,e)}catch{}}function aO(){let e=Ky(),t=Yy(),n=e.data?.workflows??[],r=t.data?.triggers??[],[i,a]=(0,V.useState)(()=>rO()??``),[o,s]=(0,V.useState)(``),[c,l]=(0,V.useState)(``),[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)(null),[m,h]=(0,V.useState)(!1),[g,_]=(0,V.useState)(!0),v=(0,V.useRef)(null);(0,V.useEffect)(()=>{!i&&n.length>0&&a(n[0]?.id??``)},[i,n]);let y=e=>{a(e),iO(e)},b=async()=>{if(!(!i||!c.trim()||!o.trim())){d(!0),p(null),h(!1);try{await Xy({workflowId:i,goal:c.trim(),workspacePath:o.trim()}),h(!0),l(``),setTimeout(()=>v.current?.focus(),100)}catch(e){p(e instanceof Error?e.message:`Dispatch failed`)}finally{d(!1)}}},x=!!i&&!!c.trim()&&!!o.trim()&&!u;return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,H.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,H.jsx)(Uo,{color:`var(--accent)`,children:`Dispatch`})}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(Uo,{children:`Workflow`}),e.isLoading?(0,H.jsx)(`div`,{className:`text-[var(--text-muted)] text-xs`,children:`Loading workflows...`}):n.length===0?(0,H.jsx)(`div`,{className:`text-[var(--text-muted)] text-xs`,children:`No workflows available`}):(0,H.jsx)(`select`,{value:i,onChange:e=>y(e.target.value),className:`w-full bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent)] cursor-pointer`,children:n.map(e=>(0,H.jsx)(`option`,{value:e.id,children:e.name??e.id},e.id))})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(Uo,{children:`Workspace path`}),(0,H.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:`/path/to/repo`,className:`w-full bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm font-mono text-[var(--text-primary)] placeholder-[var(--text-muted)] focus:outline-none focus:border-[var(--accent)]`})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(Uo,{children:`Goal`}),(0,H.jsx)(`textarea`,{ref:v,value:c,onChange:e=>l(e.target.value),placeholder:`// describe the task...`,rows:4,className:`w-full bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm font-mono text-[var(--text-primary)] placeholder-[var(--text-muted)] focus:outline-none focus:border-[var(--accent)] resize-y`,onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&e.key===`Enter`&&x&&(e.preventDefault(),b())}})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(`button`,{onClick:()=>void b(),disabled:!x,className:`self-start disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer`,children:(0,H.jsx)($a,{label:u?`RUNNING...`:`RUN`,color:x?`var(--accent)`:void 0,pulse:u})}),m&&(0,H.jsx)(`div`,{className:`text-[var(--success)] font-mono text-[10px] uppercase tracking-[0.20em]`,children:`Dispatched -- check Queue pane`}),f&&(0,H.jsx)(`div`,{className:`text-[var(--error)] text-xs font-mono`,children:f})]}),(0,H.jsxs)(`div`,{className:`border-t border-[var(--border)] pt-4`,children:[(0,H.jsxs)(`button`,{onClick:()=>_(!g),className:`flex items-center gap-2 mb-2 cursor-pointer group`,children:[(0,H.jsx)(`span`,{className:`text-[var(--text-muted)] text-xs transition-transform duration-150`,style:{transform:g?`rotate(-90deg)`:`rotate(0deg)`},children:`▼`}),(0,H.jsx)($a,{label:`TRIGGERS`,color:`var(--text-secondary)`}),r.length>0&&(0,H.jsxs)(`span`,{className:`text-xs text-[var(--text-muted)]`,children:[`(`,r.length,`)`]})]}),!g&&(0,H.jsx)(`div`,{className:`space-y-2`,children:t.isLoading?(0,H.jsx)(`div`,{className:`text-[var(--text-muted)] text-xs pl-4`,children:`Loading triggers...`}):r.length===0?(0,H.jsx)(`div`,{className:`text-[var(--text-muted)] text-xs pl-4`,children:`No triggers configured. Set WORKRAIL_TRIGGERS_ENABLED=true and create triggers.yml.`}):r.map(e=>(0,H.jsxs)(`div`,{className:`pl-4 border-l-2 border-[var(--border)] text-xs space-y-0.5`,children:[(0,H.jsx)(`div`,{className:`font-mono text-[var(--text-primary)] text-[11px]`,children:e.id}),(0,H.jsx)(`div`,{className:`text-[var(--text-muted)]`,children:e.workflowId}),(0,H.jsx)(`div`,{className:`text-[var(--text-muted)] truncate`,children:e.goal})]},e.id))})]})]})}function oO(e){let t=0,n=0,r=0;for(let i of e)i.status===`in_progress`?t++:i.status===`blocked`?n++:(i.status===`complete`||i.status===`complete_with_gaps`)&&r++;return{running:t,blocked:n,completed:r}}function sO(){let{data:e,isLoading:t,isError:n}=Hy(),r=(e?.sessions??[]).filter(e=>e.isAutonomous),{running:i,blocked:a,completed:o}=oO(r);return t?(0,H.jsx)(`div`,{className:`flex items-center justify-center py-20`,children:(0,H.jsx)(`div`,{className:`text-[var(--text-secondary)] text-sm`,children:`Loading sessions...`})}):n?(0,H.jsx)(`div`,{className:`text-[var(--error)] bg-[var(--bg-card)] rounded-lg p-4 text-sm`,children:`Failed to load sessions`}):(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,H.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,H.jsx)(Uo,{color:`var(--accent)`,children:`Queue`})}),(0,H.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,H.jsx)(cO,{count:i,label:`RUNNING`,color:`var(--accent)`,pulse:!0}),(0,H.jsx)(cO,{count:a,label:`BLOCKED`,color:`var(--blocked)`}),(0,H.jsx)(cO,{count:o,label:`COMPLETED`,color:`var(--success)`})]}),r.length===0?(0,H.jsxs)(`div`,{className:`text-center py-16`,children:[(0,H.jsx)(`p`,{className:`text-[var(--text-secondary)] text-sm`,children:`No autonomous sessions yet`}),(0,H.jsx)(`p`,{className:`text-[var(--text-muted)] text-xs mt-1`,children:`Dispatch a workflow from the left pane to start.`})]}):(0,H.jsx)(`div`,{className:`space-y-2`,children:r.map(e=>(0,H.jsx)(lO,{session:e},e.sessionId))})]})}function cO({count:e,label:t,color:n,pulse:r}){return(0,H.jsx)($a,{label:`${e} ${t}`,color:e>0?n:`var(--text-muted)`,pulse:r&&e>0})}function lO({session:e}){let[t,n]=(0,V.useState)(!1),r=xi(),i=e.sessionTitle??e.workflowName??e.workflowId??`Unnamed session`,a=W(e.lastModifiedMs);return(0,H.jsxs)(`div`,{className:`bg-[var(--bg-card)] border border-[var(--border)] rounded-lg overflow-hidden`,children:[(0,H.jsxs)(`button`,{onClick:()=>n(!t),className:`w-full px-4 py-3 flex items-center gap-3 text-left cursor-pointer hover:bg-[var(--bg-secondary)] transition-colors group`,children:[(0,H.jsx)(`span`,{className:`text-[var(--text-muted)] text-xs transition-transform duration-150 shrink-0`,style:{transform:t?`rotate(90deg)`:`rotate(0deg)`},children:`▶`}),(0,H.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-[var(--text-primary)] truncate group-hover:text-[var(--accent)] transition-colors`,children:i}),(0,H.jsx)(`div`,{className:`font-mono text-[10px] text-[var(--text-muted)] opacity-60 truncate`,children:e.sessionId})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,H.jsx)(`span`,{className:`text-[10px] text-[var(--text-muted)] tabular-nums`,children:a}),e.isLive&&(0,H.jsx)($a,{label:`LIVE`,pulse:!0,color:`var(--accent)`,"aria-label":`Actively running`}),(0,H.jsx)(to,{status:e.status})]})]}),t&&(0,H.jsxs)(`div`,{className:`px-4 pb-4 border-t border-[var(--border)] pt-3 space-y-3`,children:[e.recapSnippet?(0,H.jsx)(`div`,{className:`text-xs text-[var(--text-secondary)] font-mono whitespace-pre-wrap leading-relaxed`,children:e.recapSnippet}):(0,H.jsx)(`div`,{className:`text-xs text-[var(--text-muted)]`,children:`No recap available yet.`}),(0,H.jsx)(`button`,{onClick:()=>void r({to:`/session/$sessionId`,params:{sessionId:e.sessionId}}),className:`cursor-pointer`,children:(0,H.jsx)($a,{label:`OPEN IN DAG`,color:`var(--accent)`})})]})]})}function uO(){return(0,H.jsxs)(`div`,{className:`flex flex-col md:flex-row gap-6`,children:[(0,H.jsx)(`div`,{className:`w-full md:w-2/5 shrink-0`,children:(0,H.jsx)(aO,{})}),(0,H.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,H.jsx)(sO,{})})]})}function dO(){let e=Hy(),t=Gy();Zy();let n=e.data?.sessions;return{sessions:n,worktreeRepos:t.data?.repos??[],isLoading:e.isLoading,error:e.error instanceof Error?e.error:null,refetch:e.refetch,worktreesFetching:t.isFetching,liveCount:n?.filter(e=>e.status===`in_progress`).length??0,blockedCount:n?.filter(e=>e.status===`blocked`).length??0}}var fO={scope:`active`,focusedIndex:-1,archive:null};function pO(e){throw Error(`Unhandled WorkspaceEvent type: ${String(e.type)}`)}function mO(e,t){switch(t.type){case`scope_changed`:return{...e,scope:t.scope,focusedIndex:-1};case`focus_moved`:return{...e,focusedIndex:t.index};case`archive_opened`:return{...e,archive:{repoName:t.repoName}};case`archive_closed`:return{...e,archive:null};default:return pO(t)}}var hO=720*60*60*1e3,gO={in_progress:0,dormant:0,blocked:1,complete_with_gaps:2,complete:3};function _O(e){if(e.length!==0)return[...e].sort((e,t)=>{let n=gO[e.status]-gO[t.status];return n===0?t.lastModifiedMs-e.lastModifiedMs:n})[0]}function vO(e,t,n){let r=e.primarySession?.status;if(r===`in_progress`||r===`blocked`)return`visible`;let i=(e.worktree?.changedCount??0)>0,a=(e.worktree?.aheadCount??0)>0;return i||a?`visible`:r===`dormant`?t===`all`?`visible`:`hidden`:n-e.activityMs<hO||t===`all`?`visible`:`hidden`}function yO(e){switch(e.primarySession?.status){case`in_progress`:return 0;case`blocked`:return 1;case`dormant`:return 2;default:return(e.worktree?.changedCount??0)>0||(e.worktree?.aheadCount??0)>0?3:4}}function bO(e,t,n){return[...e].filter(e=>vO(e,t,n)===`visible`).sort((e,t)=>{let n=yO(e)-yO(t);return n===0?t.activityMs-e.activityMs:n})}function xO(e,t){let n=new Map;for(let e of t)for(let t of e.worktrees)t.branch!==null&&n.set(`${t.branch}\0${e.repoRoot}`,{wt:t,repoName:e.repoName,repoRoot:e.repoRoot});let r=new Map;for(let[e,t]of n){let[n]=e.split(`\0`),i=r.get(n)??[];i.push(t),r.set(n,i)}let i=new Map;for(let t of e){if(t.gitBranch===null)continue;let e=r.get(t.gitBranch)??[];if(e.length===0){if(!t.repoRoot)continue;let e=`${t.gitBranch}\0${t.repoRoot}`,r=i.get(e);if(r?r.push(t):i.set(e,[t]),!n.has(e)){let r=t.repoRoot.split(`/`).at(-1)??t.repoRoot;n.set(e,{wt:void 0,repoName:r,repoRoot:t.repoRoot})}continue}let a=e;if(t.repoRoot!==null){let n=e.filter(e=>e.repoRoot===t.repoRoot);n.length>0&&(a=n)}for(let e of a){let n=`${t.gitBranch}\0${e.repoRoot}`,r=i.get(n);r?r.push(t):i.set(n,[t])}}let a=[],o=new Set;for(let[e,t]of i){let[r,i]=e.split(`\0`),s=n.get(e),c=_O(t),l=Math.max(c?.lastModifiedMs??0,s?.wt?.headTimestampMs??0),u=s?.repoName??i.split(`/`).at(-1)??i;a.push({branch:r,repoRoot:i,repoName:u,worktree:s?.wt,primarySession:c,allSessions:t,activityMs:l}),o.add(e)}for(let[e,{wt:t,repoName:r,repoRoot:i}]of n){if(o.has(e))continue;let[n]=e.split(`\0`);a.push({branch:n,repoRoot:i,repoName:r,worktree:t,primarySession:void 0,allSessions:[],activityMs:t?.headTimestampMs??0})}return a}function SO(e,t,n,r){let i=xO(e,t),a=new Map;for(let e of i)a.has(e.repoRoot)||a.set(e.repoRoot,e.repoName);let o=new Map;for(let e of i){let t=o.get(e.repoRoot)??[];t.push(e),o.set(e.repoRoot,t)}let s=[...o.entries()].map(([e,t])=>({repoRoot:e,repoName:t[0].repoName,sortedItems:bO(t,n,r)})).filter(e=>e.sortedItems.length>0).sort((e,t)=>{let n=+!e.sortedItems.some(e=>e.primarySession?.status===`in_progress`||e.primarySession?.status===`blocked`),r=+!t.sortedItems.some(e=>e.primarySession?.status===`in_progress`||e.primarySession?.status===`blocked`);return n===r?e.repoName.localeCompare(t.repoName):n-r}),c=s.flatMap(e=>e.sortedItems),l=n===`active`?i.filter(e=>e.primarySession?.status===`dormant`&&(e.worktree?.changedCount??0)===0&&(e.worktree?.aheadCount??0)===0).length:0;return{repoGroups:s,orderedItems:c,archiveRepos:[...a.entries()].map(([e,t])=>[e,t]),dormantHiddenCount:l}}function CO({items:e,focusedIndex:t,scope:n,archive:r,dispatch:i,onSelectSession:a,onRefetch:o,disabled:s}){let c=(0,V.useRef)(e);c.current=e;let l=(0,V.useRef)(t);l.current=t;let u=(0,V.useRef)(n);u.current=n;let d=(0,V.useRef)(r);d.current=r;let f=(0,V.useRef)(s);f.current=s;let p=(0,V.useRef)(i);p.current=i;let m=(0,V.useRef)(a);m.current=a;let h=(0,V.useRef)(o);h.current=o,(0,V.useEffect)(()=>{function e(e){if(f.current||e.metaKey||e.ctrlKey||e.altKey)return;let t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)return;let n=c.current,r=l.current;switch(e.key){case`j`:case`ArrowDown`:e.preventDefault(),p.current({type:`focus_moved`,index:Math.min(r+1,n.length-1)});break;case`k`:case`ArrowUp`:e.preventDefault(),p.current({type:`focus_moved`,index:Math.max(r-1,0)});break;case`Enter`:case` `:if(e.preventDefault(),r>=0&&r<n.length){let e=n[r]?.primarySession?.sessionId;e&&m.current(e)}break;case`Escape`:d.current!==null&&p.current({type:`archive_closed`});break;case`/`:e.preventDefault(),p.current({type:`archive_opened`,repoName:void 0});break;case`r`:e.preventDefault(),h.current();break;case`a`:e.preventDefault(),p.current({type:`scope_changed`,scope:u.current===`active`?`all`:`active`});break}}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[])}function wO(e=!1){let t=xi(),n=dO(),[r,i]=(0,V.useReducer)(mO,fO),a=(0,V.useRef)(0),o=(0,V.useCallback)(e=>{a.current=window.scrollY,t({to:`/session/$sessionId`,params:{sessionId:e}})},[t]),s=i,c=(0,V.useMemo)(()=>n.sessions?SO(n.sessions,n.worktreeRepos,r.scope,Date.now()):null,[n.sessions,n.worktreeRepos,r.scope]);CO({items:c?.orderedItems??[],focusedIndex:r.focusedIndex,scope:r.scope,archive:r.archive,dispatch:s,onSelectSession:o,onRefetch:n.refetch,disabled:e});let{isLoading:l,error:u,worktreesFetching:d,sessions:f,liveCount:p,blockedCount:m}=n;return{state:(0,V.useMemo)(()=>l?{kind:`loading`}:u?{kind:`error`,message:u.message}:c?{kind:`ready`,scope:r.scope,focusedIndex:r.focusedIndex,archive:r.archive,repoGroups:c.repoGroups,orderedItems:c.orderedItems,archiveRepos:c.archiveRepos,dormantHiddenCount:c.dormantHiddenCount,worktreesFetching:d,hasAnySessions:(f?.length??0)>0,liveCount:p,blockedCount:m}:{kind:`loading`},[l,u,d,f,c,r,p,m]),dispatch:s,scrollYRef:a,onSelectSession:o}}function TO(){let e=Hy();return{sessions:e.data?.sessions,isLoading:e.isLoading,error:e.error instanceof Error?e.error:null}}function EO(e=``){return{rawSearch:e,sort:`recent`,groupBy:`none`,statusFilter:`all`,page:0,viewMode:`flat`}}function DO(e){throw Error(`Unhandled SessionListEvent type: ${String(e.type)}`)}function OO(e,t){switch(t.type){case`search_changed`:return{...e,rawSearch:t.value,page:0};case`sort_changed`:return{...e,sort:t.sort,page:0};case`group_changed`:return{...e,groupBy:t.groupBy,page:0};case`status_changed`:return{...e,statusFilter:t.statusFilter,page:0};case`page_changed`:return{...e,page:t.page};case`view_mode_changed`:return t.viewMode===`tree`?{...e,viewMode:`tree`,rawSearch:``,statusFilter:`all`,page:0}:{...e,viewMode:`flat`,page:0};default:return DO(t)}}var kO={in_progress:0,blocked:1,dormant:2,complete_with_gaps:3,complete:4},AO=[{value:`recent`,label:`Recent`,compareFn:(e,t)=>t.lastModifiedMs-e.lastModifiedMs},{value:`status`,label:`Status`,compareFn:(e,t)=>kO[e.status]-kO[t.status]||t.lastModifiedMs-e.lastModifiedMs},{value:`workflow`,label:`Workflow`,compareFn:(e,t)=>(e.workflowName??e.workflowId??``).localeCompare(t.workflowName??t.workflowId??``)||t.lastModifiedMs-e.lastModifiedMs},{value:`nodes`,label:`Node count`,compareFn:(e,t)=>t.nodeCount-e.nodeCount||t.lastModifiedMs-e.lastModifiedMs}],jO=[{value:`none`,label:`No grouping`,keyFn:null},{value:`workflow`,label:`Workflow`,keyFn:e=>e.workflowName??e.workflowId??`Unknown workflow`},{value:`status`,label:`Status`,keyFn:e=>e.status,groupCompareFn:(e,t)=>(kO[e]??99)-(kO[t]??99)},{value:`branch`,label:`Branch`,keyFn:e=>e.gitBranch??`No branch`}],MO=[{value:`all`,label:`All`},{value:`in_progress`,label:`In Progress`},{value:`dormant`,label:`Dormant`},{value:`complete`,label:`Complete`},{value:`complete_with_gaps`,label:`Gaps`},{value:`blocked`,label:`Blocked`}];function NO(e,t,n){let r=e;if(n!==`all`&&(r=r.filter(e=>e.status===n)),t.trim()){let e=t.toLowerCase();r=r.filter(t=>(t.sessionTitle??``).toLowerCase().includes(e)||(t.workflowName??``).toLowerCase().includes(e)||(t.workflowId??``).toLowerCase().includes(e)||t.sessionId.toLowerCase().includes(e)||(t.gitBranch??``).toLowerCase().includes(e))}return r}function PO(e,t){let n=AO.find(e=>e.value===t)??AO[0];return[...e].sort(n.compareFn)}function FO(e,t){let n=jO.find(e=>e.value===t)??jO[0];if(!n.keyFn)return[{label:``,sessions:e}];let r=new Map;for(let t of e){let e=n.keyFn(t),i=r.get(e)??[];i.push(t),r.set(e,i)}let i=n.groupCompareFn??((e,t)=>e.localeCompare(t));return Array.from(r.entries()).sort(([e],[t])=>i(e,t)).map(([e,t])=>({label:e,sessions:t}))}function IO(e){let t={all:e.length};for(let n of e)t[n.status]=(t[n.status]??0)+1;return t}function LO(e){let t=new Set(e.map(e=>e.sessionId)),n=new Map,r=new Set,i=new Set;for(let a of e){let e=a.parentSessionId;if(!e||e===a.sessionId)continue;if(!t.has(e)){r.add(a.sessionId);continue}i.add(a.sessionId);let o=n.get(e)??[];o.push(a),n.set(e,o)}let a=[];for(let t of e)i.has(t.sessionId)||a.push({session:t,children:n.get(t.sessionId)??[]});return{roots:a,orphanChildIds:r}}function RO(e,t){let[n,r]=(0,V.useState)(e),i=(0,V.useRef)(null);return(0,V.useEffect)(()=>(i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>r(e),t),()=>{i.current!==null&&clearTimeout(i.current)}),[e,t]),n}function zO({onSelectSession:e,initialSearch:t=``}){let n=TO(),[r,i]=(0,V.useReducer)(OO,void 0,()=>EO(t)),a=RO(r.rawSearch,200),o=(0,V.useRef)([]),s=(0,V.useCallback)(t=>{let n=o.current[t];n&&e(n.sessionId)},[e]),{sessions:c,isLoading:l,error:u}=n,d=(0,V.useMemo)(()=>c?IO(c):{},[c]),f=(0,V.useMemo)(()=>{if(!c)return null;let e=NO(c,a,r.statusFilter);return{groups:FO(PO(e,r.sort),r.groupBy),total:c.length,filtered:e.length}},[c,a,r.statusFilter,r.sort,r.groupBy]),p=(0,V.useMemo)(()=>LO(c||[]),[c]),m=r.groupBy!==`none`,h=f?Math.ceil(f.filtered/25):0,g=r.page*25,_=g+25,v=(0,V.useMemo)(()=>!f||m?[]:f.groups[0]?.sessions.slice(g,_)??[],[f,m,g,_]);o.current=v;let{getItemProps:y,containerProps:b}=kD({count:v.length,cols:1,onActivate:s});return{state:(0,V.useMemo)(()=>l?{kind:`loading`}:u?{kind:`error`,message:u.message}:f?{kind:`ready`,rawSearch:r.rawSearch,sort:r.sort,groupBy:r.groupBy,statusFilter:r.statusFilter,page:r.page,totalPages:h,isGrouped:m,processed:f,statusCounts:d,flatPageSessions:v,getSessionNavProps:y,sessionContainerProps:b,sortAxes:AO,groupAxes:jO,statusFilterOptions:MO,viewMode:r.viewMode,sessionTree:p}:{kind:`loading`},[l,u,f,r,h,m,d,v,y,b,p]),dispatch:i,onSelectSession:e}}var BO={selectedWorkflowId:null,selectedTag:null,selectedSource:null,hintVisible:!1};function VO(e){throw Error(`Unhandled WorkflowsEvent type: ${String(e.type)}`)}function HO(e,t){switch(t.type){case`workflow_selected`:return{...e,selectedWorkflowId:t.id,hintVisible:t.id!==null};case`tag_changed`:return{...e,selectedTag:t.tag,selectedWorkflowId:null,hintVisible:!1};case`source_changed`:return{...e,selectedSource:t.source,selectedWorkflowId:null,hintVisible:!1};case`modal_closed`:return{...e,selectedWorkflowId:null,hintVisible:!1};case`hint_dismissed`:return{...e,hintVisible:!1};default:return VO(t)}}function UO(e){let t=new Set;for(let n of e)for(let e of n.tags)e!==`routines`&&t.add(e);let n=hD.map(e=>e.id).filter(e=>t.has(e)),r=[...t].filter(e=>!hD.some(t=>t.id===e)).sort();return[...n,...r]}function WO(e){let t=new Map;for(let n of e)t.has(n.source.kind)||t.set(n.source.kind,{id:n.source.kind,displayName:n.source.displayName});return[...t.values()]}function GO(e,t,n){let r=new Set(hD.map(e=>e.id)),i=e;return t!==null&&(i=t===`__other__`?i.filter(e=>!e.tags.some(e=>e!==`routines`&&r.has(e))):i.filter(e=>e.tags.includes(t))),n!==null&&(i=i.filter(e=>e.source.displayName===n)),i}function KO(e,t){if(t!==null)return e;let n=new Set(hD.map(e=>e.id)),r=new Map,i=[];for(let t of e){let e=t.tags.find(e=>e!==`routines`&&n.has(e));if(e){let n=r.get(e)??[];n.push(t),r.set(e,n)}else i.push(t)}let a=[];for(let{id:e}of hD){let t=r.get(e);t&&a.push(...t)}return a.push(...i),a}function qO({initialTag:e,onSelectTag:t}){let n=jD(),[r,i]=(0,V.useReducer)(HO,{...BO,selectedTag:e});(0,V.useEffect)(()=>{e!==r.selectedTag&&i({type:`tag_changed`,tag:e})},[e]);let a=(0,V.useRef)(null),o=(0,V.useCallback)((e,t)=>{a.current=t,t.blur(),i({type:`workflow_selected`,id:e})},[]);(0,V.useEffect)(()=>{if(!r.selectedWorkflowId&&a.current){let e=a.current;a.current=null,e.focus()}},[r.selectedWorkflowId]),(0,V.useEffect)(()=>{if(!r.selectedWorkflowId)return;let e=window.scrollY;return document.body.style.overflow=`hidden`,document.body.style.position=`fixed`,document.body.style.top=`-${e}px`,document.body.style.width=`100%`,()=>{document.body.style.overflow=``,document.body.style.position=``,document.body.style.top=``,document.body.style.width=``,window.scrollTo(0,e)}},[r.selectedWorkflowId]),(0,V.useEffect)(()=>{if(!r.selectedWorkflowId)return;let e=e=>{e.key===`Escape`&&i({type:`modal_closed`})};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r.selectedWorkflowId]);let{isLoading:s,error:c,workflows:l}=n,u=(0,V.useMemo)(()=>{if(s)return{kind:`loading`};if(c)return{kind:`error`,message:c.message,onRetry:n.refetch};if(!l)return{kind:`loading`};let e=UO(l),t=WO(l),i=GO(l,r.selectedTag,r.selectedSource),a=KO(i,r.selectedTag),o=GO(l,null,r.selectedSource),u=GO(l,r.selectedTag,null);return{kind:`ready`,selectedWorkflowId:r.selectedWorkflowId,selectedTag:r.selectedTag,selectedSource:r.selectedSource,hintVisible:r.hintVisible,availableTags:e,availableSources:t,filteredWorkflows:i,flatWorkflows:a,sourceFilteredWorkflows:o,tagFilteredWorkflows:u}},[s,c,l,r,n.refetch]),d=u.kind===`ready`?u.flatWorkflows.length:0;return(0,V.useEffect)(()=>{if(!r.selectedWorkflowId||d<=1)return;let e=setTimeout(()=>i({type:`hint_dismissed`}),3e3);return()=>clearTimeout(e)},[r.selectedWorkflowId,d]),{state:u,dispatch:(0,V.useCallback)(e=>{e.type===`tag_changed`&&t(e.tag),i(e)},[t]),triggerRef:a,onCardSelect:o}}function JO(){let e=qy();switch(e.state){case`loading`:return{kind:`loading`};case`devModeOff`:return{kind:`devModeOff`};case`error`:return{kind:`error`,message:e.message,retry:e.retry};case`data`:return{kind:`ready`,observations:e.data.observations}}}function YO(){let e=JO(),[t,n]=(0,V.useState)(`recent`);return{state:(0,V.useMemo)(()=>{if(e.kind===`loading`)return{kind:`loading`};if(e.kind===`devModeOff`)return{kind:`devModeOff`};if(e.kind===`error`)return{kind:`error`,message:e.message,retry:e.retry};let{observations:r}=e,i=UD(r,t);return{kind:`ready`,sorted:i,maxDuration:WD(i),errorCount:GD(r),avgMs:KD(r),lastCallMs:qD(r),countLabel:YD(r.length),sortOrder:t,onSortChange:n}},[e,t])}}function XO(e){let t=Uy(e);return{data:t.data,isLoading:t.isLoading,error:t.error instanceof Error?t.error:null}}function ZO(e){let t=XO(e),[n,r]=(0,V.useState)(null),i=(0,V.useCallback)((e,t)=>{r(n=>n?.runId===e&&n?.nodeId===t?null:{runId:e,nodeId:t})},[]),a=(0,V.useCallback)(()=>{r(null)},[]),{isLoading:o,error:s,data:c}=t,l=(0,V.useMemo)(()=>!c||!n?null:c.runs.find(e=>e.runId===n.runId)??null,[c,n]);return{state:(0,V.useMemo)(()=>o?{kind:`loading`}:s?{kind:`error`,message:s.message}:c?{kind:`ready`,sessionId:e,data:c,selectedNode:n,selectedRun:l}:{kind:`loading`},[o,s,c,e,n,l]),onSelectNode:i,onCloseNode:a}}var QO=[{id:`workspace`,path:`/`},{id:`workflows`,path:`/workflows`},{id:`auto`,path:`/auto`},{id:`perf`,path:`/perf`}];function $O(){let e=xi(),t=Qi(),{location:n}=ia(),r=t({to:`/session/$sessionId`}),i=t({to:`/workflows`}),a=t({to:`/workflows/$workflowId`}),o=t({to:`/perf`}),s=t({to:`/auto`}),c=i!==!1||a!==!1?`workflows`:o===!1?s===!1?`workspace`:`auto`:`perf`,l=r!==!1,u=a!==!1,d=l?r.sessionId:null,f=u?a.workflowId:null,p=new URLSearchParams(n.search).get(`tag`),m=wO(l),h=zO({onSelectSession:m.onSelectSession}),g=m.state.kind===`ready`?m.state.liveCount:0,_=m.state.kind===`ready`?m.state.blockedCount:0,v=(0,V.useCallback)(()=>{e({to:`/`})},[e]),y=(0,V.useCallback)(t=>{e({to:`/workflows`,search:{tag:t??void 0}})},[e]),b=(0,V.useCallback)(()=>{e({to:`/workflows`,search:{tag:p??void 0}})},[e,p]),x=(0,V.useCallback)(t=>{e({to:`/workflows/$workflowId`,params:{workflowId:t},search:{tag:p??void 0}})},[e,p]),S=qO({initialTag:p,onSelectTag:y}),C=ND({workflowId:f,activeTag:p,onBack:b,onNavigateToWorkflow:x}),w=ZO(d??``),T=YO(),[E,D]=(0,V.useState)(null),O=(0,V.useCallback)((e,t)=>{t(),D(e),setTimeout(()=>D(null),200)},[]),k=(0,V.useRef)(null);return(0,V.useEffect)(()=>{let t=k.current;if(!t)return;function n(t){if(t.key===`ArrowLeft`||t.key===`ArrowRight`){t.preventDefault();let n=QO.findIndex(e=>e.id===c),r=QO[t.key===`ArrowRight`?(n+1)%QO.length:(n-1+QO.length)%QO.length];e({to:r.path,...r.path===`/workflows`?{search:{tag:void 0}}:{}})}}return t.addEventListener(`keydown`,n),()=>t.removeEventListener(`keydown`,n)},[c,e]),(0,H.jsxs)(`div`,{className:`min-h-screen`,style:{"--app-header-height":`56px`},children:[(0,H.jsxs)(`header`,{style:{background:`rgba(23, 27, 40, 0.92)`,backdropFilter:`blur(24px)`,WebkitBackdropFilter:`blur(24px)`,borderBottom:`1px solid rgba(244, 196, 48, 0.25)`,boxShadow:`0 4px 24px rgba(0,0,0,0.4)`},className:`fixed top-0 w-full z-50 flex items-center h-14 px-4 gap-6`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,H.jsx)(oo,{cut:8,borderColor:`rgba(244, 196, 48, 0.5)`,background:`rgba(27, 31, 44, 0.8)`,className:`relative w-10 h-10`,children:(0,H.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,H.jsx)(`span`,{className:`font-mono text-[11px] font-bold text-[var(--accent)] tracking-widest`,children:`WR`})})}),(0,H.jsxs)(`div`,{className:`hidden sm:flex flex-col leading-none`,children:[(0,H.jsx)(`span`,{className:`font-mono text-[11px] font-bold text-[var(--text-primary)] tracking-[0.25em] uppercase`,children:`WR_CONSOLE`}),(0,H.jsxs)(`span`,{className:`font-mono text-[9px] text-[var(--text-muted)] tracking-[0.15em]`,children:[`// V`,`3.59.4`]})]})]}),l&&d?(0,H.jsx)(`nav`,{className:`flex items-center flex-1 justify-center`,children:(0,H.jsx)(vD,{segments:[{label:`Workspace`,onClick:v},{label:d?.slice(-12)??``}]})}):(0,H.jsxs)(`div`,{role:`tablist`,"aria-label":`Console sections`,ref:k,className:`flex items-center gap-1 flex-1 justify-center`,children:[(0,H.jsxs)(`button`,{role:`tab`,id:`tab-workspace`,"aria-selected":c===`workspace`,"aria-controls":`panel-workspace`,tabIndex:c===`workspace`?0:-1,onClick:()=>O(`workspace`,()=>void e({to:`/`})),className:[`tab-btn px-4 py-2.5 font-mono text-[10px] uppercase tracking-[0.30em] transition-colors duration-150`,`focus-visible:ring-2 focus-visible:ring-[var(--accent)] focus-visible:ring-offset-1 focus-visible:outline-none`,c===`workspace`?`tab-btn--active text-[var(--accent)] text-glow-amber`:`text-[var(--text-secondary)] hover:text-[var(--text-primary)]`,E===`workspace`?`tab-activating`:``].join(` `),style:c===`workspace`?{backgroundColor:`rgba(244, 196, 48, 0.06)`}:void 0,children:[(0,H.jsx)(`span`,{className:`tab-corner tab-corner--tl`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--tr`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--bl`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--br`,"aria-hidden":`true`}),`Workspace`]}),(0,H.jsxs)(`button`,{role:`tab`,id:`tab-workflows`,"aria-selected":c===`workflows`,"aria-controls":`panel-workflows`,tabIndex:c===`workflows`?0:-1,onClick:()=>O(`workflows`,()=>void e({to:`/workflows`,search:{tag:void 0}})),className:[`tab-btn px-4 py-2.5 font-mono text-[10px] uppercase tracking-[0.30em] transition-colors duration-150`,`focus-visible:ring-2 focus-visible:ring-[var(--accent)] focus-visible:ring-offset-1 focus-visible:outline-none`,c===`workflows`?`tab-btn--active text-[var(--accent)] text-glow-amber`:`text-[var(--text-secondary)] hover:text-[var(--text-primary)]`,E===`workflows`?`tab-activating`:``].join(` `),style:c===`workflows`?{backgroundColor:`rgba(244, 196, 48, 0.06)`}:void 0,children:[(0,H.jsx)(`span`,{className:`tab-corner tab-corner--tl`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--tr`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--bl`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--br`,"aria-hidden":`true`}),`Workflows`]}),(0,H.jsxs)(`button`,{role:`tab`,id:`tab-auto`,"aria-selected":c===`auto`,"aria-controls":`panel-auto`,tabIndex:c===`auto`?0:-1,onClick:()=>O(`auto`,()=>void e({to:`/auto`})),className:[`tab-btn px-4 py-2.5 font-mono text-[10px] uppercase tracking-[0.30em] transition-colors duration-150`,`focus-visible:ring-2 focus-visible:ring-[var(--accent)] focus-visible:ring-offset-1 focus-visible:outline-none`,c===`auto`?`tab-btn--active text-[var(--accent)] text-glow-amber`:`text-[var(--text-secondary)] hover:text-[var(--text-primary)]`,E===`auto`?`tab-activating`:``].join(` `),style:c===`auto`?{backgroundColor:`rgba(244, 196, 48, 0.06)`}:void 0,children:[(0,H.jsx)(`span`,{className:`tab-corner tab-corner--tl`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--tr`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--bl`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--br`,"aria-hidden":`true`}),`Auto`]}),(0,H.jsxs)(`button`,{role:`tab`,id:`tab-perf`,"aria-selected":c===`perf`,"aria-controls":`panel-perf`,tabIndex:c===`perf`?0:-1,onClick:()=>O(`perf`,()=>void e({to:`/perf`})),className:[`tab-btn px-4 py-2.5 font-mono text-[10px] uppercase tracking-[0.30em] transition-colors duration-150`,`focus-visible:ring-2 focus-visible:ring-[var(--accent)] focus-visible:ring-offset-1 focus-visible:outline-none`,c===`perf`?`tab-btn--active text-[var(--accent)] text-glow-amber`:`text-[var(--text-secondary)] hover:text-[var(--text-primary)]`,E===`perf`?`tab-activating`:``].join(` `),style:c===`perf`?{backgroundColor:`rgba(244, 196, 48, 0.06)`}:void 0,children:[(0,H.jsx)(`span`,{className:`tab-corner tab-corner--tl`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--tr`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--bl`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--br`,"aria-hidden":`true`}),`Performance`]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[g>0&&(0,H.jsx)($a,{label:`${Math.min(g,9)}${g>9?`+`:``} LIVE`,color:`var(--accent-strong)`,pulse:!0,role:`status`,"aria-label":`${g} live session${g===1?``:`s`}`}),_>0&&(0,H.jsx)($a,{label:`${Math.min(_,9)}${_>9?`+`:``} BLOCKED`,color:`var(--blocked)`,role:`status`,"aria-label":`${_} blocked session${_===1?``:`s`}`})]})]}),(0,H.jsxs)(`main`,{className:`p-6`,style:{paddingTop:`calc(56px + 1.5rem)`},children:[(0,H.jsxs)(`div`,{id:`panel-workspace`,role:`tabpanel`,"aria-labelledby":`tab-workspace`,hidden:c===`workflows`||c===`perf`||c===`auto`,children:[(0,H.jsx)(wo,{viewModel:m,sessionListViewModel:h,hidden:l}),l&&d&&(0,H.jsx)(fD,{viewModel:w})]}),c===`workflows`&&(0,H.jsx)(`div`,{id:`panel-workflows`,role:`tabpanel`,"aria-labelledby":`tab-workflows`,children:u&&f?(0,H.jsx)(yD,{viewModel:C}):(0,H.jsx)(FD,{viewModel:S})}),c===`auto`&&(0,H.jsx)(`div`,{id:`panel-auto`,role:`tabpanel`,"aria-labelledby":`tab-auto`,children:(0,H.jsx)(uO,{})}),c===`perf`&&(0,H.jsx)(`div`,{id:`panel-perf`,role:`tabpanel`,"aria-labelledby":`tab-perf`,children:(0,H.jsx)(ZD,{viewModel:T})})]})]})}var ek=zi({component:$O}),tk=Li({getParentRoute:()=>ek,path:`/`,component:()=>null}),nk=Li({getParentRoute:()=>ek,path:`/session/$sessionId`,component:()=>null}),rk=Li({getParentRoute:()=>ek,path:`/workflows`,validateSearch:e=>({tag:typeof e.tag==`string`?e.tag:void 0}),component:()=>null}),ik=Li({getParentRoute:()=>ek,path:`/workflows/$workflowId`,validateSearch:e=>({tag:typeof e.tag==`string`?e.tag:void 0}),component:()=>null}),ak=Li({getParentRoute:()=>ek,path:`/perf`,component:()=>null}),ok=Li({getParentRoute:()=>ek,path:`/auto`,component:()=>null}),sk=ea({routeTree:ek.addChildren([tk,nk,rk,ik,ak,ok]),history:hr()}),ck=new Re({defaultOptions:{queries:{refetchInterval:5e3,staleTime:2e3}}});(0,aa.createRoot)(document.getElementById(`root`)).render((0,H.jsx)(V.StrictMode,{children:(0,H.jsx)(Ue,{client:ck,children:(0,H.jsx)(ra,{router:sk})})}));
28
+ `},i)),a}function UT(e,t){return e&&`run`in e?async function(n,r){let i=HT(n,{file:r,...t});await e.run(i,r)}:function(n,r){return HT(n,{file:r,...e||t})}}function WT(e){if(e)throw e}var GT=o(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function KT(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function qT(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?JT(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function JT(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var YT={basename:XT,dirname:ZT,extname:QT,join:$T,sep:`/`};function XT(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);nE(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function ZT(e){if(nE(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function QT(e){nE(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function $T(...e){let t=-1,n;for(;++t<e.length;)nE(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:eE(n)}function eE(e){nE(e);let t=e.codePointAt(0)===47,n=tE(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function tE(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function nE(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var rE={cwd:iE};function iE(){return`/`}function aE(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function oE(e){if(typeof e==`string`)e=new URL(e);else if(!aE(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return sE(e)}function sE(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var cE=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],lE=class{constructor(e){let t;t=e?aE(e)?{path:e}:typeof e==`string`||pE(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:rE.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<cE.length;){let e=cE[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)cE.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?YT.basename(this.path):void 0}set basename(e){dE(e,`basename`),uE(e,`basename`),this.path=YT.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?YT.dirname(this.path):void 0}set dirname(e){fE(this.basename,`dirname`),this.path=YT.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?YT.extname(this.path):void 0}set extname(e){if(uE(e,`extname`),fE(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=YT.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){aE(e)&&(e=oE(e)),dE(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?YT.basename(this.path,this.extname):void 0}set stem(e){dE(e,`stem`),uE(e,`stem`),this.path=YT.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new Qb(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function uE(e,t){if(e&&e.includes(YT.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+YT.sep+"`")}function dE(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function fE(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function pE(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var mE=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),hE=l(GT(),1),gE={}.hasOwnProperty,_E=new class e extends mE{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=qT()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,hE.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(bE(`data`,this.frozen),this.namespace[e]=t,this):gE.call(this.namespace,e)&&this.namespace[e]||void 0:e?(bE(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=CE(e),n=this.parser||this.Parser;return vE(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),vE(`process`,this.parser||this.Parser),yE(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=CE(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);TE(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),vE(`processSync`,this.parser||this.Parser),yE(`processSync`,this.compiler||this.Compiler),this.process(e,r),SE(`processSync`,`process`,t),n;function r(e,r){t=!0,WT(e),n=r}}run(e,t,n){xE(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=CE(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),SE(`runSync`,`run`,n),r;function i(e,t){WT(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=CE(t),r=this.compiler||this.Compiler;return yE(`stringify`,r),xE(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(bE(`use`,this.frozen),e!=null)if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`)if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e);else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,hE.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null)if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];KT(o)&&KT(r)&&(r=(0,hE.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function vE(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function yE(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function bE(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function xE(e){if(!KT(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function SE(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function CE(e){return wE(e)?e:new lE(e)}function wE(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function TE(e){return typeof e==`string`||EE(e)}function EE(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var DE=[],OE={allowDangerousHtml:!0},kE=/^(https?|ircs?|mailto|xmpp)$/i,AE=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function jE(e){let t=ME(e),n=NE(e);return PE(t.runSync(t.parse(n),n),e)}function ME(e){let t=e.rehypePlugins||DE,n=e.remarkPlugins||DE,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...OE}:OE;return _E().use(kw).use(n).use(UT,r).use(t)}function NE(e){let t=e.children||``,n=new lE;return typeof t==`string`?n.value=t:``+t,n}function PE(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||FE;for(let e of AE)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return NT(e,l),ox(e,{Fragment:H.Fragment,components:i,ignoreInvalidStyle:!0,jsx:H.jsx,jsxs:H.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in Ox)if(Object.hasOwn(Ox,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=Ox[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function FE(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||kE.test(e.slice(0,t))?e:``}function IE({children:e,className:t}){return(0,H.jsx)(`div`,{className:`markdown-view ${t??``}`,children:(0,H.jsx)(jE,{children:e})})}function LE({sessionId:e,nodeId:t,runStatus:n=`complete`,currentNodeId:r=null,executionTraceSummary:i=null}){let{data:a,isLoading:o,error:s}=Wy(e,t);return t?(0,H.jsxs)(`div`,{children:[(0,H.jsx)(RE,{stepLabel:a?.stepLabel??null,nodeId:t}),(0,H.jsxs)(`div`,{className:`p-4 space-y-4`,children:[o&&(0,H.jsx)(`div`,{className:`text-[var(--text-secondary)] text-sm`,children:`Loading...`}),s&&(0,H.jsx)(`div`,{className:`text-[var(--error)] text-sm bg-[var(--bg-primary)] border border-[var(--border)] px-4 py-3`,children:s.message}),a&&(0,H.jsx)(UE,{detail:a,runStatus:n,currentNodeId:r,executionTraceSummary:i})]})]}):(0,H.jsx)(`div`,{className:`px-5 py-8 text-sm text-[var(--text-secondary)]`,children:`Select a node in the lineage to inspect its recap, validations, gaps, and artifacts.`})}function RE({stepLabel:e,nodeId:t}){return(0,H.jsxs)(`div`,{className:`px-5 py-4 border-b border-[var(--border)] console-blueprint-grid`,children:[(0,H.jsx)(`div`,{className:`text-base font-semibold text-[var(--text-primary)] leading-tight`,children:e??`Untitled node`}),(0,H.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-[var(--text-muted)] truncate`,children:t})]})}function zE({item:e}){return(0,H.jsxs)(`div`,{className:`flex items-start gap-2 text-xs py-1`,children:[(0,H.jsx)(`span`,{className:`flex-1 text-[var(--text-secondary)] leading-relaxed`,children:e.summary}),(0,H.jsxs)(`span`,{className:`font-mono text-[10px] text-[var(--text-muted)] shrink-0`,children:[`#`,e.recordedAtEventIndex]})]})}function BE({nodeId:e,nodeKind:t,executionTraceSummary:n}){let{whySelected:r,conditions:i,loops:a,divergences:o,forks:s}=dy(n,e);return n.items.some(t=>t.kind!==`context_fact`&&t.refs.some(t=>t.kind===`node_id`&&t.value===e))?(0,H.jsx)(iD,{title:`Routing context`,children:(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(r.length>0||t===`blocked_attempt`)&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`mb-1.5 flex items-center gap-2`,children:(0,H.jsx)(My,{label:`WHY SELECTED`,color:`var(--accent)`,bgColor:`rgba(244,196,48,0.10)`})}),r.length>0?(0,H.jsx)(`div`,{className:`space-y-1 pl-2 border-l border-[var(--border)]`,children:r.map((e,t)=>(0,H.jsx)(zE,{item:e},t))}):t===`blocked_attempt`?(0,H.jsx)(`div`,{className:`pl-2 border-l border-[var(--border)]`,children:(0,H.jsx)(`span`,{className:`text-xs text-[var(--text-muted)]`,children:`This step was attempted but not selected as the preferred path.`})}):null]}),i.length>0&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`mb-1.5`,children:(0,H.jsx)(My,{label:`CONDITIONS EVALUATED`,color:`var(--text-secondary)`,bgColor:`rgba(168,159,140,0.10)`})}),(0,H.jsx)(`div`,{className:`space-y-1 pl-2 border-l border-[var(--border)]`,children:[...i.filter(e=>!ay(e)),...i.filter(e=>ay(e))].map((e,t)=>{let n=ay(e);return(0,H.jsxs)(`div`,{className:`flex items-start gap-2 text-xs py-0.5`,children:[(0,H.jsx)(My,{label:n?`PASS`:`SKIP`,color:n?`var(--success)`:`var(--warning)`,bgColor:n?`rgba(34,197,94,0.10)`:`rgba(251,191,36,0.10)`}),(0,H.jsx)(`span`,{className:`flex-1 text-[var(--text-secondary)] leading-relaxed`,children:e.summary})]},t)})})]}),a.length>0&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`mb-1.5`,children:(0,H.jsx)(My,{label:`LOOP`,color:`var(--accent-strong)`,bgColor:`rgba(0,240,255,0.10)`})}),(0,H.jsx)(`div`,{className:`space-y-1 pl-2 border-l border-[var(--border)]`,children:a.map((e,t)=>(0,H.jsx)(zE,{item:e},t))})]}),o.length>0&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`mb-1.5`,children:(0,H.jsx)(My,{label:`DIVERGENCE`,color:`var(--error)`,bgColor:`rgba(255,107,107,0.10)`})}),(0,H.jsx)(`div`,{className:`space-y-1 pl-2 border-l border-[var(--border)]`,children:o.map((e,t)=>(0,H.jsx)(zE,{item:e},t))})]}),s.length>0&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`mb-1.5`,children:(0,H.jsx)(My,{label:`FORK`,color:`var(--warning)`,bgColor:`rgba(251,191,36,0.10)`})}),(0,H.jsx)(`div`,{className:`space-y-1 pl-2 border-l border-[var(--border)]`,children:s.map((e,t)=>(0,H.jsx)(zE,{item:e},t))})]})]})}):(0,H.jsx)(iD,{title:`Routing context`,children:t===`blocked_attempt`&&r.length===0?(0,H.jsxs)(`div`,{className:`flex items-start gap-2 py-1`,children:[(0,H.jsx)(My,{label:`WHY SELECTED`,color:`var(--text-muted)`,bgColor:`rgba(123,141,167,0.08)`}),(0,H.jsx)(`span`,{className:`text-xs text-[var(--text-muted)] leading-relaxed`,children:`This step was attempted but not selected as the preferred path.`})]}):(0,H.jsx)(`span`,{className:`font-mono text-xs text-[var(--text-muted)]`,children:`// no routing trace for this node`})})}function VE({items:e}){let[t,n]=(0,V.useState)(!1);return(0,H.jsx)(iD,{title:`Run routing`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`button`,{type:`button`,"aria-expanded":t,onClick:()=>n(e=>!e),className:`flex items-center gap-2 font-mono text-[10px] uppercase tracking-[0.20em] text-[var(--text-muted)] hover:text-[var(--text-secondary)] transition-colors`,children:[(0,H.jsx)(My,{label:`RUN ROUTING`,color:`var(--text-muted)`,bgColor:`rgba(123,141,167,0.08)`}),(0,H.jsxs)(`span`,{className:`text-[var(--text-muted)]`,children:[`// `,e.length,` ambient items`]}),(0,H.jsx)(`span`,{children:t?`[-]`:`[+]`})]}),t&&(0,H.jsx)(`div`,{className:`mt-2 space-y-1 pl-2 border-l border-[var(--border)]`,children:e.map((e,t)=>(0,H.jsxs)(`div`,{className:`flex items-start gap-2 text-xs py-0.5`,children:[(0,H.jsx)(`span`,{className:`shrink-0 inline-flex items-center px-2 py-0.5 font-mono text-[10px] uppercase tracking-[0.16em]`,style:{color:`var(--text-muted)`,backgroundColor:`rgba(123,141,167,0.08)`,border:`1px solid rgba(123,141,167,0.20)`},children:e.kind.replace(/_/g,` `).toUpperCase()}),(0,H.jsx)(`span`,{className:`flex-1 text-[var(--text-secondary)] leading-relaxed`,children:e.summary}),(0,H.jsxs)(`span`,{className:`font-mono text-[10px] text-[var(--text-muted)] shrink-0`,children:[`#`,e.recordedAtEventIndex]})]},t))})]})})}var HE=[{id:`routing`,column:`primary`,render:({detail:e,executionTraceSummary:t})=>t===null?null:(0,H.jsx)(BE,{nodeId:e.nodeId,nodeKind:e.nodeKind,executionTraceSummary:t},`routing`)},{id:`run_routing`,column:`primary`,render:({executionTraceSummary:e})=>{if(e===null)return null;let t=e.items.filter(e=>!e.refs.some(e=>e.kind===`node_id`));return t.length===0?null:(0,H.jsx)(VE,{items:t},`run_routing`)}},{id:`recap`,column:`primary`,render:({detail:e,runStatus:t,currentNodeId:n})=>e.recapMarkdown?(0,H.jsx)(YE,{markdown:e.recapMarkdown},`recap`):t===`in_progress`&&e.nodeId===n&&!e.recapMarkdown?(0,H.jsx)(WE,{detail:e},`recap-in-progress`):null},{id:`validations`,column:`primary`,render:({detail:e})=>e.validations.length>0?(0,H.jsx)(ZE,{validations:e.validations},`validations`):null},{id:`gaps`,column:`primary`,render:({detail:e})=>e.gaps.length>0?(0,H.jsx)($E,{gaps:e.gaps},`gaps`):null},{id:`advance-outcome`,column:`primary`,render:({detail:e})=>e.advanceOutcome?(0,H.jsx)(XE,{outcome:e.advanceOutcome},`advance-outcome`):null},{id:`artifacts`,column:`primary`,render:({detail:e})=>e.artifacts.length>0?(0,H.jsx)(rD,{artifacts:e.artifacts},`artifacts`):null},{id:`node-meta`,column:`primary`,render:({detail:e})=>(0,H.jsx)(JE,{detail:e},`node-meta`)}];function UE(e){return(0,H.jsx)(`div`,{className:`space-y-4`,children:HE.map(t=>t.render(e))})}function WE({detail:e}){return(0,H.jsx)(iD,{title:`Recap`,children:(0,H.jsxs)(`div`,{className:`space-y-4 text-sm text-[var(--text-secondary)]`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(GE,{children:`In progress`}),(0,H.jsxs)(`span`,{className:`font-mono text-xs text-[var(--text-muted)]`,children:[`event #`,e.createdAtEventIndex]})]}),(0,H.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]`,children:[(0,H.jsx)(KE,{label:`Current focus`,value:e.stepLabel??`Current workflow step`,supportingText:`This step is still running, so the recap will appear once execution finishes.`}),(0,H.jsx)(KE,{label:`Current state`,value:`Waiting for step completion`,supportingText:`The node has been created and selected as the current workflow position.`,mono:!0})]}),(0,H.jsxs)(`div`,{className:`bg-[var(--bg-primary)] border border-[var(--border)] overflow-hidden`,children:[(0,H.jsx)(`div`,{className:`px-4 py-3 border-b border-[var(--border)]`,children:(0,H.jsx)(Uo,{children:`What lands here next`})}),(0,H.jsxs)(`div`,{className:`p-4 grid gap-3 md:grid-cols-3`,children:[(0,H.jsx)(qE,{title:`Recap`,description:`A step summary is written when this node completes.`}),(0,H.jsx)(qE,{title:`Validations`,description:`Validation results appear if this step records contract checks.`}),(0,H.jsx)(qE,{title:`Artifacts`,description:`Generated outputs show up here after the step produces them.`})]})]})]})})}function GE({children:e}){return(0,H.jsx)(`span`,{className:`inline-flex items-center px-2 py-1 font-medium text-xs`,style:{backgroundColor:`rgba(0, 219, 233, 0.12)`,color:`var(--accent-strong)`},children:e})}function KE({label:e,value:t,supportingText:n,mono:r=!1}){return(0,H.jsxs)(`div`,{className:`bg-[var(--bg-primary)] border border-[var(--border)] px-4 py-3 space-y-2`,children:[(0,H.jsx)(Uo,{children:e}),(0,H.jsx)(`div`,{className:r?`font-mono text-sm text-[var(--text-primary)]`:`text-[var(--text-primary)]`,children:t}),(0,H.jsx)(`div`,{className:`text-xs text-[var(--text-muted)] leading-relaxed`,children:n})]})}function qE({title:e,description:t}){return(0,H.jsxs)(`div`,{className:`border border-[var(--border)] bg-[rgba(255,255,255,0.02)] px-3 py-3 space-y-2`,children:[(0,H.jsx)(Uo,{color:`var(--text-secondary)`,children:e}),(0,H.jsx)(`div`,{className:`text-xs text-[var(--text-muted)] leading-relaxed`,children:t})]})}function JE({detail:e}){return(0,H.jsx)(iD,{title:`Node details`,children:(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsx)(aD,{label:`Kind`,value:(0,H.jsx)(sD,{kind:e.nodeKind})}),(0,H.jsx)(aD,{label:`Event index`,value:String(e.createdAtEventIndex),mono:!0}),(0,H.jsx)(aD,{label:`Parent`,value:e.parentNodeId??`Root`,mono:!0}),(0,H.jsx)(aD,{label:`Tip state`,value:e.isTip?e.isPreferredTip?`Preferred tip`:`Tip`:`Historical`})]})})}function YE({markdown:e}){return(0,H.jsx)(iD,{title:`Recap`,children:(0,H.jsx)(IE,{children:e})})}function XE({outcome:e}){let t=e.kind===`advanced`;return(0,H.jsx)(iD,{title:`Advance outcome`,children:(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-xs`,children:[(0,H.jsx)(`span`,{className:`inline-flex items-center px-2 py-1 font-medium`,style:{backgroundColor:t?`var(--success)20`:`var(--blocked)20`,color:t?`var(--success)`:`var(--blocked)`},children:t?`Advanced`:`Blocked`}),(0,H.jsxs)(`span`,{className:`text-[var(--text-muted)]`,children:[`attempt `,e.attemptId.slice(-8),` at event #`,e.recordedAtEventIndex]})]})})}function ZE({validations:e}){return(0,H.jsx)(iD,{title:`Validations (${e.length})`,children:(0,H.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,H.jsx)(QE,{validation:e},e.validationId))})})}function QE({validation:e}){let t=e.outcome===`pass`;return(0,H.jsxs)(`div`,{className:`bg-[var(--bg-primary)] border border-[var(--border)] px-4 py-3 text-xs space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`inline-flex items-center px-2 py-1 font-medium`,style:{backgroundColor:t?`var(--success)20`:`var(--error)20`,color:t?`var(--success)`:`var(--error)`},children:t?`Pass`:`Fail`}),(0,H.jsx)(`span`,{className:`text-[var(--text-muted)] font-mono`,children:e.contractRef})]}),e.issues.length>0&&(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`div`,{className:`text-[var(--text-muted)] mb-1`,children:`Issues`}),(0,H.jsx)(`ul`,{className:`list-disc list-inside text-[var(--error)] space-y-0.5`,children:e.issues.map((e,t)=>(0,H.jsx)(`li`,{children:e},t))})]}),e.suggestions.length>0&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-[var(--text-muted)] mb-1`,children:`Suggestions`}),(0,H.jsx)(`ul`,{className:`list-disc list-inside text-[var(--text-secondary)] space-y-0.5`,children:e.suggestions.map((e,t)=>(0,H.jsx)(`li`,{children:e},t))})]})]})}function $E({gaps:e}){return(0,H.jsx)(iD,{title:`Gaps (${e.length})`,children:(0,H.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,H.jsxs)(`div`,{className:`flex items-start gap-3 text-xs bg-[var(--bg-primary)] border border-[var(--border)] px-3 py-3`,children:[(0,H.jsx)(`span`,{className:`shrink-0 inline-flex items-center px-2 py-1 font-medium`,style:{backgroundColor:e.isResolved?`var(--success)20`:e.severity===`critical`?`var(--error)20`:`var(--warning)20`,color:e.isResolved?`var(--success)`:e.severity===`critical`?`var(--error)`:`var(--warning)`},children:e.isResolved?`Resolved`:e.severity===`critical`?`Critical`:`Non-critical`}),(0,H.jsx)(`span`,{className:`text-[var(--text-secondary)] leading-relaxed`,children:e.summary})]},e.gapId))})})}var eD=1e5,tD=[{prefix:`text/`,render:e=>(0,H.jsx)(`pre`,{className:`text-[var(--text-secondary)] whitespace-pre-wrap break-words font-mono max-h-40 overflow-y-auto`,children:typeof e==`string`?e:String(e)})},{prefix:`application/json`,render:e=>(0,H.jsx)(`pre`,{className:`text-[var(--text-secondary)] whitespace-pre-wrap break-words font-mono max-h-40 overflow-y-auto`,children:typeof e==`string`?e:JSON.stringify(e,null,2)})}];function nD(e){if(e.byteLength>eD)return(0,H.jsxs)(`div`,{className:`text-[var(--text-muted)] italic`,children:[`Content too large to display (`,cD(e.byteLength),` -- limit `,cD(eD),`)`]});let t=tD.find(t=>e.contentType.startsWith(t.prefix));return t?t.render(e.content):(0,H.jsx)(`pre`,{className:`text-[var(--text-secondary)] whitespace-pre-wrap break-words font-mono max-h-40 overflow-y-auto`,children:typeof e.content==`string`?e.content:JSON.stringify(e.content,null,2)})}function rD({artifacts:e}){return(0,H.jsx)(iD,{title:`Artifacts (${e.length})`,children:(0,H.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,H.jsxs)(`div`,{className:`bg-[var(--bg-primary)] border border-[var(--border)] px-4 py-3 text-xs space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[var(--text-muted)]`,children:[(0,H.jsx)(`span`,{children:e.contentType}),(0,H.jsx)(`span`,{children:`//`}),(0,H.jsx)(`span`,{children:cD(e.byteLength)})]}),nD(e)]},e.sha256))})})}function iD({title:e,children:t}){return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`mb-2`,children:(0,H.jsx)(Uo,{children:e})}),t]})}function aD({label:e,value:t,mono:n=!1}){return(0,H.jsxs)(`div`,{className:`bg-[var(--bg-primary)] border border-[var(--border)] px-4 py-3`,children:[(0,H.jsx)(Uo,{children:e}),(0,H.jsx)(`div`,{className:n?`mt-2 font-mono text-sm text-[var(--text-secondary)] truncate`:`mt-2 text-sm text-[var(--text-primary)]`,children:t})]})}var oD={step:{label:`Step`,color:`var(--accent)`},checkpoint:{label:`Checkpoint`,color:`var(--success)`},blocked_attempt:{label:`Blocked`,color:`var(--error)`}};function sD({kind:e}){let t=oD[e];return(0,H.jsx)(`span`,{className:`inline-flex items-center px-2 py-1 font-medium`,style:{backgroundColor:`${t.color}20`,color:t.color},children:t.label})}function cD(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function lD(e){return e.length>16?`\u2026${e.slice(-16)}`:e}function uD({data:e}){let t=e.runs[0]??null,n=t?.workflowName??t?.workflowId??`--`,r=t?.workflowHash?.slice(0,12)??`--`;return(0,H.jsxs)(`div`,{className:`bg-[var(--bg-card)] border border-[var(--border)] px-5 py-4 corner-brackets`,style:{backdropFilter:`blur(12px)`,WebkitBackdropFilter:`blur(12px)`},children:[e.sessionTitle&&(0,H.jsx)(`h2`,{className:`text-base font-medium text-[var(--text-primary)] mb-3`,children:e.sessionTitle}),(0,H.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-8 gap-y-2`,children:[(0,H.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)] self-center`,children:`Session`}),(0,H.jsx)(`dd`,{className:`font-mono text-xs text-[var(--text-secondary)] self-center`,children:lD(e.sessionId)}),(0,H.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)] self-center`,children:`Workflow`}),(0,H.jsx)(`dd`,{className:`text-sm text-[var(--text-primary)] self-center`,children:n}),(0,H.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)] self-center`,children:`Hash`}),(0,H.jsx)(`dd`,{className:`font-mono text-xs text-[var(--text-secondary)] self-center`,children:r}),(0,H.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)] self-center`,children:`Status`}),(0,H.jsxs)(`dd`,{className:`self-center flex items-center gap-2`,children:[(0,H.jsx)(no,{health:e.health}),e.health===`healthy`&&(0,H.jsx)(`span`,{className:`text-sm text-[var(--text-primary)]`,children:`Healthy`})]}),(0,H.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)] self-center`,children:`Runs`}),(0,H.jsxs)(`dd`,{className:`text-sm text-[var(--text-primary)] self-center`,children:[e.runs.length,` run`,e.runs.length===1?``:`s`]})]})]})}function dD({runs:e}){let t=e.some(e=>e.preferredTipNodeId!==null),n=e.some(e=>e.executionTraceSummary!==null);return(0,H.jsxs)(`div`,{className:`border border-[var(--border)] px-4 py-3 text-xs text-[var(--text-muted)] space-y-1`,children:[(0,H.jsx)(`p`,{children:t?`Nodes with a gold border are the current execution tips — click any node to inspect its execution detail.`:`Click any node in the DAG to inspect its execution detail.`}),n&&(0,H.jsxs)(`p`,{children:[`This run has execution trace data. Click`,` `,(0,H.jsx)(`span`,{className:`font-mono uppercase tracking-[0.16em]`,children:`[ TRACE ]`}),` `,`to see why certain steps ran, were skipped, or repeated.`]})]})}function fD({viewModel:e}){let{state:t,onSelectNode:n,onCloseNode:r}=e;if(t.kind===`loading`)return(0,H.jsx)(`div`,{className:`text-[var(--text-secondary)]`,children:`Loading session...`});if(t.kind===`error`)return(0,H.jsxs)(`div`,{className:`text-[var(--error)] bg-[var(--bg-card)] rounded-lg p-4`,children:[`Failed to load session: `,t.message]});let{sessionId:i,data:a,selectedNode:o,selectedRun:s}=t;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsx)(uD,{data:a}),a.runs.length===0?(0,H.jsx)(`div`,{className:`text-center py-16 text-[var(--text-secondary)]`,children:`No runs in this session`}):(0,H.jsxs)(H.Fragment,{children:[o===null&&(0,H.jsx)(dD,{runs:a.runs}),(0,H.jsx)(`div`,{className:`space-y-6`,children:a.runs.map(e=>(0,H.jsx)(pD,{run:e,selectedNodeId:o?.runId===e.runId?o.nodeId:null,onNodeClick:n},e.runId))})]})]}),(0,H.jsxs)(oo,{cut:18,borderColor:`rgba(244, 196, 48, 0.35)`,background:`rgba(27, 31, 44, 0.78)`,dropShadow:`drop-shadow(0 16px 48px rgba(0,0,0,0.9)) drop-shadow(0 2px 12px rgba(244,196,48,0.15))`,backdropFilter:`blur(16px)`,className:`fixed top-3 right-3 bottom-3 w-[560px] max-w-[calc(92vw-12px)] transition-transform duration-200 ease-out`,style:{zIndex:40,transform:o?`translateX(0)`:`translateX(calc(100% + 12px))`},children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-[var(--border)] shrink-0 console-blueprint-grid`,children:[(0,H.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)]`,children:`Node detail`}),(0,H.jsx)(`button`,{onClick:r,className:`text-[var(--text-muted)] hover:text-[var(--text-primary)] transition-colors text-xl leading-none px-1`,"aria-label":`Close`,children:`×`})]}),(0,H.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,H.jsx)(LE,{sessionId:i,nodeId:o?.nodeId??null,runStatus:s?.status??`complete`,currentNodeId:s?.preferredTipNodeId??null,executionTraceSummary:s?.executionTraceSummary??null})})]})]})}function pD({run:e,selectedNodeId:t,onNodeClick:n}){let r=e.executionTraceSummary!==null,[i,a]=(0,V.useState)(`dag`);return(0,H.jsxs)(oo,{cut:10,background:`rgba(27, 31, 44, 0.72)`,backdropFilter:`blur(8px)`,className:`relative`,style:{height:r?`542px`:`506px`},children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-[var(--border)] shrink-0`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-[var(--text-primary)]`,children:e.workflowName??e.workflowId??`Run`}),(0,H.jsx)(`span`,{className:`font-mono text-xs text-[var(--text-muted)]`,children:e.runId}),(0,H.jsxs)(`span`,{className:`font-mono text-xs text-[var(--text-muted)]`,children:[e.nodes.length,` nodes · `,e.tipNodeIds.length,` tip`,e.tipNodeIds.length===1?``:`s`]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.hasUnresolvedCriticalGaps&&(0,H.jsx)(`span`,{className:`text-xs text-[var(--warning)]`,children:`Critical gaps`}),(0,H.jsx)(to,{status:e.status})]})]}),r&&(0,H.jsxs)(`div`,{role:`tablist`,"aria-label":`Run view mode`,className:`flex items-center border-b border-[var(--border)] shrink-0 h-9 px-2 gap-0.5`,onKeyDown:e=>{e.key===`ArrowRight`&&(e.preventDefault(),a(`trace`)),e.key===`ArrowLeft`&&(e.preventDefault(),a(`dag`))},children:[(0,H.jsxs)(`button`,{type:`button`,id:`tab-dag`,role:`tab`,tabIndex:i===`dag`?0:-1,"aria-selected":i===`dag`,onClick:()=>a(`dag`),className:[`tab-btn px-3 py-1.5 font-mono text-[10px] uppercase tracking-[0.25em] transition-colors duration-150`,i===`dag`?`tab-btn--active text-[var(--accent)]`:`text-[var(--text-secondary)] hover:text-[var(--text-primary)]`].join(` `),style:i===`dag`?{backgroundColor:`rgba(244, 196, 48, 0.06)`}:void 0,children:[(0,H.jsx)(`span`,{className:`tab-corner tab-corner--tl`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--tr`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--bl`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--br`,"aria-hidden":`true`}),`DAG`]}),(0,H.jsxs)(`button`,{type:`button`,id:`tab-trace`,role:`tab`,tabIndex:i===`trace`?0:-1,"aria-selected":i===`trace`,onClick:()=>a(`trace`),className:[`tab-btn px-3 py-1.5 font-mono text-[10px] uppercase tracking-[0.25em] transition-colors duration-150`,i===`trace`?`tab-btn--active text-[var(--accent)]`:`text-[var(--text-secondary)] hover:text-[var(--text-primary)]`].join(` `),style:i===`trace`?{backgroundColor:`rgba(244, 196, 48, 0.06)`}:void 0,children:[(0,H.jsx)(`span`,{className:`tab-corner tab-corner--tl`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--tr`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--bl`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--br`,"aria-hidden":`true`}),`TRACE`]})]}),(0,H.jsx)(`div`,{role:`tabpanel`,"aria-labelledby":i===`dag`?`tab-dag`:`tab-trace`,className:`flex-1`,children:i===`trace`&&e.executionTraceSummary!==null?(0,H.jsx)(Ry,{summary:e.executionTraceSummary,runStatus:e.status}):(0,H.jsx)(fy,{run:e,selectedNodeId:t,onNodeClick:t=>n(e.runId,t)})})]})}function mD(){let[e,t]=(0,V.useState)(0),[n,r]=(0,V.useState)(0),[i,a]=(0,V.useState)(38),[o,s]=(0,V.useState)(62),[c,l]=(0,V.useState)(3),[u,d]=(0,V.useState)(2),[f,p]=(0,V.useState)(``),[m,h]=(0,V.useState)(!1),g=(0,V.useRef)(!1),_=(0,V.useRef)(null),v=(0,V.useRef)(null),y=(0,V.useRef)(null),b=(e,n,i,o,c,u)=>{g.current=!0,h(!0),t(e=>e+1),r(Math.floor(Math.random()*4)),a(5+Math.floor(Math.random()*80)),s(5+Math.floor(Math.random()*80)),l(2+Math.floor(Math.random()*40)),d(2+Math.floor(Math.random()*25)),p(i===`horizontal`?n===`next`?`modal-content--exit-h-next`:`modal-content--exit-h-prev`:n===`next`?`modal-content--exit-v-next`:`modal-content--exit-v-prev`),c.current&&(c.current.scrollTop=0);let f=u[e].id;setTimeout(()=>{o(f),p(i===`horizontal`?n===`next`?`modal-content--enter-h-next`:`modal-content--enter-h-prev`:n===`next`?`modal-content--enter-v-next`:`modal-content--enter-v-prev`),h(!1)},80),setTimeout(()=>{if(p(``),g.current=!1,_.current!==null){let e=_.current;_.current=null;let t=e>u.findIndex(e=>e.id===v.current)?`next`:`prev`;y.current?.(e,t,`horizontal`,o,c,u)}},240)};return y.current=b,{state:{isAnimating:g.current,contentAnimClass:f,borderFlashing:m,scanline:e>0?{key:e,crtOffset:n,glitchY:i,glitchY2:o,glitchW:c,glitchW2:u}:null},startTransition:b,navigate:(e,t,n,r,i,a)=>{if(t.length<=1)return;let o=t.findIndex(t=>t.id===e);if(o===-1)return;let s=n===`next`?(o+1)%t.length:(o-1+t.length)%t.length;if(g.current){_.current=s;return}b(s,n,r,i,a,t)},selectedWorkflowIdRef:v}}var hD=[{id:`coding`,label:`Coding`},{id:`review_audit`,label:`Review & Audit`},{id:`investigation`,label:`Investigation`},{id:`design`,label:`Design`},{id:`documentation`,label:`Documentation`},{id:`tickets`,label:`Tickets`},{id:`learning`,label:`Learning`},{id:`authoring`,label:`Workflow Authoring`}],gD=Object.fromEntries(hD.map(e=>[e.id,e.label]));function _D({label:e,count:t,countLabel:n=`workflow`,showRule:r=!0,separator:i=`//`}){return(0,H.jsxs)(`div`,{className:`flex items-center gap-3 mb-3 mt-2`,children:[(0,H.jsxs)(`span`,{className:`font-mono text-[11px] uppercase tracking-[0.30em] text-[var(--text-secondary)] shrink-0`,children:[e,t==null?``:` ${i} ${t} ${n}${t===1?``:`s`}`]}),r&&(0,H.jsx)(`div`,{className:`flex-1 h-px bg-[var(--border)]`})]})}function vD({segments:e,className:t=``}){return(0,H.jsx)(`nav`,{"aria-label":`Breadcrumb`,className:`flex items-center gap-0 ${t}`,children:e.map((t,n)=>{let r=n===e.length-1,i=!!t.onClick;return(0,H.jsxs)(`span`,{className:`flex items-center`,children:[(0,H.jsx)(`span`,{className:`font-mono text-[10px] tracking-[0.25em] text-[var(--text-muted)] mx-1`,children:`//`}),i?(0,H.jsx)(`button`,{type:`button`,onClick:t.onClick,className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] hover:text-[var(--accent)] transition-colors cursor-pointer`,children:t.label.toUpperCase()}):(0,H.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] ${r?`text-[var(--text-secondary)]`:`text-[var(--text-muted)]`}`,"aria-current":r?`page`:void 0,children:t.label.toUpperCase()})]},n)})})}function yD({viewModel:e}){let{state:t}=e;if(t.kind===`not_found`)return(0,H.jsx)(`div`,{className:`space-y-5 max-w-3xl`,children:(0,H.jsx)(TD,{message:``,is404:!0,onRetry:()=>void 0,onBack:t.onBack})});if(t.kind===`error`)return(0,H.jsx)(`div`,{className:`space-y-5 max-w-3xl`,children:(0,H.jsx)(TD,{message:t.message,is404:!1,onRetry:t.onRetry,onBack:t.onBack})});if(t.kind===`loading`){let{cached:e,activeTagLabel:n,onBack:r}=t;return(0,H.jsxs)(`div`,{className:`space-y-5 max-w-3xl`,children:[(0,H.jsx)(vD,{segments:n?[{label:`Workflows`,onClick:r},{label:n}]:[{label:`Workflows`,onClick:r}]}),e?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(bD,{name:e.name,description:e.description,tags:e.tags,source:e.source,stepCount:void 0}),(0,H.jsx)(`div`,{className:`space-y-4`,children:(0,H.jsx)(CD,{})})]}):(0,H.jsx)(wD,{})]})}let{workflow:n,name:r,description:i,tags:a,source:o,activeTagLabel:s,onPrev:c,onNext:l,onBack:u}=t;return(0,H.jsxs)(`div`,{className:`space-y-5 max-w-3xl`,children:[(0,H.jsx)(vD,{segments:s?[{label:`Workflows`,onClick:u},{label:s}]:[{label:`Workflows`,onClick:u}]}),(0,H.jsx)(bD,{name:r,description:i,tags:a,source:o,stepCount:n.stepCount}),(c??l)&&(0,H.jsxs)(`div`,{className:`flex items-center gap-4`,children:[c&&(0,H.jsxs)(`button`,{type:`button`,onClick:c,className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] hover:text-[var(--accent)] transition-colors`,children:[`<`,` PREV`]}),l&&(0,H.jsxs)(`button`,{type:`button`,onClick:l,className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] hover:text-[var(--accent)] transition-colors`,children:[`NEXT `,`>`]})]}),(0,H.jsx)(xD,{detail:n,name:r}),(0,H.jsx)(vD,{segments:[{label:`Workflows`,onClick:u}]})]})}function bD({name:e,description:t,tags:n,source:r,stepCount:i}){return(0,H.jsxs)(`div`,{className:`border border-[var(--border)] px-5 py-5 console-blueprint-grid`,children:[(0,H.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-[0.35em] text-[var(--text-muted)] mb-2`,children:`// Workflow`}),(0,H.jsx)(`h2`,{className:`font-mono text-xl font-bold uppercase tracking-[0.08em] leading-tight mb-3`,style:{color:`var(--accent)`,textShadow:`0 0 24px rgba(244,196,48,0.45), 0 0 48px rgba(244,196,48,0.15)`},children:e}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i!=null&&i>0&&(0,H.jsxs)(`span`,{className:`font-mono text-[10px] px-1.5 py-0.5 border border-[var(--border)] text-[var(--text-secondary)]`,children:[i,` step`,i===1?``:`s`]}),n.filter(e=>e!==`routines`).map(e=>(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`font-mono text-[10px] px-1.5 py-0.5 bg-[var(--bg-secondary)] text-[var(--text-muted)]`,children:e},e)),r&&(0,H.jsxs)(`span`,{"aria-hidden":`true`,className:`font-mono text-[10px] px-1.5 py-0.5 border border-[var(--border)] text-[var(--text-muted)]`,children:[`src: `,r.displayName]})]}),t&&(0,H.jsx)(`p`,{className:`text-sm text-[var(--text-secondary)] leading-relaxed mt-3`,children:t})]})}function xD({detail:e,name:t}){let n=e.about!==void 0&&e.about.length>0,r=e.examples!==void 0&&e.examples.length>0,i=e.preconditions!==void 0&&e.preconditions.length>0;return n||r||i?(0,H.jsxs)(`div`,{className:`space-y-6`,children:[n&&(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h3`,{className:`text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider mb-3`,children:`About`}),(0,H.jsx)(IE,{children:e.about})]}),r&&(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h3`,{className:`text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider mb-3`,children:`Try it with:`}),(0,H.jsx)(`ul`,{className:`space-y-2`,children:e.examples.map(e=>(0,H.jsxs)(`li`,{className:`flex items-start gap-3 bg-[var(--bg-card)] border border-[var(--border)] rounded-none px-4 py-3`,children:[(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`w-0.5 shrink-0 self-stretch rounded-full`,style:{backgroundColor:`var(--accent)`}}),(0,H.jsxs)(`span`,{className:`text-sm text-[var(--text-secondary)] leading-relaxed`,children:[`"`,e,`"`]})]},e))})]}),i&&(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h3`,{className:`text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider mb-3`,children:`Before you start:`}),(0,H.jsx)(`ul`,{className:`space-y-1.5`,children:e.preconditions.map(e=>(0,H.jsxs)(`li`,{className:`flex items-start gap-2 text-sm text-[var(--text-secondary)]`,children:[(0,H.jsx)(`span`,{className:`shrink-0 text-[var(--text-muted)] mt-0.5`,children:`•`}),(0,H.jsx)(`span`,{children:e})]},e))})]}),(0,H.jsx)(SD,{name:t})]}):(0,H.jsx)(`p`,{className:`text-sm text-[var(--text-muted)] italic`,children:`No additional documentation available.`})}function SD({name:e}){let[t,n]=(0,V.useState)(!1),r=`Use the ${e} to [your goal]`;return(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h3`,{className:`text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider mb-3`,children:`Start with this prompt`}),(0,H.jsxs)(`div`,{className:`flex items-center gap-3 border border-[var(--border)] px-4 py-3`,children:[(0,H.jsxs)(`span`,{className:`flex-1 text-sm text-[var(--text-secondary)] font-mono truncate`,children:[`"`,r,`"`]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>{navigator.clipboard.writeText(r).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})},className:`shrink-0 text-xs font-mono text-[var(--accent)] hover:text-[var(--text-primary)] transition-colors`,children:t?`Copied!`:`Copy`})]})]})}function CD(){return(0,H.jsxs)(`div`,{className:`space-y-3 motion-safe:animate-pulse`,children:[(0,H.jsx)(`div`,{className:`h-3 w-16 rounded bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`h-4 w-full rounded bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`h-4 w-5/6 rounded bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`h-4 w-4/6 rounded bg-[var(--bg-tertiary)]`})]})}function wD(){return(0,H.jsxs)(`div`,{className:`space-y-6 motion-safe:animate-pulse`,children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`div`,{className:`h-6 w-1/2 rounded bg-[var(--bg-tertiary)]`}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(`div`,{className:`h-5 w-16 rounded bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`h-5 w-24 rounded bg-[var(--bg-tertiary)]`})]}),(0,H.jsx)(`div`,{className:`h-4 w-full rounded bg-[var(--bg-tertiary)]`})]}),(0,H.jsx)(CD,{})]})}function TD({message:e,is404:t,onRetry:n,onBack:r}){return(0,H.jsxs)(`div`,{className:`space-y-4 bg-[var(--bg-card)] border border-[var(--border)] p-4`,children:[(0,H.jsx)(`p`,{className:`text-sm text-[var(--error)]`,children:t?`Workflow not found.`:e}),(0,H.jsxs)(`div`,{className:`flex gap-3`,children:[!t&&(0,H.jsx)(`button`,{type:`button`,onClick:n,className:`text-sm text-[var(--accent)] hover:text-[var(--accent-hover)] transition-colors`,children:`Try again`}),(0,H.jsxs)(`button`,{type:`button`,onClick:r,"aria-label":`Back to workflows list`,className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] hover:text-[var(--accent)] transition-colors`,children:[`<`,` WORKFLOWS`]})]})]})}function ED(e){if(e.size<2)return 1;let t=new Set;for(let n of e.values())t.add(Math.round(n.getBoundingClientRect().top));if(t.size<2){let t=Math.round(e.get(0)?.getBoundingClientRect().top??0),n=0;for(let r of e.values())Math.round(r.getBoundingClientRect().top)===t&&n++;return Math.max(1,n)}let n=Math.round(e.get(0)?.getBoundingClientRect().top??0),r=0;for(let t of e.values())Math.round(t.getBoundingClientRect().top)===n&&r++;return Math.max(1,r)}function DD(e,t,n,r){if(n===0)return 0;let i=(e??(t>0?-1:n))+t;return r?(i%n+n)%n:Math.max(0,Math.min(n-1,i))}function OD(e,t,n,r,i){if(n===0)return 0;let a=e??0,o=a%r,s=Math.floor(a/r),c=Math.ceil(n/r),l=s+t;l=i?(l%c+c)%c:Math.max(0,Math.min(c-1,l));let u=l*r+o;return Math.min(u,n-1)}function kD({count:e,cols:t=`auto`,onActivate:n,loop:r=!0}){let[i,a]=(0,V.useState)(null),o=(0,V.useRef)(new Map),s=(0,V.useCallback)(e=>{a(e),e!==null&&o.current.get(e)?.focus()},[]),c=(0,V.useCallback)(()=>t===`auto`?ED(o.current):Math.max(1,t),[t]);return{focusedIndex:i,setFocusedIndex:s,getItemProps:(0,V.useCallback)(t=>({tabIndex:i===null?t===0?0:-1:i===t?0:-1,onFocus:()=>{a(t)},onKeyDown:i=>{let a=c(),o=null;switch(i.key){case`ArrowRight`:case`d`:case`D`:o=DD(t,1,e,r);break;case`ArrowLeft`:case`a`:case`A`:o=DD(t,-1,e,r);break;case`ArrowDown`:case`s`:case`S`:o=OD(t,1,e,a,r);break;case`ArrowUp`:case`w`:case`W`:o=OD(t,-1,e,a,r);break;case`Home`:o=0;break;case`End`:o=e-1;break;case`Enter`:case` `:i.preventDefault(),n?.(t);return;default:return}o!==null&&(i.preventDefault(),s(o))},ref:e=>{e?o.current.set(t,e):o.current.delete(t)}}),[i,e,r,c,n,s]),containerProps:{role:`grid`}}}function AD(e){let t=Jy(e),n=()=>{t.refetch()};return t.isLoading?{kind:`loading`}:t.error?t.error instanceof By&&t.error.status===404?{kind:`not_found`}:{kind:`error`,message:t.error instanceof Error?t.error.message:`Could not load workflow details.`,refetch:n}:t.data?{kind:`ready`,detail:t.data,refetch:n}:{kind:`loading`}}function jD(){let e=Ky();return{workflows:e.data?.workflows.filter(e=>!e.tags.includes(`routines`)),isLoading:e.isLoading,error:e.error instanceof Error?e.error:null,refetch:e.refetch}}function MD(e,t){if(!e)return{prevWorkflow:null,nextWorkflow:null};let n=t.findIndex(t=>t.id===e);return n===-1?{prevWorkflow:null,nextWorkflow:null}:{prevWorkflow:n>0?t[n-1]??null:null,nextWorkflow:n<t.length-1?t[n+1]??null:null}}function ND({workflowId:e,activeTag:t,onBack:n,onNavigateToWorkflow:r}){let i=AD(e),a=jD().workflows,o=(0,V.useRef)(null),s=(0,V.useRef)(null),c=(0,V.useRef)(r);c.current=r;let l=a??[],{prevWorkflow:u,nextWorkflow:d}=(0,V.useMemo)(()=>MD(e,l),[e,l]),f=u?()=>c.current(u.id):null,p=d?()=>c.current(d.id):null;o.current=f,s.current=p;let m=i.kind===`ready`;return(0,V.useEffect)(()=>{if(!m)return;function e(e){e.metaKey||e.ctrlKey||e.altKey||(e.key===`ArrowLeft`?(e.preventDefault(),o.current?.()):e.key===`ArrowRight`&&(e.preventDefault(),s.current?.()))}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[m]),{state:(0,V.useMemo)(()=>{let r=a?.find(t=>t.id===e)??void 0,o=t?gD[t]??t:null;if(i.kind===`not_found`)return{kind:`not_found`,onBack:n};if(i.kind===`error`)return{kind:`error`,message:i.message,onBack:n,onRetry:i.refetch};if(i.kind===`ready`){let t=i.detail;return{kind:`ready`,workflow:t,name:t.name??r?.name??e??``,description:t.description??r?.description??null,tags:t.tags??r?.tags??[],source:t.source??r?.source??null,activeTagLabel:o,adjacentWorkflows:l,onPrev:f,onNext:p,onBack:n}}return{kind:`loading`,cached:r??null,activeTagLabel:o,onBack:n}},[i,a,e,t,l,f,p,n])}}function PD(e){let t=new Set(hD.map(e=>e.id)),n=new Map,r=[];for(let i of e){let e=i.tags.find(e=>e!==`routines`&&t.has(e));if(e){let t=n.get(e)??[];t.push(i),n.set(e,t)}else r.push(i)}let i=hD.filter(e=>n.has(e.id)).map(e=>({tagId:e.id,label:e.label,workflows:n.get(e.id)}));return r.length>0&&i.push({tagId:null,label:`Other`,workflows:r}),i}function FD({viewModel:e}){let{state:t,dispatch:n,triggerRef:r,onCardSelect:i}=e,a=(0,V.useRef)(null),o=(0,V.useRef)(null),s=mD(),c=t.kind===`ready`?t.selectedWorkflowId:null;if((0,V.useEffect)(()=>{if(c){let e=requestAnimationFrame(()=>a.current?.focus());return()=>cancelAnimationFrame(e)}},[c]),t.kind===`loading`)return(0,H.jsx)(zD,{});if(t.kind===`error`)return(0,H.jsx)(BD,{message:t.message,onRetry:t.onRetry});let{selectedTag:l,selectedSource:u,hintVisible:d,filteredWorkflows:f,flatWorkflows:p,availableSources:m,sourceFilteredWorkflows:h,tagFilteredWorkflows:g}=t,_=new Set(hD.map(e=>e.id)),v=new Set(h.flatMap(e=>e.tags)),y=new Map(hD.map(e=>[e.id,h.filter(t=>t.tags.includes(e.id)).length])),b=h.filter(e=>!e.tags.some(e=>e!==`routines`&&_.has(e))).length,x=h.length,S=g.length;return(0,H.jsx)(ID,{selectedWorkflowId:c,selectedTag:l,selectedSource:u,hintVisible:d,filteredWorkflows:f,flatWorkflows:p,availableSources:m,tagsWithWorkflows:v,countByTag:y,otherCount:b,allTagCount:x,allSourceCount:S,countBySource:new Map(m.map(e=>[e.displayName,g.filter(t=>t.source.displayName===e.displayName).length])),currentIndex:p.findIndex(e=>e.id===c),dispatch:n,onCardSelect:i,triggerRef:r,modalPanelRef:a,scrollRef:o,modalTransition:s})}function ID({selectedWorkflowId:e,selectedTag:t,selectedSource:n,hintVisible:r,filteredWorkflows:i,flatWorkflows:a,availableSources:o,tagsWithWorkflows:s,countByTag:c,otherCount:l,allTagCount:u,allSourceCount:d,countBySource:f,currentIndex:p,dispatch:m,onCardSelect:h,modalPanelRef:g,scrollRef:_,modalTransition:v}){let y=ND({workflowId:e,activeTag:t,onBack:()=>m({type:`modal_closed`}),onNavigateToWorkflow:e=>m({type:`workflow_selected`,id:e})}),b=(0,V.useCallback)((t,n)=>{v.navigate(e,a,t,n,e=>{m({type:`workflow_selected`,id:e}),v.selectedWorkflowIdRef.current=e},_)},[a,e,v,m,_]);(0,V.useEffect)(()=>{if(!e)return;let t=[`ArrowLeft`,`ArrowRight`,`a`,`A`,`d`,`D`],n=[`ArrowUp`,`ArrowDown`,`w`,`W`,`s`,`S`],r=e=>{if(n.includes(e.key)){e.preventDefault(),e.stopPropagation();return}t.includes(e.key)&&(e.preventDefault(),e.stopPropagation(),b([`ArrowLeft`,`a`,`A`].includes(e.key)?`prev`:`next`,`horizontal`))};return document.addEventListener(`keydown`,r,{capture:!0}),()=>{document.removeEventListener(`keydown`,r,{capture:!0})}},[e,b]);let{getItemProps:x,containerProps:S}=kD({count:a.length,cols:`auto`,onActivate:(0,V.useCallback)(e=>{let t=a[e];if(!t)return;let n=document.activeElement;n instanceof HTMLButtonElement&&h(t.id,n)},[a,h])});return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h1`,{className:`font-mono text-2xl font-bold uppercase tracking-[0.12em] leading-none`,style:{color:`var(--accent)`,textShadow:`0 0 28px rgba(244,196,48,0.35)`},children:`Workflows`}),(0,H.jsxs)(`p`,{className:`font-mono text-[10px] tracking-[0.25em] text-[var(--text-muted)] mt-1.5`,children:[`// `,i.length,` available`]})]}),(0,H.jsxs)(`div`,{role:`group`,"aria-label":`Filter workflows by category`,className:`flex flex-wrap gap-1.5`,children:[(0,H.jsx)(LD,{label:`All`,count:u,isActive:t===null,disabled:!1,onClick:()=>m({type:`tag_changed`,tag:null})}),hD.filter(e=>s.has(e.id)).map(e=>(0,H.jsx)(LD,{label:e.label,count:c.get(e.id)??0,isActive:t===e.id,disabled:!1,onClick:()=>m({type:`tag_changed`,tag:t===e.id?null:e.id})},e.id)),l>0&&(0,H.jsx)(LD,{label:`Other`,count:l,isActive:t===`__other__`,disabled:!1,onClick:()=>m({type:`tag_changed`,tag:t===`__other__`?null:`__other__`})})]}),o.length>1&&(0,H.jsxs)(`div`,{role:`group`,"aria-label":`Filter workflows by source`,className:`flex flex-wrap gap-1.5`,children:[(0,H.jsx)(LD,{label:`All Sources`,count:d,isActive:n===null,disabled:!1,onClick:()=>m({type:`source_changed`,source:null})}),o.map(e=>(0,H.jsx)(LD,{label:e.displayName,count:f.get(e.displayName)??0,isActive:n===e.displayName,disabled:!1,onClick:()=>m({type:`source_changed`,source:n===e.displayName?null:e.displayName})},e.id))]}),i.length===0?(0,H.jsxs)(`div`,{className:`py-8 text-center space-y-3`,children:[(0,H.jsx)(`p`,{className:`text-sm text-[var(--text-muted)]`,children:`No workflows in this category.`}),t!==null&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>m({type:`tag_changed`,tag:null}),className:`text-sm text-[var(--accent)] hover:text-[var(--accent-hover)] transition-colors`,children:`Clear filter`})]}):t===null?(0,H.jsx)(`div`,{className:`space-y-6`,children:(()=>{let t=0;return PD(i).map(n=>(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(_D,{label:n.label,count:n.workflows.length,showRule:!0}),(0,H.jsx)(`div`,{...S,className:`grid grid-cols-2 lg:grid-cols-3 gap-3`,children:n.workflows.map(n=>(0,H.jsx)(RD,{workflow:n,onSelect:e=>h(n.id,e),navProps:x(t++),isActive:n.id===e},n.id))})]},n.tagId??`__other__`))})()}):(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(_D,{label:t===`__other__`?`Other`:gD[t]??t,count:i.length,showRule:!0}),(0,H.jsx)(`div`,{...S,className:`grid grid-cols-2 lg:grid-cols-3 gap-3`,children:i.map((t,n)=>(0,H.jsx)(RD,{workflow:t,onSelect:e=>h(t.id,e),navProps:x(n),isActive:t.id===e},t.id))})]}),(0,H.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-end justify-center p-4 pointer-events-none`,"aria-hidden":!e,children:[e&&(0,H.jsx)(`div`,{className:`absolute inset-0 pointer-events-auto`,style:{background:`rgba(0,0,0,0.22)`,backdropFilter:`blur(2px)`},onClick:()=>m({type:`modal_closed`})}),(0,H.jsx)(`div`,{ref:g,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":`Workflow detail${e?`: ${a.find(t=>t.id===e)?.name??``}`:``}`,className:`relative w-full max-w-3xl ${e?`pointer-events-auto`:`pointer-events-none`}${v.state.borderFlashing?` modal-border-flashing`:``}`,style:{height:`85vh`,transform:e?`translateY(0) scale(1)`:`translateY(24px) scale(0.97)`,opacity:+!!e,transition:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`opacity 150ms ease-out`:`transform 250ms ease-out, opacity 250ms ease-out`,backdropFilter:`blur(2px)`,WebkitBackdropFilter:`blur(2px)`},children:(0,H.jsxs)(oo,{cut:20,borderColor:`rgba(244, 196, 48, 0.45)`,background:`rgba(15, 19, 31, 0.50)`,dropShadow:`drop-shadow(0 4px 24px rgba(244,196,48,0.15))`,className:`h-full flex flex-col`,children:[v.state.scanline!==null&&(0,H.jsx)(`div`,{className:`modal-scanline`,"aria-hidden":`true`,style:{"--crt-offset":`${v.state.scanline.crtOffset}px`,"--glitch-y":`${v.state.scanline.glitchY}%`,"--glitch-y2":`${v.state.scanline.glitchY2}%`,"--glitch-w":`${v.state.scanline.glitchW}px`,"--glitch-w2":`${v.state.scanline.glitchW2}px`,clipPath:ao(20)}},v.state.scanline.key),(0,H.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-[var(--border)] shrink-0 console-blueprint-grid`,style:{background:`rgba(15, 19, 31, 0.55)`},children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,H.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-secondary)]`,children:`Workflow`}),p>=0&&(0,H.jsxs)(`span`,{className:`font-mono text-[10px] tracking-[0.20em] text-[var(--text-secondary)]`,children:[`[ `,p+1,` / `,a.length,` ]`]}),(0,H.jsx)(`span`,{className:`font-mono text-[9px] tracking-[0.15em] text-[var(--text-secondary)] transition-opacity duration-600`,style:{opacity:r?.5:0},"aria-hidden":`true`,children:`[ A / D ] NAV`})]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>m({type:`modal_closed`}),className:`text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors text-xl leading-none`,"aria-label":`Close`,children:`×`})]}),(0,H.jsxs)(`div`,{ref:_,className:`flex-1 overflow-auto overscroll-contain px-6 py-5 ${v.state.contentAnimClass}`,style:{"--text-muted":`var(--text-secondary)`},children:[(0,H.jsx)(`div`,{"aria-live":`polite`,"aria-atomic":`true`,className:`sr-only`,children:a.find(t=>t.id===e)?.name??``}),e&&(0,H.jsx)(yD,{viewModel:y})]})]})})]})]})}function LD({label:e,count:t,isActive:n,disabled:r,onClick:i}){return(0,H.jsxs)(`button`,{type:`button`,onClick:i,disabled:r,"aria-pressed":n,className:[`px-3 py-2 min-w-[44px] min-h-[44px] rounded-none text-xs font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--accent)] focus-visible:ring-offset-2`,`disabled:opacity-50 disabled:cursor-not-allowed`,n?`border border-[var(--accent)] text-[var(--accent)] bg-transparent`:`text-[var(--text-muted)] hover:text-[var(--text-secondary)] hover:bg-[var(--bg-card)]`].join(` `),children:[e,` · `,t,n&&(0,H.jsx)(`span`,{className:`sr-only`,children:`(selected)`})]})}function RD({workflow:e,onSelect:t,navProps:n,isActive:r}){let i=e.tags.filter(e=>e!==`routines`).map(e=>gD[e]??e);return(0,H.jsx)(so,{variant:`grid`,onClick:e=>t(e.currentTarget),"aria-label":[e.name,e.description,i.length>0?`Tag: ${i.join(`, `)}`:null,`Source: ${e.source.displayName}`].filter(Boolean).join(`. `),style:r?{borderColor:`var(--accent)`,boxShadow:`0 0 0 1px rgba(244,196,48,0.4), 0 0 16px rgba(244,196,48,0.12)`}:void 0,...n,children:(0,H.jsxs)(`div`,{className:`flex flex-col flex-1 p-4 gap-2 min-w-0`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-[var(--text-primary)] group-hover:text-[var(--accent)] transition-colors leading-snug line-clamp-2`,children:e.name}),(0,H.jsx)(`p`,{className:`text-xs text-[var(--text-secondary)] line-clamp-3 leading-relaxed flex-1`,children:e.description}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mt-auto pt-2 border-t border-[var(--border)]`,children:[(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:i.slice(0,1).map(e=>(0,H.jsx)(`span`,{className:`font-mono text-[9px] px-1.5 py-0.5 bg-[var(--bg-secondary)] text-[var(--text-muted)]`,children:e},e))}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e.stepCount!=null&&e.stepCount>0&&(0,H.jsxs)(`span`,{className:`font-mono text-[9px] text-[var(--text-muted)]`,children:[e.stepCount,`s`]}),(0,H.jsxs)(`span`,{className:`font-mono text-[9px] text-[var(--text-muted)] max-w-[80px] truncate`,children:[`src: `,e.source.displayName]})]})]})]})})}function zD(){return(0,H.jsx)(`div`,{className:`space-y-6 motion-safe:animate-pulse`,children:[0,1].map(e=>(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(`div`,{className:`h-3 w-24 bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`flex-1 h-px bg-[var(--bg-tertiary)]`})]}),(0,H.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-3 gap-3`,children:[0,1,2,3,4,5].map(e=>(0,H.jsxs)(`div`,{className:`min-h-[160px] bg-[var(--bg-card)] border border-[var(--border)] flex flex-col`,children:[(0,H.jsx)(`div`,{className:`h-[3px] bg-[var(--bg-tertiary)]`}),(0,H.jsxs)(`div`,{className:`p-4 flex flex-col gap-2 flex-1`,children:[(0,H.jsx)(`div`,{className:`h-4 w-3/4 bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`h-3 w-full bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`h-3 w-5/6 bg-[var(--bg-tertiary)]`}),(0,H.jsxs)(`div`,{className:`mt-auto pt-2 border-t border-[var(--border)] flex justify-between`,children:[(0,H.jsx)(`div`,{className:`h-3 w-12 bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`h-3 w-16 bg-[var(--bg-tertiary)]`})]})]})]},e))})]},e))})}function BD({message:e,onRetry:t}){return(0,H.jsxs)(`div`,{className:`space-y-3 py-8 text-center`,children:[(0,H.jsx)(`p`,{className:`text-sm text-[var(--error)]`,children:e}),(0,H.jsx)(`button`,{type:`button`,onClick:t,className:`text-sm text-[var(--accent)] hover:text-[var(--accent-hover)] transition-colors`,children:`Try again`})]})}var VD=[{value:`recent`,label:`Recent first`,compareFn:(e,t)=>t.startedAtMs-e.startedAtMs},{value:`slowest`,label:`Slowest first`,compareFn:(e,t)=>t.durationMs-e.durationMs}],HD={success:{color:`var(--success)`,label:`OK`,isError:!1},error:{color:`var(--error)`,label:`Error`,isError:!0},unknown_tool:{color:`var(--warning)`,label:`Unknown`,isError:!0}};function UD(e,t){let n=VD.find(e=>e.value===t);return[...e].sort(n.compareFn)}function WD(e){return e.reduce((e,t)=>Math.max(e,t.durationMs),0)}function GD(e){return e.filter(e=>HD[e.outcome].isError).length}function KD(e){return e.length===0?null:Math.round(e.reduce((e,t)=>e+t.durationMs,0)/e.length)}function qD(e){return e.length===0?null:e.reduce((e,t)=>Math.max(e,t.startedAtMs),0)}function JD(e,t){return t>0?Math.round(e/t*120):0}function YD(e){return`${e} recorded`}var XD=[{key:`tool`,label:`Tool`,minWidth:`180px`},{key:`duration`,label:`Duration`,width:`220px`},{key:`started`,label:`Started`,width:`100px`},{key:`outcome`,label:`Outcome`}];function ZD({viewModel:e}){let{state:t}=e;if(t.kind===`loading`)return(0,H.jsx)(tO,{});if(t.kind===`devModeOff`)return(0,H.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,H.jsx)(`p`,{className:`text-sm text-[var(--text-muted)] text-center`,children:`nothing to see here`})});if(t.kind===`error`)return(0,H.jsxs)(`div`,{className:`space-y-3 py-8 text-center`,children:[(0,H.jsx)(`p`,{className:`text-sm text-[var(--error)]`,children:t.message}),(0,H.jsx)(`button`,{type:`button`,onClick:t.retry,className:`text-sm text-[var(--accent)] hover:text-[var(--accent-hover)] transition-colors`,children:`Try again`})]});let{sorted:n,maxDuration:r,errorCount:i,avgMs:a,lastCallMs:o,countLabel:s,sortOrder:c,onSortChange:l}=t;return(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsxs)(`p`,{className:`text-sm text-[var(--text-secondary)]`,children:[s,` | `,(0,H.jsxs)(`span`,{style:{color:i>0?`var(--error)`:`var(--text-muted)`},children:[i,` errors`]}),` | `,`avg `,a===null?`--`:`${a}ms`,` | `,`last call `,o===null?`no calls yet`:W(o)]}),(0,H.jsx)(`div`,{role:`radiogroup`,"aria-label":`Sort order`,className:`flex items-center gap-1`,children:VD.map(e=>(0,H.jsx)(eO,{label:e.label,isActive:c===e.value,onClick:()=>l(e.value)},e.value))}),(0,H.jsxs)(`table`,{className:`w-full text-sm border-collapse`,children:[(0,H.jsx)(`thead`,{children:(0,H.jsx)(`tr`,{className:`text-xs text-[var(--text-muted)] border-b border-[var(--border)]`,children:XD.map(e=>(0,H.jsx)(`th`,{scope:`col`,className:`text-left py-2 pr-4 font-medium`,style:{width:e.width,minWidth:e.minWidth},children:e.label},e.key))})}),(0,H.jsx)(`tbody`,{children:n.length===0?(0,H.jsx)(`tr`,{children:(0,H.jsx)(`td`,{colSpan:XD.length,className:`py-8 text-center text-sm text-[var(--text-muted)]`,children:`No tool calls recorded yet. Run a workflow to see timing data.`})}):n.map((e,t)=>(0,H.jsx)(QD,{obs:e,maxDuration:r},`${e.startedAtMs}-${e.toolName}-${t}`))})]})]})}function QD({obs:e,maxDuration:t}){let n=HD[e.outcome].isError,r=JD(e.durationMs,t);return(0,H.jsxs)(`tr`,{className:`border-b border-[var(--border)] hover:bg-[var(--bg-card)] transition-colors`,style:{borderLeft:n?`2px solid var(--error)`:`2px solid transparent`},children:[(0,H.jsx)(`td`,{className:`py-2 pr-4 font-mono text-[var(--text-primary)] overflow-hidden text-ellipsis`,title:e.toolName,style:{minWidth:`180px`,maxWidth:`240px`},children:(0,H.jsx)(`span`,{className:`block truncate`,children:e.toolName})}),(0,H.jsxs)(`td`,{className:`py-2 pr-4`,style:{width:`220px`},children:[(0,H.jsxs)(`span`,{className:`font-mono text-[var(--text-primary)]`,children:[e.durationMs,`ms`]}),(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`h-1 rounded mt-1`,style:{backgroundColor:`var(--accent)`,width:`${r}px`,maxWidth:`120px`}})]}),(0,H.jsx)(`td`,{className:`py-2 pr-4 text-[var(--text-secondary)]`,style:{width:`100px`},children:W(e.startedAtMs)}),(0,H.jsx)(`td`,{className:`py-2`,children:(0,H.jsx)($D,{outcome:e.outcome})})]})}function $D({outcome:e}){let t=HD[e];return(0,H.jsx)(`span`,{className:`inline-block px-2 py-0.5 rounded text-xs font-medium`,style:{color:t.color,backgroundColor:`color-mix(in srgb, ${t.color} 12%, transparent)`},children:t.label})}function eO({label:e,isActive:t,onClick:n}){return(0,H.jsx)(`button`,{type:`button`,role:`radio`,onClick:n,"aria-checked":t,className:[`px-3 py-2 rounded text-xs font-medium min-w-[44px] transition-colors`,t?`text-[var(--text-primary)]`:`text-[var(--text-muted)] hover:text-[var(--text-secondary)]`].join(` `),children:e})}function tO(){return(0,H.jsxs)(`div`,{className:`space-y-3 animate-pulse`,"aria-busy":`true`,"aria-label":`Loading performance data`,children:[(0,H.jsx)(`div`,{className:`h-4 w-64 rounded bg-[var(--bg-tertiary)]`}),(0,H.jsxs)(`div`,{className:`flex gap-1`,children:[(0,H.jsx)(`div`,{className:`h-8 w-24 rounded bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`h-8 w-24 rounded bg-[var(--bg-tertiary)]`})]}),(0,H.jsxs)(`div`,{className:`flex gap-4 border-b border-[var(--border)] pb-2`,children:[(0,H.jsx)(`div`,{className:`h-3 w-20 rounded bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`h-3 w-16 rounded bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`h-3 w-14 rounded bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`h-3 w-14 rounded bg-[var(--bg-tertiary)]`})]}),Array.from({length:8}).map((e,t)=>(0,H.jsxs)(`div`,{className:`flex gap-4 py-2`,children:[(0,H.jsx)(`div`,{className:`h-4 rounded bg-[var(--bg-tertiary)]`,style:{minWidth:`180px`,width:`180px`}}),(0,H.jsxs)(`div`,{className:`space-y-1`,style:{width:`220px`},children:[(0,H.jsx)(`div`,{className:`h-4 w-16 rounded bg-[var(--bg-tertiary)]`}),(0,H.jsx)(`div`,{className:`h-1 w-20 rounded bg-[var(--bg-tertiary)]`})]}),(0,H.jsx)(`div`,{className:`h-4 w-16 rounded bg-[var(--bg-tertiary)]`,style:{width:`100px`}}),(0,H.jsx)(`div`,{className:`h-5 w-12 rounded bg-[var(--bg-tertiary)]`})]},t))]})}var nO=`workrail:auto:mru-workflow`;function rO(){try{return localStorage.getItem(nO)}catch{return null}}function iO(e){try{localStorage.setItem(nO,e)}catch{}}function aO(){let e=Ky(),t=Yy(),n=e.data?.workflows??[],r=t.data?.triggers??[],[i,a]=(0,V.useState)(()=>rO()??``),[o,s]=(0,V.useState)(``),[c,l]=(0,V.useState)(``),[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)(null),[m,h]=(0,V.useState)(!1),[g,_]=(0,V.useState)(!0),v=(0,V.useRef)(null);(0,V.useEffect)(()=>{!i&&n.length>0&&a(n[0]?.id??``)},[i,n]);let y=e=>{a(e),iO(e)},b=async()=>{if(!(!i||!c.trim()||!o.trim())){d(!0),p(null),h(!1);try{await Xy({workflowId:i,goal:c.trim(),workspacePath:o.trim()}),h(!0),l(``),setTimeout(()=>v.current?.focus(),100)}catch(e){p(e instanceof Error?e.message:`Dispatch failed`)}finally{d(!1)}}},x=!!i&&!!c.trim()&&!!o.trim()&&!u;return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,H.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,H.jsx)(Uo,{color:`var(--accent)`,children:`Dispatch`})}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(Uo,{children:`Workflow`}),e.isLoading?(0,H.jsx)(`div`,{className:`text-[var(--text-muted)] text-xs`,children:`Loading workflows...`}):n.length===0?(0,H.jsx)(`div`,{className:`text-[var(--text-muted)] text-xs`,children:`No workflows available`}):(0,H.jsx)(`select`,{value:i,onChange:e=>y(e.target.value),className:`w-full bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent)] cursor-pointer`,children:n.map(e=>(0,H.jsx)(`option`,{value:e.id,children:e.name??e.id},e.id))})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(Uo,{children:`Workspace path`}),(0,H.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:`/path/to/repo`,className:`w-full bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm font-mono text-[var(--text-primary)] placeholder-[var(--text-muted)] focus:outline-none focus:border-[var(--accent)]`})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,H.jsx)(Uo,{children:`Goal`}),(0,H.jsx)(`textarea`,{ref:v,value:c,onChange:e=>l(e.target.value),placeholder:`// describe the task...`,rows:4,className:`w-full bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm font-mono text-[var(--text-primary)] placeholder-[var(--text-muted)] focus:outline-none focus:border-[var(--accent)] resize-y`,onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&e.key===`Enter`&&x&&(e.preventDefault(),b())}})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(`button`,{onClick:()=>void b(),disabled:!x,className:`self-start disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer`,children:(0,H.jsx)($a,{label:u?`RUNNING...`:`RUN`,color:x?`var(--accent)`:void 0,pulse:u})}),m&&(0,H.jsx)(`div`,{className:`text-[var(--success)] font-mono text-[10px] uppercase tracking-[0.20em]`,children:`Dispatched -- check Queue pane`}),f&&(0,H.jsx)(`div`,{className:`text-[var(--error)] text-xs font-mono`,children:f})]}),(0,H.jsxs)(`div`,{className:`border-t border-[var(--border)] pt-4`,children:[(0,H.jsxs)(`button`,{onClick:()=>_(!g),className:`flex items-center gap-2 mb-2 cursor-pointer group`,children:[(0,H.jsx)(`span`,{className:`text-[var(--text-muted)] text-xs transition-transform duration-150`,style:{transform:g?`rotate(-90deg)`:`rotate(0deg)`},children:`▼`}),(0,H.jsx)($a,{label:`TRIGGERS`,color:`var(--text-secondary)`}),r.length>0&&(0,H.jsxs)(`span`,{className:`text-xs text-[var(--text-muted)]`,children:[`(`,r.length,`)`]})]}),!g&&(0,H.jsx)(`div`,{className:`space-y-2`,children:t.isLoading?(0,H.jsx)(`div`,{className:`text-[var(--text-muted)] text-xs pl-4`,children:`Loading triggers...`}):r.length===0?(0,H.jsx)(`div`,{className:`text-[var(--text-muted)] text-xs pl-4`,children:`No triggers configured. Set WORKRAIL_TRIGGERS_ENABLED=true and create triggers.yml.`}):r.map(e=>(0,H.jsxs)(`div`,{className:`pl-4 border-l-2 border-[var(--border)] text-xs space-y-0.5`,children:[(0,H.jsx)(`div`,{className:`font-mono text-[var(--text-primary)] text-[11px]`,children:e.id}),(0,H.jsx)(`div`,{className:`text-[var(--text-muted)]`,children:e.workflowId}),(0,H.jsx)(`div`,{className:`text-[var(--text-muted)] truncate`,children:e.goal})]},e.id))})]})]})}function oO(e){let t=0,n=0,r=0;for(let i of e)i.status===`in_progress`?t++:i.status===`blocked`?n++:(i.status===`complete`||i.status===`complete_with_gaps`)&&r++;return{running:t,blocked:n,completed:r}}function sO(){let{data:e,isLoading:t,isError:n}=Hy(),r=(e?.sessions??[]).filter(e=>e.isAutonomous),{running:i,blocked:a,completed:o}=oO(r);return t?(0,H.jsx)(`div`,{className:`flex items-center justify-center py-20`,children:(0,H.jsx)(`div`,{className:`text-[var(--text-secondary)] text-sm`,children:`Loading sessions...`})}):n?(0,H.jsx)(`div`,{className:`text-[var(--error)] bg-[var(--bg-card)] rounded-lg p-4 text-sm`,children:`Failed to load sessions`}):(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,H.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,H.jsx)(Uo,{color:`var(--accent)`,children:`Queue`})}),(0,H.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,H.jsx)(cO,{count:i,label:`RUNNING`,color:`var(--accent)`,pulse:!0}),(0,H.jsx)(cO,{count:a,label:`BLOCKED`,color:`var(--blocked)`}),(0,H.jsx)(cO,{count:o,label:`COMPLETED`,color:`var(--success)`})]}),r.length===0?(0,H.jsxs)(`div`,{className:`text-center py-16`,children:[(0,H.jsx)(`p`,{className:`text-[var(--text-secondary)] text-sm`,children:`No autonomous sessions yet`}),(0,H.jsx)(`p`,{className:`text-[var(--text-muted)] text-xs mt-1`,children:`Dispatch a workflow from the left pane to start.`})]}):(0,H.jsx)(`div`,{className:`space-y-2`,children:r.map(e=>(0,H.jsx)(lO,{session:e},e.sessionId))})]})}function cO({count:e,label:t,color:n,pulse:r}){return(0,H.jsx)($a,{label:`${e} ${t}`,color:e>0?n:`var(--text-muted)`,pulse:r&&e>0})}function lO({session:e}){let[t,n]=(0,V.useState)(!1),r=xi(),i=e.sessionTitle??e.workflowName??e.workflowId??`Unnamed session`,a=W(e.lastModifiedMs);return(0,H.jsxs)(`div`,{className:`bg-[var(--bg-card)] border border-[var(--border)] rounded-lg overflow-hidden`,children:[(0,H.jsxs)(`button`,{onClick:()=>n(!t),className:`w-full px-4 py-3 flex items-center gap-3 text-left cursor-pointer hover:bg-[var(--bg-secondary)] transition-colors group`,children:[(0,H.jsx)(`span`,{className:`text-[var(--text-muted)] text-xs transition-transform duration-150 shrink-0`,style:{transform:t?`rotate(90deg)`:`rotate(0deg)`},children:`▶`}),(0,H.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-[var(--text-primary)] truncate group-hover:text-[var(--accent)] transition-colors`,children:i}),(0,H.jsx)(`div`,{className:`font-mono text-[10px] text-[var(--text-muted)] opacity-60 truncate`,children:e.sessionId})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,H.jsx)(`span`,{className:`text-[10px] text-[var(--text-muted)] tabular-nums`,children:a}),e.isLive&&(0,H.jsx)($a,{label:`LIVE`,pulse:!0,color:`var(--accent)`,"aria-label":`Actively running`}),(0,H.jsx)(to,{status:e.status})]})]}),t&&(0,H.jsxs)(`div`,{className:`px-4 pb-4 border-t border-[var(--border)] pt-3 space-y-3`,children:[e.recapSnippet?(0,H.jsx)(`div`,{className:`text-xs text-[var(--text-secondary)] font-mono whitespace-pre-wrap leading-relaxed`,children:e.recapSnippet}):(0,H.jsx)(`div`,{className:`text-xs text-[var(--text-muted)]`,children:`No recap available yet.`}),(0,H.jsx)(`button`,{onClick:()=>void r({to:`/session/$sessionId`,params:{sessionId:e.sessionId}}),className:`cursor-pointer`,children:(0,H.jsx)($a,{label:`OPEN IN DAG`,color:`var(--accent)`})})]})]})}function uO(){return(0,H.jsxs)(`div`,{className:`flex flex-col md:flex-row gap-6`,children:[(0,H.jsx)(`div`,{className:`w-full md:w-2/5 shrink-0`,children:(0,H.jsx)(aO,{})}),(0,H.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,H.jsx)(sO,{})})]})}function dO(){let e=Hy(),t=Gy();Zy();let n=e.data?.sessions;return{sessions:n,worktreeRepos:t.data?.repos??[],isLoading:e.isLoading,error:e.error instanceof Error?e.error:null,refetch:e.refetch,worktreesFetching:t.isFetching,liveCount:n?.filter(e=>e.status===`in_progress`).length??0,blockedCount:n?.filter(e=>e.status===`blocked`).length??0}}var fO={scope:`active`,focusedIndex:-1,archive:null};function pO(e){throw Error(`Unhandled WorkspaceEvent type: ${String(e.type)}`)}function mO(e,t){switch(t.type){case`scope_changed`:return{...e,scope:t.scope,focusedIndex:-1};case`focus_moved`:return{...e,focusedIndex:t.index};case`archive_opened`:return{...e,archive:{repoName:t.repoName}};case`archive_closed`:return{...e,archive:null};default:return pO(t)}}var hO=720*60*60*1e3,gO={in_progress:0,dormant:0,blocked:1,complete_with_gaps:2,complete:3};function _O(e){if(e.length!==0)return[...e].sort((e,t)=>{let n=gO[e.status]-gO[t.status];return n===0?t.lastModifiedMs-e.lastModifiedMs:n})[0]}function vO(e,t,n){let r=e.primarySession?.status;if(r===`in_progress`||r===`blocked`)return`visible`;let i=(e.worktree?.changedCount??0)>0,a=(e.worktree?.aheadCount??0)>0;return i||a?`visible`:r===`dormant`?t===`all`?`visible`:`hidden`:n-e.activityMs<hO||t===`all`?`visible`:`hidden`}function yO(e){switch(e.primarySession?.status){case`in_progress`:return 0;case`blocked`:return 1;case`dormant`:return 2;default:return(e.worktree?.changedCount??0)>0||(e.worktree?.aheadCount??0)>0?3:4}}function bO(e,t,n){return[...e].filter(e=>vO(e,t,n)===`visible`).sort((e,t)=>{let n=yO(e)-yO(t);return n===0?t.activityMs-e.activityMs:n})}function xO(e,t){let n=new Map;for(let e of t)for(let t of e.worktrees)t.branch!==null&&n.set(`${t.branch}\0${e.repoRoot}`,{wt:t,repoName:e.repoName,repoRoot:e.repoRoot});let r=new Map;for(let[e,t]of n){let[n]=e.split(`\0`),i=r.get(n)??[];i.push(t),r.set(n,i)}let i=new Map;for(let t of e){if(t.gitBranch===null)continue;let e=r.get(t.gitBranch)??[];if(e.length===0){if(!t.repoRoot)continue;let e=`${t.gitBranch}\0${t.repoRoot}`,r=i.get(e);if(r?r.push(t):i.set(e,[t]),!n.has(e)){let r=t.repoRoot.split(`/`).at(-1)??t.repoRoot;n.set(e,{wt:void 0,repoName:r,repoRoot:t.repoRoot})}continue}let a=e;if(t.repoRoot!==null){let n=e.filter(e=>e.repoRoot===t.repoRoot);n.length>0&&(a=n)}for(let e of a){let n=`${t.gitBranch}\0${e.repoRoot}`,r=i.get(n);r?r.push(t):i.set(n,[t])}}let a=[],o=new Set;for(let[e,t]of i){let[r,i]=e.split(`\0`),s=n.get(e),c=_O(t),l=Math.max(c?.lastModifiedMs??0,s?.wt?.headTimestampMs??0),u=s?.repoName??i.split(`/`).at(-1)??i;a.push({branch:r,repoRoot:i,repoName:u,worktree:s?.wt,primarySession:c,allSessions:t,activityMs:l}),o.add(e)}for(let[e,{wt:t,repoName:r,repoRoot:i}]of n){if(o.has(e))continue;let[n]=e.split(`\0`);a.push({branch:n,repoRoot:i,repoName:r,worktree:t,primarySession:void 0,allSessions:[],activityMs:t?.headTimestampMs??0})}return a}function SO(e,t,n,r){let i=xO(e,t),a=new Map;for(let e of i)a.has(e.repoRoot)||a.set(e.repoRoot,e.repoName);let o=new Map;for(let e of i){let t=o.get(e.repoRoot)??[];t.push(e),o.set(e.repoRoot,t)}let s=[...o.entries()].map(([e,t])=>({repoRoot:e,repoName:t[0].repoName,sortedItems:bO(t,n,r)})).filter(e=>e.sortedItems.length>0).sort((e,t)=>{let n=+!e.sortedItems.some(e=>e.primarySession?.status===`in_progress`||e.primarySession?.status===`blocked`),r=+!t.sortedItems.some(e=>e.primarySession?.status===`in_progress`||e.primarySession?.status===`blocked`);return n===r?e.repoName.localeCompare(t.repoName):n-r}),c=s.flatMap(e=>e.sortedItems),l=n===`active`?i.filter(e=>e.primarySession?.status===`dormant`&&(e.worktree?.changedCount??0)===0&&(e.worktree?.aheadCount??0)===0).length:0;return{repoGroups:s,orderedItems:c,archiveRepos:[...a.entries()].map(([e,t])=>[e,t]),dormantHiddenCount:l}}function CO({items:e,focusedIndex:t,scope:n,archive:r,dispatch:i,onSelectSession:a,onRefetch:o,disabled:s}){let c=(0,V.useRef)(e);c.current=e;let l=(0,V.useRef)(t);l.current=t;let u=(0,V.useRef)(n);u.current=n;let d=(0,V.useRef)(r);d.current=r;let f=(0,V.useRef)(s);f.current=s;let p=(0,V.useRef)(i);p.current=i;let m=(0,V.useRef)(a);m.current=a;let h=(0,V.useRef)(o);h.current=o,(0,V.useEffect)(()=>{function e(e){if(f.current||e.metaKey||e.ctrlKey||e.altKey)return;let t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)return;let n=c.current,r=l.current;switch(e.key){case`j`:case`ArrowDown`:e.preventDefault(),p.current({type:`focus_moved`,index:Math.min(r+1,n.length-1)});break;case`k`:case`ArrowUp`:e.preventDefault(),p.current({type:`focus_moved`,index:Math.max(r-1,0)});break;case`Enter`:case` `:if(e.preventDefault(),r>=0&&r<n.length){let e=n[r]?.primarySession?.sessionId;e&&m.current(e)}break;case`Escape`:d.current!==null&&p.current({type:`archive_closed`});break;case`/`:e.preventDefault(),p.current({type:`archive_opened`,repoName:void 0});break;case`r`:e.preventDefault(),h.current();break;case`a`:e.preventDefault(),p.current({type:`scope_changed`,scope:u.current===`active`?`all`:`active`});break}}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[])}function wO(e=!1){let t=xi(),n=dO(),[r,i]=(0,V.useReducer)(mO,fO),a=(0,V.useRef)(0),o=(0,V.useCallback)(e=>{a.current=window.scrollY,t({to:`/session/$sessionId`,params:{sessionId:e}})},[t]),s=i,c=(0,V.useMemo)(()=>n.sessions?SO(n.sessions,n.worktreeRepos,r.scope,Date.now()):null,[n.sessions,n.worktreeRepos,r.scope]);CO({items:c?.orderedItems??[],focusedIndex:r.focusedIndex,scope:r.scope,archive:r.archive,dispatch:s,onSelectSession:o,onRefetch:n.refetch,disabled:e});let{isLoading:l,error:u,worktreesFetching:d,sessions:f,liveCount:p,blockedCount:m}=n;return{state:(0,V.useMemo)(()=>l?{kind:`loading`}:u?{kind:`error`,message:u.message}:c?{kind:`ready`,scope:r.scope,focusedIndex:r.focusedIndex,archive:r.archive,repoGroups:c.repoGroups,orderedItems:c.orderedItems,archiveRepos:c.archiveRepos,dormantHiddenCount:c.dormantHiddenCount,worktreesFetching:d,hasAnySessions:(f?.length??0)>0,liveCount:p,blockedCount:m}:{kind:`loading`},[l,u,d,f,c,r,p,m]),dispatch:s,scrollYRef:a,onSelectSession:o}}function TO(){let e=Hy();return{sessions:e.data?.sessions,isLoading:e.isLoading,error:e.error instanceof Error?e.error:null}}function EO(e=``){return{rawSearch:e,sort:`recent`,groupBy:`none`,statusFilter:`all`,page:0,viewMode:`flat`}}function DO(e){throw Error(`Unhandled SessionListEvent type: ${String(e.type)}`)}function OO(e,t){switch(t.type){case`search_changed`:return{...e,rawSearch:t.value,page:0};case`sort_changed`:return{...e,sort:t.sort,page:0};case`group_changed`:return{...e,groupBy:t.groupBy,page:0};case`status_changed`:return{...e,statusFilter:t.statusFilter,page:0};case`page_changed`:return{...e,page:t.page};case`view_mode_changed`:return t.viewMode===`tree`?{...e,viewMode:`tree`,rawSearch:``,statusFilter:`all`,page:0}:{...e,viewMode:`flat`,page:0};default:return DO(t)}}var kO={in_progress:0,blocked:1,dormant:2,complete_with_gaps:3,complete:4},AO=[{value:`recent`,label:`Recent`,compareFn:(e,t)=>t.lastModifiedMs-e.lastModifiedMs},{value:`status`,label:`Status`,compareFn:(e,t)=>kO[e.status]-kO[t.status]||t.lastModifiedMs-e.lastModifiedMs},{value:`workflow`,label:`Workflow`,compareFn:(e,t)=>(e.workflowName??e.workflowId??``).localeCompare(t.workflowName??t.workflowId??``)||t.lastModifiedMs-e.lastModifiedMs},{value:`nodes`,label:`Node count`,compareFn:(e,t)=>t.nodeCount-e.nodeCount||t.lastModifiedMs-e.lastModifiedMs}],jO=[{value:`none`,label:`No grouping`,keyFn:null},{value:`workflow`,label:`Workflow`,keyFn:e=>e.workflowName??e.workflowId??`Unknown workflow`},{value:`status`,label:`Status`,keyFn:e=>e.status,groupCompareFn:(e,t)=>(kO[e]??99)-(kO[t]??99)},{value:`branch`,label:`Branch`,keyFn:e=>e.gitBranch??`No branch`}],MO=[{value:`all`,label:`All`},{value:`in_progress`,label:`In Progress`},{value:`dormant`,label:`Dormant`},{value:`complete`,label:`Complete`},{value:`complete_with_gaps`,label:`Gaps`},{value:`blocked`,label:`Blocked`}];function NO(e,t,n){let r=e;if(n!==`all`&&(r=r.filter(e=>e.status===n)),t.trim()){let e=t.toLowerCase();r=r.filter(t=>(t.sessionTitle??``).toLowerCase().includes(e)||(t.workflowName??``).toLowerCase().includes(e)||(t.workflowId??``).toLowerCase().includes(e)||t.sessionId.toLowerCase().includes(e)||(t.gitBranch??``).toLowerCase().includes(e))}return r}function PO(e,t){let n=AO.find(e=>e.value===t)??AO[0];return[...e].sort(n.compareFn)}function FO(e,t){let n=jO.find(e=>e.value===t)??jO[0];if(!n.keyFn)return[{label:``,sessions:e}];let r=new Map;for(let t of e){let e=n.keyFn(t),i=r.get(e)??[];i.push(t),r.set(e,i)}let i=n.groupCompareFn??((e,t)=>e.localeCompare(t));return Array.from(r.entries()).sort(([e],[t])=>i(e,t)).map(([e,t])=>({label:e,sessions:t}))}function IO(e){let t={all:e.length};for(let n of e)t[n.status]=(t[n.status]??0)+1;return t}function LO(e){let t=new Set(e.map(e=>e.sessionId)),n=new Map,r=new Set,i=new Set;for(let a of e){let e=a.parentSessionId;if(!e||e===a.sessionId)continue;if(!t.has(e)){r.add(a.sessionId);continue}i.add(a.sessionId);let o=n.get(e)??[];o.push(a),n.set(e,o)}let a=[];for(let t of e)i.has(t.sessionId)||a.push({session:t,children:n.get(t.sessionId)??[]});return{roots:a,orphanChildIds:r}}function RO(e,t){let[n,r]=(0,V.useState)(e),i=(0,V.useRef)(null);return(0,V.useEffect)(()=>(i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>r(e),t),()=>{i.current!==null&&clearTimeout(i.current)}),[e,t]),n}function zO({onSelectSession:e,initialSearch:t=``}){let n=TO(),[r,i]=(0,V.useReducer)(OO,void 0,()=>EO(t)),a=RO(r.rawSearch,200),o=(0,V.useRef)([]),s=(0,V.useCallback)(t=>{let n=o.current[t];n&&e(n.sessionId)},[e]),{sessions:c,isLoading:l,error:u}=n,d=(0,V.useMemo)(()=>c?IO(c):{},[c]),f=(0,V.useMemo)(()=>{if(!c)return null;let e=NO(c,a,r.statusFilter);return{groups:FO(PO(e,r.sort),r.groupBy),total:c.length,filtered:e.length}},[c,a,r.statusFilter,r.sort,r.groupBy]),p=(0,V.useMemo)(()=>LO(c||[]),[c]),m=r.groupBy!==`none`,h=f?Math.ceil(f.filtered/25):0,g=r.page*25,_=g+25,v=(0,V.useMemo)(()=>!f||m?[]:f.groups[0]?.sessions.slice(g,_)??[],[f,m,g,_]);o.current=v;let{getItemProps:y,containerProps:b}=kD({count:v.length,cols:1,onActivate:s});return{state:(0,V.useMemo)(()=>l?{kind:`loading`}:u?{kind:`error`,message:u.message}:f?{kind:`ready`,rawSearch:r.rawSearch,sort:r.sort,groupBy:r.groupBy,statusFilter:r.statusFilter,page:r.page,totalPages:h,isGrouped:m,processed:f,statusCounts:d,flatPageSessions:v,getSessionNavProps:y,sessionContainerProps:b,sortAxes:AO,groupAxes:jO,statusFilterOptions:MO,viewMode:r.viewMode,sessionTree:p}:{kind:`loading`},[l,u,f,r,h,m,d,v,y,b,p]),dispatch:i,onSelectSession:e}}var BO={selectedWorkflowId:null,selectedTag:null,selectedSource:null,hintVisible:!1};function VO(e){throw Error(`Unhandled WorkflowsEvent type: ${String(e.type)}`)}function HO(e,t){switch(t.type){case`workflow_selected`:return{...e,selectedWorkflowId:t.id,hintVisible:t.id!==null};case`tag_changed`:return{...e,selectedTag:t.tag,selectedWorkflowId:null,hintVisible:!1};case`source_changed`:return{...e,selectedSource:t.source,selectedWorkflowId:null,hintVisible:!1};case`modal_closed`:return{...e,selectedWorkflowId:null,hintVisible:!1};case`hint_dismissed`:return{...e,hintVisible:!1};default:return VO(t)}}function UO(e){let t=new Set;for(let n of e)for(let e of n.tags)e!==`routines`&&t.add(e);let n=hD.map(e=>e.id).filter(e=>t.has(e)),r=[...t].filter(e=>!hD.some(t=>t.id===e)).sort();return[...n,...r]}function WO(e){let t=new Map;for(let n of e)t.has(n.source.kind)||t.set(n.source.kind,{id:n.source.kind,displayName:n.source.displayName});return[...t.values()]}function GO(e,t,n){let r=new Set(hD.map(e=>e.id)),i=e;return t!==null&&(i=t===`__other__`?i.filter(e=>!e.tags.some(e=>e!==`routines`&&r.has(e))):i.filter(e=>e.tags.includes(t))),n!==null&&(i=i.filter(e=>e.source.displayName===n)),i}function KO(e,t){if(t!==null)return e;let n=new Set(hD.map(e=>e.id)),r=new Map,i=[];for(let t of e){let e=t.tags.find(e=>e!==`routines`&&n.has(e));if(e){let n=r.get(e)??[];n.push(t),r.set(e,n)}else i.push(t)}let a=[];for(let{id:e}of hD){let t=r.get(e);t&&a.push(...t)}return a.push(...i),a}function qO({initialTag:e,onSelectTag:t}){let n=jD(),[r,i]=(0,V.useReducer)(HO,{...BO,selectedTag:e});(0,V.useEffect)(()=>{e!==r.selectedTag&&i({type:`tag_changed`,tag:e})},[e]);let a=(0,V.useRef)(null),o=(0,V.useCallback)((e,t)=>{a.current=t,t.blur(),i({type:`workflow_selected`,id:e})},[]);(0,V.useEffect)(()=>{if(!r.selectedWorkflowId&&a.current){let e=a.current;a.current=null,e.focus()}},[r.selectedWorkflowId]),(0,V.useEffect)(()=>{if(!r.selectedWorkflowId)return;let e=window.scrollY;return document.body.style.overflow=`hidden`,document.body.style.position=`fixed`,document.body.style.top=`-${e}px`,document.body.style.width=`100%`,()=>{document.body.style.overflow=``,document.body.style.position=``,document.body.style.top=``,document.body.style.width=``,window.scrollTo(0,e)}},[r.selectedWorkflowId]),(0,V.useEffect)(()=>{if(!r.selectedWorkflowId)return;let e=e=>{e.key===`Escape`&&i({type:`modal_closed`})};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r.selectedWorkflowId]);let{isLoading:s,error:c,workflows:l}=n,u=(0,V.useMemo)(()=>{if(s)return{kind:`loading`};if(c)return{kind:`error`,message:c.message,onRetry:n.refetch};if(!l)return{kind:`loading`};let e=UO(l),t=WO(l),i=GO(l,r.selectedTag,r.selectedSource),a=KO(i,r.selectedTag),o=GO(l,null,r.selectedSource),u=GO(l,r.selectedTag,null);return{kind:`ready`,selectedWorkflowId:r.selectedWorkflowId,selectedTag:r.selectedTag,selectedSource:r.selectedSource,hintVisible:r.hintVisible,availableTags:e,availableSources:t,filteredWorkflows:i,flatWorkflows:a,sourceFilteredWorkflows:o,tagFilteredWorkflows:u}},[s,c,l,r,n.refetch]),d=u.kind===`ready`?u.flatWorkflows.length:0;return(0,V.useEffect)(()=>{if(!r.selectedWorkflowId||d<=1)return;let e=setTimeout(()=>i({type:`hint_dismissed`}),3e3);return()=>clearTimeout(e)},[r.selectedWorkflowId,d]),{state:u,dispatch:(0,V.useCallback)(e=>{e.type===`tag_changed`&&t(e.tag),i(e)},[t]),triggerRef:a,onCardSelect:o}}function JO(){let e=qy();switch(e.state){case`loading`:return{kind:`loading`};case`devModeOff`:return{kind:`devModeOff`};case`error`:return{kind:`error`,message:e.message,retry:e.retry};case`data`:return{kind:`ready`,observations:e.data.observations}}}function YO(){let e=JO(),[t,n]=(0,V.useState)(`recent`);return{state:(0,V.useMemo)(()=>{if(e.kind===`loading`)return{kind:`loading`};if(e.kind===`devModeOff`)return{kind:`devModeOff`};if(e.kind===`error`)return{kind:`error`,message:e.message,retry:e.retry};let{observations:r}=e,i=UD(r,t);return{kind:`ready`,sorted:i,maxDuration:WD(i),errorCount:GD(r),avgMs:KD(r),lastCallMs:qD(r),countLabel:YD(r.length),sortOrder:t,onSortChange:n}},[e,t])}}function XO(e){let t=Uy(e);return{data:t.data,isLoading:t.isLoading,error:t.error instanceof Error?t.error:null}}function ZO(e){let t=XO(e),[n,r]=(0,V.useState)(null),i=(0,V.useCallback)((e,t)=>{r(n=>n?.runId===e&&n?.nodeId===t?null:{runId:e,nodeId:t})},[]),a=(0,V.useCallback)(()=>{r(null)},[]),{isLoading:o,error:s,data:c}=t,l=(0,V.useMemo)(()=>!c||!n?null:c.runs.find(e=>e.runId===n.runId)??null,[c,n]);return{state:(0,V.useMemo)(()=>o?{kind:`loading`}:s?{kind:`error`,message:s.message}:c?{kind:`ready`,sessionId:e,data:c,selectedNode:n,selectedRun:l}:{kind:`loading`},[o,s,c,e,n,l]),onSelectNode:i,onCloseNode:a}}var QO=[{id:`workspace`,path:`/`},{id:`workflows`,path:`/workflows`},{id:`auto`,path:`/auto`},{id:`perf`,path:`/perf`}];function $O(){let e=xi(),t=Qi(),{location:n}=ia(),r=t({to:`/session/$sessionId`}),i=t({to:`/workflows`}),a=t({to:`/workflows/$workflowId`}),o=t({to:`/perf`}),s=t({to:`/auto`}),c=i!==!1||a!==!1?`workflows`:o===!1?s===!1?`workspace`:`auto`:`perf`,l=r!==!1,u=a!==!1,d=l?r.sessionId:null,f=u?a.workflowId:null,p=new URLSearchParams(n.search).get(`tag`),m=wO(l),h=zO({onSelectSession:m.onSelectSession}),g=m.state.kind===`ready`?m.state.liveCount:0,_=m.state.kind===`ready`?m.state.blockedCount:0,v=(0,V.useCallback)(()=>{e({to:`/`})},[e]),y=(0,V.useCallback)(t=>{e({to:`/workflows`,search:{tag:t??void 0}})},[e]),b=(0,V.useCallback)(()=>{e({to:`/workflows`,search:{tag:p??void 0}})},[e,p]),x=(0,V.useCallback)(t=>{e({to:`/workflows/$workflowId`,params:{workflowId:t},search:{tag:p??void 0}})},[e,p]),S=qO({initialTag:p,onSelectTag:y}),C=ND({workflowId:f,activeTag:p,onBack:b,onNavigateToWorkflow:x}),w=ZO(d??``),T=YO(),[E,D]=(0,V.useState)(null),O=(0,V.useCallback)((e,t)=>{t(),D(e),setTimeout(()=>D(null),200)},[]),k=(0,V.useRef)(null);return(0,V.useEffect)(()=>{let t=k.current;if(!t)return;function n(t){if(t.key===`ArrowLeft`||t.key===`ArrowRight`){t.preventDefault();let n=QO.findIndex(e=>e.id===c),r=QO[t.key===`ArrowRight`?(n+1)%QO.length:(n-1+QO.length)%QO.length];e({to:r.path,...r.path===`/workflows`?{search:{tag:void 0}}:{}})}}return t.addEventListener(`keydown`,n),()=>t.removeEventListener(`keydown`,n)},[c,e]),(0,H.jsxs)(`div`,{className:`min-h-screen`,style:{"--app-header-height":`56px`},children:[(0,H.jsxs)(`header`,{style:{background:`rgba(23, 27, 40, 0.92)`,backdropFilter:`blur(24px)`,WebkitBackdropFilter:`blur(24px)`,borderBottom:`1px solid rgba(244, 196, 48, 0.25)`,boxShadow:`0 4px 24px rgba(0,0,0,0.4)`},className:`fixed top-0 w-full z-50 flex items-center h-14 px-4 gap-6`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,H.jsx)(oo,{cut:8,borderColor:`rgba(244, 196, 48, 0.5)`,background:`rgba(27, 31, 44, 0.8)`,className:`relative w-10 h-10`,children:(0,H.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,H.jsx)(`span`,{className:`font-mono text-[11px] font-bold text-[var(--accent)] tracking-widest`,children:`WR`})})}),(0,H.jsxs)(`div`,{className:`hidden sm:flex flex-col leading-none`,children:[(0,H.jsx)(`span`,{className:`font-mono text-[11px] font-bold text-[var(--text-primary)] tracking-[0.25em] uppercase`,children:`WR_CONSOLE`}),(0,H.jsxs)(`span`,{className:`font-mono text-[9px] text-[var(--text-muted)] tracking-[0.15em]`,children:[`// V`,`3.59.5`]})]})]}),l&&d?(0,H.jsx)(`nav`,{className:`flex items-center flex-1 justify-center`,children:(0,H.jsx)(vD,{segments:[{label:`Workspace`,onClick:v},{label:d?.slice(-12)??``}]})}):(0,H.jsxs)(`div`,{role:`tablist`,"aria-label":`Console sections`,ref:k,className:`flex items-center gap-1 flex-1 justify-center`,children:[(0,H.jsxs)(`button`,{role:`tab`,id:`tab-workspace`,"aria-selected":c===`workspace`,"aria-controls":`panel-workspace`,tabIndex:c===`workspace`?0:-1,onClick:()=>O(`workspace`,()=>void e({to:`/`})),className:[`tab-btn px-4 py-2.5 font-mono text-[10px] uppercase tracking-[0.30em] transition-colors duration-150`,`focus-visible:ring-2 focus-visible:ring-[var(--accent)] focus-visible:ring-offset-1 focus-visible:outline-none`,c===`workspace`?`tab-btn--active text-[var(--accent)] text-glow-amber`:`text-[var(--text-secondary)] hover:text-[var(--text-primary)]`,E===`workspace`?`tab-activating`:``].join(` `),style:c===`workspace`?{backgroundColor:`rgba(244, 196, 48, 0.06)`}:void 0,children:[(0,H.jsx)(`span`,{className:`tab-corner tab-corner--tl`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--tr`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--bl`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--br`,"aria-hidden":`true`}),`Workspace`]}),(0,H.jsxs)(`button`,{role:`tab`,id:`tab-workflows`,"aria-selected":c===`workflows`,"aria-controls":`panel-workflows`,tabIndex:c===`workflows`?0:-1,onClick:()=>O(`workflows`,()=>void e({to:`/workflows`,search:{tag:void 0}})),className:[`tab-btn px-4 py-2.5 font-mono text-[10px] uppercase tracking-[0.30em] transition-colors duration-150`,`focus-visible:ring-2 focus-visible:ring-[var(--accent)] focus-visible:ring-offset-1 focus-visible:outline-none`,c===`workflows`?`tab-btn--active text-[var(--accent)] text-glow-amber`:`text-[var(--text-secondary)] hover:text-[var(--text-primary)]`,E===`workflows`?`tab-activating`:``].join(` `),style:c===`workflows`?{backgroundColor:`rgba(244, 196, 48, 0.06)`}:void 0,children:[(0,H.jsx)(`span`,{className:`tab-corner tab-corner--tl`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--tr`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--bl`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--br`,"aria-hidden":`true`}),`Workflows`]}),(0,H.jsxs)(`button`,{role:`tab`,id:`tab-auto`,"aria-selected":c===`auto`,"aria-controls":`panel-auto`,tabIndex:c===`auto`?0:-1,onClick:()=>O(`auto`,()=>void e({to:`/auto`})),className:[`tab-btn px-4 py-2.5 font-mono text-[10px] uppercase tracking-[0.30em] transition-colors duration-150`,`focus-visible:ring-2 focus-visible:ring-[var(--accent)] focus-visible:ring-offset-1 focus-visible:outline-none`,c===`auto`?`tab-btn--active text-[var(--accent)] text-glow-amber`:`text-[var(--text-secondary)] hover:text-[var(--text-primary)]`,E===`auto`?`tab-activating`:``].join(` `),style:c===`auto`?{backgroundColor:`rgba(244, 196, 48, 0.06)`}:void 0,children:[(0,H.jsx)(`span`,{className:`tab-corner tab-corner--tl`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--tr`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--bl`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--br`,"aria-hidden":`true`}),`Auto`]}),(0,H.jsxs)(`button`,{role:`tab`,id:`tab-perf`,"aria-selected":c===`perf`,"aria-controls":`panel-perf`,tabIndex:c===`perf`?0:-1,onClick:()=>O(`perf`,()=>void e({to:`/perf`})),className:[`tab-btn px-4 py-2.5 font-mono text-[10px] uppercase tracking-[0.30em] transition-colors duration-150`,`focus-visible:ring-2 focus-visible:ring-[var(--accent)] focus-visible:ring-offset-1 focus-visible:outline-none`,c===`perf`?`tab-btn--active text-[var(--accent)] text-glow-amber`:`text-[var(--text-secondary)] hover:text-[var(--text-primary)]`,E===`perf`?`tab-activating`:``].join(` `),style:c===`perf`?{backgroundColor:`rgba(244, 196, 48, 0.06)`}:void 0,children:[(0,H.jsx)(`span`,{className:`tab-corner tab-corner--tl`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--tr`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--bl`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`tab-corner tab-corner--br`,"aria-hidden":`true`}),`Performance`]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[g>0&&(0,H.jsx)($a,{label:`${Math.min(g,9)}${g>9?`+`:``} LIVE`,color:`var(--accent-strong)`,pulse:!0,role:`status`,"aria-label":`${g} live session${g===1?``:`s`}`}),_>0&&(0,H.jsx)($a,{label:`${Math.min(_,9)}${_>9?`+`:``} BLOCKED`,color:`var(--blocked)`,role:`status`,"aria-label":`${_} blocked session${_===1?``:`s`}`})]})]}),(0,H.jsxs)(`main`,{className:`p-6`,style:{paddingTop:`calc(56px + 1.5rem)`},children:[(0,H.jsxs)(`div`,{id:`panel-workspace`,role:`tabpanel`,"aria-labelledby":`tab-workspace`,hidden:c===`workflows`||c===`perf`||c===`auto`,children:[(0,H.jsx)(wo,{viewModel:m,sessionListViewModel:h,hidden:l}),l&&d&&(0,H.jsx)(fD,{viewModel:w})]}),c===`workflows`&&(0,H.jsx)(`div`,{id:`panel-workflows`,role:`tabpanel`,"aria-labelledby":`tab-workflows`,children:u&&f?(0,H.jsx)(yD,{viewModel:C}):(0,H.jsx)(FD,{viewModel:S})}),c===`auto`&&(0,H.jsx)(`div`,{id:`panel-auto`,role:`tabpanel`,"aria-labelledby":`tab-auto`,children:(0,H.jsx)(uO,{})}),c===`perf`&&(0,H.jsx)(`div`,{id:`panel-perf`,role:`tabpanel`,"aria-labelledby":`tab-perf`,children:(0,H.jsx)(ZD,{viewModel:T})})]})]})}var ek=zi({component:$O}),tk=Li({getParentRoute:()=>ek,path:`/`,component:()=>null}),nk=Li({getParentRoute:()=>ek,path:`/session/$sessionId`,component:()=>null}),rk=Li({getParentRoute:()=>ek,path:`/workflows`,validateSearch:e=>({tag:typeof e.tag==`string`?e.tag:void 0}),component:()=>null}),ik=Li({getParentRoute:()=>ek,path:`/workflows/$workflowId`,validateSearch:e=>({tag:typeof e.tag==`string`?e.tag:void 0}),component:()=>null}),ak=Li({getParentRoute:()=>ek,path:`/perf`,component:()=>null}),ok=Li({getParentRoute:()=>ek,path:`/auto`,component:()=>null}),sk=ea({routeTree:ek.addChildren([tk,nk,rk,ik,ak,ok]),history:hr()}),ck=new Re({defaultOptions:{queries:{refetchInterval:5e3,staleTime:2e3}}});(0,aa.createRoot)(document.getElementById(`root`)).render((0,H.jsx)(V.StrictMode,{children:(0,H.jsx)(Ue,{client:ck,children:(0,H.jsx)(ra,{router:sk})})}));
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>WorkRail Console</title>
7
- <script type="module" crossorigin src="/console/assets/index-Ctoxo1z6.js"></script>
7
+ <script type="module" crossorigin src="/console/assets/index-xMwhHmR2.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/console/assets/index-DGj8EsFR.css">
9
9
  </head>
10
10
  <body>
@@ -71,7 +71,7 @@ async function runFullPipelineCore(deps, opts, coordinatorStartMs) {
71
71
  if (discoveryCutoff)
72
72
  return discoveryCutoff;
73
73
  deps.stderr(`[full-pipeline] Spawning wr.discovery session`);
74
- const discoverySpawnResult = await deps.spawnSession('wr.discovery', opts.goal, opts.workspace);
74
+ const discoverySpawnResult = await deps.spawnSession('wr.discovery', opts.goal, opts.workspace, undefined, { maxSessionMinutes: Math.ceil(adaptive_pipeline_js_1.DISCOVERY_TIMEOUT_MS / 60000) });
75
75
  if (discoverySpawnResult.kind === 'err') {
76
76
  return {
77
77
  kind: 'escalated',
@@ -136,7 +136,7 @@ async function runFullPipelineCore(deps, opts, coordinatorStartMs) {
136
136
  if (shapingCutoff)
137
137
  return shapingCutoff;
138
138
  deps.stderr(`[full-pipeline] Spawning wr.shaping session`);
139
- const shapingSpawnResult = await deps.spawnSession('wr.shaping', opts.goal, opts.workspace, shapingContext);
139
+ const shapingSpawnResult = await deps.spawnSession('wr.shaping', opts.goal, opts.workspace, shapingContext, { maxSessionMinutes: Math.ceil(adaptive_pipeline_js_1.SHAPING_TIMEOUT_MS / 60000) });
140
140
  if (shapingSpawnResult.kind === 'err') {
141
141
  return {
142
142
  kind: 'escalated',
@@ -168,7 +168,7 @@ async function runFullPipelineCore(deps, opts, coordinatorStartMs) {
168
168
  const uxCutoff = (0, adaptive_pipeline_js_1.checkSpawnCutoff)(coordinatorStartMs, deps.now(), 'ux-gate');
169
169
  if (uxCutoff)
170
170
  return uxCutoff;
171
- const uxSpawnResult = await deps.spawnSession('ui-ux-design-workflow', opts.goal, opts.workspace, { shapingComplete: true });
171
+ const uxSpawnResult = await deps.spawnSession('ui-ux-design-workflow', opts.goal, opts.workspace, { shapingComplete: true }, { maxSessionMinutes: Math.ceil(adaptive_pipeline_js_1.REVIEW_TIMEOUT_MS / 60000) });
172
172
  if (uxSpawnResult.kind === 'err') {
173
173
  return {
174
174
  kind: 'escalated',
@@ -233,7 +233,7 @@ async function runFullPipelineCore(deps, opts, coordinatorStartMs) {
233
233
  deps.stderr(`[full-pipeline] Spawning coding-task-workflow-agentic`);
234
234
  const codingSpawnResult = await deps.spawnSession('coding-task-workflow-agentic', opts.goal, opts.workspace, {
235
235
  pitchPath: opts.workspace + '/.workrail/current-pitch.md',
236
- });
236
+ }, { maxSessionMinutes: Math.ceil(adaptive_pipeline_js_1.CODING_TIMEOUT_MS / 60000) });
237
237
  if (codingSpawnResult.kind === 'err') {
238
238
  return {
239
239
  kind: 'escalated',
@@ -37,7 +37,10 @@ export interface PrReviewOpts {
37
37
  readonly port?: number;
38
38
  }
39
39
  export interface CoordinatorDeps {
40
- readonly spawnSession: (workflowId: string, goal: string, workspace: string, context?: Readonly<Record<string, unknown>>) => Promise<Result<string, string>>;
40
+ readonly spawnSession: (workflowId: string, goal: string, workspace: string, context?: Readonly<Record<string, unknown>>, agentConfig?: Readonly<{
41
+ readonly maxSessionMinutes?: number;
42
+ readonly maxTurns?: number;
43
+ }>) => Promise<Result<string, string>>;
41
44
  readonly contextAssembler?: ContextAssembler;
42
45
  readonly awaitSessions: (handles: readonly string[], timeoutMs: number) => Promise<AwaitResult>;
43
46
  readonly getAgentResult: (sessionHandle: string) => Promise<{
@@ -481,16 +481,16 @@
481
481
  "sha256": "5fe866e54f796975dec5d8ba9983aefd86074db212d3fccd64eed04bc9f0b3da",
482
482
  "bytes": 8011
483
483
  },
484
- "console-ui/assets/index-Ctoxo1z6.js": {
485
- "sha256": "fc11e753539cbb514c0c3c37189f2fbe2abca848fa005c5bcae09e5c88b78bd9",
486
- "bytes": 760528
487
- },
488
484
  "console-ui/assets/index-DGj8EsFR.css": {
489
485
  "sha256": "3bdb55ec0957928e0ebbb86a7d6b36d28f7ba7d5c0f3e236fd8f2e2aacee2fa4",
490
486
  "bytes": 60631
491
487
  },
488
+ "console-ui/assets/index-xMwhHmR2.js": {
489
+ "sha256": "9fbff5f59a5e014930778fd79a1de39f532b20862a4fa10d7320d12602b445fc",
490
+ "bytes": 760528
491
+ },
492
492
  "console-ui/index.html": {
493
- "sha256": "df586c53f8a105ad224d418e70c2dd98e7be4725dfb1c194baf45eff810ff6b5",
493
+ "sha256": "1aa1ca8a09fba68cb675918108702a338ec426ec0a6778736dbd1842e8a1a8bc",
494
494
  "bytes": 417
495
495
  },
496
496
  "console/standalone-console.d.ts": {
@@ -546,8 +546,8 @@
546
546
  "bytes": 462
547
547
  },
548
548
  "coordinators/modes/full-pipeline.js": {
549
- "sha256": "a03cf485201d23b0ddf75ca36ea10741bb9d0373479e7df3350401653229ef8b",
550
- "bytes": 12850
549
+ "sha256": "945d726d728235f8f31f03f33fbde8f6614472b38921a44fba42da959875f37d",
550
+ "bytes": 13201
551
551
  },
552
552
  "coordinators/modes/implement-shared.d.ts": {
553
553
  "sha256": "fbad9d91d84d2112b273175618686489a7f106385e0e62d6cab80804d6d0f2d7",
@@ -582,8 +582,8 @@
582
582
  "bytes": 1198
583
583
  },
584
584
  "coordinators/pr-review.d.ts": {
585
- "sha256": "a8886a3c83a31e869522812d1342a301e9bfae92d8e5e694594c3c50912035d9",
586
- "bytes": 3833
585
+ "sha256": "d46e4923995a0b43aefee25da298b86235fae0ad105e548b3174c0eea9c1f8d0",
586
+ "bytes": 3947
587
587
  },
588
588
  "coordinators/pr-review.js": {
589
589
  "sha256": "84b51f931eb55d908de8c60f90b4d4b66540054791a28ce2f07426a841fed386",
@@ -1650,8 +1650,8 @@
1650
1650
  "bytes": 1363
1651
1651
  },
1652
1652
  "trigger/adapters/github-queue-poller.js": {
1653
- "sha256": "c1a4866ff7ead5b33439da2ff7842747e119bf411e8057b1a08d580816689dd1",
1654
- "bytes": 7935
1653
+ "sha256": "b15f56cf0782a1eceb66ef6d58bb75b17e14f701f1e95d072fe7a71b5aa6a4f5",
1654
+ "bytes": 8824
1655
1655
  },
1656
1656
  "trigger/adapters/gitlab-poller.d.ts": {
1657
1657
  "sha256": "f685490fafad77194fdd0f0bbaf80dbc56730aeb344853da365199a120fbe399",
@@ -1718,20 +1718,20 @@
1718
1718
  "bytes": 6968
1719
1719
  },
1720
1720
  "trigger/polling-scheduler.d.ts": {
1721
- "sha256": "60df456a31fa87ce71de76f5e31a6c460bfab588a24c8a2f06bf926fdcea550a",
1722
- "bytes": 1096
1721
+ "sha256": "3c0865f9d21819c364575062745741405bc80006f4a0754d26ed4302253371c6",
1722
+ "bytes": 1126
1723
1723
  },
1724
1724
  "trigger/polling-scheduler.js": {
1725
- "sha256": "ef1252ee4bc4592fc416e7a00aa4e7db297035a990231941ae9316cdf5fe5b9a",
1726
- "bytes": 21667
1725
+ "sha256": "0588534bacec382e00eb766d33438569f31563e5bbad8d3498ef64c00a0f87db",
1726
+ "bytes": 23912
1727
1727
  },
1728
1728
  "trigger/trigger-listener.d.ts": {
1729
1729
  "sha256": "1eebb3d4829030b264c3798b0b0d55d7357d313ab83e3f344ad455eaafcedb44",
1730
1730
  "bytes": 1740
1731
1731
  },
1732
1732
  "trigger/trigger-listener.js": {
1733
- "sha256": "09b8bbcda1825a9314dc29ac7435ef703fb0cdad13fa54ffe45f68767f22fbc7",
1734
- "bytes": 25095
1733
+ "sha256": "4aa62601aac5d3c7d1750ef839ee71a911dacbab346fb6dfdb3d7151e9e7d359",
1734
+ "bytes": 25179
1735
1735
  },
1736
1736
  "trigger/trigger-router.d.ts": {
1737
1737
  "sha256": "b916f33cab64d491ab04bd13dd37599d33e687f7aea1e69e50f5fcea4b3b4624",
@@ -148,6 +148,30 @@ function inferMaturity(body) {
148
148
  return 'idea';
149
149
  }
150
150
  async function checkIdempotency(issueNumber, sessionsDir = exports.DEFAULT_SESSIONS_DIR) {
151
+ const sidecarFilename = `queue-issue-${issueNumber}.json`;
152
+ const sidecarFilePath = path.join(sessionsDir, sidecarFilename);
153
+ try {
154
+ const sidecarContent = await fs.readFile(sidecarFilePath, 'utf8');
155
+ const sidecarParsed = JSON.parse(sidecarContent);
156
+ if (typeof sidecarParsed !== 'object' || sidecarParsed === null) {
157
+ return 'active';
158
+ }
159
+ const sidecar = sidecarParsed;
160
+ const dispatchedAt = sidecar['dispatchedAt'];
161
+ const ttlMs = sidecar['ttlMs'];
162
+ if (typeof dispatchedAt === 'number' && typeof ttlMs === 'number') {
163
+ if (dispatchedAt + ttlMs > Date.now()) {
164
+ return 'active';
165
+ }
166
+ return 'clear';
167
+ }
168
+ return 'active';
169
+ }
170
+ catch (e) {
171
+ if (e.code !== 'ENOENT') {
172
+ return 'active';
173
+ }
174
+ }
151
175
  let files;
152
176
  try {
153
177
  files = await fs.readdir(sessionsDir);
@@ -155,7 +179,7 @@ async function checkIdempotency(issueNumber, sessionsDir = exports.DEFAULT_SESSI
155
179
  catch {
156
180
  return 'clear';
157
181
  }
158
- const jsonFiles = files.filter(f => f.endsWith('.json'));
182
+ const jsonFiles = files.filter(f => f.endsWith('.json') && f !== sidecarFilename);
159
183
  for (const filename of jsonFiles) {
160
184
  try {
161
185
  const content = await fs.readFile(path.join(sessionsDir, filename), 'utf8');
@@ -29,4 +29,5 @@ export declare class PollingScheduler {
29
29
  private doPollGitHub;
30
30
  private dispatchAndRecord;
31
31
  private doPollGitHubQueue;
32
+ private applyGitHubLabel;
32
33
  }
@@ -38,6 +38,7 @@ const gitlab_poller_js_1 = require("./adapters/gitlab-poller.js");
38
38
  const github_poller_js_1 = require("./adapters/github-poller.js");
39
39
  const github_queue_poller_js_1 = require("./adapters/github-queue-poller.js");
40
40
  const github_queue_config_js_1 = require("./github-queue-config.js");
41
+ const adaptive_pipeline_js_1 = require("../coordinators/adaptive-pipeline.js");
41
42
  const fs = __importStar(require("node:fs/promises"));
42
43
  const os = __importStar(require("node:os"));
43
44
  const path = __importStar(require("node:path"));
@@ -312,15 +313,31 @@ class PollingScheduler {
312
313
  }
313
314
  this.dispatchingIssues.add(top.issue.number);
314
315
  console.log(`[QueuePoll] in-flight-add #${top.issue.number}`);
316
+ const sidecarPath = path.join(sessionsDir, `queue-issue-${top.issue.number}.json`);
317
+ const sidecarContent = JSON.stringify({
318
+ issueNumber: top.issue.number,
319
+ triggerId,
320
+ dispatchedAt: Date.now(),
321
+ ttlMs: adaptive_pipeline_js_1.DISCOVERY_TIMEOUT_MS + 60000,
322
+ }, null, 2);
323
+ void fs.writeFile(sidecarPath, sidecarContent, 'utf8').catch((e) => {
324
+ console.warn(`[QueuePoll] Failed to write sidecar for issue #${top.issue.number}: ${e instanceof Error ? e.message : String(e)}`);
325
+ });
315
326
  const dispatchP = this.router.dispatchAdaptivePipeline(workflowTrigger.goal, workflowTrigger.workspacePath, workflowTrigger.context);
327
+ const issueNumber = top.issue.number;
316
328
  void dispatchP
317
- .then(() => {
318
- this.dispatchingIssues.delete(top.issue.number);
319
- console.log(`[QueuePoll] in-flight-clear #${top.issue.number} reason=completed`);
329
+ .then((outcome) => {
330
+ this.dispatchingIssues.delete(issueNumber);
331
+ console.log(`[QueuePoll] in-flight-clear #${issueNumber} reason=completed`);
332
+ if (outcome.kind === 'escalated' || outcome.kind === 'dry_run') {
333
+ void this.applyGitHubLabel(issueNumber, 'worktrain:in-progress', queueConfig.token, source.repo);
334
+ }
335
+ void fs.unlink(sidecarPath).catch(() => { });
320
336
  })
321
337
  .catch(() => {
322
- this.dispatchingIssues.delete(top.issue.number);
323
- console.log(`[QueuePoll] in-flight-clear #${top.issue.number} reason=error`);
338
+ this.dispatchingIssues.delete(issueNumber);
339
+ console.log(`[QueuePoll] in-flight-clear #${issueNumber} reason=error`);
340
+ void fs.unlink(sidecarPath).catch(() => { });
324
341
  });
325
342
  console.log(`[QueuePoll] dispatched via adaptivePipeline goal="${workflowTrigger.goal.slice(0, 80)}"`);
326
343
  for (let i = 1; i < candidates.length; i++) {
@@ -332,6 +349,32 @@ class PollingScheduler {
332
349
  console.log(`[QueuePoll] cycle complete selected=1 skipped=${skipped.length + candidates.length - 1} elapsed=${elapsed}ms`);
333
350
  await appendQueuePollLog({ event: 'poll_cycle_complete', selected: 1, skipped: skipped.length + candidates.length - 1, elapsed, ts: new Date().toISOString() });
334
351
  }
352
+ async applyGitHubLabel(issueNumber, label, token, repo) {
353
+ const fetchFn = this.fetchFn ?? globalThis.fetch;
354
+ const url = `https://api.github.com/repos/${repo}/issues/${issueNumber}/labels`;
355
+ try {
356
+ const response = await fetchFn(url, {
357
+ method: 'POST',
358
+ headers: {
359
+ 'Authorization': `Bearer ${token}`,
360
+ 'Accept': 'application/vnd.github+json',
361
+ 'Content-Type': 'application/json',
362
+ 'X-GitHub-Api-Version': '2022-11-28',
363
+ },
364
+ body: JSON.stringify({ labels: [label] }),
365
+ });
366
+ if (!response.ok) {
367
+ const text = await response.text().catch(() => '');
368
+ console.warn(`[QueuePoll] Failed to apply label '${label}' to issue #${issueNumber}: HTTP ${response.status} ${text.slice(0, 200)}`);
369
+ }
370
+ else {
371
+ console.log(`[QueuePoll] Applied label '${label}' to issue #${issueNumber}`);
372
+ }
373
+ }
374
+ catch (e) {
375
+ console.warn(`[QueuePoll] Failed to apply label '${label}' to issue #${issueNumber}: ${e instanceof Error ? e.message : String(e)}`);
376
+ }
377
+ }
335
378
  }
336
379
  exports.PollingScheduler = PollingScheduler;
337
380
  function buildGitLabWorkflowTrigger(trigger, mr) {
@@ -218,7 +218,7 @@ async function startTriggerListener(ctx, options) {
218
218
  }
219
219
  let routerRef;
220
220
  const coordinatorDeps = {
221
- spawnSession: async (workflowId, goal, workspace, context) => {
221
+ spawnSession: async (workflowId, goal, workspace, context, agentConfig) => {
222
222
  if (routerRef === undefined) {
223
223
  return { kind: 'err', error: 'in-process router not initialized -- coordinator deps not ready' };
224
224
  }
@@ -242,6 +242,7 @@ async function startTriggerListener(ctx, options) {
242
242
  goal,
243
243
  workspacePath: workspace,
244
244
  context,
245
+ ...(agentConfig !== undefined ? { agentConfig } : {}),
245
246
  _preAllocatedStartResponse: startResult.value.response,
246
247
  });
247
248
  return { kind: 'ok', value: sessionHandle };
@@ -7351,3 +7351,138 @@ An agent can die from: stream watchdog timeout (600s no progress), OOM kill, or
7351
7351
  ### Priority
7352
7352
 
7353
7353
  High. Agent crash recovery makes the overnight-autonomous bar achievable. Without it, any hung LLM call or tool timeout fails the entire pipeline silently. With it, transient failures are automatically retried and the pipeline continues.
7354
+
7355
+ ---
7356
+
7357
+ ## Workflow execution time tracking and prediction (Apr 21, 2026)
7358
+
7359
+ **The problem:** WorkTrain has no data on how long workflows actually take. Timeouts are set by intuition (55 min for discovery, 35 for shaping, 65 for coding). We just discovered that discovery on a real workrail task takes ~16 minutes. The 55-minute timeout is 3x the actual time -- but we didn't know that until we ran a benchmark manually.
7360
+
7361
+ ### What to track
7362
+
7363
+ For every completed session, record:
7364
+ - Workflow ID
7365
+ - Total wall-clock duration
7366
+ - Number of turns
7367
+ - Number of step advances
7368
+ - Outcome (success / timeout / stuck / error)
7369
+ - Task complexity signals (codebase size, number of files read, task type from context)
7370
+
7371
+ Store in `~/.workrail/data/execution-stats.jsonl` -- one line per completed session, append-only.
7372
+
7373
+ ### What to do with it
7374
+
7375
+ **Immediate use: calibrate timeouts automatically**
7376
+
7377
+ Instead of hardcoded `DISCOVERY_TIMEOUT_MS = 55 * 60 * 1000`, read the p95 completion time from execution stats and set the timeout to `p95 * 1.5`. Start with the hardcoded values as seeds; refine after 10+ samples.
7378
+
7379
+ **Medium-term use: predict duration before dispatch**
7380
+
7381
+ Given: task description + workflow ID + codebase characteristics → predicted duration range.
7382
+
7383
+ The coordinator could use this to:
7384
+ - Warn when a task is likely to exceed session limits before starting
7385
+ - Adjust timeout budgets per-dispatch based on predicted complexity
7386
+ - Surface "this type of task usually takes 45 minutes" in `worktrain trigger test` output
7387
+
7388
+ **Longer-term use: quality/efficiency metrics**
7389
+
7390
+ Track step-advance rate (steps per turn) as a proxy for workflow efficiency. A session with 50 turns and 2 step advances is spending too many turns between steps. This feeds into the workflow improvement loop.
7391
+
7392
+ ### Implementation notes
7393
+
7394
+ - Append to `execution-stats.jsonl` in `runWorkflow()`'s finally block, same pattern as the daemon event log
7395
+ - Keep it simple: flat JSONL, no database, no schema migration
7396
+ - `worktrain status` can show recent timing stats: "Last 10 wr.discovery sessions: avg 18min, p95 31min"
7397
+ - `worktrain trigger validate` can warn if configured timeouts are well below historical p95
7398
+
7399
+ ### Priority
7400
+
7401
+ Medium. The data collection is small (~5 lines in `runWorkflow()`). The prediction and calibration are more involved. Ship collection first, calibration second.
7402
+
7403
+ ---
7404
+
7405
+ ## WorkRail MCP server self-cleanup (Apr 21, 2026)
7406
+
7407
+ **The problem:** The WorkRail MCP server accumulates stale state that never cleans itself up: old workflow copies in `~/.workrail/workflows/`, dead managed sources, git repo caches that can't pull, 500+ sessions in the store, stale remembered roots. None of it has a TTL or cleanup mechanism. Every server startup loads everything and logs validation errors for stale state.
7408
+
7409
+ ### Sources of stale state
7410
+
7411
+ 1. **`~/.workrail/workflows/`** -- manually copied or `worktrain init`-placed workflows that go stale when the repo updates. MCP server loads both repo copy and user copy; older one fails validation silently or noisily.
7412
+
7413
+ 2. **Managed sources** (`~/.workrail/data/managed-sources/`) -- paths that no longer exist stay registered. Server tries to load them on every startup.
7414
+
7415
+ 3. **Git workflow cache** (`~/.workrail/cache/git-*`) -- cloned repos whose remotes have changed, been deleted, or whose auth has expired. `git pull` fails; errors logged on every startup.
7416
+
7417
+ 4. **Session store** (`~/.workrail/data/sessions/`) -- sessions accumulate forever. No TTL, no archival. Console loads all 500+ on every `/api/v2/sessions` request (partially mitigated by mtime cache).
7418
+
7419
+ 5. **Remembered roots** (`~/.workrail/data/managed-sources/remembered-roots.json`) -- workspace paths from past sessions that no longer exist.
7420
+
7421
+ ### Fix: two layers
7422
+
7423
+ **Layer 1: Defensive loading (mostly already done)**
7424
+ Every loader should already handle missing/broken sources gracefully. Audit: are all managed source failures caught and logged as warnings rather than errors? Are git cache failures non-fatal?
7425
+
7426
+ **Layer 2: `workrail cleanup` command**
7427
+ ```
7428
+ workrail cleanup [--yes] [--sessions --older-than <age>] [--sources] [--cache] [--roots]
7429
+ ```
7430
+ - `--sources`: remove managed sources where path doesn't exist on disk
7431
+ - `--cache`: remove git caches where `git pull` fails (remote gone or auth expired)
7432
+ - `--sessions --older-than 30d`: archive or delete sessions older than N days
7433
+ - `--roots`: remove remembered roots where path doesn't exist
7434
+ - Without `--yes`: show what would be removed and ask for confirmation
7435
+ - With `--yes`: remove without prompting (for CI / worktrain init)
7436
+
7437
+ **Layer 3: Automatic startup cleanup (light)**
7438
+ On MCP server startup, silently remove managed sources where the filesystem path doesn't exist (non-destructive -- the path is already gone). Log a single "removed N stale sources" line. Do not auto-remove sessions or caches -- those require explicit user intent.
7439
+
7440
+ **Layer 4: User workflow directory sync**
7441
+ `~/.workrail/workflows/` should not be a place users copy workflows to manually. It should either:
7442
+ - Be deprecated entirely (use managed sources / workspace roots instead)
7443
+ - Have a `workrail sync` command that updates it from the canonical sources
7444
+ - Auto-detect when a user workflow is an older version of a bundled workflow and skip loading it
7445
+
7446
+ ### Priority
7447
+
7448
+ Medium for the cleanup command (quality of life, stops log noise). High for startup auto-cleanup of dead managed sources (prevents the `Invalid workflow` errors that have been confusing throughout this session). Low for session TTL/archival (the mtime cache handles the performance concern).
7449
+
7450
+ ---
7451
+
7452
+ ## Worktree orphan leak on delivery failure (Apr 21, 2026, from Audit 4)
7453
+
7454
+ **The bug:** In `src/trigger/trigger-router.ts`, `maybeRunDelivery()` on the success path deletes the session sidecar file before attempting worktree removal. If worktree removal fails (network error, git command failure), the sidecar is already gone. `runStartupRecovery()` scans sidecar files to find orphan worktrees -- so the orphaned worktree is invisible and accumulates indefinitely.
7455
+
7456
+ **Fix:** In the success path cleanup, delete the sidecar AFTER worktree removal, not before. Or better: always attempt worktree removal in a `try/finally` that deletes the sidecar regardless of whether removal succeeded.
7457
+
7458
+ **File:** `src/trigger/trigger-router.ts`, `maybeRunDelivery()` success path.
7459
+
7460
+ **Priority:** Medium. Worktrees are small, but the leak is permanent across daemon restarts.
7461
+
7462
+ ---
7463
+
7464
+ ## queue-poll.jsonl never rotated (Apr 21, 2026, from Audit 5)
7465
+
7466
+ **The bug:** `~/.workrail/queue-poll.jsonl` grows indefinitely. `appendFile`-only, no rotation. At 5-minute poll intervals with 2-3 events per cycle, this is ~8-87 MB/month depending on activity. Disk exhaustion risk on long-running daemons.
7467
+
7468
+ **Fix:** Add a size check before appending in `appendQueuePollLog()`. If file exceeds 10 MB, rotate it: rename to `queue-poll.jsonl.1`, start fresh. Keep at most 2 rotated files.
7469
+
7470
+ **File:** `src/trigger/polling-scheduler.ts`, `appendQueuePollLog()` function.
7471
+
7472
+ **Priority:** Medium. Not urgent but a production correctness issue.
7473
+
7474
+ ---
7475
+
7476
+ ## ReviewSeverity missing assertNever + stderr bypassing injected dep (Apr 21, 2026, from Audit 2)
7477
+
7478
+ **Bug 1 (Major):** In `src/coordinators/modes/implement-shared.ts`, the `switch(findings.severity)` over `ReviewSeverity` has no `default: assertNever(findings.severity)`. Widening `ReviewSeverity` with a new variant compiles cleanly and falls through silently.
7479
+
7480
+ **Fix:** Add `default: assertNever(findings.severity)` to the switch.
7481
+
7482
+ **Bug 2 (Major):** In `src/coordinators/pr-review.ts`, `readVerdictArtifact()` calls `process.stderr.write(...)` directly instead of using the injected `deps.stderr`. Tests that inject a fake dep will miss this log.
7483
+
7484
+ **Fix:** Replace `process.stderr.write(...)` with `deps.stderr(...)`.
7485
+
7486
+ **Files:** `src/coordinators/modes/implement-shared.ts`, `src/coordinators/pr-review.ts`.
7487
+
7488
+ **Priority:** Medium. Correctness issues that won't crash in production but make future refactors unsafe.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exaudeus/workrail",
3
- "version": "3.59.5",
3
+ "version": "3.59.6",
4
4
  "description": "Step-by-step workflow enforcement for AI agents via MCP",
5
5
  "license": "MIT",
6
6
  "repository": {