@netnodeag/kraftwerk 0.57.2 → 0.57.3

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.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-BlujZXnd.js","assets/dist-H3rerbMg.js","assets/dist-CjgXMnns.js","assets/dist-y6xNc3Ek.js","assets/dist-Do1TayfN.js","assets/dist-CPlSMtdY.js","assets/editor-B1Jq9YIq.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-DtVtHids.js","assets/dist-H3rerbMg.js","assets/dist-C9wdXHwY.js","assets/dist-9zOw_mLO.js","assets/dist-_9tJHb24.js","assets/dist-CPlSMtdY.js","assets/editor-B1Jq9YIq.css"])))=>i.map(i=>d[i]);
2
2
  var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function ee(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function j(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function M(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,M(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+ee(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),M(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+ee(a,u),c+=M(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+ee(a,u++),c+=M(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return M(j(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function te(e,t,n){if(e==null)return e;var r=[],i=0;return M(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ne(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var N=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},P={map:te,forEach:function(e,t,n){te(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return te(e,function(){t++}),t},toArray:function(e){return te(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=P,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:ne}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,N)}catch(e){N(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.8`})),d=o(((e,t)=>{t.exports=u()})),f=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&ee(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ee(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function ee(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,ee(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),p=o(((e,t)=>{t.exports=f()})),m=o((e=>{var t=d();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.8`})),h=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=m()})),g=o((e=>{var t=p(),n=d(),r=h();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}var m=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),D=Symbol.for(`react.memo`),O=Symbol.for(`react.lazy`),k=Symbol.for(`react.activity`),A=Symbol.for(`react.memo_cache_sentinel`),ee=Symbol.iterator;function j(e){return typeof e!=`object`||!e?null:(e=ee&&e[ee]||e[`@@iterator`],typeof e==`function`?e:null)}var M=Symbol.for(`react.client.reference`);function te(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===M?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case T:return`Suspense`;case E:return`SuspenseList`;case k:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case D:return t=e.displayName||null,t===null?te(e.type)||`Memo`:t;case O:t=e._payload,e=e._init;try{return te(e(t))}catch{}}return null}var ne=Array.isArray,N=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,re={pending:!1,data:null,method:null,action:null},F=[],ie=-1;function I(e){return{current:e}}function L(e){0>ie||(e.current=F[ie],F[ie]=null,ie--)}function R(e,t){ie++,F[ie]=e.current,e.current=t}var z=I(null),ae=I(null),oe=I(null),se=I(null);function ce(e,t){switch(R(oe,t),R(ae,e),R(z,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}L(z),R(z,e)}function B(){L(z),L(ae),L(oe)}function le(e){e.memoizedState!==null&&R(se,e);var t=z.current,n=Hd(t,e.type);t!==n&&(R(ae,e),R(z,n))}function V(e){ae.current===e&&(L(z),L(ae)),se.current===e&&(L(se),Qf._currentValue=re)}var ue,de;function fe(e){if(ue===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ue=t&&t[1]||``,de=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+ue+e+de}var pe=!1;function me(e,t){if(!e||pe)return``;pe=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
@@ -210,7 +210,7 @@ description: What this skill is for (one line)
210
210
 
211
211
  Instructions this agent follows when the skill applies or is invoked with /<name>.
212
212
  `;function Pa({slug:e}){let t=H(`/api/agents/${encodeURIComponent(e)}/skills`,!1)?.skills??[],[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``);async function c(t){s(``);let n=await fetch(`/api/agents/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}`),i=await n.json().catch(()=>null);if(!n.ok||!i||i.error)return void s(i?.error??`could not load skill`);r({name:t,content:i.content??``,isNew:!1})}async function l(){if(!n)return;a(!0),s(``);let t=await(await fetch(`/api/agents/${encodeURIComponent(e)}/skills`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:n.name,content:n.content})})).json().catch(()=>({error:`save failed`}));a(!1),t.error?s(t.error):r(null)}async function u(t){window.confirm(`Delete skill "/${t}" of this agent (its folder is removed)?`)&&(await fetch(`/api/agents/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}`,{method:`DELETE`}).catch(()=>{}),n?.name===t&&r(null))}return(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`own skills — only this agent`}),(0,S.jsx)(`span`,{className:`spacer`}),!n&&(0,S.jsxs)(`button`,{className:`open-raw`,onClick:()=>{r({name:``,content:Na,isNew:!0}),s(``)},children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` new skill`]})]}),t.length===0&&!n&&(0,S.jsxs)(`div`,{className:`viewer-note`,children:[`none — skills in `,(0,S.jsxs)(`code`,{children:[`agents/`,e,`/skills/`]}),` are private to this agent; skills for every agent live in the workspace skills folder.`]}),t.length>0&&!n&&(0,S.jsx)(`div`,{className:`m3-list`,children:t.map(e=>(0,S.jsxs)(`div`,{className:`m3-row`,children:[(0,S.jsx)(`span`,{className:`m3-ico`,children:(0,S.jsx)(C,{name:`extension`})}),(0,S.jsxs)(`span`,{className:`m3-body`,children:[(0,S.jsxs)(`span`,{className:`m3-head`,children:[`/`,e.name]}),(0,S.jsx)(`span`,{className:`m3-sub`,children:e.description||(0,S.jsx)(`code`,{children:`SKILL.md`})})]}),(0,S.jsxs)(`button`,{className:`open-raw`,onClick:()=>void c(e.name),children:[(0,S.jsx)(C,{name:`edit`,className:`ms-sm`}),` edit`]}),(0,S.jsx)(`button`,{className:`open-raw`,onClick:()=>void u(e.name),children:(0,S.jsx)(C,{name:`close`,className:`ms-sm`})})]},e.name))}),n&&(0,S.jsxs)(`div`,{className:`agent-form`,children:[(0,S.jsx)(`div`,{className:`agent-form-row`,children:(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`name — invoked as /<name>`,(0,S.jsx)(`input`,{value:n.name,placeholder:`e.g. report-html`,disabled:!n.isNew,onChange:e=>r({...n,name:e.target.value})})]})}),(0,S.jsxs)(`label`,{className:`agent-field`,children:[`SKILL.md — frontmatter (description) + the instructions`,(0,S.jsx)(`textarea`,{className:`concept-edit`,rows:Math.min(28,Math.max(12,n.content.split(`
213
- `).length+2)),value:n.content,spellCheck:!1,onChange:e=>r({...n,content:e.target.value})})]}),(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsx)(`button`,{className:`run-btn`,disabled:i||!n.name.trim(),onClick:()=>void l(),children:i?`saving…`:`save`}),(0,S.jsx)(`button`,{className:`open-raw`,disabled:i,onClick:()=>r(null),children:`cancel`})]})]}),o&&(0,S.jsxs)(`div`,{className:`msg error`,children:[(0,S.jsx)(C,{name:`error`,className:`ms-sm`}),` `,o]})]})}function Fa({slug:e}){let t=H(`/api/agents/${encodeURIComponent(e)}/routines`,!1)?.routines??[],[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(``);async function c(t){a(``);let n=await(await fetch(`/api/agents/${encodeURIComponent(e)}/routines`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)})).json();return!n.error||(a(n.error),!1)}async function l(t){s(t),a(``);let n=await(await fetch(`/api/agents/${encodeURIComponent(e)}/routines/${encodeURIComponent(t)}/run`,{method:`POST`})).json();s(``),n.error?a(n.error):n.chatId&&N(`/agents/${encodeURIComponent(e)}/chat/${n.chatId}`)}async function u(t){window.confirm(`Delete routine "${t}"?`)&&await fetch(`/api/agents/${encodeURIComponent(e)}/routines/${encodeURIComponent(t)}`,{method:`DELETE`}).catch(()=>{})}return(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`routines — scheduled prompts`}),(0,S.jsx)(`span`,{className:`spacer`}),!n&&(0,S.jsxs)(`button`,{className:`open-raw`,onClick:()=>r({name:``,schedule:`0 9 * * 1-5`,prompt:``,enabled:!0}),children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` new routine`]})]}),t.length===0&&!n&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`none — a routine messages this agent on a schedule (cron, server local time) and each run opens a new session with the result.`}),t.length>0&&(0,S.jsx)(`div`,{className:`m3-list`,children:t.map(t=>(0,S.jsxs)(`div`,{className:`m3-row`,children:[(0,S.jsx)(`span`,{className:`m3-ico`,children:(0,S.jsx)(C,{name:`schedule`})}),(0,S.jsxs)(`span`,{className:`m3-body`,children:[(0,S.jsxs)(`span`,{className:`m3-head`,children:[t.name,t.lastError&&(0,S.jsx)(`span`,{className:`chip stale`,title:t.lastError,children:`error`}),t.awaitingApproval&&t.lastChatId&&(0,S.jsx)(F,{href:`/agents/${encodeURIComponent(e)}/chat/${t.lastChatId}`,className:`chip attention`,title:`the last run asked for a permission nobody has answered yet`,children:`needs approval`})]}),(0,S.jsxs)(`span`,{className:`m3-sub`,children:[(0,S.jsx)(`code`,{children:t.schedule}),t.enabled?t.nextRunAt?` · next ${Ee(t.nextRunAt)}`:``:` · paused`,` · `,t.lastChatId?(0,S.jsxs)(F,{href:`/agents/${encodeURIComponent(e)}/chat/${t.lastChatId}`,children:[`last run `,Ee(t.lastRunAt)]}):`never ran`]})]}),(0,S.jsx)(`button`,{className:`open-raw`,disabled:o===t.id,onClick:()=>l(t.id),children:o===t.id?`starting…`:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(C,{name:`play_arrow`,className:`ms-sm`}),` run`]})}),(0,S.jsx)(`button`,{className:`open-raw`,onClick:()=>r({id:t.id,name:t.name,schedule:t.schedule,prompt:t.prompt,enabled:t.enabled}),children:`edit`}),(0,S.jsx)(`button`,{className:`open-raw`,onClick:()=>void u(t.id),children:`delete`}),(0,S.jsxs)(`label`,{className:`m3-switch`,title:t.enabled?`enabled — click to pause`:`paused — click to enable`,children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:t.enabled,onChange:()=>void c({id:t.id,name:t.name,schedule:t.schedule,prompt:t.prompt,enabled:!t.enabled})}),(0,S.jsx)(`span`,{className:`m3-switch-track`})]})]},t.id))}),n&&(0,S.jsxs)(`div`,{className:`agent-form`,children:[(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`name`,(0,S.jsx)(`input`,{value:n.name,placeholder:`e.g. Morning report`,onChange:e=>r({...n,name:e.target.value})})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{width:200},children:[`schedule (cron)`,(0,S.jsx)(`input`,{value:n.schedule,placeholder:`0 9 * * 1-5`,onChange:e=>r({...n,schedule:e.target.value})})]}),(0,S.jsxs)(`label`,{className:`agent-field wf-checks`,style:{width:90},children:[`enabled`,(0,S.jsxs)(`label`,{children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:n.enabled,onChange:e=>r({...n,enabled:e.target.checked})}),`on`]})]})]}),(0,S.jsxs)(`label`,{className:`agent-field`,children:[`prompt — what to ask this agent on each run`,(0,S.jsx)(`textarea`,{rows:5,value:n.prompt,placeholder:`Check ... and summarize what changed.`,onChange:e=>r({...n,prompt:e.target.value})})]}),(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsx)(`button`,{className:`run-btn`,disabled:!n.name.trim()||!n.prompt.trim(),onClick:async()=>{await c(n)&&r(null)},children:n.id?`save routine`:`create routine`}),(0,S.jsx)(`button`,{className:`open-raw`,onClick:()=>(r(null),a(``)),children:`cancel`})]})]}),i&&(0,S.jsxs)(`div`,{className:`msg error`,children:[(0,S.jsx)(C,{name:`error`,className:`ms-sm`}),` `,i]})]})}function Ia({slug:e}){let[t,n]=(0,v.useState)(e?null:f()),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(!1),s=H(`/api/workflows`,!1)?.workflows??[],c=H(`/api/knowledge`,!1)?.bundles??[],l=ce(),u=H(l.vibeables?`/api/vibeables`:``,!1)?.vibeables??[],d=H(`/api/skills`,!1)?.skills??[];(0,v.useEffect)(()=>{e&&fetch(`/api/agents/${encodeURIComponent(e)}`).then(e=>e.ok?e.json():Promise.reject()).then(e=>n({name:e.name,emoji:e.emoji,description:e.description??``,harness:e.harness,model:e.model??``,effort:e.effort??``,group:e.group??``,system:e.system,workflows:e.workflows,knowledge:e.knowledge??[],vibeables:e.vibeables??[],skillsAll:e.skills===void 0,skills:e.skills??[]})).catch(()=>i(`agent not found`))},[e]);function f(){return{name:``,emoji:`🤖`,description:``,harness:`claude`,model:``,effort:``,group:``,system:``,workflows:[],knowledge:[],vibeables:[],skillsAll:!0,skills:[]}}async function p(){if(!t)return;o(!0),i(``);let n=await(await fetch(e?`/api/agents/${encodeURIComponent(e)}`:`/api/agents`,{method:e?`PUT`:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({...t,skills:t.skillsAll?void 0:t.skills})})).json();o(!1),n.error?i(n.error):N(`/agents/${encodeURIComponent(n.slug)}/info`)}async function m(){e&&window.confirm(`Delete agent "${e}" and its definition folder?`)&&(await fetch(`/api/agents/${encodeURIComponent(e)}`,{method:`DELETE`}).catch(()=>{}),N(`/agents`))}if(!t)return(0,S.jsx)(`div`,{className:`empty`,children:r||`loading…`});let h=e=>n({...t,...e});return(0,S.jsxs)(`div`,{className:`new-chat`,children:[(0,S.jsx)(`div`,{className:`page-head`,children:(0,S.jsx)(`h1`,{children:e?`edit ${e}`:`new agent`})}),(0,S.jsx)(`section`,{className:`panel new-chat-panel`,children:(0,S.jsxs)(`div`,{className:`agent-form`,children:[(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`name`,(0,S.jsx)(`input`,{value:t.name,placeholder:`e.g. Max`,onChange:e=>h({name:e.target.value})})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{width:90},children:[`emoji`,(0,S.jsx)(`input`,{value:t.emoji,onChange:e=>h({emoji:e.target.value})})]})]}),(0,S.jsx)(`div`,{className:`emoji-pick`,children:ya.map(e=>(0,S.jsx)(`button`,{type:`button`,className:t.emoji===e?`active`:``,onClick:()=>h({emoji:e}),children:e},e))}),(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`description`,(0,S.jsx)(`input`,{value:t.description,placeholder:`one line: what this agent is for`,onChange:e=>h({description:e.target.value})})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{width:180},children:[`group`,(0,S.jsx)(`input`,{value:t.group,placeholder:`none`,onChange:e=>h({group:e.target.value})})]})]}),(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsxs)(`label`,{className:`agent-field`,style:{width:140},children:[`harness`,(0,S.jsxs)(`select`,{value:t.harness,onChange:e=>h({harness:e.target.value}),children:[(0,S.jsx)(`option`,{value:`claude`,children:`claude`}),(0,S.jsx)(`option`,{value:`codex`,children:`codex`}),(0,S.jsx)(`option`,{value:`pi`,children:`pi`})]})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`model`,(0,S.jsx)(`input`,{value:t.model,placeholder:`harness default — e.g. sonnet, gpt-5.6-sol`,onChange:e=>h({model:e.target.value})})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{width:140},children:[`effort`,(0,S.jsx)(`select`,{value:t.effort,onChange:e=>h({effort:e.target.value}),children:va.map(e=>(0,S.jsx)(`option`,{value:e,children:e||`default`},e))})]})]}),(0,S.jsxs)(`label`,{className:`agent-field`,children:[`system prompt — the agent's role`,(0,S.jsx)(`textarea`,{rows:10,value:t.system,placeholder:`You are the ... for this project. Your job is ...`,onChange:e=>h({system:e.target.value})})]}),(0,S.jsxs)(`div`,{className:`agent-field`,children:[(0,S.jsx)(`span`,{className:`agent-field-label`,children:`connected workflows — autoloaded into the agent's context; it can run them`}),(0,S.jsxs)(`div`,{className:`wf-checks`,children:[s.map(e=>(0,S.jsxs)(`label`,{children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:t.workflows.includes(e.slug),onChange:n=>h({workflows:n.target.checked?[...t.workflows,e.slug]:t.workflows.filter(t=>t!==e.slug)})}),(0,S.jsx)(`b`,{children:e.slug}),e.description&&(0,S.jsxs)(`span`,{className:`opt-hint`,children:[` — `,e.description]})]},e.slug)),s.length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no workflows in this project`})]})]}),(0,S.jsxs)(`div`,{className:`agent-field`,children:[(0,S.jsx)(`span`,{className:`agent-field-label`,children:`connected knowledge — OKF bundles the agent consults and maintains`}),(0,S.jsxs)(`div`,{className:`wf-checks`,children:[c.map(e=>(0,S.jsxs)(`label`,{children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:t.knowledge.includes(e.name),onChange:n=>h({knowledge:n.target.checked?[...t.knowledge,e.name]:t.knowledge.filter(t=>t!==e.name)})}),(0,S.jsx)(`b`,{children:e.name}),(0,S.jsxs)(`span`,{className:`opt-hint`,children:[` — `,e.concepts,` concepts`]})]},e.name)),c.length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no knowledge bundles in this project`})]})]}),(l.vibeables||t.vibeables.length>0)&&(0,S.jsxs)(`div`,{className:`agent-field`,"data-link-kind":`vibeables`,children:[(0,S.jsx)(`span`,{className:`agent-field-label`,children:`connected vibeables — small apps the agent builds and maintains`}),(0,S.jsxs)(`div`,{className:`wf-checks`,children:[u.map(e=>(0,S.jsxs)(`label`,{children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:t.vibeables.includes(e.slug),onChange:n=>h({vibeables:n.target.checked?[...t.vibeables,e.slug]:t.vibeables.filter(t=>t!==e.slug)})}),(0,S.jsx)(`b`,{children:e.slug}),(0,S.jsxs)(`span`,{className:`opt-hint`,children:[` — `,e.dev?`dev`:`static`]})]},e.slug)),t.vibeables.filter(e=>!u.some(t=>t.slug===e)).map(e=>(0,S.jsxs)(`label`,{children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:!0,onChange:()=>h({vibeables:t.vibeables.filter(t=>t!==e)})}),(0,S.jsx)(`b`,{children:e}),(0,S.jsx)(`span`,{className:`opt-hint`,children:` — not found in this workspace`})]},e)),!l.vibeables&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`vibeables are off in this workspace's settings`}),l.vibeables&&u.length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no vibeables in this workspace yet`})]})]}),(0,S.jsxs)(`div`,{className:`agent-field`,children:[(0,S.jsx)(`span`,{className:`agent-field-label`,children:`connected skills — workspace skill packages (see the skills tab); invoked with /name in sessions`}),(0,S.jsxs)(`div`,{className:`wf-checks`,children:[(0,S.jsxs)(`label`,{children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:t.skillsAll,onChange:e=>h({skillsAll:e.target.checked})}),(0,S.jsx)(`b`,{children:`all skills`}),(0,S.jsx)(`span`,{className:`opt-hint`,children:` — every discovered skill, including future ones`})]}),!t.skillsAll&&d.map(e=>(0,S.jsxs)(`label`,{children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:t.skills.includes(e.name),onChange:n=>h({skills:n.target.checked?[...t.skills,e.name]:t.skills.filter(t=>t!==e.name)})}),(0,S.jsxs)(`b`,{children:[`/`,e.name]}),e.description&&(0,S.jsxs)(`span`,{className:`opt-hint`,children:[` — `,e.description]})]},e.name)),!t.skillsAll&&d.length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no skills found (.claude/skills, project or user)`})]})]}),r&&(0,S.jsxs)(`div`,{className:`msg error`,children:[(0,S.jsx)(C,{name:`error`,className:`ms-sm`}),` `,r]}),(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsx)(`button`,{className:`run-btn`,disabled:!t.name.trim()||a,onClick:p,children:a?`saving…`:e?`save`:`create`}),(0,S.jsx)(`span`,{className:`spacer`}),e&&(0,S.jsx)(`button`,{className:`stop-btn`,onClick:m,children:`delete agent`})]})]})})]})}function La(e){if(!ne(e))return null;let t=e.split(`/`).filter(Boolean),n=decodeURIComponent(t[1]),r=t[0]===`agents`||t[0]===`team`;return n===`new`?t[0]===`projects`?(0,S.jsx)(ea,{},`new-project`):r?(0,S.jsx)(Ia,{},`new-agent`):(0,S.jsx)(ai,{},`new-channel`):t[0]===`projects`&&t[2]===`info`?(0,S.jsx)(sa,{slug:n,onChanged:async()=>{}},n):r&&t[2]===`info`?(0,S.jsx)(Ma,{slug:n},n):r&&t[2]===`edit`?(0,S.jsx)(Ia,{slug:n},n):t[0]===`channels`&&t[2]===`edit`?(0,S.jsx)(ai,{slug:n},n):null}function Ra({back:e,children:t}){let n=()=>N(e);return(0,v.useEffect)(()=>{let e=e=>{e.key!==`Escape`||e.defaultPrevented||document.querySelector(`.palette-backdrop`)||(e.preventDefault(),n())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}),(0,S.jsx)(`div`,{className:`modal-backdrop`,onMouseDown:n,children:(0,S.jsxs)(`div`,{className:`modal edit-modal`,role:`dialog`,"aria-label":`edit`,onMouseDown:e=>e.stopPropagation(),children:[(0,S.jsx)(`button`,{type:`button`,className:`modal-x`,onClick:n,title:`close (esc)`,"aria-label":`close`,children:(0,S.jsx)(C,{name:`close`})}),(0,S.jsx)(`div`,{className:`runs-main modal-body`,children:t})]})})}function za({runId:e,decision:t}){let{request:n,answer:r}=t,[i,a]=(0,v.useState)(n.options.length===1?n.options[0].value:null),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),f=e=>n.options.find(t=>t.value===e)?.label??e;if(r)return(0,S.jsx)(`section`,{className:`panel decision-panel is-decided`,"aria-label":`decision`,children:(0,S.jsxs)(`div`,{className:`decision-body`,children:[(0,S.jsx)(`div`,{className:`decision-title`,children:n.title??`Decision`}),(0,S.jsxs)(`div`,{className:`decision-answer`,children:[(0,S.jsx)(`span`,{className:`chip status ok`,children:f(r.decision)}),r.note&&(0,S.jsxs)(`span`,{className:`decision-note`,children:[`“`,r.note,`”`]}),r.decidedAt&&(0,S.jsx)(`span`,{className:`decision-when num`,children:Ee(r.decidedAt)})]})]})});let p=!!i&&!c&&(n.note!==`required`||!!o.trim());async function m(){if(!p)return;l(!0),d(null);let t=await fetch(`/api/runs/${encodeURIComponent(e)}/decision`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({decision:i,note:o.trim()})}).catch(()=>null);t?.ok||(d((await t?.json().catch(()=>null))?.error??`could not save the decision`),l(!1))}return(0,S.jsx)(`section`,{className:`panel decision-panel`,"aria-label":`decision needed`,children:(0,S.jsxs)(`div`,{className:`decision-body`,children:[(0,S.jsxs)(`div`,{className:`decision-head`,children:[(0,S.jsx)(`span`,{className:`lamp running`}),(0,S.jsx)(`div`,{className:`decision-title`,children:n.title??`This run needs your decision`})]}),n.prompt&&(0,S.jsx)(`p`,{className:`decision-prompt`,children:n.prompt}),(0,S.jsx)(`div`,{className:`tabs decision-options`,role:`radiogroup`,"aria-label":`options`,children:n.options.map(e=>(0,S.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":i===e.value,className:i===e.value?`active`:``,onClick:()=>a(e.value),children:e.label??e.value},e.value))}),n.note!==!1&&(0,S.jsxs)(`label`,{className:`m3-field`,children:[(0,S.jsx)(`input`,{type:`text`,value:o,placeholder:` `,"aria-label":`note`,onChange:e=>s(e.target.value),onKeyDown:e=>e.key===`Enter`&&m()}),(0,S.jsx)(`span`,{className:`m3-field-label`,children:n.note===`required`?`Note (required)`:`Note`})]}),u&&(0,S.jsx)(`div`,{className:`m3-error`,children:u}),(0,S.jsx)(`div`,{className:`m3-actions`,children:(0,S.jsx)(`button`,{className:`m3-filled-btn`,onClick:m,disabled:!p,children:c?`Saving…`:`Submit decision`})})]})})}function Ba({id:e,workflow:t}){let n=H(`/api/runs`,!0),r=n?.runs??[],[i,a]=(0,v.useState)(t??``),o=(0,v.useMemo)(()=>{let e=i.trim().toLowerCase();return e?r.filter(t=>[t.workflow,t.request,t.id].some(t=>t?.toLowerCase().includes(e))):r},[r,i]);return(0,S.jsxs)(`div`,{className:`runs-screen`,children:[(0,S.jsxs)(`aside`,{className:`runs-side`,children:[(0,S.jsxs)(`div`,{className:`side-head`,children:[(0,S.jsx)(F,{href:`/workflows`,className:`side-back`,title:`back to workflows`,children:(0,S.jsx)(C,{name:`arrow_back`,className:`ms-sm`})}),(0,S.jsx)(`span`,{className:`microlabel`,children:`runs`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(`span`,{className:`microlabel num`,children:i?`${o.length} / ${r.length}`:r.length})]}),(0,S.jsxs)(`label`,{className:`side-filter`,children:[(0,S.jsx)(C,{name:`filter_list`,className:`ms-sm`}),(0,S.jsx)(`input`,{type:`search`,value:i,placeholder:`filter by workflow or request`,"aria-label":`filter runs`,onChange:e=>a(e.target.value)})]}),(0,S.jsxs)(`div`,{className:`side-list`,children:[o.map(t=>(0,S.jsx)(Va,{r:t,active:t.id===e},t.id)),n&&r.length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no runs yet`}),r.length>0&&o.length===0&&(0,S.jsxs)(`div`,{className:`viewer-note`,children:[`no run matches “`,i,`”`]})]})]}),(0,S.jsx)(`div`,{className:`runs-main`,children:(0,S.jsx)(Ha,{id:e},e)})]})}function Va({r:e,active:t}){return(0,S.jsxs)(F,{href:`/runs/${e.id}`,className:`side-row ${t?`active`:``}`,children:[(0,S.jsx)(ke,{status:e.status}),(0,S.jsxs)(`div`,{className:`side-row-body`,children:[(0,S.jsxs)(`div`,{className:`side-row-top`,children:[(0,S.jsx)(`span`,{className:`side-wf`,children:e.workflow??`unknown`}),(0,S.jsx)(`span`,{className:`side-when num`,children:Ee(e.startedAt)})]}),(0,S.jsxs)(`div`,{className:`side-row-sub`,children:[(0,S.jsx)(`span`,{className:`side-req`,title:e.request,children:e.status===`running`&&e.currentPhase?`${e.currentPhase}`:e.request??``}),(0,S.jsx)(`span`,{className:`side-meta num`,children:e.status===`running`?(0,S.jsx)(Oe,{since:e.startedAt}):Se(e.durationMs)})]})]})]})}function Ha({id:e}){let t=H(`/api/runs/${e}`,!0),n=t?.status===`running`,[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(null),l=z();if(!t)return(0,S.jsx)(`div`,{className:`empty`,children:`loading…`});let u=t.files.some(e=>e.name===`runner.json`),d=r??(n?`run`:`artifacts`),f=l?t.files.length:t.files.filter(e=>!Ja(e.name)).length;async function p(){o(!0),c(null);let t=await fetch(`/api/runs/${e}/stop`,{method:`POST`}).catch(()=>null);t?.ok||(o(!1),c((await t?.json().catch(()=>null))?.error??`stop failed`))}async function m(){if(!window.confirm(`Remove run ${e} and all its files?`))return;c(null);let n=await fetch(`/api/runs/${e}`,{method:`DELETE`}).catch(()=>null);if(n?.ok){N(t?.workflow?`/workflows/${encodeURIComponent(t.workflow)}`:`/workflows`);return}c((await n?.json().catch(()=>null))?.error??`remove failed`)}return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`detail-head`,children:[(0,S.jsx)(ke,{status:t.status}),(0,S.jsx)(`h1`,{children:t.workflow?(0,S.jsx)(F,{href:`/workflows/${encodeURIComponent(t.workflow)}`,title:`open workflow`,children:t.workflow}):`unknown workflow`}),(0,S.jsx)(Ae,{status:t.status}),u&&(0,S.jsxs)(`span`,{className:`chip sandbox-chip`,children:[(0,S.jsx)(C,{name:`science`,className:`ms-sm`}),` sandbox`]}),(0,S.jsx)(`span`,{className:`rid`,children:e.replace(/^run-/,``)}),n?(0,S.jsx)(`button`,{className:`stop-btn`,onClick:p,disabled:a,children:a?`stopping…`:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(C,{name:`stop`,className:`ms-sm`}),` stop`]})}):(0,S.jsxs)(`button`,{className:`stop-btn`,onClick:m,title:`delete this run's folder`,children:[(0,S.jsx)(C,{name:`delete`,className:`ms-sm`}),` remove`]}),s&&(0,S.jsx)(`span`,{className:`run-action-error`,children:s}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(`button`,{className:`open-raw`,title:`chat with an agent about this run`,onClick:()=>void mi(`claude`,{kind:`run`,runId:e}),children:`⌬ discuss`}),(0,S.jsxs)(`nav`,{className:`tabs`,children:[(0,S.jsx)(`button`,{className:d===`run`?`active`:``,onClick:()=>i(`run`),children:`run`}),(0,S.jsxs)(`button`,{className:d===`artifacts`?`active`:``,onClick:()=>i(`artifacts`),children:[`artifacts `,(0,S.jsxs)(`span`,{className:`num`,children:[`(`,f,`)`]})]})]})]}),t.request&&(0,S.jsx)(`p`,{className:`detail-req`,children:t.request}),d===`run`?(0,S.jsx)(Ua,{run:t,live:n}):(0,S.jsx)(Xa,{id:e,files:t.files,live:n})]})}function Ua({run:e,live:t}){return(0,S.jsxs)(`div`,{className:`run-tab`,children:[e.decision&&(0,S.jsx)(za,{runId:e.id,decision:e.decision}),(0,S.jsxs)(`div`,{className:`statgrid`,children:[(0,S.jsxs)(`div`,{className:`stat`,children:[(0,S.jsx)(`div`,{className:`microlabel`,children:`phases`}),(0,S.jsxs)(`div`,{className:`v num`,children:[e.phasesDone,e.phasesTotal==null?``:` / ${e.phasesTotal}`]})]}),(0,S.jsxs)(`div`,{className:`stat`,children:[(0,S.jsx)(`div`,{className:`microlabel`,children:`duration`}),(0,S.jsx)(`div`,{className:`v num`,children:t?(0,S.jsx)(Oe,{since:e.startedAt}):Se(e.durationMs)})]}),(0,S.jsxs)(`div`,{className:`stat`,children:[(0,S.jsx)(`div`,{className:`microlabel`,children:`cost`}),(0,S.jsx)(`div`,{className:`v num`,children:Ce(e.costUsd??Ga(e.phases))})]}),(0,S.jsxs)(`div`,{className:`stat`,children:[(0,S.jsx)(`div`,{className:`microlabel`,children:`tokens in / out`}),(0,S.jsxs)(`div`,{className:`v num`,children:[we(Wa(e.phases,`tokensIn`)),` / `,we(Wa(e.phases,`tokensOut`))]})]})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`phase timeline`}),(0,S.jsx)(`span`,{className:`spacer`}),t&&(0,S.jsxs)(`span`,{className:`live-note`,children:[(0,S.jsx)(`span`,{className:`lamp running`}),` live · polling`]})]}),(0,S.jsx)(`div`,{className:`phases`,children:e.phases.map(e=>(0,S.jsx)(Ka,{p:e},e.phase))})]})]})}function Wa(e,t){return e.reduce((e,n)=>e+(n[t]??0),0)}function Ga(e){return e.reduce((e,t)=>e+(t.costUsd??0),0)}function Ka({p:e}){let t=e.gates.filter(e=>!e.passed);return(0,S.jsxs)(`div`,{className:`phase-row`,children:[(0,S.jsx)(ke,{status:e.status}),(0,S.jsxs)(`div`,{className:`phase-top`,children:[(0,S.jsx)(`span`,{className:`phase-name`,children:e.phase}),e.kind===`agent`?(0,S.jsxs)(`span`,{className:`chip agent`,children:[e.agent,e.model?` · ${e.model}`:``,e.protocol?` · ${e.protocol}`:``]}):(0,S.jsx)(`span`,{className:`chip`,children:`script`}),e.status===`skipped`&&(0,S.jsx)(`span`,{className:`chip status skipped`,children:`skipped`}),(0,S.jsxs)(`span`,{className:`right num`,children:[e.attempts>1&&(0,S.jsxs)(`span`,{children:[`att `,e.attempts]}),e.status===`running`?(0,S.jsx)(Oe,{since:e.startedAt}):e.durationMs!=null&&(0,S.jsx)(`span`,{children:Se(e.durationMs)}),e.kind===`agent`&&e.tokensIn!=null&&(0,S.jsxs)(`span`,{children:[we(e.tokensIn),` / `,we(e.tokensOut)]}),e.costUsd!=null&&e.costUsd>0&&(0,S.jsx)(`span`,{children:Ce(e.costUsd)})]})]}),e.status===`running`&&e.lastActivity&&(0,S.jsx)(`div`,{className:`phase-activity`,children:e.lastActivity}),e.summary&&e.status!==`running`&&(0,S.jsx)(`div`,{className:`phase-sub`,children:e.summary}),e.gates.length>0&&(0,S.jsx)(`div`,{className:`gate-line`,children:e.gates.map(e=>(0,S.jsxs)(`span`,{className:`gate ${e.passed?``:`failed`}`,title:e.failure??``,children:[(0,S.jsx)(C,{name:e.passed?`check`:`close`,className:`ms-sm`}),` `,e.gate]},e.gate))}),t.map(e=>(0,S.jsx)(`div`,{className:`gate-fail-msg`,children:e.failure},e.gate))]})}var qa=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`]);function Ja(e){return e===`runner.json`||e.endsWith(`.jsonl`)||e.endsWith(`.log`)}function Ya(e){let t=[`report.html`,`recommendation.md`].find(t=>e.some(e=>e.name===t));if(t)return t;let n=e=>{let t=e.split(`.`).pop()?.toLowerCase()??``;return[`html`,`md`,`markdown`,`pdf`].includes(t)||qa.has(t)?0:Ja(e)?2:1},r=null;for(let t of e)(!r||n(t.name)<n(r.name))&&(r=t);return r?.name??null}function Xa({id:e,files:t,live:n}){let[r,i]=(0,v.useState)(null),a=z(),o=(0,v.useMemo)(()=>a?t:t.filter(e=>!Ja(e.name)),[t,a]);return(0,v.useEffect)(()=>{!a&&r&&Ja(r)&&i(null)},[a,r]),(0,v.useEffect)(()=>{r||o.length===0||i(Ya(o))},[o,r]),(0,S.jsxs)(`div`,{className:`art-layout`,children:[(0,S.jsxs)(`section`,{className:`panel art-files`,children:[(0,S.jsx)(`div`,{className:`panel-head`,children:(0,S.jsxs)(`span`,{className:`microlabel`,children:[`files `,(0,S.jsxs)(`span`,{className:`num`,children:[`(`,o.length,`)`]})]})}),(0,S.jsxs)(`div`,{className:`file-list`,children:[o.map(e=>(0,S.jsxs)(`button`,{className:`file-row ${r===e.name?`active`:``}`,onClick:()=>i(e.name),children:[(0,S.jsx)(`span`,{className:`fname`,children:e.name}),(0,S.jsx)(`span`,{className:`fsize num`,children:Te(e.size)})]},e.name)),o.length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:t.length>0?`no result files — raw run files live in expert mode`:`no files yet`})]})]}),(0,S.jsxs)(`section`,{className:`panel art-viewer`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:r??`viewer`}),(0,S.jsx)(`span`,{className:`spacer`}),r&&(0,S.jsx)(`a`,{className:`open-raw`,href:`/api/runs/${e}/file?name=${encodeURIComponent(r)}&raw=1`,target:`_blank`,children:`open raw ↗`})]}),r?(0,S.jsx)(Za,{id:e,name:r,live:n}):(0,S.jsx)(`div`,{className:`empty`,children:`select a file`})]})]})}function Za({id:e,name:t,live:n}){let r=t.split(`.`).pop()?.toLowerCase()??``,i=`/api/runs/${e}/file?name=${encodeURIComponent(t)}&raw=1`;return r===`html`?(0,S.jsx)(`div`,{className:`viewer`,children:(0,S.jsx)(`div`,{className:`viewer-body`,children:(0,S.jsx)(`iframe`,{src:i,sandbox:`allow-scripts`,allow:`clipboard-write`,title:t})})}):r===`pdf`?(0,S.jsx)(`div`,{className:`viewer`,children:(0,S.jsx)(`div`,{className:`viewer-body`,children:(0,S.jsx)(`iframe`,{src:i,title:t})})}):qa.has(r)?(0,S.jsx)(`div`,{className:`viewer`,children:(0,S.jsx)(`div`,{className:`viewer-body`,children:(0,S.jsx)(`img`,{src:i,alt:t})})}):r===`md`||r===`markdown`?(0,S.jsx)(Qa,{id:e,name:t,live:n}):(0,S.jsx)($a,{id:e,name:t,live:n})}function Qa({id:e,name:t,live:n}){let[r,i]=(0,v.useState)(`rendered`),a=H(`/api/runs/${e}/file?name=${encodeURIComponent(t)}`,n),o=(0,v.useMemo)(()=>a?Br.sanitize(W.parse(a.content,{async:!1})):``,[a?.content]);return(0,S.jsxs)(`div`,{className:`viewer`,children:[(0,S.jsxs)(`div`,{className:`viewer-note md-toolbar`,children:[(0,S.jsxs)(`div`,{className:`tabs`,children:[(0,S.jsx)(`button`,{className:r===`rendered`?`active`:``,onClick:()=>i(`rendered`),children:`rendered`}),(0,S.jsx)(`button`,{className:r===`source`?`active`:``,onClick:()=>i(`source`),children:`source`})]}),a?.truncated&&(0,S.jsxs)(`span`,{children:[`large file — showing the last `,Te(4e5)]})]}),(0,S.jsx)(`div`,{className:`viewer-body`,children:a?r===`rendered`?(0,S.jsx)(`div`,{className:`md-body`,dangerouslySetInnerHTML:{__html:o}}):(0,S.jsx)(`pre`,{children:a.content||`(empty)`}):(0,S.jsx)(`pre`,{children:`loading…`})})]})}function $a({id:e,name:t,live:n}){let r=H(`/api/runs/${e}/file?name=${encodeURIComponent(t)}`,n);return(0,S.jsxs)(`div`,{className:`viewer`,children:[r?.truncated&&(0,S.jsxs)(`div`,{className:`viewer-note`,children:[`large file — showing the last `,Te(4e5)]}),(0,S.jsx)(`div`,{className:`viewer-body`,children:(0,S.jsx)(`pre`,{children:r?r.content||`(empty)`:`loading…`})})]})}function eo(){return H(`/api/workflows/any/run`,!1,15e3)}var to=e=>!!e?.available&&!!e?.image;function no(e){return e?e.available?e.image?`isolated container per run`:"image missing — run `kraftwerk runner build`":`Docker is not running`:``}async function ro(e,t){let n=await fetch(`/api/workflows/${encodeURIComponent(e)}/run`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),r=await n.json();if(!n.ok)throw Error(r.error??`HTTP ${n.status}`);return r.runId}function io(e,t,n,r){let[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(!0),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),m=eo();(0,v.useEffect)(()=>{!i&&n&&a(n)},[n]),(0,v.useEffect)(()=>{m&&!to(m)&&s(!1)},[m]);let h=!u&&(!t||!!i.trim())&&(!o||to(m));async function g(){if(h){d(!0),p(null);try{let t=await ro(e,{request:i.trim(),sandbox:o,ssh:c});r?(r(t),d(!1)):N(`/runs/${t}`)}catch(e){p(e.message),d(!1)}}}return{request:i,setRequest:a,sandbox:o,setSandbox:s,ssh:c,setSsh:l,busy:u,error:f,docker:m,canRun:h,launch:g}}function ao({slug:e,usesRequest:t,initialRequest:n,onLaunched:r}){let i=io(e,t,n,r);return(0,S.jsxs)(`div`,{className:`run-launcher`,children:[(0,S.jsxs)(`div`,{className:`run-launcher-main`,children:[t?(0,S.jsxs)(`label`,{className:`m3-field`,children:[(0,S.jsx)(`input`,{type:`text`,value:i.request,placeholder:` `,"aria-label":`request`,onChange:e=>i.setRequest(e.target.value),onKeyDown:e=>e.key===`Enter`&&i.launch()}),(0,S.jsx)(`span`,{className:`m3-field-label`,children:`Request`})]}):(0,S.jsx)(`span`,{className:`run-norequest`,children:`This workflow takes no request.`}),(0,S.jsxs)(`button`,{className:`m3-filled-btn run-go`,onClick:i.launch,disabled:!i.canRun,children:[(0,S.jsx)(C,{name:`play_arrow`}),` `,i.busy?`Starting…`:`Run`]})]}),(0,S.jsxs)(`div`,{className:`m3-switches run-switches`,children:[(0,S.jsx)(q,{label:`Docker sandbox`,hint:no(i.docker),checked:i.sandbox,onChange:i.setSandbox}),i.sandbox&&(0,S.jsx)(q,{label:`Forward SSH agent`,hint:`keys and known hosts from this machine`,checked:i.ssh,onChange:i.setSsh})]}),i.error&&(0,S.jsx)(`div`,{className:`m3-error`,children:i.error})]})}function q({label:e,hint:t,checked:n,onChange:r}){return(0,S.jsxs)(`button`,{type:`button`,className:`m3-switch-row`,role:`switch`,"aria-checked":n,onClick:()=>r(!n),children:[(0,S.jsxs)(`span`,{className:`m3-switch-text`,children:[(0,S.jsx)(`span`,{className:`m3-switch-label`,children:e}),t&&(0,S.jsx)(`span`,{className:`m3-switch-hint`,children:t})]}),(0,S.jsx)(`span`,{className:`m3-switch ${n?`on`:``}`,"aria-hidden":!0,children:(0,S.jsx)(`span`,{className:`m3-switch-knob`})})]})}var J=`\0done`,oo=5;function so(e,t){return e.status===`ok`?J:e.currentPhase&&t.includes(e.currentPhase)?e.currentPhase:t[0]??J}function co({wf:e,runs:t,agentIdx:n,runsHref:r}){let i=e.steps.map(e=>e.name),a=new Map([...i,J].map(e=>[e,[]]));for(let e of t)a.get(so(e,i)).push(e);let o=a.get(J)??[];return(0,S.jsxs)(`div`,{className:`board`,children:[e.steps.map((e,t)=>{let i=e.agent?n.get(e.agent)??0:null,o=a.get(e.name)??[];return(0,S.jsxs)(`div`,{className:`board-col`,"data-step":e.name,children:[(0,S.jsxs)(`div`,{className:`board-col-head`,children:[(0,S.jsx)(`span`,{className:`step-index num ${i==null?`is-script`:`aid-${i}`}`,children:t+1}),(0,S.jsx)(`span`,{className:`board-col-name`,title:e.name,children:e.name}),(0,S.jsx)(`span`,{className:`board-col-count num`,children:o.length})]}),(0,S.jsx)(lo,{cards:o,moreHref:r})]},e.name)}),(0,S.jsxs)(`div`,{className:`board-col is-done`,"data-step":`done`,children:[(0,S.jsxs)(`div`,{className:`board-col-head`,children:[(0,S.jsx)(`span`,{className:`step-index`,children:`✓`}),(0,S.jsx)(`span`,{className:`board-col-name`,children:`done`}),(0,S.jsx)(`span`,{className:`board-col-count num`,children:o.length})]}),(0,S.jsx)(lo,{cards:o,moreHref:r})]})]})}function lo({cards:e,moreHref:t}){return(0,S.jsxs)(`div`,{className:`board-col-cards`,children:[e.slice(0,oo).map(e=>(0,S.jsx)(uo,{r:e},e.id)),e.length===0&&(0,S.jsx)(`div`,{className:`board-col-empty`,children:`—`}),e.length>oo&&(0,S.jsxs)(F,{href:t,className:`board-more`,children:[`+ `,e.length-oo,` more ↗`]})]})}function uo({r:e}){let t=e.request??e.id.replace(/^run-/,``);return(0,S.jsxs)(F,{href:`/runs/${e.id}`,className:`board-card is-${e.status}`,children:[(0,S.jsxs)(`div`,{className:`board-card-top`,children:[(0,S.jsx)(ke,{status:e.status}),(0,S.jsx)(`span`,{className:`board-card-title`,title:t,children:t})]}),(0,S.jsxs)(`div`,{className:`board-card-meta num`,children:[(0,S.jsx)(`span`,{children:Ee(e.startedAt)}),(0,S.jsx)(`span`,{children:e.status===`running`?(0,S.jsx)(Oe,{since:e.startedAt}):Se(e.durationMs)}),e.costUsd!=null&&e.costUsd>0&&(0,S.jsx)(`span`,{children:Ce(e.costUsd)})]}),e.awaitingDecision&&(0,S.jsx)(`span`,{className:`chip decision`,children:`decision needed`}),(e.status===`failed`||e.status===`aborted`)&&(0,S.jsx)(`span`,{className:`chip status ${e.status}`,children:e.status})]})}function fo({slug:e,tab:t}){let n=H(`/api/workflows/${encodeURIComponent(e)}`,!1),[r,i]=(0,v.useState)(0),[a,o]=(0,v.useState)(0),s=H(`/api/runs`,a>0||Date.now()-r<2e4);if(!n)return(0,S.jsx)(`div`,{className:`empty`,children:`loading…`});if(n.error)return(0,S.jsx)(S.Fragment,{children:(0,S.jsxs)(`div`,{className:`empty`,children:[(0,S.jsx)(`span`,{className:`status-word failed`,children:`broken workflow`}),(0,S.jsx)(`pre`,{style:{marginTop:12,textAlign:`left`},children:n.error})]})});let c=new Map(n.agents.map((e,t)=>[e.id,t%4])),l=(s?.runs??[]).filter(e=>e.workflow===n.name||e.workflow===n.slug),u=`/workflows/${encodeURIComponent(n.slug)}`,d=l.filter(e=>e.status===`running`).length;return d!==a&&o(d),(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`detail-head`,children:[(0,S.jsx)(`h1`,{children:n.name??n.slug}),(0,S.jsx)(`span`,{className:`rid mono`,children:n.dir}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`nav`,{className:`tabs`,"aria-label":`workflow sections`,children:[(0,S.jsx)(F,{href:u,className:t===`overview`?`active`:``,children:`overview`}),(0,S.jsx)(F,{href:`${u}/details`,className:t===`details`?`active`:``,children:`details`}),(0,S.jsxs)(F,{href:`${u}/runs`,className:t===`runs`?`active`:``,children:[`runs `,(0,S.jsxs)(`span`,{className:`num`,children:[`(`,l.length,`)`]})]})]})]}),n.description&&(0,S.jsx)(`p`,{className:`detail-req`,children:n.description}),t===`overview`&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`section`,{className:`panel run-panel`,style:{marginBottom:18},children:(0,S.jsx)(ao,{slug:n.slug,usesRequest:n.usesRequest,initialRequest:l[0]?.request,onLaunched:()=>i(Date.now())})}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsxs)(`span`,{className:`microlabel`,children:[`board`,` `,(0,S.jsxs)(`span`,{className:`num`,children:[`(`,l.length,` runs`,d>0?`, ${d} live`:``,`)`]})]}),(0,S.jsx)(`span`,{className:`spacer`}),l[0]&&(0,S.jsx)(F,{href:`${u}/runs`,className:`open-raw`,children:`all runs ↗`})]}),(0,S.jsx)(co,{wf:n,runs:l,agentIdx:c,runsHref:`${u}/runs`})]})]}),t===`details`&&(0,S.jsx)(po,{wf:n,agentIdx:c}),t===`runs`&&(0,S.jsx)(mo,{runs:l})]})}function po({wf:e,agentIdx:t}){return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`statgrid`,children:[(0,S.jsxs)(`div`,{className:`stat`,children:[(0,S.jsx)(`div`,{className:`microlabel`,children:`agents`}),(0,S.jsx)(`div`,{className:`v num`,children:e.agents.length})]}),(0,S.jsxs)(`div`,{className:`stat`,children:[(0,S.jsx)(`div`,{className:`microlabel`,children:`steps`}),(0,S.jsxs)(`div`,{className:`v num`,children:[e.steps.length,` `,(0,S.jsxs)(`span`,{style:{color:`var(--muted)`,fontWeight:400},children:[`(`,e.steps.filter(e=>e.kind===`agent`).length,` agent ·`,` `,e.steps.filter(e=>e.kind===`script`).length,` script)`]})]})]}),e.workspace&&(0,S.jsxs)(`div`,{className:`stat`,style:{maxWidth:420},children:[(0,S.jsx)(`div`,{className:`microlabel`,children:`workspace`}),(0,S.jsx)(`div`,{className:`wf-workspace mono`,children:e.workspace})]})]}),(0,S.jsxs)(`section`,{className:`panel`,style:{marginBottom:18},children:[(0,S.jsx)(`div`,{className:`panel-head`,children:(0,S.jsx)(`span`,{className:`microlabel`,children:`agents`})}),(0,S.jsxs)(`div`,{className:`agent-grid`,children:[e.agents.map(e=>(0,S.jsx)(ho,{a:e,idx:t.get(e.id)??0},e.id)),e.agents.length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no agents — script-only workflow`})]})]}),(0,S.jsxs)(`div`,{className:`columns`,children:[(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsx)(`div`,{className:`panel-head`,children:(0,S.jsx)(`span`,{className:`microlabel`,children:`pipeline`})}),(0,S.jsx)(`div`,{className:`pipeline`,children:e.steps.map((e,n)=>(0,S.jsx)(go,{s:e,i:n,idx:e.agent?t.get(e.agent)??0:null},e.name))})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsx)(`div`,{className:`panel-head`,children:(0,S.jsxs)(`span`,{className:`microlabel`,children:[`folder `,(0,S.jsxs)(`span`,{className:`num`,children:[`(`,e.files.length,` files)`]})]})}),(0,S.jsx)(`div`,{className:`file-list`,children:e.files.map(e=>(0,S.jsx)(`div`,{className:`file-row`,style:{cursor:`default`},children:(0,S.jsx)(`span`,{className:`fname`,children:e})},e))})]})]})]})}function mo({runs:e}){return e.length===0?(0,S.jsx)(`div`,{className:`empty`,children:`no runs of this workflow yet`}):(0,S.jsx)(`div`,{className:`run-list`,children:e.map(e=>{let t=e.phasesTotal??0,n=t>0?Math.round(e.phasesDone/t*100):e.status===`ok`?100:0;return(0,S.jsxs)(F,{href:`/runs/${e.id}`,className:`run-card is-${e.status}`,children:[(0,S.jsx)(ke,{status:e.status}),(0,S.jsx)(`span`,{className:`rid`,children:e.id.replace(/^run-/,``)}),(0,S.jsx)(`span`,{className:`req`,title:e.request,children:e.status===`running`&&e.currentPhase?e.currentPhase:e.request??``}),(0,S.jsxs)(`span`,{className:`meta`,children:[e.awaitingDecision&&(0,S.jsx)(`span`,{className:`chip decision`,children:`decision needed`}),(0,S.jsx)(Ae,{status:e.status}),(0,S.jsx)(`span`,{className:`progress-track`,title:`${e.phasesDone}${t?` / ${t}`:``} steps`,children:(0,S.jsx)(`i`,{style:{width:`${n}%`}})}),(0,S.jsx)(`span`,{className:`num`,children:e.status===`running`?(0,S.jsx)(Oe,{since:e.startedAt}):Se(e.durationMs)}),(0,S.jsx)(`span`,{className:`num`,children:Ce(e.costUsd)}),(0,S.jsx)(`span`,{className:`num`,children:Ee(e.startedAt)})]})]},e.id)})})}function ho({a:e,idx:t}){return(0,S.jsxs)(`div`,{className:`agent-card aid-${t}`,children:[(0,S.jsxs)(`div`,{className:`agent-head`,children:[(0,S.jsx)(`span`,{className:`agent-dot`}),(0,S.jsx)(`b`,{children:e.name??e.id}),(0,S.jsxs)(`code`,{className:`agent-id`,children:[`[`,e.id,`]`]}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`span`,{className:`chip`,children:[e.model??`default`,e.effort?` · ${e.effort}`:``,e.protocol===`acp`?` · acp`:``]})]}),e.tools.length>0&&(0,S.jsx)(`div`,{className:`agent-tools`,children:e.tools.map(e=>(0,S.jsx)(`span`,{className:`tool-chip`,children:e},e))}),e.persona&&(0,S.jsx)(`p`,{className:`agent-persona`,children:e.persona})]})}function go({s:e,i:t,idx:n}){let r=e.kind===`script`?e.script:e.prompt;return(0,S.jsxs)(`div`,{className:`step-node`,children:[(0,S.jsx)(`div`,{className:`step-index num ${n==null?`is-script`:`aid-${n}`}`,children:t+1}),(0,S.jsxs)(`div`,{className:`step-body`,children:[(0,S.jsxs)(`div`,{className:`phase-top`,children:[(0,S.jsx)(`span`,{className:`phase-name`,children:e.name}),e.kind===`agent`?(0,S.jsxs)(`span`,{className:`chip agent-chip aid-${n??0}`,children:[`agent · `,e.agent]}):(0,S.jsxs)(`span`,{className:`chip`,children:[`script`,e.sourceRef?` · ${e.sourceRef}`:``]})]}),r&&(0,S.jsxs)(`details`,{className:`step-source`,children:[(0,S.jsx)(`summary`,{children:e.kind===`agent`?`prompt`:`script`}),(0,S.jsx)(`pre`,{children:r})]}),e.gates.length>0&&(0,S.jsx)(`div`,{className:`gate-line`,children:e.gates.map(e=>(0,S.jsxs)(`span`,{className:`gate neutral`,children:[`⛨ `,e]},e))})]})]})}function _o(e,t){let n=e.filter(e=>e.workflow===(t.name??t.slug));return{count:n.length,last:n[0]}}function vo(e,t){return`/runs/${e.id}?workflow=${encodeURIComponent(t.name??t.slug)}`}function yo({slug:e,tab:t}){let n=H(`/api/workflows`,!1),r=H(`/api/runs`,!1),[i,a]=(0,v.useState)(``),o=n?.workflows??[],s=r?.runs??[],c=(0,v.useMemo)(()=>{let e=i.trim().toLowerCase();return e?o.filter(t=>[t.name,t.slug,t.description].some(t=>t?.toLowerCase().includes(e))):o},[o,i]),l=(0,v.useMemo)(()=>{if(o.length!==0)return(o.map(e=>({w:e,last:_o(s,e).last})).filter(e=>!!e.last).sort((e,t)=>(t.last.updatedAt??``).localeCompare(e.last.updatedAt??``))[0]?.w??o[0]).slug},[o,s]),u=!!r;return(0,v.useEffect)(()=>{!e&&l&&u&&N(`/workflows/${encodeURIComponent(l)}`,{replace:!0})},[e,l,u]),(0,S.jsxs)(`div`,{className:`runs-screen workflows-screen`,children:[(0,S.jsxs)(`aside`,{className:`runs-side`,children:[(0,S.jsxs)(`div`,{className:`side-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`workflows`}),n&&(0,S.jsx)(`span`,{className:`microlabel num`,children:o.length}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(F,{href:`/runs`,className:`open-raw`,title:`every run of every workflow, newest first`,children:[(0,S.jsx)(C,{name:`history`,className:`ms-sm`}),` runs `,(0,S.jsx)(`span`,{className:`num`,children:s.length})]})]}),o.length>0&&(0,S.jsxs)(`label`,{className:`side-filter`,children:[(0,S.jsx)(C,{name:`search`,className:`ms-sm`}),(0,S.jsx)(`input`,{type:`search`,value:i,placeholder:`search workflows`,"aria-label":`search workflows`,onChange:e=>a(e.target.value)})]}),(0,S.jsxs)(`div`,{className:`side-list`,children:[c.map(t=>{let n=_o(s,t);return(0,S.jsxs)(F,{href:`/workflows/${encodeURIComponent(t.slug)}`,className:`side-row wf-row${t.slug===e?` active`:``}`,children:[(0,S.jsx)(ke,{status:n.last?.status??`idle`}),(0,S.jsxs)(`div`,{className:`side-row-body`,children:[(0,S.jsxs)(`div`,{className:`side-row-top`,children:[(0,S.jsx)(`span`,{className:`side-wf`,children:t.name??t.slug}),t.error&&(0,S.jsx)(`span`,{className:`status-word failed`,children:`broken`}),n.last&&(0,S.jsx)(`span`,{className:`side-when num`,children:De(n.last.updatedAt)})]}),(0,S.jsxs)(`div`,{className:`side-row-sub`,children:[(0,S.jsx)(`span`,{className:`side-req`,title:t.error??t.description??``,children:t.error??t.description??`${t.agents} agents · ${t.steps} steps`}),n.last?(0,S.jsxs)(`button`,{type:`button`,className:`wf-runs num`,title:`show the runs of this workflow`,onClick:e=>{e.preventDefault(),e.stopPropagation(),N(vo(n.last,t))},children:[n.count,` `,n.count===1?`run`:`runs`,` · `,(0,S.jsx)(Ae,{status:n.last.status})]}):(0,S.jsx)(`span`,{className:`wf-runs none num`,children:`no runs yet`})]})]})]},t.slug)}),n&&o.length>0&&c.length===0&&(0,S.jsxs)(`div`,{className:`viewer-note wf-nomatch`,children:[`no workflow matches “`,i,`”`]}),n&&o.length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no workflows yet`})]})]}),(0,S.jsx)(`div`,{className:`runs-main`,children:e?(0,S.jsx)(fo,{slug:e,tab:t},e):n&&o.length===0?(0,S.jsxs)(`div`,{className:`empty`,children:[`No workflows found — expected `,(0,S.jsx)(`code`,{children:`src/workflows/`}),` or `,(0,S.jsx)(`code`,{children:`workflows/`}),` next to the output folder.`]}):(0,S.jsx)(`div`,{className:`empty`,children:`loading…`})})]})}var bo=e=>e===`ok`?`ok`:e===`running`?`running`:e===`aborted`?`aborted`:`failed`,xo=e=>e===`ok`?`done`:e===`running`?`working`:e===`aborted`?`stopped`:`failed`;function So(e){return e.scope.kind===`channel`?`/channels/${e.scope.slug}`:e.scope.kind===`project`?`/projects/${e.scope.slug}/chat/${e.id}`:e.scope.kind===`agent`?`/agents/${e.scope.slug}/chat/${e.id}`:`/agents/chats/${e.id}`}function Co(e){switch(e.scope.kind){case`agent`:return e.scope.slug;case`channel`:return`#${e.scope.slug}`;case`run`:return e.scope.runId;case`knowledge`:return e.scope.bundle?`knowledge:${e.scope.bundle}`:`knowledge`;case`kraftwerk`:return`kraftwerk-aware`;case`project`:return`project:${e.scope.slug}`;default:return`general`}}function wo(e){return e.length>64?`${e.slice(0,46)}…${e.slice(-14)}`:e}function To(){let e=H(`/api/runs`,!1),t=H(`/api/chats`,!1),n=H(`/api/knowledge`,!1),r=H(`/api/agents`,!1),i=H(`/api/workflows`,!1),a=H(`/api/skills`,!1),[o,s]=(0,v.useState)(`all`),c=e?.runs??[],l=t?.chats??[],u=n?.bundles??[],d=(a?.skills??[]).filter(e=>e.source===`workspace`),f=[[i?.workflows.length,`workflows`,`/workflows`],[e?c.length:void 0,`runs`,`/runs`],[n?u.length:void 0,`bundles`,`/knowledge`],[a?d.length:void 0,`skills`,`/skills`],[t?l.length:void 0,`chats`,`/agents/chats`]],p=c.filter(e=>e.status===`failed`&&Date.now()-Date.parse(e.updatedAt)<864e5);return(0,S.jsxs)(`div`,{className:`dash`,children:[(0,S.jsxs)(`div`,{className:`page-head dash-head`,children:[(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(`span`,{className:`dash-mini`,children:f.map(([e,t,n])=>(0,S.jsxs)(F,{href:n,children:[(0,S.jsx)(`b`,{className:`num`,children:e??`…`}),` `,t]},t))})]}),p.length>0&&o!==`failed`&&(0,S.jsxs)(`button`,{className:`dash-alert`,onClick:()=>s(`failed`),children:[`⚠ `,p.length,` run`,p.length===1?``:`s`,` failed in the last 24 h — review`]}),(0,S.jsx)(Oo,{runs:c,chats:l,bundles:u,agents:r?.agents??[],workflows:i?.workflows??[],filter:o,setFilter:s})]})}function Eo(e){if(e.lamp===`running`)return`now`;let t=new Date(e.at),n=new Date;if(t.toDateString()===n.toDateString())return`today`;let r=new Date(n);return r.setDate(r.getDate()-1),t.toDateString()===r.toDateString()?`yesterday`:`earlier`}var Do=[[`all`,`all`],[`run`,`runs`],[`session`,`chats`],[`knowledge`,`knowledge`]];function Oo({runs:e,chats:t,bundles:n,agents:r,workflows:i,filter:a,setFilter:o}){let s=z(),c=(0,v.useMemo)(()=>{let o=[],c=e=>e?i.find(t=>t.slug===e)?.name??e:void 0;for(let t of e)o.push({at:t.updatedAt,kind:`run`,emoji:`⚙️`,title:c(t.workflow)??t.id,sub:t.request??``,href:`/runs/${t.id}`,lamp:bo(t.status),status:xo(t.status)});for(let e of t){let t=e.scope.kind===`agent`?r.find(t=>e.scope.kind===`agent`&&t.slug===e.scope.slug):void 0;o.push({at:e.updatedAt,kind:`session`,emoji:t?t.emoji||`🤖`:`💬`,title:t?t.name:e.title||`new chat`,sub:t?`${e.title||`new chat`}${s?` · ${e.agent}`:``}`:s?`${e.agent} · ${Co(e)}`:Co(e),href:So(e),lamp:e.awaitingApproval?`blocked`:e.busy?`running`:`ok`,status:e.awaitingApproval?`needs approval`:e.busy?`working`:void 0})}for(let e of n)e.updatedAt&&o.push({at:e.updatedAt,kind:`knowledge`,emoji:`📚`,title:e.name,sub:`${e.concepts} concepts`,href:`/knowledge/${encodeURIComponent(e.name)}`,lamp:`ok`});return(a===`all`?o:a===`failed`?o.filter(e=>e.kind===`run`&&e.lamp===`failed`):o.filter(e=>e.kind===a)).sort((e,t)=>{let n=Number(t.lamp===`running`)-Number(e.lamp===`running`);return n===0?t.at.localeCompare(e.at):n}).slice(0,15)},[e,t,n,r,s,a]),l=``;return(0,S.jsxs)(`section`,{className:`panel dash-feed`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`activity`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`span`,{className:`dash-feed-filter`,children:[Do.map(([e,t])=>(0,S.jsx)(`button`,{className:`feed-chip ${a===e?`on`:``}`,onClick:()=>o(e),children:t},e)),a===`failed`&&(0,S.jsxs)(`button`,{className:`feed-chip on failed`,onClick:()=>o(`all`),children:[`failed `,(0,S.jsx)(C,{name:`close`,className:`ms-sm`})]})]})]}),c.length===0?(0,S.jsx)(`div`,{className:`viewer-note`,children:a===`all`?`nothing yet — run a workflow or start a session`:`nothing here for this filter`}):(0,S.jsx)(`div`,{className:`m3-list`,children:c.map(e=>{let t=Eo(e),n=t===l?null:t;return l=t,(0,S.jsxs)(`div`,{className:`feed-group`,children:[n&&(0,S.jsx)(`div`,{className:`feed-day microlabel`,children:n}),(0,S.jsxs)(F,{href:e.href,className:`m3-row m3-link`,children:[(0,S.jsxs)(`span`,{className:`agent-avatar`,children:[(0,S.jsx)(`span`,{"aria-hidden":!0,children:e.emoji}),e.lamp===`running`&&(0,S.jsx)(`span`,{className:`lamp running`})]}),(0,S.jsx)(`span`,{className:`chip dash-kind ${e.kind}`,children:e.kind===`session`?`chat`:e.kind}),(0,S.jsxs)(`span`,{className:`m3-body`,children:[(0,S.jsx)(`span`,{className:`m3-head`,children:wo(e.title)}),e.sub&&(0,S.jsx)(`span`,{className:`m3-sub`,children:wo(e.sub)})]}),e.status&&(0,S.jsx)(`span`,{className:`chip status ${e.lamp}`,children:e.status}),(0,S.jsx)(`span`,{className:`side-when num`,title:new Date(e.at).toLocaleString(),children:De(e.at)}),(0,S.jsx)(`span`,{className:`m3-chev`,children:(0,S.jsx)(C,{name:`chevron_right`})})]})]},`${e.kind}:${e.href}:${e.at}`)})})]})}var ko=`modulepreload`,Ao=function(e){return`/`+e},jo={},Mo=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Ao(t,n),t=s(t),t in jo)return;jo[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:ko,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},No=(0,v.lazy)(()=>Mo(()=>import(`./editor-BlujZXnd.js`).then(e=>({default:e.DocEditor})),__vite__mapDeps([0,1,2,3,4,5,6]))),Po=()=>Mo(()=>import(`./editor-BlujZXnd.js`),__vite__mapDeps([0,1,2,3,4,5,6]));function Fo({bundle:e,conceptId:t}){let n=H(`/api/knowledge`,!1),r=n?.bundles??[],i=e===`new`,a=r.reduce((e,t)=>!e||(t.updatedAt??``)>(e.updatedAt??``)?t:e,void 0);return(0,v.useEffect)(()=>{!e&&a&&N(`/knowledge/${encodeURIComponent(a.name)}`,{replace:!0})},[e,a?.name]),(0,S.jsxs)(`div`,{className:`runs-screen`,children:[(0,S.jsxs)(`aside`,{className:`runs-side`,children:[(0,S.jsxs)(`div`,{className:`side-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`bundles`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(F,{href:`/knowledge/new`,className:`open-raw`,children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` new`]})]}),(0,S.jsxs)(`div`,{className:`side-list`,children:[r.map(t=>(0,S.jsxs)(F,{href:`/knowledge/${encodeURIComponent(t.name)}`,className:`side-row ${t.name===e?`active`:``}`,children:[(0,S.jsx)(`span`,{className:`lamp ok`}),(0,S.jsxs)(`div`,{className:`side-row-body`,children:[(0,S.jsxs)(`div`,{className:`side-row-top`,children:[(0,S.jsx)(`span`,{className:`side-wf`,children:t.name}),(0,S.jsx)(`span`,{className:`side-when num`,children:t.concepts})]}),(0,S.jsx)(`div`,{className:`side-row-sub`,children:(0,S.jsxs)(`span`,{className:`side-req`,children:[t.okfVersion?`okf ${t.okfVersion}`:`okf`,t.updatedAt?` · ${t.updatedAt.slice(0,10)}`:``]})})]})]},t.name)),n&&r.length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no bundles yet`})]})]}),(0,S.jsx)(`div`,{className:`runs-main`,children:e&&!i?(0,S.jsx)(zo,{name:e,conceptId:t},e):i||n&&!a?(0,S.jsx)(Io,{}):(0,S.jsx)(`div`,{className:`empty`,children:`loading…`})})]})}function Io(){let[e,t]=(0,v.useState)(``),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(!1);async function o(){let t=e.trim();if(!t)return;a(!0),r(``);let n=await(await fetch(`/api/knowledge`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:t})})).json();a(!1),n.error?r(n.error):N(`/knowledge/${encodeURIComponent(t)}`)}return(0,S.jsxs)(`div`,{className:`empty empty-action`,children:[(0,S.jsxs)(`div`,{className:`know-newbundle`,children:[(0,S.jsx)(`input`,{value:e,placeholder:`bundle name, e.g. customer-support`,onChange:e=>t(e.target.value),onKeyDown:e=>e.key===`Enter`&&void o(),autoFocus:!0}),(0,S.jsx)(`button`,{className:`run-btn`,disabled:!e.trim()||i,onClick:o,children:i?`creating…`:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` new bundle`]})})]}),n&&(0,S.jsxs)(`div`,{className:`msg error`,children:[(0,S.jsx)(C,{name:`error`,className:`ms-sm`}),` `,n]})]})}function Lo({tier:e}){return(0,S.jsx)(`span`,{className:`chip trust ${e}`,children:e})}var Ro=`@activity`;function zo({name:e,conceptId:t}){let n=H(`/api/knowledge/${encodeURIComponent(e)}`,!1);if(!n)return(0,S.jsx)(`div`,{className:`empty`,children:`loading…`});if(`error`in n)return(0,S.jsx)(`div`,{className:`empty`,children:`bundle not found`});let r=t===Ro?`activity`:`pages`,i=n.concepts,a=r===`pages`?t&&i.some(e=>e.id===t)?t:i[0]?.id:void 0,o=`/knowledge/${encodeURIComponent(e)}`;return(0,S.jsxs)(`div`,{className:`agent-view`,children:[(0,S.jsxs)(`div`,{className:`page-head`,children:[(0,S.jsx)(`h1`,{children:e}),(0,S.jsxs)(`span`,{className:`count`,children:[i.length,` pages`]}),(0,S.jsxs)(`div`,{className:`tabs`,children:[(0,S.jsx)(F,{href:o,className:r===`pages`?`active`:``,children:`pages`}),(0,S.jsx)(F,{href:`${o}/${Ro}`,className:r===`activity`?`active`:``,children:`activity`})]}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`button`,{className:`open-raw`,onClick:()=>void pa(e),children:[(0,S.jsx)(C,{name:`picture_as_pdf`,className:`ms-sm`}),` export PDF`]}),(0,S.jsx)(`button`,{className:`run-btn`,onClick:()=>void mi(`claude`,{kind:`knowledge`,bundle:e}),children:`curate in chat`})]}),r===`activity`?n.log?(0,S.jsx)(Ho,{name:e,log:n.log}):(0,S.jsx)(`section`,{className:`panel`,children:(0,S.jsx)(`div`,{className:`viewer-note`,children:`no activity yet`})}):i.length===0?(0,S.jsx)(`section`,{className:`panel`,children:(0,S.jsxs)(`div`,{className:`viewer-note`,children:[`No pages yet — start a chat to author some, or write one with`,` `,(0,S.jsxs)(`code`,{children:[`kraftwerk knowledge put `,e,`/<path>`]}),`.`]})}):(0,S.jsxs)(`div`,{className:`wiki`,children:[(0,S.jsx)(`aside`,{className:`wiki-side`,children:(0,S.jsx)(Wo,{concepts:i,base:o,selected:a})}),(0,S.jsx)(`div`,{className:`wiki-main`,children:a&&(0,S.jsx)(Ko,{bundle:e,conceptId:a},a)})]})]})}function Bo(e){let t=[];for(let n of e.split(`
213
+ `).length+2)),value:n.content,spellCheck:!1,onChange:e=>r({...n,content:e.target.value})})]}),(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsx)(`button`,{className:`run-btn`,disabled:i||!n.name.trim(),onClick:()=>void l(),children:i?`saving…`:`save`}),(0,S.jsx)(`button`,{className:`open-raw`,disabled:i,onClick:()=>r(null),children:`cancel`})]})]}),o&&(0,S.jsxs)(`div`,{className:`msg error`,children:[(0,S.jsx)(C,{name:`error`,className:`ms-sm`}),` `,o]})]})}function Fa({slug:e}){let t=H(`/api/agents/${encodeURIComponent(e)}/routines`,!1)?.routines??[],[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(``);async function c(t){a(``);let n=await(await fetch(`/api/agents/${encodeURIComponent(e)}/routines`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)})).json();return!n.error||(a(n.error),!1)}async function l(t){s(t),a(``);let n=await(await fetch(`/api/agents/${encodeURIComponent(e)}/routines/${encodeURIComponent(t)}/run`,{method:`POST`})).json();s(``),n.error?a(n.error):n.chatId&&N(`/agents/${encodeURIComponent(e)}/chat/${n.chatId}`)}async function u(t){window.confirm(`Delete routine "${t}"?`)&&await fetch(`/api/agents/${encodeURIComponent(e)}/routines/${encodeURIComponent(t)}`,{method:`DELETE`}).catch(()=>{})}return(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`routines — scheduled prompts`}),(0,S.jsx)(`span`,{className:`spacer`}),!n&&(0,S.jsxs)(`button`,{className:`open-raw`,onClick:()=>r({name:``,schedule:`0 9 * * 1-5`,prompt:``,enabled:!0}),children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` new routine`]})]}),t.length===0&&!n&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`none — a routine messages this agent on a schedule (cron, server local time) and each run opens a new session with the result.`}),t.length>0&&(0,S.jsx)(`div`,{className:`m3-list`,children:t.map(t=>(0,S.jsxs)(`div`,{className:`m3-row`,children:[(0,S.jsx)(`span`,{className:`m3-ico`,children:(0,S.jsx)(C,{name:`schedule`})}),(0,S.jsxs)(`span`,{className:`m3-body`,children:[(0,S.jsxs)(`span`,{className:`m3-head`,children:[t.name,t.lastError&&(0,S.jsx)(`span`,{className:`chip stale`,title:t.lastError,children:`error`}),t.awaitingApproval&&t.lastChatId&&(0,S.jsx)(F,{href:`/agents/${encodeURIComponent(e)}/chat/${t.lastChatId}`,className:`chip attention`,title:`the last run asked for a permission nobody has answered yet`,children:`needs approval`})]}),(0,S.jsxs)(`span`,{className:`m3-sub`,children:[(0,S.jsx)(`code`,{children:t.schedule}),t.enabled?t.nextRunAt?` · next ${Ee(t.nextRunAt)}`:``:` · paused`,` · `,t.lastChatId?(0,S.jsxs)(F,{href:`/agents/${encodeURIComponent(e)}/chat/${t.lastChatId}`,children:[`last run `,Ee(t.lastRunAt)]}):`never ran`]})]}),(0,S.jsx)(`button`,{className:`open-raw`,disabled:o===t.id,onClick:()=>l(t.id),children:o===t.id?`starting…`:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(C,{name:`play_arrow`,className:`ms-sm`}),` run`]})}),(0,S.jsx)(`button`,{className:`open-raw`,onClick:()=>r({id:t.id,name:t.name,schedule:t.schedule,prompt:t.prompt,enabled:t.enabled}),children:`edit`}),(0,S.jsx)(`button`,{className:`open-raw`,onClick:()=>void u(t.id),children:`delete`}),(0,S.jsxs)(`label`,{className:`m3-switch`,title:t.enabled?`enabled — click to pause`:`paused — click to enable`,children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:t.enabled,onChange:()=>void c({id:t.id,name:t.name,schedule:t.schedule,prompt:t.prompt,enabled:!t.enabled})}),(0,S.jsx)(`span`,{className:`m3-switch-track`})]})]},t.id))}),n&&(0,S.jsxs)(`div`,{className:`agent-form`,children:[(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`name`,(0,S.jsx)(`input`,{value:n.name,placeholder:`e.g. Morning report`,onChange:e=>r({...n,name:e.target.value})})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{width:200},children:[`schedule (cron)`,(0,S.jsx)(`input`,{value:n.schedule,placeholder:`0 9 * * 1-5`,onChange:e=>r({...n,schedule:e.target.value})})]}),(0,S.jsxs)(`label`,{className:`agent-field wf-checks`,style:{width:90},children:[`enabled`,(0,S.jsxs)(`label`,{children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:n.enabled,onChange:e=>r({...n,enabled:e.target.checked})}),`on`]})]})]}),(0,S.jsxs)(`label`,{className:`agent-field`,children:[`prompt — what to ask this agent on each run`,(0,S.jsx)(`textarea`,{rows:5,value:n.prompt,placeholder:`Check ... and summarize what changed.`,onChange:e=>r({...n,prompt:e.target.value})})]}),(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsx)(`button`,{className:`run-btn`,disabled:!n.name.trim()||!n.prompt.trim(),onClick:async()=>{await c(n)&&r(null)},children:n.id?`save routine`:`create routine`}),(0,S.jsx)(`button`,{className:`open-raw`,onClick:()=>(r(null),a(``)),children:`cancel`})]})]}),i&&(0,S.jsxs)(`div`,{className:`msg error`,children:[(0,S.jsx)(C,{name:`error`,className:`ms-sm`}),` `,i]})]})}function Ia({slug:e}){let[t,n]=(0,v.useState)(e?null:f()),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(!1),s=H(`/api/workflows`,!1)?.workflows??[],c=H(`/api/knowledge`,!1)?.bundles??[],l=ce(),u=H(l.vibeables?`/api/vibeables`:``,!1)?.vibeables??[],d=H(`/api/skills`,!1)?.skills??[];(0,v.useEffect)(()=>{e&&fetch(`/api/agents/${encodeURIComponent(e)}`).then(e=>e.ok?e.json():Promise.reject()).then(e=>n({name:e.name,emoji:e.emoji,description:e.description??``,harness:e.harness,model:e.model??``,effort:e.effort??``,group:e.group??``,system:e.system,workflows:e.workflows,knowledge:e.knowledge??[],vibeables:e.vibeables??[],skillsAll:e.skills===void 0,skills:e.skills??[]})).catch(()=>i(`agent not found`))},[e]);function f(){return{name:``,emoji:`🤖`,description:``,harness:`claude`,model:``,effort:``,group:``,system:``,workflows:[],knowledge:[],vibeables:[],skillsAll:!0,skills:[]}}async function p(){if(!t)return;o(!0),i(``);let n=await(await fetch(e?`/api/agents/${encodeURIComponent(e)}`:`/api/agents`,{method:e?`PUT`:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({...t,skills:t.skillsAll?void 0:t.skills})})).json();o(!1),n.error?i(n.error):N(`/agents/${encodeURIComponent(n.slug)}/info`)}async function m(){e&&window.confirm(`Delete agent "${e}" and its definition folder?`)&&(await fetch(`/api/agents/${encodeURIComponent(e)}`,{method:`DELETE`}).catch(()=>{}),N(`/agents`))}if(!t)return(0,S.jsx)(`div`,{className:`empty`,children:r||`loading…`});let h=e=>n({...t,...e});return(0,S.jsxs)(`div`,{className:`new-chat`,children:[(0,S.jsx)(`div`,{className:`page-head`,children:(0,S.jsx)(`h1`,{children:e?`edit ${e}`:`new agent`})}),(0,S.jsx)(`section`,{className:`panel new-chat-panel`,children:(0,S.jsxs)(`div`,{className:`agent-form`,children:[(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`name`,(0,S.jsx)(`input`,{value:t.name,placeholder:`e.g. Max`,onChange:e=>h({name:e.target.value})})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{width:90},children:[`emoji`,(0,S.jsx)(`input`,{value:t.emoji,onChange:e=>h({emoji:e.target.value})})]})]}),(0,S.jsx)(`div`,{className:`emoji-pick`,children:ya.map(e=>(0,S.jsx)(`button`,{type:`button`,className:t.emoji===e?`active`:``,onClick:()=>h({emoji:e}),children:e},e))}),(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`description`,(0,S.jsx)(`input`,{value:t.description,placeholder:`one line: what this agent is for`,onChange:e=>h({description:e.target.value})})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{width:180},children:[`group`,(0,S.jsx)(`input`,{value:t.group,placeholder:`none`,onChange:e=>h({group:e.target.value})})]})]}),(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsxs)(`label`,{className:`agent-field`,style:{width:140},children:[`harness`,(0,S.jsxs)(`select`,{value:t.harness,onChange:e=>h({harness:e.target.value}),children:[(0,S.jsx)(`option`,{value:`claude`,children:`claude`}),(0,S.jsx)(`option`,{value:`codex`,children:`codex`}),(0,S.jsx)(`option`,{value:`pi`,children:`pi`})]})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`model`,(0,S.jsx)(`input`,{value:t.model,placeholder:`harness default — e.g. sonnet, gpt-5.6-sol`,onChange:e=>h({model:e.target.value})})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{width:140},children:[`effort`,(0,S.jsx)(`select`,{value:t.effort,onChange:e=>h({effort:e.target.value}),children:va.map(e=>(0,S.jsx)(`option`,{value:e,children:e||`default`},e))})]})]}),(0,S.jsxs)(`label`,{className:`agent-field`,children:[`system prompt — the agent's role`,(0,S.jsx)(`textarea`,{rows:10,value:t.system,placeholder:`You are the ... for this project. Your job is ...`,onChange:e=>h({system:e.target.value})})]}),(0,S.jsxs)(`div`,{className:`agent-field`,children:[(0,S.jsx)(`span`,{className:`agent-field-label`,children:`connected workflows — autoloaded into the agent's context; it can run them`}),(0,S.jsxs)(`div`,{className:`wf-checks`,children:[s.map(e=>(0,S.jsxs)(`label`,{children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:t.workflows.includes(e.slug),onChange:n=>h({workflows:n.target.checked?[...t.workflows,e.slug]:t.workflows.filter(t=>t!==e.slug)})}),(0,S.jsx)(`b`,{children:e.slug}),e.description&&(0,S.jsxs)(`span`,{className:`opt-hint`,children:[` — `,e.description]})]},e.slug)),s.length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no workflows in this project`})]})]}),(0,S.jsxs)(`div`,{className:`agent-field`,children:[(0,S.jsx)(`span`,{className:`agent-field-label`,children:`connected knowledge — OKF bundles the agent consults and maintains`}),(0,S.jsxs)(`div`,{className:`wf-checks`,children:[c.map(e=>(0,S.jsxs)(`label`,{children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:t.knowledge.includes(e.name),onChange:n=>h({knowledge:n.target.checked?[...t.knowledge,e.name]:t.knowledge.filter(t=>t!==e.name)})}),(0,S.jsx)(`b`,{children:e.name}),(0,S.jsxs)(`span`,{className:`opt-hint`,children:[` — `,e.concepts,` concepts`]})]},e.name)),c.length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no knowledge bundles in this project`})]})]}),(l.vibeables||t.vibeables.length>0)&&(0,S.jsxs)(`div`,{className:`agent-field`,"data-link-kind":`vibeables`,children:[(0,S.jsx)(`span`,{className:`agent-field-label`,children:`connected vibeables — small apps the agent builds and maintains`}),(0,S.jsxs)(`div`,{className:`wf-checks`,children:[u.map(e=>(0,S.jsxs)(`label`,{children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:t.vibeables.includes(e.slug),onChange:n=>h({vibeables:n.target.checked?[...t.vibeables,e.slug]:t.vibeables.filter(t=>t!==e.slug)})}),(0,S.jsx)(`b`,{children:e.slug}),(0,S.jsxs)(`span`,{className:`opt-hint`,children:[` — `,e.dev?`dev`:`static`]})]},e.slug)),t.vibeables.filter(e=>!u.some(t=>t.slug===e)).map(e=>(0,S.jsxs)(`label`,{children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:!0,onChange:()=>h({vibeables:t.vibeables.filter(t=>t!==e)})}),(0,S.jsx)(`b`,{children:e}),(0,S.jsx)(`span`,{className:`opt-hint`,children:` — not found in this workspace`})]},e)),!l.vibeables&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`vibeables are off in this workspace's settings`}),l.vibeables&&u.length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no vibeables in this workspace yet`})]})]}),(0,S.jsxs)(`div`,{className:`agent-field`,children:[(0,S.jsx)(`span`,{className:`agent-field-label`,children:`connected skills — workspace skill packages (see the skills tab); invoked with /name in sessions`}),(0,S.jsxs)(`div`,{className:`wf-checks`,children:[(0,S.jsxs)(`label`,{children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:t.skillsAll,onChange:e=>h({skillsAll:e.target.checked})}),(0,S.jsx)(`b`,{children:`all skills`}),(0,S.jsx)(`span`,{className:`opt-hint`,children:` — every discovered skill, including future ones`})]}),!t.skillsAll&&d.map(e=>(0,S.jsxs)(`label`,{children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:t.skills.includes(e.name),onChange:n=>h({skills:n.target.checked?[...t.skills,e.name]:t.skills.filter(t=>t!==e.name)})}),(0,S.jsxs)(`b`,{children:[`/`,e.name]}),e.description&&(0,S.jsxs)(`span`,{className:`opt-hint`,children:[` — `,e.description]})]},e.name)),!t.skillsAll&&d.length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no skills found (.claude/skills, project or user)`})]})]}),r&&(0,S.jsxs)(`div`,{className:`msg error`,children:[(0,S.jsx)(C,{name:`error`,className:`ms-sm`}),` `,r]}),(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsx)(`button`,{className:`run-btn`,disabled:!t.name.trim()||a,onClick:p,children:a?`saving…`:e?`save`:`create`}),(0,S.jsx)(`span`,{className:`spacer`}),e&&(0,S.jsx)(`button`,{className:`stop-btn`,onClick:m,children:`delete agent`})]})]})})]})}function La(e){if(!ne(e))return null;let t=e.split(`/`).filter(Boolean),n=decodeURIComponent(t[1]),r=t[0]===`agents`||t[0]===`team`;return n===`new`?t[0]===`projects`?(0,S.jsx)(ea,{},`new-project`):r?(0,S.jsx)(Ia,{},`new-agent`):(0,S.jsx)(ai,{},`new-channel`):t[0]===`projects`&&t[2]===`info`?(0,S.jsx)(sa,{slug:n,onChanged:async()=>{}},n):r&&t[2]===`info`?(0,S.jsx)(Ma,{slug:n},n):r&&t[2]===`edit`?(0,S.jsx)(Ia,{slug:n},n):t[0]===`channels`&&t[2]===`edit`?(0,S.jsx)(ai,{slug:n},n):null}function Ra({back:e,children:t}){let n=()=>N(e);return(0,v.useEffect)(()=>{let e=e=>{e.key!==`Escape`||e.defaultPrevented||document.querySelector(`.palette-backdrop`)||(e.preventDefault(),n())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}),(0,S.jsx)(`div`,{className:`modal-backdrop`,onMouseDown:n,children:(0,S.jsxs)(`div`,{className:`modal edit-modal`,role:`dialog`,"aria-label":`edit`,onMouseDown:e=>e.stopPropagation(),children:[(0,S.jsx)(`button`,{type:`button`,className:`modal-x`,onClick:n,title:`close (esc)`,"aria-label":`close`,children:(0,S.jsx)(C,{name:`close`})}),(0,S.jsx)(`div`,{className:`runs-main modal-body`,children:t})]})})}function za({runId:e,decision:t}){let{request:n,answer:r}=t,[i,a]=(0,v.useState)(n.options.length===1?n.options[0].value:null),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),f=e=>n.options.find(t=>t.value===e)?.label??e;if(r)return(0,S.jsx)(`section`,{className:`panel decision-panel is-decided`,"aria-label":`decision`,children:(0,S.jsxs)(`div`,{className:`decision-body`,children:[(0,S.jsx)(`div`,{className:`decision-title`,children:n.title??`Decision`}),(0,S.jsxs)(`div`,{className:`decision-answer`,children:[(0,S.jsx)(`span`,{className:`chip status ok`,children:f(r.decision)}),r.note&&(0,S.jsxs)(`span`,{className:`decision-note`,children:[`“`,r.note,`”`]}),r.decidedAt&&(0,S.jsx)(`span`,{className:`decision-when num`,children:Ee(r.decidedAt)})]})]})});let p=!!i&&!c&&(n.note!==`required`||!!o.trim());async function m(){if(!p)return;l(!0),d(null);let t=await fetch(`/api/runs/${encodeURIComponent(e)}/decision`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({decision:i,note:o.trim()})}).catch(()=>null);t?.ok||(d((await t?.json().catch(()=>null))?.error??`could not save the decision`),l(!1))}return(0,S.jsx)(`section`,{className:`panel decision-panel`,"aria-label":`decision needed`,children:(0,S.jsxs)(`div`,{className:`decision-body`,children:[(0,S.jsxs)(`div`,{className:`decision-head`,children:[(0,S.jsx)(`span`,{className:`lamp running`}),(0,S.jsx)(`div`,{className:`decision-title`,children:n.title??`This run needs your decision`})]}),n.prompt&&(0,S.jsx)(`p`,{className:`decision-prompt`,children:n.prompt}),(0,S.jsx)(`div`,{className:`tabs decision-options`,role:`radiogroup`,"aria-label":`options`,children:n.options.map(e=>(0,S.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":i===e.value,className:i===e.value?`active`:``,onClick:()=>a(e.value),children:e.label??e.value},e.value))}),n.note!==!1&&(0,S.jsxs)(`label`,{className:`m3-field`,children:[(0,S.jsx)(`input`,{type:`text`,value:o,placeholder:` `,"aria-label":`note`,onChange:e=>s(e.target.value),onKeyDown:e=>e.key===`Enter`&&m()}),(0,S.jsx)(`span`,{className:`m3-field-label`,children:n.note===`required`?`Note (required)`:`Note`})]}),u&&(0,S.jsx)(`div`,{className:`m3-error`,children:u}),(0,S.jsx)(`div`,{className:`m3-actions`,children:(0,S.jsx)(`button`,{className:`m3-filled-btn`,onClick:m,disabled:!p,children:c?`Saving…`:`Submit decision`})})]})})}function Ba({id:e,workflow:t}){let n=H(`/api/runs`,!0),r=n?.runs??[],[i,a]=(0,v.useState)(t??``),o=(0,v.useMemo)(()=>{let e=i.trim().toLowerCase();return e?r.filter(t=>[t.workflow,t.request,t.id].some(t=>t?.toLowerCase().includes(e))):r},[r,i]);return(0,S.jsxs)(`div`,{className:`runs-screen`,children:[(0,S.jsxs)(`aside`,{className:`runs-side`,children:[(0,S.jsxs)(`div`,{className:`side-head`,children:[(0,S.jsx)(F,{href:`/workflows`,className:`side-back`,title:`back to workflows`,children:(0,S.jsx)(C,{name:`arrow_back`,className:`ms-sm`})}),(0,S.jsx)(`span`,{className:`microlabel`,children:`runs`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(`span`,{className:`microlabel num`,children:i?`${o.length} / ${r.length}`:r.length})]}),(0,S.jsxs)(`label`,{className:`side-filter`,children:[(0,S.jsx)(C,{name:`filter_list`,className:`ms-sm`}),(0,S.jsx)(`input`,{type:`search`,value:i,placeholder:`filter by workflow or request`,"aria-label":`filter runs`,onChange:e=>a(e.target.value)})]}),(0,S.jsxs)(`div`,{className:`side-list`,children:[o.map(t=>(0,S.jsx)(Va,{r:t,active:t.id===e},t.id)),n&&r.length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no runs yet`}),r.length>0&&o.length===0&&(0,S.jsxs)(`div`,{className:`viewer-note`,children:[`no run matches “`,i,`”`]})]})]}),(0,S.jsx)(`div`,{className:`runs-main`,children:(0,S.jsx)(Ha,{id:e},e)})]})}function Va({r:e,active:t}){return(0,S.jsxs)(F,{href:`/runs/${e.id}`,className:`side-row ${t?`active`:``}`,children:[(0,S.jsx)(ke,{status:e.status}),(0,S.jsxs)(`div`,{className:`side-row-body`,children:[(0,S.jsxs)(`div`,{className:`side-row-top`,children:[(0,S.jsx)(`span`,{className:`side-wf`,children:e.workflow??`unknown`}),(0,S.jsx)(`span`,{className:`side-when num`,children:Ee(e.startedAt)})]}),(0,S.jsxs)(`div`,{className:`side-row-sub`,children:[(0,S.jsx)(`span`,{className:`side-req`,title:e.request,children:e.status===`running`&&e.currentPhase?`${e.currentPhase}`:e.request??``}),(0,S.jsx)(`span`,{className:`side-meta num`,children:e.status===`running`?(0,S.jsx)(Oe,{since:e.startedAt}):Se(e.durationMs)})]})]})]})}function Ha({id:e}){let t=H(`/api/runs/${e}`,!0),n=t?.status===`running`,[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(null),l=z();if(!t)return(0,S.jsx)(`div`,{className:`empty`,children:`loading…`});let u=t.files.some(e=>e.name===`runner.json`),d=r??(n?`run`:`artifacts`),f=l?t.files.length:t.files.filter(e=>!Ja(e.name)).length;async function p(){o(!0),c(null);let t=await fetch(`/api/runs/${e}/stop`,{method:`POST`}).catch(()=>null);t?.ok||(o(!1),c((await t?.json().catch(()=>null))?.error??`stop failed`))}async function m(){if(!window.confirm(`Remove run ${e} and all its files?`))return;c(null);let n=await fetch(`/api/runs/${e}`,{method:`DELETE`}).catch(()=>null);if(n?.ok){N(t?.workflow?`/workflows/${encodeURIComponent(t.workflow)}`:`/workflows`);return}c((await n?.json().catch(()=>null))?.error??`remove failed`)}return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`detail-head`,children:[(0,S.jsx)(ke,{status:t.status}),(0,S.jsx)(`h1`,{children:t.workflow?(0,S.jsx)(F,{href:`/workflows/${encodeURIComponent(t.workflow)}`,title:`open workflow`,children:t.workflow}):`unknown workflow`}),(0,S.jsx)(Ae,{status:t.status}),u&&(0,S.jsxs)(`span`,{className:`chip sandbox-chip`,children:[(0,S.jsx)(C,{name:`science`,className:`ms-sm`}),` sandbox`]}),(0,S.jsx)(`span`,{className:`rid`,children:e.replace(/^run-/,``)}),n?(0,S.jsx)(`button`,{className:`stop-btn`,onClick:p,disabled:a,children:a?`stopping…`:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(C,{name:`stop`,className:`ms-sm`}),` stop`]})}):(0,S.jsxs)(`button`,{className:`stop-btn`,onClick:m,title:`delete this run's folder`,children:[(0,S.jsx)(C,{name:`delete`,className:`ms-sm`}),` remove`]}),s&&(0,S.jsx)(`span`,{className:`run-action-error`,children:s}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(`button`,{className:`open-raw`,title:`chat with an agent about this run`,onClick:()=>void mi(`claude`,{kind:`run`,runId:e}),children:`⌬ discuss`}),(0,S.jsxs)(`nav`,{className:`tabs`,children:[(0,S.jsx)(`button`,{className:d===`run`?`active`:``,onClick:()=>i(`run`),children:`run`}),(0,S.jsxs)(`button`,{className:d===`artifacts`?`active`:``,onClick:()=>i(`artifacts`),children:[`artifacts `,(0,S.jsxs)(`span`,{className:`num`,children:[`(`,f,`)`]})]})]})]}),t.request&&(0,S.jsx)(`p`,{className:`detail-req`,children:t.request}),d===`run`?(0,S.jsx)(Ua,{run:t,live:n}):(0,S.jsx)(Xa,{id:e,files:t.files,live:n})]})}function Ua({run:e,live:t}){return(0,S.jsxs)(`div`,{className:`run-tab`,children:[e.decision&&(0,S.jsx)(za,{runId:e.id,decision:e.decision}),(0,S.jsxs)(`div`,{className:`statgrid`,children:[(0,S.jsxs)(`div`,{className:`stat`,children:[(0,S.jsx)(`div`,{className:`microlabel`,children:`phases`}),(0,S.jsxs)(`div`,{className:`v num`,children:[e.phasesDone,e.phasesTotal==null?``:` / ${e.phasesTotal}`]})]}),(0,S.jsxs)(`div`,{className:`stat`,children:[(0,S.jsx)(`div`,{className:`microlabel`,children:`duration`}),(0,S.jsx)(`div`,{className:`v num`,children:t?(0,S.jsx)(Oe,{since:e.startedAt}):Se(e.durationMs)})]}),(0,S.jsxs)(`div`,{className:`stat`,children:[(0,S.jsx)(`div`,{className:`microlabel`,children:`cost`}),(0,S.jsx)(`div`,{className:`v num`,children:Ce(e.costUsd??Ga(e.phases))})]}),(0,S.jsxs)(`div`,{className:`stat`,children:[(0,S.jsx)(`div`,{className:`microlabel`,children:`tokens in / out`}),(0,S.jsxs)(`div`,{className:`v num`,children:[we(Wa(e.phases,`tokensIn`)),` / `,we(Wa(e.phases,`tokensOut`))]})]})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`phase timeline`}),(0,S.jsx)(`span`,{className:`spacer`}),t&&(0,S.jsxs)(`span`,{className:`live-note`,children:[(0,S.jsx)(`span`,{className:`lamp running`}),` live · polling`]})]}),(0,S.jsx)(`div`,{className:`phases`,children:e.phases.map(e=>(0,S.jsx)(Ka,{p:e},e.phase))})]})]})}function Wa(e,t){return e.reduce((e,n)=>e+(n[t]??0),0)}function Ga(e){return e.reduce((e,t)=>e+(t.costUsd??0),0)}function Ka({p:e}){let t=e.gates.filter(e=>!e.passed);return(0,S.jsxs)(`div`,{className:`phase-row`,children:[(0,S.jsx)(ke,{status:e.status}),(0,S.jsxs)(`div`,{className:`phase-top`,children:[(0,S.jsx)(`span`,{className:`phase-name`,children:e.phase}),e.kind===`agent`?(0,S.jsxs)(`span`,{className:`chip agent`,children:[e.agent,e.model?` · ${e.model}`:``,e.protocol?` · ${e.protocol}`:``]}):(0,S.jsx)(`span`,{className:`chip`,children:`script`}),e.status===`skipped`&&(0,S.jsx)(`span`,{className:`chip status skipped`,children:`skipped`}),(0,S.jsxs)(`span`,{className:`right num`,children:[e.attempts>1&&(0,S.jsxs)(`span`,{children:[`att `,e.attempts]}),e.status===`running`?(0,S.jsx)(Oe,{since:e.startedAt}):e.durationMs!=null&&(0,S.jsx)(`span`,{children:Se(e.durationMs)}),e.kind===`agent`&&e.tokensIn!=null&&(0,S.jsxs)(`span`,{children:[we(e.tokensIn),` / `,we(e.tokensOut)]}),e.costUsd!=null&&e.costUsd>0&&(0,S.jsx)(`span`,{children:Ce(e.costUsd)})]})]}),e.status===`running`&&e.lastActivity&&(0,S.jsx)(`div`,{className:`phase-activity`,children:e.lastActivity}),e.summary&&e.status!==`running`&&(0,S.jsx)(`div`,{className:`phase-sub`,children:e.summary}),e.gates.length>0&&(0,S.jsx)(`div`,{className:`gate-line`,children:e.gates.map(e=>(0,S.jsxs)(`span`,{className:`gate ${e.passed?``:`failed`}`,title:e.failure??``,children:[(0,S.jsx)(C,{name:e.passed?`check`:`close`,className:`ms-sm`}),` `,e.gate]},e.gate))}),t.map(e=>(0,S.jsx)(`div`,{className:`gate-fail-msg`,children:e.failure},e.gate))]})}var qa=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`]);function Ja(e){return e===`runner.json`||e.endsWith(`.jsonl`)||e.endsWith(`.log`)}function Ya(e){let t=[`report.html`,`recommendation.md`].find(t=>e.some(e=>e.name===t));if(t)return t;let n=e=>{let t=e.split(`.`).pop()?.toLowerCase()??``;return[`html`,`md`,`markdown`,`pdf`].includes(t)||qa.has(t)?0:Ja(e)?2:1},r=null;for(let t of e)(!r||n(t.name)<n(r.name))&&(r=t);return r?.name??null}function Xa({id:e,files:t,live:n}){let[r,i]=(0,v.useState)(null),a=z(),o=(0,v.useMemo)(()=>a?t:t.filter(e=>!Ja(e.name)),[t,a]);return(0,v.useEffect)(()=>{!a&&r&&Ja(r)&&i(null)},[a,r]),(0,v.useEffect)(()=>{r||o.length===0||i(Ya(o))},[o,r]),(0,S.jsxs)(`div`,{className:`art-layout`,children:[(0,S.jsxs)(`section`,{className:`panel art-files`,children:[(0,S.jsx)(`div`,{className:`panel-head`,children:(0,S.jsxs)(`span`,{className:`microlabel`,children:[`files `,(0,S.jsxs)(`span`,{className:`num`,children:[`(`,o.length,`)`]})]})}),(0,S.jsxs)(`div`,{className:`file-list`,children:[o.map(e=>(0,S.jsxs)(`button`,{className:`file-row ${r===e.name?`active`:``}`,onClick:()=>i(e.name),children:[(0,S.jsx)(`span`,{className:`fname`,children:e.name}),(0,S.jsx)(`span`,{className:`fsize num`,children:Te(e.size)})]},e.name)),o.length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:t.length>0?`no result files — raw run files live in expert mode`:`no files yet`})]})]}),(0,S.jsxs)(`section`,{className:`panel art-viewer`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:r??`viewer`}),(0,S.jsx)(`span`,{className:`spacer`}),r&&(0,S.jsx)(`a`,{className:`open-raw`,href:`/api/runs/${e}/file?name=${encodeURIComponent(r)}&raw=1`,target:`_blank`,children:`open raw ↗`})]}),r?(0,S.jsx)(Za,{id:e,name:r,live:n}):(0,S.jsx)(`div`,{className:`empty`,children:`select a file`})]})]})}function Za({id:e,name:t,live:n}){let r=t.split(`.`).pop()?.toLowerCase()??``,i=`/api/runs/${e}/file?name=${encodeURIComponent(t)}&raw=1`;return r===`html`?(0,S.jsx)(`div`,{className:`viewer`,children:(0,S.jsx)(`div`,{className:`viewer-body`,children:(0,S.jsx)(`iframe`,{src:i,sandbox:`allow-scripts`,allow:`clipboard-write`,title:t})})}):r===`pdf`?(0,S.jsx)(`div`,{className:`viewer`,children:(0,S.jsx)(`div`,{className:`viewer-body`,children:(0,S.jsx)(`iframe`,{src:i,title:t})})}):qa.has(r)?(0,S.jsx)(`div`,{className:`viewer`,children:(0,S.jsx)(`div`,{className:`viewer-body`,children:(0,S.jsx)(`img`,{src:i,alt:t})})}):r===`md`||r===`markdown`?(0,S.jsx)(Qa,{id:e,name:t,live:n}):(0,S.jsx)($a,{id:e,name:t,live:n})}function Qa({id:e,name:t,live:n}){let[r,i]=(0,v.useState)(`rendered`),a=H(`/api/runs/${e}/file?name=${encodeURIComponent(t)}`,n),o=(0,v.useMemo)(()=>a?Br.sanitize(W.parse(a.content,{async:!1})):``,[a?.content]);return(0,S.jsxs)(`div`,{className:`viewer`,children:[(0,S.jsxs)(`div`,{className:`viewer-note md-toolbar`,children:[(0,S.jsxs)(`div`,{className:`tabs`,children:[(0,S.jsx)(`button`,{className:r===`rendered`?`active`:``,onClick:()=>i(`rendered`),children:`rendered`}),(0,S.jsx)(`button`,{className:r===`source`?`active`:``,onClick:()=>i(`source`),children:`source`})]}),a?.truncated&&(0,S.jsxs)(`span`,{children:[`large file — showing the last `,Te(4e5)]})]}),(0,S.jsx)(`div`,{className:`viewer-body`,children:a?r===`rendered`?(0,S.jsx)(`div`,{className:`md-body`,dangerouslySetInnerHTML:{__html:o}}):(0,S.jsx)(`pre`,{children:a.content||`(empty)`}):(0,S.jsx)(`pre`,{children:`loading…`})})]})}function $a({id:e,name:t,live:n}){let r=H(`/api/runs/${e}/file?name=${encodeURIComponent(t)}`,n);return(0,S.jsxs)(`div`,{className:`viewer`,children:[r?.truncated&&(0,S.jsxs)(`div`,{className:`viewer-note`,children:[`large file — showing the last `,Te(4e5)]}),(0,S.jsx)(`div`,{className:`viewer-body`,children:(0,S.jsx)(`pre`,{children:r?r.content||`(empty)`:`loading…`})})]})}function eo(){return H(`/api/workflows/any/run`,!1,15e3)}var to=e=>!!e?.available&&!!e?.image;function no(e){return e?e.available?e.image?`isolated container per run`:"image missing — run `kraftwerk runner build`":`Docker is not running`:``}async function ro(e,t){let n=await fetch(`/api/workflows/${encodeURIComponent(e)}/run`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),r=await n.json();if(!n.ok)throw Error(r.error??`HTTP ${n.status}`);return r.runId}function io(e,t,n,r){let[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(!0),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),m=eo();(0,v.useEffect)(()=>{!i&&n&&a(n)},[n]),(0,v.useEffect)(()=>{m&&!to(m)&&s(!1)},[m]);let h=!u&&(!t||!!i.trim())&&(!o||to(m));async function g(){if(h){d(!0),p(null);try{let t=await ro(e,{request:i.trim(),sandbox:o,ssh:c});r?(r(t),d(!1)):N(`/runs/${t}`)}catch(e){p(e.message),d(!1)}}}return{request:i,setRequest:a,sandbox:o,setSandbox:s,ssh:c,setSsh:l,busy:u,error:f,docker:m,canRun:h,launch:g}}function ao({slug:e,usesRequest:t,initialRequest:n,onLaunched:r}){let i=io(e,t,n,r);return(0,S.jsxs)(`div`,{className:`run-launcher`,children:[(0,S.jsxs)(`div`,{className:`run-launcher-main`,children:[t?(0,S.jsxs)(`label`,{className:`m3-field`,children:[(0,S.jsx)(`input`,{type:`text`,value:i.request,placeholder:` `,"aria-label":`request`,onChange:e=>i.setRequest(e.target.value),onKeyDown:e=>e.key===`Enter`&&i.launch()}),(0,S.jsx)(`span`,{className:`m3-field-label`,children:`Request`})]}):(0,S.jsx)(`span`,{className:`run-norequest`,children:`This workflow takes no request.`}),(0,S.jsxs)(`button`,{className:`m3-filled-btn run-go`,onClick:i.launch,disabled:!i.canRun,children:[(0,S.jsx)(C,{name:`play_arrow`}),` `,i.busy?`Starting…`:`Run`]})]}),(0,S.jsxs)(`div`,{className:`m3-switches run-switches`,children:[(0,S.jsx)(q,{label:`Docker sandbox`,hint:no(i.docker),checked:i.sandbox,onChange:i.setSandbox}),i.sandbox&&(0,S.jsx)(q,{label:`Forward SSH agent`,hint:`keys and known hosts from this machine`,checked:i.ssh,onChange:i.setSsh})]}),i.error&&(0,S.jsx)(`div`,{className:`m3-error`,children:i.error})]})}function q({label:e,hint:t,checked:n,onChange:r}){return(0,S.jsxs)(`button`,{type:`button`,className:`m3-switch-row`,role:`switch`,"aria-checked":n,onClick:()=>r(!n),children:[(0,S.jsxs)(`span`,{className:`m3-switch-text`,children:[(0,S.jsx)(`span`,{className:`m3-switch-label`,children:e}),t&&(0,S.jsx)(`span`,{className:`m3-switch-hint`,children:t})]}),(0,S.jsx)(`span`,{className:`m3-switch ${n?`on`:``}`,"aria-hidden":!0,children:(0,S.jsx)(`span`,{className:`m3-switch-knob`})})]})}var J=`\0done`,oo=5;function so(e,t){return e.status===`ok`?J:e.currentPhase&&t.includes(e.currentPhase)?e.currentPhase:t[0]??J}function co({wf:e,runs:t,agentIdx:n,runsHref:r}){let i=e.steps.map(e=>e.name),a=new Map([...i,J].map(e=>[e,[]]));for(let e of t)a.get(so(e,i)).push(e);let o=a.get(J)??[];return(0,S.jsxs)(`div`,{className:`board`,children:[e.steps.map((e,t)=>{let i=e.agent?n.get(e.agent)??0:null,o=a.get(e.name)??[];return(0,S.jsxs)(`div`,{className:`board-col`,"data-step":e.name,children:[(0,S.jsxs)(`div`,{className:`board-col-head`,children:[(0,S.jsx)(`span`,{className:`step-index num ${i==null?`is-script`:`aid-${i}`}`,children:t+1}),(0,S.jsx)(`span`,{className:`board-col-name`,title:e.name,children:e.name}),(0,S.jsx)(`span`,{className:`board-col-count num`,children:o.length})]}),(0,S.jsx)(lo,{cards:o,moreHref:r})]},e.name)}),(0,S.jsxs)(`div`,{className:`board-col is-done`,"data-step":`done`,children:[(0,S.jsxs)(`div`,{className:`board-col-head`,children:[(0,S.jsx)(`span`,{className:`step-index`,children:`✓`}),(0,S.jsx)(`span`,{className:`board-col-name`,children:`done`}),(0,S.jsx)(`span`,{className:`board-col-count num`,children:o.length})]}),(0,S.jsx)(lo,{cards:o,moreHref:r})]})]})}function lo({cards:e,moreHref:t}){return(0,S.jsxs)(`div`,{className:`board-col-cards`,children:[e.slice(0,oo).map(e=>(0,S.jsx)(uo,{r:e},e.id)),e.length===0&&(0,S.jsx)(`div`,{className:`board-col-empty`,children:`—`}),e.length>oo&&(0,S.jsxs)(F,{href:t,className:`board-more`,children:[`+ `,e.length-oo,` more ↗`]})]})}function uo({r:e}){let t=e.request??e.id.replace(/^run-/,``);return(0,S.jsxs)(F,{href:`/runs/${e.id}`,className:`board-card is-${e.status}`,children:[(0,S.jsxs)(`div`,{className:`board-card-top`,children:[(0,S.jsx)(ke,{status:e.status}),(0,S.jsx)(`span`,{className:`board-card-title`,title:t,children:t})]}),(0,S.jsxs)(`div`,{className:`board-card-meta num`,children:[(0,S.jsx)(`span`,{children:Ee(e.startedAt)}),(0,S.jsx)(`span`,{children:e.status===`running`?(0,S.jsx)(Oe,{since:e.startedAt}):Se(e.durationMs)}),e.costUsd!=null&&e.costUsd>0&&(0,S.jsx)(`span`,{children:Ce(e.costUsd)})]}),e.awaitingDecision&&(0,S.jsx)(`span`,{className:`chip decision`,children:`decision needed`}),(e.status===`failed`||e.status===`aborted`)&&(0,S.jsx)(`span`,{className:`chip status ${e.status}`,children:e.status})]})}function fo({slug:e,tab:t}){let n=H(`/api/workflows/${encodeURIComponent(e)}`,!1),[r,i]=(0,v.useState)(0),[a,o]=(0,v.useState)(0),s=H(`/api/runs`,a>0||Date.now()-r<2e4);if(!n)return(0,S.jsx)(`div`,{className:`empty`,children:`loading…`});if(n.error)return(0,S.jsx)(S.Fragment,{children:(0,S.jsxs)(`div`,{className:`empty`,children:[(0,S.jsx)(`span`,{className:`status-word failed`,children:`broken workflow`}),(0,S.jsx)(`pre`,{style:{marginTop:12,textAlign:`left`},children:n.error})]})});let c=new Map(n.agents.map((e,t)=>[e.id,t%4])),l=(s?.runs??[]).filter(e=>e.workflow===n.name||e.workflow===n.slug),u=`/workflows/${encodeURIComponent(n.slug)}`,d=l.filter(e=>e.status===`running`).length;return d!==a&&o(d),(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`detail-head`,children:[(0,S.jsx)(`h1`,{children:n.name??n.slug}),(0,S.jsx)(`span`,{className:`rid mono`,children:n.dir}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`nav`,{className:`tabs`,"aria-label":`workflow sections`,children:[(0,S.jsx)(F,{href:u,className:t===`overview`?`active`:``,children:`overview`}),(0,S.jsx)(F,{href:`${u}/details`,className:t===`details`?`active`:``,children:`details`}),(0,S.jsxs)(F,{href:`${u}/runs`,className:t===`runs`?`active`:``,children:[`runs `,(0,S.jsxs)(`span`,{className:`num`,children:[`(`,l.length,`)`]})]})]})]}),n.description&&(0,S.jsx)(`p`,{className:`detail-req`,children:n.description}),t===`overview`&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`section`,{className:`panel run-panel`,style:{marginBottom:18},children:(0,S.jsx)(ao,{slug:n.slug,usesRequest:n.usesRequest,initialRequest:l[0]?.request,onLaunched:()=>i(Date.now())})}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsxs)(`span`,{className:`microlabel`,children:[`board`,` `,(0,S.jsxs)(`span`,{className:`num`,children:[`(`,l.length,` runs`,d>0?`, ${d} live`:``,`)`]})]}),(0,S.jsx)(`span`,{className:`spacer`}),l[0]&&(0,S.jsx)(F,{href:`${u}/runs`,className:`open-raw`,children:`all runs ↗`})]}),(0,S.jsx)(co,{wf:n,runs:l,agentIdx:c,runsHref:`${u}/runs`})]})]}),t===`details`&&(0,S.jsx)(po,{wf:n,agentIdx:c}),t===`runs`&&(0,S.jsx)(mo,{runs:l})]})}function po({wf:e,agentIdx:t}){return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`statgrid`,children:[(0,S.jsxs)(`div`,{className:`stat`,children:[(0,S.jsx)(`div`,{className:`microlabel`,children:`agents`}),(0,S.jsx)(`div`,{className:`v num`,children:e.agents.length})]}),(0,S.jsxs)(`div`,{className:`stat`,children:[(0,S.jsx)(`div`,{className:`microlabel`,children:`steps`}),(0,S.jsxs)(`div`,{className:`v num`,children:[e.steps.length,` `,(0,S.jsxs)(`span`,{style:{color:`var(--muted)`,fontWeight:400},children:[`(`,e.steps.filter(e=>e.kind===`agent`).length,` agent ·`,` `,e.steps.filter(e=>e.kind===`script`).length,` script)`]})]})]}),e.workspace&&(0,S.jsxs)(`div`,{className:`stat`,style:{maxWidth:420},children:[(0,S.jsx)(`div`,{className:`microlabel`,children:`workspace`}),(0,S.jsx)(`div`,{className:`wf-workspace mono`,children:e.workspace})]})]}),(0,S.jsxs)(`section`,{className:`panel`,style:{marginBottom:18},children:[(0,S.jsx)(`div`,{className:`panel-head`,children:(0,S.jsx)(`span`,{className:`microlabel`,children:`agents`})}),(0,S.jsxs)(`div`,{className:`agent-grid`,children:[e.agents.map(e=>(0,S.jsx)(ho,{a:e,idx:t.get(e.id)??0},e.id)),e.agents.length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no agents — script-only workflow`})]})]}),(0,S.jsxs)(`div`,{className:`columns`,children:[(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsx)(`div`,{className:`panel-head`,children:(0,S.jsx)(`span`,{className:`microlabel`,children:`pipeline`})}),(0,S.jsx)(`div`,{className:`pipeline`,children:e.steps.map((e,n)=>(0,S.jsx)(go,{s:e,i:n,idx:e.agent?t.get(e.agent)??0:null},e.name))})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsx)(`div`,{className:`panel-head`,children:(0,S.jsxs)(`span`,{className:`microlabel`,children:[`folder `,(0,S.jsxs)(`span`,{className:`num`,children:[`(`,e.files.length,` files)`]})]})}),(0,S.jsx)(`div`,{className:`file-list`,children:e.files.map(e=>(0,S.jsx)(`div`,{className:`file-row`,style:{cursor:`default`},children:(0,S.jsx)(`span`,{className:`fname`,children:e})},e))})]})]})]})}function mo({runs:e}){return e.length===0?(0,S.jsx)(`div`,{className:`empty`,children:`no runs of this workflow yet`}):(0,S.jsx)(`div`,{className:`run-list`,children:e.map(e=>{let t=e.phasesTotal??0,n=t>0?Math.round(e.phasesDone/t*100):e.status===`ok`?100:0;return(0,S.jsxs)(F,{href:`/runs/${e.id}`,className:`run-card is-${e.status}`,children:[(0,S.jsx)(ke,{status:e.status}),(0,S.jsx)(`span`,{className:`rid`,children:e.id.replace(/^run-/,``)}),(0,S.jsx)(`span`,{className:`req`,title:e.request,children:e.status===`running`&&e.currentPhase?e.currentPhase:e.request??``}),(0,S.jsxs)(`span`,{className:`meta`,children:[e.awaitingDecision&&(0,S.jsx)(`span`,{className:`chip decision`,children:`decision needed`}),(0,S.jsx)(Ae,{status:e.status}),(0,S.jsx)(`span`,{className:`progress-track`,title:`${e.phasesDone}${t?` / ${t}`:``} steps`,children:(0,S.jsx)(`i`,{style:{width:`${n}%`}})}),(0,S.jsx)(`span`,{className:`num`,children:e.status===`running`?(0,S.jsx)(Oe,{since:e.startedAt}):Se(e.durationMs)}),(0,S.jsx)(`span`,{className:`num`,children:Ce(e.costUsd)}),(0,S.jsx)(`span`,{className:`num`,children:Ee(e.startedAt)})]})]},e.id)})})}function ho({a:e,idx:t}){return(0,S.jsxs)(`div`,{className:`agent-card aid-${t}`,children:[(0,S.jsxs)(`div`,{className:`agent-head`,children:[(0,S.jsx)(`span`,{className:`agent-dot`}),(0,S.jsx)(`b`,{children:e.name??e.id}),(0,S.jsxs)(`code`,{className:`agent-id`,children:[`[`,e.id,`]`]}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`span`,{className:`chip`,children:[e.model??`default`,e.effort?` · ${e.effort}`:``,e.protocol===`acp`?` · acp`:``]})]}),e.tools.length>0&&(0,S.jsx)(`div`,{className:`agent-tools`,children:e.tools.map(e=>(0,S.jsx)(`span`,{className:`tool-chip`,children:e},e))}),e.persona&&(0,S.jsx)(`p`,{className:`agent-persona`,children:e.persona})]})}function go({s:e,i:t,idx:n}){let r=e.kind===`script`?e.script:e.prompt;return(0,S.jsxs)(`div`,{className:`step-node`,children:[(0,S.jsx)(`div`,{className:`step-index num ${n==null?`is-script`:`aid-${n}`}`,children:t+1}),(0,S.jsxs)(`div`,{className:`step-body`,children:[(0,S.jsxs)(`div`,{className:`phase-top`,children:[(0,S.jsx)(`span`,{className:`phase-name`,children:e.name}),e.kind===`agent`?(0,S.jsxs)(`span`,{className:`chip agent-chip aid-${n??0}`,children:[`agent · `,e.agent]}):(0,S.jsxs)(`span`,{className:`chip`,children:[`script`,e.sourceRef?` · ${e.sourceRef}`:``]})]}),r&&(0,S.jsxs)(`details`,{className:`step-source`,children:[(0,S.jsx)(`summary`,{children:e.kind===`agent`?`prompt`:`script`}),(0,S.jsx)(`pre`,{children:r})]}),e.gates.length>0&&(0,S.jsx)(`div`,{className:`gate-line`,children:e.gates.map(e=>(0,S.jsxs)(`span`,{className:`gate neutral`,children:[`⛨ `,e]},e))})]})]})}function _o(e,t){let n=e.filter(e=>e.workflow===(t.name??t.slug));return{count:n.length,last:n[0]}}function vo(e,t){return`/runs/${e.id}?workflow=${encodeURIComponent(t.name??t.slug)}`}function yo({slug:e,tab:t}){let n=H(`/api/workflows`,!1),r=H(`/api/runs`,!1),[i,a]=(0,v.useState)(``),o=n?.workflows??[],s=r?.runs??[],c=(0,v.useMemo)(()=>{let e=i.trim().toLowerCase();return e?o.filter(t=>[t.name,t.slug,t.description].some(t=>t?.toLowerCase().includes(e))):o},[o,i]),l=(0,v.useMemo)(()=>{if(o.length!==0)return(o.map(e=>({w:e,last:_o(s,e).last})).filter(e=>!!e.last).sort((e,t)=>(t.last.updatedAt??``).localeCompare(e.last.updatedAt??``))[0]?.w??o[0]).slug},[o,s]),u=!!r;return(0,v.useEffect)(()=>{!e&&l&&u&&N(`/workflows/${encodeURIComponent(l)}`,{replace:!0})},[e,l,u]),(0,S.jsxs)(`div`,{className:`runs-screen workflows-screen`,children:[(0,S.jsxs)(`aside`,{className:`runs-side`,children:[(0,S.jsxs)(`div`,{className:`side-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`workflows`}),n&&(0,S.jsx)(`span`,{className:`microlabel num`,children:o.length}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(F,{href:`/runs`,className:`open-raw`,title:`every run of every workflow, newest first`,children:[(0,S.jsx)(C,{name:`history`,className:`ms-sm`}),` runs `,(0,S.jsx)(`span`,{className:`num`,children:s.length})]})]}),o.length>0&&(0,S.jsxs)(`label`,{className:`side-filter`,children:[(0,S.jsx)(C,{name:`search`,className:`ms-sm`}),(0,S.jsx)(`input`,{type:`search`,value:i,placeholder:`search workflows`,"aria-label":`search workflows`,onChange:e=>a(e.target.value)})]}),(0,S.jsxs)(`div`,{className:`side-list`,children:[c.map(t=>{let n=_o(s,t);return(0,S.jsxs)(F,{href:`/workflows/${encodeURIComponent(t.slug)}`,className:`side-row wf-row${t.slug===e?` active`:``}`,children:[(0,S.jsx)(ke,{status:n.last?.status??`idle`}),(0,S.jsxs)(`div`,{className:`side-row-body`,children:[(0,S.jsxs)(`div`,{className:`side-row-top`,children:[(0,S.jsx)(`span`,{className:`side-wf`,children:t.name??t.slug}),t.error&&(0,S.jsx)(`span`,{className:`status-word failed`,children:`broken`}),n.last&&(0,S.jsx)(`span`,{className:`side-when num`,children:De(n.last.updatedAt)})]}),(0,S.jsxs)(`div`,{className:`side-row-sub`,children:[(0,S.jsx)(`span`,{className:`side-req`,title:t.error??t.description??``,children:t.error??t.description??`${t.agents} agents · ${t.steps} steps`}),n.last?(0,S.jsxs)(`button`,{type:`button`,className:`wf-runs num`,title:`show the runs of this workflow`,onClick:e=>{e.preventDefault(),e.stopPropagation(),N(vo(n.last,t))},children:[n.count,` `,n.count===1?`run`:`runs`,` · `,(0,S.jsx)(Ae,{status:n.last.status})]}):(0,S.jsx)(`span`,{className:`wf-runs none num`,children:`no runs yet`})]})]})]},t.slug)}),n&&o.length>0&&c.length===0&&(0,S.jsxs)(`div`,{className:`viewer-note wf-nomatch`,children:[`no workflow matches “`,i,`”`]}),n&&o.length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no workflows yet`})]})]}),(0,S.jsx)(`div`,{className:`runs-main`,children:e?(0,S.jsx)(fo,{slug:e,tab:t},e):n&&o.length===0?(0,S.jsxs)(`div`,{className:`empty`,children:[`No workflows found — expected `,(0,S.jsx)(`code`,{children:`src/workflows/`}),` or `,(0,S.jsx)(`code`,{children:`workflows/`}),` next to the output folder.`]}):(0,S.jsx)(`div`,{className:`empty`,children:`loading…`})})]})}var bo=e=>e===`ok`?`ok`:e===`running`?`running`:e===`aborted`?`aborted`:`failed`,xo=e=>e===`ok`?`done`:e===`running`?`working`:e===`aborted`?`stopped`:`failed`;function So(e){return e.scope.kind===`channel`?`/channels/${e.scope.slug}`:e.scope.kind===`project`?`/projects/${e.scope.slug}/chat/${e.id}`:e.scope.kind===`agent`?`/agents/${e.scope.slug}/chat/${e.id}`:`/agents/chats/${e.id}`}function Co(e){switch(e.scope.kind){case`agent`:return e.scope.slug;case`channel`:return`#${e.scope.slug}`;case`run`:return e.scope.runId;case`knowledge`:return e.scope.bundle?`knowledge:${e.scope.bundle}`:`knowledge`;case`kraftwerk`:return`kraftwerk-aware`;case`project`:return`project:${e.scope.slug}`;default:return`general`}}function wo(e){return e.length>64?`${e.slice(0,46)}…${e.slice(-14)}`:e}function To(){let e=H(`/api/runs`,!1),t=H(`/api/chats`,!1),n=H(`/api/knowledge`,!1),r=H(`/api/agents`,!1),i=H(`/api/workflows`,!1),a=H(`/api/skills`,!1),[o,s]=(0,v.useState)(`all`),c=e?.runs??[],l=t?.chats??[],u=n?.bundles??[],d=(a?.skills??[]).filter(e=>e.source===`workspace`),f=[[i?.workflows.length,`workflows`,`/workflows`],[e?c.length:void 0,`runs`,`/runs`],[n?u.length:void 0,`bundles`,`/knowledge`],[a?d.length:void 0,`skills`,`/skills`],[t?l.length:void 0,`chats`,`/agents/chats`]],p=c.filter(e=>e.status===`failed`&&Date.now()-Date.parse(e.updatedAt)<864e5);return(0,S.jsxs)(`div`,{className:`dash`,children:[(0,S.jsxs)(`div`,{className:`page-head dash-head`,children:[(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(`span`,{className:`dash-mini`,children:f.map(([e,t,n])=>(0,S.jsxs)(F,{href:n,children:[(0,S.jsx)(`b`,{className:`num`,children:e??`…`}),` `,t]},t))})]}),p.length>0&&o!==`failed`&&(0,S.jsxs)(`button`,{className:`dash-alert`,onClick:()=>s(`failed`),children:[`⚠ `,p.length,` run`,p.length===1?``:`s`,` failed in the last 24 h — review`]}),(0,S.jsx)(Oo,{runs:c,chats:l,bundles:u,agents:r?.agents??[],workflows:i?.workflows??[],filter:o,setFilter:s})]})}function Eo(e){if(e.lamp===`running`)return`now`;let t=new Date(e.at),n=new Date;if(t.toDateString()===n.toDateString())return`today`;let r=new Date(n);return r.setDate(r.getDate()-1),t.toDateString()===r.toDateString()?`yesterday`:`earlier`}var Do=[[`all`,`all`],[`run`,`runs`],[`session`,`chats`],[`knowledge`,`knowledge`]];function Oo({runs:e,chats:t,bundles:n,agents:r,workflows:i,filter:a,setFilter:o}){let s=z(),c=(0,v.useMemo)(()=>{let o=[],c=e=>e?i.find(t=>t.slug===e)?.name??e:void 0;for(let t of e)o.push({at:t.updatedAt,kind:`run`,emoji:`⚙️`,title:c(t.workflow)??t.id,sub:t.request??``,href:`/runs/${t.id}`,lamp:bo(t.status),status:xo(t.status)});for(let e of t){let t=e.scope.kind===`agent`?r.find(t=>e.scope.kind===`agent`&&t.slug===e.scope.slug):void 0;o.push({at:e.updatedAt,kind:`session`,emoji:t?t.emoji||`🤖`:`💬`,title:t?t.name:e.title||`new chat`,sub:t?`${e.title||`new chat`}${s?` · ${e.agent}`:``}`:s?`${e.agent} · ${Co(e)}`:Co(e),href:So(e),lamp:e.awaitingApproval?`blocked`:e.busy?`running`:`ok`,status:e.awaitingApproval?`needs approval`:e.busy?`working`:void 0})}for(let e of n)e.updatedAt&&o.push({at:e.updatedAt,kind:`knowledge`,emoji:`📚`,title:e.name,sub:`${e.concepts} concepts`,href:`/knowledge/${encodeURIComponent(e.name)}`,lamp:`ok`});return(a===`all`?o:a===`failed`?o.filter(e=>e.kind===`run`&&e.lamp===`failed`):o.filter(e=>e.kind===a)).sort((e,t)=>{let n=Number(t.lamp===`running`)-Number(e.lamp===`running`);return n===0?t.at.localeCompare(e.at):n}).slice(0,15)},[e,t,n,r,s,a]),l=``;return(0,S.jsxs)(`section`,{className:`panel dash-feed`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`activity`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`span`,{className:`dash-feed-filter`,children:[Do.map(([e,t])=>(0,S.jsx)(`button`,{className:`feed-chip ${a===e?`on`:``}`,onClick:()=>o(e),children:t},e)),a===`failed`&&(0,S.jsxs)(`button`,{className:`feed-chip on failed`,onClick:()=>o(`all`),children:[`failed `,(0,S.jsx)(C,{name:`close`,className:`ms-sm`})]})]})]}),c.length===0?(0,S.jsx)(`div`,{className:`viewer-note`,children:a===`all`?`nothing yet — run a workflow or start a session`:`nothing here for this filter`}):(0,S.jsx)(`div`,{className:`m3-list`,children:c.map(e=>{let t=Eo(e),n=t===l?null:t;return l=t,(0,S.jsxs)(`div`,{className:`feed-group`,children:[n&&(0,S.jsx)(`div`,{className:`feed-day microlabel`,children:n}),(0,S.jsxs)(F,{href:e.href,className:`m3-row m3-link`,children:[(0,S.jsxs)(`span`,{className:`agent-avatar`,children:[(0,S.jsx)(`span`,{"aria-hidden":!0,children:e.emoji}),e.lamp===`running`&&(0,S.jsx)(`span`,{className:`lamp running`})]}),(0,S.jsx)(`span`,{className:`chip dash-kind ${e.kind}`,children:e.kind===`session`?`chat`:e.kind}),(0,S.jsxs)(`span`,{className:`m3-body`,children:[(0,S.jsx)(`span`,{className:`m3-head`,children:wo(e.title)}),e.sub&&(0,S.jsx)(`span`,{className:`m3-sub`,children:wo(e.sub)})]}),e.status&&(0,S.jsx)(`span`,{className:`chip status ${e.lamp}`,children:e.status}),(0,S.jsx)(`span`,{className:`side-when num`,title:new Date(e.at).toLocaleString(),children:De(e.at)}),(0,S.jsx)(`span`,{className:`m3-chev`,children:(0,S.jsx)(C,{name:`chevron_right`})})]})]},`${e.kind}:${e.href}:${e.at}`)})})]})}var ko=`modulepreload`,Ao=function(e){return`/`+e},jo={},Mo=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Ao(t,n),t=s(t),t in jo)return;jo[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:ko,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},No=(0,v.lazy)(()=>Mo(()=>import(`./editor-DtVtHids.js`).then(e=>({default:e.DocEditor})),__vite__mapDeps([0,1,2,3,4,5,6]))),Po=()=>Mo(()=>import(`./editor-DtVtHids.js`),__vite__mapDeps([0,1,2,3,4,5,6]));function Fo({bundle:e,conceptId:t}){let n=H(`/api/knowledge`,!1),r=n?.bundles??[],i=e===`new`,a=r.reduce((e,t)=>!e||(t.updatedAt??``)>(e.updatedAt??``)?t:e,void 0);return(0,v.useEffect)(()=>{!e&&a&&N(`/knowledge/${encodeURIComponent(a.name)}`,{replace:!0})},[e,a?.name]),(0,S.jsxs)(`div`,{className:`runs-screen`,children:[(0,S.jsxs)(`aside`,{className:`runs-side`,children:[(0,S.jsxs)(`div`,{className:`side-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`bundles`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(F,{href:`/knowledge/new`,className:`open-raw`,children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` new`]})]}),(0,S.jsxs)(`div`,{className:`side-list`,children:[r.map(t=>(0,S.jsxs)(F,{href:`/knowledge/${encodeURIComponent(t.name)}`,className:`side-row ${t.name===e?`active`:``}`,children:[(0,S.jsx)(`span`,{className:`lamp ok`}),(0,S.jsxs)(`div`,{className:`side-row-body`,children:[(0,S.jsxs)(`div`,{className:`side-row-top`,children:[(0,S.jsx)(`span`,{className:`side-wf`,children:t.name}),(0,S.jsx)(`span`,{className:`side-when num`,children:t.concepts})]}),(0,S.jsx)(`div`,{className:`side-row-sub`,children:(0,S.jsxs)(`span`,{className:`side-req`,children:[t.okfVersion?`okf ${t.okfVersion}`:`okf`,t.updatedAt?` · ${t.updatedAt.slice(0,10)}`:``]})})]})]},t.name)),n&&r.length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no bundles yet`})]})]}),(0,S.jsx)(`div`,{className:`runs-main`,children:e&&!i?(0,S.jsx)(zo,{name:e,conceptId:t},e):i||n&&!a?(0,S.jsx)(Io,{}):(0,S.jsx)(`div`,{className:`empty`,children:`loading…`})})]})}function Io(){let[e,t]=(0,v.useState)(``),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(!1);async function o(){let t=e.trim();if(!t)return;a(!0),r(``);let n=await(await fetch(`/api/knowledge`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:t})})).json();a(!1),n.error?r(n.error):N(`/knowledge/${encodeURIComponent(t)}`)}return(0,S.jsxs)(`div`,{className:`empty empty-action`,children:[(0,S.jsxs)(`div`,{className:`know-newbundle`,children:[(0,S.jsx)(`input`,{value:e,placeholder:`bundle name, e.g. customer-support`,onChange:e=>t(e.target.value),onKeyDown:e=>e.key===`Enter`&&void o(),autoFocus:!0}),(0,S.jsx)(`button`,{className:`run-btn`,disabled:!e.trim()||i,onClick:o,children:i?`creating…`:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` new bundle`]})})]}),n&&(0,S.jsxs)(`div`,{className:`msg error`,children:[(0,S.jsx)(C,{name:`error`,className:`ms-sm`}),` `,n]})]})}function Lo({tier:e}){return(0,S.jsx)(`span`,{className:`chip trust ${e}`,children:e})}var Ro=`@activity`;function zo({name:e,conceptId:t}){let n=H(`/api/knowledge/${encodeURIComponent(e)}`,!1);if(!n)return(0,S.jsx)(`div`,{className:`empty`,children:`loading…`});if(`error`in n)return(0,S.jsx)(`div`,{className:`empty`,children:`bundle not found`});let r=t===Ro?`activity`:`pages`,i=n.concepts,a=r===`pages`?t&&i.some(e=>e.id===t)?t:i[0]?.id:void 0,o=`/knowledge/${encodeURIComponent(e)}`;return(0,S.jsxs)(`div`,{className:`agent-view`,children:[(0,S.jsxs)(`div`,{className:`page-head`,children:[(0,S.jsx)(`h1`,{children:e}),(0,S.jsxs)(`span`,{className:`count`,children:[i.length,` pages`]}),(0,S.jsxs)(`div`,{className:`tabs`,children:[(0,S.jsx)(F,{href:o,className:r===`pages`?`active`:``,children:`pages`}),(0,S.jsx)(F,{href:`${o}/${Ro}`,className:r===`activity`?`active`:``,children:`activity`})]}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`button`,{className:`open-raw`,onClick:()=>void pa(e),children:[(0,S.jsx)(C,{name:`picture_as_pdf`,className:`ms-sm`}),` export PDF`]}),(0,S.jsx)(`button`,{className:`run-btn`,onClick:()=>void mi(`claude`,{kind:`knowledge`,bundle:e}),children:`curate in chat`})]}),r===`activity`?n.log?(0,S.jsx)(Ho,{name:e,log:n.log}):(0,S.jsx)(`section`,{className:`panel`,children:(0,S.jsx)(`div`,{className:`viewer-note`,children:`no activity yet`})}):i.length===0?(0,S.jsx)(`section`,{className:`panel`,children:(0,S.jsxs)(`div`,{className:`viewer-note`,children:[`No pages yet — start a chat to author some, or write one with`,` `,(0,S.jsxs)(`code`,{children:[`kraftwerk knowledge put `,e,`/<path>`]}),`.`]})}):(0,S.jsxs)(`div`,{className:`wiki`,children:[(0,S.jsx)(`aside`,{className:`wiki-side`,children:(0,S.jsx)(Wo,{concepts:i,base:o,selected:a})}),(0,S.jsx)(`div`,{className:`wiki-main`,children:a&&(0,S.jsx)(Ko,{bundle:e,conceptId:a},a)})]})]})}function Bo(e){let t=[];for(let n of e.split(`
214
214
  `)){let e=n.match(/^##\s+(\d{4}-\d{2}-\d{2})/);if(e){t.push({date:e[1],entries:[]});continue}let r=n.match(/^[*-]\s+\*\*([^*]+)\*\*:\s*(.*)$/);r&&t.length>0&&t[t.length-1].entries.push({kind:r[1].toLowerCase(),text:r[2]})}return t.filter(e=>e.entries.length>0)}function Vo(e,t){let n=[],r=/\[([^\]]+)\]\(\/?([^)]+?)\.md\)/g,i=0,a;for(;a=r.exec(t);)a.index>i&&n.push(t.slice(i,a.index)),n.push((0,S.jsx)(F,{href:`/knowledge/${encodeURIComponent(e)}/${a[2].replace(/^\//,``)}`,children:a[1]},a.index)),i=a.index+a[0].length;return i<t.length&&n.push(t.slice(i)),n}function Ho({name:e,log:t}){let n=Bo(t),[r,i]=(0,v.useState)(!1);return(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`activity`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(`button`,{className:`open-raw`,onClick:()=>i(!r),children:r?`timeline`:`raw log`})]}),r||n.length===0?(0,S.jsx)(`div`,{className:`viewer-body`,children:(0,S.jsx)(`pre`,{children:t})}):(0,S.jsx)(`div`,{className:`know-log`,children:n.map(t=>(0,S.jsxs)(v.Fragment,{children:[(0,S.jsx)(`div`,{className:`m3-subhead num`,children:t.date}),t.entries.map((t,n)=>(0,S.jsxs)(`div`,{className:`know-log-row`,children:[(0,S.jsx)(`span`,{className:`chip log-kind log-${t.kind}`,children:t.kind}),(0,S.jsx)(`span`,{className:`know-log-text`,children:Vo(e,t.text)})]},n))]},t.date))})]})}function Uo(e){let t={name:``,path:``,folders:[],pages:[],total:0};for(let n of e){let e=n.id.split(`/`),r=t;r.total++;for(let t of e.slice(0,-1)){let e=r.folders.find(e=>e.name===t);e||(e={name:t,path:r.path?`${r.path}/${t}`:t,folders:[],pages:[],total:0},r.folders.push(e)),r=e,r.total++}r.pages.push(n)}let n=e=>{e.folders.sort((e,t)=>e.name.localeCompare(t.name)),e.pages.sort((e,t)=>e.title.localeCompare(t.title)),e.folders.forEach(n)};return n(t),t}function Wo({concepts:e,base:t,selected:n}){let r=(0,v.useMemo)(()=>Uo(e),[e]),[i,a]=(0,v.useState)(()=>new Set);return(0,v.useEffect)(()=>{n&&n.includes(`/`)&&a(e=>{let t=new Set(e),r=n.split(`/`).slice(0,-1);for(let e=1;e<=r.length;e++)t.delete(r.slice(0,e).join(`/`));return t.size===e.size?e:t})},[n]),(0,S.jsx)(Go,{folder:r,base:t,selected:n,closed:i,toggle:e=>a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})})}function Go({folder:e,base:t,selected:n,closed:r,toggle:i}){return(0,S.jsxs)(S.Fragment,{children:[e.pages.map(e=>(0,S.jsxs)(F,{href:`${t}/${e.id}`,className:`wiki-page ${e.id===n?`active`:``}`,title:`${e.id}.md`,children:[(0,S.jsx)(`span`,{className:`wiki-page-title`,children:e.title}),(e.stale||e.error)&&(0,S.jsx)(`span`,{className:`wiki-dot`,title:e.error??`stale`})]},e.id)),e.folders.map(e=>{let a=!r.has(e.path),o=!!n&&n.startsWith(`${e.path}/`);return(0,S.jsxs)(v.Fragment,{children:[(0,S.jsxs)(`button`,{type:`button`,className:`wiki-folder ${a?`open`:``} ${o&&!a?`holds`:``}`,onClick:()=>i(e.path),"aria-expanded":a,title:`${e.path}/`,children:[(0,S.jsx)(C,{name:`chevron_right`,className:`ms-sm wiki-folder-chev`}),(0,S.jsx)(`span`,{className:`wiki-folder-name`,children:e.name}),(0,S.jsx)(`span`,{className:`wiki-folder-count num`,children:e.total})]}),a&&(0,S.jsx)(`div`,{className:`wiki-branch`,children:(0,S.jsx)(Go,{folder:e,base:t,selected:n,closed:r,toggle:i})})]},e.path)})]})}function Ko({bundle:e,conceptId:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(`document`),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(null),[y,b]=(0,v.useState)(`saved`),[x,w]=(0,v.useState)(``),T=(0,v.useRef)(``),E=(0,v.useRef)(null),D=(0,v.useRef)(!1),O=(0,v.useRef)(null),k=(0,v.useRef)(null),A=(0,v.useRef)(null),ee=`/api/knowledge/${encodeURIComponent(e)}/concept?id=${encodeURIComponent(t)}`,j=()=>{fetch(ee).then(e=>e.ok?e.json():Promise.reject()).then(r).catch(()=>a(!0))};(0,v.useEffect)(()=>{if(c===`markdown`)return;let e=!0,t,n=async()=>{try{let t=await fetch(ee,{cache:`no-store`});if(t.ok){let n=await t.json();e&&(a(!1),r(e=>JSON.stringify(e)===JSON.stringify(n)?e:n))}else t.status===404&&e&&a(!0)}catch{}e&&(t=setTimeout(n,6e3))};return n(),()=>{e=!1,clearTimeout(t)}},[ee,c]),(0,v.useEffect)(()=>{if(!n||n.raw===E.current||O.current!==null||A.current)return;let e=!0;return Po().then(({splitFrontmatter:t,unwrapParagraphs:r})=>{if(!e)return;let{head:i,body:a}=t(n.raw);T.current=i,E.current=n.raw,D.current=!1,_(e=>({key:(e?.key??0)+1,body:r(a)}))}),()=>{e=!1}},[n]);async function M(){A.current&&await A.current;let n=O.current;if(n===null)return;O.current=null,b(`saving`);let i=(async()=>{try{let i=T.current,a=i?`${i}${i.endsWith(`
215
215
  `)?``:`
216
216
  `}${n.replace(/^\n+/,`