@netnodeag/kraftwerk 0.49.0 → 0.50.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -2
- package/dist/inspector/chat/acp.js +7 -1
- package/dist/inspector/chat/backend.d.ts +14 -3
- package/dist/inspector/chat/pi.js +2 -2
- package/dist/inspector/chat/sessions.js +13 -3
- package/dist/inspector/git.d.ts +51 -0
- package/dist/inspector/git.js +17 -9
- package/dist/inspector/repos.d.ts +47 -0
- package/dist/inspector/repos.js +121 -2
- package/dist/inspector/server.js +38 -1
- package/inspector/dist/assets/dist-BB5opUKX.js +1 -0
- package/inspector/dist/assets/{dist-CFvGR87v.js → dist-BV28M6sp.js} +1 -1
- package/inspector/dist/assets/{dist-QwwTJ2wk.js → dist-Bi4ZTD6W.js} +1 -1
- package/inspector/dist/assets/{dist-BgYnJawU.js → dist-BuqvesGh.js} +1 -1
- package/inspector/dist/assets/{dist-BrgwFqUR.js → dist-CLSTyUdp.js} +1 -1
- package/inspector/dist/assets/{dist-BIvcKBWo.js → dist-Ca8OxgWP.js} +1 -1
- package/inspector/dist/assets/{dist-BFJWVdBm.js → dist-DGB-RjHI.js} +1 -1
- package/inspector/dist/assets/{dist-CjtxxsZ2.js → dist-DHS6DxTY.js} +1 -1
- package/inspector/dist/assets/{dist-B-8ArbIm.js → dist-DVWyuKcp.js} +1 -1
- package/inspector/dist/assets/{dist-tfmgozDB.js → dist-DkEzjj-j.js} +1 -1
- package/inspector/dist/assets/{dist-Bz0bwjja.js → dist-Dv003C77.js} +1 -1
- package/inspector/dist/assets/{editor-C6m40u-h.js → editor-B5WUiag9.js} +3 -3
- package/inspector/dist/assets/{index-Cvq-RiV2.js → index-BfiWjmwA.js} +6 -6
- package/inspector/dist/assets/{index-DcQwGaV2.css → index-DCpGWY1g.css} +1 -1
- package/inspector/dist/index.html +2 -2
- package/package.json +1 -1
- package/inspector/dist/assets/dist-Bl1ogZZM.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-B5WUiag9.js","assets/dist-H3rerbMg.js","assets/dist-Ca8OxgWP.js","assets/dist-DHS6DxTY.js","assets/dist-DkEzjj-j.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 ee=/\/+/g;function te(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function A(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 ne(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,ne(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+te(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(ee,`$&/`)+`/`),ne(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(ee,`$&/`)+`/`)+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+te(a,u),c+=ne(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+te(a,u++),c+=ne(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return ne(A(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 j(e,t,n){if(e==null)return e;var r=[],i=0;return ne(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function re(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 M=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)},N={map:j,forEach:function(e,t,n){j(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return j(e,function(){t++}),t},toArray:function(e){return j(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=N,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:re}},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,M)}catch(e){M(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&&te(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&&te(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,ee=k.port2;k.port1.onmessage=D,O=function(){ee.postMessage(null)}}else O=function(){_(D,0)};function te(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,te(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`),ee=Symbol.for(`react.memo_cache_sentinel`),te=Symbol.iterator;function A(e){return typeof e!=`object`||!e?null:(e=te&&e[te]||e[`@@iterator`],typeof e==`function`?e:null)}var ne=Symbol.for(`react.client.reference`);function j(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ne?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?j(e.type)||`Memo`:t;case O:t=e._payload,e=e._init;try{return j(e(t))}catch{}}return null}var re=Array.isArray,M=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,N=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ie={pending:!1,data:null,method:null,action:null},P=[],ae=-1;function oe(e){return{current:e}}function F(e){0>ae||(e.current=P[ae],P[ae]=null,ae--)}function I(e,t){ae++,P[ae]=e.current,e.current=t}var se=oe(null),ce=oe(null),le=oe(null),ue=oe(null);function de(e,t){switch(I(le,t),I(ce,e),I(se,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}}F(se),I(se,e)}function L(){F(se),F(ce),F(le)}function fe(e){e.memoizedState!==null&&I(ue,e);var t=se.current,n=Hd(t,e.type);t!==n&&(I(ce,e),I(se,n))}function R(e){ce.current===e&&(F(se),F(ce)),ue.current===e&&(F(ue),Qf._currentValue=ie)}var pe,me;function he(e){if(pe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);pe=t&&t[1]||``,me=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+pe+e+me}var ge=!1;function _e(e,t){if(!e||ge)return``;ge=!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(`
|
|
@@ -212,10 +212,10 @@ description: What this skill is for (one line)
|
|
|
212
212
|
|
|
213
213
|
Instructions this agent follows when the skill applies or is invoked with /<name>.
|
|
214
214
|
`;function Ba({slug:e}){let t=z(`/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:za,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(`
|
|
215
|
-
`).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 Va({slug:e}){let t=z(`/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&&A(`/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)(j,{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 ${we(t.nextRunAt)}`:``:` · paused`,` · `,t.lastChatId?(0,S.jsxs)(j,{href:`/agents/${encodeURIComponent(e)}/chat/${t.lastChatId}`,children:[`last run `,we(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 Ha({slug:e}){let[t,n]=(0,v.useState)(e?null:u()),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(!1),s=z(`/api/workflows`,!1)?.workflows??[],c=z(`/api/knowledge`,!1)?.bundles??[],l=z(`/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):A(`/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(()=>{}),A(`/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:Oa.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:Da.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`})]})]})})]})}var Ua={enabled:!1,remote:`origin`,branch:``,interval:`300`,autosync:`pull`};function Wa(e){let t=e.config.git;return t?{enabled:t.enabled!==!1,remote:t.remote??Ua.remote,branch:t.branch??``,interval:String(t.interval??Ua.interval),autosync:t.autosync??Ua.autosync}:Ua}var Ga={enabled:!1,root:``};function Ka(e){let t=e.config.repos;return t?{enabled:t.enabled!==!1,root:t.root??``}:Ga}function qa(e){let t=e.config.vibeables;return t?{enabled:t.enabled!==!1,root:t.root??``}:Ga}function Ja(e){let t=e.config.projects;return t?{enabled:t.enabled!==!1,root:t.root??``}:Ga}function Ya(){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)([]),[u,d]=(0,v.useState)(Ua),[f,p]=(0,v.useState)(Ga),[m,h]=(0,v.useState)(Ga),[g,_]=(0,v.useState)(Ga),[y,b]=(0,v.useState)(!1),[x,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)(!1),[D,O]=(0,v.useState)(``);(0,v.useEffect)(()=>{fetch(`/api/settings`).then(e=>e.json()).then(e=>{t(e),r(e.config.name??``),a(e.config.icon??``),s(e.config.color??``),l(e.config.switcher??[]),d(Wa(e)),p(Ka(e)),h(qa(e)),_(Ja(e))}).catch(()=>O(`could not load settings`))},[]);let k=()=>{b(!0),E(!1),O(``)};async function ee(){w(!0),O(``);try{let e=await fetch(`/api/settings`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({name:n,icon:i,color:o,switcher:c,git:{...u,interval:u.interval===``?void 0:Number(u.interval)},repos:f,vibeables:m,projects:g})}),r=await e.json();if(!e.ok)throw Error(r.error||`save failed`);t(r),l(r.config.switcher??[]),d(Wa(r)),p(Ka(r)),h(qa(r)),_(Ja(r)),b(!1),E(!0),window.dispatchEvent(new Event(`kw-meta-refresh`))}catch(e){O(e.message)}finally{w(!1)}}let te=(e,t)=>{l(n=>n.map((n,r)=>r===e?{...n,...t}:n)),k()},A=e=>{d(t=>({...t,...e})),k()},ne=e=>{p(t=>({...t,...e})),k()},j=e=>{h(t=>({...t,...e})),k()},re=e=>{_(t=>({...t,...e})),k()};if(!e)return(0,S.jsx)(`div`,{className:`empty`,children:D||`loading…`});let M=[[`port`,String(e.resolved.port),`kraftwerk ui listens here (CLI --port wins)`],[`workflows`,e.resolved.workflowsRoot??`— none found`,`workflow definitions`],[`output`,e.resolved.outputDir,`run artifacts`],[`knowledge`,e.config.knowledge??`knowledge`,`OKF knowledge bundles`],[`agents`,e.config.agents??`agents`,`agent definitions`],[`skills`,e.config.skills??`skills`,`workspace skills`]];return(0,S.jsxs)(`div`,{className:`settings-screen`,children:[(0,S.jsxs)(`div`,{className:`settings-head`,children:[(0,S.jsxs)(`h1`,{children:[(0,S.jsx)(C,{name:`settings`,className:`ms-lg`}),` Settings`]}),(0,S.jsx)(`span`,{className:`spacer`}),D&&(0,S.jsx)(`span`,{className:`settings-err`,children:D}),T&&!y&&(0,S.jsxs)(`span`,{className:`settings-saved`,children:[(0,S.jsx)(C,{name:`check`,className:`ms-sm`}),` saved`]}),(0,S.jsx)(`button`,{className:`run-btn`,disabled:x||!y,onClick:()=>void ee(),children:x?`saving…`:`save changes`})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsx)(`div`,{className:`panel-head`,children:(0,S.jsx)(`span`,{className:`microlabel`,children:`workspace`})}),(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:{width:90},children:[`icon`,(0,S.jsx)(`input`,{value:i,placeholder:`🤖`,onChange:e=>{a(e.target.value),k()}})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`name`,(0,S.jsx)(`input`,{value:n,placeholder:`my workspace`,onChange:e=>{r(e.target.value),k()}})]}),(0,S.jsxs)(`label`,{className:`agent-field settings-color`,style:{width:130},title:`Accent in the workspace switcher; empty = derived from the folder`,children:[`color`,(0,S.jsxs)(`span`,{className:`settings-color-row`,children:[(0,S.jsx)(`input`,{type:`color`,value:/^#[0-9a-f]{6}$/i.test(o)?o:`#888888`,onChange:e=>{s(e.target.value),k()}}),(0,S.jsx)(`input`,{value:o,placeholder:`auto`,onChange:e=>{s(e.target.value),k()}})]})]})]}),(0,S.jsx)(`div`,{className:`settings-note`,children:`Shown in the header, browser tab and to other workspaces discovering this one.`})]})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`workspace switcher`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`button`,{className:`run-btn tonal`,onClick:()=>{l(e=>[...e,{name:``,url:`http://localhost:`}]),k()},children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` add entry`]})]}),(0,S.jsxs)(`div`,{className:`agent-form`,children:[c.length===0&&(0,S.jsx)(`div`,{className:`settings-note`,children:`No manual entries.`}),c.map((e,t)=>(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsxs)(`label`,{className:`agent-field`,style:{width:70},children:[`icon`,(0,S.jsx)(`input`,{value:e.icon??``,placeholder:`•`,onChange:e=>te(t,{icon:e.target.value})})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`name`,(0,S.jsx)(`input`,{value:e.name,placeholder:`other workspace`,onChange:e=>te(t,{name:e.target.value})})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1.4},children:[`url`,(0,S.jsx)(`input`,{value:e.url,placeholder:`http://localhost:1982`,onChange:e=>te(t,{url:e.target.value})})]}),(0,S.jsx)(`button`,{className:`row-x settings-row-x`,title:`remove entry`,onClick:()=>{l(e=>e.filter((e,n)=>n!==t)),k()},children:(0,S.jsx)(C,{name:`close`,className:`ms-sm`})})]},t)),(0,S.jsx)(`div`,{className:`settings-note`,children:`Running workspaces on this machine are discovered automatically — manual entries are for remote instances or extra links.`})]})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`git sync`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`a`,{className:`run-btn tonal`,href:`#/git`,children:[(0,S.jsx)(C,{name:`account_tree`,className:`ms-sm`}),` open git`]})]}),(0,S.jsxs)(`div`,{className:`agent-form`,children:[(0,S.jsxs)(`label`,{className:`settings-check`,children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:u.enabled,onChange:e=>A({enabled:e.target.checked})}),`sync workflows, knowledge, agents and skills with a git remote`]}),u.enabled&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`remote`,(0,S.jsx)(`input`,{value:u.remote,placeholder:`origin`,onChange:e=>A({remote:e.target.value})})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`branch`,(0,S.jsx)(`input`,{value:u.branch,placeholder:`checked-out branch`,onChange:e=>A({branch:e.target.value})})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{width:120},children:[`interval (s)`,(0,S.jsx)(`input`,{type:`number`,min:0,step:1,value:u.interval,placeholder:`300`,onChange:e=>A({interval:e.target.value})})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{width:150},children:[`autosync`,(0,S.jsxs)(`select`,{value:u.autosync,onChange:e=>A({autosync:e.target.value}),children:[(0,S.jsx)(`option`,{value:`pull`,children:`fetch and pull`}),(0,S.jsx)(`option`,{value:`off`,children:`fetch only`})]})]})]}),(0,S.jsx)(`div`,{className:`settings-note`,children:`The interval fetches in the background (0 turns the timer off); with autosync on it also fast-forwards when behind and nothing is modified locally. Commit and push stay manual on the git screen.`})]})]})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`repositories`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`a`,{className:`run-btn tonal`,href:`#/repos`,children:[(0,S.jsx)(C,{name:`source`,className:`ms-sm`}),` open repositories`]})]}),(0,S.jsxs)(`div`,{className:`agent-form`,children:[(0,S.jsxs)(`label`,{className:`settings-check`,children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:f.enabled,onChange:e=>ne({enabled:e.target.checked})}),`keep git repositories the agents work on under one folder`]}),f.enabled&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`agent-form-row`,children:(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`repos root`,(0,S.jsx)(`input`,{value:f.root,placeholder:`repos`,onChange:e=>ne({root:e.target.value})})]})}),(0,S.jsxs)(`div`,{className:`settings-note`,children:[`Relative to the project root. Saving creates the folder and adds it to .gitignore; every agent gets the list of clones as context and can add more with `,(0,S.jsx)(`code`,{children:`kraftwerk repos add`}),`.`]})]})]})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`vibeables`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`a`,{className:`run-btn tonal`,href:`#/vibeables`,children:[(0,S.jsx)(C,{name:`web`,className:`ms-sm`}),` open vibeables`]})]}),(0,S.jsxs)(`div`,{className:`agent-form`,children:[(0,S.jsxs)(`label`,{className:`settings-check`,children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:m.enabled,onChange:e=>j({enabled:e.target.checked})}),`build small apps live in a chat, with a preview pane next to the thread`]}),m.enabled&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`agent-form-row`,children:(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`vibeables root`,(0,S.jsx)(`input`,{value:m.root,placeholder:`kraftwerk-data/vibeables`,onChange:e=>j({root:e.target.value})})]})}),(0,S.jsxs)(`div`,{className:`settings-note`,children:[`Relative to the project root, one folder per app. Part of the workspace: versioned with it on the git screen, not git-ignored. Every chat gets a `,(0,S.jsx)(`b`,{children:`vibeable`}),` button; the agent then works inside the app folder.`]})]})]})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`projects`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`a`,{className:`run-btn tonal`,href:`#/projects`,children:[(0,S.jsx)(C,{name:`folder_special`,className:`ms-sm`}),` open projects`]})]}),(0,S.jsxs)(`div`,{className:`agent-form`,children:[(0,S.jsxs)(`label`,{className:`settings-check`,children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:g.enabled,onChange:e=>re({enabled:e.target.checked})}),`gather a goal, its brief, systems of record and links in one folder, and chat inside it`]}),g.enabled&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`agent-form-row`,children:(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`projects root`,(0,S.jsx)(`input`,{value:g.root,placeholder:`kraftwerk-data/projects`,onChange:e=>re({root:e.target.value})})]})}),(0,S.jsx)(`div`,{className:`settings-note`,children:`Relative to the project root, one folder per project (project.yml, brief.md, state.md, log.md). Part of the workspace: versioned with it on the git screen. A chat opened in a project starts with all of it as context.`})]})]})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`paths & port`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(`code`,{className:`settings-file`,title:e.configPath,children:e.exists?e.configPath:`${e.configPath} (not created yet)`})]}),(0,S.jsx)(`div`,{className:`settings-kv-list`,children:M.map(([e,t,n])=>(0,S.jsxs)(`div`,{className:`settings-kv`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:e}),(0,S.jsx)(`code`,{children:t}),(0,S.jsx)(`span`,{className:`settings-kv-hint`,children:n})]},e))}),(0,S.jsxs)(`div`,{className:`settings-note`,style:{padding:`0 18px 14px`},children:[`Read-only here — edit `,(0,S.jsx)(`code`,{children:`kraftwerk.yml`}),` directly to change these.`]})]})]})}var Xa={running:{label:`running`},stopped:{label:`stopped`},died:{label:`died`,note:`was killed or crashed`},missing:{label:`missing`,note:`folder is gone`},orphaned:{label:`orphaned`,note:`no kraftwerk.yml any more`}};function Za(){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=(0,v.useCallback)(async()=>{try{let e=await fetch(`/api/workspaces`,{cache:`no-store`});if(e.ok){t(await e.json()),r(``);return}r(e.status===404?`This workspace runs a kraftwerk without the workspaces API. Update it and restart its UI.`:`Could not load the workspace registry (HTTP ${e.status}).`)}catch(e){r(e.message||`Could not reach this workspace's server.`)}},[]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await u(),e&&(t=setTimeout(n,6e3))};return n(),()=>{e=!1,clearTimeout(t)}},[u]);let d=e=>e.root??e.url,f=async(e,t)=>{let n=d(e);a(e=>({...e,[n]:t})),s(e=>({...e,[n]:``})),l(null);try{let n=t===`stop`?{root:e.root,url:e.url}:{root:e.root},r=await ye(`/api/workspaces/${t}`,n);if(!r.ok)throw Error(r.error||`failed`);window.dispatchEvent(new Event(`kw-meta-refresh`))}catch(e){s(t=>({...t,[n]:e.message}))}finally{a(e=>{let t={...e};return delete t[n],t}),u()}},p=e?.filter(e=>e.live).length??0,m=new Map;for(let t of e??[])t.icon&&m.set(t.icon,(m.get(t.icon)??0)+1);let h=e=>!!e&&(m.get(e)??0)>1;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:`hub`,className:`ms-lg`}),` Workspaces`]}),(0,S.jsx)(`span`,{className:`spacer`}),e&&(0,S.jsxs)(`span`,{className:`settings-note`,children:[e.length,` known · `,p,` running`]}),e&&n&&(0,S.jsx)(`span`,{className:`settings-err`,children:n})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`workspaces on this machine`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`span`,{className:`settings-note`,children:[`registry: `,(0,S.jsx)(`code`,{children:`~/.kraftwerk/workspaces`})]})]}),!e&&!n&&(0,S.jsx)(`div`,{className:`ws-empty`,children:`loading…`}),!e&&n&&(0,S.jsxs)(`div`,{className:`ws-empty ws-load-error`,children:[(0,S.jsx)(C,{name:`error`,className:`ms-sm`}),` `,n]}),e&&e.length===0&&(0,S.jsx)(`div`,{className:`ws-empty`,children:`No workspaces known yet.`}),e?.map(e=>{let t=d(e),n=i[t],r=!e.live&&!!e.root&&(e.exists===!1||e.hasConfig===!1);return(0,S.jsxs)(`div`,{className:`ws-row state-${e.state} ${e.current?`current`:``}`,children:[(0,S.jsx)(ve,{className:`ws-icon`,icon:e.icon,name:e.name,color:e.color,seed:e.root??e.url,ambiguous:h(e.icon)}),(0,S.jsxs)(`div`,{className:`ws-main`,children:[(0,S.jsxs)(`div`,{className:`ws-title`,children:[e.live&&!e.current?(0,S.jsx)(`a`,{href:e.url,className:`ws-name${e.named===!1?` unnamed`:``}`,children:e.name}):(0,S.jsx)(`span`,{className:`ws-name${e.named===!1?` unnamed`:``}`,children:e.name}),e.current&&(0,S.jsx)(`span`,{className:`switcher-hint`,children:`current`}),(0,S.jsxs)(`span`,{className:`ws-state ws-state-${e.state}`,children:[e.live&&(0,S.jsx)(`span`,{className:`live-dot`}),Xa[e.state].label]}),Xa[e.state].note&&(0,S.jsx)(`span`,{className:`ws-note`,children:Xa[e.state].note})]}),(0,S.jsx)(`div`,{className:`ws-root`,title:e.root,children:e.rootLabel??(0,S.jsx)(`span`,{className:`ws-dim`,children:`no root recorded (started by an older version)`})}),(0,S.jsxs)(`div`,{className:`ws-meta`,children:[e.state!==`missing`&&e.state!==`orphaned`&&(0,S.jsx)(`span`,{children:e.url.replace(/^https?:\/\//,``)}),e.counts&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`span`,{children:[e.counts.agents,` agents`]}),(0,S.jsxs)(`span`,{children:[e.counts.workflows,` workflows`]}),(0,S.jsxs)(`span`,{children:[e.counts.runs,` runs`]}),(0,S.jsxs)(`span`,{children:[e.counts.chats,` chats`]})]}),e.lastStarted&&(0,S.jsxs)(`span`,{title:e.lastStarted,children:[`started `,Te(e.lastStarted)]}),!e.live&&e.lastStopped&&(0,S.jsxs)(`span`,{title:e.lastStopped,children:[`stopped `,Te(e.lastStopped)]}),e.startCount!=null&&(0,S.jsxs)(`span`,{children:[e.startCount,`× launched`]}),e.firstSeen&&(0,S.jsxs)(`span`,{title:e.firstSeen,children:[`first seen `,Te(e.firstSeen)]})]}),o[t]&&(0,S.jsx)(`div`,{className:`settings-err`,children:o[t]})]}),(0,S.jsxs)(`div`,{className:`ws-actions`,children:[e.live&&!e.current&&(0,S.jsxs)(`a`,{className:`ws-btn`,href:e.url,title:`Open this workspace`,children:[(0,S.jsx)(C,{name:`open_in_new`,className:`ms-sm`}),` open`]}),!e.live&&e.root&&e.exists!==!1&&!e.dirGone&&(0,S.jsxs)(`button`,{className:`ws-btn primary`,disabled:!!n,onClick:()=>void f(e,`start`),children:[(0,S.jsx)(C,{name:n===`start`?`progress_activity`:`play_arrow`,className:`ms-sm`}),n===`start`?`starting…`:`start`]}),e.live&&!e.current&&(0,S.jsxs)(`button`,{className:`ws-btn danger`,disabled:!!n,onClick:()=>void f(e,`stop`),children:[(0,S.jsx)(C,{name:n===`stop`?`progress_activity`:`stop`,className:`ms-sm`}),n===`stop`?`stopping…`:`stop`]}),r&&c!==t&&(0,S.jsxs)(`button`,{className:`ws-btn`,disabled:!!n,title:`Drop this project from the registry (files untouched)`,onClick:()=>l(t),children:[(0,S.jsx)(C,{name:`delete`,className:`ms-sm`}),` remove`]}),r&&c===t&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`button`,{className:`ws-btn danger`,onClick:()=>void f(e,`forget`),children:[(0,S.jsx)(C,{name:`delete`,className:`ms-sm`}),` confirm remove`]}),(0,S.jsx)(`button`,{className:`ws-btn`,onClick:()=>l(null),children:`cancel`})]})]})]},t)})]}),(0,S.jsxs)(`p`,{className:`settings-note`,children:[`Start launches `,(0,S.jsx)(`code`,{children:`kraftwerk ui`}),` detached in the project root (log in `,(0,S.jsx)(`code`,{children:`~/.kraftwerk/logs`}),`). Stop sends SIGTERM to the running server. Remove is offered only for records whose root no longer holds a `,(0,S.jsx)(`code`,{children:`kraftwerk.yml`}),` — the same from the terminal:`,` `,(0,S.jsx)(`code`,{children:`kraftwerk workspaces`}),`.`]})]})}function Qa(e){if(e<60)return`${e}s`;let t=Math.round(e/60);if(t<60)return`${t} min`;let n=Math.floor(t/60),r=t%60;return r?`${n} h ${r} min`:`${n} h`}var $a=[[/^(\+\+\+|---|diff |index )/,`d-meta`],[/^@@/,`d-hunk`],[/^\+/,`d-add`],[/^-/,`d-del`]],eo=e=>$a.find(([t])=>t.test(e))?.[1]??``;function to({file:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(``);return(0,v.useEffect)(()=>{let t=!0;return fetch(`/api/git/diff?path=${encodeURIComponent(e)}`).then(e=>e.json()).then(e=>{t&&(n(e.diff??``),i(!!e.truncated),o(e.error??``))}).catch(()=>t&&o(`could not load the diff`)),()=>{t=!1}},[e]),a?(0,S.jsx)(`div`,{className:`git-diff git-diff-error`,children:a}):t===null?(0,S.jsx)(`div`,{className:`git-diff`,children:`loading…`}):t.trim()?(0,S.jsxs)(`pre`,{className:`git-diff`,children:[t.split(`
|
|
215
|
+
`).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 Va({slug:e}){let t=z(`/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&&A(`/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)(j,{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 ${we(t.nextRunAt)}`:``:` · paused`,` · `,t.lastChatId?(0,S.jsxs)(j,{href:`/agents/${encodeURIComponent(e)}/chat/${t.lastChatId}`,children:[`last run `,we(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 Ha({slug:e}){let[t,n]=(0,v.useState)(e?null:u()),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(!1),s=z(`/api/workflows`,!1)?.workflows??[],c=z(`/api/knowledge`,!1)?.bundles??[],l=z(`/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):A(`/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(()=>{}),A(`/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:Oa.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:Da.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`})]})]})})]})}var Ua={enabled:!1,remote:`origin`,branch:``,interval:`300`,autosync:`pull`};function Wa(e){let t=e.config.git;return t?{enabled:t.enabled!==!1,remote:t.remote??Ua.remote,branch:t.branch??``,interval:String(t.interval??Ua.interval),autosync:t.autosync??Ua.autosync}:Ua}var Ga={enabled:!1,root:``};function Ka(e){let t=e.config.repos;return t?{enabled:t.enabled!==!1,root:t.root??``}:Ga}function qa(e){let t=e.config.vibeables;return t?{enabled:t.enabled!==!1,root:t.root??``}:Ga}function Ja(e){let t=e.config.projects;return t?{enabled:t.enabled!==!1,root:t.root??``}:Ga}function Ya(){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)([]),[u,d]=(0,v.useState)(Ua),[f,p]=(0,v.useState)(Ga),[m,h]=(0,v.useState)(Ga),[g,_]=(0,v.useState)(Ga),[y,b]=(0,v.useState)(!1),[x,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)(!1),[D,O]=(0,v.useState)(``);(0,v.useEffect)(()=>{fetch(`/api/settings`).then(e=>e.json()).then(e=>{t(e),r(e.config.name??``),a(e.config.icon??``),s(e.config.color??``),l(e.config.switcher??[]),d(Wa(e)),p(Ka(e)),h(qa(e)),_(Ja(e))}).catch(()=>O(`could not load settings`))},[]);let k=()=>{b(!0),E(!1),O(``)};async function ee(){w(!0),O(``);try{let e=await fetch(`/api/settings`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({name:n,icon:i,color:o,switcher:c,git:{...u,interval:u.interval===``?void 0:Number(u.interval)},repos:f,vibeables:m,projects:g})}),r=await e.json();if(!e.ok)throw Error(r.error||`save failed`);t(r),l(r.config.switcher??[]),d(Wa(r)),p(Ka(r)),h(qa(r)),_(Ja(r)),b(!1),E(!0),window.dispatchEvent(new Event(`kw-meta-refresh`))}catch(e){O(e.message)}finally{w(!1)}}let te=(e,t)=>{l(n=>n.map((n,r)=>r===e?{...n,...t}:n)),k()},A=e=>{d(t=>({...t,...e})),k()},ne=e=>{p(t=>({...t,...e})),k()},j=e=>{h(t=>({...t,...e})),k()},re=e=>{_(t=>({...t,...e})),k()};if(!e)return(0,S.jsx)(`div`,{className:`empty`,children:D||`loading…`});let M=[[`port`,String(e.resolved.port),`kraftwerk ui listens here (CLI --port wins)`],[`workflows`,e.resolved.workflowsRoot??`— none found`,`workflow definitions`],[`output`,e.resolved.outputDir,`run artifacts`],[`knowledge`,e.config.knowledge??`knowledge`,`OKF knowledge bundles`],[`agents`,e.config.agents??`agents`,`agent definitions`],[`skills`,e.config.skills??`skills`,`workspace skills`]];return(0,S.jsxs)(`div`,{className:`settings-screen`,children:[(0,S.jsxs)(`div`,{className:`settings-head`,children:[(0,S.jsxs)(`h1`,{children:[(0,S.jsx)(C,{name:`settings`,className:`ms-lg`}),` Settings`]}),(0,S.jsx)(`span`,{className:`spacer`}),D&&(0,S.jsx)(`span`,{className:`settings-err`,children:D}),T&&!y&&(0,S.jsxs)(`span`,{className:`settings-saved`,children:[(0,S.jsx)(C,{name:`check`,className:`ms-sm`}),` saved`]}),(0,S.jsx)(`button`,{className:`run-btn`,disabled:x||!y,onClick:()=>void ee(),children:x?`saving…`:`save changes`})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsx)(`div`,{className:`panel-head`,children:(0,S.jsx)(`span`,{className:`microlabel`,children:`workspace`})}),(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:{width:90},children:[`icon`,(0,S.jsx)(`input`,{value:i,placeholder:`🤖`,onChange:e=>{a(e.target.value),k()}})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`name`,(0,S.jsx)(`input`,{value:n,placeholder:`my workspace`,onChange:e=>{r(e.target.value),k()}})]}),(0,S.jsxs)(`label`,{className:`agent-field settings-color`,style:{width:130},title:`Accent in the workspace switcher; empty = derived from the folder`,children:[`color`,(0,S.jsxs)(`span`,{className:`settings-color-row`,children:[(0,S.jsx)(`input`,{type:`color`,value:/^#[0-9a-f]{6}$/i.test(o)?o:`#888888`,onChange:e=>{s(e.target.value),k()}}),(0,S.jsx)(`input`,{value:o,placeholder:`auto`,onChange:e=>{s(e.target.value),k()}})]})]})]}),(0,S.jsx)(`div`,{className:`settings-note`,children:`Shown in the header, browser tab and to other workspaces discovering this one.`})]})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`workspace switcher`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`button`,{className:`run-btn tonal`,onClick:()=>{l(e=>[...e,{name:``,url:`http://localhost:`}]),k()},children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` add entry`]})]}),(0,S.jsxs)(`div`,{className:`agent-form`,children:[c.length===0&&(0,S.jsx)(`div`,{className:`settings-note`,children:`No manual entries.`}),c.map((e,t)=>(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsxs)(`label`,{className:`agent-field`,style:{width:70},children:[`icon`,(0,S.jsx)(`input`,{value:e.icon??``,placeholder:`•`,onChange:e=>te(t,{icon:e.target.value})})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`name`,(0,S.jsx)(`input`,{value:e.name,placeholder:`other workspace`,onChange:e=>te(t,{name:e.target.value})})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1.4},children:[`url`,(0,S.jsx)(`input`,{value:e.url,placeholder:`http://localhost:1982`,onChange:e=>te(t,{url:e.target.value})})]}),(0,S.jsx)(`button`,{className:`row-x settings-row-x`,title:`remove entry`,onClick:()=>{l(e=>e.filter((e,n)=>n!==t)),k()},children:(0,S.jsx)(C,{name:`close`,className:`ms-sm`})})]},t)),(0,S.jsx)(`div`,{className:`settings-note`,children:`Running workspaces on this machine are discovered automatically — manual entries are for remote instances or extra links.`})]})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`git sync`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`a`,{className:`run-btn tonal`,href:`#/git`,children:[(0,S.jsx)(C,{name:`account_tree`,className:`ms-sm`}),` open git`]})]}),(0,S.jsxs)(`div`,{className:`agent-form`,children:[(0,S.jsxs)(`label`,{className:`settings-check`,children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:u.enabled,onChange:e=>A({enabled:e.target.checked})}),`sync workflows, knowledge, agents and skills with a git remote`]}),u.enabled&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`remote`,(0,S.jsx)(`input`,{value:u.remote,placeholder:`origin`,onChange:e=>A({remote:e.target.value})})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`branch`,(0,S.jsx)(`input`,{value:u.branch,placeholder:`checked-out branch`,onChange:e=>A({branch:e.target.value})})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{width:120},children:[`interval (s)`,(0,S.jsx)(`input`,{type:`number`,min:0,step:1,value:u.interval,placeholder:`300`,onChange:e=>A({interval:e.target.value})})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{width:150},children:[`autosync`,(0,S.jsxs)(`select`,{value:u.autosync,onChange:e=>A({autosync:e.target.value}),children:[(0,S.jsx)(`option`,{value:`pull`,children:`fetch and pull`}),(0,S.jsx)(`option`,{value:`off`,children:`fetch only`})]})]})]}),(0,S.jsx)(`div`,{className:`settings-note`,children:`The interval fetches in the background (0 turns the timer off); with autosync on it also fast-forwards when behind and nothing is modified locally. Commit and push stay manual on the git screen.`})]})]})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`repositories`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`a`,{className:`run-btn tonal`,href:`#/repos`,children:[(0,S.jsx)(C,{name:`source`,className:`ms-sm`}),` open repositories`]})]}),(0,S.jsxs)(`div`,{className:`agent-form`,children:[(0,S.jsxs)(`label`,{className:`settings-check`,children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:f.enabled,onChange:e=>ne({enabled:e.target.checked})}),`keep git repositories the agents work on under one folder`]}),f.enabled&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`agent-form-row`,children:(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`repos root`,(0,S.jsx)(`input`,{value:f.root,placeholder:`repos`,onChange:e=>ne({root:e.target.value})})]})}),(0,S.jsxs)(`div`,{className:`settings-note`,children:[`Relative to the project root. Saving creates the folder and adds it to .gitignore; every agent gets the list of clones as context and can add more with `,(0,S.jsx)(`code`,{children:`kraftwerk repos add`}),`.`]})]})]})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`vibeables`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`a`,{className:`run-btn tonal`,href:`#/vibeables`,children:[(0,S.jsx)(C,{name:`web`,className:`ms-sm`}),` open vibeables`]})]}),(0,S.jsxs)(`div`,{className:`agent-form`,children:[(0,S.jsxs)(`label`,{className:`settings-check`,children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:m.enabled,onChange:e=>j({enabled:e.target.checked})}),`build small apps live in a chat, with a preview pane next to the thread`]}),m.enabled&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`agent-form-row`,children:(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`vibeables root`,(0,S.jsx)(`input`,{value:m.root,placeholder:`kraftwerk-data/vibeables`,onChange:e=>j({root:e.target.value})})]})}),(0,S.jsxs)(`div`,{className:`settings-note`,children:[`Relative to the project root, one folder per app. Part of the workspace: versioned with it on the git screen, not git-ignored. Every chat gets a `,(0,S.jsx)(`b`,{children:`vibeable`}),` button; the agent then works inside the app folder.`]})]})]})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`projects`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`a`,{className:`run-btn tonal`,href:`#/projects`,children:[(0,S.jsx)(C,{name:`folder_special`,className:`ms-sm`}),` open projects`]})]}),(0,S.jsxs)(`div`,{className:`agent-form`,children:[(0,S.jsxs)(`label`,{className:`settings-check`,children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:g.enabled,onChange:e=>re({enabled:e.target.checked})}),`gather a goal, its brief, systems of record and links in one folder, and chat inside it`]}),g.enabled&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`agent-form-row`,children:(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`projects root`,(0,S.jsx)(`input`,{value:g.root,placeholder:`kraftwerk-data/projects`,onChange:e=>re({root:e.target.value})})]})}),(0,S.jsx)(`div`,{className:`settings-note`,children:`Relative to the project root, one folder per project (project.yml, brief.md, state.md, log.md). Part of the workspace: versioned with it on the git screen. A chat opened in a project starts with all of it as context.`})]})]})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`paths & port`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(`code`,{className:`settings-file`,title:e.configPath,children:e.exists?e.configPath:`${e.configPath} (not created yet)`})]}),(0,S.jsx)(`div`,{className:`settings-kv-list`,children:M.map(([e,t,n])=>(0,S.jsxs)(`div`,{className:`settings-kv`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:e}),(0,S.jsx)(`code`,{children:t}),(0,S.jsx)(`span`,{className:`settings-kv-hint`,children:n})]},e))}),(0,S.jsxs)(`div`,{className:`settings-note`,style:{padding:`0 18px 14px`},children:[`Read-only here — edit `,(0,S.jsx)(`code`,{children:`kraftwerk.yml`}),` directly to change these.`]})]})]})}var Xa={running:{label:`running`},stopped:{label:`stopped`},died:{label:`died`,note:`was killed or crashed`},missing:{label:`missing`,note:`folder is gone`},orphaned:{label:`orphaned`,note:`no kraftwerk.yml any more`}};function Za(){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=(0,v.useCallback)(async()=>{try{let e=await fetch(`/api/workspaces`,{cache:`no-store`});if(e.ok){t(await e.json()),r(``);return}r(e.status===404?`This workspace runs a kraftwerk without the workspaces API. Update it and restart its UI.`:`Could not load the workspace registry (HTTP ${e.status}).`)}catch(e){r(e.message||`Could not reach this workspace's server.`)}},[]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await u(),e&&(t=setTimeout(n,6e3))};return n(),()=>{e=!1,clearTimeout(t)}},[u]);let d=e=>e.root??e.url,f=async(e,t)=>{let n=d(e);a(e=>({...e,[n]:t})),s(e=>({...e,[n]:``})),l(null);try{let n=t===`stop`?{root:e.root,url:e.url}:{root:e.root},r=await ye(`/api/workspaces/${t}`,n);if(!r.ok)throw Error(r.error||`failed`);window.dispatchEvent(new Event(`kw-meta-refresh`))}catch(e){s(t=>({...t,[n]:e.message}))}finally{a(e=>{let t={...e};return delete t[n],t}),u()}},p=e?.filter(e=>e.live).length??0,m=new Map;for(let t of e??[])t.icon&&m.set(t.icon,(m.get(t.icon)??0)+1);let h=e=>!!e&&(m.get(e)??0)>1;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:`hub`,className:`ms-lg`}),` Workspaces`]}),(0,S.jsx)(`span`,{className:`spacer`}),e&&(0,S.jsxs)(`span`,{className:`settings-note`,children:[e.length,` known · `,p,` running`]}),e&&n&&(0,S.jsx)(`span`,{className:`settings-err`,children:n})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`workspaces on this machine`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsxs)(`span`,{className:`settings-note`,children:[`registry: `,(0,S.jsx)(`code`,{children:`~/.kraftwerk/workspaces`})]})]}),!e&&!n&&(0,S.jsx)(`div`,{className:`ws-empty`,children:`loading…`}),!e&&n&&(0,S.jsxs)(`div`,{className:`ws-empty ws-load-error`,children:[(0,S.jsx)(C,{name:`error`,className:`ms-sm`}),` `,n]}),e&&e.length===0&&(0,S.jsx)(`div`,{className:`ws-empty`,children:`No workspaces known yet.`}),e?.map(e=>{let t=d(e),n=i[t],r=!e.live&&!!e.root&&(e.exists===!1||e.hasConfig===!1);return(0,S.jsxs)(`div`,{className:`ws-row state-${e.state} ${e.current?`current`:``}`,children:[(0,S.jsx)(ve,{className:`ws-icon`,icon:e.icon,name:e.name,color:e.color,seed:e.root??e.url,ambiguous:h(e.icon)}),(0,S.jsxs)(`div`,{className:`ws-main`,children:[(0,S.jsxs)(`div`,{className:`ws-title`,children:[e.live&&!e.current?(0,S.jsx)(`a`,{href:e.url,className:`ws-name${e.named===!1?` unnamed`:``}`,children:e.name}):(0,S.jsx)(`span`,{className:`ws-name${e.named===!1?` unnamed`:``}`,children:e.name}),e.current&&(0,S.jsx)(`span`,{className:`switcher-hint`,children:`current`}),(0,S.jsxs)(`span`,{className:`ws-state ws-state-${e.state}`,children:[e.live&&(0,S.jsx)(`span`,{className:`live-dot`}),Xa[e.state].label]}),Xa[e.state].note&&(0,S.jsx)(`span`,{className:`ws-note`,children:Xa[e.state].note})]}),(0,S.jsx)(`div`,{className:`ws-root`,title:e.root,children:e.rootLabel??(0,S.jsx)(`span`,{className:`ws-dim`,children:`no root recorded (started by an older version)`})}),(0,S.jsxs)(`div`,{className:`ws-meta`,children:[e.state!==`missing`&&e.state!==`orphaned`&&(0,S.jsx)(`span`,{children:e.url.replace(/^https?:\/\//,``)}),e.counts&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`span`,{children:[e.counts.agents,` agents`]}),(0,S.jsxs)(`span`,{children:[e.counts.workflows,` workflows`]}),(0,S.jsxs)(`span`,{children:[e.counts.runs,` runs`]}),(0,S.jsxs)(`span`,{children:[e.counts.chats,` chats`]})]}),e.lastStarted&&(0,S.jsxs)(`span`,{title:e.lastStarted,children:[`started `,Te(e.lastStarted)]}),!e.live&&e.lastStopped&&(0,S.jsxs)(`span`,{title:e.lastStopped,children:[`stopped `,Te(e.lastStopped)]}),e.startCount!=null&&(0,S.jsxs)(`span`,{children:[e.startCount,`× launched`]}),e.firstSeen&&(0,S.jsxs)(`span`,{title:e.firstSeen,children:[`first seen `,Te(e.firstSeen)]})]}),o[t]&&(0,S.jsx)(`div`,{className:`settings-err`,children:o[t]})]}),(0,S.jsxs)(`div`,{className:`ws-actions`,children:[e.live&&!e.current&&(0,S.jsxs)(`a`,{className:`ws-btn`,href:e.url,title:`Open this workspace`,children:[(0,S.jsx)(C,{name:`open_in_new`,className:`ms-sm`}),` open`]}),!e.live&&e.root&&e.exists!==!1&&!e.dirGone&&(0,S.jsxs)(`button`,{className:`ws-btn primary`,disabled:!!n,onClick:()=>void f(e,`start`),children:[(0,S.jsx)(C,{name:n===`start`?`progress_activity`:`play_arrow`,className:`ms-sm`}),n===`start`?`starting…`:`start`]}),e.live&&!e.current&&(0,S.jsxs)(`button`,{className:`ws-btn danger`,disabled:!!n,onClick:()=>void f(e,`stop`),children:[(0,S.jsx)(C,{name:n===`stop`?`progress_activity`:`stop`,className:`ms-sm`}),n===`stop`?`stopping…`:`stop`]}),r&&c!==t&&(0,S.jsxs)(`button`,{className:`ws-btn`,disabled:!!n,title:`Drop this project from the registry (files untouched)`,onClick:()=>l(t),children:[(0,S.jsx)(C,{name:`delete`,className:`ms-sm`}),` remove`]}),r&&c===t&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`button`,{className:`ws-btn danger`,onClick:()=>void f(e,`forget`),children:[(0,S.jsx)(C,{name:`delete`,className:`ms-sm`}),` confirm remove`]}),(0,S.jsx)(`button`,{className:`ws-btn`,onClick:()=>l(null),children:`cancel`})]})]})]},t)})]}),(0,S.jsxs)(`p`,{className:`settings-note`,children:[`Start launches `,(0,S.jsx)(`code`,{children:`kraftwerk ui`}),` detached in the project root (log in `,(0,S.jsx)(`code`,{children:`~/.kraftwerk/logs`}),`). Stop sends SIGTERM to the running server. Remove is offered only for records whose root no longer holds a `,(0,S.jsx)(`code`,{children:`kraftwerk.yml`}),` — the same from the terminal:`,` `,(0,S.jsx)(`code`,{children:`kraftwerk workspaces`}),`.`]})]})}function Qa(e){if(e<60)return`${e}s`;let t=Math.round(e/60);if(t<60)return`${t} min`;let n=Math.floor(t/60),r=t%60;return r?`${n} h ${r} min`:`${n} h`}var $a=[[/^(\+\+\+|---|diff |index )/,`d-meta`],[/^@@/,`d-hunk`],[/^\+/,`d-add`],[/^-/,`d-del`]],eo=e=>$a.find(([t])=>t.test(e))?.[1]??``;function to({file:e}){return(0,S.jsx)(no,{url:`/api/git/diff?path=${encodeURIComponent(e)}`})}function no({url:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(``);return(0,v.useEffect)(()=>{let t=!0;return n(null),o(``),fetch(e).then(e=>e.json()).then(e=>{t&&(n(e.diff??``),i(!!e.truncated),o(e.error??``))}).catch(()=>t&&o(`could not load the diff`)),()=>{t=!1}},[e]),a?(0,S.jsx)(`div`,{className:`git-diff git-diff-error`,children:a}):t===null?(0,S.jsx)(`div`,{className:`git-diff`,children:`loading…`}):t.trim()?(0,S.jsxs)(`pre`,{className:`git-diff`,children:[t.split(`
|
|
216
216
|
`).map((e,t)=>(0,S.jsxs)(`span`,{className:eo(e),children:[e||` `,`
|
|
217
217
|
`]},t)),r&&(0,S.jsxs)(`span`,{className:`d-meta`,children:[`… diff truncated, see the rest in a terminal`,`
|
|
218
|
-
`]})]}):(0,S.jsx)(`div`,{className:`git-diff`,children:`no textual diff (binary or empty)`})}function
|
|
219
|
-
`)[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)(to,{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 ${Qa(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 ro=e=>e.replace(/^https?:\/\//,``).replace(/^git@([^:]+):/,`$1/`).replace(/\.git$/,``),io=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`},ao=e=>!!(e.error||e.dirty||e.ahead===void 0||e.ahead);function oo(){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=P(),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=io(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)(`span`,{className:`ws-name`,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 `,Te(e.updatedAt)]})]}),e.url&&(0,S.jsx)(`div`,{className:`ws-root`,title:e.url,children:ro(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?` · ${Te(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)(`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`,ao(e)),children:[(0,S.jsx)(C,{name:`delete`,className:`ms-sm`}),e.dirty||e.ahead?`delete with local changes`:ao(e)?`delete anyway`:`confirm remove`]}),(0,S.jsx)(`button`,{className:`ws-btn`,onClick:()=>l(null),children:`cancel`})]})]})]},e.slug)})]})]})}var so=[`active`,`paused`,`done`,`archived`],G={active:`running`,paused:`aborted`,done:`ok`,archived:`aborted`},K={"my-netnode":`my.netnode.ch`,"google-drive":`Google Drive`,github:`GitHub`,bitbucket:`Bitbucket`,notion:`Notion`,slack:`Slack`,url:`Link`},co=e=>K[e]??e,lo=[{id:`claude`,label:`claude`,hint:`Claude Code via ACP`},{id:`codex`,label:`codex`,hint:`Codex (ChatGPT) via ACP`},{id:`pi`,label:`pi`,hint:`pi coding agent`}],uo=[``,`low`,`medium`,`high`,`xhigh`,`max`],fo=e=>[e.harness,e.model,e.effort?`effort ${e.effort}`:``].filter(Boolean).join(` · `),po=(e,t)=>(e??[]).filter(e=>e.scope.kind===`project`&&e.scope.slug===t||e.project===t),mo=(e,t)=>`/projects/${encodeURIComponent(t)}/chat/${e.id}`;async function ho(e,t){let n=await fetch(`/api/projects/${encodeURIComponent(e)}`,{method:`PUT`,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}function go({seg:e}){let t=e[0]&&e[0]!==`new`?decodeURIComponent(e[0]):void 0,n=e[0]===`new`?`new`:e[1]===`info`?`info`:e[1]===`chat`?`chat`:t?`project`:`home`,r=n===`chat`?e[2]:void 0,[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(``),c=P(),l=(0,v.useCallback)(async()=>{try{let e=await fetch(`/api/projects`,{cache:`no-store`});if(!e.ok)throw Error(`HTTP ${e.status}`);a(await e.json()),s(``)}catch(e){s(e.message||`could not load projects`)}},[]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await l(),e&&(t=setTimeout(n,15e3))};return n(),()=>{e=!1,clearTimeout(t)}},[l]),(0,v.useEffect)(()=>{l()},[t,n,l]);let u=i?.projects??[],d=t?u.find(e=>e.slug===t):void 0,f=[...u].sort((e,t)=>(t.updatedAt??``).localeCompare(e.updatedAt??``))[0]?.slug;(0,v.useEffect)(()=>{n===`home`&&f&&A(`/projects/${encodeURIComponent(f)}`,{replace:!0})},[n,f]);let p;return p=i&&!i.enabled?(0,S.jsx)(`div`,{className:`empty`,children:i.error&&!/are off/.test(i.error)?(0,S.jsx)(`span`,{className:`settings-err`,children:i.error}):(0,S.jsxs)(S.Fragment,{children:[`Projects are off. Turn them on in `,(0,S.jsx)(`a`,{href:`#/settings`,children:`settings`}),` or add a `,(0,S.jsx)(`code`,{children:`projects:`}),` block to kraftwerk.yml.`]})}):i?n===`new`||n===`home`&&u.length===0?(0,S.jsx)(_o,{root:i.root,onCreated:l}):n===`home`?(0,S.jsx)(`div`,{className:`empty`,children:`loading…`}):t&&!d?(0,S.jsxs)(`div`,{className:`empty`,children:[`no project named `,t]}):n===`chat`&&t&&r?(0,S.jsx)(`div`,{className:`chat-main`,children:(0,S.jsx)(bo,{chatId:r,title:d?.title??t,goal:d?.goal},r)}):n===`info`&&t?(0,S.jsx)(Co,{slug:t,onChanged:l},t):t?(0,S.jsx)(vo,{slug:t,title:d?.title??t},t):(0,S.jsx)(`div`,{className:`empty`,children:`loading…`}):(0,S.jsx)(`div`,{className:`empty`,children:`loading…`}),(0,S.jsxs)(`div`,{className:`runs-screen agents-screen projects-screen ${t?`has-sessions`:``}`,children:[(0,S.jsxs)(`aside`,{className:`runs-side`,children:[(0,S.jsxs)(`div`,{className:`side-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`projects`}),(0,S.jsx)(`span`,{className:`spacer`}),i?.enabled&&(0,S.jsx)(`span`,{className:`microlabel num`,children:u.length}),i?.enabled&&(c||u.length===0)&&(0,S.jsxs)(j,{href:`/projects/new`,className:`open-raw`,children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` new`]})]}),(0,S.jsxs)(`div`,{className:`side-list`,children:[u.map(e=>(0,S.jsxs)(j,{href:`/projects/${encodeURIComponent(e.slug)}`,className:`side-row ${e.slug===t?`active`:``}`,"data-project":e.slug,children:[(0,S.jsx)(`span`,{className:`lamp ${e.configError?`failed`:G[e.status]}`,title: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.title}),e.updatedAt&&(0,S.jsx)(`span`,{className:`side-when num`,title:e.updatedAt,children:Te(e.updatedAt)})]}),(0,S.jsx)(`div`,{className:`side-row-sub`,children:(0,S.jsx)(`span`,{className:`side-req`,children:e.configError?e.configError:e.goal||e.status})})]})]},e.slug)),i&&i.enabled&&u.length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no projects yet`}),o&&(0,S.jsx)(`div`,{className:`viewer-note settings-err`,children:o})]})]}),t&&d&&(0,S.jsx)(xo,{slug:t,chatId:r}),(0,S.jsx)(`div`,{className:`runs-main`,children:p})]})}function _o({root:e,onCreated:t}){let[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),u=async e=>{e.preventDefault();let r=n.trim();if(r&&!o){s(!0),l(``);try{let e=await fetch(`/api/projects`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({title:r,goal:i.trim()})}),n=await e.json();if(!e.ok)throw Error(n.error||`HTTP ${e.status}`);A(`/projects/${encodeURIComponent(n.slug)}/info`),t()}catch(e){l(e.message)}finally{s(!1)}}};return(0,S.jsxs)(`form`,{className:`new-chat`,onSubmit:e=>void u(e),children:[(0,S.jsx)(`div`,{className:`page-head`,children:(0,S.jsx)(`h1`,{children:`new project`})}),(0,S.jsx)(`section`,{className:`panel`,children:(0,S.jsxs)(`div`,{className:`agent-form`,children:[(0,S.jsxs)(`label`,{className:`agent-field`,children:[`title`,(0,S.jsx)(`input`,{value:n,placeholder:`e.g. Relaunch netnode.ch`,"aria-label":`project title`,autoFocus:!0,onChange:e=>r(e.target.value)})]}),(0,S.jsxs)(`label`,{className:`agent-field`,children:[`goal (one line)`,(0,S.jsx)(`input`,{value:i,placeholder:`e.g. Ship the new site on NodeHive by November`,"aria-label":`project goal`,onChange:e=>a(e.target.value)})]}),(0,S.jsx)(`div`,{className:`agent-form-row`,children:(0,S.jsxs)(`button`,{className:`run-btn`,type:`submit`,disabled:o||!n.trim(),children:[(0,S.jsx)(C,{name:o?`progress_activity`:`add`,className:`ms-sm`}),o?`creating…`:`create project`]})}),c&&(0,S.jsx)(`div`,{className:`settings-err`,children:c}),(0,S.jsxs)(`div`,{className:`settings-note`,children:[`One folder each under `,(0,S.jsx)(`code`,{title:e,children:e}),` with project.yml, brief.md, state.md and log.md; part of the workspace, commit it from the git screen. Chats opened in the project carry all of it as context.`]})]})})]})}function vo({slug:e,title: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===`project`&&t.scope.slug===e);i?A(`/projects/${encodeURIComponent(e)}/chat/${i.id}`,{replace:!0}):r(!0)}).catch(()=>t&&r(!0)),()=>{t=!1}},[e]),n?(0,S.jsx)(yo,{slug:e,title:t}):(0,S.jsx)(`div`,{className:`empty`,children:`loading…`})}function yo({slug:e,title:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1);(0,v.useEffect)(()=>{let t=!0;return fetch(`/api/projects/${encodeURIComponent(e)}`).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status)))).then(e=>t&&r(e)).catch(()=>{}),()=>{t=!1}},[e]);let o=lo.find(e=>e.id===n?.harness)??lo[0];return(0,S.jsxs)(`div`,{className:`new-chat`,children:[(0,S.jsx)(`div`,{className:`page-head`,children:(0,S.jsxs)(`h1`,{children:[`new chat in `,t]})}),(0,S.jsxs)(`section`,{className:`panel new-chat-panel`,children:[(0,S.jsx)(`div`,{className:`panel-head`,children:(0,S.jsx)(`span`,{className:`microlabel`,children:`runs on`})}),(0,S.jsx)(`div`,{className:`agent-pick`,children:(0,S.jsxs)(`button`,{className:`agent-pick-btn active`,disabled:i||!n,onClick:async()=>{a(!0),await $r(o.id,{kind:`project`,slug:e}),a(!1)},children:[(0,S.jsx)(`b`,{children:i?`starting…`:`start chat`}),(0,S.jsx)(`span`,{children:n?`${fo(n)} — ${o.hint}`:`…`})]})}),(0,S.jsxs)(`div`,{className:`settings-note`,style:{padding:`0 18px 14px`},children:[`The chat starts with the project's brief, state, systems of record and links as context. Harness, model and effort are set on the `,(0,S.jsx)(j,{href:`/projects/${encodeURIComponent(e)}/info`,children:`project page`}),`, like an agent's.`]})]})]})}function bo({chatId:e,title:t,goal:n}){let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(0);(0,v.useEffect)(()=>{let t=!0;return fetch(`/api/chats/${e}`).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status)))).then(e=>t&&i(e.meta.scope)).catch(()=>t&&o(!0)),()=>{t=!1}},[e,s]);let l=r?.kind===`channel`?r.slug:void 0,u=z(l?`/api/channels`:``,!1,4e3),d=z(l?`/api/agents`:``,!1,8e3);if(a)return(0,S.jsx)(`div`,{className:`empty`,children:`chat not found`});if(!r)return(0,S.jsx)(`div`,{className:`empty`,children:`loading…`});if(l){let t=u?.channels.find(e=>e.slug===l);return u?t?(0,S.jsx)(ai,{id:e,channel:t,agents:d?.agents??[]},`${e}:channel`):(0,S.jsxs)(`div`,{className:`empty`,children:[`channel #`,l,` is gone — its definition under channels/ was removed`]}):(0,S.jsx)(`div`,{className:`empty`,children:`loading…`})}return(0,S.jsx)(ai,{id:e,agentName:t,agentDescription:n,onConverted:()=>c(e=>e+1)},`${e}:${s}`)}function xo({slug:e,chatId:t}){let n=z(`/api/chats?for=${encodeURIComponent(t??``)}`,!1),r=po(n?.chats,e),[i,a]=(0,v.useState)(!1);return(0,S.jsxs)(`aside`,{className:`runs-side`,children:[(0,S.jsxs)(`div`,{className:`side-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`chats`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(j,{href:`/projects/${encodeURIComponent(e)}/info`,className:`open-raw`,title:`project page: brief, state, records, links`,children:`info`}),(0,S.jsx)(`button`,{className:`open-raw`,disabled:i,onClick:async()=>{a(!0),await $r(`claude`,{kind:`project`,slug:e}),a(!1)},children:i?`…`:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` new`]})})]}),(0,S.jsxs)(`div`,{className:`side-list`,children:[r.map(n=>(0,S.jsxs)(j,{href:mo(n,e),className:`side-row ${n.id===t?`active`:``}`,children:[(0,S.jsx)(`span`,{className:`lamp ${n.awaitingApproval?`blocked`:n.busy?`running`:`pending`}`,title:n.awaitingApproval?`waiting for your approval`:void 0}),(0,S.jsxs)(`div`,{className:`side-row-body`,children:[(0,S.jsx)(`div`,{className:`side-row-top`,children:(0,S.jsxs)(`span`,{className:`side-wf`,children:[n.scope.kind===`channel`&&(0,S.jsx)(C,{name:`forum`,className:`ms-sm`}),n.scope.kind===`channel`?n.title||`#${n.scope.slug}`:n.title||`new chat`]})}),(0,S.jsxs)(`div`,{className:`side-row-sub`,children:[(0,S.jsx)(`span`,{className:`side-req`,children:n.scope.kind===`channel`?`channel session · #${n.scope.slug}`:n.agent}),(0,S.jsx)(`span`,{className:`side-when num`,children:we(n.updatedAt)})]})]}),(0,S.jsx)(`button`,{type:`button`,className:`row-x`,title:`delete chat`,onClick:async r=>{r.preventDefault(),r.stopPropagation(),window.confirm(`Delete chat "${n.title||n.id}"?`)&&(await fetch(`/api/chats/${n.id}`,{method:`DELETE`}).catch(()=>{}),n.id===t&&A(`/projects/${encodeURIComponent(e)}`))},children:(0,S.jsx)(C,{name:`close`,className:`ms-sm`})})]},n.id)),n&&r.length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no chats yet`})]})]})}var So=[{kind:`knowledge`,label:`knowledge`,icon:`menu_book`,href:e=>`/knowledge/${encodeURIComponent(e)}`},{kind:`vibeables`,label:`vibeables`,icon:`web`,href:e=>`/vibeables/${encodeURIComponent(e)}`},{kind:`repos`,label:`repositories`,icon:`source`},{kind:`workflows`,label:`workflows`,icon:`account_tree`,href:e=>`/workflows/${encodeURIComponent(e)}`},{kind:`agents`,label:`agents`,icon:`groups`,href:e=>`/agents/${encodeURIComponent(e)}`}];function Co({slug:e,onChanged:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(``),[x,w]=(0,v.useState)(`active`),[T,E]=(0,v.useState)(`claude`),[D,O]=(0,v.useState)(``),[k,ee]=(0,v.useState)(``),[te,ne]=(0,v.useState)(``),[j,re]=(0,v.useState)(``),[M,N]=(0,v.useState)(!1),[ie,ae]=(0,v.useState)(``),oe=P(),F=e=>{r(e),_(e.title),b(e.goal),w(e.status),E(e.harness),O(e.model??``),ee(e.effort??``),ne(e.brief),re(e.state),N(!1)};(0,v.useEffect)(()=>{let t=!0;return fetch(`/api/projects/${encodeURIComponent(e)}`).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status)))).then(e=>t&&F(e)).catch(()=>t&&a(!0)),()=>{t=!1}},[e]);let I=()=>{N(!0),d(!1),s(``)},se=async(n,i={})=>{l(!0),s(``);try{let a=await ho(e,n);i.keepEdits?r(a):F(a),d(!i.keepEdits),await t()}catch(e){s(e.message)}finally{l(!1)}},ce=async()=>{l(!0);try{let n=await fetch(`/api/projects/${encodeURIComponent(e)}`,{method:`DELETE`}),r=await n.json();if(!n.ok||!r.ok)throw Error(r.error||`failed`);await t(),A(`/projects`,{replace:!0})}catch(e){s(e.message),l(!1)}},le=async()=>{let t=ie.trim();if(t){l(!0),s(``);try{let n=await fetch(`/api/projects/${encodeURIComponent(e)}/log`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({entry:t})}),i=await n.json();if(!n.ok||!i.ok)throw Error(i.error||`failed`);ae(``),r(e=>e&&{...e,log:i.log??e.log})}catch(e){s(e.message)}finally{l(!1)}}};return i?(0,S.jsx)(`div`,{className:`empty`,children:`project not found`}):n?(0,S.jsxs)(`div`,{className:`chat-main project-page`,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:`📁`})}),(0,S.jsx)(`h1`,{children:n.title}),(0,S.jsx)(`span`,{className:`chip status ${G[n.status]}`,children:n.status}),(0,S.jsx)(`span`,{className:`chip`,title:`harness · model · effort every chat in this project runs on`,children:fo(n)}),oe&&(0,S.jsx)(`span`,{className:`rid`,title:n.path,children:n.path}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(`button`,{className:`run-btn`,disabled:f,onClick:async()=>{p(!0),await $r(`claude`,{kind:`project`,slug:e}),p(!1)},children:f?`starting…`:`new chat`})]}),n.configError&&(0,S.jsxs)(`div`,{className:`settings-err`,children:[`project.yml: `,n.configError]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`project`}),(0,S.jsx)(`span`,{className:`spacer`}),u&&!M&&(0,S.jsx)(`span`,{className:`settings-note`,children:`saved`}),(0,S.jsx)(`button`,{className:`run-btn`,disabled:c||!M,onClick:()=>void se({title:g,goal:y,status:x,harness:T,model:D,effort:k,brief:te,state:j}),children:c?`saving…`:`save changes`})]}),(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:[`title`,(0,S.jsx)(`input`,{value:g,"aria-label":`title`,onChange:e=>{_(e.target.value),I()}})]}),(0,S.jsxs)(`label`,{className:`agent-field`,children:[`status`,(0,S.jsx)(`select`,{value:x,"aria-label":`status`,onChange:e=>{w(e.target.value),I()},children:so.map(e=>(0,S.jsx)(`option`,{value:e,children:e},e))})]})]}),(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsxs)(`label`,{className:`agent-field`,style:{width:140},children:[`harness`,(0,S.jsx)(`select`,{value:T,"aria-label":`harness`,onChange:e=>{E(e.target.value),I()},children:lo.map(e=>(0,S.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`model`,(0,S.jsx)(`input`,{value:D,"aria-label":`model`,placeholder:`harness default — e.g. sonnet, gpt-5.6-sol`,onChange:e=>{O(e.target.value),I()}})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{width:140},children:[`effort`,(0,S.jsx)(`select`,{value:k,"aria-label":`effort`,onChange:e=>{ee(e.target.value),I()},children:uo.map(e=>(0,S.jsx)(`option`,{value:e,children:e||`default`},e))})]})]}),(0,S.jsxs)(`label`,{className:`agent-field`,children:[`goal (one line)`,(0,S.jsx)(`input`,{value:y,"aria-label":`goal`,placeholder:`what the project is for`,onChange:e=>{b(e.target.value),I()}})]}),(0,S.jsxs)(`label`,{className:`agent-field`,children:[`brief.md — what done looks like, constraints, stakeholders`,(0,S.jsx)(`textarea`,{rows:10,value:te,"aria-label":`brief`,onChange:e=>{ne(e.target.value),I()}})]}),(0,S.jsxs)(`label`,{className:`agent-field`,children:[`state.md — current state, rewritten at the end of a session`,(0,S.jsx)(`textarea`,{rows:6,value:j,"aria-label":`state`,onChange:e=>{re(e.target.value),I()}})]}),o&&(0,S.jsx)(`div`,{className:`settings-err`,children:o})]})]}),(0,S.jsx)(Oo,{records:n.records,saving:c,onSave:e=>se({records:e},{keepEdits:!0})}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`links`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(`span`,{className:`settings-note`,children:`by name; a target that is missing in this workspace is marked`})]}),(0,S.jsx)(`div`,{className:`m3-list`,children:So.map(i=>(0,S.jsx)(Eo,{kind:i.kind,label:i.label,icon:i.icon,href:i.href,links:n.links[i.kind],saving:c,onChange:(n,a)=>void wo(e,i.kind,n,a,e=>{r(e),t()},s)},i.kind))})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`log`}),(0,S.jsx)(`span`,{className:`spacer`})]}),(0,S.jsx)(`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:[`new entry — a decision, a milestone`,(0,S.jsx)(`input`,{value:ie,"aria-label":`log entry`,placeholder:`e.g. Decided on NodeHive as the CMS`,onChange:e=>ae(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),le())}})]}),(0,S.jsxs)(`button`,{className:`run-btn tonal`,disabled:c||!ie.trim(),onClick:()=>void le(),children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` log`]})]})}),(0,S.jsx)(`div`,{className:`md-body project-log`,dangerouslySetInnerHTML:{__html:Lr.sanitize(H.parse(n.log||`_no entries yet_`,{async:!1}))}})]}),oe&&(0,S.jsx)(`section`,{className:`panel`,children:(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`danger zone`}),(0,S.jsx)(`span`,{className:`spacer`}),m?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`button`,{className:`stop-btn`,disabled:c,onClick:()=>void ce(),children:[(0,S.jsx)(C,{name:`delete`,className:`ms-sm`}),` confirm remove`]}),(0,S.jsx)(`button`,{className:`open-raw`,onClick:()=>h(!1),children:`cancel`})]}):(0,S.jsxs)(`button`,{className:`stop-btn`,disabled:c,onClick:()=>h(!0),title:`Delete the folder; its history stays in the workspace git`,children:[(0,S.jsx)(C,{name:`delete`,className:`ms-sm`}),` remove project`]})]})})]}):(0,S.jsx)(`div`,{className:`empty`,children:`loading…`})}async function wo(e,t,n,r,i,a){try{let a=await fetch(`/api/projects/${encodeURIComponent(e)}/links`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:t,target:n,remove:r})}),o=await a.json();if(!a.ok)throw Error(o.error||`HTTP ${a.status}`);i(o)}catch(e){a(e.message)}}async function To(e){switch(e){case`knowledge`:return(await(await fetch(`/api/knowledge`)).json()).bundles.map(e=>({slug:e.name,hint:`${e.concepts} concepts`}));case`vibeables`:return(await(await fetch(`/api/vibeables`)).json()).vibeables.map(e=>({slug:e.slug,hint:e.dev?`dev`:`static`}));case`repos`:return(await(await fetch(`/api/repos`)).json()).repos.map(e=>({slug:e.slug,hint:e.branch}));case`workflows`:return(await(await fetch(`/api/workflows`)).json()).workflows.map(e=>({slug:e.slug,hint:e.description??e.name}));case`agents`:return(await(await fetch(`/api/agents`)).json()).agents.filter(e=>!e.archived).map(e=>({slug:e.slug,hint:`${e.emoji} ${e.name}`}))}}function Eo({kind:e,label:t,icon:n,href:r,links:i,saving:a,onChange:o}){let[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(``);(0,v.useEffect)(()=>{if(!s||l)return;let t=!0;return To(e).then(e=>t&&u(e)).catch(()=>t&&u([])),()=>{t=!1}},[s,l,e]);let p=new Set(i.map(e=>e.slug)),m=(l??[]).filter(e=>!p.has(e.slug));return(0,S.jsxs)(`div`,{className:`m3-row`,"data-link-kind":e,children:[(0,S.jsx)(`span`,{className:`m3-ico`,children:(0,S.jsx)(C,{name:n})}),(0,S.jsxs)(`span`,{className:`m3-body`,children:[(0,S.jsx)(`span`,{className:`m3-head`,children:t}),i.length===0&&!s&&(0,S.jsx)(`span`,{className:`m3-sub`,children:`none linked`}),i.length>0&&(0,S.jsx)(`span`,{className:`m3-chips`,children:i.map(e=>(0,S.jsxs)(`span`,{className:`chip ${e.found?``:`attention`}`,title:e.found?e.label:`configured but not found in this workspace`,children:[r&&e.found?(0,S.jsx)(j,{href:r(e.slug),children:e.slug}):e.slug,!e.found&&` · not found`,(0,S.jsx)(`button`,{type:`button`,className:`chip-x`,"aria-label":`unlink ${e.slug}`,disabled:a,onClick:()=>o(e.slug,!0),children:(0,S.jsx)(C,{name:`close`,className:`ms-sm`})})]},e.slug))}),s&&(0,S.jsx)(`span`,{className:`agent-form-row`,style:{marginTop:6},children:l===null?(0,S.jsx)(`span`,{className:`m3-sub`,children:`loading…`}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`select`,{"aria-label":`link ${t}`,value:d,onChange:e=>f(e.target.value),children:[(0,S.jsx)(`option`,{value:``,children:m.length?`pick ${t}…`:`nothing to link`}),m.map(e=>(0,S.jsxs)(`option`,{value:e.slug,children:[e.slug,e.hint?` — ${e.hint}`:``]},e.slug))]}),(0,S.jsx)(`button`,{className:`run-btn tonal`,disabled:a||!d,onClick:()=>{o(d,!1),f(``),c(!1)},children:`link`}),(0,S.jsx)(`button`,{className:`open-raw`,onClick:()=>c(!1),children:`cancel`})]})})]}),!s&&(0,S.jsxs)(`button`,{className:`open-raw`,onClick:()=>c(!0),children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` link`]})]})}var Do={kind:`url`};function Oo({records:e,saving:t,onSave:n}){let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),s=e=>i(t=>({...t??Do,...e})),c=e=>{let t={kind:e.kind.trim().toLowerCase()||`url`};for(let n of[`title`,`url`,`workspace`,`note`]){let r=(e[n]??``).trim();r&&(t[n]=r)}return t};return(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`systems of record`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(`span`,{className:`settings-note`,children:`where the truth is managed outside kraftwerk — context for the agent, not a credential`}),!r&&(0,S.jsxs)(`button`,{className:`open-raw`,onClick:()=>i({...Do}),children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` add`]})]}),(0,S.jsxs)(`div`,{className:`m3-list`,children:[e.map((r,i)=>(0,S.jsxs)(`div`,{className:`m3-row`,"data-record-kind":r.kind,children:[(0,S.jsx)(`span`,{className:`m3-ico`,children:(0,S.jsx)(C,{name:`database`})}),(0,S.jsxs)(`span`,{className:`m3-body`,children:[(0,S.jsxs)(`span`,{className:`m3-head`,children:[co(r.kind),r.title&&(0,S.jsx)(`span`,{className:`m3-sub`,children:r.title}),r.workspace&&(0,S.jsxs)(`span`,{className:`chip`,children:[`workspace `,r.workspace]})]}),(r.url||r.note)&&(0,S.jsxs)(`span`,{className:`m3-sub`,children:[r.url&&(0,S.jsx)(`a`,{href:r.url,target:`_blank`,rel:`noreferrer`,children:r.url}),r.url&&r.note&&` — `,r.note]})]}),(0,S.jsx)(`button`,{className:`open-raw`,"aria-label":`remove record ${r.title??r.kind}`,disabled:t,onClick:()=>void n(e.filter((e,t)=>t!==i)),children:(0,S.jsx)(C,{name:`close`,className:`ms-sm`})})]},i)),e.length===0&&!r&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`none yet — e.g. a my.netnode.ch workspace, a Google Drive folder, a board`}),r&&(0,S.jsxs)(`div`,{className:`agent-form`,children:[(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsxs)(`label`,{className:`agent-field`,children:[`kind`,a?(0,S.jsx)(`input`,{value:r.kind,"aria-label":`record kind`,placeholder:`e.g. jira`,onChange:e=>s({kind:e.target.value})}):(0,S.jsxs)(`select`,{value:r.kind,"aria-label":`record kind`,onChange:e=>{e.target.value===`__other`?(o(!0),s({kind:``})):s({kind:e.target.value})},children:[Object.entries(K).map(([e,t])=>(0,S.jsx)(`option`,{value:e,children:t},e)),(0,S.jsx)(`option`,{value:`__other`,children:`other…`})]})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`title`,(0,S.jsx)(`input`,{value:r.title??``,"aria-label":`record title`,placeholder:`e.g. Contracts folder`,onChange:e=>s({title:e.target.value})})]}),(0,S.jsxs)(`label`,{className:`agent-field`,children:[`workspace / id`,(0,S.jsx)(`input`,{value:r.workspace??``,"aria-label":`record workspace`,placeholder:`e.g. 22`,onChange:e=>s({workspace:e.target.value})})]})]}),(0,S.jsx)(`div`,{className:`agent-form-row`,children:(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`url`,(0,S.jsx)(`input`,{value:r.url??``,"aria-label":`record url`,placeholder:`https://…`,onChange:e=>s({url:e.target.value})})]})}),(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`note — what lives there and how it is usually reached`,(0,S.jsx)(`input`,{value:r.note??``,"aria-label":`record note`,placeholder:`e.g. tickets and roadmap; the my CLI`,onChange:e=>s({note:e.target.value})})]}),(0,S.jsx)(`button`,{className:`run-btn tonal`,disabled:t||!r.kind.trim(),onClick:async()=>{await n([...e,c(r)]),i(null),o(!1)},children:`add record`}),(0,S.jsx)(`button`,{className:`open-raw`,onClick:()=>{i(null),o(!1)},children:`cancel`})]})]})]})]})}var ko=40,Ao=/Mac|iPhone|iPad/.test(navigator.platform),jo=null,Mo=e=>(e?.workspaces??[]).flatMap(e=>[...e.agents.map(t=>({kind:`agent`,agent:t,ws:e,key:`${e.url}|agent|${t.slug}`})),...(e.channels??[]).map(t=>({kind:`channel`,channel:t,ws:e,key:`${e.url}|channel|${t.slug}`}))]),No=e=>e.kind===`agent`?e.agent.name:e.channel.name,Po=e=>e.kind===`agent`?e.agent.description:e.channel.purpose,Fo=e=>e.kind===`agent`?`/agents/${encodeURIComponent(e.agent.slug)}`:`/channels/${encodeURIComponent(e.channel.slug)}`;function Io(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=No(t).toLowerCase(),a=[e,...t.kind===`agent`?[t.agent.slug,t.agent.description??``,t.agent.group??``,`agent`]:[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 Lo(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 Ro(e){let t=Fo(e);if(e.ws.current)return A(t);let n=e.ws.live||!e.ws.root?e.ws.url:await ne(e.ws.root);window.location.assign(`${n.replace(/\/+$/,``)}/#${t}`)}function zo(){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 or channel`,"aria-label":`search`,children:[(0,S.jsx)(C,{name:`search`}),(0,S.jsx)(`kbd`,{className:`kbd`,children:Ao?`⌘K`:`Ctrl K`})]}),e&&(0,S.jsx)(Bo,{onClose:()=>t(!1)})]})}function Bo({onClose:e}){let[t,n]=(0,v.useState)(jo),[r,i]=(0,v.useState)(jo===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=>{jo=t,e&&n(t)}).catch(()=>e&&o(!0)).finally(()=>e&&i(!1)),()=>{e=!1}},[]);let g=(0,v.useMemo)(()=>Mo(t),[t]),_=(0,v.useMemo)(()=>Io(g,s).slice(0,ko),[g,s]),y=(0,v.useMemo)(()=>Lo(_),[_]),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(),Ro(t);return}f(t.key),m(``),Ro(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 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:t.kind===`agent`?t.agent.emoji:(0,S.jsx)(C,{name:`forum`})}),(0,S.jsxs)(`span`,{className:`palette-text`,children:[(0,S.jsx)(`span`,{className:`palette-name`,children:No(t)}),Po(t)&&(0,S.jsx)(`span`,{className:`palette-sub`,children:Po(t)})]}),d===t.key?(0,S.jsx)(C,{name:`progress_activity`,className:`ms-sm`}):t.kind===`channel`&&(0,S.jsx)(`span`,{className:`palette-chip`,children:`channel`})]},t.key)})]},t.ws.url||t.ws.name))})}else T=a?(0,S.jsx)(`div`,{className:`palette-empty`,children:`could not load the agents and channels`}):r?(0,S.jsx)(`div`,{className:`palette-empty`,children:`looking for agents 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 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 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 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]})]})]})})}var Vo=`modulepreload`,Ho=function(e){return`/`+e},Uo={},Wo=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=Ho(t,n),t=s(t),t in Uo)return;Uo[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`:Vo,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)})},Go=(0,v.lazy)(()=>Wo(()=>import(`./editor-C6m40u-h.js`).then(e=>({default:e.EditorScreen})),__vite__mapDeps([0,1,2,3,4,5,6])));function Ko(){let[e,t=``]=w().split(`?`),n=e.split(`/`).filter(Boolean),r=new URLSearchParams(t).get(`workflow`)??void 0,[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!0),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(!1),[y,b]=(0,v.useState)(!1),[x,T]=(0,v.useState)(!1),[E,D]=(0,v.useState)(!1),[O,k]=(0,v.useState)([]);(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;a(t.projectName??``),s(t.projectIcon??``),l(t.projectColor??``),d(t.projectNamed!==!1),p(t.projectRootLabel??``),h(t.projectRoot??``),_(!!t.git),b(!!t.repos),T(!!t.vibeables),D(!!t.projects),F({git:!!t.git,repos:!!t.repos,vibeables:!!t.vibeables,projects:!!t.projects}),k(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(ee(i?`${i} — kraftwerk`:`kraftwerk inspector`),!o)return;let e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y="0.9em" font-size="85">${o}</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)}`},[i,o]);let te;if(te=n[0]===`runs`&&n[1]?(0,S.jsx)(bi,{id:n[1],workflow:r}):n[0]===`runs`?(0,S.jsx)(es,{}):n[0]===`workflows`&&n[1]?(0,S.jsx)(Wi,{slug:decodeURIComponent(n[1])}):n[0]===`workflows`?(0,S.jsx)(Hi,{}):n[0]===`chats`?(0,S.jsx)(ka,{seg:n}):n[0]===`skills`?(0,S.jsx)(wa,{name:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`settings`?(0,S.jsx)(Ya,{}):n[0]===`workspaces`?(0,S.jsx)(Za,{}):n[0]===`git`?(0,S.jsx)(no,{}):n[0]===`repos`?(0,S.jsx)(oo,{}):n[0]===`vibeables`?(0,S.jsx)(Wr,{slug:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`projects`?(0,S.jsx)(go,{seg:n.slice(1)}):n[0]===`agents`||n[0]===`team`?(0,S.jsx)(ka,{seg:n.slice(1)}):n[0]===`channels`?(0,S.jsx)(Gr,{seg:n.slice(1)}):n[0]===`knowledge`?(0,S.jsx)(da,{bundle:n[1]?decodeURIComponent(n[1]):void 0,conceptId:n.length>2?n.slice(2).map(decodeURIComponent).join(`/`):void 0}):(0,S.jsx)($i,{}),n[0]===`edit`&&n[1]&&n.length>2)return(0,S.jsx)(v.Suspense,{fallback:(0,S.jsx)(`div`,{className:`empty`,children:`loading editor…`}),children:(0,S.jsx)(Go,{bundle:decodeURIComponent(n[1]),conceptId:n.slice(2).map(decodeURIComponent).join(`/`)},n.slice(1).join(`/`))});let A=(...e)=>e.includes(n[0]??``)?`active`:``;return(0,v.useEffect)(()=>{let e=document.documentElement,t=m||i,n=t?ge(ce(c,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=``},[c,m,i]),(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`header`,{className:`topbar`,style:{"--ws-c":ce(c,m||i)},children:[(0,S.jsxs)(`span`,{className:`wordmark`,children:[(0,S.jsx)(`a`,{href:`#/`,className:`home-link`,title:`Dashboard`,children:i?(0,S.jsx)(ve,{className:`home-tile`,icon:o,name:i,color:c,seed:m||i}):(0,S.jsx)(C,{name:`home`})}),i&&(0,S.jsx)($o,{name:i,icon:o,color:c,named:u,root:f,seed:m||i,entries:O})]}),(0,S.jsxs)(`nav`,{children:[(0,S.jsxs)(`a`,{href:`#/channels`,className:A(`channels`),children:[(0,S.jsx)(C,{name:`forum`}),` channels`]}),E&&(0,S.jsxs)(`a`,{href:`#/projects`,className:A(`projects`),children:[(0,S.jsx)(C,{name:`folder_special`}),` projects`]}),(0,S.jsxs)(`a`,{href:`#/agents`,className:A(`agents`,`team`,`chats`),children:[(0,S.jsx)(C,{name:`groups`}),` agents`]}),(0,S.jsxs)(`a`,{href:`#/workflows`,className:A(`workflows`,`runs`),children:[(0,S.jsx)(C,{name:`account_tree`}),` workflows`]}),(0,S.jsxs)(`a`,{href:`#/knowledge`,className:A(`knowledge`),children:[(0,S.jsx)(C,{name:`menu_book`}),` knowledge`]}),(0,S.jsxs)(`a`,{href:`#/skills`,className:A(`skills`)+` nav-expert`,children:[(0,S.jsx)(C,{name:`extension`}),` skills`]}),y&&(0,S.jsxs)(`a`,{href:`#/repos`,className:A(`repos`)+` nav-expert`,children:[(0,S.jsx)(C,{name:`source`}),` repositories`]}),x&&(0,S.jsxs)(`a`,{href:`#/vibeables`,className:A(`vibeables`),children:[(0,S.jsx)(C,{name:`web`}),` vibeables`]}),g&&(0,S.jsx)(qo,{active:n[0]===`git`})]}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(zo,{}),(0,S.jsx)(ss,{}),(0,S.jsx)(rs,{}),(0,S.jsx)(is,{}),(0,S.jsx)(cs,{})]}),(0,S.jsx)(`main`,{className:`shell`,children:te})]})}function qo({active:e}){let t=z(`/api/git`,!1,15e3),n=t?.files?.filter(e=>e.syncable).length??0;return(0,S.jsxs)(`a`,{href:`#/git`,className:e?`nav-expert active`:`nav-expert`,children:[(0,S.jsx)(C,{name:`cloud_sync`}),` git`,!!t?.behind&&(0,S.jsxs)(`span`,{className:`git-badge behind`,children:[t.behind,`↓`]}),!!t?.ahead&&(0,S.jsxs)(`span`,{className:`git-badge ahead`,children:[t.ahead,`↑`]}),!t?.ahead&&!t?.behind&&!!n&&(0,S.jsx)(`span`,{className:`git-badge dirty`,children:n})]})}function Jo(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 Yo({label:e}){return e?(0,S.jsx)(`span`,{className:`switcher-root`,title:e,children:(0,S.jsx)(`span`,{dir:`ltr`,children:e})}):null}function Xo({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 Zo({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 ne(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)(ve,{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)(Xo,{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)(Yo,{label:e.rootLabel})]}),(0,S.jsxs)(`span`,{className:`switcher-side`,children:[(0,S.jsx)(`span`,{className:`switcher-port`,children:Jo(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 Qo({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)(ve,{icon:e.icon,name:e.name,color:e.color,seed:n,ambiguous:t}),(0,S.jsxs)(`span`,{className:`switcher-text`,children:[(0,S.jsx)(Xo,{name:e.name,named:e.named}),(0,S.jsx)(Yo,{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`}),Jo(e.url)]})})]})}function $o({name:e,icon:t,color:n,named:r,root:i,seed:a,entries:o}){let[s,c]=(0,v.useState)(!1),l=P();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)(ve,{icon:t,name:e,color:n,seed:p,ambiguous:d(t)}),(0,S.jsxs)(`span`,{className:`switcher-text`,children:[(0,S.jsx)(Xo,{name:e,named:r}),i?(0,S.jsx)(Yo,{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)(Zo,{entry:e,ambiguous:d(e.icon)},e.root):(0,S.jsx)(Qo,{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 es(){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?A(`/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 ts(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 ns=`kw-version-changed`;function rs(){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(ns,i),()=>{e=!1,clearTimeout(n),window.removeEventListener(ns,i)}},[]);let i=e?.restartable&&e.diskVersion&&e.diskVersion!==e.version?e.diskVersion:null;async function a(){i&&(r(!0),await ts(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 is(){let e=P();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:()=>ie(!e),children:[(0,S.jsx)(`span`,{className:`expert-track`,children:(0,S.jsx)(`span`,{className:`expert-knob`})}),`expert`]})}var as={approval:`gavel`,routine_done:`schedule`,routine_failed:`schedule`,run_done:`account_tree`,run_failed:`account_tree`},os=`kw.notif.toast.dismissed`;function ss(){let[e,t]=(0,v.useState)(!1),n=z(`/api/notifications`,!1,5e3),[r,i]=(0,v.useState)(()=>typeof Notification>`u`?`unsupported`:Notification.permission),[a,o]=(0,v.useState)(()=>{try{return localStorage.getItem(os)===`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]}),A(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),A(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(os,`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:as[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:Te(e.at)})]},e.id))})]})]})}function cs(){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)(ds,{})]}),(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)(us,{})]})]})]})}function ls(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 us(){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(ns))}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(`
|
|
220
|
-
`),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),
|
|
221
|
-
`),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?
|
|
218
|
+
`]})]}):(0,S.jsx)(`div`,{className:`git-diff`,children:`no textual diff (binary or empty)`})}function ro(){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 ye(`/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 ye(`/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 `,Te(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(`
|
|
219
|
+
`)[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)(to,{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 ${Qa(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 io=e=>e.replace(/^https?:\/\//,``).replace(/^git@([^:]+):/,`$1/`).replace(/\.git$/,``),ao=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`},oo=e=>!!(e.error||e.dirty||e.ahead===void 0||e.ahead);function so({slug:e}){return e?(0,S.jsx)(G,{slug:e}):(0,S.jsx)(K,{})}function G({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=P(),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)(j,{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=ao(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)(j,{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:io(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?` · ${Te(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 `,Te(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)(no,{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,` · `,Te(t.committedAt)]})]}),s===t.hash&&(0,S.jsx)(no,{url:`/api/repos/${encodeURIComponent(e)}/commits/${t.hash}`})]},t.hash))]})]})}function K(){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=P(),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=ao(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)(j,{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 `,Te(e.updatedAt)]})]}),e.url&&(0,S.jsx)(`div`,{className:`ws-root`,title:e.url,children:io(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?` · ${Te(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)(j,{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`,oo(e)),children:[(0,S.jsx)(C,{name:`delete`,className:`ms-sm`}),e.dirty||e.ahead?`delete with local changes`:oo(e)?`delete anyway`:`confirm remove`]}),(0,S.jsx)(`button`,{className:`ws-btn`,onClick:()=>l(null),children:`cancel`})]})]})]},e.slug)})]})]})}var co=[`active`,`paused`,`done`,`archived`],lo={active:`running`,paused:`aborted`,done:`ok`,archived:`aborted`},uo={"my-netnode":`my.netnode.ch`,"google-drive":`Google Drive`,github:`GitHub`,bitbucket:`Bitbucket`,notion:`Notion`,slack:`Slack`,url:`Link`},fo=e=>uo[e]??e,po=[{id:`claude`,label:`claude`,hint:`Claude Code via ACP`},{id:`codex`,label:`codex`,hint:`Codex (ChatGPT) via ACP`},{id:`pi`,label:`pi`,hint:`pi coding agent`}],mo=[``,`low`,`medium`,`high`,`xhigh`,`max`],ho=e=>[e.harness,e.model,e.effort?`effort ${e.effort}`:``].filter(Boolean).join(` · `),go=(e,t)=>(e??[]).filter(e=>e.scope.kind===`project`&&e.scope.slug===t||e.project===t),_o=(e,t)=>`/projects/${encodeURIComponent(t)}/chat/${e.id}`;async function vo(e,t){let n=await fetch(`/api/projects/${encodeURIComponent(e)}`,{method:`PUT`,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}function yo({seg:e}){let t=e[0]&&e[0]!==`new`?decodeURIComponent(e[0]):void 0,n=e[0]===`new`?`new`:e[1]===`info`?`info`:e[1]===`chat`?`chat`:t?`project`:`home`,r=n===`chat`?e[2]:void 0,[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(``),c=P(),l=(0,v.useCallback)(async()=>{try{let e=await fetch(`/api/projects`,{cache:`no-store`});if(!e.ok)throw Error(`HTTP ${e.status}`);a(await e.json()),s(``)}catch(e){s(e.message||`could not load projects`)}},[]);(0,v.useEffect)(()=>{let e=!0,t,n=async()=>{await l(),e&&(t=setTimeout(n,15e3))};return n(),()=>{e=!1,clearTimeout(t)}},[l]),(0,v.useEffect)(()=>{l()},[t,n,l]);let u=i?.projects??[],d=t?u.find(e=>e.slug===t):void 0,f=[...u].sort((e,t)=>(t.updatedAt??``).localeCompare(e.updatedAt??``))[0]?.slug;(0,v.useEffect)(()=>{n===`home`&&f&&A(`/projects/${encodeURIComponent(f)}`,{replace:!0})},[n,f]);let p;return p=i&&!i.enabled?(0,S.jsx)(`div`,{className:`empty`,children:i.error&&!/are off/.test(i.error)?(0,S.jsx)(`span`,{className:`settings-err`,children:i.error}):(0,S.jsxs)(S.Fragment,{children:[`Projects are off. Turn them on in `,(0,S.jsx)(`a`,{href:`#/settings`,children:`settings`}),` or add a `,(0,S.jsx)(`code`,{children:`projects:`}),` block to kraftwerk.yml.`]})}):i?n===`new`||n===`home`&&u.length===0?(0,S.jsx)(bo,{root:i.root,onCreated:l}):n===`home`?(0,S.jsx)(`div`,{className:`empty`,children:`loading…`}):t&&!d?(0,S.jsxs)(`div`,{className:`empty`,children:[`no project named `,t]}):n===`chat`&&t&&r?(0,S.jsx)(`div`,{className:`chat-main`,children:(0,S.jsx)(Co,{chatId:r,title:d?.title??t,goal:d?.goal},r)}):n===`info`&&t?(0,S.jsx)(Eo,{slug:t,onChanged:l},t):t?(0,S.jsx)(xo,{slug:t,title:d?.title??t},t):(0,S.jsx)(`div`,{className:`empty`,children:`loading…`}):(0,S.jsx)(`div`,{className:`empty`,children:`loading…`}),(0,S.jsxs)(`div`,{className:`runs-screen agents-screen projects-screen ${t?`has-sessions`:``}`,children:[(0,S.jsxs)(`aside`,{className:`runs-side`,children:[(0,S.jsxs)(`div`,{className:`side-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`projects`}),(0,S.jsx)(`span`,{className:`spacer`}),i?.enabled&&(0,S.jsx)(`span`,{className:`microlabel num`,children:u.length}),i?.enabled&&(c||u.length===0)&&(0,S.jsxs)(j,{href:`/projects/new`,className:`open-raw`,children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` new`]})]}),(0,S.jsxs)(`div`,{className:`side-list`,children:[u.map(e=>(0,S.jsxs)(j,{href:`/projects/${encodeURIComponent(e.slug)}`,className:`side-row ${e.slug===t?`active`:``}`,"data-project":e.slug,children:[(0,S.jsx)(`span`,{className:`lamp ${e.configError?`failed`:lo[e.status]}`,title: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.title}),e.updatedAt&&(0,S.jsx)(`span`,{className:`side-when num`,title:e.updatedAt,children:Te(e.updatedAt)})]}),(0,S.jsx)(`div`,{className:`side-row-sub`,children:(0,S.jsx)(`span`,{className:`side-req`,children:e.configError?e.configError:e.goal||e.status})})]})]},e.slug)),i&&i.enabled&&u.length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no projects yet`}),o&&(0,S.jsx)(`div`,{className:`viewer-note settings-err`,children:o})]})]}),t&&d&&(0,S.jsx)(wo,{slug:t,chatId:r}),(0,S.jsx)(`div`,{className:`runs-main`,children:p})]})}function bo({root:e,onCreated:t}){let[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),u=async e=>{e.preventDefault();let r=n.trim();if(r&&!o){s(!0),l(``);try{let e=await fetch(`/api/projects`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({title:r,goal:i.trim()})}),n=await e.json();if(!e.ok)throw Error(n.error||`HTTP ${e.status}`);A(`/projects/${encodeURIComponent(n.slug)}/info`),t()}catch(e){l(e.message)}finally{s(!1)}}};return(0,S.jsxs)(`form`,{className:`new-chat`,onSubmit:e=>void u(e),children:[(0,S.jsx)(`div`,{className:`page-head`,children:(0,S.jsx)(`h1`,{children:`new project`})}),(0,S.jsx)(`section`,{className:`panel`,children:(0,S.jsxs)(`div`,{className:`agent-form`,children:[(0,S.jsxs)(`label`,{className:`agent-field`,children:[`title`,(0,S.jsx)(`input`,{value:n,placeholder:`e.g. Relaunch netnode.ch`,"aria-label":`project title`,autoFocus:!0,onChange:e=>r(e.target.value)})]}),(0,S.jsxs)(`label`,{className:`agent-field`,children:[`goal (one line)`,(0,S.jsx)(`input`,{value:i,placeholder:`e.g. Ship the new site on NodeHive by November`,"aria-label":`project goal`,onChange:e=>a(e.target.value)})]}),(0,S.jsx)(`div`,{className:`agent-form-row`,children:(0,S.jsxs)(`button`,{className:`run-btn`,type:`submit`,disabled:o||!n.trim(),children:[(0,S.jsx)(C,{name:o?`progress_activity`:`add`,className:`ms-sm`}),o?`creating…`:`create project`]})}),c&&(0,S.jsx)(`div`,{className:`settings-err`,children:c}),(0,S.jsxs)(`div`,{className:`settings-note`,children:[`One folder each under `,(0,S.jsx)(`code`,{title:e,children:e}),` with project.yml, brief.md, state.md and log.md; part of the workspace, commit it from the git screen. Chats opened in the project carry all of it as context.`]})]})})]})}function xo({slug:e,title: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===`project`&&t.scope.slug===e);i?A(`/projects/${encodeURIComponent(e)}/chat/${i.id}`,{replace:!0}):r(!0)}).catch(()=>t&&r(!0)),()=>{t=!1}},[e]),n?(0,S.jsx)(So,{slug:e,title:t}):(0,S.jsx)(`div`,{className:`empty`,children:`loading…`})}function So({slug:e,title:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1);(0,v.useEffect)(()=>{let t=!0;return fetch(`/api/projects/${encodeURIComponent(e)}`).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status)))).then(e=>t&&r(e)).catch(()=>{}),()=>{t=!1}},[e]);let o=po.find(e=>e.id===n?.harness)??po[0];return(0,S.jsxs)(`div`,{className:`new-chat`,children:[(0,S.jsx)(`div`,{className:`page-head`,children:(0,S.jsxs)(`h1`,{children:[`new chat in `,t]})}),(0,S.jsxs)(`section`,{className:`panel new-chat-panel`,children:[(0,S.jsx)(`div`,{className:`panel-head`,children:(0,S.jsx)(`span`,{className:`microlabel`,children:`runs on`})}),(0,S.jsx)(`div`,{className:`agent-pick`,children:(0,S.jsxs)(`button`,{className:`agent-pick-btn active`,disabled:i||!n,onClick:async()=>{a(!0),await $r(o.id,{kind:`project`,slug:e}),a(!1)},children:[(0,S.jsx)(`b`,{children:i?`starting…`:`start chat`}),(0,S.jsx)(`span`,{children:n?`${ho(n)} — ${o.hint}`:`…`})]})}),(0,S.jsxs)(`div`,{className:`settings-note`,style:{padding:`0 18px 14px`},children:[`The chat starts with the project's brief, state, systems of record and links as context. Harness, model and effort are set on the `,(0,S.jsx)(j,{href:`/projects/${encodeURIComponent(e)}/info`,children:`project page`}),`, like an agent's.`]})]})]})}function Co({chatId:e,title:t,goal:n}){let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(0);(0,v.useEffect)(()=>{let t=!0;return fetch(`/api/chats/${e}`).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status)))).then(e=>t&&i(e.meta.scope)).catch(()=>t&&o(!0)),()=>{t=!1}},[e,s]);let l=r?.kind===`channel`?r.slug:void 0,u=z(l?`/api/channels`:``,!1,4e3),d=z(l?`/api/agents`:``,!1,8e3);if(a)return(0,S.jsx)(`div`,{className:`empty`,children:`chat not found`});if(!r)return(0,S.jsx)(`div`,{className:`empty`,children:`loading…`});if(l){let t=u?.channels.find(e=>e.slug===l);return u?t?(0,S.jsx)(ai,{id:e,channel:t,agents:d?.agents??[]},`${e}:channel`):(0,S.jsxs)(`div`,{className:`empty`,children:[`channel #`,l,` is gone — its definition under channels/ was removed`]}):(0,S.jsx)(`div`,{className:`empty`,children:`loading…`})}return(0,S.jsx)(ai,{id:e,agentName:t,agentDescription:n,onConverted:()=>c(e=>e+1)},`${e}:${s}`)}function wo({slug:e,chatId:t}){let n=z(`/api/chats?for=${encodeURIComponent(t??``)}`,!1),r=go(n?.chats,e),[i,a]=(0,v.useState)(!1);return(0,S.jsxs)(`aside`,{className:`runs-side`,children:[(0,S.jsxs)(`div`,{className:`side-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`chats`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(j,{href:`/projects/${encodeURIComponent(e)}/info`,className:`open-raw`,title:`project page: brief, state, records, links`,children:`info`}),(0,S.jsx)(`button`,{className:`open-raw`,disabled:i,onClick:async()=>{a(!0),await $r(`claude`,{kind:`project`,slug:e}),a(!1)},children:i?`…`:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` new`]})})]}),(0,S.jsxs)(`div`,{className:`side-list`,children:[r.map(n=>(0,S.jsxs)(j,{href:_o(n,e),className:`side-row ${n.id===t?`active`:``}`,children:[(0,S.jsx)(`span`,{className:`lamp ${n.awaitingApproval?`blocked`:n.busy?`running`:`pending`}`,title:n.awaitingApproval?`waiting for your approval`:void 0}),(0,S.jsxs)(`div`,{className:`side-row-body`,children:[(0,S.jsx)(`div`,{className:`side-row-top`,children:(0,S.jsxs)(`span`,{className:`side-wf`,children:[n.scope.kind===`channel`&&(0,S.jsx)(C,{name:`forum`,className:`ms-sm`}),n.scope.kind===`channel`?n.title||`#${n.scope.slug}`:n.title||`new chat`]})}),(0,S.jsxs)(`div`,{className:`side-row-sub`,children:[(0,S.jsx)(`span`,{className:`side-req`,children:n.scope.kind===`channel`?`channel session · #${n.scope.slug}`:n.agent}),(0,S.jsx)(`span`,{className:`side-when num`,children:we(n.updatedAt)})]})]}),(0,S.jsx)(`button`,{type:`button`,className:`row-x`,title:`delete chat`,onClick:async r=>{r.preventDefault(),r.stopPropagation(),window.confirm(`Delete chat "${n.title||n.id}"?`)&&(await fetch(`/api/chats/${n.id}`,{method:`DELETE`}).catch(()=>{}),n.id===t&&A(`/projects/${encodeURIComponent(e)}`))},children:(0,S.jsx)(C,{name:`close`,className:`ms-sm`})})]},n.id)),n&&r.length===0&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`no chats yet`})]})]})}var To=[{kind:`knowledge`,label:`knowledge`,icon:`menu_book`,href:e=>`/knowledge/${encodeURIComponent(e)}`},{kind:`vibeables`,label:`vibeables`,icon:`web`,href:e=>`/vibeables/${encodeURIComponent(e)}`},{kind:`repos`,label:`repositories`,icon:`source`},{kind:`workflows`,label:`workflows`,icon:`account_tree`,href:e=>`/workflows/${encodeURIComponent(e)}`},{kind:`agents`,label:`agents`,icon:`groups`,href:e=>`/agents/${encodeURIComponent(e)}`}];function Eo({slug:e,onChanged:t}){let[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(``),[x,w]=(0,v.useState)(`active`),[T,E]=(0,v.useState)(`claude`),[D,O]=(0,v.useState)(``),[k,ee]=(0,v.useState)(``),[te,ne]=(0,v.useState)(``),[j,re]=(0,v.useState)(``),[M,N]=(0,v.useState)(!1),[ie,ae]=(0,v.useState)(``),oe=P(),F=e=>{r(e),_(e.title),b(e.goal),w(e.status),E(e.harness),O(e.model??``),ee(e.effort??``),ne(e.brief),re(e.state),N(!1)};(0,v.useEffect)(()=>{let t=!0;return fetch(`/api/projects/${encodeURIComponent(e)}`).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status)))).then(e=>t&&F(e)).catch(()=>t&&a(!0)),()=>{t=!1}},[e]);let I=()=>{N(!0),d(!1),s(``)},se=async(n,i={})=>{l(!0),s(``);try{let a=await vo(e,n);i.keepEdits?r(a):F(a),d(!i.keepEdits),await t()}catch(e){s(e.message)}finally{l(!1)}},ce=async()=>{l(!0);try{let n=await fetch(`/api/projects/${encodeURIComponent(e)}`,{method:`DELETE`}),r=await n.json();if(!n.ok||!r.ok)throw Error(r.error||`failed`);await t(),A(`/projects`,{replace:!0})}catch(e){s(e.message),l(!1)}},le=async()=>{let t=ie.trim();if(t){l(!0),s(``);try{let n=await fetch(`/api/projects/${encodeURIComponent(e)}/log`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({entry:t})}),i=await n.json();if(!n.ok||!i.ok)throw Error(i.error||`failed`);ae(``),r(e=>e&&{...e,log:i.log??e.log})}catch(e){s(e.message)}finally{l(!1)}}};return i?(0,S.jsx)(`div`,{className:`empty`,children:`project not found`}):n?(0,S.jsxs)(`div`,{className:`chat-main project-page`,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:`📁`})}),(0,S.jsx)(`h1`,{children:n.title}),(0,S.jsx)(`span`,{className:`chip status ${lo[n.status]}`,children:n.status}),(0,S.jsx)(`span`,{className:`chip`,title:`harness · model · effort every chat in this project runs on`,children:ho(n)}),oe&&(0,S.jsx)(`span`,{className:`rid`,title:n.path,children:n.path}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(`button`,{className:`run-btn`,disabled:f,onClick:async()=>{p(!0),await $r(`claude`,{kind:`project`,slug:e}),p(!1)},children:f?`starting…`:`new chat`})]}),n.configError&&(0,S.jsxs)(`div`,{className:`settings-err`,children:[`project.yml: `,n.configError]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`project`}),(0,S.jsx)(`span`,{className:`spacer`}),u&&!M&&(0,S.jsx)(`span`,{className:`settings-note`,children:`saved`}),(0,S.jsx)(`button`,{className:`run-btn`,disabled:c||!M,onClick:()=>void se({title:g,goal:y,status:x,harness:T,model:D,effort:k,brief:te,state:j}),children:c?`saving…`:`save changes`})]}),(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:[`title`,(0,S.jsx)(`input`,{value:g,"aria-label":`title`,onChange:e=>{_(e.target.value),I()}})]}),(0,S.jsxs)(`label`,{className:`agent-field`,children:[`status`,(0,S.jsx)(`select`,{value:x,"aria-label":`status`,onChange:e=>{w(e.target.value),I()},children:co.map(e=>(0,S.jsx)(`option`,{value:e,children:e},e))})]})]}),(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsxs)(`label`,{className:`agent-field`,style:{width:140},children:[`harness`,(0,S.jsx)(`select`,{value:T,"aria-label":`harness`,onChange:e=>{E(e.target.value),I()},children:po.map(e=>(0,S.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`model`,(0,S.jsx)(`input`,{value:D,"aria-label":`model`,placeholder:`harness default — e.g. sonnet, gpt-5.6-sol`,onChange:e=>{O(e.target.value),I()}})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{width:140},children:[`effort`,(0,S.jsx)(`select`,{value:k,"aria-label":`effort`,onChange:e=>{ee(e.target.value),I()},children:mo.map(e=>(0,S.jsx)(`option`,{value:e,children:e||`default`},e))})]})]}),(0,S.jsxs)(`label`,{className:`agent-field`,children:[`goal (one line)`,(0,S.jsx)(`input`,{value:y,"aria-label":`goal`,placeholder:`what the project is for`,onChange:e=>{b(e.target.value),I()}})]}),(0,S.jsxs)(`label`,{className:`agent-field`,children:[`brief.md — what done looks like, constraints, stakeholders`,(0,S.jsx)(`textarea`,{rows:10,value:te,"aria-label":`brief`,onChange:e=>{ne(e.target.value),I()}})]}),(0,S.jsxs)(`label`,{className:`agent-field`,children:[`state.md — current state, rewritten at the end of a session`,(0,S.jsx)(`textarea`,{rows:6,value:j,"aria-label":`state`,onChange:e=>{re(e.target.value),I()}})]}),o&&(0,S.jsx)(`div`,{className:`settings-err`,children:o})]})]}),(0,S.jsx)(jo,{records:n.records,saving:c,onSave:e=>se({records:e},{keepEdits:!0})}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`links`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(`span`,{className:`settings-note`,children:`by name; a target that is missing in this workspace is marked`})]}),(0,S.jsx)(`div`,{className:`m3-list`,children:To.map(i=>(0,S.jsx)(ko,{kind:i.kind,label:i.label,icon:i.icon,href:i.href,links:n.links[i.kind],saving:c,onChange:(n,a)=>void Do(e,i.kind,n,a,e=>{r(e),t()},s)},i.kind))})]}),(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`log`}),(0,S.jsx)(`span`,{className:`spacer`})]}),(0,S.jsx)(`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:[`new entry — a decision, a milestone`,(0,S.jsx)(`input`,{value:ie,"aria-label":`log entry`,placeholder:`e.g. Decided on NodeHive as the CMS`,onChange:e=>ae(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),le())}})]}),(0,S.jsxs)(`button`,{className:`run-btn tonal`,disabled:c||!ie.trim(),onClick:()=>void le(),children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` log`]})]})}),(0,S.jsx)(`div`,{className:`md-body project-log`,dangerouslySetInnerHTML:{__html:Lr.sanitize(H.parse(n.log||`_no entries yet_`,{async:!1}))}})]}),oe&&(0,S.jsx)(`section`,{className:`panel`,children:(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`danger zone`}),(0,S.jsx)(`span`,{className:`spacer`}),m?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`button`,{className:`stop-btn`,disabled:c,onClick:()=>void ce(),children:[(0,S.jsx)(C,{name:`delete`,className:`ms-sm`}),` confirm remove`]}),(0,S.jsx)(`button`,{className:`open-raw`,onClick:()=>h(!1),children:`cancel`})]}):(0,S.jsxs)(`button`,{className:`stop-btn`,disabled:c,onClick:()=>h(!0),title:`Delete the folder; its history stays in the workspace git`,children:[(0,S.jsx)(C,{name:`delete`,className:`ms-sm`}),` remove project`]})]})})]}):(0,S.jsx)(`div`,{className:`empty`,children:`loading…`})}async function Do(e,t,n,r,i,a){try{let a=await fetch(`/api/projects/${encodeURIComponent(e)}/links`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:t,target:n,remove:r})}),o=await a.json();if(!a.ok)throw Error(o.error||`HTTP ${a.status}`);i(o)}catch(e){a(e.message)}}async function Oo(e){switch(e){case`knowledge`:return(await(await fetch(`/api/knowledge`)).json()).bundles.map(e=>({slug:e.name,hint:`${e.concepts} concepts`}));case`vibeables`:return(await(await fetch(`/api/vibeables`)).json()).vibeables.map(e=>({slug:e.slug,hint:e.dev?`dev`:`static`}));case`repos`:return(await(await fetch(`/api/repos`)).json()).repos.map(e=>({slug:e.slug,hint:e.branch}));case`workflows`:return(await(await fetch(`/api/workflows`)).json()).workflows.map(e=>({slug:e.slug,hint:e.description??e.name}));case`agents`:return(await(await fetch(`/api/agents`)).json()).agents.filter(e=>!e.archived).map(e=>({slug:e.slug,hint:`${e.emoji} ${e.name}`}))}}function ko({kind:e,label:t,icon:n,href:r,links:i,saving:a,onChange:o}){let[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(``);(0,v.useEffect)(()=>{if(!s||l)return;let t=!0;return Oo(e).then(e=>t&&u(e)).catch(()=>t&&u([])),()=>{t=!1}},[s,l,e]);let p=new Set(i.map(e=>e.slug)),m=(l??[]).filter(e=>!p.has(e.slug));return(0,S.jsxs)(`div`,{className:`m3-row`,"data-link-kind":e,children:[(0,S.jsx)(`span`,{className:`m3-ico`,children:(0,S.jsx)(C,{name:n})}),(0,S.jsxs)(`span`,{className:`m3-body`,children:[(0,S.jsx)(`span`,{className:`m3-head`,children:t}),i.length===0&&!s&&(0,S.jsx)(`span`,{className:`m3-sub`,children:`none linked`}),i.length>0&&(0,S.jsx)(`span`,{className:`m3-chips`,children:i.map(e=>(0,S.jsxs)(`span`,{className:`chip ${e.found?``:`attention`}`,title:e.found?e.label:`configured but not found in this workspace`,children:[r&&e.found?(0,S.jsx)(j,{href:r(e.slug),children:e.slug}):e.slug,!e.found&&` · not found`,(0,S.jsx)(`button`,{type:`button`,className:`chip-x`,"aria-label":`unlink ${e.slug}`,disabled:a,onClick:()=>o(e.slug,!0),children:(0,S.jsx)(C,{name:`close`,className:`ms-sm`})})]},e.slug))}),s&&(0,S.jsx)(`span`,{className:`agent-form-row`,style:{marginTop:6},children:l===null?(0,S.jsx)(`span`,{className:`m3-sub`,children:`loading…`}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`select`,{"aria-label":`link ${t}`,value:d,onChange:e=>f(e.target.value),children:[(0,S.jsx)(`option`,{value:``,children:m.length?`pick ${t}…`:`nothing to link`}),m.map(e=>(0,S.jsxs)(`option`,{value:e.slug,children:[e.slug,e.hint?` — ${e.hint}`:``]},e.slug))]}),(0,S.jsx)(`button`,{className:`run-btn tonal`,disabled:a||!d,onClick:()=>{o(d,!1),f(``),c(!1)},children:`link`}),(0,S.jsx)(`button`,{className:`open-raw`,onClick:()=>c(!1),children:`cancel`})]})})]}),!s&&(0,S.jsxs)(`button`,{className:`open-raw`,onClick:()=>c(!0),children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` link`]})]})}var Ao={kind:`url`};function jo({records:e,saving:t,onSave:n}){let[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),s=e=>i(t=>({...t??Ao,...e})),c=e=>{let t={kind:e.kind.trim().toLowerCase()||`url`};for(let n of[`title`,`url`,`workspace`,`note`]){let r=(e[n]??``).trim();r&&(t[n]=r)}return t};return(0,S.jsxs)(`section`,{className:`panel`,children:[(0,S.jsxs)(`div`,{className:`panel-head`,children:[(0,S.jsx)(`span`,{className:`microlabel`,children:`systems of record`}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(`span`,{className:`settings-note`,children:`where the truth is managed outside kraftwerk — context for the agent, not a credential`}),!r&&(0,S.jsxs)(`button`,{className:`open-raw`,onClick:()=>i({...Ao}),children:[(0,S.jsx)(C,{name:`add`,className:`ms-sm`}),` add`]})]}),(0,S.jsxs)(`div`,{className:`m3-list`,children:[e.map((r,i)=>(0,S.jsxs)(`div`,{className:`m3-row`,"data-record-kind":r.kind,children:[(0,S.jsx)(`span`,{className:`m3-ico`,children:(0,S.jsx)(C,{name:`database`})}),(0,S.jsxs)(`span`,{className:`m3-body`,children:[(0,S.jsxs)(`span`,{className:`m3-head`,children:[fo(r.kind),r.title&&(0,S.jsx)(`span`,{className:`m3-sub`,children:r.title}),r.workspace&&(0,S.jsxs)(`span`,{className:`chip`,children:[`workspace `,r.workspace]})]}),(r.url||r.note)&&(0,S.jsxs)(`span`,{className:`m3-sub`,children:[r.url&&(0,S.jsx)(`a`,{href:r.url,target:`_blank`,rel:`noreferrer`,children:r.url}),r.url&&r.note&&` — `,r.note]})]}),(0,S.jsx)(`button`,{className:`open-raw`,"aria-label":`remove record ${r.title??r.kind}`,disabled:t,onClick:()=>void n(e.filter((e,t)=>t!==i)),children:(0,S.jsx)(C,{name:`close`,className:`ms-sm`})})]},i)),e.length===0&&!r&&(0,S.jsx)(`div`,{className:`viewer-note`,children:`none yet — e.g. a my.netnode.ch workspace, a Google Drive folder, a board`}),r&&(0,S.jsxs)(`div`,{className:`agent-form`,children:[(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsxs)(`label`,{className:`agent-field`,children:[`kind`,a?(0,S.jsx)(`input`,{value:r.kind,"aria-label":`record kind`,placeholder:`e.g. jira`,onChange:e=>s({kind:e.target.value})}):(0,S.jsxs)(`select`,{value:r.kind,"aria-label":`record kind`,onChange:e=>{e.target.value===`__other`?(o(!0),s({kind:``})):s({kind:e.target.value})},children:[Object.entries(uo).map(([e,t])=>(0,S.jsx)(`option`,{value:e,children:t},e)),(0,S.jsx)(`option`,{value:`__other`,children:`other…`})]})]}),(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`title`,(0,S.jsx)(`input`,{value:r.title??``,"aria-label":`record title`,placeholder:`e.g. Contracts folder`,onChange:e=>s({title:e.target.value})})]}),(0,S.jsxs)(`label`,{className:`agent-field`,children:[`workspace / id`,(0,S.jsx)(`input`,{value:r.workspace??``,"aria-label":`record workspace`,placeholder:`e.g. 22`,onChange:e=>s({workspace:e.target.value})})]})]}),(0,S.jsx)(`div`,{className:`agent-form-row`,children:(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`url`,(0,S.jsx)(`input`,{value:r.url??``,"aria-label":`record url`,placeholder:`https://…`,onChange:e=>s({url:e.target.value})})]})}),(0,S.jsxs)(`div`,{className:`agent-form-row`,children:[(0,S.jsxs)(`label`,{className:`agent-field`,style:{flex:1},children:[`note — what lives there and how it is usually reached`,(0,S.jsx)(`input`,{value:r.note??``,"aria-label":`record note`,placeholder:`e.g. tickets and roadmap; the my CLI`,onChange:e=>s({note:e.target.value})})]}),(0,S.jsx)(`button`,{className:`run-btn tonal`,disabled:t||!r.kind.trim(),onClick:async()=>{await n([...e,c(r)]),i(null),o(!1)},children:`add record`}),(0,S.jsx)(`button`,{className:`open-raw`,onClick:()=>{i(null),o(!1)},children:`cancel`})]})]})]})]})}var Mo=40,No=/Mac|iPhone|iPad/.test(navigator.platform),Po=null,Fo=e=>(e?.workspaces??[]).flatMap(e=>[...e.agents.map(t=>({kind:`agent`,agent:t,ws:e,key:`${e.url}|agent|${t.slug}`})),...(e.channels??[]).map(t=>({kind:`channel`,channel:t,ws:e,key:`${e.url}|channel|${t.slug}`}))]),Io=e=>e.kind===`agent`?e.agent.name:e.channel.name,Lo=e=>e.kind===`agent`?e.agent.description:e.channel.purpose,Ro=e=>e.kind===`agent`?`/agents/${encodeURIComponent(e.agent.slug)}`:`/channels/${encodeURIComponent(e.channel.slug)}`;function zo(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=Io(t).toLowerCase(),a=[e,...t.kind===`agent`?[t.agent.slug,t.agent.description??``,t.agent.group??``,`agent`]:[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 Bo(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 Vo(e){let t=Ro(e);if(e.ws.current)return A(t);let n=e.ws.live||!e.ws.root?e.ws.url:await ne(e.ws.root);window.location.assign(`${n.replace(/\/+$/,``)}/#${t}`)}function Ho(){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 or channel`,"aria-label":`search`,children:[(0,S.jsx)(C,{name:`search`}),(0,S.jsx)(`kbd`,{className:`kbd`,children:No?`⌘K`:`Ctrl K`})]}),e&&(0,S.jsx)(Uo,{onClose:()=>t(!1)})]})}function Uo({onClose:e}){let[t,n]=(0,v.useState)(Po),[r,i]=(0,v.useState)(Po===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=>{Po=t,e&&n(t)}).catch(()=>e&&o(!0)).finally(()=>e&&i(!1)),()=>{e=!1}},[]);let g=(0,v.useMemo)(()=>Fo(t),[t]),_=(0,v.useMemo)(()=>zo(g,s).slice(0,Mo),[g,s]),y=(0,v.useMemo)(()=>Bo(_),[_]),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(),Vo(t);return}f(t.key),m(``),Vo(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 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:t.kind===`agent`?t.agent.emoji:(0,S.jsx)(C,{name:`forum`})}),(0,S.jsxs)(`span`,{className:`palette-text`,children:[(0,S.jsx)(`span`,{className:`palette-name`,children:Io(t)}),Lo(t)&&(0,S.jsx)(`span`,{className:`palette-sub`,children:Lo(t)})]}),d===t.key?(0,S.jsx)(C,{name:`progress_activity`,className:`ms-sm`}):t.kind===`channel`&&(0,S.jsx)(`span`,{className:`palette-chip`,children:`channel`})]},t.key)})]},t.ws.url||t.ws.name))})}else T=a?(0,S.jsx)(`div`,{className:`palette-empty`,children:`could not load the agents and channels`}):r?(0,S.jsx)(`div`,{className:`palette-empty`,children:`looking for agents 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 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 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 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]})]})]})})}var Wo=`modulepreload`,Go=function(e){return`/`+e},Ko={},qo=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=Go(t,n),t=s(t),t in Ko)return;Ko[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`:Wo,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)})},Jo=(0,v.lazy)(()=>qo(()=>import(`./editor-B5WUiag9.js`).then(e=>({default:e.EditorScreen})),__vite__mapDeps([0,1,2,3,4,5,6])));function Yo(){let[e,t=``]=w().split(`?`),n=e.split(`/`).filter(Boolean),r=new URLSearchParams(t).get(`workflow`)??void 0,[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!0),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(!1),[y,b]=(0,v.useState)(!1),[x,T]=(0,v.useState)(!1),[E,D]=(0,v.useState)(!1),[O,k]=(0,v.useState)([]);(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;a(t.projectName??``),s(t.projectIcon??``),l(t.projectColor??``),d(t.projectNamed!==!1),p(t.projectRootLabel??``),h(t.projectRoot??``),_(!!t.git),b(!!t.repos),T(!!t.vibeables),D(!!t.projects),F({git:!!t.git,repos:!!t.repos,vibeables:!!t.vibeables,projects:!!t.projects}),k(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(ee(i?`${i} — kraftwerk`:`kraftwerk inspector`),!o)return;let e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y="0.9em" font-size="85">${o}</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)}`},[i,o]);let te;if(te=n[0]===`runs`&&n[1]?(0,S.jsx)(bi,{id:n[1],workflow:r}):n[0]===`runs`?(0,S.jsx)(rs,{}):n[0]===`workflows`&&n[1]?(0,S.jsx)(Wi,{slug:decodeURIComponent(n[1])}):n[0]===`workflows`?(0,S.jsx)(Hi,{}):n[0]===`chats`?(0,S.jsx)(ka,{seg:n}):n[0]===`skills`?(0,S.jsx)(wa,{name:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`settings`?(0,S.jsx)(Ya,{}):n[0]===`workspaces`?(0,S.jsx)(Za,{}):n[0]===`git`?(0,S.jsx)(ro,{}):n[0]===`repos`?(0,S.jsx)(so,{slug:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`vibeables`?(0,S.jsx)(Wr,{slug:n[1]?decodeURIComponent(n[1]):void 0}):n[0]===`projects`?(0,S.jsx)(yo,{seg:n.slice(1)}):n[0]===`agents`||n[0]===`team`?(0,S.jsx)(ka,{seg:n.slice(1)}):n[0]===`channels`?(0,S.jsx)(Gr,{seg:n.slice(1)}):n[0]===`knowledge`?(0,S.jsx)(da,{bundle:n[1]?decodeURIComponent(n[1]):void 0,conceptId:n.length>2?n.slice(2).map(decodeURIComponent).join(`/`):void 0}):(0,S.jsx)($i,{}),n[0]===`edit`&&n[1]&&n.length>2)return(0,S.jsx)(v.Suspense,{fallback:(0,S.jsx)(`div`,{className:`empty`,children:`loading editor…`}),children:(0,S.jsx)(Jo,{bundle:decodeURIComponent(n[1]),conceptId:n.slice(2).map(decodeURIComponent).join(`/`)},n.slice(1).join(`/`))});let A=(...e)=>e.includes(n[0]??``)?`active`:``;return(0,v.useEffect)(()=>{let e=document.documentElement,t=m||i,n=t?ge(ce(c,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=``},[c,m,i]),(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`header`,{className:`topbar`,style:{"--ws-c":ce(c,m||i)},children:[(0,S.jsxs)(`span`,{className:`wordmark`,children:[(0,S.jsx)(`a`,{href:`#/`,className:`home-link`,title:`Dashboard`,children:i?(0,S.jsx)(ve,{className:`home-tile`,icon:o,name:i,color:c,seed:m||i}):(0,S.jsx)(C,{name:`home`})}),i&&(0,S.jsx)(ns,{name:i,icon:o,color:c,named:u,root:f,seed:m||i,entries:O})]}),(0,S.jsxs)(`nav`,{children:[(0,S.jsxs)(`a`,{href:`#/channels`,className:A(`channels`),children:[(0,S.jsx)(C,{name:`forum`}),` channels`]}),E&&(0,S.jsxs)(`a`,{href:`#/projects`,className:A(`projects`),children:[(0,S.jsx)(C,{name:`folder_special`}),` projects`]}),(0,S.jsxs)(`a`,{href:`#/agents`,className:A(`agents`,`team`,`chats`),children:[(0,S.jsx)(C,{name:`groups`}),` agents`]}),(0,S.jsxs)(`a`,{href:`#/workflows`,className:A(`workflows`,`runs`),children:[(0,S.jsx)(C,{name:`account_tree`}),` workflows`]}),(0,S.jsxs)(`a`,{href:`#/knowledge`,className:A(`knowledge`),children:[(0,S.jsx)(C,{name:`menu_book`}),` knowledge`]}),(0,S.jsxs)(`a`,{href:`#/skills`,className:A(`skills`)+` nav-expert`,children:[(0,S.jsx)(C,{name:`extension`}),` skills`]}),y&&(0,S.jsxs)(`a`,{href:`#/repos`,className:A(`repos`)+` nav-expert`,children:[(0,S.jsx)(C,{name:`source`}),` repositories`]}),x&&(0,S.jsxs)(`a`,{href:`#/vibeables`,className:A(`vibeables`),children:[(0,S.jsx)(C,{name:`web`}),` vibeables`]}),g&&(0,S.jsx)(Xo,{active:n[0]===`git`})]}),(0,S.jsx)(`span`,{className:`spacer`}),(0,S.jsx)(Ho,{}),(0,S.jsx)(us,{}),(0,S.jsx)(os,{}),(0,S.jsx)(ss,{}),(0,S.jsx)(ds,{})]}),(0,S.jsx)(`main`,{className:`shell`,children:te})]})}function Xo({active:e}){let t=z(`/api/git`,!1,15e3),n=t?.files?.filter(e=>e.syncable).length??0;return(0,S.jsxs)(`a`,{href:`#/git`,className:e?`nav-expert active`:`nav-expert`,children:[(0,S.jsx)(C,{name:`cloud_sync`}),` git`,!!t?.behind&&(0,S.jsxs)(`span`,{className:`git-badge behind`,children:[t.behind,`↓`]}),!!t?.ahead&&(0,S.jsxs)(`span`,{className:`git-badge ahead`,children:[t.ahead,`↑`]}),!t?.ahead&&!t?.behind&&!!n&&(0,S.jsx)(`span`,{className:`git-badge dirty`,children:n})]})}function Zo(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 Qo({label:e}){return e?(0,S.jsx)(`span`,{className:`switcher-root`,title:e,children:(0,S.jsx)(`span`,{dir:`ltr`,children:e})}):null}function $o({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 es({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 ne(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)(ve,{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)($o,{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)(Qo,{label:e.rootLabel})]}),(0,S.jsxs)(`span`,{className:`switcher-side`,children:[(0,S.jsx)(`span`,{className:`switcher-port`,children:Zo(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 ts({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)(ve,{icon:e.icon,name:e.name,color:e.color,seed:n,ambiguous:t}),(0,S.jsxs)(`span`,{className:`switcher-text`,children:[(0,S.jsx)($o,{name:e.name,named:e.named}),(0,S.jsx)(Qo,{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`}),Zo(e.url)]})})]})}function ns({name:e,icon:t,color:n,named:r,root:i,seed:a,entries:o}){let[s,c]=(0,v.useState)(!1),l=P();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)(ve,{icon:t,name:e,color:n,seed:p,ambiguous:d(t)}),(0,S.jsxs)(`span`,{className:`switcher-text`,children:[(0,S.jsx)($o,{name:e,named:r}),i?(0,S.jsx)(Qo,{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)(es,{entry:e,ambiguous:d(e.icon)},e.root):(0,S.jsx)(ts,{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 rs(){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?A(`/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 is(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 as=`kw-version-changed`;function os(){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(as,i),()=>{e=!1,clearTimeout(n),window.removeEventListener(as,i)}},[]);let i=e?.restartable&&e.diskVersion&&e.diskVersion!==e.version?e.diskVersion:null;async function a(){i&&(r(!0),await is(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 ss(){let e=P();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:()=>ie(!e),children:[(0,S.jsx)(`span`,{className:`expert-track`,children:(0,S.jsx)(`span`,{className:`expert-knob`})}),`expert`]})}var cs={approval:`gavel`,routine_done:`schedule`,routine_failed:`schedule`,run_done:`account_tree`,run_failed:`account_tree`},ls=`kw.notif.toast.dismissed`;function us(){let[e,t]=(0,v.useState)(!1),n=z(`/api/notifications`,!1,5e3),[r,i]=(0,v.useState)(()=>typeof Notification>`u`?`unsupported`:Notification.permission),[a,o]=(0,v.useState)(()=>{try{return localStorage.getItem(ls)===`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]}),A(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),A(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(ls,`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:cs[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:Te(e.at)})]},e.id))})]})]})}function ds(){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)(ms,{})]}),(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)(ps,{})]})]})]})}function fs(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 ps(){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(as))}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(`
|
|
220
|
+
`),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),is(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(`
|
|
221
|
+
`),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?fs(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 ms(){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)(Yo,{})}));export{x as a,o as c,te as i,s as l,C as n,h as o,A as r,d as s,qo as t,l as u};
|