cascade-ai 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +676 -0
- package/bin/cascade.js +3 -0
- package/completions/cascade.bash +23 -0
- package/completions/cascade.fish +20 -0
- package/completions/cascade.zsh +32 -0
- package/dist/cli.cjs +10442 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +2 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +10395 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +7544 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1578 -0
- package/dist/index.d.ts +1578 -0
- package/dist/index.js +7452 -0
- package/dist/index.js.map +1 -0
- package/dist/keytar-F4YAPN53.node +0 -0
- package/package.json +135 -0
- package/web/dist/assets/index-DO_ICahS.css +1 -0
- package/web/dist/assets/index-qNI_hqt1.js +216 -0
- package/web/dist/assets/react-Cpp6qqoq.js +1 -0
- package/web/dist/assets/reactflow-B1e2RnXD.js +48 -0
- package/web/dist/assets/socketio-BcxXcwBL.js +1 -0
- package/web/dist/index.html +16 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
var ys=Object.defineProperty;var ws=(e,s,t)=>s in e?ys(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t;var Me=(e,s,t)=>ws(e,typeof s!="symbol"?s+"":s,t);import{r as h,a as $t,H as rt,P as it,M as js,R as _s,B as Ss,b as Ns,C as ks,c as Cs}from"./reactflow-B1e2RnXD.js";import{l as Es}from"./socketio-BcxXcwBL.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function t(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(r){if(r.ep)return;r.ep=!0;const i=t(r);fetch(r.href,i)}})();var Ut={exports:{}},je={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var Is=h,As=Symbol.for("react.element"),Ms=Symbol.for("react.fragment"),Ts=Object.prototype.hasOwnProperty,Os=Is.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Rs={key:!0,ref:!0,__self:!0,__source:!0};function Bt(e,s,t){var n,r={},i=null,o=null;t!==void 0&&(i=""+t),s.key!==void 0&&(i=""+s.key),s.ref!==void 0&&(o=s.ref);for(n in s)Ts.call(s,n)&&!Rs.hasOwnProperty(n)&&(r[n]=s[n]);if(e&&e.defaultProps)for(n in s=e.defaultProps,s)r[n]===void 0&&(r[n]=s[n]);return{$$typeof:As,type:e,key:i,ref:o,props:r,_owner:Os.current}}je.Fragment=Ms;je.jsx=Bt;je.jsxs=Bt;Ut.exports=je;var a=Ut.exports,Be={},at=$t;Be.createRoot=at.createRoot,Be.hydrateRoot=at.hydrateRoot;var Vt={exports:{}},Wt={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* use-sync-external-store-with-selector.production.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var te=h;function Ds(e,s){return e===s&&(e!==0||1/e===1/s)||e!==e&&s!==s}var zs=typeof Object.is=="function"?Object.is:Ds,Ps=te.useSyncExternalStore,Ls=te.useRef,Fs=te.useEffect,$s=te.useMemo,Us=te.useDebugValue;Wt.useSyncExternalStoreWithSelector=function(e,s,t,n,r){var i=Ls(null);if(i.current===null){var o={hasValue:!1,value:null};i.current=o}else o=i.current;i=$s(function(){function c(f){if(!d){if(d=!0,u=f,f=n(f),r!==void 0&&o.hasValue){var g=o.value;if(r(g,f))return m=g}return m=f}if(g=m,zs(u,f))return g;var y=n(f);return r!==void 0&&r(g,y)?(u=f,g):(u=f,m=y)}var d=!1,u,m,p=t===void 0?null:t;return[function(){return c(s())},p===null?void 0:function(){return c(p())}]},[s,t,n,r]);var l=Ps(e,i[0],i[1]);return Fs(function(){o.hasValue=!0,o.value=l},[l]),Us(l),l};Vt.exports=Wt;var Bs=Vt.exports;function Vs(e){e()}function Ws(){let e=null,s=null;return{clear(){e=null,s=null},notify(){Vs(()=>{let t=e;for(;t;)t.callback(),t=t.next})},get(){const t=[];let n=e;for(;n;)t.push(n),n=n.next;return t},subscribe(t){let n=!0;const r=s={callback:t,next:null,prev:s};return r.prev?r.prev.next=r:e=r,function(){!n||e===null||(n=!1,r.next?r.next.prev=r.prev:s=r.prev,r.prev?r.prev.next=r.next:e=r.next)}}}}var ot={notify(){},get:()=>[]};function Hs(e,s){let t,n=ot,r=0,i=!1;function o(y){u();const v=n.subscribe(y);let x=!1;return()=>{x||(x=!0,v(),m())}}function l(){n.notify()}function c(){g.onStateChange&&g.onStateChange()}function d(){return i}function u(){r++,t||(t=e.subscribe(c),n=Ws())}function m(){r--,t&&r===0&&(t(),t=void 0,n.clear(),n=ot)}function p(){i||(i=!0,u())}function f(){i&&(i=!1,m())}const g={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:d,trySubscribe:p,tryUnsubscribe:f,getListeners:()=>n};return g}var qs=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ks=qs(),Gs=()=>typeof navigator<"u"&&navigator.product==="ReactNative",Js=Gs(),Xs=()=>Ks||Js?h.useLayoutEffect:h.useEffect,Ys=Xs(),Te=Symbol.for("react-redux-context"),Oe=typeof globalThis<"u"?globalThis:{};function Zs(){if(!h.createContext)return{};const e=Oe[Te]??(Oe[Te]=new Map);let s=e.get(h.createContext);return s||(s=h.createContext(null),e.set(h.createContext,s)),s}var $=Zs();function Qs(e){const{children:s,context:t,serverState:n,store:r}=e,i=h.useMemo(()=>{const c=Hs(r);return{store:r,subscription:c,getServerState:n?()=>n:void 0}},[r,n]),o=h.useMemo(()=>r.getState(),[r]);Ys(()=>{const{subscription:c}=i;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),o!==r.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[i,o]);const l=t||$;return h.createElement(l.Provider,{value:i},s)}var en=Qs;function Ye(e=$){return function(){return h.useContext(e)}}var Ht=Ye();function qt(e=$){const s=e===$?Ht:Ye(e),t=()=>{const{store:n}=s();return n};return Object.assign(t,{withTypes:()=>t}),t}var tn=qt();function sn(e=$){const s=e===$?tn:qt(e),t=()=>s().dispatch;return Object.assign(t,{withTypes:()=>t}),t}var nn=sn(),rn=(e,s)=>e===s;function an(e=$){const s=e===$?Ht:Ye(e),t=(n,r={})=>{const{equalityFn:i=rn}=typeof r=="function"?{equalityFn:r}:r,o=s(),{store:l,subscription:c,getServerState:d}=o;h.useRef(!0);const u=h.useCallback({[n.name](p){return n(p)}}[n.name],[n]),m=Bs.useSyncExternalStoreWithSelector(c.addNestedSub,l.getState,d||l.getState,u,i);return h.useDebugValue(m),m};return Object.assign(t,{withTypes:()=>t}),t}var on=an();function E(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var ln=typeof Symbol=="function"&&Symbol.observable||"@@observable",lt=ln,Re=()=>Math.random().toString(36).substring(7).split("").join("."),cn={INIT:`@@redux/INIT${Re()}`,REPLACE:`@@redux/REPLACE${Re()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${Re()}`},me=cn;function Ze(e){if(typeof e!="object"||e===null)return!1;let s=e;for(;Object.getPrototypeOf(s)!==null;)s=Object.getPrototypeOf(s);return Object.getPrototypeOf(e)===s||Object.getPrototypeOf(e)===null}function Kt(e,s,t){if(typeof e!="function")throw new Error(E(2));if(typeof s=="function"&&typeof t=="function"||typeof t=="function"&&typeof arguments[3]=="function")throw new Error(E(0));if(typeof s=="function"&&typeof t>"u"&&(t=s,s=void 0),typeof t<"u"){if(typeof t!="function")throw new Error(E(1));return t(Kt)(e,s)}let n=e,r=s,i=new Map,o=i,l=0,c=!1;function d(){o===i&&(o=new Map,i.forEach((v,x)=>{o.set(x,v)}))}function u(){if(c)throw new Error(E(3));return r}function m(v){if(typeof v!="function")throw new Error(E(4));if(c)throw new Error(E(5));let x=!0;d();const b=l++;return o.set(b,v),function(){if(x){if(c)throw new Error(E(6));x=!1,d(),o.delete(b),i=null}}}function p(v){if(!Ze(v))throw new Error(E(7));if(typeof v.type>"u")throw new Error(E(8));if(typeof v.type!="string")throw new Error(E(17));if(c)throw new Error(E(9));try{c=!0,r=n(r,v)}finally{c=!1}return(i=o).forEach(b=>{b()}),v}function f(v){if(typeof v!="function")throw new Error(E(10));n=v,p({type:me.REPLACE})}function g(){const v=m;return{subscribe(x){if(typeof x!="object"||x===null)throw new Error(E(11));function b(){const w=x;w.next&&w.next(u())}return b(),{unsubscribe:v(b)}},[lt](){return this}}}return p({type:me.INIT}),{dispatch:p,subscribe:m,getState:u,replaceReducer:f,[lt]:g}}function dn(e){Object.keys(e).forEach(s=>{const t=e[s];if(typeof t(void 0,{type:me.INIT})>"u")throw new Error(E(12));if(typeof t(void 0,{type:me.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(E(13))})}function un(e){const s=Object.keys(e),t={};for(let i=0;i<s.length;i++){const o=s[i];typeof e[o]=="function"&&(t[o]=e[o])}const n=Object.keys(t);let r;try{dn(t)}catch(i){r=i}return function(o={},l){if(r)throw r;let c=!1;const d={};for(let u=0;u<n.length;u++){const m=n[u],p=t[m],f=o[m],g=p(f,l);if(typeof g>"u")throw l&&l.type,new Error(E(14));d[m]=g,c=c||g!==f}return c=c||n.length!==Object.keys(o).length,c?d:o}}function pe(...e){return e.length===0?s=>s:e.length===1?e[0]:e.reduce((s,t)=>(...n)=>s(t(...n)))}function fn(...e){return s=>(t,n)=>{const r=s(t,n);let i=()=>{throw new Error(E(15))};const o={getState:r.getState,dispatch:(c,...d)=>i(c,...d)},l=e.map(c=>c(o));return i=pe(...l)(r.dispatch),{...r,dispatch:i}}}function hn(e){return Ze(e)&&"type"in e&&typeof e.type=="string"}var Gt=Symbol.for("immer-nothing"),ct=Symbol.for("immer-draftable"),M=Symbol.for("immer-state");function R(e,...s){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var O=Object,H=O.getPrototypeOf,xe="constructor",_e="prototype",Ve="configurable",ge="enumerable",fe="writable",Z="value",F=e=>!!e&&!!e[M];function D(e){var s;return e?Jt(e)||Ne(e)||!!e[ct]||!!((s=e[xe])!=null&&s[ct])||ke(e)||Ce(e):!1}var mn=O[_e][xe].toString(),dt=new WeakMap;function Jt(e){if(!e||!Qe(e))return!1;const s=H(e);if(s===null||s===O[_e])return!0;const t=O.hasOwnProperty.call(s,xe)&&s[xe];if(t===Object)return!0;if(!W(t))return!1;let n=dt.get(t);return n===void 0&&(n=Function.toString.call(t),dt.set(t,n)),n===mn}function Se(e,s,t=!0){se(e)===0?(t?Reflect.ownKeys(e):O.keys(e)).forEach(r=>{s(r,e[r],e)}):e.forEach((n,r)=>s(r,n,e))}function se(e){const s=e[M];return s?s.type_:Ne(e)?1:ke(e)?2:Ce(e)?3:0}var ut=(e,s,t=se(e))=>t===2?e.has(s):O[_e].hasOwnProperty.call(e,s),We=(e,s,t=se(e))=>t===2?e.get(s):e[s],ve=(e,s,t,n=se(e))=>{n===2?e.set(s,t):n===3?e.add(t):e[s]=t};function pn(e,s){return e===s?e!==0||1/e===1/s:e!==e&&s!==s}var Ne=Array.isArray,ke=e=>e instanceof Map,Ce=e=>e instanceof Set,Qe=e=>typeof e=="object",W=e=>typeof e=="function",De=e=>typeof e=="boolean";function xn(e){const s=+e;return Number.isInteger(s)&&String(s)===e}var P=e=>e.copy_||e.base_,et=e=>e.modified_?e.copy_:e.base_;function He(e,s){if(ke(e))return new Map(e);if(Ce(e))return new Set(e);if(Ne(e))return Array[_e].slice.call(e);const t=Jt(e);if(s===!0||s==="class_only"&&!t){const n=O.getOwnPropertyDescriptors(e);delete n[M];let r=Reflect.ownKeys(n);for(let i=0;i<r.length;i++){const o=r[i],l=n[o];l[fe]===!1&&(l[fe]=!0,l[Ve]=!0),(l.get||l.set)&&(n[o]={[Ve]:!0,[fe]:!0,[ge]:l[ge],[Z]:e[o]})}return O.create(H(e),n)}else{const n=H(e);if(n!==null&&t)return{...e};const r=O.create(n);return O.assign(r,e)}}function tt(e,s=!1){return Ee(e)||F(e)||!D(e)||(se(e)>1&&O.defineProperties(e,{set:ae,add:ae,clear:ae,delete:ae}),O.freeze(e),s&&Se(e,(t,n)=>{tt(n,!0)},!1)),e}function gn(){R(2)}var ae={[Z]:gn};function Ee(e){return e===null||!Qe(e)?!0:O.isFrozen(e)}var be="MapSet",qe="Patches",ft="ArrayMethods",Xt={};function B(e){const s=Xt[e];return s||R(0,e),s}var ht=e=>!!Xt[e],Q,Yt=()=>Q,vn=(e,s)=>({drafts_:[],parent_:e,immer_:s,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:ht(be)?B(be):void 0,arrayMethodsPlugin_:ht(ft)?B(ft):void 0});function mt(e,s){s&&(e.patchPlugin_=B(qe),e.patches_=[],e.inversePatches_=[],e.patchListener_=s)}function Ke(e){Ge(e),e.drafts_.forEach(bn),e.drafts_=null}function Ge(e){e===Q&&(Q=e.parent_)}var pt=e=>Q=vn(Q,e);function bn(e){const s=e[M];s.type_===0||s.type_===1?s.revoke_():s.revoked_=!0}function xt(e,s){s.unfinalizedDrafts_=s.drafts_.length;const t=s.drafts_[0];if(e!==void 0&&e!==t){t[M].modified_&&(Ke(s),R(4)),D(e)&&(e=gt(s,e));const{patchPlugin_:r}=s;r&&r.generateReplacementPatches_(t[M].base_,e,s)}else e=gt(s,t);return yn(s,e,!0),Ke(s),s.patches_&&s.patchListener_(s.patches_,s.inversePatches_),e!==Gt?e:void 0}function gt(e,s){if(Ee(s))return s;const t=s[M];if(!t)return ye(s,e.handledSet_,e);if(!Ie(t,e))return s;if(!t.modified_)return t.base_;if(!t.finalized_){const{callbacks_:n}=t;if(n)for(;n.length>0;)n.pop()(e);es(t,e)}return t.copy_}function yn(e,s,t=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&tt(s,t)}function Zt(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Ie=(e,s)=>e.scope_===s,wn=[];function Qt(e,s,t,n){const r=P(e),i=e.type_;if(n!==void 0&&We(r,n,i)===s){ve(r,n,t,i);return}if(!e.draftLocations_){const l=e.draftLocations_=new Map;Se(r,(c,d)=>{if(F(d)){const u=l.get(d)||[];u.push(c),l.set(d,u)}})}const o=e.draftLocations_.get(s)??wn;for(const l of o)ve(r,l,t,i)}function jn(e,s,t){e.callbacks_.push(function(r){var l;const i=s;if(!i||!Ie(i,r))return;(l=r.mapSetPlugin_)==null||l.fixSetContents(i);const o=et(i);Qt(e,i.draft_??i,o,t),es(i,r)})}function es(e,s){var n;if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(((n=e.assigned_)==null?void 0:n.size)??0)>0)){const{patchPlugin_:r}=s;if(r){const i=r.getPath(e);i&&r.generatePatches_(e,i,s)}Zt(e)}}function _n(e,s,t){const{scope_:n}=e;if(F(t)){const r=t[M];Ie(r,n)&&r.callbacks_.push(function(){he(e);const o=et(r);Qt(e,t,o,s)})}else D(t)&&e.callbacks_.push(function(){const i=P(e);e.type_===3?i.has(t)&&ye(t,n.handledSet_,n):We(i,s,e.type_)===t&&n.drafts_.length>1&&(e.assigned_.get(s)??!1)===!0&&e.copy_&&ye(We(e.copy_,s,e.type_),n.handledSet_,n)})}function ye(e,s,t){return!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||F(e)||s.has(e)||!D(e)||Ee(e)||(s.add(e),Se(e,(n,r)=>{if(F(r)){const i=r[M];if(Ie(i,t)){const o=et(i);ve(e,n,o,e.type_),Zt(i)}}else D(r)&&ye(r,s,t)})),e}function Sn(e,s){const t=Ne(e),n={type_:t?1:0,scope_:s?s.scope_:Yt(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:s,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let r=n,i=we;t&&(r=[n],i=ee);const{revoke:o,proxy:l}=Proxy.revocable(r,i);return n.draft_=l,n.revoke_=o,[l,n]}var we={get(e,s){if(s===M)return e;let t=e.scope_.arrayMethodsPlugin_;const n=e.type_===1&&typeof s=="string";if(n&&t!=null&&t.isArrayOperationMethod(s))return t.createMethodInterceptor(e,s);const r=P(e);if(!ut(r,s,e.type_))return Nn(e,r,s);const i=r[s];if(e.finalized_||!D(i)||n&&e.operationMethod&&(t!=null&&t.isMutatingArrayMethod(e.operationMethod))&&xn(s))return i;if(i===ze(e.base_,s)){he(e);const o=e.type_===1?+s:s,l=Xe(e.scope_,i,e,o);return e.copy_[o]=l}return i},has(e,s){return s in P(e)},ownKeys(e){return Reflect.ownKeys(P(e))},set(e,s,t){const n=ts(P(e),s);if(n!=null&&n.set)return n.set.call(e.draft_,t),!0;if(!e.modified_){const r=ze(P(e),s),i=r==null?void 0:r[M];if(i&&i.base_===t)return e.copy_[s]=t,e.assigned_.set(s,!1),!0;if(pn(t,r)&&(t!==void 0||ut(e.base_,s,e.type_)))return!0;he(e),Je(e)}return e.copy_[s]===t&&(t!==void 0||s in e.copy_)||Number.isNaN(t)&&Number.isNaN(e.copy_[s])||(e.copy_[s]=t,e.assigned_.set(s,!0),_n(e,s,t)),!0},deleteProperty(e,s){return he(e),ze(e.base_,s)!==void 0||s in e.base_?(e.assigned_.set(s,!1),Je(e)):e.assigned_.delete(s),e.copy_&&delete e.copy_[s],!0},getOwnPropertyDescriptor(e,s){const t=P(e),n=Reflect.getOwnPropertyDescriptor(t,s);return n&&{[fe]:!0,[Ve]:e.type_!==1||s!=="length",[ge]:n[ge],[Z]:t[s]}},defineProperty(){R(11)},getPrototypeOf(e){return H(e.base_)},setPrototypeOf(){R(12)}},ee={};for(let e in we){let s=we[e];ee[e]=function(){const t=arguments;return t[0]=t[0][0],s.apply(this,t)}}ee.deleteProperty=function(e,s){return ee.set.call(this,e,s,void 0)};ee.set=function(e,s,t){return we.set.call(this,e[0],s,t,e[0])};function ze(e,s){const t=e[M];return(t?P(t):e)[s]}function Nn(e,s,t){var r;const n=ts(s,t);return n?Z in n?n[Z]:(r=n.get)==null?void 0:r.call(e.draft_):void 0}function ts(e,s){if(!(s in e))return;let t=H(e);for(;t;){const n=Object.getOwnPropertyDescriptor(t,s);if(n)return n;t=H(t)}}function Je(e){e.modified_||(e.modified_=!0,e.parent_&&Je(e.parent_))}function he(e){e.copy_||(e.assigned_=new Map,e.copy_=He(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var kn=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(s,t,n)=>{if(W(s)&&!W(t)){const i=t;t=s;const o=this;return function(c=i,...d){return o.produce(c,u=>t.call(this,u,...d))}}W(t)||R(6),n!==void 0&&!W(n)&&R(7);let r;if(D(s)){const i=pt(this),o=Xe(i,s,void 0);let l=!0;try{r=t(o),l=!1}finally{l?Ke(i):Ge(i)}return mt(i,n),xt(r,i)}else if(!s||!Qe(s)){if(r=t(s),r===void 0&&(r=s),r===Gt&&(r=void 0),this.autoFreeze_&&tt(r,!0),n){const i=[],o=[];B(qe).generateReplacementPatches_(s,r,{patches_:i,inversePatches_:o}),n(i,o)}return r}else R(1,s)},this.produceWithPatches=(s,t)=>{if(W(s))return(o,...l)=>this.produceWithPatches(o,c=>s(c,...l));let n,r;return[this.produce(s,t,(o,l)=>{n=o,r=l}),n,r]},De(e==null?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),De(e==null?void 0:e.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),De(e==null?void 0:e.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){D(e)||R(8),F(e)&&(e=Cn(e));const s=pt(this),t=Xe(s,e,void 0);return t[M].isManual_=!0,Ge(s),t}finishDraft(e,s){const t=e&&e[M];(!t||!t.isManual_)&&R(9);const{scope_:n}=t;return mt(n,s),xt(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,s){let t;for(t=s.length-1;t>=0;t--){const r=s[t];if(r.path.length===0&&r.op==="replace"){e=r.value;break}}t>-1&&(s=s.slice(t+1));const n=B(qe).applyPatches_;return F(e)?n(e,s):this.produce(e,r=>n(r,s))}};function Xe(e,s,t,n){const[r,i]=ke(s)?B(be).proxyMap_(s,t):Ce(s)?B(be).proxySet_(s,t):Sn(s,t);return((t==null?void 0:t.scope_)??Yt()).drafts_.push(r),i.callbacks_=(t==null?void 0:t.callbacks_)??[],i.key_=n,t&&n!==void 0?jn(t,i,n):i.callbacks_.push(function(c){var u;(u=c.mapSetPlugin_)==null||u.fixSetContents(i);const{patchPlugin_:d}=c;i.modified_&&d&&d.generatePatches_(i,[],c)}),r}function Cn(e){return F(e)||R(10,e),ss(e)}function ss(e){if(!D(e)||Ee(e))return e;const s=e[M];let t,n=!0;if(s){if(!s.modified_)return s.base_;s.finalized_=!0,t=He(e,s.scope_.immer_.useStrictShallowCopy_),n=s.scope_.immer_.shouldUseStrictIteration()}else t=He(e,!0);return Se(t,(r,i)=>{ve(t,r,ss(i))},n),s&&(s.finalized_=!1),t}var En=new kn,ns=En.produce;function In(e,s=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(s)}function An(e,s=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(s)}function Mn(e,s="expected all items to be functions, instead received the following types: "){if(!e.every(t=>typeof t=="function")){const t=e.map(n=>typeof n=="function"?`function ${n.name||"unnamed"}()`:typeof n).join(", ");throw new TypeError(`${s}[${t}]`)}}var vt=e=>Array.isArray(e)?e:[e];function Tn(e){const s=Array.isArray(e[0])?e[0]:e;return Mn(s,"createSelector expects all input-selectors to be functions, but received the following types: "),s}function On(e,s){const t=[],{length:n}=e;for(let r=0;r<n;r++)t.push(e[r].apply(null,s));return t}var Rn=class{constructor(e){this.value=e}deref(){return this.value}},Dn=typeof WeakRef<"u"?WeakRef:Rn,zn=0,bt=1;function oe(){return{s:zn,v:void 0,o:null,p:null}}function rs(e,s={}){let t=oe();const{resultEqualityCheck:n}=s;let r,i=0;function o(){var m;let l=t;const{length:c}=arguments;for(let p=0,f=c;p<f;p++){const g=arguments[p];if(typeof g=="function"||typeof g=="object"&&g!==null){let y=l.o;y===null&&(l.o=y=new WeakMap);const v=y.get(g);v===void 0?(l=oe(),y.set(g,l)):l=v}else{let y=l.p;y===null&&(l.p=y=new Map);const v=y.get(g);v===void 0?(l=oe(),y.set(g,l)):l=v}}const d=l;let u;if(l.s===bt)u=l.v;else if(u=e.apply(null,arguments),i++,n){const p=((m=r==null?void 0:r.deref)==null?void 0:m.call(r))??r;p!=null&&n(p,u)&&(u=p,i!==0&&i--),r=typeof u=="object"&&u!==null||typeof u=="function"?new Dn(u):u}return d.s=bt,d.v=u,u}return o.clearCache=()=>{t=oe(),o.resetResultsCount()},o.resultsCount=()=>i,o.resetResultsCount=()=>{i=0},o}function Pn(e,...s){const t=typeof e=="function"?{memoize:e,memoizeOptions:s}:e,n=(...r)=>{let i=0,o=0,l,c={},d=r.pop();typeof d=="object"&&(c=d,d=r.pop()),In(d,`createSelector expects an output function after the inputs, but received: [${typeof d}]`);const u={...t,...c},{memoize:m,memoizeOptions:p=[],argsMemoize:f=rs,argsMemoizeOptions:g=[]}=u,y=vt(p),v=vt(g),x=Tn(r),b=m(function(){return i++,d.apply(null,arguments)},...y),_=f(function(){o++;const j=On(x,arguments);return l=b.apply(null,j),l},...v);return Object.assign(_,{resultFunc:d,memoizedResultFunc:b,dependencies:x,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>l,recomputations:()=>i,resetRecomputations:()=>{i=0},memoize:m,argsMemoize:f})};return Object.assign(n,{withTypes:()=>n}),n}var q=Pn(rs),Ln=Object.assign((e,s=q)=>{An(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);const t=Object.keys(e),n=t.map(i=>e[i]);return s(n,(...i)=>i.reduce((o,l,c)=>(o[t[c]]=l,o),{}))},{withTypes:()=>Ln});function is(e){return({dispatch:t,getState:n})=>r=>i=>typeof i=="function"?i(t,n,e):r(i)}var Fn=is(),$n=is,Un=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?pe:pe.apply(null,arguments)},Bn=e=>e&&typeof e.match=="function";function X(e,s){function t(...n){if(s){let r=s(...n);if(!r)throw new Error(L(0));return{type:e,payload:r.payload,..."meta"in r&&{meta:r.meta},..."error"in r&&{error:r.error}}}return{type:e,payload:n[0]}}return t.toString=()=>`${e}`,t.type=e,t.match=n=>hn(n)&&n.type===e,t}var as=class G extends Array{constructor(...s){super(...s),Object.setPrototypeOf(this,G.prototype)}static get[Symbol.species](){return G}concat(...s){return super.concat.apply(this,s)}prepend(...s){return s.length===1&&Array.isArray(s[0])?new G(...s[0].concat(this)):new G(...s.concat(this))}};function yt(e){return D(e)?ns(e,()=>{}):e}function le(e,s,t){return e.has(s)?e.get(s):e.set(s,t(s)).get(s)}function Vn(e){return typeof e=="boolean"}var Wn=()=>function(s){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:r=!0,actionCreatorCheck:i=!0}=s??{};let o=new as;return t&&(Vn(t)?o.push(Fn):o.push($n(t.extraArgument))),o},Hn="RTK_autoBatch",wt=e=>s=>{setTimeout(s,e)},qn=(e={type:"raf"})=>s=>(...t)=>{const n=s(...t);let r=!0,i=!1,o=!1;const l=new Set,c=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:wt(10):e.type==="callback"?e.queueNotification:wt(e.timeout),d=()=>{o=!1,i&&(i=!1,l.forEach(u=>u()))};return Object.assign({},n,{subscribe(u){const m=()=>r&&u(),p=n.subscribe(m);return l.add(u),()=>{p(),l.delete(u)}},dispatch(u){var m;try{return r=!((m=u==null?void 0:u.meta)!=null&&m[Hn]),i=!r,i&&(o||(o=!0,c(d))),n.dispatch(u)}finally{r=!0}}})},Kn=e=>function(t){const{autoBatch:n=!0}=t??{};let r=new as(e);return n&&r.push(qn(typeof n=="object"?n:void 0)),r};function Gn(e){const s=Wn(),{reducer:t=void 0,middleware:n,devTools:r=!0,preloadedState:i=void 0,enhancers:o=void 0}=e||{};let l;if(typeof t=="function")l=t;else if(Ze(t))l=un(t);else throw new Error(L(1));let c;typeof n=="function"?c=n(s):c=s();let d=pe;r&&(d=Un({trace:!1,...typeof r=="object"&&r}));const u=fn(...c),m=Kn(u);let p=typeof o=="function"?o(m):m();const f=d(...p);return Kt(l,i,f)}function os(e){const s={},t=[];let n;const r={addCase(i,o){const l=typeof i=="string"?i:i.type;if(!l)throw new Error(L(28));if(l in s)throw new Error(L(29));return s[l]=o,r},addAsyncThunk(i,o){return o.pending&&(s[i.pending.type]=o.pending),o.rejected&&(s[i.rejected.type]=o.rejected),o.fulfilled&&(s[i.fulfilled.type]=o.fulfilled),o.settled&&t.push({matcher:i.settled,reducer:o.settled}),r},addMatcher(i,o){return t.push({matcher:i,reducer:o}),r},addDefaultCase(i){return n=i,r}};return e(r),[s,t,n]}function Jn(e){return typeof e=="function"}function Xn(e,s){let[t,n,r]=os(s),i;if(Jn(e))i=()=>yt(e());else{const l=yt(e);i=()=>l}function o(l=i(),c){let d=[t[c.type],...n.filter(({matcher:u})=>u(c)).map(({reducer:u})=>u)];return d.filter(u=>!!u).length===0&&(d=[r]),d.reduce((u,m)=>{if(m)if(F(u)){const f=m(u,c);return f===void 0?u:f}else{if(D(u))return ns(u,p=>m(p,c));{const p=m(u,c);if(p===void 0){if(u===null)return u;throw Error("A case reducer on a non-draftable value must not return undefined")}return p}}return u},l)}return o.getInitialState=i,o}var Yn=(e,s)=>Bn(e)?e.match(s):e(s);function Zn(...e){return s=>e.some(t=>Yn(t,s))}var Qn="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",er=(e=21)=>{let s="",t=e;for(;t--;)s+=Qn[Math.random()*64|0];return s},tr=["name","message","stack","code"],Pe=class{constructor(e,s){Me(this,"_type");this.payload=e,this.meta=s}},jt=class{constructor(e,s){Me(this,"_type");this.payload=e,this.meta=s}},sr=e=>{if(typeof e=="object"&&e!==null){const s={};for(const t of tr)typeof e[t]=="string"&&(s[t]=e[t]);return s}return{message:String(e)}},_t="External signal was aborted",nr=(()=>{function e(s,t,n){const r=X(s+"/fulfilled",(c,d,u,m)=>({payload:c,meta:{...m||{},arg:u,requestId:d,requestStatus:"fulfilled"}})),i=X(s+"/pending",(c,d,u)=>({payload:void 0,meta:{...u||{},arg:d,requestId:c,requestStatus:"pending"}})),o=X(s+"/rejected",(c,d,u,m,p)=>({payload:m,error:(n&&n.serializeError||sr)(c||"Rejected"),meta:{...p||{},arg:u,requestId:d,rejectedWithValue:!!m,requestStatus:"rejected",aborted:(c==null?void 0:c.name)==="AbortError",condition:(c==null?void 0:c.name)==="ConditionError"}}));function l(c,{signal:d}={}){return(u,m,p)=>{const f=n!=null&&n.idGenerator?n.idGenerator(c):er(),g=new AbortController;let y,v;function x(_){v=_,g.abort()}d&&(d.aborted?x(_t):d.addEventListener("abort",()=>x(_t),{once:!0}));const b=async function(){var j,N;let _;try{let C=(j=n==null?void 0:n.condition)==null?void 0:j.call(n,c,{getState:m,extra:p});if(ir(C)&&(C=await C),C===!1||g.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};const I=new Promise((S,T)=>{y=()=>{T({name:"AbortError",message:v||"Aborted"})},g.signal.addEventListener("abort",y,{once:!0})});u(i(f,c,(N=n==null?void 0:n.getPendingMeta)==null?void 0:N.call(n,{requestId:f,arg:c},{getState:m,extra:p}))),_=await Promise.race([I,Promise.resolve(t(c,{dispatch:u,getState:m,extra:p,requestId:f,signal:g.signal,abort:x,rejectWithValue:(S,T)=>new Pe(S,T),fulfillWithValue:(S,T)=>new jt(S,T)})).then(S=>{if(S instanceof Pe)throw S;return S instanceof jt?r(S.payload,f,c,S.meta):r(S,f,c)})])}catch(C){_=C instanceof Pe?o(null,f,c,C.payload,C.meta):o(C,f,c)}finally{y&&g.signal.removeEventListener("abort",y)}return n&&!n.dispatchConditionRejection&&o.match(_)&&_.meta.condition||u(_),_}();return Object.assign(b,{abort:x,requestId:f,arg:c,unwrap(){return b.then(rr)}})}}return Object.assign(l,{pending:i,rejected:o,fulfilled:r,settled:Zn(o,r),typePrefix:s})}return e.withTypes=()=>e,e})();function rr(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}function ir(e){return e!==null&&typeof e=="object"&&typeof e.then=="function"}var ar=Symbol.for("rtk-slice-createasyncthunk");function or(e,s){return`${e}/${s}`}function lr({creators:e}={}){var t;const s=(t=e==null?void 0:e.asyncThunk)==null?void 0:t[ar];return function(r){const{name:i,reducerPath:o=i}=r;if(!i)throw new Error(L(11));const l=(typeof r.reducers=="function"?r.reducers(ur()):r.reducers)||{},c=Object.keys(l),d={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(w,j){const N=typeof w=="string"?w:w.type;if(!N)throw new Error(L(12));if(N in d.sliceCaseReducersByType)throw new Error(L(13));return d.sliceCaseReducersByType[N]=j,u},addMatcher(w,j){return d.sliceMatchers.push({matcher:w,reducer:j}),u},exposeAction(w,j){return d.actionCreators[w]=j,u},exposeCaseReducer(w,j){return d.sliceCaseReducersByName[w]=j,u}};c.forEach(w=>{const j=l[w],N={reducerName:w,type:or(i,w),createNotation:typeof r.reducers=="function"};hr(j)?pr(N,j,u,s):fr(N,j,u)});function m(){const[w={},j=[],N=void 0]=typeof r.extraReducers=="function"?os(r.extraReducers):[r.extraReducers],C={...w,...d.sliceCaseReducersByType};return Xn(r.initialState,I=>{for(let S in C)I.addCase(S,C[S]);for(let S of d.sliceMatchers)I.addMatcher(S.matcher,S.reducer);for(let S of j)I.addMatcher(S.matcher,S.reducer);N&&I.addDefaultCase(N)})}const p=w=>w,f=new Map,g=new WeakMap;let y;function v(w,j){return y||(y=m()),y(w,j)}function x(){return y||(y=m()),y.getInitialState()}function b(w,j=!1){function N(I){let S=I[w];return typeof S>"u"&&j&&(S=le(g,N,x)),S}function C(I=p){const S=le(f,j,()=>new WeakMap);return le(S,I,()=>{const T={};for(const[k,z]of Object.entries(r.selectors??{}))T[k]=cr(z,I,()=>le(g,I,x),j);return T})}return{reducerPath:w,getSelectors:C,get selectors(){return C(N)},selectSlice:N}}const _={name:i,reducer:v,actions:d.actionCreators,caseReducers:d.sliceCaseReducersByName,getInitialState:x,...b(o),injectInto(w,{reducerPath:j,...N}={}){const C=j??o;return w.inject({reducerPath:C,reducer:v},N),{..._,...b(C,!0)}}};return _}}function cr(e,s,t,n){function r(i,...o){let l=s(i);return typeof l>"u"&&n&&(l=t()),e(l,...o)}return r.unwrapped=e,r}var dr=lr();function ur(){function e(s,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:s,...t}}return e.withTypes=()=>e,{reducer(s){return Object.assign({[s.name](...t){return s(...t)}}[s.name],{_reducerDefinitionType:"reducer"})},preparedReducer(s,t){return{_reducerDefinitionType:"reducerWithPrepare",prepare:s,reducer:t}},asyncThunk:e}}function fr({type:e,reducerName:s,createNotation:t},n,r){let i,o;if("reducer"in n){if(t&&!mr(n))throw new Error(L(17));i=n.reducer,o=n.prepare}else i=n;r.addCase(e,i).exposeCaseReducer(s,i).exposeAction(s,o?X(e,o):X(e))}function hr(e){return e._reducerDefinitionType==="asyncThunk"}function mr(e){return e._reducerDefinitionType==="reducerWithPrepare"}function pr({type:e,reducerName:s},t,n,r){if(!r)throw new Error(L(18));const{payloadCreator:i,fulfilled:o,pending:l,rejected:c,settled:d,options:u}=t,m=r(e,i,u);n.exposeAction(s,m),o&&n.addCase(m.fulfilled,o),l&&n.addCase(m.pending,l),c&&n.addCase(m.rejected,c),d&&n.addMatcher(m.settled,d),n.exposeCaseReducer(s,{fulfilled:o||ce,pending:l||ce,rejected:c||ce,settled:d||ce})}function ce(){}function L(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}const xr=nr("runtime/fetchHistory",async({sessionId:e,before:s,limit:t=100})=>{const n=localStorage.getItem("cascade_token")??"",r=`/api/runtime/logs/${e}?limit=${t}${s?`&before=${s}`:""}`,i=await fetch(r,{headers:{Authorization:`Bearer ${n}`}});if(!i.ok)throw new Error("Failed to fetch history");const o=await i.json();return{sessionId:e,logs:o}}),gr={sessions:{},nodes:{},logIds:{},logs:{},activeSessionId:null,scope:"workspace",connected:!1};function St(e,s,t){for(const n of s){const r=n.sessionId??t??"",i=`${r}:${n.tierId}`;e[i]={...e[i],...n,sessionId:r}}}function de(e,s,t,n=1e3){e.logIds[s]||(e.logIds[s]=new Set),e.logs[s]||(e.logs[s]=[]);const r=e.logIds[s],i=e.logs[s];for(const o of t)r.has(o.id)||(r.add(o.id),i.push(o));if(i.length>n){const o=i.splice(0,i.length-n);for(const l of o)r.delete(l.id)}}const ls=dr({name:"runtime",initialState:gr,reducers:{setConnected(e,s){e.connected=s.payload},setScope(e,s){e.scope=s.payload},setActiveSession(e,s){e.activeSessionId=s.payload},updateRTKSnapshot(e,s){var o;const{sessions:t,nodes:n,logs:r,scope:i}=s.payload;(i==="workspace"||i==="global")&&(e.scope=i);for(const l of t)e.sessions[l.sessionId]={...e.sessions[l.sessionId]??{},...l};if(!e.activeSessionId&&t.length>0&&(e.activeSessionId=((o=t.find(l=>l.status==="ACTIVE"))==null?void 0:o.sessionId)??t[0].sessionId),n!=null&&n.length&&St(e.nodes,n),r!=null&&r.length)for(const l of r)l.sessionId&&de(e,l.sessionId,[l])},updateSessionDetails(e,s){var i;const{sessionId:t,nodes:n,logs:r}=s.payload;St(e.nodes,n,t),de(e,t,r),(i=e.logs[t])==null||i.sort((o,l)=>new Date(o.timestamp).getTime()-new Date(l.timestamp).getTime())},appendLog(e,s){const t=s.payload;de(e,t.sessionId,[t])},clearFrontendGraphs(e){e.nodes={},e.logIds={},e.logs={}},removeSessionsBulk(e,s){var t,n;for(const r of s.payload){delete e.sessions[r];for(const i of Object.keys(e.nodes))((t=e.nodes[i])==null?void 0:t.sessionId)===r&&delete e.nodes[i];delete e.logs[r],delete e.logIds[r]}if(e.activeSessionId&&s.payload.includes(e.activeSessionId)){const r=Object.values(e.sessions);e.activeSessionId=((n=r[0])==null?void 0:n.sessionId)??null}}},extraReducers(e){e.addCase(xr.fulfilled,(s,t)=>{var i;const{sessionId:n,logs:r}=t.payload;de(s,n,r,2e3),(i=s.logs[n])==null||i.sort((o,l)=>new Date(o.timestamp).getTime()-new Date(l.timestamp).getTime())})}}),{setConnected:Nt,setScope:Vi,setActiveSession:vr,updateRTKSnapshot:cs,updateSessionDetails:br,appendLog:yr,clearFrontendGraphs:kt,removeSessionsBulk:wr}=ls.actions,ne=e=>e.runtime,jr=q(ne,e=>Object.values(e.sessions).sort((s,t)=>new Date(t.updatedAt).getTime()-new Date(s.updatedAt).getTime())),st=q(ne,e=>e.activeSessionId?e.sessions[e.activeSessionId]??null:null),_r=q(ne,e=>e.activeSessionId?Object.values(e.nodes).filter(s=>s.sessionId===e.activeSessionId):[]),Sr=q(ne,e=>e.activeSessionId?e.logs[e.activeSessionId]??[]:[]),Nr=q(ne,e=>e.connected),kr=ls.reducer,Cr=Gn({reducer:{runtime:kr},middleware:e=>e({serializableCheck:{ignoredPaths:["runtime.logIds"]}})}),Ae=()=>nn(),U=on;var re={},nt={};function Er(e,s,t){for(var n=0,r=0,i=t.length;r<i;r++)n=t.charCodeAt(r),n<128?e.setUint8(s++,n):n<2048?(e.setUint8(s++,192|n>>6),e.setUint8(s++,128|n&63)):n<55296||n>=57344?(e.setUint8(s++,224|n>>12),e.setUint8(s++,128|n>>6&63),e.setUint8(s++,128|n&63)):(r++,n=65536+((n&1023)<<10|t.charCodeAt(r)&1023),e.setUint8(s++,240|n>>18),e.setUint8(s++,128|n>>12&63),e.setUint8(s++,128|n>>6&63),e.setUint8(s++,128|n&63))}function Ir(e){for(var s=0,t=0,n=0,r=e.length;n<r;n++)s=e.charCodeAt(n),s<128?t+=1:s<2048?t+=2:s<55296||s>=57344?t+=3:(n++,t+=4);return t}function J(e,s,t){var n=typeof t,r=0,i=0,o=0,l=0,c=0,d=0;if(n==="string"){if(c=Ir(t),c<32)e.push(c|160),d=1;else if(c<256)e.push(217,c),d=2;else if(c<65536)e.push(218,c>>8,c),d=3;else if(c<4294967296)e.push(219,c>>24,c>>16,c>>8,c),d=5;else throw new Error("String too long");return s.push({_str:t,_length:c,_offset:e.length}),d+c}if(n==="number")return Math.floor(t)!==t||!isFinite(t)?(e.push(203),s.push({_float:t,_length:8,_offset:e.length}),9):t>=0?t<128?(e.push(t),1):t<256?(e.push(204,t),2):t<65536?(e.push(205,t>>8,t),3):t<4294967296?(e.push(206,t>>24,t>>16,t>>8,t),5):(o=t/Math.pow(2,32)>>0,l=t>>>0,e.push(207,o>>24,o>>16,o>>8,o,l>>24,l>>16,l>>8,l),9):t>=-32?(e.push(t),1):t>=-128?(e.push(208,t),2):t>=-32768?(e.push(209,t>>8,t),3):t>=-2147483648?(e.push(210,t>>24,t>>16,t>>8,t),5):(o=Math.floor(t/Math.pow(2,32)),l=t>>>0,e.push(211,o>>24,o>>16,o>>8,o,l>>24,l>>16,l>>8,l),9);if(n==="object"){if(t===null)return e.push(192),1;if(Array.isArray(t)){if(c=t.length,c<16)e.push(c|144),d=1;else if(c<65536)e.push(220,c>>8,c),d=3;else if(c<4294967296)e.push(221,c>>24,c>>16,c>>8,c),d=5;else throw new Error("Array too large");for(r=0;r<c;r++)d+=J(e,s,t[r]);return d}if(t instanceof Date){var u=t.getTime();return o=Math.floor(u/Math.pow(2,32)),l=u>>>0,e.push(215,0,o>>24,o>>16,o>>8,o,l>>24,l>>16,l>>8,l),10}if(t instanceof ArrayBuffer){if(c=t.byteLength,c<256)e.push(196,c),d=2;else if(c<65536)e.push(197,c>>8,c),d=3;else if(c<4294967296)e.push(198,c>>24,c>>16,c>>8,c),d=5;else throw new Error("Buffer too large");return s.push({_bin:t,_length:c,_offset:e.length}),d+c}if(typeof t.toJSON=="function")return J(e,s,t.toJSON());var m=[],p="",f=Object.keys(t);for(r=0,i=f.length;r<i;r++)p=f[r],typeof t[p]!="function"&&m.push(p);if(c=m.length,c<16)e.push(c|128),d=1;else if(c<65536)e.push(222,c>>8,c),d=3;else if(c<4294967296)e.push(223,c>>24,c>>16,c>>8,c),d=5;else throw new Error("Object too large");for(r=0;r<c;r++)p=m[r],d+=J(e,s,p),d+=J(e,s,t[p]);return d}if(n==="boolean")return e.push(t?195:194),1;if(n==="undefined")return e.push(212,0,0),3;throw new Error("Could not encode")}function Ar(e){var s=[],t=[],n=J(s,t,e),r=new ArrayBuffer(n),i=new DataView(r),o=0,l=0,c=-1;t.length>0&&(c=t[0]._offset);for(var d,u=0,m=0,p=0,f=s.length;p<f;p++)if(i.setUint8(l+p,s[p]),p+1===c){if(d=t[o],u=d._length,m=l+c,d._bin)for(var g=new Uint8Array(d._bin),y=0;y<u;y++)i.setUint8(m+y,g[y]);else d._str?Er(i,m,d._str):d._float!==void 0&&i.setFloat64(m,d._float);o++,l+=u,t[o]&&(c=t[o]._offset)}return r}var Mr=Ar;function K(e){if(this._offset=0,e instanceof ArrayBuffer)this._buffer=e,this._view=new DataView(this._buffer);else if(ArrayBuffer.isView(e))this._buffer=e.buffer,this._view=new DataView(this._buffer,e.byteOffset,e.byteLength);else throw new Error("Invalid argument")}function Tr(e,s,t){for(var n="",r=0,i=s,o=s+t;i<o;i++){var l=e.getUint8(i);if(!(l&128)){n+=String.fromCharCode(l);continue}if((l&224)===192){n+=String.fromCharCode((l&31)<<6|e.getUint8(++i)&63);continue}if((l&240)===224){n+=String.fromCharCode((l&15)<<12|(e.getUint8(++i)&63)<<6|(e.getUint8(++i)&63)<<0);continue}if((l&248)===240){r=(l&7)<<18|(e.getUint8(++i)&63)<<12|(e.getUint8(++i)&63)<<6|(e.getUint8(++i)&63)<<0,r>=65536?(r-=65536,n+=String.fromCharCode((r>>>10)+55296,(r&1023)+56320)):n+=String.fromCharCode(r);continue}throw new Error("Invalid byte "+l.toString(16))}return n}K.prototype._array=function(e){for(var s=new Array(e),t=0;t<e;t++)s[t]=this._parse();return s};K.prototype._map=function(e){for(var s="",t={},n=0;n<e;n++)s=this._parse(),t[s]=this._parse();return t};K.prototype._str=function(e){var s=Tr(this._view,this._offset,e);return this._offset+=e,s};K.prototype._bin=function(e){var s=this._buffer.slice(this._offset,this._offset+e);return this._offset+=e,s};K.prototype._parse=function(){var e=this._view.getUint8(this._offset++),s,t=0,n=0,r=0,i=0;if(e<192)return e<128?e:e<144?this._map(e&15):e<160?this._array(e&15):this._str(e&31);if(e>223)return(255-e+1)*-1;switch(e){case 192:return null;case 194:return!1;case 195:return!0;case 196:return t=this._view.getUint8(this._offset),this._offset+=1,this._bin(t);case 197:return t=this._view.getUint16(this._offset),this._offset+=2,this._bin(t);case 198:return t=this._view.getUint32(this._offset),this._offset+=4,this._bin(t);case 199:return t=this._view.getUint8(this._offset),n=this._view.getInt8(this._offset+1),this._offset+=2,[n,this._bin(t)];case 200:return t=this._view.getUint16(this._offset),n=this._view.getInt8(this._offset+2),this._offset+=3,[n,this._bin(t)];case 201:return t=this._view.getUint32(this._offset),n=this._view.getInt8(this._offset+4),this._offset+=5,[n,this._bin(t)];case 202:return s=this._view.getFloat32(this._offset),this._offset+=4,s;case 203:return s=this._view.getFloat64(this._offset),this._offset+=8,s;case 204:return s=this._view.getUint8(this._offset),this._offset+=1,s;case 205:return s=this._view.getUint16(this._offset),this._offset+=2,s;case 206:return s=this._view.getUint32(this._offset),this._offset+=4,s;case 207:return r=this._view.getUint32(this._offset)*Math.pow(2,32),i=this._view.getUint32(this._offset+4),this._offset+=8,r+i;case 208:return s=this._view.getInt8(this._offset),this._offset+=1,s;case 209:return s=this._view.getInt16(this._offset),this._offset+=2,s;case 210:return s=this._view.getInt32(this._offset),this._offset+=4,s;case 211:return r=this._view.getInt32(this._offset)*Math.pow(2,32),i=this._view.getUint32(this._offset+4),this._offset+=8,r+i;case 212:if(n=this._view.getInt8(this._offset),this._offset+=1,n===0){this._offset+=1;return}return[n,this._bin(1)];case 213:return n=this._view.getInt8(this._offset),this._offset+=1,[n,this._bin(2)];case 214:return n=this._view.getInt8(this._offset),this._offset+=1,[n,this._bin(4)];case 215:return n=this._view.getInt8(this._offset),this._offset+=1,n===0?(r=this._view.getInt32(this._offset)*Math.pow(2,32),i=this._view.getUint32(this._offset+4),this._offset+=8,new Date(r+i)):[n,this._bin(8)];case 216:return n=this._view.getInt8(this._offset),this._offset+=1,[n,this._bin(16)];case 217:return t=this._view.getUint8(this._offset),this._offset+=1,this._str(t);case 218:return t=this._view.getUint16(this._offset),this._offset+=2,this._str(t);case 219:return t=this._view.getUint32(this._offset),this._offset+=4,this._str(t);case 220:return t=this._view.getUint16(this._offset),this._offset+=2,this._array(t);case 221:return t=this._view.getUint32(this._offset),this._offset+=4,this._array(t);case 222:return t=this._view.getUint16(this._offset),this._offset+=2,this._map(t);case 223:return t=this._view.getUint32(this._offset),this._offset+=4,this._map(t)}throw new Error("Could not parse")};function Or(e){var s=new K(e),t=s._parse();if(s._offset!==e.byteLength)throw new Error(e.byteLength-s._offset+" trailing bytes");return t}var Rr=Or;nt.encode=Mr;nt.decode=Rr;var ds={exports:{}};(function(e){e.exports=s;function s(n){if(n)return t(n)}function t(n){for(var r in s.prototype)n[r]=s.prototype[r];return n}s.prototype.on=s.prototype.addEventListener=function(n,r){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(r),this},s.prototype.once=function(n,r){function i(){this.off(n,i),r.apply(this,arguments)}return i.fn=r,this.on(n,i),this},s.prototype.off=s.prototype.removeListener=s.prototype.removeAllListeners=s.prototype.removeEventListener=function(n,r){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var i=this._callbacks["$"+n];if(!i)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var o,l=0;l<i.length;l++)if(o=i[l],o===r||o.fn===r){i.splice(l,1);break}return i.length===0&&delete this._callbacks["$"+n],this},s.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var r=new Array(arguments.length-1),i=this._callbacks["$"+n],o=1;o<arguments.length;o++)r[o-1]=arguments[o];if(i){i=i.slice(0);for(var o=0,l=i.length;o<l;++o)i[o].apply(this,r)}return this},s.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]},s.prototype.hasListeners=function(n){return!!this.listeners(n).length}})(ds);var Dr=ds.exports,us=nt,zr=Dr;re.protocol=5;var Y=re.PacketType={CONNECT:0,DISCONNECT:1,EVENT:2,ACK:3,CONNECT_ERROR:4},Ct=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e},fs=function(e){return typeof e=="string"},Et=function(e){return Object.prototype.toString.call(e)==="[object Object]"};function hs(){}hs.prototype.encode=function(e){return[us.encode(e)]};function ie(){}zr(ie.prototype);ie.prototype.add=function(e){var s=us.decode(e);this.checkPacket(s),this.emit("decoded",s)};function Pr(e){switch(e.type){case Y.CONNECT:return e.data===void 0||Et(e.data);case Y.DISCONNECT:return e.data===void 0;case Y.CONNECT_ERROR:return fs(e.data)||Et(e.data);default:return Array.isArray(e.data)}}ie.prototype.checkPacket=function(e){var s=Ct(e.type)&&e.type>=Y.CONNECT&&e.type<=Y.CONNECT_ERROR;if(!s)throw new Error("invalid packet type");if(!fs(e.nsp))throw new Error("invalid namespace");if(!Pr(e))throw new Error("invalid payload");var t=e.id===void 0||Ct(e.id);if(!t)throw new Error("invalid packet id")};ie.prototype.destroy=function(){};re.Encoder=hs;re.Decoder=ie;function Lr({url:e="/",token:s,activeSessionId:t,onRuntimeRefresh:n,onStreamToken:r,onCostUpdate:i,onEscalation:o}={}){const[l,c]=h.useState(null),d=Ae(),u=h.useRef(n),m=h.useRef(r),p=h.useRef(i),f=h.useRef(o);u.current=n,m.current=r,p.current=i,f.current=o;const g=h.useRef(t);g.current=t;const y=h.useRef(null);return h.useEffect(()=>{const v=Es(e,{auth:s?{token:s}:{},transports:["websocket","polling"],reconnection:!0,reconnectionDelay:500,parser:re});return v.on("connect",()=>{d(Nt(!0)),v.emit("runtime:refresh",{scope:"workspace"});const x=g.current;x&&(v.emit("join:session",{sessionId:x}),y.current=x),c(v)}),v.on("disconnect",()=>{d(Nt(!1)),c(null)}),v.on("runtime:update",x=>{d(cs(x))}),v.on("session:details",x=>{d(br(x))}),v.on("log:new",x=>{d(yr(x))}),v.on("runtime:refresh",x=>{var _;const b=x;(_=u.current)==null||_.call(u,b==null?void 0:b.scope)}),v.on("stream:token",x=>{var b;(b=m.current)==null||b.call(m,x)}),v.on("cost:update",x=>{var b;(b=p.current)==null||b.call(p,x)}),v.on("permission:user-required",x=>{var b;(b=f.current)==null||b.call(f,x)}),()=>{v.disconnect(),c(null),y.current=null}},[e,s,d]),h.useEffect(()=>{l&&t!==y.current&&(y.current&&l.emit("leave:session",{sessionId:y.current}),t&&l.emit("join:session",{sessionId:t}),y.current=t??null)},[l,t]),{socket:l}}const Fr=h.memo(function({onLogin:s}){const[t,n]=h.useState(""),[r,i]=h.useState(""),[o,l]=h.useState(!1),c=async d=>{if(d.preventDefault(),!!t.trim()){l(!0),i("");try{const u=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:"admin",password:t})});if(u.ok){const m=await u.json();s(m.token)}else i("Invalid token — check your cascade dashboard config.")}catch{i("Cannot reach server. Is the dashboard running?")}finally{l(!1)}}};return a.jsxs("div",{className:"relative flex items-center justify-center w-full h-full bg-[var(--bg-base)] dot-grid overflow-hidden",children:[a.jsx("div",{className:"absolute top-[20%] left-[30%] w-[480px] h-[480px] rounded-full bg-[var(--accent)] opacity-[0.035] blur-[140px] pointer-events-none"}),a.jsx("div",{className:"absolute bottom-[20%] right-[25%] w-[320px] h-[320px] rounded-full bg-[var(--t3-color)] opacity-[0.03] blur-[120px] pointer-events-none"}),a.jsxs("form",{onSubmit:c,"aria-label":"Cascade AI login",className:`\r
|
|
18
|
+
relative z-10 w-full max-w-[360px]\r
|
|
19
|
+
glass-elevated rounded-[var(--radius-lg)]\r
|
|
20
|
+
p-8 shadow-dialog animate-fade-in-up\r
|
|
21
|
+
`,children:[a.jsxs("div",{className:"flex items-center gap-3 mb-8",children:[a.jsx("div",{className:`\r
|
|
22
|
+
w-9 h-9 rounded-[var(--radius-sm)] bg-[var(--accent)]\r
|
|
23
|
+
flex items-center justify-center flex-shrink-0\r
|
|
24
|
+
shadow-[var(--shadow-glow-violet)]\r
|
|
25
|
+
`,children:a.jsx("span",{className:"text-white font-black text-[14px] font-mono",children:"C"})}),a.jsxs("div",{children:[a.jsx("h1",{className:"text-[15px] font-bold text-[var(--text-primary)] tracking-tight",children:"Cascade AI"}),a.jsx("p",{className:"section-label mt-0.5",children:"Dashboard"})]})]}),a.jsxs("div",{className:"mb-5",children:[a.jsx("label",{htmlFor:"token-input",className:"block section-label mb-2",children:"Access Token"}),a.jsx("input",{id:"token-input",type:"password",className:"input",placeholder:"paste your token here",value:t,onChange:d=>n(d.target.value),autoComplete:"current-password",autoFocus:!0}),r&&a.jsx("p",{role:"alert",className:"text-[11px] text-[var(--error)] mt-2 font-mono",children:r})]}),a.jsx("button",{type:"submit",disabled:o||!t.trim(),className:"btn btn-primary w-full justify-center py-2.5",children:o?a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"w-3 h-3 rounded-full border border-white/40 border-t-white animate-spin"}),"Connecting…"]}):"Connect"}),a.jsxs("p",{className:"text-center text-[10px] text-[var(--text-faint)] mt-5 font-mono",children:["No token?"," ",a.jsx("code",{className:"text-[var(--text-muted)]",children:"dashboard.auth: false"})]})]})]})});/**
|
|
26
|
+
* @license lucide-react v0.460.0 - ISC
|
|
27
|
+
*
|
|
28
|
+
* This source code is licensed under the ISC license.
|
|
29
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
30
|
+
*/const $r=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ms=(...e)=>e.filter((s,t,n)=>!!s&&s.trim()!==""&&n.indexOf(s)===t).join(" ").trim();/**
|
|
31
|
+
* @license lucide-react v0.460.0 - ISC
|
|
32
|
+
*
|
|
33
|
+
* This source code is licensed under the ISC license.
|
|
34
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
35
|
+
*/var Ur={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
36
|
+
* @license lucide-react v0.460.0 - ISC
|
|
37
|
+
*
|
|
38
|
+
* This source code is licensed under the ISC license.
|
|
39
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
40
|
+
*/const Br=h.forwardRef(({color:e="currentColor",size:s=24,strokeWidth:t=2,absoluteStrokeWidth:n,className:r="",children:i,iconNode:o,...l},c)=>h.createElement("svg",{ref:c,...Ur,width:s,height:s,stroke:e,strokeWidth:n?Number(t)*24/Number(s):t,className:ms("lucide",r),...l},[...o.map(([d,u])=>h.createElement(d,u)),...Array.isArray(i)?i:[i]]));/**
|
|
41
|
+
* @license lucide-react v0.460.0 - ISC
|
|
42
|
+
*
|
|
43
|
+
* This source code is licensed under the ISC license.
|
|
44
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
45
|
+
*/const A=(e,s)=>{const t=h.forwardRef(({className:n,...r},i)=>h.createElement(Br,{ref:i,iconNode:s,className:ms(`lucide-${$r(e)}`,n),...r}));return t.displayName=`${e}`,t};/**
|
|
46
|
+
* @license lucide-react v0.460.0 - ISC
|
|
47
|
+
*
|
|
48
|
+
* This source code is licensed under the ISC license.
|
|
49
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
50
|
+
*/const ps=A("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/**
|
|
51
|
+
* @license lucide-react v0.460.0 - ISC
|
|
52
|
+
*
|
|
53
|
+
* This source code is licensed under the ISC license.
|
|
54
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
55
|
+
*/const Vr=A("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
|
|
56
|
+
* @license lucide-react v0.460.0 - ISC
|
|
57
|
+
*
|
|
58
|
+
* This source code is licensed under the ISC license.
|
|
59
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
60
|
+
*/const Wr=A("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
|
|
61
|
+
* @license lucide-react v0.460.0 - ISC
|
|
62
|
+
*
|
|
63
|
+
* This source code is licensed under the ISC license.
|
|
64
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
65
|
+
*/const xs=A("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
|
|
66
|
+
* @license lucide-react v0.460.0 - ISC
|
|
67
|
+
*
|
|
68
|
+
* This source code is licensed under the ISC license.
|
|
69
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
70
|
+
*/const It=A("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);/**
|
|
71
|
+
* @license lucide-react v0.460.0 - ISC
|
|
72
|
+
*
|
|
73
|
+
* This source code is licensed under the ISC license.
|
|
74
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
75
|
+
*/const Hr=A("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
|
|
76
|
+
* @license lucide-react v0.460.0 - ISC
|
|
77
|
+
*
|
|
78
|
+
* This source code is licensed under the ISC license.
|
|
79
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
80
|
+
*/const qr=A("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/**
|
|
81
|
+
* @license lucide-react v0.460.0 - ISC
|
|
82
|
+
*
|
|
83
|
+
* This source code is licensed under the ISC license.
|
|
84
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
85
|
+
*/const Kr=A("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);/**
|
|
86
|
+
* @license lucide-react v0.460.0 - ISC
|
|
87
|
+
*
|
|
88
|
+
* This source code is licensed under the ISC license.
|
|
89
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
90
|
+
*/const Gr=A("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
|
|
91
|
+
* @license lucide-react v0.460.0 - ISC
|
|
92
|
+
*
|
|
93
|
+
* This source code is licensed under the ISC license.
|
|
94
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
95
|
+
*/const Jr=A("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);/**
|
|
96
|
+
* @license lucide-react v0.460.0 - ISC
|
|
97
|
+
*
|
|
98
|
+
* This source code is licensed under the ISC license.
|
|
99
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
100
|
+
*/const Xr=A("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
|
|
101
|
+
* @license lucide-react v0.460.0 - ISC
|
|
102
|
+
*
|
|
103
|
+
* This source code is licensed under the ISC license.
|
|
104
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
105
|
+
*/const Yr=A("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/**
|
|
106
|
+
* @license lucide-react v0.460.0 - ISC
|
|
107
|
+
*
|
|
108
|
+
* This source code is licensed under the ISC license.
|
|
109
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
110
|
+
*/const At=A("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
|
|
111
|
+
* @license lucide-react v0.460.0 - ISC
|
|
112
|
+
*
|
|
113
|
+
* This source code is licensed under the ISC license.
|
|
114
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
115
|
+
*/const Mt=A("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
|
|
116
|
+
* @license lucide-react v0.460.0 - ISC
|
|
117
|
+
*
|
|
118
|
+
* This source code is licensed under the ISC license.
|
|
119
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
120
|
+
*/const Zr=A("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
|
|
121
|
+
* @license lucide-react v0.460.0 - ISC
|
|
122
|
+
*
|
|
123
|
+
* This source code is licensed under the ISC license.
|
|
124
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
125
|
+
*/const Qr=A("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),ei=[{id:"topology",icon:Jr,label:"Agent Topology"},{id:"sessions",icon:Kr,label:"Sessions"},{id:"logs",icon:Hr,label:"Telemetry"},{id:"settings",icon:Xr,label:"Settings"}];function Tt({label:e}){return a.jsx("div",{role:"tooltip",className:`\r
|
|
126
|
+
absolute left-full ml-3 px-2.5 py-1.5\r
|
|
127
|
+
text-[10px] font-medium font-mono text-[var(--text-primary)]\r
|
|
128
|
+
bg-[var(--bg-overlay)] border border-[var(--border-strong)]\r
|
|
129
|
+
rounded-[var(--radius-sm)] whitespace-nowrap pointer-events-none\r
|
|
130
|
+
opacity-0 group-hover:opacity-100\r
|
|
131
|
+
translate-x-[-4px] group-hover:translate-x-0\r
|
|
132
|
+
transition-all duration-150 z-50\r
|
|
133
|
+
shadow-[var(--shadow-panel)]\r
|
|
134
|
+
`,children:e})}const ti=h.memo(function({activeTab:s,onTabChange:t,onLogout:n}){return a.jsxs("nav",{"aria-label":"Main navigation",className:`\r
|
|
135
|
+
flex flex-col items-center py-5 gap-1\r
|
|
136
|
+
w-[56px] flex-shrink-0 h-full z-20\r
|
|
137
|
+
bg-[var(--bg-surface)]\r
|
|
138
|
+
border-r border-[var(--border-subtle)]\r
|
|
139
|
+
`,children:[a.jsx("div",{className:`\r
|
|
140
|
+
mb-4 w-8 h-8 rounded-[var(--radius-sm)]\r
|
|
141
|
+
bg-[var(--accent)] flex items-center justify-center\r
|
|
142
|
+
shadow-[var(--shadow-glow-violet)] select-none\r
|
|
143
|
+
`,children:a.jsx("span",{className:"text-white font-black text-[13px] font-mono tracking-tighter",children:"C"})}),a.jsx("div",{className:"divider w-8 mb-2"}),a.jsx("div",{className:"flex flex-col gap-0.5 flex-1 w-full px-1.5",children:ei.map(({id:r,icon:i,label:o})=>{const l=s===r;return a.jsxs("div",{className:"relative group",children:[a.jsx("button",{id:`nav-${r}`,"aria-label":o,"aria-current":l?"page":void 0,onClick:()=>t(r),className:`nav-rail-btn w-full ${l?"active":""}`,children:a.jsx(i,{size:17,strokeWidth:l?2:1.75})}),a.jsx(Tt,{label:o})]},r)})}),a.jsxs("div",{className:"relative group px-1.5 w-full",children:[a.jsx("button",{"aria-label":"Log out",onClick:n,className:"nav-rail-btn w-full text-[var(--text-faint)] hover:text-[var(--error)]",children:a.jsx(Gr,{size:15,strokeWidth:1.75})}),a.jsx(Tt,{label:"Log out"})]})]})});function si(e){const[s,t]=h.useState(null);return h.useEffect(()=>{if(!e){t(null);return}let n=!1;const r=async()=>{const o=Date.now();try{await fetch("/api/ping",{cache:"no-store"}),n||t(Date.now()-o)}catch{n||t(null)}};r();const i=setInterval(r,5e3);return()=>{n=!0,clearInterval(i)}},[e]),s}function ni(e){const[s,t]=h.useState("");return h.useEffect(()=>{if(!e){t("");return}const n=()=>{const i=Date.now()-new Date(e).getTime(),o=Math.floor(i/36e5).toString().padStart(2,"0"),l=Math.floor(i%36e5/6e4).toString().padStart(2,"0"),c=Math.floor(i%6e4/1e3).toString().padStart(2,"0");t(`${o}:${l}:${c}`)};n();const r=setInterval(n,1e3);return()=>clearInterval(r)},[e]),s}function ue({label:e,value:s,highlight:t}){return a.jsxs("div",{className:"metric-chip",children:[a.jsx("span",{className:"label",children:e}),a.jsx("span",{className:`value ${t?"text-[var(--warning)]":""}`,children:s})]})}const ri=h.memo(function({isConnected:s,totalCostUsd:t,totalTokens:n}){const r=U(st),i=si(s),o=ni(r==null?void 0:r.startedAt);return a.jsxs("header",{"aria-label":"Dashboard header",className:`\r
|
|
144
|
+
flex items-center justify-between px-5 h-11\r
|
|
145
|
+
border-b border-[var(--border-subtle)]\r
|
|
146
|
+
bg-[var(--bg-surface)] flex-shrink-0 z-10\r
|
|
147
|
+
`,children:[a.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx("span",{"aria-label":s?"Connected":"Disconnected",className:`
|
|
148
|
+
w-1.5 h-1.5 rounded-full transition-all duration-500
|
|
149
|
+
${s?"bg-[var(--success)] shadow-[var(--shadow-glow-green)]":"bg-[var(--text-faint)]"}
|
|
150
|
+
`}),a.jsx("span",{className:"section-label",children:s?"Live":"Offline"})]}),r&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"divider-v h-4 flex-shrink-0"}),a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("span",{className:"text-[12px] font-medium text-[var(--text-primary)] truncate max-w-[200px]",children:r.title||"Untitled Session"}),a.jsx("span",{className:`badge badge-${r.status} flex-shrink-0`,children:r.status})]})]})]}),a.jsxs("div",{className:"flex items-center gap-5",children:[i!==null&&a.jsx(ue,{label:"Ping",value:`${i}ms`}),o&&a.jsx(ue,{label:"Uptime",value:o}),a.jsx("div",{className:"divider-v h-4"}),a.jsx(ue,{label:"Tokens",value:n>=1e3?`${(n/1e3).toFixed(1)}k`:n.toLocaleString()}),a.jsx(ue,{label:"Cost",value:`$${t.toFixed(4)}`,highlight:t>1})]})]})}),Le={T1:"var(--t1-color)",T2:"var(--t2-color)",T3:"var(--t3-color)"},Ot={ACTIVE:"border-[var(--t3-color)] agent-node-ACTIVE",COMPLETED:"border-[var(--success)] agent-node-COMPLETED",FAILED:"border-[var(--error)] agent-node-FAILED",ESCALATED:"border-[var(--warning)] agent-node-ESCALATED",IDLE:"border-[var(--border-subtle)]"},ii=h.memo(function({data:s,selected:t}){const n=Ot[s.status]??Ot.IDLE;return a.jsxs("div",{"aria-label":`${s.role} agent: ${s.label}, status: ${s.status}`,className:`
|
|
151
|
+
relative px-3.5 py-3 glass min-w-[170px] max-w-[210px]
|
|
152
|
+
rounded-[var(--radius-md)] border transition-all duration-300
|
|
153
|
+
${n}
|
|
154
|
+
${t?"ring-2 ring-[var(--accent)] ring-offset-2 ring-offset-[var(--bg-base)]":""}
|
|
155
|
+
`,children:[a.jsx(rt,{type:"target",position:it.Top,className:"!w-1.5 !h-1.5 !bg-[var(--border-strong)] !border-none !top-[-4px]"}),a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"badge",style:{color:Le[s.role],background:`color-mix(in srgb, ${Le[s.role]} 10%, transparent)`,borderColor:`color-mix(in srgb, ${Le[s.role]} 22%, transparent)`},children:s.role}),a.jsxs("div",{className:"flex items-center gap-1",children:[s.status==="ACTIVE"&&a.jsx("div",{className:"flex gap-[2px] items-center","aria-label":"Active",children:[0,100,200].map(r=>a.jsx("span",{className:"w-1 h-1 rounded-full bg-[var(--t3-color)]",style:{animation:`pulse-glow 1.4s ease-in-out ${r}ms infinite`}},r))}),s.status==="COMPLETED"&&a.jsx("span",{className:"text-[var(--success)] text-[10px] font-mono",children:"✓"}),s.status==="FAILED"&&a.jsx("span",{className:"text-[var(--error)] text-[10px] font-mono",children:"✗"}),s.status==="ESCALATED"&&a.jsx("span",{className:"text-[var(--warning)] text-[10px]",children:"⚠"})]})]}),a.jsx("p",{className:"text-[11px] font-semibold text-[var(--text-primary)] truncate leading-snug mb-0.5",children:s.label}),s.action&&a.jsx("p",{className:"text-[9px] text-[var(--text-muted)] truncate leading-snug font-mono",children:s.action}),s.progressPct!==void 0&&s.status==="ACTIVE"&&a.jsx("div",{className:"progress-track mt-2.5",children:a.jsx("div",{className:"progress-fill",style:{width:`${s.progressPct}%`}})}),a.jsx(rt,{type:"source",position:it.Bottom,className:"!w-1.5 !h-1.5 !bg-[var(--border-strong)] !border-none !bottom-[-4px]"})]})}),ai={agent:ii};function oi(){return a.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-5 animate-fade-in select-none",children:[a.jsxs("div",{className:"relative w-16 h-16",children:[[0,1,2].map(e=>a.jsx("div",{className:"absolute inset-0 rounded-full border border-[var(--accent)]",style:{opacity:.12+e*.08,animation:`orbit ${3.5+e*.8}s linear infinite`,animationDelay:`${e*-1.2}s`}},e)),a.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-2xl",children:"⬡"})]}),a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-[13px] font-medium text-[var(--text-primary)]",children:"No active agents"}),a.jsx("p",{className:"text-[11px] text-[var(--text-muted)] mt-1",children:"Start a task to see the agent topology"})]})]})}const li=h.memo(function({nodes:s,edges:t,selectedNodeId:n,onSelectNode:r}){const i=h.useMemo(()=>{if(!s.length)return[];const c={T1:[],T2:[],T3:[]};s.forEach(p=>{var f;return(f=c[p.role])==null?void 0:f.push(p)});const d={T1:40,T2:210,T3:380},u=250,m=500;return s.map(p=>{const f=c[p.role],g=f.findIndex(b=>b.id===p.id),y=f.length,v=m-(y-1)*u/2+g*u,x=d[p.role]??40;return{id:p.id,type:"agent",position:{x:v,y:x},selected:n===p.id,data:{role:p.role,label:p.label,status:p.status,action:p.action,progressPct:p.progressPct}}})},[s,n]),o=h.useMemo(()=>t.map((c,d)=>({id:`e${d}`,source:c.from,target:c.to,animated:!0,style:{stroke:"rgba(124,106,247,0.28)",strokeWidth:1.5},markerEnd:{type:js.ArrowClosed,color:"rgba(124,106,247,0.45)",width:10,height:10}})),[t]),l=h.useCallback((c,d)=>{r(d.id===n?null:d.id)},[r,n]);return s.length?a.jsxs("div",{className:"w-full h-full relative","aria-label":"Agent topology graph",role:"img",children:[a.jsxs(_s,{nodes:i,edges:o,nodeTypes:ai,onNodeClick:l,onPaneClick:()=>r(null),fitView:!0,fitViewOptions:{padding:.18,maxZoom:1.2},minZoom:.25,maxZoom:2.5,proOptions:{hideAttribution:!0},children:[a.jsx(Ss,{variant:Ns.Dots,color:"rgba(255,255,255,0.03)",gap:24,size:1}),a.jsx(ks,{showInteractive:!1,"aria-label":"Graph controls"})]}),a.jsx("div",{className:"absolute inset-x-0 top-0 h-14 bg-gradient-to-b from-[var(--bg-base)] to-transparent pointer-events-none"}),a.jsx("div",{className:"absolute inset-x-0 bottom-0 h-14 bg-gradient-to-t from-[var(--bg-base)] to-transparent pointer-events-none"})]}):a.jsx(oi,{})});function ci({pct:e}){return a.jsx("div",{className:"progress-track",children:a.jsx("div",{className:"progress-fill",style:{width:`${Math.min(Math.max(e,0),100)}%`}})})}function Fe({icon:e,label:s,children:t}){return a.jsxs("div",{className:"px-4 py-3 border-b border-[var(--border-subtle)]",children:[a.jsxs("p",{className:"section-label flex items-center gap-1.5 mb-1.5",children:[a.jsx(e,{size:9}),s]}),t]})}const di=h.memo(function({node:s,streamLog:t,onClose:n}){const r=h.useRef(null);return h.useEffect(()=>{r.current&&(r.current.scrollTop=r.current.scrollHeight)},[t]),h.useEffect(()=>{const i=o=>{o.key==="Escape"&&n()};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[n]),a.jsxs("aside",{role:"complementary","aria-label":"Agent inspector",className:`\r
|
|
156
|
+
flex flex-col w-[300px] flex-shrink-0 h-full\r
|
|
157
|
+
border-l border-[var(--border-subtle)]\r
|
|
158
|
+
bg-[var(--bg-surface)] animate-slide-in overflow-hidden\r
|
|
159
|
+
`,children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-[var(--border-subtle)] flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(It,{size:13,className:"text-[var(--accent)]"}),a.jsx("span",{className:"section-label",children:"Inspector"})]}),a.jsx("button",{"aria-label":"Close inspector",onClick:n,className:`\r
|
|
160
|
+
w-6 h-6 rounded-[var(--radius-xs)] flex items-center justify-center\r
|
|
161
|
+
text-[var(--text-faint)] hover:text-[var(--text-primary)]\r
|
|
162
|
+
hover:bg-[var(--bg-elevated)] transition-all\r
|
|
163
|
+
`,children:a.jsx(Qr,{size:13})})]}),s?a.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[a.jsxs("div",{className:"px-4 py-4 border-b border-[var(--border-subtle)]",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx("span",{className:`badge badge-${s.role}`,children:s.role}),a.jsx("span",{className:`badge badge-${s.status}`,children:s.status})]}),a.jsx("h2",{className:"text-[12px] font-semibold text-[var(--text-primary)] leading-snug",children:s.label}),a.jsx("p",{className:"text-[9px] text-[var(--text-muted)] font-mono mt-1 break-all opacity-60",children:s.tierId})]}),s.progressPct!==void 0&&a.jsxs(Fe,{icon:ps,label:"Progress",children:[a.jsx("div",{className:"flex items-center justify-between mb-1.5",children:a.jsxs("span",{className:"text-[10px] font-mono text-[var(--text-primary)]",children:[s.progressPct,"%"]})}),a.jsx(ci,{pct:s.progressPct})]}),s.currentAction&&a.jsx(Fe,{icon:Wr,label:"Current action",children:a.jsx("p",{className:"text-[11px] text-[var(--text-primary)] leading-snug",children:s.currentAction})}),a.jsx(Fe,{icon:xs,label:"Last update",children:a.jsx("p",{className:"text-[10px] font-mono text-[var(--text-muted)]",children:new Date(s.updatedAt).toLocaleTimeString()})}),a.jsxs("div",{className:"flex flex-col flex-1 min-h-0 px-3 py-3",children:[a.jsx("p",{className:"section-label mb-2 flex-shrink-0",children:"Live output"}),a.jsx("div",{ref:r,className:`\r
|
|
164
|
+
flex-1 overflow-y-auto font-mono text-[9.5px]\r
|
|
165
|
+
text-[var(--t3-color)] leading-[1.7]\r
|
|
166
|
+
whitespace-pre-wrap break-words\r
|
|
167
|
+
bg-[var(--bg-base)] rounded-[var(--radius-xs)]\r
|
|
168
|
+
p-2.5 border border-[var(--border-subtle)]\r
|
|
169
|
+
scrollbar-thin\r
|
|
170
|
+
`,"aria-live":"polite","aria-label":"Live token stream",children:t?a.jsxs("span",{children:[t.slice(-4e3),a.jsx("span",{className:"animate-blink text-[var(--t3-color)]",children:"█"})]}):a.jsx("span",{className:"text-[var(--text-faint)] italic",children:"Waiting for output…"})})]})]}):a.jsxs("div",{className:"flex flex-col items-center justify-center flex-1 gap-3 text-center p-6",children:[a.jsx("div",{className:"w-9 h-9 rounded-full bg-[var(--bg-elevated)] flex items-center justify-center",children:a.jsx(It,{size:16,className:"text-[var(--text-faint)]"})}),a.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:"Select an agent node to inspect it"})]})]})});function $e({icon:e,tier:s,label:t,isLast:n=!1}){return a.jsxs("div",{className:`flex items-start gap-3 py-2.5 ${n?"":"border-b border-[var(--border-subtle)]"}`,children:[a.jsx("div",{className:`\r
|
|
171
|
+
flex-shrink-0 w-6 h-6 rounded-full\r
|
|
172
|
+
bg-[var(--bg-overlay)] border border-[var(--border-subtle)]\r
|
|
173
|
+
flex items-center justify-center text-[11px] mt-0.5\r
|
|
174
|
+
`,children:e}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[a.jsx("span",{className:`badge badge-${s}`,children:s}),a.jsx("span",{className:"text-[10px] text-[var(--text-muted)] truncate",children:t})]}),a.jsx("p",{className:"text-[9px] font-mono text-[var(--warning)]",children:"⚠ Uncertain — escalated upward"})]}),a.jsx(Vr,{size:10,className:"text-[var(--text-faint)] mt-1.5 flex-shrink-0"})]})}const ui=h.memo(function({request:s,onDecide:t}){h.useEffect(()=>{const o=l=>{l.key==="y"&&t(!0,!1),l.key==="n"&&t(!1,!1)};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[t]);const n=h.useCallback(o=>t(!0,o),[t]),r=h.useCallback(o=>t(!1,o),[t]),i=s.input.path??s.input.command??JSON.stringify(s.input).slice(0,60);return a.jsx("div",{className:"fixed inset-0 bg-black/65 backdrop-blur-[6px] z-50 flex items-center justify-center p-4 animate-fade-in",role:"dialog","aria-modal":"true","aria-labelledby":"escalation-title",children:a.jsxs("div",{className:"w-full max-w-[460px] glass-elevated rounded-[var(--radius-lg)] shadow-dialog animate-fade-in-up",onClick:o=>o.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center gap-3 px-5 pt-5 pb-4 border-b border-[var(--border-subtle)]",children:[a.jsx("div",{className:`\r
|
|
175
|
+
w-9 h-9 rounded-[var(--radius-sm)] flex-shrink-0\r
|
|
176
|
+
bg-[rgba(245,166,35,0.1)] border border-[rgba(245,166,35,0.22)]\r
|
|
177
|
+
flex items-center justify-center\r
|
|
178
|
+
`,children:a.jsx(Yr,{size:18,className:"text-[var(--warning)]"})}),a.jsxs("div",{children:[a.jsx("h2",{id:"escalation-title",className:"text-[13px] font-bold text-[var(--text-primary)]",children:"Permission required"}),a.jsx("p",{className:"text-[10px] text-[var(--text-muted)] font-mono mt-0.5",children:"No tier could determine if this action is safe"})]})]}),a.jsxs("div",{className:"px-5 py-4 border-b border-[var(--border-subtle)]",children:[a.jsx("p",{className:"section-label mb-2",children:"Requested action"}),a.jsxs("div",{className:`\r
|
|
179
|
+
flex items-center gap-2\r
|
|
180
|
+
bg-[var(--bg-base)] rounded-[var(--radius-xs)]\r
|
|
181
|
+
border border-[var(--border-subtle)] px-3 py-2\r
|
|
182
|
+
`,children:[a.jsx("code",{className:"text-[var(--accent)] font-mono font-bold text-[11px] flex-shrink-0",children:s.toolName}),i&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-faint)] text-[11px]",children:"→"}),a.jsx("code",{className:"text-[var(--text-muted)] font-mono text-[10px] truncate flex-1 min-w-0",children:i})]}),s.isDangerous&&a.jsx("span",{className:"ml-auto badge badge-FAILED flex-shrink-0",children:"Dangerous"})]})]}),a.jsxs("div",{className:"px-5 py-4 border-b border-[var(--border-subtle)]",children:[a.jsx("p",{className:"section-label mb-2",children:"Escalation trail"}),a.jsx($e,{icon:"🔹",tier:"T3",label:`"${s.subtaskContext}" requested this`}),a.jsx($e,{icon:"🟣",tier:"T2",label:`Section "${s.sectionContext}" evaluated — uncertain`}),a.jsx($e,{icon:"🟡",tier:"T1",label:"Full task context evaluated — uncertain",isLast:!0}),a.jsxs("div",{className:"flex items-center gap-3 pt-3",children:[a.jsx("div",{className:"w-6 h-6 rounded-full bg-[var(--accent)] flex items-center justify-center flex-shrink-0",children:a.jsx("span",{className:"text-white text-[10px] font-bold",children:"?"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-[11px] font-semibold text-[var(--text-primary)]",children:"Your decision required"}),a.jsxs("p",{className:"text-[9px] font-mono text-[var(--text-muted)] mt-0.5",children:["Press"," ",a.jsx("kbd",{className:"px-1 py-0.5 rounded-[3px] bg-[var(--bg-overlay)] border border-[var(--border-strong)] font-mono text-[8px]",children:"Y"})," ","to approve,"," ",a.jsx("kbd",{className:"px-1 py-0.5 rounded-[3px] bg-[var(--bg-overlay)] border border-[var(--border-strong)] font-mono text-[8px]",children:"N"})," ","to deny"]})]})]})]}),a.jsxs("div",{className:"px-5 py-4",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[a.jsx("button",{className:"btn btn-danger justify-center",onClick:()=>r(!1),children:"Deny once"}),a.jsx("button",{className:"btn btn-success justify-center",onClick:()=>n(!1),children:"Approve once"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsx("button",{className:"btn btn-ghost justify-center",onClick:()=>r(!0),children:"Always deny"}),a.jsx("button",{className:"btn btn-ghost justify-center",onClick:()=>n(!0),children:"Always approve"})]})]})]})})});function fi(e){const s=Date.now()-new Date(e).getTime();return s<6e4?"just now":s<36e5?`${Math.floor(s/6e4)}m ago`:s<864e5?`${Math.floor(s/36e5)}h ago`:new Date(e).toLocaleDateString()}function hi(e,s){const t=new Date(s).getTime()-new Date(e).getTime();return t<1e3?"<1s":t<6e4?`${Math.round(t/1e3)}s`:`${Math.round(t/6e4)}m`}const mi=h.memo(function(){const s=Ae(),t=U(jr),n=U(st),[r,i]=h.useState(new Set),[o,l]=h.useState(null),[c,d]=h.useState(!1),u=h.useCallback(x=>{r.size===0&&s(vr(x))},[s,r.size]),m=h.useCallback((x,b,_)=>{_.stopPropagation(),i(w=>{var N;const j=new Set(w);if(_.shiftKey&&o!==null){const[C,I]=[Math.min(o,b),Math.max(o,b)];for(let S=C;S<=I;S++){const T=(N=t[S])==null?void 0:N.sessionId;T&&j.add(T)}}else j.has(x)?j.delete(x):j.add(x);return j}),l(b)},[o,t]),p=h.useCallback(()=>{r.size===t.length?i(new Set):i(new Set(t.map(x=>x.sessionId)))},[r.size,t]),f=h.useCallback(async()=>{if(!(r.size===0||c)){d(!0);try{const x=Array.from(r);(await fetch("/api/sessions",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:x})})).ok&&(s(wr(x)),i(new Set),l(null))}finally{d(!1)}}},[r,c,s]),g=h.useCallback(()=>{i(new Set),l(null)},[]);if(!t.length)return a.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 animate-fade-in",children:[a.jsx("div",{className:"w-11 h-11 rounded-full bg-[var(--bg-elevated)] flex items-center justify-center",children:a.jsx(ps,{size:18,className:"text-[var(--text-faint)]"})}),a.jsx("p",{className:"text-[12px] text-[var(--text-muted)]",children:"No sessions yet"}),a.jsx("p",{className:"text-[10px] font-mono text-[var(--text-faint)]",children:"Run a task to create the first session"})]});const y=r.size===t.length,v=r.size>0;return a.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[a.jsx("div",{className:"px-5 py-4 border-b border-[var(--border-subtle)] flex-shrink-0 bg-[var(--bg-surface)]",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"section-label",children:"Sessions"}),a.jsxs("p",{className:"text-[10px] font-mono text-[var(--text-faint)] mt-1",children:[t.length," session",t.length!==1?"s":"",v&&a.jsxs("span",{className:"text-[var(--accent)] ml-2",children:["· ",r.size," selected"]})]})]}),a.jsx("button",{onClick:p,title:y?"Deselect all":"Select all",className:"p-1.5 rounded hover:bg-[var(--bg-elevated)] transition-colors",children:y?a.jsx(At,{size:14,className:"text-[var(--accent)]"}):a.jsx(Mt,{size:14,className:"text-[var(--text-faint)]"})})]})}),a.jsx("div",{className:"flex-1 overflow-y-auto",children:t.map((x,b)=>{const _=x.sessionId===(n==null?void 0:n.sessionId),w=r.has(x.sessionId);return a.jsxs("button",{"aria-selected":_,"aria-label":`Session: ${x.title}, status: ${x.status}`,onClick:()=>u(x.sessionId),className:`
|
|
183
|
+
w-full text-left px-5 py-3.5
|
|
184
|
+
border-b border-[var(--border-subtle)]
|
|
185
|
+
transition-all duration-150 relative
|
|
186
|
+
animate-slide-up
|
|
187
|
+
`,style:{animationDelay:`${b*25}ms`,background:w?"rgba(124,106,247,0.08)":_?"rgba(124,106,247,0.05)":void 0,borderLeft:w||_?"2px solid var(--accent)":"2px solid transparent",paddingLeft:_||w?"18px":"20px"},children:[a.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("span",{role:"checkbox","aria-checked":w,onClick:j=>m(x.sessionId,b,j),className:"flex-shrink-0 cursor-pointer",children:w?a.jsx(At,{size:12,className:"text-[var(--accent)]"}):a.jsx(Mt,{size:12,className:"text-[var(--text-faint)] opacity-40 hover:opacity-100 transition-opacity"})}),a.jsx("span",{className:"text-[12px] font-semibold text-[var(--text-primary)] truncate",children:x.title||"Untitled Session"})]}),a.jsx("span",{className:`badge badge-${x.status} flex-shrink-0`,children:x.status})]}),x.workspacePath&&a.jsxs("div",{className:"flex items-center gap-1.5 mb-1 pl-5",children:[a.jsx(qr,{size:9,className:"text-[var(--text-faint)] flex-shrink-0"}),a.jsx("span",{className:"text-[9px] font-mono text-[var(--text-faint)] truncate",children:x.workspacePath.split("/").pop()})]}),x.latestPrompt&&a.jsxs("p",{className:"text-[10px] text-[var(--text-muted)] truncate mb-1.5 italic pl-5",children:['"',x.latestPrompt,'"']}),a.jsxs("div",{className:"flex items-center gap-3 pl-5",children:[a.jsxs("span",{className:"flex items-center gap-1 text-[9px] font-mono text-[var(--text-faint)]",children:[a.jsx(xs,{size:8}),fi(x.updatedAt)]}),a.jsx("span",{className:"text-[9px] font-mono text-[var(--text-faint)]",children:hi(x.startedAt,x.updatedAt)})]})]},x.sessionId)})}),v&&a.jsxs("div",{className:`
|
|
188
|
+
absolute bottom-4 left-1/2 -translate-x-1/2
|
|
189
|
+
flex items-center gap-3 px-4 py-2.5 rounded-xl
|
|
190
|
+
bg-[var(--bg-elevated)] border border-[var(--border-subtle)]
|
|
191
|
+
shadow-lg z-10 animate-slide-up
|
|
192
|
+
`,children:[a.jsxs("span",{className:"text-[11px] font-mono text-[var(--text-muted)]",children:[r.size," selected"]}),a.jsxs("button",{onClick:f,disabled:c,className:`
|
|
193
|
+
flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-medium
|
|
194
|
+
bg-red-500/10 text-red-400 border border-red-500/20
|
|
195
|
+
hover:bg-red-500/20 transition-colors disabled:opacity-50
|
|
196
|
+
`,children:[a.jsx(Zr,{size:12}),c?"Deleting...":`Delete ${r.size}`]}),a.jsx("button",{onClick:g,className:"text-[11px] text-[var(--text-faint)] hover:text-[var(--text-muted)] transition-colors",children:"Cancel"})]})]})});function V(e,s,t){let n=t.initialDeps??[],r,i=!0;function o(){var l,c,d;let u;t.key&&((l=t.debug)!=null&&l.call(t))&&(u=Date.now());const m=e();if(!(m.length!==n.length||m.some((g,y)=>n[y]!==g)))return r;n=m;let f;if(t.key&&((c=t.debug)!=null&&c.call(t))&&(f=Date.now()),r=s(...m),t.key&&((d=t.debug)!=null&&d.call(t))){const g=Math.round((Date.now()-u)*100)/100,y=Math.round((Date.now()-f)*100)/100,v=y/16,x=(b,_)=>{for(b=String(b);b.length<_;)b=" "+b;return b};console.info(`%c⏱ ${x(y,5)} /${x(g,5)} ms`,`
|
|
197
|
+
font-size: .6rem;
|
|
198
|
+
font-weight: bold;
|
|
199
|
+
color: hsl(${Math.max(0,Math.min(120-120*v,120))}deg 100% 31%);`,t==null?void 0:t.key)}return t!=null&&t.onChange&&!(i&&t.skipInitialOnChange)&&t.onChange(r),i=!1,r}return o.updateDeps=l=>{n=l},o}function Rt(e,s){if(e===void 0)throw new Error("Unexpected undefined");return e}const pi=(e,s)=>Math.abs(e-s)<1.01,xi=(e,s,t)=>{let n;return function(...r){e.clearTimeout(n),n=e.setTimeout(()=>s.apply(this,r),t)}},Dt=e=>{const{offsetWidth:s,offsetHeight:t}=e;return{width:s,height:t}},gi=e=>e,vi=e=>{const s=Math.max(e.startIndex-e.overscan,0),t=Math.min(e.endIndex+e.overscan,e.count-1),n=[];for(let r=s;r<=t;r++)n.push(r);return n},bi=(e,s)=>{const t=e.scrollElement;if(!t)return;const n=e.targetWindow;if(!n)return;const r=o=>{const{width:l,height:c}=o;s({width:Math.round(l),height:Math.round(c)})};if(r(Dt(t)),!n.ResizeObserver)return()=>{};const i=new n.ResizeObserver(o=>{const l=()=>{const c=o[0];if(c!=null&&c.borderBoxSize){const d=c.borderBoxSize[0];if(d){r({width:d.inlineSize,height:d.blockSize});return}}r(Dt(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},zt={passive:!0},Pt=typeof window>"u"?!0:"onscrollend"in window,yi=(e,s)=>{const t=e.scrollElement;if(!t)return;const n=e.targetWindow;if(!n)return;let r=0;const i=e.options.useScrollendEvent&&Pt?()=>{}:xi(n,()=>{s(r,!1)},e.options.isScrollingResetDelay),o=u=>()=>{const{horizontal:m,isRtl:p}=e.options;r=m?t.scrollLeft*(p&&-1||1):t.scrollTop,i(),s(r,u)},l=o(!0),c=o(!1);t.addEventListener("scroll",l,zt);const d=e.options.useScrollendEvent&&Pt;return d&&t.addEventListener("scrollend",c,zt),()=>{t.removeEventListener("scroll",l),d&&t.removeEventListener("scrollend",c)}},wi=(e,s,t)=>{if(s!=null&&s.borderBoxSize){const n=s.borderBoxSize[0];if(n)return Math.round(n[t.options.horizontal?"inlineSize":"blockSize"])}return e[t.options.horizontal?"offsetWidth":"offsetHeight"]},ji=(e,{adjustments:s=0,behavior:t},n)=>{var r,i;const o=e+s;(i=(r=n.scrollElement)==null?void 0:r.scrollTo)==null||i.call(r,{[n.options.horizontal?"left":"top"]:o,behavior:t})};class _i{constructor(s){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var t,n,r;return((r=(n=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:n.now)==null?void 0:r.call(n))??Date.now()},this.observer=(()=>{let t=null;const n=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(r=>{r.forEach(i=>{const o=()=>{const l=i.target,c=this.indexFromElement(l);if(!l.isConnected){this.observer.unobserve(l);return}this.shouldMeasureDuringScroll(c)&&this.resizeItem(c,this.options.measureElement(l,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var r;(r=n())==null||r.disconnect(),t=null},observe:r=>{var i;return(i=n())==null?void 0:i.observe(r,{box:"border-box"})},unobserve:r=>{var i;return(i=n())==null?void 0:i.unobserve(r)}}})(),this.range=null,this.setOptions=t=>{Object.entries(t).forEach(([n,r])=>{typeof r>"u"&&delete t[n]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:gi,rangeExtractor:vi,onChange:()=>{},measureElement:wi,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",...t}},this.notify=t=>{var n,r;(r=(n=this.options).onChange)==null||r.call(n,this,t)},this.maybeNotify=V(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const n=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==n){if(this.cleanup(),!n){this.maybeNotify();return}this.scrollElement=n,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(r=>{this.observer.observe(r)}),this.unsubs.push(this.options.observeElementRect(this,r=>{this.scrollRect=r,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(r,i)=>{this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()<r?"forward":"backward":null,this.scrollOffset=r,this.isScrolling=i,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(t,n)=>{const r=new Map,i=new Map;for(let o=n-1;o>=0;o--){const l=t[o];if(r.has(l.lane))continue;const c=i.get(l.lane);if(c==null||l.end>c.end?i.set(l.lane,l):l.end<c.end&&r.set(l.lane,!0),r.size===this.options.lanes)break}return i.size===this.options.lanes?Array.from(i.values()).sort((o,l)=>o.end===l.end?o.index-l.index:o.end-l.end)[0]:void 0},this.getMeasurementOptions=V(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(t,n,r,i,o,l,c)=>(this.prevLanes!==void 0&&this.prevLanes!==l&&(this.lanesChangedFlag=!0),this.prevLanes=l,this.pendingMeasuredCacheIndexes=[],{count:t,paddingStart:n,scrollMargin:r,getItemKey:i,enabled:o,lanes:l,laneAssignmentMode:c}),{key:!1}),this.getMeasurements=V(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:t,paddingStart:n,scrollMargin:r,getItemKey:i,enabled:o,lanes:l,laneAssignmentMode:c},d)=>{if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const f of this.laneAssignments.keys())f>=t&&this.laneAssignments.delete(f);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(f=>{this.itemSizeCache.set(f.key,f.size)}));const u=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1);const m=this.measurementsCache.slice(0,u),p=new Array(l).fill(void 0);for(let f=0;f<u;f++){const g=m[f];g&&(p[g.lane]=f)}for(let f=u;f<t;f++){const g=i(f),y=this.laneAssignments.get(f);let v,x;const b=c==="estimate"||d.has(g);if(y!==void 0&&this.options.lanes>1){v=y;const N=p[v],C=N!==void 0?m[N]:void 0;x=C?C.end+this.options.gap:n+r}else{const N=this.options.lanes===1?m[f-1]:this.getFurthestMeasurement(m,f);x=N?N.end+this.options.gap:n+r,v=N?N.lane:f%this.options.lanes,this.options.lanes>1&&b&&this.laneAssignments.set(f,v)}const _=d.get(g),w=typeof _=="number"?_:this.options.estimateSize(f),j=x+w;m[f]={index:f,start:x,size:w,end:j,key:g,lane:v},p[v]=f}return this.measurementsCache=m,m},{key:!1,debug:()=>this.options.debug}),this.calculateRange=V(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,n,r,i)=>this.range=t.length>0&&n>0?Si({measurements:t,outerSize:n,scrollOffset:r,lanes:i}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=V(()=>{let t=null,n=null;const r=this.calculateRange();return r&&(t=r.startIndex,n=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,n]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,n]},(t,n,r,i,o)=>i===null||o===null?[]:t({startIndex:i,endIndex:o,overscan:n,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{const n=this.options.indexAttribute,r=t.getAttribute(n);return r?parseInt(r,10):(console.warn(`Missing attribute name '${n}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var n;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const r=this.scrollState.index??((n=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:n.index);if(r!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),o=Math.max(0,r-i),l=Math.min(this.options.count-1,r+i);return t>=o&&t<=l}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((o,l)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(l))});return}const n=this.indexFromElement(t),r=this.options.getItemKey(n),i=this.elementsCache.get(r);i!==t&&(i&&this.observer.unobserve(i),this.observer.observe(t),this.elementsCache.set(r,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,n)=>{var r;const i=this.measurementsCache[t];if(!i)return;const o=this.itemSizeCache.get(i.key)??i.size,l=n-o;l!==0&&(((r=this.scrollState)==null?void 0:r.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(i,l,this):i.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=l,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(i.index),this.itemSizeCache=new Map(this.itemSizeCache.set(i.key,n)),this.notify(!1))},this.getVirtualItems=V(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,n)=>{const r=[];for(let i=0,o=t.length;i<o;i++){const l=t[i],c=n[l];r.push(c)}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const n=this.getMeasurements();if(n.length!==0)return Rt(n[gs(0,n.length-1,r=>Rt(n[r]).start,t)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(t,n,r=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),o=this.getScrollOffset();n==="auto"&&(n=t>=o+i?"end":"start"),n==="center"?t+=(r-i)/2:n==="end"&&(t-=i);const l=this.getMaxScrollOffset();return Math.max(Math.min(l,t),0)},this.getOffsetForIndex=(t,n="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const r=this.getSize(),i=this.getScrollOffset(),o=this.measurementsCache[t];if(!o)return;if(n==="auto")if(o.end>=i+r-this.options.scrollPaddingEnd)n="end";else if(o.start<=i+this.options.scrollPaddingStart)n="start";else return[i,n];if(n==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),n];const l=n==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(l,n,o.size),n]},this.scrollToOffset=(t,{align:n="start",behavior:r="auto"}={})=>{const i=this.getOffsetForAlignment(t,n),o=this.now();this.scrollState={index:null,align:n,behavior:r,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:n="auto",behavior:r="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));const i=this.getOffsetForIndex(t,n);if(!i)return;const[o,l]=i,c=this.now();this.scrollState={index:t,align:l,behavior:r,startedAt:c,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:n="auto"}={})=>{const r=this.getScrollOffset()+t,i=this.now();this.scrollState={index:null,align:"start",behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var t;const n=this.getMeasurements();let r;if(n.length===0)r=this.options.paddingStart;else if(this.options.lanes===1)r=((t=n[n.length-1])==null?void 0:t.end)??0;else{const i=Array(this.options.lanes).fill(null);let o=n.length-1;for(;o>=0&&i.some(l=>l===null);){const l=n[o];i[l.lane]===null&&(i[l.lane]=l.end),o--}r=Math.max(...i.filter(l=>l!==null))}return Math.max(r-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(t,{adjustments:n,behavior:r})=>{this.options.scrollToFn(t,{behavior:r,adjustments:n},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(s)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const n=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,r=n?n[0]:this.scrollState.lastTargetOffset,i=1,o=r!==this.scrollState.lastTargetOffset;if(!o&&pi(r,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.scrollState=null;return}}else this.scrollState.stableFrames=0,o&&(this.scrollState.lastTargetOffset=r,this.scrollState.behavior="auto",this._scrollToOffset(r,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}}const gs=(e,s,t,n)=>{for(;e<=s;){const r=(e+s)/2|0,i=t(r);if(i<n)e=r+1;else if(i>n)s=r-1;else return r}return e>0?e-1:0};function Si({measurements:e,outerSize:s,scrollOffset:t,lanes:n}){const r=e.length-1,i=c=>e[c].start;if(e.length<=n)return{startIndex:0,endIndex:r};let o=gs(0,r,i,t),l=o;if(n===1)for(;l<r&&e[l].end<t+s;)l++;else if(n>1){const c=Array(n).fill(0);for(;l<r&&c.some(u=>u<t+s);){const u=e[l];c[u.lane]=u.end,l++}const d=Array(n).fill(t+s);for(;o>=0&&d.some(u=>u>=t);){const u=e[o];d[u.lane]=u.start,o--}o=Math.max(0,o-o%n),l=Math.min(r,l+(n-1-l%n))}return{startIndex:o,endIndex:l}}const Lt=typeof document<"u"?h.useLayoutEffect:h.useEffect;function Ni({useFlushSync:e=!0,...s}){const t=h.useReducer(()=>({}),{})[1],n={...s,onChange:(i,o)=>{var l;e&&o?$t.flushSync(t):t(),(l=s.onChange)==null||l.call(s,i,o)}},[r]=h.useState(()=>new _i(n));return r.setOptions(n),Lt(()=>r._didMount(),[]),Lt(()=>r._willUpdate()),r}function ki(e){return Ni({observeElementRect:bi,observeElementOffset:yi,scrollToFn:ji,...e})}function Ft({label:e,active:s,onClick:t}){return a.jsx("button",{className:`
|
|
200
|
+
px-2.5 py-1 rounded-[3px] text-[9px] font-mono font-bold
|
|
201
|
+
uppercase tracking-wider transition-all duration-100 border
|
|
202
|
+
${s?"bg-[var(--accent)] text-white border-[var(--accent)]":"bg-transparent text-[var(--text-muted)] border-[var(--border-subtle)] hover:border-[var(--border-strong)] hover:text-[var(--text-primary)]"}
|
|
203
|
+
`,onClick:t,children:e})}const Ci=38,Ei=h.memo(function({log:s,style:t}){return a.jsxs("div",{style:t,className:`\r
|
|
204
|
+
flex items-center gap-3 px-5\r
|
|
205
|
+
border-b border-[var(--border-subtle)]\r
|
|
206
|
+
hover:bg-[var(--bg-elevated)] transition-colors\r
|
|
207
|
+
`,children:[a.jsx("span",{className:"text-[9px] font-mono text-[var(--text-faint)] flex-shrink-0 w-[64px] tabular-nums",children:new Date(s.timestamp).toLocaleTimeString("en-US",{hour12:!1})}),a.jsx("span",{className:`badge badge-${s.role} flex-shrink-0`,children:s.role}),a.jsx("span",{className:`badge badge-${s.status} flex-shrink-0`,children:s.status}),a.jsx("span",{className:"text-[10px] font-medium text-[var(--text-primary)] truncate flex-shrink-0 max-w-[120px]",children:s.label}),s.currentAction&&a.jsx("span",{className:"text-[9px] text-[var(--text-muted)] font-mono truncate flex-1 min-w-0",children:s.currentAction})]})}),Ii=h.memo(function(){const s=U(Sr),[t,n]=h.useState("ALL"),[r,i]=h.useState("ALL"),[o,l]=h.useState(!0),c=h.useRef(null),d=h.useMemo(()=>s.filter(f=>!(t!=="ALL"&&f.role!==t||r!=="ALL"&&f.status!==r)),[s,t,r]),u=ki({count:d.length,getScrollElement:()=>c.current,estimateSize:()=>Ci,overscan:12}),m=h.useCallback(()=>{d.length>0&&u.scrollToIndex(d.length-1,{behavior:"smooth"})},[d.length,u]);h.useEffect(()=>{o&&m()},[d.length,o]);const p=h.useCallback(()=>{const f=c.current;f&&l(f.scrollHeight-f.scrollTop<=f.clientHeight+60)},[]);return a.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-[var(--bg-base)]",children:[a.jsxs("div",{className:`\r
|
|
208
|
+
flex items-center gap-2 px-5 py-2.5\r
|
|
209
|
+
border-b border-[var(--border-subtle)] flex-shrink-0 flex-wrap\r
|
|
210
|
+
bg-[var(--bg-surface)]\r
|
|
211
|
+
`,children:[a.jsx("span",{className:"section-label mr-1",children:"Role"}),["ALL","T1","T2","T3"].map(f=>a.jsx(Ft,{label:f,active:t===f,onClick:()=>n(f)},f)),a.jsx("div",{className:"divider-v h-4 mx-1"}),a.jsx("span",{className:"section-label mr-1",children:"Status"}),["ALL","ACTIVE","COMPLETED","FAILED","ESCALATED"].map(f=>a.jsx(Ft,{label:f,active:r===f,onClick:()=>i(f)},f)),a.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[a.jsxs("span",{className:"text-[9px] font-mono text-[var(--text-faint)] tabular-nums",children:[d.length.toLocaleString()," entries"]}),!o&&a.jsx("button",{className:"btn btn-ghost py-0.5 px-2",onClick:()=>{l(!0),m()},children:"↓ Jump to latest"})]})]}),a.jsxs("div",{className:`\r
|
|
212
|
+
flex items-center gap-3 px-5 py-1.5\r
|
|
213
|
+
border-b border-[var(--border-subtle)]\r
|
|
214
|
+
bg-[var(--bg-surface)] flex-shrink-0\r
|
|
215
|
+
`,children:[a.jsx("span",{className:"section-label w-[64px]",children:"Time"}),a.jsx("span",{className:"section-label w-[28px]",children:"Tier"}),a.jsx("span",{className:"section-label w-[72px]",children:"Status"}),a.jsx("span",{className:"section-label w-[120px]",children:"Agent"}),a.jsx("span",{className:"section-label",children:"Action"})]}),d.length===0?a.jsx("div",{className:"flex items-center justify-center flex-1 text-[var(--text-faint)] text-[11px] font-mono",children:s.length===0?"// no log entries":"// no entries match filter"}):a.jsx("div",{ref:c,onScroll:p,className:"flex-1 overflow-y-auto",role:"log","aria-label":"Activity log","aria-live":"polite",children:a.jsx("div",{style:{height:u.getTotalSize(),position:"relative"},children:u.getVirtualItems().map(f=>{const g=d[f.index];return a.jsx(Ei,{log:g,style:{position:"absolute",top:0,left:0,right:0,transform:`translateY(${f.start}px)`,height:`${f.size}px`}},g.id)})})})]})}),Ai=[{id:"identities",label:"Identities",icon:"◎"},{id:"tier-limits",label:"Tier Limits",icon:"⊟"},{id:"budget",label:"Budget",icon:"⟁"},{id:"danger",label:"Danger Zone",icon:"⚡"}];function Mi({token:e}){const s=Ae(),[t,n]=h.useState("identities");return a.jsxs("div",{className:"flex h-full overflow-hidden animate-fade-in",children:[a.jsxs("nav",{className:"w-44 flex-shrink-0 border-r border-[var(--border-base)] p-4 flex flex-col gap-1",children:[a.jsx("p",{className:"section-label mb-3",children:"Settings"}),Ai.map(r=>a.jsxs("button",{onClick:()=>n(r.id),className:`flex items-center gap-2.5 px-3 py-2 rounded-[var(--radius-sm)] text-sm transition-all text-left
|
|
216
|
+
${t===r.id?"bg-[var(--accent)]/15 text-[var(--accent)] font-medium":"text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-elevated)]"}`,children:[a.jsx("span",{className:"text-[11px] font-mono opacity-70",children:r.icon}),r.label]},r.id))]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-8",children:a.jsxs("div",{className:"max-w-2xl mx-auto",children:[t==="identities"&&a.jsx(Ti,{token:e}),t==="tier-limits"&&a.jsx(Ri,{token:e}),t==="budget"&&a.jsx(Di,{token:e}),t==="danger"&&a.jsx(zi,{token:e,dispatch:s})]})})]})}function Ti({token:e}){const[s,t]=h.useState([]),[n,r]=h.useState(!0),[i,o]=h.useState(!1),[l,c]=h.useState(null),[d,u]=h.useState({name:"",description:"",systemPrompt:"",setDefault:!1}),[m,p]=h.useState(""),f=h.useCallback(async()=>{try{const b=await fetch("/api/identities",{headers:{Authorization:`Bearer ${e}`}});b.ok&&t(await b.json())}finally{r(!1)}},[e]);h.useEffect(()=>{f()},[f]);const g=()=>{u({name:"",description:"",systemPrompt:"",setDefault:!1}),p("")},y=async()=>{if(!d.name.trim()){p("Name is required");return}(await fetch("/api/identities",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(d)})).ok?(g(),o(!1),await f()):p("Failed to create identity")},v=async(b,_)=>{await fetch(`/api/identities/${b}`,{method:"PUT",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(_)}),c(null),await f()},x=async b=>{await fetch(`/api/identities/${b}`,{method:"DELETE",headers:{Authorization:`Bearer ${e}`}}),await f()};return n?a.jsx(Pi,{}):a.jsxs("section",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-bold text-[var(--text-primary)]",children:"Identities"}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mt-1",children:"Persona profiles that shape how agents behave."})]}),a.jsx("button",{onClick:()=>{g(),o(!0)},className:"btn btn-primary h-8 text-sm px-3",children:"+ New Identity"})]}),i&&a.jsxs("div",{className:"glass-elevated rounded-[var(--radius-lg)] p-5 mb-6 border border-[var(--accent)]/30",children:[a.jsx("p",{className:"font-medium text-[var(--text-primary)] mb-4",children:"Create Identity"}),a.jsx(vs,{form:d,onChange:u,error:m}),a.jsxs("div",{className:"flex gap-2 mt-4",children:[a.jsx("button",{onClick:y,className:"btn btn-primary text-sm",children:"Create"}),a.jsx("button",{onClick:()=>{o(!1),g()},className:"btn glass text-sm",children:"Cancel"})]})]}),s.length===0&&!i&&a.jsxs("div",{className:"text-center py-12 text-[var(--text-muted)]",children:[a.jsx("p",{className:"text-2xl mb-2",children:"◎"}),a.jsx("p",{children:"No identities yet. Create one above."})]}),a.jsx("div",{className:"flex flex-col gap-3",children:s.map(b=>a.jsx(Oi,{identity:b,token:e,editing:l===b.id,onEdit:()=>c(l===b.id?null:b.id),onSave:_=>v(b.id,_),onDelete:()=>x(b.id),onSetDefault:()=>v(b.id,{setDefault:!0})},b.id))})]})}function vs({form:e,onChange:s,error:t}){return a.jsxs("div",{className:"flex flex-col gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"section-label mb-1 block",children:"Name *"}),a.jsx("input",{className:"input",placeholder:"e.g. Senior Engineer",value:e.name,onChange:n=>s({...e,name:n.target.value})})]}),a.jsxs("div",{children:[a.jsx("label",{className:"section-label mb-1 block",children:"Description"}),a.jsx("input",{className:"input",placeholder:"Short description",value:e.description,onChange:n=>s({...e,description:n.target.value})})]}),a.jsxs("div",{children:[a.jsx("label",{className:"section-label mb-1 block",children:"System Prompt"}),a.jsx("textarea",{className:"input resize-none",rows:3,placeholder:"You are a senior engineer who writes concise, maintainable code...",value:e.systemPrompt,onChange:n=>s({...e,systemPrompt:n.target.value})})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:e.setDefault,onChange:n=>s({...e,setDefault:n.target.checked}),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm text-[var(--text-muted)]",children:"Set as default identity"})]}),t&&a.jsx("p",{className:"text-[11px] text-[var(--error)] font-mono",children:t})]})}function Oi({identity:e,editing:s,onEdit:t,onSave:n,onDelete:r,onSetDefault:i}){var u;const[o,l]=h.useState({name:e.name,description:e.description??"",systemPrompt:e.systemPrompt??"",setDefault:e.isDefault}),[c,d]=h.useState(!1);return a.jsxs("div",{className:`glass-elevated rounded-[var(--radius-lg)] p-4 border transition-all ${s?"border-[var(--accent)]/40":"border-[var(--border-base)]"}`,children:[a.jsxs("div",{className:"flex items-start justify-between gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("div",{className:"w-8 h-8 rounded-full bg-[var(--accent)]/20 flex items-center justify-center flex-shrink-0 text-[var(--accent)] font-bold text-sm",children:(u=e.name[0])==null?void 0:u.toUpperCase()}),a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("p",{className:"font-medium text-[var(--text-primary)] truncate",children:e.name}),e.isDefault&&a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-[var(--accent)]/20 text-[var(--accent)] font-mono",children:"Default"})]}),e.description&&a.jsx("p",{className:"text-xs text-[var(--text-muted)] mt-0.5 truncate",children:e.description})]})]}),a.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[!e.isDefault&&a.jsx("button",{onClick:i,className:"btn glass text-xs h-7 px-2",children:"Set Default"}),a.jsx("button",{onClick:t,className:"btn glass text-xs h-7 px-2",children:s?"Cancel":"Edit"}),c?a.jsx("button",{onClick:r,className:"btn text-xs h-7 px-2 bg-[var(--error)] border-transparent text-white",children:"Confirm"}):a.jsx("button",{onClick:()=>d(!0),className:"btn glass text-xs h-7 px-2 text-[var(--error)]",children:"Delete"})]})]}),s&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border-base)]",children:[a.jsx(vs,{form:o,onChange:l,error:""}),a.jsx("div",{className:"flex gap-2 mt-4",children:a.jsx("button",{onClick:()=>n(o),className:"btn btn-primary text-sm",children:"Save Changes"})})]})]})}function Ri({token:e}){const[s,t]=h.useState({}),[n,r]=h.useState(!1),[i,o]=h.useState(!1);h.useEffect(()=>{fetch("/api/config",{headers:{Authorization:`Bearer ${e}`}}).then(d=>d.json()).then(d=>{d.tierLimits&&t(d.tierLimits)})},[e]);const l=async()=>{r(!0);try{await fetch("/api/config",{method:"PUT",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify({tierLimits:s})}),o(!0),setTimeout(()=>o(!1),2e3)}finally{r(!1)}},c=[{key:"t1MaxTokens",label:"T1 (Administrator)",desc:"Max output tokens for the planner tier",placeholder:"4096"},{key:"t2MaxTokens",label:"T2 (Manager)",desc:"Max output tokens for manager/coordinator",placeholder:"8192"},{key:"t3MaxTokens",label:"T3 (Worker)",desc:"Max output tokens for each task worker",placeholder:"32768"}];return a.jsxs("section",{children:[a.jsx("h2",{className:"text-lg font-bold text-[var(--text-primary)] mb-1",children:"Tier Token Limits"}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-6",children:"Cap the maximum output tokens per AI call for each tier. Leave blank to use model defaults."}),a.jsx("div",{className:"glass-elevated rounded-[var(--radius-lg)] divide-y divide-[var(--border-base)]",children:c.map(d=>a.jsxs("div",{className:"flex items-center justify-between p-5 gap-6",children:[a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-[var(--text-primary)]",children:d.label}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mt-0.5",children:d.desc})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:128,max:2e5,step:128,placeholder:d.placeholder,value:s[d.key]??"",onChange:u=>t(m=>({...m,[d.key]:u.target.value?Number(u.target.value):void 0})),className:"input w-28 text-right font-mono text-sm"}),a.jsx("span",{className:"text-xs text-[var(--text-faint)] font-mono",children:"tokens"})]})]},d.key))}),a.jsxs("div",{className:"flex items-center gap-3 mt-4",children:[a.jsx("button",{onClick:l,disabled:n,className:"btn btn-primary",children:n?"Saving…":i?"✓ Saved":"Save Limits"}),i&&a.jsx("span",{className:"text-xs text-green-400 font-mono",children:"Persisted to .cascade/config.json"})]})]})}function Di({token:e}){var p;const[s,t]=h.useState({warnAtPct:80}),[n,r]=h.useState(null),[i,o]=h.useState(!1),[l,c]=h.useState(!1);h.useEffect(()=>{fetch("/api/config",{headers:{Authorization:`Bearer ${e}`}}).then(f=>f.json()).then(f=>{f.budget&&t(f.budget)}),fetch("/api/stats",{headers:{Authorization:`Bearer ${e}`}}).then(f=>f.json()).then(f=>r(f))},[e]);const d=async()=>{o(!0);try{await fetch("/api/config",{method:"PUT",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify({budget:s})}),c(!0),setTimeout(()=>c(!1),2e3)}finally{o(!1)}},u=s.sessionBudgetUsd&&n?Math.min(100,n.totalCostUsd/s.sessionBudgetUsd*100):null,m=s.warnAtPct;return a.jsxs("section",{children:[a.jsx("h2",{className:"text-lg font-bold text-[var(--text-primary)] mb-1",children:"Cost Budget"}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-6",children:"Set spending limits. The agent will abort if a session budget is exceeded."}),a.jsxs("div",{className:"glass-elevated rounded-[var(--radius-lg)] divide-y divide-[var(--border-base)] mb-4",children:[a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"flex items-center justify-between gap-6",children:[a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-[var(--text-primary)]",children:"Session Budget"}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mt-0.5",children:"Max spend per REPL session. Exceeding this aborts the current run."})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[var(--text-faint)] font-mono text-sm",children:"$"}),a.jsx("input",{type:"number",min:0,step:.01,placeholder:"0.50",value:s.sessionBudgetUsd??"",onChange:f=>t(g=>({...g,sessionBudgetUsd:f.target.value?Number(f.target.value):void 0})),className:"input w-24 text-right font-mono text-sm"})]})]}),u!==null&&a.jsxs("div",{className:"mt-3",children:[a.jsxs("div",{className:"flex justify-between text-xs text-[var(--text-faint)] mb-1",children:[a.jsx("span",{children:"Session spend"}),a.jsxs("span",{children:["$",n==null?void 0:n.totalCostUsd.toFixed(4)," / $",(p=s.sessionBudgetUsd)==null?void 0:p.toFixed(2)]})]}),a.jsx("div",{className:"h-1.5 rounded-full bg-[var(--bg-base)] overflow-hidden",children:a.jsx("div",{className:`h-full rounded-full transition-all ${u>=100?"bg-[var(--error)]":u>=m?"bg-yellow-400":"bg-[var(--accent)]"}`,style:{width:`${u}%`}})})]})]}),a.jsx("div",{className:"p-5",children:a.jsxs("div",{className:"flex items-center justify-between gap-6",children:[a.jsxs("div",{children:[a.jsxs("p",{className:"font-medium text-[var(--text-primary)]",children:["Daily Budget ",a.jsx("span",{className:"text-xs text-[var(--text-faint)] ml-1",children:"(display only)"})]}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mt-0.5",children:"Informational limit shown in the dashboard for reference."})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[var(--text-faint)] font-mono text-sm",children:"$"}),a.jsx("input",{type:"number",min:0,step:.1,placeholder:"5.00",value:s.dailyBudgetUsd??"",onChange:f=>t(g=>({...g,dailyBudgetUsd:f.target.value?Number(f.target.value):void 0})),className:"input w-24 text-right font-mono text-sm"})]})]})}),a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-[var(--text-primary)]",children:"Warn at"}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mt-0.5",children:"Show a dashboard warning when spend reaches this % of limit."})]}),a.jsxs("span",{className:"text-sm font-mono text-[var(--accent)]",children:[s.warnAtPct,"%"]})]}),a.jsx("input",{type:"range",min:10,max:99,step:5,value:s.warnAtPct,onChange:f=>t(g=>({...g,warnAtPct:Number(f.target.value)})),className:"w-full accent-[var(--accent)]"}),a.jsxs("div",{className:"flex justify-between text-xs text-[var(--text-faint)] mt-1",children:[a.jsx("span",{children:"10%"}),a.jsx("span",{children:"50%"}),a.jsx("span",{children:"99%"})]})]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{onClick:d,disabled:i,className:"btn btn-primary",children:i?"Saving…":l?"✓ Saved":"Save Budget"}),l&&a.jsx("span",{className:"text-xs text-green-400 font-mono",children:"Persisted to .cascade/config.json"})]})]})}function zi({token:e,dispatch:s}){const[t,n]=h.useState(null),[r,i]=h.useState(!1),o=async l=>{n(l);try{await fetch(l,{method:"DELETE",headers:{Authorization:`Bearer ${e}`}})}finally{n(null),i(!1)}};return a.jsxs("section",{children:[a.jsx("h2",{className:"text-lg font-bold text-[var(--error)] mb-1",children:"Danger Zone"}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-6",children:"These actions are irreversible."}),a.jsxs("div",{className:"rounded-[var(--radius-lg)] border border-[var(--error)]/30 divide-y divide-[var(--error)]/10 overflow-hidden",children:[a.jsx(Ue,{title:"Clear All Sessions",desc:"Permanently delete all conversation sessions and messages.",action:r?a.jsx("button",{onClick:()=>o("/api/sessions"),disabled:!!t,className:"btn text-sm bg-[var(--error)] border-transparent text-white",children:t==="/api/sessions"?"Clearing…":"Confirm Delete"}):a.jsx("button",{onClick:()=>i(!0),className:"btn glass text-sm border-[var(--error)]/40 text-[var(--error)]",children:"Clear Sessions"})}),a.jsx(Ue,{title:"Clear Graphs (Backend + Frontend)",desc:"Delete all runtime node logs from DB and reset the topology view.",action:a.jsx("button",{onClick:async()=>{await o("/api/runtime"),s(kt())},disabled:!!t,className:"btn glass text-sm border-[var(--error)]/40 text-[var(--error)]",children:t==="/api/runtime"?"Clearing…":"Clear DB Graphs"})}),a.jsx(Ue,{title:"Clear Graphs (Frontend Only)",desc:"Reset the topology view locally without touching the server database.",action:a.jsx("button",{onClick:()=>s(kt()),className:"btn glass text-sm",children:"Clear View"})})]})]})}function Ue({title:e,desc:s,action:t}){return a.jsxs("div",{className:"flex items-center justify-between gap-6 p-5 bg-[var(--error)]/[0.03]",children:[a.jsxs("div",{children:[a.jsx("p",{className:"font-medium text-[var(--text-primary)]",children:e}),a.jsx("p",{className:"text-sm text-[var(--text-muted)] mt-0.5",children:s})]}),a.jsx("div",{className:"flex-shrink-0",children:t})]})}function Pi(){return a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx("div",{className:"w-6 h-6 rounded-full border-2 border-[var(--accent)] border-t-transparent animate-spin"})})}function Li(){const[e,s]=h.useState(()=>localStorage.getItem("cascade_token")),[t,n]=h.useState(e===null);h.useEffect(()=>{e===null&&(async()=>{try{(await fetch("/api/runtime?scope=workspace",{headers:{Authorization:"Bearer "}})).ok&&(s(""),localStorage.setItem("cascade_token",""))}catch{}finally{n(!1)}})()},[e]);const r=h.useCallback(o=>{s(o),localStorage.setItem("cascade_token",o)},[]),i=h.useCallback(()=>{s(null),localStorage.removeItem("cascade_token")},[]);return t?a.jsx("div",{className:"flex items-center justify-center w-full h-full bg-[var(--bg-base)]",children:a.jsxs("div",{className:"flex flex-col items-center gap-3",children:[a.jsx("div",{className:"w-8 h-8 rounded-full border-2 border-[var(--accent)] border-t-transparent animate-spin"}),a.jsx("p",{className:"section-label",children:"Connecting…"})]})}):e===null?a.jsx(Fr,{onLogin:r}):a.jsx(Fi,{token:e,onLogout:i,onNeedAuth:()=>{s(null),localStorage.removeItem("cascade_token")}})}function Fi({token:e,onLogout:s,onNeedAuth:t}){const n=Ae(),[r,i]=h.useState("topology"),[o,l]=h.useState(null),[c,d]=h.useState(""),[u,m]=h.useState(null),[p,f]=h.useState(0),[g,y]=h.useState(0),v=U(_r),x=U(st),b=U(Nr),_=h.useRef(u);_.current=u;const w=h.useCallback(async(k="workspace")=>{try{const z=await fetch(`/api/runtime?scope=${k}`,{headers:{Authorization:`Bearer ${e}`},cache:"no-store"});if(z.status===401){t();return}if(z.ok){const bs=await z.json();n(cs(bs))}}catch{}},[e,n,t]),{socket:j}=Lr({url:"/",token:e,activeSessionId:x==null?void 0:x.sessionId,onRuntimeRefresh:k=>w(k??"workspace"),onStreamToken:k=>d(z=>(z+k.text).slice(-8e3)),onCostUpdate:k=>{typeof k.totalCostUsd=="number"&&f(k.totalCostUsd),typeof k.totalTokens=="number"&&y(k.totalTokens)},onEscalation:k=>{_.current||m(k)}});h.useEffect(()=>{w()},[w]);const N=h.useMemo(()=>v.map(k=>({id:k.tierId,role:k.role,label:k.label,status:k.status,action:k.currentAction,progressPct:k.progressPct})),[v]),C=h.useMemo(()=>v.filter(k=>k.parentId).map(k=>({from:k.parentId,to:k.tierId})),[v]),I=h.useMemo(()=>v.find(k=>k.tierId===o)??null,[v,o]),S=h.useCallback((k,z)=>{!u||!j||(j.emit("permission:decision",{requestId:u.id,approved:k,always:z,decidedBy:"USER"}),m(null))},[u,j]),T=o!==null;return a.jsxs("div",{className:"flex h-full w-full overflow-hidden bg-[var(--bg-base)]",children:[a.jsx(ti,{activeTab:r,onTabChange:i,onLogout:s}),a.jsxs("div",{className:"flex flex-col flex-1 min-w-0 overflow-hidden",children:[a.jsx(ri,{isConnected:b,totalCostUsd:p,totalTokens:g}),a.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[a.jsxs("main",{className:"flex-1 min-w-0 overflow-hidden relative dot-grid",children:[r==="topology"&&a.jsx(li,{nodes:N,edges:C,selectedNodeId:o??void 0,onSelectNode:l}),r==="sessions"&&a.jsx(mi,{}),r==="logs"&&a.jsx(Ii,{}),r==="settings"&&a.jsx(Mi,{token:e})]}),r==="topology"&&T&&a.jsx(di,{node:I,streamLog:c,onClose:()=>l(null)})]})]}),u&&a.jsx(ui,{request:u,onDecide:S})]})}Be.createRoot(document.getElementById("root")).render(a.jsx(Cs.StrictMode,{children:a.jsx(en,{store:Cr,children:a.jsx(Li,{})})}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./reactflow-B1e2RnXD.js";
|