@netnodeag/kraftwerk 0.56.1 → 0.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/inspector/agents.d.ts +4 -1
- package/dist/inspector/agents.js +4 -1
- package/dist/inspector/chat/sessions.d.ts +10 -0
- package/dist/inspector/chat/sessions.js +32 -1
- package/inspector/dist/assets/{dist-CXBK9Pdj.js → dist-BcS1Njyq.js} +1 -1
- package/inspector/dist/assets/{dist-B2tmzGgq.js → dist-BrUShpLH.js} +1 -1
- package/inspector/dist/assets/dist-CGWAF7Tk.js +1 -0
- package/inspector/dist/assets/{dist-Cqn44l76.js → dist-CTas0XD2.js} +1 -1
- package/inspector/dist/assets/{dist-DaSKRcSv.js → dist-CxfEyWP7.js} +1 -1
- package/inspector/dist/assets/{dist-BVp49Nrd.js → dist-DCqNJSEI.js} +1 -1
- package/inspector/dist/assets/{dist-CnYaAWXA.js → dist-DdhI0zj1.js} +1 -1
- package/inspector/dist/assets/{dist-CW4ZUSA0.js → dist-DdoRy57n.js} +1 -1
- package/inspector/dist/assets/{dist-CNeu-4yQ.js → dist-DlQ7TKno.js} +1 -1
- package/inspector/dist/assets/{dist-B-CznTlk.js → dist-TS_oRzHj.js} +1 -1
- package/inspector/dist/assets/{dist-Bic1t6cR.js → dist-w_-v1fMw.js} +1 -1
- package/inspector/dist/assets/{editor-DMHihW2Y.js → editor-CHv_lIkP.js} +3 -3
- package/inspector/dist/assets/{index-wVIiNEJQ.js → index-0D7irZ4E.js} +5 -5
- package/inspector/dist/index.html +1 -1
- package/package.json +1 -1
- package/inspector/dist/assets/dist-DUfudLK-.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor-CHv_lIkP.js","assets/dist-H3rerbMg.js","assets/dist-BcS1Njyq.js","assets/dist-DCqNJSEI.js","assets/dist-DdhI0zj1.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 j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function ee(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===``?`.`+j(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+j(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+j(a,u++),c+=M(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return M(ee(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 N(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 P(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 F=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)},I={map:N,forEach:function(e,t,n){N(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return N(e,function(){t++}),t},toArray:function(e){return N(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=I,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:P}},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,F)}catch(e){F(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&&j(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&&j(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 j(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,j(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`),j=Symbol.iterator;function ee(e){return typeof e!=`object`||!e?null:(e=j&&e[j]||e[`@@iterator`],typeof e==`function`?e:null)}var M=Symbol.for(`react.client.reference`);function N(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?N(e.type)||`Memo`:t;case O:t=e._payload,e=e._init;try{return N(e(t))}catch{}}return null}var P=Array.isArray,F=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te={pending:!1,data:null,method:null,action:null},L=[],ne=-1;function re(e){return{current:e}}function R(e){0>ne||(e.current=L[ne],L[ne]=null,ne--)}function z(e,t){ne++,L[ne]=e.current,e.current=t}var B=re(null),ie=re(null),ae=re(null),oe=re(null);function se(e,t){switch(z(ae,t),z(ie,e),z(B,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}}R(B),z(B,e)}function V(){R(B),R(ie),R(ae)}function ce(e){e.memoizedState!==null&&z(oe,e);var t=B.current,n=Hd(t,e.type);t!==n&&(z(ie,e),z(B,n))}function H(e){ie.current===e&&(R(B),R(ie)),oe.current===e&&(R(oe),Qf._currentValue=te)}var le,ue;function de(e){if(le===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);le=t&&t[1]||``,ue=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+le+e+ue}var fe=!1;function pe(e,t){if(!e||fe)return``;fe=!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(`
|
|
@@ -202,15 +202,15 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
202
202
|
<script>setTimeout(() => window.print(), 400);<\/script>
|
|
203
203
|
</body>
|
|
204
204
|
</html>`;n.location.href=URL.createObjectURL(new Blob([p],{type:`text/html`}))}function pa(e,t){return e.split(/(```[\s\S]*?```|`[^`]*`)/).map((e,n)=>n%2==1?e:e.replace(/\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/g,(e,n,r)=>{let i=n.trim().replace(/\.md$/,``),a=(r??i).trim();return t===null?a:`[${a}](#/knowledge/${encodeURIComponent(t)}/${i})`})).join(``)}function ma(e){let t=[];return{md:e.replace(/^\[\^([^\]]+)\]:[ \t]*(.+)$/gm,(e,n,r)=>(t.push({id:n,text:r.trim()}),``)).replace(/\[\^([^\]]+)\]/g,(e,n)=>{let r=t.findIndex(e=>e.id===n);return r>=0?`<sup class="fnref">${r+1}</sup>`:``}),notes:t}}function ha(e,t){let n=new DOMParser().parseFromString(e,`text/html`),r=t.title,i=n.body.firstElementChild;t.titleIsFallback&&i?.tagName===`H1`&&(r=i.textContent?.trim()||r,i.remove());let a=n.createElement(`header`);a.innerHTML=`<h1>${ga(r)}</h1><div class="meta">${ga(t.meta)}</div>`,n.body.prepend(a);for(let e of n.querySelectorAll(`table`)){e.classList.add(`md`);for(let t of e.querySelectorAll(`th, td`))(t.textContent??``).trim().length<=14&&t.classList.add(`nw`)}for(let e of[5,4,3,2,1])for(let t of Array.from(n.body.querySelectorAll(`:scope > h${e}`))){let r=n.createElement(`h${e+1}`);r.innerHTML=t.innerHTML,t.replaceWith(r)}for(let e of Array.from(n.body.querySelectorAll(`:scope > header, :scope > h2, :scope > h3, :scope > h4`))){let t=e.nextElementSibling;if(!t||/^H[1-6]$/.test(t.tagName))continue;let r=n.createElement(`div`);r.className=`keep`,e.replaceWith(r),r.append(e,t)}return{html:n.body.innerHTML,title:r}}function ga(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}var _a=[``,`low`,`medium`,`high`,`xhigh`,`max`],va=[`🤖`,`🧑💻`,`🎧`,`🛠️`,`📊`,`✍️`,`🔍`,`🧹`,`📦`,`🚀`];function ya({seg:e}){let t=e[0]&&e[0]!==`new`&&e[0]!==`chats`?decodeURIComponent(e[0]):void 0,n=e[0]===`new`?`new`:e[0]===`chats`?`chats`:e[1]===`edit`?`edit`:e[1]===`info`?`info`:e[1]===`chat`?`chat`:t?`agent`:`home`,r=n===`chats`&&e[1]===`new`,i=n===`chat`?e[2]:n===`chats`&&!r?e[1]:void 0,a=U(`/api/agents`,!1),o=B(),s=Li(),[c,l]=(0,v.useState)(()=>{try{let e=JSON.parse(localStorage.getItem(`kw-agent-groups`)??`[]`);return Array.isArray(e)?e.map(String):[]}catch{return[]}}),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(null),[x,w]=(0,v.useState)(null),[T,E]=(0,v.useState)({}),D=(a?.agents??[]).map(e=>T[e.slug]===void 0?e:{...e,group:T[e.slug]||void 0});(0,v.useEffect)(()=>{E(e=>{let t={...e},n=!1;for(let e of a?.agents??[])t[e.slug]!==void 0&&(e.group??``)===t[e.slug]&&(delete t[e.slug],n=!0);return n?t:e})},[a]);let O=D.filter(e=>!e.archived),k=D.filter(e=>e.archived),[A,j]=(0,v.useState)(!1),ee=[...new Set([...O.map(e=>e.group??``).filter(Boolean),...c])].sort((e,t)=>e.localeCompare(t)),M=O.filter(e=>!e.group);function N(e){l(e);try{localStorage.setItem(`kw-agent-groups`,JSON.stringify(e))}catch{}}function P(){let e=f.trim();d(!1),p(``),e&&!ee.includes(e)&&N([...c,e])}function F(e,t){h(null);let n=t.trim();if(n&&n!==e){for(let t of D.filter(t=>t.group===e))I(t.slug,n);c.includes(e)&&N([...new Set(c.map(t=>t===e?n:t))])}}async function I(e,t){if((D.find(t=>t.slug===e)?.group??``)!==t){E(n=>({...n,[e]:t}));try{let n=await fetch(`/api/agents/${encodeURIComponent(e)}`);if(!n.ok)throw Error();let r=await n.json();if(!(await fetch(`/api/agents/${encodeURIComponent(e)}`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({...r,group:t||void 0})})).ok)throw Error()}catch{E(t=>{let n={...t};return delete n[e],n})}}}let te=e=>o?{onDragOver:t=>{y!=null&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,x!==e&&w(e))},onDrop:t=>{t.preventDefault();let n=t.dataTransfer.getData(`text/plain`)||y;n&&I(n,e),b(null),w(null)}}:{},ne=e=>(0,S.jsxs)(L,{href:`/agents/${encodeURIComponent(e.slug)}`,className:`side-row ${e.slug===t?`active`:``} ${y===e.slug?`dragging`:``}`,draggable:o,onDragStart:t=>{t.dataTransfer.setData(`text/plain`,e.slug),t.dataTransfer.effectAllowed=`move`,b(e.slug)},onDragEnd:()=>{b(null),w(null)},children:[(0,S.jsx)(`span`,{className:`agent-avatar sm`,children:(0,S.jsx)(`span`,{"aria-hidden":!0,children:e.emoji})}),(0,S.jsxs)(`div`,{className:`side-row-body`,children:[(0,S.jsx)(`div`,{className:`side-row-top`,children:(0,S.jsx)(`span`,{className:`side-wf`,children:e.name})}),(0,S.jsx)(`div`,{className:`side-row-sub`,children:(0,S.jsx)(`span`,{className:`side-req`,children:e.description||e.harness})})]})]},e.slug),re=e=>(0,S.jsxs)(L,{href:`/agents/${encodeURIComponent(e.slug)}/info`,className:`side-row archived-row ${e.slug===t?`active`:``}`,children:[(0,S.jsx)(`span`,{className:`agent-avatar sm`,children:(0,S.jsx)(`span`,{"aria-hidden":!0,children:e.emoji})}),(0,S.jsxs)(`div`,{className:`side-row-body`,children:[(0,S.jsx)(`div`,{className:`side-row-top`,children:(0,S.jsx)(`span`,{className:`side-wf`,children:e.name})}),(0,S.jsx)(`div`,{className:`side-row-sub`,children:(0,S.jsx)(`span`,{className:`side-req`,children:e.description||e.harness})})]})]},e.slug),R;R=n===`new`?(0,S.jsx)(Fa,{},`new`):n===`edit`&&t?(0,S.jsx)(Fa,{slug:t},t):n===`chat`&&t&&i===`new`?(0,S.jsx)(Ca,{slug:t,name:D.find(e=>e.slug===t)?.name},t):n===`chat`&&t&&i?(0,S.jsx)(`div`,{className:`chat-main`,children:(0,S.jsx)(yi,{id:i,agentName:D.find(e=>e.slug===t)?.name??t,agentDescription:D.find(e=>e.slug===t)?.description},i)}):n===`chats`?i?(0,S.jsx)(`div`,{className:`chat-main`,children:(0,S.jsx)(yi,{id:i},i)}):r?(0,S.jsx)(mi,{}):(0,S.jsx)(wa,{}):n===`info`&&t?(0,S.jsx)(ja,{slug:t},t):t?(0,S.jsx)(Sa,{slug:t,name:D.find(e=>e.slug===t)?.name},t):a?O.length?(0,S.jsx)(ka,{agents:O}):(0,S.jsx)(Aa,{}):(0,S.jsx)(`div`,{className:`empty`,children:`loading…`});let z=(n===`agent`||n===`info`||n===`chat`)&&t?D.find(e=>e.slug===t)?.knowledge??[]:[],[ie,ae]=(0,v.useState)(()=>localStorage.getItem(`kw-kside`)!==`hidden`),[oe,se]=(0,v.useState)(()=>Number(localStorage.getItem(`kw-kside-w`))||460),V=z.length>0&&ie;function ce(e){ae(e),localStorage.setItem(`kw-kside`,e?`open`:`hidden`)}function H(e){se(e),localStorage.setItem(`kw-kside-w`,String(e))}return(0,S.jsxs)(`div`,{className:`runs-screen agents-screen ${t||n===`chats`?`has-tabs`:``} ${(t||n===`chats`)&&s?`has-sessions`:``} ${V?`has-knowledge`:``}`,style:V?{"--kside-w":`${oe}px`}:void 0,children:[(0,S.jsxs)(`aside`,{className:`runs-side`,children:[(0,S.jsxs)(`div`,{className:`side-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`agents`}),(0,S.jsx)(`span`,{className:`spacer`}),o&&(0,S.jsxs)(L,{href:`/agents/new`,className:`open-raw`,children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` new`]})]}),(0,S.jsxs)(`div`,{className:`side-list`,children:[(0,S.jsxs)(L,{href:`/agents/chats`,className:`side-row side-general ${n===`chats`?`active`:``}`,children:[(0,S.jsx)(`span`,{className:`agent-avatar sm`,children:(0,S.jsx)(`span`,{"aria-hidden":!0,children:`🎩`})}),(0,S.jsxs)(`div`,{className:`side-row-body`,children:[(0,S.jsx)(`div`,{className:`side-row-top`,children:(0,S.jsx)(`span`,{className:`side-wf`,children:`Ralv`})}),(0,S.jsx)(`div`,{className:`side-row-sub`,children:(0,S.jsx)(`span`,{className:`side-req`,children:`chief of staff of the workspace`})})]})]}),(0,S.jsxs)(`div`,{className:`side-group ${y&&x===``?`drop-over`:``}`,...te(``),children:[M.map(ne),y!=null&&M.length===0&&(0,S.jsx)(`div`,{className:`side-group-empty`,children:`no group — drop here`})]}),ee.map(e=>{let t=O.filter(t=>t.group===e);return(0,S.jsxs)(`div`,{className:`side-group ${y&&x===e?`drop-over`:``}`,...te(e),children:[(0,S.jsxs)(`div`,{className:`side-group-head`,children:[m===e?(0,S.jsx)(`input`,{className:`side-group-rename`,autoFocus:!0,value:g,onChange:e=>_(e.target.value),onKeyDown:t=>{t.key===`Enter`&&F(e,g),t.key===`Escape`&&h(null)},onBlur:()=>F(e,g)}):(0,S.jsx)(`span`,{className:`microlabel`,children:e}),(0,S.jsx)(`span`,{className:`side-group-count num`,children:t.length}),(0,S.jsx)(`span`,{className:`spacer`}),o&&m!==e&&(0,S.jsx)(`button`,{className:`side-group-x`,title:`Rename group`,onClick:()=>{h(e),_(e)},children:(0,S.jsx)(C,{name:`edit`,className:`ms-sm`})}),o&&t.length===0&&c.includes(e)&&(0,S.jsx)(`button`,{className:`side-group-x`,title:`Remove empty group`,onClick:()=>N(c.filter(t=>t!==e)),children:(0,S.jsx)(C,{name:`close`,className:`ms-sm`})})]}),t.map(ne),t.length===0&&(0,S.jsx)(`div`,{className:`side-group-empty`,children:o?`drag agents here`:`no agents`})]},e)}),k.length>0&&(0,S.jsxs)(`div`,{className:`side-group side-archived`,children:[(0,S.jsxs)(`button`,{className:`side-archived-toggle`,"aria-expanded":A,onClick:()=>j(e=>!e),children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`archived`}),(0,S.jsx)(`span`,{className:`side-group-count num`,children:k.length}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(C,{name:A?`expand_less`:`expand_more`,className:`ms-sm`})]}),A&&k.map(re)]}),a&&D.length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no agents yet`}),o&&(u?(0,S.jsx)(`div`,{className:`side-group-new`,children:(0,S.jsx)(`input`,{autoFocus:!0,value:f,placeholder:`group name, e.g. Team Content`,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&P(),e.key===`Escape`&&(d(!1),p(``))},onBlur:P})}):(0,S.jsxs)(`button`,{className:`side-group-add`,onClick:()=>d(!0),children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` group`]}))]})]}),t&&(0,S.jsx)(Ta,{slug:t,chatId:i===`new`?void 0:i}),n===`chats`&&(0,S.jsx)(Oa,{chatId:i}),(0,S.jsx)(`div`,{className:`runs-main`,children:R}),V&&(0,S.jsx)(ba,{bundles:z,onHide:()=>ce(!1),onResize:H}),z.length>0&&!ie&&(0,S.jsxs)(`button`,{className:`kside-reopen`,onClick:()=>ce(!0),title:`Show knowledge sidebar`,children:[(0,S.jsx)(C,{name:`menu_book`,className:`ms-sm`}),` knowledge`]})]})}function ba({bundles:e,onHide:t,onResize:n}){let[r,i]=(0,v.useState)({}),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)({}),[l,u]=(0,v.useState)({}),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(``);(0,v.useEffect)(()=>{i({});let t=!0,n,r=async()=>{await Promise.all(e.map(async e=>{try{let n=await fetch(`/api/knowledge/${encodeURIComponent(e)}`,{cache:`no-store`}),r=n.ok?await n.json():null;t&&i(t=>JSON.stringify(t[e])===JSON.stringify(r)?t:{...t,[e]:r})}catch{t&&i(t=>e in t?t:{...t,[e]:null})}})),t&&(n=setTimeout(r,6e3))};return r(),()=>{t=!1,clearTimeout(n)}},[e.join(`,`)]),(0,v.useEffect)(()=>{if(!a||d===a)return;let e=a.indexOf(`::`),t=a.slice(0,e),n=a.slice(e+2),r=!0,i,o=async()=>{try{let e=await fetch(`/api/knowledge/${encodeURIComponent(t)}/concept?id=${encodeURIComponent(n)}`,{cache:`no-store`}),i=e.ok?await e.json():null;r&&c(e=>JSON.stringify(e[a])===JSON.stringify(i)?e:{...e,[a]:i})}catch{r&&c(e=>a in e?e:{...e,[a]:null})}r&&(i=setTimeout(o,6e3))};return o(),()=>{r=!1,clearTimeout(i)}},[a,d]);function b(e,t){let n=`${e}::${t}`;o(a===n?null:n)}async function x(e,t){let n=`${e}::${t}`;g(!0),y(``);try{let r=await(await fetch(`/api/knowledge/${encodeURIComponent(e)}/concept`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:t,content:p})})).json();r.error?y(r.error):(c(e=>({...e,[n]:r})),f(null))}catch(e){y(e.message)}g(!1)}return(0,S.jsxs)(`aside`,{className:`runs-side knowledge-side`,children:[(0,S.jsx)(`div`,{className:`kside-resizer`,title:`Drag to resize`,onMouseDown:e=>{e.preventDefault();let t=e.clientX,r=e.currentTarget.parentElement.offsetWidth,i=e=>n(Math.min(900,Math.max(280,r+(t-e.clientX)))),a=()=>{window.removeEventListener(`mousemove`,i),window.removeEventListener(`mouseup`,a)};window.addEventListener(`mousemove`,i),window.addEventListener(`mouseup`,a)}}),(0,S.jsxs)(`div`,{className:`side-head`,children:[(0,S.jsxs)(`span`,{className:`kside-headline`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`knowledge`}),(0,S.jsx)(`span`,{className:`kside-hint`,children:`read & kept current by this agent`})]}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`button`,{className:`open-raw`,onClick:t,title:`Hide knowledge sidebar`,children:[`hide `,(0,S.jsx)(C,{name:`close`,className:`ms-sm`})]})]}),(0,S.jsx)(`div`,{className:`side-list`,children:e.map(e=>{let t=r[e],n=l[e]===!0;return(0,S.jsxs)(`div`,{className:`kside-bundle`,children:[(0,S.jsxs)(`div`,{className:`kside-bundle-head`,children:[(0,S.jsxs)(`button`,{className:`kside-bundle-toggle`,"aria-expanded":!n,onClick:()=>u({...l,[e]:!n}),children:[(0,S.jsx)(`span`,{className:`kside-chev ${n?``:`open`}`,"aria-hidden":!0,children:(0,S.jsx)(C,{name:`chevron_right`,className:`ms-sm`})}),(0,S.jsx)(`span`,{className:`kside-bundle-name`,children:e}),t&&(0,S.jsx)(`span`,{className:`kside-count num`,children:t.concepts.length})]}),(0,S.jsx)(`button`,{className:`kside-open`,title:`Export this bundle as PDF`,onClick:()=>void fa(e),children:(0,S.jsx)(C,{name:`picture_as_pdf`,className:`ms-sm`})}),(0,S.jsx)(L,{href:`/knowledge/${encodeURIComponent(e)}`,className:`kside-open`,title:`Open this bundle on the knowledge screen`,children:`↗`})]}),!n&&t===null&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`bundle not found`}),!n&&t?.concepts.map(t=>{let n=`${e}::${t.id}`,r=a===n,i=`/knowledge/${encodeURIComponent(e)}/${t.id.split(`/`).map(encodeURIComponent).join(`/`)}`;return(0,S.jsxs)(`div`,{className:`kside-concept ${r?`open`:``}`,children:[(0,S.jsxs)(`button`,{className:`kside-row`,"aria-expanded":r,title:t.description||void 0,onClick:()=>b(e,t.id),children:[(0,S.jsx)(`span`,{className:`kside-chev ${r?`open`:``}`,"aria-hidden":!0,children:(0,S.jsx)(C,{name:`chevron_right`,className:`ms-sm`})}),(0,S.jsx)(`span`,{className:`kside-title`,children:t.title||t.id}),t.stale&&(0,S.jsx)(`span`,{className:`kside-stale`,title:`Past its stale-after date — ask the agent to re-verify it`,children:`stale`})]}),r&&(0,S.jsx)(`div`,{className:`kside-card`,ref:e=>e?.scrollIntoView({block:`nearest`}),children:s[n]===void 0?(0,S.jsx)(`div`,{className:`viewer-note`,children:`loading…`}):s[n]===null?(0,S.jsx)(`div`,{className:`viewer-note`,children:`could not load concept`}):d===n?(0,S.jsxs)(`div`,{className:`kside-edit`,children:[(0,S.jsx)(`textarea`,{className:`concept-edit`,value:p,rows:Math.min(28,Math.max(10,p.split(`
|
|
205
|
-
`).length+2)),onChange:e=>m(e.target.value),spellCheck:!1}),(0,S.jsxs)(`div`,{className:`kside-actions`,children:[(0,S.jsx)(`button`,{className:`open-raw`,disabled:h,onClick:()=>f(null),children:`cancel`}),(0,S.jsx)(`button`,{className:`open-raw`,disabled:h,onClick:()=>x(e,t.id),children:h?`saving…`:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(C,{name:`check`,className:`ms-sm`}),` save`]})})]}),_&&(0,S.jsxs)(`div`,{className:`msg error`,children:[(0,S.jsx)(C,{name:`error`,className:`ms-sm`}),` `,_]})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`kside-card-bar`,children:[t.type&&(0,S.jsx)(`span`,{className:`kside-type`,children:t.type}),xa(t)&&(0,S.jsxs)(`span`,{className:`kside-updated num`,children:[`updated `,Te(xa(t))]}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`button`,{className:`open-raw`,onClick:()=>{m(s[n].raw),f(n),y(``)},children:[(0,S.jsx)(C,{name:`edit`,className:`ms-sm`}),` edit`]}),(0,S.jsxs)(L,{href:`/knowledge/${encodeURIComponent(e)}/${t.id}`,className:`open-raw`,title:`The page in the knowledge section`,children:[(0,S.jsx)(C,{name:`open_in_new`,className:`ms-sm`}),` page`]}),(0,S.jsx)(L,{href:i,className:`open-raw`,children:`open ↗`})]}),(0,S.jsx)(`div`,{className:`kside-md md-body`,dangerouslySetInnerHTML:{__html:zr.sanitize(G.parse(s[n].body??``,{async:!1}))}})]})})]},t.id)}),!n&&t&&t.concepts.length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no concepts yet`})]},e)})})]})}function xa(e){return[e.generated?.at,...e.verified.map(e=>e.at)].filter(e=>typeof e==`string`&&e.length>0).sort().pop()}function Sa({slug:e,name:t}){let[n,r]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let t=!0;return r(!1),fetch(`/api/chats`).then(e=>e.json()).then(n=>{if(!t)return;let i=n.chats.find(t=>t.scope.kind===`agent`&&t.scope.slug===e);i?F(`/agents/${encodeURIComponent(e)}/chat/${i.id}`,{replace:!0}):r(!0)}).catch(()=>t&&r(!0)),()=>{t=!1}},[e]),n?(0,S.jsx)(Ca,{slug:e,name:t}):(0,S.jsx)(`div`,{className:`empty`,children:`loading…`})}function Ca({slug:e,name:t}){let[n,r]=(0,v.useState)(!1);return(0,S.jsxs)(`div`,{className:`new-chat`,children:[(0,S.jsx)(`div`,{className:`page-head`,children:(0,S.jsxs)(`h1`,{children:[`new session with `,t??e]})}),(0,S.jsx)(`section`,{className:`panel new-chat-panel`,children:(0,S.jsx)(`div`,{className:`agent-pick`,children:(0,S.jsxs)(`button`,{className:`agent-pick-btn active`,disabled:n,onClick:async()=>{r(!0),await pi(`claude`,{kind:`agent`,slug:e}),r(!1)},children:[(0,S.jsx)(`b`,{children:n?`starting…`:`start session`}),(0,S.jsx)(`span`,{children:`on the agent's harness, with its role, knowledge and skills`})]})})})]})}function wa(){let[e,t]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let e=!0;return fetch(`/api/chats`).then(e=>e.json()).then(n=>{if(!e)return;let r=n.chats.find(e=>e.scope.kind!==`agent`&&e.scope.kind!==`channel`&&e.scope.kind!==`project`);r?F(`/agents/chats/${r.id}`,{replace:!0}):t(!0)}).catch(()=>e&&t(!0)),()=>{e=!1}},[]),e?(0,S.jsx)(mi,{}):(0,S.jsx)(`div`,{className:`empty`,children:`loading…`})}function Ta({slug:e,chatId:t}){let[n,r]=(0,v.useState)(!1),i=(0,v.useCallback)(t=>t.filter(t=>t.scope.kind===`agent`&&t.scope.slug===e),[e]),a=(0,v.useCallback)(t=>`/agents/${encodeURIComponent(e)}/chat/${t.id}`,[e]);return(0,S.jsx)(Vi,{storeKey:`agent:${e}`,label:`sessions`,fallbackTitle:`new session`,chatId:t,filter:i,hrefOf:a,closeHref:`/agents/${encodeURIComponent(e)}/chat/new`,actions:(0,S.jsx)(`button`,{type:`button`,className:`tab-new`,disabled:n,title:`new session`,"aria-label":`new session`,onClick:async()=>{r(!0),await pi(`claude`,{kind:`agent`,slug:e}),r(!1)},children:(0,S.jsx)(C,{name:n?`progress_activity`:`add`,className:`ms-sm`})})})}var Ea=e=>e.filter(e=>e.scope.kind!==`agent`&&e.scope.kind!==`channel`&&e.scope.kind!==`project`),Da=e=>`/agents/chats/${e.id}`;function Oa({chatId:e}){return(0,S.jsx)(Vi,{storeKey:`general`,label:`chats`,fallbackTitle:`new chat`,chatId:e,filter:Ea,hrefOf:Da,closeHref:`/agents/chats/new`,subOf:e=>(0,S.jsxs)(S.Fragment,{children:[e.agent,e.scope.kind===`run`?` · ${e.scope.runId}`:e.scope.kind===`kraftwerk`?` · kraftwerk`:e.scope.kind===`knowledge`?` · knowledge${e.scope.bundle?`:${e.scope.bundle}`:``}`:``]}),actions:(0,S.jsx)(L,{href:`/agents/chats/new`,className:`tab-new`,title:`new chat`,"aria-label":`new chat`,children:(0,S.jsx)(C,{name:`add`,className:`ms-sm`})})})}function ka({agents:e}){return(0,v.useEffect)(()=>{let t=!0,n=()=>F(`/agents/${encodeURIComponent(e[0].slug)}`,{replace:!0});return fetch(`/api/chats`).then(e=>e.json()).then(r=>{if(!t)return;let i=new Set(e.map(e=>e.slug)),a=r.chats.find(e=>e.scope.kind===`agent`&&i.has(e.scope.slug));a&&a.scope.kind===`agent`?F(`/agents/${encodeURIComponent(a.scope.slug)}/chat/${a.id}`,{replace:!0}):n()}).catch(()=>t&&n()),()=>{t=!1}},[e.map(e=>e.slug).join(`,`)]),(0,S.jsx)(`div`,{className:`empty`,children:`loading…`})}function Aa(){let e=B();return(0,S.jsx)(`div`,{className:`empty empty-action`,children:e?(0,S.jsxs)(`button`,{className:`run-btn`,onClick:()=>F(`/agents/new`),children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` create your first agent`]}):(0,S.jsx)(`span`,{children:`Creating agents needs expert mode — flip the switch in the top bar.`})})}function ja({slug:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)([]),[p,m]=(0,v.useState)(!0),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(``),b=U(`/api/workflows`,!1),
|
|
205
|
+
`).length+2)),onChange:e=>m(e.target.value),spellCheck:!1}),(0,S.jsxs)(`div`,{className:`kside-actions`,children:[(0,S.jsx)(`button`,{className:`open-raw`,disabled:h,onClick:()=>f(null),children:`cancel`}),(0,S.jsx)(`button`,{className:`open-raw`,disabled:h,onClick:()=>x(e,t.id),children:h?`saving…`:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(C,{name:`check`,className:`ms-sm`}),` save`]})})]}),_&&(0,S.jsxs)(`div`,{className:`msg error`,children:[(0,S.jsx)(C,{name:`error`,className:`ms-sm`}),` `,_]})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`kside-card-bar`,children:[t.type&&(0,S.jsx)(`span`,{className:`kside-type`,children:t.type}),xa(t)&&(0,S.jsxs)(`span`,{className:`kside-updated num`,children:[`updated `,Te(xa(t))]}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`button`,{className:`open-raw`,onClick:()=>{m(s[n].raw),f(n),y(``)},children:[(0,S.jsx)(C,{name:`edit`,className:`ms-sm`}),` edit`]}),(0,S.jsxs)(L,{href:`/knowledge/${encodeURIComponent(e)}/${t.id}`,className:`open-raw`,title:`The page in the knowledge section`,children:[(0,S.jsx)(C,{name:`open_in_new`,className:`ms-sm`}),` page`]}),(0,S.jsx)(L,{href:i,className:`open-raw`,children:`open ↗`})]}),(0,S.jsx)(`div`,{className:`kside-md md-body`,dangerouslySetInnerHTML:{__html:zr.sanitize(G.parse(s[n].body??``,{async:!1}))}})]})})]},t.id)}),!n&&t&&t.concepts.length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no concepts yet`})]},e)})})]})}function xa(e){return[e.generated?.at,...e.verified.map(e=>e.at)].filter(e=>typeof e==`string`&&e.length>0).sort().pop()}function Sa({slug:e,name:t}){let[n,r]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let t=!0;return r(!1),fetch(`/api/chats`).then(e=>e.json()).then(n=>{if(!t)return;let i=n.chats.find(t=>t.scope.kind===`agent`&&t.scope.slug===e);i?F(`/agents/${encodeURIComponent(e)}/chat/${i.id}`,{replace:!0}):r(!0)}).catch(()=>t&&r(!0)),()=>{t=!1}},[e]),n?(0,S.jsx)(Ca,{slug:e,name:t}):(0,S.jsx)(`div`,{className:`empty`,children:`loading…`})}function Ca({slug:e,name:t}){let[n,r]=(0,v.useState)(!1);return(0,S.jsxs)(`div`,{className:`new-chat`,children:[(0,S.jsx)(`div`,{className:`page-head`,children:(0,S.jsxs)(`h1`,{children:[`new session with `,t??e]})}),(0,S.jsx)(`section`,{className:`panel new-chat-panel`,children:(0,S.jsx)(`div`,{className:`agent-pick`,children:(0,S.jsxs)(`button`,{className:`agent-pick-btn active`,disabled:n,onClick:async()=>{r(!0),await pi(`claude`,{kind:`agent`,slug:e}),r(!1)},children:[(0,S.jsx)(`b`,{children:n?`starting…`:`start session`}),(0,S.jsx)(`span`,{children:`on the agent's harness, with its role, knowledge and skills`})]})})})]})}function wa(){let[e,t]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let e=!0;return fetch(`/api/chats`).then(e=>e.json()).then(n=>{if(!e)return;let r=n.chats.find(e=>e.scope.kind!==`agent`&&e.scope.kind!==`channel`&&e.scope.kind!==`project`);r?F(`/agents/chats/${r.id}`,{replace:!0}):t(!0)}).catch(()=>e&&t(!0)),()=>{e=!1}},[]),e?(0,S.jsx)(mi,{}):(0,S.jsx)(`div`,{className:`empty`,children:`loading…`})}function Ta({slug:e,chatId:t}){let[n,r]=(0,v.useState)(!1),i=(0,v.useCallback)(t=>t.filter(t=>t.scope.kind===`agent`&&t.scope.slug===e),[e]),a=(0,v.useCallback)(t=>`/agents/${encodeURIComponent(e)}/chat/${t.id}`,[e]);return(0,S.jsx)(Vi,{storeKey:`agent:${e}`,label:`sessions`,fallbackTitle:`new session`,chatId:t,filter:i,hrefOf:a,closeHref:`/agents/${encodeURIComponent(e)}/chat/new`,actions:(0,S.jsx)(`button`,{type:`button`,className:`tab-new`,disabled:n,title:`new session`,"aria-label":`new session`,onClick:async()=>{r(!0),await pi(`claude`,{kind:`agent`,slug:e}),r(!1)},children:(0,S.jsx)(C,{name:n?`progress_activity`:`add`,className:`ms-sm`})})})}var Ea=e=>e.filter(e=>e.scope.kind!==`agent`&&e.scope.kind!==`channel`&&e.scope.kind!==`project`),Da=e=>`/agents/chats/${e.id}`;function Oa({chatId:e}){return(0,S.jsx)(Vi,{storeKey:`general`,label:`chats`,fallbackTitle:`new chat`,chatId:e,filter:Ea,hrefOf:Da,closeHref:`/agents/chats/new`,subOf:e=>(0,S.jsxs)(S.Fragment,{children:[e.agent,e.scope.kind===`run`?` · ${e.scope.runId}`:e.scope.kind===`kraftwerk`?` · kraftwerk`:e.scope.kind===`knowledge`?` · knowledge${e.scope.bundle?`:${e.scope.bundle}`:``}`:``]}),actions:(0,S.jsx)(L,{href:`/agents/chats/new`,className:`tab-new`,title:`new chat`,"aria-label":`new chat`,children:(0,S.jsx)(C,{name:`add`,className:`ms-sm`})})})}function ka({agents:e}){return(0,v.useEffect)(()=>{let t=!0,n=()=>F(`/agents/${encodeURIComponent(e[0].slug)}`,{replace:!0});return fetch(`/api/chats`).then(e=>e.json()).then(r=>{if(!t)return;let i=new Set(e.map(e=>e.slug)),a=r.chats.find(e=>e.scope.kind===`agent`&&i.has(e.scope.slug));a&&a.scope.kind===`agent`?F(`/agents/${encodeURIComponent(a.scope.slug)}/chat/${a.id}`,{replace:!0}):n()}).catch(()=>t&&n()),()=>{t=!1}},[e.map(e=>e.slug).join(`,`)]),(0,S.jsx)(`div`,{className:`empty`,children:`loading…`})}function Aa(){let e=B();return(0,S.jsx)(`div`,{className:`empty empty-action`,children:e?(0,S.jsxs)(`button`,{className:`run-btn`,onClick:()=>F(`/agents/new`),children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` create your first agent`]}):(0,S.jsx)(`span`,{children:`Creating agents needs expert mode — flip the switch in the top bar.`})})}function ja({slug:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)([]),[p,m]=(0,v.useState)(!0),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(``),b=se(),x=U(`/api/workflows`,!1),w=U(`/api/knowledge`,!1),T=U(b.vibeables?`/api/vibeables`:``,!1),E=U(`/api/skills`,!1);(0,v.useEffect)(()=>{let t=!0;return fetch(`/api/agents/${encodeURIComponent(e)}`).then(e=>e.ok?e.json():Promise.reject()).then(e=>t&&n(e)).catch(()=>t&&i(!0)),()=>{t=!1}},[e]);async function D(r){if(t){g(!0),y(``);try{let i=await(await fetch(`/api/agents/${encodeURIComponent(e)}`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({name:t.name,emoji:t.emoji,description:t.description,harness:t.harness,model:t.model,effort:t.effort,group:t.group,system:t.system,workflows:t.workflows,knowledge:t.knowledge,vibeables:t.vibeables,skills:t.skills,...r})})).json();i.error?y(i.error):(n(i),c(``))}catch(e){y(e.message)}g(!1)}}function O(e,t){f(t?[...d,e]:d.filter(t=>t!==e))}async function k(t){g(!0),y(``);try{let r=await(await fetch(`/api/agents/${encodeURIComponent(e)}/archive`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({archived:t})})).json();r.error?y(r.error):n(r)}catch(e){y(e.message)}g(!1)}if(r)return(0,S.jsx)(`div`,{className:`empty`,children:`agent not found`});if(!t)return(0,S.jsx)(`div`,{className:`empty`,children:`loading…`});let A=e=>(0,S.jsxs)(`div`,{className:`agent-form-row`,style:{marginTop:8},children:[(0,S.jsx)(`button`,{className:`run-btn`,disabled:h,onClick:()=>void D(e),children:h?`saving…`:`save`}),(0,S.jsx)(`button`,{className:`open-raw`,disabled:h,onClick:()=>(c(``),y(``)),children:`cancel`})]});return(0,S.jsxs)(`div`,{className:`agent-view`,children:[(0,S.jsxs)(`div`,{className:`detail-head`,children:[(0,S.jsx)(`span`,{className:`agent-avatar lg`,children:(0,S.jsx)(`span`,{"aria-hidden":!0,children:t.emoji})}),(0,S.jsx)(`h1`,{children:t.name}),(0,S.jsx)(`span`,{className:`chip agent`,children:t.harness}),t.model&&(0,S.jsx)(`span`,{className:`chip`,children:t.model}),t.effort&&(0,S.jsxs)(`span`,{className:`chip`,children:[`effort: `,t.effort]}),t.archived&&(0,S.jsxs)(`span`,{className:`chip archived-chip`,children:[(0,S.jsx)(C,{name:`inventory_2`,className:`ms-sm`}),` archived`]}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(L,{href:`/agents/${encodeURIComponent(e)}/edit`,className:`open-raw`,children:`edit`}),t.archived?(0,S.jsxs)(`button`,{className:`run-btn tonal`,disabled:h,onClick:()=>void k(!1),children:[(0,S.jsx)(C,{name:`unarchive`,className:`ms-sm`}),` `,h?`…`:`unarchive`]}):(0,S.jsx)(S.Fragment,{children:(0,S.jsxs)(`button`,{className:`open-raw`,disabled:h,title:`Hide this agent from the roster — restorable any time`,onClick:()=>void k(!0),children:[(0,S.jsx)(C,{name:`archive`,className:`ms-sm`}),` archive`]})})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`m3-list`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`m3-row m3-toggle`,onClick:()=>o(!a),children:[(0,S.jsx)(`span`,{className:`m3-ico`,children:(0,S.jsx)(C,{name:`badge`})}),(0,S.jsxs)(`span`,{className:`m3-body`,children:[(0,S.jsx)(`span`,{className:`m3-head`,children:`role`}),!a&&(0,S.jsx)(`span`,{className:`m3-sub m3-ellipsis`,children:(t.system||``).trim().split(`
|
|
206
206
|
`)[0]||`empty — expand to give this agent a role`})]}),(0,S.jsx)(`span`,{className:`m3-chev ${a?`open`:``}`,children:(0,S.jsx)(C,{name:`expand_more`,className:`ms-sm`})})]}),a&&s!==`role`&&(0,S.jsxs)(`div`,{className:`m3-expand`,children:[(0,S.jsx)(`pre`,{children:t.system||`(empty — click edit to give this agent a role)`}),(0,S.jsxs)(`div`,{className:`agent-form-row`,style:{marginTop:10},children:[(0,S.jsxs)(`button`,{className:`open-raw`,onClick:()=>{u(t.system),c(`role`),y(``)},children:[(0,S.jsx)(C,{name:`edit`,className:`ms-sm`}),` edit role`]}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`span`,{className:`m3-sub`,children:[`agents/`,t.slug,`/system.md`]})]})]}),a&&s===`role`&&(0,S.jsxs)(`div`,{className:`m3-expand`,children:[(0,S.jsx)(`textarea`,{className:`concept-edit`,rows:Math.min(24,Math.max(8,l.split(`
|
|
207
|
-
`).length+2)),value:l,placeholder:`You are the ... for this project. Your job is ...`,onChange:e=>u(e.target.value),spellCheck:!1}),
|
|
207
|
+
`).length+2)),value:l,placeholder:`You are the ... for this project. Your job is ...`,onChange:e=>u(e.target.value),spellCheck:!1}),A({system:l})]}),(0,S.jsxs)(`div`,{className:`m3-row`,children:[(0,S.jsx)(`span`,{className:`m3-ico`,children:(0,S.jsx)(C,{name:`account_tree`})}),(0,S.jsxs)(`span`,{className:`m3-body`,children:[(0,S.jsx)(`span`,{className:`m3-head`,children:`workflows`}),s===`workflows`?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`wf-checks`,children:[(x?.workflows??[]).map(e=>(0,S.jsxs)(`label`,{children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:d.includes(e.slug),onChange:t=>O(e.slug,t.target.checked)}),(0,S.jsx)(`b`,{children:e.slug}),e.description&&(0,S.jsxs)(`span`,{className:`opt-hint`,children:[` — `,e.description]})]},e.slug)),(x?.workflows??[]).length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no workflows in this project`})]}),A({workflows:d})]}):t.workflows.length===0?(0,S.jsx)(`span`,{className:`m3-sub`,children:`none connected — the agent can run any workflow you connect`}):(0,S.jsx)(`span`,{className:`m3-chips`,children:t.workflows.map(e=>(0,S.jsx)(L,{href:`/workflows/${encodeURIComponent(e)}`,className:`chip`,children:e},e))})]}),s!==`workflows`&&(0,S.jsx)(`button`,{className:`open-raw`,onClick:()=>{f(t.workflows),c(`workflows`),y(``)},children:`edit`})]}),(0,S.jsxs)(`div`,{className:`m3-row`,children:[(0,S.jsx)(`span`,{className:`m3-ico`,children:(0,S.jsx)(C,{name:`menu_book`})}),(0,S.jsxs)(`span`,{className:`m3-body`,children:[(0,S.jsx)(`span`,{className:`m3-head`,children:`knowledge`}),s===`knowledge`?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`wf-checks`,children:[(w?.bundles??[]).map(e=>(0,S.jsxs)(`label`,{children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:d.includes(e.name),onChange:t=>O(e.name,t.target.checked)}),(0,S.jsx)(`b`,{children:e.name}),(0,S.jsxs)(`span`,{className:`opt-hint`,children:[` — `,e.concepts,` concepts`]})]},e.name)),(w?.bundles??[]).length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no knowledge bundles in this project`})]}),A({knowledge:d})]}):t.knowledge.length===0?(0,S.jsx)(`span`,{className:`m3-sub`,children:`none connected — connected bundles are read and kept current by the agent`}):(0,S.jsx)(`span`,{className:`m3-chips`,children:t.knowledge.map(e=>(0,S.jsx)(L,{href:`/knowledge/${encodeURIComponent(e)}`,className:`chip`,children:e},e))})]}),s!==`knowledge`&&(0,S.jsx)(`button`,{className:`open-raw`,onClick:()=>{f(t.knowledge),c(`knowledge`),y(``)},children:`edit`})]}),(b.vibeables||(t.vibeables??[]).length>0)&&(0,S.jsxs)(`div`,{className:`m3-row`,"data-link-kind":`vibeables`,children:[(0,S.jsx)(`span`,{className:`m3-ico`,children:(0,S.jsx)(C,{name:`web`})}),(0,S.jsxs)(`span`,{className:`m3-body`,children:[(0,S.jsx)(`span`,{className:`m3-head`,children:`vibeables`}),s===`vibeables`?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`wf-checks`,children:[(T?.vibeables??[]).map(e=>(0,S.jsxs)(`label`,{children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:d.includes(e.slug),onChange:t=>O(e.slug,t.target.checked)}),(0,S.jsx)(`b`,{children:e.slug}),(0,S.jsxs)(`span`,{className:`opt-hint`,children:[` — `,e.dev?`dev`:`static`]})]},e.slug)),d.filter(e=>!(T?.vibeables??[]).some(t=>t.slug===e)).map(e=>(0,S.jsxs)(`label`,{children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:!0,onChange:t=>O(e,t.target.checked)}),(0,S.jsx)(`b`,{children:e}),(0,S.jsx)(`span`,{className:`opt-hint`,children:` — not found in this workspace`})]},e)),!b.vibeables&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`vibeables are off in this workspace's settings`}),b.vibeables&&(T?.vibeables??[]).length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no vibeables in this workspace yet — create one on the vibeables screen`})]}),A({vibeables:d})]}):(t.vibeables??[]).length===0?(0,S.jsx)(`span`,{className:`m3-sub`,children:`none linked — linked apps are the agent's to build and maintain; it knows them from the first message`}):(0,S.jsx)(`span`,{className:`m3-chips`,children:(t.vibeables??[]).map(e=>{let t=!b.vibeables||!T||T.vibeables.some(t=>t.slug===e);return(0,S.jsxs)(L,{href:`/vibeables/${encodeURIComponent(e)}`,className:`chip ${t?``:`attention`}`,title:t?void 0:`configured but not found in this workspace`,children:[e,!t&&` · not found`]},e)})})]}),s!==`vibeables`&&(0,S.jsx)(`button`,{className:`open-raw`,onClick:()=>{f(t.vibeables??[]),c(`vibeables`),y(``)},children:`edit`})]}),(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.jsx)(`span`,{className:`m3-head`,children:`shared skills`}),s===`skills`?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`wf-checks`,children:[(0,S.jsxs)(`label`,{children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked)}),(0,S.jsx)(`b`,{children:`all skills`}),(0,S.jsx)(`span`,{className:`opt-hint`,children:` — every discovered skill, including future ones`})]}),!p&&(E?.skills??[]).map(e=>(0,S.jsxs)(`label`,{children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:d.includes(e.name),onChange:t=>O(e.name,t.target.checked)}),(0,S.jsxs)(`b`,{children:[`/`,e.name]}),e.description&&(0,S.jsxs)(`span`,{className:`opt-hint`,children:[` — `,e.description]})]},e.name)),!p&&(E?.skills??[]).length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no skills found (.claude/skills, project or user)`})]}),A({skills:p?void 0:d})]}):t.skills===void 0?(0,S.jsx)(`span`,{className:`m3-sub`,children:`all discovered skills (default) — invoke with /name in a session`}):t.skills.length===0?(0,S.jsx)(`span`,{className:`m3-sub`,children:`none — this agent runs without skills`}):(0,S.jsx)(`span`,{className:`m3-chips`,children:t.skills.map(e=>(0,S.jsxs)(`span`,{className:`chip`,children:[`/`,e]},e))})]}),s!==`skills`&&(0,S.jsx)(`button`,{className:`open-raw`,onClick:()=>{m(t.skills===void 0),f(t.skills??[]),c(`skills`),y(``)},children:`edit`})]})]}),_&&(0,S.jsxs)(`div`,{className:`msg error`,children:[(0,S.jsx)(C,{name:`error`,className:`ms-sm`}),` `,_]})]}),(0,S.jsx)(Na,{slug:e}),(0,S.jsx)(Pa,{slug:e})]})}var Ma=`---
|
|
208
208
|
description: What this skill is for (one line)
|
|
209
209
|
---
|
|
210
210
|
|
|
211
211
|
Instructions this agent follows when the skill applies or is invoked with /<name>.
|
|
212
212
|
`;function Na({slug:e}){let t=U(`/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:Ma,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 Pa({slug:e}){let t=U(`/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&&F(`/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)(L,{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 ${Te(t.nextRunAt)}`:``:` · paused`,` · `,t.lastChatId?(0,S.jsxs)(L,{href:`/agents/${encodeURIComponent(e)}/chat/${t.lastChatId}`,children:[`last run `,Te(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 Fa({slug:e}){let[t,n]=(0,v.useState)(e?null:u()),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(!1),s=U(`/api/workflows`,!1)?.workflows??[],c=U(`/api/knowledge`,!1)?.bundles??[],l=U(`/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??[],skillsAll:e.skills===void 0,skills:e.skills??[]})).catch(()=>i(`agent not found`))},[e]);function u(){return{name:``,emoji:`🤖`,description:``,harness:`claude`,model:``,effort:``,group:``,system:``,workflows:[],knowledge:[],skillsAll:!0,skills:[]}}async function d(){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):F(`/agents/${encodeURIComponent(n.slug)}/info`)}async function f(){e&&window.confirm(`Delete agent "${e}" and its definition folder?`)&&(await fetch(`/api/agents/${encodeURIComponent(e)}`,{method:`DELETE`}).catch(()=>{}),F(`/agents`))}if(!t)return(0,S.jsx)(`div`,{className:`empty`,children:r||`loading…`});let p=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=>p({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=>p({emoji:e.target.value})})]})]}),(0,S.jsx)(`div`,{className:`emoji-pick`,children:va.map(e=>(0,S.jsx)(`button`,{type:`button`,className:t.emoji===e?`active`:``,onClick:()=>p({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=>p({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=>p({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=>p({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=>p({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=>p({effort:e.target.value}),children:_a.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=>p({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=>p({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=>p({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`})]})]}),(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=>p({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&&l.map(e=>(0,S.jsxs)(`label`,{children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:t.skills.includes(e.name),onChange:n=>p({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&&l.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:d,children:a?`saving…`:e?`save`:`create`}),(0,S.jsx)(`span`,{className:`spacer`}),e&&(0,S.jsx)(`button`,{className:`stop-btn`,onClick:f,children:`delete agent`})]})]})})]})}function Ia(e){if(!P(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)($i,{},`new-project`):r?(0,S.jsx)(Fa,{},`new-agent`):(0,S.jsx)(ii,{},`new-channel`):t[0]===`projects`&&t[2]===`info`?(0,S.jsx)(oa,{slug:n,onChanged:async()=>{}},n):r&&t[2]===`info`?(0,S.jsx)(ja,{slug:n},n):r&&t[2]===`edit`?(0,S.jsx)(Fa,{slug:n},n):t[0]===`channels`&&t[2]===`edit`?(0,S.jsx)(ii,{slug:n},n):null}function La({back:e,children:t}){let n=()=>F(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 Ra({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:Te(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 za({id:e,workflow:t}){let n=U(`/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)(L,{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)(Ba,{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)(Va,{id:e},e)})]})}function Ba({r:e,active:t}){return(0,S.jsxs)(L,{href:`/runs/${e.id}`,className:`side-row ${t?`active`:``}`,children:[(0,S.jsx)(Oe,{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:Te(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)(De,{since:e.startedAt}):xe(e.durationMs)})]})]})]})}function Va({id:e}){let t=U(`/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=B();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=>!qa(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){F(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)(Oe,{status:t.status}),(0,S.jsx)(`h1`,{children:t.workflow?(0,S.jsx)(L,{href:`/workflows/${encodeURIComponent(t.workflow)}`,title:`open workflow`,children:t.workflow}):`unknown workflow`}),(0,S.jsx)(ke,{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 pi(`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)(Ha,{run:t,live:n}):(0,S.jsx)(Ya,{id:e,files:t.files,live:n})]})}function Ha({run:e,live:t}){return(0,S.jsxs)(`div`,{className:`run-tab`,children:[e.decision&&(0,S.jsx)(Ra,{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)(De,{since:e.startedAt}):xe(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:Se(e.costUsd??Wa(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:[Ce(Ua(e.phases,`tokensIn`)),` / `,Ce(Ua(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)(Ga,{p:e},e.phase))})]})]})}function Ua(e,t){return e.reduce((e,n)=>e+(n[t]??0),0)}function Wa(e){return e.reduce((e,t)=>e+(t.costUsd??0),0)}function Ga({p:e}){let t=e.gates.filter(e=>!e.passed);return(0,S.jsxs)(`div`,{className:`phase-row`,children:[(0,S.jsx)(Oe,{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)(De,{since:e.startedAt}):e.durationMs!=null&&(0,S.jsx)(`span`,{children:xe(e.durationMs)}),e.kind===`agent`&&e.tokensIn!=null&&(0,S.jsxs)(`span`,{children:[Ce(e.tokensIn),` / `,Ce(e.tokensOut)]}),e.costUsd!=null&&e.costUsd>0&&(0,S.jsx)(`span`,{children:Se(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 Ka=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`]);function qa(e){return e===`runner.json`||e.endsWith(`.jsonl`)||e.endsWith(`.log`)}function Ja(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)||Ka.has(t)?0:qa(e)?2:1},r=null;for(let t of e)(!r||n(t.name)<n(r.name))&&(r=t);return r?.name??null}function Ya({id:e,files:t,live:n}){let[r,i]=(0,v.useState)(null),a=B(),o=(0,v.useMemo)(()=>a?t:t.filter(e=>!qa(e.name)),[t,a]);return(0,v.useEffect)(()=>{!a&&r&&qa(r)&&i(null)},[a,r]),(0,v.useEffect)(()=>{r||o.length===0||i(Ja(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:we(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)(Xa,{id:e,name:r,live:n}):(0,S.jsx)(`div`,{className:`empty`,children:`select a file`})]})]})}function Xa({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})})}):Ka.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)(Za,{id:e,name:t,live:n}):(0,S.jsx)(Qa,{id:e,name:t,live:n})}function Za({id:e,name:t,live:n}){let[r,i]=(0,v.useState)(`rendered`),a=U(`/api/runs/${e}/file?name=${encodeURIComponent(t)}`,n),o=(0,v.useMemo)(()=>a?zr.sanitize(G.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 `,we(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 Qa({id:e,name:t,live:n}){let r=U(`/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 `,we(4e5)]}),(0,S.jsx)(`div`,{className:`viewer-body`,children:(0,S.jsx)(`pre`,{children:r?r.content||`(empty)`:`loading…`})})]})}function $a(){return U(`/api/workflows/any/run`,!1,15e3)}var eo=e=>!!e?.available&&!!e?.image;function to(e){return e?e.available?e.image?`isolated container per run`:"image missing — run `kraftwerk runner build`":`Docker is not running`:``}async function no(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 ro(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=$a();(0,v.useEffect)(()=>{!i&&n&&a(n)},[n]),(0,v.useEffect)(()=>{m&&!eo(m)&&s(!1)},[m]);let h=!u&&(!t||!!i.trim())&&(!o||eo(m));async function g(){if(h){d(!0),p(null);try{let t=await no(e,{request:i.trim(),sandbox:o,ssh:c});r?(r(t),d(!1)):F(`/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 io({slug:e,usesRequest:t,initialRequest:n,onLaunched:r}){let i=ro(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)(J,{label:`Docker sandbox`,hint:to(i.docker),checked:i.sandbox,onChange:i.setSandbox}),i.sandbox&&(0,S.jsx)(J,{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 J({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 Y=`\0done`,ao=5;function oo(e,t){return e.status===`ok`?Y:e.currentPhase&&t.includes(e.currentPhase)?e.currentPhase:t[0]??Y}function so({wf:e,runs:t,agentIdx:n,runsHref:r}){let i=e.steps.map(e=>e.name),a=new Map([...i,Y].map(e=>[e,[]]));for(let e of t)a.get(oo(e,i)).push(e);let o=a.get(Y)??[];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)(co,{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)(co,{cards:o,moreHref:r})]})]})}function co({cards:e,moreHref:t}){return(0,S.jsxs)(`div`,{className:`board-col-cards`,children:[e.slice(0,ao).map(e=>(0,S.jsx)(lo,{r:e},e.id)),e.length===0&&(0,S.jsx)(`div`,{className:`board-col-empty`,children:`—`}),e.length>ao&&(0,S.jsxs)(L,{href:t,className:`board-more`,children:[`+ `,e.length-ao,` more ↗`]})]})}function lo({r:e}){let t=e.request??e.id.replace(/^run-/,``);return(0,S.jsxs)(L,{href:`/runs/${e.id}`,className:`board-card is-${e.status}`,children:[(0,S.jsxs)(`div`,{className:`board-card-top`,children:[(0,S.jsx)(Oe,{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:Te(e.startedAt)}),(0,S.jsx)(`span`,{children:e.status===`running`?(0,S.jsx)(De,{since:e.startedAt}):xe(e.durationMs)}),e.costUsd!=null&&e.costUsd>0&&(0,S.jsx)(`span`,{children:Se(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 uo({slug:e,tab:t}){let n=U(`/api/workflows/${encodeURIComponent(e)}`,!1),[r,i]=(0,v.useState)(0),[a,o]=(0,v.useState)(0),s=U(`/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)(L,{href:u,className:t===`overview`?`active`:``,children:`overview`}),(0,S.jsx)(L,{href:`${u}/details`,className:t===`details`?`active`:``,children:`details`}),(0,S.jsxs)(L,{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)(io,{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)(L,{href:`${u}/runs`,className:`open-raw`,children:`all runs ↗`})]}),(0,S.jsx)(so,{wf:n,runs:l,agentIdx:c,runsHref:`${u}/runs`})]})]}),t===`details`&&(0,S.jsx)(fo,{wf:n,agentIdx:c}),t===`runs`&&(0,S.jsx)(po,{runs:l})]})}function fo({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)(mo,{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)(ho,{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 po({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)(L,{href:`/runs/${e.id}`,className:`run-card is-${e.status}`,children:[(0,S.jsx)(Oe,{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)(ke,{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)(De,{since:e.startedAt}):xe(e.durationMs)}),(0,S.jsx)(`span`,{className:`num`,children:Se(e.costUsd)}),(0,S.jsx)(`span`,{className:`num`,children:Te(e.startedAt)})]})]},e.id)})})}function mo({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 ho({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 go(e,t){let n=e.filter(e=>e.workflow===(t.name??t.slug));return{count:n.length,last:n[0]}}function _o(e,t){return`/runs/${e.id}?workflow=${encodeURIComponent(t.name??t.slug)}`}function vo({slug:e,tab:t}){let n=U(`/api/workflows`,!1),r=U(`/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:go(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&&F(`/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)(L,{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=go(s,t);return(0,S.jsxs)(L,{href:`/workflows/${encodeURIComponent(t.slug)}`,className:`side-row wf-row${t.slug===e?` active`:``}`,children:[(0,S.jsx)(Oe,{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:Ee(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(),F(_o(n.last,t))},children:[n.count,` `,n.count===1?`run`:`runs`,` · `,(0,S.jsx)(ke,{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)(uo,{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 yo=e=>e===`ok`?`ok`:e===`running`?`running`:e===`aborted`?`aborted`:`failed`,bo=e=>e===`ok`?`done`:e===`running`?`working`:e===`aborted`?`stopped`:`failed`;function xo(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 So(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 Co(e){return e.length>64?`${e.slice(0,46)}…${e.slice(-14)}`:e}function wo(){let e=U(`/api/runs`,!1),t=U(`/api/chats`,!1),n=U(`/api/knowledge`,!1),r=U(`/api/agents`,!1),i=U(`/api/workflows`,!1),a=U(`/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)(L,{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)(Do,{runs:c,chats:l,bundles:u,agents:r?.agents??[],workflows:i?.workflows??[],filter:o,setFilter:s})]})}function To(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 Eo=[[`all`,`all`],[`run`,`runs`],[`session`,`chats`],[`knowledge`,`knowledge`]];function Do({runs:e,chats:t,bundles:n,agents:r,workflows:i,filter:a,setFilter:o}){let s=B(),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:yo(t.status),status:bo(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} · ${So(e)}`:So(e),href:xo(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:[Eo.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=To(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)(L,{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:Co(e.title)}),e.sub&&(0,S.jsx)(`span`,{className:`m3-sub`,children:Co(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:Ee(e.at)}),(0,S.jsx)(`span`,{className:`m3-chev`,children:(0,S.jsx)(C,{name:`chevron_right`})})]})]},`${e.kind}:${e.href}:${e.at}`)})})]})}var Oo=`modulepreload`,ko=function(e){return`/`+e},Ao={},jo=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=ko(t,n),t=s(t),t in Ao)return;Ao[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`:Oo,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)})},Mo=(0,v.lazy)(()=>jo(()=>import(`./editor-DMHihW2Y.js`).then(e=>({default:e.DocEditor})),__vite__mapDeps([0,1,2,3,4,5,6]))),No=()=>jo(()=>import(`./editor-DMHihW2Y.js`),__vite__mapDeps([0,1,2,3,4,5,6]));function Po({bundle:e,conceptId:t}){let n=U(`/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&&F(`/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)(L,{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)(L,{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)(Ro,{name:e,conceptId:t},e):i||n&&!a?(0,S.jsx)(Fo,{}):(0,S.jsx)(`div`,{className:`empty`,children:`loading…`})})]})}function Fo(){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):F(`/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 Io({tier:e}){return(0,S.jsx)(`span`,{className:`chip trust ${e}`,children:e})}var Lo=`@activity`;function Ro({name:e,conceptId:t}){let n=U(`/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===Lo?`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)(L,{href:o,className:r===`pages`?`active`:``,children:`pages`}),(0,S.jsx)(L,{href:`${o}/${Lo}`,className:r===`activity`?`active`:``,children:`activity`})]}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`button`,{className:`open-raw`,onClick:()=>void fa(e),children:[(0,S.jsx)(C,{name:`picture_as_pdf`,className:`ms-sm`}),` export PDF`]}),(0,S.jsx)(`button`,{className:`run-btn`,onClick:()=>void pi(`claude`,{kind:`knowledge`,bundle:e}),children:`curate in chat`})]}),r===`activity`?n.log?(0,S.jsx)(Vo,{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)(Uo,{concepts:i,base:o,selected:a})}),(0,S.jsx)(`div`,{className:`wiki-main`,children:a&&(0,S.jsx)(Go,{bundle:e,conceptId:a},a)})]})]})}function zo(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 Pa({slug:e}){let t=U(`/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&&F(`/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)(L,{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 ${Te(t.nextRunAt)}`:``:` · paused`,` · `,t.lastChatId?(0,S.jsxs)(L,{href:`/agents/${encodeURIComponent(e)}/chat/${t.lastChatId}`,children:[`last run `,Te(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 Fa({slug:e}){let[t,n]=(0,v.useState)(e?null:f()),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(!1),s=U(`/api/workflows`,!1)?.workflows??[],c=U(`/api/knowledge`,!1)?.bundles??[],l=se(),u=U(l.vibeables?`/api/vibeables`:``,!1)?.vibeables??[],d=U(`/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):F(`/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(()=>{}),F(`/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:va.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:_a.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 Ia(e){if(!P(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)($i,{},`new-project`):r?(0,S.jsx)(Fa,{},`new-agent`):(0,S.jsx)(ii,{},`new-channel`):t[0]===`projects`&&t[2]===`info`?(0,S.jsx)(oa,{slug:n,onChanged:async()=>{}},n):r&&t[2]===`info`?(0,S.jsx)(ja,{slug:n},n):r&&t[2]===`edit`?(0,S.jsx)(Fa,{slug:n},n):t[0]===`channels`&&t[2]===`edit`?(0,S.jsx)(ii,{slug:n},n):null}function La({back:e,children:t}){let n=()=>F(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 Ra({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:Te(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 za({id:e,workflow:t}){let n=U(`/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)(L,{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)(Ba,{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)(Va,{id:e},e)})]})}function Ba({r:e,active:t}){return(0,S.jsxs)(L,{href:`/runs/${e.id}`,className:`side-row ${t?`active`:``}`,children:[(0,S.jsx)(Oe,{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:Te(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)(De,{since:e.startedAt}):xe(e.durationMs)})]})]})]})}function Va({id:e}){let t=U(`/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=B();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=>!qa(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){F(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)(Oe,{status:t.status}),(0,S.jsx)(`h1`,{children:t.workflow?(0,S.jsx)(L,{href:`/workflows/${encodeURIComponent(t.workflow)}`,title:`open workflow`,children:t.workflow}):`unknown workflow`}),(0,S.jsx)(ke,{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 pi(`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)(Ha,{run:t,live:n}):(0,S.jsx)(Ya,{id:e,files:t.files,live:n})]})}function Ha({run:e,live:t}){return(0,S.jsxs)(`div`,{className:`run-tab`,children:[e.decision&&(0,S.jsx)(Ra,{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)(De,{since:e.startedAt}):xe(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:Se(e.costUsd??Wa(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:[Ce(Ua(e.phases,`tokensIn`)),` / `,Ce(Ua(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)(Ga,{p:e},e.phase))})]})]})}function Ua(e,t){return e.reduce((e,n)=>e+(n[t]??0),0)}function Wa(e){return e.reduce((e,t)=>e+(t.costUsd??0),0)}function Ga({p:e}){let t=e.gates.filter(e=>!e.passed);return(0,S.jsxs)(`div`,{className:`phase-row`,children:[(0,S.jsx)(Oe,{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)(De,{since:e.startedAt}):e.durationMs!=null&&(0,S.jsx)(`span`,{children:xe(e.durationMs)}),e.kind===`agent`&&e.tokensIn!=null&&(0,S.jsxs)(`span`,{children:[Ce(e.tokensIn),` / `,Ce(e.tokensOut)]}),e.costUsd!=null&&e.costUsd>0&&(0,S.jsx)(`span`,{children:Se(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 Ka=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`]);function qa(e){return e===`runner.json`||e.endsWith(`.jsonl`)||e.endsWith(`.log`)}function Ja(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)||Ka.has(t)?0:qa(e)?2:1},r=null;for(let t of e)(!r||n(t.name)<n(r.name))&&(r=t);return r?.name??null}function Ya({id:e,files:t,live:n}){let[r,i]=(0,v.useState)(null),a=B(),o=(0,v.useMemo)(()=>a?t:t.filter(e=>!qa(e.name)),[t,a]);return(0,v.useEffect)(()=>{!a&&r&&qa(r)&&i(null)},[a,r]),(0,v.useEffect)(()=>{r||o.length===0||i(Ja(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:we(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)(Xa,{id:e,name:r,live:n}):(0,S.jsx)(`div`,{className:`empty`,children:`select a file`})]})]})}function Xa({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})})}):Ka.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)(Za,{id:e,name:t,live:n}):(0,S.jsx)(Qa,{id:e,name:t,live:n})}function Za({id:e,name:t,live:n}){let[r,i]=(0,v.useState)(`rendered`),a=U(`/api/runs/${e}/file?name=${encodeURIComponent(t)}`,n),o=(0,v.useMemo)(()=>a?zr.sanitize(G.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 `,we(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 Qa({id:e,name:t,live:n}){let r=U(`/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 `,we(4e5)]}),(0,S.jsx)(`div`,{className:`viewer-body`,children:(0,S.jsx)(`pre`,{children:r?r.content||`(empty)`:`loading…`})})]})}function $a(){return U(`/api/workflows/any/run`,!1,15e3)}var eo=e=>!!e?.available&&!!e?.image;function to(e){return e?e.available?e.image?`isolated container per run`:"image missing — run `kraftwerk runner build`":`Docker is not running`:``}async function no(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 ro(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=$a();(0,v.useEffect)(()=>{!i&&n&&a(n)},[n]),(0,v.useEffect)(()=>{m&&!eo(m)&&s(!1)},[m]);let h=!u&&(!t||!!i.trim())&&(!o||eo(m));async function g(){if(h){d(!0),p(null);try{let t=await no(e,{request:i.trim(),sandbox:o,ssh:c});r?(r(t),d(!1)):F(`/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 io({slug:e,usesRequest:t,initialRequest:n,onLaunched:r}){let i=ro(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)(J,{label:`Docker sandbox`,hint:to(i.docker),checked:i.sandbox,onChange:i.setSandbox}),i.sandbox&&(0,S.jsx)(J,{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 J({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 Y=`\0done`,ao=5;function oo(e,t){return e.status===`ok`?Y:e.currentPhase&&t.includes(e.currentPhase)?e.currentPhase:t[0]??Y}function so({wf:e,runs:t,agentIdx:n,runsHref:r}){let i=e.steps.map(e=>e.name),a=new Map([...i,Y].map(e=>[e,[]]));for(let e of t)a.get(oo(e,i)).push(e);let o=a.get(Y)??[];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)(co,{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)(co,{cards:o,moreHref:r})]})]})}function co({cards:e,moreHref:t}){return(0,S.jsxs)(`div`,{className:`board-col-cards`,children:[e.slice(0,ao).map(e=>(0,S.jsx)(lo,{r:e},e.id)),e.length===0&&(0,S.jsx)(`div`,{className:`board-col-empty`,children:`—`}),e.length>ao&&(0,S.jsxs)(L,{href:t,className:`board-more`,children:[`+ `,e.length-ao,` more ↗`]})]})}function lo({r:e}){let t=e.request??e.id.replace(/^run-/,``);return(0,S.jsxs)(L,{href:`/runs/${e.id}`,className:`board-card is-${e.status}`,children:[(0,S.jsxs)(`div`,{className:`board-card-top`,children:[(0,S.jsx)(Oe,{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:Te(e.startedAt)}),(0,S.jsx)(`span`,{children:e.status===`running`?(0,S.jsx)(De,{since:e.startedAt}):xe(e.durationMs)}),e.costUsd!=null&&e.costUsd>0&&(0,S.jsx)(`span`,{children:Se(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 uo({slug:e,tab:t}){let n=U(`/api/workflows/${encodeURIComponent(e)}`,!1),[r,i]=(0,v.useState)(0),[a,o]=(0,v.useState)(0),s=U(`/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)(L,{href:u,className:t===`overview`?`active`:``,children:`overview`}),(0,S.jsx)(L,{href:`${u}/details`,className:t===`details`?`active`:``,children:`details`}),(0,S.jsxs)(L,{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)(io,{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)(L,{href:`${u}/runs`,className:`open-raw`,children:`all runs ↗`})]}),(0,S.jsx)(so,{wf:n,runs:l,agentIdx:c,runsHref:`${u}/runs`})]})]}),t===`details`&&(0,S.jsx)(fo,{wf:n,agentIdx:c}),t===`runs`&&(0,S.jsx)(po,{runs:l})]})}function fo({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)(mo,{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)(ho,{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 po({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)(L,{href:`/runs/${e.id}`,className:`run-card is-${e.status}`,children:[(0,S.jsx)(Oe,{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)(ke,{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)(De,{since:e.startedAt}):xe(e.durationMs)}),(0,S.jsx)(`span`,{className:`num`,children:Se(e.costUsd)}),(0,S.jsx)(`span`,{className:`num`,children:Te(e.startedAt)})]})]},e.id)})})}function mo({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 ho({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 go(e,t){let n=e.filter(e=>e.workflow===(t.name??t.slug));return{count:n.length,last:n[0]}}function _o(e,t){return`/runs/${e.id}?workflow=${encodeURIComponent(t.name??t.slug)}`}function vo({slug:e,tab:t}){let n=U(`/api/workflows`,!1),r=U(`/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:go(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&&F(`/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)(L,{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=go(s,t);return(0,S.jsxs)(L,{href:`/workflows/${encodeURIComponent(t.slug)}`,className:`side-row wf-row${t.slug===e?` active`:``}`,children:[(0,S.jsx)(Oe,{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:Ee(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(),F(_o(n.last,t))},children:[n.count,` `,n.count===1?`run`:`runs`,` · `,(0,S.jsx)(ke,{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)(uo,{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 yo=e=>e===`ok`?`ok`:e===`running`?`running`:e===`aborted`?`aborted`:`failed`,bo=e=>e===`ok`?`done`:e===`running`?`working`:e===`aborted`?`stopped`:`failed`;function xo(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 So(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 Co(e){return e.length>64?`${e.slice(0,46)}…${e.slice(-14)}`:e}function wo(){let e=U(`/api/runs`,!1),t=U(`/api/chats`,!1),n=U(`/api/knowledge`,!1),r=U(`/api/agents`,!1),i=U(`/api/workflows`,!1),a=U(`/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)(L,{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)(Do,{runs:c,chats:l,bundles:u,agents:r?.agents??[],workflows:i?.workflows??[],filter:o,setFilter:s})]})}function To(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 Eo=[[`all`,`all`],[`run`,`runs`],[`session`,`chats`],[`knowledge`,`knowledge`]];function Do({runs:e,chats:t,bundles:n,agents:r,workflows:i,filter:a,setFilter:o}){let s=B(),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:yo(t.status),status:bo(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} · ${So(e)}`:So(e),href:xo(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:[Eo.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=To(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)(L,{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:Co(e.title)}),e.sub&&(0,S.jsx)(`span`,{className:`m3-sub`,children:Co(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:Ee(e.at)}),(0,S.jsx)(`span`,{className:`m3-chev`,children:(0,S.jsx)(C,{name:`chevron_right`})})]})]},`${e.kind}:${e.href}:${e.at}`)})})]})}var Oo=`modulepreload`,ko=function(e){return`/`+e},Ao={},jo=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=ko(t,n),t=s(t),t in Ao)return;Ao[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`:Oo,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)})},Mo=(0,v.lazy)(()=>jo(()=>import(`./editor-CHv_lIkP.js`).then(e=>({default:e.DocEditor})),__vite__mapDeps([0,1,2,3,4,5,6]))),No=()=>jo(()=>import(`./editor-CHv_lIkP.js`),__vite__mapDeps([0,1,2,3,4,5,6]));function Po({bundle:e,conceptId:t}){let n=U(`/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&&F(`/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)(L,{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)(L,{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)(Ro,{name:e,conceptId:t},e):i||n&&!a?(0,S.jsx)(Fo,{}):(0,S.jsx)(`div`,{className:`empty`,children:`loading…`})})]})}function Fo(){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):F(`/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 Io({tier:e}){return(0,S.jsx)(`span`,{className:`chip trust ${e}`,children:e})}var Lo=`@activity`;function Ro({name:e,conceptId:t}){let n=U(`/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===Lo?`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)(L,{href:o,className:r===`pages`?`active`:``,children:`pages`}),(0,S.jsx)(L,{href:`${o}/${Lo}`,className:r===`activity`?`active`:``,children:`activity`})]}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`button`,{className:`open-raw`,onClick:()=>void fa(e),children:[(0,S.jsx)(C,{name:`picture_as_pdf`,className:`ms-sm`}),` export PDF`]}),(0,S.jsx)(`button`,{className:`run-btn`,onClick:()=>void pi(`claude`,{kind:`knowledge`,bundle:e}),children:`curate in chat`})]}),r===`activity`?n.log?(0,S.jsx)(Vo,{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)(Uo,{concepts:i,base:o,selected:a})}),(0,S.jsx)(`div`,{className:`wiki-main`,children:a&&(0,S.jsx)(Go,{bundle:e,conceptId:a},a)})]})]})}function zo(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 Bo(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)(L,{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 Vo({name:e,log:t}){let n=zo(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:Bo(e,t.text)})]},n))]},t.date))})]})}function Ho(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 Uo({concepts:e,base:t,selected:n}){let r=(0,v.useMemo)(()=>Ho(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)(Wo,{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 Wo({folder:e,base:t,selected:n,closed:r,toggle:i}){return(0,S.jsxs)(S.Fragment,{children:[e.pages.map(e=>(0,S.jsxs)(L,{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)(Wo,{folder:e,base:t,selected:n,closed:r,toggle:i})})]},e.path)})]})}function Go({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),j=`/api/knowledge/${encodeURIComponent(e)}/concept?id=${encodeURIComponent(t)}`,ee=()=>{fetch(j).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(j,{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)}},[j,c]),(0,v.useEffect)(()=>{if(!n||n.raw===E.current||O.current!==null||A.current)return;let e=!0;return No().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+/,`
|
|
@@ -219,6 +219,6 @@ Instructions this agent follows when the skill applies or is invoked with /<name
|
|
|
219
219
|
`).map((e,t)=>(0,S.jsxs)(`span`,{className:ls(e),children:[e||` `,`
|
|
220
220
|
`]},t)),r&&(0,S.jsxs)(`span`,{className:`d-meta`,children:[`… diff truncated, see the rest in a terminal`,`
|
|
221
221
|
`]})]}):(0,S.jsx)(`div`,{className:`git-diff`,children:`no textual diff (binary or empty)`})}function fs(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(new Set),[i,a]=(0,v.useState)(new Set),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(``),m=(0,v.useCallback)(async()=>{try{let e=await fetch(`/api/git`,{cache:`no-store`});e.ok&&t(await e.json())}catch{}},[]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await m(),e&&(t=setTimeout(n,6e3))};return n(),()=>{e=!1,clearTimeout(t)}},[m]),(0,v.useEffect)(()=>{if(!e?.files)return;let t=new Set(e.files.filter(e=>e.syncable).map(e=>e.path));r(e=>{let n=new Set([...e].filter(e=>t.has(e)));return n.size===e.size?e:n})},[e]);let h=async(e,t)=>{l(e),d(``),p(``);try{let n=await be(`/api/git/${e}`,t);n.ok?p(e===`push`?`pushed`:e===`pull`?`pulled`:`fetched`):d(n.error||`${e} failed`)}catch(t){d(t.message||`${e} failed`)}finally{l(``)}m()},g=async()=>{l(`commit`),d(``),p(``);try{let e=await be(`/api/git/commit`,{paths:[...n],message:o});e.ok?(p(`committed ${n.size} file${n.size===1?``:`s`}`),r(new Set),s(``)):d(e.error||`commit failed`)}catch(e){d(e.message||`commit failed`)}finally{l(``)}m()};if(!e)return(0,S.jsx)(`div`,{className:`settings-screen`,children:(0,S.jsx)(`div`,{className:`ws-empty`,children:`loading…`})});if(!e.enabled)return(0,S.jsxs)(`div`,{className:`settings-screen`,children:[(0,S.jsx)(`div`,{className:`settings-head`,children:(0,S.jsxs)(`h1`,{children:[(0,S.jsx)(C,{name:`cloud_sync`,className:`ms-lg`}),` Git sync`]})}),(0,S.jsx)(`section`,{className:`panel`,children:(0,S.jsxs)(`div`,{className:`ws-empty`,children:[`Git sync is off. Turn it on in `,(0,S.jsx)(`a`,{href:`#/settings`,children:`settings`}),`, or add a `,(0,S.jsx)(`code`,{children:`git:`}),` block to kraftwerk.yml.`]})})]});let _=(e.files??[]).filter(e=>e.syncable),y=(e.files??[]).filter(e=>!e.syncable),b=(e,t)=>r(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r});return(0,S.jsxs)(`div`,{className:`settings-screen ws-screen`,children:[(0,S.jsxs)(`div`,{className:`settings-head`,children:[(0,S.jsxs)(`h1`,{children:[(0,S.jsx)(C,{name:`cloud_sync`,className:`ms-lg`}),` Git sync`]}),(0,S.jsx)(`span`,{className:`spacer`}),f&&(0,S.jsxs)(`span`,{className:`settings-saved`,children:[(0,S.jsx)(C,{name:`check`,className:`ms-sm`}),` `,f]}),u&&(0,S.jsx)(`span`,{className:`settings-err`,children:u})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`branch`}),(0,S.jsx)(`span`,{className:`spacer`}),e.lastFetch&&(0,S.jsxs)(`span`,{className:`settings-note`,title:e.lastFetch,children:[`fetched `,Ee(e.lastFetch)]}),e.lastError&&(0,S.jsxs)(`span`,{className:`settings-err git-sync-err`,title:e.lastError,children:[(0,S.jsx)(C,{name:`cloud_off`,className:`ms-sm`}),` `,e.lastError.split(`
|
|
222
|
-
`)[0]]})]}),e.error?(0,S.jsxs)(`div`,{className:`ws-empty ws-load-error`,children:[(0,S.jsx)(C,{name:`error`,className:`ms-sm`}),` `,e.error]}):(0,S.jsxs)(`div`,{className:`git-head`,children:[(0,S.jsxs)(`div`,{className:`git-branch`,children:[(0,S.jsx)(C,{name:`account_tree`,className:`ms-sm`}),(0,S.jsx)(`strong`,{children:e.branch}),e.upstream?(0,S.jsxs)(`span`,{className:`settings-note`,children:[`tracking `,e.upstream]}):(0,S.jsx)(`span`,{className:`settings-note`,children:`no upstream yet, push sets one`})]}),(0,S.jsxs)(`div`,{className:`git-counts`,children:[e.diverged&&(0,S.jsx)(`span`,{className:`git-diverged`,children:`diverged, resolve in a terminal`}),!!e.behind&&(0,S.jsxs)(`span`,{className:`git-behind`,children:[e.behind,` behind`]}),!!e.ahead&&(0,S.jsxs)(`span`,{className:`git-ahead`,children:[e.ahead,` ahead`]}),!e.ahead&&!e.behind&&(0,S.jsx)(`span`,{className:`settings-note`,children:`up to date`})]}),(0,S.jsxs)(`div`,{className:`ws-actions`,children:[(0,S.jsxs)(`button`,{className:`ws-btn`,disabled:!!c,onClick:()=>void h(`fetch`),children:[(0,S.jsx)(C,{name:c===`fetch`?`progress_activity`:`refresh`,className:`ms-sm`}),` fetch`]}),(0,S.jsxs)(`button`,{className:`ws-btn`,disabled:!!c||!e.behind||e.diverged,title:e.diverged?`Diverged. Resolve in a terminal.`:`Fast-forward to the remote`,onClick:()=>void h(`pull`),children:[(0,S.jsx)(C,{name:c===`pull`?`progress_activity`:`download`,className:`ms-sm`}),` pull`]}),(0,S.jsxs)(`button`,{className:`ws-btn primary`,disabled:!!c||!e.ahead&&!!e.upstream,title:e.upstream?`Push to the upstream`:`Push and set the upstream`,onClick:()=>void h(`push`),children:[(0,S.jsx)(C,{name:c===`push`?`progress_activity`:`upload`,className:`ms-sm`}),` push`]})]})]})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`changes`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(`span`,{className:`settings-note`,children:_.length===0?`workspace clean`:`${n.size} of ${_.length} selected`})]}),_.length===0&&y.length===0&&(0,S.jsx)(`div`,{className:`ws-empty`,children:`Nothing changed under the workspace paths.`}),_.map(e=>(0,S.jsxs)(`div`,{className:`git-row`,children:[(0,S.jsx)(`label`,{className:`git-pick`,children:(0,S.jsx)(`input`,{type:`checkbox`,checked:n.has(e.path),onChange:t=>b(e.path,t.target.checked)})}),(0,S.jsxs)(`button`,{className:`git-file`,onClick:()=>a(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n}),children:[(0,S.jsx)(C,{name:i.has(e.path)?`expand_more`:`chevron_right`,className:`ms-sm`}),(0,S.jsx)(`span`,{className:`git-status s-${e.status}`,children:e.status}),(0,S.jsx)(`span`,{className:`git-path`,children:e.path})]}),i.has(e.path)&&(0,S.jsx)(us,{file:e.path})]},e.path)),_.length>0&&(0,S.jsxs)(`div`,{className:`git-commit`,children:[(0,S.jsx)(`input`,{className:`git-message`,placeholder:`Commit message`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!c&&o.trim()&&n.size>0&&g()}}),(0,S.jsx)(`button`,{className:`ws-btn`,disabled:n.size===_.length,onClick:()=>r(new Set(_.map(e=>e.path))),children:`select all`}),(0,S.jsxs)(`button`,{className:`ws-btn primary`,disabled:!!c||n.size===0||!o.trim(),onClick:()=>void g(),children:[(0,S.jsx)(C,{name:c===`commit`?`progress_activity`:`check`,className:`ms-sm`}),`commit `,n.size||``]})]}),y.length>0&&(0,S.jsxs)(`details`,{className:`git-blocked`,children:[(0,S.jsxs)(`summary`,{children:[y.length,e.blockedHidden?`+`:``,` change`,y.length===1&&!e.blockedHidden?``:`s`,` outside the workspace paths`]}),y.map(e=>(0,S.jsxs)(`div`,{className:`git-row blocked`,children:[(0,S.jsx)(`span`,{className:`git-status s-blocked`,children:e.status}),(0,S.jsx)(`span`,{className:`git-path`,children:e.path}),(0,S.jsx)(`span`,{className:`settings-note`,children:e.reason})]},e.path)),!!e.blockedHidden&&(0,S.jsx)(`div`,{className:`git-row blocked`,children:(0,S.jsxs)(`span`,{className:`settings-note`,children:[`and `,e.blockedHidden,` more, not listed`]})})]})]}),(0,S.jsxs)(`p`,{className:`settings-note`,children:[`Synced paths: `,(e.scope??[]).map((e,t)=>(0,S.jsxs)(`span`,{children:[t>0&&`, `,(0,S.jsx)(`code`,{children:e})]},e)),`. Run artifacts and files like `,(0,S.jsx)(`code`,{children:`.env`}),` are never staged.`,` `,e.interval?`Fetches every ${ss(e.interval)}${e.autosync===`pull`?` and fast-forwards when the working tree is clean`:``}. `:`Background fetching is off. `,`Commit and push are always manual.`]})]})}var ps=e=>e.replace(/^https?:\/\//,``).replace(/^git@([^:]+):/,`$1/`).replace(/\.git$/,``),ms=e=>e.error?{label:`unreadable`,cls:`missing`}:e.dirty?{label:`${e.dirty} changed`,cls:`died`}:e.ahead?{label:`${e.ahead} to push`,cls:`running`}:e.behind?{label:`${e.behind} behind`,cls:`stopped`}:{label:`clean`,cls:`running`},hs=e=>!!(e.error||e.dirty||e.ahead===void 0||e.ahead);function gs({slug:e}){return e?(0,S.jsx)(_s,{slug:e}):(0,S.jsx)(vs,{})}function _s({slug:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(0),h=B(),g=(0,v.useCallback)(async()=>{try{let t=await fetch(`/api/repos/${encodeURIComponent(e)}`,{cache:`no-store`}),r=await t.json();if(!t.ok)throw Error(r.error||`HTTP ${t.status}`);n(r),i(``)}catch(e){i(e.message||`could not load the repository`)}},[e]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await g(),e&&(t=setTimeout(n,5e3))};return n(),()=>{e=!1,clearTimeout(t)}},[g,p]);let _=async()=>{u(`update`),f(``);try{let t=await fetch(`/api/repos/${encodeURIComponent(e)}/update`,{method:`POST`}),n=await t.json();if(!t.ok||!n.ok)throw Error(n.error||`failed`);n.error&&f(n.error)}catch(e){f(e.message)}finally{u(``),m(e=>e+1)}};if(r&&!t)return(0,S.jsxs)(`div`,{className:`settings-screen ws-screen repos-screen repo-page`,children:[(0,S.jsxs)(`div`,{className:`settings-head`,children:[(0,S.jsxs)(L,{href:`/repos`,className:`open-raw`,title:`all repositories`,children:[(0,S.jsx)(C,{name:`arrow_back`,className:`ms-sm`}),` repositories`]}),(0,S.jsxs)(`h1`,{children:[(0,S.jsx)(C,{name:`folder_data`,className:`ms-lg`}),` `,e]})]}),(0,S.jsx)(`div`,{className:`settings-err`,children:r})]});if(!t)return(0,S.jsx)(`div`,{className:`empty`,children:`loading…`});let y=ms(t),b=t.commits.filter(e=>e.local).length;return(0,S.jsxs)(`div`,{className:`settings-screen ws-screen repos-screen repo-page`,children:[(0,S.jsxs)(`div`,{className:`settings-head`,children:[(0,S.jsxs)(L,{href:`/repos`,className:`open-raw`,title:`all repositories`,children:[(0,S.jsx)(C,{name:`arrow_back`,className:`ms-sm`}),` repositories`]}),(0,S.jsxs)(`h1`,{children:[(0,S.jsx)(C,{name:`folder_data`,className:`ms-lg`}),` `,t.slug]}),t.branch&&(0,S.jsx)(`span`,{className:`repo-branch`,children:t.branch}),t.upstream&&(0,S.jsxs)(`span`,{className:`settings-note`,title:`upstream`,children:[`→ `,t.upstream]}),(0,S.jsx)(`span`,{className:`ws-state ws-state-${y.cls}`,children:y.label}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`button`,{className:`ws-btn`,disabled:!!l,onClick:()=>void _(),title:`git fetch, then fast-forward when clean`,children:[(0,S.jsx)(C,{name:l===`update`?`progress_activity`:`sync`,className:`ms-sm`}),l===`update`?`updating…`:`update`]})]}),(0,S.jsxs)(`div`,{className:`settings-note repo-facts`,children:[t.url&&(0,S.jsx)(`span`,{title:t.url,children:ps(t.url)}),h&&(0,S.jsx)(`span`,{title:t.path,children:t.path}),t.head&&(0,S.jsxs)(`span`,{children:[`at `,(0,S.jsx)(`code`,{children:t.head}),t.committedAt?` · ${Ee(t.committedAt)}`:``]}),!!t.ahead&&(0,S.jsxs)(`span`,{children:[t.ahead,` to push`]}),!!t.behind&&(0,S.jsxs)(`span`,{children:[t.behind,` behind`]}),t.updatedAt&&(0,S.jsxs)(`span`,{children:[`changed `,Ee(t.updatedAt)]})]}),(t.error||d||r)&&(0,S.jsx)(`div`,{className:`settings-err`,children:t.error||d||r}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`changes · working tree against HEAD`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`span`,{className:`settings-note`,children:[t.files.length,` file`,t.files.length===1?``:`s`,t.insertions||t.deletions?(0,S.jsxs)(S.Fragment,{children:[` · `,(0,S.jsxs)(`span`,{className:`d-add`,children:[`+`,t.insertions]}),` `,(0,S.jsxs)(`span`,{className:`d-del`,children:[`−`,t.deletions]})]}):null]})]}),t.files.length===0&&(0,S.jsx)(`div`,{className:`ws-empty`,children:`Clean — nothing changed since the last commit.`}),t.files.map(n=>(0,S.jsxs)(`div`,{className:`repo-file ${a===n.path?`open`:``}`,"data-file":n.path,children:[(0,S.jsxs)(`button`,{className:`repo-file-row`,onClick:()=>o(a===n.path?null:n.path),children:[(0,S.jsx)(C,{name:a===n.path?`expand_more`:`chevron_right`,className:`ms-sm`}),(0,S.jsx)(`span`,{className:`git-code git-code-${n.status}`,children:n.status}),(0,S.jsx)(`span`,{className:`repo-file-path`,children:n.path})]}),a===n.path&&(0,S.jsx)(ds,{url:`/api/repos/${encodeURIComponent(e)}/diff?path=${encodeURIComponent(n.path)}&v=${encodeURIComponent(t.updatedAt??``)}`})]},n.path))]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`commits · newest first`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(`span`,{className:`settings-note`,children:b?`${b} not pushed`:t.commits.length?`all pushed`:``})]}),t.commits.length===0&&(0,S.jsx)(`div`,{className:`ws-empty`,children:`No commits yet.`}),t.commits.map(t=>(0,S.jsxs)(`div`,{className:`repo-commit ${s===t.hash?`open`:``} ${t.local?`local`:``}`,"data-commit":t.short,children:[(0,S.jsxs)(`button`,{className:`repo-file-row`,onClick:()=>c(s===t.hash?null:t.hash),title:t.hash,children:[(0,S.jsx)(C,{name:s===t.hash?`expand_more`:`chevron_right`,className:`ms-sm`}),(0,S.jsx)(`code`,{children:t.short}),(0,S.jsx)(`span`,{className:`repo-file-path`,children:t.subject}),t.local&&(0,S.jsx)(`span`,{className:`chip`,children:`not pushed`}),(0,S.jsxs)(`span`,{className:`settings-note`,children:[t.author,` · `,Ee(t.committedAt)]})]}),s===t.hash&&(0,S.jsx)(ds,{url:`/api/repos/${encodeURIComponent(e)}/commits/${t.hash}`})]},t.hash))]})]})}function vs(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)({}),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(!1),[y,b]=(0,v.useState)(``),x=B(),w=(0,v.useCallback)(async()=>{try{let e=await fetch(`/api/repos`,{cache:`no-store`});if(!e.ok)throw Error(`HTTP ${e.status}`);t(await e.json()),r(``)}catch(e){r(e.message||`could not load repositories`)}},[]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await w(),e&&(t=setTimeout(n,15e3))};return n(),()=>{e=!1,clearTimeout(t)}},[w]);let T=async(e,t,n=!1)=>{a(n=>({...n,[e]:t})),s(t=>({...t,[e]:``})),l(null);try{let r=t===`update`?await fetch(`/api/repos/${encodeURIComponent(e)}/update`,{method:`POST`}):await fetch(`/api/repos/${encodeURIComponent(e)}${n?`?force=1`:``}`,{method:`DELETE`}),i=await r.json();if(!r.ok||!i.ok)throw Error(i.error||`failed`);i.error&&s(t=>({...t,[e]:i.error}))}catch(t){s(n=>({...n,[e]:t.message}))}finally{a(t=>{let n={...t};return delete n[e],n}),w()}},E=async e=>{if(e.preventDefault(),u.trim()&&!g){_(!0),b(``);try{let e=await fetch(`/api/repos`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({url:u.trim(),name:f.trim()||void 0,branch:m.trim()||void 0})}),t=await e.json();if(!e.ok)throw Error(t.error||`clone failed`);d(``),p(``),h(``),await w()}catch(e){b(e.message)}finally{_(!1)}}},D=[...e?.repos??[]].sort((e,t)=>(t.updatedAt??``).localeCompare(e.updatedAt??``));return(0,S.jsxs)(`div`,{className:`settings-screen ws-screen repos-screen`,children:[(0,S.jsxs)(`div`,{className:`settings-head`,children:[(0,S.jsxs)(`h1`,{children:[(0,S.jsx)(C,{name:`source`,className:`ms-lg`}),` Repositories`]}),(0,S.jsx)(`span`,{className:`spacer`}),e?.enabled&&(0,S.jsxs)(`span`,{className:`settings-note`,children:[D.length,` cloned`]}),n&&(0,S.jsx)(`span`,{className:`settings-err`,children:n})]}),e&&!e.enabled&&(0,S.jsx)(`section`,{className:`panel`,children:(0,S.jsx)(`div`,{className:`ws-empty`,children:e.error&&!/are off/.test(e.error)?(0,S.jsx)(`span`,{className:`settings-err`,children:e.error}):(0,S.jsxs)(S.Fragment,{children:[`Repositories are off. Turn them on in `,(0,S.jsx)(`a`,{href:`#/settings`,children:`settings`}),` or add a `,(0,S.jsx)(`code`,{children:`repos:`}),` block to kraftwerk.yml.`]})})}),e?.enabled&&(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`add a repository`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`span`,{className:`settings-note`,children:[`clones into `,(0,S.jsx)(`code`,{title:e.root,children:e.root})]})]}),(0,S.jsxs)(`form`,{className:`agent-form`,onSubmit:e=>void E(e),children:[(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:2},children:[`url`,(0,S.jsx)(`input`,{value:u,placeholder:`https://github.com/org/repo.git, git@host:org/repo.git or github:org/repo`,onChange:e=>d(e.target.value),autoFocus:!0})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`name`,(0,S.jsx)(`input`,{value:f,placeholder:`from the url`,onChange:e=>p(e.target.value)})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{width:140},children:[`branch`,(0,S.jsx)(`input`,{value:m,placeholder:`default`,onChange:e=>h(e.target.value)})]}),(0,S.jsxs)(`button`,{className:`ws-btn primary`,type:`submit`,disabled:g||!u.trim(),children:[(0,S.jsx)(C,{name:g?`progress_activity`:`download`,className:`ms-sm`}),g?`cloning…`:`clone`]})]}),y&&(0,S.jsx)(`div`,{className:`settings-err`,children:y}),(0,S.jsxs)(`div`,{className:`settings-note`,children:[`Uses your own git credentials and never prompts: a private remote must already work from a terminal. Agents see every clone here and can add more with `,(0,S.jsx)(`code`,{children:`kraftwerk repos add`}),`.`]})]})]}),e?.enabled&&(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsx)(`div`,{className:`panel-head`,children:(0,S.jsx)(`span`,{className:`microlabel`,children:`cloned repositories · newest change first`})}),D.length===0&&(0,S.jsx)(`div`,{className:`ws-empty`,children:`Nothing cloned yet.`}),D.map(e=>{let t=i[e.slug],n=ms(e);return(0,S.jsxs)(`div`,{className:`ws-row repo-row state-${n.cls}`,"data-repo":e.slug,children:[(0,S.jsx)(`span`,{className:`switcher-icon ws-icon`,children:(0,S.jsx)(C,{name:`folder_data`})}),(0,S.jsxs)(`div`,{className:`ws-main`,children:[(0,S.jsxs)(`div`,{className:`ws-title`,children:[(0,S.jsx)(L,{href:`/repos/${encodeURIComponent(e.slug)}`,className:`ws-name`,title:`changes and commits`,children:e.slug}),e.branch&&(0,S.jsx)(`span`,{className:`repo-branch`,children:e.branch}),(0,S.jsx)(`span`,{className:`ws-state ws-state-${n.cls}`,children:n.label}),e.updatedAt&&(0,S.jsxs)(`span`,{className:`vibeable-when`,title:e.updatedAt,children:[`changed `,Ee(e.updatedAt)]})]}),e.url&&(0,S.jsx)(`div`,{className:`ws-root`,title:e.url,children:ps(e.url)}),x&&(0,S.jsx)(`div`,{className:`ws-root ws-dim`,title:e.path,children:e.path}),(0,S.jsxs)(`div`,{className:`ws-meta`,children:[e.head&&(0,S.jsxs)(`span`,{title:e.committedAt,children:[(0,S.jsx)(`code`,{children:e.head}),` `,e.subject,e.committedAt?` · ${Ee(e.committedAt)}`:``]}),!!e.behind&&!!e.dirty&&(0,S.jsxs)(`span`,{children:[`behind by `,e.behind]}),e.error&&(0,S.jsx)(`span`,{className:`settings-err`,children:e.error})]}),o[e.slug]&&(0,S.jsx)(`div`,{className:`settings-err`,children:o[e.slug]})]}),(0,S.jsxs)(`div`,{className:`ws-actions`,children:[(0,S.jsxs)(L,{href:`/repos/${encodeURIComponent(e.slug)}`,className:`ws-btn`,title:`changed files with diffs, recent commits`,children:[(0,S.jsx)(C,{name:`difference`,className:`ms-sm`}),` changes`]}),(0,S.jsxs)(`button`,{className:`ws-btn`,disabled:!!t,onClick:()=>void T(e.slug,`update`),title:`git fetch, then fast-forward when clean`,children:[(0,S.jsx)(C,{name:t===`update`?`progress_activity`:`sync`,className:`ms-sm`}),t===`update`?`updating…`:`update`]}),c!==e.slug&&(0,S.jsxs)(`button`,{className:`ws-btn`,disabled:!!t,onClick:()=>l(e.slug),title:`Delete the clone`,children:[(0,S.jsx)(C,{name:`delete`,className:`ms-sm`}),` remove`]}),c===e.slug&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`button`,{className:`ws-btn danger`,onClick:()=>void T(e.slug,`remove`,hs(e)),children:[(0,S.jsx)(C,{name:`delete`,className:`ms-sm`}),e.dirty||e.ahead?`delete with local changes`:hs(e)?`delete anyway`:`confirm remove`]}),(0,S.jsx)(`button`,{className:`ws-btn`,onClick:()=>l(null),children:`cancel`})]})]})]},e.slug)})]})]})}var ys=40,bs=/Mac|iPhone|iPad/.test(navigator.platform),xs=null,Ss=e=>(e?.workspaces??[]).flatMap(e=>[...e.agents.map(t=>({kind:`agent`,agent:t,ws:e,key:`${e.url}|agent|${t.slug}`})),...(e.projects??[]).map(t=>({kind:`project`,project:t,ws:e,key:`${e.url}|project|${t.slug}`})),...(e.channels??[]).map(t=>({kind:`channel`,channel:t,ws:e,key:`${e.url}|channel|${t.slug}`}))]),Cs=e=>e.kind===`agent`?e.agent.name:e.kind===`project`?e.project.title:e.channel.name,ws=e=>e.kind===`agent`?e.agent.description:e.kind===`project`?e.project.goal||(e.project.status===`active`?void 0:e.project.status):e.channel.purpose,Ts=e=>e.kind===`agent`?`/agents/${encodeURIComponent(e.agent.slug)}`:e.kind===`project`?`/projects/${encodeURIComponent(e.project.slug)}`:`/channels/${encodeURIComponent(e.channel.slug)}`,Es={active:`📁`,paused:`⏸️`,done:`✅`,archived:`🗄️`},Ds=e=>e.kind===`agent`?e.agent.emoji:e.kind===`project`?Es[e.project.status]:(0,S.jsx)(C,{name:`forum`});function Os(e,t){let n=t.toLowerCase().split(/\s+/).filter(Boolean);if(n.length===0)return e;let r=[],i=new Map;for(let t of e){i.has(t.ws)||i.set(t.ws,i.size);let e=Cs(t).toLowerCase(),a=[e,...t.kind===`agent`?[t.agent.slug,t.agent.description??``,t.agent.group??``,`agent`]:t.kind===`project`?[t.project.slug,t.project.goal??``,t.project.status,`project`]:[t.channel.slug,t.channel.purpose??``,`channel`],t.ws.name].join(` `).toLowerCase();if(!n.every(e=>a.includes(e)))continue;let o=e.startsWith(n[0])?0:e.includes(n[0])?1:2;r.push({hit:t,score:o,ws:i.get(t.ws)})}return r.sort((e,t)=>e.ws-t.ws||e.score-t.score).map(e=>e.hit)}function ks(e){let t=[];for(let n of e){let e=t.find(e=>e.ws===n.ws);e?e.hits.push(n):t.push({ws:n.ws,hits:[n]})}return t}async function As(e){let t=Ts(e);if(e.ws.current)return F(t);let n=e.ws.live||!e.ws.root?e.ws.url:await I(e.ws.root);window.location.assign(`${n.replace(/\/+$/,``)}/#${t}`)}function js(){let[e,t]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`k`&&(e.preventDefault(),t(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`button`,{type:`button`,className:`search-btn`,onClick:()=>t(!0),title:`jump to an agent, project or channel`,"aria-label":`search`,children:[(0,S.jsx)(C,{name:`search`}),(0,S.jsx)(`kbd`,{className:`kbd`,children:bs?`⌘K`:`Ctrl K`})]}),e&&(0,S.jsx)(Ms,{onClose:()=>t(!1)})]})}function Ms({onClose:e}){let[t,n]=(0,v.useState)(xs),[r,i]=(0,v.useState)(xs===null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(0),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(``),h=(0,v.useRef)(null);(0,v.useEffect)(()=>{let e=!0;return fetch(`/api/search/agents`,{cache:`no-store`}).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status)))).then(t=>{xs=t,e&&n(t)}).catch(()=>e&&o(!0)).finally(()=>e&&i(!1)),()=>{e=!1}},[]);let g=(0,v.useMemo)(()=>Ss(t),[t]),_=(0,v.useMemo)(()=>Os(g,s).slice(0,ys),[g,s]),y=(0,v.useMemo)(()=>ks(_),[_]),b=Math.min(l,Math.max(_.length-1,0));(0,v.useEffect)(()=>{h.current?.querySelector(`[aria-selected="true"]`)?.scrollIntoView({block:`nearest`})},[b,_]);let x=t=>{if(!d){if(t.ws.current||t.ws.live){e(),As(t);return}f(t.key),m(``),As(t).catch(e=>{f(null),m(`${t.ws.name}: ${e.message}`)})}},w=t=>{if(t.key===`ArrowDown`)t.preventDefault(),u(_.length?(b+1)%_.length:0);else if(t.key===`ArrowUp`)t.preventDefault(),u(_.length?(b-1+_.length)%_.length:0);else if(t.key===`Enter`){t.preventDefault();let e=_[b];e&&x(e)}else t.key===`Escape`&&(t.preventDefault(),e())},T;if(_.length>0){let e=-1;T=(0,S.jsx)(`ul`,{className:`palette-list`,role:`listbox`,"aria-label":`agents, projects and channels`,ref:h,children:y.map(t=>(0,S.jsxs)(v.Fragment,{children:[(0,S.jsxs)(`li`,{className:`palette-group`,role:`presentation`,title:t.ws.current?`this workspace`:t.ws.url,children:[t.ws.icon&&(0,S.jsx)(`span`,{"aria-hidden":!0,children:t.ws.icon}),(0,S.jsx)(`span`,{className:`palette-group-name`,children:t.ws.name}),t.ws.current?(0,S.jsx)(`span`,{className:`palette-group-note`,children:`this workspace`}):t.ws.live?(0,S.jsx)(C,{name:`open_in_new`,className:`ms-sm`}):(0,S.jsx)(`span`,{className:`palette-chip`,children:`stopped`})]}),t.hits.map(t=>{let n=++e;return(0,S.jsxs)(`li`,{role:`option`,"aria-selected":n===b,className:`palette-item${n===b?` active`:``}`,onMouseMove:()=>n!==b&&u(n),onClick:()=>x(t),children:[(0,S.jsx)(`span`,{className:`palette-emoji`,"aria-hidden":!0,children:Ds(t)}),(0,S.jsxs)(`span`,{className:`palette-text`,children:[(0,S.jsx)(`span`,{className:`palette-name`,children:Cs(t)}),ws(t)&&(0,S.jsx)(`span`,{className:`palette-sub`,children:ws(t)})]}),d===t.key?(0,S.jsx)(C,{name:`progress_activity`,className:`ms-sm`}):t.kind!==`agent`&&(0,S.jsx)(`span`,{className:`palette-chip`,children:t.kind})]},t.key)})]},t.ws.url||t.ws.name))})}else T=a?(0,S.jsx)(`div`,{className:`palette-empty`,children:`could not load the agents, projects and channels`}):r?(0,S.jsx)(`div`,{className:`palette-empty`,children:`looking for agents, projects and channels…`}):g.length===0?(0,S.jsxs)(`div`,{className:`palette-empty`,children:[`no agents yet — `,(0,S.jsx)(`a`,{href:`#/agents/new`,onClick:e,children:`create one`})]}):(0,S.jsxs)(`div`,{className:`palette-empty`,children:[`no agent, project or channel matches “`,s,`”`]});return(0,S.jsx)(`div`,{className:`palette-backdrop`,onMouseDown:e,children:(0,S.jsxs)(`div`,{className:`palette`,role:`dialog`,"aria-label":`jump to an agent, project or channel`,onMouseDown:e=>e.stopPropagation(),onKeyDown:w,children:[(0,S.jsxs)(`div`,{className:`palette-input`,children:[(0,S.jsx)(C,{name:`search`}),(0,S.jsx)(`input`,{autoFocus:!0,value:s,onChange:e=>{c(e.target.value),u(0)},placeholder:`jump to an agent, project or channel…`,"aria-label":`search`,autoComplete:`off`,spellCheck:!1}),r&&t&&(0,S.jsx)(C,{name:`progress_activity`,className:`ms-sm`}),(0,S.jsx)(`kbd`,{className:`kbd`,children:`esc`})]}),T,(0,S.jsxs)(`div`,{className:`palette-foot`,children:[(0,S.jsxs)(`span`,{children:[(0,S.jsx)(`kbd`,{className:`kbd`,children:`↑`}),(0,S.jsx)(`kbd`,{className:`kbd`,children:`↓`}),` move`]}),(0,S.jsxs)(`span`,{children:[(0,S.jsx)(`kbd`,{className:`kbd`,children:`↵`}),` open`]}),d&&(0,S.jsxs)(`span`,{className:`palette-note`,children:[(0,S.jsx)(C,{name:`progress_activity`,className:`ms-sm`}),` starting the workspace…`]}),p&&(0,S.jsxs)(`span`,{className:`palette-warn`,title:p,children:[(0,S.jsx)(C,{name:`warning`,className:`ms-sm`}),` `,p]})]})]})})}function Ns({chatPath:e}){let t=se(),n=B(),r=U(`/api/agents`,!1,15e3),i=U(`/api/channels`,!1,6e3),a=U(t.projects?`/api/projects`:``,!1,15e3),o=e.split(`/`).filter(Boolean),s=(e,t)=>o[0]===e&&(t===void 0||(o[1]?decodeURIComponent(o[1]):void 0)===t),c=o[0]===`agents`&&o[1]===`chats`;return(0,S.jsx)(`nav`,{className:`rail`,"aria-label":`Conversations`,children:(0,S.jsxs)(`div`,{className:`rail-list`,children:[(0,S.jsxs)(L,{href:`/`,className:`rail-row rail-home${e===`/`?` active`:``}`,children:[(0,S.jsx)(`span`,{className:`rail-mark`,"aria-hidden":!0,children:(0,S.jsx)(C,{name:`home`})}),(0,S.jsxs)(`span`,{className:`rail-text`,children:[(0,S.jsx)(`span`,{className:`rail-name`,children:`Home`}),(0,S.jsx)(`span`,{className:`rail-sub`,children:`Today: what needs you, what happened`})]})]}),(0,S.jsxs)(L,{href:`/agents/chats`,className:`rail-row${c?` active`:``}`,children:[(0,S.jsx)(`span`,{className:`rail-mark`,"aria-hidden":!0,children:`🎩`}),(0,S.jsxs)(`span`,{className:`rail-text`,children:[(0,S.jsx)(`span`,{className:`rail-name`,children:`Ralv`}),(0,S.jsx)(`span`,{className:`rail-sub`,children:`Chief of staff: knows the workspace, advises, launches things`})]})]}),t.projects&&(0,S.jsxs)(`div`,{className:`rail-group`,role:`group`,"aria-label":`Projects`,children:[(0,S.jsx)(L,{href:`/projects`,className:`rail-group-head`,children:`projects`}),(a?.projects??[]).map(e=>(0,S.jsxs)(L,{href:`/projects/${encodeURIComponent(e.slug)}`,className:`rail-row${s(`projects`,e.slug)?` active`:``}`,"data-project":e.slug,children:[(0,S.jsx)(`span`,{className:`rail-mark`,"aria-hidden":!0,children:e.status===`done`?`✅`:e.status===`paused`?`⏸️`:e.status===`archived`?`🗄️`:`📁`}),(0,S.jsxs)(`span`,{className:`rail-text`,children:[(0,S.jsx)(`span`,{className:`rail-name`,children:e.title}),(e.goal||e.status!==`active`)&&(0,S.jsx)(`span`,{className:`rail-sub`,children:e.goal||e.status})]})]},e.slug)),a?.enabled&&(n||(a.projects??[]).length===0)&&(0,S.jsxs)(L,{href:`/projects/new`,className:`rail-add`,children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` new project`]})]}),(0,S.jsxs)(`div`,{className:`rail-group`,role:`group`,"aria-label":`Agents`,children:[(0,S.jsx)(L,{href:`/agents`,className:`rail-group-head`,children:`agents`}),(r?.agents??[]).filter(e=>!e.archived).map(e=>(0,S.jsxs)(L,{href:`/agents/${encodeURIComponent(e.slug)}`,className:`rail-row${s(`agents`,e.slug)||s(`team`,e.slug)?` active`:``}`,children:[(0,S.jsx)(`span`,{className:`rail-mark`,"aria-hidden":!0,children:e.emoji||`🤖`}),(0,S.jsxs)(`span`,{className:`rail-text`,children:[(0,S.jsx)(`span`,{className:`rail-name`,children:e.name}),e.description&&(0,S.jsx)(`span`,{className:`rail-sub`,children:e.description})]})]},e.slug)),n&&(0,S.jsxs)(L,{href:`/agents/new`,className:`rail-add`,children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` new agent`]})]}),(0,S.jsxs)(`div`,{className:`rail-group`,role:`group`,"aria-label":`Channels`,children:[(0,S.jsx)(L,{href:`/channels`,className:`rail-group-head`,children:`channels`}),(i?.channels??[]).map(e=>(0,S.jsxs)(L,{href:`/channels/${encodeURIComponent(e.slug)}`,className:`rail-row${s(`channels`,e.slug)?` active`:``}`,children:[(0,S.jsx)(`span`,{className:`rail-mark rail-hash`,"aria-hidden":!0,children:`#`}),(0,S.jsxs)(`span`,{className:`rail-text`,children:[(0,S.jsxs)(`span`,{className:`rail-name`,children:[e.name,(e.busy||e.awaitingApproval)&&(0,S.jsx)(`span`,{className:`lamp ${e.awaitingApproval?`blocked`:`running`}`,title:e.awaitingApproval?`waiting for your approval`:`an agent is working`})]}),(0,S.jsx)(`span`,{className:`rail-sub`,children:e.purpose||(e.members.length?`with ${e.members.map(e=>`@${e}`).join(` `)}`:`no agents yet`)})]})]},e.slug)),(0,S.jsxs)(L,{href:`/channels/new`,className:`rail-add`,children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` new channel`]})]})]})})}function Ps({path:e}){let t=B(),n=se(),r=e.split(`/`).filter(Boolean)[0]??``;if(!t)return null;let i=[{id:`workflows`,href:`/workflows`,label:`workflows`,icon:`account_tree`},{id:`knowledge`,href:`/knowledge`,label:`knowledge`,icon:`menu_book`},...n.vibeables?[{id:`vibeables`,href:`/vibeables`,label:`vibeables`,icon:`web`}]:[],{id:`skills`,href:`/skills`,label:`skills`,icon:`extension`,expert:!0},...n.repos?[{id:`repos`,href:`/repos`,label:`repositories`,icon:`source`,expert:!0}]:[],...n.git?[{id:`git`,href:`/git`,label:`git`,icon:`cloud_sync`,expert:!0,badge:(0,S.jsx)(Fs,{})}]:[],{id:`workspaces`,href:`/workspaces`,label:`workspaces`,icon:`grid_view`,expert:!0},{id:`settings`,href:`/settings`,label:`settings`,icon:`settings`,expert:!0}],a=e=>r===e||e===`workflows`&&r===`runs`;return(0,S.jsx)(`nav`,{className:`global-nav`,"aria-label":`Workspace`,children:i.map(e=>(0,S.jsxs)(`a`,{href:`#${e.href}`,className:`${e.expert?`nav-expert`:``}${a(e.id)?` active`:``}`,"aria-current":a(e.id)?`page`:void 0,children:[(0,S.jsx)(C,{name:e.icon}),` `,e.label,e.badge]},e.id))})}function Fs(){let e=U(`/api/git`,!1,15e3),t=e?.files?.filter(e=>e.syncable).length??0;return(0,S.jsxs)(S.Fragment,{children:[!!e?.behind&&(0,S.jsxs)(`span`,{className:`git-badge behind`,children:[e.behind,`↓`]}),!!e?.ahead&&(0,S.jsxs)(`span`,{className:`git-badge ahead`,children:[e.ahead,`↑`]}),!e?.ahead&&!e?.behind&&!!t&&(0,S.jsx)(`span`,{className:`git-badge dirty`,children:t})]})}function Is(e){let t=e.split(`/`).filter(Boolean),n=t[1]?decodeURIComponent(t[1]):``;return t[0]===`projects`&&n&&n!==`new`?{kind:`project`,slug:n}:t[0]===`channels`&&n&&n!==`new`?{kind:`channel`,slug:n}:(t[0]===`agents`||t[0]===`team`)&&n&&n!==`new`&&n!==`chats`?{kind:`agent`,slug:n}:{kind:`general`}}async function Ls(e){try{let t=await fetch(e,{cache:`no-store`});return t.ok?await t.json():null}catch{return null}}var Rs=(e,t)=>e.map(e=>({slug:e,found:t.has(e)}));function zs({chatPath:e,workspace:t}){let n=Is(e),r=`${n.kind}:${`slug`in n?n.slug:``}`,i=se(),a=B(),[o,s]=n.kind===`project`?[`/projects/${encodeURIComponent(n.slug)}/info`,`edit the project: brief, state, records, links`]:n.kind===`agent`?[`/agents/${encodeURIComponent(n.slug)}/info`,`edit the agent: profile and settings`]:n.kind===`channel`?[`/channels/${encodeURIComponent(n.slug)}/edit`,`edit the channel`]:a?[`/settings`,`workspace settings`]:[void 0,``],c=U(`/api/workflows`,!1,15e3),l=U(`/api/runs`,!1,6e3),u=U(`/api/knowledge`,!1,15e3),d=U(i.vibeables?`/api/vibeables`:``,!1,15e3),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(0),[g,_]=(0,v.useState)(()=>{try{return localStorage.getItem(`kw-ctx-tab`)||`workflows`}catch{return`workflows`}}),[y,b]=(0,v.useState)(0);(0,v.useEffect)(()=>{let e=()=>x(`browser`);return window.addEventListener(Vr,e),()=>window.removeEventListener(Vr,e)},[]);let x=e=>{_(e);try{localStorage.setItem(`kw-ctx-tab`,e)}catch{}},[w,T]=(0,v.useState)({});(0,v.useEffect)(()=>T(j.current?{vibeables:`/vibeables/${encodeURIComponent(j.current.slug)}`}:{}),[r]);let E=e=>T(t=>({...t,[P]:e})),D=()=>T(e=>({...e,[P]:null})),O=e=>t=>t.startsWith(e)?(T(e=>({...e,[P]:t})),!0):!1,[k,A]=(0,v.useState)(null),j=(0,v.useRef)(null);(0,v.useEffect)(()=>{let e=e=>{let t=e.detail;j.current=t,A(t),t?(x(`vibeables`),T(e=>({...e,vibeables:`/vibeables/${encodeURIComponent(t.slug)}`}))):T(e=>e.vibeables?.startsWith(`/vibeables/`)?{...e,vibeables:null}:e)};return window.addEventListener(Yr,e),()=>window.removeEventListener(Yr,e)},[]);let ee=i.vibeables&&!!(f?.all||f?.vibeables||k),M=i.repos&&!!f?.repos,N=[{id:`workflows`,label:`workflows`,count:f?.workflows.length,allHref:`/workflows`},{id:`knowledge`,label:`knowledge`,count:f?.knowledge.length,allHref:`/knowledge`},...ee?[{id:`vibeables`,label:`vibeables`,count:f?.all?d?.vibeables.length:f?.vibeables?.length,allHref:`/vibeables`}]:[],...M?[{id:`repos`,label:`repositories`,count:f?.repos?.length,allHref:`/repos`}]:[],...f?.agents?[{id:`agents`,label:`agents`,count:f.agents.length,allHref:`/agents`}]:[],...f?.records&&f.records.length>0?[{id:`records`,label:`records`,count:f.records.length}]:[],{id:`browser`,label:`browser`,count:y}],P=N.some(e=>e.id===g)?g:`workflows`,F=N.find(e=>e.id===P),I=w[P]??null,ne=!!k&&P===`vibeables`&&I===`/vibeables/${encodeURIComponent(k.slug)}`,re=e=>t=>{t.metaKey||t.ctrlKey||t.shiftKey||t.button!==0||(t.preventDefault(),E(e))};(0,v.useEffect)(()=>{let e=setInterval(()=>h(e=>e+1),15e3);return()=>clearInterval(e)},[]),(0,v.useEffect)(()=>{let e=!0,r=new Set((c?.workflows??[]).map(e=>e.slug)),i=new Set((u?.bundles??[]).map(e=>e.name));return(async()=>{let a=null;if(n.kind===`agent`){let e=await Ls(`/api/agents/${encodeURIComponent(n.slug)}`);e&&(a={title:`${e.emoji?`${e.emoji} `:``}${e.name}`,workflows:Rs(e.workflows,r),knowledge:Rs(e.knowledge,i),editHref:`/agents/${encodeURIComponent(n.slug)}/edit`})}else if(n.kind===`project`){let e=await Ls(`/api/projects/${encodeURIComponent(n.slug)}`);e&&(a={title:`📁 ${e.title}`,workflows:e.links.workflows,knowledge:e.links.knowledge,vibeables:e.links.vibeables,repos:e.links.repos,agents:e.links.agents,records:e.records,editHref:`/projects/${encodeURIComponent(n.slug)}/info`})}else if(n.kind===`channel`){let e=(await Ls(`/api/channels`))?.channels.find(e=>e.slug===n.slug);if(e){let t=(await Promise.all(e.members.map(e=>Ls(`/api/agents/${encodeURIComponent(e)}`)))).filter(e=>!!e),o=e=>[...new Set(t.flatMap(e))];a={title:`#${e.slug}`,workflows:Rs(o(e=>e.workflows),r),knowledge:Rs(o(e=>e.knowledge),i),agents:e.members.map(e=>({slug:e,found:t.some(t=>t.slug===e),label:t.find(t=>t.slug===e)?.name})),editHref:`/channels/${encodeURIComponent(n.slug)}/edit`}}}else a={title:`${t.icon?`${t.icon} `:``}${t.name||`workspace`}`,workflows:Rs([...r],r),knowledge:Rs([...i],i),all:!0};e&&p(a)})(),()=>{e=!1}},[r,m,c,u,t.name,t.icon]);let R=e=>c?.workflows.find(t=>t.slug===e),z=e=>e?l?.runs.find(t=>t.workflow===(e.name??e.slug)||t.workflow===e.slug):void 0,ie=e=>u?.bundles.find(t=>t.name===e),ae=e=>d?.vibeables.find(t=>t.slug===e),oe=e=>(0,S.jsxs)(`div`,{className:`ctx-empty`,children:[f?.all?`No ${e} in this workspace yet.`:`No ${e} linked.`,f?.editHref&&a&&!f.all&&(0,S.jsxs)(S.Fragment,{children:[` `,(0,S.jsx)(L,{href:f.editHref,children:`Edit the links`}),`.`]})]});return(0,S.jsxs)(`aside`,{className:`ctx`,"aria-label":`Context`,children:[(0,S.jsxs)(`div`,{className:`ctx-head${f?` sign-in`:``}`,children:[(0,S.jsx)(`span`,{className:`ctx-title`,title:f?.title,children:f?f.title:`…`}),o&&(0,S.jsx)(L,{href:o,className:`ctx-edit`,title:s,"aria-label":s,children:(0,S.jsx)(C,{name:`edit`,className:`ms-sm`})})]},f?.title??``),(0,S.jsx)(`div`,{className:`ctx-tabs`,role:`tablist`,"aria-label":`Categories`,children:N.map(e=>(0,S.jsxs)(`button`,{role:`tab`,className:`ctx-tab`,"aria-selected":e.id===P,onClick:()=>x(e.id),children:[e.label,e.count!==void 0&&(0,S.jsx)(`span`,{className:`ctx-tab-n num`,children:e.count})]},e.id))}),I&&(0,S.jsxs)(`div`,{className:`ctx-open-head`,children:[(0,S.jsxs)(`button`,{className:`open-raw`,onClick:D,"aria-label":`Back to the list`,children:[(0,S.jsx)(C,{name:`arrow_back`,className:`ms-sm`}),` `,F?.label]}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(L,{href:I,className:`ctx-all`,title:`Open as a page`,children:[`page `,(0,S.jsx)(C,{name:`open_in_new`,className:`ms-sm`})]})]}),I&&P===`knowledge`&&(0,S.jsx)(`div`,{className:`ctx-body ctx-embed`,children:(0,S.jsx)(te.Provider,{value:O(`/knowledge/`),children:(()=>{let e=I.split(`/`).filter(Boolean),t=decodeURIComponent(e[1]??``),n=e.length>2?e.slice(2).map(decodeURIComponent).join(`/`):void 0;return(0,S.jsx)(Ro,{name:t,conceptId:n},t)})()})}),I&&P===`workflows`&&(0,S.jsx)(`div`,{className:`ctx-body ctx-embed`,children:(0,S.jsx)(te.Provider,{value:O(`/workflows/`),children:(()=>{let e=I.split(`/`).filter(Boolean),t=e[2]===`details`||e[2]===`runs`?e[2]:`overview`;return(0,S.jsx)(uo,{slug:decodeURIComponent(e[1]??``),tab:t},e[1])})()})}),I&&P===`vibeables`&&!ne&&(0,S.jsx)(`div`,{className:`ctx-body ctx-embed ctx-embed-vibe`,children:(0,S.jsx)($r,{slug:decodeURIComponent(I.split(`/`).filter(Boolean)[1]??``)},I)}),(0,S.jsx)(`div`,{id:Xr,className:`ctx-body ctx-embed ctx-embed-vibe`,hidden:!ne}),(0,S.jsx)(`div`,{className:`ctx-body ctx-embed ctx-browser`,hidden:P!==`browser`,children:(0,S.jsx)(Jr,{storeKey:r,onTabs:b},r)}),(0,S.jsxs)(`div`,{className:`ctx-body`,role:`tabpanel`,hidden:P===`browser`||!!I&&[`knowledge`,`workflows`,`vibeables`].includes(P),children:[F?.allHref&&(0,S.jsxs)(`div`,{className:`ctx-section-head`,children:[(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(L,{href:F.allHref,className:`ctx-all`,children:[`all `,F.label,` `,(0,S.jsx)(C,{name:`arrow_forward`,className:`ms-sm`})]})]}),P===`workflows`&&(0,S.jsxs)(S.Fragment,{children:[f&&f.workflows.length===0&&oe(`workflows`),f?.workflows.map(({slug:e,found:t})=>{let n=R(e),r=z(n);return(0,S.jsxs)(L,{href:`/workflows/${encodeURIComponent(e)}`,className:`ctx-row${t?``:` missing`}`,onClick:t?re(`/workflows/${encodeURIComponent(e)}`):void 0,children:[(0,S.jsx)(Oe,{status:!t||n?.error?`failed`:r?.status??`idle`}),(0,S.jsxs)(`span`,{className:`ctx-text`,children:[(0,S.jsx)(`span`,{className:`ctx-name`,children:n?.name??e}),(0,S.jsx)(`span`,{className:`ctx-sub`,children:t?n?.error?`broken`:r?`${r.status} · ${Ee(r.updatedAt)}`:n?.description??`no runs yet`:`not in this workspace`})]}),t&&!n?.error&&(0,S.jsx)(C,{name:`chevron_right`,className:`ctx-go ms-sm`})]},e)})]}),P===`knowledge`&&(0,S.jsxs)(S.Fragment,{children:[f&&f.knowledge.length===0&&oe(`knowledge`),f?.knowledge.map(({slug:e,found:t})=>{let n=ie(e);return(0,S.jsxs)(L,{href:`/knowledge/${encodeURIComponent(e)}`,className:`ctx-row${t?``:` missing`}`,onClick:t?re(`/knowledge/${encodeURIComponent(e)}`):void 0,children:[(0,S.jsx)(C,{name:`menu_book`,className:`ctx-icon ms-sm`}),(0,S.jsxs)(`span`,{className:`ctx-text`,children:[(0,S.jsx)(`span`,{className:`ctx-name`,children:e}),(0,S.jsx)(`span`,{className:`ctx-sub`,children:t?n?`${n.concepts} ${n.concepts===1?`page`:`pages`}${n.updatedAt?` · ${Ee(n.updatedAt)}`:``}`:``:`not in this workspace`})]})]},e)})]}),P===`vibeables`&&f&&(0,S.jsxs)(S.Fragment,{children:[(f.all?(d?.vibeables??[]).map(e=>({slug:e.slug,found:!0})):f.vibeables??[]).map(({slug:e,found:t})=>{let n=ae(e);return(0,S.jsxs)(L,{href:`/vibeables/${encodeURIComponent(e)}`,className:`ctx-row${t?``:` missing`}`,onClick:t?re(`/vibeables/${encodeURIComponent(e)}`):void 0,children:[(0,S.jsx)(C,{name:`web`,className:`ctx-icon ms-sm`}),(0,S.jsxs)(`span`,{className:`ctx-text`,children:[(0,S.jsx)(`span`,{className:`ctx-name`,children:e}),(0,S.jsx)(`span`,{className:`ctx-sub`,children:t?n?.updatedAt?`changed ${Ee(n.updatedAt)}`:``:`not in this workspace`})]})]},e)}),f.all&&d&&d.vibeables.length===0&&oe(`vibeables`),!f.all&&f.vibeables?.length===0&&oe(`vibeables`)]}),P===`repos`&&f?.repos&&(0,S.jsxs)(S.Fragment,{children:[f.repos.length===0&&oe(`repositories`),f.repos.map(({slug:e,found:t})=>(0,S.jsxs)(L,{href:`/repos/${encodeURIComponent(e)}`,className:`ctx-row${t?``:` missing`}`,children:[(0,S.jsx)(C,{name:`source`,className:`ctx-icon ms-sm`}),(0,S.jsxs)(`span`,{className:`ctx-text`,children:[(0,S.jsx)(`span`,{className:`ctx-name`,children:e}),!t&&(0,S.jsx)(`span`,{className:`ctx-sub`,children:`not in this workspace`})]})]},e))]}),P===`agents`&&f?.agents&&(0,S.jsxs)(S.Fragment,{children:[f.agents.length===0&&oe(`agents`),f.agents.map(({slug:e,found:t,label:n})=>(0,S.jsxs)(L,{href:`/agents/${encodeURIComponent(e)}`,className:`ctx-row${t?``:` missing`}`,children:[(0,S.jsx)(C,{name:`person`,className:`ctx-icon ms-sm`}),(0,S.jsxs)(`span`,{className:`ctx-text`,children:[(0,S.jsx)(`span`,{className:`ctx-name`,children:n??e}),!t&&(0,S.jsx)(`span`,{className:`ctx-sub`,children:`not in this workspace`})]})]},e))]}),P===`records`&&f?.records&&(0,S.jsx)(S.Fragment,{children:f.records.map((e,t)=>(0,S.jsxs)(`a`,{href:e.url||void 0,target:`_blank`,rel:`noopener`,className:`ctx-row`,children:[(0,S.jsx)(C,{name:`open_in_new`,className:`ctx-icon ms-sm`}),(0,S.jsxs)(`span`,{className:`ctx-text`,children:[(0,S.jsx)(`span`,{className:`ctx-name`,children:e.title||e.kind}),e.note&&(0,S.jsx)(`span`,{className:`ctx-sub`,children:e.note})]})]},t))})]},P)]})}var Bs=`kw-chat-path`,Vs=`kw-ctx-w`,Hs=()=>{try{let e=Number(localStorage.getItem(Vs));return e>0?e:null}catch{return null}};function Us({onResize:e}){let[t,n]=(0,v.useState)(!1);return(0,S.jsx)(`div`,{className:`split-handle${t?` dragging`:``}`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`resize chat and context`,title:`drag to resize · double-click for half and half`,onPointerDown:t=>{if(t.button!==0)return;let r=t.currentTarget.closest(`.shell`);if(!r)return;t.preventDefault();let i=r.getBoundingClientRect().right-parseFloat(getComputedStyle(r).paddingRight),a=t=>e(Math.round(i-t.clientX)),o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o),document.body.classList.remove(`kw-resizing`),n(!1)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o),document.body.classList.add(`kw-resizing`),n(!0)},onDoubleClick:()=>e(null)})}var Ws=(e,t)=>{try{return sessionStorage.getItem(e)||t}catch{return t}},Gs=(e,t)=>{try{sessionStorage.setItem(e,t)}catch{}};function Ks(){let e=w(),[t]=e.split(`?`),n=t.split(`/`).filter(Boolean),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(!0),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)([]),_=ee.has(n[0]??``),y=n.length===0,[b,x]=(0,v.useState)(()=>Ws(Bs,`/agents/chats`)),T=_?Ia(t):null,E=_&&!T?t:b,[D,O]=(0,v.useState)(`chat`),[k,j]=(0,v.useState)(Hs),P=e=>{j(e);try{e===null?localStorage.removeItem(Vs):localStorage.setItem(Vs,String(e))}catch{}};(0,v.useEffect)(()=>{_&&!Ia(t)&&(x(t),Gs(Bs,t))},[e]),(0,v.useEffect)(()=>{let e=e=>{let t=e.detail;M(t)===`chat`?(x(t),Gs(Bs,t)):window.location.replace(`#${t}`)};return window.addEventListener(N,e),()=>window.removeEventListener(N,e)},[]),(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{try{let t=await fetch(`/api/meta`,{cache:`no-store`}).then(e=>e.json());if(!e)return;i(t.projectName??``),o(t.projectIcon??``),c(t.projectColor??``),u(t.projectNamed!==!1),f(t.projectRootLabel??``),m(t.projectRoot??``),oe({git:!!t.git,repos:!!t.repos,vibeables:!!t.vibeables,projects:!!t.projects}),g(Array.isArray(t.switcher)?t.switcher:[])}catch{}e&&(t=setTimeout(n,3e4))};n();let r=()=>{clearTimeout(t),n()};return window.addEventListener(`kw-meta-refresh`,r),()=>{e=!1,clearTimeout(t),window.removeEventListener(`kw-meta-refresh`,r)}},[]),(0,v.useEffect)(()=>{if(A(r?`${r} — kraftwerk`:`kraftwerk inspector`),!a)return;let e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y="0.9em" font-size="85">${a}</text></svg>`,t=document.querySelector(`link[rel="icon"]`);t||(t=document.createElement(`link`),t.rel=`icon`,document.head.appendChild(t)),t.href=`data:image/svg+xml,${encodeURIComponent(e)}`},[r,a]);let F=E.split(`/`).filter(Boolean),I=new URLSearchParams(e.split(`?`)[1]??``).get(`workflow`)??void 0,te;te=F[0]===`chats`?(0,S.jsx)(ya,{seg:F}):F[0]===`projects`?(0,S.jsx)(Qi,{seg:F.slice(1)}):F[0]===`channels`?(0,S.jsx)(ai,{seg:F.slice(1)}):(0,S.jsx)(ya,{seg:F.slice(1)});let L=null;return n[0]===`runs`&&n[1]?L=(0,S.jsx)(za,{id:n[1],workflow:I}):n[0]===`runs`?L=(0,S.jsx)($s,{}):n[0]===`workflows`?L=(0,S.jsx)(vo,{slug:n[1]?decodeURIComponent(n[1]):void 0,tab:n[2]===`details`||n[2]===`runs`?n[2]:`overview`}):n[0]===`vibeables`?L=(0,S.jsx)(ri,{slug:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`knowledge`?L=(0,S.jsx)(Po,{bundle:n[1]?decodeURIComponent(n[1]):void 0,conceptId:n.length>2?n.slice(2).map(decodeURIComponent).join(`/`):void 0}):n[0]===`skills`?L=(0,S.jsx)(Jo,{name:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`settings`?L=(0,S.jsx)(is,{}):n[0]===`workspaces`?L=(0,S.jsx)(os,{}):n[0]===`git`?L=(0,S.jsx)(fs,{}):n[0]===`repos`&&(L=(0,S.jsx)(gs,{slug:n[1]?decodeURIComponent(n[1]):void 0})),(0,v.useEffect)(()=>{let e=document.documentElement,t=p||r,n=t?_e(ce(s,t)):null;if(!n){delete e.dataset.wsAccent;return}for(let[t,r]of Object.entries(n))e.style.setProperty(t,r);e.dataset.wsAccent=``},[s,p,r]),(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`header`,{className:`topbar`,style:{"--ws-c":ce(s,p||r)},children:[(0,S.jsxs)(`span`,{className:`wordmark`,children:[(0,S.jsx)(`a`,{href:`#/`,className:`home-link`,title:`Dashboard`,children:r?(0,S.jsx)(ye,{className:`home-tile`,icon:a,name:r,color:s,seed:p||r}):(0,S.jsx)(C,{name:`home`})}),r&&(0,S.jsx)(Qs,{name:r,icon:a,color:s,named:l,root:d,seed:p||r,entries:h})]}),(0,S.jsx)(Ps,{path:t}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(js,{}),(0,S.jsx)(oc,{}),(0,S.jsx)(nc,{}),(0,S.jsx)(rc,{}),(0,S.jsx)(sc,{})]}),L&&(0,S.jsx)(`main`,{className:`shell shell-global`,children:L}),(0,S.jsxs)(`main`,{className:`shell three${y?` home`:``}`,"data-focus":D,hidden:!!L,style:k?{"--ctx-w":`${k}px`}:void 0,children:[(0,S.jsx)(Ns,{chatPath:y?`/`:E}),(0,S.jsxs)(`section`,{className:`col-chat`,"aria-label":y?`Dashboard`:`Conversation`,children:[y?(0,S.jsx)(wo,{}):te,(0,S.jsx)(Us,{onResize:P})]}),(0,S.jsx)(zs,{chatPath:y?`/`:E,workspace:{name:r,icon:a}}),T&&(0,S.jsx)(La,{back:E,children:T})]}),!L&&(0,S.jsxs)(`nav`,{className:`places`,"aria-label":`Sections`,children:[(0,S.jsxs)(`button`,{className:D===`chat`?`active`:``,onClick:()=>O(`chat`),children:[(0,S.jsx)(C,{name:`forum`}),` chat`]}),(0,S.jsxs)(`button`,{className:D===`context`?`active`:``,onClick:()=>O(`context`),children:[(0,S.jsx)(C,{name:`account_tree`}),` context`]})]})]})}function qs(e){try{let t=new URL(e);return t.hostname===`localhost`||t.hostname===`127.0.0.1`?`:${t.port||(t.protocol===`https:`?443:80)}`:t.host}catch{return e.replace(/^https?:\/\//,``)}}function Js({label:e}){return e?(0,S.jsx)(`span`,{className:`switcher-root`,title:e,children:(0,S.jsx)(`span`,{dir:`ltr`,children:e})}):null}function Ys({name:e,named:t}){let n=t===!1;return(0,S.jsx)(`span`,{className:`switcher-name${n?` unnamed`:``}`,title:n?`${e} — folder name; set name: in kraftwerk.yml`:e,children:e})}function Xs({entry:e,ambiguous:t}){let[n,r]=(0,v.useState)(`idle`),[i,a]=(0,v.useState)(``),o=e.exists===!1,s=async()=>{r(`starting`),a(``);try{window.location.assign(await I(e.root))}catch(e){r(`error`),a(e.message)}};return(0,S.jsxs)(`span`,{className:`switcher-item stopped ${o?`missing`:``}`,role:`menuitem`,style:{"--ws-c":ce(e.color,e.root??e.url)},children:[(0,S.jsx)(ye,{icon:e.icon,name:e.name,color:e.color,seed:e.root??e.url,ambiguous:t}),(0,S.jsxs)(`span`,{className:`switcher-text`,children:[(0,S.jsx)(Ys,{name:e.name,named:e.named}),n===`error`?(0,S.jsx)(`span`,{className:`switcher-sub switcher-err`,title:i,children:i}):o?(0,S.jsx)(`span`,{className:`switcher-sub`,children:`folder missing`}):(0,S.jsx)(Js,{label:e.rootLabel})]}),(0,S.jsxs)(`span`,{className:`switcher-side`,children:[(0,S.jsx)(`span`,{className:`switcher-port`,children:qs(e.url)}),(0,S.jsxs)(`button`,{className:`switcher-start`,disabled:o||n===`starting`,title:o?`The project folder no longer exists`:`Start the UI for this project`,onClick:e=>{e.stopPropagation(),s()},children:[n===`starting`?(0,S.jsx)(C,{name:`progress_activity`}):(0,S.jsx)(C,{name:`play_arrow`}),n===`starting`?`starting`:`start`]})]})]})}function Zs({entry:e,ambiguous:t}){let n=e.root??e.url;return(0,S.jsxs)(`a`,{className:`switcher-item${e.live?` live`:``}`,role:`menuitem`,href:e.url,style:{"--ws-c":ce(e.color,n)},children:[(0,S.jsx)(ye,{icon:e.icon,name:e.name,color:e.color,seed:n,ambiguous:t}),(0,S.jsxs)(`span`,{className:`switcher-text`,children:[(0,S.jsx)(Ys,{name:e.name,named:e.named}),(0,S.jsx)(Js,{label:e.rootLabel??(e.root?void 0:e.url.replace(/^https?:\/\//,``))})]}),(0,S.jsx)(`span`,{className:`switcher-side`,children:(0,S.jsxs)(`span`,{className:`switcher-port`,children:[e.live&&(0,S.jsx)(`span`,{className:`live-dot`,title:`running`}),qs(e.url)]})})]})}function Qs({name:e,icon:t,color:n,named:r,root:i,seed:a,entries:o}){let[s,c]=(0,v.useState)(!1),l=B();if((0,v.useEffect)(()=>{if(!s)return;let e=e=>{e.target.closest(`.switcher-wrap`)||c(!1)};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[s]),o.length===0)return(0,S.jsx)(`span`,{className:`env-name`,title:i||`Project (kraftwerk.yml: name)`,children:e});let u=new Map;for(let e of[t,...o.map(e=>e.icon)])e&&u.set(e,(u.get(e)??0)+1);let d=e=>!!e&&(u.get(e)??0)>1,f=[{key:`running`,label:`running`,items:o.filter(e=>e.live===!0)},{key:`stopped`,label:`stopped`,items:o.filter(e=>e.live===!1)},{key:`linked`,label:`linked`,items:o.filter(e=>e.live===void 0)}].filter(e=>e.items.length>0),p=a||e;return(0,S.jsxs)(`span`,{className:`switcher-wrap`,children:[(0,S.jsxs)(`button`,{className:`env-name env-switch`,title:i?`${i} — switch workspace`:`Switch workspace`,"aria-haspopup":`menu`,"aria-expanded":s,onClick:()=>c(e=>!e),children:[e,(0,S.jsx)(C,{name:`expand_more`})]}),s&&(0,S.jsxs)(`div`,{className:`switcher-pop`,role:`menu`,children:[(0,S.jsx)(`div`,{className:`switcher-head`,children:`Workspaces`}),(0,S.jsxs)(`span`,{className:`switcher-item current`,"aria-current":`true`,style:{"--ws-c":ce(n,p)},children:[(0,S.jsx)(ye,{icon:t,name:e,color:n,seed:p,ambiguous:d(t)}),(0,S.jsxs)(`span`,{className:`switcher-text`,children:[(0,S.jsx)(Ys,{name:e,named:r}),i?(0,S.jsx)(Js,{label:i}):(0,S.jsx)(`span`,{className:`switcher-sub`,children:`this workspace`})]}),(0,S.jsx)(`span`,{className:`switcher-side`,children:(0,S.jsx)(C,{name:`check`,className:`switcher-check`})})]}),f.map(e=>(0,S.jsxs)(`div`,{className:`switcher-group switcher-group-${e.key}`,role:`group`,"aria-label":e.label,children:[(0,S.jsx)(`div`,{className:`switcher-group-head`,children:e.label}),e.items.map(e=>e.live===!1&&e.root?(0,S.jsx)(Xs,{entry:e,ambiguous:d(e.icon)},e.root):(0,S.jsx)(Zs,{entry:e,ambiguous:d(e.icon)},e.root??e.url))]},e.key)),l&&(0,S.jsxs)(`a`,{className:`switcher-foot`,href:`#/workspaces`,role:`menuitem`,onClick:()=>c(!1),children:[(0,S.jsx)(C,{name:`hub`}),` manage workspaces`]})]})]})}function $s(){let[e,t]=(0,v.useState)(null);return(0,v.useEffect)(()=>{let e=!0;return fetch(`/api/runs`).then(e=>e.json()).then(n=>{e&&(n.runs.length>0?F(`/runs/${n.runs[0].id}`,{replace:!0}):t({outputDir:n.outputDir}))}).catch(()=>{}),()=>{e=!1}},[]),e?(0,S.jsxs)(`div`,{className:`empty`,children:[`No runs found in `,(0,S.jsx)(`code`,{children:e.outputDir}),`. Start one from the`,` `,(0,S.jsx)(`a`,{href:`#/workflows`,children:`workflows`}),` list or with `,(0,S.jsx)(`code`,{children:`kraftwerk run <workflow> [request]`}),`.`]}):(0,S.jsx)(`div`,{className:`empty`,children:`loading…`})}async function ec(e){await fetch(`/api/restart`,{method:`POST`}).catch(()=>{});for(let t=0;t<60;t++){await new Promise(e=>setTimeout(e,500));try{if((await fetch(`/api/meta`,{cache:`no-store`}).then(e=>e.json())).version===e)break}catch{}}location.reload()}var tc=`kw-version-changed`;function nc(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(!1);(0,v.useEffect)(()=>{let e=!0,n,r=async()=>{clearTimeout(n);try{let n=await fetch(`/api/meta`,{cache:`no-store`}).then(e=>e.json());e&&t(n)}catch{}e&&(n=setTimeout(r,3e4))};r();let i=()=>void r();return window.addEventListener(tc,i),()=>{e=!1,clearTimeout(n),window.removeEventListener(tc,i)}},[]);let i=e?.restartable&&e.diskVersion&&e.diskVersion!==e.version?e.diskVersion:null;async function a(){i&&(r(!0),await ec(i))}return!i&&!n?null:(0,S.jsx)(`button`,{className:`relaunch-note`,disabled:n,title:`v${i} is installed on disk, the server still runs v${e?.version}. Click to relaunch with the new version.`,onClick:()=>void a(),children:n?`relaunching…`:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(C,{name:`restart_alt`,className:`ms-sm`}),` v`,i,` ready — relaunch`]})})}function rc(){let e=B();return(0,S.jsxs)(`button`,{className:`expert-toggle ${e?`on`:``}`,title:e?`Expert mode on — full detail`:`Expert mode off — simplified view`,"aria-pressed":e,onClick:()=>z(!e),children:[(0,S.jsx)(`span`,{className:`expert-track`,children:(0,S.jsx)(`span`,{className:`expert-knob`})}),`expert`]})}var ic={approval:`gavel`,routine_done:`schedule`,routine_failed:`schedule`,run_done:`account_tree`,run_failed:`account_tree`},ac=`kw.notif.toast.dismissed`;function oc(){let[e,t]=(0,v.useState)(!1),n=U(`/api/notifications`,!1,5e3),[r,i]=(0,v.useState)(()=>typeof Notification>`u`?`unsupported`:Notification.permission),[a,o]=(0,v.useState)(()=>{try{return localStorage.getItem(ac)===`1`}catch{return!1}}),s=(0,v.useRef)(null),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(null);(0,v.useEffect)(()=>l(null),[n]);let f=c??n,p=f?.items??[],m=f?.unread??0;(0,v.useEffect)(()=>k(m),[m]),(0,v.useEffect)(()=>{if(n){if(!s.current){s.current=new Set(p.map(e=>e.id));return}for(let e of p)if(!s.current.has(e.id)&&(s.current.add(e.id),!(e.readAt||r!==`granted`)&&(document.hidden||location.hash!==`#${e.href}`)))try{let t=new Notification(e.title,{body:e.body,tag:e.id});t.onclick=()=>{window.focus(),g(e),t.close()}}catch{}}},[n]),(0,v.useEffect)(()=>{if(!e)return;let n=e=>{e.target.closest(`.notif-wrap`)||t(!1)};return window.addEventListener(`mousedown`,n),()=>window.removeEventListener(`mousedown`,n)},[e]);async function h(e,t){try{let n=await fetch(e,{method:e.endsWith(`/notifications`)?`DELETE`:`POST`,headers:{"content-type":`application/json`},body:t===void 0?void 0:JSON.stringify(t)});if(!n.ok)return;let r=await n.json();l(`items`in r?r:{items:[],unread:0})}catch{}}function g(e){t(!1),e.readAt||h(`/api/notifications/read`,{ids:[e.id]}),F(e.href)}async function _(e){d(e.id);try{let n=await(await fetch(`/api/notifications/${encodeURIComponent(e.id)}/diagnose`,{method:`POST`})).json();n.href?(t(!1),F(n.href)):n.error&&alert(n.error)}catch{}d(null)}async function y(){typeof Notification>`u`||i(await Notification.requestPermission())}function b(){o(!0);try{localStorage.setItem(ac,`1`)}catch{}}let x=r==="default"&&!a;return(0,S.jsxs)(`span`,{className:`notif-wrap`,children:[(0,S.jsxs)(`button`,{className:`info-btn notif-btn ${m?`has-unread`:``}`,title:m?`${m} item${m===1?``:`s`} need your attention`:`Notifications`,"aria-label":`Notifications`,onClick:()=>t(e=>!e),children:[(0,S.jsx)(C,{name:m?`notifications_active`:`notifications`}),m>0&&(0,S.jsx)(`span`,{className:`notif-badge`,children:m>99?`99+`:m})]}),e&&(0,S.jsxs)(`div`,{className:`info-pop notif-pop`,role:`menu`,children:[(0,S.jsxs)(`div`,{className:`notif-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`notifications`}),(0,S.jsx)(`span`,{className:`spacer`}),m>0&&(0,S.jsx)(`button`,{className:`open-raw`,onClick:()=>void h(`/api/notifications/read`),children:`mark all read`}),p.length>0&&(0,S.jsx)(`button`,{className:`open-raw`,onClick:()=>void h(`/api/notifications`),children:`clear`})]}),x&&(0,S.jsxs)(`div`,{className:`notif-hint`,children:[(0,S.jsx)(`span`,{children:`Get a system notification when something needs you, even with this tab in the background.`}),(0,S.jsxs)(`span`,{className:`notif-hint-actions`,children:[(0,S.jsx)(`button`,{className:`ws-btn primary`,onClick:()=>void y(),children:`enable`}),(0,S.jsx)(`button`,{className:`ws-btn`,onClick:b,children:`not now`})]})]}),r===`denied`&&(0,S.jsx)(`div`,{className:`notif-hint muted`,children:`Browser notifications are blocked for this site — allow them in the address bar to get system alerts.`}),p.length===0?(0,S.jsx)(`div`,{className:`notif-empty`,children:`nothing needs you right now`}):(0,S.jsx)(`div`,{className:`notif-list`,children:p.slice(0,50).map(e=>(0,S.jsxs)(`div`,{className:`notif-row ${e.readAt?``:`unread`} ${e.kind}`,role:`button`,tabIndex:0,onClick:()=>g(e),onKeyDown:t=>{t.key===`Enter`&&g(e)},children:[(0,S.jsx)(`span`,{className:`notif-ico`,children:(0,S.jsx)(C,{name:ic[e.kind]})}),(0,S.jsxs)(`span`,{className:`notif-body`,children:[(0,S.jsx)(`span`,{className:`notif-title`,children:e.title}),e.body&&(0,S.jsx)(`span`,{className:`notif-sub`,children:e.body}),e.diagnose&&(0,S.jsx)(`span`,{className:`notif-actions`,children:(0,S.jsxs)(`button`,{className:`ws-btn notif-diagnose`,disabled:u===e.id,title:`Open a chat that finds the cause and proposes the fix`,onClick:t=>{t.stopPropagation(),_(e)},children:[(0,S.jsx)(C,{name:u===e.id?`progress_activity`:`troubleshoot`,className:`ms-sm`}),u===e.id?`starting…`:`diagnose`]})})]}),(0,S.jsx)(`span`,{className:`notif-when num`,children:Ee(e.at)})]},e.id))})]})]})}function sc(){let[e,t]=(0,v.useState)(!1),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(``);(0,v.useEffect)(()=>{if(!e)return;fetch(`/api/runs`).then(e=>e.json()).then(r).catch(()=>{}),fetch(`/api/workflows`).then(e=>e.json()).then(a).catch(()=>{}),fetch(`/api/meta`).then(e=>e.json()).then(e=>s(e.version)).catch(()=>{});let n=e=>{e.target.closest(`.info-wrap`)||t(!1)};return window.addEventListener(`mousedown`,n),()=>window.removeEventListener(`mousedown`,n)},[e]);let c=n?.runs[0];return(0,S.jsxs)(`span`,{className:`info-wrap`,children:[(0,S.jsx)(`button`,{className:`info-btn`,title:`Project info`,"aria-label":`Project info`,onClick:()=>t(e=>!e),children:(0,S.jsx)(C,{name:`info`})}),e&&(0,S.jsxs)(`div`,{className:`info-pop`,children:[(0,S.jsxs)(`div`,{className:`info-row`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`Workflows`}),(0,S.jsx)(`span`,{className:`info-v`,children:i?`${i.workflows.length} discovered`:`…`}),(0,S.jsx)(`code`,{className:`info-path`,title:i?.root,children:i?.root??``})]}),(0,S.jsxs)(`div`,{className:`info-row`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`Runs`}),(0,S.jsxs)(`span`,{className:`info-v`,children:[n?`${n.runs.length} total`:`…`,c?` · latest ${c.status}`:``]}),(0,S.jsx)(`code`,{className:`info-path`,title:n?.outputDir,children:n?.outputDir??``})]}),(0,S.jsxs)(`div`,{className:`info-row info-actions`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`Workspace`}),(0,S.jsxs)(`a`,{className:`update-btn`,href:`#/settings`,onClick:()=>t(!1),children:[(0,S.jsx)(C,{name:`settings`,className:`ms-sm`}),` settings`]})]}),(0,S.jsxs)(`div`,{className:`info-row info-actions`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`Theme`}),(0,S.jsx)(uc,{})]}),(0,S.jsxs)(`div`,{className:`info-row info-actions`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`Version`}),(0,S.jsx)(`span`,{className:`info-v mono`,children:o?`kraftwerk ${o}`:`…`}),(0,S.jsx)(lc,{})]})]})]})}function cc(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++)if((n[e]??0)!==(r[e]??0))return(n[e]??0)<(r[e]??0);return!1}function lc(){let[e,t]=(0,v.useState)(`idle`),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1);async function u(){t(`busy`);try{let e=await fetch(`/api/update-check`,{cache:`no-store`}),n=await e.json();if(!e.ok||!n.latest)throw Error();r(n),t(`done`)}catch{t(`err`)}}let d=i?.state===`running`;(0,v.useEffect)(()=>{if(!d)return;let e=!0,t=setInterval(async()=>{try{let t=await fetch(`/api/update`,{cache:`no-store`}).then(e=>e.json());if(!e)return;a(t),t.state!==`running`&&window.dispatchEvent(new Event(tc))}catch{}},1e3);return()=>{e=!1,clearInterval(t)}},[d]);async function f(){if(!n)return;s(``);let e=await fetch(`/api/update`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({version:n.latest})}),t=await e.json();e.ok?a(t):s(t.error??`update refused`)}if(i&&i.state!==`idle`&&n){let e=i.log[i.log.length-1]??``;return i.state===`running`?(0,S.jsxs)(`span`,{className:`update-result update-progress`,children:[(0,S.jsx)(C,{name:`progress_activity`,className:`ms-sm ms-spin`}),` installing v`,n.latest,`…`,e&&(0,S.jsx)(`code`,{className:`update-log`,title:i.log.join(`
|
|
222
|
+
`)[0]]})]}),e.error?(0,S.jsxs)(`div`,{className:`ws-empty ws-load-error`,children:[(0,S.jsx)(C,{name:`error`,className:`ms-sm`}),` `,e.error]}):(0,S.jsxs)(`div`,{className:`git-head`,children:[(0,S.jsxs)(`div`,{className:`git-branch`,children:[(0,S.jsx)(C,{name:`account_tree`,className:`ms-sm`}),(0,S.jsx)(`strong`,{children:e.branch}),e.upstream?(0,S.jsxs)(`span`,{className:`settings-note`,children:[`tracking `,e.upstream]}):(0,S.jsx)(`span`,{className:`settings-note`,children:`no upstream yet, push sets one`})]}),(0,S.jsxs)(`div`,{className:`git-counts`,children:[e.diverged&&(0,S.jsx)(`span`,{className:`git-diverged`,children:`diverged, resolve in a terminal`}),!!e.behind&&(0,S.jsxs)(`span`,{className:`git-behind`,children:[e.behind,` behind`]}),!!e.ahead&&(0,S.jsxs)(`span`,{className:`git-ahead`,children:[e.ahead,` ahead`]}),!e.ahead&&!e.behind&&(0,S.jsx)(`span`,{className:`settings-note`,children:`up to date`})]}),(0,S.jsxs)(`div`,{className:`ws-actions`,children:[(0,S.jsxs)(`button`,{className:`ws-btn`,disabled:!!c,onClick:()=>void h(`fetch`),children:[(0,S.jsx)(C,{name:c===`fetch`?`progress_activity`:`refresh`,className:`ms-sm`}),` fetch`]}),(0,S.jsxs)(`button`,{className:`ws-btn`,disabled:!!c||!e.behind||e.diverged,title:e.diverged?`Diverged. Resolve in a terminal.`:`Fast-forward to the remote`,onClick:()=>void h(`pull`),children:[(0,S.jsx)(C,{name:c===`pull`?`progress_activity`:`download`,className:`ms-sm`}),` pull`]}),(0,S.jsxs)(`button`,{className:`ws-btn primary`,disabled:!!c||!e.ahead&&!!e.upstream,title:e.upstream?`Push to the upstream`:`Push and set the upstream`,onClick:()=>void h(`push`),children:[(0,S.jsx)(C,{name:c===`push`?`progress_activity`:`upload`,className:`ms-sm`}),` push`]})]})]})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`changes`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(`span`,{className:`settings-note`,children:_.length===0?`workspace clean`:`${n.size} of ${_.length} selected`})]}),_.length===0&&y.length===0&&(0,S.jsx)(`div`,{className:`ws-empty`,children:`Nothing changed under the workspace paths.`}),_.map(e=>(0,S.jsxs)(`div`,{className:`git-row`,children:[(0,S.jsx)(`label`,{className:`git-pick`,children:(0,S.jsx)(`input`,{type:`checkbox`,checked:n.has(e.path),onChange:t=>b(e.path,t.target.checked)})}),(0,S.jsxs)(`button`,{className:`git-file`,onClick:()=>a(t=>{let n=new Set(t);return n.has(e.path)?n.delete(e.path):n.add(e.path),n}),children:[(0,S.jsx)(C,{name:i.has(e.path)?`expand_more`:`chevron_right`,className:`ms-sm`}),(0,S.jsx)(`span`,{className:`git-status s-${e.status}`,children:e.status}),(0,S.jsx)(`span`,{className:`git-path`,children:e.path})]}),i.has(e.path)&&(0,S.jsx)(us,{file:e.path})]},e.path)),_.length>0&&(0,S.jsxs)(`div`,{className:`git-commit`,children:[(0,S.jsx)(`input`,{className:`git-message`,placeholder:`Commit message`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!c&&o.trim()&&n.size>0&&g()}}),(0,S.jsx)(`button`,{className:`ws-btn`,disabled:n.size===_.length,onClick:()=>r(new Set(_.map(e=>e.path))),children:`select all`}),(0,S.jsxs)(`button`,{className:`ws-btn primary`,disabled:!!c||n.size===0||!o.trim(),onClick:()=>void g(),children:[(0,S.jsx)(C,{name:c===`commit`?`progress_activity`:`check`,className:`ms-sm`}),`commit `,n.size||``]})]}),y.length>0&&(0,S.jsxs)(`details`,{className:`git-blocked`,children:[(0,S.jsxs)(`summary`,{children:[y.length,e.blockedHidden?`+`:``,` change`,y.length===1&&!e.blockedHidden?``:`s`,` outside the workspace paths`]}),y.map(e=>(0,S.jsxs)(`div`,{className:`git-row blocked`,children:[(0,S.jsx)(`span`,{className:`git-status s-blocked`,children:e.status}),(0,S.jsx)(`span`,{className:`git-path`,children:e.path}),(0,S.jsx)(`span`,{className:`settings-note`,children:e.reason})]},e.path)),!!e.blockedHidden&&(0,S.jsx)(`div`,{className:`git-row blocked`,children:(0,S.jsxs)(`span`,{className:`settings-note`,children:[`and `,e.blockedHidden,` more, not listed`]})})]})]}),(0,S.jsxs)(`p`,{className:`settings-note`,children:[`Synced paths: `,(e.scope??[]).map((e,t)=>(0,S.jsxs)(`span`,{children:[t>0&&`, `,(0,S.jsx)(`code`,{children:e})]},e)),`. Run artifacts and files like `,(0,S.jsx)(`code`,{children:`.env`}),` are never staged.`,` `,e.interval?`Fetches every ${ss(e.interval)}${e.autosync===`pull`?` and fast-forwards when the working tree is clean`:``}. `:`Background fetching is off. `,`Commit and push are always manual.`]})]})}var ps=e=>e.replace(/^https?:\/\//,``).replace(/^git@([^:]+):/,`$1/`).replace(/\.git$/,``),ms=e=>e.error?{label:`unreadable`,cls:`missing`}:e.dirty?{label:`${e.dirty} changed`,cls:`died`}:e.ahead?{label:`${e.ahead} to push`,cls:`running`}:e.behind?{label:`${e.behind} behind`,cls:`stopped`}:{label:`clean`,cls:`running`},hs=e=>!!(e.error||e.dirty||e.ahead===void 0||e.ahead);function gs({slug:e}){return e?(0,S.jsx)(_s,{slug:e}):(0,S.jsx)(vs,{})}function _s({slug:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(0),h=B(),g=(0,v.useCallback)(async()=>{try{let t=await fetch(`/api/repos/${encodeURIComponent(e)}`,{cache:`no-store`}),r=await t.json();if(!t.ok)throw Error(r.error||`HTTP ${t.status}`);n(r),i(``)}catch(e){i(e.message||`could not load the repository`)}},[e]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await g(),e&&(t=setTimeout(n,5e3))};return n(),()=>{e=!1,clearTimeout(t)}},[g,p]);let _=async()=>{u(`update`),f(``);try{let t=await fetch(`/api/repos/${encodeURIComponent(e)}/update`,{method:`POST`}),n=await t.json();if(!t.ok||!n.ok)throw Error(n.error||`failed`);n.error&&f(n.error)}catch(e){f(e.message)}finally{u(``),m(e=>e+1)}};if(r&&!t)return(0,S.jsxs)(`div`,{className:`settings-screen ws-screen repos-screen repo-page`,children:[(0,S.jsxs)(`div`,{className:`settings-head`,children:[(0,S.jsxs)(L,{href:`/repos`,className:`open-raw`,title:`all repositories`,children:[(0,S.jsx)(C,{name:`arrow_back`,className:`ms-sm`}),` repositories`]}),(0,S.jsxs)(`h1`,{children:[(0,S.jsx)(C,{name:`folder_data`,className:`ms-lg`}),` `,e]})]}),(0,S.jsx)(`div`,{className:`settings-err`,children:r})]});if(!t)return(0,S.jsx)(`div`,{className:`empty`,children:`loading…`});let y=ms(t),b=t.commits.filter(e=>e.local).length;return(0,S.jsxs)(`div`,{className:`settings-screen ws-screen repos-screen repo-page`,children:[(0,S.jsxs)(`div`,{className:`settings-head`,children:[(0,S.jsxs)(L,{href:`/repos`,className:`open-raw`,title:`all repositories`,children:[(0,S.jsx)(C,{name:`arrow_back`,className:`ms-sm`}),` repositories`]}),(0,S.jsxs)(`h1`,{children:[(0,S.jsx)(C,{name:`folder_data`,className:`ms-lg`}),` `,t.slug]}),t.branch&&(0,S.jsx)(`span`,{className:`repo-branch`,children:t.branch}),t.upstream&&(0,S.jsxs)(`span`,{className:`settings-note`,title:`upstream`,children:[`→ `,t.upstream]}),(0,S.jsx)(`span`,{className:`ws-state ws-state-${y.cls}`,children:y.label}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`button`,{className:`ws-btn`,disabled:!!l,onClick:()=>void _(),title:`git fetch, then fast-forward when clean`,children:[(0,S.jsx)(C,{name:l===`update`?`progress_activity`:`sync`,className:`ms-sm`}),l===`update`?`updating…`:`update`]})]}),(0,S.jsxs)(`div`,{className:`settings-note repo-facts`,children:[t.url&&(0,S.jsx)(`span`,{title:t.url,children:ps(t.url)}),h&&(0,S.jsx)(`span`,{title:t.path,children:t.path}),t.head&&(0,S.jsxs)(`span`,{children:[`at `,(0,S.jsx)(`code`,{children:t.head}),t.committedAt?` · ${Ee(t.committedAt)}`:``]}),!!t.ahead&&(0,S.jsxs)(`span`,{children:[t.ahead,` to push`]}),!!t.behind&&(0,S.jsxs)(`span`,{children:[t.behind,` behind`]}),t.updatedAt&&(0,S.jsxs)(`span`,{children:[`changed `,Ee(t.updatedAt)]})]}),(t.error||d||r)&&(0,S.jsx)(`div`,{className:`settings-err`,children:t.error||d||r}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`changes · working tree against HEAD`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`span`,{className:`settings-note`,children:[t.files.length,` file`,t.files.length===1?``:`s`,t.insertions||t.deletions?(0,S.jsxs)(S.Fragment,{children:[` · `,(0,S.jsxs)(`span`,{className:`d-add`,children:[`+`,t.insertions]}),` `,(0,S.jsxs)(`span`,{className:`d-del`,children:[`−`,t.deletions]})]}):null]})]}),t.files.length===0&&(0,S.jsx)(`div`,{className:`ws-empty`,children:`Clean — nothing changed since the last commit.`}),t.files.map(n=>(0,S.jsxs)(`div`,{className:`repo-file ${a===n.path?`open`:``}`,"data-file":n.path,children:[(0,S.jsxs)(`button`,{className:`repo-file-row`,onClick:()=>o(a===n.path?null:n.path),children:[(0,S.jsx)(C,{name:a===n.path?`expand_more`:`chevron_right`,className:`ms-sm`}),(0,S.jsx)(`span`,{className:`git-code git-code-${n.status}`,children:n.status}),(0,S.jsx)(`span`,{className:`repo-file-path`,children:n.path})]}),a===n.path&&(0,S.jsx)(ds,{url:`/api/repos/${encodeURIComponent(e)}/diff?path=${encodeURIComponent(n.path)}&v=${encodeURIComponent(t.updatedAt??``)}`})]},n.path))]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`commits · newest first`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(`span`,{className:`settings-note`,children:b?`${b} not pushed`:t.commits.length?`all pushed`:``})]}),t.commits.length===0&&(0,S.jsx)(`div`,{className:`ws-empty`,children:`No commits yet.`}),t.commits.map(t=>(0,S.jsxs)(`div`,{className:`repo-commit ${s===t.hash?`open`:``} ${t.local?`local`:``}`,"data-commit":t.short,children:[(0,S.jsxs)(`button`,{className:`repo-file-row`,onClick:()=>c(s===t.hash?null:t.hash),title:t.hash,children:[(0,S.jsx)(C,{name:s===t.hash?`expand_more`:`chevron_right`,className:`ms-sm`}),(0,S.jsx)(`code`,{children:t.short}),(0,S.jsx)(`span`,{className:`repo-file-path`,children:t.subject}),t.local&&(0,S.jsx)(`span`,{className:`chip`,children:`not pushed`}),(0,S.jsxs)(`span`,{className:`settings-note`,children:[t.author,` · `,Ee(t.committedAt)]})]}),s===t.hash&&(0,S.jsx)(ds,{url:`/api/repos/${encodeURIComponent(e)}/commits/${t.hash}`})]},t.hash))]})]})}function vs(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)({}),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(!1),[y,b]=(0,v.useState)(``),x=B(),w=(0,v.useCallback)(async()=>{try{let e=await fetch(`/api/repos`,{cache:`no-store`});if(!e.ok)throw Error(`HTTP ${e.status}`);t(await e.json()),r(``)}catch(e){r(e.message||`could not load repositories`)}},[]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await w(),e&&(t=setTimeout(n,15e3))};return n(),()=>{e=!1,clearTimeout(t)}},[w]);let T=async(e,t,n=!1)=>{a(n=>({...n,[e]:t})),s(t=>({...t,[e]:``})),l(null);try{let r=t===`update`?await fetch(`/api/repos/${encodeURIComponent(e)}/update`,{method:`POST`}):await fetch(`/api/repos/${encodeURIComponent(e)}${n?`?force=1`:``}`,{method:`DELETE`}),i=await r.json();if(!r.ok||!i.ok)throw Error(i.error||`failed`);i.error&&s(t=>({...t,[e]:i.error}))}catch(t){s(n=>({...n,[e]:t.message}))}finally{a(t=>{let n={...t};return delete n[e],n}),w()}},E=async e=>{if(e.preventDefault(),u.trim()&&!g){_(!0),b(``);try{let e=await fetch(`/api/repos`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({url:u.trim(),name:f.trim()||void 0,branch:m.trim()||void 0})}),t=await e.json();if(!e.ok)throw Error(t.error||`clone failed`);d(``),p(``),h(``),await w()}catch(e){b(e.message)}finally{_(!1)}}},D=[...e?.repos??[]].sort((e,t)=>(t.updatedAt??``).localeCompare(e.updatedAt??``));return(0,S.jsxs)(`div`,{className:`settings-screen ws-screen repos-screen`,children:[(0,S.jsxs)(`div`,{className:`settings-head`,children:[(0,S.jsxs)(`h1`,{children:[(0,S.jsx)(C,{name:`source`,className:`ms-lg`}),` Repositories`]}),(0,S.jsx)(`span`,{className:`spacer`}),e?.enabled&&(0,S.jsxs)(`span`,{className:`settings-note`,children:[D.length,` cloned`]}),n&&(0,S.jsx)(`span`,{className:`settings-err`,children:n})]}),e&&!e.enabled&&(0,S.jsx)(`section`,{className:`panel`,children:(0,S.jsx)(`div`,{className:`ws-empty`,children:e.error&&!/are off/.test(e.error)?(0,S.jsx)(`span`,{className:`settings-err`,children:e.error}):(0,S.jsxs)(S.Fragment,{children:[`Repositories are off. Turn them on in `,(0,S.jsx)(`a`,{href:`#/settings`,children:`settings`}),` or add a `,(0,S.jsx)(`code`,{children:`repos:`}),` block to kraftwerk.yml.`]})})}),e?.enabled&&(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`add a repository`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`span`,{className:`settings-note`,children:[`clones into `,(0,S.jsx)(`code`,{title:e.root,children:e.root})]})]}),(0,S.jsxs)(`form`,{className:`agent-form`,onSubmit:e=>void E(e),children:[(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:2},children:[`url`,(0,S.jsx)(`input`,{value:u,placeholder:`https://github.com/org/repo.git, git@host:org/repo.git or github:org/repo`,onChange:e=>d(e.target.value),autoFocus:!0})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`name`,(0,S.jsx)(`input`,{value:f,placeholder:`from the url`,onChange:e=>p(e.target.value)})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{width:140},children:[`branch`,(0,S.jsx)(`input`,{value:m,placeholder:`default`,onChange:e=>h(e.target.value)})]}),(0,S.jsxs)(`button`,{className:`ws-btn primary`,type:`submit`,disabled:g||!u.trim(),children:[(0,S.jsx)(C,{name:g?`progress_activity`:`download`,className:`ms-sm`}),g?`cloning…`:`clone`]})]}),y&&(0,S.jsx)(`div`,{className:`settings-err`,children:y}),(0,S.jsxs)(`div`,{className:`settings-note`,children:[`Uses your own git credentials and never prompts: a private remote must already work from a terminal. Agents see every clone here and can add more with `,(0,S.jsx)(`code`,{children:`kraftwerk repos add`}),`.`]})]})]}),e?.enabled&&(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsx)(`div`,{className:`panel-head`,children:(0,S.jsx)(`span`,{className:`microlabel`,children:`cloned repositories · newest change first`})}),D.length===0&&(0,S.jsx)(`div`,{className:`ws-empty`,children:`Nothing cloned yet.`}),D.map(e=>{let t=i[e.slug],n=ms(e);return(0,S.jsxs)(`div`,{className:`ws-row repo-row state-${n.cls}`,"data-repo":e.slug,children:[(0,S.jsx)(`span`,{className:`switcher-icon ws-icon`,children:(0,S.jsx)(C,{name:`folder_data`})}),(0,S.jsxs)(`div`,{className:`ws-main`,children:[(0,S.jsxs)(`div`,{className:`ws-title`,children:[(0,S.jsx)(L,{href:`/repos/${encodeURIComponent(e.slug)}`,className:`ws-name`,title:`changes and commits`,children:e.slug}),e.branch&&(0,S.jsx)(`span`,{className:`repo-branch`,children:e.branch}),(0,S.jsx)(`span`,{className:`ws-state ws-state-${n.cls}`,children:n.label}),e.updatedAt&&(0,S.jsxs)(`span`,{className:`vibeable-when`,title:e.updatedAt,children:[`changed `,Ee(e.updatedAt)]})]}),e.url&&(0,S.jsx)(`div`,{className:`ws-root`,title:e.url,children:ps(e.url)}),x&&(0,S.jsx)(`div`,{className:`ws-root ws-dim`,title:e.path,children:e.path}),(0,S.jsxs)(`div`,{className:`ws-meta`,children:[e.head&&(0,S.jsxs)(`span`,{title:e.committedAt,children:[(0,S.jsx)(`code`,{children:e.head}),` `,e.subject,e.committedAt?` · ${Ee(e.committedAt)}`:``]}),!!e.behind&&!!e.dirty&&(0,S.jsxs)(`span`,{children:[`behind by `,e.behind]}),e.error&&(0,S.jsx)(`span`,{className:`settings-err`,children:e.error})]}),o[e.slug]&&(0,S.jsx)(`div`,{className:`settings-err`,children:o[e.slug]})]}),(0,S.jsxs)(`div`,{className:`ws-actions`,children:[(0,S.jsxs)(L,{href:`/repos/${encodeURIComponent(e.slug)}`,className:`ws-btn`,title:`changed files with diffs, recent commits`,children:[(0,S.jsx)(C,{name:`difference`,className:`ms-sm`}),` changes`]}),(0,S.jsxs)(`button`,{className:`ws-btn`,disabled:!!t,onClick:()=>void T(e.slug,`update`),title:`git fetch, then fast-forward when clean`,children:[(0,S.jsx)(C,{name:t===`update`?`progress_activity`:`sync`,className:`ms-sm`}),t===`update`?`updating…`:`update`]}),c!==e.slug&&(0,S.jsxs)(`button`,{className:`ws-btn`,disabled:!!t,onClick:()=>l(e.slug),title:`Delete the clone`,children:[(0,S.jsx)(C,{name:`delete`,className:`ms-sm`}),` remove`]}),c===e.slug&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`button`,{className:`ws-btn danger`,onClick:()=>void T(e.slug,`remove`,hs(e)),children:[(0,S.jsx)(C,{name:`delete`,className:`ms-sm`}),e.dirty||e.ahead?`delete with local changes`:hs(e)?`delete anyway`:`confirm remove`]}),(0,S.jsx)(`button`,{className:`ws-btn`,onClick:()=>l(null),children:`cancel`})]})]})]},e.slug)})]})]})}var ys=40,bs=/Mac|iPhone|iPad/.test(navigator.platform),xs=null,Ss=e=>(e?.workspaces??[]).flatMap(e=>[...e.agents.map(t=>({kind:`agent`,agent:t,ws:e,key:`${e.url}|agent|${t.slug}`})),...(e.projects??[]).map(t=>({kind:`project`,project:t,ws:e,key:`${e.url}|project|${t.slug}`})),...(e.channels??[]).map(t=>({kind:`channel`,channel:t,ws:e,key:`${e.url}|channel|${t.slug}`}))]),Cs=e=>e.kind===`agent`?e.agent.name:e.kind===`project`?e.project.title:e.channel.name,ws=e=>e.kind===`agent`?e.agent.description:e.kind===`project`?e.project.goal||(e.project.status===`active`?void 0:e.project.status):e.channel.purpose,Ts=e=>e.kind===`agent`?`/agents/${encodeURIComponent(e.agent.slug)}`:e.kind===`project`?`/projects/${encodeURIComponent(e.project.slug)}`:`/channels/${encodeURIComponent(e.channel.slug)}`,Es={active:`📁`,paused:`⏸️`,done:`✅`,archived:`🗄️`},Ds=e=>e.kind===`agent`?e.agent.emoji:e.kind===`project`?Es[e.project.status]:(0,S.jsx)(C,{name:`forum`});function Os(e,t){let n=t.toLowerCase().split(/\s+/).filter(Boolean);if(n.length===0)return e;let r=[],i=new Map;for(let t of e){i.has(t.ws)||i.set(t.ws,i.size);let e=Cs(t).toLowerCase(),a=[e,...t.kind===`agent`?[t.agent.slug,t.agent.description??``,t.agent.group??``,`agent`]:t.kind===`project`?[t.project.slug,t.project.goal??``,t.project.status,`project`]:[t.channel.slug,t.channel.purpose??``,`channel`],t.ws.name].join(` `).toLowerCase();if(!n.every(e=>a.includes(e)))continue;let o=e.startsWith(n[0])?0:e.includes(n[0])?1:2;r.push({hit:t,score:o,ws:i.get(t.ws)})}return r.sort((e,t)=>e.ws-t.ws||e.score-t.score).map(e=>e.hit)}function ks(e){let t=[];for(let n of e){let e=t.find(e=>e.ws===n.ws);e?e.hits.push(n):t.push({ws:n.ws,hits:[n]})}return t}async function As(e){let t=Ts(e);if(e.ws.current)return F(t);let n=e.ws.live||!e.ws.root?e.ws.url:await I(e.ws.root);window.location.assign(`${n.replace(/\/+$/,``)}/#${t}`)}function js(){let[e,t]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`k`&&(e.preventDefault(),t(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`button`,{type:`button`,className:`search-btn`,onClick:()=>t(!0),title:`jump to an agent, project or channel`,"aria-label":`search`,children:[(0,S.jsx)(C,{name:`search`}),(0,S.jsx)(`kbd`,{className:`kbd`,children:bs?`⌘K`:`Ctrl K`})]}),e&&(0,S.jsx)(Ms,{onClose:()=>t(!1)})]})}function Ms({onClose:e}){let[t,n]=(0,v.useState)(xs),[r,i]=(0,v.useState)(xs===null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(0),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(``),h=(0,v.useRef)(null);(0,v.useEffect)(()=>{let e=!0;return fetch(`/api/search/agents`,{cache:`no-store`}).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status)))).then(t=>{xs=t,e&&n(t)}).catch(()=>e&&o(!0)).finally(()=>e&&i(!1)),()=>{e=!1}},[]);let g=(0,v.useMemo)(()=>Ss(t),[t]),_=(0,v.useMemo)(()=>Os(g,s).slice(0,ys),[g,s]),y=(0,v.useMemo)(()=>ks(_),[_]),b=Math.min(l,Math.max(_.length-1,0));(0,v.useEffect)(()=>{h.current?.querySelector(`[aria-selected="true"]`)?.scrollIntoView({block:`nearest`})},[b,_]);let x=t=>{if(!d){if(t.ws.current||t.ws.live){e(),As(t);return}f(t.key),m(``),As(t).catch(e=>{f(null),m(`${t.ws.name}: ${e.message}`)})}},w=t=>{if(t.key===`ArrowDown`)t.preventDefault(),u(_.length?(b+1)%_.length:0);else if(t.key===`ArrowUp`)t.preventDefault(),u(_.length?(b-1+_.length)%_.length:0);else if(t.key===`Enter`){t.preventDefault();let e=_[b];e&&x(e)}else t.key===`Escape`&&(t.preventDefault(),e())},T;if(_.length>0){let e=-1;T=(0,S.jsx)(`ul`,{className:`palette-list`,role:`listbox`,"aria-label":`agents, projects and channels`,ref:h,children:y.map(t=>(0,S.jsxs)(v.Fragment,{children:[(0,S.jsxs)(`li`,{className:`palette-group`,role:`presentation`,title:t.ws.current?`this workspace`:t.ws.url,children:[t.ws.icon&&(0,S.jsx)(`span`,{"aria-hidden":!0,children:t.ws.icon}),(0,S.jsx)(`span`,{className:`palette-group-name`,children:t.ws.name}),t.ws.current?(0,S.jsx)(`span`,{className:`palette-group-note`,children:`this workspace`}):t.ws.live?(0,S.jsx)(C,{name:`open_in_new`,className:`ms-sm`}):(0,S.jsx)(`span`,{className:`palette-chip`,children:`stopped`})]}),t.hits.map(t=>{let n=++e;return(0,S.jsxs)(`li`,{role:`option`,"aria-selected":n===b,className:`palette-item${n===b?` active`:``}`,onMouseMove:()=>n!==b&&u(n),onClick:()=>x(t),children:[(0,S.jsx)(`span`,{className:`palette-emoji`,"aria-hidden":!0,children:Ds(t)}),(0,S.jsxs)(`span`,{className:`palette-text`,children:[(0,S.jsx)(`span`,{className:`palette-name`,children:Cs(t)}),ws(t)&&(0,S.jsx)(`span`,{className:`palette-sub`,children:ws(t)})]}),d===t.key?(0,S.jsx)(C,{name:`progress_activity`,className:`ms-sm`}):t.kind!==`agent`&&(0,S.jsx)(`span`,{className:`palette-chip`,children:t.kind})]},t.key)})]},t.ws.url||t.ws.name))})}else T=a?(0,S.jsx)(`div`,{className:`palette-empty`,children:`could not load the agents, projects and channels`}):r?(0,S.jsx)(`div`,{className:`palette-empty`,children:`looking for agents, projects and channels…`}):g.length===0?(0,S.jsxs)(`div`,{className:`palette-empty`,children:[`no agents yet — `,(0,S.jsx)(`a`,{href:`#/agents/new`,onClick:e,children:`create one`})]}):(0,S.jsxs)(`div`,{className:`palette-empty`,children:[`no agent, project or channel matches “`,s,`”`]});return(0,S.jsx)(`div`,{className:`palette-backdrop`,onMouseDown:e,children:(0,S.jsxs)(`div`,{className:`palette`,role:`dialog`,"aria-label":`jump to an agent, project or channel`,onMouseDown:e=>e.stopPropagation(),onKeyDown:w,children:[(0,S.jsxs)(`div`,{className:`palette-input`,children:[(0,S.jsx)(C,{name:`search`}),(0,S.jsx)(`input`,{autoFocus:!0,value:s,onChange:e=>{c(e.target.value),u(0)},placeholder:`jump to an agent, project or channel…`,"aria-label":`search`,autoComplete:`off`,spellCheck:!1}),r&&t&&(0,S.jsx)(C,{name:`progress_activity`,className:`ms-sm`}),(0,S.jsx)(`kbd`,{className:`kbd`,children:`esc`})]}),T,(0,S.jsxs)(`div`,{className:`palette-foot`,children:[(0,S.jsxs)(`span`,{children:[(0,S.jsx)(`kbd`,{className:`kbd`,children:`↑`}),(0,S.jsx)(`kbd`,{className:`kbd`,children:`↓`}),` move`]}),(0,S.jsxs)(`span`,{children:[(0,S.jsx)(`kbd`,{className:`kbd`,children:`↵`}),` open`]}),d&&(0,S.jsxs)(`span`,{className:`palette-note`,children:[(0,S.jsx)(C,{name:`progress_activity`,className:`ms-sm`}),` starting the workspace…`]}),p&&(0,S.jsxs)(`span`,{className:`palette-warn`,title:p,children:[(0,S.jsx)(C,{name:`warning`,className:`ms-sm`}),` `,p]})]})]})})}function Ns({chatPath:e}){let t=se(),n=B(),r=U(`/api/agents`,!1,15e3),i=U(`/api/channels`,!1,6e3),a=U(t.projects?`/api/projects`:``,!1,15e3),o=e.split(`/`).filter(Boolean),s=(e,t)=>o[0]===e&&(t===void 0||(o[1]?decodeURIComponent(o[1]):void 0)===t),c=o[0]===`agents`&&o[1]===`chats`;return(0,S.jsx)(`nav`,{className:`rail`,"aria-label":`Conversations`,children:(0,S.jsxs)(`div`,{className:`rail-list`,children:[(0,S.jsxs)(L,{href:`/`,className:`rail-row rail-home${e===`/`?` active`:``}`,children:[(0,S.jsx)(`span`,{className:`rail-mark`,"aria-hidden":!0,children:(0,S.jsx)(C,{name:`home`})}),(0,S.jsxs)(`span`,{className:`rail-text`,children:[(0,S.jsx)(`span`,{className:`rail-name`,children:`Home`}),(0,S.jsx)(`span`,{className:`rail-sub`,children:`Today: what needs you, what happened`})]})]}),(0,S.jsxs)(L,{href:`/agents/chats`,className:`rail-row${c?` active`:``}`,children:[(0,S.jsx)(`span`,{className:`rail-mark`,"aria-hidden":!0,children:`🎩`}),(0,S.jsxs)(`span`,{className:`rail-text`,children:[(0,S.jsx)(`span`,{className:`rail-name`,children:`Ralv`}),(0,S.jsx)(`span`,{className:`rail-sub`,children:`Chief of staff: knows the workspace, advises, launches things`})]})]}),t.projects&&(0,S.jsxs)(`div`,{className:`rail-group`,role:`group`,"aria-label":`Projects`,children:[(0,S.jsx)(L,{href:`/projects`,className:`rail-group-head`,children:`projects`}),(a?.projects??[]).map(e=>(0,S.jsxs)(L,{href:`/projects/${encodeURIComponent(e.slug)}`,className:`rail-row${s(`projects`,e.slug)?` active`:``}`,"data-project":e.slug,children:[(0,S.jsx)(`span`,{className:`rail-mark`,"aria-hidden":!0,children:e.status===`done`?`✅`:e.status===`paused`?`⏸️`:e.status===`archived`?`🗄️`:`📁`}),(0,S.jsxs)(`span`,{className:`rail-text`,children:[(0,S.jsx)(`span`,{className:`rail-name`,children:e.title}),(e.goal||e.status!==`active`)&&(0,S.jsx)(`span`,{className:`rail-sub`,children:e.goal||e.status})]})]},e.slug)),a?.enabled&&(n||(a.projects??[]).length===0)&&(0,S.jsxs)(L,{href:`/projects/new`,className:`rail-add`,children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` new project`]})]}),(0,S.jsxs)(`div`,{className:`rail-group`,role:`group`,"aria-label":`Agents`,children:[(0,S.jsx)(L,{href:`/agents`,className:`rail-group-head`,children:`agents`}),(r?.agents??[]).filter(e=>!e.archived).map(e=>(0,S.jsxs)(L,{href:`/agents/${encodeURIComponent(e.slug)}`,className:`rail-row${s(`agents`,e.slug)||s(`team`,e.slug)?` active`:``}`,children:[(0,S.jsx)(`span`,{className:`rail-mark`,"aria-hidden":!0,children:e.emoji||`🤖`}),(0,S.jsxs)(`span`,{className:`rail-text`,children:[(0,S.jsx)(`span`,{className:`rail-name`,children:e.name}),e.description&&(0,S.jsx)(`span`,{className:`rail-sub`,children:e.description})]})]},e.slug)),n&&(0,S.jsxs)(L,{href:`/agents/new`,className:`rail-add`,children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` new agent`]})]}),(0,S.jsxs)(`div`,{className:`rail-group`,role:`group`,"aria-label":`Channels`,children:[(0,S.jsx)(L,{href:`/channels`,className:`rail-group-head`,children:`channels`}),(i?.channels??[]).map(e=>(0,S.jsxs)(L,{href:`/channels/${encodeURIComponent(e.slug)}`,className:`rail-row${s(`channels`,e.slug)?` active`:``}`,children:[(0,S.jsx)(`span`,{className:`rail-mark rail-hash`,"aria-hidden":!0,children:`#`}),(0,S.jsxs)(`span`,{className:`rail-text`,children:[(0,S.jsxs)(`span`,{className:`rail-name`,children:[e.name,(e.busy||e.awaitingApproval)&&(0,S.jsx)(`span`,{className:`lamp ${e.awaitingApproval?`blocked`:`running`}`,title:e.awaitingApproval?`waiting for your approval`:`an agent is working`})]}),(0,S.jsx)(`span`,{className:`rail-sub`,children:e.purpose||(e.members.length?`with ${e.members.map(e=>`@${e}`).join(` `)}`:`no agents yet`)})]})]},e.slug)),(0,S.jsxs)(L,{href:`/channels/new`,className:`rail-add`,children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` new channel`]})]})]})})}function Ps({path:e}){let t=B(),n=se(),r=e.split(`/`).filter(Boolean)[0]??``;if(!t)return null;let i=[{id:`workflows`,href:`/workflows`,label:`workflows`,icon:`account_tree`},{id:`knowledge`,href:`/knowledge`,label:`knowledge`,icon:`menu_book`},...n.vibeables?[{id:`vibeables`,href:`/vibeables`,label:`vibeables`,icon:`web`}]:[],{id:`skills`,href:`/skills`,label:`skills`,icon:`extension`,expert:!0},...n.repos?[{id:`repos`,href:`/repos`,label:`repositories`,icon:`source`,expert:!0}]:[],...n.git?[{id:`git`,href:`/git`,label:`git`,icon:`cloud_sync`,expert:!0,badge:(0,S.jsx)(Fs,{})}]:[],{id:`workspaces`,href:`/workspaces`,label:`workspaces`,icon:`grid_view`,expert:!0},{id:`settings`,href:`/settings`,label:`settings`,icon:`settings`,expert:!0}],a=e=>r===e||e===`workflows`&&r===`runs`;return(0,S.jsx)(`nav`,{className:`global-nav`,"aria-label":`Workspace`,children:i.map(e=>(0,S.jsxs)(`a`,{href:`#${e.href}`,className:`${e.expert?`nav-expert`:``}${a(e.id)?` active`:``}`,"aria-current":a(e.id)?`page`:void 0,children:[(0,S.jsx)(C,{name:e.icon}),` `,e.label,e.badge]},e.id))})}function Fs(){let e=U(`/api/git`,!1,15e3),t=e?.files?.filter(e=>e.syncable).length??0;return(0,S.jsxs)(S.Fragment,{children:[!!e?.behind&&(0,S.jsxs)(`span`,{className:`git-badge behind`,children:[e.behind,`↓`]}),!!e?.ahead&&(0,S.jsxs)(`span`,{className:`git-badge ahead`,children:[e.ahead,`↑`]}),!e?.ahead&&!e?.behind&&!!t&&(0,S.jsx)(`span`,{className:`git-badge dirty`,children:t})]})}function Is(e){let t=e.split(`/`).filter(Boolean),n=t[1]?decodeURIComponent(t[1]):``;return t[0]===`projects`&&n&&n!==`new`?{kind:`project`,slug:n}:t[0]===`channels`&&n&&n!==`new`?{kind:`channel`,slug:n}:(t[0]===`agents`||t[0]===`team`)&&n&&n!==`new`&&n!==`chats`?{kind:`agent`,slug:n}:{kind:`general`}}async function Ls(e){try{let t=await fetch(e,{cache:`no-store`});return t.ok?await t.json():null}catch{return null}}var Rs=(e,t)=>e.map(e=>({slug:e,found:t.has(e)}));function zs({chatPath:e,workspace:t}){let n=Is(e),r=`${n.kind}:${`slug`in n?n.slug:``}`,i=se(),a=B(),[o,s]=n.kind===`project`?[`/projects/${encodeURIComponent(n.slug)}/info`,`edit the project: brief, state, records, links`]:n.kind===`agent`?[`/agents/${encodeURIComponent(n.slug)}/info`,`edit the agent: profile and settings`]:n.kind===`channel`?[`/channels/${encodeURIComponent(n.slug)}/edit`,`edit the channel`]:a?[`/settings`,`workspace settings`]:[void 0,``],c=U(`/api/workflows`,!1,15e3),l=U(`/api/runs`,!1,6e3),u=U(`/api/knowledge`,!1,15e3),d=U(i.vibeables?`/api/vibeables`:``,!1,15e3),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(0),[g,_]=(0,v.useState)(()=>{try{return localStorage.getItem(`kw-ctx-tab`)||`workflows`}catch{return`workflows`}}),[y,b]=(0,v.useState)(0);(0,v.useEffect)(()=>{let e=()=>x(`browser`);return window.addEventListener(Vr,e),()=>window.removeEventListener(Vr,e)},[]);let x=e=>{_(e);try{localStorage.setItem(`kw-ctx-tab`,e)}catch{}},[w,T]=(0,v.useState)({});(0,v.useEffect)(()=>T(j.current?{vibeables:`/vibeables/${encodeURIComponent(j.current.slug)}`}:{}),[r]);let E=e=>T(t=>({...t,[P]:e})),D=()=>T(e=>({...e,[P]:null})),O=e=>t=>t.startsWith(e)?(T(e=>({...e,[P]:t})),!0):!1,[k,A]=(0,v.useState)(null),j=(0,v.useRef)(null);(0,v.useEffect)(()=>{let e=e=>{let t=e.detail;j.current=t,A(t),t?(x(`vibeables`),T(e=>({...e,vibeables:`/vibeables/${encodeURIComponent(t.slug)}`}))):T(e=>e.vibeables?.startsWith(`/vibeables/`)?{...e,vibeables:null}:e)};return window.addEventListener(Yr,e),()=>window.removeEventListener(Yr,e)},[]);let ee=i.vibeables&&!!(f?.all||f?.vibeables||k),M=i.repos&&!!f?.repos,N=[{id:`workflows`,label:`workflows`,count:f?.workflows.length,allHref:`/workflows`},{id:`knowledge`,label:`knowledge`,count:f?.knowledge.length,allHref:`/knowledge`},...ee?[{id:`vibeables`,label:`vibeables`,count:f?.all?d?.vibeables.length:f?.vibeables?.length,allHref:`/vibeables`}]:[],...M?[{id:`repos`,label:`repositories`,count:f?.repos?.length,allHref:`/repos`}]:[],...f?.agents?[{id:`agents`,label:`agents`,count:f.agents.length,allHref:`/agents`}]:[],...f?.records&&f.records.length>0?[{id:`records`,label:`records`,count:f.records.length}]:[],{id:`browser`,label:`browser`,count:y}],P=N.some(e=>e.id===g)?g:`workflows`,F=N.find(e=>e.id===P),I=w[P]??null,ne=!!k&&P===`vibeables`&&I===`/vibeables/${encodeURIComponent(k.slug)}`,re=e=>t=>{t.metaKey||t.ctrlKey||t.shiftKey||t.button!==0||(t.preventDefault(),E(e))};(0,v.useEffect)(()=>{let e=setInterval(()=>h(e=>e+1),15e3);return()=>clearInterval(e)},[]),(0,v.useEffect)(()=>{let e=!0,r=new Set((c?.workflows??[]).map(e=>e.slug)),i=new Set((u?.bundles??[]).map(e=>e.name)),a=new Set((d?.vibeables??[]).map(e=>e.slug));return(async()=>{let o=null;if(n.kind===`agent`){let e=await Ls(`/api/agents/${encodeURIComponent(n.slug)}`);e&&(o={title:`${e.emoji?`${e.emoji} `:``}${e.name}`,workflows:Rs(e.workflows,r),knowledge:Rs(e.knowledge,i),editHref:`/agents/${encodeURIComponent(n.slug)}/edit`},(e.vibeables??[]).length>0&&(o.vibeables=Rs(e.vibeables,a)))}else if(n.kind===`project`){let e=await Ls(`/api/projects/${encodeURIComponent(n.slug)}`);e&&(o={title:`📁 ${e.title}`,workflows:e.links.workflows,knowledge:e.links.knowledge,vibeables:e.links.vibeables,repos:e.links.repos,agents:e.links.agents,records:e.records,editHref:`/projects/${encodeURIComponent(n.slug)}/info`})}else if(n.kind===`channel`){let e=(await Ls(`/api/channels`))?.channels.find(e=>e.slug===n.slug);if(e){let t=(await Promise.all(e.members.map(e=>Ls(`/api/agents/${encodeURIComponent(e)}`)))).filter(e=>!!e),s=e=>[...new Set(t.flatMap(e))],c=s(e=>e.vibeables??[]);o={title:`#${e.slug}`,workflows:Rs(s(e=>e.workflows),r),knowledge:Rs(s(e=>e.knowledge),i),...c.length>0?{vibeables:Rs(c,a)}:{},agents:e.members.map(e=>({slug:e,found:t.some(t=>t.slug===e),label:t.find(t=>t.slug===e)?.name})),editHref:`/channels/${encodeURIComponent(n.slug)}/edit`}}}else o={title:`${t.icon?`${t.icon} `:``}${t.name||`workspace`}`,workflows:Rs([...r],r),knowledge:Rs([...i],i),all:!0};e&&p(o)})(),()=>{e=!1}},[r,m,c,u,d,t.name,t.icon]);let R=e=>c?.workflows.find(t=>t.slug===e),z=e=>e?l?.runs.find(t=>t.workflow===(e.name??e.slug)||t.workflow===e.slug):void 0,ie=e=>u?.bundles.find(t=>t.name===e),ae=e=>d?.vibeables.find(t=>t.slug===e),oe=e=>(0,S.jsxs)(`div`,{className:`ctx-empty`,children:[f?.all?`No ${e} in this workspace yet.`:`No ${e} linked.`,f?.editHref&&a&&!f.all&&(0,S.jsxs)(S.Fragment,{children:[` `,(0,S.jsx)(L,{href:f.editHref,children:`Edit the links`}),`.`]})]});return(0,S.jsxs)(`aside`,{className:`ctx`,"aria-label":`Context`,children:[(0,S.jsxs)(`div`,{className:`ctx-head${f?` sign-in`:``}`,children:[(0,S.jsx)(`span`,{className:`ctx-title`,title:f?.title,children:f?f.title:`…`}),o&&(0,S.jsx)(L,{href:o,className:`ctx-edit`,title:s,"aria-label":s,children:(0,S.jsx)(C,{name:`edit`,className:`ms-sm`})})]},f?.title??``),(0,S.jsx)(`div`,{className:`ctx-tabs`,role:`tablist`,"aria-label":`Categories`,children:N.map(e=>(0,S.jsxs)(`button`,{role:`tab`,className:`ctx-tab`,"aria-selected":e.id===P,onClick:()=>x(e.id),children:[e.label,e.count!==void 0&&(0,S.jsx)(`span`,{className:`ctx-tab-n num`,children:e.count})]},e.id))}),I&&(0,S.jsxs)(`div`,{className:`ctx-open-head`,children:[(0,S.jsxs)(`button`,{className:`open-raw`,onClick:D,"aria-label":`Back to the list`,children:[(0,S.jsx)(C,{name:`arrow_back`,className:`ms-sm`}),` `,F?.label]}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(L,{href:I,className:`ctx-all`,title:`Open as a page`,children:[`page `,(0,S.jsx)(C,{name:`open_in_new`,className:`ms-sm`})]})]}),I&&P===`knowledge`&&(0,S.jsx)(`div`,{className:`ctx-body ctx-embed`,children:(0,S.jsx)(te.Provider,{value:O(`/knowledge/`),children:(()=>{let e=I.split(`/`).filter(Boolean),t=decodeURIComponent(e[1]??``),n=e.length>2?e.slice(2).map(decodeURIComponent).join(`/`):void 0;return(0,S.jsx)(Ro,{name:t,conceptId:n},t)})()})}),I&&P===`workflows`&&(0,S.jsx)(`div`,{className:`ctx-body ctx-embed`,children:(0,S.jsx)(te.Provider,{value:O(`/workflows/`),children:(()=>{let e=I.split(`/`).filter(Boolean),t=e[2]===`details`||e[2]===`runs`?e[2]:`overview`;return(0,S.jsx)(uo,{slug:decodeURIComponent(e[1]??``),tab:t},e[1])})()})}),I&&P===`vibeables`&&!ne&&(0,S.jsx)(`div`,{className:`ctx-body ctx-embed ctx-embed-vibe`,children:(0,S.jsx)($r,{slug:decodeURIComponent(I.split(`/`).filter(Boolean)[1]??``)},I)}),(0,S.jsx)(`div`,{id:Xr,className:`ctx-body ctx-embed ctx-embed-vibe`,hidden:!ne}),(0,S.jsx)(`div`,{className:`ctx-body ctx-embed ctx-browser`,hidden:P!==`browser`,children:(0,S.jsx)(Jr,{storeKey:r,onTabs:b},r)}),(0,S.jsxs)(`div`,{className:`ctx-body`,role:`tabpanel`,hidden:P===`browser`||!!I&&[`knowledge`,`workflows`,`vibeables`].includes(P),children:[F?.allHref&&(0,S.jsxs)(`div`,{className:`ctx-section-head`,children:[(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(L,{href:F.allHref,className:`ctx-all`,children:[`all `,F.label,` `,(0,S.jsx)(C,{name:`arrow_forward`,className:`ms-sm`})]})]}),P===`workflows`&&(0,S.jsxs)(S.Fragment,{children:[f&&f.workflows.length===0&&oe(`workflows`),f?.workflows.map(({slug:e,found:t})=>{let n=R(e),r=z(n);return(0,S.jsxs)(L,{href:`/workflows/${encodeURIComponent(e)}`,className:`ctx-row${t?``:` missing`}`,onClick:t?re(`/workflows/${encodeURIComponent(e)}`):void 0,children:[(0,S.jsx)(Oe,{status:!t||n?.error?`failed`:r?.status??`idle`}),(0,S.jsxs)(`span`,{className:`ctx-text`,children:[(0,S.jsx)(`span`,{className:`ctx-name`,children:n?.name??e}),(0,S.jsx)(`span`,{className:`ctx-sub`,children:t?n?.error?`broken`:r?`${r.status} · ${Ee(r.updatedAt)}`:n?.description??`no runs yet`:`not in this workspace`})]}),t&&!n?.error&&(0,S.jsx)(C,{name:`chevron_right`,className:`ctx-go ms-sm`})]},e)})]}),P===`knowledge`&&(0,S.jsxs)(S.Fragment,{children:[f&&f.knowledge.length===0&&oe(`knowledge`),f?.knowledge.map(({slug:e,found:t})=>{let n=ie(e);return(0,S.jsxs)(L,{href:`/knowledge/${encodeURIComponent(e)}`,className:`ctx-row${t?``:` missing`}`,onClick:t?re(`/knowledge/${encodeURIComponent(e)}`):void 0,children:[(0,S.jsx)(C,{name:`menu_book`,className:`ctx-icon ms-sm`}),(0,S.jsxs)(`span`,{className:`ctx-text`,children:[(0,S.jsx)(`span`,{className:`ctx-name`,children:e}),(0,S.jsx)(`span`,{className:`ctx-sub`,children:t?n?`${n.concepts} ${n.concepts===1?`page`:`pages`}${n.updatedAt?` · ${Ee(n.updatedAt)}`:``}`:``:`not in this workspace`})]})]},e)})]}),P===`vibeables`&&f&&(0,S.jsxs)(S.Fragment,{children:[(f.all?(d?.vibeables??[]).map(e=>({slug:e.slug,found:!0})):f.vibeables??[]).map(({slug:e,found:t})=>{let n=ae(e);return(0,S.jsxs)(L,{href:`/vibeables/${encodeURIComponent(e)}`,className:`ctx-row${t?``:` missing`}`,onClick:t?re(`/vibeables/${encodeURIComponent(e)}`):void 0,children:[(0,S.jsx)(C,{name:`web`,className:`ctx-icon ms-sm`}),(0,S.jsxs)(`span`,{className:`ctx-text`,children:[(0,S.jsx)(`span`,{className:`ctx-name`,children:e}),(0,S.jsx)(`span`,{className:`ctx-sub`,children:t?n?.updatedAt?`changed ${Ee(n.updatedAt)}`:``:`not in this workspace`})]})]},e)}),f.all&&d&&d.vibeables.length===0&&oe(`vibeables`),!f.all&&f.vibeables?.length===0&&oe(`vibeables`)]}),P===`repos`&&f?.repos&&(0,S.jsxs)(S.Fragment,{children:[f.repos.length===0&&oe(`repositories`),f.repos.map(({slug:e,found:t})=>(0,S.jsxs)(L,{href:`/repos/${encodeURIComponent(e)}`,className:`ctx-row${t?``:` missing`}`,children:[(0,S.jsx)(C,{name:`source`,className:`ctx-icon ms-sm`}),(0,S.jsxs)(`span`,{className:`ctx-text`,children:[(0,S.jsx)(`span`,{className:`ctx-name`,children:e}),!t&&(0,S.jsx)(`span`,{className:`ctx-sub`,children:`not in this workspace`})]})]},e))]}),P===`agents`&&f?.agents&&(0,S.jsxs)(S.Fragment,{children:[f.agents.length===0&&oe(`agents`),f.agents.map(({slug:e,found:t,label:n})=>(0,S.jsxs)(L,{href:`/agents/${encodeURIComponent(e)}`,className:`ctx-row${t?``:` missing`}`,children:[(0,S.jsx)(C,{name:`person`,className:`ctx-icon ms-sm`}),(0,S.jsxs)(`span`,{className:`ctx-text`,children:[(0,S.jsx)(`span`,{className:`ctx-name`,children:n??e}),!t&&(0,S.jsx)(`span`,{className:`ctx-sub`,children:`not in this workspace`})]})]},e))]}),P===`records`&&f?.records&&(0,S.jsx)(S.Fragment,{children:f.records.map((e,t)=>(0,S.jsxs)(`a`,{href:e.url||void 0,target:`_blank`,rel:`noopener`,className:`ctx-row`,children:[(0,S.jsx)(C,{name:`open_in_new`,className:`ctx-icon ms-sm`}),(0,S.jsxs)(`span`,{className:`ctx-text`,children:[(0,S.jsx)(`span`,{className:`ctx-name`,children:e.title||e.kind}),e.note&&(0,S.jsx)(`span`,{className:`ctx-sub`,children:e.note})]})]},t))})]},P)]})}var Bs=`kw-chat-path`,Vs=`kw-ctx-w`,Hs=()=>{try{let e=Number(localStorage.getItem(Vs));return e>0?e:null}catch{return null}};function Us({onResize:e}){let[t,n]=(0,v.useState)(!1);return(0,S.jsx)(`div`,{className:`split-handle${t?` dragging`:``}`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`resize chat and context`,title:`drag to resize · double-click for half and half`,onPointerDown:t=>{if(t.button!==0)return;let r=t.currentTarget.closest(`.shell`);if(!r)return;t.preventDefault();let i=r.getBoundingClientRect().right-parseFloat(getComputedStyle(r).paddingRight),a=t=>e(Math.round(i-t.clientX)),o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o),document.body.classList.remove(`kw-resizing`),n(!1)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o),document.body.classList.add(`kw-resizing`),n(!0)},onDoubleClick:()=>e(null)})}var Ws=(e,t)=>{try{return sessionStorage.getItem(e)||t}catch{return t}},Gs=(e,t)=>{try{sessionStorage.setItem(e,t)}catch{}};function Ks(){let e=w(),[t]=e.split(`?`),n=t.split(`/`).filter(Boolean),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(!0),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)([]),_=ee.has(n[0]??``),y=n.length===0,[b,x]=(0,v.useState)(()=>Ws(Bs,`/agents/chats`)),T=_?Ia(t):null,E=_&&!T?t:b,[D,O]=(0,v.useState)(`chat`),[k,j]=(0,v.useState)(Hs),P=e=>{j(e);try{e===null?localStorage.removeItem(Vs):localStorage.setItem(Vs,String(e))}catch{}};(0,v.useEffect)(()=>{_&&!Ia(t)&&(x(t),Gs(Bs,t))},[e]),(0,v.useEffect)(()=>{let e=e=>{let t=e.detail;M(t)===`chat`?(x(t),Gs(Bs,t)):window.location.replace(`#${t}`)};return window.addEventListener(N,e),()=>window.removeEventListener(N,e)},[]),(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{try{let t=await fetch(`/api/meta`,{cache:`no-store`}).then(e=>e.json());if(!e)return;i(t.projectName??``),o(t.projectIcon??``),c(t.projectColor??``),u(t.projectNamed!==!1),f(t.projectRootLabel??``),m(t.projectRoot??``),oe({git:!!t.git,repos:!!t.repos,vibeables:!!t.vibeables,projects:!!t.projects}),g(Array.isArray(t.switcher)?t.switcher:[])}catch{}e&&(t=setTimeout(n,3e4))};n();let r=()=>{clearTimeout(t),n()};return window.addEventListener(`kw-meta-refresh`,r),()=>{e=!1,clearTimeout(t),window.removeEventListener(`kw-meta-refresh`,r)}},[]),(0,v.useEffect)(()=>{if(A(r?`${r} — kraftwerk`:`kraftwerk inspector`),!a)return;let e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y="0.9em" font-size="85">${a}</text></svg>`,t=document.querySelector(`link[rel="icon"]`);t||(t=document.createElement(`link`),t.rel=`icon`,document.head.appendChild(t)),t.href=`data:image/svg+xml,${encodeURIComponent(e)}`},[r,a]);let F=E.split(`/`).filter(Boolean),I=new URLSearchParams(e.split(`?`)[1]??``).get(`workflow`)??void 0,te;te=F[0]===`chats`?(0,S.jsx)(ya,{seg:F}):F[0]===`projects`?(0,S.jsx)(Qi,{seg:F.slice(1)}):F[0]===`channels`?(0,S.jsx)(ai,{seg:F.slice(1)}):(0,S.jsx)(ya,{seg:F.slice(1)});let L=null;return n[0]===`runs`&&n[1]?L=(0,S.jsx)(za,{id:n[1],workflow:I}):n[0]===`runs`?L=(0,S.jsx)($s,{}):n[0]===`workflows`?L=(0,S.jsx)(vo,{slug:n[1]?decodeURIComponent(n[1]):void 0,tab:n[2]===`details`||n[2]===`runs`?n[2]:`overview`}):n[0]===`vibeables`?L=(0,S.jsx)(ri,{slug:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`knowledge`?L=(0,S.jsx)(Po,{bundle:n[1]?decodeURIComponent(n[1]):void 0,conceptId:n.length>2?n.slice(2).map(decodeURIComponent).join(`/`):void 0}):n[0]===`skills`?L=(0,S.jsx)(Jo,{name:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`settings`?L=(0,S.jsx)(is,{}):n[0]===`workspaces`?L=(0,S.jsx)(os,{}):n[0]===`git`?L=(0,S.jsx)(fs,{}):n[0]===`repos`&&(L=(0,S.jsx)(gs,{slug:n[1]?decodeURIComponent(n[1]):void 0})),(0,v.useEffect)(()=>{let e=document.documentElement,t=p||r,n=t?_e(ce(s,t)):null;if(!n){delete e.dataset.wsAccent;return}for(let[t,r]of Object.entries(n))e.style.setProperty(t,r);e.dataset.wsAccent=``},[s,p,r]),(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`header`,{className:`topbar`,style:{"--ws-c":ce(s,p||r)},children:[(0,S.jsxs)(`span`,{className:`wordmark`,children:[(0,S.jsx)(`a`,{href:`#/`,className:`home-link`,title:`Dashboard`,children:r?(0,S.jsx)(ye,{className:`home-tile`,icon:a,name:r,color:s,seed:p||r}):(0,S.jsx)(C,{name:`home`})}),r&&(0,S.jsx)(Qs,{name:r,icon:a,color:s,named:l,root:d,seed:p||r,entries:h})]}),(0,S.jsx)(Ps,{path:t}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(js,{}),(0,S.jsx)(oc,{}),(0,S.jsx)(nc,{}),(0,S.jsx)(rc,{}),(0,S.jsx)(sc,{})]}),L&&(0,S.jsx)(`main`,{className:`shell shell-global`,children:L}),(0,S.jsxs)(`main`,{className:`shell three${y?` home`:``}`,"data-focus":D,hidden:!!L,style:k?{"--ctx-w":`${k}px`}:void 0,children:[(0,S.jsx)(Ns,{chatPath:y?`/`:E}),(0,S.jsxs)(`section`,{className:`col-chat`,"aria-label":y?`Dashboard`:`Conversation`,children:[y?(0,S.jsx)(wo,{}):te,(0,S.jsx)(Us,{onResize:P})]}),(0,S.jsx)(zs,{chatPath:y?`/`:E,workspace:{name:r,icon:a}}),T&&(0,S.jsx)(La,{back:E,children:T})]}),!L&&(0,S.jsxs)(`nav`,{className:`places`,"aria-label":`Sections`,children:[(0,S.jsxs)(`button`,{className:D===`chat`?`active`:``,onClick:()=>O(`chat`),children:[(0,S.jsx)(C,{name:`forum`}),` chat`]}),(0,S.jsxs)(`button`,{className:D===`context`?`active`:``,onClick:()=>O(`context`),children:[(0,S.jsx)(C,{name:`account_tree`}),` context`]})]})]})}function qs(e){try{let t=new URL(e);return t.hostname===`localhost`||t.hostname===`127.0.0.1`?`:${t.port||(t.protocol===`https:`?443:80)}`:t.host}catch{return e.replace(/^https?:\/\//,``)}}function Js({label:e}){return e?(0,S.jsx)(`span`,{className:`switcher-root`,title:e,children:(0,S.jsx)(`span`,{dir:`ltr`,children:e})}):null}function Ys({name:e,named:t}){let n=t===!1;return(0,S.jsx)(`span`,{className:`switcher-name${n?` unnamed`:``}`,title:n?`${e} — folder name; set name: in kraftwerk.yml`:e,children:e})}function Xs({entry:e,ambiguous:t}){let[n,r]=(0,v.useState)(`idle`),[i,a]=(0,v.useState)(``),o=e.exists===!1,s=async()=>{r(`starting`),a(``);try{window.location.assign(await I(e.root))}catch(e){r(`error`),a(e.message)}};return(0,S.jsxs)(`span`,{className:`switcher-item stopped ${o?`missing`:``}`,role:`menuitem`,style:{"--ws-c":ce(e.color,e.root??e.url)},children:[(0,S.jsx)(ye,{icon:e.icon,name:e.name,color:e.color,seed:e.root??e.url,ambiguous:t}),(0,S.jsxs)(`span`,{className:`switcher-text`,children:[(0,S.jsx)(Ys,{name:e.name,named:e.named}),n===`error`?(0,S.jsx)(`span`,{className:`switcher-sub switcher-err`,title:i,children:i}):o?(0,S.jsx)(`span`,{className:`switcher-sub`,children:`folder missing`}):(0,S.jsx)(Js,{label:e.rootLabel})]}),(0,S.jsxs)(`span`,{className:`switcher-side`,children:[(0,S.jsx)(`span`,{className:`switcher-port`,children:qs(e.url)}),(0,S.jsxs)(`button`,{className:`switcher-start`,disabled:o||n===`starting`,title:o?`The project folder no longer exists`:`Start the UI for this project`,onClick:e=>{e.stopPropagation(),s()},children:[n===`starting`?(0,S.jsx)(C,{name:`progress_activity`}):(0,S.jsx)(C,{name:`play_arrow`}),n===`starting`?`starting`:`start`]})]})]})}function Zs({entry:e,ambiguous:t}){let n=e.root??e.url;return(0,S.jsxs)(`a`,{className:`switcher-item${e.live?` live`:``}`,role:`menuitem`,href:e.url,style:{"--ws-c":ce(e.color,n)},children:[(0,S.jsx)(ye,{icon:e.icon,name:e.name,color:e.color,seed:n,ambiguous:t}),(0,S.jsxs)(`span`,{className:`switcher-text`,children:[(0,S.jsx)(Ys,{name:e.name,named:e.named}),(0,S.jsx)(Js,{label:e.rootLabel??(e.root?void 0:e.url.replace(/^https?:\/\//,``))})]}),(0,S.jsx)(`span`,{className:`switcher-side`,children:(0,S.jsxs)(`span`,{className:`switcher-port`,children:[e.live&&(0,S.jsx)(`span`,{className:`live-dot`,title:`running`}),qs(e.url)]})})]})}function Qs({name:e,icon:t,color:n,named:r,root:i,seed:a,entries:o}){let[s,c]=(0,v.useState)(!1),l=B();if((0,v.useEffect)(()=>{if(!s)return;let e=e=>{e.target.closest(`.switcher-wrap`)||c(!1)};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[s]),o.length===0)return(0,S.jsx)(`span`,{className:`env-name`,title:i||`Project (kraftwerk.yml: name)`,children:e});let u=new Map;for(let e of[t,...o.map(e=>e.icon)])e&&u.set(e,(u.get(e)??0)+1);let d=e=>!!e&&(u.get(e)??0)>1,f=[{key:`running`,label:`running`,items:o.filter(e=>e.live===!0)},{key:`stopped`,label:`stopped`,items:o.filter(e=>e.live===!1)},{key:`linked`,label:`linked`,items:o.filter(e=>e.live===void 0)}].filter(e=>e.items.length>0),p=a||e;return(0,S.jsxs)(`span`,{className:`switcher-wrap`,children:[(0,S.jsxs)(`button`,{className:`env-name env-switch`,title:i?`${i} — switch workspace`:`Switch workspace`,"aria-haspopup":`menu`,"aria-expanded":s,onClick:()=>c(e=>!e),children:[e,(0,S.jsx)(C,{name:`expand_more`})]}),s&&(0,S.jsxs)(`div`,{className:`switcher-pop`,role:`menu`,children:[(0,S.jsx)(`div`,{className:`switcher-head`,children:`Workspaces`}),(0,S.jsxs)(`span`,{className:`switcher-item current`,"aria-current":`true`,style:{"--ws-c":ce(n,p)},children:[(0,S.jsx)(ye,{icon:t,name:e,color:n,seed:p,ambiguous:d(t)}),(0,S.jsxs)(`span`,{className:`switcher-text`,children:[(0,S.jsx)(Ys,{name:e,named:r}),i?(0,S.jsx)(Js,{label:i}):(0,S.jsx)(`span`,{className:`switcher-sub`,children:`this workspace`})]}),(0,S.jsx)(`span`,{className:`switcher-side`,children:(0,S.jsx)(C,{name:`check`,className:`switcher-check`})})]}),f.map(e=>(0,S.jsxs)(`div`,{className:`switcher-group switcher-group-${e.key}`,role:`group`,"aria-label":e.label,children:[(0,S.jsx)(`div`,{className:`switcher-group-head`,children:e.label}),e.items.map(e=>e.live===!1&&e.root?(0,S.jsx)(Xs,{entry:e,ambiguous:d(e.icon)},e.root):(0,S.jsx)(Zs,{entry:e,ambiguous:d(e.icon)},e.root??e.url))]},e.key)),l&&(0,S.jsxs)(`a`,{className:`switcher-foot`,href:`#/workspaces`,role:`menuitem`,onClick:()=>c(!1),children:[(0,S.jsx)(C,{name:`hub`}),` manage workspaces`]})]})]})}function $s(){let[e,t]=(0,v.useState)(null);return(0,v.useEffect)(()=>{let e=!0;return fetch(`/api/runs`).then(e=>e.json()).then(n=>{e&&(n.runs.length>0?F(`/runs/${n.runs[0].id}`,{replace:!0}):t({outputDir:n.outputDir}))}).catch(()=>{}),()=>{e=!1}},[]),e?(0,S.jsxs)(`div`,{className:`empty`,children:[`No runs found in `,(0,S.jsx)(`code`,{children:e.outputDir}),`. Start one from the`,` `,(0,S.jsx)(`a`,{href:`#/workflows`,children:`workflows`}),` list or with `,(0,S.jsx)(`code`,{children:`kraftwerk run <workflow> [request]`}),`.`]}):(0,S.jsx)(`div`,{className:`empty`,children:`loading…`})}async function ec(e){await fetch(`/api/restart`,{method:`POST`}).catch(()=>{});for(let t=0;t<60;t++){await new Promise(e=>setTimeout(e,500));try{if((await fetch(`/api/meta`,{cache:`no-store`}).then(e=>e.json())).version===e)break}catch{}}location.reload()}var tc=`kw-version-changed`;function nc(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(!1);(0,v.useEffect)(()=>{let e=!0,n,r=async()=>{clearTimeout(n);try{let n=await fetch(`/api/meta`,{cache:`no-store`}).then(e=>e.json());e&&t(n)}catch{}e&&(n=setTimeout(r,3e4))};r();let i=()=>void r();return window.addEventListener(tc,i),()=>{e=!1,clearTimeout(n),window.removeEventListener(tc,i)}},[]);let i=e?.restartable&&e.diskVersion&&e.diskVersion!==e.version?e.diskVersion:null;async function a(){i&&(r(!0),await ec(i))}return!i&&!n?null:(0,S.jsx)(`button`,{className:`relaunch-note`,disabled:n,title:`v${i} is installed on disk, the server still runs v${e?.version}. Click to relaunch with the new version.`,onClick:()=>void a(),children:n?`relaunching…`:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(C,{name:`restart_alt`,className:`ms-sm`}),` v`,i,` ready — relaunch`]})})}function rc(){let e=B();return(0,S.jsxs)(`button`,{className:`expert-toggle ${e?`on`:``}`,title:e?`Expert mode on — full detail`:`Expert mode off — simplified view`,"aria-pressed":e,onClick:()=>z(!e),children:[(0,S.jsx)(`span`,{className:`expert-track`,children:(0,S.jsx)(`span`,{className:`expert-knob`})}),`expert`]})}var ic={approval:`gavel`,routine_done:`schedule`,routine_failed:`schedule`,run_done:`account_tree`,run_failed:`account_tree`},ac=`kw.notif.toast.dismissed`;function oc(){let[e,t]=(0,v.useState)(!1),n=U(`/api/notifications`,!1,5e3),[r,i]=(0,v.useState)(()=>typeof Notification>`u`?`unsupported`:Notification.permission),[a,o]=(0,v.useState)(()=>{try{return localStorage.getItem(ac)===`1`}catch{return!1}}),s=(0,v.useRef)(null),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(null);(0,v.useEffect)(()=>l(null),[n]);let f=c??n,p=f?.items??[],m=f?.unread??0;(0,v.useEffect)(()=>k(m),[m]),(0,v.useEffect)(()=>{if(n){if(!s.current){s.current=new Set(p.map(e=>e.id));return}for(let e of p)if(!s.current.has(e.id)&&(s.current.add(e.id),!(e.readAt||r!==`granted`)&&(document.hidden||location.hash!==`#${e.href}`)))try{let t=new Notification(e.title,{body:e.body,tag:e.id});t.onclick=()=>{window.focus(),g(e),t.close()}}catch{}}},[n]),(0,v.useEffect)(()=>{if(!e)return;let n=e=>{e.target.closest(`.notif-wrap`)||t(!1)};return window.addEventListener(`mousedown`,n),()=>window.removeEventListener(`mousedown`,n)},[e]);async function h(e,t){try{let n=await fetch(e,{method:e.endsWith(`/notifications`)?`DELETE`:`POST`,headers:{"content-type":`application/json`},body:t===void 0?void 0:JSON.stringify(t)});if(!n.ok)return;let r=await n.json();l(`items`in r?r:{items:[],unread:0})}catch{}}function g(e){t(!1),e.readAt||h(`/api/notifications/read`,{ids:[e.id]}),F(e.href)}async function _(e){d(e.id);try{let n=await(await fetch(`/api/notifications/${encodeURIComponent(e.id)}/diagnose`,{method:`POST`})).json();n.href?(t(!1),F(n.href)):n.error&&alert(n.error)}catch{}d(null)}async function y(){typeof Notification>`u`||i(await Notification.requestPermission())}function b(){o(!0);try{localStorage.setItem(ac,`1`)}catch{}}let x=r==="default"&&!a;return(0,S.jsxs)(`span`,{className:`notif-wrap`,children:[(0,S.jsxs)(`button`,{className:`info-btn notif-btn ${m?`has-unread`:``}`,title:m?`${m} item${m===1?``:`s`} need your attention`:`Notifications`,"aria-label":`Notifications`,onClick:()=>t(e=>!e),children:[(0,S.jsx)(C,{name:m?`notifications_active`:`notifications`}),m>0&&(0,S.jsx)(`span`,{className:`notif-badge`,children:m>99?`99+`:m})]}),e&&(0,S.jsxs)(`div`,{className:`info-pop notif-pop`,role:`menu`,children:[(0,S.jsxs)(`div`,{className:`notif-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`notifications`}),(0,S.jsx)(`span`,{className:`spacer`}),m>0&&(0,S.jsx)(`button`,{className:`open-raw`,onClick:()=>void h(`/api/notifications/read`),children:`mark all read`}),p.length>0&&(0,S.jsx)(`button`,{className:`open-raw`,onClick:()=>void h(`/api/notifications`),children:`clear`})]}),x&&(0,S.jsxs)(`div`,{className:`notif-hint`,children:[(0,S.jsx)(`span`,{children:`Get a system notification when something needs you, even with this tab in the background.`}),(0,S.jsxs)(`span`,{className:`notif-hint-actions`,children:[(0,S.jsx)(`button`,{className:`ws-btn primary`,onClick:()=>void y(),children:`enable`}),(0,S.jsx)(`button`,{className:`ws-btn`,onClick:b,children:`not now`})]})]}),r===`denied`&&(0,S.jsx)(`div`,{className:`notif-hint muted`,children:`Browser notifications are blocked for this site — allow them in the address bar to get system alerts.`}),p.length===0?(0,S.jsx)(`div`,{className:`notif-empty`,children:`nothing needs you right now`}):(0,S.jsx)(`div`,{className:`notif-list`,children:p.slice(0,50).map(e=>(0,S.jsxs)(`div`,{className:`notif-row ${e.readAt?``:`unread`} ${e.kind}`,role:`button`,tabIndex:0,onClick:()=>g(e),onKeyDown:t=>{t.key===`Enter`&&g(e)},children:[(0,S.jsx)(`span`,{className:`notif-ico`,children:(0,S.jsx)(C,{name:ic[e.kind]})}),(0,S.jsxs)(`span`,{className:`notif-body`,children:[(0,S.jsx)(`span`,{className:`notif-title`,children:e.title}),e.body&&(0,S.jsx)(`span`,{className:`notif-sub`,children:e.body}),e.diagnose&&(0,S.jsx)(`span`,{className:`notif-actions`,children:(0,S.jsxs)(`button`,{className:`ws-btn notif-diagnose`,disabled:u===e.id,title:`Open a chat that finds the cause and proposes the fix`,onClick:t=>{t.stopPropagation(),_(e)},children:[(0,S.jsx)(C,{name:u===e.id?`progress_activity`:`troubleshoot`,className:`ms-sm`}),u===e.id?`starting…`:`diagnose`]})})]}),(0,S.jsx)(`span`,{className:`notif-when num`,children:Ee(e.at)})]},e.id))})]})]})}function sc(){let[e,t]=(0,v.useState)(!1),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(``);(0,v.useEffect)(()=>{if(!e)return;fetch(`/api/runs`).then(e=>e.json()).then(r).catch(()=>{}),fetch(`/api/workflows`).then(e=>e.json()).then(a).catch(()=>{}),fetch(`/api/meta`).then(e=>e.json()).then(e=>s(e.version)).catch(()=>{});let n=e=>{e.target.closest(`.info-wrap`)||t(!1)};return window.addEventListener(`mousedown`,n),()=>window.removeEventListener(`mousedown`,n)},[e]);let c=n?.runs[0];return(0,S.jsxs)(`span`,{className:`info-wrap`,children:[(0,S.jsx)(`button`,{className:`info-btn`,title:`Project info`,"aria-label":`Project info`,onClick:()=>t(e=>!e),children:(0,S.jsx)(C,{name:`info`})}),e&&(0,S.jsxs)(`div`,{className:`info-pop`,children:[(0,S.jsxs)(`div`,{className:`info-row`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`Workflows`}),(0,S.jsx)(`span`,{className:`info-v`,children:i?`${i.workflows.length} discovered`:`…`}),(0,S.jsx)(`code`,{className:`info-path`,title:i?.root,children:i?.root??``})]}),(0,S.jsxs)(`div`,{className:`info-row`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`Runs`}),(0,S.jsxs)(`span`,{className:`info-v`,children:[n?`${n.runs.length} total`:`…`,c?` · latest ${c.status}`:``]}),(0,S.jsx)(`code`,{className:`info-path`,title:n?.outputDir,children:n?.outputDir??``})]}),(0,S.jsxs)(`div`,{className:`info-row info-actions`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`Workspace`}),(0,S.jsxs)(`a`,{className:`update-btn`,href:`#/settings`,onClick:()=>t(!1),children:[(0,S.jsx)(C,{name:`settings`,className:`ms-sm`}),` settings`]})]}),(0,S.jsxs)(`div`,{className:`info-row info-actions`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`Theme`}),(0,S.jsx)(uc,{})]}),(0,S.jsxs)(`div`,{className:`info-row info-actions`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`Version`}),(0,S.jsx)(`span`,{className:`info-v mono`,children:o?`kraftwerk ${o}`:`…`}),(0,S.jsx)(lc,{})]})]})]})}function cc(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++)if((n[e]??0)!==(r[e]??0))return(n[e]??0)<(r[e]??0);return!1}function lc(){let[e,t]=(0,v.useState)(`idle`),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1);async function u(){t(`busy`);try{let e=await fetch(`/api/update-check`,{cache:`no-store`}),n=await e.json();if(!e.ok||!n.latest)throw Error();r(n),t(`done`)}catch{t(`err`)}}let d=i?.state===`running`;(0,v.useEffect)(()=>{if(!d)return;let e=!0,t=setInterval(async()=>{try{let t=await fetch(`/api/update`,{cache:`no-store`}).then(e=>e.json());if(!e)return;a(t),t.state!==`running`&&window.dispatchEvent(new Event(tc))}catch{}},1e3);return()=>{e=!1,clearInterval(t)}},[d]);async function f(){if(!n)return;s(``);let e=await fetch(`/api/update`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({version:n.latest})}),t=await e.json();e.ok?a(t):s(t.error??`update refused`)}if(i&&i.state!==`idle`&&n){let e=i.log[i.log.length-1]??``;return i.state===`running`?(0,S.jsxs)(`span`,{className:`update-result update-progress`,children:[(0,S.jsx)(C,{name:`progress_activity`,className:`ms-sm ms-spin`}),` installing v`,n.latest,`…`,e&&(0,S.jsx)(`code`,{className:`update-log`,title:i.log.join(`
|
|
223
223
|
`),children:e})]}):i.state===`done`?(0,S.jsxs)(`span`,{className:`update-result newer`,children:[`v`,n.latest,` installed —`,` `,i.restartable?(0,S.jsxs)(`button`,{className:`update-btn`,disabled:c,onClick:()=>{l(!0),ec(n.latest)},children:[(0,S.jsx)(C,{name:`restart_alt`,className:`ms-sm`}),` `,c?`relaunching…`:`relaunch`]}):(0,S.jsxs)(S.Fragment,{children:[`restart `,(0,S.jsx)(`code`,{children:`kraftwerk ui`}),` to use it`]})]}):(0,S.jsxs)(`span`,{className:`update-result update-failed`,title:i.log.join(`
|
|
224
224
|
`),children:[(0,S.jsx)(C,{name:`error`,className:`ms-sm`}),` install failed`,e?` — ${e}`:``,` · `,(0,S.jsxs)(`code`,{children:[`npm i -g `,n.name,`@latest`]})]})}return e===`done`&&n?cc(n.current,n.latest)?(0,S.jsxs)(`span`,{className:`update-result newer`,children:[`v`,n.latest,` available —`,` `,o?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`span`,{className:`update-refused`,title:o,children:o}),` · `,(0,S.jsxs)(`code`,{children:[`npm i -g `,n.name,`@latest`]})]}):(0,S.jsxs)(`button`,{className:`update-btn`,onClick:()=>void f(),children:[(0,S.jsx)(C,{name:`download`,className:`ms-sm`}),` update now`]})]}):(0,S.jsxs)(`span`,{className:`update-result`,children:[(0,S.jsx)(C,{name:`check`,className:`ms-sm`}),` up to date`]}):(0,S.jsx)(`button`,{className:`update-btn`,disabled:e===`busy`,onClick:()=>void u(),children:e===`busy`?`checking…`:e===`err`?`npm unreachable — retry`:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(C,{name:`sync`,className:`ms-sm`}),` check for updates`]})})}function uc(){return(0,S.jsx)(`button`,{className:`theme-btn`,onClick:()=>{let e=document.documentElement,t=e.dataset.theme===`light`?`dark`:`light`;e.dataset.theme=t;try{localStorage.setItem(`kw-theme`,t)}catch{}},children:`day / night`})}(0,y.createRoot)(document.getElementById(`root`)).render((0,S.jsx)(v.StrictMode,{children:(0,S.jsx)(Ks,{})}));export{o as a,d as i,x as n,s as o,h as r,l as s,jo as t};
|