@exaudeus/workrail 3.79.0 → 3.79.1

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 GT(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function KT(e,t){let n=BT(e,t),r=n.one(e,void 0),i=TT(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 qT(e,t){return e&&`run`in e?async function(n,r){let i=KT(n,{file:r,...t});await e.run(i,r)}:function(n,r){return KT(n,{file:r,...e||t})}}function JT(e){if(e)throw e}var YT=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 XT(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 ZT(){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?QT(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 QT(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 $T={basename:eE,dirname:tE,extname:nE,join:rE,sep:`/`};function eE(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);oE(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 tE(e){if(oE(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 nE(e){oE(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 rE(...e){let t=-1,n;for(;++t<e.length;)oE(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:iE(n)}function iE(e){oE(e);let t=e.codePointAt(0)===47,n=aE(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function aE(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 oE(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var sE={cwd:cE};function cE(){return`/`}function lE(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function uE(e){if(typeof e==`string`)e=new URL(e);else if(!lE(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 dE(e)}function dE(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 fE=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],pE=class{constructor(e){let t;t=e?lE(e)?{path:e}:typeof e==`string`||_E(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:sE.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<fE.length;){let e=fE[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)fE.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?$T.basename(this.path):void 0}set basename(e){hE(e,`basename`),mE(e,`basename`),this.path=$T.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?$T.dirname(this.path):void 0}set dirname(e){gE(this.basename,`dirname`),this.path=$T.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?$T.extname(this.path):void 0}set extname(e){if(mE(e,`extname`),gE(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=$T.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){lE(e)&&(e=uE(e)),hE(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?$T.basename(this.path,this.extname):void 0}set stem(e){hE(e,`stem`),mE(e,`stem`),this.path=$T.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 nx(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 mE(e,t){if(e&&e.includes($T.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+$T.sep+"`")}function hE(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function gE(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function _E(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var vE=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),yE=l(YT(),1),bE={}.hasOwnProperty,xE=new class e extends vE{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=ZT()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,yE.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(wE(`data`,this.frozen),this.namespace[e]=t,this):bE.call(this.namespace,e)&&this.namespace[e]||void 0:e?(wE(`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=DE(e),n=this.parser||this.Parser;return SE(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),SE(`process`,this.parser||this.Parser),CE(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=DE(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);kE(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(),SE(`processSync`,this.parser||this.Parser),CE(`processSync`,this.compiler||this.Compiler),this.process(e,r),EE(`processSync`,`process`,t),n;function r(e,r){t=!0,JT(e),n=r}}run(e,t,n){TE(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=DE(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),EE(`runSync`,`run`,n),r;function i(e,t){JT(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=DE(t),r=this.compiler||this.Compiler;return CE(`stringify`,r),TE(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(wE(`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,yE.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];XT(o)&&XT(r)&&(r=(0,yE.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function SE(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function CE(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function wE(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 TE(e){if(!XT(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function EE(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function DE(e){return OE(e)?e:new pE(e)}function OE(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function kE(e){return typeof e==`string`||AE(e)}function AE(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var jE=[],ME={allowDangerousHtml:!0},NE=/^(https?|ircs?|mailto|xmpp)$/i,PE=[{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 FE(e){let t=IE(e),n=LE(e);return RE(t.runSync(t.parse(n),n),e)}function IE(e){let t=e.rehypePlugins||jE,n=e.remarkPlugins||jE,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...ME}:ME;return xE().use(Nw).use(n).use(qT,r).use(t)}function LE(e){let t=e.children||``,n=new pE;return typeof t==`string`?n.value=t:``+t,n}function RE(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||zE;for(let e of PE)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return LT(e,l),ux(e,{Fragment:V.Fragment,components:i,ignoreInvalidStyle:!0,jsx:V.jsx,jsxs:V.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 Mx)if(Object.hasOwn(Mx,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=Mx[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 zE(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||NE.test(e.slice(0,t))?e:``}function BE({children:e,className:t}){return(0,V.jsx)(`div`,{className:`markdown-view ${t??``}`,children:(0,V.jsx)(FE,{children:e})})}function VE({sessionId:e,nodeId:t,runStatus:n=`complete`,currentNodeId:r=null,executionTraceSummary:i=null}){let{data:a,isLoading:o,error:s}=qy(e,t);return t?(0,V.jsxs)(`div`,{children:[(0,V.jsx)(HE,{stepLabel:a?.stepLabel??null,nodeId:t}),(0,V.jsxs)(`div`,{className:`p-4 space-y-4`,children:[o&&(0,V.jsx)(`div`,{className:`text-[var(--text-secondary)] text-sm`,children:`Loading...`}),s&&(0,V.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,V.jsx)(qE,{detail:a,runStatus:n,currentNodeId:r,executionTraceSummary:i})]})]}):(0,V.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 HE({stepLabel:e,nodeId:t}){return(0,V.jsxs)(`div`,{className:`px-5 py-4 border-b border-[var(--border)] console-blueprint-grid`,children:[(0,V.jsx)(`div`,{className:`text-base font-semibold text-[var(--text-primary)] leading-tight`,children:e??`Untitled node`}),(0,V.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-[var(--text-muted)] truncate`,children:t})]})}function UE({item:e}){return(0,V.jsxs)(`div`,{className:`flex items-start gap-2 text-xs py-1`,children:[(0,V.jsx)(`span`,{className:`flex-1 text-[var(--text-secondary)] leading-relaxed`,children:e.summary}),(0,V.jsxs)(`span`,{className:`font-mono text-[10px] text-[var(--text-muted)] shrink-0`,children:[`#`,e.recordedAtEventIndex]})]})}function WE({nodeId:e,nodeKind:t,executionTraceSummary:n}){let{whySelected:r,conditions:i,loops:a,divergences:o,forks:s}=my(n,e);return n.items.some(t=>t.kind!==`context_fact`&&t.refs.some(t=>t.kind===`node_id`&&t.value===e))?(0,V.jsx)(cD,{title:`Routing context`,children:(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(r.length>0||t===`blocked_attempt`)&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`mb-1.5 flex items-center gap-2`,children:(0,V.jsx)(Fy,{label:`WHY SELECTED`,color:`var(--accent)`,bgColor:`rgba(244,196,48,0.10)`})}),r.length>0?(0,V.jsx)(`div`,{className:`space-y-1 pl-2 border-l border-[var(--border)]`,children:r.map((e,t)=>(0,V.jsx)(UE,{item:e},t))}):t===`blocked_attempt`?(0,V.jsx)(`div`,{className:`pl-2 border-l border-[var(--border)]`,children:(0,V.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,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`mb-1.5`,children:(0,V.jsx)(Fy,{label:`CONDITIONS EVALUATED`,color:`var(--text-secondary)`,bgColor:`rgba(168,159,140,0.10)`})}),(0,V.jsx)(`div`,{className:`space-y-1 pl-2 border-l border-[var(--border)]`,children:[...i.filter(e=>!cy(e)),...i.filter(e=>cy(e))].map((e,t)=>{let n=cy(e);return(0,V.jsxs)(`div`,{className:`flex items-start gap-2 text-xs py-0.5`,children:[(0,V.jsx)(Fy,{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,V.jsx)(`span`,{className:`flex-1 text-[var(--text-secondary)] leading-relaxed`,children:e.summary})]},t)})})]}),a.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`mb-1.5`,children:(0,V.jsx)(Fy,{label:`LOOP`,color:`var(--accent-strong)`,bgColor:`rgba(0,240,255,0.10)`})}),(0,V.jsx)(`div`,{className:`space-y-1 pl-2 border-l border-[var(--border)]`,children:a.map((e,t)=>(0,V.jsx)(UE,{item:e},t))})]}),o.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`mb-1.5`,children:(0,V.jsx)(Fy,{label:`DIVERGENCE`,color:`var(--error)`,bgColor:`rgba(255,107,107,0.10)`})}),(0,V.jsx)(`div`,{className:`space-y-1 pl-2 border-l border-[var(--border)]`,children:o.map((e,t)=>(0,V.jsx)(UE,{item:e},t))})]}),s.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`mb-1.5`,children:(0,V.jsx)(Fy,{label:`FORK`,color:`var(--warning)`,bgColor:`rgba(251,191,36,0.10)`})}),(0,V.jsx)(`div`,{className:`space-y-1 pl-2 border-l border-[var(--border)]`,children:s.map((e,t)=>(0,V.jsx)(UE,{item:e},t))})]})]})}):(0,V.jsx)(cD,{title:`Routing context`,children:t===`blocked_attempt`&&r.length===0?(0,V.jsxs)(`div`,{className:`flex items-start gap-2 py-1`,children:[(0,V.jsx)(Fy,{label:`WHY SELECTED`,color:`var(--text-muted)`,bgColor:`rgba(123,141,167,0.08)`}),(0,V.jsx)(`span`,{className:`text-xs text-[var(--text-muted)] leading-relaxed`,children:`This step was attempted but not selected as the preferred path.`})]}):(0,V.jsx)(`span`,{className:`font-mono text-xs text-[var(--text-muted)]`,children:`// no routing trace for this node`})})}function GE({items:e}){let[t,n]=(0,B.useState)(!1);return(0,V.jsx)(cD,{title:`Run routing`,children:(0,V.jsxs)(`div`,{children:[(0,V.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,V.jsx)(Fy,{label:`RUN ROUTING`,color:`var(--text-muted)`,bgColor:`rgba(123,141,167,0.08)`}),(0,V.jsxs)(`span`,{className:`text-[var(--text-muted)]`,children:[`// `,e.length,` ambient items`]}),(0,V.jsx)(`span`,{children:t?`[-]`:`[+]`})]}),t&&(0,V.jsx)(`div`,{className:`mt-2 space-y-1 pl-2 border-l border-[var(--border)]`,children:e.map((e,t)=>(0,V.jsxs)(`div`,{className:`flex items-start gap-2 text-xs py-0.5`,children:[(0,V.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,V.jsx)(`span`,{className:`flex-1 text-[var(--text-secondary)] leading-relaxed`,children:e.summary}),(0,V.jsxs)(`span`,{className:`font-mono text-[10px] text-[var(--text-muted)] shrink-0`,children:[`#`,e.recordedAtEventIndex]})]},t))})]})})}var KE=[{id:`routing`,column:`primary`,render:({detail:e,executionTraceSummary:t})=>t===null?null:(0,V.jsx)(WE,{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,V.jsx)(GE,{items:t},`run_routing`)}},{id:`recap`,column:`primary`,render:({detail:e,runStatus:t,currentNodeId:n})=>e.recapMarkdown?(0,V.jsx)($E,{markdown:e.recapMarkdown},`recap`):t===`in_progress`&&e.nodeId===n&&!e.recapMarkdown?(0,V.jsx)(JE,{detail:e},`recap-in-progress`):null},{id:`validations`,column:`primary`,render:({detail:e})=>e.validations.length>0?(0,V.jsx)(tD,{validations:e.validations},`validations`):null},{id:`gaps`,column:`primary`,render:({detail:e})=>e.gaps.length>0?(0,V.jsx)(rD,{gaps:e.gaps},`gaps`):null},{id:`advance-outcome`,column:`primary`,render:({detail:e})=>e.advanceOutcome?(0,V.jsx)(eD,{outcome:e.advanceOutcome},`advance-outcome`):null},{id:`artifacts`,column:`primary`,render:({detail:e})=>e.artifacts.length>0?(0,V.jsx)(sD,{artifacts:e.artifacts},`artifacts`):null},{id:`node-meta`,column:`primary`,render:({detail:e})=>(0,V.jsx)(QE,{detail:e},`node-meta`)}];function qE(e){return(0,V.jsx)(`div`,{className:`space-y-4`,children:KE.map(t=>t.render(e))})}function JE({detail:e}){return(0,V.jsx)(cD,{title:`Recap`,children:(0,V.jsxs)(`div`,{className:`space-y-4 text-sm text-[var(--text-secondary)]`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(YE,{children:`In progress`}),(0,V.jsxs)(`span`,{className:`font-mono text-xs text-[var(--text-muted)]`,children:[`event #`,e.createdAtEventIndex]})]}),(0,V.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]`,children:[(0,V.jsx)(XE,{label:`Current focus`,value:e.stepLabel??`Current workflow step`,supportingText:`This step is still running, so the recap will appear once execution finishes.`}),(0,V.jsx)(XE,{label:`Current state`,value:`Waiting for step completion`,supportingText:`The node has been created and selected as the current workflow position.`,mono:!0})]}),(0,V.jsxs)(`div`,{className:`bg-[var(--bg-primary)] border border-[var(--border)] overflow-hidden`,children:[(0,V.jsx)(`div`,{className:`px-4 py-3 border-b border-[var(--border)]`,children:(0,V.jsx)(Ko,{children:`What lands here next`})}),(0,V.jsxs)(`div`,{className:`p-4 grid gap-3 md:grid-cols-3`,children:[(0,V.jsx)(ZE,{title:`Recap`,description:`A step summary is written when this node completes.`}),(0,V.jsx)(ZE,{title:`Validations`,description:`Validation results appear if this step records contract checks.`}),(0,V.jsx)(ZE,{title:`Artifacts`,description:`Generated outputs show up here after the step produces them.`})]})]})]})})}function YE({children:e}){return(0,V.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 XE({label:e,value:t,supportingText:n,mono:r=!1}){return(0,V.jsxs)(`div`,{className:`bg-[var(--bg-primary)] border border-[var(--border)] px-4 py-3 space-y-2`,children:[(0,V.jsx)(Ko,{children:e}),(0,V.jsx)(`div`,{className:r?`font-mono text-sm text-[var(--text-primary)]`:`text-[var(--text-primary)]`,children:t}),(0,V.jsx)(`div`,{className:`text-xs text-[var(--text-muted)] leading-relaxed`,children:n})]})}function ZE({title:e,description:t}){return(0,V.jsxs)(`div`,{className:`border border-[var(--border)] bg-[rgba(255,255,255,0.02)] px-3 py-3 space-y-2`,children:[(0,V.jsx)(Ko,{color:`var(--text-secondary)`,children:e}),(0,V.jsx)(`div`,{className:`text-xs text-[var(--text-muted)] leading-relaxed`,children:t})]})}function QE({detail:e}){return(0,V.jsx)(cD,{title:`Node details`,children:(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsx)(lD,{label:`Kind`,value:(0,V.jsx)(dD,{kind:e.nodeKind})}),(0,V.jsx)(lD,{label:`Event index`,value:String(e.createdAtEventIndex),mono:!0}),(0,V.jsx)(lD,{label:`Parent`,value:e.parentNodeId??`Root`,mono:!0}),(0,V.jsx)(lD,{label:`Tip state`,value:e.isTip?e.isPreferredTip?`Preferred tip`:`Tip`:`Historical`})]})})}function $E({markdown:e}){return(0,V.jsx)(cD,{title:`Recap`,children:(0,V.jsx)(BE,{children:e})})}function eD({outcome:e}){let t=e.kind===`advanced`;return(0,V.jsx)(cD,{title:`Advance outcome`,children:(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-xs`,children:[(0,V.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,V.jsxs)(`span`,{className:`text-[var(--text-muted)]`,children:[`attempt `,e.attemptId.slice(-8),` at event #`,e.recordedAtEventIndex]})]})})}function tD({validations:e}){return(0,V.jsx)(cD,{title:`Validations (${e.length})`,children:(0,V.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,V.jsx)(nD,{validation:e},e.validationId))})})}function nD({validation:e}){let t=e.outcome===`pass`;return(0,V.jsxs)(`div`,{className:`bg-[var(--bg-primary)] border border-[var(--border)] px-4 py-3 text-xs space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.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,V.jsx)(`span`,{className:`text-[var(--text-muted)] font-mono`,children:e.contractRef})]}),e.issues.length>0&&(0,V.jsxs)(`div`,{className:`space-y-1`,children:[(0,V.jsx)(`div`,{className:`text-[var(--text-muted)] mb-1`,children:`Issues`}),(0,V.jsx)(`ul`,{className:`list-disc list-inside text-[var(--error)] space-y-0.5`,children:e.issues.map((e,t)=>(0,V.jsx)(`li`,{children:e},t))})]}),e.suggestions.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-[var(--text-muted)] mb-1`,children:`Suggestions`}),(0,V.jsx)(`ul`,{className:`list-disc list-inside text-[var(--text-secondary)] space-y-0.5`,children:e.suggestions.map((e,t)=>(0,V.jsx)(`li`,{children:e},t))})]})]})}function rD({gaps:e}){return(0,V.jsx)(cD,{title:`Gaps (${e.length})`,children:(0,V.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,V.jsxs)(`div`,{className:`flex items-start gap-3 text-xs bg-[var(--bg-primary)] border border-[var(--border)] px-3 py-3`,children:[(0,V.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,V.jsx)(`span`,{className:`text-[var(--text-secondary)] leading-relaxed`,children:e.summary})]},e.gapId))})})}var iD=1e5,aD=[{prefix:`text/`,render:e=>(0,V.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,V.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 oD(e){if(e.byteLength>iD)return(0,V.jsxs)(`div`,{className:`text-[var(--text-muted)] italic`,children:[`Content too large to display (`,fD(e.byteLength),` -- limit `,fD(iD),`)`]});let t=aD.find(t=>e.contentType.startsWith(t.prefix));return t?t.render(e.content):(0,V.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 sD({artifacts:e}){return(0,V.jsx)(cD,{title:`Artifacts (${e.length})`,children:(0,V.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,V.jsxs)(`div`,{className:`bg-[var(--bg-primary)] border border-[var(--border)] px-4 py-3 text-xs space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[var(--text-muted)]`,children:[(0,V.jsx)(`span`,{children:e.contentType}),(0,V.jsx)(`span`,{children:`//`}),(0,V.jsx)(`span`,{children:fD(e.byteLength)})]}),oD(e)]},e.sha256))})})}function cD({title:e,children:t}){return(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`mb-2`,children:(0,V.jsx)(Ko,{children:e})}),t]})}function lD({label:e,value:t,mono:n=!1}){return(0,V.jsxs)(`div`,{className:`bg-[var(--bg-primary)] border border-[var(--border)] px-4 py-3`,children:[(0,V.jsx)(Ko,{children:e}),(0,V.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 uD={step:{label:`Step`,color:`var(--accent)`},checkpoint:{label:`Checkpoint`,color:`var(--success)`},blocked_attempt:{label:`Blocked`,color:`var(--error)`}};function dD({kind:e}){let t=uD[e];return(0,V.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 fD(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function pD(e){return e.length>16?`\u2026${e.slice(-16)}`:e}function mD({data:e}){let t=e.runs[0]??null,n=t?.workflowName??t?.workflowId??`--`,r=t?.workflowHash?.slice(0,12)??`--`;return(0,V.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,V.jsx)(`h2`,{className:`text-base font-medium text-[var(--text-primary)] mb-3`,children:e.sessionTitle}),(0,V.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-8 gap-y-2`,children:[(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)] self-center`,children:`Session`}),(0,V.jsx)(`dd`,{className:`font-mono text-xs text-[var(--text-secondary)] self-center`,children:pD(e.sessionId)}),(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)] self-center`,children:`Workflow`}),(0,V.jsx)(`dd`,{className:`text-sm text-[var(--text-primary)] self-center`,children:n}),(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)] self-center`,children:`Hash`}),(0,V.jsx)(`dd`,{className:`font-mono text-xs text-[var(--text-secondary)] self-center`,children:r}),(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)] self-center`,children:`Status`}),(0,V.jsxs)(`dd`,{className:`self-center flex items-center gap-2`,children:[(0,V.jsx)(ao,{health:e.health}),e.health===`healthy`&&(0,V.jsx)(`span`,{className:`text-sm text-[var(--text-primary)]`,children:`Healthy`})]}),(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)] self-center`,children:`Runs`}),(0,V.jsxs)(`dd`,{className:`text-sm text-[var(--text-primary)] self-center`,children:[e.runs.length,` run`,e.runs.length===1?``:`s`]})]})]})}function hD({summary:e}){let t=new TextEncoder().encode(e).length;return(0,V.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:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,V.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)]`,children:`Injected Context`}),(0,V.jsxs)(`span`,{className:`font-mono text-[10px] text-[var(--text-muted)]`,children:[t.toLocaleString(),` bytes`]})]}),(0,V.jsx)(`pre`,{className:`font-mono text-xs text-[var(--text-secondary)] whitespace-pre-wrap break-words max-h-48 overflow-y-auto leading-relaxed`,children:e})]})}function gD(e){if(e<6e4)return`${Math.round(e/1e3)}s`;let t=Math.floor(e/6e4),n=Math.round(e%6e4/1e3);return n>0?`${t}m ${n}s`:`${t}m`}function _D({sessionId:e,metrics:t}){let[n,r]=(0,B.useState)({kind:`idle`}),i=Jy(e,!1),a=t.startGitSha!==null&&t.endGitSha!==null,o=async()=>{r({kind:`loading`});try{let e=await i.refetch();e.isSuccess&&e.data?r({kind:`loaded`,linesAdded:e.data.linesAdded,linesRemoved:e.data.linesRemoved,filesChanged:e.data.filesChanged}):r({kind:`error`,message:e.error instanceof Error?e.error.message:`Diff computation failed`})}catch(e){r({kind:`error`,message:e instanceof Error?e.message:`Diff computation failed`})}};return(0,V.jsxs)(`div`,{className:`bg-[var(--bg-card)] border border-[var(--border)] px-5 py-4 corner-brackets space-y-4`,style:{backdropFilter:`blur(12px)`,WebkitBackdropFilter:`blur(12px)`},children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)]`,children:`Session Metrics`}),(0,V.jsx)(`span`,{className:`font-mono text-[10px] text-[var(--text-muted)]`,children:`Session-level totals across all runs.`})]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[t.outcome!==null&&(0,V.jsx)(`span`,{className:`px-2 py-1 text-xs font-mono border border-[var(--border)] text-[var(--text-secondary)] bg-[var(--bg-card)]`,children:t.outcome}),t.durationMs!==void 0&&(0,V.jsx)(`span`,{className:`px-2 py-1 text-xs font-mono border border-[var(--border)] text-[var(--text-secondary)] bg-[var(--bg-card)]`,children:gD(t.durationMs)}),t.filesChanged!==null&&(0,V.jsxs)(`span`,{className:`px-2 py-1 text-xs font-mono border border-[var(--border)] text-[var(--text-secondary)] bg-[var(--bg-card)]`,children:[t.filesChanged,` file`,t.filesChanged===1?``:`s`,` changed`]}),t.captureConfidence!==`none`&&(0,V.jsxs)(`span`,{className:`px-2 py-1 text-xs font-mono border border-[var(--border)] text-[var(--text-muted)] bg-[var(--bg-card)]`,children:[t.captureConfidence,` confidence`]})]}),(0,V.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-8 gap-y-2`,children:[t.gitBranch!==null&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] self-center`,children:`Git Branch`}),(0,V.jsx)(`dd`,{className:`font-mono text-xs text-[var(--text-secondary)] self-center`,children:t.gitBranch})]}),t.startGitSha!==null&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] self-center`,children:`Start SHA`}),(0,V.jsx)(`dd`,{className:`font-mono text-xs text-[var(--text-secondary)] self-center`,children:t.startGitSha.slice(0,12)})]}),t.endGitSha!==null&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] self-center`,children:`End SHA`}),(0,V.jsx)(`dd`,{className:`font-mono text-xs text-[var(--text-secondary)] self-center`,children:t.endGitSha.slice(0,12)})]}),t.durationMs!==void 0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] self-center`,children:`Duration`}),(0,V.jsx)(`dd`,{className:`font-mono text-xs text-[var(--text-secondary)] self-center`,children:gD(t.durationMs)})]}),t.agentCommitShas.length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] self-start`,children:`Commits`}),(0,V.jsx)(`dd`,{className:`font-mono text-xs text-[var(--text-secondary)]`,children:t.agentCommitShas.map(e=>(0,V.jsx)(`div`,{children:e.slice(0,12)},e))})]}),t.outcome!==null&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] self-center`,children:`Outcome`}),(0,V.jsxs)(`dd`,{className:`text-xs text-[var(--text-secondary)] self-center`,children:[t.outcome,` `,(0,V.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`(agent-reported)`})]})]}),t.filesChanged!==null&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] self-center`,children:`Files Changed`}),(0,V.jsxs)(`dd`,{className:`text-xs text-[var(--text-secondary)] self-center`,children:[t.filesChanged,` `,(0,V.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`(agent-reported)`})]})]}),t.linesAdded!==null&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] self-center`,children:`Lines Added`}),(0,V.jsxs)(`dd`,{className:`text-xs text-[var(--text-secondary)] self-center`,children:[t.linesAdded,` `,(0,V.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`(agent-reported)`})]})]}),t.linesRemoved!==null&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] self-center`,children:`Lines Removed`}),(0,V.jsxs)(`dd`,{className:`text-xs text-[var(--text-secondary)] self-center`,children:[t.linesRemoved,` `,(0,V.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`(agent-reported)`})]})]}),t.prNumbers.length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] self-center`,children:`PRs`}),(0,V.jsxs)(`dd`,{className:`text-xs text-[var(--text-secondary)] self-center`,children:[t.prNumbers.join(`, `),` `,(0,V.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`(agent-reported)`})]})]}),n.kind===`loaded`&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] self-center`,children:`LOC Added`}),(0,V.jsxs)(`dd`,{className:`text-xs text-[var(--text-secondary)] self-center`,children:[n.linesAdded,` `,(0,V.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`(git diff)`})]}),(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] self-center`,children:`LOC Removed`}),(0,V.jsxs)(`dd`,{className:`text-xs text-[var(--text-secondary)] self-center`,children:[n.linesRemoved,` `,(0,V.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`(git diff)`})]})]})]}),a&&n.kind!==`loaded`&&(0,V.jsxs)(`div`,{className:`flex items-center gap-3 pt-1`,children:[n.kind===`idle`&&(0,V.jsx)(`button`,{type:`button`,onClick:()=>{o()},className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] hover:text-[var(--text-primary)] border border-[var(--border)] px-3 py-1.5 transition-colors`,children:`Load diff`}),n.kind===`loading`&&(0,V.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)]`,children:`Computing...`}),n.kind===`error`&&(0,V.jsxs)(`span`,{className:`text-xs text-[var(--error)]`,children:[n.message,` `,(0,V.jsx)(`button`,{type:`button`,onClick:()=>{o()},className:`underline text-[var(--text-muted)] hover:text-[var(--text-primary)] transition-colors`,children:`Retry`})]})]})]})}function vD({runs:e}){let t=e.some(e=>e.preferredTipNodeId!==null),n=e.some(e=>e.executionTraceSummary!==null);return(0,V.jsxs)(`div`,{className:`border border-[var(--border)] px-4 py-3 text-xs text-[var(--text-muted)] space-y-1`,children:[(0,V.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,V.jsxs)(`p`,{children:[`This run has execution trace data. Click`,` `,(0,V.jsx)(`span`,{className:`font-mono uppercase tracking-[0.16em]`,children:`[ TRACE ]`}),` `,`to see why certain steps ran, were skipped, or repeated.`]})]})}function yD({viewModel:e}){let{state:t,onSelectNode:n,onCloseNode:r}=e;if(t.kind===`loading`)return(0,V.jsx)(`div`,{className:`text-[var(--text-secondary)]`,children:`Loading session...`});if(t.kind===`error`)return(0,V.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,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsx)(mD,{data:a}),a.metrics!==null&&(0,V.jsx)(_D,{sessionId:i,metrics:a.metrics}),a.injectedContext!==void 0&&(0,V.jsx)(hD,{summary:a.injectedContext.assembledContextSummary}),a.runs.length===0?(0,V.jsx)(`div`,{className:`text-center py-16 text-[var(--text-secondary)]`,children:`No runs in this session`}):(0,V.jsxs)(V.Fragment,{children:[o===null&&(0,V.jsx)(vD,{runs:a.runs}),(0,V.jsx)(`div`,{className:`space-y-6`,children:a.runs.map(e=>(0,V.jsx)(bD,{run:e,selectedNodeId:o?.runId===e.runId?o.nodeId:null,onNodeClick:n},e.runId))})]})]}),(0,V.jsxs)(W,{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,V.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-[var(--border)] shrink-0 console-blueprint-grid`,children:[(0,V.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)]`,children:`Node detail`}),(0,V.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,V.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,V.jsx)(VE,{sessionId:i,nodeId:o?.nodeId??null,runStatus:s?.status??`complete`,currentNodeId:s?.preferredTipNodeId??null,executionTraceSummary:s?.executionTraceSummary??null})})]})]})}function bD({run:e,selectedNodeId:t,onNodeClick:n}){let r=e.executionTraceSummary!==null,[i,a]=(0,B.useState)(`dag`);return(0,V.jsxs)(W,{cut:10,background:`rgba(27, 31, 44, 0.72)`,backdropFilter:`blur(8px)`,className:`relative`,style:{height:r?`542px`:`506px`},children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-[var(--border)] shrink-0`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(`span`,{className:`text-sm font-medium text-[var(--text-primary)]`,children:e.workflowName??e.workflowId??`Run`}),(0,V.jsx)(`span`,{className:`font-mono text-xs text-[var(--text-muted)]`,children:e.runId}),(0,V.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,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.hasUnresolvedCriticalGaps&&(0,V.jsx)(`span`,{className:`text-xs text-[var(--warning)]`,children:`Critical gaps`}),(0,V.jsx)(io,{status:e.status})]})]}),r&&(0,V.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,V.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,V.jsx)(`span`,{className:`tab-corner tab-corner--tl`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--tr`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--bl`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--br`,"aria-hidden":`true`}),`DAG`]}),(0,V.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,V.jsx)(`span`,{className:`tab-corner tab-corner--tl`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--tr`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--bl`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--br`,"aria-hidden":`true`}),`TRACE`]})]}),(0,V.jsx)(`div`,{role:`tabpanel`,"aria-labelledby":i===`dag`?`tab-dag`:`tab-trace`,className:`flex-1`,children:i===`trace`&&e.executionTraceSummary!==null?(0,V.jsx)(Vy,{summary:e.executionTraceSummary,runStatus:e.status}):(0,V.jsx)(hy,{run:e,selectedNodeId:t,onNodeClick:t=>n(e.runId,t)})})]})}function xD(){let[e,t]=(0,B.useState)(0),[n,r]=(0,B.useState)(0),[i,a]=(0,B.useState)(38),[o,s]=(0,B.useState)(62),[c,l]=(0,B.useState)(3),[u,d]=(0,B.useState)(2),[f,p]=(0,B.useState)(``),[m,h]=(0,B.useState)(!1),g=(0,B.useRef)(!1),_=(0,B.useRef)(null),v=(0,B.useRef)(null),y=(0,B.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 SD=[{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`}],CD=Object.fromEntries(SD.map(e=>[e.id,e.label]));function wD({label:e,count:t,countLabel:n=`workflow`,showRule:r=!0,separator:i=`//`}){return(0,V.jsxs)(`div`,{className:`flex items-center gap-3 mb-3 mt-2`,children:[(0,V.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,V.jsx)(`div`,{className:`flex-1 h-px bg-[var(--border)]`})]})}function TD({segments:e,className:t=``}){return(0,V.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,V.jsxs)(`span`,{className:`flex items-center`,children:[(0,V.jsx)(`span`,{className:`font-mono text-[10px] tracking-[0.25em] text-[var(--text-muted)] mx-1`,children:`//`}),i?(0,V.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,V.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 ED({viewModel:e}){let{state:t}=e;if(t.kind===`not_found`)return(0,V.jsx)(`div`,{className:`space-y-5 max-w-3xl`,children:(0,V.jsx)(MD,{message:``,is404:!0,onRetry:()=>void 0,onBack:t.onBack})});if(t.kind===`error`)return(0,V.jsx)(`div`,{className:`space-y-5 max-w-3xl`,children:(0,V.jsx)(MD,{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,V.jsxs)(`div`,{className:`space-y-5 max-w-3xl`,children:[(0,V.jsx)(TD,{segments:n?[{label:`Workflows`,onClick:r},{label:n}]:[{label:`Workflows`,onClick:r}]}),e?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(DD,{name:e.name,description:e.description,tags:e.tags,source:e.source,stepCount:void 0}),(0,V.jsx)(`div`,{className:`space-y-4`,children:(0,V.jsx)(AD,{})})]}):(0,V.jsx)(jD,{})]})}let{workflow:n,name:r,description:i,tags:a,source:o,activeTagLabel:s,onPrev:c,onNext:l,onBack:u}=t;return(0,V.jsxs)(`div`,{className:`space-y-5 max-w-3xl`,children:[(0,V.jsx)(TD,{segments:s?[{label:`Workflows`,onClick:u},{label:s}]:[{label:`Workflows`,onClick:u}]}),(0,V.jsx)(DD,{name:r,description:i,tags:a,source:o,stepCount:n.stepCount}),(c??l)&&(0,V.jsxs)(`div`,{className:`flex items-center gap-4`,children:[c&&(0,V.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,V.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,V.jsx)(OD,{detail:n,name:r}),(0,V.jsx)(TD,{segments:[{label:`Workflows`,onClick:u}]})]})}function DD({name:e,description:t,tags:n,source:r,stepCount:i}){return(0,V.jsxs)(`div`,{className:`border border-[var(--border)] px-5 py-5 console-blueprint-grid`,children:[(0,V.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-[0.35em] text-[var(--text-muted)] mb-2`,children:`// Workflow`}),(0,V.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,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i!=null&&i>0&&(0,V.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,V.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,V.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,V.jsx)(`p`,{className:`text-sm text-[var(--text-secondary)] leading-relaxed mt-3`,children:t})]})}function OD({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,V.jsxs)(`div`,{className:`space-y-6`,children:[n&&(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider mb-3`,children:`About`}),(0,V.jsx)(BE,{children:e.about})]}),r&&(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider mb-3`,children:`Try it with:`}),(0,V.jsx)(`ul`,{className:`space-y-2`,children:e.examples.map(e=>(0,V.jsxs)(`li`,{className:`flex items-start gap-3 bg-[var(--bg-card)] border border-[var(--border)] rounded-none px-4 py-3`,children:[(0,V.jsx)(`div`,{"aria-hidden":`true`,className:`w-0.5 shrink-0 self-stretch rounded-full`,style:{backgroundColor:`var(--accent)`}}),(0,V.jsxs)(`span`,{className:`text-sm text-[var(--text-secondary)] leading-relaxed`,children:[`"`,e,`"`]})]},e))})]}),i&&(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider mb-3`,children:`Before you start:`}),(0,V.jsx)(`ul`,{className:`space-y-1.5`,children:e.preconditions.map(e=>(0,V.jsxs)(`li`,{className:`flex items-start gap-2 text-sm text-[var(--text-secondary)]`,children:[(0,V.jsx)(`span`,{className:`shrink-0 text-[var(--text-muted)] mt-0.5`,children:`•`}),(0,V.jsx)(`span`,{children:e})]},e))})]}),(0,V.jsx)(kD,{name:t})]}):(0,V.jsx)(`p`,{className:`text-sm text-[var(--text-muted)] italic`,children:`No additional documentation available.`})}function kD({name:e}){let[t,n]=(0,B.useState)(!1),r=`Use the ${e} to [your goal]`;return(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider mb-3`,children:`Start with this prompt`}),(0,V.jsxs)(`div`,{className:`flex items-center gap-3 border border-[var(--border)] px-4 py-3`,children:[(0,V.jsxs)(`span`,{className:`flex-1 text-sm text-[var(--text-secondary)] font-mono truncate`,children:[`"`,r,`"`]}),(0,V.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 AD(){return(0,V.jsxs)(`div`,{className:`space-y-3 motion-safe:animate-pulse`,children:[(0,V.jsx)(`div`,{className:`h-3 w-16 rounded bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`h-4 w-full rounded bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`h-4 w-5/6 rounded bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`h-4 w-4/6 rounded bg-[var(--bg-tertiary)]`})]})}function jD(){return(0,V.jsxs)(`div`,{className:`space-y-6 motion-safe:animate-pulse`,children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`div`,{className:`h-6 w-1/2 rounded bg-[var(--bg-tertiary)]`}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(`div`,{className:`h-5 w-16 rounded bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`h-5 w-24 rounded bg-[var(--bg-tertiary)]`})]}),(0,V.jsx)(`div`,{className:`h-4 w-full rounded bg-[var(--bg-tertiary)]`})]}),(0,V.jsx)(AD,{})]})}function MD({message:e,is404:t,onRetry:n,onBack:r}){return(0,V.jsxs)(`div`,{className:`space-y-4 bg-[var(--bg-card)] border border-[var(--border)] p-4`,children:[(0,V.jsx)(`p`,{className:`text-sm text-[var(--error)]`,children:t?`Workflow not found.`:e}),(0,V.jsxs)(`div`,{className:`flex gap-3`,children:[!t&&(0,V.jsx)(`button`,{type:`button`,onClick:n,className:`text-sm text-[var(--accent)] hover:text-[var(--accent-hover)] transition-colors`,children:`Try again`}),(0,V.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 ND(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 PD(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 FD(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 ID({count:e,cols:t=`auto`,onActivate:n,loop:r=!0}){let[i,a]=(0,B.useState)(null),o=(0,B.useRef)(new Map),s=(0,B.useCallback)(e=>{a(e),e!==null&&o.current.get(e)?.focus()},[]),c=(0,B.useCallback)(()=>t===`auto`?ND(o.current):Math.max(1,t),[t]);return{focusedIndex:i,setFocusedIndex:s,getItemProps:(0,B.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=PD(t,1,e,r);break;case`ArrowLeft`:case`a`:case`A`:o=PD(t,-1,e,r);break;case`ArrowDown`:case`s`:case`S`:o=FD(t,1,e,a,r);break;case`ArrowUp`:case`w`:case`W`:o=FD(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 LD(e){let t=Qy(e),n=()=>{t.refetch()};return t.isLoading?{kind:`loading`}:t.error?t.error instanceof Uy&&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 RD(){let e=Xy();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 zD(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 BD({workflowId:e,activeTag:t,onBack:n,onNavigateToWorkflow:r}){let i=LD(e),a=RD().workflows,o=(0,B.useRef)(null),s=(0,B.useRef)(null),c=(0,B.useRef)(r);c.current=r;let l=a??[],{prevWorkflow:u,nextWorkflow:d}=(0,B.useMemo)(()=>zD(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,B.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,B.useMemo)(()=>{let r=a?.find(t=>t.id===e)??void 0,o=t?CD[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 VD(e){let t=new Set(SD.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=SD.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 HD({viewModel:e}){let{state:t,dispatch:n,triggerRef:r,onCardSelect:i}=e,a=(0,B.useRef)(null),o=(0,B.useRef)(null),s=xD(),c=t.kind===`ready`?t.selectedWorkflowId:null;if((0,B.useEffect)(()=>{if(c){let e=requestAnimationFrame(()=>a.current?.focus());return()=>cancelAnimationFrame(e)}},[c]),t.kind===`loading`)return(0,V.jsx)(KD,{});if(t.kind===`error`)return(0,V.jsx)(qD,{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(SD.map(e=>e.id)),v=new Set(h.flatMap(e=>e.tags)),y=new Map(SD.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,V.jsx)(UD,{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 UD({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=BD({workflowId:e,activeTag:t,onBack:()=>m({type:`modal_closed`}),onNavigateToWorkflow:e=>m({type:`workflow_selected`,id:e})}),b=(0,B.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,B.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}=ID({count:a.length,cols:`auto`,onActivate:(0,B.useCallback)(e=>{let t=a[e];if(!t)return;let n=document.activeElement;n instanceof HTMLButtonElement&&h(t.id,n)},[a,h])});return(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.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,V.jsxs)(`p`,{className:`font-mono text-[10px] tracking-[0.25em] text-[var(--text-muted)] mt-1.5`,children:[`// `,i.length,` available`]})]}),(0,V.jsxs)(`div`,{role:`group`,"aria-label":`Filter workflows by category`,className:`flex flex-wrap gap-1.5`,children:[(0,V.jsx)(WD,{label:`All`,count:u,isActive:t===null,disabled:!1,onClick:()=>m({type:`tag_changed`,tag:null})}),SD.filter(e=>s.has(e.id)).map(e=>(0,V.jsx)(WD,{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,V.jsx)(WD,{label:`Other`,count:l,isActive:t===`__other__`,disabled:!1,onClick:()=>m({type:`tag_changed`,tag:t===`__other__`?null:`__other__`})})]}),o.length>1&&(0,V.jsxs)(`div`,{role:`group`,"aria-label":`Filter workflows by source`,className:`flex flex-wrap gap-1.5`,children:[(0,V.jsx)(WD,{label:`All Sources`,count:d,isActive:n===null,disabled:!1,onClick:()=>m({type:`source_changed`,source:null})}),o.map(e=>(0,V.jsx)(WD,{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,V.jsxs)(`div`,{className:`py-8 text-center space-y-3`,children:[(0,V.jsx)(`p`,{className:`text-sm text-[var(--text-muted)]`,children:`No workflows in this category.`}),t!==null&&(0,V.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,V.jsx)(`div`,{className:`space-y-6`,children:(()=>{let t=0;return VD(i).map(n=>(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(wD,{label:n.label,count:n.workflows.length,showRule:!0}),(0,V.jsx)(`div`,{...S,className:`grid grid-cols-2 lg:grid-cols-3 gap-3`,children:n.workflows.map(n=>(0,V.jsx)(GD,{workflow:n,onSelect:e=>h(n.id,e),navProps:x(t++),isActive:n.id===e},n.id))})]},n.tagId??`__other__`))})()}):(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(wD,{label:t===`__other__`?`Other`:CD[t]??t,count:i.length,showRule:!0}),(0,V.jsx)(`div`,{...S,className:`grid grid-cols-2 lg:grid-cols-3 gap-3`,children:i.map((t,n)=>(0,V.jsx)(GD,{workflow:t,onSelect:e=>h(t.id,e),navProps:x(n),isActive:t.id===e},t.id))})]}),(0,V.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-end justify-center p-4 pointer-events-none`,"aria-hidden":!e,children:[e&&(0,V.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,V.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,V.jsxs)(W,{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,V.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:co(20)}},v.state.scanline.key),(0,V.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,V.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,V.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-secondary)]`,children:`Workflow`}),p>=0&&(0,V.jsxs)(`span`,{className:`font-mono text-[10px] tracking-[0.20em] text-[var(--text-secondary)]`,children:[`[ `,p+1,` / `,a.length,` ]`]}),(0,V.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,V.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,V.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,V.jsx)(`div`,{"aria-live":`polite`,"aria-atomic":`true`,className:`sr-only`,children:a.find(t=>t.id===e)?.name??``}),e&&(0,V.jsx)(ED,{viewModel:y})]})]})})]})]})}function WD({label:e,count:t,isActive:n,disabled:r,onClick:i}){return(0,V.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,V.jsx)(`span`,{className:`sr-only`,children:`(selected)`})]})}function GD({workflow:e,onSelect:t,navProps:n,isActive:r}){let i=e.tags.filter(e=>e!==`routines`).map(e=>CD[e]??e);return(0,V.jsx)(lo,{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,V.jsxs)(`div`,{className:`flex flex-col flex-1 p-4 gap-2 min-w-0`,children:[(0,V.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,V.jsx)(`p`,{className:`text-xs text-[var(--text-secondary)] line-clamp-3 leading-relaxed flex-1`,children:e.description}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mt-auto pt-2 border-t border-[var(--border)]`,children:[(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:i.slice(0,1).map(e=>(0,V.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,V.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e.stepCount!=null&&e.stepCount>0&&(0,V.jsxs)(`span`,{className:`font-mono text-[9px] text-[var(--text-muted)]`,children:[e.stepCount,`s`]}),(0,V.jsxs)(`span`,{className:`font-mono text-[9px] text-[var(--text-muted)] max-w-[80px] truncate`,children:[`src: `,e.source.displayName]})]})]})]})})}function KD(){return(0,V.jsx)(`div`,{className:`space-y-6 motion-safe:animate-pulse`,children:[0,1].map(e=>(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(`div`,{className:`h-3 w-24 bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`flex-1 h-px bg-[var(--bg-tertiary)]`})]}),(0,V.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-3 gap-3`,children:[0,1,2,3,4,5].map(e=>(0,V.jsxs)(`div`,{className:`min-h-[160px] bg-[var(--bg-card)] border border-[var(--border)] flex flex-col`,children:[(0,V.jsx)(`div`,{className:`h-[3px] bg-[var(--bg-tertiary)]`}),(0,V.jsxs)(`div`,{className:`p-4 flex flex-col gap-2 flex-1`,children:[(0,V.jsx)(`div`,{className:`h-4 w-3/4 bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`h-3 w-full bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`h-3 w-5/6 bg-[var(--bg-tertiary)]`}),(0,V.jsxs)(`div`,{className:`mt-auto pt-2 border-t border-[var(--border)] flex justify-between`,children:[(0,V.jsx)(`div`,{className:`h-3 w-12 bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`h-3 w-16 bg-[var(--bg-tertiary)]`})]})]})]},e))})]},e))})}function qD({message:e,onRetry:t}){return(0,V.jsxs)(`div`,{className:`space-y-3 py-8 text-center`,children:[(0,V.jsx)(`p`,{className:`text-sm text-[var(--error)]`,children:e}),(0,V.jsx)(`button`,{type:`button`,onClick:t,className:`text-sm text-[var(--accent)] hover:text-[var(--accent-hover)] transition-colors`,children:`Try again`})]})}var JD=[{value:`recent`,label:`Recent first`,compareFn:(e,t)=>t.startedAtMs-e.startedAtMs},{value:`slowest`,label:`Slowest first`,compareFn:(e,t)=>t.durationMs-e.durationMs}],YD={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 XD(e,t){let n=JD.find(e=>e.value===t);return[...e].sort(n.compareFn)}function ZD(e){return e.reduce((e,t)=>Math.max(e,t.durationMs),0)}function QD(e){return e.filter(e=>YD[e.outcome].isError).length}function $D(e){return e.length===0?null:Math.round(e.reduce((e,t)=>e+t.durationMs,0)/e.length)}function eO(e){return e.length===0?null:e.reduce((e,t)=>Math.max(e,t.startedAtMs),0)}function tO(e,t){return t>0?Math.round(e/t*120):0}function nO(e){return`${e} recorded`}var rO=[{key:`tool`,label:`Tool`,minWidth:`180px`},{key:`duration`,label:`Duration`,width:`220px`},{key:`started`,label:`Started`,width:`100px`},{key:`outcome`,label:`Outcome`}];function iO({viewModel:e}){let{state:t}=e;if(t.kind===`loading`)return(0,V.jsx)(cO,{});if(t.kind===`devModeOff`)return(0,V.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,V.jsx)(`p`,{className:`text-sm text-[var(--text-muted)] text-center`,children:`nothing to see here`})});if(t.kind===`error`)return(0,V.jsxs)(`div`,{className:`space-y-3 py-8 text-center`,children:[(0,V.jsx)(`p`,{className:`text-sm text-[var(--error)]`,children:t.message}),(0,V.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,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsxs)(`p`,{className:`text-sm text-[var(--text-secondary)]`,children:[s,` | `,(0,V.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`:fo(o)]}),(0,V.jsx)(`div`,{role:`radiogroup`,"aria-label":`Sort order`,className:`flex items-center gap-1`,children:JD.map(e=>(0,V.jsx)(sO,{label:e.label,isActive:c===e.value,onClick:()=>l(e.value)},e.value))}),(0,V.jsxs)(`table`,{className:`w-full text-sm border-collapse`,children:[(0,V.jsx)(`thead`,{children:(0,V.jsx)(`tr`,{className:`text-xs text-[var(--text-muted)] border-b border-[var(--border)]`,children:rO.map(e=>(0,V.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,V.jsx)(`tbody`,{children:n.length===0?(0,V.jsx)(`tr`,{children:(0,V.jsx)(`td`,{colSpan:rO.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,V.jsx)(aO,{obs:e,maxDuration:r},`${e.startedAtMs}-${e.toolName}-${t}`))})]})]})}function aO({obs:e,maxDuration:t}){let n=YD[e.outcome].isError,r=tO(e.durationMs,t);return(0,V.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,V.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,V.jsx)(`span`,{className:`block truncate`,children:e.toolName})}),(0,V.jsxs)(`td`,{className:`py-2 pr-4`,style:{width:`220px`},children:[(0,V.jsxs)(`span`,{className:`font-mono text-[var(--text-primary)]`,children:[e.durationMs,`ms`]}),(0,V.jsx)(`div`,{"aria-hidden":`true`,className:`h-1 rounded mt-1`,style:{backgroundColor:`var(--accent)`,width:`${r}px`,maxWidth:`120px`}})]}),(0,V.jsx)(`td`,{className:`py-2 pr-4 text-[var(--text-secondary)]`,style:{width:`100px`},children:fo(e.startedAtMs)}),(0,V.jsx)(`td`,{className:`py-2`,children:(0,V.jsx)(oO,{outcome:e.outcome})})]})}function oO({outcome:e}){let t=YD[e];return(0,V.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 sO({label:e,isActive:t,onClick:n}){return(0,V.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 cO(){return(0,V.jsxs)(`div`,{className:`space-y-3 animate-pulse`,"aria-busy":`true`,"aria-label":`Loading performance data`,children:[(0,V.jsx)(`div`,{className:`h-4 w-64 rounded bg-[var(--bg-tertiary)]`}),(0,V.jsxs)(`div`,{className:`flex gap-1`,children:[(0,V.jsx)(`div`,{className:`h-8 w-24 rounded bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`h-8 w-24 rounded bg-[var(--bg-tertiary)]`})]}),(0,V.jsxs)(`div`,{className:`flex gap-4 border-b border-[var(--border)] pb-2`,children:[(0,V.jsx)(`div`,{className:`h-3 w-20 rounded bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`h-3 w-16 rounded bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`h-3 w-14 rounded bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`h-3 w-14 rounded bg-[var(--bg-tertiary)]`})]}),Array.from({length:8}).map((e,t)=>(0,V.jsxs)(`div`,{className:`flex gap-4 py-2`,children:[(0,V.jsx)(`div`,{className:`h-4 rounded bg-[var(--bg-tertiary)]`,style:{minWidth:`180px`,width:`180px`}}),(0,V.jsxs)(`div`,{className:`space-y-1`,style:{width:`220px`},children:[(0,V.jsx)(`div`,{className:`h-4 w-16 rounded bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`h-1 w-20 rounded bg-[var(--bg-tertiary)]`})]}),(0,V.jsx)(`div`,{className:`h-4 w-16 rounded bg-[var(--bg-tertiary)]`,style:{width:`100px`}}),(0,V.jsx)(`div`,{className:`h-5 w-12 rounded bg-[var(--bg-tertiary)]`})]},t))]})}var lO=`workrail:auto:mru-workflow`;function uO(){try{return localStorage.getItem(lO)}catch{return null}}function dO(e){try{localStorage.setItem(lO,e)}catch{}}function fO(){let e=Xy(),t=$y(),n=e.data?.workflows??[],r=t.data?.triggers??[],[i,a]=(0,B.useState)(()=>uO()??``),[o,s]=(0,B.useState)(``),[c,l]=(0,B.useState)(``),[u,d]=(0,B.useState)(!1),[f,p]=(0,B.useState)(null),[m,h]=(0,B.useState)(!1),[g,_]=(0,B.useState)(!0),v=(0,B.useRef)(null);(0,B.useEffect)(()=>{!i&&n.length>0&&a(n[0]?.id??``)},[i,n]);let y=e=>{a(e),dO(e)},b=async()=>{if(!(!i||!c.trim()||!o.trim())){d(!0),p(null),h(!1);try{await eb({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,V.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,V.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,V.jsx)(Ko,{color:`var(--accent)`,children:`Dispatch`})}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(Ko,{children:`Workflow`}),e.isLoading?(0,V.jsx)(`div`,{className:`text-[var(--text-muted)] text-xs`,children:`Loading workflows...`}):n.length===0?(0,V.jsx)(`div`,{className:`text-[var(--text-muted)] text-xs`,children:`No workflows available`}):(0,V.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,V.jsx)(`option`,{value:e.id,children:e.name??e.id},e.id))})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(Ko,{children:`Workspace path`}),(0,V.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,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(Ko,{children:`Goal`}),(0,V.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,V.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,V.jsx)(`button`,{onClick:()=>void b(),disabled:!x,className:`self-start disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer`,children:(0,V.jsx)(no,{label:u?`RUNNING...`:`RUN`,color:x?`var(--accent)`:void 0,pulse:u})}),m&&(0,V.jsx)(`div`,{className:`text-[var(--success)] font-mono text-[10px] uppercase tracking-[0.20em]`,children:`Dispatched -- check Queue pane`}),f&&(0,V.jsx)(`div`,{className:`text-[var(--error)] text-xs font-mono`,children:f})]}),(0,V.jsxs)(`div`,{className:`border-t border-[var(--border)] pt-4`,children:[(0,V.jsxs)(`button`,{onClick:()=>_(!g),className:`flex items-center gap-2 mb-2 cursor-pointer group`,children:[(0,V.jsx)(`span`,{className:`text-[var(--text-muted)] text-xs transition-transform duration-150`,style:{transform:g?`rotate(-90deg)`:`rotate(0deg)`},children:`▼`}),(0,V.jsx)(no,{label:`TRIGGERS`,color:`var(--text-secondary)`}),r.length>0&&(0,V.jsxs)(`span`,{className:`text-xs text-[var(--text-muted)]`,children:[`(`,r.length,`)`]})]}),!g&&(0,V.jsx)(`div`,{className:`space-y-2`,children:t.isLoading?(0,V.jsx)(`div`,{className:`text-[var(--text-muted)] text-xs pl-4`,children:`Loading triggers...`}):r.length===0?(0,V.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,V.jsxs)(`div`,{className:`pl-4 border-l-2 border-[var(--border)] text-xs space-y-0.5`,children:[(0,V.jsx)(`div`,{className:`font-mono text-[var(--text-primary)] text-[11px]`,children:e.id}),(0,V.jsx)(`div`,{className:`text-[var(--text-muted)]`,children:e.workflowId}),(0,V.jsx)(`div`,{className:`text-[var(--text-muted)] truncate`,children:e.goal})]},e.id))})]})]})}function pO(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 mO(){let{data:e,isLoading:t,isError:n}=Gy(),r=(e?.sessions??[]).filter(e=>e.isAutonomous),{running:i,blocked:a,completed:o}=pO(r);return t?(0,V.jsx)(`div`,{className:`flex items-center justify-center py-20`,children:(0,V.jsx)(`div`,{className:`text-[var(--text-secondary)] text-sm`,children:`Loading sessions...`})}):n?(0,V.jsx)(`div`,{className:`text-[var(--error)] bg-[var(--bg-card)] rounded-lg p-4 text-sm`,children:`Failed to load sessions`}):(0,V.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,V.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,V.jsx)(Ko,{color:`var(--accent)`,children:`Queue`})}),(0,V.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,V.jsx)(hO,{count:i,label:`RUNNING`,color:`var(--accent)`,pulse:!0}),(0,V.jsx)(hO,{count:a,label:`BLOCKED`,color:`var(--blocked)`}),(0,V.jsx)(hO,{count:o,label:`COMPLETED`,color:`var(--success)`})]}),r.length===0?(0,V.jsxs)(`div`,{className:`text-center py-16`,children:[(0,V.jsx)(`p`,{className:`text-[var(--text-secondary)] text-sm`,children:`No autonomous sessions yet`}),(0,V.jsx)(`p`,{className:`text-[var(--text-muted)] text-xs mt-1`,children:`Dispatch a workflow from the left pane to start.`})]}):(0,V.jsx)(`div`,{className:`space-y-2`,children:r.map(e=>(0,V.jsx)(gO,{session:e},e.sessionId))})]})}function hO({count:e,label:t,color:n,pulse:r}){return(0,V.jsx)(no,{label:`${e} ${t}`,color:e>0?n:`var(--text-muted)`,pulse:r&&e>0})}function gO({session:e}){let[t,n]=(0,B.useState)(!1),r=wi(),i=e.sessionTitle??e.workflowName??e.workflowId??`Unnamed session`,a=fo(e.lastModifiedMs);return(0,V.jsxs)(`div`,{className:`bg-[var(--bg-card)] border border-[var(--border)] rounded-lg overflow-hidden`,children:[(0,V.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,V.jsx)(`span`,{className:`text-[var(--text-muted)] text-xs transition-transform duration-150 shrink-0`,style:{transform:t?`rotate(90deg)`:`rotate(0deg)`},children:`▶`}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-sm font-medium text-[var(--text-primary)] truncate group-hover:text-[var(--accent)] transition-colors`,children:i}),(0,V.jsx)(`div`,{className:`font-mono text-[10px] text-[var(--text-muted)] opacity-60 truncate`,children:e.sessionId})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,V.jsx)(`span`,{className:`text-[10px] text-[var(--text-muted)] tabular-nums`,children:a}),e.isLive&&(0,V.jsx)(no,{label:`LIVE`,pulse:!0,color:`var(--accent)`,"aria-label":`Actively running`}),(0,V.jsx)(io,{status:e.status})]})]}),t&&(0,V.jsxs)(`div`,{className:`px-4 pb-4 border-t border-[var(--border)] pt-3 space-y-3`,children:[e.recapSnippet?(0,V.jsx)(`div`,{className:`text-xs text-[var(--text-secondary)] font-mono whitespace-pre-wrap leading-relaxed`,children:e.recapSnippet}):(0,V.jsx)(`div`,{className:`text-xs text-[var(--text-muted)]`,children:`No recap available yet.`}),(0,V.jsx)(`button`,{onClick:()=>void r({to:`/session/$sessionId`,params:{sessionId:e.sessionId}}),className:`cursor-pointer`,children:(0,V.jsx)(no,{label:`OPEN IN DAG`,color:`var(--accent)`})})]})]})}function _O(){return(0,V.jsxs)(`div`,{className:`flex flex-col md:flex-row gap-6`,children:[(0,V.jsx)(`div`,{className:`w-full md:w-2/5 shrink-0`,children:(0,V.jsx)(fO,{})}),(0,V.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,V.jsx)(mO,{})})]})}function vO(){let e=Gy(),t=Yy();tb();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 yO={scope:`active`,focusedIndex:-1,archive:null};function bO(e){throw Error(`Unhandled WorkspaceEvent type: ${String(e.type)}`)}function xO(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 bO(t)}}var SO=720*60*60*1e3,CO={in_progress:0,dormant:0,blocked:1,complete_with_gaps:2,complete:3};function wO(e){if(e.length!==0)return[...e].sort((e,t)=>{let n=CO[e.status]-CO[t.status];return n===0?t.lastModifiedMs-e.lastModifiedMs:n})[0]}function TO(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<SO||t===`all`?`visible`:`hidden`}function EO(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 DO(e,t,n){return[...e].filter(e=>TO(e,t,n)===`visible`).sort((e,t)=>{let n=EO(e)-EO(t);return n===0?t.activityMs-e.activityMs:n})}function OO(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=wO(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 kO(e,t,n,r){let i=OO(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:DO(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 AO({items:e,focusedIndex:t,scope:n,archive:r,dispatch:i,onSelectSession:a,onRefetch:o,disabled:s}){let c=(0,B.useRef)(e);c.current=e;let l=(0,B.useRef)(t);l.current=t;let u=(0,B.useRef)(n);u.current=n;let d=(0,B.useRef)(r);d.current=r;let f=(0,B.useRef)(s);f.current=s;let p=(0,B.useRef)(i);p.current=i;let m=(0,B.useRef)(a);m.current=a;let h=(0,B.useRef)(o);h.current=o,(0,B.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 jO(e=!1){let t=wi(),n=vO(),[r,i]=(0,B.useReducer)(xO,yO),a=(0,B.useRef)(0),o=(0,B.useCallback)(e=>{a.current=window.scrollY,t({to:`/session/$sessionId`,params:{sessionId:e}})},[t]),s=i,c=(0,B.useMemo)(()=>n.sessions?kO(n.sessions,n.worktreeRepos,r.scope,Date.now()):null,[n.sessions,n.worktreeRepos,r.scope]);AO({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,B.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 MO(){let e=Gy();return{sessions:e.data?.sessions,isLoading:e.isLoading,error:e.error instanceof Error?e.error:null}}function NO(e=``){return{rawSearch:e,sort:`recent`,groupBy:`none`,statusFilter:`all`,page:0,viewMode:`flat`}}function PO(e){throw Error(`Unhandled SessionListEvent type: ${String(e.type)}`)}function FO(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 PO(t)}}var IO={in_progress:0,blocked:1,dormant:2,complete_with_gaps:3,complete:4},LO=[{value:`recent`,label:`Recent`,compareFn:(e,t)=>t.lastModifiedMs-e.lastModifiedMs},{value:`status`,label:`Status`,compareFn:(e,t)=>IO[e.status]-IO[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}],RO=[{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)=>(IO[e]??99)-(IO[t]??99)},{value:`branch`,label:`Branch`,keyFn:e=>e.gitBranch??`No branch`}],zO=[{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 BO(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 VO(e,t){let n=LO.find(e=>e.value===t)??LO[0];return[...e].sort(n.compareFn)}function HO(e,t){let n=RO.find(e=>e.value===t)??RO[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 UO(e){let t={all:e.length};for(let n of e)t[n.status]=(t[n.status]??0)+1;return t}function WO(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 GO(e,t){let[n,r]=(0,B.useState)(e),i=(0,B.useRef)(null);return(0,B.useEffect)(()=>(i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>r(e),t),()=>{i.current!==null&&clearTimeout(i.current)}),[e,t]),n}function KO({onSelectSession:e,initialSearch:t=``}){let n=MO(),[r,i]=(0,B.useReducer)(FO,void 0,()=>NO(t)),a=GO(r.rawSearch,200),o=(0,B.useRef)([]),s=(0,B.useCallback)(t=>{let n=o.current[t];n&&e(n.sessionId)},[e]),{sessions:c,isLoading:l,error:u}=n,d=(0,B.useMemo)(()=>c?UO(c):{},[c]),f=(0,B.useMemo)(()=>{if(!c)return null;let e=BO(c,a,r.statusFilter);return{groups:HO(VO(e,r.sort),r.groupBy),total:c.length,filtered:e.length}},[c,a,r.statusFilter,r.sort,r.groupBy]),p=(0,B.useMemo)(()=>WO(c||[]),[c]),m=r.groupBy!==`none`,h=f?Math.ceil(f.filtered/25):0,g=r.page*25,_=g+25,v=(0,B.useMemo)(()=>!f||m?[]:f.groups[0]?.sessions.slice(g,_)??[],[f,m,g,_]);o.current=v;let{getItemProps:y,containerProps:b}=ID({count:v.length,cols:1,onActivate:s});return{state:(0,B.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:LO,groupAxes:RO,statusFilterOptions:zO,viewMode:r.viewMode,sessionTree:p}:{kind:`loading`},[l,u,f,r,h,m,d,v,y,b,p]),dispatch:i,onSelectSession:e}}var qO={selectedWorkflowId:null,selectedTag:null,selectedSource:null,hintVisible:!1};function JO(e){throw Error(`Unhandled WorkflowsEvent type: ${String(e.type)}`)}function YO(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 JO(t)}}function XO(e){let t=new Set;for(let n of e)for(let e of n.tags)e!==`routines`&&t.add(e);let n=SD.map(e=>e.id).filter(e=>t.has(e)),r=[...t].filter(e=>!SD.some(t=>t.id===e)).sort();return[...n,...r]}function ZO(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 QO(e,t,n){let r=new Set(SD.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 $O(e,t){if(t!==null)return e;let n=new Set(SD.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 SD){let t=r.get(e);t&&a.push(...t)}return a.push(...i),a}function ek({initialTag:e,onSelectTag:t}){let n=RD(),[r,i]=(0,B.useReducer)(YO,{...qO,selectedTag:e});(0,B.useEffect)(()=>{e!==r.selectedTag&&i({type:`tag_changed`,tag:e})},[e]);let a=(0,B.useRef)(null),o=(0,B.useCallback)((e,t)=>{a.current=t,t.blur(),i({type:`workflow_selected`,id:e})},[]);(0,B.useEffect)(()=>{if(!r.selectedWorkflowId&&a.current){let e=a.current;a.current=null,e.focus()}},[r.selectedWorkflowId]),(0,B.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,B.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,B.useMemo)(()=>{if(s)return{kind:`loading`};if(c)return{kind:`error`,message:c.message,onRetry:n.refetch};if(!l)return{kind:`loading`};let e=XO(l),t=ZO(l),i=QO(l,r.selectedTag,r.selectedSource),a=$O(i,r.selectedTag),o=QO(l,null,r.selectedSource),u=QO(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,B.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,B.useCallback)(e=>{e.type===`tag_changed`&&t(e.tag),i(e)},[t]),triggerRef:a,onCardSelect:o}}function tk(){let e=Zy();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 nk(){let e=tk(),[t,n]=(0,B.useState)(`recent`);return{state:(0,B.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=XD(r,t);return{kind:`ready`,sorted:i,maxDuration:ZD(i),errorCount:QD(r),avgMs:$D(r),lastCallMs:eO(r),countLabel:nO(r.length),sortOrder:t,onSortChange:n}},[e,t])}}function rk(e){let t=Ky(e);return{data:t.data,isLoading:t.isLoading,error:t.error instanceof Error?t.error:null}}function ik(e){let t=rk(e),[n,r]=(0,B.useState)(null),i=(0,B.useCallback)((e,t)=>{r(n=>n?.runId===e&&n?.nodeId===t?null:{runId:e,nodeId:t})},[]),a=(0,B.useCallback)(()=>{r(null)},[]),{isLoading:o,error:s,data:c}=t,l=(0,B.useMemo)(()=>!c||!n?null:c.runs.find(e=>e.runId===n.runId)??null,[c,n]);return{state:(0,B.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 ak=[{id:`workspace`,path:`/`},{id:`workflows`,path:`/workflows`},{id:`auto`,path:`/auto`},{id:`perf`,path:`/perf`}];function ok(){let e=wi(),t=ta(),{location:n}=sa(),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=jO(l),h=KO({onSelectSession:m.onSelectSession}),g=m.state.kind===`ready`?m.state.liveCount:0,_=m.state.kind===`ready`?m.state.blockedCount:0,v=(0,B.useCallback)(()=>{e({to:`/`})},[e]),y=(0,B.useCallback)(t=>{e({to:`/workflows`,search:{tag:t??void 0}})},[e]),b=(0,B.useCallback)(()=>{e({to:`/workflows`,search:{tag:p??void 0}})},[e,p]),x=(0,B.useCallback)(t=>{e({to:`/workflows/$workflowId`,params:{workflowId:t},search:{tag:p??void 0}})},[e,p]),S=ek({initialTag:p,onSelectTag:y}),C=BD({workflowId:f,activeTag:p,onBack:b,onNavigateToWorkflow:x}),w=ik(d??``),T=nk(),[E,D]=(0,B.useState)(null),O=(0,B.useCallback)((e,t)=>{t(),D(e),setTimeout(()=>D(null),200)},[]),k=(0,B.useRef)(null);return(0,B.useEffect)(()=>{let t=k.current;if(!t)return;function n(t){if(t.key===`ArrowLeft`||t.key===`ArrowRight`){t.preventDefault();let n=ak.findIndex(e=>e.id===c),r=ak[t.key===`ArrowRight`?(n+1)%ak.length:(n-1+ak.length)%ak.length];e({to:r.path,...r.path===`/workflows`?{search:{tag:void 0}}:{}})}}return t.addEventListener(`keydown`,n),()=>t.removeEventListener(`keydown`,n)},[c,e]),(0,V.jsxs)(`div`,{className:`min-h-screen`,style:{"--app-header-height":`56px`},children:[(0,V.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,V.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,V.jsx)(W,{cut:8,borderColor:`rgba(244, 196, 48, 0.5)`,background:`rgba(27, 31, 44, 0.8)`,className:`relative w-10 h-10`,children:(0,V.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,V.jsx)(`span`,{className:`font-mono text-[11px] font-bold text-[var(--accent)] tracking-widest`,children:`WR`})})}),(0,V.jsxs)(`div`,{className:`hidden sm:flex flex-col leading-none`,children:[(0,V.jsx)(`span`,{className:`font-mono text-[11px] font-bold text-[var(--text-primary)] tracking-[0.25em] uppercase`,children:`WR_CONSOLE`}),(0,V.jsxs)(`span`,{className:`font-mono text-[9px] text-[var(--text-muted)] tracking-[0.15em]`,children:[`// V`,`3.78.2`]})]})]}),l&&d?(0,V.jsx)(`nav`,{className:`flex items-center flex-1 justify-center`,children:(0,V.jsx)(TD,{segments:[{label:`Workspace`,onClick:v},{label:d?.slice(-12)??``}]})}):(0,V.jsxs)(`div`,{role:`tablist`,"aria-label":`Console sections`,ref:k,className:`flex items-center gap-1 flex-1 justify-center`,children:[(0,V.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,V.jsx)(`span`,{className:`tab-corner tab-corner--tl`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--tr`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--bl`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--br`,"aria-hidden":`true`}),`Workspace`]}),(0,V.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,V.jsx)(`span`,{className:`tab-corner tab-corner--tl`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--tr`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--bl`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--br`,"aria-hidden":`true`}),`Workflows`]}),(0,V.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,V.jsx)(`span`,{className:`tab-corner tab-corner--tl`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--tr`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--bl`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--br`,"aria-hidden":`true`}),`Auto`]}),(0,V.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,V.jsx)(`span`,{className:`tab-corner tab-corner--tl`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--tr`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--bl`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--br`,"aria-hidden":`true`}),`Performance`]})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[g>0&&(0,V.jsx)(no,{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,V.jsx)(no,{label:`${Math.min(_,9)}${_>9?`+`:``} BLOCKED`,color:`var(--blocked)`,role:`status`,"aria-label":`${_} blocked session${_===1?``:`s`}`})]})]}),(0,V.jsxs)(`main`,{className:`p-6`,style:{paddingTop:`calc(56px + 1.5rem)`},children:[(0,V.jsxs)(`div`,{id:`panel-workspace`,role:`tabpanel`,"aria-labelledby":`tab-workspace`,hidden:c===`workflows`||c===`perf`||c===`auto`,children:[(0,V.jsx)(Do,{viewModel:m,sessionListViewModel:h,hidden:l}),l&&d&&(0,V.jsx)(yD,{viewModel:w})]}),c===`workflows`&&(0,V.jsx)(`div`,{id:`panel-workflows`,role:`tabpanel`,"aria-labelledby":`tab-workflows`,children:u&&f?(0,V.jsx)(ED,{viewModel:C}):(0,V.jsx)(HD,{viewModel:S})}),c===`auto`&&(0,V.jsx)(`div`,{id:`panel-auto`,role:`tabpanel`,"aria-labelledby":`tab-auto`,children:(0,V.jsx)(_O,{})}),c===`perf`&&(0,V.jsx)(`div`,{id:`panel-perf`,role:`tabpanel`,"aria-labelledby":`tab-perf`,children:(0,V.jsx)(iO,{viewModel:T})})]})]})}var sk=Hi({component:ok}),ck=Bi({getParentRoute:()=>sk,path:`/`,component:()=>null}),lk=Bi({getParentRoute:()=>sk,path:`/session/$sessionId`,component:()=>null}),uk=Bi({getParentRoute:()=>sk,path:`/workflows`,validateSearch:e=>({tag:typeof e.tag==`string`?e.tag:void 0}),component:()=>null}),dk=Bi({getParentRoute:()=>sk,path:`/workflows/$workflowId`,validateSearch:e=>({tag:typeof e.tag==`string`?e.tag:void 0}),component:()=>null}),fk=Bi({getParentRoute:()=>sk,path:`/perf`,component:()=>null}),pk=Bi({getParentRoute:()=>sk,path:`/auto`,component:()=>null}),mk=ra({routeTree:sk.addChildren([ck,lk,uk,dk,fk,pk]),history:yr()}),hk=new ze({defaultOptions:{queries:{refetchInterval:5e3,staleTime:2e3}}});(0,ca.createRoot)(document.getElementById(`root`)).render((0,V.jsx)(B.StrictMode,{children:(0,V.jsx)(We,{client:hk,children:(0,V.jsx)(oa,{router:mk})})}));
28
+ `},i)),a}function qT(e,t){return e&&`run`in e?async function(n,r){let i=KT(n,{file:r,...t});await e.run(i,r)}:function(n,r){return KT(n,{file:r,...e||t})}}function JT(e){if(e)throw e}var YT=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 XT(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 ZT(){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?QT(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 QT(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 $T={basename:eE,dirname:tE,extname:nE,join:rE,sep:`/`};function eE(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);oE(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 tE(e){if(oE(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 nE(e){oE(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 rE(...e){let t=-1,n;for(;++t<e.length;)oE(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:iE(n)}function iE(e){oE(e);let t=e.codePointAt(0)===47,n=aE(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function aE(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 oE(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var sE={cwd:cE};function cE(){return`/`}function lE(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function uE(e){if(typeof e==`string`)e=new URL(e);else if(!lE(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 dE(e)}function dE(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 fE=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],pE=class{constructor(e){let t;t=e?lE(e)?{path:e}:typeof e==`string`||_E(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:sE.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<fE.length;){let e=fE[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)fE.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?$T.basename(this.path):void 0}set basename(e){hE(e,`basename`),mE(e,`basename`),this.path=$T.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?$T.dirname(this.path):void 0}set dirname(e){gE(this.basename,`dirname`),this.path=$T.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?$T.extname(this.path):void 0}set extname(e){if(mE(e,`extname`),gE(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=$T.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){lE(e)&&(e=uE(e)),hE(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?$T.basename(this.path,this.extname):void 0}set stem(e){hE(e,`stem`),mE(e,`stem`),this.path=$T.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 nx(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 mE(e,t){if(e&&e.includes($T.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+$T.sep+"`")}function hE(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function gE(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function _E(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var vE=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),yE=l(YT(),1),bE={}.hasOwnProperty,xE=new class e extends vE{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=ZT()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,yE.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(wE(`data`,this.frozen),this.namespace[e]=t,this):bE.call(this.namespace,e)&&this.namespace[e]||void 0:e?(wE(`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=DE(e),n=this.parser||this.Parser;return SE(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),SE(`process`,this.parser||this.Parser),CE(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=DE(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);kE(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(),SE(`processSync`,this.parser||this.Parser),CE(`processSync`,this.compiler||this.Compiler),this.process(e,r),EE(`processSync`,`process`,t),n;function r(e,r){t=!0,JT(e),n=r}}run(e,t,n){TE(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=DE(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),EE(`runSync`,`run`,n),r;function i(e,t){JT(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=DE(t),r=this.compiler||this.Compiler;return CE(`stringify`,r),TE(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(wE(`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,yE.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];XT(o)&&XT(r)&&(r=(0,yE.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function SE(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function CE(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function wE(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 TE(e){if(!XT(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function EE(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function DE(e){return OE(e)?e:new pE(e)}function OE(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function kE(e){return typeof e==`string`||AE(e)}function AE(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var jE=[],ME={allowDangerousHtml:!0},NE=/^(https?|ircs?|mailto|xmpp)$/i,PE=[{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 FE(e){let t=IE(e),n=LE(e);return RE(t.runSync(t.parse(n),n),e)}function IE(e){let t=e.rehypePlugins||jE,n=e.remarkPlugins||jE,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...ME}:ME;return xE().use(Nw).use(n).use(qT,r).use(t)}function LE(e){let t=e.children||``,n=new pE;return typeof t==`string`?n.value=t:``+t,n}function RE(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||zE;for(let e of PE)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return LT(e,l),ux(e,{Fragment:V.Fragment,components:i,ignoreInvalidStyle:!0,jsx:V.jsx,jsxs:V.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 Mx)if(Object.hasOwn(Mx,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=Mx[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 zE(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||NE.test(e.slice(0,t))?e:``}function BE({children:e,className:t}){return(0,V.jsx)(`div`,{className:`markdown-view ${t??``}`,children:(0,V.jsx)(FE,{children:e})})}function VE({sessionId:e,nodeId:t,runStatus:n=`complete`,currentNodeId:r=null,executionTraceSummary:i=null}){let{data:a,isLoading:o,error:s}=qy(e,t);return t?(0,V.jsxs)(`div`,{children:[(0,V.jsx)(HE,{stepLabel:a?.stepLabel??null,nodeId:t}),(0,V.jsxs)(`div`,{className:`p-4 space-y-4`,children:[o&&(0,V.jsx)(`div`,{className:`text-[var(--text-secondary)] text-sm`,children:`Loading...`}),s&&(0,V.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,V.jsx)(qE,{detail:a,runStatus:n,currentNodeId:r,executionTraceSummary:i})]})]}):(0,V.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 HE({stepLabel:e,nodeId:t}){return(0,V.jsxs)(`div`,{className:`px-5 py-4 border-b border-[var(--border)] console-blueprint-grid`,children:[(0,V.jsx)(`div`,{className:`text-base font-semibold text-[var(--text-primary)] leading-tight`,children:e??`Untitled node`}),(0,V.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-[var(--text-muted)] truncate`,children:t})]})}function UE({item:e}){return(0,V.jsxs)(`div`,{className:`flex items-start gap-2 text-xs py-1`,children:[(0,V.jsx)(`span`,{className:`flex-1 text-[var(--text-secondary)] leading-relaxed`,children:e.summary}),(0,V.jsxs)(`span`,{className:`font-mono text-[10px] text-[var(--text-muted)] shrink-0`,children:[`#`,e.recordedAtEventIndex]})]})}function WE({nodeId:e,nodeKind:t,executionTraceSummary:n}){let{whySelected:r,conditions:i,loops:a,divergences:o,forks:s}=my(n,e);return n.items.some(t=>t.kind!==`context_fact`&&t.refs.some(t=>t.kind===`node_id`&&t.value===e))?(0,V.jsx)(cD,{title:`Routing context`,children:(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(r.length>0||t===`blocked_attempt`)&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`mb-1.5 flex items-center gap-2`,children:(0,V.jsx)(Fy,{label:`WHY SELECTED`,color:`var(--accent)`,bgColor:`rgba(244,196,48,0.10)`})}),r.length>0?(0,V.jsx)(`div`,{className:`space-y-1 pl-2 border-l border-[var(--border)]`,children:r.map((e,t)=>(0,V.jsx)(UE,{item:e},t))}):t===`blocked_attempt`?(0,V.jsx)(`div`,{className:`pl-2 border-l border-[var(--border)]`,children:(0,V.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,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`mb-1.5`,children:(0,V.jsx)(Fy,{label:`CONDITIONS EVALUATED`,color:`var(--text-secondary)`,bgColor:`rgba(168,159,140,0.10)`})}),(0,V.jsx)(`div`,{className:`space-y-1 pl-2 border-l border-[var(--border)]`,children:[...i.filter(e=>!cy(e)),...i.filter(e=>cy(e))].map((e,t)=>{let n=cy(e);return(0,V.jsxs)(`div`,{className:`flex items-start gap-2 text-xs py-0.5`,children:[(0,V.jsx)(Fy,{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,V.jsx)(`span`,{className:`flex-1 text-[var(--text-secondary)] leading-relaxed`,children:e.summary})]},t)})})]}),a.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`mb-1.5`,children:(0,V.jsx)(Fy,{label:`LOOP`,color:`var(--accent-strong)`,bgColor:`rgba(0,240,255,0.10)`})}),(0,V.jsx)(`div`,{className:`space-y-1 pl-2 border-l border-[var(--border)]`,children:a.map((e,t)=>(0,V.jsx)(UE,{item:e},t))})]}),o.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`mb-1.5`,children:(0,V.jsx)(Fy,{label:`DIVERGENCE`,color:`var(--error)`,bgColor:`rgba(255,107,107,0.10)`})}),(0,V.jsx)(`div`,{className:`space-y-1 pl-2 border-l border-[var(--border)]`,children:o.map((e,t)=>(0,V.jsx)(UE,{item:e},t))})]}),s.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`mb-1.5`,children:(0,V.jsx)(Fy,{label:`FORK`,color:`var(--warning)`,bgColor:`rgba(251,191,36,0.10)`})}),(0,V.jsx)(`div`,{className:`space-y-1 pl-2 border-l border-[var(--border)]`,children:s.map((e,t)=>(0,V.jsx)(UE,{item:e},t))})]})]})}):(0,V.jsx)(cD,{title:`Routing context`,children:t===`blocked_attempt`&&r.length===0?(0,V.jsxs)(`div`,{className:`flex items-start gap-2 py-1`,children:[(0,V.jsx)(Fy,{label:`WHY SELECTED`,color:`var(--text-muted)`,bgColor:`rgba(123,141,167,0.08)`}),(0,V.jsx)(`span`,{className:`text-xs text-[var(--text-muted)] leading-relaxed`,children:`This step was attempted but not selected as the preferred path.`})]}):(0,V.jsx)(`span`,{className:`font-mono text-xs text-[var(--text-muted)]`,children:`// no routing trace for this node`})})}function GE({items:e}){let[t,n]=(0,B.useState)(!1);return(0,V.jsx)(cD,{title:`Run routing`,children:(0,V.jsxs)(`div`,{children:[(0,V.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,V.jsx)(Fy,{label:`RUN ROUTING`,color:`var(--text-muted)`,bgColor:`rgba(123,141,167,0.08)`}),(0,V.jsxs)(`span`,{className:`text-[var(--text-muted)]`,children:[`// `,e.length,` ambient items`]}),(0,V.jsx)(`span`,{children:t?`[-]`:`[+]`})]}),t&&(0,V.jsx)(`div`,{className:`mt-2 space-y-1 pl-2 border-l border-[var(--border)]`,children:e.map((e,t)=>(0,V.jsxs)(`div`,{className:`flex items-start gap-2 text-xs py-0.5`,children:[(0,V.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,V.jsx)(`span`,{className:`flex-1 text-[var(--text-secondary)] leading-relaxed`,children:e.summary}),(0,V.jsxs)(`span`,{className:`font-mono text-[10px] text-[var(--text-muted)] shrink-0`,children:[`#`,e.recordedAtEventIndex]})]},t))})]})})}var KE=[{id:`routing`,column:`primary`,render:({detail:e,executionTraceSummary:t})=>t===null?null:(0,V.jsx)(WE,{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,V.jsx)(GE,{items:t},`run_routing`)}},{id:`recap`,column:`primary`,render:({detail:e,runStatus:t,currentNodeId:n})=>e.recapMarkdown?(0,V.jsx)($E,{markdown:e.recapMarkdown},`recap`):t===`in_progress`&&e.nodeId===n&&!e.recapMarkdown?(0,V.jsx)(JE,{detail:e},`recap-in-progress`):null},{id:`validations`,column:`primary`,render:({detail:e})=>e.validations.length>0?(0,V.jsx)(tD,{validations:e.validations},`validations`):null},{id:`gaps`,column:`primary`,render:({detail:e})=>e.gaps.length>0?(0,V.jsx)(rD,{gaps:e.gaps},`gaps`):null},{id:`advance-outcome`,column:`primary`,render:({detail:e})=>e.advanceOutcome?(0,V.jsx)(eD,{outcome:e.advanceOutcome},`advance-outcome`):null},{id:`artifacts`,column:`primary`,render:({detail:e})=>e.artifacts.length>0?(0,V.jsx)(sD,{artifacts:e.artifacts},`artifacts`):null},{id:`node-meta`,column:`primary`,render:({detail:e})=>(0,V.jsx)(QE,{detail:e},`node-meta`)}];function qE(e){return(0,V.jsx)(`div`,{className:`space-y-4`,children:KE.map(t=>t.render(e))})}function JE({detail:e}){return(0,V.jsx)(cD,{title:`Recap`,children:(0,V.jsxs)(`div`,{className:`space-y-4 text-sm text-[var(--text-secondary)]`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(YE,{children:`In progress`}),(0,V.jsxs)(`span`,{className:`font-mono text-xs text-[var(--text-muted)]`,children:[`event #`,e.createdAtEventIndex]})]}),(0,V.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]`,children:[(0,V.jsx)(XE,{label:`Current focus`,value:e.stepLabel??`Current workflow step`,supportingText:`This step is still running, so the recap will appear once execution finishes.`}),(0,V.jsx)(XE,{label:`Current state`,value:`Waiting for step completion`,supportingText:`The node has been created and selected as the current workflow position.`,mono:!0})]}),(0,V.jsxs)(`div`,{className:`bg-[var(--bg-primary)] border border-[var(--border)] overflow-hidden`,children:[(0,V.jsx)(`div`,{className:`px-4 py-3 border-b border-[var(--border)]`,children:(0,V.jsx)(Ko,{children:`What lands here next`})}),(0,V.jsxs)(`div`,{className:`p-4 grid gap-3 md:grid-cols-3`,children:[(0,V.jsx)(ZE,{title:`Recap`,description:`A step summary is written when this node completes.`}),(0,V.jsx)(ZE,{title:`Validations`,description:`Validation results appear if this step records contract checks.`}),(0,V.jsx)(ZE,{title:`Artifacts`,description:`Generated outputs show up here after the step produces them.`})]})]})]})})}function YE({children:e}){return(0,V.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 XE({label:e,value:t,supportingText:n,mono:r=!1}){return(0,V.jsxs)(`div`,{className:`bg-[var(--bg-primary)] border border-[var(--border)] px-4 py-3 space-y-2`,children:[(0,V.jsx)(Ko,{children:e}),(0,V.jsx)(`div`,{className:r?`font-mono text-sm text-[var(--text-primary)]`:`text-[var(--text-primary)]`,children:t}),(0,V.jsx)(`div`,{className:`text-xs text-[var(--text-muted)] leading-relaxed`,children:n})]})}function ZE({title:e,description:t}){return(0,V.jsxs)(`div`,{className:`border border-[var(--border)] bg-[rgba(255,255,255,0.02)] px-3 py-3 space-y-2`,children:[(0,V.jsx)(Ko,{color:`var(--text-secondary)`,children:e}),(0,V.jsx)(`div`,{className:`text-xs text-[var(--text-muted)] leading-relaxed`,children:t})]})}function QE({detail:e}){return(0,V.jsx)(cD,{title:`Node details`,children:(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsx)(lD,{label:`Kind`,value:(0,V.jsx)(dD,{kind:e.nodeKind})}),(0,V.jsx)(lD,{label:`Event index`,value:String(e.createdAtEventIndex),mono:!0}),(0,V.jsx)(lD,{label:`Parent`,value:e.parentNodeId??`Root`,mono:!0}),(0,V.jsx)(lD,{label:`Tip state`,value:e.isTip?e.isPreferredTip?`Preferred tip`:`Tip`:`Historical`})]})})}function $E({markdown:e}){return(0,V.jsx)(cD,{title:`Recap`,children:(0,V.jsx)(BE,{children:e})})}function eD({outcome:e}){let t=e.kind===`advanced`;return(0,V.jsx)(cD,{title:`Advance outcome`,children:(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-xs`,children:[(0,V.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,V.jsxs)(`span`,{className:`text-[var(--text-muted)]`,children:[`attempt `,e.attemptId.slice(-8),` at event #`,e.recordedAtEventIndex]})]})})}function tD({validations:e}){return(0,V.jsx)(cD,{title:`Validations (${e.length})`,children:(0,V.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,V.jsx)(nD,{validation:e},e.validationId))})})}function nD({validation:e}){let t=e.outcome===`pass`;return(0,V.jsxs)(`div`,{className:`bg-[var(--bg-primary)] border border-[var(--border)] px-4 py-3 text-xs space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.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,V.jsx)(`span`,{className:`text-[var(--text-muted)] font-mono`,children:e.contractRef})]}),e.issues.length>0&&(0,V.jsxs)(`div`,{className:`space-y-1`,children:[(0,V.jsx)(`div`,{className:`text-[var(--text-muted)] mb-1`,children:`Issues`}),(0,V.jsx)(`ul`,{className:`list-disc list-inside text-[var(--error)] space-y-0.5`,children:e.issues.map((e,t)=>(0,V.jsx)(`li`,{children:e},t))})]}),e.suggestions.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-[var(--text-muted)] mb-1`,children:`Suggestions`}),(0,V.jsx)(`ul`,{className:`list-disc list-inside text-[var(--text-secondary)] space-y-0.5`,children:e.suggestions.map((e,t)=>(0,V.jsx)(`li`,{children:e},t))})]})]})}function rD({gaps:e}){return(0,V.jsx)(cD,{title:`Gaps (${e.length})`,children:(0,V.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,V.jsxs)(`div`,{className:`flex items-start gap-3 text-xs bg-[var(--bg-primary)] border border-[var(--border)] px-3 py-3`,children:[(0,V.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,V.jsx)(`span`,{className:`text-[var(--text-secondary)] leading-relaxed`,children:e.summary})]},e.gapId))})})}var iD=1e5,aD=[{prefix:`text/`,render:e=>(0,V.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,V.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 oD(e){if(e.byteLength>iD)return(0,V.jsxs)(`div`,{className:`text-[var(--text-muted)] italic`,children:[`Content too large to display (`,fD(e.byteLength),` -- limit `,fD(iD),`)`]});let t=aD.find(t=>e.contentType.startsWith(t.prefix));return t?t.render(e.content):(0,V.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 sD({artifacts:e}){return(0,V.jsx)(cD,{title:`Artifacts (${e.length})`,children:(0,V.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,V.jsxs)(`div`,{className:`bg-[var(--bg-primary)] border border-[var(--border)] px-4 py-3 text-xs space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[var(--text-muted)]`,children:[(0,V.jsx)(`span`,{children:e.contentType}),(0,V.jsx)(`span`,{children:`//`}),(0,V.jsx)(`span`,{children:fD(e.byteLength)})]}),oD(e)]},e.sha256))})})}function cD({title:e,children:t}){return(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`mb-2`,children:(0,V.jsx)(Ko,{children:e})}),t]})}function lD({label:e,value:t,mono:n=!1}){return(0,V.jsxs)(`div`,{className:`bg-[var(--bg-primary)] border border-[var(--border)] px-4 py-3`,children:[(0,V.jsx)(Ko,{children:e}),(0,V.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 uD={step:{label:`Step`,color:`var(--accent)`},checkpoint:{label:`Checkpoint`,color:`var(--success)`},blocked_attempt:{label:`Blocked`,color:`var(--error)`}};function dD({kind:e}){let t=uD[e];return(0,V.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 fD(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function pD(e){return e.length>16?`\u2026${e.slice(-16)}`:e}function mD({data:e}){let t=e.runs[0]??null,n=t?.workflowName??t?.workflowId??`--`,r=t?.workflowHash?.slice(0,12)??`--`;return(0,V.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,V.jsx)(`h2`,{className:`text-base font-medium text-[var(--text-primary)] mb-3`,children:e.sessionTitle}),(0,V.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-8 gap-y-2`,children:[(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)] self-center`,children:`Session`}),(0,V.jsx)(`dd`,{className:`font-mono text-xs text-[var(--text-secondary)] self-center`,children:pD(e.sessionId)}),(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)] self-center`,children:`Workflow`}),(0,V.jsx)(`dd`,{className:`text-sm text-[var(--text-primary)] self-center`,children:n}),(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)] self-center`,children:`Hash`}),(0,V.jsx)(`dd`,{className:`font-mono text-xs text-[var(--text-secondary)] self-center`,children:r}),(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)] self-center`,children:`Status`}),(0,V.jsxs)(`dd`,{className:`self-center flex items-center gap-2`,children:[(0,V.jsx)(ao,{health:e.health}),e.health===`healthy`&&(0,V.jsx)(`span`,{className:`text-sm text-[var(--text-primary)]`,children:`Healthy`})]}),(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)] self-center`,children:`Runs`}),(0,V.jsxs)(`dd`,{className:`text-sm text-[var(--text-primary)] self-center`,children:[e.runs.length,` run`,e.runs.length===1?``:`s`]})]})]})}function hD({summary:e}){let t=new TextEncoder().encode(e).length;return(0,V.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:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,V.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)]`,children:`Injected Context`}),(0,V.jsxs)(`span`,{className:`font-mono text-[10px] text-[var(--text-muted)]`,children:[t.toLocaleString(),` bytes`]})]}),(0,V.jsx)(`pre`,{className:`font-mono text-xs text-[var(--text-secondary)] whitespace-pre-wrap break-words max-h-48 overflow-y-auto leading-relaxed`,children:e})]})}function gD(e){if(e<6e4)return`${Math.round(e/1e3)}s`;let t=Math.floor(e/6e4),n=Math.round(e%6e4/1e3);return n>0?`${t}m ${n}s`:`${t}m`}function _D({sessionId:e,metrics:t}){let[n,r]=(0,B.useState)({kind:`idle`}),i=Jy(e,!1),a=t.startGitSha!==null&&t.endGitSha!==null,o=async()=>{r({kind:`loading`});try{let e=await i.refetch();e.isSuccess&&e.data?r({kind:`loaded`,linesAdded:e.data.linesAdded,linesRemoved:e.data.linesRemoved,filesChanged:e.data.filesChanged}):r({kind:`error`,message:e.error instanceof Error?e.error.message:`Diff computation failed`})}catch(e){r({kind:`error`,message:e instanceof Error?e.message:`Diff computation failed`})}};return(0,V.jsxs)(`div`,{className:`bg-[var(--bg-card)] border border-[var(--border)] px-5 py-4 corner-brackets space-y-4`,style:{backdropFilter:`blur(12px)`,WebkitBackdropFilter:`blur(12px)`},children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)]`,children:`Session Metrics`}),(0,V.jsx)(`span`,{className:`font-mono text-[10px] text-[var(--text-muted)]`,children:`Session-level totals across all runs.`})]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[t.outcome!==null&&(0,V.jsx)(`span`,{className:`px-2 py-1 text-xs font-mono border border-[var(--border)] text-[var(--text-secondary)] bg-[var(--bg-card)]`,children:t.outcome}),t.durationMs!==void 0&&(0,V.jsx)(`span`,{className:`px-2 py-1 text-xs font-mono border border-[var(--border)] text-[var(--text-secondary)] bg-[var(--bg-card)]`,children:gD(t.durationMs)}),t.filesChanged!==null&&(0,V.jsxs)(`span`,{className:`px-2 py-1 text-xs font-mono border border-[var(--border)] text-[var(--text-secondary)] bg-[var(--bg-card)]`,children:[t.filesChanged,` file`,t.filesChanged===1?``:`s`,` changed`]}),t.captureConfidence!==`none`&&(0,V.jsxs)(`span`,{className:`px-2 py-1 text-xs font-mono border border-[var(--border)] text-[var(--text-muted)] bg-[var(--bg-card)]`,children:[t.captureConfidence,` confidence`]})]}),(0,V.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-8 gap-y-2`,children:[t.gitBranch!==null&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] self-center`,children:`Git Branch`}),(0,V.jsx)(`dd`,{className:`font-mono text-xs text-[var(--text-secondary)] self-center`,children:t.gitBranch})]}),t.startGitSha!==null&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] self-center`,children:`Start SHA`}),(0,V.jsx)(`dd`,{className:`font-mono text-xs text-[var(--text-secondary)] self-center`,children:t.startGitSha.slice(0,12)})]}),t.endGitSha!==null&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] self-center`,children:`End SHA`}),(0,V.jsx)(`dd`,{className:`font-mono text-xs text-[var(--text-secondary)] self-center`,children:t.endGitSha.slice(0,12)})]}),t.durationMs!==void 0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] self-center`,children:`Duration`}),(0,V.jsx)(`dd`,{className:`font-mono text-xs text-[var(--text-secondary)] self-center`,children:gD(t.durationMs)})]}),t.agentCommitShas.length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] self-start`,children:`Commits`}),(0,V.jsx)(`dd`,{className:`font-mono text-xs text-[var(--text-secondary)]`,children:t.agentCommitShas.map(e=>(0,V.jsx)(`div`,{children:e.slice(0,12)},e))})]}),t.outcome!==null&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] self-center`,children:`Outcome`}),(0,V.jsxs)(`dd`,{className:`text-xs text-[var(--text-secondary)] self-center`,children:[t.outcome,` `,(0,V.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`(agent-reported)`})]})]}),t.filesChanged!==null&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] self-center`,children:`Files Changed`}),(0,V.jsxs)(`dd`,{className:`text-xs text-[var(--text-secondary)] self-center`,children:[t.filesChanged,` `,(0,V.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`(agent-reported)`})]})]}),t.linesAdded!==null&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] self-center`,children:`Lines Added`}),(0,V.jsxs)(`dd`,{className:`text-xs text-[var(--text-secondary)] self-center`,children:[t.linesAdded,` `,(0,V.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`(agent-reported)`})]})]}),t.linesRemoved!==null&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] self-center`,children:`Lines Removed`}),(0,V.jsxs)(`dd`,{className:`text-xs text-[var(--text-secondary)] self-center`,children:[t.linesRemoved,` `,(0,V.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`(agent-reported)`})]})]}),t.prNumbers.length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] self-center`,children:`PRs`}),(0,V.jsxs)(`dd`,{className:`text-xs text-[var(--text-secondary)] self-center`,children:[t.prNumbers.join(`, `),` `,(0,V.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`(agent-reported)`})]})]}),n.kind===`loaded`&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] self-center`,children:`LOC Added`}),(0,V.jsxs)(`dd`,{className:`text-xs text-[var(--text-secondary)] self-center`,children:[n.linesAdded,` `,(0,V.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`(git diff)`})]}),(0,V.jsx)(`dt`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] self-center`,children:`LOC Removed`}),(0,V.jsxs)(`dd`,{className:`text-xs text-[var(--text-secondary)] self-center`,children:[n.linesRemoved,` `,(0,V.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`(git diff)`})]})]})]}),a&&n.kind!==`loaded`&&(0,V.jsxs)(`div`,{className:`flex items-center gap-3 pt-1`,children:[n.kind===`idle`&&(0,V.jsx)(`button`,{type:`button`,onClick:()=>{o()},className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)] hover:text-[var(--text-primary)] border border-[var(--border)] px-3 py-1.5 transition-colors`,children:`Load diff`}),n.kind===`loading`&&(0,V.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[0.25em] text-[var(--text-muted)]`,children:`Computing...`}),n.kind===`error`&&(0,V.jsxs)(`span`,{className:`text-xs text-[var(--error)]`,children:[n.message,` `,(0,V.jsx)(`button`,{type:`button`,onClick:()=>{o()},className:`underline text-[var(--text-muted)] hover:text-[var(--text-primary)] transition-colors`,children:`Retry`})]})]})]})}function vD({runs:e}){let t=e.some(e=>e.preferredTipNodeId!==null),n=e.some(e=>e.executionTraceSummary!==null);return(0,V.jsxs)(`div`,{className:`border border-[var(--border)] px-4 py-3 text-xs text-[var(--text-muted)] space-y-1`,children:[(0,V.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,V.jsxs)(`p`,{children:[`This run has execution trace data. Click`,` `,(0,V.jsx)(`span`,{className:`font-mono uppercase tracking-[0.16em]`,children:`[ TRACE ]`}),` `,`to see why certain steps ran, were skipped, or repeated.`]})]})}function yD({viewModel:e}){let{state:t,onSelectNode:n,onCloseNode:r}=e;if(t.kind===`loading`)return(0,V.jsx)(`div`,{className:`text-[var(--text-secondary)]`,children:`Loading session...`});if(t.kind===`error`)return(0,V.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,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsx)(mD,{data:a}),a.metrics!==null&&(0,V.jsx)(_D,{sessionId:i,metrics:a.metrics}),a.injectedContext!==void 0&&(0,V.jsx)(hD,{summary:a.injectedContext.assembledContextSummary}),a.runs.length===0?(0,V.jsx)(`div`,{className:`text-center py-16 text-[var(--text-secondary)]`,children:`No runs in this session`}):(0,V.jsxs)(V.Fragment,{children:[o===null&&(0,V.jsx)(vD,{runs:a.runs}),(0,V.jsx)(`div`,{className:`space-y-6`,children:a.runs.map(e=>(0,V.jsx)(bD,{run:e,selectedNodeId:o?.runId===e.runId?o.nodeId:null,onNodeClick:n},e.runId))})]})]}),(0,V.jsxs)(W,{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,V.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-[var(--border)] shrink-0 console-blueprint-grid`,children:[(0,V.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-muted)]`,children:`Node detail`}),(0,V.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,V.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,V.jsx)(VE,{sessionId:i,nodeId:o?.nodeId??null,runStatus:s?.status??`complete`,currentNodeId:s?.preferredTipNodeId??null,executionTraceSummary:s?.executionTraceSummary??null})})]})]})}function bD({run:e,selectedNodeId:t,onNodeClick:n}){let r=e.executionTraceSummary!==null,[i,a]=(0,B.useState)(`dag`);return(0,V.jsxs)(W,{cut:10,background:`rgba(27, 31, 44, 0.72)`,backdropFilter:`blur(8px)`,className:`relative`,style:{height:r?`542px`:`506px`},children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-[var(--border)] shrink-0`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(`span`,{className:`text-sm font-medium text-[var(--text-primary)]`,children:e.workflowName??e.workflowId??`Run`}),(0,V.jsx)(`span`,{className:`font-mono text-xs text-[var(--text-muted)]`,children:e.runId}),(0,V.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,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.hasUnresolvedCriticalGaps&&(0,V.jsx)(`span`,{className:`text-xs text-[var(--warning)]`,children:`Critical gaps`}),(0,V.jsx)(io,{status:e.status})]})]}),r&&(0,V.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,V.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,V.jsx)(`span`,{className:`tab-corner tab-corner--tl`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--tr`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--bl`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--br`,"aria-hidden":`true`}),`DAG`]}),(0,V.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,V.jsx)(`span`,{className:`tab-corner tab-corner--tl`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--tr`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--bl`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--br`,"aria-hidden":`true`}),`TRACE`]})]}),(0,V.jsx)(`div`,{role:`tabpanel`,"aria-labelledby":i===`dag`?`tab-dag`:`tab-trace`,className:`flex-1`,children:i===`trace`&&e.executionTraceSummary!==null?(0,V.jsx)(Vy,{summary:e.executionTraceSummary,runStatus:e.status}):(0,V.jsx)(hy,{run:e,selectedNodeId:t,onNodeClick:t=>n(e.runId,t)})})]})}function xD(){let[e,t]=(0,B.useState)(0),[n,r]=(0,B.useState)(0),[i,a]=(0,B.useState)(38),[o,s]=(0,B.useState)(62),[c,l]=(0,B.useState)(3),[u,d]=(0,B.useState)(2),[f,p]=(0,B.useState)(``),[m,h]=(0,B.useState)(!1),g=(0,B.useRef)(!1),_=(0,B.useRef)(null),v=(0,B.useRef)(null),y=(0,B.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 SD=[{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`}],CD=Object.fromEntries(SD.map(e=>[e.id,e.label]));function wD({label:e,count:t,countLabel:n=`workflow`,showRule:r=!0,separator:i=`//`}){return(0,V.jsxs)(`div`,{className:`flex items-center gap-3 mb-3 mt-2`,children:[(0,V.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,V.jsx)(`div`,{className:`flex-1 h-px bg-[var(--border)]`})]})}function TD({segments:e,className:t=``}){return(0,V.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,V.jsxs)(`span`,{className:`flex items-center`,children:[(0,V.jsx)(`span`,{className:`font-mono text-[10px] tracking-[0.25em] text-[var(--text-muted)] mx-1`,children:`//`}),i?(0,V.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,V.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 ED({viewModel:e}){let{state:t}=e;if(t.kind===`not_found`)return(0,V.jsx)(`div`,{className:`space-y-5 max-w-3xl`,children:(0,V.jsx)(MD,{message:``,is404:!0,onRetry:()=>void 0,onBack:t.onBack})});if(t.kind===`error`)return(0,V.jsx)(`div`,{className:`space-y-5 max-w-3xl`,children:(0,V.jsx)(MD,{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,V.jsxs)(`div`,{className:`space-y-5 max-w-3xl`,children:[(0,V.jsx)(TD,{segments:n?[{label:`Workflows`,onClick:r},{label:n}]:[{label:`Workflows`,onClick:r}]}),e?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(DD,{name:e.name,description:e.description,tags:e.tags,source:e.source,stepCount:void 0}),(0,V.jsx)(`div`,{className:`space-y-4`,children:(0,V.jsx)(AD,{})})]}):(0,V.jsx)(jD,{})]})}let{workflow:n,name:r,description:i,tags:a,source:o,activeTagLabel:s,onPrev:c,onNext:l,onBack:u}=t;return(0,V.jsxs)(`div`,{className:`space-y-5 max-w-3xl`,children:[(0,V.jsx)(TD,{segments:s?[{label:`Workflows`,onClick:u},{label:s}]:[{label:`Workflows`,onClick:u}]}),(0,V.jsx)(DD,{name:r,description:i,tags:a,source:o,stepCount:n.stepCount}),(c??l)&&(0,V.jsxs)(`div`,{className:`flex items-center gap-4`,children:[c&&(0,V.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,V.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,V.jsx)(OD,{detail:n,name:r}),(0,V.jsx)(TD,{segments:[{label:`Workflows`,onClick:u}]})]})}function DD({name:e,description:t,tags:n,source:r,stepCount:i}){return(0,V.jsxs)(`div`,{className:`border border-[var(--border)] px-5 py-5 console-blueprint-grid`,children:[(0,V.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-[0.35em] text-[var(--text-muted)] mb-2`,children:`// Workflow`}),(0,V.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,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i!=null&&i>0&&(0,V.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,V.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,V.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,V.jsx)(`p`,{className:`text-sm text-[var(--text-secondary)] leading-relaxed mt-3`,children:t})]})}function OD({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,V.jsxs)(`div`,{className:`space-y-6`,children:[n&&(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider mb-3`,children:`About`}),(0,V.jsx)(BE,{children:e.about})]}),r&&(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider mb-3`,children:`Try it with:`}),(0,V.jsx)(`ul`,{className:`space-y-2`,children:e.examples.map(e=>(0,V.jsxs)(`li`,{className:`flex items-start gap-3 bg-[var(--bg-card)] border border-[var(--border)] rounded-none px-4 py-3`,children:[(0,V.jsx)(`div`,{"aria-hidden":`true`,className:`w-0.5 shrink-0 self-stretch rounded-full`,style:{backgroundColor:`var(--accent)`}}),(0,V.jsxs)(`span`,{className:`text-sm text-[var(--text-secondary)] leading-relaxed`,children:[`"`,e,`"`]})]},e))})]}),i&&(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider mb-3`,children:`Before you start:`}),(0,V.jsx)(`ul`,{className:`space-y-1.5`,children:e.preconditions.map(e=>(0,V.jsxs)(`li`,{className:`flex items-start gap-2 text-sm text-[var(--text-secondary)]`,children:[(0,V.jsx)(`span`,{className:`shrink-0 text-[var(--text-muted)] mt-0.5`,children:`•`}),(0,V.jsx)(`span`,{children:e})]},e))})]}),(0,V.jsx)(kD,{name:t})]}):(0,V.jsx)(`p`,{className:`text-sm text-[var(--text-muted)] italic`,children:`No additional documentation available.`})}function kD({name:e}){let[t,n]=(0,B.useState)(!1),r=`Use the ${e} to [your goal]`;return(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-[var(--text-muted)] uppercase tracking-wider mb-3`,children:`Start with this prompt`}),(0,V.jsxs)(`div`,{className:`flex items-center gap-3 border border-[var(--border)] px-4 py-3`,children:[(0,V.jsxs)(`span`,{className:`flex-1 text-sm text-[var(--text-secondary)] font-mono truncate`,children:[`"`,r,`"`]}),(0,V.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 AD(){return(0,V.jsxs)(`div`,{className:`space-y-3 motion-safe:animate-pulse`,children:[(0,V.jsx)(`div`,{className:`h-3 w-16 rounded bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`h-4 w-full rounded bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`h-4 w-5/6 rounded bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`h-4 w-4/6 rounded bg-[var(--bg-tertiary)]`})]})}function jD(){return(0,V.jsxs)(`div`,{className:`space-y-6 motion-safe:animate-pulse`,children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`div`,{className:`h-6 w-1/2 rounded bg-[var(--bg-tertiary)]`}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(`div`,{className:`h-5 w-16 rounded bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`h-5 w-24 rounded bg-[var(--bg-tertiary)]`})]}),(0,V.jsx)(`div`,{className:`h-4 w-full rounded bg-[var(--bg-tertiary)]`})]}),(0,V.jsx)(AD,{})]})}function MD({message:e,is404:t,onRetry:n,onBack:r}){return(0,V.jsxs)(`div`,{className:`space-y-4 bg-[var(--bg-card)] border border-[var(--border)] p-4`,children:[(0,V.jsx)(`p`,{className:`text-sm text-[var(--error)]`,children:t?`Workflow not found.`:e}),(0,V.jsxs)(`div`,{className:`flex gap-3`,children:[!t&&(0,V.jsx)(`button`,{type:`button`,onClick:n,className:`text-sm text-[var(--accent)] hover:text-[var(--accent-hover)] transition-colors`,children:`Try again`}),(0,V.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 ND(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 PD(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 FD(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 ID({count:e,cols:t=`auto`,onActivate:n,loop:r=!0}){let[i,a]=(0,B.useState)(null),o=(0,B.useRef)(new Map),s=(0,B.useCallback)(e=>{a(e),e!==null&&o.current.get(e)?.focus()},[]),c=(0,B.useCallback)(()=>t===`auto`?ND(o.current):Math.max(1,t),[t]);return{focusedIndex:i,setFocusedIndex:s,getItemProps:(0,B.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=PD(t,1,e,r);break;case`ArrowLeft`:case`a`:case`A`:o=PD(t,-1,e,r);break;case`ArrowDown`:case`s`:case`S`:o=FD(t,1,e,a,r);break;case`ArrowUp`:case`w`:case`W`:o=FD(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 LD(e){let t=Qy(e),n=()=>{t.refetch()};return t.isLoading?{kind:`loading`}:t.error?t.error instanceof Uy&&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 RD(){let e=Xy();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 zD(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 BD({workflowId:e,activeTag:t,onBack:n,onNavigateToWorkflow:r}){let i=LD(e),a=RD().workflows,o=(0,B.useRef)(null),s=(0,B.useRef)(null),c=(0,B.useRef)(r);c.current=r;let l=a??[],{prevWorkflow:u,nextWorkflow:d}=(0,B.useMemo)(()=>zD(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,B.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,B.useMemo)(()=>{let r=a?.find(t=>t.id===e)??void 0,o=t?CD[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 VD(e){let t=new Set(SD.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=SD.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 HD({viewModel:e}){let{state:t,dispatch:n,triggerRef:r,onCardSelect:i}=e,a=(0,B.useRef)(null),o=(0,B.useRef)(null),s=xD(),c=t.kind===`ready`?t.selectedWorkflowId:null;if((0,B.useEffect)(()=>{if(c){let e=requestAnimationFrame(()=>a.current?.focus());return()=>cancelAnimationFrame(e)}},[c]),t.kind===`loading`)return(0,V.jsx)(KD,{});if(t.kind===`error`)return(0,V.jsx)(qD,{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(SD.map(e=>e.id)),v=new Set(h.flatMap(e=>e.tags)),y=new Map(SD.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,V.jsx)(UD,{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 UD({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=BD({workflowId:e,activeTag:t,onBack:()=>m({type:`modal_closed`}),onNavigateToWorkflow:e=>m({type:`workflow_selected`,id:e})}),b=(0,B.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,B.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}=ID({count:a.length,cols:`auto`,onActivate:(0,B.useCallback)(e=>{let t=a[e];if(!t)return;let n=document.activeElement;n instanceof HTMLButtonElement&&h(t.id,n)},[a,h])});return(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.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,V.jsxs)(`p`,{className:`font-mono text-[10px] tracking-[0.25em] text-[var(--text-muted)] mt-1.5`,children:[`// `,i.length,` available`]})]}),(0,V.jsxs)(`div`,{role:`group`,"aria-label":`Filter workflows by category`,className:`flex flex-wrap gap-1.5`,children:[(0,V.jsx)(WD,{label:`All`,count:u,isActive:t===null,disabled:!1,onClick:()=>m({type:`tag_changed`,tag:null})}),SD.filter(e=>s.has(e.id)).map(e=>(0,V.jsx)(WD,{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,V.jsx)(WD,{label:`Other`,count:l,isActive:t===`__other__`,disabled:!1,onClick:()=>m({type:`tag_changed`,tag:t===`__other__`?null:`__other__`})})]}),o.length>1&&(0,V.jsxs)(`div`,{role:`group`,"aria-label":`Filter workflows by source`,className:`flex flex-wrap gap-1.5`,children:[(0,V.jsx)(WD,{label:`All Sources`,count:d,isActive:n===null,disabled:!1,onClick:()=>m({type:`source_changed`,source:null})}),o.map(e=>(0,V.jsx)(WD,{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,V.jsxs)(`div`,{className:`py-8 text-center space-y-3`,children:[(0,V.jsx)(`p`,{className:`text-sm text-[var(--text-muted)]`,children:`No workflows in this category.`}),t!==null&&(0,V.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,V.jsx)(`div`,{className:`space-y-6`,children:(()=>{let t=0;return VD(i).map(n=>(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(wD,{label:n.label,count:n.workflows.length,showRule:!0}),(0,V.jsx)(`div`,{...S,className:`grid grid-cols-2 lg:grid-cols-3 gap-3`,children:n.workflows.map(n=>(0,V.jsx)(GD,{workflow:n,onSelect:e=>h(n.id,e),navProps:x(t++),isActive:n.id===e},n.id))})]},n.tagId??`__other__`))})()}):(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(wD,{label:t===`__other__`?`Other`:CD[t]??t,count:i.length,showRule:!0}),(0,V.jsx)(`div`,{...S,className:`grid grid-cols-2 lg:grid-cols-3 gap-3`,children:i.map((t,n)=>(0,V.jsx)(GD,{workflow:t,onSelect:e=>h(t.id,e),navProps:x(n),isActive:t.id===e},t.id))})]}),(0,V.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-end justify-center p-4 pointer-events-none`,"aria-hidden":!e,children:[e&&(0,V.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,V.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,V.jsxs)(W,{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,V.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:co(20)}},v.state.scanline.key),(0,V.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,V.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,V.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-[0.30em] text-[var(--text-secondary)]`,children:`Workflow`}),p>=0&&(0,V.jsxs)(`span`,{className:`font-mono text-[10px] tracking-[0.20em] text-[var(--text-secondary)]`,children:[`[ `,p+1,` / `,a.length,` ]`]}),(0,V.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,V.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,V.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,V.jsx)(`div`,{"aria-live":`polite`,"aria-atomic":`true`,className:`sr-only`,children:a.find(t=>t.id===e)?.name??``}),e&&(0,V.jsx)(ED,{viewModel:y})]})]})})]})]})}function WD({label:e,count:t,isActive:n,disabled:r,onClick:i}){return(0,V.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,V.jsx)(`span`,{className:`sr-only`,children:`(selected)`})]})}function GD({workflow:e,onSelect:t,navProps:n,isActive:r}){let i=e.tags.filter(e=>e!==`routines`).map(e=>CD[e]??e);return(0,V.jsx)(lo,{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,V.jsxs)(`div`,{className:`flex flex-col flex-1 p-4 gap-2 min-w-0`,children:[(0,V.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,V.jsx)(`p`,{className:`text-xs text-[var(--text-secondary)] line-clamp-3 leading-relaxed flex-1`,children:e.description}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mt-auto pt-2 border-t border-[var(--border)]`,children:[(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:i.slice(0,1).map(e=>(0,V.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,V.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e.stepCount!=null&&e.stepCount>0&&(0,V.jsxs)(`span`,{className:`font-mono text-[9px] text-[var(--text-muted)]`,children:[e.stepCount,`s`]}),(0,V.jsxs)(`span`,{className:`font-mono text-[9px] text-[var(--text-muted)] max-w-[80px] truncate`,children:[`src: `,e.source.displayName]})]})]})]})})}function KD(){return(0,V.jsx)(`div`,{className:`space-y-6 motion-safe:animate-pulse`,children:[0,1].map(e=>(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(`div`,{className:`h-3 w-24 bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`flex-1 h-px bg-[var(--bg-tertiary)]`})]}),(0,V.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-3 gap-3`,children:[0,1,2,3,4,5].map(e=>(0,V.jsxs)(`div`,{className:`min-h-[160px] bg-[var(--bg-card)] border border-[var(--border)] flex flex-col`,children:[(0,V.jsx)(`div`,{className:`h-[3px] bg-[var(--bg-tertiary)]`}),(0,V.jsxs)(`div`,{className:`p-4 flex flex-col gap-2 flex-1`,children:[(0,V.jsx)(`div`,{className:`h-4 w-3/4 bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`h-3 w-full bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`h-3 w-5/6 bg-[var(--bg-tertiary)]`}),(0,V.jsxs)(`div`,{className:`mt-auto pt-2 border-t border-[var(--border)] flex justify-between`,children:[(0,V.jsx)(`div`,{className:`h-3 w-12 bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`h-3 w-16 bg-[var(--bg-tertiary)]`})]})]})]},e))})]},e))})}function qD({message:e,onRetry:t}){return(0,V.jsxs)(`div`,{className:`space-y-3 py-8 text-center`,children:[(0,V.jsx)(`p`,{className:`text-sm text-[var(--error)]`,children:e}),(0,V.jsx)(`button`,{type:`button`,onClick:t,className:`text-sm text-[var(--accent)] hover:text-[var(--accent-hover)] transition-colors`,children:`Try again`})]})}var JD=[{value:`recent`,label:`Recent first`,compareFn:(e,t)=>t.startedAtMs-e.startedAtMs},{value:`slowest`,label:`Slowest first`,compareFn:(e,t)=>t.durationMs-e.durationMs}],YD={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 XD(e,t){let n=JD.find(e=>e.value===t);return[...e].sort(n.compareFn)}function ZD(e){return e.reduce((e,t)=>Math.max(e,t.durationMs),0)}function QD(e){return e.filter(e=>YD[e.outcome].isError).length}function $D(e){return e.length===0?null:Math.round(e.reduce((e,t)=>e+t.durationMs,0)/e.length)}function eO(e){return e.length===0?null:e.reduce((e,t)=>Math.max(e,t.startedAtMs),0)}function tO(e,t){return t>0?Math.round(e/t*120):0}function nO(e){return`${e} recorded`}var rO=[{key:`tool`,label:`Tool`,minWidth:`180px`},{key:`duration`,label:`Duration`,width:`220px`},{key:`started`,label:`Started`,width:`100px`},{key:`outcome`,label:`Outcome`}];function iO({viewModel:e}){let{state:t}=e;if(t.kind===`loading`)return(0,V.jsx)(cO,{});if(t.kind===`devModeOff`)return(0,V.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,V.jsx)(`p`,{className:`text-sm text-[var(--text-muted)] text-center`,children:`nothing to see here`})});if(t.kind===`error`)return(0,V.jsxs)(`div`,{className:`space-y-3 py-8 text-center`,children:[(0,V.jsx)(`p`,{className:`text-sm text-[var(--error)]`,children:t.message}),(0,V.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,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsxs)(`p`,{className:`text-sm text-[var(--text-secondary)]`,children:[s,` | `,(0,V.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`:fo(o)]}),(0,V.jsx)(`div`,{role:`radiogroup`,"aria-label":`Sort order`,className:`flex items-center gap-1`,children:JD.map(e=>(0,V.jsx)(sO,{label:e.label,isActive:c===e.value,onClick:()=>l(e.value)},e.value))}),(0,V.jsxs)(`table`,{className:`w-full text-sm border-collapse`,children:[(0,V.jsx)(`thead`,{children:(0,V.jsx)(`tr`,{className:`text-xs text-[var(--text-muted)] border-b border-[var(--border)]`,children:rO.map(e=>(0,V.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,V.jsx)(`tbody`,{children:n.length===0?(0,V.jsx)(`tr`,{children:(0,V.jsx)(`td`,{colSpan:rO.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,V.jsx)(aO,{obs:e,maxDuration:r},`${e.startedAtMs}-${e.toolName}-${t}`))})]})]})}function aO({obs:e,maxDuration:t}){let n=YD[e.outcome].isError,r=tO(e.durationMs,t);return(0,V.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,V.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,V.jsx)(`span`,{className:`block truncate`,children:e.toolName})}),(0,V.jsxs)(`td`,{className:`py-2 pr-4`,style:{width:`220px`},children:[(0,V.jsxs)(`span`,{className:`font-mono text-[var(--text-primary)]`,children:[e.durationMs,`ms`]}),(0,V.jsx)(`div`,{"aria-hidden":`true`,className:`h-1 rounded mt-1`,style:{backgroundColor:`var(--accent)`,width:`${r}px`,maxWidth:`120px`}})]}),(0,V.jsx)(`td`,{className:`py-2 pr-4 text-[var(--text-secondary)]`,style:{width:`100px`},children:fo(e.startedAtMs)}),(0,V.jsx)(`td`,{className:`py-2`,children:(0,V.jsx)(oO,{outcome:e.outcome})})]})}function oO({outcome:e}){let t=YD[e];return(0,V.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 sO({label:e,isActive:t,onClick:n}){return(0,V.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 cO(){return(0,V.jsxs)(`div`,{className:`space-y-3 animate-pulse`,"aria-busy":`true`,"aria-label":`Loading performance data`,children:[(0,V.jsx)(`div`,{className:`h-4 w-64 rounded bg-[var(--bg-tertiary)]`}),(0,V.jsxs)(`div`,{className:`flex gap-1`,children:[(0,V.jsx)(`div`,{className:`h-8 w-24 rounded bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`h-8 w-24 rounded bg-[var(--bg-tertiary)]`})]}),(0,V.jsxs)(`div`,{className:`flex gap-4 border-b border-[var(--border)] pb-2`,children:[(0,V.jsx)(`div`,{className:`h-3 w-20 rounded bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`h-3 w-16 rounded bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`h-3 w-14 rounded bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`h-3 w-14 rounded bg-[var(--bg-tertiary)]`})]}),Array.from({length:8}).map((e,t)=>(0,V.jsxs)(`div`,{className:`flex gap-4 py-2`,children:[(0,V.jsx)(`div`,{className:`h-4 rounded bg-[var(--bg-tertiary)]`,style:{minWidth:`180px`,width:`180px`}}),(0,V.jsxs)(`div`,{className:`space-y-1`,style:{width:`220px`},children:[(0,V.jsx)(`div`,{className:`h-4 w-16 rounded bg-[var(--bg-tertiary)]`}),(0,V.jsx)(`div`,{className:`h-1 w-20 rounded bg-[var(--bg-tertiary)]`})]}),(0,V.jsx)(`div`,{className:`h-4 w-16 rounded bg-[var(--bg-tertiary)]`,style:{width:`100px`}}),(0,V.jsx)(`div`,{className:`h-5 w-12 rounded bg-[var(--bg-tertiary)]`})]},t))]})}var lO=`workrail:auto:mru-workflow`;function uO(){try{return localStorage.getItem(lO)}catch{return null}}function dO(e){try{localStorage.setItem(lO,e)}catch{}}function fO(){let e=Xy(),t=$y(),n=e.data?.workflows??[],r=t.data?.triggers??[],[i,a]=(0,B.useState)(()=>uO()??``),[o,s]=(0,B.useState)(``),[c,l]=(0,B.useState)(``),[u,d]=(0,B.useState)(!1),[f,p]=(0,B.useState)(null),[m,h]=(0,B.useState)(!1),[g,_]=(0,B.useState)(!0),v=(0,B.useRef)(null);(0,B.useEffect)(()=>{!i&&n.length>0&&a(n[0]?.id??``)},[i,n]);let y=e=>{a(e),dO(e)},b=async()=>{if(!(!i||!c.trim()||!o.trim())){d(!0),p(null),h(!1);try{await eb({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,V.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,V.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,V.jsx)(Ko,{color:`var(--accent)`,children:`Dispatch`})}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(Ko,{children:`Workflow`}),e.isLoading?(0,V.jsx)(`div`,{className:`text-[var(--text-muted)] text-xs`,children:`Loading workflows...`}):n.length===0?(0,V.jsx)(`div`,{className:`text-[var(--text-muted)] text-xs`,children:`No workflows available`}):(0,V.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,V.jsx)(`option`,{value:e.id,children:e.name??e.id},e.id))})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(Ko,{children:`Workspace path`}),(0,V.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,V.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,V.jsx)(Ko,{children:`Goal`}),(0,V.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,V.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,V.jsx)(`button`,{onClick:()=>void b(),disabled:!x,className:`self-start disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer`,children:(0,V.jsx)(no,{label:u?`RUNNING...`:`RUN`,color:x?`var(--accent)`:void 0,pulse:u})}),m&&(0,V.jsx)(`div`,{className:`text-[var(--success)] font-mono text-[10px] uppercase tracking-[0.20em]`,children:`Dispatched -- check Queue pane`}),f&&(0,V.jsx)(`div`,{className:`text-[var(--error)] text-xs font-mono`,children:f})]}),(0,V.jsxs)(`div`,{className:`border-t border-[var(--border)] pt-4`,children:[(0,V.jsxs)(`button`,{onClick:()=>_(!g),className:`flex items-center gap-2 mb-2 cursor-pointer group`,children:[(0,V.jsx)(`span`,{className:`text-[var(--text-muted)] text-xs transition-transform duration-150`,style:{transform:g?`rotate(-90deg)`:`rotate(0deg)`},children:`▼`}),(0,V.jsx)(no,{label:`TRIGGERS`,color:`var(--text-secondary)`}),r.length>0&&(0,V.jsxs)(`span`,{className:`text-xs text-[var(--text-muted)]`,children:[`(`,r.length,`)`]})]}),!g&&(0,V.jsx)(`div`,{className:`space-y-2`,children:t.isLoading?(0,V.jsx)(`div`,{className:`text-[var(--text-muted)] text-xs pl-4`,children:`Loading triggers...`}):r.length===0?(0,V.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,V.jsxs)(`div`,{className:`pl-4 border-l-2 border-[var(--border)] text-xs space-y-0.5`,children:[(0,V.jsx)(`div`,{className:`font-mono text-[var(--text-primary)] text-[11px]`,children:e.id}),(0,V.jsx)(`div`,{className:`text-[var(--text-muted)]`,children:e.workflowId}),(0,V.jsx)(`div`,{className:`text-[var(--text-muted)] truncate`,children:e.goal})]},e.id))})]})]})}function pO(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 mO(){let{data:e,isLoading:t,isError:n}=Gy(),r=(e?.sessions??[]).filter(e=>e.isAutonomous),{running:i,blocked:a,completed:o}=pO(r);return t?(0,V.jsx)(`div`,{className:`flex items-center justify-center py-20`,children:(0,V.jsx)(`div`,{className:`text-[var(--text-secondary)] text-sm`,children:`Loading sessions...`})}):n?(0,V.jsx)(`div`,{className:`text-[var(--error)] bg-[var(--bg-card)] rounded-lg p-4 text-sm`,children:`Failed to load sessions`}):(0,V.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,V.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,V.jsx)(Ko,{color:`var(--accent)`,children:`Queue`})}),(0,V.jsxs)(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[(0,V.jsx)(hO,{count:i,label:`RUNNING`,color:`var(--accent)`,pulse:!0}),(0,V.jsx)(hO,{count:a,label:`BLOCKED`,color:`var(--blocked)`}),(0,V.jsx)(hO,{count:o,label:`COMPLETED`,color:`var(--success)`})]}),r.length===0?(0,V.jsxs)(`div`,{className:`text-center py-16`,children:[(0,V.jsx)(`p`,{className:`text-[var(--text-secondary)] text-sm`,children:`No autonomous sessions yet`}),(0,V.jsx)(`p`,{className:`text-[var(--text-muted)] text-xs mt-1`,children:`Dispatch a workflow from the left pane to start.`})]}):(0,V.jsx)(`div`,{className:`space-y-2`,children:r.map(e=>(0,V.jsx)(gO,{session:e},e.sessionId))})]})}function hO({count:e,label:t,color:n,pulse:r}){return(0,V.jsx)(no,{label:`${e} ${t}`,color:e>0?n:`var(--text-muted)`,pulse:r&&e>0})}function gO({session:e}){let[t,n]=(0,B.useState)(!1),r=wi(),i=e.sessionTitle??e.workflowName??e.workflowId??`Unnamed session`,a=fo(e.lastModifiedMs);return(0,V.jsxs)(`div`,{className:`bg-[var(--bg-card)] border border-[var(--border)] rounded-lg overflow-hidden`,children:[(0,V.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,V.jsx)(`span`,{className:`text-[var(--text-muted)] text-xs transition-transform duration-150 shrink-0`,style:{transform:t?`rotate(90deg)`:`rotate(0deg)`},children:`▶`}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-sm font-medium text-[var(--text-primary)] truncate group-hover:text-[var(--accent)] transition-colors`,children:i}),(0,V.jsx)(`div`,{className:`font-mono text-[10px] text-[var(--text-muted)] opacity-60 truncate`,children:e.sessionId})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,V.jsx)(`span`,{className:`text-[10px] text-[var(--text-muted)] tabular-nums`,children:a}),e.isLive&&(0,V.jsx)(no,{label:`LIVE`,pulse:!0,color:`var(--accent)`,"aria-label":`Actively running`}),(0,V.jsx)(io,{status:e.status})]})]}),t&&(0,V.jsxs)(`div`,{className:`px-4 pb-4 border-t border-[var(--border)] pt-3 space-y-3`,children:[e.recapSnippet?(0,V.jsx)(`div`,{className:`text-xs text-[var(--text-secondary)] font-mono whitespace-pre-wrap leading-relaxed`,children:e.recapSnippet}):(0,V.jsx)(`div`,{className:`text-xs text-[var(--text-muted)]`,children:`No recap available yet.`}),(0,V.jsx)(`button`,{onClick:()=>void r({to:`/session/$sessionId`,params:{sessionId:e.sessionId}}),className:`cursor-pointer`,children:(0,V.jsx)(no,{label:`OPEN IN DAG`,color:`var(--accent)`})})]})]})}function _O(){return(0,V.jsxs)(`div`,{className:`flex flex-col md:flex-row gap-6`,children:[(0,V.jsx)(`div`,{className:`w-full md:w-2/5 shrink-0`,children:(0,V.jsx)(fO,{})}),(0,V.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,V.jsx)(mO,{})})]})}function vO(){let e=Gy(),t=Yy();tb();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 yO={scope:`active`,focusedIndex:-1,archive:null};function bO(e){throw Error(`Unhandled WorkspaceEvent type: ${String(e.type)}`)}function xO(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 bO(t)}}var SO=720*60*60*1e3,CO={in_progress:0,dormant:0,blocked:1,complete_with_gaps:2,complete:3};function wO(e){if(e.length!==0)return[...e].sort((e,t)=>{let n=CO[e.status]-CO[t.status];return n===0?t.lastModifiedMs-e.lastModifiedMs:n})[0]}function TO(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<SO||t===`all`?`visible`:`hidden`}function EO(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 DO(e,t,n){return[...e].filter(e=>TO(e,t,n)===`visible`).sort((e,t)=>{let n=EO(e)-EO(t);return n===0?t.activityMs-e.activityMs:n})}function OO(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=wO(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 kO(e,t,n,r){let i=OO(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:DO(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 AO({items:e,focusedIndex:t,scope:n,archive:r,dispatch:i,onSelectSession:a,onRefetch:o,disabled:s}){let c=(0,B.useRef)(e);c.current=e;let l=(0,B.useRef)(t);l.current=t;let u=(0,B.useRef)(n);u.current=n;let d=(0,B.useRef)(r);d.current=r;let f=(0,B.useRef)(s);f.current=s;let p=(0,B.useRef)(i);p.current=i;let m=(0,B.useRef)(a);m.current=a;let h=(0,B.useRef)(o);h.current=o,(0,B.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 jO(e=!1){let t=wi(),n=vO(),[r,i]=(0,B.useReducer)(xO,yO),a=(0,B.useRef)(0),o=(0,B.useCallback)(e=>{a.current=window.scrollY,t({to:`/session/$sessionId`,params:{sessionId:e}})},[t]),s=i,c=(0,B.useMemo)(()=>n.sessions?kO(n.sessions,n.worktreeRepos,r.scope,Date.now()):null,[n.sessions,n.worktreeRepos,r.scope]);AO({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,B.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 MO(){let e=Gy();return{sessions:e.data?.sessions,isLoading:e.isLoading,error:e.error instanceof Error?e.error:null}}function NO(e=``){return{rawSearch:e,sort:`recent`,groupBy:`none`,statusFilter:`all`,page:0,viewMode:`flat`}}function PO(e){throw Error(`Unhandled SessionListEvent type: ${String(e.type)}`)}function FO(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 PO(t)}}var IO={in_progress:0,blocked:1,dormant:2,complete_with_gaps:3,complete:4},LO=[{value:`recent`,label:`Recent`,compareFn:(e,t)=>t.lastModifiedMs-e.lastModifiedMs},{value:`status`,label:`Status`,compareFn:(e,t)=>IO[e.status]-IO[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}],RO=[{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)=>(IO[e]??99)-(IO[t]??99)},{value:`branch`,label:`Branch`,keyFn:e=>e.gitBranch??`No branch`}],zO=[{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 BO(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 VO(e,t){let n=LO.find(e=>e.value===t)??LO[0];return[...e].sort(n.compareFn)}function HO(e,t){let n=RO.find(e=>e.value===t)??RO[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 UO(e){let t={all:e.length};for(let n of e)t[n.status]=(t[n.status]??0)+1;return t}function WO(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 GO(e,t){let[n,r]=(0,B.useState)(e),i=(0,B.useRef)(null);return(0,B.useEffect)(()=>(i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>r(e),t),()=>{i.current!==null&&clearTimeout(i.current)}),[e,t]),n}function KO({onSelectSession:e,initialSearch:t=``}){let n=MO(),[r,i]=(0,B.useReducer)(FO,void 0,()=>NO(t)),a=GO(r.rawSearch,200),o=(0,B.useRef)([]),s=(0,B.useCallback)(t=>{let n=o.current[t];n&&e(n.sessionId)},[e]),{sessions:c,isLoading:l,error:u}=n,d=(0,B.useMemo)(()=>c?UO(c):{},[c]),f=(0,B.useMemo)(()=>{if(!c)return null;let e=BO(c,a,r.statusFilter);return{groups:HO(VO(e,r.sort),r.groupBy),total:c.length,filtered:e.length}},[c,a,r.statusFilter,r.sort,r.groupBy]),p=(0,B.useMemo)(()=>WO(c||[]),[c]),m=r.groupBy!==`none`,h=f?Math.ceil(f.filtered/25):0,g=r.page*25,_=g+25,v=(0,B.useMemo)(()=>!f||m?[]:f.groups[0]?.sessions.slice(g,_)??[],[f,m,g,_]);o.current=v;let{getItemProps:y,containerProps:b}=ID({count:v.length,cols:1,onActivate:s});return{state:(0,B.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:LO,groupAxes:RO,statusFilterOptions:zO,viewMode:r.viewMode,sessionTree:p}:{kind:`loading`},[l,u,f,r,h,m,d,v,y,b,p]),dispatch:i,onSelectSession:e}}var qO={selectedWorkflowId:null,selectedTag:null,selectedSource:null,hintVisible:!1};function JO(e){throw Error(`Unhandled WorkflowsEvent type: ${String(e.type)}`)}function YO(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 JO(t)}}function XO(e){let t=new Set;for(let n of e)for(let e of n.tags)e!==`routines`&&t.add(e);let n=SD.map(e=>e.id).filter(e=>t.has(e)),r=[...t].filter(e=>!SD.some(t=>t.id===e)).sort();return[...n,...r]}function ZO(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 QO(e,t,n){let r=new Set(SD.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 $O(e,t){if(t!==null)return e;let n=new Set(SD.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 SD){let t=r.get(e);t&&a.push(...t)}return a.push(...i),a}function ek({initialTag:e,onSelectTag:t}){let n=RD(),[r,i]=(0,B.useReducer)(YO,{...qO,selectedTag:e});(0,B.useEffect)(()=>{e!==r.selectedTag&&i({type:`tag_changed`,tag:e})},[e]);let a=(0,B.useRef)(null),o=(0,B.useCallback)((e,t)=>{a.current=t,t.blur(),i({type:`workflow_selected`,id:e})},[]);(0,B.useEffect)(()=>{if(!r.selectedWorkflowId&&a.current){let e=a.current;a.current=null,e.focus()}},[r.selectedWorkflowId]),(0,B.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,B.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,B.useMemo)(()=>{if(s)return{kind:`loading`};if(c)return{kind:`error`,message:c.message,onRetry:n.refetch};if(!l)return{kind:`loading`};let e=XO(l),t=ZO(l),i=QO(l,r.selectedTag,r.selectedSource),a=$O(i,r.selectedTag),o=QO(l,null,r.selectedSource),u=QO(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,B.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,B.useCallback)(e=>{e.type===`tag_changed`&&t(e.tag),i(e)},[t]),triggerRef:a,onCardSelect:o}}function tk(){let e=Zy();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 nk(){let e=tk(),[t,n]=(0,B.useState)(`recent`);return{state:(0,B.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=XD(r,t);return{kind:`ready`,sorted:i,maxDuration:ZD(i),errorCount:QD(r),avgMs:$D(r),lastCallMs:eO(r),countLabel:nO(r.length),sortOrder:t,onSortChange:n}},[e,t])}}function rk(e){let t=Ky(e);return{data:t.data,isLoading:t.isLoading,error:t.error instanceof Error?t.error:null}}function ik(e){let t=rk(e),[n,r]=(0,B.useState)(null),i=(0,B.useCallback)((e,t)=>{r(n=>n?.runId===e&&n?.nodeId===t?null:{runId:e,nodeId:t})},[]),a=(0,B.useCallback)(()=>{r(null)},[]),{isLoading:o,error:s,data:c}=t,l=(0,B.useMemo)(()=>!c||!n?null:c.runs.find(e=>e.runId===n.runId)??null,[c,n]);return{state:(0,B.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 ak=[{id:`workspace`,path:`/`},{id:`workflows`,path:`/workflows`},{id:`auto`,path:`/auto`},{id:`perf`,path:`/perf`}];function ok(){let e=wi(),t=ta(),{location:n}=sa(),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=jO(l),h=KO({onSelectSession:m.onSelectSession}),g=m.state.kind===`ready`?m.state.liveCount:0,_=m.state.kind===`ready`?m.state.blockedCount:0,v=(0,B.useCallback)(()=>{e({to:`/`})},[e]),y=(0,B.useCallback)(t=>{e({to:`/workflows`,search:{tag:t??void 0}})},[e]),b=(0,B.useCallback)(()=>{e({to:`/workflows`,search:{tag:p??void 0}})},[e,p]),x=(0,B.useCallback)(t=>{e({to:`/workflows/$workflowId`,params:{workflowId:t},search:{tag:p??void 0}})},[e,p]),S=ek({initialTag:p,onSelectTag:y}),C=BD({workflowId:f,activeTag:p,onBack:b,onNavigateToWorkflow:x}),w=ik(d??``),T=nk(),[E,D]=(0,B.useState)(null),O=(0,B.useCallback)((e,t)=>{t(),D(e),setTimeout(()=>D(null),200)},[]),k=(0,B.useRef)(null);return(0,B.useEffect)(()=>{let t=k.current;if(!t)return;function n(t){if(t.key===`ArrowLeft`||t.key===`ArrowRight`){t.preventDefault();let n=ak.findIndex(e=>e.id===c),r=ak[t.key===`ArrowRight`?(n+1)%ak.length:(n-1+ak.length)%ak.length];e({to:r.path,...r.path===`/workflows`?{search:{tag:void 0}}:{}})}}return t.addEventListener(`keydown`,n),()=>t.removeEventListener(`keydown`,n)},[c,e]),(0,V.jsxs)(`div`,{className:`min-h-screen`,style:{"--app-header-height":`56px`},children:[(0,V.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,V.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,V.jsx)(W,{cut:8,borderColor:`rgba(244, 196, 48, 0.5)`,background:`rgba(27, 31, 44, 0.8)`,className:`relative w-10 h-10`,children:(0,V.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,V.jsx)(`span`,{className:`font-mono text-[11px] font-bold text-[var(--accent)] tracking-widest`,children:`WR`})})}),(0,V.jsxs)(`div`,{className:`hidden sm:flex flex-col leading-none`,children:[(0,V.jsx)(`span`,{className:`font-mono text-[11px] font-bold text-[var(--text-primary)] tracking-[0.25em] uppercase`,children:`WR_CONSOLE`}),(0,V.jsxs)(`span`,{className:`font-mono text-[9px] text-[var(--text-muted)] tracking-[0.15em]`,children:[`// V`,`3.79.0`]})]})]}),l&&d?(0,V.jsx)(`nav`,{className:`flex items-center flex-1 justify-center`,children:(0,V.jsx)(TD,{segments:[{label:`Workspace`,onClick:v},{label:d?.slice(-12)??``}]})}):(0,V.jsxs)(`div`,{role:`tablist`,"aria-label":`Console sections`,ref:k,className:`flex items-center gap-1 flex-1 justify-center`,children:[(0,V.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,V.jsx)(`span`,{className:`tab-corner tab-corner--tl`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--tr`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--bl`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--br`,"aria-hidden":`true`}),`Workspace`]}),(0,V.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,V.jsx)(`span`,{className:`tab-corner tab-corner--tl`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--tr`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--bl`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--br`,"aria-hidden":`true`}),`Workflows`]}),(0,V.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,V.jsx)(`span`,{className:`tab-corner tab-corner--tl`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--tr`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--bl`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--br`,"aria-hidden":`true`}),`Auto`]}),(0,V.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,V.jsx)(`span`,{className:`tab-corner tab-corner--tl`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--tr`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--bl`,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`tab-corner tab-corner--br`,"aria-hidden":`true`}),`Performance`]})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[g>0&&(0,V.jsx)(no,{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,V.jsx)(no,{label:`${Math.min(_,9)}${_>9?`+`:``} BLOCKED`,color:`var(--blocked)`,role:`status`,"aria-label":`${_} blocked session${_===1?``:`s`}`})]})]}),(0,V.jsxs)(`main`,{className:`p-6`,style:{paddingTop:`calc(56px + 1.5rem)`},children:[(0,V.jsxs)(`div`,{id:`panel-workspace`,role:`tabpanel`,"aria-labelledby":`tab-workspace`,hidden:c===`workflows`||c===`perf`||c===`auto`,children:[(0,V.jsx)(Do,{viewModel:m,sessionListViewModel:h,hidden:l}),l&&d&&(0,V.jsx)(yD,{viewModel:w})]}),c===`workflows`&&(0,V.jsx)(`div`,{id:`panel-workflows`,role:`tabpanel`,"aria-labelledby":`tab-workflows`,children:u&&f?(0,V.jsx)(ED,{viewModel:C}):(0,V.jsx)(HD,{viewModel:S})}),c===`auto`&&(0,V.jsx)(`div`,{id:`panel-auto`,role:`tabpanel`,"aria-labelledby":`tab-auto`,children:(0,V.jsx)(_O,{})}),c===`perf`&&(0,V.jsx)(`div`,{id:`panel-perf`,role:`tabpanel`,"aria-labelledby":`tab-perf`,children:(0,V.jsx)(iO,{viewModel:T})})]})]})}var sk=Hi({component:ok}),ck=Bi({getParentRoute:()=>sk,path:`/`,component:()=>null}),lk=Bi({getParentRoute:()=>sk,path:`/session/$sessionId`,component:()=>null}),uk=Bi({getParentRoute:()=>sk,path:`/workflows`,validateSearch:e=>({tag:typeof e.tag==`string`?e.tag:void 0}),component:()=>null}),dk=Bi({getParentRoute:()=>sk,path:`/workflows/$workflowId`,validateSearch:e=>({tag:typeof e.tag==`string`?e.tag:void 0}),component:()=>null}),fk=Bi({getParentRoute:()=>sk,path:`/perf`,component:()=>null}),pk=Bi({getParentRoute:()=>sk,path:`/auto`,component:()=>null}),mk=ra({routeTree:sk.addChildren([ck,lk,uk,dk,fk,pk]),history:yr()}),hk=new ze({defaultOptions:{queries:{refetchInterval:5e3,staleTime:2e3}}});(0,ca.createRoot)(document.getElementById(`root`)).render((0,V.jsx)(B.StrictMode,{children:(0,V.jsx)(We,{client:hk,children:(0,V.jsx)(oa,{router:mk})})}));
@@ -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-C1ORzpX3.js"></script>
7
+ <script type="module" crossorigin src="/console/assets/index-DOM4l2VE.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/console/assets/index-DHrKiMCf.css">
9
9
  </head>
10
10
  <body>
@@ -92,7 +92,10 @@ class AgentLoop {
92
92
  catch (err) {
93
93
  const isAbort = this._abortController.signal.aborted ||
94
94
  (err instanceof Error && err.name === 'AbortError');
95
- const message = err instanceof Error ? err.message : String(err);
95
+ let message = err instanceof Error ? err.message : String(err);
96
+ if (!isAbort && err.status === 400) {
97
+ message = `agentConfig.model '${modelId}' was rejected by the API (check agentConfig.model in triggers.yml): ${message}`;
98
+ }
96
99
  this._appendErrorMessage(isAbort ? 'aborted' : message);
97
100
  await this._emitEvent({ type: 'agent_end' });
98
101
  return;
@@ -473,16 +473,16 @@
473
473
  "sha256": "5fe866e54f796975dec5d8ba9983aefd86074db212d3fccd64eed04bc9f0b3da",
474
474
  "bytes": 8011
475
475
  },
476
- "console-ui/assets/index-C1ORzpX3.js": {
477
- "sha256": "593e14bb3358a7e9eebe71e1f01c326ad5c1ff0ed634f0854d651d659da160f8",
478
- "bytes": 768377
479
- },
480
476
  "console-ui/assets/index-DHrKiMCf.css": {
481
477
  "sha256": "40290b50e21ee7e82433efe13b1aa31c1ea608bd057a5c4e324982f284bc928b",
482
478
  "bytes": 60673
483
479
  },
480
+ "console-ui/assets/index-DOM4l2VE.js": {
481
+ "sha256": "76a424f2a7290b2ef725da71cfba95f6a533a140ea88045081c028b664027b55",
482
+ "bytes": 768377
483
+ },
484
484
  "console-ui/index.html": {
485
- "sha256": "95b0bf2ad3f5fd759c38e42924de4657b60e2001e3e96ff49d02447ce3590819",
485
+ "sha256": "aab205e50e09387ae7c3fd333dbba53e8f8eb68c63a78e884144a7599d9d04ab",
486
486
  "bytes": 417
487
487
  },
488
488
  "console/standalone-console.d.ts": {
@@ -634,8 +634,8 @@
634
634
  "bytes": 3891
635
635
  },
636
636
  "daemon/agent-loop.js": {
637
- "sha256": "fb154e46790a89fe4a92cfa5e3c37361b1d1a41c2443437105cfda9d6c78a981",
638
- "bytes": 10607
637
+ "sha256": "9fe0cf3ae8cc08a7ff33bdf0c960ecd8b3b17345ca8574f64979b1b50d9ad236",
638
+ "bytes": 10819
639
639
  },
640
640
  "daemon/context-loader.d.ts": {
641
641
  "sha256": "73992e98475c16b94b880c1daac1da0d0650adfb895d1415ac18e73606f99a5c",
@@ -2106,12 +2106,12 @@
2106
2106
  "bytes": 1830
2107
2107
  },
2108
2108
  "trigger/trigger-store.js": {
2109
- "sha256": "79e7fe516eede2008fc3a32c439c2840a4895b265b13dba8977a76a51d0903e4",
2110
- "bytes": 50609
2109
+ "sha256": "7d30f1c3d1d6edc3c8d6a2c6e45098ee6e377cf02d404e6140165679da1d77ec",
2110
+ "bytes": 52050
2111
2111
  },
2112
2112
  "trigger/types.d.ts": {
2113
- "sha256": "68887851741b85262c438d602f1892cd1a4c8ce8adf9f3aeb483965b3011aecf",
2114
- "bytes": 4490
2113
+ "sha256": "fa0573c51c67037629116edeb1aec06fb27f9d31d0b964f52f243b7d6d020ab0",
2114
+ "bytes": 4515
2115
2115
  },
2116
2116
  "trigger/types.js": {
2117
2117
  "sha256": "45b4e4f23a6d1a2b07350196871b0c53840e5d8142b47f7acedd2f40ae7a6b73",
@@ -621,6 +621,18 @@ function validateAndResolveTrigger(raw, env, workspaces = {}) {
621
621
  let agentConfig;
622
622
  if (raw.agentConfig) {
623
623
  const model = raw.agentConfig.model?.trim() || undefined;
624
+ if (model !== undefined) {
625
+ const slashIdx = model.indexOf('/');
626
+ const provider = slashIdx === -1 ? '' : model.slice(0, slashIdx);
627
+ const modelId = slashIdx === -1 ? '' : model.slice(slashIdx + 1);
628
+ if (!provider || !modelId) {
629
+ return (0, result_js_1.err)({
630
+ kind: 'invalid_field_value',
631
+ field: `agentConfig.model (must be in 'provider/model-id' format, e.g. amazon-bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0, got: "${model}")`,
632
+ triggerId: rawId,
633
+ });
634
+ }
635
+ }
624
636
  let maxSessionMinutes;
625
637
  if (raw.agentConfig.maxSessionMinutes !== undefined) {
626
638
  const asNumber = Number(raw.agentConfig.maxSessionMinutes);
@@ -1064,6 +1076,22 @@ function validateTriggerStrict(trigger) {
1064
1076
  suggestedFix: 'branchPrefix: worktrain/',
1065
1077
  });
1066
1078
  }
1079
+ if (trigger.agentConfig?.model !== undefined) {
1080
+ const m = trigger.agentConfig.model;
1081
+ const slashIdx = m.indexOf('/');
1082
+ const provider = slashIdx === -1 ? '' : m.slice(0, slashIdx);
1083
+ const modelId = slashIdx === -1 ? '' : m.slice(slashIdx + 1);
1084
+ if (!provider || !modelId) {
1085
+ issues.push({
1086
+ rule: 'invalid-model-format',
1087
+ severity: 'error',
1088
+ triggerId: id,
1089
+ message: `agentConfig.model "${m}" is not in 'provider/model-id' format -- ` +
1090
+ 'both provider and model-id must be non-empty (e.g. amazon-bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0)',
1091
+ suggestedFix: 'model: amazon-bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0',
1092
+ });
1093
+ }
1094
+ }
1067
1095
  if (trigger.concurrencyMode === 'parallel' &&
1068
1096
  (!trigger.branchStrategy || trigger.branchStrategy === 'none') &&
1069
1097
  (trigger.autoCommit || trigger.autoOpenPR)) {
@@ -115,7 +115,7 @@ export interface WebhookEvent {
115
115
  readonly payload: Readonly<Record<string, unknown>>;
116
116
  readonly signature?: string;
117
117
  }
118
- export type TriggerValidationRule = 'autocommit-needs-worktree' | 'autoopenpr-needs-autocommit' | 'worktree-needs-base-branch' | 'worktree-needs-prefix' | 'parallel-without-worktree' | 'missing-goal-template' | 'missing-max-session-minutes' | 'missing-max-turns' | 'autocommit-on-main-checkout' | 'missing-max-queue-depth';
118
+ export type TriggerValidationRule = 'autocommit-needs-worktree' | 'autoopenpr-needs-autocommit' | 'worktree-needs-base-branch' | 'worktree-needs-prefix' | 'parallel-without-worktree' | 'missing-goal-template' | 'missing-max-session-minutes' | 'missing-max-turns' | 'autocommit-on-main-checkout' | 'missing-max-queue-depth' | 'invalid-model-format';
119
119
  export interface TriggerValidationIssue {
120
120
  readonly rule: TriggerValidationRule;
121
121
  readonly severity: 'error' | 'warning' | 'info';
@@ -610,6 +610,64 @@ Tier 0 injection needs a dedicated system prompt section separate from `assemble
610
610
 
611
611
  ---
612
612
 
613
+ ### Interpretation checkpoint for coding workflow: Candidate 5 (May 6, 2026)
614
+
615
+ **Status: done** | Shipped in PR #962 (feat/etienneb/interpretation-checkpoint, May 7, 2026)
616
+
617
+ **Score: 12** | Cor:2 Cap:3 Eff:2 Lev:3 Con:2 | Blocked: no
618
+
619
+ Added `phase-0c-assumption-verification` step to `wr.coding-task` (v1.3.0 → v1.4.0) between Phase 0 (classify) and Phase 0.5 (upstream context). The step requires the coding agent to state a one-sentence interpretation before listing any assumptions, produce exactly 3 codebase assumptions with predicted locations and severity labels, verify each assumption by reading the predicted location, and output an `InterpretationArtifact` context key with `ambiguityLevel: clear | uncertain`. High-severity refutations surface to operator via `report_issue`. Also appended Subtype A/B classification prompt to the retrospective step for distribution measurement.
620
+
621
+ This is the first step of the intent gap intervention sequence: Candidate 5 (shipped) → Candidate 4 (git-grounded context, next) → Candidate 1 or 3 gated on Subtype A/B empirical data.
622
+
623
+ ---
624
+
625
+ ### External assumption ranking for interpretation checkpoint (May 6, 2026)
626
+
627
+ **Status: idea** | Priority: medium
628
+
629
+ **Score: 10** | Cor:2 Cap:2 Eff:2 Lev:2 Con:2 | Blocked: no (Candidate 5 shipped PR #962, May 7, 2026)
630
+
631
+ The interpretation checkpoint (Candidate 5) asks the coding agent to label each of its own assumptions as `severity: high` or `severity: low`. This self-labeling is a known weak point: an agent with a confident wrong prior may mislabel its most dangerous architectural assumption as low-severity to avoid triggering the gate. Self-assessed severity is the single lowest-confidence element in the pitch (confidence: 0.55).
632
+
633
+ An external agent -- one that did not produce the assumptions -- can independently rank them by actual risk before verification runs. The external agent receives only the ticket and the assumption list (not the producing agent's full context or reasoning) and answers: which of these assumptions is most load-bearing? Which, if wrong, would cause the most damage? Are there high-risk areas this agent didn't surface at all?
634
+
635
+ The producing agent then verifies in order of externally-ranked risk rather than self-assessed severity. Severity classification moves from self-labeling to an independent signal, removing the 0.55-confidence gap entirely.
636
+
637
+ **Relationship to targeted session review:** the external ranking agent's output is also a high-signal review moment -- if the external agent flags assumptions the producing agent didn't think to surface, that delta is direct evidence of an interpretation gap.
638
+
639
+ **Things to hash out:**
640
+ - What context does the ranking agent receive? Ticket + assumption list only, or also the affected file list and design lock references? More context improves ranking quality but risks contaminating the independence.
641
+ - Is this a lightweight parallel call (runs simultaneously with verification setup) or a blocking step?
642
+ - How are conflicts between self-assessed severity and external ranking resolved? External ranking should win, but the producing agent should see the disagreement and explain it.
643
+ - Cost: one additional inference call per session. Acceptable for standard/thorough sessions; probably skip for QUICK mode.
644
+
645
+ ---
646
+
647
+ ### Intent gap correction: fix the interpretation after assumption refutation (May 6, 2026)
648
+
649
+ **Status: idea** | Priority: medium
650
+
651
+ **Score: 10** | Cor:2 Cap:2 Eff:2 Lev:2 Con:2 | Blocked: no (Candidate 5 shipped PR #962, May 7, 2026)
652
+
653
+ When an agent's assumption-surfacing step (Candidate 5) refutes a high-severity assumption, the current scoped fix is to surface the refutation to the operator and halt. But the real problem is deeper: the wrong prior that caused the refuted assumption may have already contaminated earlier context -- the upstream context harvest, the problem framing, the `reframedProblem` and `challengedAssumptions` context keys. A simple "re-read the file and try again" doesn't fix a wrong model; it patches the symptom in one step while leaving the contaminated context intact. Long-term, a refuted assumption that reflects a codebase-specific wrong prior (Subtype B) should also update the Memory store and eventually the knowledge graph so future sessions don't repeat the mistake.
654
+
655
+ This is explicitly out of scope for the Candidate 5 pitch -- detection is the right first boundary. Correction is a separate, larger problem that depends on session context rollback, Memory store integration, and eventually the knowledge graph.
656
+
657
+ **Done looks like:** when a high-severity assumption is refuted mid-session, the system can: (1) identify which prior context keys were formed under the wrong prior, (2) trigger a targeted correction sub-flow that re-derives those keys with the corrected interpretation, (3) write the correction back to the Memory store so future sessions in this workspace start with the right prior.
658
+
659
+ **Things to hash out:**
660
+ - What is the right granularity for context rollback? Rolling back individual keys vs. re-running entire prior phases are very different costs.
661
+ - How do you distinguish "assumption was wrong about this specific file" (local fix) from "assumption reflects a systematic wrong prior about this codebase pattern" (Memory store update warranted)?
662
+ - What is the trigger for a Memory store write -- every refuted high-severity assumption, or only ones confirmed as Subtype B by retrospective labeling?
663
+ - How does this interact with the knowledge graph when it ships? The assumption store (Candidate 2 from the intent gap discovery) and the knowledge graph are both candidates for receiving the correction signal.
664
+
665
+ **Relationship to existing entries:**
666
+ - Blocked by: Candidate 5 (assumption surfacing step) -- detection must exist before correction can be designed
667
+ - Related to: Subtype B intent failure (below), Knowledge graph (backlog), Memory store / living work context (shipped PR #939, #948, #952)
668
+
669
+ ---
670
+
613
671
  ### Subtype B intent failure: agent has a wrong prior about what this codebase does (May 5, 2026)
614
672
 
615
673
  **Status: idea -- needs empirical study before design** | Priority: high
@@ -1652,6 +1710,77 @@ Combined with the `DEFAULT_MAX_TURNS` cap, this provides defense-in-depth agains
1652
1710
 
1653
1711
  The durable session store, v2 engine, and workflow authoring features shared by all three systems.
1654
1712
 
1713
+ ### Coordinator-managed typed output vocabulary: agent emits typed events, coordinator reacts per type (May 7, 2026)
1714
+
1715
+ **Status: idea** | Priority: high
1716
+
1717
+ **Score: 12** | Cor:2 Cap:3 Eff:2 Lev:3 Con:2 | Blocked: no
1718
+
1719
+ Today, agent output is largely untyped -- notes, artifacts, context keys. The coordinator reacts to typed handoff artifacts at phase boundaries, but within a session the agent's observations, decisions, findings, and suggestions are all prose. The coordinator cannot programmatically react to them.
1720
+
1721
+ The idea: the coordinator owns a vocabulary of typed output kinds that it supports. Before a session starts, it injects that vocabulary into the agent's context -- the agent knows exactly what typed things it can emit and what each one means. When the agent emits a typed output, the coordinator reacts with the appropriate process for that type. The reaction is deterministic coordinator logic (not LLM reasoning), specified per type.
1722
+
1723
+ **Examples of typed output kinds and coordinator reactions:**
1724
+
1725
+ - `suggestion(kind: "abstraction_extraction")` → coordinator fires targeted verification: "what are the three future cases this serves?"
1726
+ - `finding(severity: "critical", area: "security")` → coordinator routes to immediate review, may block merge
1727
+ - `decision(chose: X, over: Y, rationale: ...)` → coordinator checks for conflicts with prior decisions in the session store
1728
+ - `scope_change(direction: "larger", reason: ...)` → coordinator re-evaluates task complexity, may re-route to a heavier workflow
1729
+ - `blocker(kind: "missing_context", what: ...)` → coordinator attempts to resolve the blocker from known sources before surfacing to operator
1730
+ - `learning(claim: ..., area: ..., confidence: ...)` → coordinator writes to the assumption store for future sessions
1731
+ - `assumption(claim: ..., severity: ...)` → coordinator gates on verification before proceeding (Candidate 5 is a specific instance of this)
1732
+
1733
+ **What makes this powerful:**
1734
+ The agent doesn't need to know what happens next when it emits a typed output -- that's the coordinator's job. The agent just has to recognize "this is an assumption I'm making" or "this is a scope change I'm noticing" and emit the right type. The coordinator's reaction logic handles the rest deterministically, without LLM turns.
1735
+
1736
+ **Relationship to existing entries:**
1737
+ - "Typed suggestion artifacts with workflow-directed verification" (below): a specific application of this pattern to suggestions
1738
+ - "Coordinator mid-session hooks": the coordinator's reaction to typed outputs is exactly a mid-session hook triggered by a specific event type
1739
+ - "Candidate 5 / interpretation checkpoint": the assumption verification step is a manually-implemented instance of this pattern for one output type
1740
+ - "Coordinator session store awareness": the coordinator's reaction to a `learning` or `decision` type can write to the session store for future sessions
1741
+
1742
+ **Things to hash out:**
1743
+ - Who defines the vocabulary of supported types -- the engine (closed set), the workflow author (per-workflow), or the coordinator (per-deployment)?
1744
+ - How does the agent learn what types are available? Injected in the system prompt, declared in the workflow, or both?
1745
+ - What is the API surface for emitting a typed output? A dedicated tool, a structured artifact field, a reserved context key pattern?
1746
+ - How are reactions defined? TypeScript in the coordinator script, declarative rules in triggers.yml, or something else?
1747
+ - What happens when the agent emits a type the coordinator doesn't handle? Silent drop, warning, or error?
1748
+ - Should typed outputs be visible in the console as first-class events, or only in the raw session log?
1749
+
1750
+ ---
1751
+
1752
+ ### Typed suggestion artifacts with workflow-directed verification (May 7, 2026)
1753
+
1754
+ **Status: idea** | Priority: medium
1755
+
1756
+ **Score: 11** | Cor:2 Cap:3 Eff:2 Lev:2 Con:2 | Blocked: no
1757
+
1758
+ Agents frequently make suggestions mid-workflow -- propose an abstraction, recommend a deferral, flag a scope expansion, suggest a performance optimization. Today these live in plain prose notes. The workflow cannot distinguish one type of suggestion from another, cannot apply targeted follow-up logic, and cannot verify that the suggestion was actually scrutinized before being accepted. A suggestion that warrants architectural review gets the same treatment as one that warrants nothing.
1759
+
1760
+ The idea: a typed `suggestion` tool call that the agent makes instead of embedding the suggestion in prose. The artifact carries a `kind` field (closed enum, workflow-declared) that tells the engine what type of suggestion this is. The workflow author declares, per suggestion kind, what verification the engine should require before the suggestion is accepted.
1761
+
1762
+ **Example suggestion kinds and their natural follow-up scrutiny:**
1763
+ - `abstraction_extraction` -- "is this premature? what are the three concrete future cases this serves? does any of them exist in the current backlog? does this introduce coupling that didn't exist before?"
1764
+ - `architectural_change` -- "does this conflict with any design locks? what breaks downstream?"
1765
+ - `scope_expansion` -- "is this actually in scope? is this the scope rationalization failure mode -- the agent declaring it's a separate ticket to avoid doing the work?"
1766
+ - `deferral` -- "is this genuinely separate work, or is the agent completing checkboxes while leaving real work undone?"
1767
+ - `performance_optimization` -- "is this premature? what is the actual measured bottleneck? what evidence justifies this now?"
1768
+
1769
+ **Mechanism:** fits naturally with the assessment gate system. A `suggestion_quality` assessment with dimensions specific to the suggestion kind. The workflow author declares which dimensions apply to each kind. When the agent emits a typed suggestion, the engine fires a `require_followup` consequence requiring the agent to answer the verification criteria for that kind before proceeding. If the agent cannot answer them satisfactorily, the suggestion does not pass.
1770
+
1771
+ **API shape is open:** the typed suggestion could be a dedicated tool call (`suggest(type: "abstraction_extraction", ...)`), a structured artifact field in `continue_workflow`, a special context key, or something else entirely. The key property is that it is machine-readable and has a `kind` field the engine can act on -- not prose. The exact surface needs design work.
1772
+
1773
+ **The friction concern:** if suggestions require too much overhead, agents will stop surfacing them or bury them in prose to avoid the gate. The verification criteria must be targeted and lightweight -- not a full review pass, just the specific questions that matter for that kind. "What are the three future cases this abstraction serves?" is lightweight. "Run a full architecture review" is not.
1774
+
1775
+ **Things to hash out:**
1776
+ - What is the closed set of suggestion kinds for the initial version? Too many kinds creates complexity; too few misses the point.
1777
+ - Should suggestion kinds be workflow-declared (each workflow author defines their own) or engine-owned (a closed set the engine enforces)? Engine-owned is more consistent but less flexible.
1778
+ - How does the agent signal that a suggestion was considered and rejected, not just overlooked? A declined suggestion should be as visible as an accepted one.
1779
+ - Does the verification happen inline (a `require_followup` on the same step) or as a separate verification step? Inline is lower friction; a separate step is more auditable.
1780
+ - How does this interact with the existing `report_issue` mechanism? Some suggestions that fail verification should surface to the operator, not just loop back to the agent.
1781
+
1782
+ ---
1783
+
1655
1784
  ### WorkTrain as the canonical workflow author -- MCP as a derived runtime (Apr 30, 2026)
1656
1785
 
1657
1786
  **Status: idea** | Priority: high
@@ -1954,6 +2083,37 @@ Surface in: `worktrain status`, `worktrain health <sessionId>`, console session
1954
2083
 
1955
2084
  Coordinator design patterns for WorkTrain's autonomous pipeline.
1956
2085
 
2086
+ ### Reliable synthetic human gates: mimicking operator approval and refusal in autonomous pipelines (May 6, 2026)
2087
+
2088
+ **Status: idea** | Priority: high
2089
+
2090
+ **Score: 13** | Cor:3 Cap:3 Eff:2 Lev:3 Con:2 | Blocked: no
2091
+
2092
+ WorkTrain's pipeline has several points where a human operator would naturally approve, reject, or redirect -- confirming an interpretation before coding starts, approving a direction from discovery, accepting a shaped pitch. In guided MCP sessions these gates fire as `requireConfirmation` steps. In fully autonomous daemon sessions, they either don't fire or surface to the operator outbox and wait indefinitely. There is currently no reliable mechanism for the coordinator to make these gate decisions autonomously in a way that is trustworthy enough to substitute for human judgment.
2093
+
2094
+ The problem is not just "add an LLM to make the decision." An LLM making approval decisions is subject to the same sycophancy, self-enhancement bias, and overconfidence problems the rest of the pipeline has. A naïve "spawn an agent to approve this" produces rubber-stamping, not genuine gatekeeping. What is needed is a structured, auditable, multi-signal gate that approximates what a careful human reviewer would do -- checking specific criteria, flagging specific concerns, requiring specific evidence before proceeding.
2095
+
2096
+ **What a strong synthetic gate needs:**
2097
+ - Typed criteria against which the artifact is evaluated (not free-form "does this look good?")
2098
+ - An independent agent that did not produce the artifact being evaluated
2099
+ - A cross-family challenger where possible (different model family = different correlated blind spots)
2100
+ - A structured verdict with explicit rationale tied to the criteria, not a confidence score
2101
+ - An escalation path when the synthetic gate is uncertain -- surface to operator rather than rubber-stamp
2102
+
2103
+ **Use cases that need this:**
2104
+ - Interpretation checkpoint: does the coded assumption set actually cover the architectural risks for this ticket?
2105
+ - Shaping approval: does the pitch have genuine acceptance criteria or are they vague enough to accept anything?
2106
+ - Discovery direction: is the selected direction actually distinct from the runner-up, or are they the same approach with different labels?
2107
+ - Review verdict: is this finding severe enough to block merge, or is it a style preference being inflated?
2108
+
2109
+ **Things to hash out:**
2110
+ - What is the right abstraction? A reusable `synthetic-gate` routine that takes typed criteria + artifact and returns a structured verdict? Or specialized gates per use case?
2111
+ - How do you prevent the synthetic gate from being gamed by the same agent that produced the artifact? The gate agent must not have access to the producing agent's reasoning, only its output.
2112
+ - What is the confidence threshold below which the synthetic gate escalates to a human rather than deciding? And how is that threshold configured per trigger?
2113
+ - How do you validate that a synthetic gate is actually performing the function of a human gate -- not just producing confident verdicts? Requires a calibration dataset of known-correct and known-incorrect artifacts with human ground truth.
2114
+ - Relationship to the `requireConfirmation` gate mechanism: the synthetic gate is the autonomous equivalent. It should produce the same typed routing signal the human confirmation gate produces, so the coordinator routing logic doesn't need to know which kind of gate fired.
2115
+
2116
+ ---
1957
2117
 
1958
2118
  ### Agents must not perform delivery actions -- only the coordinator's delivery layer can (Apr 30, 2026)
1959
2119
 
@@ -2464,6 +2624,67 @@ Ghost nodes represent steps that were compiled into the DAG but skipped at runti
2464
2624
 
2465
2625
  ## Workflow Library
2466
2626
 
2627
+ ### Pre-specialized expert agents: on-demand consultants for main agents (May 7, 2026)
2628
+
2629
+ **Status: idea** | Priority: high
2630
+
2631
+ **Score: 13** | Cor:2 Cap:3 Eff:2 Lev:3 Con:3 | Blocked: no
2632
+
2633
+ The main agent running a coding, review, or investigation workflow is not the expert. It is the orchestrator. When it needs specialized input -- "is this Kotlin idiomatic?", "does this violate any payments module invariants?", "what are the FP patterns this codebase uses for this?" -- it should be able to ask a pre-specialized consultant agent and get a bounded, expert answer back.
2634
+
2635
+ These expert agents are not running the main workflow. They do not own any phase or make any final decisions. They are consulted: spawned with a specific question, pre-loaded with dense expertise in a specific domain, and they return a bounded answer. The main agent synthesizes the input and retains full ownership.
2636
+
2637
+ **Examples:**
2638
+ - A Kotlin idioms expert pre-loaded with Kotlin best practices, common pitfalls, and idiomatic patterns -- queried when the coding or review agent wants to know "is this idiomatic Kotlin?"
2639
+ - A functional programming expert pre-loaded with the FP philosophy and patterns relevant to this codebase (from CLAUDE.md, design docs, etc.) -- queried when the agent is making decisions that touch FP style
2640
+ - A payments module expert pre-loaded with the payments execution paths, known invariants, and past design decisions -- queried when the task touches payments code
2641
+ - A security expert pre-loaded with the codebase's auth model, known vulnerabilities, and security invariants -- queried during review of auth-adjacent changes
2642
+
2643
+ **Two distinct usage patterns -- both valid:**
2644
+
2645
+ *Consultant mode:* The main agent mid-task asks a specific question ("is this Kotlin idiomatic?"), a pre-specialized agent is spawned with that question and its expertise briefing, it returns a bounded answer, the main agent synthesizes and moves on. Lightweight, on-demand, the main agent drives the interaction.
2646
+
2647
+ *Parallel specialist mode:* The coordinator spawns multiple pre-specialized agents simultaneously for a phase of work -- e.g. an MR review that launches a Kotlin expert, a payments module expert, and an FP patterns expert in parallel, each reviewing the same diff through their lens. The main agent or coordinator synthesizes. This is the 3-angle executor pattern from wr.discovery applied to expertise curation rather than framing angles. Each specialist contributes their perspective; no single agent has to cover everything.
2648
+
2649
+ The parallel specialist mode is conceptually similar to the existing reviewer families in wr.mr-review, but with expertise injection replacing role prompts. "You are a correctness reviewer" and "you are an agent briefed on this codebase's actual invariants, the past bugs in this module, and the specific patterns we use here" are very different levels of specificity.
2650
+
2651
+ **What makes expert consultants distinct from existing reviewer families (MR review):**
2652
+ Existing reviewer families are top-level sessions running the full review workflow independently. Expert consultants (in consultant mode) are lightweight bounded spawns -- more like calling a function than running a parallel pipeline. In parallel specialist mode they are closer to reviewer families, but curated for the specific task rather than generically role-assigned.
2653
+
2654
+ **What makes this distinct from existing context injection:**
2655
+ Existing context injection (living work context, assembledContextSummary) threads pipeline state between phases -- history of what happened. Expert consultants carry curated domain expertise -- best practices, idioms, invariants, patterns. The content type is different: not "what was done" but "what is true about this domain."
2656
+
2657
+ **Implementation shape -- specialized workflows, not just context injection:**
2658
+
2659
+ The most powerful form of a specialist is not an agent that receives a big expertise briefing at spawn time and then works freely. It is an agent running a purpose-built specialized workflow that contains both the expertise and the process for applying it systematically.
2660
+
2661
+ A `wr.kotlin-review` workflow contains: the Kotlin expertise in `metaGuidance` and `references`, and a structured procedure -- "step 1: check null safety patterns at these call sites; step 2: evaluate coroutine usage against these criteria; step 3: check data class conventions..." Breaking the domain into steps ensures the specialist covers everything the domain requires, in the right order, with the right depth. A pure context dump leaves coverage to chance; a workflow enforces it.
2662
+
2663
+ This also makes specialists auditable: you can see in the session store exactly which steps the specialist ran, what it found, and whether it covered all required dimensions. And specialized workflows improve over time via `wr.workflow-for-workflows`, compounding quality the same way all bundled workflows do.
2664
+
2665
+ For dynamic specialists (payments module expert, specific subsystem expert), the workflow defines the process for generating the briefing dynamically -- walk these execution paths, read these design docs, extract these invariants -- rather than containing a static briefing.
2666
+
2667
+ **What needs to be built:**
2668
+ - A catalog of specialized workflows: static domain specialists (wr.kotlin-review, wr.fp-patterns-review) and dynamic module specialists (wr.module-expert with a briefing-generation phase)
2669
+ - A matching mechanism: given the task's affected files and domains, which specialist workflows are relevant?
2670
+ - A consultation protocol: how does the main agent query a specialist? How does the specialist return a typed artifact the main agent can act on?
2671
+ - Dynamic briefing generation: for module-specific specialists, a workflow phase that walks affected execution paths and generates the curated briefing before the expert work begins
2672
+
2673
+ **Relationship to existing entries:**
2674
+ - "Knowledge graph": the long-term structural ground truth version of this. Expert briefings are the lower-cost precursor that doesn't require the full graph.
2675
+ - "Assumption store": verified codebase facts are one input to the module expert briefing.
2676
+ - "Coordinator mid-session hooks": expert consultation could be triggered mid-session by the coordinator when specific signals fire (e.g. agent touches a known-tricky module).
2677
+
2678
+ **Things to hash out:**
2679
+ - What is the right format for an expertise briefing? Prose vs structured facts vs a combination?
2680
+ - How are static briefings maintained? They go stale as language versions change and codebases evolve.
2681
+ - How are dynamic briefings generated? Static analysis? LLM-assisted code walk? What is the cost and freshness guarantee?
2682
+ - How does the main agent know which experts are available and when to consult them? Explicit workflow step, or opportunistic mid-task consultation?
2683
+ - Token budget: expert consultation adds turns and tokens. When is the cost worth it vs. the main agent just proceeding with its own judgment?
2684
+ - How does the consultation differ from just giving the main agent a bigger context window? The answer should be "specificity and freshness" -- a consultant briefed on this specific module is better than a general agent with everything injected.
2685
+
2686
+ ---
2687
+
2467
2688
  ### Automatic root cause analysis when MR review finds issues post-coding (Apr 30, 2026)
2468
2689
 
2469
2690
  **Status: idea** | Priority: high
@@ -2480,6 +2701,8 @@ When an MR review session (run by a WorkTrain agent) finds issues in a coding se
2480
2701
 
2481
2702
  **Why this matters**: every finding that slips through is a signal about a workflow or process gap. Today that signal is lost. Capturing it systematically and feeding it back into workflow improvement closes the quality loop.
2482
2703
 
2704
+ **Concrete model:** CodeRabbit does this for MR reviews -- when a human reviewer corrects a CodeRabbit finding or points out something it missed, CodeRabbit extracts a structured learning (`{ claim, repo, file context, timestamp }`) and injects it into future review sessions for the same repo. WorkTrain should do the same, and broader: learnings from coding corrections (not just review corrections) feed into the per-workspace codebase assumption store, which directly addresses Subtype B intent failures. Human feedback on WorkTrain's PRs is the write path for that store.
2705
+
2483
2706
  **Things to hash out:**
2484
2707
  - How does WorkTrain detect that a human has commented on a PR post-review? This requires monitoring the PR for new review activity after WorkTrain's session completed -- either webhook events or polling.
2485
2708
  - What does the analysis session actually produce? A structured finding about the gap? A concrete proposal for workflow improvement? Both?
@@ -2487,6 +2710,21 @@ When an MR review session (run by a WorkTrain agent) finds issues in a coding se
2487
2710
  - How do you distinguish "the workflow is fine but this was a genuinely hard edge case" from "the workflow has a systematic gap"? A single miss doesn't prove a gap; multiple misses of the same kind do.
2488
2711
  - Should the analysis result feed directly into `workflow-effectiveness-assessment`, or is it a separate concern?
2489
2712
  - For the "coding agent missed it" case: is the right fix to change the coding workflow, or to make the review workflow more adversarial?
2713
+ - How are codebase-specific learnings extracted from free-form human review comments? A structured extraction step (similar to CodeRabbit's learning extraction) is needed to turn "actually this is wrong because X" into a typed store entry.
2714
+ - How are extracted learnings scoped and invalidated over time? Per-repo scope is right for codebase-specific facts, but learnings go stale after refactors. A `lastVerified` + staleness mechanism is needed.
2715
+ - Relationship to the assumption store (Candidate 2 from the intent gap discovery): human PR corrections are the primary write path for the per-workspace codebase assumption store. These two entries should be designed together.
2716
+
2717
+ ---
2718
+
2719
+ ### wr.discovery recommendation quality improvements v3.5 (May 6, 2026)
2720
+
2721
+ **Status: done** | Shipped in PR #951 (feat/etienneb/discovery-workflow-v35, May 6, 2026)
2722
+
2723
+ **Score: 13** | Cor:2 Cap:3 Eff:2 Lev:3 Con:3 | Blocked: no
2724
+
2725
+ Evidence-based redesign of `wr.discovery` (v3.4.0 → v3.5.0) addressing three failure modes -- coverage (right answer never generated), quality (wrong answer selected), and selection (right answer not selected). Key changes: all three assessment gates now have `assessmentConsequences` that block on failure; Phase 3d/3e split isolates external challenge from fresh-context selection; typed `SelectionOutput` tier (`strong_recommendation | provisional_recommendation | insufficient_signal`) driven by observable signals; `FrameValidityCheck` at landscape-to-frame transition; verbalized sampling + ordinary persona rotation in executor goal strings; `recommendationConfidenceBand` downgrade-only invariant across resolution phases; Phase 6 restructured as falsification-shaped fresh-context validator; `selectionTier` added to `wr.discovery_handoff` artifact.
2726
+
2727
+ Full audit at `.workrail/discovery-workflow-audit.md`, implementation plan at `.workrail/discovery-workflow-implementation-plan.md`.
2490
2728
 
2491
2729
  ---
2492
2730
 
@@ -2601,6 +2839,45 @@ Some workflows want notes to consistently capture current understanding, key fin
2601
2839
 
2602
2840
  ---
2603
2841
 
2842
+ ### Targeted session review: extract high-signal moments instead of reviewing full transcripts (May 6, 2026)
2843
+
2844
+ **Status: idea** | Priority: high
2845
+
2846
+ **Score: 12** | Cor:2 Cap:3 Eff:2 Lev:3 Con:2 | Blocked: no
2847
+
2848
+ Reviewing a full agent session transcript to evaluate quality is prohibitively expensive -- long sessions have hundreds of tool calls, file reads, and reasoning steps. But most of the signal about whether a session went well lives in a small number of high-signal moments: confirmation gates, places where the agent flagged uncertainty or divergence, steps where the agent's output failed to match the expected contract, and points where the agent encountered reality and had to adapt. Reviewing those moments selectively is 10-50x cheaper than reading the full transcript and captures most of the quality signal.
2849
+
2850
+ **High-signal moments worth targeting:**
2851
+
2852
+ 1. **Confirmation gate outcomes** -- when a `requireConfirmation` gate fired, what did the agent report? Did it accurately represent the state of the work? Was the decision the right one in hindsight?
2853
+
2854
+ 2. **Agent self-reported issues** -- calls to `report_issue` or `signal_coordinator` during the session. These are the agent's own flags that something was wrong. Each one warrants inspection: was the issue real, was the agent's characterization accurate, was the resolution appropriate?
2855
+
2856
+ 3. **Contract validation failures** -- steps where the engine returned a `blocked` or `require_followup` response. The agent's output failed the output contract. What did it produce, and why?
2857
+
2858
+ 4. **Agent-workflow friction points** -- places where the agent deviated from the expected step procedure, added divergence markers, or explicitly noted a gap between the workflow instructions and the reality it encountered. These are the inputs to workflow improvement.
2859
+
2860
+ 5. **Interpretation vs outcome delta** -- the gap between what the agent stated it was building (interpretation checkpoint, once it exists) and what it actually produced. The delta is the intent gap in concrete form.
2861
+
2862
+ 6. **Sycophancy signals** -- position changes without new evidence, position reversals after challenge, confidence-accuracy mismatches visible in the notes.
2863
+
2864
+ **Why this matters:** without targeted review, session quality is only observable at the PR level (did the output pass review?). That's a lagging indicator that catches failures after they've shipped cost. Targeted review of high-signal moments catches failures mid-session or immediately post-session, before the cost compounds.
2865
+
2866
+ **Relationship to existing entries:**
2867
+ - "Agent-reportable workflow bugs" (below) -- the agent's own flags are one of the primary review targets
2868
+ - "Synthetic human gates" -- the targeted review output is what a synthetic gate would consume to make an approval decision
2869
+ - "Automatic root cause analysis" -- targeted review is the cheaper precursor that identifies which sessions warrant full root cause analysis
2870
+ - "Per-run workflow improvement retrospective" -- the session retrospective is one moment in the targeted review; this entry is about the full set of moments across a session
2871
+
2872
+ **Things to hash out:**
2873
+ - What is the right extraction mechanism? The session event log already records every tool call, step advance, and artifact. A targeted review agent reads selected event types rather than the full log. What is the right query interface?
2874
+ - Which moments are always reviewed vs. sampled? Confirmation gates and `report_issue` calls probably warrant 100% review; routine step advances can be sampled.
2875
+ - Should targeted review happen synchronously (coordinator waits before proceeding) or asynchronously (review happens in parallel, findings surface to operator outbox)?
2876
+ - How are review findings acted on? They could feed into: (a) the synthetic gate decision for the current session, (b) the workflow improvement retrospective, (c) the assumption store if codebase-specific learnings are extracted.
2877
+ - What does the targeted review agent actually produce? A structured verdict per moment reviewed, a severity-tagged list of concerns, or a binary pass/fail?
2878
+
2879
+ ---
2880
+
2604
2881
  ### Agent-reportable workflow bugs (Apr 28, 2026)
2605
2882
 
2606
2883
  **Status: idea** | Priority: high
@@ -2617,6 +2894,7 @@ A mechanism for agents to report problems with the WorkRail system itself during
2617
2894
  - Should reports survive session cleanup, or is their lifetime tied to the session?
2618
2895
  - Who owns acting on these reports -- the operator, the workflow author, or an automated system?
2619
2896
  - Should this be available in interactive (MCP) sessions, or daemon sessions only?
2897
+ - Relationship to "Targeted session review": agent-reported workflow bugs are one of the primary high-signal moments that targeted session review would extract and inspect.
2620
2898
 
2621
2899
  ---
2622
2900
 
@@ -2673,6 +2951,40 @@ A proof record contains: `prNumber`, `goal`, `verificationChain` (array of `{ ki
2673
2951
 
2674
2952
  ---
2675
2953
 
2954
+ ### Coordinator mid-session hooks: react to workflow events without waiting for session completion (May 6, 2026)
2955
+
2956
+ **Status: idea** | Priority: high
2957
+
2958
+ **Score: 12** | Cor:2 Cap:3 Eff:2 Lev:3 Con:2 | Blocked: no
2959
+
2960
+ The coordinator currently acts only between sessions -- it spawns a session, awaits its completion, reads the typed output artifact, and decides what to do next. It has no mechanism to react to events that happen inside a running session. This means the coordinator cannot spawn helper agents mid-session (e.g. an external assumption ranker when the interpretation checkpoint fires), cannot intercept a confirmation gate and satisfy it autonomously, and cannot act on a step completion artifact before the full session finishes.
2961
+
2962
+ The gap: workflow lifecycle events (step completed, gate fired, artifact emitted, `report_issue` called) are currently only visible after the session ends via the session store. The coordinator needs a way to subscribe to these events as they happen and act on them -- spawning agents, injecting steer messages, or making routing decisions -- without waiting for session completion.
2963
+
2964
+ **Concrete use cases this unlocks:**
2965
+ - Spawn an external assumption-ranking agent when the interpretation checkpoint step completes, inject its ranking back into the session before verification runs
2966
+ - Auto-satisfy a `requireConfirmation` gate in autonomous mode by running a synthetic gate evaluation and steering the session with the result
2967
+ - Spawn a targeted review agent when a specific step artifact is emitted, surface findings before the session proceeds to the next phase
2968
+ - React to a `report_issue` call mid-session by spawning an investigation agent immediately rather than waiting for the full session to fail
2969
+
2970
+ **What this requires:**
2971
+ - A real-time or near-real-time event subscription mechanism from the coordinator to the session event log (the append-only JSONL already has all the events; the coordinator needs a watch/poll interface on it)
2972
+ - A `steer` injection path from the coordinator into a running session (the steer endpoint already exists at `POST /sessions/:id/steer`)
2973
+ - A coordinator hook registry: declarative rules of the form "when session X emits event type Y with artifact kind Z, execute hook H"
2974
+
2975
+ **Relationship to existing entries:**
2976
+ - "Scripts-first coordinator" (below): the hooks would be coordinator scripts reacting to events, not LLM reasoning
2977
+ - "Native multi-agent orchestration": `spawn_session` + `await_sessions` handles between-session orchestration; this handles within-session coordination
2978
+ - "Workflow runtime adapter": mid-session hooks are how the daemon adapter satisfies `requireConfirmation` gates autonomously
2979
+
2980
+ **Things to hash out:**
2981
+ - Poll vs push: the session event log is append-only JSONL. The coordinator can poll it efficiently (tail -f equivalent), but a proper event bus (the daemon event emitter already exists) would be cleaner. Which is the right mechanism?
2982
+ - Hook registry format: declarative JSON rules in `triggers.yml`, or imperative TypeScript in the coordinator script? The declarative approach is more auditable; the imperative approach is more flexible.
2983
+ - Ordering guarantees: if the coordinator injects a steer message in response to a step completion, does the session engine guarantee the steer is processed before the next step begins? Race condition risk.
2984
+ - Blast radius: a hook that fires incorrectly (wrong event matched, wrong steer injected) could derail a running session in a hard-to-debug way. What are the rollback and auditability guarantees?
2985
+
2986
+ ---
2987
+
2676
2988
  ### Scripts-first coordinator: avoid the main agent wherever possible (Apr 15, 2026)
2677
2989
 
2678
2990
  **Status: partial** | Foundation shipped PR #908 (Apr 30, 2026)
@@ -4758,7 +5070,25 @@ The agent is expensive, inconsistent, and slow. Scripts are free, deterministic,
4758
5070
 
4759
5071
  ### Dynamic model selection
4760
5072
 
4761
- **Status: done** -- shipped in `triggers.yml` `agentConfig.model`
5073
+ **Status: partial** -- raw model ID (`agentConfig.model`) shipped in `triggers.yml`. Two gaps remain: (1) no validation at trigger parse or startup -- a bad model ID is only caught when the first LLM call fires; (2) every trigger hardcodes a provider-specific ID, which breaks when the inference profile naming convention changes (e.g. `us.anthropic.claude-haiku-4-5-20251001` vs `us.anthropic.claude-haiku-4-5-20251001-v1:0`).
5074
+
5075
+ ### Model tier abstraction: cheap / medium / expensive (May 7, 2026)
5076
+
5077
+ **Status: idea** | Priority: medium
5078
+
5079
+ **Score: 11** | Cor:2 Cap:3 Eff:2 Lev:3 Con:2 | Blocked: no
5080
+
5081
+ **The problem:** Triggers hardcode provider-specific model IDs (`amazon-bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0`). When inference profile naming conventions change, or when switching providers/regions, every trigger must be updated manually. The daemon's adaptive coordinator already makes implicit cost/quality tradeoffs (Haiku for routing, Sonnet for coding) but has no first-class mechanism to express them -- it's locked to whatever IDs are in `agentConfig.model`.
5082
+
5083
+ **The idea:** Introduce a tier abstraction. Triggers and workflow phases declare a tier (`cheap | medium | expensive`). The daemon resolves tiers to concrete model IDs from a tier map in `~/.workrail/config.json`. The adaptive coordinator picks tiers per phase: cheap for classification and routing, medium for coding, expensive for architectural review. Changing provider or region means updating the tier map once.
5084
+
5085
+ **Validation is a prerequisite.** Before tiers make sense, bad model IDs need to be caught at startup rather than at first LLM call. See "Model ID validation at daemon startup" below.
5086
+
5087
+ **Things to hash out:**
5088
+ - Where does the tier map live? `~/.workrail/config.json` (global) vs. `triggers.yml` (per-workspace) vs. both with cascade.
5089
+ - Does the tier map need to carry both a Bedrock and a direct-API model per tier, or does one path own the daemon?
5090
+ - Should the adaptive coordinator receive the tier map as a dependency, or should it always spawn sessions with explicit `agentConfig.model` set by the coordinator?
5091
+ - How do you handle models that exist on one provider but not another (e.g. Opus available on Bedrock but not direct API under certain rate limits)?
4762
5092
 
4763
5093
  ### Multi-agent support (spawn_agent + coordinator sessions)
4764
5094
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exaudeus/workrail",
3
- "version": "3.79.0",
3
+ "version": "3.79.1",
4
4
  "description": "Step-by-step workflow enforcement for AI agents via MCP",
5
5
  "license": "MIT",
6
6
  "repository": {