@grackle-ai/web 0.100.0 → 0.100.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KnowledgePage-
|
|
2
|
-
import{r as iT,a as oT,b as y,j as i,d as J0,H as W0,P as X0,i as rT,B as lT,c as cT,C as dT,M as uT,e as fT}from"./dagview-tHPW3Rz3.js";import{c as pT,a as mT,G as hT,f as gT,M as vT,A as dx,D as ux,W as yT,O as bT,b as xT,C as wi,d as fx,e as px,w as _T,t as kT,p as Cc,g as ST,R as Rr,S as Q0}from"./grpc-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KnowledgePage-BLz5X1AT.js","assets/dagview-tHPW3Rz3.js","assets/grpc-CsVN0-gD.js","assets/markdown-Yr3vTPLR.js","assets/KnowledgePage-BmY14aDt.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as iT,a as oT,b as y,j as i,d as J0,H as W0,P as X0,i as rT,B as lT,c as cT,C as dT,M as uT,e as fT}from"./dagview-tHPW3Rz3.js";import{c as pT,a as mT,G as hT,f as gT,M as vT,A as dx,D as ux,W as yT,O as bT,b as xT,C as wi,d as fx,e as px,w as _T,t as kT,p as Cc,g as ST,R as Rr,S as Q0}from"./grpc-CsVN0-gD.js";import{v as TT,r as wT,t as Ec,i as jT,f as NT,M as hd,a as gd}from"./markdown-Yr3vTPLR.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))r(c);new MutationObserver(c=>{for(const d of c)if(d.type==="childList")for(const u of d.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function o(c){const d={};return c.integrity&&(d.integrity=c.integrity),c.referrerPolicy&&(d.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?d.credentials="include":c.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function r(c){if(c.ep)return;c.ep=!0;const d=o(c);fetch(c.href,d)}})();var zf={exports:{}},Mr={},$f={exports:{}},Uf={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* scheduler.production.js
|
|
5
5
|
*
|
|
@@ -227,7 +227,7 @@ Error generating stack: `+l.message+`
|
|
|
227
227
|
Please change the parent <Route path="${T}"> to <Route path="${T==="/"?"*":`${T}/*`}">.`)}let v=Zt(),b;if(s){let T=typeof s=="string"?zo(s):s;xt(m==="/"||((N=T.pathname)==null?void 0:N.startsWith(m)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${m}" but pathname "${T.pathname}" was given in the \`location\` prop.`),b=T}else b=v;let x=b.pathname||"/",S=x;if(m!=="/"){let T=m.replace(/^\//,"").split("/");S="/"+x.replace(/^\//,"").split("/").slice(T.length).join("/")}let k=yx(t,{pathname:S});Xn(g||k!=null,`No routes matched location "${b.pathname}${b.search}${b.hash}" `),Xn(k==null||k[k.length-1].route.element!==void 0||k[k.length-1].route.Component!==void 0||k[k.length-1].route.lazy!==void 0,`Matched leaf route at location "${b.pathname}${b.search}${b.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let w=fj(k&&k.map(T=>Object.assign({},T,{params:Object.assign({},u,T.params),pathname:Ts([m,r.encodeLocation?r.encodeLocation(T.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:T.pathname]),pathnameBase:T.pathnameBase==="/"?m:Ts([m,r.encodeLocation?r.encodeLocation(T.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:T.pathnameBase])})),c,o);return s&&w?y.createElement(cl.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...b},navigationType:"POP"}},w):w}function lj(){let t=vj(),s=Zw(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),o=t instanceof Error?t.stack:null,r="rgba(200,200,200, 0.5)",c={padding:"0.5rem",backgroundColor:r},d={padding:"2px 4px",backgroundColor:r},u=null;return console.error("Error handled by React Router default ErrorBoundary:",t),u=y.createElement(y.Fragment,null,y.createElement("p",null,"💿 Hey developer 👋"),y.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",y.createElement("code",{style:d},"ErrorBoundary")," or"," ",y.createElement("code",{style:d},"errorElement")," prop on your route.")),y.createElement(y.Fragment,null,y.createElement("h2",null,"Unexpected Application Error!"),y.createElement("h3",{style:{fontStyle:"italic"}},s),o?y.createElement("pre",{style:c},o):null,u)}var cj=y.createElement(lj,null),Ax=class extends y.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,s){return s.location!==t.location||s.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:s.error,location:s.location,revalidation:t.revalidation||s.revalidation}}componentDidCatch(t,s){this.props.onError?this.props.onError(t,s):console.error("React Router caught the following error during render",t)}render(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const o=nj(t.digest);o&&(t=o)}let s=t!==void 0?y.createElement(Qn.Provider,{value:this.props.routeContext},y.createElement(cm.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?y.createElement(dj,{error:t},s):s}};Ax.contextType=Jw;var Hf=new WeakMap;function dj({children:t,error:s}){let{basename:o}=y.useContext(Ln);if(typeof s=="object"&&s&&"digest"in s&&typeof s.digest=="string"){let r=tj(s.digest);if(r){let c=Hf.get(s);if(c)throw c;let d=Sx(r.location,o);if(kx&&!Hf.get(s))if(d.isExternal||r.reloadDocument)window.location.href=d.absoluteURL||d.to;else{const u=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(d.to,{replace:r.replace}));throw Hf.set(s,u),u}return y.createElement("meta",{httpEquiv:"refresh",content:`0;url=${d.absoluteURL||d.to}`})}}return t}function uj({routeContext:t,match:s,children:o}){let r=y.useContext($o);return r&&r.static&&r.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=s.route.id),y.createElement(Qn.Provider,{value:t},o)}function fj(t,s=[],o){let r=o==null?void 0:o.state;if(t==null){if(!r)return null;if(r.errors)t=r.matches;else if(s.length===0&&!r.initialized&&r.matches.length>0)t=r.matches;else return null}let c=t,d=r==null?void 0:r.errors;if(d!=null){let v=c.findIndex(b=>b.route.id&&(d==null?void 0:d[b.route.id])!==void 0);xt(v>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(d).join(",")}`),c=c.slice(0,Math.min(c.length,v+1))}let u=!1,p=-1;if(o&&r){u=r.renderFallback;for(let v=0;v<c.length;v++){let b=c[v];if((b.route.HydrateFallback||b.route.hydrateFallbackElement)&&(p=v),b.route.id){let{loaderData:x,errors:S}=r,k=b.route.loader&&!x.hasOwnProperty(b.route.id)&&(!S||S[b.route.id]===void 0);if(b.route.lazy||k){o.isStatic&&(u=!0),p>=0?c=c.slice(0,p+1):c=[c[0]];break}}}}let m=o==null?void 0:o.onError,g=r&&m?(v,b)=>{var x,S;m(v,{location:r.location,params:((S=(x=r.matches)==null?void 0:x[0])==null?void 0:S.params)??{},unstable_pattern:Kw(r.matches),errorInfo:b})}:void 0;return c.reduceRight((v,b,x)=>{let S,k=!1,w=null,N=null;r&&(S=d&&b.route.id?d[b.route.id]:void 0,w=b.route.errorElement||cj,u&&(p<0&&x===0?(Dx("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),k=!0,N=null):p===x&&(k=!0,N=b.route.hydrateFallbackElement||null)));let T=s.concat(c.slice(0,x+1)),C=()=>{let D;return S?D=w:k?D=N:b.route.Component?D=y.createElement(b.route.Component,null):b.route.element?D=b.route.element:D=v,y.createElement(uj,{match:b,routeContext:{outlet:v,matches:T,isDataRoute:r!=null},children:D})};return r&&(b.route.ErrorBoundary||b.route.errorElement||x===0)?y.createElement(Ax,{location:r.location,revalidation:r.revalidation,component:w,error:S,children:C(),routeContext:{outlet:null,matches:T,isDataRoute:!0},onError:g}):C()},null)}function dm(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function pj(t){let s=y.useContext($o);return xt(s,dm(t)),s}function mj(t){let s=y.useContext(yd);return xt(s,dm(t)),s}function hj(t){let s=y.useContext(Qn);return xt(s,dm(t)),s}function um(t){let s=hj(t),o=s.matches[s.matches.length-1];return xt(o.route.id,`${t} can only be used on routes that contain a unique "id"`),o.route.id}function gj(){return um("useRouteId")}function vj(){var r;let t=y.useContext(cm),s=mj("useRouteError"),o=um("useRouteError");return t!==void 0?t:(r=s.errors)==null?void 0:r[o]}function yj(){let{router:t}=pj("useNavigate"),s=um("useNavigate"),o=y.useRef(!1);return Cx(()=>{o.current=!0}),y.useCallback(async(c,d={})=>{Xn(o.current,Nx),o.current&&(typeof c=="number"?await t.navigate(c):await t.navigate(c,{fromRouteId:s,...d}))},[t,s])}var hy={};function Dx(t,s,o){!s&&!hy[t]&&(hy[t]=!0,Xn(!1,o))}y.memo(bj);function bj({routes:t,future:s,state:o,isStatic:r,onError:c}){return Ex(t,void 0,{state:o,isStatic:r,onError:c})}function ds({to:t,replace:s,state:o,relative:r}){xt(Ai(),"<Navigate> may be used only in the context of a <Router> component.");let{static:c}=y.useContext(Ln);Xn(!c,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:d}=y.useContext(Qn),{pathname:u}=Zt(),p=bd(),m=vd(t,lm(d),u,r==="path"),g=JSON.stringify(m);return y.useEffect(()=>{p(JSON.parse(g),{replace:s,state:o,relative:r})},[p,g,r,s,o]),null}function Va(t){return oj(t.context)}function Ae(t){xt(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function xj({basename:t="/",children:s=null,location:o,navigationType:r="POP",navigator:c,static:d=!1,unstable_useTransitions:u}){xt(!Ai(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let p=t.replace(/^\/*/,"/"),m=y.useMemo(()=>({basename:p,navigator:c,static:d,unstable_useTransitions:u,future:{}}),[p,c,d,u]);typeof o=="string"&&(o=zo(o));let{pathname:g="/",search:v="",hash:b="",state:x=null,key:S="default",unstable_mask:k}=o,w=y.useMemo(()=>{let N=ea(g,p);return N==null?null:{location:{pathname:N,search:v,hash:b,state:x,key:S,unstable_mask:k},navigationType:r}},[p,g,v,b,x,S,r,k]);return Xn(w!=null,`<Router basename="${p}"> is not able to match the URL "${g}${v}${b}" because it does not start with the basename, so the <Router> won't render anything.`),w==null?null:y.createElement(Ln.Provider,{value:m},y.createElement(cl.Provider,{children:s,value:w}))}function _j({children:t,location:s}){return rj(Dp(t),s)}function Dp(t,s=[]){let o=[];return y.Children.forEach(t,(r,c)=>{if(!y.isValidElement(r))return;let d=[...s,c];if(r.type===y.Fragment){o.push.apply(o,Dp(r.props.children,d));return}xt(r.type===Ae,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),xt(!r.props.index||!r.props.children,"An index route cannot have child routes.");let u={id:r.props.id||d.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(u.children=Dp(r.props.children,d)),o.push(u)}),o}var Gc="get",Fc="application/x-www-form-urlencoded";function xd(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function kj(t){return xd(t)&&t.tagName.toLowerCase()==="button"}function Sj(t){return xd(t)&&t.tagName.toLowerCase()==="form"}function Tj(t){return xd(t)&&t.tagName.toLowerCase()==="input"}function wj(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function jj(t,s){return t.button===0&&(!s||s==="_self")&&!wj(t)}function Rp(t=""){return new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((s,o)=>{let r=t[o];return s.concat(Array.isArray(r)?r.map(c=>[o,c]):[[o,r]])},[]))}function Nj(t,s){let o=Rp(t);return s&&s.forEach((r,c)=>{o.has(c)||s.getAll(c).forEach(d=>{o.append(c,d)})}),o}var Ac=null;function Cj(){if(Ac===null)try{new FormData(document.createElement("form"),0),Ac=!1}catch{Ac=!0}return Ac}var Ej=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Vf(t){return t!=null&&!Ej.has(t)?(Xn(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Fc}"`),null):t}function Aj(t,s){let o,r,c,d,u;if(Sj(t)){let p=t.getAttribute("action");r=p?ea(p,s):null,o=t.getAttribute("method")||Gc,c=Vf(t.getAttribute("enctype"))||Fc,d=new FormData(t)}else if(kj(t)||Tj(t)&&(t.type==="submit"||t.type==="image")){let p=t.form;if(p==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let m=t.getAttribute("formaction")||p.getAttribute("action");if(r=m?ea(m,s):null,o=t.getAttribute("formmethod")||p.getAttribute("method")||Gc,c=Vf(t.getAttribute("formenctype"))||Vf(p.getAttribute("enctype"))||Fc,d=new FormData(p,t),!Cj()){let{name:g,type:v,value:b}=t;if(v==="image"){let x=g?`${g}.`:"";d.append(`${x}x`,"0"),d.append(`${x}y`,"0")}else g&&d.append(g,b)}}else{if(xd(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');o=Gc,r=null,c=Fc,u=t}return d&&c==="text/plain"&&(u=d,d=void 0),{action:r,method:o.toLowerCase(),encType:c,formData:d,body:u}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function fm(t,s){if(t===!1||t===null||typeof t>"u")throw new Error(s)}function Dj(t,s,o,r){let c=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return o?c.pathname.endsWith("/")?c.pathname=`${c.pathname}_.${r}`:c.pathname=`${c.pathname}.${r}`:c.pathname==="/"?c.pathname=`_root.${r}`:s&&ea(c.pathname,s)==="/"?c.pathname=`${s.replace(/\/$/,"")}/_root.${r}`:c.pathname=`${c.pathname.replace(/\/$/,"")}.${r}`,c}async function Rj(t,s){if(t.id in s)return s[t.id];try{let o=await import(t.module);return s[t.id]=o,o}catch(o){return console.error(`Error loading route module \`${t.module}\`, reloading page...`),console.error(o),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Mj(t){return t==null?!1:t.href==null?t.rel==="preload"&&typeof t.imageSrcSet=="string"&&typeof t.imageSizes=="string":typeof t.rel=="string"&&typeof t.href=="string"}async function Ij(t,s,o){let r=await Promise.all(t.map(async c=>{let d=s.routes[c.route.id];if(d){let u=await Rj(d,o);return u.links?u.links():[]}return[]}));return zj(r.flat(1).filter(Mj).filter(c=>c.rel==="stylesheet"||c.rel==="preload").map(c=>c.rel==="stylesheet"?{...c,rel:"prefetch",as:"style"}:{...c,rel:"prefetch"}))}function gy(t,s,o,r,c,d){let u=(m,g)=>o[g]?m.route.id!==o[g].route.id:!0,p=(m,g)=>{var v;return o[g].pathname!==m.pathname||((v=o[g].route.path)==null?void 0:v.endsWith("*"))&&o[g].params["*"]!==m.params["*"]};return d==="assets"?s.filter((m,g)=>u(m,g)||p(m,g)):d==="data"?s.filter((m,g)=>{var b;let v=r.routes[m.route.id];if(!v||!v.hasLoader)return!1;if(u(m,g)||p(m,g))return!0;if(m.route.shouldRevalidate){let x=m.route.shouldRevalidate({currentUrl:new URL(c.pathname+c.search+c.hash,window.origin),currentParams:((b=o[0])==null?void 0:b.params)||{},nextUrl:new URL(t,window.origin),nextParams:m.params,defaultShouldRevalidate:!0});if(typeof x=="boolean")return x}return!0}):[]}function Oj(t,s,{includeHydrateFallback:o}={}){return Bj(t.map(r=>{let c=s.routes[r.route.id];if(!c)return[];let d=[c.module];return c.clientActionModule&&(d=d.concat(c.clientActionModule)),c.clientLoaderModule&&(d=d.concat(c.clientLoaderModule)),o&&c.hydrateFallbackModule&&(d=d.concat(c.hydrateFallbackModule)),c.imports&&(d=d.concat(c.imports)),d}).flat(1))}function Bj(t){return[...new Set(t)]}function Lj(t){let s={},o=Object.keys(t).sort();for(let r of o)s[r]=t[r];return s}function zj(t,s){let o=new Set;return new Set(s),t.reduce((r,c)=>{let d=JSON.stringify(Lj(c));return o.has(d)||(o.add(d),r.push({key:d,link:c})),r},[])}function Rx(){let t=y.useContext($o);return fm(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function $j(){let t=y.useContext(yd);return fm(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var pm=y.createContext(void 0);pm.displayName="FrameworkContext";function Mx(){let t=y.useContext(pm);return fm(t,"You must render this element inside a <HydratedRouter> element"),t}function Uj(t,s){let o=y.useContext(pm),[r,c]=y.useState(!1),[d,u]=y.useState(!1),{onFocus:p,onBlur:m,onMouseEnter:g,onMouseLeave:v,onTouchStart:b}=s,x=y.useRef(null);y.useEffect(()=>{if(t==="render"&&u(!0),t==="viewport"){let w=T=>{T.forEach(C=>{u(C.isIntersecting)})},N=new IntersectionObserver(w,{threshold:.5});return x.current&&N.observe(x.current),()=>{N.disconnect()}}},[t]),y.useEffect(()=>{if(r){let w=setTimeout(()=>{u(!0)},100);return()=>{clearTimeout(w)}}},[r]);let S=()=>{c(!0)},k=()=>{c(!1),u(!1)};return o?t!=="intent"?[d,x,{}]:[d,x,{onFocus:Ir(p,S),onBlur:Ir(m,k),onMouseEnter:Ir(g,S),onMouseLeave:Ir(v,k),onTouchStart:Ir(b,S)}]:[!1,x,{}]}function Ir(t,s){return o=>{t&&t(o),o.defaultPrevented||s(o)}}function Pj({page:t,...s}){let{router:o}=Rx(),r=y.useMemo(()=>yx(o.routes,t,o.basename),[o.routes,t,o.basename]);return r?y.createElement(Vj,{page:t,matches:r,...s}):null}function Hj(t){let{manifest:s,routeModules:o}=Mx(),[r,c]=y.useState([]);return y.useEffect(()=>{let d=!1;return Ij(t,s,o).then(u=>{d||c(u)}),()=>{d=!0}},[t,s,o]),r}function Vj({page:t,matches:s,...o}){let r=Zt(),{future:c,manifest:d,routeModules:u}=Mx(),{basename:p}=Rx(),{loaderData:m,matches:g}=$j(),v=y.useMemo(()=>gy(t,s,g,d,r,"data"),[t,s,g,d,r]),b=y.useMemo(()=>gy(t,s,g,d,r,"assets"),[t,s,g,d,r]),x=y.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let w=new Set,N=!1;if(s.forEach(C=>{var B;let D=d.routes[C.route.id];!D||!D.hasLoader||(!v.some(E=>E.route.id===C.route.id)&&C.route.id in m&&((B=u[C.route.id])!=null&&B.shouldRevalidate)||D.hasClientLoader?N=!0:w.add(C.route.id))}),w.size===0)return[];let T=Dj(t,p,c.unstable_trailingSlashAwareDataRequests,"data");return N&&w.size>0&&T.searchParams.set("_routes",s.filter(C=>w.has(C.route.id)).map(C=>C.route.id).join(",")),[T.pathname+T.search]},[p,c.unstable_trailingSlashAwareDataRequests,m,r,d,v,s,t,u]),S=y.useMemo(()=>Oj(b,d),[b,d]),k=Hj(b);return y.createElement(y.Fragment,null,x.map(w=>y.createElement("link",{key:w,rel:"prefetch",as:"fetch",href:w,...o})),S.map(w=>y.createElement("link",{key:w,rel:"modulepreload",href:w,...o})),k.map(({key:w,link:N})=>y.createElement("link",{key:w,nonce:o.nonce,...N,crossOrigin:N.crossOrigin??o.crossOrigin})))}function qj(...t){return s=>{t.forEach(o=>{typeof o=="function"?o(s):o!=null&&(o.current=s)})}}var Gj=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Gj&&(window.__reactRouterVersion="7.13.2")}catch{}function Fj({basename:t,children:s,unstable_useTransitions:o,window:r}){let c=y.useRef();c.current==null&&(c.current=Tw({window:r,v5Compat:!0}));let d=c.current,[u,p]=y.useState({action:d.action,location:d.location}),m=y.useCallback(g=>{o===!1?p(g):y.startTransition(()=>p(g))},[o]);return y.useLayoutEffect(()=>d.listen(m),[d,m]),y.createElement(xj,{basename:t,children:s,location:u.location,navigationType:u.action,navigator:d,unstable_useTransitions:o})}var Ix=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,mm=y.forwardRef(function({onClick:s,discover:o="render",prefetch:r="none",relative:c,reloadDocument:d,replace:u,unstable_mask:p,state:m,target:g,to:v,preventScrollReset:b,viewTransition:x,unstable_defaultShouldRevalidate:S,...k},w){let{basename:N,navigator:T,unstable_useTransitions:C}=y.useContext(Ln),D=typeof v=="string"&&Ix.test(v),B=Sx(v,N);v=B.to;let E=sj(v,{relative:c}),A=Zt(),P=null;if(p){let ie=vd(p,[],A.unstable_mask?A.unstable_mask.pathname:"/",!0);N!=="/"&&(ie.pathname=ie.pathname==="/"?N:Ts([N,ie.pathname])),P=T.createHref(ie)}let[I,U,Q]=Uj(r,k),$=Jj(v,{replace:u,unstable_mask:p,state:m,target:g,preventScrollReset:b,relative:c,viewTransition:x,unstable_defaultShouldRevalidate:S,unstable_useTransitions:C});function W(ie){s&&s(ie),ie.defaultPrevented||$(ie)}let pe=!(B.isExternal||d),H=y.createElement("a",{...k,...Q,href:(pe?P:void 0)||B.absoluteURL||E,onClick:pe?W:s,ref:qj(w,U),target:g,"data-discover":!D&&o==="render"?"true":void 0});return I&&!D?y.createElement(y.Fragment,null,H,y.createElement(Pj,{page:E})):H});mm.displayName="Link";var Zj=y.forwardRef(function({"aria-current":s="page",caseSensitive:o=!1,className:r="",end:c=!1,style:d,to:u,viewTransition:p,children:m,...g},v){let b=dl(u,{relative:g.relative}),x=Zt(),S=y.useContext(yd),{navigator:k,basename:w}=y.useContext(Ln),N=S!=null&&tN(b)&&p===!0,T=k.encodeLocation?k.encodeLocation(b).pathname:b.pathname,C=x.pathname,D=S&&S.navigation&&S.navigation.location?S.navigation.location.pathname:null;o||(C=C.toLowerCase(),D=D?D.toLowerCase():null,T=T.toLowerCase()),D&&w&&(D=ea(D,w)||D);const B=T!=="/"&&T.endsWith("/")?T.length-1:T.length;let E=C===T||!c&&C.startsWith(T)&&C.charAt(B)==="/",A=D!=null&&(D===T||!c&&D.startsWith(T)&&D.charAt(T.length)==="/"),P={isActive:E,isPending:A,isTransitioning:N},I=E?s:void 0,U;typeof r=="function"?U=r(P):U=[r,E?"active":null,A?"pending":null,N?"transitioning":null].filter(Boolean).join(" ");let Q=typeof d=="function"?d(P):d;return y.createElement(mm,{...g,"aria-current":I,className:U,ref:v,style:Q,to:u,viewTransition:p},typeof m=="function"?m(P):m)});Zj.displayName="NavLink";var Kj=y.forwardRef(({discover:t="render",fetcherKey:s,navigate:o,reloadDocument:r,replace:c,state:d,method:u=Gc,action:p,onSubmit:m,relative:g,preventScrollReset:v,viewTransition:b,unstable_defaultShouldRevalidate:x,...S},k)=>{let{unstable_useTransitions:w}=y.useContext(Ln),N=Qj(),T=eN(p,{relative:g}),C=u.toLowerCase()==="get"?"get":"post",D=typeof p=="string"&&Ix.test(p),B=E=>{if(m&&m(E),E.defaultPrevented)return;E.preventDefault();let A=E.nativeEvent.submitter,P=(A==null?void 0:A.getAttribute("formmethod"))||u,I=()=>N(A||E.currentTarget,{fetcherKey:s,method:P,navigate:o,replace:c,state:d,relative:g,preventScrollReset:v,viewTransition:b,unstable_defaultShouldRevalidate:x});w&&o!==!1?y.startTransition(()=>I()):I()};return y.createElement("form",{ref:k,method:C,action:T,onSubmit:r?m:B,...S,"data-discover":!D&&t==="render"?"true":void 0})});Kj.displayName="Form";function Yj(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ox(t){let s=y.useContext($o);return xt(s,Yj(t)),s}function Jj(t,{target:s,replace:o,unstable_mask:r,state:c,preventScrollReset:d,relative:u,viewTransition:p,unstable_defaultShouldRevalidate:m,unstable_useTransitions:g}={}){let v=bd(),b=Zt(),x=dl(t,{relative:u});return y.useCallback(S=>{if(jj(S,s)){S.preventDefault();let k=o!==void 0?o:el(b)===el(x),w=()=>v(t,{replace:k,unstable_mask:r,state:c,preventScrollReset:d,relative:u,viewTransition:p,unstable_defaultShouldRevalidate:m});g?y.startTransition(()=>w()):w()}},[b,v,x,o,r,c,s,t,d,u,p,m,g])}function hm(t){Xn(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let s=y.useRef(Rp(t)),o=y.useRef(!1),r=Zt(),c=y.useMemo(()=>Nj(r.search,o.current?null:s.current),[r.search]),d=bd(),u=y.useCallback((p,m)=>{const g=Rp(typeof p=="function"?p(new URLSearchParams(c)):p);o.current=!0,d("?"+g,m)},[d,c]);return[c,u]}var Wj=0,Xj=()=>`__${String(++Wj)}__`;function Qj(){let{router:t}=Ox("useSubmit"),{basename:s}=y.useContext(Ln),o=gj(),r=t.fetch,c=t.navigate;return y.useCallback(async(d,u={})=>{let{action:p,method:m,encType:g,formData:v,body:b}=Aj(d,s);if(u.navigate===!1){let x=u.fetcherKey||Xj();await r(x,o,u.action||p,{unstable_defaultShouldRevalidate:u.unstable_defaultShouldRevalidate,preventScrollReset:u.preventScrollReset,formData:v,body:b,formMethod:u.method||m,formEncType:u.encType||g,flushSync:u.flushSync})}else await c(u.action||p,{unstable_defaultShouldRevalidate:u.unstable_defaultShouldRevalidate,preventScrollReset:u.preventScrollReset,formData:v,body:b,formMethod:u.method||m,formEncType:u.encType||g,replace:u.replace,state:u.state,fromRouteId:o,flushSync:u.flushSync,viewTransition:u.viewTransition})},[r,c,s,o])}function eN(t,{relative:s}={}){let{basename:o}=y.useContext(Ln),r=y.useContext(Qn);xt(r,"useFormAction must be used inside a RouteContext");let[c]=r.matches.slice(-1),d={...dl(t||".",{relative:s})},u=Zt();if(t==null){d.search=u.search;let p=new URLSearchParams(d.search),m=p.getAll("index");if(m.some(v=>v==="")){p.delete("index"),m.filter(b=>b).forEach(b=>p.append("index",b));let v=p.toString();d.search=v?`?${v}`:""}}return(!t||t===".")&&c.route.index&&(d.search=d.search?d.search.replace(/^\?/,"?index&"):"?index"),o!=="/"&&(d.pathname=d.pathname==="/"?o:Ts([o,d.pathname])),el(d)}function tN(t,{relative:s}={}){let o=y.useContext(wx);xt(o!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Ox("useViewTransitionState"),c=dl(t,{relative:s});if(!o.isTransitioning)return!1;let d=ea(o.currentLocation.pathname,r)||o.currentLocation.pathname,u=ea(o.nextLocation.pathname,r)||o.nextLocation.pathname;return tl(c.pathname,u)!=null||tl(c.pathname,d)!=null}function kt(){const t=bd();return y.useCallback((s,o)=>{typeof s=="number"?t(s):t(s,o)},[t])}function gm(t){return`/sessions/${encodeURIComponent(t)}`}function $a(t,s){return s?`/environments/${encodeURIComponent(s)}/workspaces/${encodeURIComponent(t)}`:`/workspaces/${encodeURIComponent(t)}`}function On(t,s,o,r){const c=encodeURIComponent(t);let d;return o&&r?d=`/environments/${encodeURIComponent(r)}/workspaces/${encodeURIComponent(o)}/tasks/${c}`:o?d=`/workspaces/${encodeURIComponent(o)}/tasks/${c}`:d=`/tasks/${c}`,s?`${d}/${s}`:d}function Di(t,s,o){const r=new URLSearchParams;t&&r.set("workspace",t),s&&r.set("parent",s);const c=r.toString();if(t&&o){const d=`/environments/${encodeURIComponent(o)}/workspaces/${encodeURIComponent(t)}/tasks/new`;return s?`${d}?parent=${encodeURIComponent(s)}`:d}return c?`/tasks/new?${c}`:"/tasks/new"}function Bx(t){return`/sessions/new?${new URLSearchParams({env:t}).toString()}`}const Ro="/environments",nN="/environments/new";function ji(t){return`/environments/${encodeURIComponent(t)}`}function sN(t){return`/environments/${encodeURIComponent(t)}/edit`}const Do="/settings",aN="/settings/credentials",qf="/settings/personas",iN="/settings/personas/new";function Lx(t){return`/settings/personas/${encodeURIComponent(t)}`}const oN="/settings/shortcuts",rN="/pair",lN="/chat",Ni="/",cN="/tasks",zx="/workspaces/new",$x="/knowledge",_d="/findings";function dN(t,s){return t&&s?`/environments/${encodeURIComponent(s)}/workspaces/${encodeURIComponent(t)}/findings`:_d}function Mp(t,s,o){const r=encodeURIComponent(t);return s&&o?`/environments/${encodeURIComponent(o)}/workspaces/${encodeURIComponent(s)}/findings/${r}`:`/findings/${r}`}const uN=lw,fN={task:Sw};function pN({workspaceId:t,environmentId:s,tasks:o,resolvedThemeId:r}){const c=kt(),d=y.useMemo(()=>o.filter(b=>b.workspaceId===t),[o,t]),{nodes:u,edges:p}=WT(d),m=y.useMemo(()=>{const b=getComputedStyle(document.documentElement),x={};for(const[S,k]of Object.entries(uN))x[S]=b.getPropertyValue(k).trim()||"#6b7a8d";return x},[r]),g=y.useCallback((b,x)=>{c(On(x.id,void 0,t,s))},[c,t,s]),v=y.useCallback(b=>{const x=b.data;return m[x.task.status]||m.pending},[m]);return d.length===0?i.jsxs("div",{className:hn.emptyCta,children:[i.jsx("button",{className:hn.ctaButton,onClick:()=>c(Di(t,void 0,s)),children:"Create Task"}),i.jsx("div",{className:hn.ctaDescription,children:"Create tasks to see the dependency graph"})]}):i.jsx("div",{className:hn.dagContainer,children:i.jsxs(rT,{nodes:u,edges:p,nodeTypes:fN,onNodeClick:g,fitView:!0,fitViewOptions:{padding:.2},minZoom:.3,maxZoom:2,children:[i.jsx(lT,{variant:cT.Dots,gap:24,size:1,color:"var(--text-disabled)"}),i.jsx(dT,{showInteractive:!1}),i.jsx(uT,{nodeColor:v,maskColor:"var(--bg-overlay)",style:{background:"var(--bg-inset)"}})]})})}const mN="_breadcrumbs_17or2_1",hN="_list_17or2_11",gN="_item_17or2_21",vN="_separator_17or2_28",yN="_link_17or2_34",bN="_current_17or2_57",ko={breadcrumbs:mN,list:hN,item:gN,separator:vN,link:yN,current:bN};function Ns({segments:t}){return i.jsx("nav",{className:ko.breadcrumbs,"aria-label":"Breadcrumb","data-testid":"breadcrumbs",children:i.jsx("ol",{className:ko.list,children:t.map((s,o)=>{const r=o===t.length-1;return i.jsxs("li",{className:ko.item,children:[o>0&&i.jsx("span",{className:ko.separator,"aria-hidden":"true",children:i.jsx(sa,{size:lt})}),s.url&&!r?i.jsx(mm,{className:ko.link,to:s.url,title:s.label,children:s.label}):i.jsx("span",{className:ko.current,"aria-current":"page",title:s.label,children:s.label})]},o)})})})}const xN="_btn_dwk2o_1",_N="_sm_dwk2o_22",kN="_md_dwk2o_28",SN="_lg_dwk2o_34",TN="_primary_dwk2o_40",wN="_danger_dwk2o_55",jN="_outline_dwk2o_70",NN="_ghost_dwk2o_80",Gf={btn:xN,sm:_N,md:kN,lg:SN,primary:TN,danger:wN,outline:jN,ghost:NN},Js=y.forwardRef(function({variant:s="primary",size:o="md",className:r,children:c,...d},u){const p=[Gf.btn,Gf[s],Gf[o],r].filter(Boolean).join(" ");return i.jsx("button",{ref:u,className:p,...d,children:c})}),CN="_copyButton_1bqk0_1",EN={copyButton:CN},AN=2e3;function DN({text:t,className:s,"data-testid":o}){const[r,c]=y.useState(!1),d=y.useRef(void 0);y.useEffect(()=>()=>{d.current!==void 0&&clearTimeout(d.current)},[]);const u=y.useCallback(async()=>{try{await navigator.clipboard.writeText(t),c(!0),d.current!==void 0&&clearTimeout(d.current),d.current=setTimeout(()=>{c(!1),d.current=void 0},AN)}catch{}},[t]);return i.jsx("button",{type:"button",className:`${EN.copyButton} ${s??""}`,onClick:()=>{u().catch(()=>{})},"aria-label":r?"Copied":"Copy to clipboard","data-testid":o??"copy-button",children:r?i.jsx(Ei,{size:tn,"aria-hidden":"true"}):i.jsx(gx,{size:tn,"aria-hidden":"true"})})}const RN="_banner_bxqlh_1",MN="_label_bxqlh_15",IN="_text_bxqlh_25",ON="_link_bxqlh_29",Dc={banner:RN,label:MN,text:IN,link:ON};function BN(){return i.jsxs("div",{className:Dc.banner,"data-testid":"demo-banner",children:[i.jsx("span",{className:Dc.label,children:"DEMO"}),i.jsxs("span",{className:Dc.text,children:["This is an interactive demo with mock data."," ",i.jsx("a",{href:"https://github.com/nick-pape/grackle",target:"_blank",rel:"noopener noreferrer",className:Dc.link,children:"Install Grackle"})," ","to use it for real."]})]})}const LN="_container_og0yp_1",zN="_chevronButton_og0yp_6",$N="_mainButton_og0yp_6",UN="_sm_og0yp_34",PN="_md_og0yp_34",HN="_lg_og0yp_34",VN="_primary_og0yp_57",qN="_danger_og0yp_70",GN="_outline_og0yp_83",FN="_ghost_og0yp_92",ZN="_dropdown_og0yp_100",KN="_option_og0yp_113",YN="_optionLabel_og0yp_130",JN="_optionDesc_og0yp_135",Fs={container:LN,chevronButton:zN,mainButton:$N,sm:UN,md:PN,lg:HN,primary:VN,danger:qN,outline:GN,ghost:FN,dropdown:ZN,option:KN,optionLabel:YN,optionDesc:JN};function Ux({label:t,onClick:s,options:o,variant:r="primary",size:c="md","data-testid":d}){const[u,p]=y.useState(!1),m=y.useRef(null);y.useEffect(()=>{if(!u)return;function x(S){m.current&&S.target instanceof Node&&!m.current.contains(S.target)&&p(!1)}return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[u]),y.useEffect(()=>{if(!u)return;function x(S){S.key==="Escape"&&p(!1)}return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[u]);const g=Fs[r]||"",v=Fs[c]||"",b=()=>{u&&p(!1),s()};return i.jsxs("div",{ref:m,className:Fs.container,"data-testid":d,children:[i.jsx("button",{type:"button",className:`${Fs.mainButton} ${g} ${v}`,onClick:b,"data-testid":d?`${d}-main`:void 0,children:t}),i.jsx("button",{type:"button",className:`${Fs.chevronButton} ${g} ${v}`,onClick:()=>p(x=>!x),"aria-label":`More options for ${t}`,"aria-haspopup":"menu","aria-expanded":u,"data-testid":d?`${d}-chevron`:void 0,children:i.jsx(hx,{size:tn,"aria-hidden":"true"})}),u&&i.jsx("div",{className:Fs.dropdown,"data-testid":d?`${d}-menu`:void 0,children:o.map((x,S)=>i.jsxs("button",{type:"button",className:Fs.option,onClick:()=>{x.onClick(),p(!1)},children:[i.jsx("span",{className:Fs.optionLabel,children:x.label}),x.description&&i.jsx("span",{className:Fs.optionDesc,children:x.description})]},S))})]})}function Ip(){Ip=function(c,d){return new o(c,void 0,d)};var t=RegExp.prototype,s=new WeakMap;function o(c,d,u){var p=new RegExp(c,d);return s.set(p,u||s.get(c)),ed(p,o.prototype)}function r(c,d){var u=s.get(d);return Object.keys(u).reduce(function(p,m){var g=u[m];if(typeof g=="number")p[m]=c[g];else{for(var v=0;c[g[v]]===void 0&&v+1<g.length;)v++;p[m]=c[g[v]]}return p},Object.create(null))}return(function(c,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(d&&d.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),Object.defineProperty(c,"prototype",{writable:!1}),d&&ed(c,d)})(o,RegExp),o.prototype.exec=function(c){var d=t.exec.call(this,c);if(d){d.groups=r(d,this);var u=d.indices;u&&(u.groups=r(u,this))}return d},o.prototype[Symbol.replace]=function(c,d){if(typeof d=="string"){var u=s.get(this);return t[Symbol.replace].call(this,c,d.replace(/\$<([^>]+)>/g,function(m,g){var v=u[g];return"$"+(Array.isArray(v)?v.join("$"):v)}))}if(typeof d=="function"){var p=this;return t[Symbol.replace].call(this,c,function(){var m=arguments;return typeof m[m.length-1]!="object"&&(m=[].slice.call(m)).push(r(m,p)),d.apply(this,m)})}return t[Symbol.replace].call(this,c,d)},Ip.apply(this,arguments)}function ed(t,s){return ed=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(o,r){return o.__proto__=r,o},ed(t,s)}function vy(t,s){(s==null||s>t.length)&&(s=t.length);for(var o=0,r=new Array(s);o<s;o++)r[o]=t[o];return r}function Ff(t,s){var o=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(o)return(o=o.call(t)).next.bind(o);if(Array.isArray(t)||(o=(function(c,d){if(c){if(typeof c=="string")return vy(c,d);var u=Object.prototype.toString.call(c).slice(8,-1);return u==="Object"&&c.constructor&&(u=c.constructor.name),u==="Map"||u==="Set"?Array.from(c):u==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(u)?vy(c,d):void 0}})(t))||s){o&&(t=o);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
228
228
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var WN=(function(t){return function(s){return s===void 0&&(s={}),(function(r,c){if(c&&!r.registered(c))throw new Error('The default language "'+c+'" is not registered with refractor.')})(t,s.defaultLanguage),function(r){TT(r,"element",o)};function o(r,c,d){var u,p;if(d&&d.tagName==="pre"&&r.tagName==="code"){var m=(r==null||(u=r.data)==null?void 0:u.meta)||(r==null||(p=r.properties)==null?void 0:p.metastring)||"";r.properties.className?typeof r.properties.className=="boolean"?r.properties.className=[]:Array.isArray(r.properties.className)||(r.properties.className=[r.properties.className]):r.properties.className=[];var g,v,b=(function(E){for(var A,P=Ff(E.properties.className);!(A=P()).done;){var I=A.value;if(I.slice(0,9)==="language-")return I.slice(9).toLowerCase()}return null})(r);if(!b&&s.defaultLanguage&&r.properties.className.push("language-"+(b=s.defaultLanguage)),r.properties.className.push("code-highlight"),b)try{var x,S;S=(x=b)!=null&&x.includes("diff-")?b.split("-")[1]:b,g=t.highlight(Ec(r),S),d.properties.className=(d.properties.className||[]).concat("language-"+S)}catch(E){if(!s.ignoreMissing||!/Unknown language/.test(E.message))throw E;g=r}else g=r;g.children=(v=1,function E(A){return A.reduce(function(P,I){if(I.type==="text"){var U=I.value,Q=(U.match(/\n/g)||"").length;if(Q===0)I.position={start:{line:v,column:1},end:{line:v,column:1}},P.push(I);else for(var $,W=U.split(`
|
|
229
229
|
`),pe=Ff(W.entries());!($=pe()).done;){var H=$.value,ie=H[0],L=H[1];P.push({type:"text",value:ie===W.length-1?L:L+`
|
|
230
|
-
`,position:{start:{line:v+ie,column:1},end:{line:v+ie,column:1}}})}return v+=Q,P}if(Object.prototype.hasOwnProperty.call(I,"children")){var Z=v;return I.children=E(I.children),P.push(I),I.position={start:{line:Z,column:1},end:{line:v,column:1}},P}return P.push(I),P},[])})(g.children),g.position=g.children.length>0?{start:{line:g.children[0].position.start.line,column:0},end:{line:g.children[g.children.length-1].position.end.line,column:0}}:{start:{line:0,column:0},end:{line:0,column:0}};for(var k,w=(function(E){var A=/{([\d,-]+)}/,P=E.split(",").map(function(Q){return Q.trim()}).join();if(A.test(P)){var I=A.exec(P)[1],U=jT(I);return function(Q){return U.includes(Q+1)}}return function(){return!1}})(m),N=(function(E){var A=Ip(/showLineNumbers=(\d+)/i,{lines:1});if(A.test(E)){var P=A.exec(E);return Number(P.groups.lines)}return 1})(m),T=(function(E){for(var A=new Array(E),P=0;P<E;P++)A[P]={type:"element",tagName:"span",properties:{className:[]},children:[]};return A})(g.position.end.line),C=["showlinenumbers=false",'showlinenumbers="false"',"showlinenumbers={false}"],D=function(){var E,A,P=k.value,I=P[0],U=P[1];U.properties.className=["code-line"];var Q=NT(g,function($){return $.position.start.line<=I+1&&$.position.end.line>=I+1});U.children=Q.children,(m.toLowerCase().includes("showLineNumbers".toLowerCase())||s.showLineNumbers===!0||typeof s.showLineNumbers=="object"&&s.showLineNumbers.includes(b))&&!C.some(function($){return m.toLowerCase().includes($)})&&(U.properties.line=[(I+N).toString()],U.properties.className.push("line-number")),w(I)&&U.properties.className.push("highlight-line"),(b==="diff"||(E=b)!=null&&E.includes("diff-"))&&Ec(U).substring(0,1)==="-"?U.properties.className.push("deleted"):(b==="diff"||(A=b)!=null&&A.includes("diff-"))&&Ec(U).substring(0,1)==="+"&&U.properties.className.push("inserted")},B=Ff(T.entries());!(k=B()).done;)D();T.length>0&&Ec(T[T.length-1]).trim()===""&&T.pop(),r.children=T}}}})(wT);function Mo(t){if(t>=1e6)return`${(t/1e6).toFixed(1)}M`;if(t>=1e3){const s=Number((t/1e3).toFixed(1));return s>=1e3?`${(t/1e6).toFixed(1)}M`:`${s.toFixed(1)}k`}return String(t)}function Ss(t){
|
|
230
|
+
`,position:{start:{line:v+ie,column:1},end:{line:v+ie,column:1}}})}return v+=Q,P}if(Object.prototype.hasOwnProperty.call(I,"children")){var Z=v;return I.children=E(I.children),P.push(I),I.position={start:{line:Z,column:1},end:{line:v,column:1}},P}return P.push(I),P},[])})(g.children),g.position=g.children.length>0?{start:{line:g.children[0].position.start.line,column:0},end:{line:g.children[g.children.length-1].position.end.line,column:0}}:{start:{line:0,column:0},end:{line:0,column:0}};for(var k,w=(function(E){var A=/{([\d,-]+)}/,P=E.split(",").map(function(Q){return Q.trim()}).join();if(A.test(P)){var I=A.exec(P)[1],U=jT(I);return function(Q){return U.includes(Q+1)}}return function(){return!1}})(m),N=(function(E){var A=Ip(/showLineNumbers=(\d+)/i,{lines:1});if(A.test(E)){var P=A.exec(E);return Number(P.groups.lines)}return 1})(m),T=(function(E){for(var A=new Array(E),P=0;P<E;P++)A[P]={type:"element",tagName:"span",properties:{className:[]},children:[]};return A})(g.position.end.line),C=["showlinenumbers=false",'showlinenumbers="false"',"showlinenumbers={false}"],D=function(){var E,A,P=k.value,I=P[0],U=P[1];U.properties.className=["code-line"];var Q=NT(g,function($){return $.position.start.line<=I+1&&$.position.end.line>=I+1});U.children=Q.children,(m.toLowerCase().includes("showLineNumbers".toLowerCase())||s.showLineNumbers===!0||typeof s.showLineNumbers=="object"&&s.showLineNumbers.includes(b))&&!C.some(function($){return m.toLowerCase().includes($)})&&(U.properties.line=[(I+N).toString()],U.properties.className.push("line-number")),w(I)&&U.properties.className.push("highlight-line"),(b==="diff"||(E=b)!=null&&E.includes("diff-"))&&Ec(U).substring(0,1)==="-"?U.properties.className.push("deleted"):(b==="diff"||(A=b)!=null&&A.includes("diff-"))&&Ec(U).substring(0,1)==="+"&&U.properties.className.push("inserted")},B=Ff(T.entries());!(k=B()).done;)D();T.length>0&&Ec(T[T.length-1]).trim()===""&&T.pop(),r.children=T}}}})(wT);function Mo(t){if(t>=1e6)return`${(t/1e6).toFixed(1)}M`;if(t>=1e3){const s=Number((t/1e3).toFixed(1));return s>=1e3?`${(t/1e6).toFixed(1)}M`:`${s.toFixed(1)}k`}return String(t)}function Ss(t){if(t===0)return"-";const s=t/1e5;if(s<.01){const o=t<5?5:4;return`$${s.toFixed(o)}`}return`$${s.toFixed(2)}`}const yy=new Set(["grackle"]);function Uo(t){if(t.startsWith("mcp__")){const o=t.indexOf("__",5);if(o>5){const r=t.slice(5,o);if(yy.has(r))return t.slice(o+2)}}const s=t.indexOf("-");if(s>0){const o=t.slice(0,s);if(yy.has(o))return t.slice(s+1)}return t}const XN={read:"file-read",view:"file-read",edit:"file-edit",file_change:"file-edit",write:"file-write",bash:"shell",powershell:"shell",command_execution:"shell",grep:"search",glob:"search",todowrite:"todo",update_plan:"todo",todo_write:"todo",report_intent:"metadata",finding_post:"finding",finding_list:"finding",task_list:"task",task_create:"task",task_show:"task",task_update:"task",task_start:"task",task_complete:"task",task_resume:"task",task_delete:"task",workpad_write:"workpad",workpad_read:"workpad",knowledge_search:"knowledge",knowledge_get_node:"knowledge",knowledge_create_node:"knowledge",ipc_spawn:"ipc",ipc_write:"ipc",ipc_close:"ipc",ipc_list_fds:"ipc",ipc_terminate:"ipc",ipc_create_stream:"ipc",ipc_attach:"ipc",toolsearch:"tool-search",agent:"agent",task:"agent",read_agent:"agent"};function QN(t){const s=Uo(t);return XN[s.toLowerCase()]??"generic"}const eC="_card_qkm9i_2",tC="_cardBlue_qkm9i_20",nC="_cardOrange_qkm9i_24",sC="_cardGreen_qkm9i_28",aC="_cardPurple_qkm9i_32",iC="_cardNeutral_qkm9i_36",oC="_cardRed_qkm9i_40",rC="_cardTeal_qkm9i_44",lC="_header_qkm9i_48",cC="_icon_qkm9i_55",dC="_toolName_qkm9i_64",uC="_fileName_qkm9i_71",fC="_badge_qkm9i_80",pC="_spacer_qkm9i_87",mC="_bodyToggle_qkm9i_91",hC="_chevron_qkm9i_109",gC="_chevronExpanded_qkm9i_115",vC="_pre_qkm9i_119",yC="_diffAdd_qkm9i_143",bC="_diffRemove_qkm9i_155",xC="_diffContext_qkm9i_167",_C="_diffHeader_qkm9i_176",kC="_diffLine_qkm9i_182",SC="_exitOk_qkm9i_188",TC="_exitError_qkm9i_194",wC="_exitPending_qkm9i_200",jC="_inProgress_qkm9i_228",NC="_metadata_qkm9i_232",CC="_metadataPrefix_qkm9i_239",M={card:eC,cardBlue:tC,cardOrange:nC,cardGreen:sC,cardPurple:aC,cardNeutral:iC,cardRed:oC,cardTeal:rC,header:lC,icon:cC,toolName:dC,fileName:uC,badge:fC,spacer:pC,bodyToggle:mC,chevron:hC,chevronExpanded:gC,pre:vC,diffAdd:yC,diffRemove:bC,diffContext:xC,diffHeader:_C,diffLine:kC,exitOk:SC,exitError:TC,exitPending:wC,inProgress:jC,metadata:NC,metadataPrefix:CC};function EC(t){if(t==null||typeof t!="object")return"";const s=t;return typeof s.file_path=="string"?s.file_path:typeof s.path=="string"?s.path:""}function AC(t){const s=t.split(/[/\\]/);return s[s.length-1]||t}const Zf=5;function by({tool:t,args:s,result:o,isError:r,writeVariant:c}){const[d,u]=y.useState(!1),p=EC(s),m=AC(p),g=o===void 0,v=r?M.cardRed:c?M.cardGreen:M.cardBlue,b=c?"var(--accent-green)":"var(--accent-blue)",x=c?i.jsx(_2,{size:tn}):i.jsx(S2,{size:tn}),S=c?"tool-card-file-write":"tool-card-file-read",k=(o==null?void 0:o.split(`
|
|
231
231
|
`))??[],w=k.length>Zf,N=d?k:k.slice(0,Zf);return i.jsxs("div",{className:`${M.card} ${v} ${g?M.inProgress:""}`,"data-testid":S,children:[i.jsxs("div",{className:M.header,children:[i.jsx("span",{className:M.icon,children:x}),i.jsx("span",{className:M.toolName,style:{color:b},children:t}),m&&i.jsx("span",{className:M.fileName,title:p,children:m}),!g&&k.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:M.spacer}),i.jsxs("span",{className:M.badge,children:[k.length," lines"]})]})]}),r&&o&&i.jsx("pre",{className:M.pre,"data-testid":"tool-card-error",children:o}),!r&&!g&&k.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("pre",{className:M.pre,"data-testid":"tool-card-content",children:N.map((T,C)=>i.jsxs("span",{className:M.diffLine,children:[i.jsx("span",{style:{color:"var(--text-tertiary)",userSelect:"none",marginRight:"var(--space-sm)",display:"inline-block",width:"3ch",textAlign:"right"},children:C+1}),T]},C))}),w&&i.jsxs("button",{type:"button",className:M.bodyToggle,onClick:()=>{u(T=>!T)},"aria-expanded":d,"data-testid":"tool-card-toggle",children:[i.jsx("span",{className:`${M.chevron} ${d?M.chevronExpanded:""}`,"aria-hidden":"true",children:i.jsx(sa,{size:lt})}),d?"collapse":`${k.length-Zf} more lines`]})]})]})}function DC(t){const s=t.split(`
|
|
232
232
|
`),o=[];for(const r of s)r.startsWith("diff --git")||r.startsWith("index ")||(r.startsWith("--- ")||r.startsWith("+++ "))&&!r.startsWith("---- ")&&!r.startsWith("++++ ")||(r.startsWith("@@")?o.push({type:"header",content:r}):r.startsWith("+")?o.push({type:"add",content:r.slice(1)}):r.startsWith("-")?o.push({type:"remove",content:r.slice(1)}):r.startsWith(" ")?o.push({type:"context",content:r.slice(1)}):r===""&&o.push({type:"context",content:""}));return o}function RC(t,s){const o=t.split(`
|
|
233
233
|
`),r=s.split(`
|
|
@@ -252,7 +252,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
252
252
|
`))??[],S=x.length>sp,k=c?b:x.slice(0,sp).join(`
|
|
253
253
|
`),w=m.isPoll?"Subagent":"Agent";return i.jsxs("div",{className:`${M.card} ${r?M.cardRed:M.cardTeal} ${g?M.inProgress:""}`,"data-testid":"tool-card-agent",children:[i.jsxs("div",{className:M.header,children:[i.jsx("span",{className:M.icon,style:{color:"var(--accent-teal, #2dd4bf)"},children:"▶"}),i.jsx("span",{className:M.toolName,style:{color:"var(--accent-teal, #2dd4bf)"},children:w}),m.agentType&&i.jsx("span",{className:is.badgePill,"data-testid":"tool-card-agent-type",children:m.agentType}),m.model&&i.jsx("span",{className:is.modelBadge,"data-testid":"tool-card-agent-model",children:m.model}),m.isBackground&&i.jsxs("span",{className:is.backgroundBadge,"data-testid":"tool-card-agent-background",children:[i.jsx("span",{className:g?is.backgroundDotPulsing:is.backgroundDot,children:"●"}),"BG"]}),m.agentName&&i.jsx("span",{className:M.fileName,"data-testid":"tool-card-agent-name",children:m.agentName}),m.agentId&&i.jsx("span",{className:M.fileName,"data-testid":"tool-card-agent-id",children:m.agentId}),i.jsx("span",{className:M.spacer}),g&&!m.isBackground&&i.jsx("span",{className:M.exitPending,"data-testid":"tool-card-pending",children:"●"})]}),m.description&&i.jsx("div",{className:is.description,"data-testid":"tool-card-agent-description",children:m.isResume?`Resuming: ${m.description}`:m.description}),v&&i.jsxs("div",{className:is.statusLine,"data-testid":"tool-card-agent-status",children:[i.jsx("span",{className:v.status==="completed"?is.statusCompleted:v.status==="running"?is.statusRunning:is.statusError,children:v.status}),v.metadata&&i.jsx("span",{children:v.metadata})]}),m.prompt&&i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",className:is.promptToggle,onClick:()=>{p(N=>!N)},"aria-expanded":u,"data-testid":"tool-card-prompt-toggle",children:[i.jsx("span",{className:`${M.chevron} ${u?M.chevronExpanded:""}`,children:"▸"}),"prompt"]}),u&&i.jsx("pre",{className:M.pre,"data-testid":"tool-card-prompt",children:m.prompt})]}),r&&o&&i.jsx("pre",{className:M.pre,"data-testid":"tool-card-error",children:o}),!r&&!g&&b&&i.jsxs(i.Fragment,{children:[i.jsx("pre",{className:M.pre,"data-testid":"tool-card-result",children:k}),S&&i.jsxs("button",{type:"button",className:M.bodyToggle,onClick:()=>{d(N=>!N)},"aria-expanded":c,"data-testid":"tool-card-toggle",children:[i.jsx("span",{className:`${M.chevron} ${c?M.chevronExpanded:""}`,children:"▸"}),c?"collapse":`${x.length-sp} more lines`]})]})]})}function ap(t){switch(QN(t.tool)){case"file-read":return i.jsx(by,{...t});case"file-edit":return i.jsx(zC,{...t});case"file-write":return i.jsx(by,{...t,writeVariant:!0});case"shell":return i.jsx(VC,{...t});case"search":return i.jsx(GC,{...t});case"todo":return i.jsx(dE,{...t});case"metadata":return i.jsx(fE,{...t});case"finding":return i.jsx(hE,{...t});case"task":return i.jsx(bE,{...t});case"workpad":return i.jsx(kE,{...t});case"knowledge":return i.jsx(wE,{...t});case"ipc":return i.jsx(CE,{...t});case"tool-search":return i.jsx(AE,{...t});case"agent":return i.jsx(KE,{...t});default:return i.jsx(ME,{...t})}}const YE="_systemContextEvent_hmqlm_1",JE="_systemContextHeader_hmqlm_7",WE="_systemContextBadge_hmqlm_28",XE="_systemContextToggle_hmqlm_37",QE="_systemContextPre_hmqlm_43",eA="_systemContextEllipsis_hmqlm_54",tA="_systemEvent_hmqlm_58",nA="_systemTimestamp_hmqlm_65",sA="_textEvent_hmqlm_69",aA="_codeBlockWrapper_hmqlm_156",iA="_codeBlockCopyButton_hmqlm_159",oA="_errorEvent_hmqlm_163",rA="_statusEvent_hmqlm_171",lA="_userInputEvent_hmqlm_180",cA="_userInputContent_hmqlm_186",dA="_signalEvent_hmqlm_203",uA="_signalBadge_hmqlm_214",fA="_signalContent_hmqlm_223",pA="_usageEvent_hmqlm_228",mA="_usageBadge_hmqlm_235",hA="_defaultEvent_hmqlm_244",$t={systemContextEvent:YE,systemContextHeader:JE,systemContextBadge:WE,systemContextToggle:XE,systemContextPre:QE,systemContextEllipsis:eA,systemEvent:tA,systemTimestamp:nA,textEvent:sA,codeBlockWrapper:aA,codeBlockCopyButton:iA,errorEvent:oA,statusEvent:rA,userInputEvent:lA,userInputContent:cA,signalEvent:dA,signalBadge:uA,signalContent:fA,usageEvent:pA,usageBadge:mA,defaultEvent:hA},ky=3;function gA({content:t}){const[s,o]=y.useState(!1),r=t.split(`
|
|
254
254
|
`),c=r.length>ky,d=s?t:r.slice(0,ky).join(`
|
|
255
|
-
`);return i.jsxs("div",{className:$t.systemContextEvent,"data-testid":"system-context-event",children:[i.jsxs("button",{type:"button",className:$t.systemContextHeader,onClick:()=>{o(u=>!u)},"aria-expanded":s,children:[i.jsx("span",{className:$t.systemContextBadge,children:"SYSTEM PROMPT"}),c&&i.jsx("span",{className:$t.systemContextToggle,"aria-hidden":"true",children:s?i.jsx(hx,{size:lt}):i.jsx(sa,{size:lt})})]}),i.jsxs("pre",{className:$t.systemContextPre,children:[d,!s&&c&&i.jsx("span",{className:$t.systemContextEllipsis,children:"…"})]})]})}function vA({time:t,content:s}){return i.jsxs("div",{className:$t.systemEvent,children:[i.jsxs("span",{className:$t.systemTimestamp,children:["[",t,"]"]})," ",s]})}function Op(t){return typeof t=="string"?t:typeof t=="number"?String(t):Array.isArray(t)?t.map(Op).join(""):t!=null&&typeof t=="object"&&"props"in t?Op(t.props.children):""}function yA({children:t,node:s,...o}){const r=Op(t);return i.jsxs("div",{className:$t.codeBlockWrapper,children:[i.jsx("pre",{...o,children:t}),i.jsx(DN,{text:r,"data-testid":"copy-code-block",className:$t.codeBlockCopyButton})]})}const bA={pre:yA};function xA({content:t}){return i.jsx("div",{className:$t.textEvent,children:i.jsx(hd,{remarkPlugins:[gd],rehypePlugins:[WN],components:bA,children:t})})}function _A({content:t}){return i.jsxs("div",{className:$t.errorEvent,children:["Error: ",t]})}function kA({content:t}){return i.jsxs("div",{className:$t.statusEvent,children:["--- ",t," ---"]})}function SA({content:t}){return i.jsx("div",{className:$t.userInputEvent,children:i.jsx("span",{className:$t.userInputContent,children:t})})}function TA({content:t}){return i.jsxs("div",{className:$t.signalEvent,"data-testid":"signal-event",children:[i.jsx("span",{className:$t.signalBadge,children:"SIGNAL"}),i.jsx("span",{className:$t.signalContent,children:t})]})}function wA({content:t}){let s=t;try{const o=JSON.parse(t),r=Number(o.input_tokens)||0,c=Number(o.output_tokens)||0,d=Mo(r+c),u=Ss(Number(o.
|
|
255
|
+
`);return i.jsxs("div",{className:$t.systemContextEvent,"data-testid":"system-context-event",children:[i.jsxs("button",{type:"button",className:$t.systemContextHeader,onClick:()=>{o(u=>!u)},"aria-expanded":s,children:[i.jsx("span",{className:$t.systemContextBadge,children:"SYSTEM PROMPT"}),c&&i.jsx("span",{className:$t.systemContextToggle,"aria-hidden":"true",children:s?i.jsx(hx,{size:lt}):i.jsx(sa,{size:lt})})]}),i.jsxs("pre",{className:$t.systemContextPre,children:[d,!s&&c&&i.jsx("span",{className:$t.systemContextEllipsis,children:"…"})]})]})}function vA({time:t,content:s}){return i.jsxs("div",{className:$t.systemEvent,children:[i.jsxs("span",{className:$t.systemTimestamp,children:["[",t,"]"]})," ",s]})}function Op(t){return typeof t=="string"?t:typeof t=="number"?String(t):Array.isArray(t)?t.map(Op).join(""):t!=null&&typeof t=="object"&&"props"in t?Op(t.props.children):""}function yA({children:t,node:s,...o}){const r=Op(t);return i.jsxs("div",{className:$t.codeBlockWrapper,children:[i.jsx("pre",{...o,children:t}),i.jsx(DN,{text:r,"data-testid":"copy-code-block",className:$t.codeBlockCopyButton})]})}const bA={pre:yA};function xA({content:t}){return i.jsx("div",{className:$t.textEvent,children:i.jsx(hd,{remarkPlugins:[gd],rehypePlugins:[WN],components:bA,children:t})})}function _A({content:t}){return i.jsxs("div",{className:$t.errorEvent,children:["Error: ",t]})}function kA({content:t}){return i.jsxs("div",{className:$t.statusEvent,children:["--- ",t," ---"]})}function SA({content:t}){return i.jsx("div",{className:$t.userInputEvent,children:i.jsx("span",{className:$t.userInputContent,children:t})})}function TA({content:t}){return i.jsxs("div",{className:$t.signalEvent,"data-testid":"signal-event",children:[i.jsx("span",{className:$t.signalBadge,children:"SIGNAL"}),i.jsx("span",{className:$t.signalContent,children:t})]})}function wA({content:t}){let s=t;try{const o=JSON.parse(t),r=Number(o.input_tokens)||0,c=Number(o.output_tokens)||0,d=Mo(r+c),u=Ss(Number(o.cost_millicents)||0);s=`${d} tokens · ${u}`}catch{}return i.jsx("div",{className:$t.usageEvent,"data-testid":"usage-event",children:i.jsx("span",{className:$t.usageBadge,children:s})})}function jA({content:t}){return i.jsx("div",{className:$t.defaultEvent,children:t})}function NA({event:t,toolUseCtx:s,settled:o}){const r=new Date(t.timestamp).toLocaleTimeString();switch(t.eventType){case"system":{if(t.raw)try{if(JSON.parse(t.raw).systemContext===!0)return i.jsx(gA,{content:t.content})}catch{}return i.jsx(vA,{time:r,content:t.content})}case"text":case"output":return i.jsx(xA,{content:t.content});case"tool_use":{let c="",d={};try{const u=JSON.parse(t.content);c=u.tool||"",d=u.args}catch{}return i.jsx(ap,{tool:c,args:d,result:o?"":void 0})}case"tool_result":{let c=!1;if(t.raw)try{c=JSON.parse(t.raw).is_error===!0}catch{}let d=t.content;if(t.content.trimStart().startsWith("{"))try{const u=JSON.parse(t.content);typeof u.content=="string"&&(d=u.content)}catch{}return s?i.jsx(ap,{tool:s.tool,args:s.args,result:d,isError:c,detailedResult:s.detailedResult}):i.jsx(ap,{tool:"Tool output",args:void 0,result:d,isError:c})}case"error":return i.jsx(_A,{content:t.content});case"status":return i.jsx(kA,{content:t.content});case"user_input":return i.jsx(SA,{content:t.content});case"signal":return i.jsx(TA,{content:t.content});case"usage":return i.jsx(wA,{content:t.content});default:return i.jsx(jA,{content:t.content})}}const vm=y.createContext({});function ym(t){const s=y.useRef(null);return s.current===null&&(s.current=t()),s.current}const kd=y.createContext(null),bm=y.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});class CA extends y.Component{getSnapshotBeforeUpdate(s){const o=this.props.childRef.current;if(o&&s.isPresent&&!this.props.isPresent){const r=this.props.sizeRef.current;r.height=o.offsetHeight||0,r.width=o.offsetWidth||0,r.top=o.offsetTop,r.left=o.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}}function EA({children:t,isPresent:s}){const o=y.useId(),r=y.useRef(null),c=y.useRef({width:0,height:0,top:0,left:0}),{nonce:d}=y.useContext(bm);return y.useInsertionEffect(()=>{const{width:u,height:p,top:m,left:g}=c.current;if(s||!r.current||!u||!p)return;r.current.dataset.motionPopId=o;const v=document.createElement("style");return d&&(v.nonce=d),document.head.appendChild(v),v.sheet&&v.sheet.insertRule(`
|
|
256
256
|
[data-motion-pop-id="${o}"] {
|
|
257
257
|
position: absolute !important;
|
|
258
258
|
width: ${u}px !important;
|
|
@@ -271,7 +271,7 @@ ${JSON.stringify(u,void 0,2)}
|
|
|
271
271
|
\`\`\``):s.push(`${m} (${c}):`);break}case"error":{s.push(`**Error** (${c}):
|
|
272
272
|
${r.content}`);break}}}return s.join(`
|
|
273
273
|
|
|
274
|
-
`)}function s6({events:t,formatForClipboard:s}){const[o,r]=y.useState(!1),[c,d]=y.useState(new Set),u=y.useRef(void 0),p=y.useMemo(()=>c.size,[c]),m=y.useCallback(k=>{r(!0),k!==void 0?(d(new Set([k])),u.current=k):(d(new Set),u.current=void 0)},[]),g=y.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=y.useCallback((k,w)=>{if(w&&u.current!==void 0){const N=Math.min(u.current,k),T=Math.max(u.current,k);d(C=>{const D=new Set(C);for(let B=N;B<=T;B++)B<t.length&&rl(t[B])&&D.add(B);return D})}else d(N=>{const T=new Set(N);return T.has(k)?T.delete(k):T.add(k),T.size===0?(r(!1),u.current=void 0):u.current=k,T})},[t]),b=y.useCallback(()=>{const k=new Set;for(let w=0;w<t.length;w++)rl(t[w])&&k.add(w);d(k)},[t]),x=y.useCallback(()=>{d(new Set)},[]),S=y.useCallback(async()=>{const w=[...c].sort((T,C)=>T-C).filter(T=>T<t.length).map(T=>t[T]);if(w.length===0)return!1;const N=s(w);try{return await navigator.clipboard.writeText(N),!0}catch{return!1}},[c,t,s]);return{isSelecting:o,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:b,deselectAll:x,copySelected:S}}const a6="_wrapper_1cdza_1",i6="_scrollContainer_1cdza_9",o6="_selectingPadding_1cdza_16",r6="_toolbar_1cdza_20",l6="_directionToggle_1cdza_27",c6="_scrollToAnchor_1cdza_65",d6="_scrollToAnchorBottom_1cdza_89",u6="_scrollToAnchorTop_1cdza_93",f6="_eventOverflowWarning_1cdza_97",Ys={wrapper:a6,scrollContainer:i6,selectingPadding:o6,toolbar:r6,directionToggle:l6,scrollToAnchor:c6,scrollToAnchorBottom:d6,scrollToAnchorTop:u6,eventOverflowWarning:f6};function p6(t){const s=new Date(t.timestamp).toLocaleTimeString();switch(t.eventType){case"text":case"output":return`Select message from assistant at ${s}`;case"user_input":return`Select message from user at ${s}`;case"tool_result":case"tool_use":return`Select tool event at ${s}`;case"error":return`Select error at ${s}`;default:return`Select event at ${s}`}}const b1="grackle-stream-direction";function m6(){try{return localStorage.getItem(b1)==="reversed"}catch{return!1}}function h6({eventsDropped:t}){return t<=0?i.jsx(i.Fragment,{}):i.jsxs("div",{className:Ys.eventOverflowWarning,role:"alert",children:[i.jsx(om,{size:tn,"aria-hidden":"true"})," ",t.toLocaleString()," older event",t===1?"":"s"," were dropped — only the most recent 5,000 are shown. Full history is available in the session log."]})}function Xm({events:t,eventsDropped:s,emptyState:o,onShowToast:r}){const c=y.useRef(null),[d,u]=y.useState(m6),p=Q4(),m=s6({events:t,formatForClipboard:n6}),g=y.useMemo(()=>t.filter(rl).length,[t]),v=y.useMemo(()=>d?[...t].reverse():t,[t,d]),{isAtAnchor:b,scrollToAnchor:x}=Q3({scrollRef:c,contentLength:t.length,isReversed:d,paused:m.isSelecting}),S=()=>{const T=!d;u(T);try{localStorage.setItem(b1,T?"reversed":"default")}catch{}};y.useEffect(()=>{if(!m.isSelecting)return;const T=C=>{C.key==="Escape"&&m.cancelSelection()};return window.addEventListener("keydown",T),()=>{window.removeEventListener("keydown",T)}},[m.isSelecting,m.cancelSelection]);const k=y.useCallback(async()=>{await m.copySelected()&&(r==null||r(`Copied ${m.selectedCount} message${m.selectedCount===1?"":"s"} to clipboard`,"success"))},[m,r]),w=p?0:.2,N=d?-8:8;return i.jsxs("div",{className:Ys.wrapper,children:[i.jsx("div",{className:Ys.toolbar,children:i.jsx(Lo,{text:d?"Showing newest first":"Showing oldest first",children:i.jsx("button",{className:Ys.directionToggle,onClick:S,"aria-label":d?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:d?i.jsx(ry,{size:tn,"aria-hidden":"true"}):i.jsx(ly,{size:tn,"aria-hidden":"true"})})})}),i.jsxs("div",{ref:c,className:`${Ys.scrollContainer} ${m.isSelecting?Ys.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&o,i.jsx(h6,{eventsDropped:s}),i.jsx(us,{initial:!1,children:v.map((T,C)=>{const D=d?t.length-1-C:C;return i.jsx(Rt.div,{initial:{opacity:0,y:N},animate:{opacity:1,y:0},transition:{duration:w,ease:"easeOut"},children:i.jsx(H3,{copyText:t6(T),isContentBearing:rl(T),isSelecting:m.isSelecting,isSelected:m.selectedIndices.has(D),checkboxLabel:p6(T),onSelect:()=>{m.enterSelectionMode(D)},onToggle:B=>{m.toggleEvent(D,B)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:i.jsx(NA,{event:T,toolUseCtx:T.toolUseCtx,settled:T.settled})})},`${T.sessionId}-${T.timestamp}-${D}`)})})]}),i.jsx(us,{children:m.isSelecting&&i.jsx(J3,{selectedCount:m.selectedCount,totalSelectable:g,onSelectAll:m.selectAll,onDeselectAll:m.deselectAll,onCopy:()=>{k().catch(()=>{})},onCancel:m.cancelSelection})}),i.jsx(us,{children:!b&&i.jsxs(Rt.button,{className:`${Ys.scrollToAnchor} ${d?Ys.scrollToAnchorTop:Ys.scrollToAnchorBottom}`,onClick:x,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.15},"aria-label":"Scroll to latest","data-testid":"scroll-to-anchor",children:[d?i.jsx(ly,{size:tn,"aria-hidden":"true"}):i.jsx(ry,{size:tn,"aria-hidden":"true"})," New events"]})})]})}function Qm(t){const{value:s,onSave:o,validate:r,fieldId:c,activeFieldId:d,onActivate:u,enterToSave:p=!0,trimOnSave:m=!0}=t,[g,v]=y.useState(""),[b,x]=y.useState(""),S=y.useRef(!1),k=d===c,w=y.useCallback(P=>{v(P),x("")},[]),N=y.useCallback(()=>{x("")},[]),T=y.useCallback(()=>{S.current=!1,u==null||u(null),v(""),x("")},[u]),C=y.useCallback(()=>{const P=m?g.trim():g;if(r){const U=r(g);if(U){x(U);return}}const I=m?s.trim():s;if(P===I){T();return}o(P),T()},[g,s,m,r,o,T]),D=y.useCallback(()=>{S.current=!0,u==null||u(c),v(s),x("")},[c,s,u]),B=y.useCallback(P=>{if(S.current){S.current=!1;return}P.relatedTarget instanceof HTMLElement&&P.relatedTarget.dataset.editAction===c||C()},[c,C]),E=y.useCallback(P=>{P.key==="Escape"?T():P.key==="Enter"&&p&&C()},[T,p,C]),A=(()=>{if(!k)return!1;const P=m?s.trim():s;return(m?g.trim():g)!==P})();return y.useEffect(()=>{!k&&(g!==""||b!=="")&&(v(""),x(""))},[k,g,b]),{isEditing:k,draft:g,error:b,isDirty:A,startEdit:D,cancelEdit:T,save:C,setDraft:w,clearError:N,handleBlur:B,handleKeyDown:E,ignoreInitialBlurRef:S}}const g6="_editFieldWrapper_yuzty_1",v6="_editInput_yuzty_10",y6="_editTextarea_yuzty_42",b6="_editSelect_yuzty_78",x6="_editError_yuzty_111",_6="_editInputInvalid_yuzty_118",k6="_editHint_yuzty_123",S6="_unsavedDot_yuzty_132",T6="_metaValueClickable_yuzty_140",w6="_editButton_yuzty_159",j6="_metaPlaceholder_yuzty_175",N6="_worktreeToggle_yuzty_180",nt={editFieldWrapper:g6,editInput:v6,editTextarea:y6,editSelect:b6,editError:x6,editInputInvalid:_6,editHint:k6,unsavedDot:S6,metaValueClickable:T6,editButton:w6,metaPlaceholder:j6,worktreeToggle:N6};function ln(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="text",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,maxLength:b,ariaLabel:x,"data-testid":S}=t,k=y.useRef(null),w=Qm({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(w.isEditing){const T=window.setTimeout(()=>{var C;(C=k.current)==null||C.focus()},0);return()=>window.clearTimeout(T)}},[w.isEditing]),c==="create"){const T=D=>{m==null||m(D.target.value)},C=r==null?void 0:r(s);return i.jsxs("div",{className:nt.editFieldWrapper,children:[i.jsx("input",{className:`${nt.editInput} ${C?nt.editInputInvalid:""}`,value:s,onChange:T,maxLength:b,placeholder:v,"aria-label":x,"data-testid":S?`${S}-input`:void 0}),C&&i.jsx("span",{className:nt.editError,"data-testid":"edit-error",children:C})]})}if(w.isEditing)return i.jsxs("div",{className:nt.editFieldWrapper,children:[i.jsx("input",{ref:k,className:`${nt.editInput} ${w.error?nt.editInputInvalid:""}`,value:w.draft,onChange:T=>w.setDraft(T.target.value),onBlur:w.handleBlur,onKeyDown:w.handleKeyDown,maxLength:b,placeholder:v,"aria-label":x,"data-testid":S?`${S}-input`:void 0}),w.isDirty&&i.jsx("span",{className:nt.unsavedDot,title:"Unsaved changes"}),w.error&&i.jsx("span",{className:nt.editError,"data-testid":"edit-error",children:w.error}),i.jsx("span",{className:nt.editHint,children:"Enter to save · Esc to cancel"})]});const N=g==null?void 0:g(s);return i.jsxs("span",{role:"button",tabIndex:0,className:nt.metaValueClickable,onClick:()=>w.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),w.startEdit())},title:"Click to edit","aria-label":x,"data-testid":S?`${S}-button`:void 0,children:[N!==void 0?N:s?i.jsx("span",{children:s}):i.jsx("span",{className:nt.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:nt.editButton,"aria-hidden":"true",children:"✏️"})]})}function Xp(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="textarea",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":x}=t,S=y.useRef(null),k=Qm({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(k.isEditing){const N=window.setTimeout(()=>{var T;(T=S.current)==null||T.focus()},0);return()=>window.clearTimeout(N)}},[k.isEditing]),c==="create"){const N=C=>{m==null||m(C.target.value)},T=r==null?void 0:r(s);return i.jsxs("div",{className:nt.editFieldWrapper,children:[i.jsx("textarea",{className:`${nt.editTextarea} ${T?nt.editInputInvalid:""}`,value:s,onChange:N,placeholder:v,"aria-label":b,"data-testid":x?`${x}-input`:void 0}),T&&i.jsx("span",{className:nt.editError,"data-testid":"edit-error",children:T})]})}if(k.isEditing)return i.jsxs("div",{className:nt.editFieldWrapper,children:[i.jsx("textarea",{ref:S,className:`${nt.editTextarea} ${k.error?nt.editInputInvalid:""}`,value:k.draft,onChange:N=>k.setDraft(N.target.value),onBlur:k.handleBlur,onKeyDown:k.handleKeyDown,title:b,"aria-label":b,"data-testid":x?`${x}-input`:void 0}),k.isDirty&&i.jsx("span",{className:nt.unsavedDot,title:"Unsaved changes"}),k.error&&i.jsx("span",{className:nt.editError,"data-testid":"edit-error",children:k.error}),i.jsx("span",{className:nt.editHint,children:"Tab to save · Esc to cancel"})]});const w=g==null?void 0:g(s);return i.jsxs("span",{role:"button",tabIndex:0,className:nt.metaValueClickable,onClick:()=>k.startEdit(),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),k.startEdit())},title:"Click to edit","aria-label":b,"data-testid":x?`${x}-button`:void 0,children:[w!==void 0?w:s?i.jsx("span",{children:s}):i.jsx("span",{className:nt.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:nt.editButton,"aria-hidden":"true",children:"✏️"})]})}function ud(t){var D;const{value:s,onSave:o,mode:r="edit",options:c,fieldId:d="select",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":x}=t,S=y.useRef(null),k=Qm({value:s,onSave:o,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(k.isEditing){const B=window.setTimeout(()=>{var E;(E=S.current)==null||E.focus()},0);return()=>window.clearTimeout(B)}},[k.isEditing]);const w=y.useCallback(B=>{const E=B.target.value;k.ignoreInitialBlurRef.current=!1,E!==s&&o(E),k.cancelEdit()},[s,o,k]),N=y.useCallback(B=>{if(k.ignoreInitialBlurRef.current){k.ignoreInitialBlurRef.current=!1;return}B.relatedTarget instanceof HTMLElement&&B.relatedTarget.dataset.editAction===d||k.cancelEdit()},[d,k]);if(r==="create")return i.jsx("select",{className:nt.editSelect,value:s,onChange:B=>m==null?void 0:m(B.target.value),"aria-label":b,"data-testid":x?`${x}-select`:void 0,children:c.map(B=>i.jsx("option",{value:B.value,children:B.label},B.value))});if(k.isEditing)return i.jsx("select",{ref:S,className:nt.editSelect,value:k.draft,onChange:w,onBlur:N,title:b,"aria-label":b,"data-testid":x?`${x}-select`:void 0,children:c.map(B=>i.jsx("option",{value:B.value,children:B.label},B.value))});const T=g==null?void 0:g(s),C=(D=c.find(B=>B.value===s))==null?void 0:D.label;return i.jsxs("button",{type:"button",className:nt.metaValueClickable,onClick:()=>k.startEdit(),title:"Click to change","aria-label":b,"data-testid":x?`${x}-button`:void 0,children:[T!==void 0?T:C?i.jsx("span",{children:C}):i.jsx("span",{className:nt.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:nt.editButton,"aria-hidden":"true",children:"✏️"})]})}function C6(t){const{checked:s,onChange:o,label:r,ariaLabel:c,"data-testid":d}=t;return i.jsxs("label",{className:nt.worktreeToggle,"data-testid":d,children:[i.jsx("input",{type:"checkbox",checked:s,onChange:u=>o(u.target.checked),"aria-label":c}),i.jsx("span",{children:r})]})}const E6="_envRow_1e1r5_1",A6="_envDot_1e1r5_7",D6="_envDotGreen_1e1r5_14",R6="_envDotYellow_1e1r5_18",M6="_envDotRed_1e1r5_22",I6="_envDotGray_1e1r5_26",Ao={envRow:E6,envDot:A6,envDotGreen:D6,envDotYellow:R6,envDotRed:M6,envDotGray:I6};function O6(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?Ao.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?Ao.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?Ao.envDotRed:Ao.envDotGray}function B6(t){const{value:s,onSave:o,environments:r,allowNone:c=!1,fieldId:d="environment",activeFieldId:u,onActivate:p,placeholder:m="No environment",ariaLabel:g="Environment","data-testid":v}=t,b=r.find(k=>k.id===s),x=[...c?[{value:"",label:"None"}]:[],...r.map(k=>({value:k.id,label:k.displayName}))],S=()=>{if(b)return i.jsxs("span",{className:Ao.envRow,children:[i.jsx("span",{className:`${Ao.envDot} ${O6(b.status)}`}),b.displayName]})};return i.jsx(ud,{value:s,onSave:o,options:x,fieldId:d,activeFieldId:u,onActivate:p,renderDisplay:S,placeholder:m,ariaLabel:g,"data-testid":v})}const L6="_nav_1snmp_1",z6="_searchForm_1snmp_8",$6="_searchInput_1snmp_15",U6="_searchButton_1snmp_33",P6="_clearButton_1snmp_68",H6="_workspaceSelect_1snmp_85",V6="_listHeader_1snmp_99",q6="_nodeList_1snmp_108",G6="_nodeItem_1snmp_116",F6="_indicator_1snmp_129",Z6="_label_1snmp_136",K6="_badge_1snmp_145",Yn={nav:L6,searchForm:z6,searchInput:$6,searchButton:U6,clearButton:P6,workspaceSelect:H6,listHeader:V6,nodeList:q6,nodeItem:G6,indicator:F6,label:Z6,badge:K6};function Y6({nodes:t,workspaces:s,loading:o,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=y.useState(""),v=y.useCallback(k=>{k.preventDefault(),m.trim()&&c(m.trim())},[m,c]),b=y.useCallback(()=>{g(""),d()},[d]),x=y.useCallback(k=>{u(k)},[u]),S=y.useCallback(k=>{g(""),p(k)},[p]);return i.jsxs("div",{className:Yn.nav,"data-testid":"knowledge-nav",children:[i.jsxs("form",{className:Yn.searchForm,onSubmit:v,children:[i.jsx("input",{className:Yn.searchInput,type:"text",placeholder:"Search...",value:m,onChange:k=>{g(k.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),i.jsx("button",{type:"submit",className:Yn.searchButton,disabled:o,children:"Go"})]}),r&&i.jsx("button",{type:"button",className:Yn.clearButton,onClick:b,children:"Clear search"}),i.jsxs("select",{className:Yn.workspaceSelect,onChange:k=>{S(k.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[i.jsx("option",{value:"",children:"All workspaces"}),s.map(k=>i.jsx("option",{value:k.id,children:k.name},k.id))]}),i.jsxs("div",{className:Yn.listHeader,children:["Nodes (",t.length,")"]}),i.jsx("ul",{className:Yn.nodeList,children:t.map(k=>i.jsxs("li",{className:Yn.nodeItem,onClick:()=>{x(k.id)},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),x(k.id))},role:"button",tabIndex:0,children:[i.jsx("span",{className:Yn.indicator,style:{backgroundColor:k.kind==="reference"?"#4A9EFF":k.category==="decision"?"#22C55E":k.category==="concept"?"#A855F7":k.category==="snippet"?"#6B7280":"#EAB308"}}),i.jsx("span",{className:Yn.label,children:k.label}),i.jsx("span",{className:Yn.badge,children:k.kind==="reference"?k.sourceType:k.category})]},k.id))})]})}const J6="_container_1mq5u_1",W6="_hamburger_1mq5u_33",X6="_brand_1mq5u_49",Q6="_brandLogo_1mq5u_68",e5="_info_1mq5u_75",t5="_connectionLabel_1mq5u_90",n5="_connectionDot_1mq5u_103",s5="_connected_1mq5u_106",a5="_disconnected_1mq5u_110",Zs={container:J6,hamburger:W6,brand:X6,brandLogo:Q6,info:e5,connectionLabel:t5,connectionDot:n5,connected:s5,disconnected:a5};function i5({connected:t,environments:s,sessions:o,onToggleSidebar:r,sidebarOpen:c}){const d=kt(),u=s.length,p=s.filter(g=>g.status==="connected").length,m=o.filter(g=>["running","idle"].includes(g.status)).length;return i.jsxs("div",{className:Zs.container,children:[r&&i.jsx("button",{type:"button",className:Zs.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:i.jsx(z2,{size:zt,"aria-hidden":"true"})}),i.jsx(Lo,{text:"Home",placement:"bottom",children:i.jsxs("button",{type:"button",className:Zs.brand,onClick:()=>d(Ni),"data-testid":"statusbar-brand",children:[i.jsx("img",{src:"/icon-192x192.png",alt:"",className:Zs.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),i.jsxs("div",{className:Zs.info,children:[i.jsxs("span",{"aria-label":t?"Connected":"Disconnected",children:[i.jsx("span",{className:`${Zs.connectionDot} ${t?Zs.connected:Zs.disconnected}`,"aria-hidden":"true",children:i.jsx(La,{size:rm,fill:"currentColor"})})," ",i.jsx("span",{className:Zs.connectionLabel,"aria-hidden":"true",children:t?"Connected":"Disconnected"})]}),i.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),i.jsxs("span",{children:[m," active"]})]})]})}const o5="_nav_13gkc_1",r5="_tab_13gkc_35",l5="_tabIcon_13gkc_68",c5="_tabLabel_13gkc_79",d5="_tabActive_13gkc_84",zr={nav:o5,tab:r5,tabIcon:l5,tabLabel:c5,tabActive:d5},Jc=[{view:"dashboard",label:"Dashboard",icon:i.jsx(w2,{size:zt}),route:Ni,testId:"sidebar-tab-dashboard"},{view:"chat",label:"Chat",icon:i.jsx(U2,{size:zt}),route:lN,testId:"sidebar-tab-chat"},{view:"tasks",label:"Tasks",icon:i.jsx(f2,{size:zt}),route:cN,testId:"sidebar-tab-tasks"},{view:"environments",label:"Environments",icon:i.jsx(H2,{size:zt}),route:Ro,testId:"sidebar-tab-environments"},{view:"knowledge",label:"Knowledge",icon:i.jsx(o2,{size:zt}),route:$x,testId:"sidebar-tab-knowledge"},{view:"findings",label:"Findings",icon:i.jsx(vx,{size:zt}),route:_d,testId:"sidebar-tab-findings"},{view:"settings",label:"Settings",icon:i.jsx(W2,{size:zt}),route:aN,testId:"sidebar-tab-settings"}];function u5(t){return t===Ni||t==="/"?"dashboard":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith($x)?"knowledge":t.startsWith(_d)?"findings":t.startsWith(Do)?"settings":"tasks"}function f5({tabs:t=Jc}){const s=Zt(),o=kt(),r=y.useRef(null),c=u5(s.pathname),d=y.useCallback(p=>{o(p.route)},[o]),u=y.useCallback(p=>{var x,S;const m=(x=r.current)==null?void 0:x.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(k=>k===document.activeElement),v=g>=0?g:t.findIndex(k=>k.view===c);let b=v;if(p.key==="ArrowRight"||p.key==="j"||p.key==="J")p.preventDefault(),b=(v+1)%t.length;else if(p.key==="ArrowLeft"||p.key==="k"||p.key==="K")p.preventDefault(),b=(v-1+t.length)%t.length;else if(p.key==="Home")p.preventDefault(),b=0;else if(p.key==="End")p.preventDefault(),b=t.length-1;else return;o(t[b].route),(S=m[b])==null||S.focus()},[c,o,t]);return i.jsx("nav",{className:zr.nav,ref:r,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:u,"data-testid":"sidebar-nav",children:t.map(p=>{const m=p.view===c;return i.jsx(Lo,{text:p.label,placement:"bottom",children:i.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${zr.tab} ${m?zr.tabActive:""}`,onClick:()=>d(p),"data-testid":p.testId,"aria-label":p.label,children:[i.jsx("span",{className:zr.tabIcon,"aria-hidden":"true",children:p.icon}),i.jsx("span",{className:zr.tabLabel,children:p.label})]})},p.view)})})}const p5="_container_pi6ii_1",m5="_content_pi6ii_66",Pb={container:p5,content:m5},h5=320,x1=220,_1=600,k1="grackle-sidebar-width";function g5(){try{const t=localStorage.getItem(k1);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=x1&&s<=_1)return s}}catch{}return h5}function v5(t){try{localStorage.setItem(k1,String(t))}catch{}}function y5({content:t}){const[s]=y.useState(g5),o=y.useRef(null);if(y.useEffect(()=>{const r=o.current;if(!r)return;const c=new ResizeObserver(d=>{for(const u of d){const p=u.borderBoxSize[0];if(p){const m=Math.round(p.inlineSize);m>=x1&&m<=_1&&v5(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return i.jsx("div",{className:Pb.container,ref:o,"data-testid":"sidebar",style:{width:s},children:i.jsx("div",{className:Pb.content,children:t})})}const b5="_bar_tnfsh_1",x5="_btnPrimary_tnfsh_32",_5="_statusText_tnfsh_85",k5="_statusCompleted_tnfsh_90",S5="_statusFailed_tnfsh_94",T5="_statusBlocked_tnfsh_98",w5="_hintText_tnfsh_103",wt={bar:b5,btnPrimary:x5,statusText:_5,statusCompleted:k5,statusFailed:S5,statusBlocked:T5,hintText:w5};function j5({sessions:t,tasks:s,environments:o}){const r=kt(),c=Zt(),d=At("/sessions/:sessionId"),u=At("/tasks/:taskId"),p=At("/tasks/:taskId/stream"),m=At("/tasks/:taskId/findings"),g=At("/tasks/:taskId/edit"),v=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),b=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),x=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings"),S=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),k=At("/sessions/new"),w=At("/environments/:environmentId/workspaces/:workspaceId"),N=At("/tasks/new"),T=At("/chat"),C=At("/"),D=At("/settings/*"),B=d==null?void 0:d.params.sessionId,E=(u==null?void 0:u.params.taskId)??(p==null?void 0:p.params.taskId)??(m==null?void 0:m.params.taskId)??(v==null?void 0:v.params.taskId)??(b==null?void 0:b.params.taskId)??(x==null?void 0:x.params.taskId)??(S==null?void 0:S.params.taskId),A=v??b??x??S,P=(A==null?void 0:A.params.environmentId)??(w==null?void 0:w.params.environmentId),I=c.pathname.startsWith("/environments")&&!w&&!A,U=!!T,Q=!!k,$=!!w&&!v&&!b&&!x&&!S,W=!!N;if(!!C&&!Q&&!$&&!W||!!D||(!!g||!!S)||W||I||Q)return i.jsx(i.Fragment,{});if(U)return o.find(Z=>Z.adapterType==="local"&&Z.status==="connected")?i.jsx(i.Fragment,{}):i.jsx("div",{className:wt.bar,children:i.jsx("span",{className:wt.hintText,children:"Add a local environment to start chatting"})});if($)return i.jsx("div",{className:wt.bar,children:i.jsx("span",{className:wt.hintText,children:"Select a task or click + to create one"})});if(E){const L=s.find(ce=>ce.id===E);if(!L)return i.jsx("div",{className:wt.bar,children:i.jsx("span",{className:wt.hintText,children:"Loading..."})});const Z=new Map(s.map(ce=>[ce.id,ce])),J=L.dependsOn.some(ce=>{const X=Z.get(ce);return X!==void 0&&X.status!=="complete"});if(L.status==="not_started"){const ce=J?L.dependsOn.map(X=>Z.get(X)).filter(X=>X&&X.status!=="complete").map(X=>X.title):[];return i.jsx("div",{className:wt.bar,children:J?i.jsxs("span",{className:wt.statusBlocked,children:["Blocked by: ",ce.join(", ")]}):i.jsx("span",{className:wt.hintText,children:"Use the buttons above to start or manage this task"})})}if(L.status==="working"||L.status==="paused"){const ce=L.latestSessionId||void 0,X=ce?t.find(fe=>fe.id===ce):void 0;return X&&X.status!=="stopped"?i.jsx(i.Fragment,{}):i.jsx("div",{className:wt.bar,children:i.jsx("span",{className:wt.hintText,children:"Waiting for agent..."})})}if(L.status==="complete")return i.jsxs("div",{className:wt.bar,children:[i.jsx("span",{className:`${wt.statusText} ${wt.statusCompleted}`,children:"Task completed"}),i.jsx("button",{onClick:()=>r(Di(L.workspaceId,void 0,P)),className:wt.btnPrimary,children:"+ New Task"})]});if(L.status==="failed")return i.jsx("div",{className:wt.bar,children:i.jsx("span",{className:`${wt.statusText} ${wt.statusFailed}`,children:"Task failed"})})}if(B){const L=t.find(ce=>ce.id===B),Z=(L==null?void 0:L.status)==="stopped";if(L!==void 0&&!Z)return i.jsx(i.Fragment,{});if(Z)return i.jsxs("div",{className:wt.bar,children:[i.jsxs("span",{className:`${wt.statusText} ${wt.hintText}`,children:["Session ",L.endReason||L.status]}),i.jsx("button",{onClick:()=>r(Bx(L.environmentId)),className:wt.btnPrimary,children:"+ New Chat"})]})}return i.jsx("div",{className:wt.bar,children:i.jsx("span",{className:wt.hintText,children:"Loading..."})})}const N5="_nav_14i94_1",C5="_tab_14i94_24",E5="_tabActive_14i94_62",A5="_tabLabel_14i94_75",D5="_statusDot_14i94_81",R5="_pulse_14i94_87",M5="_addButton_14i94_99",I5="_empty_14i94_132",Aa={nav:N5,tab:C5,tabActive:E5,tabLabel:A5,statusDot:D5,pulse:R5,addButton:M5,empty:I5},O5={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function B5({environments:t}){const s=kt(),o=y.useRef(null),r=At("/environments/:environmentId"),c=At("/environments/:environmentId/edit"),d=At("/environments/:environmentId/workspaces/:workspaceId"),u=At("/environments/:environmentId/workspaces/:workspaceId/*"),p=(r==null?void 0:r.params.environmentId)??(c==null?void 0:c.params.environmentId)??(d==null?void 0:d.params.environmentId)??(u==null?void 0:u.params.environmentId),m=p==="new"?void 0:p,g=y.useCallback(x=>{s(ji(x))},[s]),v=y.useCallback(x=>{var T;const S=(T=o.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const k=Array.from(S).findIndex(C=>C===document.activeElement),w=k>=0?k:t.findIndex(C=>C.id===m);let N=w;if(x.key==="ArrowDown"||x.key==="j"||x.key==="J")x.preventDefault(),N=(w+1)%S.length;else if(x.key==="ArrowUp"||x.key==="k"||x.key==="K")x.preventDefault(),N=(w-1+S.length)%S.length;else if(x.key==="Home")x.preventDefault(),N=0;else if(x.key==="End")x.preventDefault(),N=S.length-1;else return;N<t.length&&s(ji(t[N].id)),S[N].focus()},[m,t,s]),b=m??(t.length>0?t[0].id:void 0);return i.jsxs("div",{className:Aa.nav,"data-testid":"environment-nav",children:[i.jsx("nav",{ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(x=>{const S=x.id===m,k=x.id===b,w=O5[x.status]||"var(--text-tertiary)",N=x.status==="connected";return i.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:k?0:-1,className:`${Aa.tab} ${S?Aa.tabActive:""}`,onClick:()=>g(x.id),"data-testid":"env-nav-item",children:[i.jsx("span",{className:`${Aa.statusDot} ${N?Aa.pulse:""}`,style:{color:w},"aria-hidden":"true",children:i.jsx(La,{size:rm,fill:"currentColor"})}),i.jsx("span",{className:Aa.tabLabel,title:x.displayName||x.id,children:x.displayName||x.id})]},x.id)})}),i.jsx("button",{type:"button",className:Aa.addButton,onClick:()=>s(nN),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&i.jsx("div",{className:Aa.empty,children:"No environments yet."})]})}function eh(t){const s=new Date(t),o=new Date,r=o.getTime()-s.getTime(),c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return"just now";if(d<60)return`${d}m ago`;if(u<24)return`${u}h ago`;if(p===1)return"yesterday";if(p<7)return`${p} days ago`;const m=s.getFullYear()===o.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}const Hb={architecture:{text:"var(--accent-blue)",bg:"var(--accent-blue-dim)"},api:{text:"var(--accent-green)",bg:"var(--accent-green-dim)"},bug:{text:"var(--accent-red)",bg:"var(--accent-red-dim)"},decision:{text:"var(--accent-yellow)",bg:"var(--accent-yellow-dim)"},dependency:{text:"var(--accent-purple)",bg:"var(--accent-purple-dim)"},pattern:{text:"var(--accent-cyan)",bg:"var(--accent-cyan-dim)"},general:{text:"var(--text-secondary)",bg:"var(--bg-elevated)"}};function fd(t){return Hb[t]||Hb.general}const L5="_nav_dlm8m_1",z5="_categoryPills_dlm8m_24",$5="_categoryPill_dlm8m_24",U5="_tab_dlm8m_42",P5="_tabActive_dlm8m_80",H5="_tabContent_dlm8m_93",V5="_tabLabel_dlm8m_100",q5="_tabMeta_dlm8m_106",G5="_categoryDot_dlm8m_111",F5="_empty_dlm8m_118",xs={nav:L5,categoryPills:z5,categoryPill:$5,tab:U5,tabActive:P5,tabContent:H5,tabLabel:V5,tabMeta:q5,categoryDot:G5,empty:F5};function Z5({findings:t,workspaceId:s,environmentId:o}){const r=kt(),c=y.useRef(null),d=At("/findings/:findingId"),u=At("/environments/:environmentId/workspaces/:workspaceId/findings/:findingId"),p=(d==null?void 0:d.params.findingId)??(u==null?void 0:u.params.findingId),m=y.useMemo(()=>{const x=new Set(t.map(S=>S.category).filter(Boolean));return Array.from(x).sort()},[t]),g=y.useCallback(x=>{r(Mp(x,s,o))},[r,s,o]),v=y.useCallback(x=>{var T;const S=(T=c.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const k=Array.from(S).findIndex(C=>C===document.activeElement),w=k>=0?k:t.findIndex(C=>C.id===p);let N=w;if(x.key==="ArrowDown"||x.key==="j"||x.key==="J")x.preventDefault(),N=(w+1)%S.length;else if(x.key==="ArrowUp"||x.key==="k"||x.key==="K")x.preventDefault(),N=(w-1+S.length)%S.length;else if(x.key==="Home")x.preventDefault(),N=0;else if(x.key==="End")x.preventDefault(),N=S.length-1;else return;N<t.length&&r(Mp(t[N].id,s,o)),S[N].focus()},[p,t,r,s,o]),b=p??(t.length>0?t[0].id:void 0);return i.jsxs("div",{className:xs.nav,"data-testid":"findings-nav",children:[m.length>1&&i.jsx("div",{className:xs.categoryPills,"data-testid":"findings-nav-categories",children:m.map(x=>i.jsx("span",{className:xs.categoryPill,style:{color:fd(x).text},children:x},x))}),i.jsx("nav",{ref:c,role:"tablist","aria-orientation":"vertical","aria-label":"Findings",onKeyDown:v,children:t.map(x=>{const S=x.id===p,k=x.id===b;return i.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:k?0:-1,className:`${xs.tab} ${S?xs.tabActive:""}`,onClick:()=>g(x.id),"data-testid":"finding-nav-item",children:[i.jsx("span",{className:xs.categoryDot,style:{color:fd(x.category).text},"aria-hidden":"true",children:i.jsx(La,{size:rm,fill:"currentColor"})}),i.jsxs("span",{className:xs.tabContent,children:[i.jsx("span",{className:xs.tabLabel,title:x.title,children:x.title}),i.jsx("span",{className:xs.tabMeta,title:x.createdAt,children:eh(x.createdAt)})]})]},x.id)})}),t.length===0&&i.jsx("div",{className:xs.empty,children:"No findings yet. Agents will post discoveries here."})]})}function K5(t){if(t.length===0)return[];const s=[...t].sort((r,c)=>r[0]-c[0]),o=[[s[0][0],s[0][1]]];for(let r=1;r<s.length;r++){const c=o[o.length-1],[d,u]=s[r];d<=c[1]+1?c[1]=Math.max(c[1],u):o.push([d,u])}return o}function S1({text:t,indices:s,highlightClass:o}){if(!s||s.length===0)return i.jsx(i.Fragment,{children:t});const r=K5(s),c=[];let d=0;for(const[u,p]of r)u>d&&c.push(i.jsx("span",{children:t.slice(d,u)},`p${d}`)),c.push(i.jsx("mark",{className:o,children:t.slice(u,p+1)},`m${u}`)),d=p+1;return d<t.length&&c.push(i.jsx("span",{children:t.slice(d)},`p${d}`)),i.jsx(i.Fragment,{children:c})}function Y5(t){const s=new Map(t.map(r=>[r.id,{...r,children:[]}])),o=[];for(const r of s.values())r.parentTaskId&&s.has(r.parentTaskId)?s.get(r.parentTaskId).children.push(r):o.push(r);for(const r of s.values())r.children.sort((c,d)=>c.sortOrder-d.sortOrder);return o.sort((r,c)=>r.sortOrder-c.sortOrder)}function J5(t,s){const o=new Map;for(const d of t){const p=d.dependsOn.length>0&&d.dependsOn.some(g=>s.get(g)!=="complete")?"blocked":d.status,m=o.get(p);m?m.push(d):o.set(p,[d])}const r=[],c=new Set;for(const d of ow){c.add(d);const u=o.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=za(d);r.push({status:d,label:p.label,style:p,tasks:u})}}for(const[d,u]of o)if(!c.has(d)&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=za(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const W5="_container_z4i38_1",X5="_header_z4i38_5",Q5="_headerActions_z4i38_17",eI="_searchInput_z4i38_23",tI="_searchHighlight_z4i38_56",nI="_groupToggle_z4i38_62",sI="_groupToggleActive_z4i38_89",aI="_addButton_z4i38_93",iI="_taskRow_z4i38_120",oI="_selected_z4i38_140",rI="_expandArrow_z4i38_150",lI="_expanded_z4i38_157",cI="_leafSpacer_z4i38_161",dI="_taskStatusIcon_z4i38_166",uI="_taskTitle_z4i38_170",fI="_workspaceBadge_z4i38_177",pI="_childCountBadge_z4i38_195",mI="_dependencyBadge_z4i38_208",hI="_blockedBadge_z4i38_220",gI="_addChildButton_z4i38_225",vI="_emptyState_z4i38_268",yI="_statusGroupHeader_z4i38_275",bI="_statusGroupIcon_z4i38_294",xI="_statusGroupLabel_z4i38_298",_I="_statusGroupCount_z4i38_303",Ge={container:W5,header:X5,headerActions:Q5,searchInput:eI,searchHighlight:tI,groupToggle:nI,groupToggleActive:sI,addButton:aI,taskRow:iI,selected:oI,expandArrow:rI,expanded:lI,leafSpacer:cI,taskStatusIcon:dI,taskTitle:uI,workspaceBadge:fI,childCountBadge:pI,dependencyBadge:mI,blockedBadge:hI,addChildButton:gI,emptyState:vI,statusGroupHeader:yI,statusGroupIcon:bI,statusGroupLabel:xI,statusGroupCount:_I},kI=[{name:"title",weight:2},{name:"description",weight:1}],T1=16,SI=16,w1="grackle-task-group-by-status";function Vb(){try{return localStorage.getItem(w1)==="true"}catch{return!1}}function TI(t){try{localStorage.setItem(w1,String(t))}catch{}}function wI({group:t,isExpanded:s,onToggle:o,selectedTaskId:r,navigate:c,titleHighlights:d,workspaceNames:u}){return i.jsxs("div",{"data-testid":`status-group-${t.status}`,children:[i.jsxs("div",{className:Ge.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:o,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),o())},children:[i.jsx("span",{className:`${Ge.expandArrow} ${s?Ge.expanded:""}`,"aria-hidden":"true",children:i.jsx(sa,{size:lt})}),i.jsx("span",{className:Ge.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),i.jsx("span",{className:Ge.statusGroupLabel,children:t.label}),i.jsx("span",{className:Ge.statusGroupCount,children:t.tasks.length})]}),i.jsx(us,{children:s&&i.jsx(Rt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},style:{overflow:"hidden"},children:t.tasks.map(p=>{const m=za(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return i.jsxs("div",{onClick:()=>c(On(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:b=>{b.currentTarget===b.target&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c(On(p.id)))},className:`${Ge.taskRow} ${g?Ge.selected:""}`,style:{"--task-indent":`${T1}px`},"data-task-id":p.id,children:[i.jsx("span",{className:Ge.leafSpacer}),i.jsx("span",{className:Ge.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${ll(p.status)}`,children:m.icon}),i.jsx("span",{className:Ge.taskTitle,title:p.title,children:i.jsx(S1,{text:p.title,indices:d.get(p.id),highlightClass:Ge.searchHighlight})}),v&&i.jsx("span",{className:Ge.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function j1({node:t,depth:s,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=za(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(T=>u.get(T)!=="complete"),b=o.has(t.id),x=t.children.length>0,S=c===t.id,k=T1+s*SI,N=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{onClick:()=>d(On(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:T=>{T.currentTarget===T.target&&(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),d(On(t.id)))},className:`${Ge.taskRow} ${S?Ge.selected:""}`,style:{"--task-indent":`${k}px`},"data-task-id":t.id,children:[x&&i.jsx("span",{className:`${Ge.expandArrow} ${b?Ge.expanded:""}`,role:"button",tabIndex:0,"aria-label":b?"Collapse task":"Expand task",onClick:T=>{T.stopPropagation(),r(t.id)},onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),T.stopPropagation(),r(t.id))},children:i.jsx(sa,{size:lt,"aria-hidden":"true"})}),!x&&i.jsx("span",{className:Ge.leafSpacer}),i.jsx("span",{className:Ge.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${ll(t.status)}`,children:g.icon}),i.jsx("span",{className:Ge.taskTitle,title:t.title,children:i.jsx(S1,{text:t.title,indices:p.get(t.id),highlightClass:Ge.searchHighlight})}),N&&i.jsx("span",{className:Ge.workspaceBadge,title:N,children:N}),x&&i.jsxs("span",{className:Ge.childCountBadge,children:[t.children.filter(T=>T.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&i.jsx("span",{className:`${Ge.dependencyBadge} ${v?Ge.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<vT&&i.jsx(Lo,{text:"Add child task",children:i.jsx("button",{onClick:T=>{T.stopPropagation(),d(Di(t.workspaceId,t.id))},"aria-label":"Add child task",className:Ge.addChildButton,children:"+"})})]}),i.jsx(us,{children:x&&b&&i.jsx(Rt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},style:{overflow:"hidden"},children:t.children.map(T=>i.jsx(j1,{node:T,depth:s+1,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},T.id))})})]})}function jI({workspaces:t,tasks:s}){const o=kt(),[r,c]=y.useState(new Set),[d,u]=y.useState(new Set),[p,m]=y.useState(Vb),[g,v]=y.useState(Vb),[b,x]=y.useState(new Map),S=At("/tasks/:taskId/*"),k=(S==null?void 0:S.params.taskId)!=="new"?S==null?void 0:S.params.taskId:void 0,w=y.useMemo(()=>new Map(s.map(H=>[H.id,H.status])),[s]),N=y.useMemo(()=>new Map(t.map(H=>[H.id,H.name])),[t]),T=()=>{const H=!p;TI(H),m(H),H&&(v(!0),x(new Map))},C=H=>{x(ie=>{const L=new Map(ie),Z=L.has(H)?L.get(H):g;return L.set(H,!Z),L})},D=H=>b.has(H)?b.get(H):g,B=H=>{c(ie=>{const L=new Set(ie);return L.has(H)?(L.delete(H),u(Z=>new Set(Z).add(H))):(L.add(H),u(Z=>{const J=new Set(Z);return J.delete(H),J})),L})};y.useEffect(()=>{const H=new Set(s.filter(ie=>ie.parentTaskId).map(ie=>ie.parentTaskId));H.size>0&&c(ie=>{const L=new Set(ie);for(const Z of H)d.has(Z)||L.add(Z);return L})},[s,d]);const[E,A]=y.useState(""),{directMatchTaskIds:P,treeMatchTaskIds:I,titleHighlights:U}=y.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const H=gT(s,E,kI),ie=new Set(H.map(ce=>ce.item.id)),L=new Map;for(const ce of H){const X=ce.matches.find(ge=>ge.key==="title");X&&L.set(ce.item.id,X.indices)}const Z=new Set(ie),J=new Map(s.map(ce=>[ce.id,ce]));for(const ce of[...ie]){let X=J.get(ce);for(;X!=null&&X.parentTaskId;)Z.add(X.parentTaskId),X=J.get(X.parentTaskId)}return{directMatchTaskIds:ie,treeMatchTaskIds:Z,titleHighlights:L}},[E,s]),Q=P!==null,$=Q?p?P:I:null,W=$?s.filter(H=>$.has(H.id)):s,pe=p?[]:Y5(W);return i.jsxs("div",{className:Ge.container,children:[i.jsxs("div",{className:Ge.header,children:[i.jsx("span",{children:"Tasks"}),i.jsxs("div",{className:Ge.headerActions,children:[i.jsx(Lo,{text:p?"Switch to tree view":"Group tasks by status",children:i.jsx("button",{className:`${Ge.groupToggle} ${p?Ge.groupToggleActive:""}`,onClick:T,"aria-label":p?"Switch to tree view":"Group tasks by status","aria-pressed":p,"data-testid":"task-group-by-status-toggle",children:i.jsx(I2,{size:tn})})}),i.jsx(Lo,{text:"New task",children:i.jsx("button",{className:Ge.addButton,onClick:()=>o(Di()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&i.jsx("input",{type:"text",value:E,onChange:H=>A(H.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:Ge.searchInput,"data-testid":"sidebar-search"}),p?J5(W,w).map(H=>i.jsx(wI,{group:H,isExpanded:D(H.status),onToggle:()=>C(H.status),selectedTaskId:k,navigate:o,titleHighlights:U,workspaceNames:N},H.status)):pe.map(H=>i.jsx(j1,{node:H,depth:0,expandedTasks:r,toggleTask:B,selectedTaskId:k,navigate:o,taskStatusById:w,titleHighlights:U,workspaceNames:N},H.id)),W.length===0&&!Q&&i.jsx("div",{className:Ge.emptyState,children:"No tasks yet. Click + to create one."}),W.length===0&&Q&&i.jsx("div",{className:Ge.emptyState,children:"No matching tasks"})]})}const NI="_toast_ed2dk_1",CI="_success_ed2dk_18",EI="_icon_ed2dk_22",AI="_error_ed2dk_25",DI="_warning_ed2dk_32",RI="_info_ed2dk_38",MI="_message_ed2dk_53",II="_close_ed2dk_60",$r={toast:NI,success:CI,icon:EI,error:AI,warning:DI,info:RI,message:MI,close:II},OI={success:i.jsx(Ei,{size:zt}),error:i.jsx(Ha,{size:zt}),warning:i.jsx(om,{size:zt}),info:i.jsx(im,{size:zt})};function BI({toast:t,onDismiss:s}){return y.useEffect(()=>{const o=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(o)},[t.id,t.duration,s]),i.jsxs(Rt.div,{className:`${$r.toast} ${$r[t.variant]}`,role:"status",initial:{opacity:0,y:-16,scale:.94},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.94},transition:{duration:.2,ease:"easeOut"},layout:!0,children:[i.jsx("span",{className:$r.icon,"aria-hidden":"true",children:OI[t.variant]}),i.jsx("span",{className:$r.message,children:t.message}),i.jsx("button",{type:"button",className:$r.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:i.jsx(Ha,{size:tn,"aria-hidden":"true"})})]})}const LI="_container_qqse2_1",zI={container:LI};function $I({toasts:t,onDismiss:s}){return i.jsx("div",{className:zI.container,"data-testid":"toast-container",children:i.jsx(us,{children:t.map(o=>i.jsx(BI,{toast:o,onDismiss:s},o.id))})})}const UI="_callout_e5awm_1",PI="_success_e5awm_11",HI="_icon_e5awm_15",VI="_error_e5awm_18",qI="_warning_e5awm_25",GI="_info_e5awm_32",FI="_content_e5awm_48",ZI="_close_e5awm_53",Ur={callout:UI,success:PI,icon:HI,error:VI,warning:qI,info:GI,content:FI,close:ZI},KI={success:i.jsx(Ei,{size:zt}),error:i.jsx(Ha,{size:zt}),warning:i.jsx(om,{size:zt}),info:i.jsx(im,{size:zt})};function YI({variant:t="info",children:s,dismissible:o=!1,className:r}){const[c,d]=y.useState(!1);return i.jsx(i.Fragment,{children:!c&&i.jsxs("div",{className:[Ur.callout,Ur[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[i.jsx("span",{className:Ur.icon,"aria-hidden":"true",children:KI[t]}),i.jsx("span",{className:Ur.content,children:s}),o&&i.jsx("button",{type:"button",className:Ur.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:i.jsx(Ha,{size:tn,"aria-hidden":"true"})})]})})}function JI({currentVersion:t,latestVersion:s,updateAvailable:o,isDocker:r}){if(!o)return i.jsx(i.Fragment,{});const c=r?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return i.jsx("div",{"data-testid":"update-banner",children:i.jsxs(YI,{variant:"info",dismissible:!0,children:[i.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",t,")."," ","Run: ",i.jsx("code",{children:c})]})})}const WI="_container_de44x_1",XI="_emptyState_de44x_8",QI="_card_de44x_14",eO="_cardClickable_de44x_34",tO="_cardHeader_de44x_42",nO="_categoryBadge_de44x_54",sO="_findingTitle_de44x_62",aO="_findingDate_de44x_68",iO="_findingContent_de44x_80",oO="_tags_de44x_86",rO="_tag_de44x_86",rs={container:WI,emptyState:XI,card:QI,cardClickable:eO,cardHeader:tO,categoryBadge:nO,findingTitle:sO,findingDate:aO,findingContent:iO,tags:oO,tag:rO};function N1({findings:t,onFindingClick:s}){return t.length===0?i.jsx("div",{className:rs.emptyState,children:"No findings yet. Agents will post discoveries here."}):i.jsx("div",{className:rs.container,children:t.map((o,r)=>{const c=fd(o.category),d=s?Rt.button:Rt.div;return i.jsxs(d,{type:s?"button":void 0,className:`${rs.card} ${s?rs.cardClickable:""}`,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:r*.05,duration:.2},onClick:s?()=>{s(o.id)}:void 0,children:[i.jsxs("div",{className:rs.cardHeader,children:[i.jsx("span",{className:rs.categoryBadge,style:{background:c.bg,color:c.text},children:o.category}),i.jsx("span",{className:rs.findingTitle,children:o.title}),i.jsx("span",{className:rs.findingDate,title:o.createdAt,children:eh(o.createdAt)})]}),i.jsx("div",{className:rs.findingContent,children:o.content.length>300?o.content.slice(0,300)+"...":o.content}),o.tags.length>0&&i.jsx("div",{className:rs.tags,children:o.tags.map(u=>i.jsx("span",{className:rs.tag,style:{color:c.text,textShadow:`0 0 8px ${c.text}`},children:u},u))})]},o.id)})})}const lO="_section_1ingb_14",cO="_sectionTitle_1ingb_26",dO="_sectionDescription_1ingb_35",uO="_tokenList_1ingb_48",fO="_tokenRow_1ingb_55",pO="_tokenBadge_1ingb_68",mO="_tokenName_1ingb_83",hO="_tokenTarget_1ingb_90",gO="_deleteButton_1ingb_99",vO="_addForm_1ingb_113",yO="_formRow_1ingb_119",bO="_input_1ingb_125",xO="_select_1ingb_155",_O="_addButton_1ingb_187",kO="_emptyStateInfo_1ingb_221",SO="_themeOptions_1ingb_229",TO="_themeOption_1ingb_229",wO="_themeOptionSelected_1ingb_254",jO="_themeOptionHeader_1ingb_259",NO="_themeOptionLabel_1ingb_266",CO="_themeOptionDesc_1ingb_273",EO="_variantToggle_1ingb_279",AO="_variantButton_1ingb_286",DO="_variantActive_1ingb_305",RO="_themeSwatches_1ingb_311",MO="_themeSwatch_1ingb_311",IO="_systemToggle_1ingb_325",OO="_systemToggleHint_1ingb_341",BO="_themeActive_1ingb_348",LO="_aboutGrid_1ingb_354",zO="_aboutItem_1ingb_360",$O="_aboutLabel_1ingb_373",UO="_aboutValue_1ingb_379",PO="_aboutDot_1ingb_387",HO="_aboutDotConnected_1ingb_394",VO="_aboutDotDisconnected_1ingb_398",be={section:lO,sectionTitle:cO,sectionDescription:dO,tokenList:uO,tokenRow:fO,tokenBadge:pO,tokenName:mO,tokenTarget:hO,deleteButton:gO,addForm:vO,formRow:yO,input:bO,select:xO,addButton:_O,emptyStateInfo:kO,themeOptions:SO,themeOption:TO,themeOptionSelected:wO,themeOptionHeader:jO,themeOptionLabel:NO,themeOptionDesc:CO,variantToggle:EO,variantButton:AO,variantActive:DO,themeSwatches:RO,themeSwatch:MO,systemToggle:IO,systemToggleHint:OO,themeActive:BO,aboutGrid:LO,aboutItem:zO,aboutLabel:$O,aboutValue:UO,aboutDot:PO,aboutDotConnected:HO,aboutDotDisconnected:VO},qO=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function GO({tokens:t,onSetToken:s,onDeleteToken:o,onShowToast:r}){const[c,d]=y.useState(""),[u,p]=y.useState(""),[m,g]=y.useState("env_var"),[v,b]=y.useState(""),[x,S]=y.useState(null),k=T=>{if(T.preventDefault(),!c||!u)return;const C=m==="env_var"?v||c.toUpperCase()+"_TOKEN":"";s(c,u,m,C,m==="file"?v:""),r==null||r("Token saved successfully","success"),d(""),p(""),b("")},w=T=>{S(T)},N=()=>{x&&(o(x),r==null||r("Token deleted","info")),S(null)};return i.jsxs(i.Fragment,{children:[i.jsx(Ci,{isOpen:x!==null,title:"Delete Token?",description:x?`"${x}" will be permanently removed.`:void 0,onConfirm:N,onCancel:()=>S(null)}),i.jsxs("section",{className:be.section,children:[i.jsx("h3",{className:be.sectionTitle,children:"Tokens"}),i.jsx("p",{className:be.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?i.jsx("div",{className:be.emptyStateInfo,children:"Add your first API token to enable service integrations."}):i.jsx("div",{className:be.tokenList,children:t.map(T=>i.jsxs("div",{className:be.tokenRow,children:[i.jsx("span",{className:be.tokenBadge,children:T.tokenType}),i.jsx("span",{className:be.tokenName,children:T.name}),i.jsx("span",{className:be.tokenTarget,children:T.tokenType==="env_var"?T.envVar:T.filePath}),i.jsx("button",{className:be.deleteButton,onClick:()=>w(T.name),title:`Delete ${T.name}`,"aria-label":`Delete ${T.name}`,children:i.jsx(Ha,{size:tn,"aria-hidden":"true"})})]},T.name))}),i.jsxs("form",{className:be.addForm,onSubmit:k,children:[i.jsxs("div",{className:be.formRow,children:[i.jsx("input",{className:be.input,type:"text",placeholder:"Token name",value:c,onChange:T=>d(T.target.value)}),i.jsx("input",{className:be.input,type:"password",placeholder:"Value",value:u,onChange:T=>p(T.target.value)})]}),i.jsxs("div",{className:be.formRow,children:[i.jsx("select",{className:be.select,value:m,onChange:T=>g(T.target.value),children:qO.map(T=>i.jsx("option",{value:T.value,children:T.label},T.value))}),i.jsx("input",{className:be.input,type:"text",placeholder:m==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:v,onChange:T=>b(T.target.value)}),i.jsx("button",{className:be.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const Cd=[{id:"grackle",label:"Grackle",description:"The default Grackle theme — iridescent purple on clean dark.",swatches:["#0e1218","#8b5cf6","#60a5fa","#e5e7eb","#34d399"],variantLightId:"grackle-light",variantDarkId:"grackle-dark"},{id:"grackle-light",label:"Grackle Light",description:"Light Grackle variant.",hidden:!0},{id:"grackle-dark",label:"Grackle Dark",description:"Dark Grackle variant.",hidden:!0},{id:"glass",label:"Glassmorphism",description:"Dark frosted-glass aesthetic with backdrop blur effects.",swatches:["#0a0c14","#4ecca3","#70a1ff","#e2e8f0","#a855f7"]},{id:"matrix",label:"Matrix",description:"Phosphor-green CRT terminal with scanlines and glow.",swatches:["#050505","#00ff41","#00bfff","#33ff77","#ffb000"]},{id:"brutalist",label:"Neubrutalism",description:"Thick borders, raw colors, bold type — ugly on purpose.",swatches:["#f5f0e8","#ff5757","#5ce1e6","#1a1a1a","#ffde59"],variantLightId:"brutalist-light",variantDarkId:"brutalist-dark"},{id:"brutalist-light",label:"Neubrutalism Light",description:"Light neubrutalism variant.",hidden:!0},{id:"brutalist-dark",label:"Neubrutalism Dark",description:"Dark neubrutalism variant.",hidden:!0},{id:"monokai",label:"Monokai",description:"Classic warm editor palette — pink, green, and purple.",swatches:["#272822","#f92672","#a6e22e","#f8f8f2","#ae81ff"],variantLightId:"monokai-light",variantDarkId:"monokai-dark"},{id:"monokai-dark",label:"Monokai Dark",description:"Dark Monokai variant.",hidden:!0},{id:"monokai-light",label:"Monokai Light",description:"Light Monokai variant.",hidden:!0},{id:"ubuntu",label:"Ubuntu",description:"Aubergine terminal with the GNOME Tango palette.",swatches:["#300a24","#8ae234","#ef2929","#eeeeec","#fce94f"]},{id:"sandstone",label:"Sandstone",description:"Warm terracotta accent on dark brown, in the style of Claude Code.",swatches:["#1a1815","#C15F3C","#6b8afd","#e8e6e3","#a78bfa"]},{id:"verdigris",label:"Verdigris",description:"Teal accent on charcoal, in the style of ChatGPT.",swatches:["#141414","#00a67e","#3b82f6","#ececec","#ab68ff"]},{id:"primer",label:"Primer",description:"Blue accent on ink-dark grey, in the style of GitHub.",swatches:["#0d1117","#58a6ff","#3fb950","#c9d1d9","#bc8cff"]}],C1=new Set(Cd.map(t=>t.id)),qb="grackle";function Qp(t){return Cd.find(s=>s.id===t)}function FO({themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c}){return i.jsxs("section",{className:be.section,children:[i.jsx("h3",{className:be.sectionTitle,children:"Appearance"}),i.jsx("p",{className:be.sectionDescription,children:"Choose how Grackle looks across the app."}),i.jsx("div",{className:be.themeOptions,children:Cd.filter(d=>!d.hidden).map(d=>{const u=!!(d.variantLightId&&d.variantDarkId),p=u?t===d.id||t===d.variantLightId||t===d.variantDarkId:t===d.id,m=u&&s===d.variantLightId;return i.jsxs("button",{type:"button",className:`${be.themeOption} ${p?be.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>o(d.id),children:[i.jsxs("span",{className:be.themeOptionHeader,children:[i.jsxs("span",{children:[i.jsx("span",{className:be.themeOptionLabel,children:d.label}),i.jsx("span",{className:be.themeOptionDesc,children:d.description})]}),u&&i.jsxs("span",{className:be.variantToggle,children:[i.jsx("span",{role:"button",tabIndex:0,className:`${be.variantButton} ${p&&m?be.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantLightId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantLightId))},"aria-label":"Light variant","aria-pressed":p&&m,children:"☼"}),i.jsx("span",{role:"button",tabIndex:0,className:`${be.variantButton} ${p&&!m?be.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantDarkId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantDarkId))},"aria-label":"Dark variant","aria-pressed":p&&!m,children:"☾"})]})]}),d.swatches&&i.jsx("span",{className:be.themeSwatches,children:d.swatches.map((g,v)=>i.jsx("span",{className:be.themeSwatch,style:{background:g}},v))})]},d.id)})}),i.jsxs("label",{className:be.systemToggle,children:[i.jsx("input",{type:"checkbox",checked:r,onChange:d=>c(d.target.checked)}),i.jsx("span",{children:"Match system light/dark preference"})]}),i.jsx("p",{className:be.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),i.jsxs("p",{className:be.themeActive,children:["Active theme: ",i.jsx("strong",{children:s})]})]})}function ZO({connected:t,environments:s,sessions:o}){const r=s.filter(u=>u.status==="connected").length,c=s.length,d=o.filter(u=>["running","idle"].includes(u.status)).length;return i.jsxs("section",{className:be.section,"data-testid":"about-panel",children:[i.jsx("h3",{className:be.sectionTitle,children:"About"}),i.jsx("p",{className:be.sectionDescription,children:"Connection status and application information."}),i.jsxs("div",{className:be.aboutGrid,children:[i.jsxs("div",{className:be.aboutItem,children:[i.jsx("span",{className:be.aboutLabel,children:"Connection"}),i.jsxs("span",{className:be.aboutValue,children:[i.jsx("span",{className:`${be.aboutDot} ${t?be.aboutDotConnected:be.aboutDotDisconnected}`}),t?"Connected":"Disconnected"]})]}),i.jsxs("div",{className:be.aboutItem,children:[i.jsx("span",{className:be.aboutLabel,children:"Environments"}),i.jsxs("span",{className:be.aboutValue,children:[r,"/",c," connected"]})]}),i.jsxs("div",{className:be.aboutItem,children:[i.jsx("span",{className:be.aboutLabel,children:"Active Sessions"}),i.jsx("span",{className:be.aboutValue,children:d})]}),i.jsxs("div",{className:be.aboutItem,children:[i.jsx("span",{className:be.aboutLabel,children:"Version"}),i.jsx("span",{className:be.aboutValue,children:"0.99.0"})]})]})]})}const KO="_container_cddyd_1",YO="_header_cddyd_8",JO="_headerTitle_cddyd_35",WO="_badge_cddyd_44",XO="_headerActions_cddyd_54",QO="_body_cddyd_61",eB="_formContent_cddyd_73",tB="_section_cddyd_85",nB="_label_cddyd_91",sB="_titleInput_cddyd_98",aB="_descriptionTextarea_cddyd_131",iB="_parentContext_cddyd_167",oB="_parentLabel_cddyd_175",rB="_parentName_cddyd_182",lB="_personaSelect_cddyd_186",cB="_depList_cddyd_220",dB="_depItem_cddyd_226",uB="_depItemSelected_cddyd_248",fB="_noDeps_cddyd_252",pB="_btnPrimary_cddyd_258",mB="_btnGhost_cddyd_289",tt={container:KO,header:YO,headerTitle:JO,badge:WO,headerActions:XO,body:QO,formContent:eB,section:tB,label:nB,titleInput:sB,descriptionTextarea:aB,parentContext:iB,parentLabel:oB,parentName:rB,personaSelect:lB,depList:cB,depItem:dB,depItemSelected:uB,noDeps:fB,btnPrimary:pB,btnGhost:mB};function E1({mode:t,taskId:s,workspaceId:o,parentTaskId:r,environmentId:c,tasks:d,workspaces:u,personas:p,onCreateTask:m,onUpdateTask:g,onEditDone:v,onShowToast:b}){const x=kt(),S=t==="edit",k=S&&s?d.find(ve=>ve.id===s):void 0,w=S?(k==null?void 0:k.workspaceId)??"":o??"",[N,T]=y.useState(w),C=w||N,D=u.find(ve=>ve.id===C),B=c??(D==null?void 0:D.environmentId),E=!S&&!o,A=S?(k==null?void 0:k.parentTaskId)??"":r??"",P=A?d.find(ve=>ve.id===A):void 0,[I,U]=y.useState((k==null?void 0:k.title)??""),[Q,$]=y.useState((k==null?void 0:k.description)??""),[W,pe]=y.useState((k==null?void 0:k.dependsOn)??[]),[H,ie]=y.useState((k==null?void 0:k.defaultPersonaId)??""),[L,Z]=y.useState((k==null?void 0:k.canDecompose)??!1),[J,ce]=y.useState(!1),X=y.useRef(!1);y.useEffect(()=>{S&&k&&!X.current&&(X.current=!0,U(k.title),$(k.description),pe(k.dependsOn),ie(k.defaultPersonaId),Z(k.canDecompose))},[S,k]);const ge=d.filter(ve=>ve.workspaceId===C&&(!S||ve.id!==s)&&ve.id!==A),fe=I.trim().length>0&&(!S||k!==void 0)&&C.length>0,Ce=ve=>{pe(Le=>Le.includes(ve)?Le.filter(Mt=>Mt!==ve):[...Le,ve])},Ze=()=>{!fe||J||S&&k===void 0||(S&&s?(g(s,I.trim(),Q,W,H),b==null||b("Task updated","success"),v?v():x(On(s,void 0,C,B),{replace:!0})):(ce(!0),m(C,I.trim(),Q,W.length>0?W:void 0,A||void 0,H,L,()=>{b==null||b("Task created","success"),x(o?$a(o,B):"/tasks",{replace:!0})},ve=>{b==null||b(ve,"error"),ce(!1)})))},me=()=>{if(v){v();return}x(S&&s?On(s,void 0,C,B):o?$a(o,B):"/tasks")},_e=S?"edit task":A?"child task":"new task";return i.jsxs("div",{className:tt.container,children:[i.jsxs("div",{className:tt.header,children:[i.jsxs("div",{className:tt.headerTitle,children:[i.jsx("span",{className:tt.badge,children:_e}),P&&i.jsxs("span",{className:tt.parentContext,children:[i.jsx("span",{className:tt.parentLabel,children:"Child of"}),i.jsx("span",{className:tt.parentName,children:P.title})]})]}),i.jsxs("div",{className:tt.headerActions,children:[i.jsx("button",{onClick:Ze,disabled:!fe||J,className:tt.btnPrimary,"data-testid":"task-edit-save",children:J?"Creating…":S?"Save Changes":"Create"}),i.jsx("button",{onClick:me,className:tt.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:tt.body,children:i.jsxs("div",{className:tt.formContent,children:[E&&i.jsxs("div",{className:tt.section,children:[i.jsx("label",{className:tt.label,htmlFor:"task-edit-workspace",children:"Workspace"}),i.jsxs("select",{id:"task-edit-workspace",value:N,onChange:ve=>T(ve.target.value),className:tt.personaSelect,"data-testid":"task-edit-workspace",children:[i.jsx("option",{value:"",children:"Select a workspace..."}),u.map(ve=>i.jsx("option",{value:ve.id,children:ve.name},ve.id))]})]}),i.jsxs("div",{className:tt.section,children:[i.jsx("label",{className:tt.label,htmlFor:"task-edit-title",children:"Title"}),i.jsx("input",{id:"task-edit-title",type:"text",value:I,onChange:ve=>U(ve.target.value),placeholder:"Task title...",autoFocus:!0,className:tt.titleInput,"data-testid":"task-edit-title",onKeyDown:ve=>{ve.key==="Enter"&&fe&&Ze()}})]}),i.jsxs("div",{className:tt.section,children:[i.jsx("label",{className:tt.label,htmlFor:"task-edit-description",children:"Description"}),i.jsx("textarea",{id:"task-edit-description",value:Q,onChange:ve=>$(ve.target.value),placeholder:"Describe the task... (markdown supported)",className:tt.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),i.jsxs("div",{className:tt.section,children:[i.jsx("label",{className:tt.label,htmlFor:"task-edit-persona",children:"Default Persona"}),i.jsxs("select",{id:"task-edit-persona",value:H,onChange:ve=>ie(ve.target.value),className:tt.personaSelect,"data-testid":"task-edit-persona",children:[i.jsx("option",{value:"",children:"(Inherit)"}),p.map(ve=>i.jsx("option",{value:ve.id,children:ve.name},ve.id))]})]}),!S&&i.jsx("div",{className:tt.section,children:i.jsxs("label",{className:tt.depItem,"data-testid":"task-edit-can-decompose",children:[i.jsx("input",{type:"checkbox",checked:L,onChange:ve=>Z(ve.target.checked)}),"Can spawn subtasks"]})}),i.jsxs("div",{className:tt.section,children:[i.jsx("div",{className:tt.label,children:"Dependencies"}),ge.length===0?i.jsx("div",{className:tt.noDeps,children:"No other tasks in this workspace"}):i.jsx("div",{className:tt.depList,children:ge.map(ve=>{const Le=W.includes(ve.id);return i.jsxs("label",{className:`${tt.depItem} ${Le?tt.depItemSelected:""}`,"data-testid":`dep-option-${ve.id}`,children:[i.jsx("input",{type:"checkbox",checked:Le,onChange:()=>Ce(ve.id)}),ve.title,i.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",ve.status,")"]})]},ve.id)})})]})]})})]})}const hB="_actionButtons_1rjka_1",gB="_btnPrimary_1rjka_8",vB="_btnDanger_1rjka_39",yB="_btnGhost_1rjka_78",Ft={actionButtons:hB,btnPrimary:gB,btnDanger:vB,btnGhost:yB};function bB({task:t,sessionId:s,isBlocked:o,onStart:r,onResume:c,onStop:d,onPause:u,onDelete:p,onEdit:m}){if(t.status==="not_started")return o?i.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:m,className:Ft.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):i.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{"data-testid":"task-header-start",onClick:r,className:Ft.btnPrimary,children:"Start"}),i.jsx("button",{onClick:m,className:Ft.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return i.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Ft.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:u,disabled:!s,className:Ft.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused")return i.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Ft.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:c,className:Ft.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),i.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="complete")return i.jsx("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:i.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return i.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:r,className:Ft.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),i.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const xB="_workpadSection_y8nj9_1",_B="_workpadLabel_y8nj9_9",kB="_workpadStatus_y8nj9_17",SB="_workpadSummary_y8nj9_23",TB="_workpadExtra_y8nj9_29",Da={workpadSection:xB,workpadLabel:_B,workpadStatus:kB,workpadSummary:SB,workpadExtra:TB};function wB({workpad:t}){if(!t)return;let s;try{const o=JSON.parse(t);if(o==null||typeof o!="object"||Array.isArray(o))return;s=o}catch{return i.jsxs("div",{className:Da.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:Da.workpadLabel,children:"Workpad"}),i.jsx("div",{className:Da.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return i.jsxs("div",{className:Da.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:Da.workpadLabel,children:"Workpad"}),s.status&&i.jsx("div",{className:Da.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&i.jsx("div",{className:Da.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&i.jsx("div",{className:Da.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const jB="_overviewDashboard_r05qm_1",NB="_overviewHero_r05qm_7",CB="_statusBadge_r05qm_14",EB="_statusPending_r05qm_26",AB="_statusAssigned_r05qm_31",DB="_statusInProgress_r05qm_36",RB="_statusReview_r05qm_41",MB="_statusDone_r05qm_46",IB="_statusFailed_r05qm_51",OB="_statusWaitingInput_r05qm_56",BB="_overviewBranchPill_r05qm_61",LB="_branchLink_r05qm_76",zB="_overviewSection_r05qm_87",$B="_overviewLabel_r05qm_93",UB="_overviewValue_r05qm_100",PB="_overviewMuted_r05qm_105",HB="_overviewMarkdown_r05qm_111",VB="_envRow_r05qm_180",qB="_envDot_r05qm_186",GB="_envDotGreen_r05qm_193",FB="_envDotYellow_r05qm_197",ZB="_envDotRed_r05qm_201",KB="_envDotGray_r05qm_205",YB="_depList_r05qm_209",JB="_depItem_r05qm_215",WB="_depBlocked_r05qm_222",XB="_depDone_r05qm_226",QB="_timeline_r05qm_230",eL="_timelineRow_r05qm_236",tL="_timelineKey_r05qm_243",nL="_timelineValue_r05qm_249",sL="_timelineDelta_r05qm_253",aL="_reviewNotes_r05qm_264",he={overviewDashboard:jB,overviewHero:NB,statusBadge:CB,statusPending:EB,statusAssigned:AB,statusInProgress:DB,statusReview:RB,statusDone:MB,statusFailed:IB,statusWaitingInput:OB,overviewBranchPill:BB,branchLink:LB,overviewSection:zB,overviewLabel:$B,overviewValue:UB,overviewMuted:PB,overviewMarkdown:HB,envRow:VB,envDot:qB,envDotGreen:GB,envDotYellow:FB,envDotRed:ZB,envDotGray:KB,depList:YB,depItem:JB,depBlocked:WB,depDone:XB,timeline:QB,timelineRow:eL,timelineKey:tL,timelineValue:nL,timelineDelta:sL,reviewNotes:aL};function Lc(t){if(!t)return"—";const s=new Date(t);return isNaN(s.getTime())?"—":s.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function yp(t,s){if(!t||!s)return;const o=new Date(s).getTime()-new Date(t).getTime();if(isNaN(o)||o<0)return;const r=Math.floor(o/6e4),c=Math.floor(o%6e4/1e3);if(r===0)return`${c}s`;const d=Math.floor(r/60),u=r%60;return d===0?`${r}m ${c}s`:`${d}h ${u}m`}function Gb(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?he.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?he.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?he.envDotRed:he.envDotGray}function iL({status:t}){const s=za(t),o=iw(t);return i.jsx("span",{className:`${he.statusBadge} ${he[o]??he.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function oL({task:t,tasksById:s,environments:o,workspaces:r,taskSessions:c,selectedEnvId:d,taskUsage:u,treeUsage:p}){const m=c.length>0?c[c.length-1]:void 0,g=(m==null?void 0:m.environmentId)??"",v=g?o.find(k=>k.id===g):void 0,b=r.find(k=>k.id===t.workspaceId),x=o.find(k=>k.id===d),S=t.branch&&(b!=null&&b.repoUrl)?`${b.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return i.jsxs("div",{className:he.overviewDashboard,"data-testid":"task-overview-panel",children:[i.jsxs("div",{className:he.overviewHero,children:[i.jsx(iL,{status:t.status}),t.branch&&i.jsx("span",{className:he.overviewBranchPill,"data-testid":"task-overview-branch",children:S?i.jsxs("a",{href:S,target:"_blank",rel:"noreferrer noopener",className:he.branchLink,children:["🔗"," ",t.branch]}):i.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&i.jsxs("div",{className:he.overviewSection,"data-testid":"task-overview-description",children:[i.jsx("div",{className:he.overviewLabel,children:"Description"}),i.jsx("div",{className:he.overviewMarkdown,children:i.jsx(hd,{remarkPlugins:[gd],children:t.description})})]}),t.workpad&&i.jsx(wB,{workpad:t.workpad}),i.jsxs("div",{className:he.overviewSection,children:[i.jsx("div",{className:he.overviewLabel,children:"Environment"}),g&&v?i.jsxs("div",{className:he.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${he.envDot} ${Gb(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),i.jsx("span",{className:he.overviewValue,children:v.displayName})]}):x?i.jsxs("div",{className:he.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${he.envDot} ${Gb(x.status)}`,title:x.status,"aria-label":`Status: ${x.status}`,role:"img"}),i.jsx("span",{className:he.overviewValue,children:x.displayName}),i.jsx("span",{className:he.overviewMuted,children:"(workspace default)"})]}):i.jsx("div",{className:he.overviewMuted,children:"Set in workspace settings"})]}),i.jsxs("div",{className:he.overviewSection,"data-testid":"task-overview-dependencies",children:[i.jsx("div",{className:he.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?i.jsx("div",{className:he.overviewMuted,children:"None"}):i.jsx("div",{className:he.depList,children:t.dependsOn.map(k=>{const w=s.get(k),N=(w==null?void 0:w.status)==="complete";return i.jsxs("div",{className:`${he.depItem} ${N?he.depDone:he.depBlocked}`,children:[i.jsx("span",{children:N?"✓":"○"}),i.jsx("span",{children:(w==null?void 0:w.title)??k})]},k)})})]}),i.jsxs("div",{className:he.overviewSection,"data-testid":"task-overview-timeline",children:[i.jsx("div",{className:he.overviewLabel,children:"Timeline"}),i.jsxs("div",{className:he.timeline,children:[t.createdAt&&i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Created"}),i.jsx("span",{className:he.timelineValue,children:Lc(t.createdAt)})]}),t.assignedAt&&(()=>{const k=yp(t.createdAt,t.assignedAt);return i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Assigned"}),i.jsx("span",{className:he.timelineValue,children:Lc(t.assignedAt)}),k!==void 0&&i.jsx("span",{className:he.timelineDelta,children:k})]})})(),t.startedAt&&(()=>{const k=yp(t.assignedAt??t.createdAt,t.startedAt);return i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Started"}),i.jsx("span",{className:he.timelineValue,children:Lc(t.startedAt)}),k!==void 0&&i.jsx("span",{className:he.timelineDelta,children:k})]})})(),t.completedAt&&(()=>{const k=yp(t.startedAt,t.completedAt);return i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Completed"}),i.jsx("span",{className:he.timelineValue,children:Lc(t.completedAt)}),k!==void 0&&i.jsx("span",{className:he.timelineDelta,children:k})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&i.jsx("div",{className:he.overviewMuted,children:"No timing data"})]})]}),u&&u.costUsd>0&&i.jsxs("div",{className:he.overviewSection,"data-testid":"task-overview-usage",children:[i.jsx("div",{className:he.overviewLabel,children:"Usage"}),i.jsxs("div",{className:he.timeline,children:[i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Cost"}),i.jsx("span",{className:he.timelineValue,children:Ss(u.costUsd)}),i.jsxs("span",{className:he.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costUsd>u.costUsd&&i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Total (incl. subtasks)"}),i.jsx("span",{className:he.timelineValue,children:Ss(p.costUsd)}),i.jsxs("span",{className:he.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),(t.tokenBudget>0||t.costBudgetMillicents>0)&&i.jsxs("div",{className:he.overviewSection,"data-testid":"task-overview-budget",children:[i.jsx("div",{className:he.overviewLabel,children:"Budget"}),i.jsxs("div",{className:he.timeline,children:[t.tokenBudget>0&&i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Tokens"}),i.jsxs("span",{className:he.timelineValue,children:[Mo(((u==null?void 0:u.inputTokens)??0)+((u==null?void 0:u.outputTokens)??0))," / ",Mo(t.tokenBudget)]})]}),t.costBudgetMillicents>0&&i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Cost"}),i.jsxs("span",{className:he.timelineValue,children:[Ss((u==null?void 0:u.costUsd)??0)," / ",Ss(t.costBudgetMillicents/1e5)]})]})]})]}),t.reviewNotes&&i.jsxs("div",{className:he.overviewSection,"data-testid":"task-overview-review-notes",children:[i.jsx("div",{className:he.overviewLabel,children:"Review Notes"}),i.jsx("div",{className:he.reviewNotes,children:t.reviewNotes})]})]})}const rL="_container_legrg_1",lL="_header_legrg_8",cL="_headerTitle_legrg_35",dL="_badge_legrg_44",uL="_headerActions_legrg_54",fL="_body_legrg_61",pL="_formContent_legrg_73",mL="_section_legrg_85",hL="_label_legrg_91",gL="_nameInput_legrg_98",vL="_fieldInput_legrg_131",yL="_adapterSelect_legrg_164",bL="_readOnlyValue_legrg_198",xL="_codespaceSection_legrg_204",_L="_codespaceActions_legrg_210",kL="_creatingHint_legrg_216",SL="_errorHint_legrg_222",TL="_btnPrimary_legrg_235",wL="_btnGhost_legrg_266",re={container:rL,header:lL,headerTitle:cL,badge:dL,headerActions:uL,body:fL,formContent:pL,section:mL,label:hL,nameInput:gL,fieldInput:vL,adapterSelect:yL,readOnlyValue:bL,codespaceSection:xL,codespaceActions:_L,creatingHint:kL,errorHint:SL,btnPrimary:TL,btnGhost:wL},Wc=1,Xc=65535;function bp(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=Wc&&s<=Xc}function xp(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function jL({codespaceName:t,onCodespaceNameChange:s,envName:o,onEnvNameChange:r,codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:m}){const[g,v]=y.useState("pick"),[b,x]=y.useState(""),[S,k]=y.useState("");return g==="create"?i.jsxs("div",{className:re.codespaceSection,children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Repository"}),i.jsx("input",{type:"text",value:b,onChange:w=>x(w.target.value),placeholder:"owner/repo",className:re.fieldInput,"data-testid":"env-codespace-repo"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Machine Type"}),i.jsx("input",{type:"text",value:S,onChange:w=>k(w.target.value),placeholder:"Machine type (optional)...",className:re.fieldInput,"data-testid":"env-codespace-machine"})]}),i.jsxs("div",{className:re.codespaceActions,children:[i.jsx("button",{onClick:()=>{b.trim()&&(m(b.trim(),S.trim()||void 0),v("pick"),x(""),k(""))},disabled:!b.trim(),className:re.btnPrimary,children:"Create"}),i.jsx("button",{onClick:()=>{v("pick"),x(""),k("")},className:re.btnGhost,children:"Cancel"})]})]}):i.jsx("div",{className:re.codespaceSection,children:i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Codespace"}),!u&&i.jsxs("select",{value:t,onChange:w=>{w.target.value==="__create__"?(v("create"),s("")):(s(w.target.value),w.target.value&&!o.trim()&&r(w.target.value))},disabled:p,className:re.adapterSelect,"data-testid":"env-codespace-select",children:[i.jsx("option",{value:"",children:"Select a codespace..."}),c.map(w=>i.jsxs("option",{value:w.name,children:[w.name," (",w.repository,") — ",w.state]},w.name)),i.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&i.jsx("span",{className:re.creatingHint,children:"Creating codespace..."}),u&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:re.errorHint,children:u}),i.jsx("input",{type:"text",value:t,onChange:w=>s(w.target.value),placeholder:"Or enter codespace name manually...",className:re.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&i.jsx("span",{className:re.errorHint,children:d})]})})}function A1({mode:t,environmentId:s,environments:o,onAddEnvironment:r,onUpdateEnvironment:c,onListCodespaces:d,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v,onShowToast:b}){const x=kt(),S=t==="edit",k=S&&s?o.find(me=>me.id===s):void 0,[w,N]=y.useState(""),[T,C]=y.useState("local"),[D,B]=y.useState(""),[E,A]=y.useState(""),[P,I]=y.useState(""),[U,Q]=y.useState(""),[$,W]=y.useState(""),[pe,H]=y.useState(""),[ie,L]=y.useState(""),[Z,J]=y.useState(null),ce=y.useCallback(()=>{const me={};if(T==="local"){if(D.trim()&&(me.host=D.trim()),E.trim()){const _e=Number(E);Number.isInteger(_e)&&(me.port=_e)}}else if(T==="ssh"){if(me.host=D.trim(),P.trim()&&(me.user=P.trim()),E.trim()){const _e=Number(E);Number.isInteger(_e)&&(me.sshPort=_e)}U.trim()&&(me.identityFile=U.trim())}else T==="docker"?($.trim()&&(me.image=$.trim()),pe.trim()&&(me.repo=pe.trim())):T==="codespace"&&(me.codespaceName=ie.trim());return me},[T,D,E,P,U,$,pe,ie]),X=()=>!(!w.trim()||T==="ssh"&&!D.trim()||T==="codespace"&&!ie.trim()||(T==="local"||T==="ssh")&&!bp(E)),ge=()=>{X()&&(r(w.trim(),T,ce()),b==null||b("Environment added successfully","success"),x(Ro,{replace:!0}))},fe=()=>{x(s?ji(s):Ro)},Ce=y.useCallback((me,_e)=>{if(!k||!s)return;const ve=xp(k.adapterConfig),Le=_e.trim();Le?ve[me]=Le:delete ve[me],c(s,{adapterConfig:ve})},[k,s,c]),Ze=y.useCallback((me,_e)=>{if(!k||!s)return;const ve=xp(k.adapterConfig);if(_e.trim()){const Le=Number(_e);Number.isInteger(Le)&&Le>=Wc&&Le<=Xc&&(ve[me]=Le)}else delete ve[me];c(s,{adapterConfig:ve})},[k,s,c]);if(S){if(!k)return i.jsxs("div",{className:re.container,children:[i.jsxs("div",{className:re.header,children:[i.jsx("div",{className:re.headerTitle,children:i.jsx("span",{className:re.badge,children:"edit environment"})}),i.jsx("div",{className:re.headerActions,children:i.jsx("button",{onClick:fe,className:re.btnGhost,children:"Back"})})]}),i.jsx("div",{className:re.body,children:i.jsx("div",{className:re.formContent,children:i.jsx("span",{className:re.readOnlyValue,children:"Environment not found"})})})]});const me=xp(k.adapterConfig);return i.jsxs("div",{className:re.container,"data-testid":"env-edit-panel",children:[i.jsxs("div",{className:re.header,children:[i.jsx("div",{className:re.headerTitle,children:i.jsx("span",{className:re.badge,children:"edit environment"})}),i.jsx("div",{className:re.headerActions,children:i.jsx("button",{onClick:fe,className:re.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),i.jsx("div",{className:re.body,children:i.jsxs("div",{className:re.formContent,children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Name"}),i.jsx(ln,{value:k.displayName,onSave:_e=>{s&&c(s,{displayName:_e})},validate:_e=>_e.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:Z,onActivate:J,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Adapter Type"}),i.jsx("span",{className:re.readOnlyValue,"data-testid":"env-edit-adapter-type",children:k.adapterType})]}),k.adapterType==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Host"}),i.jsx(ln,{value:String(me.host??""),onSave:_e=>Ce("host",_e),mode:"edit",fieldId:"host",activeFieldId:Z,onActivate:J,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Port"}),i.jsx(ln,{value:String(me.port??""),onSave:_e=>Ze("port",_e),validate:_e=>bp(_e)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:Z,onActivate:J,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),k.adapterType==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Host"}),i.jsx(ln,{value:String(me.host??""),onSave:_e=>Ce("host",_e),validate:_e=>_e.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:Z,onActivate:J,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"User"}),i.jsx(ln,{value:String(me.user??""),onSave:_e=>Ce("user",_e),mode:"edit",fieldId:"user",activeFieldId:Z,onActivate:J,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"SSH Port"}),i.jsx(ln,{value:String(me.sshPort??""),onSave:_e=>Ze("sshPort",_e),validate:_e=>bp(_e)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:Z,onActivate:J,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Identity File"}),i.jsx(ln,{value:String(me.identityFile??""),onSave:_e=>Ce("identityFile",_e),mode:"edit",fieldId:"identityFile",activeFieldId:Z,onActivate:J,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),k.adapterType==="docker"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Image"}),i.jsx(ln,{value:String(me.image??""),onSave:_e=>Ce("image",_e),mode:"edit",fieldId:"image",activeFieldId:Z,onActivate:J,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Repo"}),i.jsx(ln,{value:String(me.repo??""),onSave:_e=>Ce("repo",_e),mode:"edit",fieldId:"repo",activeFieldId:Z,onActivate:J,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),k.adapterType==="codespace"&&i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Codespace Name"}),i.jsx(ln,{value:String(me.codespaceName??""),onSave:_e=>Ce("codespaceName",_e),validate:_e=>_e.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:Z,onActivate:J,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return i.jsxs("div",{className:re.container,"data-testid":"env-create-panel",children:[i.jsxs("div",{className:re.header,children:[i.jsx("div",{className:re.headerTitle,children:i.jsx("span",{className:re.badge,children:"new environment"})}),i.jsxs("div",{className:re.headerActions,children:[i.jsx("button",{onClick:ge,disabled:!X(),className:re.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),i.jsx("button",{onClick:fe,className:re.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:re.body,children:i.jsxs("div",{className:re.formContent,children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-name",children:"Name"}),i.jsx("input",{id:"env-create-name",type:"text",value:w,onChange:me=>N(me.target.value),placeholder:"Environment name...",autoFocus:!0,className:re.nameInput,"data-testid":"env-create-name",onKeyDown:me=>{me.key==="Enter"&&X()&&ge()}})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),i.jsxs("select",{id:"env-create-adapter",value:T,onChange:me=>{C(me.target.value),me.target.value==="codespace"&&d()},className:re.adapterSelect,"data-testid":"env-create-adapter",children:[i.jsx("option",{value:"local",children:"local"}),i.jsx("option",{value:"ssh",children:"ssh"}),i.jsx("option",{value:"docker",children:"docker"}),i.jsx("option",{value:"codespace",children:"codespace"})]})]}),T==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:D,onChange:me=>B(me.target.value),placeholder:"Host (optional)...",className:re.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-port",children:"Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:Wc,max:Xc,value:E,onChange:me=>A(me.target.value),placeholder:"Port (optional)...",className:re.fieldInput,"data-testid":"env-create-port"})]})]}),T==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:D,onChange:me=>B(me.target.value),placeholder:"Host (required)...",className:re.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-user",children:"User"}),i.jsx("input",{id:"env-create-user",type:"text",value:P,onChange:me=>I(me.target.value),placeholder:"User (optional)...",className:re.fieldInput,"data-testid":"env-create-user"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-port",children:"SSH Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:Wc,max:Xc,value:E,onChange:me=>A(me.target.value),placeholder:"SSH port (optional)...",className:re.fieldInput,"data-testid":"env-create-port"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-identity",children:"Identity File"}),i.jsx("input",{id:"env-create-identity",type:"text",value:U,onChange:me=>Q(me.target.value),placeholder:"Identity file (optional)...",className:re.fieldInput,"data-testid":"env-create-identity"})]})]}),T==="docker"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-image",children:"Image"}),i.jsx("input",{id:"env-create-image",type:"text",value:$,onChange:me=>W(me.target.value),placeholder:"Image (optional)...",className:re.fieldInput,"data-testid":"env-create-image"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-repo",children:"Repo"}),i.jsx("input",{id:"env-create-repo",type:"text",value:pe,onChange:me=>H(me.target.value),placeholder:"Repo (optional)...",className:re.fieldInput,"data-testid":"env-create-repo"})]})]}),T==="codespace"&&i.jsx(jL,{codespaceName:ie,onCodespaceNameChange:L,envName:w,onEnvNameChange:N,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v})]})})]})}const NL="_group_1iprv_1",CL="_groupTitle_1iprv_8",EL="_shortcutList_1iprv_17",AL="_shortcutRow_1iprv_23",DL="_keys_1iprv_36",RL="_kbd_1iprv_43",ML="_description_1iprv_60",xi={group:NL,groupTitle:CL,shortcutList:EL,shortcutRow:AL,keys:DL,kbd:RL,description:ML},IL=[{title:"Global",shortcuts:[{keys:["?"],description:"Open keyboard shortcuts reference"},{keys:["N"],description:"Create a new task"},{keys:["Escape"],description:"Close dialog or cancel editing"}]},{title:"Task Page",shortcuts:[{keys:["1"],description:"Switch to Overview tab"},{keys:["2"],description:"Switch to Stream tab"},{keys:["3"],description:"Switch to Findings tab"}]},{title:"Workspace Page",shortcuts:[{keys:["1"],description:"Switch to Graph view"},{keys:["2"],description:"Switch to Board view"},{keys:["3"],description:"Switch to Tasks view"}]},{title:"Navigation Lists",shortcuts:[{keys:["←"],description:"Previous tab (horizontal nav)"},{keys:["→"],description:"Next tab (horizontal nav)"},{keys:["↑"],description:"Previous item (vertical nav)"},{keys:["↓"],description:"Next item (vertical nav)"},{keys:["J"],description:"Next item (alias for arrow down/right)"},{keys:["K"],description:"Previous item (alias for arrow up/left)"},{keys:["Home"],description:"Jump to first item"},{keys:["End"],description:"Jump to last item"}]},{title:"Editing",shortcuts:[{keys:["Enter"],description:"Activate / save inline edit"},{keys:["Space"],description:"Activate button or start editing"},{keys:["Escape"],description:"Cancel edit and discard changes"}]},{title:"Chat",shortcuts:[{keys:["Enter"],description:"Send message (when input is focused)"}]}];function OL(){return i.jsxs("section",{className:be.section,"data-testid":"keyboard-shortcuts-panel",children:[i.jsx("h3",{className:be.sectionTitle,children:"Keyboard Shortcuts"}),i.jsx("p",{className:be.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),IL.map(t=>i.jsxs("div",{className:xi.group,children:[i.jsx("h4",{className:xi.groupTitle,children:t.title}),i.jsx("div",{className:xi.shortcutList,children:t.shortcuts.map(s=>i.jsxs("div",{className:xi.shortcutRow,children:[i.jsx("span",{className:xi.keys,children:s.keys.map(o=>i.jsx("kbd",{className:xi.kbd,children:o},o))}),i.jsx("span",{className:xi.description,children:s.description})]},s.description))})]},t.title))]})}const BL=[{key:"claude",label:"Claude",description:"Forward Claude credentials for AI agent access.",options:[{value:"off",label:"Off"},{value:"subscription",label:"Subscription"},{value:"api_key",label:"API Key"}]},{key:"github",label:"GitHub",description:"Forward GITHUB_TOKEN and GH_TOKEN for git operations.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"copilot",label:"Copilot",description:"Forward Copilot tokens (COPILOT_GITHUB_TOKEN, CLI config).",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"codex",label:"Codex",description:"Forward OPENAI_API_KEY for Codex/OpenAI access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"goose",label:"Goose",description:"Forward Goose config and API keys for Goose agent access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]}];function LL({credentialProviders:t,onUpdateCredentialProviders:s}){const o=(r,c)=>{const d={...t};r==="claude"?d.claude=c:d[r]=c,s(d)};return i.jsxs("section",{className:be.section,children:[i.jsx("h3",{className:be.sectionTitle,children:"Credential Providers"}),i.jsx("p",{className:be.sectionDescription,children:"Enable providers to automatically forward credentials to environments at task start. Credentials are read fresh from the host each time."}),i.jsx("div",{className:be.tokenList,children:BL.map(r=>i.jsxs("div",{className:be.tokenRow,children:[i.jsx("span",{className:be.tokenName,children:r.label}),i.jsx("span",{className:be.tokenTarget,children:r.description}),i.jsx("select",{className:be.select,value:t[r.key],onChange:c=>o(r.key,c.target.value),children:r.options.map(c=>i.jsx("option",{value:c.value,children:c.label},c.value))})]},r.key))})]})}const zL="_container_10efq_1",$L="_header_10efq_7",UL="_list_10efq_105",PL="_card_10efq_111",HL="_cardHeader_10efq_125",VL="_cardTitle_10efq_135",qL="_defaultBadge_10efq_141",GL="_cardActions_10efq_155",FL="_description_10efq_160",ZL="_meta_10efq_166",KL="_empty_10efq_212",YL="_typeBadge_10efq_362",Jn={container:zL,header:$L,list:UL,card:PL,cardHeader:HL,cardTitle:VL,defaultBadge:qL,cardActions:GL,description:FL,meta:ZL,empty:KL,typeBadge:YL};function JL({personas:t,appDefaultPersonaId:s,onDeletePersona:o,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=y.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await o(v),p(null)};return i.jsxs("div",{className:Jn.container,children:[i.jsxs("div",{className:Jn.header,children:[i.jsx("h2",{children:"Personas"}),i.jsx(Js,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?i.jsx("p",{className:Jn.empty,children:"No personas yet. Create one to get started."}):i.jsx("div",{className:Jn.list,children:t.map(v=>{const b=s===v.id,x=v.type==="script";return i.jsxs("div",{className:Jn.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:S=>{S.currentTarget===S.target&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),d(v.id))},children:[i.jsxs("div",{className:Jn.cardHeader,children:[i.jsxs("span",{className:Jn.cardTitle,children:[i.jsx("strong",{children:v.name}),i.jsx("span",{className:Jn.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:x?"Script":"Agent"}),b&&i.jsx("span",{className:Jn.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),i.jsxs("div",{className:Jn.cardActions,onClick:S=>S.stopPropagation(),children:[!b&&i.jsx(Js,{variant:"ghost",size:"sm",onClick:()=>{r(v.id).catch(()=>{})},"data-testid":`persona-set-default-${v.id}`,title:"Set as app default persona",children:"Set Default"}),i.jsx(Js,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),i.jsx(Js,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&i.jsx("p",{className:Jn.description,children:v.description}),i.jsxs("div",{className:Jn.meta,children:[v.runtime&&i.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&i.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&i.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),i.jsx(Ci,{isOpen:u!==null,title:"Delete Persona?",description:`"${(m==null?void 0:m.name)??""}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:()=>{u&&g(u).catch(()=>{})},onCancel:()=>p(null)})]})}const WL="_container_uy08i_1",XL="_header_uy08i_7",QL="_count_uy08i_13",e8="_presets_uy08i_18",t8="_presetButton_uy08i_24",n8="_filterInput_uy08i_41",s8="_groups_uy08i_53",a8="_group_uy08i_53",i8="_groupHeader_uy08i_68",o8="_groupName_uy08i_77",r8="_groupCount_uy08i_81",l8="_toolList_uy08i_87",c8="_toolItem_uy08i_95",d8="_toolName_uy08i_103",pn={container:WL,header:XL,count:QL,presets:e8,presetButton:t8,filterInput:n8,groups:s8,group:a8,groupHeader:i8,groupName:o8,groupCount:r8,toolList:l8,toolItem:c8,toolName:d8},u8=(()=>{const t=new Map;for(const s of dx){const o=s==="get_version_status"?"version":s.split("_")[0];t.has(o)||t.set(o,[]),t.get(o).push(s)}return[...t.entries()].sort(([s],[o])=>s.localeCompare(o)).map(([s,o])=>({group:s,tools:o.sort()}))})(),f8=[{name:"default",label:"Default",tools:ux},{name:"worker",label:"Worker",tools:yT},{name:"orchestrator",label:"Orchestrator",tools:bT},{name:"admin",label:"Admin",tools:xT}];function Fb({selectedTools:t,onChange:s,disabled:o}){const[r,c]=y.useState(""),d=y.useMemo(()=>new Set(t),[t]),u=y.useCallback(v=>{if(o)return;const b=new Set(d);b.has(v)?b.delete(v):b.add(v),s([...b].sort())},[d,s,o]),p=y.useCallback((v,b)=>{if(o)return;const x=new Set(d);for(const S of v)b?x.delete(S):x.add(S);s([...x].sort())},[d,s,o]),m=y.useCallback(v=>{o||s([...v].sort())},[s,o]),g=r.toLowerCase();return i.jsxs("div",{className:pn.container,"data-testid":"mcp-tool-selector",children:[i.jsx("div",{className:pn.header,children:i.jsx("span",{className:pn.count,children:t.length===0?`Using default (${ux.length} tools)`:`${t.length} of ${dx.size} tools selected`})}),i.jsxs("div",{className:pn.presets,"data-testid":"mcp-tool-presets",children:[f8.map(v=>i.jsx("button",{type:"button",className:pn.presetButton,disabled:o,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),i.jsx("button",{type:"button",className:pn.presetButton,disabled:o,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),i.jsx("input",{type:"text",className:pn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:o,"data-testid":"mcp-tool-filter"}),i.jsx("div",{className:pn.groups,children:u8.map(({group:v,tools:b})=>{const x=g?b.filter(k=>k.toLowerCase().includes(g)):b;if(x.length===0)return null;const S=x.every(k=>d.has(k));return i.jsxs("div",{className:pn.group,"data-testid":`tool-group-${v}`,children:[i.jsxs("label",{className:pn.groupHeader,children:[i.jsx("input",{type:"checkbox",checked:S,onChange:()=>p(x,S),disabled:o,"data-testid":`group-toggle-${v}`}),i.jsx("span",{className:pn.groupName,children:v}),i.jsxs("span",{className:pn.groupCount,children:["(",x.filter(k=>d.has(k)).length,"/",x.length,")"]})]}),i.jsx("div",{className:pn.toolList,children:x.map(k=>i.jsxs("label",{className:pn.toolItem,children:[i.jsx("input",{type:"checkbox",checked:d.has(k),onChange:()=>u(k),disabled:o,"data-testid":`tool-${k}`}),i.jsx("span",{className:pn.toolName,children:k})]},k))})]},v)})})]})}const p8="_nav_1bhou_1",m8="_tab_1bhou_24",h8="_tabIcon_1bhou_62",g8="_tabActive_1bhou_68",zc={nav:p8,tab:m8,tabIcon:h8,tabActive:g8},Ks=[{path:"credentials",label:"Credentials",icon:i.jsx(C2,{size:zt})},{path:"personas",label:"Personas",icon:i.jsx(nw,{size:zt})},{path:"appearance",label:"Appearance",icon:i.jsx(q2,{size:zt})},{path:"shortcuts",label:"Shortcuts",icon:i.jsx(A2,{size:zt})},{path:"about",label:"About",icon:i.jsx(im,{size:zt})}];function v8(){var u;const t=Zt(),s=kt(),o=y.useRef(null),r=((u=Ks.find(p=>{const m=`${Do}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??Ks[0].path,c=y.useCallback(p=>{s(`${Do}/${p}`)},[s]),d=y.useCallback(p=>{var S,k;const m=(S=o.current)==null?void 0:S.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(w=>w===document.activeElement),v=g>=0?g:Ks.findIndex(w=>w.path===r);let b=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),b=(v+1)%Ks.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),b=(v-1+Ks.length)%Ks.length;else if(p.key==="Home")p.preventDefault(),b=0;else if(p.key==="End")p.preventDefault(),b=Ks.length-1;else return;const x=Ks[b].path;s(`${Do}/${x}`),(k=m[b])==null||k.focus()},[r,s]);return i.jsx("nav",{className:zc.nav,ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:Ks.map(p=>{const m=p.path===r;return i.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${zc.tab} ${m?zc.tabActive:""}`,onClick:()=>c(p.path),children:[i.jsx("span",{className:zc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}function y8({tasks:t,taskStatusById:s,sessionStatusByTaskId:o}){const r=new Map;for(const d of t)if(d.parentTaskId){const u=r.get(d.parentTaskId);u?u.push(d):r.set(d.parentTaskId,[d])}const c=new Map(cy.map(d=>[d,[]]));for(const d of t){const u=ll(d.status),p=d.dependsOn.length>0&&d.dependsOn.some(k=>s.get(k)!=="complete"),m=r.get(d.id)??[],g=m.length,v=m.filter(k=>k.status==="complete").length;let b;if(u==="paused"&&o){const k=o.get(d.id);k==="idle"?b="Needs input":k==="completed"&&(b="Ready to complete")}const x={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:b},S=c.get(u);S?S.push(x):c.get("not_started").push(x)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return cy.map(d=>{const u=za(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const b8="_boardContainer_1c4y1_1",x8="_column_1c4y1_17",_8="_columnHeader_1c4y1_34",k8="_columnIcon_1c4y1_47",S8="_columnLabel_1c4y1_52",T8="_columnCount_1c4y1_57",w8="_cardList_1c4y1_67",j8="_emptyPlaceholder_1c4y1_76",N8="_card_1c4y1_67",C8="_cardHeader_1c4y1_107",E8="_cardStatusIcon_1c4y1_113",A8="_cardTitle_1c4y1_119",D8="_cardBadges_1c4y1_127",R8="_badge_1c4y1_134",M8="_blockedBadge_1c4y1_146",I8="_childBadge_1c4y1_151",O8="_depBadge_1c4y1_155",B8="_parentBadge_1c4y1_159",L8="_pausedSubBadge_1c4y1_166",z8="_personaBadge_1c4y1_170",$8="_envBadge_1c4y1_174",U8="_emptyCta_1c4y1_178",P8="_ctaButton_1c4y1_188",H8="_ctaDescription_1c4y1_204",it={boardContainer:b8,column:x8,columnHeader:_8,columnIcon:k8,columnLabel:S8,columnCount:T8,cardList:w8,emptyPlaceholder:j8,card:N8,cardHeader:C8,cardStatusIcon:E8,cardTitle:A8,cardBadges:D8,badge:R8,blockedBadge:M8,childBadge:I8,depBadge:O8,parentBadge:B8,pausedSubBadge:L8,personaBadge:z8,envBadge:$8,emptyCta:U8,ctaButton:P8,ctaDescription:H8};function V8({workspaceId:t,environmentId:s,tasks:o,sessions:r,personas:c,environments:d}){const u=kt(),p=y.useMemo(()=>o.filter(x=>x.workspaceId===t),[o,t]),m=y.useMemo(()=>new Map(o.map(x=>[x.id,x.status])),[o]),g=y.useMemo(()=>new Map(p.map(x=>[x.id,x])),[p]),v=y.useMemo(()=>{const x=new Map(r.map(C=>[C.id,C])),S=new Map(c.map(C=>[C.id,C])),k=new Map(d.map(C=>[C.id,C])),w=new Map,N=new Map,T=new Map;for(const C of p)if(C.latestSessionId){const D=x.get(C.latestSessionId);if(D){if(w.set(C.id,D.endReason||D.status),D.personaId){const B=S.get(D.personaId);B&&N.set(C.id,B.name)}if(D.environmentId){const B=k.get(D.environmentId);B&&T.set(C.id,B.displayName)}}}return{sessionStatusByTaskId:w,personaNameByTaskId:N,environmentNameByTaskId:T}},[p,r,c,d]),b=y.useMemo(()=>y8({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?i.jsxs("div",{className:it.emptyCta,"data-testid":"board-empty-cta",children:[i.jsx("button",{className:it.ctaButton,onClick:()=>u(Di(t,void 0,s)),children:"Create Task"}),i.jsx("div",{className:it.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):i.jsx("div",{className:it.boardContainer,"data-testid":"board-container",children:b.map(x=>i.jsxs("section",{className:it.column,"data-testid":`board-column-${x.status}`,"aria-label":`${x.label}, ${x.tasks.length} ${x.tasks.length===1?"task":"tasks"}`,children:[i.jsxs("div",{className:it.columnHeader,children:[i.jsx("span",{className:it.columnIcon,style:{color:x.style.color},children:x.style.icon}),i.jsx("span",{className:it.columnLabel,children:x.label}),i.jsx("span",{className:it.columnCount,"data-testid":`board-count-${x.status}`,children:x.tasks.length})]}),i.jsx("div",{className:it.cardList,children:x.tasks.length===0?i.jsx("div",{className:it.emptyPlaceholder,children:"No tasks"}):i.jsx(us,{mode:"popLayout",children:x.tasks.map(S=>i.jsx(Rt.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:i.jsx(q8,{boardTask:S,tasksById:g,personaName:v.personaNameByTaskId.get(S.task.id),envName:v.environmentNameByTaskId.get(S.task.id),onClick:()=>u(On(S.task.id,void 0,t,s))})},S.task.id))})})]},x.status))})}function q8({boardTask:t,tasksById:s,personaName:o,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=za(d.status),b=d.parentTaskId?s.get(d.parentTaskId):void 0;return i.jsxs("div",{className:it.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),c())},children:[i.jsxs("div",{className:it.cardHeader,children:[i.jsx("span",{className:it.cardStatusIcon,style:{color:v.color},children:v.icon}),i.jsx("span",{className:it.cardTitle,children:d.title})]}),i.jsxs("div",{className:it.cardBadges,children:[b&&i.jsx("span",{className:`${it.badge} ${it.parentBadge}`,title:b.title,children:b.title}),p>0&&i.jsxs("span",{className:`${it.badge} ${it.childBadge}`,children:[m,"/",p]}),u&&i.jsx("span",{className:`${it.badge} ${it.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&i.jsx("span",{className:`${it.badge} ${it.depBadge}`,children:"dep"}),g&&i.jsx("span",{className:`${it.badge} ${it.pausedSubBadge}`,children:g}),o&&i.jsx("span",{className:`${it.badge} ${it.personaBadge}`,children:o}),r&&i.jsx("span",{className:`${it.badge} ${it.envBadge}`,children:r})]})]})}const G8="_formContent_ymnez_1",F8="_section_ymnez_13",Z8="_label_ymnez_19",K8="_titleInput_ymnez_26",Y8="_descriptionTextarea_ymnez_58",J8="_selectField_ymnez_94",W8="_checkboxRow_ymnez_128",X8="_checkboxLabel_ymnez_141",Q8="_fieldError_ymnez_146",bt={formContent:G8,section:F8,label:Z8,titleInput:K8,descriptionTextarea:Y8,selectField:J8,checkboxRow:W8,checkboxLabel:X8,fieldError:Q8};function e7(t,s){return{name:(t==null?void 0:t.name)??"",description:(t==null?void 0:t.description)??"",repoUrl:(t==null?void 0:t.repoUrl)??"",environmentId:(t==null?void 0:t.environmentId)??s??"",defaultPersonaId:(t==null?void 0:t.defaultPersonaId)??"",useWorktrees:(t==null?void 0:t.useWorktrees)??!0,workingDirectory:(t==null?void 0:t.workingDirectory)??""}}const t7=100;function n7({values:t,onChange:s,environments:o,personas:r,errors:c,disabled:d,autoFocusName:u}){const p=(m,g)=>{s({...t,[m]:g})};return i.jsxs("div",{className:bt.formContent,children:[i.jsxs("div",{className:bt.section,children:[i.jsx("label",{className:bt.label,htmlFor:"ws-name",children:"Name"}),i.jsx("input",{id:"ws-name",className:bt.titleInput,type:"text",value:t.name,onChange:m=>p("name",m.target.value),placeholder:"Workspace name",maxLength:t7,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&i.jsx("span",{className:bt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),i.jsxs("div",{className:bt.section,children:[i.jsx("label",{className:bt.label,htmlFor:"ws-description",children:"Description"}),i.jsx("textarea",{id:"ws-description",className:bt.descriptionTextarea,value:t.description,onChange:m=>p("description",m.target.value),placeholder:"Optional description (Markdown supported)",disabled:d,"data-testid":"workspace-form-description"})]}),i.jsxs("div",{className:bt.section,children:[i.jsx("label",{className:bt.label,htmlFor:"ws-repo",children:"Repository URL"}),i.jsx("input",{id:"ws-repo",className:bt.titleInput,type:"text",value:t.repoUrl,onChange:m=>p("repoUrl",m.target.value),placeholder:"https://github.com/org/repo",disabled:d,"data-testid":"workspace-form-repo"}),(c==null?void 0:c.repoUrl)&&i.jsx("span",{className:bt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),i.jsxs("div",{className:bt.section,children:[i.jsx("label",{className:bt.label,htmlFor:"ws-environment",children:"Environment"}),i.jsxs("select",{id:"ws-environment",className:bt.selectField,value:t.environmentId,onChange:m=>p("environmentId",m.target.value),disabled:d,"data-testid":"workspace-form-environment",children:[i.jsx("option",{value:"",children:"Select environment…"}),o.map(m=>i.jsx("option",{value:m.id,children:m.displayName||m.id},m.id))]}),(c==null?void 0:c.environmentId)&&i.jsx("span",{className:bt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),i.jsxs("div",{className:bt.section,children:[i.jsx("label",{className:bt.label,htmlFor:"ws-persona",children:"Default Persona"}),i.jsxs("select",{id:"ws-persona",className:bt.selectField,value:t.defaultPersonaId,onChange:m=>p("defaultPersonaId",m.target.value),disabled:d,"data-testid":"workspace-form-persona",children:[i.jsx("option",{value:"",children:"(Inherit)"}),r.map(m=>i.jsx("option",{value:m.id,children:m.name},m.id))]})]}),i.jsx("div",{className:bt.section,children:i.jsxs("label",{className:bt.checkboxRow,children:[i.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:m=>p("useWorktrees",m.target.checked),disabled:d,"data-testid":"workspace-form-worktrees"}),i.jsx("span",{className:bt.checkboxLabel,children:"Enable worktree isolation"})]})}),i.jsxs("div",{className:bt.section,children:[i.jsx("label",{className:bt.label,htmlFor:"ws-workdir",children:"Working Directory"}),i.jsx("input",{id:"ws-workdir",className:bt.titleInput,type:"text",value:t.workingDirectory,onChange:m=>p("workingDirectory",m.target.value),placeholder:"Default (server default)",disabled:d,"data-testid":"workspace-form-workdir"})]})]})}const D1=y.createContext(void 0),s7=4e3;function a7({children:t}){const[s,o]=y.useState([]),r=y.useRef(0),c=y.useCallback(u=>{o(p=>p.filter(m=>m.id!==u))},[]),d=y.useCallback((u,p="info",m=s7)=>{const g=`toast-${++r.current}`;o(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return i.jsx(D1.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function Sn(){const t=y.useContext(D1);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const em="grackle-theme",R1="grackle-prefer-system",M1="(prefers-color-scheme: dark)";let Gr=[],Qc;function _p(){Qc=void 0;for(const t of Gr)t()}function tm(){return typeof window>"u"?!1:window.matchMedia(M1).matches}function Wr(){if(typeof localStorage>"u")return qb;try{const t=localStorage.getItem(em);if(t!==null&&C1.has(t))return t}catch{}return qb}function pd(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(R1)==="true"}catch{return!1}}function nm(t){return Cd.find(s=>s.variantLightId===t||s.variantDarkId===t)}function I1(t,s){const o=Qp(t);if(o!=null&&o.variantDarkId)return s&&o.variantLightId?tm()?o.variantDarkId:o.variantLightId:o.variantDarkId;if(o!=null&&o.hidden&&s){const r=nm(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return tm()?r.variantDarkId:r.variantLightId}return t}function To(t,s,o=!1){o&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=I1(t,s),o&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&To(Wr(),pd());function i7(){return Qc===void 0&&(Qc={themeId:Wr(),systemDark:tm(),preferSystem:pd()}),Qc}function o7(t){return Gr=[...Gr,t],()=>{Gr=Gr.filter(s=>s!==t)}}function r7(){const t=y.useSyncExternalStore(o7,i7),{themeId:s,preferSystem:o}=t,r=I1(s,o),c=y.useCallback(u=>{if(C1.has(u)){try{localStorage.setItem(em,u)}catch{}To(u,pd(),!0),_p()}},[]),d=y.useCallback(u=>{try{localStorage.setItem(R1,u?"true":"false")}catch{}if(u){const p=Wr(),m=Qp(p);if(m!=null&&m.hidden){const g=nm(p);if(g)try{localStorage.setItem(em,g.id)}catch{}}}To(Wr(),u,!0),_p()},[]);return y.useEffect(()=>{To(s,o)},[s,o]),y.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(M1),p=()=>{const m=Wr(),g=pd();if(g){const v=Qp(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&To(m,g),v!=null&&v.hidden){const b=nm(m);b!=null&&b.variantDarkId&&b.variantLightId&&To(m,g)}}_p()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:o,setPreferSystem:d}}const O1=y.createContext(void 0);function l7({children:t}){const s=r7();return i.jsx(O1.Provider,{value:s,children:t})}function B1(){const t=y.useContext(O1);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const L1=y.createContext(void 0),z1=y.createContext(void 0);function c7({children:t}){const[s,o]=y.useState(void 0),r=y.useCallback(c=>{o(c)},[]);return i.jsx(z1.Provider,{value:r,children:i.jsx(L1.Provider,{value:s,children:t})})}function d7(){return y.useContext(L1)}function u7(){const t=y.useContext(z1);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const th=y.createContext(void 0);function mt(){const t=y.useContext(th);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function $1(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function U1(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function f7(t){return $1(t)&&typeof t.sessionId=="string"&&typeof t.eventType=="string"&&typeof t.timestamp=="string"&&typeof t.content=="string"&&(t.raw===void 0||typeof t.raw=="string")}const p7=new Set(["off","subscription","api_key"]),$c=new Set(["off","on"]);function m7(t){return $1(t)&&p7.has(t.claude)&&$c.has(t.github)&&$c.has(t.copilot)&&$c.has(t.codex)&&$c.has(t.goose)}function P1(t){switch(t){case"waiting_input":return"idle";case"completed":return"stopped";case"killed":return"stopped";case"failed":return"stopped";case"interrupted":return"stopped";case"terminated":return"stopped";default:return t}}function H1(t){switch(t){case"completed":return"completed";case"killed":return"killed";case"failed":return"interrupted";case"interrupted":return"interrupted";case"terminated":return"terminated";default:return}}const So=5e3;function h7(t,s){const o=[];let r=t;const c=new Set;for(;r&&s.has(r)&&!c.has(r);){c.add(r);const d=s.get(r);o.unshift(d),r=d.parentTaskId||void 0}return o}const na={label:"Home",url:Ni};function g7(t){return t?[na,{label:"Settings",url:Do},{label:t,url:void 0}]:[na,{label:"Settings",url:void 0}]}const nh={label:"Environments",url:Ro};function v7(){return[na,{label:"Environments",url:void 0}]}function y7(){return[na,{label:"New Chat",url:void 0}]}function b7(t){return[na,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function x7(t,s,o,r){const c=o.find(u=>u.id===t),d=r.find(u=>u.id===s);return[na,nh,{label:(d==null?void 0:d.displayName)??"Environment",url:ji(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function _7(t,s,o,r,c){const d=h7(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?o.find(S=>S.id===p):void 0,g=s??(m==null?void 0:m.environmentId),v=g?r.find(S=>S.id===g):void 0,b=[na];v&&g&&(b.push(nh),b.push({label:v.displayName,url:ji(g)})),m&&g&&b.push({label:m.name,url:$a(m.id,g)});for(let S=0;S<d.length-1;S++)b.push({label:d[S].title,url:On(d[S].id,void 0,p,g)});const x=d[d.length-1];return b.push({label:(x==null?void 0:x.title)??t,url:void 0}),b}const k7={label:"Findings",url:_d};function S7(){return[na,{label:"Findings",url:void 0}]}function V1(t,s,o,r,c){const d=[na];if(s&&o){const u=r.find(m=>m.id===s),p=c.find(m=>m.id===o);d.push(nh),p&&d.push({label:p.displayName,url:ji(o)}),u&&d.push({label:u.name,url:$a(s,o)}),d.push({label:"Findings",url:dN(s,o)})}else d.push(k7);return d.push({label:t,url:void 0}),d}function sh(t){const s=[];for(const o of t){const r=s[s.length-1];o.eventType==="text"&&(r==null?void 0:r.eventType)==="text"?s[s.length-1]={...r,content:r.content+o.content}:s.push(o)}return s}function Uc(t){if(typeof t.id=="string")return t.id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const o=t.item;if(o&&typeof o.id=="string")return o.id}function T7(t){if(typeof t.tool_use_id=="string")return t.tool_use_id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const o=t.item;if(o&&typeof o.id=="string")return o.id}function ah(t){const s=new Map;for(const v of t)if(v.raw)try{s.set(v,JSON.parse(v.raw))}catch{}const o=new Map;for(const v of t){if(v.eventType!=="tool_use")continue;const b=s.get(v),x=b?Uc(b):void 0;if(x)try{const S=JSON.parse(v.content);o.set(x,{tool:S.tool,args:S.args})}catch{}}const r=new Set,c=new Set,d=t.map((v,b)=>{if(v.eventType!=="tool_result")return v;const x=s.get(v),S=x?T7(x):void 0;if(!S)return v;const k=o.get(S);if(!k)return v;r.add(S),c.add(b);let w;const N=v.content.trim();if(N.startsWith("{"))try{const T=JSON.parse(N);typeof T.detailedContent=="string"&&(w=T.detailedContent)}catch{}return{...v,toolUseCtx:{...k,detailedResult:w}}}),u=[];for(let v=0;v<d.length;v++){if(d[v].eventType!=="tool_use")continue;const b=s.get(d[v]),x=b?Uc(b):void 0;x&&r.has(x)||u.push(v)}const p=[];for(let v=0;v<d.length;v++)d[v].eventType!=="tool_result"||c.has(v)||p.push(v);let m=0;for(const v of u){for(;m<p.length&&p[m]<v;)m++;if(m>=p.length)break;const b=p[m];if(b!==v+1)continue;const x=d[v],S=d[b];let k;try{const w=JSON.parse(x.content);k={tool:w.tool,args:w.args}}catch{}if(k){let w;const N=S.content.trim();if(N.startsWith("{"))try{const D=JSON.parse(N);typeof D.detailedContent=="string"&&(w=D.detailedContent)}catch{}d[b]={...S,toolUseCtx:{...k,detailedResult:w}},c.add(b);const T=s.get(x),C=T?Uc(T):void 0;C?r.add(C):(r.add(`__seq_${v}`),s.set(x,{...T??{},__seqId:`__seq_${v}`})),m++}}const g=d.filter(v=>{if(v.eventType!=="tool_use")return!0;const b=s.get(v);if(!b)return!0;const x=Uc(b);if(x&&r.has(x))return!1;const S=b.__seqId;return!(S&&r.has(S))});for(let v=0;v<g.length;v++){if(g[v].eventType!=="tool_use")continue;let b=!1;for(let x=v+1;x<g.length;x++)if(g[x].eventType!=="tool_use"){b=!0;break}b&&(g[v]={...g[v],settled:!0})}return g}function w7(t,s,o){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=q1(s),d=s.filter(m=>sm(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||sm(m,c)).length,p=o.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function q1(t){const s=new Map;for(const o of t)s.set(o.id,o.status);return s}function sm(t,s){return t.dependsOn.some(o=>s.get(o)!=="complete")}function j7(t,s){var u;const o=new Map;for(const p of s)o.set(p.id,p);const r=q1(t),c=[];for(const p of t){const m=p.workspaceId?((u=o.get(p.workspaceId))==null?void 0:u.name)??"Unknown":"Unknown";p.status==="failed"?c.push({task:p,reason:"failed",workspaceName:m}):sm(p,r)?c.push({task:p,reason:"blocked",workspaceName:m}):p.status==="paused"&&c.push({task:p,reason:"paused",workspaceName:m})}const d={failed:0,blocked:1,paused:2};return c.sort((p,m)=>(d[p.reason]??3)-(d[m.reason]??3)),c}function N7(t,s){const o=new Map;for(const r of s)o.set(r.id,r);return t.filter(r=>r.status==="running"||r.status==="idle"||r.status==="waiting").map(r=>{var c;return{session:r,environmentName:((c=o.get(r.environmentId))==null?void 0:c.displayName)??"Unknown"}})}function C7(t,s,o){const r=new Map;for(const c of s){if(!c.workspaceId)continue;let d=r.get(c.workspaceId);d||(d={totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0},r.set(c.workspaceId,d)),d.totalTasks+=1,c.status==="complete"?d.completedTasks+=1:c.status==="working"?d.workingTasks+=1:c.status==="failed"&&(d.failedTasks+=1)}return t.map(c=>{const d=r.get(c.id)??{totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0};return{workspace:c,totalTasks:d.totalTasks,completedTasks:d.completedTasks,workingTasks:d.workingTasks,failedTasks:d.failedTasks}})}const ks=[{id:"kn-auth-flow",label:"Authentication Flow",kind:"knowledge",category:"concept",content:"The application uses JWT Bearer tokens for stateless authentication. Access tokens expire after 24h. Refresh tokens are stored in the database and rotated on use. The auth middleware verifies tokens and attaches the decoded payload to req.user.",tags:["auth","jwt","security"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:30:00Z",updatedAt:"2026-02-27T08:15:00Z",val:5},{id:"kn-db-schema",label:"Database Schema",kind:"knowledge",category:"concept",content:"PostgreSQL database with tables: users, sessions, refresh_tokens, audit_log. Uses UUID primary keys, TIMESTAMPTZ for all timestamps, and JSONB for flexible metadata columns. Connection pooling via pg-pool with per-tenant isolation.",tags:["database","postgres","schema"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:00:00Z",updatedAt:"2026-02-26T22:45:00Z",val:4},{id:"kn-error-handling",label:"Error Response Pattern",kind:"knowledge",category:"concept",content:"All API errors follow the shape { error: string, code: string, details?: unknown }. HTTP status codes map to: 400 (validation), 401 (unauthenticated), 403 (forbidden), 404 (not found), 409 (conflict), 429 (rate limited), 500 (internal).",tags:["api","errors","patterns"],workspaceId:"proj-alpha",createdAt:"2026-02-27T08:17:00Z",updatedAt:"2026-02-27T08:17:00Z",val:3},{id:"kn-rate-limiting",label:"Rate Limiting Strategy",kind:"knowledge",category:"concept",content:"Token-bucket algorithm with in-memory state per client IP. Default rate: 100 requests/minute, burst: 20. Returns 429 with Retry-After header. Redis adapter available for multi-instance deployments.",tags:["api","rate-limiting","infrastructure"],workspaceId:"proj-alpha",createdAt:"2026-02-27T09:00:00Z",updatedAt:"2026-02-27T09:00:00Z",val:2},{id:"kn-etl-pipeline",label:"ETL Pipeline Architecture",kind:"knowledge",category:"concept",content:"Data pipelines follow an Extract-Transform-Load pattern with pluggable stages. Each stage reads from a source (Postgres, S3, API), transforms via configurable mappers, and loads into a target (Parquet, BigQuery, S3). Incremental loads use high-watermark tracking.",tags:["etl","pipeline","architecture"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:00:00Z",updatedAt:"2026-02-27T09:05:00Z",val:4},{id:"kn-parquet-format",label:"Parquet Output Format",kind:"knowledge",category:"concept",content:"Parquet files are written with row-group buffering (configurable batch size, default 10000 rows). Supports Snappy, ZSTD, and GZIP compression. Schema is derived from the internal column type system using Arrow type mapping.",tags:["parquet","data-format","compression"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:05:00Z",updatedAt:"2026-02-26T08:15:00Z",val:3},{id:"kn-jwt-over-session",label:"JWT over Session Auth",kind:"knowledge",category:"decision",content:"Chose JWT tokens over server-side sessions for stateless auth. Rationale: (1) no session store needed, (2) works across microservices without shared state, (3) supports mobile clients natively. Trade-off: tokens can't be revoked instantly (mitigated by short expiry + refresh rotation).",tags:["auth","decision","jwt"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:00:00Z",updatedAt:"2026-02-25T10:00:00Z",val:3},{id:"kn-pg-pool-decision",label:"pg-pool over Knex",kind:"knowledge",category:"decision",content:"Chose pg-pool over Knex for connection pooling. pg-pool gives direct control over idle timeout, max connections, and health check queries. Knex wraps pg-pool and adds query-building overhead we don't need since we write raw SQL with parameterized queries.",tags:["database","decision","postgres"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:30:00Z",updatedAt:"2026-02-23T11:30:00Z",val:2},{id:"kn-watermark-decision",label:"Local Watermark Storage",kind:"knowledge",category:"decision",content:"Currently using local SQLite for watermark storage. This works for single-worker pipelines but needs to move to a shared store (Redis or Postgres) for production multi-worker scenarios. Tracked as a follow-up task.",tags:["pipeline","decision","watermarks"],workspaceId:"proj-beta",createdAt:"2026-02-27T09:05:00Z",updatedAt:"2026-02-27T09:05:00Z",val:2},{id:"kn-jwt-middleware",label:"JWT Verify Middleware",kind:"knowledge",category:"snippet",content:`\`\`\`typescript
|
|
274
|
+
`)}function s6({events:t,formatForClipboard:s}){const[o,r]=y.useState(!1),[c,d]=y.useState(new Set),u=y.useRef(void 0),p=y.useMemo(()=>c.size,[c]),m=y.useCallback(k=>{r(!0),k!==void 0?(d(new Set([k])),u.current=k):(d(new Set),u.current=void 0)},[]),g=y.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=y.useCallback((k,w)=>{if(w&&u.current!==void 0){const N=Math.min(u.current,k),T=Math.max(u.current,k);d(C=>{const D=new Set(C);for(let B=N;B<=T;B++)B<t.length&&rl(t[B])&&D.add(B);return D})}else d(N=>{const T=new Set(N);return T.has(k)?T.delete(k):T.add(k),T.size===0?(r(!1),u.current=void 0):u.current=k,T})},[t]),b=y.useCallback(()=>{const k=new Set;for(let w=0;w<t.length;w++)rl(t[w])&&k.add(w);d(k)},[t]),x=y.useCallback(()=>{d(new Set)},[]),S=y.useCallback(async()=>{const w=[...c].sort((T,C)=>T-C).filter(T=>T<t.length).map(T=>t[T]);if(w.length===0)return!1;const N=s(w);try{return await navigator.clipboard.writeText(N),!0}catch{return!1}},[c,t,s]);return{isSelecting:o,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:b,deselectAll:x,copySelected:S}}const a6="_wrapper_1cdza_1",i6="_scrollContainer_1cdza_9",o6="_selectingPadding_1cdza_16",r6="_toolbar_1cdza_20",l6="_directionToggle_1cdza_27",c6="_scrollToAnchor_1cdza_65",d6="_scrollToAnchorBottom_1cdza_89",u6="_scrollToAnchorTop_1cdza_93",f6="_eventOverflowWarning_1cdza_97",Ys={wrapper:a6,scrollContainer:i6,selectingPadding:o6,toolbar:r6,directionToggle:l6,scrollToAnchor:c6,scrollToAnchorBottom:d6,scrollToAnchorTop:u6,eventOverflowWarning:f6};function p6(t){const s=new Date(t.timestamp).toLocaleTimeString();switch(t.eventType){case"text":case"output":return`Select message from assistant at ${s}`;case"user_input":return`Select message from user at ${s}`;case"tool_result":case"tool_use":return`Select tool event at ${s}`;case"error":return`Select error at ${s}`;default:return`Select event at ${s}`}}const b1="grackle-stream-direction";function m6(){try{return localStorage.getItem(b1)==="reversed"}catch{return!1}}function h6({eventsDropped:t}){return t<=0?i.jsx(i.Fragment,{}):i.jsxs("div",{className:Ys.eventOverflowWarning,role:"alert",children:[i.jsx(om,{size:tn,"aria-hidden":"true"})," ",t.toLocaleString()," older event",t===1?"":"s"," were dropped — only the most recent 5,000 are shown. Full history is available in the session log."]})}function Xm({events:t,eventsDropped:s,emptyState:o,onShowToast:r}){const c=y.useRef(null),[d,u]=y.useState(m6),p=Q4(),m=s6({events:t,formatForClipboard:n6}),g=y.useMemo(()=>t.filter(rl).length,[t]),v=y.useMemo(()=>d?[...t].reverse():t,[t,d]),{isAtAnchor:b,scrollToAnchor:x}=Q3({scrollRef:c,contentLength:t.length,isReversed:d,paused:m.isSelecting}),S=()=>{const T=!d;u(T);try{localStorage.setItem(b1,T?"reversed":"default")}catch{}};y.useEffect(()=>{if(!m.isSelecting)return;const T=C=>{C.key==="Escape"&&m.cancelSelection()};return window.addEventListener("keydown",T),()=>{window.removeEventListener("keydown",T)}},[m.isSelecting,m.cancelSelection]);const k=y.useCallback(async()=>{await m.copySelected()&&(r==null||r(`Copied ${m.selectedCount} message${m.selectedCount===1?"":"s"} to clipboard`,"success"))},[m,r]),w=p?0:.2,N=d?-8:8;return i.jsxs("div",{className:Ys.wrapper,children:[i.jsx("div",{className:Ys.toolbar,children:i.jsx(Lo,{text:d?"Showing newest first":"Showing oldest first",children:i.jsx("button",{className:Ys.directionToggle,onClick:S,"aria-label":d?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:d?i.jsx(ry,{size:tn,"aria-hidden":"true"}):i.jsx(ly,{size:tn,"aria-hidden":"true"})})})}),i.jsxs("div",{ref:c,className:`${Ys.scrollContainer} ${m.isSelecting?Ys.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&o,i.jsx(h6,{eventsDropped:s}),i.jsx(us,{initial:!1,children:v.map((T,C)=>{const D=d?t.length-1-C:C;return i.jsx(Rt.div,{initial:{opacity:0,y:N},animate:{opacity:1,y:0},transition:{duration:w,ease:"easeOut"},children:i.jsx(H3,{copyText:t6(T),isContentBearing:rl(T),isSelecting:m.isSelecting,isSelected:m.selectedIndices.has(D),checkboxLabel:p6(T),onSelect:()=>{m.enterSelectionMode(D)},onToggle:B=>{m.toggleEvent(D,B)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:i.jsx(NA,{event:T,toolUseCtx:T.toolUseCtx,settled:T.settled})})},`${T.sessionId}-${T.timestamp}-${D}`)})})]}),i.jsx(us,{children:m.isSelecting&&i.jsx(J3,{selectedCount:m.selectedCount,totalSelectable:g,onSelectAll:m.selectAll,onDeselectAll:m.deselectAll,onCopy:()=>{k().catch(()=>{})},onCancel:m.cancelSelection})}),i.jsx(us,{children:!b&&i.jsxs(Rt.button,{className:`${Ys.scrollToAnchor} ${d?Ys.scrollToAnchorTop:Ys.scrollToAnchorBottom}`,onClick:x,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.15},"aria-label":"Scroll to latest","data-testid":"scroll-to-anchor",children:[d?i.jsx(ly,{size:tn,"aria-hidden":"true"}):i.jsx(ry,{size:tn,"aria-hidden":"true"})," New events"]})})]})}function Qm(t){const{value:s,onSave:o,validate:r,fieldId:c,activeFieldId:d,onActivate:u,enterToSave:p=!0,trimOnSave:m=!0}=t,[g,v]=y.useState(""),[b,x]=y.useState(""),S=y.useRef(!1),k=d===c,w=y.useCallback(P=>{v(P),x("")},[]),N=y.useCallback(()=>{x("")},[]),T=y.useCallback(()=>{S.current=!1,u==null||u(null),v(""),x("")},[u]),C=y.useCallback(()=>{const P=m?g.trim():g;if(r){const U=r(g);if(U){x(U);return}}const I=m?s.trim():s;if(P===I){T();return}o(P),T()},[g,s,m,r,o,T]),D=y.useCallback(()=>{S.current=!0,u==null||u(c),v(s),x("")},[c,s,u]),B=y.useCallback(P=>{if(S.current){S.current=!1;return}P.relatedTarget instanceof HTMLElement&&P.relatedTarget.dataset.editAction===c||C()},[c,C]),E=y.useCallback(P=>{P.key==="Escape"?T():P.key==="Enter"&&p&&C()},[T,p,C]),A=(()=>{if(!k)return!1;const P=m?s.trim():s;return(m?g.trim():g)!==P})();return y.useEffect(()=>{!k&&(g!==""||b!=="")&&(v(""),x(""))},[k,g,b]),{isEditing:k,draft:g,error:b,isDirty:A,startEdit:D,cancelEdit:T,save:C,setDraft:w,clearError:N,handleBlur:B,handleKeyDown:E,ignoreInitialBlurRef:S}}const g6="_editFieldWrapper_yuzty_1",v6="_editInput_yuzty_10",y6="_editTextarea_yuzty_42",b6="_editSelect_yuzty_78",x6="_editError_yuzty_111",_6="_editInputInvalid_yuzty_118",k6="_editHint_yuzty_123",S6="_unsavedDot_yuzty_132",T6="_metaValueClickable_yuzty_140",w6="_editButton_yuzty_159",j6="_metaPlaceholder_yuzty_175",N6="_worktreeToggle_yuzty_180",nt={editFieldWrapper:g6,editInput:v6,editTextarea:y6,editSelect:b6,editError:x6,editInputInvalid:_6,editHint:k6,unsavedDot:S6,metaValueClickable:T6,editButton:w6,metaPlaceholder:j6,worktreeToggle:N6};function ln(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="text",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,maxLength:b,ariaLabel:x,"data-testid":S}=t,k=y.useRef(null),w=Qm({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(w.isEditing){const T=window.setTimeout(()=>{var C;(C=k.current)==null||C.focus()},0);return()=>window.clearTimeout(T)}},[w.isEditing]),c==="create"){const T=D=>{m==null||m(D.target.value)},C=r==null?void 0:r(s);return i.jsxs("div",{className:nt.editFieldWrapper,children:[i.jsx("input",{className:`${nt.editInput} ${C?nt.editInputInvalid:""}`,value:s,onChange:T,maxLength:b,placeholder:v,"aria-label":x,"data-testid":S?`${S}-input`:void 0}),C&&i.jsx("span",{className:nt.editError,"data-testid":"edit-error",children:C})]})}if(w.isEditing)return i.jsxs("div",{className:nt.editFieldWrapper,children:[i.jsx("input",{ref:k,className:`${nt.editInput} ${w.error?nt.editInputInvalid:""}`,value:w.draft,onChange:T=>w.setDraft(T.target.value),onBlur:w.handleBlur,onKeyDown:w.handleKeyDown,maxLength:b,placeholder:v,"aria-label":x,"data-testid":S?`${S}-input`:void 0}),w.isDirty&&i.jsx("span",{className:nt.unsavedDot,title:"Unsaved changes"}),w.error&&i.jsx("span",{className:nt.editError,"data-testid":"edit-error",children:w.error}),i.jsx("span",{className:nt.editHint,children:"Enter to save · Esc to cancel"})]});const N=g==null?void 0:g(s);return i.jsxs("span",{role:"button",tabIndex:0,className:nt.metaValueClickable,onClick:()=>w.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),w.startEdit())},title:"Click to edit","aria-label":x,"data-testid":S?`${S}-button`:void 0,children:[N!==void 0?N:s?i.jsx("span",{children:s}):i.jsx("span",{className:nt.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:nt.editButton,"aria-hidden":"true",children:"✏️"})]})}function Xp(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="textarea",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":x}=t,S=y.useRef(null),k=Qm({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(k.isEditing){const N=window.setTimeout(()=>{var T;(T=S.current)==null||T.focus()},0);return()=>window.clearTimeout(N)}},[k.isEditing]),c==="create"){const N=C=>{m==null||m(C.target.value)},T=r==null?void 0:r(s);return i.jsxs("div",{className:nt.editFieldWrapper,children:[i.jsx("textarea",{className:`${nt.editTextarea} ${T?nt.editInputInvalid:""}`,value:s,onChange:N,placeholder:v,"aria-label":b,"data-testid":x?`${x}-input`:void 0}),T&&i.jsx("span",{className:nt.editError,"data-testid":"edit-error",children:T})]})}if(k.isEditing)return i.jsxs("div",{className:nt.editFieldWrapper,children:[i.jsx("textarea",{ref:S,className:`${nt.editTextarea} ${k.error?nt.editInputInvalid:""}`,value:k.draft,onChange:N=>k.setDraft(N.target.value),onBlur:k.handleBlur,onKeyDown:k.handleKeyDown,title:b,"aria-label":b,"data-testid":x?`${x}-input`:void 0}),k.isDirty&&i.jsx("span",{className:nt.unsavedDot,title:"Unsaved changes"}),k.error&&i.jsx("span",{className:nt.editError,"data-testid":"edit-error",children:k.error}),i.jsx("span",{className:nt.editHint,children:"Tab to save · Esc to cancel"})]});const w=g==null?void 0:g(s);return i.jsxs("span",{role:"button",tabIndex:0,className:nt.metaValueClickable,onClick:()=>k.startEdit(),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),k.startEdit())},title:"Click to edit","aria-label":b,"data-testid":x?`${x}-button`:void 0,children:[w!==void 0?w:s?i.jsx("span",{children:s}):i.jsx("span",{className:nt.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:nt.editButton,"aria-hidden":"true",children:"✏️"})]})}function ud(t){var D;const{value:s,onSave:o,mode:r="edit",options:c,fieldId:d="select",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":x}=t,S=y.useRef(null),k=Qm({value:s,onSave:o,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(k.isEditing){const B=window.setTimeout(()=>{var E;(E=S.current)==null||E.focus()},0);return()=>window.clearTimeout(B)}},[k.isEditing]);const w=y.useCallback(B=>{const E=B.target.value;k.ignoreInitialBlurRef.current=!1,E!==s&&o(E),k.cancelEdit()},[s,o,k]),N=y.useCallback(B=>{if(k.ignoreInitialBlurRef.current){k.ignoreInitialBlurRef.current=!1;return}B.relatedTarget instanceof HTMLElement&&B.relatedTarget.dataset.editAction===d||k.cancelEdit()},[d,k]);if(r==="create")return i.jsx("select",{className:nt.editSelect,value:s,onChange:B=>m==null?void 0:m(B.target.value),"aria-label":b,"data-testid":x?`${x}-select`:void 0,children:c.map(B=>i.jsx("option",{value:B.value,children:B.label},B.value))});if(k.isEditing)return i.jsx("select",{ref:S,className:nt.editSelect,value:k.draft,onChange:w,onBlur:N,title:b,"aria-label":b,"data-testid":x?`${x}-select`:void 0,children:c.map(B=>i.jsx("option",{value:B.value,children:B.label},B.value))});const T=g==null?void 0:g(s),C=(D=c.find(B=>B.value===s))==null?void 0:D.label;return i.jsxs("button",{type:"button",className:nt.metaValueClickable,onClick:()=>k.startEdit(),title:"Click to change","aria-label":b,"data-testid":x?`${x}-button`:void 0,children:[T!==void 0?T:C?i.jsx("span",{children:C}):i.jsx("span",{className:nt.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:nt.editButton,"aria-hidden":"true",children:"✏️"})]})}function C6(t){const{checked:s,onChange:o,label:r,ariaLabel:c,"data-testid":d}=t;return i.jsxs("label",{className:nt.worktreeToggle,"data-testid":d,children:[i.jsx("input",{type:"checkbox",checked:s,onChange:u=>o(u.target.checked),"aria-label":c}),i.jsx("span",{children:r})]})}const E6="_envRow_1e1r5_1",A6="_envDot_1e1r5_7",D6="_envDotGreen_1e1r5_14",R6="_envDotYellow_1e1r5_18",M6="_envDotRed_1e1r5_22",I6="_envDotGray_1e1r5_26",Ao={envRow:E6,envDot:A6,envDotGreen:D6,envDotYellow:R6,envDotRed:M6,envDotGray:I6};function O6(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?Ao.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?Ao.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?Ao.envDotRed:Ao.envDotGray}function B6(t){const{value:s,onSave:o,environments:r,allowNone:c=!1,fieldId:d="environment",activeFieldId:u,onActivate:p,placeholder:m="No environment",ariaLabel:g="Environment","data-testid":v}=t,b=r.find(k=>k.id===s),x=[...c?[{value:"",label:"None"}]:[],...r.map(k=>({value:k.id,label:k.displayName}))],S=()=>{if(b)return i.jsxs("span",{className:Ao.envRow,children:[i.jsx("span",{className:`${Ao.envDot} ${O6(b.status)}`}),b.displayName]})};return i.jsx(ud,{value:s,onSave:o,options:x,fieldId:d,activeFieldId:u,onActivate:p,renderDisplay:S,placeholder:m,ariaLabel:g,"data-testid":v})}const L6="_nav_1snmp_1",z6="_searchForm_1snmp_8",$6="_searchInput_1snmp_15",U6="_searchButton_1snmp_33",P6="_clearButton_1snmp_68",H6="_workspaceSelect_1snmp_85",V6="_listHeader_1snmp_99",q6="_nodeList_1snmp_108",G6="_nodeItem_1snmp_116",F6="_indicator_1snmp_129",Z6="_label_1snmp_136",K6="_badge_1snmp_145",Yn={nav:L6,searchForm:z6,searchInput:$6,searchButton:U6,clearButton:P6,workspaceSelect:H6,listHeader:V6,nodeList:q6,nodeItem:G6,indicator:F6,label:Z6,badge:K6};function Y6({nodes:t,workspaces:s,loading:o,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=y.useState(""),v=y.useCallback(k=>{k.preventDefault(),m.trim()&&c(m.trim())},[m,c]),b=y.useCallback(()=>{g(""),d()},[d]),x=y.useCallback(k=>{u(k)},[u]),S=y.useCallback(k=>{g(""),p(k)},[p]);return i.jsxs("div",{className:Yn.nav,"data-testid":"knowledge-nav",children:[i.jsxs("form",{className:Yn.searchForm,onSubmit:v,children:[i.jsx("input",{className:Yn.searchInput,type:"text",placeholder:"Search...",value:m,onChange:k=>{g(k.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),i.jsx("button",{type:"submit",className:Yn.searchButton,disabled:o,children:"Go"})]}),r&&i.jsx("button",{type:"button",className:Yn.clearButton,onClick:b,children:"Clear search"}),i.jsxs("select",{className:Yn.workspaceSelect,onChange:k=>{S(k.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[i.jsx("option",{value:"",children:"All workspaces"}),s.map(k=>i.jsx("option",{value:k.id,children:k.name},k.id))]}),i.jsxs("div",{className:Yn.listHeader,children:["Nodes (",t.length,")"]}),i.jsx("ul",{className:Yn.nodeList,children:t.map(k=>i.jsxs("li",{className:Yn.nodeItem,onClick:()=>{x(k.id)},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),x(k.id))},role:"button",tabIndex:0,children:[i.jsx("span",{className:Yn.indicator,style:{backgroundColor:k.kind==="reference"?"#4A9EFF":k.category==="decision"?"#22C55E":k.category==="concept"?"#A855F7":k.category==="snippet"?"#6B7280":"#EAB308"}}),i.jsx("span",{className:Yn.label,children:k.label}),i.jsx("span",{className:Yn.badge,children:k.kind==="reference"?k.sourceType:k.category})]},k.id))})]})}const J6="_container_1mq5u_1",W6="_hamburger_1mq5u_33",X6="_brand_1mq5u_49",Q6="_brandLogo_1mq5u_68",e5="_info_1mq5u_75",t5="_connectionLabel_1mq5u_90",n5="_connectionDot_1mq5u_103",s5="_connected_1mq5u_106",a5="_disconnected_1mq5u_110",Zs={container:J6,hamburger:W6,brand:X6,brandLogo:Q6,info:e5,connectionLabel:t5,connectionDot:n5,connected:s5,disconnected:a5};function i5({connected:t,environments:s,sessions:o,onToggleSidebar:r,sidebarOpen:c}){const d=kt(),u=s.length,p=s.filter(g=>g.status==="connected").length,m=o.filter(g=>["running","idle"].includes(g.status)).length;return i.jsxs("div",{className:Zs.container,children:[r&&i.jsx("button",{type:"button",className:Zs.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:i.jsx(z2,{size:zt,"aria-hidden":"true"})}),i.jsx(Lo,{text:"Home",placement:"bottom",children:i.jsxs("button",{type:"button",className:Zs.brand,onClick:()=>d(Ni),"data-testid":"statusbar-brand",children:[i.jsx("img",{src:"/icon-192x192.png",alt:"",className:Zs.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),i.jsxs("div",{className:Zs.info,children:[i.jsxs("span",{"aria-label":t?"Connected":"Disconnected",children:[i.jsx("span",{className:`${Zs.connectionDot} ${t?Zs.connected:Zs.disconnected}`,"aria-hidden":"true",children:i.jsx(La,{size:rm,fill:"currentColor"})})," ",i.jsx("span",{className:Zs.connectionLabel,"aria-hidden":"true",children:t?"Connected":"Disconnected"})]}),i.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),i.jsxs("span",{children:[m," active"]})]})]})}const o5="_nav_13gkc_1",r5="_tab_13gkc_35",l5="_tabIcon_13gkc_68",c5="_tabLabel_13gkc_79",d5="_tabActive_13gkc_84",zr={nav:o5,tab:r5,tabIcon:l5,tabLabel:c5,tabActive:d5},Jc=[{view:"dashboard",label:"Dashboard",icon:i.jsx(w2,{size:zt}),route:Ni,testId:"sidebar-tab-dashboard"},{view:"chat",label:"Chat",icon:i.jsx(U2,{size:zt}),route:lN,testId:"sidebar-tab-chat"},{view:"tasks",label:"Tasks",icon:i.jsx(f2,{size:zt}),route:cN,testId:"sidebar-tab-tasks"},{view:"environments",label:"Environments",icon:i.jsx(H2,{size:zt}),route:Ro,testId:"sidebar-tab-environments"},{view:"knowledge",label:"Knowledge",icon:i.jsx(o2,{size:zt}),route:$x,testId:"sidebar-tab-knowledge"},{view:"findings",label:"Findings",icon:i.jsx(vx,{size:zt}),route:_d,testId:"sidebar-tab-findings"},{view:"settings",label:"Settings",icon:i.jsx(W2,{size:zt}),route:aN,testId:"sidebar-tab-settings"}];function u5(t){return t===Ni||t==="/"?"dashboard":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith($x)?"knowledge":t.startsWith(_d)?"findings":t.startsWith(Do)?"settings":"tasks"}function f5({tabs:t=Jc}){const s=Zt(),o=kt(),r=y.useRef(null),c=u5(s.pathname),d=y.useCallback(p=>{o(p.route)},[o]),u=y.useCallback(p=>{var x,S;const m=(x=r.current)==null?void 0:x.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(k=>k===document.activeElement),v=g>=0?g:t.findIndex(k=>k.view===c);let b=v;if(p.key==="ArrowRight"||p.key==="j"||p.key==="J")p.preventDefault(),b=(v+1)%t.length;else if(p.key==="ArrowLeft"||p.key==="k"||p.key==="K")p.preventDefault(),b=(v-1+t.length)%t.length;else if(p.key==="Home")p.preventDefault(),b=0;else if(p.key==="End")p.preventDefault(),b=t.length-1;else return;o(t[b].route),(S=m[b])==null||S.focus()},[c,o,t]);return i.jsx("nav",{className:zr.nav,ref:r,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:u,"data-testid":"sidebar-nav",children:t.map(p=>{const m=p.view===c;return i.jsx(Lo,{text:p.label,placement:"bottom",children:i.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${zr.tab} ${m?zr.tabActive:""}`,onClick:()=>d(p),"data-testid":p.testId,"aria-label":p.label,children:[i.jsx("span",{className:zr.tabIcon,"aria-hidden":"true",children:p.icon}),i.jsx("span",{className:zr.tabLabel,children:p.label})]})},p.view)})})}const p5="_container_pi6ii_1",m5="_content_pi6ii_66",Pb={container:p5,content:m5},h5=320,x1=220,_1=600,k1="grackle-sidebar-width";function g5(){try{const t=localStorage.getItem(k1);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=x1&&s<=_1)return s}}catch{}return h5}function v5(t){try{localStorage.setItem(k1,String(t))}catch{}}function y5({content:t}){const[s]=y.useState(g5),o=y.useRef(null);if(y.useEffect(()=>{const r=o.current;if(!r)return;const c=new ResizeObserver(d=>{for(const u of d){const p=u.borderBoxSize[0];if(p){const m=Math.round(p.inlineSize);m>=x1&&m<=_1&&v5(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return i.jsx("div",{className:Pb.container,ref:o,"data-testid":"sidebar",style:{width:s},children:i.jsx("div",{className:Pb.content,children:t})})}const b5="_bar_tnfsh_1",x5="_btnPrimary_tnfsh_32",_5="_statusText_tnfsh_85",k5="_statusCompleted_tnfsh_90",S5="_statusFailed_tnfsh_94",T5="_statusBlocked_tnfsh_98",w5="_hintText_tnfsh_103",wt={bar:b5,btnPrimary:x5,statusText:_5,statusCompleted:k5,statusFailed:S5,statusBlocked:T5,hintText:w5};function j5({sessions:t,tasks:s,environments:o}){const r=kt(),c=Zt(),d=At("/sessions/:sessionId"),u=At("/tasks/:taskId"),p=At("/tasks/:taskId/stream"),m=At("/tasks/:taskId/findings"),g=At("/tasks/:taskId/edit"),v=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),b=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),x=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings"),S=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),k=At("/sessions/new"),w=At("/environments/:environmentId/workspaces/:workspaceId"),N=At("/tasks/new"),T=At("/chat"),C=At("/"),D=At("/settings/*"),B=d==null?void 0:d.params.sessionId,E=(u==null?void 0:u.params.taskId)??(p==null?void 0:p.params.taskId)??(m==null?void 0:m.params.taskId)??(v==null?void 0:v.params.taskId)??(b==null?void 0:b.params.taskId)??(x==null?void 0:x.params.taskId)??(S==null?void 0:S.params.taskId),A=v??b??x??S,P=(A==null?void 0:A.params.environmentId)??(w==null?void 0:w.params.environmentId),I=c.pathname.startsWith("/environments")&&!w&&!A,U=!!T,Q=!!k,$=!!w&&!v&&!b&&!x&&!S,W=!!N;if(!!C&&!Q&&!$&&!W||!!D||(!!g||!!S)||W||I||Q)return i.jsx(i.Fragment,{});if(U)return o.find(Z=>Z.adapterType==="local"&&Z.status==="connected")?i.jsx(i.Fragment,{}):i.jsx("div",{className:wt.bar,children:i.jsx("span",{className:wt.hintText,children:"Add a local environment to start chatting"})});if($)return i.jsx("div",{className:wt.bar,children:i.jsx("span",{className:wt.hintText,children:"Select a task or click + to create one"})});if(E){const L=s.find(ce=>ce.id===E);if(!L)return i.jsx("div",{className:wt.bar,children:i.jsx("span",{className:wt.hintText,children:"Loading..."})});const Z=new Map(s.map(ce=>[ce.id,ce])),J=L.dependsOn.some(ce=>{const X=Z.get(ce);return X!==void 0&&X.status!=="complete"});if(L.status==="not_started"){const ce=J?L.dependsOn.map(X=>Z.get(X)).filter(X=>X&&X.status!=="complete").map(X=>X.title):[];return i.jsx("div",{className:wt.bar,children:J?i.jsxs("span",{className:wt.statusBlocked,children:["Blocked by: ",ce.join(", ")]}):i.jsx("span",{className:wt.hintText,children:"Use the buttons above to start or manage this task"})})}if(L.status==="working"||L.status==="paused"){const ce=L.latestSessionId||void 0,X=ce?t.find(fe=>fe.id===ce):void 0;return X&&X.status!=="stopped"?i.jsx(i.Fragment,{}):i.jsx("div",{className:wt.bar,children:i.jsx("span",{className:wt.hintText,children:"Waiting for agent..."})})}if(L.status==="complete")return i.jsxs("div",{className:wt.bar,children:[i.jsx("span",{className:`${wt.statusText} ${wt.statusCompleted}`,children:"Task completed"}),i.jsx("button",{onClick:()=>r(Di(L.workspaceId,void 0,P)),className:wt.btnPrimary,children:"+ New Task"})]});if(L.status==="failed")return i.jsx("div",{className:wt.bar,children:i.jsx("span",{className:`${wt.statusText} ${wt.statusFailed}`,children:"Task failed"})})}if(B){const L=t.find(ce=>ce.id===B),Z=(L==null?void 0:L.status)==="stopped";if(L!==void 0&&!Z)return i.jsx(i.Fragment,{});if(Z)return i.jsxs("div",{className:wt.bar,children:[i.jsxs("span",{className:`${wt.statusText} ${wt.hintText}`,children:["Session ",L.endReason||L.status]}),i.jsx("button",{onClick:()=>r(Bx(L.environmentId)),className:wt.btnPrimary,children:"+ New Chat"})]})}return i.jsx("div",{className:wt.bar,children:i.jsx("span",{className:wt.hintText,children:"Loading..."})})}const N5="_nav_14i94_1",C5="_tab_14i94_24",E5="_tabActive_14i94_62",A5="_tabLabel_14i94_75",D5="_statusDot_14i94_81",R5="_pulse_14i94_87",M5="_addButton_14i94_99",I5="_empty_14i94_132",Aa={nav:N5,tab:C5,tabActive:E5,tabLabel:A5,statusDot:D5,pulse:R5,addButton:M5,empty:I5},O5={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function B5({environments:t}){const s=kt(),o=y.useRef(null),r=At("/environments/:environmentId"),c=At("/environments/:environmentId/edit"),d=At("/environments/:environmentId/workspaces/:workspaceId"),u=At("/environments/:environmentId/workspaces/:workspaceId/*"),p=(r==null?void 0:r.params.environmentId)??(c==null?void 0:c.params.environmentId)??(d==null?void 0:d.params.environmentId)??(u==null?void 0:u.params.environmentId),m=p==="new"?void 0:p,g=y.useCallback(x=>{s(ji(x))},[s]),v=y.useCallback(x=>{var T;const S=(T=o.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const k=Array.from(S).findIndex(C=>C===document.activeElement),w=k>=0?k:t.findIndex(C=>C.id===m);let N=w;if(x.key==="ArrowDown"||x.key==="j"||x.key==="J")x.preventDefault(),N=(w+1)%S.length;else if(x.key==="ArrowUp"||x.key==="k"||x.key==="K")x.preventDefault(),N=(w-1+S.length)%S.length;else if(x.key==="Home")x.preventDefault(),N=0;else if(x.key==="End")x.preventDefault(),N=S.length-1;else return;N<t.length&&s(ji(t[N].id)),S[N].focus()},[m,t,s]),b=m??(t.length>0?t[0].id:void 0);return i.jsxs("div",{className:Aa.nav,"data-testid":"environment-nav",children:[i.jsx("nav",{ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(x=>{const S=x.id===m,k=x.id===b,w=O5[x.status]||"var(--text-tertiary)",N=x.status==="connected";return i.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:k?0:-1,className:`${Aa.tab} ${S?Aa.tabActive:""}`,onClick:()=>g(x.id),"data-testid":"env-nav-item",children:[i.jsx("span",{className:`${Aa.statusDot} ${N?Aa.pulse:""}`,style:{color:w},"aria-hidden":"true",children:i.jsx(La,{size:rm,fill:"currentColor"})}),i.jsx("span",{className:Aa.tabLabel,title:x.displayName||x.id,children:x.displayName||x.id})]},x.id)})}),i.jsx("button",{type:"button",className:Aa.addButton,onClick:()=>s(nN),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&i.jsx("div",{className:Aa.empty,children:"No environments yet."})]})}function eh(t){const s=new Date(t),o=new Date,r=o.getTime()-s.getTime(),c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return"just now";if(d<60)return`${d}m ago`;if(u<24)return`${u}h ago`;if(p===1)return"yesterday";if(p<7)return`${p} days ago`;const m=s.getFullYear()===o.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}const Hb={architecture:{text:"var(--accent-blue)",bg:"var(--accent-blue-dim)"},api:{text:"var(--accent-green)",bg:"var(--accent-green-dim)"},bug:{text:"var(--accent-red)",bg:"var(--accent-red-dim)"},decision:{text:"var(--accent-yellow)",bg:"var(--accent-yellow-dim)"},dependency:{text:"var(--accent-purple)",bg:"var(--accent-purple-dim)"},pattern:{text:"var(--accent-cyan)",bg:"var(--accent-cyan-dim)"},general:{text:"var(--text-secondary)",bg:"var(--bg-elevated)"}};function fd(t){return Hb[t]||Hb.general}const L5="_nav_dlm8m_1",z5="_categoryPills_dlm8m_24",$5="_categoryPill_dlm8m_24",U5="_tab_dlm8m_42",P5="_tabActive_dlm8m_80",H5="_tabContent_dlm8m_93",V5="_tabLabel_dlm8m_100",q5="_tabMeta_dlm8m_106",G5="_categoryDot_dlm8m_111",F5="_empty_dlm8m_118",xs={nav:L5,categoryPills:z5,categoryPill:$5,tab:U5,tabActive:P5,tabContent:H5,tabLabel:V5,tabMeta:q5,categoryDot:G5,empty:F5};function Z5({findings:t,workspaceId:s,environmentId:o}){const r=kt(),c=y.useRef(null),d=At("/findings/:findingId"),u=At("/environments/:environmentId/workspaces/:workspaceId/findings/:findingId"),p=(d==null?void 0:d.params.findingId)??(u==null?void 0:u.params.findingId),m=y.useMemo(()=>{const x=new Set(t.map(S=>S.category).filter(Boolean));return Array.from(x).sort()},[t]),g=y.useCallback(x=>{r(Mp(x,s,o))},[r,s,o]),v=y.useCallback(x=>{var T;const S=(T=c.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const k=Array.from(S).findIndex(C=>C===document.activeElement),w=k>=0?k:t.findIndex(C=>C.id===p);let N=w;if(x.key==="ArrowDown"||x.key==="j"||x.key==="J")x.preventDefault(),N=(w+1)%S.length;else if(x.key==="ArrowUp"||x.key==="k"||x.key==="K")x.preventDefault(),N=(w-1+S.length)%S.length;else if(x.key==="Home")x.preventDefault(),N=0;else if(x.key==="End")x.preventDefault(),N=S.length-1;else return;N<t.length&&r(Mp(t[N].id,s,o)),S[N].focus()},[p,t,r,s,o]),b=p??(t.length>0?t[0].id:void 0);return i.jsxs("div",{className:xs.nav,"data-testid":"findings-nav",children:[m.length>1&&i.jsx("div",{className:xs.categoryPills,"data-testid":"findings-nav-categories",children:m.map(x=>i.jsx("span",{className:xs.categoryPill,style:{color:fd(x).text},children:x},x))}),i.jsx("nav",{ref:c,role:"tablist","aria-orientation":"vertical","aria-label":"Findings",onKeyDown:v,children:t.map(x=>{const S=x.id===p,k=x.id===b;return i.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:k?0:-1,className:`${xs.tab} ${S?xs.tabActive:""}`,onClick:()=>g(x.id),"data-testid":"finding-nav-item",children:[i.jsx("span",{className:xs.categoryDot,style:{color:fd(x.category).text},"aria-hidden":"true",children:i.jsx(La,{size:rm,fill:"currentColor"})}),i.jsxs("span",{className:xs.tabContent,children:[i.jsx("span",{className:xs.tabLabel,title:x.title,children:x.title}),i.jsx("span",{className:xs.tabMeta,title:x.createdAt,children:eh(x.createdAt)})]})]},x.id)})}),t.length===0&&i.jsx("div",{className:xs.empty,children:"No findings yet. Agents will post discoveries here."})]})}function K5(t){if(t.length===0)return[];const s=[...t].sort((r,c)=>r[0]-c[0]),o=[[s[0][0],s[0][1]]];for(let r=1;r<s.length;r++){const c=o[o.length-1],[d,u]=s[r];d<=c[1]+1?c[1]=Math.max(c[1],u):o.push([d,u])}return o}function S1({text:t,indices:s,highlightClass:o}){if(!s||s.length===0)return i.jsx(i.Fragment,{children:t});const r=K5(s),c=[];let d=0;for(const[u,p]of r)u>d&&c.push(i.jsx("span",{children:t.slice(d,u)},`p${d}`)),c.push(i.jsx("mark",{className:o,children:t.slice(u,p+1)},`m${u}`)),d=p+1;return d<t.length&&c.push(i.jsx("span",{children:t.slice(d)},`p${d}`)),i.jsx(i.Fragment,{children:c})}function Y5(t){const s=new Map(t.map(r=>[r.id,{...r,children:[]}])),o=[];for(const r of s.values())r.parentTaskId&&s.has(r.parentTaskId)?s.get(r.parentTaskId).children.push(r):o.push(r);for(const r of s.values())r.children.sort((c,d)=>c.sortOrder-d.sortOrder);return o.sort((r,c)=>r.sortOrder-c.sortOrder)}function J5(t,s){const o=new Map;for(const d of t){const p=d.dependsOn.length>0&&d.dependsOn.some(g=>s.get(g)!=="complete")?"blocked":d.status,m=o.get(p);m?m.push(d):o.set(p,[d])}const r=[],c=new Set;for(const d of ow){c.add(d);const u=o.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=za(d);r.push({status:d,label:p.label,style:p,tasks:u})}}for(const[d,u]of o)if(!c.has(d)&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=za(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const W5="_container_z4i38_1",X5="_header_z4i38_5",Q5="_headerActions_z4i38_17",eI="_searchInput_z4i38_23",tI="_searchHighlight_z4i38_56",nI="_groupToggle_z4i38_62",sI="_groupToggleActive_z4i38_89",aI="_addButton_z4i38_93",iI="_taskRow_z4i38_120",oI="_selected_z4i38_140",rI="_expandArrow_z4i38_150",lI="_expanded_z4i38_157",cI="_leafSpacer_z4i38_161",dI="_taskStatusIcon_z4i38_166",uI="_taskTitle_z4i38_170",fI="_workspaceBadge_z4i38_177",pI="_childCountBadge_z4i38_195",mI="_dependencyBadge_z4i38_208",hI="_blockedBadge_z4i38_220",gI="_addChildButton_z4i38_225",vI="_emptyState_z4i38_268",yI="_statusGroupHeader_z4i38_275",bI="_statusGroupIcon_z4i38_294",xI="_statusGroupLabel_z4i38_298",_I="_statusGroupCount_z4i38_303",Ge={container:W5,header:X5,headerActions:Q5,searchInput:eI,searchHighlight:tI,groupToggle:nI,groupToggleActive:sI,addButton:aI,taskRow:iI,selected:oI,expandArrow:rI,expanded:lI,leafSpacer:cI,taskStatusIcon:dI,taskTitle:uI,workspaceBadge:fI,childCountBadge:pI,dependencyBadge:mI,blockedBadge:hI,addChildButton:gI,emptyState:vI,statusGroupHeader:yI,statusGroupIcon:bI,statusGroupLabel:xI,statusGroupCount:_I},kI=[{name:"title",weight:2},{name:"description",weight:1}],T1=16,SI=16,w1="grackle-task-group-by-status";function Vb(){try{return localStorage.getItem(w1)==="true"}catch{return!1}}function TI(t){try{localStorage.setItem(w1,String(t))}catch{}}function wI({group:t,isExpanded:s,onToggle:o,selectedTaskId:r,navigate:c,titleHighlights:d,workspaceNames:u}){return i.jsxs("div",{"data-testid":`status-group-${t.status}`,children:[i.jsxs("div",{className:Ge.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:o,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),o())},children:[i.jsx("span",{className:`${Ge.expandArrow} ${s?Ge.expanded:""}`,"aria-hidden":"true",children:i.jsx(sa,{size:lt})}),i.jsx("span",{className:Ge.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),i.jsx("span",{className:Ge.statusGroupLabel,children:t.label}),i.jsx("span",{className:Ge.statusGroupCount,children:t.tasks.length})]}),i.jsx(us,{children:s&&i.jsx(Rt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},style:{overflow:"hidden"},children:t.tasks.map(p=>{const m=za(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return i.jsxs("div",{onClick:()=>c(On(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:b=>{b.currentTarget===b.target&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c(On(p.id)))},className:`${Ge.taskRow} ${g?Ge.selected:""}`,style:{"--task-indent":`${T1}px`},"data-task-id":p.id,children:[i.jsx("span",{className:Ge.leafSpacer}),i.jsx("span",{className:Ge.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${ll(p.status)}`,children:m.icon}),i.jsx("span",{className:Ge.taskTitle,title:p.title,children:i.jsx(S1,{text:p.title,indices:d.get(p.id),highlightClass:Ge.searchHighlight})}),v&&i.jsx("span",{className:Ge.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function j1({node:t,depth:s,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=za(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(T=>u.get(T)!=="complete"),b=o.has(t.id),x=t.children.length>0,S=c===t.id,k=T1+s*SI,N=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{onClick:()=>d(On(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:T=>{T.currentTarget===T.target&&(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),d(On(t.id)))},className:`${Ge.taskRow} ${S?Ge.selected:""}`,style:{"--task-indent":`${k}px`},"data-task-id":t.id,children:[x&&i.jsx("span",{className:`${Ge.expandArrow} ${b?Ge.expanded:""}`,role:"button",tabIndex:0,"aria-label":b?"Collapse task":"Expand task",onClick:T=>{T.stopPropagation(),r(t.id)},onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),T.stopPropagation(),r(t.id))},children:i.jsx(sa,{size:lt,"aria-hidden":"true"})}),!x&&i.jsx("span",{className:Ge.leafSpacer}),i.jsx("span",{className:Ge.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${ll(t.status)}`,children:g.icon}),i.jsx("span",{className:Ge.taskTitle,title:t.title,children:i.jsx(S1,{text:t.title,indices:p.get(t.id),highlightClass:Ge.searchHighlight})}),N&&i.jsx("span",{className:Ge.workspaceBadge,title:N,children:N}),x&&i.jsxs("span",{className:Ge.childCountBadge,children:[t.children.filter(T=>T.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&i.jsx("span",{className:`${Ge.dependencyBadge} ${v?Ge.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<vT&&i.jsx(Lo,{text:"Add child task",children:i.jsx("button",{onClick:T=>{T.stopPropagation(),d(Di(t.workspaceId,t.id))},"aria-label":"Add child task",className:Ge.addChildButton,children:"+"})})]}),i.jsx(us,{children:x&&b&&i.jsx(Rt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},style:{overflow:"hidden"},children:t.children.map(T=>i.jsx(j1,{node:T,depth:s+1,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},T.id))})})]})}function jI({workspaces:t,tasks:s}){const o=kt(),[r,c]=y.useState(new Set),[d,u]=y.useState(new Set),[p,m]=y.useState(Vb),[g,v]=y.useState(Vb),[b,x]=y.useState(new Map),S=At("/tasks/:taskId/*"),k=(S==null?void 0:S.params.taskId)!=="new"?S==null?void 0:S.params.taskId:void 0,w=y.useMemo(()=>new Map(s.map(H=>[H.id,H.status])),[s]),N=y.useMemo(()=>new Map(t.map(H=>[H.id,H.name])),[t]),T=()=>{const H=!p;TI(H),m(H),H&&(v(!0),x(new Map))},C=H=>{x(ie=>{const L=new Map(ie),Z=L.has(H)?L.get(H):g;return L.set(H,!Z),L})},D=H=>b.has(H)?b.get(H):g,B=H=>{c(ie=>{const L=new Set(ie);return L.has(H)?(L.delete(H),u(Z=>new Set(Z).add(H))):(L.add(H),u(Z=>{const J=new Set(Z);return J.delete(H),J})),L})};y.useEffect(()=>{const H=new Set(s.filter(ie=>ie.parentTaskId).map(ie=>ie.parentTaskId));H.size>0&&c(ie=>{const L=new Set(ie);for(const Z of H)d.has(Z)||L.add(Z);return L})},[s,d]);const[E,A]=y.useState(""),{directMatchTaskIds:P,treeMatchTaskIds:I,titleHighlights:U}=y.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const H=gT(s,E,kI),ie=new Set(H.map(ce=>ce.item.id)),L=new Map;for(const ce of H){const X=ce.matches.find(ge=>ge.key==="title");X&&L.set(ce.item.id,X.indices)}const Z=new Set(ie),J=new Map(s.map(ce=>[ce.id,ce]));for(const ce of[...ie]){let X=J.get(ce);for(;X!=null&&X.parentTaskId;)Z.add(X.parentTaskId),X=J.get(X.parentTaskId)}return{directMatchTaskIds:ie,treeMatchTaskIds:Z,titleHighlights:L}},[E,s]),Q=P!==null,$=Q?p?P:I:null,W=$?s.filter(H=>$.has(H.id)):s,pe=p?[]:Y5(W);return i.jsxs("div",{className:Ge.container,children:[i.jsxs("div",{className:Ge.header,children:[i.jsx("span",{children:"Tasks"}),i.jsxs("div",{className:Ge.headerActions,children:[i.jsx(Lo,{text:p?"Switch to tree view":"Group tasks by status",children:i.jsx("button",{className:`${Ge.groupToggle} ${p?Ge.groupToggleActive:""}`,onClick:T,"aria-label":p?"Switch to tree view":"Group tasks by status","aria-pressed":p,"data-testid":"task-group-by-status-toggle",children:i.jsx(I2,{size:tn})})}),i.jsx(Lo,{text:"New task",children:i.jsx("button",{className:Ge.addButton,onClick:()=>o(Di()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&i.jsx("input",{type:"text",value:E,onChange:H=>A(H.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:Ge.searchInput,"data-testid":"sidebar-search"}),p?J5(W,w).map(H=>i.jsx(wI,{group:H,isExpanded:D(H.status),onToggle:()=>C(H.status),selectedTaskId:k,navigate:o,titleHighlights:U,workspaceNames:N},H.status)):pe.map(H=>i.jsx(j1,{node:H,depth:0,expandedTasks:r,toggleTask:B,selectedTaskId:k,navigate:o,taskStatusById:w,titleHighlights:U,workspaceNames:N},H.id)),W.length===0&&!Q&&i.jsx("div",{className:Ge.emptyState,children:"No tasks yet. Click + to create one."}),W.length===0&&Q&&i.jsx("div",{className:Ge.emptyState,children:"No matching tasks"})]})}const NI="_toast_ed2dk_1",CI="_success_ed2dk_18",EI="_icon_ed2dk_22",AI="_error_ed2dk_25",DI="_warning_ed2dk_32",RI="_info_ed2dk_38",MI="_message_ed2dk_53",II="_close_ed2dk_60",$r={toast:NI,success:CI,icon:EI,error:AI,warning:DI,info:RI,message:MI,close:II},OI={success:i.jsx(Ei,{size:zt}),error:i.jsx(Ha,{size:zt}),warning:i.jsx(om,{size:zt}),info:i.jsx(im,{size:zt})};function BI({toast:t,onDismiss:s}){return y.useEffect(()=>{const o=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(o)},[t.id,t.duration,s]),i.jsxs(Rt.div,{className:`${$r.toast} ${$r[t.variant]}`,role:"status",initial:{opacity:0,y:-16,scale:.94},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.94},transition:{duration:.2,ease:"easeOut"},layout:!0,children:[i.jsx("span",{className:$r.icon,"aria-hidden":"true",children:OI[t.variant]}),i.jsx("span",{className:$r.message,children:t.message}),i.jsx("button",{type:"button",className:$r.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:i.jsx(Ha,{size:tn,"aria-hidden":"true"})})]})}const LI="_container_qqse2_1",zI={container:LI};function $I({toasts:t,onDismiss:s}){return i.jsx("div",{className:zI.container,"data-testid":"toast-container",children:i.jsx(us,{children:t.map(o=>i.jsx(BI,{toast:o,onDismiss:s},o.id))})})}const UI="_callout_e5awm_1",PI="_success_e5awm_11",HI="_icon_e5awm_15",VI="_error_e5awm_18",qI="_warning_e5awm_25",GI="_info_e5awm_32",FI="_content_e5awm_48",ZI="_close_e5awm_53",Ur={callout:UI,success:PI,icon:HI,error:VI,warning:qI,info:GI,content:FI,close:ZI},KI={success:i.jsx(Ei,{size:zt}),error:i.jsx(Ha,{size:zt}),warning:i.jsx(om,{size:zt}),info:i.jsx(im,{size:zt})};function YI({variant:t="info",children:s,dismissible:o=!1,className:r}){const[c,d]=y.useState(!1);return i.jsx(i.Fragment,{children:!c&&i.jsxs("div",{className:[Ur.callout,Ur[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[i.jsx("span",{className:Ur.icon,"aria-hidden":"true",children:KI[t]}),i.jsx("span",{className:Ur.content,children:s}),o&&i.jsx("button",{type:"button",className:Ur.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:i.jsx(Ha,{size:tn,"aria-hidden":"true"})})]})})}function JI({currentVersion:t,latestVersion:s,updateAvailable:o,isDocker:r}){if(!o)return i.jsx(i.Fragment,{});const c=r?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return i.jsx("div",{"data-testid":"update-banner",children:i.jsxs(YI,{variant:"info",dismissible:!0,children:[i.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",t,")."," ","Run: ",i.jsx("code",{children:c})]})})}const WI="_container_de44x_1",XI="_emptyState_de44x_8",QI="_card_de44x_14",eO="_cardClickable_de44x_34",tO="_cardHeader_de44x_42",nO="_categoryBadge_de44x_54",sO="_findingTitle_de44x_62",aO="_findingDate_de44x_68",iO="_findingContent_de44x_80",oO="_tags_de44x_86",rO="_tag_de44x_86",rs={container:WI,emptyState:XI,card:QI,cardClickable:eO,cardHeader:tO,categoryBadge:nO,findingTitle:sO,findingDate:aO,findingContent:iO,tags:oO,tag:rO};function N1({findings:t,onFindingClick:s}){return t.length===0?i.jsx("div",{className:rs.emptyState,children:"No findings yet. Agents will post discoveries here."}):i.jsx("div",{className:rs.container,children:t.map((o,r)=>{const c=fd(o.category),d=s?Rt.button:Rt.div;return i.jsxs(d,{type:s?"button":void 0,className:`${rs.card} ${s?rs.cardClickable:""}`,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:r*.05,duration:.2},onClick:s?()=>{s(o.id)}:void 0,children:[i.jsxs("div",{className:rs.cardHeader,children:[i.jsx("span",{className:rs.categoryBadge,style:{background:c.bg,color:c.text},children:o.category}),i.jsx("span",{className:rs.findingTitle,children:o.title}),i.jsx("span",{className:rs.findingDate,title:o.createdAt,children:eh(o.createdAt)})]}),i.jsx("div",{className:rs.findingContent,children:o.content.length>300?o.content.slice(0,300)+"...":o.content}),o.tags.length>0&&i.jsx("div",{className:rs.tags,children:o.tags.map(u=>i.jsx("span",{className:rs.tag,style:{color:c.text,textShadow:`0 0 8px ${c.text}`},children:u},u))})]},o.id)})})}const lO="_section_1ingb_14",cO="_sectionTitle_1ingb_26",dO="_sectionDescription_1ingb_35",uO="_tokenList_1ingb_48",fO="_tokenRow_1ingb_55",pO="_tokenBadge_1ingb_68",mO="_tokenName_1ingb_83",hO="_tokenTarget_1ingb_90",gO="_deleteButton_1ingb_99",vO="_addForm_1ingb_113",yO="_formRow_1ingb_119",bO="_input_1ingb_125",xO="_select_1ingb_155",_O="_addButton_1ingb_187",kO="_emptyStateInfo_1ingb_221",SO="_themeOptions_1ingb_229",TO="_themeOption_1ingb_229",wO="_themeOptionSelected_1ingb_254",jO="_themeOptionHeader_1ingb_259",NO="_themeOptionLabel_1ingb_266",CO="_themeOptionDesc_1ingb_273",EO="_variantToggle_1ingb_279",AO="_variantButton_1ingb_286",DO="_variantActive_1ingb_305",RO="_themeSwatches_1ingb_311",MO="_themeSwatch_1ingb_311",IO="_systemToggle_1ingb_325",OO="_systemToggleHint_1ingb_341",BO="_themeActive_1ingb_348",LO="_aboutGrid_1ingb_354",zO="_aboutItem_1ingb_360",$O="_aboutLabel_1ingb_373",UO="_aboutValue_1ingb_379",PO="_aboutDot_1ingb_387",HO="_aboutDotConnected_1ingb_394",VO="_aboutDotDisconnected_1ingb_398",be={section:lO,sectionTitle:cO,sectionDescription:dO,tokenList:uO,tokenRow:fO,tokenBadge:pO,tokenName:mO,tokenTarget:hO,deleteButton:gO,addForm:vO,formRow:yO,input:bO,select:xO,addButton:_O,emptyStateInfo:kO,themeOptions:SO,themeOption:TO,themeOptionSelected:wO,themeOptionHeader:jO,themeOptionLabel:NO,themeOptionDesc:CO,variantToggle:EO,variantButton:AO,variantActive:DO,themeSwatches:RO,themeSwatch:MO,systemToggle:IO,systemToggleHint:OO,themeActive:BO,aboutGrid:LO,aboutItem:zO,aboutLabel:$O,aboutValue:UO,aboutDot:PO,aboutDotConnected:HO,aboutDotDisconnected:VO},qO=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function GO({tokens:t,onSetToken:s,onDeleteToken:o,onShowToast:r}){const[c,d]=y.useState(""),[u,p]=y.useState(""),[m,g]=y.useState("env_var"),[v,b]=y.useState(""),[x,S]=y.useState(null),k=T=>{if(T.preventDefault(),!c||!u)return;const C=m==="env_var"?v||c.toUpperCase()+"_TOKEN":"";s(c,u,m,C,m==="file"?v:""),r==null||r("Token saved successfully","success"),d(""),p(""),b("")},w=T=>{S(T)},N=()=>{x&&(o(x),r==null||r("Token deleted","info")),S(null)};return i.jsxs(i.Fragment,{children:[i.jsx(Ci,{isOpen:x!==null,title:"Delete Token?",description:x?`"${x}" will be permanently removed.`:void 0,onConfirm:N,onCancel:()=>S(null)}),i.jsxs("section",{className:be.section,children:[i.jsx("h3",{className:be.sectionTitle,children:"Tokens"}),i.jsx("p",{className:be.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?i.jsx("div",{className:be.emptyStateInfo,children:"Add your first API token to enable service integrations."}):i.jsx("div",{className:be.tokenList,children:t.map(T=>i.jsxs("div",{className:be.tokenRow,children:[i.jsx("span",{className:be.tokenBadge,children:T.tokenType}),i.jsx("span",{className:be.tokenName,children:T.name}),i.jsx("span",{className:be.tokenTarget,children:T.tokenType==="env_var"?T.envVar:T.filePath}),i.jsx("button",{className:be.deleteButton,onClick:()=>w(T.name),title:`Delete ${T.name}`,"aria-label":`Delete ${T.name}`,children:i.jsx(Ha,{size:tn,"aria-hidden":"true"})})]},T.name))}),i.jsxs("form",{className:be.addForm,onSubmit:k,children:[i.jsxs("div",{className:be.formRow,children:[i.jsx("input",{className:be.input,type:"text",placeholder:"Token name",value:c,onChange:T=>d(T.target.value)}),i.jsx("input",{className:be.input,type:"password",placeholder:"Value",value:u,onChange:T=>p(T.target.value)})]}),i.jsxs("div",{className:be.formRow,children:[i.jsx("select",{className:be.select,value:m,onChange:T=>g(T.target.value),children:qO.map(T=>i.jsx("option",{value:T.value,children:T.label},T.value))}),i.jsx("input",{className:be.input,type:"text",placeholder:m==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:v,onChange:T=>b(T.target.value)}),i.jsx("button",{className:be.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const Cd=[{id:"grackle",label:"Grackle",description:"The default Grackle theme — iridescent purple on clean dark.",swatches:["#0e1218","#8b5cf6","#60a5fa","#e5e7eb","#34d399"],variantLightId:"grackle-light",variantDarkId:"grackle-dark"},{id:"grackle-light",label:"Grackle Light",description:"Light Grackle variant.",hidden:!0},{id:"grackle-dark",label:"Grackle Dark",description:"Dark Grackle variant.",hidden:!0},{id:"glass",label:"Glassmorphism",description:"Dark frosted-glass aesthetic with backdrop blur effects.",swatches:["#0a0c14","#4ecca3","#70a1ff","#e2e8f0","#a855f7"]},{id:"matrix",label:"Matrix",description:"Phosphor-green CRT terminal with scanlines and glow.",swatches:["#050505","#00ff41","#00bfff","#33ff77","#ffb000"]},{id:"brutalist",label:"Neubrutalism",description:"Thick borders, raw colors, bold type — ugly on purpose.",swatches:["#f5f0e8","#ff5757","#5ce1e6","#1a1a1a","#ffde59"],variantLightId:"brutalist-light",variantDarkId:"brutalist-dark"},{id:"brutalist-light",label:"Neubrutalism Light",description:"Light neubrutalism variant.",hidden:!0},{id:"brutalist-dark",label:"Neubrutalism Dark",description:"Dark neubrutalism variant.",hidden:!0},{id:"monokai",label:"Monokai",description:"Classic warm editor palette — pink, green, and purple.",swatches:["#272822","#f92672","#a6e22e","#f8f8f2","#ae81ff"],variantLightId:"monokai-light",variantDarkId:"monokai-dark"},{id:"monokai-dark",label:"Monokai Dark",description:"Dark Monokai variant.",hidden:!0},{id:"monokai-light",label:"Monokai Light",description:"Light Monokai variant.",hidden:!0},{id:"ubuntu",label:"Ubuntu",description:"Aubergine terminal with the GNOME Tango palette.",swatches:["#300a24","#8ae234","#ef2929","#eeeeec","#fce94f"]},{id:"sandstone",label:"Sandstone",description:"Warm terracotta accent on dark brown, in the style of Claude Code.",swatches:["#1a1815","#C15F3C","#6b8afd","#e8e6e3","#a78bfa"]},{id:"verdigris",label:"Verdigris",description:"Teal accent on charcoal, in the style of ChatGPT.",swatches:["#141414","#00a67e","#3b82f6","#ececec","#ab68ff"]},{id:"primer",label:"Primer",description:"Blue accent on ink-dark grey, in the style of GitHub.",swatches:["#0d1117","#58a6ff","#3fb950","#c9d1d9","#bc8cff"]}],C1=new Set(Cd.map(t=>t.id)),qb="grackle";function Qp(t){return Cd.find(s=>s.id===t)}function FO({themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c}){return i.jsxs("section",{className:be.section,children:[i.jsx("h3",{className:be.sectionTitle,children:"Appearance"}),i.jsx("p",{className:be.sectionDescription,children:"Choose how Grackle looks across the app."}),i.jsx("div",{className:be.themeOptions,children:Cd.filter(d=>!d.hidden).map(d=>{const u=!!(d.variantLightId&&d.variantDarkId),p=u?t===d.id||t===d.variantLightId||t===d.variantDarkId:t===d.id,m=u&&s===d.variantLightId;return i.jsxs("button",{type:"button",className:`${be.themeOption} ${p?be.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>o(d.id),children:[i.jsxs("span",{className:be.themeOptionHeader,children:[i.jsxs("span",{children:[i.jsx("span",{className:be.themeOptionLabel,children:d.label}),i.jsx("span",{className:be.themeOptionDesc,children:d.description})]}),u&&i.jsxs("span",{className:be.variantToggle,children:[i.jsx("span",{role:"button",tabIndex:0,className:`${be.variantButton} ${p&&m?be.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantLightId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantLightId))},"aria-label":"Light variant","aria-pressed":p&&m,children:"☼"}),i.jsx("span",{role:"button",tabIndex:0,className:`${be.variantButton} ${p&&!m?be.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantDarkId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantDarkId))},"aria-label":"Dark variant","aria-pressed":p&&!m,children:"☾"})]})]}),d.swatches&&i.jsx("span",{className:be.themeSwatches,children:d.swatches.map((g,v)=>i.jsx("span",{className:be.themeSwatch,style:{background:g}},v))})]},d.id)})}),i.jsxs("label",{className:be.systemToggle,children:[i.jsx("input",{type:"checkbox",checked:r,onChange:d=>c(d.target.checked)}),i.jsx("span",{children:"Match system light/dark preference"})]}),i.jsx("p",{className:be.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),i.jsxs("p",{className:be.themeActive,children:["Active theme: ",i.jsx("strong",{children:s})]})]})}function ZO({connected:t,environments:s,sessions:o}){const r=s.filter(u=>u.status==="connected").length,c=s.length,d=o.filter(u=>["running","idle"].includes(u.status)).length;return i.jsxs("section",{className:be.section,"data-testid":"about-panel",children:[i.jsx("h3",{className:be.sectionTitle,children:"About"}),i.jsx("p",{className:be.sectionDescription,children:"Connection status and application information."}),i.jsxs("div",{className:be.aboutGrid,children:[i.jsxs("div",{className:be.aboutItem,children:[i.jsx("span",{className:be.aboutLabel,children:"Connection"}),i.jsxs("span",{className:be.aboutValue,children:[i.jsx("span",{className:`${be.aboutDot} ${t?be.aboutDotConnected:be.aboutDotDisconnected}`}),t?"Connected":"Disconnected"]})]}),i.jsxs("div",{className:be.aboutItem,children:[i.jsx("span",{className:be.aboutLabel,children:"Environments"}),i.jsxs("span",{className:be.aboutValue,children:[r,"/",c," connected"]})]}),i.jsxs("div",{className:be.aboutItem,children:[i.jsx("span",{className:be.aboutLabel,children:"Active Sessions"}),i.jsx("span",{className:be.aboutValue,children:d})]}),i.jsxs("div",{className:be.aboutItem,children:[i.jsx("span",{className:be.aboutLabel,children:"Version"}),i.jsx("span",{className:be.aboutValue,children:"0.100.0"})]})]})]})}const KO="_container_cddyd_1",YO="_header_cddyd_8",JO="_headerTitle_cddyd_35",WO="_badge_cddyd_44",XO="_headerActions_cddyd_54",QO="_body_cddyd_61",eB="_formContent_cddyd_73",tB="_section_cddyd_85",nB="_label_cddyd_91",sB="_titleInput_cddyd_98",aB="_descriptionTextarea_cddyd_131",iB="_parentContext_cddyd_167",oB="_parentLabel_cddyd_175",rB="_parentName_cddyd_182",lB="_personaSelect_cddyd_186",cB="_depList_cddyd_220",dB="_depItem_cddyd_226",uB="_depItemSelected_cddyd_248",fB="_noDeps_cddyd_252",pB="_btnPrimary_cddyd_258",mB="_btnGhost_cddyd_289",tt={container:KO,header:YO,headerTitle:JO,badge:WO,headerActions:XO,body:QO,formContent:eB,section:tB,label:nB,titleInput:sB,descriptionTextarea:aB,parentContext:iB,parentLabel:oB,parentName:rB,personaSelect:lB,depList:cB,depItem:dB,depItemSelected:uB,noDeps:fB,btnPrimary:pB,btnGhost:mB};function E1({mode:t,taskId:s,workspaceId:o,parentTaskId:r,environmentId:c,tasks:d,workspaces:u,personas:p,onCreateTask:m,onUpdateTask:g,onEditDone:v,onShowToast:b}){const x=kt(),S=t==="edit",k=S&&s?d.find(ve=>ve.id===s):void 0,w=S?(k==null?void 0:k.workspaceId)??"":o??"",[N,T]=y.useState(w),C=w||N,D=u.find(ve=>ve.id===C),B=c??(D==null?void 0:D.environmentId),E=!S&&!o,A=S?(k==null?void 0:k.parentTaskId)??"":r??"",P=A?d.find(ve=>ve.id===A):void 0,[I,U]=y.useState((k==null?void 0:k.title)??""),[Q,$]=y.useState((k==null?void 0:k.description)??""),[W,pe]=y.useState((k==null?void 0:k.dependsOn)??[]),[H,ie]=y.useState((k==null?void 0:k.defaultPersonaId)??""),[L,Z]=y.useState((k==null?void 0:k.canDecompose)??!1),[J,ce]=y.useState(!1),X=y.useRef(!1);y.useEffect(()=>{S&&k&&!X.current&&(X.current=!0,U(k.title),$(k.description),pe(k.dependsOn),ie(k.defaultPersonaId),Z(k.canDecompose))},[S,k]);const ge=d.filter(ve=>ve.workspaceId===C&&(!S||ve.id!==s)&&ve.id!==A),fe=I.trim().length>0&&(!S||k!==void 0)&&C.length>0,Ce=ve=>{pe(Le=>Le.includes(ve)?Le.filter(Mt=>Mt!==ve):[...Le,ve])},Ze=()=>{!fe||J||S&&k===void 0||(S&&s?(g(s,I.trim(),Q,W,H),b==null||b("Task updated","success"),v?v():x(On(s,void 0,C,B),{replace:!0})):(ce(!0),m(C,I.trim(),Q,W.length>0?W:void 0,A||void 0,H,L,()=>{b==null||b("Task created","success"),x(o?$a(o,B):"/tasks",{replace:!0})},ve=>{b==null||b(ve,"error"),ce(!1)})))},me=()=>{if(v){v();return}x(S&&s?On(s,void 0,C,B):o?$a(o,B):"/tasks")},_e=S?"edit task":A?"child task":"new task";return i.jsxs("div",{className:tt.container,children:[i.jsxs("div",{className:tt.header,children:[i.jsxs("div",{className:tt.headerTitle,children:[i.jsx("span",{className:tt.badge,children:_e}),P&&i.jsxs("span",{className:tt.parentContext,children:[i.jsx("span",{className:tt.parentLabel,children:"Child of"}),i.jsx("span",{className:tt.parentName,children:P.title})]})]}),i.jsxs("div",{className:tt.headerActions,children:[i.jsx("button",{onClick:Ze,disabled:!fe||J,className:tt.btnPrimary,"data-testid":"task-edit-save",children:J?"Creating…":S?"Save Changes":"Create"}),i.jsx("button",{onClick:me,className:tt.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:tt.body,children:i.jsxs("div",{className:tt.formContent,children:[E&&i.jsxs("div",{className:tt.section,children:[i.jsx("label",{className:tt.label,htmlFor:"task-edit-workspace",children:"Workspace"}),i.jsxs("select",{id:"task-edit-workspace",value:N,onChange:ve=>T(ve.target.value),className:tt.personaSelect,"data-testid":"task-edit-workspace",children:[i.jsx("option",{value:"",children:"Select a workspace..."}),u.map(ve=>i.jsx("option",{value:ve.id,children:ve.name},ve.id))]})]}),i.jsxs("div",{className:tt.section,children:[i.jsx("label",{className:tt.label,htmlFor:"task-edit-title",children:"Title"}),i.jsx("input",{id:"task-edit-title",type:"text",value:I,onChange:ve=>U(ve.target.value),placeholder:"Task title...",autoFocus:!0,className:tt.titleInput,"data-testid":"task-edit-title",onKeyDown:ve=>{ve.key==="Enter"&&fe&&Ze()}})]}),i.jsxs("div",{className:tt.section,children:[i.jsx("label",{className:tt.label,htmlFor:"task-edit-description",children:"Description"}),i.jsx("textarea",{id:"task-edit-description",value:Q,onChange:ve=>$(ve.target.value),placeholder:"Describe the task... (markdown supported)",className:tt.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),i.jsxs("div",{className:tt.section,children:[i.jsx("label",{className:tt.label,htmlFor:"task-edit-persona",children:"Default Persona"}),i.jsxs("select",{id:"task-edit-persona",value:H,onChange:ve=>ie(ve.target.value),className:tt.personaSelect,"data-testid":"task-edit-persona",children:[i.jsx("option",{value:"",children:"(Inherit)"}),p.map(ve=>i.jsx("option",{value:ve.id,children:ve.name},ve.id))]})]}),!S&&i.jsx("div",{className:tt.section,children:i.jsxs("label",{className:tt.depItem,"data-testid":"task-edit-can-decompose",children:[i.jsx("input",{type:"checkbox",checked:L,onChange:ve=>Z(ve.target.checked)}),"Can spawn subtasks"]})}),i.jsxs("div",{className:tt.section,children:[i.jsx("div",{className:tt.label,children:"Dependencies"}),ge.length===0?i.jsx("div",{className:tt.noDeps,children:"No other tasks in this workspace"}):i.jsx("div",{className:tt.depList,children:ge.map(ve=>{const Le=W.includes(ve.id);return i.jsxs("label",{className:`${tt.depItem} ${Le?tt.depItemSelected:""}`,"data-testid":`dep-option-${ve.id}`,children:[i.jsx("input",{type:"checkbox",checked:Le,onChange:()=>Ce(ve.id)}),ve.title,i.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",ve.status,")"]})]},ve.id)})})]})]})})]})}const hB="_actionButtons_1rjka_1",gB="_btnPrimary_1rjka_8",vB="_btnDanger_1rjka_39",yB="_btnGhost_1rjka_78",Ft={actionButtons:hB,btnPrimary:gB,btnDanger:vB,btnGhost:yB};function bB({task:t,sessionId:s,isBlocked:o,onStart:r,onResume:c,onStop:d,onPause:u,onDelete:p,onEdit:m}){if(t.status==="not_started")return o?i.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:m,className:Ft.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):i.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{"data-testid":"task-header-start",onClick:r,className:Ft.btnPrimary,children:"Start"}),i.jsx("button",{onClick:m,className:Ft.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return i.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Ft.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:u,disabled:!s,className:Ft.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused")return i.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Ft.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:c,className:Ft.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),i.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="complete")return i.jsx("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:i.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return i.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:r,className:Ft.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),i.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const xB="_workpadSection_y8nj9_1",_B="_workpadLabel_y8nj9_9",kB="_workpadStatus_y8nj9_17",SB="_workpadSummary_y8nj9_23",TB="_workpadExtra_y8nj9_29",Da={workpadSection:xB,workpadLabel:_B,workpadStatus:kB,workpadSummary:SB,workpadExtra:TB};function wB({workpad:t}){if(!t)return;let s;try{const o=JSON.parse(t);if(o==null||typeof o!="object"||Array.isArray(o))return;s=o}catch{return i.jsxs("div",{className:Da.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:Da.workpadLabel,children:"Workpad"}),i.jsx("div",{className:Da.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return i.jsxs("div",{className:Da.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:Da.workpadLabel,children:"Workpad"}),s.status&&i.jsx("div",{className:Da.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&i.jsx("div",{className:Da.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&i.jsx("div",{className:Da.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const jB="_overviewDashboard_r05qm_1",NB="_overviewHero_r05qm_7",CB="_statusBadge_r05qm_14",EB="_statusPending_r05qm_26",AB="_statusAssigned_r05qm_31",DB="_statusInProgress_r05qm_36",RB="_statusReview_r05qm_41",MB="_statusDone_r05qm_46",IB="_statusFailed_r05qm_51",OB="_statusWaitingInput_r05qm_56",BB="_overviewBranchPill_r05qm_61",LB="_branchLink_r05qm_76",zB="_overviewSection_r05qm_87",$B="_overviewLabel_r05qm_93",UB="_overviewValue_r05qm_100",PB="_overviewMuted_r05qm_105",HB="_overviewMarkdown_r05qm_111",VB="_envRow_r05qm_180",qB="_envDot_r05qm_186",GB="_envDotGreen_r05qm_193",FB="_envDotYellow_r05qm_197",ZB="_envDotRed_r05qm_201",KB="_envDotGray_r05qm_205",YB="_depList_r05qm_209",JB="_depItem_r05qm_215",WB="_depBlocked_r05qm_222",XB="_depDone_r05qm_226",QB="_timeline_r05qm_230",eL="_timelineRow_r05qm_236",tL="_timelineKey_r05qm_243",nL="_timelineValue_r05qm_249",sL="_timelineDelta_r05qm_253",aL="_reviewNotes_r05qm_264",he={overviewDashboard:jB,overviewHero:NB,statusBadge:CB,statusPending:EB,statusAssigned:AB,statusInProgress:DB,statusReview:RB,statusDone:MB,statusFailed:IB,statusWaitingInput:OB,overviewBranchPill:BB,branchLink:LB,overviewSection:zB,overviewLabel:$B,overviewValue:UB,overviewMuted:PB,overviewMarkdown:HB,envRow:VB,envDot:qB,envDotGreen:GB,envDotYellow:FB,envDotRed:ZB,envDotGray:KB,depList:YB,depItem:JB,depBlocked:WB,depDone:XB,timeline:QB,timelineRow:eL,timelineKey:tL,timelineValue:nL,timelineDelta:sL,reviewNotes:aL};function Lc(t){if(!t)return"—";const s=new Date(t);return isNaN(s.getTime())?"—":s.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function yp(t,s){if(!t||!s)return;const o=new Date(s).getTime()-new Date(t).getTime();if(isNaN(o)||o<0)return;const r=Math.floor(o/6e4),c=Math.floor(o%6e4/1e3);if(r===0)return`${c}s`;const d=Math.floor(r/60),u=r%60;return d===0?`${r}m ${c}s`:`${d}h ${u}m`}function Gb(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?he.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?he.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?he.envDotRed:he.envDotGray}function iL({status:t}){const s=za(t),o=iw(t);return i.jsx("span",{className:`${he.statusBadge} ${he[o]??he.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function oL({task:t,tasksById:s,environments:o,workspaces:r,taskSessions:c,selectedEnvId:d,taskUsage:u,treeUsage:p}){const m=c.length>0?c[c.length-1]:void 0,g=(m==null?void 0:m.environmentId)??"",v=g?o.find(k=>k.id===g):void 0,b=r.find(k=>k.id===t.workspaceId),x=o.find(k=>k.id===d),S=t.branch&&(b!=null&&b.repoUrl)?`${b.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return i.jsxs("div",{className:he.overviewDashboard,"data-testid":"task-overview-panel",children:[i.jsxs("div",{className:he.overviewHero,children:[i.jsx(iL,{status:t.status}),t.branch&&i.jsx("span",{className:he.overviewBranchPill,"data-testid":"task-overview-branch",children:S?i.jsxs("a",{href:S,target:"_blank",rel:"noreferrer noopener",className:he.branchLink,children:["🔗"," ",t.branch]}):i.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&i.jsxs("div",{className:he.overviewSection,"data-testid":"task-overview-description",children:[i.jsx("div",{className:he.overviewLabel,children:"Description"}),i.jsx("div",{className:he.overviewMarkdown,children:i.jsx(hd,{remarkPlugins:[gd],children:t.description})})]}),t.workpad&&i.jsx(wB,{workpad:t.workpad}),i.jsxs("div",{className:he.overviewSection,children:[i.jsx("div",{className:he.overviewLabel,children:"Environment"}),g&&v?i.jsxs("div",{className:he.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${he.envDot} ${Gb(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),i.jsx("span",{className:he.overviewValue,children:v.displayName})]}):x?i.jsxs("div",{className:he.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${he.envDot} ${Gb(x.status)}`,title:x.status,"aria-label":`Status: ${x.status}`,role:"img"}),i.jsx("span",{className:he.overviewValue,children:x.displayName}),i.jsx("span",{className:he.overviewMuted,children:"(workspace default)"})]}):i.jsx("div",{className:he.overviewMuted,children:"Set in workspace settings"})]}),i.jsxs("div",{className:he.overviewSection,"data-testid":"task-overview-dependencies",children:[i.jsx("div",{className:he.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?i.jsx("div",{className:he.overviewMuted,children:"None"}):i.jsx("div",{className:he.depList,children:t.dependsOn.map(k=>{const w=s.get(k),N=(w==null?void 0:w.status)==="complete";return i.jsxs("div",{className:`${he.depItem} ${N?he.depDone:he.depBlocked}`,children:[i.jsx("span",{children:N?"✓":"○"}),i.jsx("span",{children:(w==null?void 0:w.title)??k})]},k)})})]}),i.jsxs("div",{className:he.overviewSection,"data-testid":"task-overview-timeline",children:[i.jsx("div",{className:he.overviewLabel,children:"Timeline"}),i.jsxs("div",{className:he.timeline,children:[t.createdAt&&i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Created"}),i.jsx("span",{className:he.timelineValue,children:Lc(t.createdAt)})]}),t.assignedAt&&(()=>{const k=yp(t.createdAt,t.assignedAt);return i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Assigned"}),i.jsx("span",{className:he.timelineValue,children:Lc(t.assignedAt)}),k!==void 0&&i.jsx("span",{className:he.timelineDelta,children:k})]})})(),t.startedAt&&(()=>{const k=yp(t.assignedAt??t.createdAt,t.startedAt);return i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Started"}),i.jsx("span",{className:he.timelineValue,children:Lc(t.startedAt)}),k!==void 0&&i.jsx("span",{className:he.timelineDelta,children:k})]})})(),t.completedAt&&(()=>{const k=yp(t.startedAt,t.completedAt);return i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Completed"}),i.jsx("span",{className:he.timelineValue,children:Lc(t.completedAt)}),k!==void 0&&i.jsx("span",{className:he.timelineDelta,children:k})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&i.jsx("div",{className:he.overviewMuted,children:"No timing data"})]})]}),u&&u.costMillicents>0&&i.jsxs("div",{className:he.overviewSection,"data-testid":"task-overview-usage",children:[i.jsx("div",{className:he.overviewLabel,children:"Usage"}),i.jsxs("div",{className:he.timeline,children:[i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Cost"}),i.jsx("span",{className:he.timelineValue,children:Ss(u.costMillicents)}),i.jsxs("span",{className:he.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costMillicents>u.costMillicents&&i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Total (incl. subtasks)"}),i.jsx("span",{className:he.timelineValue,children:Ss(p.costMillicents)}),i.jsxs("span",{className:he.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),(t.tokenBudget>0||t.costBudgetMillicents>0)&&i.jsxs("div",{className:he.overviewSection,"data-testid":"task-overview-budget",children:[i.jsx("div",{className:he.overviewLabel,children:"Budget"}),i.jsxs("div",{className:he.timeline,children:[t.tokenBudget>0&&i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Tokens"}),i.jsxs("span",{className:he.timelineValue,children:[Mo(((u==null?void 0:u.inputTokens)??0)+((u==null?void 0:u.outputTokens)??0))," / ",Mo(t.tokenBudget)]})]}),t.costBudgetMillicents>0&&i.jsxs("div",{className:he.timelineRow,children:[i.jsx("span",{className:he.timelineKey,children:"Cost"}),i.jsxs("span",{className:he.timelineValue,children:[Ss((u==null?void 0:u.costMillicents)??0)," / ",Ss(t.costBudgetMillicents)]})]})]})]}),t.reviewNotes&&i.jsxs("div",{className:he.overviewSection,"data-testid":"task-overview-review-notes",children:[i.jsx("div",{className:he.overviewLabel,children:"Review Notes"}),i.jsx("div",{className:he.reviewNotes,children:t.reviewNotes})]})]})}const rL="_container_legrg_1",lL="_header_legrg_8",cL="_headerTitle_legrg_35",dL="_badge_legrg_44",uL="_headerActions_legrg_54",fL="_body_legrg_61",pL="_formContent_legrg_73",mL="_section_legrg_85",hL="_label_legrg_91",gL="_nameInput_legrg_98",vL="_fieldInput_legrg_131",yL="_adapterSelect_legrg_164",bL="_readOnlyValue_legrg_198",xL="_codespaceSection_legrg_204",_L="_codespaceActions_legrg_210",kL="_creatingHint_legrg_216",SL="_errorHint_legrg_222",TL="_btnPrimary_legrg_235",wL="_btnGhost_legrg_266",re={container:rL,header:lL,headerTitle:cL,badge:dL,headerActions:uL,body:fL,formContent:pL,section:mL,label:hL,nameInput:gL,fieldInput:vL,adapterSelect:yL,readOnlyValue:bL,codespaceSection:xL,codespaceActions:_L,creatingHint:kL,errorHint:SL,btnPrimary:TL,btnGhost:wL},Wc=1,Xc=65535;function bp(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=Wc&&s<=Xc}function xp(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function jL({codespaceName:t,onCodespaceNameChange:s,envName:o,onEnvNameChange:r,codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:m}){const[g,v]=y.useState("pick"),[b,x]=y.useState(""),[S,k]=y.useState("");return g==="create"?i.jsxs("div",{className:re.codespaceSection,children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Repository"}),i.jsx("input",{type:"text",value:b,onChange:w=>x(w.target.value),placeholder:"owner/repo",className:re.fieldInput,"data-testid":"env-codespace-repo"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Machine Type"}),i.jsx("input",{type:"text",value:S,onChange:w=>k(w.target.value),placeholder:"Machine type (optional)...",className:re.fieldInput,"data-testid":"env-codespace-machine"})]}),i.jsxs("div",{className:re.codespaceActions,children:[i.jsx("button",{onClick:()=>{b.trim()&&(m(b.trim(),S.trim()||void 0),v("pick"),x(""),k(""))},disabled:!b.trim(),className:re.btnPrimary,children:"Create"}),i.jsx("button",{onClick:()=>{v("pick"),x(""),k("")},className:re.btnGhost,children:"Cancel"})]})]}):i.jsx("div",{className:re.codespaceSection,children:i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Codespace"}),!u&&i.jsxs("select",{value:t,onChange:w=>{w.target.value==="__create__"?(v("create"),s("")):(s(w.target.value),w.target.value&&!o.trim()&&r(w.target.value))},disabled:p,className:re.adapterSelect,"data-testid":"env-codespace-select",children:[i.jsx("option",{value:"",children:"Select a codespace..."}),c.map(w=>i.jsxs("option",{value:w.name,children:[w.name," (",w.repository,") — ",w.state]},w.name)),i.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&i.jsx("span",{className:re.creatingHint,children:"Creating codespace..."}),u&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:re.errorHint,children:u}),i.jsx("input",{type:"text",value:t,onChange:w=>s(w.target.value),placeholder:"Or enter codespace name manually...",className:re.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&i.jsx("span",{className:re.errorHint,children:d})]})})}function A1({mode:t,environmentId:s,environments:o,onAddEnvironment:r,onUpdateEnvironment:c,onListCodespaces:d,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v,onShowToast:b}){const x=kt(),S=t==="edit",k=S&&s?o.find(me=>me.id===s):void 0,[w,N]=y.useState(""),[T,C]=y.useState("local"),[D,B]=y.useState(""),[E,A]=y.useState(""),[P,I]=y.useState(""),[U,Q]=y.useState(""),[$,W]=y.useState(""),[pe,H]=y.useState(""),[ie,L]=y.useState(""),[Z,J]=y.useState(null),ce=y.useCallback(()=>{const me={};if(T==="local"){if(D.trim()&&(me.host=D.trim()),E.trim()){const _e=Number(E);Number.isInteger(_e)&&(me.port=_e)}}else if(T==="ssh"){if(me.host=D.trim(),P.trim()&&(me.user=P.trim()),E.trim()){const _e=Number(E);Number.isInteger(_e)&&(me.sshPort=_e)}U.trim()&&(me.identityFile=U.trim())}else T==="docker"?($.trim()&&(me.image=$.trim()),pe.trim()&&(me.repo=pe.trim())):T==="codespace"&&(me.codespaceName=ie.trim());return me},[T,D,E,P,U,$,pe,ie]),X=()=>!(!w.trim()||T==="ssh"&&!D.trim()||T==="codespace"&&!ie.trim()||(T==="local"||T==="ssh")&&!bp(E)),ge=()=>{X()&&(r(w.trim(),T,ce()),b==null||b("Environment added successfully","success"),x(Ro,{replace:!0}))},fe=()=>{x(s?ji(s):Ro)},Ce=y.useCallback((me,_e)=>{if(!k||!s)return;const ve=xp(k.adapterConfig),Le=_e.trim();Le?ve[me]=Le:delete ve[me],c(s,{adapterConfig:ve})},[k,s,c]),Ze=y.useCallback((me,_e)=>{if(!k||!s)return;const ve=xp(k.adapterConfig);if(_e.trim()){const Le=Number(_e);Number.isInteger(Le)&&Le>=Wc&&Le<=Xc&&(ve[me]=Le)}else delete ve[me];c(s,{adapterConfig:ve})},[k,s,c]);if(S){if(!k)return i.jsxs("div",{className:re.container,children:[i.jsxs("div",{className:re.header,children:[i.jsx("div",{className:re.headerTitle,children:i.jsx("span",{className:re.badge,children:"edit environment"})}),i.jsx("div",{className:re.headerActions,children:i.jsx("button",{onClick:fe,className:re.btnGhost,children:"Back"})})]}),i.jsx("div",{className:re.body,children:i.jsx("div",{className:re.formContent,children:i.jsx("span",{className:re.readOnlyValue,children:"Environment not found"})})})]});const me=xp(k.adapterConfig);return i.jsxs("div",{className:re.container,"data-testid":"env-edit-panel",children:[i.jsxs("div",{className:re.header,children:[i.jsx("div",{className:re.headerTitle,children:i.jsx("span",{className:re.badge,children:"edit environment"})}),i.jsx("div",{className:re.headerActions,children:i.jsx("button",{onClick:fe,className:re.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),i.jsx("div",{className:re.body,children:i.jsxs("div",{className:re.formContent,children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Name"}),i.jsx(ln,{value:k.displayName,onSave:_e=>{s&&c(s,{displayName:_e})},validate:_e=>_e.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:Z,onActivate:J,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Adapter Type"}),i.jsx("span",{className:re.readOnlyValue,"data-testid":"env-edit-adapter-type",children:k.adapterType})]}),k.adapterType==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Host"}),i.jsx(ln,{value:String(me.host??""),onSave:_e=>Ce("host",_e),mode:"edit",fieldId:"host",activeFieldId:Z,onActivate:J,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Port"}),i.jsx(ln,{value:String(me.port??""),onSave:_e=>Ze("port",_e),validate:_e=>bp(_e)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:Z,onActivate:J,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),k.adapterType==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Host"}),i.jsx(ln,{value:String(me.host??""),onSave:_e=>Ce("host",_e),validate:_e=>_e.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:Z,onActivate:J,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"User"}),i.jsx(ln,{value:String(me.user??""),onSave:_e=>Ce("user",_e),mode:"edit",fieldId:"user",activeFieldId:Z,onActivate:J,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"SSH Port"}),i.jsx(ln,{value:String(me.sshPort??""),onSave:_e=>Ze("sshPort",_e),validate:_e=>bp(_e)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:Z,onActivate:J,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Identity File"}),i.jsx(ln,{value:String(me.identityFile??""),onSave:_e=>Ce("identityFile",_e),mode:"edit",fieldId:"identityFile",activeFieldId:Z,onActivate:J,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),k.adapterType==="docker"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Image"}),i.jsx(ln,{value:String(me.image??""),onSave:_e=>Ce("image",_e),mode:"edit",fieldId:"image",activeFieldId:Z,onActivate:J,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Repo"}),i.jsx(ln,{value:String(me.repo??""),onSave:_e=>Ce("repo",_e),mode:"edit",fieldId:"repo",activeFieldId:Z,onActivate:J,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),k.adapterType==="codespace"&&i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,children:"Codespace Name"}),i.jsx(ln,{value:String(me.codespaceName??""),onSave:_e=>Ce("codespaceName",_e),validate:_e=>_e.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:Z,onActivate:J,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return i.jsxs("div",{className:re.container,"data-testid":"env-create-panel",children:[i.jsxs("div",{className:re.header,children:[i.jsx("div",{className:re.headerTitle,children:i.jsx("span",{className:re.badge,children:"new environment"})}),i.jsxs("div",{className:re.headerActions,children:[i.jsx("button",{onClick:ge,disabled:!X(),className:re.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),i.jsx("button",{onClick:fe,className:re.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:re.body,children:i.jsxs("div",{className:re.formContent,children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-name",children:"Name"}),i.jsx("input",{id:"env-create-name",type:"text",value:w,onChange:me=>N(me.target.value),placeholder:"Environment name...",autoFocus:!0,className:re.nameInput,"data-testid":"env-create-name",onKeyDown:me=>{me.key==="Enter"&&X()&&ge()}})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),i.jsxs("select",{id:"env-create-adapter",value:T,onChange:me=>{C(me.target.value),me.target.value==="codespace"&&d()},className:re.adapterSelect,"data-testid":"env-create-adapter",children:[i.jsx("option",{value:"local",children:"local"}),i.jsx("option",{value:"ssh",children:"ssh"}),i.jsx("option",{value:"docker",children:"docker"}),i.jsx("option",{value:"codespace",children:"codespace"})]})]}),T==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:D,onChange:me=>B(me.target.value),placeholder:"Host (optional)...",className:re.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-port",children:"Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:Wc,max:Xc,value:E,onChange:me=>A(me.target.value),placeholder:"Port (optional)...",className:re.fieldInput,"data-testid":"env-create-port"})]})]}),T==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:D,onChange:me=>B(me.target.value),placeholder:"Host (required)...",className:re.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-user",children:"User"}),i.jsx("input",{id:"env-create-user",type:"text",value:P,onChange:me=>I(me.target.value),placeholder:"User (optional)...",className:re.fieldInput,"data-testid":"env-create-user"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-port",children:"SSH Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:Wc,max:Xc,value:E,onChange:me=>A(me.target.value),placeholder:"SSH port (optional)...",className:re.fieldInput,"data-testid":"env-create-port"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-identity",children:"Identity File"}),i.jsx("input",{id:"env-create-identity",type:"text",value:U,onChange:me=>Q(me.target.value),placeholder:"Identity file (optional)...",className:re.fieldInput,"data-testid":"env-create-identity"})]})]}),T==="docker"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-image",children:"Image"}),i.jsx("input",{id:"env-create-image",type:"text",value:$,onChange:me=>W(me.target.value),placeholder:"Image (optional)...",className:re.fieldInput,"data-testid":"env-create-image"})]}),i.jsxs("div",{className:re.section,children:[i.jsx("label",{className:re.label,htmlFor:"env-create-repo",children:"Repo"}),i.jsx("input",{id:"env-create-repo",type:"text",value:pe,onChange:me=>H(me.target.value),placeholder:"Repo (optional)...",className:re.fieldInput,"data-testid":"env-create-repo"})]})]}),T==="codespace"&&i.jsx(jL,{codespaceName:ie,onCodespaceNameChange:L,envName:w,onEnvNameChange:N,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v})]})})]})}const NL="_group_1iprv_1",CL="_groupTitle_1iprv_8",EL="_shortcutList_1iprv_17",AL="_shortcutRow_1iprv_23",DL="_keys_1iprv_36",RL="_kbd_1iprv_43",ML="_description_1iprv_60",xi={group:NL,groupTitle:CL,shortcutList:EL,shortcutRow:AL,keys:DL,kbd:RL,description:ML},IL=[{title:"Global",shortcuts:[{keys:["?"],description:"Open keyboard shortcuts reference"},{keys:["N"],description:"Create a new task"},{keys:["Escape"],description:"Close dialog or cancel editing"}]},{title:"Task Page",shortcuts:[{keys:["1"],description:"Switch to Overview tab"},{keys:["2"],description:"Switch to Stream tab"},{keys:["3"],description:"Switch to Findings tab"}]},{title:"Workspace Page",shortcuts:[{keys:["1"],description:"Switch to Graph view"},{keys:["2"],description:"Switch to Board view"},{keys:["3"],description:"Switch to Tasks view"}]},{title:"Navigation Lists",shortcuts:[{keys:["←"],description:"Previous tab (horizontal nav)"},{keys:["→"],description:"Next tab (horizontal nav)"},{keys:["↑"],description:"Previous item (vertical nav)"},{keys:["↓"],description:"Next item (vertical nav)"},{keys:["J"],description:"Next item (alias for arrow down/right)"},{keys:["K"],description:"Previous item (alias for arrow up/left)"},{keys:["Home"],description:"Jump to first item"},{keys:["End"],description:"Jump to last item"}]},{title:"Editing",shortcuts:[{keys:["Enter"],description:"Activate / save inline edit"},{keys:["Space"],description:"Activate button or start editing"},{keys:["Escape"],description:"Cancel edit and discard changes"}]},{title:"Chat",shortcuts:[{keys:["Enter"],description:"Send message (when input is focused)"}]}];function OL(){return i.jsxs("section",{className:be.section,"data-testid":"keyboard-shortcuts-panel",children:[i.jsx("h3",{className:be.sectionTitle,children:"Keyboard Shortcuts"}),i.jsx("p",{className:be.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),IL.map(t=>i.jsxs("div",{className:xi.group,children:[i.jsx("h4",{className:xi.groupTitle,children:t.title}),i.jsx("div",{className:xi.shortcutList,children:t.shortcuts.map(s=>i.jsxs("div",{className:xi.shortcutRow,children:[i.jsx("span",{className:xi.keys,children:s.keys.map(o=>i.jsx("kbd",{className:xi.kbd,children:o},o))}),i.jsx("span",{className:xi.description,children:s.description})]},s.description))})]},t.title))]})}const BL=[{key:"claude",label:"Claude",description:"Forward Claude credentials for AI agent access.",options:[{value:"off",label:"Off"},{value:"subscription",label:"Subscription"},{value:"api_key",label:"API Key"}]},{key:"github",label:"GitHub",description:"Forward GITHUB_TOKEN and GH_TOKEN for git operations.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"copilot",label:"Copilot",description:"Forward Copilot tokens (COPILOT_GITHUB_TOKEN, CLI config).",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"codex",label:"Codex",description:"Forward OPENAI_API_KEY for Codex/OpenAI access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"goose",label:"Goose",description:"Forward Goose config and API keys for Goose agent access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]}];function LL({credentialProviders:t,onUpdateCredentialProviders:s}){const o=(r,c)=>{const d={...t};r==="claude"?d.claude=c:d[r]=c,s(d)};return i.jsxs("section",{className:be.section,children:[i.jsx("h3",{className:be.sectionTitle,children:"Credential Providers"}),i.jsx("p",{className:be.sectionDescription,children:"Enable providers to automatically forward credentials to environments at task start. Credentials are read fresh from the host each time."}),i.jsx("div",{className:be.tokenList,children:BL.map(r=>i.jsxs("div",{className:be.tokenRow,children:[i.jsx("span",{className:be.tokenName,children:r.label}),i.jsx("span",{className:be.tokenTarget,children:r.description}),i.jsx("select",{className:be.select,value:t[r.key],onChange:c=>o(r.key,c.target.value),children:r.options.map(c=>i.jsx("option",{value:c.value,children:c.label},c.value))})]},r.key))})]})}const zL="_container_10efq_1",$L="_header_10efq_7",UL="_list_10efq_105",PL="_card_10efq_111",HL="_cardHeader_10efq_125",VL="_cardTitle_10efq_135",qL="_defaultBadge_10efq_141",GL="_cardActions_10efq_155",FL="_description_10efq_160",ZL="_meta_10efq_166",KL="_empty_10efq_212",YL="_typeBadge_10efq_362",Jn={container:zL,header:$L,list:UL,card:PL,cardHeader:HL,cardTitle:VL,defaultBadge:qL,cardActions:GL,description:FL,meta:ZL,empty:KL,typeBadge:YL};function JL({personas:t,appDefaultPersonaId:s,onDeletePersona:o,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=y.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await o(v),p(null)};return i.jsxs("div",{className:Jn.container,children:[i.jsxs("div",{className:Jn.header,children:[i.jsx("h2",{children:"Personas"}),i.jsx(Js,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?i.jsx("p",{className:Jn.empty,children:"No personas yet. Create one to get started."}):i.jsx("div",{className:Jn.list,children:t.map(v=>{const b=s===v.id,x=v.type==="script";return i.jsxs("div",{className:Jn.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:S=>{S.currentTarget===S.target&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),d(v.id))},children:[i.jsxs("div",{className:Jn.cardHeader,children:[i.jsxs("span",{className:Jn.cardTitle,children:[i.jsx("strong",{children:v.name}),i.jsx("span",{className:Jn.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:x?"Script":"Agent"}),b&&i.jsx("span",{className:Jn.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),i.jsxs("div",{className:Jn.cardActions,onClick:S=>S.stopPropagation(),children:[!b&&i.jsx(Js,{variant:"ghost",size:"sm",onClick:()=>{r(v.id).catch(()=>{})},"data-testid":`persona-set-default-${v.id}`,title:"Set as app default persona",children:"Set Default"}),i.jsx(Js,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),i.jsx(Js,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&i.jsx("p",{className:Jn.description,children:v.description}),i.jsxs("div",{className:Jn.meta,children:[v.runtime&&i.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&i.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&i.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),i.jsx(Ci,{isOpen:u!==null,title:"Delete Persona?",description:`"${(m==null?void 0:m.name)??""}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:()=>{u&&g(u).catch(()=>{})},onCancel:()=>p(null)})]})}const WL="_container_uy08i_1",XL="_header_uy08i_7",QL="_count_uy08i_13",e8="_presets_uy08i_18",t8="_presetButton_uy08i_24",n8="_filterInput_uy08i_41",s8="_groups_uy08i_53",a8="_group_uy08i_53",i8="_groupHeader_uy08i_68",o8="_groupName_uy08i_77",r8="_groupCount_uy08i_81",l8="_toolList_uy08i_87",c8="_toolItem_uy08i_95",d8="_toolName_uy08i_103",pn={container:WL,header:XL,count:QL,presets:e8,presetButton:t8,filterInput:n8,groups:s8,group:a8,groupHeader:i8,groupName:o8,groupCount:r8,toolList:l8,toolItem:c8,toolName:d8},u8=(()=>{const t=new Map;for(const s of dx){const o=s==="get_version_status"?"version":s.split("_")[0];t.has(o)||t.set(o,[]),t.get(o).push(s)}return[...t.entries()].sort(([s],[o])=>s.localeCompare(o)).map(([s,o])=>({group:s,tools:o.sort()}))})(),f8=[{name:"default",label:"Default",tools:ux},{name:"worker",label:"Worker",tools:yT},{name:"orchestrator",label:"Orchestrator",tools:bT},{name:"admin",label:"Admin",tools:xT}];function Fb({selectedTools:t,onChange:s,disabled:o}){const[r,c]=y.useState(""),d=y.useMemo(()=>new Set(t),[t]),u=y.useCallback(v=>{if(o)return;const b=new Set(d);b.has(v)?b.delete(v):b.add(v),s([...b].sort())},[d,s,o]),p=y.useCallback((v,b)=>{if(o)return;const x=new Set(d);for(const S of v)b?x.delete(S):x.add(S);s([...x].sort())},[d,s,o]),m=y.useCallback(v=>{o||s([...v].sort())},[s,o]),g=r.toLowerCase();return i.jsxs("div",{className:pn.container,"data-testid":"mcp-tool-selector",children:[i.jsx("div",{className:pn.header,children:i.jsx("span",{className:pn.count,children:t.length===0?`Using default (${ux.length} tools)`:`${t.length} of ${dx.size} tools selected`})}),i.jsxs("div",{className:pn.presets,"data-testid":"mcp-tool-presets",children:[f8.map(v=>i.jsx("button",{type:"button",className:pn.presetButton,disabled:o,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),i.jsx("button",{type:"button",className:pn.presetButton,disabled:o,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),i.jsx("input",{type:"text",className:pn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:o,"data-testid":"mcp-tool-filter"}),i.jsx("div",{className:pn.groups,children:u8.map(({group:v,tools:b})=>{const x=g?b.filter(k=>k.toLowerCase().includes(g)):b;if(x.length===0)return null;const S=x.every(k=>d.has(k));return i.jsxs("div",{className:pn.group,"data-testid":`tool-group-${v}`,children:[i.jsxs("label",{className:pn.groupHeader,children:[i.jsx("input",{type:"checkbox",checked:S,onChange:()=>p(x,S),disabled:o,"data-testid":`group-toggle-${v}`}),i.jsx("span",{className:pn.groupName,children:v}),i.jsxs("span",{className:pn.groupCount,children:["(",x.filter(k=>d.has(k)).length,"/",x.length,")"]})]}),i.jsx("div",{className:pn.toolList,children:x.map(k=>i.jsxs("label",{className:pn.toolItem,children:[i.jsx("input",{type:"checkbox",checked:d.has(k),onChange:()=>u(k),disabled:o,"data-testid":`tool-${k}`}),i.jsx("span",{className:pn.toolName,children:k})]},k))})]},v)})})]})}const p8="_nav_1bhou_1",m8="_tab_1bhou_24",h8="_tabIcon_1bhou_62",g8="_tabActive_1bhou_68",zc={nav:p8,tab:m8,tabIcon:h8,tabActive:g8},Ks=[{path:"credentials",label:"Credentials",icon:i.jsx(C2,{size:zt})},{path:"personas",label:"Personas",icon:i.jsx(nw,{size:zt})},{path:"appearance",label:"Appearance",icon:i.jsx(q2,{size:zt})},{path:"shortcuts",label:"Shortcuts",icon:i.jsx(A2,{size:zt})},{path:"about",label:"About",icon:i.jsx(im,{size:zt})}];function v8(){var u;const t=Zt(),s=kt(),o=y.useRef(null),r=((u=Ks.find(p=>{const m=`${Do}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??Ks[0].path,c=y.useCallback(p=>{s(`${Do}/${p}`)},[s]),d=y.useCallback(p=>{var S,k;const m=(S=o.current)==null?void 0:S.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(w=>w===document.activeElement),v=g>=0?g:Ks.findIndex(w=>w.path===r);let b=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),b=(v+1)%Ks.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),b=(v-1+Ks.length)%Ks.length;else if(p.key==="Home")p.preventDefault(),b=0;else if(p.key==="End")p.preventDefault(),b=Ks.length-1;else return;const x=Ks[b].path;s(`${Do}/${x}`),(k=m[b])==null||k.focus()},[r,s]);return i.jsx("nav",{className:zc.nav,ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:Ks.map(p=>{const m=p.path===r;return i.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${zc.tab} ${m?zc.tabActive:""}`,onClick:()=>c(p.path),children:[i.jsx("span",{className:zc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}function y8({tasks:t,taskStatusById:s,sessionStatusByTaskId:o}){const r=new Map;for(const d of t)if(d.parentTaskId){const u=r.get(d.parentTaskId);u?u.push(d):r.set(d.parentTaskId,[d])}const c=new Map(cy.map(d=>[d,[]]));for(const d of t){const u=ll(d.status),p=d.dependsOn.length>0&&d.dependsOn.some(k=>s.get(k)!=="complete"),m=r.get(d.id)??[],g=m.length,v=m.filter(k=>k.status==="complete").length;let b;if(u==="paused"&&o){const k=o.get(d.id);k==="idle"?b="Needs input":k==="completed"&&(b="Ready to complete")}const x={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:b},S=c.get(u);S?S.push(x):c.get("not_started").push(x)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return cy.map(d=>{const u=za(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const b8="_boardContainer_1c4y1_1",x8="_column_1c4y1_17",_8="_columnHeader_1c4y1_34",k8="_columnIcon_1c4y1_47",S8="_columnLabel_1c4y1_52",T8="_columnCount_1c4y1_57",w8="_cardList_1c4y1_67",j8="_emptyPlaceholder_1c4y1_76",N8="_card_1c4y1_67",C8="_cardHeader_1c4y1_107",E8="_cardStatusIcon_1c4y1_113",A8="_cardTitle_1c4y1_119",D8="_cardBadges_1c4y1_127",R8="_badge_1c4y1_134",M8="_blockedBadge_1c4y1_146",I8="_childBadge_1c4y1_151",O8="_depBadge_1c4y1_155",B8="_parentBadge_1c4y1_159",L8="_pausedSubBadge_1c4y1_166",z8="_personaBadge_1c4y1_170",$8="_envBadge_1c4y1_174",U8="_emptyCta_1c4y1_178",P8="_ctaButton_1c4y1_188",H8="_ctaDescription_1c4y1_204",it={boardContainer:b8,column:x8,columnHeader:_8,columnIcon:k8,columnLabel:S8,columnCount:T8,cardList:w8,emptyPlaceholder:j8,card:N8,cardHeader:C8,cardStatusIcon:E8,cardTitle:A8,cardBadges:D8,badge:R8,blockedBadge:M8,childBadge:I8,depBadge:O8,parentBadge:B8,pausedSubBadge:L8,personaBadge:z8,envBadge:$8,emptyCta:U8,ctaButton:P8,ctaDescription:H8};function V8({workspaceId:t,environmentId:s,tasks:o,sessions:r,personas:c,environments:d}){const u=kt(),p=y.useMemo(()=>o.filter(x=>x.workspaceId===t),[o,t]),m=y.useMemo(()=>new Map(o.map(x=>[x.id,x.status])),[o]),g=y.useMemo(()=>new Map(p.map(x=>[x.id,x])),[p]),v=y.useMemo(()=>{const x=new Map(r.map(C=>[C.id,C])),S=new Map(c.map(C=>[C.id,C])),k=new Map(d.map(C=>[C.id,C])),w=new Map,N=new Map,T=new Map;for(const C of p)if(C.latestSessionId){const D=x.get(C.latestSessionId);if(D){if(w.set(C.id,D.endReason||D.status),D.personaId){const B=S.get(D.personaId);B&&N.set(C.id,B.name)}if(D.environmentId){const B=k.get(D.environmentId);B&&T.set(C.id,B.displayName)}}}return{sessionStatusByTaskId:w,personaNameByTaskId:N,environmentNameByTaskId:T}},[p,r,c,d]),b=y.useMemo(()=>y8({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?i.jsxs("div",{className:it.emptyCta,"data-testid":"board-empty-cta",children:[i.jsx("button",{className:it.ctaButton,onClick:()=>u(Di(t,void 0,s)),children:"Create Task"}),i.jsx("div",{className:it.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):i.jsx("div",{className:it.boardContainer,"data-testid":"board-container",children:b.map(x=>i.jsxs("section",{className:it.column,"data-testid":`board-column-${x.status}`,"aria-label":`${x.label}, ${x.tasks.length} ${x.tasks.length===1?"task":"tasks"}`,children:[i.jsxs("div",{className:it.columnHeader,children:[i.jsx("span",{className:it.columnIcon,style:{color:x.style.color},children:x.style.icon}),i.jsx("span",{className:it.columnLabel,children:x.label}),i.jsx("span",{className:it.columnCount,"data-testid":`board-count-${x.status}`,children:x.tasks.length})]}),i.jsx("div",{className:it.cardList,children:x.tasks.length===0?i.jsx("div",{className:it.emptyPlaceholder,children:"No tasks"}):i.jsx(us,{mode:"popLayout",children:x.tasks.map(S=>i.jsx(Rt.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:i.jsx(q8,{boardTask:S,tasksById:g,personaName:v.personaNameByTaskId.get(S.task.id),envName:v.environmentNameByTaskId.get(S.task.id),onClick:()=>u(On(S.task.id,void 0,t,s))})},S.task.id))})})]},x.status))})}function q8({boardTask:t,tasksById:s,personaName:o,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=za(d.status),b=d.parentTaskId?s.get(d.parentTaskId):void 0;return i.jsxs("div",{className:it.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),c())},children:[i.jsxs("div",{className:it.cardHeader,children:[i.jsx("span",{className:it.cardStatusIcon,style:{color:v.color},children:v.icon}),i.jsx("span",{className:it.cardTitle,children:d.title})]}),i.jsxs("div",{className:it.cardBadges,children:[b&&i.jsx("span",{className:`${it.badge} ${it.parentBadge}`,title:b.title,children:b.title}),p>0&&i.jsxs("span",{className:`${it.badge} ${it.childBadge}`,children:[m,"/",p]}),u&&i.jsx("span",{className:`${it.badge} ${it.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&i.jsx("span",{className:`${it.badge} ${it.depBadge}`,children:"dep"}),g&&i.jsx("span",{className:`${it.badge} ${it.pausedSubBadge}`,children:g}),o&&i.jsx("span",{className:`${it.badge} ${it.personaBadge}`,children:o}),r&&i.jsx("span",{className:`${it.badge} ${it.envBadge}`,children:r})]})]})}const G8="_formContent_ymnez_1",F8="_section_ymnez_13",Z8="_label_ymnez_19",K8="_titleInput_ymnez_26",Y8="_descriptionTextarea_ymnez_58",J8="_selectField_ymnez_94",W8="_checkboxRow_ymnez_128",X8="_checkboxLabel_ymnez_141",Q8="_fieldError_ymnez_146",bt={formContent:G8,section:F8,label:Z8,titleInput:K8,descriptionTextarea:Y8,selectField:J8,checkboxRow:W8,checkboxLabel:X8,fieldError:Q8};function e7(t,s){return{name:(t==null?void 0:t.name)??"",description:(t==null?void 0:t.description)??"",repoUrl:(t==null?void 0:t.repoUrl)??"",environmentId:(t==null?void 0:t.environmentId)??s??"",defaultPersonaId:(t==null?void 0:t.defaultPersonaId)??"",useWorktrees:(t==null?void 0:t.useWorktrees)??!0,workingDirectory:(t==null?void 0:t.workingDirectory)??""}}const t7=100;function n7({values:t,onChange:s,environments:o,personas:r,errors:c,disabled:d,autoFocusName:u}){const p=(m,g)=>{s({...t,[m]:g})};return i.jsxs("div",{className:bt.formContent,children:[i.jsxs("div",{className:bt.section,children:[i.jsx("label",{className:bt.label,htmlFor:"ws-name",children:"Name"}),i.jsx("input",{id:"ws-name",className:bt.titleInput,type:"text",value:t.name,onChange:m=>p("name",m.target.value),placeholder:"Workspace name",maxLength:t7,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&i.jsx("span",{className:bt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),i.jsxs("div",{className:bt.section,children:[i.jsx("label",{className:bt.label,htmlFor:"ws-description",children:"Description"}),i.jsx("textarea",{id:"ws-description",className:bt.descriptionTextarea,value:t.description,onChange:m=>p("description",m.target.value),placeholder:"Optional description (Markdown supported)",disabled:d,"data-testid":"workspace-form-description"})]}),i.jsxs("div",{className:bt.section,children:[i.jsx("label",{className:bt.label,htmlFor:"ws-repo",children:"Repository URL"}),i.jsx("input",{id:"ws-repo",className:bt.titleInput,type:"text",value:t.repoUrl,onChange:m=>p("repoUrl",m.target.value),placeholder:"https://github.com/org/repo",disabled:d,"data-testid":"workspace-form-repo"}),(c==null?void 0:c.repoUrl)&&i.jsx("span",{className:bt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),i.jsxs("div",{className:bt.section,children:[i.jsx("label",{className:bt.label,htmlFor:"ws-environment",children:"Environment"}),i.jsxs("select",{id:"ws-environment",className:bt.selectField,value:t.environmentId,onChange:m=>p("environmentId",m.target.value),disabled:d,"data-testid":"workspace-form-environment",children:[i.jsx("option",{value:"",children:"Select environment…"}),o.map(m=>i.jsx("option",{value:m.id,children:m.displayName||m.id},m.id))]}),(c==null?void 0:c.environmentId)&&i.jsx("span",{className:bt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),i.jsxs("div",{className:bt.section,children:[i.jsx("label",{className:bt.label,htmlFor:"ws-persona",children:"Default Persona"}),i.jsxs("select",{id:"ws-persona",className:bt.selectField,value:t.defaultPersonaId,onChange:m=>p("defaultPersonaId",m.target.value),disabled:d,"data-testid":"workspace-form-persona",children:[i.jsx("option",{value:"",children:"(Inherit)"}),r.map(m=>i.jsx("option",{value:m.id,children:m.name},m.id))]})]}),i.jsx("div",{className:bt.section,children:i.jsxs("label",{className:bt.checkboxRow,children:[i.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:m=>p("useWorktrees",m.target.checked),disabled:d,"data-testid":"workspace-form-worktrees"}),i.jsx("span",{className:bt.checkboxLabel,children:"Enable worktree isolation"})]})}),i.jsxs("div",{className:bt.section,children:[i.jsx("label",{className:bt.label,htmlFor:"ws-workdir",children:"Working Directory"}),i.jsx("input",{id:"ws-workdir",className:bt.titleInput,type:"text",value:t.workingDirectory,onChange:m=>p("workingDirectory",m.target.value),placeholder:"Default (server default)",disabled:d,"data-testid":"workspace-form-workdir"})]})]})}const D1=y.createContext(void 0),s7=4e3;function a7({children:t}){const[s,o]=y.useState([]),r=y.useRef(0),c=y.useCallback(u=>{o(p=>p.filter(m=>m.id!==u))},[]),d=y.useCallback((u,p="info",m=s7)=>{const g=`toast-${++r.current}`;o(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return i.jsx(D1.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function Sn(){const t=y.useContext(D1);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const em="grackle-theme",R1="grackle-prefer-system",M1="(prefers-color-scheme: dark)";let Gr=[],Qc;function _p(){Qc=void 0;for(const t of Gr)t()}function tm(){return typeof window>"u"?!1:window.matchMedia(M1).matches}function Wr(){if(typeof localStorage>"u")return qb;try{const t=localStorage.getItem(em);if(t!==null&&C1.has(t))return t}catch{}return qb}function pd(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(R1)==="true"}catch{return!1}}function nm(t){return Cd.find(s=>s.variantLightId===t||s.variantDarkId===t)}function I1(t,s){const o=Qp(t);if(o!=null&&o.variantDarkId)return s&&o.variantLightId?tm()?o.variantDarkId:o.variantLightId:o.variantDarkId;if(o!=null&&o.hidden&&s){const r=nm(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return tm()?r.variantDarkId:r.variantLightId}return t}function To(t,s,o=!1){o&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=I1(t,s),o&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&To(Wr(),pd());function i7(){return Qc===void 0&&(Qc={themeId:Wr(),systemDark:tm(),preferSystem:pd()}),Qc}function o7(t){return Gr=[...Gr,t],()=>{Gr=Gr.filter(s=>s!==t)}}function r7(){const t=y.useSyncExternalStore(o7,i7),{themeId:s,preferSystem:o}=t,r=I1(s,o),c=y.useCallback(u=>{if(C1.has(u)){try{localStorage.setItem(em,u)}catch{}To(u,pd(),!0),_p()}},[]),d=y.useCallback(u=>{try{localStorage.setItem(R1,u?"true":"false")}catch{}if(u){const p=Wr(),m=Qp(p);if(m!=null&&m.hidden){const g=nm(p);if(g)try{localStorage.setItem(em,g.id)}catch{}}}To(Wr(),u,!0),_p()},[]);return y.useEffect(()=>{To(s,o)},[s,o]),y.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(M1),p=()=>{const m=Wr(),g=pd();if(g){const v=Qp(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&To(m,g),v!=null&&v.hidden){const b=nm(m);b!=null&&b.variantDarkId&&b.variantLightId&&To(m,g)}}_p()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:o,setPreferSystem:d}}const O1=y.createContext(void 0);function l7({children:t}){const s=r7();return i.jsx(O1.Provider,{value:s,children:t})}function B1(){const t=y.useContext(O1);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const L1=y.createContext(void 0),z1=y.createContext(void 0);function c7({children:t}){const[s,o]=y.useState(void 0),r=y.useCallback(c=>{o(c)},[]);return i.jsx(z1.Provider,{value:r,children:i.jsx(L1.Provider,{value:s,children:t})})}function d7(){return y.useContext(L1)}function u7(){const t=y.useContext(z1);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const th=y.createContext(void 0);function mt(){const t=y.useContext(th);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function $1(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function U1(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function f7(t){return $1(t)&&typeof t.sessionId=="string"&&typeof t.eventType=="string"&&typeof t.timestamp=="string"&&typeof t.content=="string"&&(t.raw===void 0||typeof t.raw=="string")}const p7=new Set(["off","subscription","api_key"]),$c=new Set(["off","on"]);function m7(t){return $1(t)&&p7.has(t.claude)&&$c.has(t.github)&&$c.has(t.copilot)&&$c.has(t.codex)&&$c.has(t.goose)}function P1(t){switch(t){case"waiting_input":return"idle";case"completed":return"stopped";case"killed":return"stopped";case"failed":return"stopped";case"interrupted":return"stopped";case"terminated":return"stopped";default:return t}}function H1(t){switch(t){case"completed":return"completed";case"killed":return"killed";case"failed":return"interrupted";case"interrupted":return"interrupted";case"terminated":return"terminated";default:return}}const So=5e3;function h7(t,s){const o=[];let r=t;const c=new Set;for(;r&&s.has(r)&&!c.has(r);){c.add(r);const d=s.get(r);o.unshift(d),r=d.parentTaskId||void 0}return o}const na={label:"Home",url:Ni};function g7(t){return t?[na,{label:"Settings",url:Do},{label:t,url:void 0}]:[na,{label:"Settings",url:void 0}]}const nh={label:"Environments",url:Ro};function v7(){return[na,{label:"Environments",url:void 0}]}function y7(){return[na,{label:"New Chat",url:void 0}]}function b7(t){return[na,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function x7(t,s,o,r){const c=o.find(u=>u.id===t),d=r.find(u=>u.id===s);return[na,nh,{label:(d==null?void 0:d.displayName)??"Environment",url:ji(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function _7(t,s,o,r,c){const d=h7(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?o.find(S=>S.id===p):void 0,g=s??(m==null?void 0:m.environmentId),v=g?r.find(S=>S.id===g):void 0,b=[na];v&&g&&(b.push(nh),b.push({label:v.displayName,url:ji(g)})),m&&g&&b.push({label:m.name,url:$a(m.id,g)});for(let S=0;S<d.length-1;S++)b.push({label:d[S].title,url:On(d[S].id,void 0,p,g)});const x=d[d.length-1];return b.push({label:(x==null?void 0:x.title)??t,url:void 0}),b}const k7={label:"Findings",url:_d};function S7(){return[na,{label:"Findings",url:void 0}]}function V1(t,s,o,r,c){const d=[na];if(s&&o){const u=r.find(m=>m.id===s),p=c.find(m=>m.id===o);d.push(nh),p&&d.push({label:p.displayName,url:ji(o)}),u&&d.push({label:u.name,url:$a(s,o)}),d.push({label:"Findings",url:dN(s,o)})}else d.push(k7);return d.push({label:t,url:void 0}),d}function sh(t){const s=[];for(const o of t){const r=s[s.length-1];o.eventType==="text"&&(r==null?void 0:r.eventType)==="text"?s[s.length-1]={...r,content:r.content+o.content}:s.push(o)}return s}function Uc(t){if(typeof t.id=="string")return t.id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const o=t.item;if(o&&typeof o.id=="string")return o.id}function T7(t){if(typeof t.tool_use_id=="string")return t.tool_use_id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const o=t.item;if(o&&typeof o.id=="string")return o.id}function ah(t){const s=new Map;for(const v of t)if(v.raw)try{s.set(v,JSON.parse(v.raw))}catch{}const o=new Map;for(const v of t){if(v.eventType!=="tool_use")continue;const b=s.get(v),x=b?Uc(b):void 0;if(x)try{const S=JSON.parse(v.content);o.set(x,{tool:S.tool,args:S.args})}catch{}}const r=new Set,c=new Set,d=t.map((v,b)=>{if(v.eventType!=="tool_result")return v;const x=s.get(v),S=x?T7(x):void 0;if(!S)return v;const k=o.get(S);if(!k)return v;r.add(S),c.add(b);let w;const N=v.content.trim();if(N.startsWith("{"))try{const T=JSON.parse(N);typeof T.detailedContent=="string"&&(w=T.detailedContent)}catch{}return{...v,toolUseCtx:{...k,detailedResult:w}}}),u=[];for(let v=0;v<d.length;v++){if(d[v].eventType!=="tool_use")continue;const b=s.get(d[v]),x=b?Uc(b):void 0;x&&r.has(x)||u.push(v)}const p=[];for(let v=0;v<d.length;v++)d[v].eventType!=="tool_result"||c.has(v)||p.push(v);let m=0;for(const v of u){for(;m<p.length&&p[m]<v;)m++;if(m>=p.length)break;const b=p[m];if(b!==v+1)continue;const x=d[v],S=d[b];let k;try{const w=JSON.parse(x.content);k={tool:w.tool,args:w.args}}catch{}if(k){let w;const N=S.content.trim();if(N.startsWith("{"))try{const D=JSON.parse(N);typeof D.detailedContent=="string"&&(w=D.detailedContent)}catch{}d[b]={...S,toolUseCtx:{...k,detailedResult:w}},c.add(b);const T=s.get(x),C=T?Uc(T):void 0;C?r.add(C):(r.add(`__seq_${v}`),s.set(x,{...T??{},__seqId:`__seq_${v}`})),m++}}const g=d.filter(v=>{if(v.eventType!=="tool_use")return!0;const b=s.get(v);if(!b)return!0;const x=Uc(b);if(x&&r.has(x))return!1;const S=b.__seqId;return!(S&&r.has(S))});for(let v=0;v<g.length;v++){if(g[v].eventType!=="tool_use")continue;let b=!1;for(let x=v+1;x<g.length;x++)if(g[x].eventType!=="tool_use"){b=!0;break}b&&(g[v]={...g[v],settled:!0})}return g}function w7(t,s,o){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=q1(s),d=s.filter(m=>sm(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||sm(m,c)).length,p=o.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function q1(t){const s=new Map;for(const o of t)s.set(o.id,o.status);return s}function sm(t,s){return t.dependsOn.some(o=>s.get(o)!=="complete")}function j7(t,s){var u;const o=new Map;for(const p of s)o.set(p.id,p);const r=q1(t),c=[];for(const p of t){const m=p.workspaceId?((u=o.get(p.workspaceId))==null?void 0:u.name)??"Unknown":"Unknown";p.status==="failed"?c.push({task:p,reason:"failed",workspaceName:m}):sm(p,r)?c.push({task:p,reason:"blocked",workspaceName:m}):p.status==="paused"&&c.push({task:p,reason:"paused",workspaceName:m})}const d={failed:0,blocked:1,paused:2};return c.sort((p,m)=>(d[p.reason]??3)-(d[m.reason]??3)),c}function N7(t,s){const o=new Map;for(const r of s)o.set(r.id,r);return t.filter(r=>r.status==="running"||r.status==="idle"||r.status==="waiting").map(r=>{var c;return{session:r,environmentName:((c=o.get(r.environmentId))==null?void 0:c.displayName)??"Unknown"}})}function C7(t,s,o){const r=new Map;for(const c of s){if(!c.workspaceId)continue;let d=r.get(c.workspaceId);d||(d={totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0},r.set(c.workspaceId,d)),d.totalTasks+=1,c.status==="complete"?d.completedTasks+=1:c.status==="working"?d.workingTasks+=1:c.status==="failed"&&(d.failedTasks+=1)}return t.map(c=>{const d=r.get(c.id)??{totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0};return{workspace:c,totalTasks:d.totalTasks,completedTasks:d.completedTasks,workingTasks:d.workingTasks,failedTasks:d.failedTasks}})}const ks=[{id:"kn-auth-flow",label:"Authentication Flow",kind:"knowledge",category:"concept",content:"The application uses JWT Bearer tokens for stateless authentication. Access tokens expire after 24h. Refresh tokens are stored in the database and rotated on use. The auth middleware verifies tokens and attaches the decoded payload to req.user.",tags:["auth","jwt","security"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:30:00Z",updatedAt:"2026-02-27T08:15:00Z",val:5},{id:"kn-db-schema",label:"Database Schema",kind:"knowledge",category:"concept",content:"PostgreSQL database with tables: users, sessions, refresh_tokens, audit_log. Uses UUID primary keys, TIMESTAMPTZ for all timestamps, and JSONB for flexible metadata columns. Connection pooling via pg-pool with per-tenant isolation.",tags:["database","postgres","schema"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:00:00Z",updatedAt:"2026-02-26T22:45:00Z",val:4},{id:"kn-error-handling",label:"Error Response Pattern",kind:"knowledge",category:"concept",content:"All API errors follow the shape { error: string, code: string, details?: unknown }. HTTP status codes map to: 400 (validation), 401 (unauthenticated), 403 (forbidden), 404 (not found), 409 (conflict), 429 (rate limited), 500 (internal).",tags:["api","errors","patterns"],workspaceId:"proj-alpha",createdAt:"2026-02-27T08:17:00Z",updatedAt:"2026-02-27T08:17:00Z",val:3},{id:"kn-rate-limiting",label:"Rate Limiting Strategy",kind:"knowledge",category:"concept",content:"Token-bucket algorithm with in-memory state per client IP. Default rate: 100 requests/minute, burst: 20. Returns 429 with Retry-After header. Redis adapter available for multi-instance deployments.",tags:["api","rate-limiting","infrastructure"],workspaceId:"proj-alpha",createdAt:"2026-02-27T09:00:00Z",updatedAt:"2026-02-27T09:00:00Z",val:2},{id:"kn-etl-pipeline",label:"ETL Pipeline Architecture",kind:"knowledge",category:"concept",content:"Data pipelines follow an Extract-Transform-Load pattern with pluggable stages. Each stage reads from a source (Postgres, S3, API), transforms via configurable mappers, and loads into a target (Parquet, BigQuery, S3). Incremental loads use high-watermark tracking.",tags:["etl","pipeline","architecture"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:00:00Z",updatedAt:"2026-02-27T09:05:00Z",val:4},{id:"kn-parquet-format",label:"Parquet Output Format",kind:"knowledge",category:"concept",content:"Parquet files are written with row-group buffering (configurable batch size, default 10000 rows). Supports Snappy, ZSTD, and GZIP compression. Schema is derived from the internal column type system using Arrow type mapping.",tags:["parquet","data-format","compression"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:05:00Z",updatedAt:"2026-02-26T08:15:00Z",val:3},{id:"kn-jwt-over-session",label:"JWT over Session Auth",kind:"knowledge",category:"decision",content:"Chose JWT tokens over server-side sessions for stateless auth. Rationale: (1) no session store needed, (2) works across microservices without shared state, (3) supports mobile clients natively. Trade-off: tokens can't be revoked instantly (mitigated by short expiry + refresh rotation).",tags:["auth","decision","jwt"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:00:00Z",updatedAt:"2026-02-25T10:00:00Z",val:3},{id:"kn-pg-pool-decision",label:"pg-pool over Knex",kind:"knowledge",category:"decision",content:"Chose pg-pool over Knex for connection pooling. pg-pool gives direct control over idle timeout, max connections, and health check queries. Knex wraps pg-pool and adds query-building overhead we don't need since we write raw SQL with parameterized queries.",tags:["database","decision","postgres"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:30:00Z",updatedAt:"2026-02-23T11:30:00Z",val:2},{id:"kn-watermark-decision",label:"Local Watermark Storage",kind:"knowledge",category:"decision",content:"Currently using local SQLite for watermark storage. This works for single-worker pipelines but needs to move to a shared store (Redis or Postgres) for production multi-worker scenarios. Tracked as a follow-up task.",tags:["pipeline","decision","watermarks"],workspaceId:"proj-beta",createdAt:"2026-02-27T09:05:00Z",updatedAt:"2026-02-27T09:05:00Z",val:2},{id:"kn-jwt-middleware",label:"JWT Verify Middleware",kind:"knowledge",category:"snippet",content:`\`\`\`typescript
|
|
275
275
|
export function verifyToken(req: Request, res: Response, next: NextFunction): void {
|
|
276
276
|
const header = req.headers.authorization;
|
|
277
277
|
if (!header?.startsWith("Bearer ")) {
|
|
@@ -294,7 +294,7 @@ CREATE TABLE audit_log (
|
|
|
294
294
|
ip_address INET,
|
|
295
295
|
created_at TIMESTAMPTZ DEFAULT now()
|
|
296
296
|
);
|
|
297
|
-
\`\`\``,tags:["database","audit","schema","sql"],workspaceId:"proj-alpha",createdAt:"2026-02-26T22:45:15Z",updatedAt:"2026-02-26T22:45:15Z",val:2},{id:"kn-n1-query",label:"N+1 Query in User List",kind:"knowledge",category:"insight",content:"GET /api/users performs a separate query for each user's role metadata, resulting in N+1 queries. For 500 users this adds ~2 seconds of latency. Solution: use a JOIN or batch lookup to fetch all role data in a single query.",tags:["performance","database","n+1"],workspaceId:"proj-alpha",createdAt:"2026-02-22T09:30:00Z",updatedAt:"2026-02-22T09:30:00Z",val:2},{id:"kn-session-race",label:"Session Cleanup Race Condition",kind:"knowledge",category:"insight",content:"When two concurrent requests hit /api/logout, the second call throws a 500 because the session row has already been deleted. Fix: use DELETE ... RETURNING or add IF EXISTS guard to make the operation idempotent.",tags:["bug","concurrency","sessions"],workspaceId:"proj-alpha",createdAt:"2026-02-26T22:50:00Z",updatedAt:"2026-02-26T22:50:00Z",val:2},{id:"kn-ref-task-001",label:"JWT Auth Task",kind:"reference",sourceType:"task",sourceId:"task-001",content:"Implement JWT authentication across all protected routes, replacing session-based auth.",workspaceId:"proj-alpha",createdAt:"2026-02-25T10:00:00Z",updatedAt:"2026-02-27T08:15:00Z",val:3},{id:"kn-ref-task-006",label:"Parquet Export Task",kind:"reference",sourceType:"task",sourceId:"task-006",content:"Add Parquet export support for pipeline outputs, enabling downstream Spark consumption.",workspaceId:"proj-beta",createdAt:"2026-02-26T08:00:00Z",updatedAt:"2026-02-27T09:00:00Z",val:3},{id:"kn-ref-sess-001",label:"Auth Middleware Session",kind:"reference",sourceType:"session",sourceId:"sess-001",content:"Active session implementing JWT auth middleware, rewrote auth.ts, login.ts, and test suite.",workspaceId:"proj-alpha",createdAt:"2026-02-27T08:15:00Z",updatedAt:"2026-02-27T08:15:42Z",val:2}],Ra=[{source:"kn-auth-flow",target:"kn-jwt-over-session",type:"decided_by"},{source:"kn-auth-flow",target:"kn-jwt-middleware",type:"implemented_by"},{source:"kn-auth-flow",target:"kn-ref-task-001",type:"tracked_in"},{source:"kn-auth-flow",target:"kn-error-handling",type:"relates_to"},{source:"kn-jwt-over-session",target:"kn-ref-task-001",type:"motivated_by"},{source:"kn-db-schema",target:"kn-pg-pool-decision",type:"decided_by"},{source:"kn-db-schema",target:"kn-audit-schema",type:"contains"},{source:"kn-db-schema",target:"kn-n1-query",type:"affected_by"},{source:"kn-db-schema",target:"kn-session-race",type:"affected_by"},{source:"kn-rate-limiting",target:"kn-error-handling",type:"relates_to"},{source:"kn-rate-limiting",target:"kn-auth-flow",type:"depends_on"},{source:"kn-etl-pipeline",target:"kn-parquet-format",type:"outputs_to"},{source:"kn-etl-pipeline",target:"kn-watermark-decision",type:"decided_by"},{source:"kn-etl-pipeline",target:"kn-ref-task-006",type:"tracked_in"},{source:"kn-parquet-format",target:"kn-ref-task-006",type:"tracked_in"},{source:"kn-watermark-decision",target:"kn-etl-pipeline",type:"relates_to"},{source:"kn-ref-task-001",target:"kn-ref-sess-001",type:"has_session"},{source:"kn-jwt-middleware",target:"kn-ref-sess-001",type:"created_in"},{source:"kn-audit-schema",target:"kn-db-schema",type:"part_of"}],E7=new Map(ks.map(t=>[t.id,t]));function kp(t){const s=E7.get(t);if(!s)throw new Error(`MOCK_KNOWLEDGE_NODES is missing node "${t}"`);return s}const Zb={"kn-auth-flow":{node:kp("kn-auth-flow"),edges:[{fromId:"kn-auth-flow",toId:"kn-jwt-over-session",type:"decided_by"},{fromId:"kn-auth-flow",toId:"kn-jwt-middleware",type:"implemented_by"},{fromId:"kn-auth-flow",toId:"kn-ref-task-001",type:"tracked_in"},{fromId:"kn-auth-flow",toId:"kn-error-handling",type:"relates_to"},{fromId:"kn-rate-limiting",toId:"kn-auth-flow",type:"depends_on"}]},"kn-db-schema":{node:kp("kn-db-schema"),edges:[{fromId:"kn-db-schema",toId:"kn-pg-pool-decision",type:"decided_by"},{fromId:"kn-db-schema",toId:"kn-audit-schema",type:"contains"},{fromId:"kn-db-schema",toId:"kn-n1-query",type:"affected_by"},{fromId:"kn-db-schema",toId:"kn-session-race",type:"affected_by"},{fromId:"kn-audit-schema",toId:"kn-db-schema",type:"part_of"}]},"kn-etl-pipeline":{node:kp("kn-etl-pipeline"),edges:[{fromId:"kn-etl-pipeline",toId:"kn-parquet-format",type:"outputs_to"},{fromId:"kn-etl-pipeline",toId:"kn-watermark-decision",type:"decided_by"},{fromId:"kn-etl-pipeline",toId:"kn-ref-task-006",type:"tracked_in"},{fromId:"kn-watermark-decision",toId:"kn-etl-pipeline",type:"relates_to"}]}},A7=[{id:"env-local-01",displayName:"Local Dev",adapterType:"local",adapterConfig:"{}",status:"connected",bootstrapped:!0},{id:"env-docker-01",displayName:"Docker Sandbox",adapterType:"docker",adapterConfig:'{"image":"node:20"}',status:"connected",bootstrapped:!0},{id:"env-cs-01",displayName:"GitHub Codespace",adapterType:"codespace",adapterConfig:'{"codespaceName":"my-codespace"}',status:"connected",bootstrapped:!0},{id:"env-remote-01",displayName:"Staging (SSH)",adapterType:"ssh",adapterConfig:'{"host":"192.168.1.10","user":"deploy","sshPort":22}',status:"disconnected",bootstrapped:!1},{id:"error-env",displayName:"Error Test",adapterType:"local",adapterConfig:"{}",status:"connected",bootstrapped:!0}],D7=[{id:"sess-001-prev",environmentId:"env-local-01",runtime:"claude-code",status:"stopped",endReason:"interrupted",prompt:"Implement auth middleware",startedAt:"2026-02-26T14:00:00Z",endedAt:"2026-02-26T15:12:00Z",error:"Context window exceeded before completing implementation",inputTokens:84200,outputTokens:12750,
|
|
297
|
+
\`\`\``,tags:["database","audit","schema","sql"],workspaceId:"proj-alpha",createdAt:"2026-02-26T22:45:15Z",updatedAt:"2026-02-26T22:45:15Z",val:2},{id:"kn-n1-query",label:"N+1 Query in User List",kind:"knowledge",category:"insight",content:"GET /api/users performs a separate query for each user's role metadata, resulting in N+1 queries. For 500 users this adds ~2 seconds of latency. Solution: use a JOIN or batch lookup to fetch all role data in a single query.",tags:["performance","database","n+1"],workspaceId:"proj-alpha",createdAt:"2026-02-22T09:30:00Z",updatedAt:"2026-02-22T09:30:00Z",val:2},{id:"kn-session-race",label:"Session Cleanup Race Condition",kind:"knowledge",category:"insight",content:"When two concurrent requests hit /api/logout, the second call throws a 500 because the session row has already been deleted. Fix: use DELETE ... RETURNING or add IF EXISTS guard to make the operation idempotent.",tags:["bug","concurrency","sessions"],workspaceId:"proj-alpha",createdAt:"2026-02-26T22:50:00Z",updatedAt:"2026-02-26T22:50:00Z",val:2},{id:"kn-ref-task-001",label:"JWT Auth Task",kind:"reference",sourceType:"task",sourceId:"task-001",content:"Implement JWT authentication across all protected routes, replacing session-based auth.",workspaceId:"proj-alpha",createdAt:"2026-02-25T10:00:00Z",updatedAt:"2026-02-27T08:15:00Z",val:3},{id:"kn-ref-task-006",label:"Parquet Export Task",kind:"reference",sourceType:"task",sourceId:"task-006",content:"Add Parquet export support for pipeline outputs, enabling downstream Spark consumption.",workspaceId:"proj-beta",createdAt:"2026-02-26T08:00:00Z",updatedAt:"2026-02-27T09:00:00Z",val:3},{id:"kn-ref-sess-001",label:"Auth Middleware Session",kind:"reference",sourceType:"session",sourceId:"sess-001",content:"Active session implementing JWT auth middleware, rewrote auth.ts, login.ts, and test suite.",workspaceId:"proj-alpha",createdAt:"2026-02-27T08:15:00Z",updatedAt:"2026-02-27T08:15:42Z",val:2}],Ra=[{source:"kn-auth-flow",target:"kn-jwt-over-session",type:"decided_by"},{source:"kn-auth-flow",target:"kn-jwt-middleware",type:"implemented_by"},{source:"kn-auth-flow",target:"kn-ref-task-001",type:"tracked_in"},{source:"kn-auth-flow",target:"kn-error-handling",type:"relates_to"},{source:"kn-jwt-over-session",target:"kn-ref-task-001",type:"motivated_by"},{source:"kn-db-schema",target:"kn-pg-pool-decision",type:"decided_by"},{source:"kn-db-schema",target:"kn-audit-schema",type:"contains"},{source:"kn-db-schema",target:"kn-n1-query",type:"affected_by"},{source:"kn-db-schema",target:"kn-session-race",type:"affected_by"},{source:"kn-rate-limiting",target:"kn-error-handling",type:"relates_to"},{source:"kn-rate-limiting",target:"kn-auth-flow",type:"depends_on"},{source:"kn-etl-pipeline",target:"kn-parquet-format",type:"outputs_to"},{source:"kn-etl-pipeline",target:"kn-watermark-decision",type:"decided_by"},{source:"kn-etl-pipeline",target:"kn-ref-task-006",type:"tracked_in"},{source:"kn-parquet-format",target:"kn-ref-task-006",type:"tracked_in"},{source:"kn-watermark-decision",target:"kn-etl-pipeline",type:"relates_to"},{source:"kn-ref-task-001",target:"kn-ref-sess-001",type:"has_session"},{source:"kn-jwt-middleware",target:"kn-ref-sess-001",type:"created_in"},{source:"kn-audit-schema",target:"kn-db-schema",type:"part_of"}],E7=new Map(ks.map(t=>[t.id,t]));function kp(t){const s=E7.get(t);if(!s)throw new Error(`MOCK_KNOWLEDGE_NODES is missing node "${t}"`);return s}const Zb={"kn-auth-flow":{node:kp("kn-auth-flow"),edges:[{fromId:"kn-auth-flow",toId:"kn-jwt-over-session",type:"decided_by"},{fromId:"kn-auth-flow",toId:"kn-jwt-middleware",type:"implemented_by"},{fromId:"kn-auth-flow",toId:"kn-ref-task-001",type:"tracked_in"},{fromId:"kn-auth-flow",toId:"kn-error-handling",type:"relates_to"},{fromId:"kn-rate-limiting",toId:"kn-auth-flow",type:"depends_on"}]},"kn-db-schema":{node:kp("kn-db-schema"),edges:[{fromId:"kn-db-schema",toId:"kn-pg-pool-decision",type:"decided_by"},{fromId:"kn-db-schema",toId:"kn-audit-schema",type:"contains"},{fromId:"kn-db-schema",toId:"kn-n1-query",type:"affected_by"},{fromId:"kn-db-schema",toId:"kn-session-race",type:"affected_by"},{fromId:"kn-audit-schema",toId:"kn-db-schema",type:"part_of"}]},"kn-etl-pipeline":{node:kp("kn-etl-pipeline"),edges:[{fromId:"kn-etl-pipeline",toId:"kn-parquet-format",type:"outputs_to"},{fromId:"kn-etl-pipeline",toId:"kn-watermark-decision",type:"decided_by"},{fromId:"kn-etl-pipeline",toId:"kn-ref-task-006",type:"tracked_in"},{fromId:"kn-watermark-decision",toId:"kn-etl-pipeline",type:"relates_to"}]}},A7=[{id:"env-local-01",displayName:"Local Dev",adapterType:"local",adapterConfig:"{}",status:"connected",bootstrapped:!0},{id:"env-docker-01",displayName:"Docker Sandbox",adapterType:"docker",adapterConfig:'{"image":"node:20"}',status:"connected",bootstrapped:!0},{id:"env-cs-01",displayName:"GitHub Codespace",adapterType:"codespace",adapterConfig:'{"codespaceName":"my-codespace"}',status:"connected",bootstrapped:!0},{id:"env-remote-01",displayName:"Staging (SSH)",adapterType:"ssh",adapterConfig:'{"host":"192.168.1.10","user":"deploy","sshPort":22}',status:"disconnected",bootstrapped:!1},{id:"error-env",displayName:"Error Test",adapterType:"local",adapterConfig:"{}",status:"connected",bootstrapped:!0}],D7=[{id:"sess-001-prev",environmentId:"env-local-01",runtime:"claude-code",status:"stopped",endReason:"interrupted",prompt:"Implement auth middleware",startedAt:"2026-02-26T14:00:00Z",endedAt:"2026-02-26T15:12:00Z",error:"Context window exceeded before completing implementation",inputTokens:84200,outputTokens:12750,costMillicents:41e3},{id:"sess-001",environmentId:"env-local-01",runtime:"claude-code",status:"running",prompt:"Refactor the authentication middleware to use JWT tokens",startedAt:"2026-02-27T08:15:00Z",inputTokens:42600,outputTokens:8100,costMillicents:22e3},{id:"sess-002",environmentId:"env-docker-01",runtime:"copilot",status:"stopped",endReason:"completed",prompt:"Write unit tests for the user registration endpoint",startedAt:"2026-02-27T07:30:00Z",endedAt:"2026-02-27T07:33:00Z",inputTokens:31400,outputTokens:9800,costMillicents:18e3},{id:"sess-003",environmentId:"env-local-01",runtime:"claude-code",status:"stopped",endReason:"interrupted",prompt:"Migrate database schema to add audit_log table",startedAt:"2026-02-26T22:45:00Z",endedAt:"2026-02-26T23:10:00Z",inputTokens:56300,outputTokens:14200,costMillicents:31e3},{id:"sess-004",environmentId:"env-docker-01",runtime:"codex",status:"running",prompt:"Implement rate limiting for the public API",startedAt:"2026-02-27T09:00:00Z",inputTokens:18900,outputTokens:4500,costMillicents:1e4},{id:"sess-005",environmentId:"env-cs-01",runtime:"claude-code",status:"suspended",prompt:"Refactor database connection pooling for multi-tenant isolation",startedAt:"2026-02-27T06:00:00Z",inputTokens:67800,outputTokens:19300,costMillicents:38e3}],R7=[{sessionId:"sess-001-prev",eventType:"status",timestamp:"2026-02-26T14:00:01Z",content:"running"},{sessionId:"sess-001-prev",eventType:"system",timestamp:"2026-02-26T14:00:02Z",content:`You are a senior backend engineer. Focus on security best practices and thorough testing.
|
|
298
298
|
Project: acme/alpha — Node.js + Express REST API
|
|
299
299
|
Task: Implement auth middleware using JWT tokens`,raw:JSON.stringify({systemContext:!0})},{sessionId:"sess-001-prev",eventType:"text",timestamp:"2026-02-26T14:00:05Z",content:"I'll start by reading the current authentication middleware to understand what needs to change."},{sessionId:"sess-001-prev",eventType:"tool_use",timestamp:"2026-02-26T14:00:06Z",content:JSON.stringify({tool:"Read",args:{file_path:"src/middleware/auth.ts"}}),raw:JSON.stringify({id:"tu-prev-001",type:"tool_use"})},{sessionId:"sess-001-prev",eventType:"tool_result",timestamp:"2026-02-26T14:00:07Z",content:`import session from "express-session";
|
|
300
300
|
import type { Request, Response, NextFunction } from "express";
|
|
@@ -308,7 +308,7 @@ export function requireAuth(req: Request, res: Response, next: NextFunction): vo
|
|
|
308
308
|
}`,raw:JSON.stringify({tool_use_id:"tu-prev-001"})},{sessionId:"sess-001-prev",eventType:"text",timestamp:"2026-02-26T14:00:10Z",content:"The current auth uses express-session with server-side session storage. Let me find all files that depend on this pattern."},{sessionId:"sess-001-prev",eventType:"tool_use",timestamp:"2026-02-26T14:00:11Z",content:JSON.stringify({tool:"Grep",args:{pattern:"req\\.session",path:"src/"}}),raw:JSON.stringify({id:"tu-prev-002",type:"tool_use"})},{sessionId:"sess-001-prev",eventType:"tool_result",timestamp:"2026-02-26T14:00:12Z",content:`src/middleware/auth.ts:4: if (!req.session?.userId) {
|
|
309
309
|
src/routes/login.ts:18: req.session.userId = user.id;
|
|
310
310
|
src/routes/login.ts:19: req.session.role = user.role;
|
|
311
|
-
src/routes/protected.ts:7: const userId = req.session.userId;`,raw:JSON.stringify({tool_use_id:"tu-prev-002"})},{sessionId:"sess-001-prev",eventType:"usage",timestamp:"2026-02-26T14:30:00Z",content:JSON.stringify({input_tokens:42100,output_tokens:6350,
|
|
311
|
+
src/routes/protected.ts:7: const userId = req.session.userId;`,raw:JSON.stringify({tool_use_id:"tu-prev-002"})},{sessionId:"sess-001-prev",eventType:"usage",timestamp:"2026-02-26T14:30:00Z",content:JSON.stringify({input_tokens:42100,output_tokens:6350,cost_millicents:21e3})},{sessionId:"sess-001-prev",eventType:"text",timestamp:"2026-02-26T14:30:02Z",content:"Found 3 files using session-based auth. Now let me read the login route and the protected route to understand the full flow before making changes."},{sessionId:"sess-001-prev",eventType:"tool_use",timestamp:"2026-02-26T14:30:03Z",content:JSON.stringify({tool:"Read",args:{file_path:"src/routes/login.ts"}}),raw:JSON.stringify({id:"tu-prev-003",type:"tool_use"})},{sessionId:"sess-001-prev",eventType:"tool_result",timestamp:"2026-02-26T14:30:04Z",content:`import { Router } from "express";
|
|
312
312
|
import bcrypt from "bcrypt";
|
|
313
313
|
import { db } from "../db.js";
|
|
314
314
|
|
|
@@ -446,7 +446,7 @@ describe("verifyToken", () => {
|
|
|
446
446
|
PASS src/middleware/__tests__/auth.test.ts
|
|
447
447
|
|
|
448
448
|
Test Suites: 3 passed, 3 total
|
|
449
|
-
Tests: 14 passed, 14 total`,raw:JSON.stringify({tool_use_id:"tu-001-08"})},{sessionId:"sess-001",eventType:"usage",timestamp:"2026-02-27T08:15:41Z",content:JSON.stringify({input_tokens:42600,output_tokens:8100,
|
|
449
|
+
Tests: 14 passed, 14 total`,raw:JSON.stringify({tool_use_id:"tu-001-08"})},{sessionId:"sess-001",eventType:"usage",timestamp:"2026-02-27T08:15:41Z",content:JSON.stringify({input_tokens:42600,output_tokens:8100,cost_millicents:22e3})},{sessionId:"sess-001",eventType:"text",timestamp:"2026-02-27T08:15:42Z",content:`All 14 tests pass. Here's a summary of the changes:
|
|
450
450
|
|
|
451
451
|
### Changes made
|
|
452
452
|
|
|
@@ -513,7 +513,7 @@ export default router;`,raw:JSON.stringify({tool_use_id:"tu-002-01"})},{sessionI
|
|
|
513
513
|
✓ should reject duplicate email (12ms)
|
|
514
514
|
✓ should sanitize HTML in name field (6ms)
|
|
515
515
|
|
|
516
|
-
Tests: 8 passed, 8 total`,raw:JSON.stringify({tool_use_id:"tu-002-03"})},{sessionId:"sess-002",eventType:"usage",timestamp:"2026-02-27T07:32:00Z",content:JSON.stringify({input_tokens:31400,output_tokens:9800,
|
|
516
|
+
Tests: 8 passed, 8 total`,raw:JSON.stringify({tool_use_id:"tu-002-03"})},{sessionId:"sess-002",eventType:"usage",timestamp:"2026-02-27T07:32:00Z",content:JSON.stringify({input_tokens:31400,output_tokens:9800,cost_millicents:18e3})},{sessionId:"sess-002",eventType:"text",timestamp:"2026-02-27T07:32:30Z",content:"All 8 test cases pass. Created `src/routes/__tests__/register.test.ts` with comprehensive coverage for the registration endpoint including input validation, duplicate detection, and security edge cases."},{sessionId:"sess-002",eventType:"status",timestamp:"2026-02-27T07:33:00Z",content:"completed"},{sessionId:"sess-003",eventType:"status",timestamp:"2026-02-26T22:45:01Z",content:"running"},{sessionId:"sess-003",eventType:"system",timestamp:"2026-02-26T22:45:02Z",content:`You are a database engineer. Focus on safe migrations, zero-downtime deployments, and data integrity.
|
|
517
517
|
Project: acme/alpha — Node.js + Express + PostgreSQL
|
|
518
518
|
Task: Add audit_log table and migrate schema`,raw:JSON.stringify({systemContext:!0})},{sessionId:"sess-003",eventType:"text",timestamp:"2026-02-26T22:45:05Z",content:"I need to add an `audit_log` table for tracking all write operations. Let me review the current schema first."},{sessionId:"sess-003",eventType:"tool_use",timestamp:"2026-02-26T22:45:06Z",content:JSON.stringify({tool:"Read",args:{file_path:"migrations/001_initial.sql"}}),raw:JSON.stringify({id:"tu-003-01",type:"tool_use"})},{sessionId:"sess-003",eventType:"tool_result",timestamp:"2026-02-26T22:45:07Z",content:`CREATE TABLE users (
|
|
519
519
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
@@ -566,7 +566,7 @@ COMMIT;
|
|
|
566
566
|
- 3 indexes on audit_log
|
|
567
567
|
|
|
568
568
|
WARNING: CREATE INDEX CONCURRENTLY cannot run inside a transaction block.
|
|
569
|
-
Please split this into a separate migration step.`,raw:JSON.stringify({tool_use_id:"tu-003-03",is_error:!0})},{sessionId:"sess-003",eventType:"text",timestamp:"2026-02-26T22:46:15Z",content:"Good catch from the dry run! `CREATE INDEX CONCURRENTLY` can't run inside a transaction. I need to split the migration into two files: one for the transactional DDL and another for the concurrent index creation."},{sessionId:"sess-003",eventType:"usage",timestamp:"2026-02-26T23:00:00Z",content:JSON.stringify({input_tokens:56300,output_tokens:14200,
|
|
569
|
+
Please split this into a separate migration step.`,raw:JSON.stringify({tool_use_id:"tu-003-03",is_error:!0})},{sessionId:"sess-003",eventType:"text",timestamp:"2026-02-26T22:46:15Z",content:"Good catch from the dry run! `CREATE INDEX CONCURRENTLY` can't run inside a transaction. I need to split the migration into two files: one for the transactional DDL and another for the concurrent index creation."},{sessionId:"sess-003",eventType:"usage",timestamp:"2026-02-26T23:00:00Z",content:JSON.stringify({input_tokens:56300,output_tokens:14200,cost_millicents:31e3})},{sessionId:"sess-003",eventType:"status",timestamp:"2026-02-26T23:10:00Z",content:"interrupted"},{sessionId:"sess-004",eventType:"status",timestamp:"2026-02-27T09:00:01Z",content:"running"},{sessionId:"sess-004",eventType:"system",timestamp:"2026-02-27T09:00:02Z",content:`You are a backend engineer specializing in API infrastructure.
|
|
570
570
|
Project: acme/data-pipeline — ETL pipelines for analytics
|
|
571
571
|
Task: Implement rate limiting for the public API using a token-bucket algorithm`,raw:JSON.stringify({systemContext:!0})},{sessionId:"sess-004",eventType:"text",timestamp:"2026-02-27T09:00:05Z",content:"I'll implement rate limiting using a token-bucket algorithm. Let me first survey the existing API infrastructure to find the right integration point."},{sessionId:"sess-004",eventType:"tool_use",timestamp:"2026-02-27T09:00:05.5Z",content:JSON.stringify({tool:"TodoWrite",args:{todos:[{content:"Survey middleware structure",activeForm:"Surveying middleware",status:"in_progress"},{content:"Implement token-bucket algorithm",activeForm:"Implementing token bucket",status:"pending"},{content:"Add rate limit middleware to app",activeForm:"Adding middleware",status:"pending"},{content:"Write tests for rate limiting",activeForm:"Writing tests",status:"pending"},{content:"Add Redis adapter for multi-instance",activeForm:"Adding Redis adapter",status:"pending"}]}})},{sessionId:"sess-004",eventType:"tool_use",timestamp:"2026-02-27T09:00:06Z",content:JSON.stringify({tool:"Glob",args:{pattern:"src/middleware/**/*.ts"}}),raw:JSON.stringify({id:"tu-004-01",type:"tool_use"})},{sessionId:"sess-004",eventType:"tool_result",timestamp:"2026-02-27T09:00:07Z",content:`src/middleware/cors.ts
|
|
572
572
|
src/middleware/error-handler.ts
|
|
@@ -603,7 +603,7 @@ src/services/analytics.ts:1:import { pool } from "../db/pool.js";`,raw:JSON.stri
|
|
|
603
603
|
2. Update all consumers to use \`getPool(tenantId)\` instead of the global pool
|
|
604
604
|
3. Add middleware to extract tenant ID from the request
|
|
605
605
|
|
|
606
|
-
This is a significant refactor. Let me start with the PoolManager class.`},{sessionId:"sess-005",eventType:"usage",timestamp:"2026-02-27T06:30:00Z",content:JSON.stringify({input_tokens:67800,output_tokens:19300,cost_usd:.38})},{sessionId:"sess-005",eventType:"status",timestamp:"2026-02-27T06:30:01Z",content:"suspended"}],M7=[{id:"proj-alpha",name:"Workspace Alpha",description:"Core platform API and authentication services",repoUrl:"https://github.com/acme/alpha",environmentId:"env-local-01",linkedEnvironmentIds:["env-docker-01"],status:"active",workingDirectory:"",useWorktrees:!0,defaultPersonaId:"",tokenBudget:0,costBudgetMillicents:0,createdAt:"2026-01-15T10:00:00Z",updatedAt:"2026-01-15T10:00:00Z"},{id:"proj-beta",name:"Data Pipeline",description:"ETL pipelines for analytics and reporting",repoUrl:"https://github.com/acme/data-pipeline",environmentId:"env-docker-01",linkedEnvironmentIds:[],status:"active",workingDirectory:"",useWorktrees:!0,defaultPersonaId:"",tokenBudget:0,costBudgetMillicents:0,createdAt:"2026-02-01T14:30:00Z",updatedAt:"2026-02-01T14:30:00Z"},{id:"proj-gamma",name:"Mobile App",description:"React Native cross-platform mobile application",repoUrl:"",environmentId:"env-local-01",linkedEnvironmentIds:[],status:"archived",workingDirectory:"",useWorktrees:!0,defaultPersonaId:"",tokenBudget:0,costBudgetMillicents:0,createdAt:"2025-11-20T09:00:00Z",updatedAt:"2025-11-20T09:00:00Z"}],I7=[{id:"task-001",workspaceId:"proj-alpha",title:"Implement JWT authentication",description:"Replace session-based auth with JWT tokens across all protected routes",status:"working",branch:"feat/jwt-auth",latestSessionId:"sess-001",dependsOn:[],reviewNotes:void 0,sortOrder:1,createdAt:"2026-02-25T10:00:00Z",parentTaskId:"",depth:0,childTaskIds:["task-001a","task-001b","task-001c"],canDecompose:!0,defaultPersonaId:"",workpad:JSON.stringify({status:"in_progress",summary:"Design and implement JWT-based authentication with access/refresh tokens, replacing session-based auth.",extra:{approach:"Replace express-session with JWT Bearer tokens. Access tokens expire in 24h, refresh tokens stored in DB.",files_changed:["src/middleware/auth.ts","src/routes/login.ts","src/routes/protected.ts"],decisions:["Chose jsonwebtoken over jose for consistency with existing codebase","24h access token expiry — long enough for dev sessions, short enough for security","Refresh tokens are 48-byte random hex stored in DB with user association"],blockers:"Need to verify token rotation strategy with security team before merging"}}),tokenBudget:0,costBudgetMillicents:0},{id:"task-001a",workspaceId:"proj-alpha",title:"Design token schema",description:"Define JWT payload structure, expiry, and refresh token strategy",status:"complete",branch:"feat/jwt-auth/design-token-schema",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:1,createdAt:"2026-02-25T10:10:00Z",parentTaskId:"task-001",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-001b",workspaceId:"proj-alpha",title:"Implement auth middleware",description:"Build Express middleware that verifies JWT Bearer tokens",status:"working",branch:"feat/jwt-auth/implement-auth-middleware",latestSessionId:"sess-001",dependsOn:[],reviewNotes:void 0,sortOrder:2,createdAt:"2026-02-25T10:15:00Z",parentTaskId:"task-001",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-001c",workspaceId:"proj-alpha",title:"Write auth integration tests",description:"End-to-end tests for login flow, token refresh, and protected route access",status:"not_started",branch:"",latestSessionId:"",dependsOn:["task-001b"],reviewNotes:void 0,sortOrder:3,createdAt:"2026-02-25T10:20:00Z",parentTaskId:"task-001",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-002",workspaceId:"proj-alpha",title:"Add rate limiting",description:"Implement token-bucket rate limiting for public API endpoints",status:"not_started",branch:"",latestSessionId:"",dependsOn:["task-001"],reviewNotes:void 0,sortOrder:2,createdAt:"2026-02-25T10:05:00Z",parentTaskId:"",depth:0,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-003",workspaceId:"proj-alpha",title:"Set up OpenAPI documentation",description:"Generate Swagger docs from route decorators and serve at /api/docs",status:"paused",branch:"feat/openapi-docs",latestSessionId:"sess-002",dependsOn:[],reviewNotes:void 0,sortOrder:3,createdAt:"2026-02-24T16:00:00Z",parentTaskId:"",depth:0,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-004",workspaceId:"proj-alpha",title:"Database connection pooling",description:"Switch from single connection to a connection pool with health checks",status:"complete",branch:"feat/db-pool",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:4,createdAt:"2026-02-23T11:00:00Z",parentTaskId:"",depth:0,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-005",workspaceId:"proj-alpha",title:"Fix N+1 query in user list",description:"Use a JOIN instead of per-row lookups in GET /api/users",status:"not_started",branch:"fix/user-list-n1",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:5,createdAt:"2026-02-22T09:30:00Z",parentTaskId:"",depth:0,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-006",workspaceId:"proj-beta",title:"Add Parquet export support",description:"Allow pipeline outputs to be written as Parquet files for Spark consumption",status:"working",branch:"feat/parquet-export",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:1,createdAt:"2026-02-26T08:00:00Z",parentTaskId:"",depth:0,childTaskIds:["task-006a","task-006b","task-006c","task-006d"],canDecompose:!0,defaultPersonaId:"",workpad:JSON.stringify({status:"in_progress",summary:"Plan for adding Parquet export support, including compression options and performance benchmarks.",extra:{approach:"Use apache-arrow npm package for Parquet write support. Map internal column types to Arrow type system.",compression:{supported:["snappy","zstd","gzip"],default:"snappy"},benchmarks:{"1M rows snappy":"2.3s","1M rows zstd":"3.1s","1M rows gzip":"4.8s"}}}),tokenBudget:0,costBudgetMillicents:0},{id:"task-006a",workspaceId:"proj-beta",title:"Define Parquet schema mapping",description:"Map internal column types to Arrow/Parquet type system",status:"complete",branch:"feat/parquet-export/define-parquet-schema-mapping",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:1,createdAt:"2026-02-26T08:05:00Z",parentTaskId:"task-006",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-006b",workspaceId:"proj-beta",title:"Implement row-group writer",description:"Write buffered row groups with configurable batch size",status:"complete",branch:"feat/parquet-export/implement-row-group-writer",latestSessionId:"",dependsOn:["task-006a"],reviewNotes:void 0,sortOrder:2,createdAt:"2026-02-26T08:10:00Z",parentTaskId:"task-006",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-006c",workspaceId:"proj-beta",title:"Add compression options",description:"Support Snappy, ZSTD, and GZIP compression for Parquet output",status:"working",branch:"feat/parquet-export/add-compression-options",latestSessionId:"sess-004",dependsOn:["task-006b"],reviewNotes:void 0,sortOrder:3,createdAt:"2026-02-26T08:15:00Z",parentTaskId:"task-006",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-006d",workspaceId:"proj-beta",title:"Write Parquet integration tests",description:"Round-trip tests: write Parquet, read back with pyarrow, verify data integrity",status:"not_started",branch:"",latestSessionId:"",dependsOn:["task-006c"],reviewNotes:void 0,sortOrder:4,createdAt:"2026-02-26T08:20:00Z",parentTaskId:"task-006",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-007",workspaceId:"proj-beta",title:"Implement incremental loads",description:"Track watermarks so pipelines only process new/changed rows",status:"working",branch:"feat/incremental",latestSessionId:"sess-004",dependsOn:[],reviewNotes:void 0,sortOrder:2,createdAt:"2026-02-26T08:30:00Z",parentTaskId:"",depth:0,childTaskIds:["task-007a","task-007b"],canDecompose:!0,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-007a",workspaceId:"proj-beta",title:"Design watermark storage",description:"Define schema for per-pipeline high-watermark tracking",status:"complete",branch:"feat/incremental/design-watermark-storage",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:1,createdAt:"2026-02-26T08:35:00Z",parentTaskId:"task-007",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-007b",workspaceId:"proj-beta",title:"Implement change detection query",description:"Generate WHERE clauses from watermarks to fetch only changed rows",status:"failed",branch:"feat/incremental/implement-change-detection-query",latestSessionId:"",dependsOn:["task-007a"],reviewNotes:void 0,sortOrder:2,createdAt:"2026-02-26T08:40:00Z",parentTaskId:"task-007",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-008",workspaceId:"proj-beta",title:"Add pipeline monitoring dashboard",description:"Real-time metrics for pipeline throughput, latency, and error rates",status:"paused",branch:"feat/monitoring",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:3,createdAt:"2026-02-26T09:00:00Z",parentTaskId:"",depth:0,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0}],Pc=[{id:"find-001",workspaceId:"proj-alpha",taskId:"task-001",sessionId:"sess-001",category:"architecture",title:"Auth middleware is tightly coupled to Express",content:"The current auth middleware directly references Express Request/Response types. Consider extracting a framework-agnostic token verification layer so we can reuse it in the WebSocket auth path.",tags:["auth","decoupling","middleware"],createdAt:"2026-02-27T08:16:00Z"},{id:"find-002",workspaceId:"proj-alpha",taskId:"task-003",sessionId:"sess-002",category:"api",title:"Missing pagination on GET /api/users",content:"The users endpoint returns all rows without limit/offset. For datasets over 10k rows this will cause timeouts. Recommend cursor-based pagination with a default page size of 50.",tags:["api","pagination","performance"],createdAt:"2026-02-27T07:31:00Z"},{id:"find-003",workspaceId:"proj-alpha",taskId:"task-005",sessionId:"sess-003",category:"bug",title:"Race condition in session cleanup",content:"When two requests hit /api/logout concurrently, the second call throws a 500 because the session row has already been deleted. Needs an idempotent DELETE or a conditional check.",tags:["bug","concurrency","sessions"],createdAt:"2026-02-26T22:50:00Z"},{id:"find-004",workspaceId:"proj-alpha",taskId:"task-004",sessionId:"",category:"decision",title:"Chose pg-pool over knex connection pool",content:"pg-pool gives us direct control over idle timeout, max connections, and health check queries. Knex wraps pg-pool anyway and adds overhead we don't need since we write raw SQL.",tags:["database","decision","postgres"],createdAt:"2026-02-23T11:30:00Z"},{id:"find-005",workspaceId:"proj-alpha",taskId:"",sessionId:"",category:"dependency",title:"jsonwebtoken has 3 high-severity CVEs",content:"The jsonwebtoken package (v8.x) has known vulnerabilities. Consider migrating to jose which is maintained, supports ESM, and covers the same JWS/JWE surface area with zero dependencies.",tags:["security","dependency","jwt"],createdAt:"2026-02-27T08:20:00Z"},{id:"find-006",workspaceId:"proj-alpha",taskId:"task-001",sessionId:"sess-001",category:"pattern",title:"Consistent error response shape",content:"All error responses should follow the shape `{ error: string, code: string, details?: unknown }`. Currently some routes return `{ message: string }` and others return `{ error: string }`.",tags:["api","consistency","error-handling"],createdAt:"2026-02-27T08:17:00Z"},{id:"find-007",workspaceId:"proj-beta",taskId:"task-007",sessionId:"sess-004",category:"architecture",title:"Watermark storage should be pluggable",content:"The incremental load watermarks are currently stored in a local SQLite file. For production multi-worker scenarios, this needs to be backed by a shared store (Redis or Postgres).",tags:["architecture","pipeline","scalability"],createdAt:"2026-02-27T09:05:00Z"}],O7=[{name:"anthropic",tokenType:"env_var",envVar:"ANTHROPIC_API_KEY",filePath:"",expiresAt:""},{name:"github",tokenType:"env_var",envVar:"GITHUB_TOKEN",filePath:"",expiresAt:"2026-12-31T23:59:59Z"},{name:"gcp-service-account",tokenType:"file",envVar:"",filePath:"/home/user/.config/gcloud/credentials.json",expiresAt:""}],B7=[{id:"persona-arch",name:"Software Architect",description:"Designs system architecture, defines interfaces, and decomposes large features into implementable tasks.",systemPrompt:"You are a senior software architect. Focus on clean interfaces, separation of concerns, and scalable patterns. When decomposing work, create concrete subtasks with clear acceptance criteria.",toolConfig:JSON.stringify({allowedTools:["Read","Grep","Glob","Write","Edit"]}),runtime:"claude-code",model:"claude-sonnet-4-6",maxTurns:50,mcpServers:"[]",createdAt:"2026-02-20T10:00:00Z",updatedAt:"2026-02-20T10:00:00Z",type:"agent",script:"",allowedMcpTools:["task_create","task_update","task_list","finding_post","finding_list","knowledge_search","knowledge_create_node","session_spawn"]},{id:"persona-fe",name:"Frontend Engineer",description:"React specialist — builds UI components, writes CSS, implements routing, and creates Playwright tests.",systemPrompt:"You are a frontend engineer specializing in React, TypeScript, and modern CSS. Follow component composition patterns, use semantic HTML, and write accessible markup.",toolConfig:JSON.stringify({allowedTools:["Read","Grep","Glob","Write","Edit","Bash"]}),runtime:"claude-code",model:"claude-sonnet-4-6",maxTurns:100,mcpServers:"[]",createdAt:"2026-02-20T10:05:00Z",updatedAt:"2026-02-20T10:05:00Z",type:"agent",script:"",allowedMcpTools:[]},{id:"persona-reviewer",name:"Code Reviewer",description:"Reviews diffs for correctness, security, and style. Posts findings for issues discovered.",systemPrompt:"You are a meticulous code reviewer. Check for security vulnerabilities, performance issues, and style consistency. Post findings for anything noteworthy.",toolConfig:JSON.stringify({allowedTools:["Read","Grep","Glob"]}),runtime:"claude-code",model:"claude-sonnet-4-6",maxTurns:30,mcpServers:"[]",createdAt:"2026-02-20T10:10:00Z",updatedAt:"2026-02-20T10:10:00Z",type:"agent",script:"",allowedMcpTools:["finding_post","finding_list","knowledge_search"]},{id:"persona-tester",name:"QA Engineer",description:"Writes comprehensive test suites — unit tests, integration tests, and E2E Playwright specs.",systemPrompt:"You are a QA engineer focused on test coverage. Write tests that cover happy paths, edge cases, error scenarios, and accessibility. Use Playwright for E2E tests.",toolConfig:JSON.stringify({allowedTools:["Read","Grep","Glob","Write","Edit","Bash"]}),runtime:"claude-code",model:"claude-sonnet-4-6",maxTurns:80,mcpServers:"[]",createdAt:"2026-02-20T10:15:00Z",updatedAt:"2026-02-20T10:15:00Z",type:"agent",script:"",allowedMcpTools:[]},{id:"persona-lint",name:"Lint & Format",description:"Scripted persona — runs ESLint and Prettier on changed files, auto-fixes violations, and posts a findings summary.",systemPrompt:"",toolConfig:"{}",runtime:"genaiscript",model:"",maxTurns:1,mcpServers:"[]",createdAt:"2026-02-21T09:00:00Z",updatedAt:"2026-02-21T09:00:00Z",type:"script",script:`const files = env.files.filter(f => /\\.(ts|tsx|js)$/.test(f.filename));
|
|
606
|
+
This is a significant refactor. Let me start with the PoolManager class.`},{sessionId:"sess-005",eventType:"usage",timestamp:"2026-02-27T06:30:00Z",content:JSON.stringify({input_tokens:67800,output_tokens:19300,cost_millicents:38e3})},{sessionId:"sess-005",eventType:"status",timestamp:"2026-02-27T06:30:01Z",content:"suspended"}],M7=[{id:"proj-alpha",name:"Workspace Alpha",description:"Core platform API and authentication services",repoUrl:"https://github.com/acme/alpha",environmentId:"env-local-01",linkedEnvironmentIds:["env-docker-01"],status:"active",workingDirectory:"",useWorktrees:!0,defaultPersonaId:"",tokenBudget:0,costBudgetMillicents:0,createdAt:"2026-01-15T10:00:00Z",updatedAt:"2026-01-15T10:00:00Z"},{id:"proj-beta",name:"Data Pipeline",description:"ETL pipelines for analytics and reporting",repoUrl:"https://github.com/acme/data-pipeline",environmentId:"env-docker-01",linkedEnvironmentIds:[],status:"active",workingDirectory:"",useWorktrees:!0,defaultPersonaId:"",tokenBudget:0,costBudgetMillicents:0,createdAt:"2026-02-01T14:30:00Z",updatedAt:"2026-02-01T14:30:00Z"},{id:"proj-gamma",name:"Mobile App",description:"React Native cross-platform mobile application",repoUrl:"",environmentId:"env-local-01",linkedEnvironmentIds:[],status:"archived",workingDirectory:"",useWorktrees:!0,defaultPersonaId:"",tokenBudget:0,costBudgetMillicents:0,createdAt:"2025-11-20T09:00:00Z",updatedAt:"2025-11-20T09:00:00Z"}],I7=[{id:"task-001",workspaceId:"proj-alpha",title:"Implement JWT authentication",description:"Replace session-based auth with JWT tokens across all protected routes",status:"working",branch:"feat/jwt-auth",latestSessionId:"sess-001",dependsOn:[],reviewNotes:void 0,sortOrder:1,createdAt:"2026-02-25T10:00:00Z",parentTaskId:"",depth:0,childTaskIds:["task-001a","task-001b","task-001c"],canDecompose:!0,defaultPersonaId:"",workpad:JSON.stringify({status:"in_progress",summary:"Design and implement JWT-based authentication with access/refresh tokens, replacing session-based auth.",extra:{approach:"Replace express-session with JWT Bearer tokens. Access tokens expire in 24h, refresh tokens stored in DB.",files_changed:["src/middleware/auth.ts","src/routes/login.ts","src/routes/protected.ts"],decisions:["Chose jsonwebtoken over jose for consistency with existing codebase","24h access token expiry — long enough for dev sessions, short enough for security","Refresh tokens are 48-byte random hex stored in DB with user association"],blockers:"Need to verify token rotation strategy with security team before merging"}}),tokenBudget:0,costBudgetMillicents:0},{id:"task-001a",workspaceId:"proj-alpha",title:"Design token schema",description:"Define JWT payload structure, expiry, and refresh token strategy",status:"complete",branch:"feat/jwt-auth/design-token-schema",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:1,createdAt:"2026-02-25T10:10:00Z",parentTaskId:"task-001",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-001b",workspaceId:"proj-alpha",title:"Implement auth middleware",description:"Build Express middleware that verifies JWT Bearer tokens",status:"working",branch:"feat/jwt-auth/implement-auth-middleware",latestSessionId:"sess-001",dependsOn:[],reviewNotes:void 0,sortOrder:2,createdAt:"2026-02-25T10:15:00Z",parentTaskId:"task-001",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-001c",workspaceId:"proj-alpha",title:"Write auth integration tests",description:"End-to-end tests for login flow, token refresh, and protected route access",status:"not_started",branch:"",latestSessionId:"",dependsOn:["task-001b"],reviewNotes:void 0,sortOrder:3,createdAt:"2026-02-25T10:20:00Z",parentTaskId:"task-001",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-002",workspaceId:"proj-alpha",title:"Add rate limiting",description:"Implement token-bucket rate limiting for public API endpoints",status:"not_started",branch:"",latestSessionId:"",dependsOn:["task-001"],reviewNotes:void 0,sortOrder:2,createdAt:"2026-02-25T10:05:00Z",parentTaskId:"",depth:0,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-003",workspaceId:"proj-alpha",title:"Set up OpenAPI documentation",description:"Generate Swagger docs from route decorators and serve at /api/docs",status:"paused",branch:"feat/openapi-docs",latestSessionId:"sess-002",dependsOn:[],reviewNotes:void 0,sortOrder:3,createdAt:"2026-02-24T16:00:00Z",parentTaskId:"",depth:0,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-004",workspaceId:"proj-alpha",title:"Database connection pooling",description:"Switch from single connection to a connection pool with health checks",status:"complete",branch:"feat/db-pool",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:4,createdAt:"2026-02-23T11:00:00Z",parentTaskId:"",depth:0,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-005",workspaceId:"proj-alpha",title:"Fix N+1 query in user list",description:"Use a JOIN instead of per-row lookups in GET /api/users",status:"not_started",branch:"fix/user-list-n1",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:5,createdAt:"2026-02-22T09:30:00Z",parentTaskId:"",depth:0,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-006",workspaceId:"proj-beta",title:"Add Parquet export support",description:"Allow pipeline outputs to be written as Parquet files for Spark consumption",status:"working",branch:"feat/parquet-export",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:1,createdAt:"2026-02-26T08:00:00Z",parentTaskId:"",depth:0,childTaskIds:["task-006a","task-006b","task-006c","task-006d"],canDecompose:!0,defaultPersonaId:"",workpad:JSON.stringify({status:"in_progress",summary:"Plan for adding Parquet export support, including compression options and performance benchmarks.",extra:{approach:"Use apache-arrow npm package for Parquet write support. Map internal column types to Arrow type system.",compression:{supported:["snappy","zstd","gzip"],default:"snappy"},benchmarks:{"1M rows snappy":"2.3s","1M rows zstd":"3.1s","1M rows gzip":"4.8s"}}}),tokenBudget:0,costBudgetMillicents:0},{id:"task-006a",workspaceId:"proj-beta",title:"Define Parquet schema mapping",description:"Map internal column types to Arrow/Parquet type system",status:"complete",branch:"feat/parquet-export/define-parquet-schema-mapping",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:1,createdAt:"2026-02-26T08:05:00Z",parentTaskId:"task-006",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-006b",workspaceId:"proj-beta",title:"Implement row-group writer",description:"Write buffered row groups with configurable batch size",status:"complete",branch:"feat/parquet-export/implement-row-group-writer",latestSessionId:"",dependsOn:["task-006a"],reviewNotes:void 0,sortOrder:2,createdAt:"2026-02-26T08:10:00Z",parentTaskId:"task-006",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-006c",workspaceId:"proj-beta",title:"Add compression options",description:"Support Snappy, ZSTD, and GZIP compression for Parquet output",status:"working",branch:"feat/parquet-export/add-compression-options",latestSessionId:"sess-004",dependsOn:["task-006b"],reviewNotes:void 0,sortOrder:3,createdAt:"2026-02-26T08:15:00Z",parentTaskId:"task-006",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-006d",workspaceId:"proj-beta",title:"Write Parquet integration tests",description:"Round-trip tests: write Parquet, read back with pyarrow, verify data integrity",status:"not_started",branch:"",latestSessionId:"",dependsOn:["task-006c"],reviewNotes:void 0,sortOrder:4,createdAt:"2026-02-26T08:20:00Z",parentTaskId:"task-006",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-007",workspaceId:"proj-beta",title:"Implement incremental loads",description:"Track watermarks so pipelines only process new/changed rows",status:"working",branch:"feat/incremental",latestSessionId:"sess-004",dependsOn:[],reviewNotes:void 0,sortOrder:2,createdAt:"2026-02-26T08:30:00Z",parentTaskId:"",depth:0,childTaskIds:["task-007a","task-007b"],canDecompose:!0,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-007a",workspaceId:"proj-beta",title:"Design watermark storage",description:"Define schema for per-pipeline high-watermark tracking",status:"complete",branch:"feat/incremental/design-watermark-storage",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:1,createdAt:"2026-02-26T08:35:00Z",parentTaskId:"task-007",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-007b",workspaceId:"proj-beta",title:"Implement change detection query",description:"Generate WHERE clauses from watermarks to fetch only changed rows",status:"failed",branch:"feat/incremental/implement-change-detection-query",latestSessionId:"",dependsOn:["task-007a"],reviewNotes:void 0,sortOrder:2,createdAt:"2026-02-26T08:40:00Z",parentTaskId:"task-007",depth:1,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0},{id:"task-008",workspaceId:"proj-beta",title:"Add pipeline monitoring dashboard",description:"Real-time metrics for pipeline throughput, latency, and error rates",status:"paused",branch:"feat/monitoring",latestSessionId:"",dependsOn:[],reviewNotes:void 0,sortOrder:3,createdAt:"2026-02-26T09:00:00Z",parentTaskId:"",depth:0,childTaskIds:[],canDecompose:!1,defaultPersonaId:"",workpad:"",tokenBudget:0,costBudgetMillicents:0}],Pc=[{id:"find-001",workspaceId:"proj-alpha",taskId:"task-001",sessionId:"sess-001",category:"architecture",title:"Auth middleware is tightly coupled to Express",content:"The current auth middleware directly references Express Request/Response types. Consider extracting a framework-agnostic token verification layer so we can reuse it in the WebSocket auth path.",tags:["auth","decoupling","middleware"],createdAt:"2026-02-27T08:16:00Z"},{id:"find-002",workspaceId:"proj-alpha",taskId:"task-003",sessionId:"sess-002",category:"api",title:"Missing pagination on GET /api/users",content:"The users endpoint returns all rows without limit/offset. For datasets over 10k rows this will cause timeouts. Recommend cursor-based pagination with a default page size of 50.",tags:["api","pagination","performance"],createdAt:"2026-02-27T07:31:00Z"},{id:"find-003",workspaceId:"proj-alpha",taskId:"task-005",sessionId:"sess-003",category:"bug",title:"Race condition in session cleanup",content:"When two requests hit /api/logout concurrently, the second call throws a 500 because the session row has already been deleted. Needs an idempotent DELETE or a conditional check.",tags:["bug","concurrency","sessions"],createdAt:"2026-02-26T22:50:00Z"},{id:"find-004",workspaceId:"proj-alpha",taskId:"task-004",sessionId:"",category:"decision",title:"Chose pg-pool over knex connection pool",content:"pg-pool gives us direct control over idle timeout, max connections, and health check queries. Knex wraps pg-pool anyway and adds overhead we don't need since we write raw SQL.",tags:["database","decision","postgres"],createdAt:"2026-02-23T11:30:00Z"},{id:"find-005",workspaceId:"proj-alpha",taskId:"",sessionId:"",category:"dependency",title:"jsonwebtoken has 3 high-severity CVEs",content:"The jsonwebtoken package (v8.x) has known vulnerabilities. Consider migrating to jose which is maintained, supports ESM, and covers the same JWS/JWE surface area with zero dependencies.",tags:["security","dependency","jwt"],createdAt:"2026-02-27T08:20:00Z"},{id:"find-006",workspaceId:"proj-alpha",taskId:"task-001",sessionId:"sess-001",category:"pattern",title:"Consistent error response shape",content:"All error responses should follow the shape `{ error: string, code: string, details?: unknown }`. Currently some routes return `{ message: string }` and others return `{ error: string }`.",tags:["api","consistency","error-handling"],createdAt:"2026-02-27T08:17:00Z"},{id:"find-007",workspaceId:"proj-beta",taskId:"task-007",sessionId:"sess-004",category:"architecture",title:"Watermark storage should be pluggable",content:"The incremental load watermarks are currently stored in a local SQLite file. For production multi-worker scenarios, this needs to be backed by a shared store (Redis or Postgres).",tags:["architecture","pipeline","scalability"],createdAt:"2026-02-27T09:05:00Z"}],O7=[{name:"anthropic",tokenType:"env_var",envVar:"ANTHROPIC_API_KEY",filePath:"",expiresAt:""},{name:"github",tokenType:"env_var",envVar:"GITHUB_TOKEN",filePath:"",expiresAt:"2026-12-31T23:59:59Z"},{name:"gcp-service-account",tokenType:"file",envVar:"",filePath:"/home/user/.config/gcloud/credentials.json",expiresAt:""}],B7=[{id:"persona-arch",name:"Software Architect",description:"Designs system architecture, defines interfaces, and decomposes large features into implementable tasks.",systemPrompt:"You are a senior software architect. Focus on clean interfaces, separation of concerns, and scalable patterns. When decomposing work, create concrete subtasks with clear acceptance criteria.",toolConfig:JSON.stringify({allowedTools:["Read","Grep","Glob","Write","Edit"]}),runtime:"claude-code",model:"claude-sonnet-4-6",maxTurns:50,mcpServers:"[]",createdAt:"2026-02-20T10:00:00Z",updatedAt:"2026-02-20T10:00:00Z",type:"agent",script:"",allowedMcpTools:["task_create","task_update","task_list","finding_post","finding_list","knowledge_search","knowledge_create_node","session_spawn"]},{id:"persona-fe",name:"Frontend Engineer",description:"React specialist — builds UI components, writes CSS, implements routing, and creates Playwright tests.",systemPrompt:"You are a frontend engineer specializing in React, TypeScript, and modern CSS. Follow component composition patterns, use semantic HTML, and write accessible markup.",toolConfig:JSON.stringify({allowedTools:["Read","Grep","Glob","Write","Edit","Bash"]}),runtime:"claude-code",model:"claude-sonnet-4-6",maxTurns:100,mcpServers:"[]",createdAt:"2026-02-20T10:05:00Z",updatedAt:"2026-02-20T10:05:00Z",type:"agent",script:"",allowedMcpTools:[]},{id:"persona-reviewer",name:"Code Reviewer",description:"Reviews diffs for correctness, security, and style. Posts findings for issues discovered.",systemPrompt:"You are a meticulous code reviewer. Check for security vulnerabilities, performance issues, and style consistency. Post findings for anything noteworthy.",toolConfig:JSON.stringify({allowedTools:["Read","Grep","Glob"]}),runtime:"claude-code",model:"claude-sonnet-4-6",maxTurns:30,mcpServers:"[]",createdAt:"2026-02-20T10:10:00Z",updatedAt:"2026-02-20T10:10:00Z",type:"agent",script:"",allowedMcpTools:["finding_post","finding_list","knowledge_search"]},{id:"persona-tester",name:"QA Engineer",description:"Writes comprehensive test suites — unit tests, integration tests, and E2E Playwright specs.",systemPrompt:"You are a QA engineer focused on test coverage. Write tests that cover happy paths, edge cases, error scenarios, and accessibility. Use Playwright for E2E tests.",toolConfig:JSON.stringify({allowedTools:["Read","Grep","Glob","Write","Edit","Bash"]}),runtime:"claude-code",model:"claude-sonnet-4-6",maxTurns:80,mcpServers:"[]",createdAt:"2026-02-20T10:15:00Z",updatedAt:"2026-02-20T10:15:00Z",type:"agent",script:"",allowedMcpTools:[]},{id:"persona-lint",name:"Lint & Format",description:"Scripted persona — runs ESLint and Prettier on changed files, auto-fixes violations, and posts a findings summary.",systemPrompt:"",toolConfig:"{}",runtime:"genaiscript",model:"",maxTurns:1,mcpServers:"[]",createdAt:"2026-02-21T09:00:00Z",updatedAt:"2026-02-21T09:00:00Z",type:"script",script:`const files = env.files.filter(f => /\\.(ts|tsx|js)$/.test(f.filename));
|
|
607
607
|
for (const f of files) {
|
|
608
608
|
const eslintResult = await host.exec("npx", ["eslint", "--fix", f.filename]);
|
|
609
609
|
if (eslintResult.exitCode !== 0) {
|
|
@@ -635,7 +635,7 @@ router.delete("/:id", deleteUser);
|
|
|
635
635
|
PASS src/routes/__tests__/billing.test.ts
|
|
636
636
|
|
|
637
637
|
Test Suites: 3 passed, 3 total
|
|
638
|
-
Tests: 22 passed, 22 total`,raw:JSON.stringify({tool_use_id:"stream-a-02"})}},{delayMs:4500,event:{eventType:"usage",timestamp:Me(4500),content:JSON.stringify({input_tokens:28400,output_tokens:7200,
|
|
638
|
+
Tests: 22 passed, 22 total`,raw:JSON.stringify({tool_use_id:"stream-a-02"})}},{delayMs:4500,event:{eventType:"usage",timestamp:Me(4500),content:JSON.stringify({input_tokens:28400,output_tokens:7200,cost_millicents:15e3})}},{delayMs:5e3,event:{eventType:"text",timestamp:Me(5e3),content:"All 22 tests pass. The route refactoring is complete."}},{delayMs:5500,event:{eventType:"status",timestamp:Me(5500),content:"completed"}}]},{label:"Database Migration",pauseForInput:!0,pauseAfterStep:4,steps:[{delayMs:0,event:{eventType:"status",timestamp:Me(0),content:"running"}},{delayMs:600,event:{eventType:"text",timestamp:Me(600),content:"Scanning the current database schema to plan the migration."}},{delayMs:1200,event:{eventType:"tool_use",timestamp:Me(1200),content:JSON.stringify({tool:"Read",args:{file_path:"migrations/001_initial.sql"}}),raw:JSON.stringify({id:"stream-b-01",type:"tool_use"})}},{delayMs:1800,event:{eventType:"tool_result",timestamp:Me(1800),content:`CREATE TABLE users (
|
|
639
639
|
id UUID PRIMARY KEY,
|
|
640
640
|
name TEXT NOT NULL,
|
|
641
641
|
email TEXT UNIQUE NOT NULL,
|
|
@@ -698,7 +698,7 @@ export function verifyToken(req: Request, res: Response, next: NextFunction): vo
|
|
|
698
698
|
|
|
699
699
|
Tests: 3 passed, 3 total
|
|
700
700
|
Time: 1.234s`,raw:JSON.stringify({tool_use_id:"tool-mock-003",is_error:!1})}},{delayMs:6400,event:{eventType:"tool_use",timestamp:Me(6400),content:JSON.stringify({tool:"Grep",args:{pattern:"decoded\\.exp",path:"src/"}}),raw:JSON.stringify({id:"tool-mock-004"})}},{delayMs:7e3,event:{eventType:"tool_result",timestamp:Me(7e3),content:`src/middleware/auth.ts:14: if (decoded.exp < Date.now() / 1000) {
|
|
701
|
-
src/utils/token-refresh.ts:28: const remaining = decoded.exp - Date.now() / 1000;`,raw:JSON.stringify({tool_use_id:"tool-mock-004",is_error:!1})}},{delayMs:7800,event:{eventType:"text",timestamp:Me(7800),content:"Fixed. The token expiry comparison was inverted — `decoded.exp > Date.now()` should have been `<` (a token is expired when its `exp` is in the past). The other occurrence in `token-refresh.ts` uses subtraction (not comparison), so it was already correct. All 3 auth tests pass."}},{delayMs:8400,event:{eventType:"usage",timestamp:Me(8400),content:JSON.stringify({input_tokens:42600,output_tokens:1850,cost_usd:.12})}},{delayMs:8800,event:{eventType:"status",timestamp:Me(8800),content:"completed"}}]}],_s={onConnect:async()=>{},onDisconnect:()=>{},handleEvent:()=>!1},Yb=400;function z7({children:t}){const[s,o]=y.useState(A7),[r,c]=y.useState(D7),[d,u]=y.useState(R7),[p,m]=y.useState(void 0),[g,v]=y.useState(M7),[b,x]=y.useState(""),[S,k]=y.useState(I7),[w,N]=y.useState(Pc),[T,C]=y.useState(void 0),D=!1,[B,E]=y.useState(O7),[A,P]=y.useState({claude:"off",github:"off",copilot:"off",codex:"off",goose:"off"}),[I,U]=y.useState(B7),[Q]=y.useState(L7),[$,W]=y.useState(""),[pe,H]=y.useState(ks),[ie,L]=y.useState(Ra),[Z,J]=y.useState(void 0),[ce,X]=y.useState(void 0),[ge,fe]=y.useState(""),Ce=y.useRef(void 0),Ze=y.useRef(0),me=y.useRef(0),_e=y.useRef(new Set),ve=y.useRef(new Map),Le=y.useRef(S);Le.current=S;const Mt=y.useRef(new Map),Tn=y.useRef(new Map),oe=y.useCallback(V=>(Ze.current+=1,`mock-${V}-${String(Ze.current).padStart(3,"0")}`),[]),Ve=y.useCallback(()=>{const V=Kb[me.current%Kb.length];return me.current+=1,V},[]),qt=y.useCallback((V,ae,le)=>{const de=setTimeout(()=>{var ye;_e.current.delete(de),le&&((ye=ve.current.get(le))==null||ye.delete(de)),V()},ae);_e.current.add(de),le&&(ve.current.has(le)||ve.current.set(le,new Set),ve.current.get(le).add(de))},[]),te=y.useCallback(V=>{const ae=ve.current.get(V);ae&&(ae.forEach(le=>{clearTimeout(le),_e.current.delete(le)}),ve.current.delete(V))},[]),ht=y.useCallback((V,ae,le)=>{c(de=>de.map(ye=>ye.id===V?{...ye,status:ae,...le!==void 0?{endReason:le}:{}}:ye))},[]),at=y.useCallback(V=>{u(ae=>[...ae,V])},[]),Kt=y.useCallback((V,ae,le)=>{ae.forEach((de,ye)=>{qt(()=>{const We={sessionId:V,...de.event,timestamp:new Date().toISOString()};if(at(We),de.event.eventType==="status"){const Te=P1(de.event.content),Ie=H1(de.event.content);ht(V,Te,Ie)}ye===ae.length-1&&le&&le()},de.delayMs,V)})},[qt,at,ht]),gt=y.useCallback(async(V,ae,le,de)=>{console.log("[MockGrackle] spawn",{environmentId:V,prompt:ae,runtime:de});const ye=oe("sess"),We={id:ye,environmentId:V,runtime:de||"claude-code",status:"running",prompt:ae,startedAt:new Date().toISOString()};c(Ie=>[...Ie,We]),m(ye);const Te=Ve();if(console.log(`[MockGrackle] Playing scenario: ${Te.label}`),Te.pauseForInput){const Ie=Te.pauseAfterStep??Te.steps.length-1,Ke=Te.steps.slice(0,Ie+1),ct=Ke.length>0?Ke[Ke.length-1].delayMs:0;Kt(ye,Ke),qt(()=>{ht(ye,"idle"),at({sessionId:ye,eventType:"status",timestamp:new Date().toISOString(),content:"idle"})},ct+Yb,ye),Te.resumeSteps&&Mt.current.set(ye,Te.resumeSteps)}else Kt(ye,Te.steps)},[oe,Ve,Kt,qt,ht,at]),ps=y.useCallback(async V=>{console.log("[MockGrackle] kill",V),te(V),Mt.current.delete(V),ht(V,"stopped","killed"),at({sessionId:V,eventType:"status",timestamp:new Date().toISOString(),content:"killed"}),k(ae=>ae.map(le=>le.latestSessionId===V&&le.status==="working"?{...le,status:"not_started"}:le))},[te,ht,at]),aa=y.useCallback(async V=>{console.log("[MockGrackle] stopGraceful",V),te(V),Mt.current.delete(V),ht(V,"stopped","terminated"),at({sessionId:V,eventType:"status",timestamp:new Date().toISOString(),content:"terminated"}),k(ae=>ae.map(le=>le.latestSessionId===V&&le.status==="working"?{...le,status:"not_started"}:le))},[te,ht,at]),es=y.useCallback(()=>{console.log("[MockGrackle] refresh")},[]),Fa=y.useCallback(async V=>{console.log("[MockGrackle] loadSessionEvents",V)},[]),ia=y.useCallback(()=>{console.log("[MockGrackle] clearEvents"),u([])},[]),Yt=y.useCallback(async(V,ae,le,de,ye,We,Te,Ie,Ke)=>{console.log("[MockGrackle] createWorkspace",{name:V,description:ae});const ct={id:oe("proj"),name:V,description:ae||"",repoUrl:le||"",environmentId:de||"",linkedEnvironmentIds:[],status:"active",workingDirectory:Te||"",useWorktrees:We??!0,defaultPersonaId:ye||"",tokenBudget:0,costBudgetMillicents:0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};v(Xe=>[...Xe,ct]),Ie&&Ie()},[oe]),Mi=y.useCallback(async V=>{console.log("[MockGrackle] archiveWorkspace",V),v(ae=>ae.map(le=>le.id===V?{...le,status:"archived"}:le))},[]),oa=y.useCallback(async V=>{console.log("[MockGrackle] loadTasks",V)},[]),Za=y.useCallback(async(V,ae,le,de,ye,We,Te,Ie,Ke)=>{console.log("[MockGrackle] createTask",{workspaceId:V,title:ae,parentTaskId:ye}),k(ct=>{const Xt=ct.filter(gn=>gn.workspaceId===V).reduce((gn,Qa)=>Math.max(gn,Qa.sortOrder),0),jt=ye?ct.find(gn=>gn.id===ye):void 0;if(ye&&!jt)return console.warn("[MockGrackle] Parent task not found:",ye),ct;if(jt&&!jt.canDecompose)return console.warn("[MockGrackle] Parent task does not have decomposition rights:",ye),ct;const Ue=jt?jt.depth+1:0,It={id:oe("task"),workspaceId:V,title:ae,description:le||"",status:"not_started",branch:"",latestSessionId:"",dependsOn:de||[],reviewNotes:void 0,sortOrder:Xt+1,createdAt:new Date().toISOString(),parentTaskId:ye||"",depth:Ue,childTaskIds:[],canDecompose:Te??!ye,defaultPersonaId:We||"",workpad:"",tokenBudget:0,costBudgetMillicents:0};return[...ct,It]}),Ie&&Ie()},[oe]),ms=y.useCallback(async(V,ae,le,de)=>{var ct;console.log("[MockGrackle] startTask",{taskId:V});const ye=Le.current.find(Xe=>Xe.id===V),We=(ye==null?void 0:ye.title)??"",Te=oe("sess"),Ie={id:Te,environmentId:"env-local-01",runtime:"claude-code",status:"running",prompt:We||V,startedAt:new Date().toISOString()};c(Xe=>[...Xe,Ie]),k(Xe=>Xe.map(Xt=>Xt.id===V?{...Xt,status:"working",latestSessionId:Te,branch:`mock/${V.slice(0,8)}`}:Xt));const Ke=Ve();if(console.log(`[MockGrackle] Playing task scenario: ${Ke.label}`),Ke.pauseForInput){const Xe=Ke.pauseAfterStep??Ke.steps.length-1,Xt=Ke.steps.slice(0,Xe+1),jt=Xt.length>0?Xt[Xt.length-1].delayMs:0;if(Kt(Te,Xt),qt(()=>{ht(Te,"idle"),at({sessionId:Te,eventType:"status",timestamp:new Date().toISOString(),content:"idle"})},jt+Yb,Te),Ke.resumeSteps){const Ue=[...Ke.resumeSteps];Mt.current.set(Te,Ue);const It=Ue.reduce((gn,Qa)=>Math.max(gn,Qa.delayMs),0);Tn.current.set(Te,{taskId:V,delayAfterResume:It+200})}}else{const Xe=Ke.steps.length>0?Ke.steps[Ke.steps.length-1].delayMs:0;Kt(Te,Ke.steps);const Xt=(ct=Ke.steps[Ke.steps.length-1])==null?void 0:ct.event.content;qt(()=>{Xt==="completed"?k(jt=>jt.map(Ue=>Ue.id===V&&Ue.status==="working"?{...Ue,status:"paused"}:Ue)):Xt==="failed"&&k(jt=>jt.map(Ue=>Ue.id===V&&Ue.status==="working"?{...Ue,status:"failed"}:Ue))},Xe+100,Te)}},[oe,Ve,Kt,qt,ht,at]),Ii=y.useCallback(async(V,ae)=>{console.log("[MockGrackle] sendInput",{sessionId:V,text:ae}),at({sessionId:V,eventType:"output",timestamp:new Date().toISOString(),content:`User input: ${ae}`}),ht(V,"running"),at({sessionId:V,eventType:"status",timestamp:new Date().toISOString(),content:"running"});const le=Mt.current.get(V);if(le)Mt.current.delete(V),Kt(V,le);else{const ye=[{delayMs:500,event:{eventType:"output",timestamp:new Date().toISOString(),content:"I received your input, continuing..."}},{delayMs:1500,event:{eventType:"status",timestamp:new Date().toISOString(),content:"completed"}}];Kt(V,ye)}const de=Tn.current.get(V);de&&(Tn.current.delete(V),qt(()=>{k(ye=>ye.map(We=>We.id===de.taskId&&We.status==="working"?{...We,status:"paused"}:We))},de.delayAfterResume,V))},[at,ht,Kt,qt]),wn=y.useCallback(async V=>{console.log("[MockGrackle] completeTask",V),k(ae=>ae.map(le=>le.id===V?{...le,status:"complete"}:le))},[]),Re=y.useCallback(async V=>{console.log("[MockGrackle] resumeTask",V)},[]),Je=y.useCallback(async(V,ae,le,de,ye)=>{console.log("[MockGrackle] updateTask",{taskId:V,title:ae}),k(We=>We.map(Te=>Te.id===V?{...Te,title:ae.trim()||Te.title,description:le,dependsOn:de,...ye!==void 0?{defaultPersonaId:ye}:{}}:Te))},[]),Jt=y.useCallback(async V=>{console.log("[MockGrackle] deleteTask",V),k(ae=>ae.filter(le=>le.id!==V))},[]),St=y.useCallback(async V=>{console.log("[MockGrackle] loadFindings",V),N(Pc.filter(ae=>ae.workspaceId===V))},[]),un=y.useCallback(async()=>{console.log("[MockGrackle] loadAllFindings"),N([...Pc])},[]),Wt=y.useCallback(async V=>{console.log("[MockGrackle] loadFinding",V);const ae=Pc.find(le=>le.id===V);C(ae)},[]),Oi=y.useCallback(async(V,ae,le,de,ye)=>{console.log("[MockGrackle] postFinding",{workspaceId:V,title:ae});const We={id:oe("find"),workspaceId:V,taskId:"",sessionId:"",category:de||"general",title:ae,content:le,tags:ye||[],createdAt:new Date().toISOString()};N(Te=>[...Te,We])},[oe]),Bi=y.useCallback(async()=>{console.log("[MockGrackle] loadEnvironments")},[]),Li=y.useCallback(async(V,ae,le)=>{console.log("[MockGrackle] addEnvironment",{displayName:V,adapterType:ae,adapterConfig:le})},[]),Ka=y.useCallback(async(V,ae)=>{console.log("[MockGrackle] updateEnvironment",{environmentId:V,...ae}),o(le=>le.map(de=>de.id!==V?de:{...de,...ae.displayName!==void 0?{displayName:ae.displayName}:{},...ae.adapterConfig!==void 0?{adapterConfig:JSON.stringify(ae.adapterConfig)}:{}}))},[]),Ya=y.useCallback(async()=>{console.log("[MockGrackle] loadTokens")},[]),Ja=y.useCallback(async(V,ae,le,de,ye)=>{console.log("[MockGrackle] setToken",{name:V,tokenType:le}),E(We=>[...We.filter(Ie=>Ie.name!==V),{name:V,tokenType:le,envVar:de,filePath:ye,expiresAt:""}])},[]),hs=y.useCallback(async V=>{console.log("[MockGrackle] deleteToken",V),E(ae=>ae.filter(le=>le.name!==V))},[]),Wa=y.useCallback(async V=>{console.log("[MockGrackle] updateCredentialProviders",V),P(V)},[]);y.useEffect(()=>()=>{_e.current.forEach(clearTimeout),_e.current.clear()},[]);const Xa=y.useMemo(()=>({connected:!0,environments:{environments:s,environmentsLoading:!1,provisionStatus:{},operationError:"",clearOperationError:()=>{},loadEnvironments:Bi,addEnvironment:Li,updateEnvironment:Ka,provisionEnvironment:async(V,ae)=>{},stopEnvironment:async()=>{},removeEnvironment:async()=>{},domainHook:_s},sessions:{sessions:r,sessionsLoading:!1,events:d,eventsDropped:0,lastSpawnedId:p,taskSessions:Q,spawn:gt,sendInput:Ii,kill:ps,stopGraceful:aa,loadSessionEvents:Fa,clearEvents:ia,loadTaskSessions:async V=>{console.log("[MockGrackle] loadTaskSessions",V)},domainHook:_s},workspaces:{workspaces:g,workspacesLoading:!1,workspaceCreating:!1,loadWorkspaces:async()=>{console.log("[MockGrackle] loadWorkspaces")},createWorkspace:Yt,archiveWorkspace:Mi,updateWorkspace:async(V,ae)=>{console.log("[MockGrackle] updateWorkspace",{workspaceId:V,...ae}),v(le=>le.map(de=>de.id!==V?de:{...de,...ae.name!==void 0?{name:ae.name}:{},...ae.description!==void 0?{description:ae.description}:{},...ae.repoUrl!==void 0?{repoUrl:ae.repoUrl}:{},...ae.environmentId!==void 0?{environmentId:ae.environmentId}:{},...ae.workingDirectory!==void 0?{workingDirectory:ae.workingDirectory}:{},...ae.useWorktrees!==void 0?{useWorktrees:ae.useWorktrees}:{},...ae.defaultPersonaId!==void 0?{defaultPersonaId:ae.defaultPersonaId}:{},updatedAt:new Date().toISOString()}))},linkEnvironment:async(V,ae)=>{if(console.log("[MockGrackle] linkEnvironment",{workspaceId:V,environmentId:ae}),ae==="error-env"){x("Failed to link environment");return}x(""),v(le=>le.map(de=>de.id!==V||de.linkedEnvironmentIds.includes(ae)?de:{...de,linkedEnvironmentIds:[...de.linkedEnvironmentIds,ae]}))},unlinkEnvironment:async(V,ae)=>{if(console.log("[MockGrackle] unlinkEnvironment",{workspaceId:V,environmentId:ae}),ae==="error-env"){x("Failed to unlink environment");return}x(""),v(le=>le.map(de=>de.id!==V?de:{...de,linkedEnvironmentIds:de.linkedEnvironmentIds.filter(ye=>ye!==ae)}))},linkOperationError:b,clearLinkOperationError:()=>{x("")},domainHook:_s},tasks:{tasks:S,tasksLoading:!1,taskStartingId:void 0,loadTasks:oa,loadAllTasks:async()=>{console.log("[MockGrackle] loadAllTasks")},createTask:Za,startTask:ms,stopTask:async V=>{console.log("[MockGrackle] stopTask",{taskId:V}),await wn(V)},completeTask:wn,resumeTask:Re,updateTask:Je,deleteTask:Jt,domainHook:_s},findings:{findings:w,selectedFinding:T,findingLoading:D,findingsLoading:!1,loadFindings:St,loadAllFindings:un,loadFinding:Wt,postFinding:Oi,domainHook:_s},tokens:{tokens:B,tokensLoading:!1,loadTokens:Ya,setToken:Ja,deleteToken:hs,domainHook:_s},credentials:{credentialProviders:A,credentialsLoading:!1,updateCredentialProviders:Wa,domainHook:_s},codespaces:{codespaces:[],codespaceError:"",codespaceListError:"",codespaceCreating:!1,listCodespaces:async()=>{},createCodespace:async()=>{},domainHook:_s},personas:{personas:I,personasLoading:!1,createPersona:async(V,ae,le,de,ye,We,Te,Ie,Ke)=>{console.log("[MockGrackle] createPersona",{name:V});const ct={id:`mock-persona-${Date.now()}`,name:V,description:ae,systemPrompt:le,toolConfig:"{}",runtime:de??"claude-code",model:ye||"",maxTurns:We||0,mcpServers:"[]",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),type:Te||"agent",script:Ie||"",allowedMcpTools:Ke||[]};return U(Xe=>[...Xe,ct]),ct},updatePersona:async(V,ae,le,de,ye,We,Te,Ie,Ke,ct)=>{console.log("[MockGrackle] updatePersona",{personaId:V,name:ae});const Xe=I.find(Ue=>Ue.id===V);if(!Xe)throw new Error(`Persona not found: ${V}`);const Xt=new Date().toISOString(),jt={...Xe,...ae!==void 0?{name:ae}:{},...le!==void 0?{description:le}:{},...de!==void 0?{systemPrompt:de}:{},...ye!==void 0?{runtime:ye}:{},...We!==void 0?{model:We}:{},...Te!==void 0?{maxTurns:Te}:{},...Ie!==void 0?{type:Ie}:{},...Ke!==void 0?{script:Ke}:{},...ct!==void 0?{allowedMcpTools:ct}:{},updatedAt:Xt};return U(Ue=>Ue.map(It=>It.id===V?jt:It)),jt},deletePersona:async V=>{console.log("[MockGrackle] deletePersona",V),U(ae=>ae.filter(le=>le.id!==V))},domainHook:_s},knowledge:{graphData:{nodes:pe,links:ie},selectedNode:Z,loading:!1,selectedId:ce,searchQuery:ge,search:async V=>{if(console.log("[MockGrackle] knowledge.search",V),!V.trim()){fe(V);return}fe(V);const ae=Ce.current,le=ae?ks.filter(Te=>!Te.workspaceId||Te.workspaceId===ae):ks,de=V.toLowerCase(),ye=le.filter(Te=>{var Ie,Ke,ct;return Te.label.toLowerCase().includes(de)||((Ie=Te.content)==null?void 0:Ie.toLowerCase().includes(de))||((Ke=Te.tags)==null?void 0:Ke.some(Xe=>Xe.toLowerCase().includes(de)))||((ct=Te.category)==null?void 0:ct.toLowerCase().includes(de))});H(ye);const We=new Set(ye.map(Te=>Te.id));L(Ra.filter(Te=>We.has(Te.source)&&We.has(Te.target))),X(void 0),J(void 0)},clearSearch:()=>{console.log("[MockGrackle] knowledge.clearSearch"),fe("");const V=Ce.current,ae=V?ks.filter(de=>!de.workspaceId||de.workspaceId===V):ks;H(ae);const le=new Set(ae.map(de=>de.id));L(Ra.filter(de=>le.has(de.source)&&le.has(de.target)))},selectNode:async V=>{console.log("[MockGrackle] knowledge.selectNode",V),X(V);const ae=V in Zb?Zb[V]:void 0;if(ae)J(ae);else{const le=ks.find(de=>de.id===V);if(le){const de=Ra.filter(ye=>ye.source===V||ye.target===V).map(ye=>({fromId:ye.source,toId:ye.target,type:ye.type}));J({node:le,edges:de})}}},clearSelection:()=>{console.log("[MockGrackle] knowledge.clearSelection"),X(void 0),J(void 0)},expandNode:async V=>{console.log("[MockGrackle] knowledge.expandNode",V),H(ae=>{const le=new Set(ae.map(Ie=>Ie.id)),de=Ra.filter(Ie=>Ie.source===V||Ie.target===V),ye=new Set;for(const Ie of de)le.has(Ie.source)||ye.add(Ie.source),le.has(Ie.target)||ye.add(Ie.target);if(ye.size===0)return ae;const We=ks.filter(Ie=>ye.has(Ie.id)),Te=new Set([...le,...ye]);return L(Ie=>{const Ke=new Set(Ie.map(Xe=>`${Xe.source}|${Xe.target}|${Xe.type}`)),ct=Ra.filter(Xe=>Te.has(Xe.source)&&Te.has(Xe.target)&&!Ke.has(`${Xe.source}|${Xe.target}|${Xe.type}`));return ct.length>0?[...Ie,...ct]:Ie}),[...ae,...We]})},loadRecent:async V=>{if(console.log("[MockGrackle] knowledge.loadRecent",V),Ce.current=V,V){const ae=ks.filter(de=>!de.workspaceId||de.workspaceId===V);H(ae);const le=new Set(ae.map(de=>de.id));L(Ra.filter(de=>le.has(de.source)&&le.has(de.target)))}else H(ks),L(Ra);fe("")},handleEvent:()=>!1,domainHook:_s},appDefaultPersonaId:$,setAppDefaultPersonaId:async V=>{console.log("[MockGrackle] setAppDefaultPersonaId",V),W(V)},onboardingCompleted:!0,completeOnboarding:async()=>{console.log("[MockGrackle] completeOnboarding")},usageCache:{"workspace:proj-alpha":{inputTokens:214500,outputTokens:44850,costUsd:1.12,sessionCount:4},"workspace:proj-beta":{inputTokens:86700,outputTokens:23800,costUsd:.48,sessionCount:3},"task:task-001":{inputTokens:126800,outputTokens:20850,costUsd:.63,sessionCount:2},"task:task-006":{inputTokens:18900,outputTokens:4500,costUsd:.1,sessionCount:1},"task_tree:task-001":{inputTokens:126800,outputTokens:20850,costUsd:.63,sessionCount:2},"task_tree:task-006":{inputTokens:18900,outputTokens:4500,costUsd:.1,sessionCount:1}},loadUsage:async(V,ae)=>{console.log(`[MockGrackle] loadUsage(${V}, ${ae})`)},refresh:es}),[s,r,d,p,Q,g,b,S,w,T,B,A,I,$,pe,ie,Z,ce,ge,gt,Ii,ps,aa,Fa,ia,Yt,Mi,oa,Za,ms,wn,Re,Je,Jt,St,un,Wt,Oi,Bi,Li,Ka,Ya,Ja,hs,Wa,es]);return i.jsx(th.Provider,{value:Xa,children:t})}const $7=3e3;function U7(t){const[s,o]=y.useState(!1),r=y.useRef(t.onSessionEvent);r.current=t.onSessionEvent;const c=y.useRef(t.onDomainEvent);c.current=t.onDomainEvent;const d=y.useRef(t.onConnect);d.current=t.onConnect;const u=y.useRef(t.onDisconnect);return u.current=t.onDisconnect,y.useEffect(()=>{let p=!1,m;async function g(){var v,b;if(!p){try{const x=Ne.streamEvents({});o(!0),Promise.resolve((v=d.current)==null?void 0:v.call(d)).catch(()=>{});for await(const S of x){if(p)break;const k=S.event;if(k.case==="sessionEvent"){const w=k.value;r.current({sessionId:w.sessionId,type:w.type,timestamp:w.timestamp,content:w.content,raw:w.raw})}else if(k.case==="domainEvent"){const w=k.value;c.current({id:w.id,type:w.type,timestamp:w.timestamp,payloadJson:w.payloadJson})}}}catch(x){if(x instanceof wi&&x.code===fx.Unauthenticated){window.location.href=rN;return}}p||(o(!1),(b=u.current)==null||b.call(u),m=setTimeout(()=>{g().catch(()=>{})},$7))}}return g().catch(()=>{}),()=>{p=!0,clearTimeout(m),o(!1)}},[]),{connected:s}}const am=["core","orchestration"],G1=y.createContext({pluginNames:[...am],loading:!1,error:void 0});function P7({children:t}){const[s,o]=y.useState([...am]),[r,c]=y.useState(!0),[d,u]=y.useState(void 0);return y.useEffect(()=>{let p=!1;return fetch("/api/manifest").then(async m=>{if(!m.ok)throw new Error(`Manifest fetch returned ${m.status}`);return m.json()}).then(m=>{p||(o(m.plugins.map(g=>g.name)),c(!1))}).catch(m=>{p||(o([...am]),u(m instanceof Error?m:new Error(String(m))),c(!1))}),()=>{p=!0}},[]),i.jsx(G1.Provider,{value:{pluginNames:s,loading:r,error:d},children:t})}function ih(){return y.useContext(G1)}const H7=new Set(["dashboard","chat","environments","settings"]),V7=new Set(["tasks","findings"]),q7=new Set(["knowledge"]),F1={core:{navItems:Jc.filter(t=>H7.has(t.view)),domainHookKeys:["environments","sessions","workspaces","tokens","credentials","codespaces"]},orchestration:{navItems:Jc.filter(t=>V7.has(t.view)),domainHookKeys:["tasks","findings","personas","notifications"]},knowledge:{navItems:Jc.filter(t=>q7.has(t.view)),domainHookKeys:["knowledge"]}};function G7(t){return t.flatMap(s=>{var o;return((o=F1[s])==null?void 0:o.navItems)??[]})}function F7(t){return new Set(t.flatMap(s=>{var o;return((o=F1[s])==null?void 0:o.domainHookKeys)??[]}))}function Z7(t){return{id:t.id,displayName:t.displayName,adapterType:t.adapterType,adapterConfig:t.adapterConfig||"{}",status:t.status,bootstrapped:t.bootstrapped}}function Jb(t){return{id:t.id,environmentId:t.environmentId,runtime:t.runtime,status:t.status,prompt:t.prompt,startedAt:t.startedAt,endedAt:t.endedAt||void 0,error:t.error||void 0,endReason:t.endReason||void 0,personaId:t.personaId||void 0,inputTokens:t.inputTokens,outputTokens:t.outputTokens,costUsd:t.costUsd}}function K7(t){return{sessionId:t.sessionId,eventType:px(t.type),timestamp:t.timestamp,content:t.content,raw:t.raw||void 0}}function Y7(t){return{id:t.id,name:t.name,description:t.description,repoUrl:t.repoUrl,environmentId:t.environmentId,linkedEnvironmentIds:[...t.linkedEnvironmentIds],status:_T(t.status),workingDirectory:t.workingDirectory,useWorktrees:t.useWorktrees,defaultPersonaId:t.defaultPersonaId,tokenBudget:t.tokenBudget,costBudgetMillicents:t.costBudgetMillicents,createdAt:t.createdAt,updatedAt:t.updatedAt}}function Wb(t){return{id:t.id,workspaceId:t.workspaceId??void 0,title:t.title,description:t.description,status:kT(t.status),branch:t.branch,latestSessionId:t.latestSessionId,dependsOn:[...t.dependsOn],sortOrder:t.sortOrder,createdAt:t.createdAt,startedAt:t.startedAt||void 0,completedAt:t.completedAt||void 0,parentTaskId:t.parentTaskId,depth:t.depth,childTaskIds:[...t.childTaskIds],canDecompose:t.canDecompose,defaultPersonaId:t.defaultPersonaId,workpad:t.workpad,tokenBudget:t.tokenBudget,costBudgetMillicents:t.costBudgetMillicents}}function Sp(t){return{id:t.id,workspaceId:t.workspaceId,taskId:t.taskId,sessionId:t.sessionId,category:t.category,title:t.title,content:t.content,tags:[...t.tags],createdAt:t.createdAt}}function J7(t){return{name:t.name,tokenType:t.type,envVar:t.envVar,filePath:t.filePath,expiresAt:t.expiresAt}}function W7(t){return{claude:ST(t.claude),github:Cc(t.github),copilot:Cc(t.copilot),codex:Cc(t.codex),goose:Cc(t.goose)}}function X7(t){return{name:t.name,repository:t.repository,state:t.state,gitStatus:t.gitStatus}}function Tp(t){return{id:t.id,name:t.name,description:t.description,systemPrompt:t.systemPrompt,toolConfig:t.toolConfig?JSON.stringify({allowedTools:[...t.toolConfig.allowedTools],disallowedTools:[...t.toolConfig.disallowedTools]}):"{}",runtime:t.runtime,model:t.model,maxTurns:t.maxTurns,mcpServers:JSON.stringify(t.mcpServers.map(s=>({name:s.name,command:s.command,args:[...s.args],tools:[...s.tools]}))),createdAt:t.createdAt,updatedAt:t.updatedAt,type:t.type||"agent",script:t.script,allowedMcpTools:[...t.allowedMcpTools]}}function Q7(t){return{inputTokens:t.inputTokens,outputTokens:t.outputTokens,costUsd:t.costUsd,sessionCount:t.sessionCount}}function Hc(t,s=0){return{id:t.id,label:t.title||t.label||t.id,kind:t.kind,category:t.category||void 0,sourceType:t.sourceType||void 0,sourceId:t.sourceId||void 0,content:t.content||void 0,tags:t.tags.length>0?[...t.tags]:void 0,workspaceId:t.workspaceId||void 0,createdAt:t.createdAt||void 0,updatedAt:t.updatedAt||void 0,val:s}}function wp(t){return{source:t.fromId,target:t.toId,type:t.type}}function Ga(){const[t,s]=y.useState(!1),o=y.useRef(0),r=y.useCallback(c=>(o.current++,o.current===1&&s(!0),c.finally(()=>{o.current--,o.current===0&&s(!1)})),[]);return{loading:t,track:r}}const Xb=5e3;function Pr(t){return t instanceof wi?t.message:"Operation failed"}function ez(){const[t,s]=y.useState([]),{loading:o,track:r}=Ga(),[c,d]=y.useState({}),[u,p]=y.useState(""),m=y.useCallback(()=>{p("")},[]),g=y.useCallback(async()=>{try{const C=await r(Ne.listEnvironments({}));s(C.environments.map(Z7))}catch{}},[r]),v=y.useCallback(C=>{switch(C.type){case"environment.added":return!0;case"environment.removed":{const D=C.payload.environmentId;return D&&(s(B=>B.filter(E=>E.id!==D)),d(B=>{const E={...B};return delete E[D],E})),!0}case"environment.changed":return g().catch(()=>{}),!0;case"environment.provision_progress":{const D=C.payload;if(typeof D.environmentId!="string"||typeof D.stage!="string"||typeof D.message!="string"||typeof D.progress!="number")return U1("environment.provision_progress","invalid payload"),!0;if(d(B=>({...B,[D.environmentId]:{stage:D.stage,message:D.message,progress:D.progress}})),D.stage==="ready"){const B=D.environmentId;setTimeout(()=>{d(E=>{const A={...E};return delete A[B],A})},Xb)}return!0}default:return!1}},[g]),b=y.useCallback(C=>{var D;if(C.type==="environments"){const B=Array.isArray((D=C.payload)==null?void 0:D.environments)?C.payload.environments:[];return s(B),!0}return!1},[]),x=y.useCallback(async(C,D,B)=>{p("");try{await Ne.addEnvironment({displayName:C,adapterType:D,adapterConfig:JSON.stringify(B??{})})}catch(E){p(Pr(E))}},[]),S=y.useCallback(async(C,D)=>{p("");try{await Ne.updateEnvironment({id:C,displayName:D.displayName,adapterConfig:D.adapterConfig?JSON.stringify(D.adapterConfig):void 0})}catch(B){p(Pr(B))}},[]),k=y.useCallback(async(C,D)=>{p("");try{const B=Ne.provisionEnvironment({id:C,force:D??!1});for await(const E of B)d(A=>({...A,[C]:{stage:E.stage,message:E.message,progress:E.progress}})),E.stage==="ready"&&setTimeout(()=>{d(A=>{const P={...A};return delete P[C],P})},Xb)}catch(B){d(E=>{const A={...E};return delete A[C],A}),p(Pr(B))}},[]),w=y.useCallback(async C=>{p("");try{await Ne.stopEnvironment({id:C})}catch(D){p(Pr(D))}},[]),N=y.useCallback(async C=>{p("");try{await Ne.removeEnvironment({id:C})}catch(D){p(Pr(D))}},[]);return{environments:t,environmentsLoading:o,provisionStatus:c,operationError:u,clearOperationError:m,loadEnvironments:g,addEnvironment:x,updateEnvironment:S,provisionEnvironment:k,stopEnvironment:w,removeEnvironment:N,handleEvent:v,handleLegacyMessage:b,domainHook:{onConnect:()=>g(),onDisconnect:()=>{},handleEvent:v}}}const jp=new Set(["pending","running","idle"]),tz=new Set(["completed","failed","interrupted","hibernating","suspended"]),Qb=["pending","running","idle"];function nz(){const[t,s]=y.useState([]),{loading:o,track:r}=Ga(),[c,d]=y.useState([]),[u,p]=y.useState(0),[m,g]=y.useState(void 0),[v,b]=y.useState({}),x=y.useCallback(async()=>{try{const U=(await r(Ne.listSessions({}))).sessions.map(Jb);s(Q=>{const $=new Map(Q.map(W=>[W.id,W]));return U.map(W=>{const pe=$.get(W.id),H=pe==null?void 0:pe.status;return!H||H===W.status?W:tz.has(H)&&jp.has(W.status)?{...W,status:H,...pe.endReason!==void 0?{endReason:pe.endReason}:{}}:jp.has(H)&&jp.has(W.status)&&Qb.indexOf(H)>Qb.indexOf(W.status)?{...W,status:H}:W})})}catch{}},[r]),S=y.useCallback(I=>{if(I.type!=="session_event")return!1;if(!f7(I.payload))return U1("session_event","payload is not a valid SessionEvent"),!0;const U=I.payload;let Q=0;if(d($=>{const W=[...$,U];return W.length>So?(Q=W.length-So,W.slice(-So)):W}),Q>0&&p($=>$+Q),U.eventType==="usage")try{const $=JSON.parse(U.content),W=Number($.input_tokens)||0,pe=Number($.output_tokens)||0,H=Number($.cost_usd)||0;(W>0||pe>0||H>0)&&s(ie=>ie.map(L=>L.id===U.sessionId?{...L,inputTokens:(L.inputTokens??0)+W,outputTokens:(L.outputTokens??0)+pe,costUsd:(L.costUsd??0)+H}:L))}catch{}if(U.eventType==="status"){const $=P1(U.content),W=H1(U.content);s(pe=>pe.some(ie=>ie.id===U.sessionId)?pe.map(ie=>ie.id===U.sessionId?{...ie,status:$,...W!==void 0?{endReason:W}:{}}:ie):[...pe,{id:U.sessionId,environmentId:"",runtime:"",status:$,prompt:"",startedAt:U.timestamp,...W!==void 0?{endReason:W}:{}}])}return!0},[]),k=y.useCallback(I=>{S({type:"session_event",payload:I})},[S]),w=y.useCallback(I=>{var U,Q,$,W,pe;switch(I.type){case"sessions":{const H=Array.isArray((U=I.payload)==null?void 0:U.sessions)?I.payload.sessions:[];return s(H),!0}case"spawned":{const H=(Q=I.payload)==null?void 0:Q.sessionId;return typeof H=="string"&&H&&g(H),x().catch(()=>{}),!0}case"session_events":{const H=Array.isArray(($=I.payload)==null?void 0:$.events)?I.payload.events:[];return H.length>0&&d(H),!0}case"task_sessions":{const H=(W=I.payload)==null?void 0:W.taskId;if(typeof H=="string"&&H){const ie=Array.isArray((pe=I.payload)==null?void 0:pe.sessions)?I.payload.sessions:[];b(L=>({...L,[H]:ie}))}return!0}default:return!1}},[x]),N=y.useCallback(async(I,U,Q,$)=>{try{const W=await Ne.spawnAgent({environmentId:I,prompt:U,personaId:Q||"",workingDirectory:$||""});g(W.id),await x()}catch{}},[x]),T=y.useCallback(async(I,U)=>{try{await Ne.sendInput({sessionId:I,text:U})}catch{}},[]),C=y.useCallback(async I=>{try{await Ne.killAgent({id:I,graceful:!1})}catch{}},[]),D=y.useCallback(async I=>{try{await Ne.killAgent({id:I,graceful:!0})}catch{}},[]),B=y.useCallback(async I=>{try{const Q=(await Ne.getSessionEvents({id:I})).events.map(K7);if(Q.length>0){let $=0;d(W=>{const pe=new Set;for(const L of W)L.sessionId===I&&pe.add(`${L.timestamp}|${L.eventType}`);const H=Q.filter(L=>!pe.has(`${L.timestamp}|${L.eventType}`)),ie=[...W,...H].sort((L,Z)=>L.sessionId!==Z.sessionId?0:L.timestamp.localeCompare(Z.timestamp));return ie.length>So?($=ie.length-So,ie.slice(-So)):ie}),$>0&&p(W=>W+$)}}catch{}},[]),E=y.useCallback(()=>{d([]),p(0)},[]),A=y.useCallback(async I=>{try{const Q=(await Ne.getTaskSessions({id:I})).sessions.map(Jb);b($=>({...$,[I]:Q}))}catch{}},[]);return{sessions:t,sessionsLoading:o,events:c,eventsDropped:u,lastSpawnedId:m,taskSessions:v,loadSessions:x,spawn:N,sendInput:T,kill:C,stopGraceful:D,loadSessionEvents:B,clearEvents:E,loadTaskSessions:A,handleMessage:S,handleSessionEvent:k,handleLegacyMessage:w,domainHook:{onConnect:()=>x(),onDisconnect:()=>{E()},handleEvent:()=>!1}}}function ex(t){return t instanceof wi?t.message:"Operation failed"}function sz(){const[t,s]=y.useState([]),{loading:o,track:r}=Ga(),[c,d]=y.useState(!1),[u,p]=y.useState(""),m=y.useCallback(async()=>{try{const C=await r(Ne.listWorkspaces({}));s(C.workspaces.map(Y7))}catch{}},[r]),g=y.useCallback(C=>{switch(C.type){case"workspace.created":return d(!1),m().catch(()=>{}),!0;case"workspace.archived":case"workspace.updated":return m().catch(()=>{}),!0;default:return!1}},[m]),v=y.useCallback(()=>{d(!1)},[]),b=y.useCallback(async(C,D,B,E,A,P,I,U,Q)=>{d(!0);try{await Ne.createWorkspace({name:C,description:D||"",repoUrl:B||"",environmentId:E||"",defaultPersonaId:A||void 0,useWorktrees:P??!0,workingDirectory:I||void 0}),d(!1),U==null||U()}catch($){d(!1);const W=$ instanceof wi?$.message:"Failed to create workspace";Q==null||Q(W)}},[]),x=y.useCallback(async C=>{try{await Ne.archiveWorkspace({id:C})}catch{}},[]),S=y.useCallback(async(C,D)=>{try{await Ne.updateWorkspace({id:C,...D})}catch{}},[]),k=y.useCallback(()=>{p("")},[]),w=y.useCallback(async(C,D)=>{try{p(""),await Ne.linkEnvironment({workspaceId:C,environmentId:D}),await m().catch(()=>{})}catch(B){p(ex(B))}},[m]),N=y.useCallback(async(C,D)=>{try{p(""),await Ne.unlinkEnvironment({workspaceId:C,environmentId:D}),await m().catch(()=>{})}catch(B){p(ex(B))}},[m]);return{workspaces:t,workspacesLoading:o,workspaceCreating:c,loadWorkspaces:m,createWorkspace:b,archiveWorkspace:x,updateWorkspace:S,linkEnvironment:w,unlinkEnvironment:N,linkOperationError:u,clearLinkOperationError:k,handleEvent:g,onDisconnect:v,domainHook:{onConnect:()=>m(),onDisconnect:v,handleEvent:g}}}function az(){const[t,s]=y.useState([]),{loading:o,track:r}=Ga(),[c,d]=y.useState(void 0),u=y.useRef({}),p=y.useCallback(async E=>{try{const P=(await Ne.listTasks({workspaceId:E})).tasks.map(Wb);s(I=>[...I.filter(U=>U.workspaceId!==E),...P])}catch{}},[]),m=y.useCallback(async()=>{try{const A=(await r(Ne.listTasks({}))).tasks.map(Wb);s(P=>{const I=new Set(A.map(U=>U.id));return[...P.filter(U=>!I.has(U.id)),...A]})}catch{}},[r]),g=y.useCallback((E,A)=>{const P=I=>{clearTimeout(u.current[I]),u.current[I]=setTimeout(()=>{delete u.current[I],p(I).catch(()=>{})},200)};E?P(E):A&&s(I=>{const U=I.find(Q=>Q.id===A);return U!=null&&U.workspaceId?P(U.workspaceId):m().catch(()=>{}),I})},[p,m]),v=y.useCallback(E=>{const A=E.payload;switch(E.type){case"task.created":{const P=typeof A.workspaceId=="string"?A.workspaceId:"";return P&&p(P).catch(()=>{}),!0}case"task.started":{const P=typeof A.taskId=="string"?A.taskId:"",I=typeof A.sessionId=="string"?A.sessionId:"",U=typeof A.workspaceId=="string"?A.workspaceId:"";return d(Q=>P&&Q===P?void 0:Q),I&&P&&s(Q=>Q.map($=>$.id===P?{...$,latestSessionId:I}:$)),g(U,P),!0}case"task.completed":case"task.deleted":case"task.reparented":case"task.updated":{const P=typeof A.workspaceId=="string"?A.workspaceId:"",I=typeof A.taskId=="string"?A.taskId:"";return d(U=>I&&U===I?void 0:U),g(P,I),!0}default:return!1}},[p,g]),b=y.useCallback(()=>{d(void 0)},[]),x=y.useCallback(E=>{var A,P;if(E.type==="tasks"){const I=Array.isArray((A=E.payload)==null?void 0:A.tasks)?E.payload.tasks:[],U=typeof((P=E.payload)==null?void 0:P.workspaceId)=="string"&&E.payload.workspaceId?E.payload.workspaceId:"";return s(U?Q=>[...Q.filter($=>$.workspaceId!==U),...I]:Q=>{const $=new Set(I.map(W=>W.id));return[...Q.filter(W=>!$.has(W.id)),...I]}),!0}return!1},[]),S=y.useCallback(async(E,A,P,I,U,Q,$,W,pe)=>{try{await Ne.createTask({workspaceId:E,title:A,description:P||"",dependsOn:I||[],parentTaskId:U||"",defaultPersonaId:Q||void 0,canDecompose:$??void 0}),W==null||W()}catch(H){const ie=H instanceof wi?H.message:"Failed to create task";pe==null||pe(ie)}},[]),k=y.useCallback(async(E,A,P,I)=>{d(E);try{await Ne.startTask({taskId:E,personaId:A||"",environmentId:P||"",notes:I||""})}catch(U){if(U instanceof wi&&U.code===fx.ResourceExhausted)return;d(void 0)}},[]),w=y.useCallback(async E=>{try{await Ne.stopTask({id:E})}catch{}},[]),N=y.useCallback(async E=>{try{await Ne.completeTask({id:E})}catch{}},[]),T=y.useCallback(async E=>{try{await Ne.resumeTask({id:E})}catch{}},[]),C=y.useCallback(async(E,A,P,I,U)=>{try{await Ne.updateTask({id:E,title:A,description:P,dependsOn:I,...U!==void 0?{defaultPersonaId:U}:{}})}catch{}},[]),D=y.useCallback(async E=>{try{await Ne.deleteTask({id:E})}catch{}},[]);return{tasks:t,tasksLoading:o,taskStartingId:c,loadTasks:p,loadAllTasks:m,createTask:S,startTask:k,stopTask:w,completeTask:N,resumeTask:T,updateTask:C,deleteTask:D,handleEvent:v,onDisconnect:b,handleLegacyMessage:x,domainHook:{onConnect:()=>m(),onDisconnect:b,handleEvent:v}}}function iz(){const[t,s]=y.useState([]),[o,r]=y.useState(void 0),[c,d]=y.useState(!1),{loading:u,track:p}=Ga(),m=y.useCallback(async k=>{try{const w=await p(Ne.queryFindings({workspaceId:k}));s(w.findings.map(Sp))}catch{}},[p]),g=y.useCallback(async()=>{try{const k=await p(Ne.queryFindings({workspaceId:""}));s(k.findings.map(Sp))}catch{}},[p]),v=y.useCallback(async k=>{r(void 0),d(!0);try{const w=await Ne.getFinding({id:k});r(Sp(w))}catch{r(void 0)}finally{d(!1)}},[]),b=y.useCallback(k=>{if(k.type==="finding.posted"){const w=typeof k.payload.workspaceId=="string"?k.payload.workspaceId:"";return w&&m(w).catch(()=>{}),!0}return!1},[m]),x=y.useCallback(async(k,w,N,T,C)=>{try{await Ne.postFinding({workspaceId:k,title:w,content:N,category:T??"general",tags:C??[]})}catch{}},[]);return{findings:t,selectedFinding:o,findingLoading:c,findingsLoading:u,loadFindings:m,loadAllFindings:g,loadFinding:v,postFinding:x,handleEvent:b,domainHook:{onConnect:()=>g(),onDisconnect:()=>{},handleEvent:b}}}function oz(){const[t,s]=y.useState([]),{loading:o,track:r}=Ga(),c=y.useCallback(async()=>{try{const g=await r(Ne.listTokens({}));s(g.tokens.map(J7))}catch{}},[r]),d=y.useCallback(g=>g.type==="token.changed"?(c().catch(()=>{}),!0):!1,[c]),u=y.useCallback(async(g,v,b,x,S)=>{try{await Ne.setToken({name:g,value:v,type:b,envVar:x,filePath:S})}catch{}},[]),p=y.useCallback(async g=>{try{await Ne.deleteToken({name:g})}catch{}},[]);return{tokens:t,tokensLoading:o,loadTokens:c,setToken:u,deleteToken:p,handleEvent:d,domainHook:{onConnect:()=>c(),onDisconnect:()=>{},handleEvent:d}}}function rz(){const[t,s]=y.useState({claude:"off",github:"off",copilot:"off",codex:"off",goose:"off"}),{loading:o,track:r}=Ga(),c=y.useCallback(async()=>{try{const m=await r(Ne.getCredentialProviders({}));s(W7(m))}catch{}},[r]),d=y.useCallback(m=>m.type==="credential.providers_changed"?(m7(m.payload)&&s(m.payload),!0):!1,[]),u=y.useCallback(async m=>{const g=[{provider:"claude",value:m.claude},{provider:"github",value:m.github},{provider:"copilot",value:m.copilot},{provider:"codex",value:m.codex},{provider:"goose",value:m.goose}];await Promise.allSettled(g.map(({provider:v,value:b})=>Ne.setCredentialProvider({provider:v,value:b})))},[]);return{credentialProviders:t,credentialsLoading:o,loadCredentials:c,updateCredentialProviders:u,handleEvent:d,domainHook:{onConnect:()=>c(),onDisconnect:()=>{},handleEvent:d}}}function lz(){const[t,s]=y.useState([]),[o,r]=y.useState(""),[c,d]=y.useState(""),[u,p]=y.useState(!1),m=y.useCallback(async()=>{try{const b=await Ne.listCodespaces({});s(b.codespaces.map(X7)),d(b.error)}catch{}},[]),g=y.useCallback(async(b,x)=>{p(!0),r("");try{await Ne.createCodespace({repo:b,machine:x??""}),p(!1),await m()}catch(S){p(!1);const k=S instanceof wi?S.message:"Failed to create codespace";r(k)}},[m]);return{codespaces:t,codespaceError:o,codespaceListError:c,codespaceCreating:u,listCodespaces:m,createCodespace:g,domainHook:{onConnect:()=>m(),onDisconnect:()=>{},handleEvent:()=>!1}}}function cz(){const[t,s]=y.useState([]),{loading:o,track:r}=Ga(),c=y.useCallback(async()=>{try{const v=await r(Ne.listPersonas({}));s(v.personas.map(Tp))}catch{}},[r]),d=y.useCallback(v=>{switch(v.type){case"persona.created":case"persona.updated":case"persona.deleted":return c().catch(()=>{}),!0;default:return!1}},[c]),u=y.useCallback(async(v,b,x,S,k,w,N,T,C)=>{const D=await Ne.createPersona({name:v,description:b,systemPrompt:x,runtime:S||"",model:k||"",maxTurns:w||0,type:N||"agent",script:T||"",allowedMcpTools:C||[]}),B=Tp(D);return s(E=>[...E.filter(A=>A.id!==B.id),B]),B},[]),p=y.useCallback(async(v,b,x,S,k,w,N,T,C,D)=>{const B={id:v};b!==void 0&&(B.name=b),x!==void 0&&(B.description=x),S!==void 0&&(B.systemPrompt=S),k!==void 0&&(B.runtime=k),w!==void 0&&(B.model=w),N!==void 0&&(B.maxTurns=N),T!==void 0&&(B.type=T),C!==void 0&&(B.script=C),D!==void 0&&(B.allowedMcpTools={tools:D});const E=await Ne.updatePersona(B),A=Tp(E);return s(P=>P.map(I=>I.id===A.id?A:I)),A},[]),m=y.useCallback(async v=>{await Ne.deletePersona({id:v}),s(b=>b.filter(x=>x.id!==v))},[]);return{personas:t,personasLoading:o,loadPersonas:c,createPersona:u,updatePersona:p,deletePersona:m,handleEvent:d,domainHook:{onConnect:()=>c(),onDisconnect:()=>{},handleEvent:d}}}function dz(t){if(t)try{return JSON.parse(t)}catch{return}}function uz(){const[t,s]=y.useState(new Map),[o,r]=y.useState([]),[c,d]=y.useState(void 0),[u,p]=y.useState(void 0),[m,g]=y.useState(!1),[v,b]=y.useState(""),x=y.useRef(""),S=y.useCallback(async E=>{const A=E??"";x.current=A,b(""),g(!0);try{const P=await Ne.listRecentKnowledgeNodes({limit:30,workspaceId:A}),I=new Map,U=[];for(const Q of P.nodes)I.set(Q.id,Hc(Q));for(const Q of P.edges)U.push(wp(Q));for(const Q of U){const $=I.get(Q.source);$&&($.val+=1);const W=I.get(Q.target);W&&(W.val+=1)}s(I),r(U)}catch{}finally{g(!1)}},[]),k=y.useCallback(async E=>{if(E.trim()){b(E),p(void 0),d(void 0),g(!0);try{const A=await Ne.searchKnowledge({query:E,limit:20,workspaceId:x.current}),P=new Map,I=[];for(const U of A.results){U.node&&P.set(U.node.id,Hc(U.node,U.edges.length));for(const Q of U.edges)I.push(wp(Q))}s(P),r(I)}catch{}finally{g(!1)}}},[]),w=y.useCallback(()=>{S(x.current).catch(()=>{})},[S]),N=y.useCallback(async E=>{p(E);try{const A=await Ne.getKnowledgeNode({id:E});if(!A.node){d(void 0);return}d({node:Hc(A.node,A.edges.length),edges:A.edges.map(P=>({fromId:P.fromId,toId:P.toId,type:P.type,metadata:dz(P.metadataJson)}))})}catch{d(void 0)}},[]),T=y.useCallback(()=>{p(void 0),d(void 0)},[]),C=y.useCallback(async E=>{try{const A=await Ne.expandKnowledgeNode({id:E,depth:1});s(P=>{const I=new Map(P);for(const U of A.nodes)I.has(U.id)||I.set(U.id,Hc(U));return I}),r(P=>{const I=new Set(P.map(Q=>`${Q.source}:${Q.target}:${Q.type}`)),U=[];for(const Q of A.edges){const $=wp(Q),W=`${$.source}:${$.target}:${$.type}`;I.has(W)||U.push($)}return[...P,...U]})}catch{}},[]),D=y.useCallback(E=>!1,[]),B={onConnect:async()=>{},onDisconnect:()=>{},handleEvent:D};return{graphData:{nodes:[...t.values()],links:o},selectedNode:c,selectedId:u,loading:m,searchQuery:v,search:k,clearSearch:w,selectNode:N,clearSelection:T,expandNode:C,loadRecent:S,handleEvent:D,domainHook:B}}function fz(){const t=y.useRef("default");y.useEffect(()=>{typeof Notification>"u"||(t.current=Notification.permission)},[]);function s(r){if(r.type!=="notification.escalated")return!1;if(typeof Notification>"u")return!0;if(t.current==="default")return Notification.requestPermission().then(u=>{t.current=u}).catch(()=>{}),!0;if(t.current!=="granted")return!0;const c=r.payload,d=new Notification(c.title||"Agent needs input",{body:c.message||"An agent is waiting for your input.",tag:c.escalationId,icon:"/icon-192x192.png"});return d.onclick=()=>{window.focus(),c.taskUrl&&(window.location.href=c.taskUrl),d.close()},!0}return{handleEvent:s,domainHook:{onConnect:async()=>{},onDisconnect:()=>{},handleEvent:s}}}function pz(){const[t,s]=y.useState(""),[o,r]=y.useState(void 0),[c,d]=y.useState({}),{pluginNames:u}=ih(),p=F7(u),m=ez(),g=nz(),v=sz(),b=az(),x=iz(),S=oz(),k=rz(),w=lz(),N=cz(),T=uz(),C=fz(),D=[...p.has("environments")?[m.domainHook]:[],...p.has("sessions")?[g.domainHook]:[],...p.has("workspaces")?[v.domainHook]:[],...p.has("tasks")?[b.domainHook]:[],...p.has("findings")?[x.domainHook]:[],...p.has("tokens")?[S.domainHook]:[],...p.has("credentials")?[k.domainHook]:[],...p.has("codespaces")?[w.domainHook]:[],...p.has("personas")?[N.domainHook]:[],...p.has("knowledge")?[T.domainHook]:[],...p.has("notifications")?[C.domainHook]:[]],{connected:B}=U7({onSessionEvent:H=>{g.handleSessionEvent({sessionId:H.sessionId,eventType:px(H.type),timestamp:H.timestamp,content:H.content,raw:H.raw||void 0})},onDomainEvent:H=>{try{const ie=JSON.parse(H.payloadJson);Q({id:H.id,type:H.type,timestamp:H.timestamp,payload:ie})}catch{console.warn("[grackle] Failed to parse domain event payloadJson:",H.payloadJson)}},onConnect:$,onDisconnect:W}),E="default_persona_id",A="onboarding_completed",P=y.useCallback(async H=>{const ie=await Ne.setSetting({key:E,value:H});s(ie.value)},[]),I=y.useCallback(async()=>{r(!0);try{await Ne.setSetting({key:A,value:"true"})}catch{}},[]),U=y.useCallback(async(H,ie)=>{try{const L=await Ne.getUsage({scope:H,id:ie}),Z=`${H}:${ie}`;d(J=>({...J,[Z]:Q7(L)}))}catch{}},[]);function Q(H){const ie=H.payload.key,L=H.payload.value;if(H.type==="setting.changed"){ie===E&&s(L??""),ie===A&&r(L==="true");return}for(const Z of D)if(Z.handleEvent(H))break;(H.type==="environment.removed"||H.type==="environment.changed"||H.type==="task.started")&&g.loadSessions().catch(()=>{})}async function $(){for(const H of D)H.onConnect().catch(()=>{});try{const H=await Ne.getSetting({key:E});s(H.value)}catch{}try{const H=await Ne.getSetting({key:A});r(H.value==="true")}catch{}}function W(){D.forEach(H=>H.onDisconnect())}const pe=y.useCallback(()=>{m.loadEnvironments().catch(()=>{}),g.loadSessions().catch(()=>{}),v.loadWorkspaces().catch(()=>{}),S.loadTokens().catch(()=>{})},[m.loadEnvironments,g.loadSessions,v.loadWorkspaces,S.loadTokens]);return{connected:B,environments:{environments:m.environments,environmentsLoading:m.environmentsLoading,provisionStatus:m.provisionStatus,operationError:m.operationError,clearOperationError:m.clearOperationError,loadEnvironments:m.loadEnvironments,addEnvironment:m.addEnvironment,updateEnvironment:m.updateEnvironment,provisionEnvironment:m.provisionEnvironment,stopEnvironment:m.stopEnvironment,removeEnvironment:m.removeEnvironment,domainHook:m.domainHook},sessions:{sessions:g.sessions,sessionsLoading:g.sessionsLoading,events:g.events,eventsDropped:g.eventsDropped,lastSpawnedId:g.lastSpawnedId,taskSessions:g.taskSessions,spawn:g.spawn,sendInput:g.sendInput,kill:g.kill,stopGraceful:g.stopGraceful,loadSessionEvents:g.loadSessionEvents,clearEvents:g.clearEvents,loadTaskSessions:g.loadTaskSessions,domainHook:g.domainHook},workspaces:{workspaces:v.workspaces,workspacesLoading:v.workspacesLoading,workspaceCreating:v.workspaceCreating,loadWorkspaces:v.loadWorkspaces,createWorkspace:v.createWorkspace,archiveWorkspace:v.archiveWorkspace,updateWorkspace:v.updateWorkspace,linkEnvironment:v.linkEnvironment,unlinkEnvironment:v.unlinkEnvironment,linkOperationError:v.linkOperationError,clearLinkOperationError:v.clearLinkOperationError,domainHook:v.domainHook},tasks:{tasks:b.tasks,tasksLoading:b.tasksLoading,taskStartingId:b.taskStartingId,loadTasks:b.loadTasks,loadAllTasks:b.loadAllTasks,createTask:b.createTask,startTask:b.startTask,stopTask:b.stopTask,completeTask:b.completeTask,resumeTask:b.resumeTask,updateTask:b.updateTask,deleteTask:b.deleteTask,domainHook:b.domainHook},findings:{findings:x.findings,selectedFinding:x.selectedFinding,findingLoading:x.findingLoading,findingsLoading:x.findingsLoading,loadFindings:x.loadFindings,loadAllFindings:x.loadAllFindings,loadFinding:x.loadFinding,postFinding:x.postFinding,domainHook:x.domainHook},tokens:{tokens:S.tokens,tokensLoading:S.tokensLoading,loadTokens:S.loadTokens,setToken:S.setToken,deleteToken:S.deleteToken,domainHook:S.domainHook},credentials:{credentialProviders:k.credentialProviders,credentialsLoading:k.credentialsLoading,updateCredentialProviders:k.updateCredentialProviders,domainHook:k.domainHook},codespaces:{codespaces:w.codespaces,codespaceError:w.codespaceError,codespaceListError:w.codespaceListError,codespaceCreating:w.codespaceCreating,listCodespaces:w.listCodespaces,createCodespace:w.createCodespace,domainHook:w.domainHook},personas:{personas:N.personas,personasLoading:N.personasLoading,createPersona:N.createPersona,updatePersona:N.updatePersona,deletePersona:N.deletePersona,domainHook:N.domainHook},knowledge:T,appDefaultPersonaId:t,setAppDefaultPersonaId:P,onboardingCompleted:o,completeOnboarding:I,usageCache:c,loadUsage:U,refresh:pe}}function mz({children:t}){const s=pz();return i.jsx(th.Provider,{value:s,children:t})}function hz(t,s){const o=y.useRef(null);y.useEffect(()=>{const r=o.current;if(o.current=t,r===null)return;const c=new Map;for(const u of r)c.set(u.id,u);const d=new Set;for(const u of t){d.add(u.id);const p=c.get(u.id);if(p&&p.status!==u.status&&u.status!=="sleeping"){if(u.status==="connecting"){s("Provisioning environment…","info");continue}u.status==="connected"?s("Environment connected","success"):u.status==="error"?s("Environment provision failed","error"):u.status==="disconnected"&&(p.status==="connected"?s("Environment disconnected","warning"):s("Environment stopped","info"))}}for(const u of r)d.has(u.id)||s("Environment removed","info")},[t,s])}function gz(t,s,o){const r=y.useRef(t);y.useEffect(()=>{t&&t!==r.current&&(o(t,"error"),s()),r.current=t},[t,s,o])}const vz={working:{message:"Task is now running",variant:"info"},paused:{message:"Task paused",variant:"warning"},complete:{message:"Task complete",variant:"success"},failed:{message:"Task failed to complete",variant:"error"}};function yz(t){return vz[t]}function bz(t,s){if(t===void 0)return[];const o=[],r=new Map;for(const d of t)r.set(d.id,d);const c=new Set;for(const d of s){c.add(d.id);const u=r.get(d.id);if(!u||u.status===d.status)continue;const p=yz(d.status);p&&o.push(p)}for(const d of t)c.has(d.id)||o.push({message:"Task deleted",variant:"info"});return o}function xz(t,s){const o=y.useRef(void 0);y.useEffect(()=>{const r=o.current;o.current=t;const c=bz(r,t);for(const d of c)s(d.message,d.variant)},[t,s])}const _z="_dashboard_16pzm_1",kz="_kpiStrip_16pzm_11",Sz="_kpiCard_16pzm_23",Tz="_kpiValue_16pzm_68",wz="_kpiLabel_16pzm_76",jz="_bodyGrid_16pzm_84",Nz="_section_16pzm_96",Cz="_sectionHeader_16pzm_109",Ez="_sectionIcon_16pzm_118",Az="_sectionTitle_16pzm_123",Dz="_sectionCount_16pzm_131",Rz="_sectionBody_16pzm_138",Mz="_emptyHint_16pzm_143",Iz="_sessionRow_16pzm_150",Oz="_sessionPrompt_16pzm_177",Bz="_sessionEnv_16pzm_186",Lz="_sessionRuntime_16pzm_192",zz="_sessionStatus_16pzm_198",$z="_statusDot_16pzm_207",Uz="_attentionRow_16pzm_233",Pz="_attentionTitle_16pzm_259",Hz="_attentionMeta_16pzm_267",Vz="_reasonBadge_16pzm_274",qz="_bottomGrid_16pzm_301",Gz="_envRow_16pzm_312",Fz="_envName_16pzm_323",Zz="_envStatusBadge_16pzm_333",Kz="_workspaceRow_16pzm_369",Yz="_workspaceTop_16pzm_395",Jz="_workspaceName_16pzm_401",Wz="_workspaceCounts_16pzm_407",Xz="_progressBar_16pzm_415",Qz="_progressFill_16pzm_422",ue={dashboard:_z,kpiStrip:kz,kpiCard:Sz,kpiValue:Tz,kpiLabel:wz,bodyGrid:jz,section:Nz,sectionHeader:Cz,sectionIcon:Ez,sectionTitle:Az,sectionCount:Dz,sectionBody:Rz,emptyHint:Mz,sessionRow:Iz,sessionPrompt:Oz,sessionEnv:Bz,sessionRuntime:Lz,sessionStatus:zz,statusDot:$z,attentionRow:Uz,attentionTitle:Pz,attentionMeta:Hz,reasonBadge:Vz,bottomGrid:qz,envRow:Gz,envName:Fz,envStatusBadge:Zz,workspaceRow:Kz,workspaceTop:Yz,workspaceName:Jz,workspaceCounts:Wz,progressBar:Xz,progressFill:Qz};function e$(){return i.jsxs("div",{className:ue.dashboard,"aria-hidden":"true",children:[i.jsx("div",{className:ue.kpiStrip,children:Array.from({length:4},(t,s)=>i.jsxs("div",{className:ue.kpiCard,children:[i.jsx(we,{width:"3rem",height:"2rem"}),i.jsx(we,{width:"80%",height:"0.75rem"})]},s))}),i.jsxs("div",{className:ue.bodyGrid,children:[i.jsxs("div",{className:ue.section,children:[i.jsxs("div",{className:ue.sectionHeader,children:[i.jsx(we,{width:"1rem",height:"1rem",variant:"circular"}),i.jsx(we,{width:"8rem",height:"0.75rem"}),i.jsx("span",{className:ue.sectionCount,children:i.jsx(we,{width:"1rem",height:"0.75rem"})})]}),i.jsx("div",{className:ue.sectionBody,children:Array.from({length:3},(t,s)=>i.jsxs("div",{className:ue.sessionRow,style:{cursor:"default"},children:[i.jsx(we,{width:"60%",height:"0.875rem"}),i.jsx(we,{width:"4rem",height:"0.75rem"}),i.jsx(we,{width:"3rem",height:"0.75rem"}),i.jsx(we,{width:"3rem",height:"0.75rem"})]},s))})]}),i.jsxs("div",{className:ue.section,children:[i.jsxs("div",{className:ue.sectionHeader,children:[i.jsx(we,{width:"1rem",height:"1rem",variant:"circular"}),i.jsx(we,{width:"8rem",height:"0.75rem"}),i.jsx("span",{className:ue.sectionCount,children:i.jsx(we,{width:"1rem",height:"0.75rem"})})]}),i.jsx("div",{className:ue.sectionBody,children:Array.from({length:2},(t,s)=>i.jsxs("div",{className:ue.attentionRow,style:{cursor:"default"},children:[i.jsxs("div",{className:ue.attentionTitle,children:[i.jsx(we,{width:"3rem",height:"0.875rem",borderRadius:"var(--radius-sm)"}),i.jsx(we,{width:"70%",height:"0.875rem"})]}),i.jsx("div",{className:ue.attentionMeta,children:i.jsx(we,{width:"5rem",height:"0.625rem"})})]},s))})]})]}),i.jsxs("div",{className:ue.bottomGrid,children:[i.jsxs("div",{className:ue.section,children:[i.jsxs("div",{className:ue.sectionHeader,children:[i.jsx(we,{width:"1rem",height:"1rem",variant:"circular"}),i.jsx(we,{width:"9rem",height:"0.75rem"}),i.jsx("span",{className:ue.sectionCount,children:i.jsx(we,{width:"1rem",height:"0.75rem"})})]}),i.jsx("div",{className:ue.sectionBody,children:Array.from({length:2},(t,s)=>i.jsxs("div",{className:ue.envRow,children:[i.jsx(we,{width:"60%",height:"0.875rem"}),i.jsx(we,{width:"4rem",height:"0.875rem",borderRadius:"var(--radius-sm)"})]},s))})]}),i.jsxs("div",{className:ue.section,children:[i.jsxs("div",{className:ue.sectionHeader,children:[i.jsx(we,{width:"1rem",height:"1rem",variant:"circular"}),i.jsx(we,{width:"6rem",height:"0.75rem"}),i.jsx("span",{className:ue.sectionCount,children:i.jsx(we,{width:"1rem",height:"0.75rem"})})]}),i.jsx("div",{className:ue.sectionBody,children:Array.from({length:2},(t,s)=>i.jsxs("div",{className:ue.workspaceRow,style:{cursor:"default"},children:[i.jsxs("div",{className:ue.workspaceTop,children:[i.jsx(we,{width:"50%",height:"0.875rem"}),i.jsx(we,{width:"2rem",height:"0.75rem"})]}),i.jsx("div",{className:ue.progressBar,children:i.jsx("div",{className:ue.progressFill,style:{width:"0%"}})})]},s))})]})]})]})}const t$={hidden:{opacity:0,y:12},visible:t=>({opacity:1,y:0,transition:{delay:t*.06,duration:.3,ease:"easeOut"}})},Vc={hidden:{opacity:0,y:16},visible:t=>({opacity:1,y:0,transition:{delay:.15+t*.08,duration:.35,ease:"easeOut"}})};function n$(t,s,o,r){const c=[`${t} of ${s} tasks completed`];return o>0&&c.push(`${o} in progress`),r>0&&c.push(`${r} failed`),c.join(", ")}function qc({value:t,label:s,accent:o,index:r,testId:c}){return i.jsxs(Rt.div,{className:ue.kpiCard,"data-accent":o,"data-testid":c,variants:t$,initial:"hidden",animate:"visible",custom:r,children:[i.jsx("span",{className:ue.kpiValue,children:t}),i.jsx("span",{className:ue.kpiLabel,children:s})]})}function s$(){const{workspaces:{workspaces:t,workspacesLoading:s},tasks:{tasks:o,tasksLoading:r,loadTasks:c},sessions:{sessions:d,sessionsLoading:u},environments:{environments:p,environmentsLoading:m}}=mt(),g=kt(),v=y.useRef(new Set);y.useEffect(()=>{for(const N of t)v.current.has(N.id)||(v.current.add(N.id),c(N.id).catch(()=>{}))},[t,c]);const b=y.useMemo(()=>w7(d,o,p),[d,o,p]),x=y.useMemo(()=>N7(d,p),[d,p]),S=y.useMemo(()=>j7(o,t),[o,t]),k=y.useMemo(()=>C7(t,o),[t,o,p]);return d.length===0&&o.length===0&&p.length===0&&t.length===0&&(u||r||m||s)?i.jsx(e$,{}):i.jsxs("div",{className:ue.dashboard,"data-testid":"dashboard",children:[i.jsxs("div",{className:ue.kpiStrip,"data-testid":"dashboard-kpi-strip",children:[i.jsx(qc,{value:b.activeSessions,label:"Active Sessions",accent:"green",index:0,testId:"kpi-active-sessions"}),i.jsx(qc,{value:b.blockedTasks,label:"Blocked Tasks",accent:"yellow",index:1,testId:"kpi-blocked-tasks"}),i.jsx(qc,{value:b.attentionTasks,label:"Needs Attention",accent:"red",index:2,testId:"kpi-attention-tasks"}),i.jsx(qc,{value:b.unhealthyEnvironments,label:"Unhealthy Envs",accent:"blue",index:3,testId:"kpi-unhealthy-envs"})]}),i.jsxs("div",{className:ue.bodyGrid,children:[i.jsxs(Rt.div,{className:ue.section,variants:Vc,initial:"hidden",animate:"visible",custom:0,"data-testid":"dashboard-active-sessions",children:[i.jsxs("div",{className:ue.sectionHeader,children:[i.jsx("span",{className:ue.sectionIcon,"aria-hidden":"true",children:"●"}),i.jsx("span",{className:ue.sectionTitle,children:"Active Sessions"}),i.jsx("span",{className:ue.sectionCount,children:x.length})]}),i.jsx("div",{className:ue.sectionBody,children:x.length===0?i.jsx("div",{className:ue.emptyHint,children:"No active sessions"}):x.map(({session:N,environmentName:T})=>i.jsxs("button",{type:"button",className:ue.sessionRow,onClick:()=>g(gm(N.id)),"data-testid":"session-row",children:[i.jsx("span",{className:ue.sessionPrompt,title:N.prompt,children:N.prompt||"—"}),i.jsx("span",{className:ue.sessionEnv,children:T}),i.jsx("span",{className:ue.sessionRuntime,children:N.runtime}),i.jsxs("span",{className:ue.sessionStatus,children:[i.jsx("span",{className:ue.statusDot,"data-status":N.status}),N.status]})]},N.id))})]}),i.jsxs(Rt.div,{className:ue.section,variants:Vc,initial:"hidden",animate:"visible",custom:1,"data-testid":"dashboard-needs-attention",children:[i.jsxs("div",{className:ue.sectionHeader,children:[i.jsx("span",{className:ue.sectionIcon,"aria-hidden":"true",children:"⚑"}),i.jsx("span",{className:ue.sectionTitle,children:"Needs Attention"}),i.jsx("span",{className:ue.sectionCount,children:S.length})]}),i.jsx("div",{className:ue.sectionBody,children:S.length===0?i.jsx("div",{className:ue.emptyHint,children:"All clear"}):S.map(({task:N,reason:T,workspaceName:C})=>i.jsxs("button",{type:"button",className:ue.attentionRow,onClick:()=>g(On(N.id)),"data-testid":"attention-row",children:[i.jsxs("div",{className:ue.attentionTitle,children:[i.jsx("span",{className:ue.reasonBadge,"data-reason":T,children:T}),N.title]}),i.jsx("div",{className:ue.attentionMeta,children:i.jsx("span",{children:C})})]},N.id))})]})]}),i.jsxs("div",{className:ue.bottomGrid,children:[i.jsxs(Rt.div,{className:ue.section,variants:Vc,initial:"hidden",animate:"visible",custom:2,"data-testid":"dashboard-env-health",children:[i.jsxs("div",{className:ue.sectionHeader,children:[i.jsx("span",{className:ue.sectionIcon,"aria-hidden":"true",children:"◈"}),i.jsx("span",{className:ue.sectionTitle,children:"Environment Health"}),i.jsx("span",{className:ue.sectionCount,children:p.length})]}),i.jsx("div",{className:ue.sectionBody,children:p.length===0?i.jsx("div",{className:ue.emptyHint,children:"No environments configured"}):p.map(N=>i.jsxs("div",{className:ue.envRow,"data-testid":"dashboard-env-row",children:[i.jsx("span",{className:ue.envName,children:N.displayName}),i.jsx("span",{className:ue.envStatusBadge,"data-status":N.status,children:N.status})]},N.id))})]}),i.jsxs(Rt.div,{className:ue.section,variants:Vc,initial:"hidden",animate:"visible",custom:3,"data-testid":"dashboard-workspace-snapshot",children:[i.jsxs("div",{className:ue.sectionHeader,children:[i.jsx("span",{className:ue.sectionIcon,"aria-hidden":"true",children:"▦"}),i.jsx("span",{className:ue.sectionTitle,children:"Workspaces"}),i.jsx("span",{className:ue.sectionCount,children:t.length})]}),i.jsx("div",{className:ue.sectionBody,children:k.length===0?i.jsx("div",{className:ue.emptyHint,children:"No workspaces yet"}):k.map(({workspace:N,totalTasks:T,completedTasks:C,workingTasks:D,failedTasks:B})=>{const E=T>0?Math.round(C/T*100):0;return i.jsxs("button",{type:"button",className:ue.workspaceRow,onClick:()=>g($a(N.id,N.environmentId)),"data-testid":"workspace-row",children:[i.jsxs("div",{className:ue.workspaceTop,children:[i.jsx("span",{className:ue.workspaceName,children:N.name}),i.jsxs("span",{className:ue.workspaceCounts,"aria-label":n$(C,T,D,B),children:[C,"/",T,D>0&&i.jsxs("span",{style:{color:"var(--accent-green)"},"aria-hidden":"true",children:["▸",D]}),B>0&&i.jsxs("span",{style:{color:"var(--accent-red)"},"aria-hidden":"true",children:["✗",B]})]})]}),T>0&&i.jsx("div",{className:ue.progressBar,children:i.jsx("div",{className:ue.progressFill,style:{width:`${E}%`}})})]},N.id)})})]})]})]})}const a$="_panelContainer_1udy7_1",i$="_emptyState_1udy7_8",o$="_workspaceSummary_1udy7_17",r$="_workspaceSummaryTitle_1udy7_28",l$="_workspaceSummarySubtitle_1udy7_32",c$="_header_1udy7_36",d$="_headerInfo_1udy7_71",u$="_headerTitle_1udy7_106",f$="_taskStatusBadge_1udy7_128",p$="_taskBranch_1udy7_137",m$="_taskBlockedBadge_1udy7_143",h$="_tabBar_1udy7_277",g$="_tab_1udy7_277",v$="_active_1udy7_303",y$="_eventScroll_1udy7_308",b$="_tabContent_1udy7_314",x$="_noContext_1udy7_319",_$="_overviewContent_1udy7_325",k$="_overviewDashboard_1udy7_334",S$="_overviewHero_1udy7_340",T$="_overviewSection_1udy7_347",w$="_overviewLabel_1udy7_353",j$="_envRow_1udy7_360",N$="_timeline_1udy7_366",C$="_timelineRow_1udy7_372",E$="_waitingMessage_1udy7_379",A$="_errorMessage_1udy7_383",D$="_emptyCta_1udy7_387",R$="_ctaTitle_1udy7_399",M$="_ctaDescription_1udy7_405",I$="_ctaButton_1udy7_412",O$="_workspaceHeader_1udy7_533",B$="_workspaceName_1udy7_558",L$="_workspaceMeta_1udy7_571",z$="_metaRow_1udy7_579",$$="_metaLabel_1udy7_592",U$="_metaValue_1udy7_607",P$="_archiveButton_1udy7_617",H$="_repoLink_1udy7_647",V$="_metaToggle_1udy7_657",q$="_metaToggleArrow_1udy7_678",G$="_metaToggleArrowOpen_1udy7_683",F$="_progressBarContainer_1udy7_687",Z$="_progressBar_1udy7_687",K$="_progressFill_1udy7_703",Y$="_progressLabel_1udy7_710",J$="_metaTimestamps_1udy7_717",W$="_metaTimestamp_1udy7_717",X$="_metaPlaceholder_1udy7_739",Q$="_linkedEnvList_1udy7_744",eU="_linkedEnvChip_1udy7_750",tU="_chipDismiss_1udy7_762",nU="_linkError_1udy7_777",sU="_linkEnvSelect_1udy7_782",Y={panelContainer:a$,emptyState:i$,workspaceSummary:o$,workspaceSummaryTitle:r$,workspaceSummarySubtitle:l$,header:c$,headerInfo:d$,headerTitle:u$,taskStatusBadge:f$,taskBranch:p$,taskBlockedBadge:m$,tabBar:h$,tab:g$,active:v$,eventScroll:y$,tabContent:b$,noContext:x$,overviewContent:_$,overviewDashboard:k$,overviewHero:S$,overviewSection:T$,overviewLabel:w$,envRow:j$,timeline:N$,timelineRow:C$,waitingMessage:E$,errorMessage:A$,emptyCta:D$,ctaTitle:R$,ctaDescription:M$,ctaButton:I$,workspaceHeader:O$,workspaceName:B$,workspaceMeta:L$,metaRow:z$,metaLabel:$$,metaValue:U$,archiveButton:P$,repoLink:H$,metaToggle:V$,metaToggleArrow:q$,metaToggleArrowOpen:G$,progressBarContainer:F$,progressBar:Z$,progressFill:K$,progressLabel:Y$,metaTimestamps:J$,metaTimestamp:W$,metaPlaceholder:X$,linkedEnvList:Q$,linkedEnvChip:eU,chipDismiss:tU,linkError:nU,linkEnvSelect:sU};function aU(){return i.jsx("div",{className:Y.emptyState,children:"Select a task or click + to create one"})}function iU(){return i.jsx("div",{className:Y.emptyState,children:"Select an environment to manage its workspaces, or add a new one."})}function oU(){const{workspaces:{workspaces:t},environments:{environments:s}}=mt(),o=kt(),r=s.length>0;return t.length>0?i.jsx(s$,{}):i.jsxs("div",{className:Y.emptyCta,"data-testid":"welcome-cta",children:[i.jsx("div",{className:Y.ctaTitle,children:"Welcome to Grackle"}),i.jsx("div",{className:Y.ctaDescription,children:"Organize your work into workspaces and let agents tackle the tasks."}),i.jsx("button",{className:Y.ctaButton,onClick:()=>o(zx),disabled:!r,"data-testid":"welcome-create-button",children:"Create Your First Workspace"}),!r&&i.jsx("div",{className:Y.ctaDescription,children:"Add an environment first before creating a workspace."})]})}const rU="_panelContainer_19poq_1",lU="_chatHeader_19poq_8",cU="_chatHeaderInfo_19poq_37",dU="_emptyState_19poq_43",uU="_emptyTitle_19poq_55",fU="_emptyDescription_19poq_61",pU="_emptyHint_19poq_67",Ba={panelContainer:rU,chatHeader:lU,chatHeaderInfo:cU,emptyState:dU,emptyTitle:uU,emptyDescription:fU,emptyHint:pU};function mU(){return i.jsx("div",{className:Ba.panelContainer,"aria-hidden":"true",children:i.jsxs("div",{style:{flex:1,overflow:"hidden",padding:"var(--space-md)",display:"flex",flexDirection:"column",gap:"var(--space-md)"},children:[i.jsx(we,{width:"65%",height:"2.5rem",borderRadius:"var(--radius-sm)"}),i.jsx(we,{width:"85%",height:"4rem",borderRadius:"var(--radius-sm)"}),i.jsx(we,{width:"45%",height:"2rem",borderRadius:"var(--radius-sm)"}),i.jsx(we,{width:"75%",height:"3rem",borderRadius:"var(--radius-sm)"}),i.jsx(we,{width:"55%",height:"2.5rem",borderRadius:"var(--radius-sm)"})]})})}function hU({hasLocalEnvironment:t}){return i.jsxs("div",{className:Ba.emptyState,"data-testid":"chat-empty-state",children:[i.jsx("div",{className:Ba.emptyTitle,children:"Welcome to Grackle"}),i.jsx("div",{className:Ba.emptyDescription,children:t?"Type a message below to start chatting with the System agent. It can help you plan work, create tasks, and coordinate agents.":"Add a local environment in Settings to start chatting."}),!t&&i.jsx("div",{className:Ba.emptyHint,children:"Go to Settings → Environments to add one."})]})}function gU(){const{tasks:{tasks:t,tasksLoading:s,startTask:o},sessions:{sessions:r,sessionsLoading:c,events:d,eventsDropped:u,taskSessions:p,loadTaskSessions:m,loadSessionEvents:g,kill:v,stopGraceful:b,sendInput:x,spawn:S},environments:{environments:k,provisionEnvironment:w},personas:{personas:N}}=mt(),{showToast:T}=Sn(),C=y.useRef(void 0),[D,B]=y.useState(),E=t.find(W=>W.id===Rr),A=E!=null&&E.latestSessionId?r.find(W=>W.id===E.latestSessionId)??(p[Rr]??[]).find(W=>W.id===E.latestSessionId):void 0;y.useEffect(()=>{m(Rr).catch(()=>{})},[m]),y.useEffect(()=>{E!=null&&E.latestSessionId&&m(Rr).catch(()=>{})},[E==null?void 0:E.latestSessionId,m]),y.useEffect(()=>{A&&A.id!==C.current&&(C.current=A.id,g(A.id).catch(()=>{}))},[A==null?void 0:A.id,g]);const P=y.useMemo(()=>{if(!A)return[];const W=d.filter(pe=>pe.sessionId===A.id);return ah(sh(W))},[d,A==null?void 0:A.id]),I=k.find(W=>W.adapterType==="local"&&W.status==="connected"),U=A!==void 0&&A.status!=="stopped"&&A.status!=="suspended",Q=(A==null?void 0:A.status)==="idle";y.useEffect(()=>{D&&A&&Q&&(x(A.id,D).catch(()=>{}),B(void 0))},[D,Q,A==null?void 0:A.id,x]);const $=y.useCallback((W,pe,H,ie)=>{ie&&B(ie),o(W,pe,H).catch(()=>{})},[o]);return!E&&(c||s)?i.jsx(mU,{}):i.jsxs("div",{className:Ba.panelContainer,"data-testid":"chat-page",children:[U&&i.jsxs("div",{className:Ba.chatHeader,children:[i.jsxs("span",{className:Ba.chatHeaderInfo,children:["Session: ",A.id.slice(0,8)," | ",A.runtime," | ",A.status]}),i.jsx(Ux,{label:"Stop",onClick:()=>{b(A.id).catch(()=>{})},variant:"danger",size:"sm","data-testid":"stop-split-button",options:[{label:"Stop",description:"Graceful shutdown",onClick:()=>{b(A.id).catch(()=>{})}},{label:"Kill",description:"Force kill",onClick:()=>{v(A.id).catch(()=>{})}}]})]}),i.jsx(Xm,{events:P,eventsDropped:u,emptyState:i.jsx(hU,{hasLocalEnvironment:!!I}),onShowToast:T}),I&&U&&i.jsx(Qr,{mode:"send",sessionId:A.id,environmentId:A.environmentId,personas:N,environments:k,onSendInput:(W,pe)=>{x(W,pe).catch(()=>{})},onSpawn:(W,pe,H)=>{S(W,pe,H).catch(()=>{})},onStartTask:(W,pe,H)=>{o(W,pe,H).catch(()=>{})},onProvisionEnvironment:W=>{w(W).catch(()=>{})},onShowToast:T}),I&&!U&&i.jsx(Qr,{mode:"start",taskId:Rr,environmentId:I.id,personas:N,environments:k,onSendInput:(W,pe)=>{x(W,pe).catch(()=>{})},onSpawn:(W,pe,H)=>{S(W,pe,H).catch(()=>{})},onStartTask:$,onProvisionEnvironment:W=>{w(W).catch(()=>{})},onShowToast:T})]})}function vU(){const t=y7(),[s]=hm(),o=s.get("env")??"",{sessions:{sendInput:r,spawn:c},tasks:{startTask:d},personas:{personas:u},environments:{environments:p,provisionEnvironment:m}}=mt(),{showToast:g}=Sn();return i.jsxs("div",{className:Y.panelContainer,children:[i.jsx(Ns,{segments:t}),i.jsx("div",{className:Y.emptyState,children:"Enter a prompt below to start a new session"}),i.jsx(Qr,{mode:"spawn",environmentId:o,showPersonaSelect:!0,personas:u,environments:p,onSendInput:(v,b)=>{r(v,b).catch(()=>{})},onSpawn:(v,b,x)=>{c(v,b,x).catch(()=>{})},onStartTask:(v,b,x)=>{d(v,b,x).catch(()=>{})},onProvisionEnvironment:v=>{m(v).catch(()=>{})},onShowToast:g})]})}function yU(){return i.jsxs("div",{className:Y.panelContainer,"aria-hidden":"true",children:[i.jsxs("div",{className:Y.header,children:[i.jsx("span",{children:i.jsx(we,{width:"10rem",height:"0.875rem"})}),i.jsx("span",{className:Y.headerInfo,children:i.jsx(we,{width:"16rem",height:"0.875rem"})})]}),i.jsx("div",{className:Y.eventScroll,children:i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-md)"},children:[i.jsx(we,{width:"70%",height:"2.5rem",borderRadius:"var(--radius-sm)"}),i.jsx(we,{width:"90%",height:"4rem",borderRadius:"var(--radius-sm)"}),i.jsx(we,{width:"50%",height:"2rem",borderRadius:"var(--radius-sm)"}),i.jsx(we,{width:"80%",height:"3.5rem",borderRadius:"var(--radius-sm)"}),i.jsx(we,{width:"60%",height:"2.5rem",borderRadius:"var(--radius-sm)"})]})})]})}function bU({sessionId:t,session:s,isActive:o,onStop:r,onKill:c}){return i.jsxs("div",{className:Y.header,children:[i.jsxs("span",{children:["Session: ",t.slice(0,8),s&&` | ${s.runtime} | ${s.endReason||s.status}`,s!=null&&s.inputTokens||s!=null&&s.outputTokens||s!=null&&s.costUsd?` | ${Mo((s.inputTokens??0)+(s.outputTokens??0))} tokens · ${Ss(s.costUsd??0)}`:""]}),i.jsxs("span",{className:Y.headerInfo,children:[s&&i.jsx("span",{children:s.prompt.length>60?s.prompt.slice(0,60)+"...":s.prompt}),o&&i.jsx(Ux,{label:"Stop",onClick:r,variant:"danger",size:"sm","data-testid":"stop-split-button",options:[{label:"Stop",description:"Graceful shutdown",onClick:r},{label:"Kill",description:"Force kill",onClick:c}]})]})]})}function xU({session:t}){const s=t&&(t.status==="stopped"||t.status==="suspended"),o=s?`Session ${t.endReason||t.status} with no events recorded.`:"Waiting for events...";return i.jsx("div",{className:s?Y.errorMessage:Y.waitingMessage,children:o})}function _U(){const{sessionId:t}=fs(),{sessions:{events:s,eventsDropped:o,sessions:r,sessionsLoading:c,kill:d,stopGraceful:u,loadSessionEvents:p,sendInput:m,spawn:g},tasks:{startTask:v},personas:{personas:b},environments:{environments:x,provisionEnvironment:S}}=mt(),{showToast:k}=Sn(),w=y.useRef(void 0),N=b7(t),T=r.find(B=>B.id===t)??void 0,C=y.useMemo(()=>{const B=t?s.filter(E=>E.sessionId===t):[];return ah(sh(B))},[s,t]);if(y.useEffect(()=>{t&&t!==w.current&&(w.current=t,p(t).catch(()=>{}))},[t,p]),!T&&c)return i.jsx(yU,{});if(!t)return i.jsx("div",{className:Y.emptyState,children:"No session selected"});const D=(T==null?void 0:T.status)==="running"||(T==null?void 0:T.status)==="idle";return i.jsxs("div",{className:Y.panelContainer,children:[i.jsx(Ns,{segments:N}),i.jsx(bU,{sessionId:t,session:T,isActive:D,onStop:()=>{u(t).catch(()=>{})},onKill:()=>{d(t).catch(()=>{})}}),i.jsx(Xm,{events:C,eventsDropped:o,emptyState:i.jsx(xU,{session:T}),onShowToast:k}),D&&i.jsx(Qr,{mode:"send",sessionId:t,environmentId:T.environmentId,personas:b,environments:x,onSendInput:(B,E)=>{m(B,E).catch(()=>{})},onSpawn:(B,E,A)=>{g(B,E,A).catch(()=>{})},onStartTask:(B,E,A)=>{v(B,E,A).catch(()=>{})},onProvisionEnvironment:B=>{S(B).catch(()=>{})},onShowToast:k})]})}function kU(t){if(!t)return!1;const s=t.tagName;return!!(s==="INPUT"||s==="TEXTAREA"||s==="SELECT"||t.isContentEditable)}function Qs(t,s){const o=y.useRef(s);o.current=s;const{key:r,ctrl:c=!1,shift:d=!1,suppressInInputs:u=!0,enabled:p=!0}=t;y.useEffect(()=>{if(!p)return;const m=g=>{if(u&&kU(document.activeElement??void 0))return;const v=g.ctrlKey||g.metaKey;c===v&&(d&&!g.shiftKey||g.key===r&&o.current())};return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m)}},[r,c,d,u,p])}function SU(){return i.jsxs("div",{className:Y.panelContainer,"aria-hidden":"true",children:[i.jsx("div",{className:Y.workspaceHeader,children:i.jsx("span",{className:Y.workspaceName,children:i.jsx(we,{width:"12rem",height:"1.25rem"})})}),i.jsx("div",{className:Y.metaToggle,style:{cursor:"default"},children:i.jsx(we,{width:"4rem",height:"0.625rem"})}),i.jsxs("div",{className:Y.progressBarContainer,children:[i.jsx("div",{className:Y.progressBar,children:i.jsx("div",{className:Y.progressFill,style:{width:"0%"}})}),i.jsx(we,{width:"2rem",height:"0.625rem"})]}),i.jsxs("div",{className:Y.tabBar,role:"tablist","aria-label":"Workspace view",children:[i.jsx("span",{className:`${Y.tab} ${Y.active}`,children:"Graph"}),i.jsx("span",{className:Y.tab,children:"Board"}),i.jsx("span",{className:Y.tab,children:"Tasks"})]}),i.jsx("div",{className:Y.overviewContent,children:Array.from({length:3},(t,s)=>i.jsx(dd,{lines:2},s))})]})}function tx(t){if(!t)return"";const s=new Date(t);if(isNaN(s.getTime()))return"";const r=Date.now()-s.getTime();if(r<0)return"just now";const c=Math.floor(r/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const d=Math.floor(c/60);if(d<24)return`${d}h ago`;const u=Math.floor(d/24);return u<30?`${u}d ago`:s.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}const Np=100;function TU(t){try{const s=new URL(t);return s.protocol!=="http:"&&s.protocol!=="https:"?void 0:s.toString()}catch{return}}function wU(){const{workspaceId:t,environmentId:s}=fs(),o=kt(),{tasks:{tasks:r},environments:{environments:c},workspaces:{workspaces:d,workspacesLoading:u,archiveWorkspace:p,updateWorkspace:m,linkEnvironment:g,unlinkEnvironment:v,linkOperationError:b,clearLinkOperationError:x},personas:{personas:S},sessions:{sessions:k},usageCache:w,loadUsage:N}=mt(),{resolvedThemeId:T}=B1(),[C,D]=y.useState("tasks"),[B,E]=y.useState(!1),[A,P]=y.useState(null),[I,U]=y.useState(!1),Q=y.useRef(void 0),$=d.find(X=>X.id===t),W=s??($==null?void 0:$.environmentId)??"",pe=x7(t,W,d,c);Qs({key:"1"},()=>D("graph")),Qs({key:"2"},()=>D("board")),Qs({key:"3"},()=>D("tasks")),y.useEffect(()=>{const X=Q.current;Q.current=t,!(X===void 0||X===t)&&A!==null&&P(null)},[t,A]);const H=k.reduce((X,ge)=>X+(ge.costUsd??0),0);y.useEffect(()=>{t&&N("workspace",t).catch(()=>{})},[t,N,H]);const ie=t?w[`workspace:${t}`]:void 0,L=r.filter(X=>X.workspaceId===t),Z=L.filter(X=>X.status==="complete").length,J=L.length,ce=J>0?Math.round(Z/J*100):0;return!$&&u?i.jsx(SU,{}):i.jsxs("div",{className:Y.panelContainer,children:[i.jsx(Ns,{segments:pe}),i.jsxs("div",{className:Y.workspaceHeader,children:[i.jsx("span",{className:Y.workspaceName,"data-testid":"workspace-name",children:i.jsx(ln,{value:($==null?void 0:$.name)||"",onSave:X=>{$&&m($.id,{name:X}).catch(()=>{})},validate:X=>{const ge=X.trim();if(!ge)return"Name is required";if(ge.length>Np)return`Max ${Np} characters`},maxLength:Np,fieldId:"name",activeFieldId:A,onActivate:P,ariaLabel:"Workspace name",renderDisplay:X=>X||t||void 0,"data-testid":"edit-name"})}),i.jsx("button",{className:Y.archiveButton,onClick:()=>E(!0),title:"Archive workspace","data-testid":"archive-workspace-button",children:"Archive"})]}),i.jsxs("button",{className:Y.metaToggle,onClick:()=>U(!I),"aria-expanded":!I,"aria-controls":"workspace-meta-panel","data-testid":"meta-toggle",children:[i.jsx("span",{className:`${Y.metaToggleArrow} ${I?"":Y.metaToggleArrowOpen}`,children:"▶"}),"Details"]}),!I&&i.jsxs("div",{className:Y.workspaceMeta,"data-testid":"workspace-meta",id:"workspace-meta-panel",children:[i.jsxs("div",{className:Y.metaRow,children:[i.jsx("span",{className:Y.metaLabel,children:"Description"}),i.jsx("div",{className:Y.metaValue,children:i.jsx(Xp,{value:($==null?void 0:$.description)||"",onSave:X=>{$&&m($.id,{description:X}).catch(()=>{})},fieldId:"description",activeFieldId:A,onActivate:P,renderDisplay:X=>X?i.jsx("span",{className:Y.overviewMarkdown,children:i.jsx(hd,{remarkPlugins:[gd],children:X})}):void 0,placeholder:"No description",ariaLabel:"Workspace description","data-testid":"edit-description"})})]}),i.jsxs("div",{className:Y.metaRow,children:[i.jsx("span",{className:Y.metaLabel,children:"Repository"}),i.jsx("div",{className:Y.metaValue,children:i.jsx(ln,{value:($==null?void 0:$.repoUrl)||"",onSave:X=>{$&&m($.id,{repoUrl:X}).catch(()=>{})},validate:X=>{const ge=X.trim();if(ge&&!/^https?:\/\/.+/.test(ge))return"Must be a valid http(s) URL"},fieldId:"repoUrl",activeFieldId:A,onActivate:P,renderDisplay:X=>{const ge=TU(X);return ge?i.jsx("a",{className:Y.repoLink,href:ge,target:"_blank",rel:"noopener noreferrer",onClick:fe=>fe.stopPropagation(),children:X}):X?i.jsx("span",{children:X}):void 0},placeholder:"No repository",ariaLabel:"Workspace repository URL","data-testid":"edit-repo"})})]}),i.jsxs("div",{className:Y.metaRow,children:[i.jsx("span",{className:Y.metaLabel,children:"Environment"}),i.jsx("div",{className:Y.metaValue,children:i.jsx(B6,{value:($==null?void 0:$.environmentId)||"",onSave:X=>{$&&X&&m($.id,{environmentId:X}).catch(()=>{})},environments:c,fieldId:"environmentId",activeFieldId:A,onActivate:P,placeholder:"Select environment",ariaLabel:"Workspace environment","data-testid":"edit-env"})})]}),i.jsxs("div",{className:Y.metaRow,children:[i.jsx("span",{className:Y.metaLabel,children:"Linked Envs"}),i.jsx("div",{className:Y.metaValue,"data-testid":"linked-environments",children:$?i.jsxs("span",{className:Y.linkedEnvList,children:[(()=>{const X=[...new Set($.linkedEnvironmentIds.filter(ge=>ge!==$.environmentId))];return X.length===0?i.jsx("span",{className:Y.metaPlaceholder,children:"None"}):X.map(ge=>{const fe=c.find(Ce=>Ce.id===ge);return i.jsxs("span",{className:Y.linkedEnvChip,"data-testid":`linked-env-${ge}`,children:[(fe==null?void 0:fe.displayName)||ge,i.jsx("button",{className:Y.chipDismiss,onClick:()=>{v($.id,ge).catch(()=>{})},title:`Unlink ${(fe==null?void 0:fe.displayName)||ge}`,"aria-label":`Unlink ${(fe==null?void 0:fe.displayName)||ge}`,"data-testid":`unlink-env-${ge}`,children:"x"})]},ge)})})(),(()=>{const X=new Set($.linkedEnvironmentIds),ge=c.filter(fe=>fe.id!==$.environmentId&&!X.has(fe.id));return ge.length===0?null:i.jsxs("select",{className:Y.linkEnvSelect,value:"",onChange:fe=>{fe.target.value&&g($.id,fe.target.value).catch(()=>{})},"aria-label":"Link environment","data-testid":"link-env-select",children:[i.jsx("option",{value:"",children:"+ Link"}),ge.map(fe=>i.jsx("option",{value:fe.id,children:fe.displayName||fe.id},fe.id))]})})(),b&&i.jsxs("span",{className:Y.linkError,"data-testid":"link-operation-error",role:"alert",children:[b,i.jsx("button",{className:Y.chipDismiss,onClick:x,"aria-label":"Dismiss error","data-testid":"dismiss-link-error",children:"x"})]})]}):i.jsx("span",{className:Y.metaPlaceholder,children:"None"})})]}),i.jsxs("div",{className:Y.metaRow,children:[i.jsx("span",{className:Y.metaLabel,children:"Persona"}),i.jsx("div",{className:Y.metaValue,children:i.jsx(ud,{value:($==null?void 0:$.defaultPersonaId)||"",onSave:X=>{$&&m($.id,{defaultPersonaId:X}).catch(()=>{})},options:[{value:"",label:"(Inherit)"},...S.map(X=>({value:X.id,label:X.name}))],fieldId:"defaultPersonaId",activeFieldId:A,onActivate:P,renderDisplay:X=>{const ge=S.find(fe=>fe.id===X);if(ge)return i.jsx("span",{children:ge.name})},placeholder:($==null?void 0:$.defaultPersonaId)||"(Inherit)",ariaLabel:"Workspace default persona","data-testid":"edit-persona"})})]}),i.jsxs("div",{className:Y.metaRow,children:[i.jsx("span",{className:Y.metaLabel,children:"Worktrees"}),i.jsx("div",{className:Y.metaValue,children:i.jsx(C6,{checked:($==null?void 0:$.useWorktrees)??!0,onChange:X=>{$&&m($.id,{useWorktrees:X}).catch(()=>{})},label:"Enable worktree isolation","data-testid":"worktree-toggle"})})]}),i.jsxs("div",{className:Y.metaRow,children:[i.jsx("span",{className:Y.metaLabel,children:"Working Dir"}),i.jsx("div",{className:Y.metaValue,children:i.jsx(ln,{value:($==null?void 0:$.workingDirectory)||"",onSave:X=>{$&&m($.id,{workingDirectory:X}).catch(()=>{})},fieldId:"workingDirectory",activeFieldId:A,onActivate:P,placeholder:"Default (server default)",ariaLabel:"Working directory","data-testid":"edit-working-directory"})})]}),$&&i.jsxs("div",{className:Y.metaTimestamps,children:[i.jsxs("span",{className:Y.metaTimestamp,children:["Created ",tx($.createdAt)]}),$.updatedAt&&$.updatedAt!==$.createdAt&&i.jsxs("span",{className:Y.metaTimestamp,children:["· Updated ",tx($.updatedAt)]})]})]}),J>0&&i.jsxs("div",{className:Y.progressBarContainer,"data-testid":"progress-bar",children:[i.jsx("div",{className:Y.progressBar,children:i.jsx("div",{className:Y.progressFill,style:{width:`${ce}%`}})}),i.jsxs("span",{className:Y.progressLabel,children:[Z,"/",J]})]}),ie&&ie.costUsd>0&&i.jsx("div",{className:Y.progressBarContainer,children:i.jsxs("span",{className:Y.progressLabel,children:["Usage: ",Ss(ie.costUsd)," (",ie.sessionCount," session",ie.sessionCount!==1?"s":"",")"]})}),$&&($.tokenBudget>0||$.costBudgetMillicents>0)&&i.jsx("div",{className:Y.progressBarContainer,children:i.jsxs("span",{className:Y.progressLabel,children:["Budget:"," ",$.tokenBudget>0&&i.jsxs(i.Fragment,{children:["Tokens: ",Mo(((ie==null?void 0:ie.inputTokens)??0)+((ie==null?void 0:ie.outputTokens)??0))," / ",Mo($.tokenBudget)]}),$.tokenBudget>0&&$.costBudgetMillicents>0&&" | ",$.costBudgetMillicents>0&&i.jsxs(i.Fragment,{children:["Cost: ",Ss((ie==null?void 0:ie.costUsd)??0)," / ",Ss($.costBudgetMillicents/1e5)]})]})}),i.jsxs("div",{className:Y.tabBar,role:"tablist","aria-label":"Workspace view",children:[i.jsx("button",{role:"tab","aria-selected":C==="graph",className:`${Y.tab} ${C==="graph"?Y.active:""}`,onClick:()=>D("graph"),children:"Graph"}),i.jsx("button",{role:"tab","aria-selected":C==="board",className:`${Y.tab} ${C==="board"?Y.active:""}`,onClick:()=>D("board"),"data-testid":"board-tab",children:"Board"}),i.jsx("button",{role:"tab","aria-selected":C==="tasks",className:`${Y.tab} ${C==="tasks"?Y.active:""}`,onClick:()=>D("tasks"),children:"Tasks"})]}),C==="tasks"&&J>0&&i.jsxs("div",{className:Y.workspaceSummary,children:[i.jsx("span",{className:Y.workspaceSummaryTitle,children:`${Z}/${J} tasks complete`}),i.jsx("span",{className:Y.workspaceSummarySubtitle,children:"Select a task or click + to create one"})]}),C==="tasks"&&J===0&&i.jsxs("div",{className:Y.emptyCta,children:[i.jsx("button",{className:Y.ctaButton,onClick:()=>o(Di(t,void 0,W)),children:"Create Task"}),i.jsx("div",{className:Y.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}),C==="board"&&i.jsx(V8,{workspaceId:t,environmentId:W,tasks:r,sessions:k,personas:S,environments:c}),C==="graph"&&i.jsx(pN,{workspaceId:t,environmentId:W,tasks:r,resolvedThemeId:T}),i.jsx(Ci,{isOpen:B,title:"Archive Workspace?",description:"This will hide the workspace from the sidebar. Tasks will not be deleted.",confirmLabel:"Archive",onConfirm:()=>{$&&(p($.id).catch(()=>{}),o("/",{replace:!0})),E(!1)},onCancel:()=>E(!1)})]})}const jU="_container_3pgew_1",NU="_header_3pgew_8",CU="_headerTitle_3pgew_35",EU="_headerActions_3pgew_44",AU="_body_3pgew_51",DU="_btnPrimary_3pgew_63",RU="_btnGhost_3pgew_94",MU="_error_3pgew_116",Ma={container:jU,header:NU,headerTitle:CU,headerActions:EU,body:AU,btnPrimary:DU,btnGhost:RU,error:MU};function IU(t){const s={};return t.name.trim()||(s.name="Name is required"),t.repoUrl.trim()&&!/^https?:\/\/.+/i.test(t.repoUrl.trim())&&(s.repoUrl="Must be a valid http(s) URL"),t.environmentId||(s.environmentId="Environment is required"),Object.keys(s).length>0?s:void 0}const OU=[{label:"Home",url:Ni},{label:"New Workspace",url:void 0}];function BU(){const[t]=hm(),s=t.get("environment")??void 0,{environments:{environments:o},personas:{personas:r},workspaces:{createWorkspace:c,workspaceCreating:d}}=mt(),{showToast:u}=Sn(),p=kt(),[m,g]=y.useState(()=>{var N;return e7(void 0,s||((N=o[0])==null?void 0:N.id))}),[v,b]=y.useState(),[x,S]=y.useState();y.useEffect(()=>{s||m.environmentId||o.length===0||g(N=>{var T;return N.environmentId?N:{...N,environmentId:((T=o[0])==null?void 0:T.id)??""}})},[o,s,m.environmentId]);const k=()=>{const N=IU(m);if(N){b(N),S(void 0);return}b(void 0),S(void 0),c(m.name.trim(),m.description,m.repoUrl.trim(),m.environmentId,m.defaultPersonaId,m.useWorktrees,m.workingDirectory,()=>{u("Workspace created","success"),p(Ni,{replace:!0})},T=>{S(T)}).catch(()=>{})},w=()=>{p(s?ji(s):Ni,{replace:!0})};return i.jsxs("div",{className:Ma.container,children:[i.jsxs("div",{className:Ma.header,children:[i.jsx("div",{className:Ma.headerTitle,children:i.jsx(Ns,{segments:OU})}),i.jsxs("div",{className:Ma.headerActions,children:[i.jsx("button",{className:Ma.btnGhost,onClick:w,disabled:d,"data-testid":"workspace-create-cancel",children:"Cancel"}),i.jsx("button",{className:Ma.btnPrimary,onClick:k,disabled:d||!m.name.trim()||!m.environmentId,"data-testid":"workspace-create-save",children:d?i.jsx(g1,{size:"sm",label:"Creating"}):"Create Workspace"})]})]}),i.jsxs("div",{className:Ma.body,children:[i.jsx(n7,{values:m,onChange:N=>{g(N),b(void 0),S(void 0)},environments:o,personas:r,errors:v,disabled:d,autoFocusName:!0}),x&&i.jsx("div",{className:Ma.error,"data-testid":"workspace-create-submit-error",children:x})]})]})}function nx(){const{workspaceId:t,environmentId:s}=fs(),[o]=hm(),r=t??o.get("workspace")??"",c=o.get("parent")??void 0,{tasks:{tasks:d,createTask:u,updateTask:p},workspaces:{workspaces:m},personas:{personas:g}}=mt(),{showToast:v}=Sn();return i.jsx(E1,{mode:"new",workspaceId:r,parentTaskId:c,environmentId:s,tasks:d,workspaces:m,personas:g,onCreateTask:(b,x,S,k,w,N,T,C,D)=>{u(b,x,S,k,w,N,T,C,D).catch(()=>{})},onUpdateTask:(b,x,S,k,w)=>{p(b,x,S,k,w).catch(()=>{})},onShowToast:v})}function LU(){return i.jsxs("div",{className:Y.panelContainer,"aria-hidden":"true",children:[i.jsx("div",{className:Y.header,children:i.jsxs("span",{className:Y.headerTitle,children:[i.jsx(we,{width:"12rem",height:"1rem"}),i.jsx(we,{width:"4rem",height:"1rem",borderRadius:"var(--radius-full)"})]})}),i.jsxs("div",{className:Y.tabBar,role:"tablist","aria-label":"Task view",children:[i.jsx("span",{className:`${Y.tab} ${Y.active}`,children:"Overview"}),i.jsx("span",{className:Y.tab,children:"Stream"}),i.jsx("span",{className:Y.tab,children:"Findings"})]}),i.jsx("div",{className:Y.overviewContent,children:i.jsxs("div",{className:Y.overviewDashboard,children:[i.jsx("div",{className:Y.overviewHero,children:i.jsx(we,{width:"5rem",height:"1.5rem",borderRadius:"var(--radius-full)"})}),i.jsxs("div",{className:Y.overviewSection,children:[i.jsx("div",{className:Y.overviewLabel,children:"Description"}),i.jsx(Wp,{lines:2})]}),i.jsxs("div",{className:Y.overviewSection,children:[i.jsx("div",{className:Y.overviewLabel,children:"Environment"}),i.jsxs("div",{className:Y.envRow,children:[i.jsx(we,{width:"0.5rem",height:"0.5rem",variant:"circular"}),i.jsx(we,{width:"8rem",height:"0.875rem"})]})]}),i.jsxs("div",{className:Y.overviewSection,children:[i.jsx("div",{className:Y.overviewLabel,children:"Dependencies"}),i.jsx(Wp,{lines:2})]}),i.jsxs("div",{className:Y.overviewSection,children:[i.jsx("div",{className:Y.overviewLabel,children:"Timeline"}),i.jsx("div",{className:Y.timeline,children:Array.from({length:4},(t,s)=>i.jsxs("div",{className:Y.timelineRow,children:[i.jsx(we,{width:"4rem",height:"0.75rem"}),i.jsx(we,{width:"10rem",height:"0.75rem"})]},s))})]})]})})]})}function Ia(){const{taskId:t,workspaceId:s,environmentId:o}=fs(),r=Zt(),c=kt(),{showToast:d}=Sn(),{sessions:{events:u,eventsDropped:p,sessions:m,loadSessionEvents:g,taskSessions:v,loadTaskSessions:b,sendInput:x,spawn:S,kill:k},tasks:{tasks:w,tasksLoading:N,startTask:T,stopTask:C,resumeTask:D,deleteTask:B,createTask:E,updateTask:A},environments:{environments:P,provisionEnvironment:I},findings:{findings:U,loadFindings:Q},workspaces:{workspaces:$},personas:{personas:W},usageCache:pe,loadUsage:H}=mt(),ie=y.useRef(void 0),L=y.useRef(void 0),Z=y.useRef(void 0),J=y.useRef(void 0),ce=y.useRef(void 0),X=r.pathname.endsWith("/stream")?"stream":r.pathname.endsWith("/findings")?"findings":"overview",ge=r.pathname.endsWith("/edit"),[fe,Ce]=y.useState(X),[Ze,me]=y.useState(!1),[_e,ve]=y.useState(void 0),[Le,Mt]=y.useState(""),[Tn,oe]=y.useState(ge),Ve=y.useRef(X),qt=y.useRef(ge),te=w.find(Re=>Re.id===t),ht=(te==null?void 0:te.workspaceId)||void 0,at=$.find(Re=>Re.id===ht);y.useEffect(()=>{X!==Ve.current&&(Ve.current=X,X!==fe&&Ce(X))},[X,fe]),y.useEffect(()=>{ge!==qt.current&&(qt.current=ge,ge!==Tn&&oe(ge))},[ge,Tn]),y.useEffect(()=>{if(Le===""){if(at!=null&&at.environmentId)Mt(at.environmentId);else if(P.length>0){const Re=P.find(Je=>Je.status==="connected");Mt((Re==null?void 0:Re.id)??P[0].id)}}},[Le,at==null?void 0:at.environmentId,P]);const Kt=te?v[te.id]??[]:[];let gt;_e&&Kt.some(Re=>Re.id===_e)?gt=_e:gt=(te==null?void 0:te.latestSessionId)||void 0;const ps=()=>{me(!0)},aa=()=>{if(!te)return;B(te.id).catch(()=>{}),me(!1);const Re=o??(at==null?void 0:at.environmentId);c(te.workspaceId&&Re?$a(te.workspaceId,Re):"/",{replace:!0})};y.useEffect(()=>{(te==null?void 0:te.id)!==L.current&&(L.current=te==null?void 0:te.id,ve(void 0),Mt(""),oe(ge))},[te==null?void 0:te.id,ge]),y.useEffect(()=>{if(!(te!=null&&te.id))return;const Re=te.id!==J.current,Je=te.latestSessionId!==ce.current;(Re||Je)&&(J.current=te.id,ce.current=te.latestSessionId,b(te.id).catch(()=>{}))},[te==null?void 0:te.id,te==null?void 0:te.latestSessionId,b]),y.useEffect(()=>{if((te==null?void 0:te.status)!==Z.current){const Re=Z.current===void 0;Z.current=te==null?void 0:te.status;const Je=(te==null?void 0:te.status)==="not_started"?"overview":(te==null?void 0:te.status)==="working"||(te==null?void 0:te.status)==="paused"?"stream":(te==null?void 0:te.status)==="complete"?"findings":void 0;Je&&Je!==fe&&!(Re&&X!=="overview")&&Ce(Je)}},[te==null?void 0:te.status,fe,X]);const es=y.useMemo(()=>new Map(w.map(Re=>[Re.id,Re])),[w]),Fa=y.useMemo(()=>{const Re=gt?u.filter(Je=>Je.sessionId===gt):[];return ah(sh(Re))},[u,gt]),ia=te?te.dependsOn.some(Re=>{const Je=es.get(Re);return Je!==void 0&&Je.status!=="complete"}):!1,Yt=y.useMemo(()=>_7(t,o,$,P,es),[t,o,$,P,es]);y.useEffect(()=>{gt&>!==ie.current&&(ie.current=gt,g(gt).catch(()=>{}))},[gt,g]),y.useEffect(()=>{fe==="findings"&&ht&&Q(ht).catch(()=>{})},[fe,ht,Q]);const Mi=Kt.reduce((Re,Je)=>Re+(Je.costUsd??0),0);y.useEffect(()=>{te&&(H("task",te.id).catch(()=>{}),te.childTaskIds.length>0&&H("task_tree",te.id).catch(()=>{}))},[te==null?void 0:te.id,te==null?void 0:te.childTaskIds.length,H,Mi]);const oa=te?`task:${te.id}`:"",Za=oa in pe?pe[oa]:void 0,ms=te?`task_tree:${te.id}`:"",Ii=te&&te.childTaskIds.length>0&&ms in pe?pe[ms]:void 0,wn=Re=>{Ce(Re),c(On(t,Re==="overview"?void 0:Re,s,o))};return Qs({key:"1"},()=>wn("overview")),Qs({key:"2"},()=>wn("stream")),Qs({key:"3"},()=>wn("findings")),!te&&N?i.jsx(LU,{}):i.jsxs("div",{className:Y.panelContainer,children:[i.jsx(Ns,{segments:Yt}),i.jsxs("div",{className:Y.header,children:[i.jsxs("span",{className:Y.headerTitle,children:[i.jsx("span",{"data-testid":"task-title",children:(te==null?void 0:te.title)||t}),te&&i.jsx("span",{className:Y.taskStatusBadge,"data-testid":"task-status",children:te.status}),(te==null?void 0:te.branch)&&i.jsx("span",{className:Y.taskBranch,children:te.branch}),ia&&i.jsx("span",{className:Y.taskBlockedBadge,children:"blocked"})]}),te&&i.jsx(bB,{task:te,sessionId:gt,isBlocked:ia,onStart:()=>{T(te.id,void 0,Le).catch(()=>{})},onResume:()=>{D(te.id).catch(()=>{})},onStop:()=>{C(te.id).catch(()=>{})},onPause:()=>{gt&&k(gt).catch(()=>{})},onDelete:ps,onEdit:()=>oe(!0)})]}),i.jsxs("div",{className:Y.tabBar,role:"tablist","aria-label":"Task view",children:[i.jsx("button",{role:"tab","aria-selected":fe==="overview",className:`${Y.tab} ${fe==="overview"?Y.active:""}`,onClick:()=>wn("overview"),children:"Overview"}),i.jsx("button",{role:"tab","aria-selected":fe==="stream",className:`${Y.tab} ${fe==="stream"?Y.active:""}`,onClick:()=>wn("stream"),children:"Stream"}),i.jsx("button",{role:"tab","aria-selected":fe==="findings",className:`${Y.tab} ${fe==="findings"?Y.active:""}`,onClick:()=>wn("findings"),children:"Findings"})]}),i.jsxs(us,{mode:"wait",children:[fe==="overview"&&i.jsx(Rt.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},className:Y.overviewContent,"data-testid":"task-overview",children:Tn&&te?i.jsx(E1,{mode:"edit",taskId:te.id,workspaceId:ht,environmentId:o,tasks:w,workspaces:$,personas:W,onCreateTask:(Re,Je,Jt,St,un,Wt,Oi,Bi,Li)=>{E(Re,Je,Jt,St,un,Wt,Oi,Bi,Li).catch(()=>{})},onUpdateTask:(Re,Je,Jt,St,un)=>{A(Re,Je,Jt,St,un).catch(()=>{})},onEditDone:()=>{ge?c(On(te.id,void 0,s,o),{replace:!0}):oe(!1)},onShowToast:d}):te?i.jsx(oL,{task:te,tasksById:es,environments:P,workspaces:$,taskSessions:Kt,selectedEnvId:Le,taskUsage:Za,treeUsage:Ii}):i.jsx("div",{className:Y.waitingMessage,children:"No additional details"})},"overview"),fe==="stream"&&i.jsxs(Rt.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},style:{display:"flex",flexDirection:"column",flex:1,overflow:"hidden"},children:[i.jsx(M3,{taskSessions:Kt,selectedSessionId:gt,onSelect:Re=>ve(Re)}),i.jsx(Xm,{events:Fa,eventsDropped:p,emptyState:!gt&&te?ia?i.jsx("div",{className:Y.emptyCta,"data-testid":"stream-blocked-message",children:i.jsx("div",{className:Y.ctaDescription,children:"This task is blocked by incomplete dependencies"})}):i.jsxs("div",{className:Y.emptyCta,children:[i.jsx("button",{"data-testid":"stream-start-cta",className:Y.ctaButton,onClick:()=>{T(te.id,void 0,Le).catch(()=>{})},children:"Start Task"}),i.jsx("div",{className:Y.ctaDescription,children:"Click to begin agent execution"})]}):gt&&Fa.length===0?i.jsx("div",{className:Y.waitingMessage,children:"Waiting for events..."}):void 0,onShowToast:d})]},"stream"),fe==="findings"&&i.jsx(Rt.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},className:Y.tabContent,children:ht?i.jsx(N1,{findings:U.filter(Re=>Re.workspaceId===ht)}):i.jsx("div",{className:Y.noContext,children:"Navigate to a task within a workspace to view findings"})},"findings")]}),(()=>{if(!te||te.status!=="working"&&te.status!=="paused")return;const Re=gt?m.find(Je=>Je.id===gt):void 0;if(!(!Re||Re.status==="stopped"))return i.jsx(Qr,{mode:"send",sessionId:Re.id,environmentId:Re.environmentId,personas:W,environments:P,onSendInput:(Je,Jt)=>{x(Je,Jt).catch(()=>{})},onSpawn:(Je,Jt,St)=>{S(Je,Jt,St).catch(()=>{})},onStartTask:(Je,Jt,St)=>{T(Je,Jt,St).catch(()=>{})},onProvisionEnvironment:Je=>{I(Je).catch(()=>{})},onShowToast:d})})(),te&&i.jsx(Ci,{isOpen:Ze,title:"Delete Task?",description:`"${te.title}" will be permanently removed.`,onConfirm:aa,onCancel:()=>me(!1)})]})}function zU(){const{environments:{environments:t,addEnvironment:s,updateEnvironment:o},codespaces:{codespaces:r,codespaceError:c,codespaceListError:d,codespaceCreating:u,listCodespaces:p,createCodespace:m}}=mt(),{showToast:g}=Sn();return i.jsx(A1,{mode:"new",environments:t,onAddEnvironment:(v,b,x)=>{s(v,b,x).catch(()=>{})},onUpdateEnvironment:(v,b)=>{o(v,b).catch(()=>{})},onListCodespaces:()=>{p().catch(()=>{})},codespaces:r,codespaceError:c,codespaceListError:d,codespaceCreating:u,onCreateCodespace:(v,b)=>{m(v,b).catch(()=>{})},onShowToast:g})}function $U(){const{environmentId:t}=fs(),{environments:{environments:s,addEnvironment:o,updateEnvironment:r},codespaces:{codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,listCodespaces:m,createCodespace:g}}=mt(),{showToast:v}=Sn();return i.jsx(A1,{mode:"edit",environmentId:t,environments:s,onAddEnvironment:(b,x,S)=>{o(b,x,S).catch(()=>{})},onUpdateEnvironment:(b,x)=>{r(b,x).catch(()=>{})},onListCodespaces:()=>{m().catch(()=>{})},codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:(b,x)=>{g(b,x).catch(()=>{})},onShowToast:v})}const UU="_layout_11u79_1",PU="_content_11u79_8",HU="_tabPanel_11u79_14",Xr={layout:UU,content:PU,tabPanel:HU};function VU(){const t=v7();return i.jsxs("div",{className:Xr.layout,children:[i.jsx(Ns,{segments:t}),i.jsx("div",{className:Xr.content,children:i.jsx(Va,{})})]})}const qU="_container_144a4_1",GU="_envHeader_144a4_6",FU="_envTitleRow_144a4_10",ZU="_statusDot_144a4_16",KU="_envName_144a4_21",YU="_statusBadge_144a4_27",JU="_envMeta_144a4_33",WU="_metaTag_144a4_39",XU="_actions_144a4_51",QU="_provisionMessage_144a4_59",eP="_errorMessage_144a4_64",tP="_section_144a4_69",nP="_sectionHeader_144a4_73",sP="_cardList_144a4_121",aP="_card_144a4_121",iP="_cardHeader_144a4_138",oP="_cardName_144a4_144",rP="_cardActions_144a4_149",lP="_cardDescription_144a4_154",cP="_cardMeta_144a4_160",dP="_repoLink_144a4_166",uP="_empty_144a4_174",fP="_errorHint_144a4_180",pP="_btnPrimary_144a4_186",mP="_btnOutline_144a4_220",hP="_btnSmall_144a4_247",gP="_btnDanger_144a4_273",Se={container:qU,envHeader:GU,envTitleRow:FU,statusDot:ZU,envName:KU,statusBadge:YU,envMeta:JU,metaTag:WU,actions:XU,provisionMessage:QU,errorMessage:eP,section:tP,sectionHeader:nP,cardList:sP,card:aP,cardHeader:iP,cardName:oP,cardActions:rP,cardDescription:lP,cardMeta:cP,repoLink:dP,empty:uP,errorHint:fP,btnPrimary:pP,btnOutline:mP,btnSmall:hP,btnDanger:gP};function vP(){return i.jsxs("div",{className:Se.container,"aria-hidden":"true",children:[i.jsxs("div",{className:Se.envHeader,children:[i.jsxs("div",{className:Se.envTitleRow,children:[i.jsx(we,{width:"0.875rem",height:"0.875rem",variant:"circular"}),i.jsx(we,{width:"12rem",height:"1.5rem"}),i.jsx(we,{width:"4rem",height:"0.875rem"})]}),i.jsxs("div",{className:Se.envMeta,children:[i.jsx(we,{width:"6rem",height:"1.25rem",borderRadius:"var(--radius-sm)"}),i.jsx(we,{width:"5rem",height:"1.25rem",borderRadius:"var(--radius-sm)"}),i.jsx(we,{width:"4.5rem",height:"1.25rem",borderRadius:"var(--radius-sm)"})]})]}),i.jsxs("div",{className:Se.actions,children:[i.jsx(we,{width:"5rem",height:"2rem",borderRadius:"var(--radius-sm)"}),i.jsx(we,{width:"4rem",height:"2rem",borderRadius:"var(--radius-sm)"})]}),i.jsxs("div",{className:Se.section,children:[i.jsx("div",{className:Se.sectionHeader,children:i.jsx("h3",{style:{margin:0},children:"Workspaces"})}),i.jsxs("div",{className:Se.cardList,children:[i.jsx(dd,{lines:2}),i.jsx(dd,{lines:2})]})]})]})}const yP={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function bP(){const{environmentId:t}=fs(),s=kt(),{environments:{environments:o,environmentsLoading:r,provisionStatus:c,provisionEnvironment:d,stopEnvironment:u,removeEnvironment:p},workspaces:{workspaces:m,archiveWorkspace:g,linkEnvironment:v,unlinkEnvironment:b,linkOperationError:x,clearLinkOperationError:S},sessions:{sessions:k}}=mt(),[w,N]=y.useState(!1),[T,C]=y.useState(!1),[D,B]=y.useState(void 0),E=o.find(J=>J.id===t);if(!E&&r)return i.jsx(vP,{});if(!t||!E)return i.jsx(ds,{to:Ro,replace:!0});const A=m.filter(J=>J.environmentId===E.id),P=m.filter(J=>J.linkedEnvironmentIds.includes(E.id)&&J.environmentId!==E.id).filter((J,ce,X)=>X.findIndex(ge=>ge.id===J.id)===ce),I=k.filter(J=>J.environmentId===E.id),U=I.reduce((J,ce)=>J+(ce.costUsd??0),0),Q=yP[E.status]||"var(--text-tertiary)",$=E.status==="connected",W=E.status==="connecting",pe=E.status==="disconnected"||E.status==="error"||E.status==="sleeping",H=E.id in c?c[E.id]:void 0,ie=()=>{p(E.id).catch(()=>{}),N(!1),s(Ro,{replace:!0})},L=()=>{C(!1),d(E.id,!0).catch(()=>{})},Z=J=>{g(J).catch(()=>{}),B(void 0)};return i.jsxs("div",{className:Se.container,children:[i.jsx(Ci,{isOpen:w,title:"Delete Environment?",description:`"${E.displayName||E.id}" will be permanently removed along with all its data.`,onConfirm:ie,onCancel:()=>N(!1)}),i.jsx(Ci,{isOpen:T,title:"Reprovision Environment?",description:"This will kill any active session and force a fresh provision cycle. The environment will be temporarily disconnected.",confirmLabel:"Reprovision",onConfirm:L,onCancel:()=>C(!1)}),i.jsxs("div",{className:Se.envHeader,children:[i.jsxs("div",{className:Se.envTitleRow,children:[i.jsx("span",{className:Se.statusDot,style:{color:Q},children:"●"}),i.jsx("h2",{className:Se.envName,children:E.displayName||E.id}),i.jsx("span",{className:Se.statusBadge,style:{color:Q},children:E.status})]}),i.jsxs("div",{className:Se.envMeta,children:[i.jsxs("span",{className:Se.metaTag,children:["Adapter: ",E.adapterType]}),I.length>0&&i.jsxs("span",{className:Se.metaTag,children:[I.length," session",I.length!==1?"s":""]}),U>0&&i.jsxs("span",{className:Se.metaTag,children:["Cost: ",Ss(U)]})]})]}),i.jsxs("div",{className:Se.actions,children:[$&&i.jsxs(i.Fragment,{children:[i.jsx("button",{className:Se.btnPrimary,onClick:()=>s(Bx(E.id)),children:"New Chat"}),i.jsx("button",{className:Se.btnOutline,onClick:()=>{u(E.id).catch(()=>{})},children:"Stop"}),i.jsx("button",{className:Se.btnOutline,onClick:()=>C(!0),disabled:H!==void 0,"data-testid":"env-reprovision-btn",children:"Reprovision"})]}),pe&&i.jsx("button",{className:Se.btnPrimary,onClick:()=>{d(E.id).catch(()=>{})},children:E.status==="error"?"Retry":E.status==="sleeping"?"Wake":"Connect"}),W&&H!==void 0&&i.jsx("span",{className:Se.provisionMessage,children:H.message}),E.status==="error"&&(H==null?void 0:H.stage)==="error"&&i.jsx("span",{className:Se.errorMessage,children:H.message}),i.jsx("button",{className:Se.btnOutline,onClick:()=>s(sN(E.id)),"data-testid":"env-edit-btn",children:"Edit Config"}),i.jsx("button",{className:Se.btnDanger,onClick:()=>N(!0),children:"Delete"})]}),i.jsxs("div",{className:Se.section,children:[i.jsxs("div",{className:Se.sectionHeader,children:[i.jsx("h3",{children:"Workspaces"}),i.jsx("button",{className:Se.btnPrimary,onClick:()=>s(`${zx}?environment=${encodeURIComponent(E.id)}`),"data-testid":"workspace-create-button",children:"+ New Workspace"})]}),A.length===0&&i.jsx("p",{className:Se.empty,children:"No workspaces yet. Create one to get started."}),i.jsx("div",{className:Se.cardList,children:A.map(J=>i.jsx(xP,{workspace:J,confirmArchiveId:D,onOpen:()=>s($a(J.id,E.id)),onArchive:()=>B(J.id),onConfirmArchive:()=>Z(J.id),onCancelArchive:()=>B(void 0)},J.id))})]}),i.jsxs("div",{className:Se.section,children:[i.jsxs("div",{className:Se.sectionHeader,children:[i.jsx("h3",{children:"Linked Workspaces"}),(()=>{const J=m.filter(ce=>ce.environmentId!==E.id&&!ce.linkedEnvironmentIds.includes(E.id)&&ce.status==="active");return J.length===0?null:i.jsxs("select",{className:Se.btnPrimary,value:"",onChange:ce=>{ce.target.value&&v(ce.target.value,E.id).catch(()=>{})},"aria-label":"Link a workspace","data-testid":"link-workspace-select",children:[i.jsx("option",{value:"",children:"+ Link Workspace"}),J.map(ce=>i.jsx("option",{value:ce.id,children:ce.name},ce.id))]})})()]}),P.length===0&&i.jsx("p",{className:Se.empty,"data-testid":"linked-workspaces-empty",children:"No workspaces are linked to this environment."}),x&&i.jsxs("p",{className:Se.errorHint,"data-testid":"link-operation-error",role:"alert",children:[x,i.jsx("button",{className:Se.btnSmall,onClick:S,"aria-label":"Dismiss error","data-testid":"dismiss-link-error",children:"Dismiss"})]}),i.jsx("div",{className:Se.cardList,"data-testid":"linked-workspaces-list",children:P.map(J=>{var ce;return i.jsxs("div",{className:Se.card,"data-testid":`linked-workspace-card-${J.id}`,children:[i.jsxs("div",{className:Se.cardHeader,children:[i.jsx("strong",{className:Se.cardName,children:J.name}),i.jsxs("div",{className:Se.cardActions,children:[i.jsx("button",{className:Se.btnSmall,onClick:()=>s($a(J.id,J.environmentId)),children:"Open"}),i.jsx("button",{className:Se.btnSmall,onClick:()=>{b(J.id,E.id).catch(()=>{})},"data-testid":`unlink-workspace-${J.id}`,children:"Unlink"})]})]}),J.description&&i.jsx("p",{className:Se.cardDescription,children:J.description}),i.jsxs("div",{className:Se.cardMeta,children:["Primary: ",((ce=o.find(X=>X.id===J.environmentId))==null?void 0:ce.displayName)||J.environmentId]})]},J.id)})})]})]})}function xP({workspace:t,confirmArchiveId:s,onOpen:o,onArchive:r,onConfirmArchive:c,onCancelArchive:d}){const u=s===t.id,p=t.repoUrl&&/^https?:\/\//.test(t.repoUrl);return i.jsxs("div",{className:Se.card,"data-testid":"workspace-card",children:[i.jsxs("div",{className:Se.cardHeader,children:[i.jsx("strong",{className:Se.cardName,children:t.name}),i.jsxs("div",{className:Se.cardActions,children:[i.jsx("button",{className:Se.btnSmall,onClick:o,children:"Open"}),u?i.jsxs(i.Fragment,{children:[i.jsx("button",{className:Se.btnDanger,onClick:c,children:"Confirm"}),i.jsx("button",{className:Se.btnSmall,onClick:d,children:"Cancel"})]}):i.jsx("button",{className:Se.btnSmall,onClick:r,children:"Archive"})]})]}),t.description&&i.jsx("p",{className:Se.cardDescription,children:t.description}),t.repoUrl&&i.jsx("div",{className:Se.cardMeta,children:p?i.jsx("a",{href:t.repoUrl,target:"_blank",rel:"noopener noreferrer",className:Se.repoLink,children:t.repoUrl}):i.jsx("span",{children:t.repoUrl})})]})}const _P={credentials:"Credentials",personas:"Personas",appearance:"Appearance",about:"About",shortcuts:"Shortcuts"};function kP(){const s=Zt().pathname.replace(/^\/settings\/?/,"").split("/")[0],o=_P[s],r=g7(o);return i.jsxs("div",{className:Xr.layout,children:[i.jsx(Ns,{segments:r}),i.jsx("div",{className:Xr.content,children:i.jsx("div",{className:Xr.tabPanel,children:i.jsx(Va,{})},s)})]})}function SP(){const{tokens:{tokens:t,setToken:s,deleteToken:o},credentials:{credentialProviders:r,updateCredentialProviders:c}}=mt(),{showToast:d}=Sn();return i.jsxs(i.Fragment,{children:[i.jsx(LL,{credentialProviders:r,onUpdateCredentialProviders:u=>{c(u).catch(()=>{})}}),i.jsx(GO,{tokens:t,onSetToken:(u,p,m,g,v)=>{s(u,p,m,g,v).catch(()=>{})},onDeleteToken:u=>{o(u).catch(()=>{})},onShowToast:d})]})}function TP(){const{personas:{personas:t,deletePersona:s},appDefaultPersonaId:o,setAppDefaultPersonaId:r}=mt(),{showToast:c}=Sn(),d=kt();return i.jsx(JL,{personas:t,appDefaultPersonaId:o,onDeletePersona:async u=>{try{await s(u)}catch(p){throw console.error("Failed to delete persona",{personaId:u,error:p}),c("Failed to delete persona","error"),p}},onSetAppDefaultPersonaId:async u=>{try{await r(u)}catch(p){console.error("Failed to set app default persona ID",{personaId:u,error:p}),c("Failed to set app default persona","error")}},onNavigateToNew:()=>d(iN),onNavigateToPersona:u=>d(Lx(u))})}const wP="_container_1ooin_1",jP="_form_1ooin_7",NP="_formActions_1ooin_75",CP="_editableSection_1ooin_82",EP="_defaultBadge_1ooin_93",AP="_typeToggle_1ooin_107",DP="_scriptEditor_1ooin_121",RP="_optional_1ooin_128",ls={container:wP,form:jP,formActions:NP,editableSection:CP,defaultBadge:EP,typeToggle:AP,scriptEditor:DP,optional:RP},sx=[{value:"claude-code",label:"claude-code"},{value:"codex",label:"codex"},{value:"copilot",label:"copilot"},{value:"goose",label:"goose"},{value:"stub",label:"stub"},{value:"claude-code-acp",label:"claude-code-acp (experimental)"},{value:"codex-acp",label:"codex-acp (experimental)"},{value:"copilot-acp",label:"copilot-acp (experimental)"}],ax=[{value:"genaiscript",label:"genaiscript"}],MP="0";function ix(){const{personaId:t}=fs(),s=kt(),{showToast:o}=Sn(),{personas:{personas:r,createPersona:c,updatePersona:d,deletePersona:u},appDefaultPersonaId:p,setAppDefaultPersonaId:m}=mt(),g=t===void 0,v=g?void 0:r.find(x=>x.id===t);if(!g&&r.length>0&&!v)return i.jsx(ds,{to:qf,replace:!0});const b=[{label:"Settings",url:Do},{label:"Personas",url:qf},{label:g?"New Persona":(v==null?void 0:v.name)??"Persona",url:void 0}];return i.jsxs("div",{className:ls.container,children:[i.jsx(Ns,{segments:b}),i.jsx(IP,{existing:v,isNew:g,appDefaultPersonaId:p,onCreatePersona:c,onUpdatePersona:d,onDeletePersona:u,onSetAppDefaultPersonaId:m,onDone:()=>{s(qf)},showToast:o})]})}function IP({existing:t,isNew:s,appDefaultPersonaId:o,onCreatePersona:r,onUpdatePersona:c,onDeletePersona:d,onSetAppDefaultPersonaId:u,onDone:p,showToast:m}){const g=kt(),[v,b]=y.useState((t==null?void 0:t.name)??""),[x,S]=y.useState((t==null?void 0:t.description)??""),[k,w]=y.useState((t==null?void 0:t.systemPrompt)??""),[N,T]=y.useState((t==null?void 0:t.runtime)??"claude-code"),[C,D]=y.useState((t==null?void 0:t.model)??"sonnet"),[B,E]=y.useState((t==null?void 0:t.maxTurns)??0),[A,P]=y.useState((t==null?void 0:t.type)==="script"?"script":"agent"),[I,U]=y.useState((t==null?void 0:t.script)??""),[Q,$]=y.useState((t==null?void 0:t.allowedMcpTools)??[]),[W,pe]=y.useState(!1),[H,ie]=y.useState(null),[L,Z]=y.useState(!!s);y.useEffect(()=>{if(!s&&t&&!L){Z(!0),b(t.name),S(t.description),w(t.systemPrompt);const oe=t.type==="script"?"script":"agent";T(oe==="script"?t.runtime||"genaiscript":t.runtime),D(t.model),E(t.maxTurns),P(oe),U(t.script||""),$(t.allowedMcpTools)}},[s,t,L]);const J=oe=>{P(oe),oe==="script"?T("genaiscript"):N==="genaiscript"&&T("claude-code")},ce=!s&&t===void 0,X=v.trim().length>0&&!ce&&k.trim().length>0&&(A==="script"?I.trim().length>0:!!N&&!!C),ge=s&&X,fe=!s&&o===(t==null?void 0:t.id),Ce=!s&&t&&!fe&&A==="agent"&&!!N&&!!C,Ze=(oe,Ve)=>{if(!oe.trim())return`${Ve} is required`},me=oe=>{if(oe.preventDefault(),!(ce||!X)){if(t){c(t.id,v,x,k,N,C,B,A,I).then(()=>{m("Persona updated","success"),p()},()=>{m("Failed to save persona","error")});return}r(v,x,k,N,C,B,A,I,Q).then(Ve=>{m("Persona created","success"),g(Lx(Ve.id),{replace:!0})},()=>{m("Failed to save persona","error")})}},_e=()=>{t&&d(t.id).then(()=>{m("Persona deleted","success"),p()},()=>{m("Failed to delete persona","error")})},ve=async(oe,Ve,qt,te)=>oe().then(()=>{Ve(),m(qt,"success")},()=>{m(te,"error")}),Le=(oe,Ve)=>{if(!t)return;const qt=oe==="type"?String(Ve):A,te=oe==="runtime"?String(Ve):oe==="type"?String(Ve)==="script"?"genaiscript":N==="genaiscript"?"claude-code":N:N,ht=oe==="model"?String(Ve):C,at=oe==="maxTurns"?Number(Ve):B,Kt=oe==="systemPrompt"?String(Ve):k,gt=oe==="script"?String(Ve):I;ve(()=>c(t.id,oe==="name"?String(Ve):v,oe==="description"?String(Ve):x,Kt,te,ht,at,qt,gt),()=>{if(oe==="type"){const ps=String(Ve)==="script"?"script":"agent";P(ps),T(te)}oe==="runtime"&&T(String(Ve)),oe==="name"&&b(String(Ve)),oe==="description"&&S(String(Ve)),oe==="systemPrompt"&&w(String(Ve)),oe==="model"&&D(String(Ve)),oe==="maxTurns"&&E(Number(Ve)),oe==="script"&&U(String(Ve))},"Persona updated","Failed to update persona").catch(()=>{})},Mt=oe=>{me(oe)},Tn=()=>{t&&u(t.id).then(()=>{m("Set as app default","success")},()=>{m("Failed to set app default","error")})};return i.jsxs(i.Fragment,{children:[ce?i.jsxs("div",{className:ls.form,children:[i.jsx("h3",{children:"Edit Persona"}),i.jsx("p",{children:"Loading persona..."})]}):s?i.jsxs("form",{onSubmit:Mt,className:ls.form,children:[i.jsx("h3",{children:"Create Persona"}),i.jsxs("div",{className:ls.typeToggle,"data-testid":"persona-type-toggle",children:[i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:"personaType",value:"agent",checked:A==="agent",onChange:()=>J("agent")}),"Agent"]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:"personaType",value:"script",checked:A==="script",onChange:()=>J("script")}),"Script"]})]}),i.jsxs("label",{children:["Name",i.jsx("input",{type:"text",value:v,onChange:oe=>b(oe.target.value),placeholder:A==="script"?"e.g. Nightly Report":"e.g. Frontend Engineer",required:!0,"data-testid":"persona-detail-name"})]}),i.jsxs("label",{children:["Description",i.jsx("input",{type:"text",value:x,onChange:oe=>S(oe.target.value),placeholder:"Brief description...","data-testid":"persona-detail-description"})]}),i.jsxs("label",{children:["Runtime",i.jsx("select",{value:N,onChange:oe=>T(oe.target.value),"data-testid":"persona-runtime-select",children:(A==="script"?ax:sx).map(oe=>i.jsx("option",{value:oe.value,children:oe.label},oe.value))})]}),A==="agent"&&i.jsxs(i.Fragment,{children:[i.jsxs("label",{children:["Model",i.jsx("input",{type:"text",value:C,onChange:oe=>D(oe.target.value),placeholder:"e.g. sonnet","data-testid":"persona-detail-model"})]}),i.jsxs("label",{children:["Max Turns",i.jsx("input",{type:"number",value:B,onChange:oe=>E(parseInt(oe.target.value,10)||0),min:0,"data-testid":"persona-detail-max-turns"})]}),i.jsxs("label",{children:["System Prompt",i.jsx("textarea",{value:k,onChange:oe=>w(oe.target.value),placeholder:"You are a senior frontend engineer...",rows:10,required:!0,"data-testid":"persona-detail-prompt"})]})]}),A==="script"&&i.jsxs(i.Fragment,{children:[i.jsxs("label",{children:["Model ",i.jsx("span",{className:ls.optional,children:"(optional)"}),i.jsx("input",{type:"text",value:C,onChange:oe=>D(oe.target.value),placeholder:"e.g. sonnet (leave empty for script-only)","data-testid":"persona-detail-model"})]}),i.jsxs("label",{children:["System Prompt",i.jsx("textarea",{value:k,onChange:oe=>w(oe.target.value),placeholder:"Context for the script...",rows:4,required:!0,"data-testid":"persona-detail-prompt"})]}),i.jsxs("label",{children:["Script",i.jsx("textarea",{value:I,onChange:oe=>U(oe.target.value),placeholder:`script({ model: "openai:gpt-4o" });
|
|
701
|
+
src/utils/token-refresh.ts:28: const remaining = decoded.exp - Date.now() / 1000;`,raw:JSON.stringify({tool_use_id:"tool-mock-004",is_error:!1})}},{delayMs:7800,event:{eventType:"text",timestamp:Me(7800),content:"Fixed. The token expiry comparison was inverted — `decoded.exp > Date.now()` should have been `<` (a token is expired when its `exp` is in the past). The other occurrence in `token-refresh.ts` uses subtraction (not comparison), so it was already correct. All 3 auth tests pass."}},{delayMs:8400,event:{eventType:"usage",timestamp:Me(8400),content:JSON.stringify({input_tokens:42600,output_tokens:1850,cost_millicents:12e3})}},{delayMs:8800,event:{eventType:"status",timestamp:Me(8800),content:"completed"}}]}],_s={onConnect:async()=>{},onDisconnect:()=>{},handleEvent:()=>!1},Yb=400;function z7({children:t}){const[s,o]=y.useState(A7),[r,c]=y.useState(D7),[d,u]=y.useState(R7),[p,m]=y.useState(void 0),[g,v]=y.useState(M7),[b,x]=y.useState(""),[S,k]=y.useState(I7),[w,N]=y.useState(Pc),[T,C]=y.useState(void 0),D=!1,[B,E]=y.useState(O7),[A,P]=y.useState({claude:"off",github:"off",copilot:"off",codex:"off",goose:"off"}),[I,U]=y.useState(B7),[Q]=y.useState(L7),[$,W]=y.useState(""),[pe,H]=y.useState(ks),[ie,L]=y.useState(Ra),[Z,J]=y.useState(void 0),[ce,X]=y.useState(void 0),[ge,fe]=y.useState(""),Ce=y.useRef(void 0),Ze=y.useRef(0),me=y.useRef(0),_e=y.useRef(new Set),ve=y.useRef(new Map),Le=y.useRef(S);Le.current=S;const Mt=y.useRef(new Map),Tn=y.useRef(new Map),oe=y.useCallback(V=>(Ze.current+=1,`mock-${V}-${String(Ze.current).padStart(3,"0")}`),[]),Ve=y.useCallback(()=>{const V=Kb[me.current%Kb.length];return me.current+=1,V},[]),qt=y.useCallback((V,ae,le)=>{const de=setTimeout(()=>{var ye;_e.current.delete(de),le&&((ye=ve.current.get(le))==null||ye.delete(de)),V()},ae);_e.current.add(de),le&&(ve.current.has(le)||ve.current.set(le,new Set),ve.current.get(le).add(de))},[]),te=y.useCallback(V=>{const ae=ve.current.get(V);ae&&(ae.forEach(le=>{clearTimeout(le),_e.current.delete(le)}),ve.current.delete(V))},[]),ht=y.useCallback((V,ae,le)=>{c(de=>de.map(ye=>ye.id===V?{...ye,status:ae,...le!==void 0?{endReason:le}:{}}:ye))},[]),at=y.useCallback(V=>{u(ae=>[...ae,V])},[]),Kt=y.useCallback((V,ae,le)=>{ae.forEach((de,ye)=>{qt(()=>{const We={sessionId:V,...de.event,timestamp:new Date().toISOString()};if(at(We),de.event.eventType==="status"){const Te=P1(de.event.content),Ie=H1(de.event.content);ht(V,Te,Ie)}ye===ae.length-1&&le&&le()},de.delayMs,V)})},[qt,at,ht]),gt=y.useCallback(async(V,ae,le,de)=>{console.log("[MockGrackle] spawn",{environmentId:V,prompt:ae,runtime:de});const ye=oe("sess"),We={id:ye,environmentId:V,runtime:de||"claude-code",status:"running",prompt:ae,startedAt:new Date().toISOString()};c(Ie=>[...Ie,We]),m(ye);const Te=Ve();if(console.log(`[MockGrackle] Playing scenario: ${Te.label}`),Te.pauseForInput){const Ie=Te.pauseAfterStep??Te.steps.length-1,Ke=Te.steps.slice(0,Ie+1),ct=Ke.length>0?Ke[Ke.length-1].delayMs:0;Kt(ye,Ke),qt(()=>{ht(ye,"idle"),at({sessionId:ye,eventType:"status",timestamp:new Date().toISOString(),content:"idle"})},ct+Yb,ye),Te.resumeSteps&&Mt.current.set(ye,Te.resumeSteps)}else Kt(ye,Te.steps)},[oe,Ve,Kt,qt,ht,at]),ps=y.useCallback(async V=>{console.log("[MockGrackle] kill",V),te(V),Mt.current.delete(V),ht(V,"stopped","killed"),at({sessionId:V,eventType:"status",timestamp:new Date().toISOString(),content:"killed"}),k(ae=>ae.map(le=>le.latestSessionId===V&&le.status==="working"?{...le,status:"not_started"}:le))},[te,ht,at]),aa=y.useCallback(async V=>{console.log("[MockGrackle] stopGraceful",V),te(V),Mt.current.delete(V),ht(V,"stopped","terminated"),at({sessionId:V,eventType:"status",timestamp:new Date().toISOString(),content:"terminated"}),k(ae=>ae.map(le=>le.latestSessionId===V&&le.status==="working"?{...le,status:"not_started"}:le))},[te,ht,at]),es=y.useCallback(()=>{console.log("[MockGrackle] refresh")},[]),Fa=y.useCallback(async V=>{console.log("[MockGrackle] loadSessionEvents",V)},[]),ia=y.useCallback(()=>{console.log("[MockGrackle] clearEvents"),u([])},[]),Yt=y.useCallback(async(V,ae,le,de,ye,We,Te,Ie,Ke)=>{console.log("[MockGrackle] createWorkspace",{name:V,description:ae});const ct={id:oe("proj"),name:V,description:ae||"",repoUrl:le||"",environmentId:de||"",linkedEnvironmentIds:[],status:"active",workingDirectory:Te||"",useWorktrees:We??!0,defaultPersonaId:ye||"",tokenBudget:0,costBudgetMillicents:0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};v(Xe=>[...Xe,ct]),Ie&&Ie()},[oe]),Mi=y.useCallback(async V=>{console.log("[MockGrackle] archiveWorkspace",V),v(ae=>ae.map(le=>le.id===V?{...le,status:"archived"}:le))},[]),oa=y.useCallback(async V=>{console.log("[MockGrackle] loadTasks",V)},[]),Za=y.useCallback(async(V,ae,le,de,ye,We,Te,Ie,Ke)=>{console.log("[MockGrackle] createTask",{workspaceId:V,title:ae,parentTaskId:ye}),k(ct=>{const Xt=ct.filter(gn=>gn.workspaceId===V).reduce((gn,Qa)=>Math.max(gn,Qa.sortOrder),0),jt=ye?ct.find(gn=>gn.id===ye):void 0;if(ye&&!jt)return console.warn("[MockGrackle] Parent task not found:",ye),ct;if(jt&&!jt.canDecompose)return console.warn("[MockGrackle] Parent task does not have decomposition rights:",ye),ct;const Ue=jt?jt.depth+1:0,It={id:oe("task"),workspaceId:V,title:ae,description:le||"",status:"not_started",branch:"",latestSessionId:"",dependsOn:de||[],reviewNotes:void 0,sortOrder:Xt+1,createdAt:new Date().toISOString(),parentTaskId:ye||"",depth:Ue,childTaskIds:[],canDecompose:Te??!ye,defaultPersonaId:We||"",workpad:"",tokenBudget:0,costBudgetMillicents:0};return[...ct,It]}),Ie&&Ie()},[oe]),ms=y.useCallback(async(V,ae,le,de)=>{var ct;console.log("[MockGrackle] startTask",{taskId:V});const ye=Le.current.find(Xe=>Xe.id===V),We=(ye==null?void 0:ye.title)??"",Te=oe("sess"),Ie={id:Te,environmentId:"env-local-01",runtime:"claude-code",status:"running",prompt:We||V,startedAt:new Date().toISOString()};c(Xe=>[...Xe,Ie]),k(Xe=>Xe.map(Xt=>Xt.id===V?{...Xt,status:"working",latestSessionId:Te,branch:`mock/${V.slice(0,8)}`}:Xt));const Ke=Ve();if(console.log(`[MockGrackle] Playing task scenario: ${Ke.label}`),Ke.pauseForInput){const Xe=Ke.pauseAfterStep??Ke.steps.length-1,Xt=Ke.steps.slice(0,Xe+1),jt=Xt.length>0?Xt[Xt.length-1].delayMs:0;if(Kt(Te,Xt),qt(()=>{ht(Te,"idle"),at({sessionId:Te,eventType:"status",timestamp:new Date().toISOString(),content:"idle"})},jt+Yb,Te),Ke.resumeSteps){const Ue=[...Ke.resumeSteps];Mt.current.set(Te,Ue);const It=Ue.reduce((gn,Qa)=>Math.max(gn,Qa.delayMs),0);Tn.current.set(Te,{taskId:V,delayAfterResume:It+200})}}else{const Xe=Ke.steps.length>0?Ke.steps[Ke.steps.length-1].delayMs:0;Kt(Te,Ke.steps);const Xt=(ct=Ke.steps[Ke.steps.length-1])==null?void 0:ct.event.content;qt(()=>{Xt==="completed"?k(jt=>jt.map(Ue=>Ue.id===V&&Ue.status==="working"?{...Ue,status:"paused"}:Ue)):Xt==="failed"&&k(jt=>jt.map(Ue=>Ue.id===V&&Ue.status==="working"?{...Ue,status:"failed"}:Ue))},Xe+100,Te)}},[oe,Ve,Kt,qt,ht,at]),Ii=y.useCallback(async(V,ae)=>{console.log("[MockGrackle] sendInput",{sessionId:V,text:ae}),at({sessionId:V,eventType:"output",timestamp:new Date().toISOString(),content:`User input: ${ae}`}),ht(V,"running"),at({sessionId:V,eventType:"status",timestamp:new Date().toISOString(),content:"running"});const le=Mt.current.get(V);if(le)Mt.current.delete(V),Kt(V,le);else{const ye=[{delayMs:500,event:{eventType:"output",timestamp:new Date().toISOString(),content:"I received your input, continuing..."}},{delayMs:1500,event:{eventType:"status",timestamp:new Date().toISOString(),content:"completed"}}];Kt(V,ye)}const de=Tn.current.get(V);de&&(Tn.current.delete(V),qt(()=>{k(ye=>ye.map(We=>We.id===de.taskId&&We.status==="working"?{...We,status:"paused"}:We))},de.delayAfterResume,V))},[at,ht,Kt,qt]),wn=y.useCallback(async V=>{console.log("[MockGrackle] completeTask",V),k(ae=>ae.map(le=>le.id===V?{...le,status:"complete"}:le))},[]),Re=y.useCallback(async V=>{console.log("[MockGrackle] resumeTask",V)},[]),Je=y.useCallback(async(V,ae,le,de,ye)=>{console.log("[MockGrackle] updateTask",{taskId:V,title:ae}),k(We=>We.map(Te=>Te.id===V?{...Te,title:ae.trim()||Te.title,description:le,dependsOn:de,...ye!==void 0?{defaultPersonaId:ye}:{}}:Te))},[]),Jt=y.useCallback(async V=>{console.log("[MockGrackle] deleteTask",V),k(ae=>ae.filter(le=>le.id!==V))},[]),St=y.useCallback(async V=>{console.log("[MockGrackle] loadFindings",V),N(Pc.filter(ae=>ae.workspaceId===V))},[]),un=y.useCallback(async()=>{console.log("[MockGrackle] loadAllFindings"),N([...Pc])},[]),Wt=y.useCallback(async V=>{console.log("[MockGrackle] loadFinding",V);const ae=Pc.find(le=>le.id===V);C(ae)},[]),Oi=y.useCallback(async(V,ae,le,de,ye)=>{console.log("[MockGrackle] postFinding",{workspaceId:V,title:ae});const We={id:oe("find"),workspaceId:V,taskId:"",sessionId:"",category:de||"general",title:ae,content:le,tags:ye||[],createdAt:new Date().toISOString()};N(Te=>[...Te,We])},[oe]),Bi=y.useCallback(async()=>{console.log("[MockGrackle] loadEnvironments")},[]),Li=y.useCallback(async(V,ae,le)=>{console.log("[MockGrackle] addEnvironment",{displayName:V,adapterType:ae,adapterConfig:le})},[]),Ka=y.useCallback(async(V,ae)=>{console.log("[MockGrackle] updateEnvironment",{environmentId:V,...ae}),o(le=>le.map(de=>de.id!==V?de:{...de,...ae.displayName!==void 0?{displayName:ae.displayName}:{},...ae.adapterConfig!==void 0?{adapterConfig:JSON.stringify(ae.adapterConfig)}:{}}))},[]),Ya=y.useCallback(async()=>{console.log("[MockGrackle] loadTokens")},[]),Ja=y.useCallback(async(V,ae,le,de,ye)=>{console.log("[MockGrackle] setToken",{name:V,tokenType:le}),E(We=>[...We.filter(Ie=>Ie.name!==V),{name:V,tokenType:le,envVar:de,filePath:ye,expiresAt:""}])},[]),hs=y.useCallback(async V=>{console.log("[MockGrackle] deleteToken",V),E(ae=>ae.filter(le=>le.name!==V))},[]),Wa=y.useCallback(async V=>{console.log("[MockGrackle] updateCredentialProviders",V),P(V)},[]);y.useEffect(()=>()=>{_e.current.forEach(clearTimeout),_e.current.clear()},[]);const Xa=y.useMemo(()=>({connected:!0,environments:{environments:s,environmentsLoading:!1,provisionStatus:{},operationError:"",clearOperationError:()=>{},loadEnvironments:Bi,addEnvironment:Li,updateEnvironment:Ka,provisionEnvironment:async(V,ae)=>{},stopEnvironment:async()=>{},removeEnvironment:async()=>{},domainHook:_s},sessions:{sessions:r,sessionsLoading:!1,events:d,eventsDropped:0,lastSpawnedId:p,taskSessions:Q,spawn:gt,sendInput:Ii,kill:ps,stopGraceful:aa,loadSessionEvents:Fa,clearEvents:ia,loadTaskSessions:async V=>{console.log("[MockGrackle] loadTaskSessions",V)},domainHook:_s},workspaces:{workspaces:g,workspacesLoading:!1,workspaceCreating:!1,loadWorkspaces:async()=>{console.log("[MockGrackle] loadWorkspaces")},createWorkspace:Yt,archiveWorkspace:Mi,updateWorkspace:async(V,ae)=>{console.log("[MockGrackle] updateWorkspace",{workspaceId:V,...ae}),v(le=>le.map(de=>de.id!==V?de:{...de,...ae.name!==void 0?{name:ae.name}:{},...ae.description!==void 0?{description:ae.description}:{},...ae.repoUrl!==void 0?{repoUrl:ae.repoUrl}:{},...ae.environmentId!==void 0?{environmentId:ae.environmentId}:{},...ae.workingDirectory!==void 0?{workingDirectory:ae.workingDirectory}:{},...ae.useWorktrees!==void 0?{useWorktrees:ae.useWorktrees}:{},...ae.defaultPersonaId!==void 0?{defaultPersonaId:ae.defaultPersonaId}:{},updatedAt:new Date().toISOString()}))},linkEnvironment:async(V,ae)=>{if(console.log("[MockGrackle] linkEnvironment",{workspaceId:V,environmentId:ae}),ae==="error-env"){x("Failed to link environment");return}x(""),v(le=>le.map(de=>de.id!==V||de.linkedEnvironmentIds.includes(ae)?de:{...de,linkedEnvironmentIds:[...de.linkedEnvironmentIds,ae]}))},unlinkEnvironment:async(V,ae)=>{if(console.log("[MockGrackle] unlinkEnvironment",{workspaceId:V,environmentId:ae}),ae==="error-env"){x("Failed to unlink environment");return}x(""),v(le=>le.map(de=>de.id!==V?de:{...de,linkedEnvironmentIds:de.linkedEnvironmentIds.filter(ye=>ye!==ae)}))},linkOperationError:b,clearLinkOperationError:()=>{x("")},domainHook:_s},tasks:{tasks:S,tasksLoading:!1,taskStartingId:void 0,loadTasks:oa,loadAllTasks:async()=>{console.log("[MockGrackle] loadAllTasks")},createTask:Za,startTask:ms,stopTask:async V=>{console.log("[MockGrackle] stopTask",{taskId:V}),await wn(V)},completeTask:wn,resumeTask:Re,updateTask:Je,deleteTask:Jt,domainHook:_s},findings:{findings:w,selectedFinding:T,findingLoading:D,findingsLoading:!1,loadFindings:St,loadAllFindings:un,loadFinding:Wt,postFinding:Oi,domainHook:_s},tokens:{tokens:B,tokensLoading:!1,loadTokens:Ya,setToken:Ja,deleteToken:hs,domainHook:_s},credentials:{credentialProviders:A,credentialsLoading:!1,updateCredentialProviders:Wa,domainHook:_s},codespaces:{codespaces:[],codespaceError:"",codespaceListError:"",codespaceCreating:!1,listCodespaces:async()=>{},createCodespace:async()=>{},domainHook:_s},personas:{personas:I,personasLoading:!1,createPersona:async(V,ae,le,de,ye,We,Te,Ie,Ke)=>{console.log("[MockGrackle] createPersona",{name:V});const ct={id:`mock-persona-${Date.now()}`,name:V,description:ae,systemPrompt:le,toolConfig:"{}",runtime:de??"claude-code",model:ye||"",maxTurns:We||0,mcpServers:"[]",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),type:Te||"agent",script:Ie||"",allowedMcpTools:Ke||[]};return U(Xe=>[...Xe,ct]),ct},updatePersona:async(V,ae,le,de,ye,We,Te,Ie,Ke,ct)=>{console.log("[MockGrackle] updatePersona",{personaId:V,name:ae});const Xe=I.find(Ue=>Ue.id===V);if(!Xe)throw new Error(`Persona not found: ${V}`);const Xt=new Date().toISOString(),jt={...Xe,...ae!==void 0?{name:ae}:{},...le!==void 0?{description:le}:{},...de!==void 0?{systemPrompt:de}:{},...ye!==void 0?{runtime:ye}:{},...We!==void 0?{model:We}:{},...Te!==void 0?{maxTurns:Te}:{},...Ie!==void 0?{type:Ie}:{},...Ke!==void 0?{script:Ke}:{},...ct!==void 0?{allowedMcpTools:ct}:{},updatedAt:Xt};return U(Ue=>Ue.map(It=>It.id===V?jt:It)),jt},deletePersona:async V=>{console.log("[MockGrackle] deletePersona",V),U(ae=>ae.filter(le=>le.id!==V))},domainHook:_s},knowledge:{graphData:{nodes:pe,links:ie},selectedNode:Z,loading:!1,selectedId:ce,searchQuery:ge,search:async V=>{if(console.log("[MockGrackle] knowledge.search",V),!V.trim()){fe(V);return}fe(V);const ae=Ce.current,le=ae?ks.filter(Te=>!Te.workspaceId||Te.workspaceId===ae):ks,de=V.toLowerCase(),ye=le.filter(Te=>{var Ie,Ke,ct;return Te.label.toLowerCase().includes(de)||((Ie=Te.content)==null?void 0:Ie.toLowerCase().includes(de))||((Ke=Te.tags)==null?void 0:Ke.some(Xe=>Xe.toLowerCase().includes(de)))||((ct=Te.category)==null?void 0:ct.toLowerCase().includes(de))});H(ye);const We=new Set(ye.map(Te=>Te.id));L(Ra.filter(Te=>We.has(Te.source)&&We.has(Te.target))),X(void 0),J(void 0)},clearSearch:()=>{console.log("[MockGrackle] knowledge.clearSearch"),fe("");const V=Ce.current,ae=V?ks.filter(de=>!de.workspaceId||de.workspaceId===V):ks;H(ae);const le=new Set(ae.map(de=>de.id));L(Ra.filter(de=>le.has(de.source)&&le.has(de.target)))},selectNode:async V=>{console.log("[MockGrackle] knowledge.selectNode",V),X(V);const ae=V in Zb?Zb[V]:void 0;if(ae)J(ae);else{const le=ks.find(de=>de.id===V);if(le){const de=Ra.filter(ye=>ye.source===V||ye.target===V).map(ye=>({fromId:ye.source,toId:ye.target,type:ye.type}));J({node:le,edges:de})}}},clearSelection:()=>{console.log("[MockGrackle] knowledge.clearSelection"),X(void 0),J(void 0)},expandNode:async V=>{console.log("[MockGrackle] knowledge.expandNode",V),H(ae=>{const le=new Set(ae.map(Ie=>Ie.id)),de=Ra.filter(Ie=>Ie.source===V||Ie.target===V),ye=new Set;for(const Ie of de)le.has(Ie.source)||ye.add(Ie.source),le.has(Ie.target)||ye.add(Ie.target);if(ye.size===0)return ae;const We=ks.filter(Ie=>ye.has(Ie.id)),Te=new Set([...le,...ye]);return L(Ie=>{const Ke=new Set(Ie.map(Xe=>`${Xe.source}|${Xe.target}|${Xe.type}`)),ct=Ra.filter(Xe=>Te.has(Xe.source)&&Te.has(Xe.target)&&!Ke.has(`${Xe.source}|${Xe.target}|${Xe.type}`));return ct.length>0?[...Ie,...ct]:Ie}),[...ae,...We]})},loadRecent:async V=>{if(console.log("[MockGrackle] knowledge.loadRecent",V),Ce.current=V,V){const ae=ks.filter(de=>!de.workspaceId||de.workspaceId===V);H(ae);const le=new Set(ae.map(de=>de.id));L(Ra.filter(de=>le.has(de.source)&&le.has(de.target)))}else H(ks),L(Ra);fe("")},handleEvent:()=>!1,domainHook:_s},appDefaultPersonaId:$,setAppDefaultPersonaId:async V=>{console.log("[MockGrackle] setAppDefaultPersonaId",V),W(V)},onboardingCompleted:!0,completeOnboarding:async()=>{console.log("[MockGrackle] completeOnboarding")},usageCache:{"workspace:proj-alpha":{inputTokens:214500,outputTokens:44850,costMillicents:112e3,sessionCount:4},"workspace:proj-beta":{inputTokens:86700,outputTokens:23800,costMillicents:48e3,sessionCount:3},"task:task-001":{inputTokens:126800,outputTokens:20850,costMillicents:63e3,sessionCount:2},"task:task-006":{inputTokens:18900,outputTokens:4500,costMillicents:1e4,sessionCount:1},"task_tree:task-001":{inputTokens:126800,outputTokens:20850,costMillicents:63e3,sessionCount:2},"task_tree:task-006":{inputTokens:18900,outputTokens:4500,costMillicents:1e4,sessionCount:1}},loadUsage:async(V,ae)=>{console.log(`[MockGrackle] loadUsage(${V}, ${ae})`)},refresh:es}),[s,r,d,p,Q,g,b,S,w,T,B,A,I,$,pe,ie,Z,ce,ge,gt,Ii,ps,aa,Fa,ia,Yt,Mi,oa,Za,ms,wn,Re,Je,Jt,St,un,Wt,Oi,Bi,Li,Ka,Ya,Ja,hs,Wa,es]);return i.jsx(th.Provider,{value:Xa,children:t})}const $7=3e3;function U7(t){const[s,o]=y.useState(!1),r=y.useRef(t.onSessionEvent);r.current=t.onSessionEvent;const c=y.useRef(t.onDomainEvent);c.current=t.onDomainEvent;const d=y.useRef(t.onConnect);d.current=t.onConnect;const u=y.useRef(t.onDisconnect);return u.current=t.onDisconnect,y.useEffect(()=>{let p=!1,m;async function g(){var v,b;if(!p){try{const x=Ne.streamEvents({});o(!0),Promise.resolve((v=d.current)==null?void 0:v.call(d)).catch(()=>{});for await(const S of x){if(p)break;const k=S.event;if(k.case==="sessionEvent"){const w=k.value;r.current({sessionId:w.sessionId,type:w.type,timestamp:w.timestamp,content:w.content,raw:w.raw})}else if(k.case==="domainEvent"){const w=k.value;c.current({id:w.id,type:w.type,timestamp:w.timestamp,payloadJson:w.payloadJson})}}}catch(x){if(x instanceof wi&&x.code===fx.Unauthenticated){window.location.href=rN;return}}p||(o(!1),(b=u.current)==null||b.call(u),m=setTimeout(()=>{g().catch(()=>{})},$7))}}return g().catch(()=>{}),()=>{p=!0,clearTimeout(m),o(!1)}},[]),{connected:s}}const am=["core","orchestration"],G1=y.createContext({pluginNames:[...am],loading:!1,error:void 0});function P7({children:t}){const[s,o]=y.useState([...am]),[r,c]=y.useState(!0),[d,u]=y.useState(void 0);return y.useEffect(()=>{let p=!1;return fetch("/api/manifest").then(async m=>{if(!m.ok)throw new Error(`Manifest fetch returned ${m.status}`);return m.json()}).then(m=>{p||(o(m.plugins.map(g=>g.name)),c(!1))}).catch(m=>{p||(o([...am]),u(m instanceof Error?m:new Error(String(m))),c(!1))}),()=>{p=!0}},[]),i.jsx(G1.Provider,{value:{pluginNames:s,loading:r,error:d},children:t})}function ih(){return y.useContext(G1)}const H7=new Set(["dashboard","chat","environments","settings"]),V7=new Set(["tasks","findings"]),q7=new Set(["knowledge"]),F1={core:{navItems:Jc.filter(t=>H7.has(t.view)),domainHookKeys:["environments","sessions","workspaces","tokens","credentials","codespaces"]},orchestration:{navItems:Jc.filter(t=>V7.has(t.view)),domainHookKeys:["tasks","findings","personas","notifications"]},knowledge:{navItems:Jc.filter(t=>q7.has(t.view)),domainHookKeys:["knowledge"]}};function G7(t){return t.flatMap(s=>{var o;return((o=F1[s])==null?void 0:o.navItems)??[]})}function F7(t){return new Set(t.flatMap(s=>{var o;return((o=F1[s])==null?void 0:o.domainHookKeys)??[]}))}function Z7(t){return{id:t.id,displayName:t.displayName,adapterType:t.adapterType,adapterConfig:t.adapterConfig||"{}",status:t.status,bootstrapped:t.bootstrapped}}function Jb(t){return{id:t.id,environmentId:t.environmentId,runtime:t.runtime,status:t.status,prompt:t.prompt,startedAt:t.startedAt,endedAt:t.endedAt||void 0,error:t.error||void 0,endReason:t.endReason||void 0,personaId:t.personaId||void 0,inputTokens:t.inputTokens,outputTokens:t.outputTokens,costMillicents:t.costMillicents}}function K7(t){return{sessionId:t.sessionId,eventType:px(t.type),timestamp:t.timestamp,content:t.content,raw:t.raw||void 0}}function Y7(t){return{id:t.id,name:t.name,description:t.description,repoUrl:t.repoUrl,environmentId:t.environmentId,linkedEnvironmentIds:[...t.linkedEnvironmentIds],status:_T(t.status),workingDirectory:t.workingDirectory,useWorktrees:t.useWorktrees,defaultPersonaId:t.defaultPersonaId,tokenBudget:t.tokenBudget,costBudgetMillicents:t.costBudgetMillicents,createdAt:t.createdAt,updatedAt:t.updatedAt}}function Wb(t){return{id:t.id,workspaceId:t.workspaceId??void 0,title:t.title,description:t.description,status:kT(t.status),branch:t.branch,latestSessionId:t.latestSessionId,dependsOn:[...t.dependsOn],sortOrder:t.sortOrder,createdAt:t.createdAt,startedAt:t.startedAt||void 0,completedAt:t.completedAt||void 0,parentTaskId:t.parentTaskId,depth:t.depth,childTaskIds:[...t.childTaskIds],canDecompose:t.canDecompose,defaultPersonaId:t.defaultPersonaId,workpad:t.workpad,tokenBudget:t.tokenBudget,costBudgetMillicents:t.costBudgetMillicents}}function Sp(t){return{id:t.id,workspaceId:t.workspaceId,taskId:t.taskId,sessionId:t.sessionId,category:t.category,title:t.title,content:t.content,tags:[...t.tags],createdAt:t.createdAt}}function J7(t){return{name:t.name,tokenType:t.type,envVar:t.envVar,filePath:t.filePath,expiresAt:t.expiresAt}}function W7(t){return{claude:ST(t.claude),github:Cc(t.github),copilot:Cc(t.copilot),codex:Cc(t.codex),goose:Cc(t.goose)}}function X7(t){return{name:t.name,repository:t.repository,state:t.state,gitStatus:t.gitStatus}}function Tp(t){return{id:t.id,name:t.name,description:t.description,systemPrompt:t.systemPrompt,toolConfig:t.toolConfig?JSON.stringify({allowedTools:[...t.toolConfig.allowedTools],disallowedTools:[...t.toolConfig.disallowedTools]}):"{}",runtime:t.runtime,model:t.model,maxTurns:t.maxTurns,mcpServers:JSON.stringify(t.mcpServers.map(s=>({name:s.name,command:s.command,args:[...s.args],tools:[...s.tools]}))),createdAt:t.createdAt,updatedAt:t.updatedAt,type:t.type||"agent",script:t.script,allowedMcpTools:[...t.allowedMcpTools]}}function Q7(t){return{inputTokens:t.inputTokens,outputTokens:t.outputTokens,costMillicents:t.costMillicents,sessionCount:t.sessionCount}}function Hc(t,s=0){return{id:t.id,label:t.title||t.label||t.id,kind:t.kind,category:t.category||void 0,sourceType:t.sourceType||void 0,sourceId:t.sourceId||void 0,content:t.content||void 0,tags:t.tags.length>0?[...t.tags]:void 0,workspaceId:t.workspaceId||void 0,createdAt:t.createdAt||void 0,updatedAt:t.updatedAt||void 0,val:s}}function wp(t){return{source:t.fromId,target:t.toId,type:t.type}}function Ga(){const[t,s]=y.useState(!1),o=y.useRef(0),r=y.useCallback(c=>(o.current++,o.current===1&&s(!0),c.finally(()=>{o.current--,o.current===0&&s(!1)})),[]);return{loading:t,track:r}}const Xb=5e3;function Pr(t){return t instanceof wi?t.message:"Operation failed"}function ez(){const[t,s]=y.useState([]),{loading:o,track:r}=Ga(),[c,d]=y.useState({}),[u,p]=y.useState(""),m=y.useCallback(()=>{p("")},[]),g=y.useCallback(async()=>{try{const C=await r(Ne.listEnvironments({}));s(C.environments.map(Z7))}catch{}},[r]),v=y.useCallback(C=>{switch(C.type){case"environment.added":return!0;case"environment.removed":{const D=C.payload.environmentId;return D&&(s(B=>B.filter(E=>E.id!==D)),d(B=>{const E={...B};return delete E[D],E})),!0}case"environment.changed":return g().catch(()=>{}),!0;case"environment.provision_progress":{const D=C.payload;if(typeof D.environmentId!="string"||typeof D.stage!="string"||typeof D.message!="string"||typeof D.progress!="number")return U1("environment.provision_progress","invalid payload"),!0;if(d(B=>({...B,[D.environmentId]:{stage:D.stage,message:D.message,progress:D.progress}})),D.stage==="ready"){const B=D.environmentId;setTimeout(()=>{d(E=>{const A={...E};return delete A[B],A})},Xb)}return!0}default:return!1}},[g]),b=y.useCallback(C=>{var D;if(C.type==="environments"){const B=Array.isArray((D=C.payload)==null?void 0:D.environments)?C.payload.environments:[];return s(B),!0}return!1},[]),x=y.useCallback(async(C,D,B)=>{p("");try{await Ne.addEnvironment({displayName:C,adapterType:D,adapterConfig:JSON.stringify(B??{})})}catch(E){p(Pr(E))}},[]),S=y.useCallback(async(C,D)=>{p("");try{await Ne.updateEnvironment({id:C,displayName:D.displayName,adapterConfig:D.adapterConfig?JSON.stringify(D.adapterConfig):void 0})}catch(B){p(Pr(B))}},[]),k=y.useCallback(async(C,D)=>{p("");try{const B=Ne.provisionEnvironment({id:C,force:D??!1});for await(const E of B)d(A=>({...A,[C]:{stage:E.stage,message:E.message,progress:E.progress}})),E.stage==="ready"&&setTimeout(()=>{d(A=>{const P={...A};return delete P[C],P})},Xb)}catch(B){d(E=>{const A={...E};return delete A[C],A}),p(Pr(B))}},[]),w=y.useCallback(async C=>{p("");try{await Ne.stopEnvironment({id:C})}catch(D){p(Pr(D))}},[]),N=y.useCallback(async C=>{p("");try{await Ne.removeEnvironment({id:C})}catch(D){p(Pr(D))}},[]);return{environments:t,environmentsLoading:o,provisionStatus:c,operationError:u,clearOperationError:m,loadEnvironments:g,addEnvironment:x,updateEnvironment:S,provisionEnvironment:k,stopEnvironment:w,removeEnvironment:N,handleEvent:v,handleLegacyMessage:b,domainHook:{onConnect:()=>g(),onDisconnect:()=>{},handleEvent:v}}}const jp=new Set(["pending","running","idle"]),tz=new Set(["completed","failed","interrupted","hibernating","suspended"]),Qb=["pending","running","idle"];function nz(){const[t,s]=y.useState([]),{loading:o,track:r}=Ga(),[c,d]=y.useState([]),[u,p]=y.useState(0),[m,g]=y.useState(void 0),[v,b]=y.useState({}),x=y.useCallback(async()=>{try{const U=(await r(Ne.listSessions({}))).sessions.map(Jb);s(Q=>{const $=new Map(Q.map(W=>[W.id,W]));return U.map(W=>{const pe=$.get(W.id),H=pe==null?void 0:pe.status;return!H||H===W.status?W:tz.has(H)&&jp.has(W.status)?{...W,status:H,...pe.endReason!==void 0?{endReason:pe.endReason}:{}}:jp.has(H)&&jp.has(W.status)&&Qb.indexOf(H)>Qb.indexOf(W.status)?{...W,status:H}:W})})}catch{}},[r]),S=y.useCallback(I=>{if(I.type!=="session_event")return!1;if(!f7(I.payload))return U1("session_event","payload is not a valid SessionEvent"),!0;const U=I.payload;let Q=0;if(d($=>{const W=[...$,U];return W.length>So?(Q=W.length-So,W.slice(-So)):W}),Q>0&&p($=>$+Q),U.eventType==="usage")try{const $=JSON.parse(U.content),W=Number($.input_tokens)||0,pe=Number($.output_tokens)||0,H=Number($.cost_millicents)||0;(W>0||pe>0||H>0)&&s(ie=>ie.map(L=>L.id===U.sessionId?{...L,inputTokens:(L.inputTokens??0)+W,outputTokens:(L.outputTokens??0)+pe,costMillicents:(L.costMillicents??0)+H}:L))}catch{}if(U.eventType==="status"){const $=P1(U.content),W=H1(U.content);s(pe=>pe.some(ie=>ie.id===U.sessionId)?pe.map(ie=>ie.id===U.sessionId?{...ie,status:$,...W!==void 0?{endReason:W}:{}}:ie):[...pe,{id:U.sessionId,environmentId:"",runtime:"",status:$,prompt:"",startedAt:U.timestamp,...W!==void 0?{endReason:W}:{}}])}return!0},[]),k=y.useCallback(I=>{S({type:"session_event",payload:I})},[S]),w=y.useCallback(I=>{var U,Q,$,W,pe;switch(I.type){case"sessions":{const H=Array.isArray((U=I.payload)==null?void 0:U.sessions)?I.payload.sessions:[];return s(H),!0}case"spawned":{const H=(Q=I.payload)==null?void 0:Q.sessionId;return typeof H=="string"&&H&&g(H),x().catch(()=>{}),!0}case"session_events":{const H=Array.isArray(($=I.payload)==null?void 0:$.events)?I.payload.events:[];return H.length>0&&d(H),!0}case"task_sessions":{const H=(W=I.payload)==null?void 0:W.taskId;if(typeof H=="string"&&H){const ie=Array.isArray((pe=I.payload)==null?void 0:pe.sessions)?I.payload.sessions:[];b(L=>({...L,[H]:ie}))}return!0}default:return!1}},[x]),N=y.useCallback(async(I,U,Q,$)=>{try{const W=await Ne.spawnAgent({environmentId:I,prompt:U,personaId:Q||"",workingDirectory:$||""});g(W.id),await x()}catch{}},[x]),T=y.useCallback(async(I,U)=>{try{await Ne.sendInput({sessionId:I,text:U})}catch{}},[]),C=y.useCallback(async I=>{try{await Ne.killAgent({id:I,graceful:!1})}catch{}},[]),D=y.useCallback(async I=>{try{await Ne.killAgent({id:I,graceful:!0})}catch{}},[]),B=y.useCallback(async I=>{try{const Q=(await Ne.getSessionEvents({id:I})).events.map(K7);if(Q.length>0){let $=0;d(W=>{const pe=new Set;for(const L of W)L.sessionId===I&&pe.add(`${L.timestamp}|${L.eventType}`);const H=Q.filter(L=>!pe.has(`${L.timestamp}|${L.eventType}`)),ie=[...W,...H].sort((L,Z)=>L.sessionId!==Z.sessionId?0:L.timestamp.localeCompare(Z.timestamp));return ie.length>So?($=ie.length-So,ie.slice(-So)):ie}),$>0&&p(W=>W+$)}}catch{}},[]),E=y.useCallback(()=>{d([]),p(0)},[]),A=y.useCallback(async I=>{try{const Q=(await Ne.getTaskSessions({id:I})).sessions.map(Jb);b($=>({...$,[I]:Q}))}catch{}},[]);return{sessions:t,sessionsLoading:o,events:c,eventsDropped:u,lastSpawnedId:m,taskSessions:v,loadSessions:x,spawn:N,sendInput:T,kill:C,stopGraceful:D,loadSessionEvents:B,clearEvents:E,loadTaskSessions:A,handleMessage:S,handleSessionEvent:k,handleLegacyMessage:w,domainHook:{onConnect:()=>x(),onDisconnect:()=>{E()},handleEvent:()=>!1}}}function ex(t){return t instanceof wi?t.message:"Operation failed"}function sz(){const[t,s]=y.useState([]),{loading:o,track:r}=Ga(),[c,d]=y.useState(!1),[u,p]=y.useState(""),m=y.useCallback(async()=>{try{const C=await r(Ne.listWorkspaces({}));s(C.workspaces.map(Y7))}catch{}},[r]),g=y.useCallback(C=>{switch(C.type){case"workspace.created":return d(!1),m().catch(()=>{}),!0;case"workspace.archived":case"workspace.updated":return m().catch(()=>{}),!0;default:return!1}},[m]),v=y.useCallback(()=>{d(!1)},[]),b=y.useCallback(async(C,D,B,E,A,P,I,U,Q)=>{d(!0);try{await Ne.createWorkspace({name:C,description:D||"",repoUrl:B||"",environmentId:E||"",defaultPersonaId:A||void 0,useWorktrees:P??!0,workingDirectory:I||void 0}),d(!1),U==null||U()}catch($){d(!1);const W=$ instanceof wi?$.message:"Failed to create workspace";Q==null||Q(W)}},[]),x=y.useCallback(async C=>{try{await Ne.archiveWorkspace({id:C})}catch{}},[]),S=y.useCallback(async(C,D)=>{try{await Ne.updateWorkspace({id:C,...D})}catch{}},[]),k=y.useCallback(()=>{p("")},[]),w=y.useCallback(async(C,D)=>{try{p(""),await Ne.linkEnvironment({workspaceId:C,environmentId:D}),await m().catch(()=>{})}catch(B){p(ex(B))}},[m]),N=y.useCallback(async(C,D)=>{try{p(""),await Ne.unlinkEnvironment({workspaceId:C,environmentId:D}),await m().catch(()=>{})}catch(B){p(ex(B))}},[m]);return{workspaces:t,workspacesLoading:o,workspaceCreating:c,loadWorkspaces:m,createWorkspace:b,archiveWorkspace:x,updateWorkspace:S,linkEnvironment:w,unlinkEnvironment:N,linkOperationError:u,clearLinkOperationError:k,handleEvent:g,onDisconnect:v,domainHook:{onConnect:()=>m(),onDisconnect:v,handleEvent:g}}}function az(){const[t,s]=y.useState([]),{loading:o,track:r}=Ga(),[c,d]=y.useState(void 0),u=y.useRef({}),p=y.useCallback(async E=>{try{const P=(await Ne.listTasks({workspaceId:E})).tasks.map(Wb);s(I=>[...I.filter(U=>U.workspaceId!==E),...P])}catch{}},[]),m=y.useCallback(async()=>{try{const A=(await r(Ne.listTasks({}))).tasks.map(Wb);s(P=>{const I=new Set(A.map(U=>U.id));return[...P.filter(U=>!I.has(U.id)),...A]})}catch{}},[r]),g=y.useCallback((E,A)=>{const P=I=>{clearTimeout(u.current[I]),u.current[I]=setTimeout(()=>{delete u.current[I],p(I).catch(()=>{})},200)};E?P(E):A&&s(I=>{const U=I.find(Q=>Q.id===A);return U!=null&&U.workspaceId?P(U.workspaceId):m().catch(()=>{}),I})},[p,m]),v=y.useCallback(E=>{const A=E.payload;switch(E.type){case"task.created":{const P=typeof A.workspaceId=="string"?A.workspaceId:"";return P&&p(P).catch(()=>{}),!0}case"task.started":{const P=typeof A.taskId=="string"?A.taskId:"",I=typeof A.sessionId=="string"?A.sessionId:"",U=typeof A.workspaceId=="string"?A.workspaceId:"";return d(Q=>P&&Q===P?void 0:Q),I&&P&&s(Q=>Q.map($=>$.id===P?{...$,latestSessionId:I}:$)),g(U,P),!0}case"task.completed":case"task.deleted":case"task.reparented":case"task.updated":{const P=typeof A.workspaceId=="string"?A.workspaceId:"",I=typeof A.taskId=="string"?A.taskId:"";return d(U=>I&&U===I?void 0:U),g(P,I),!0}default:return!1}},[p,g]),b=y.useCallback(()=>{d(void 0)},[]),x=y.useCallback(E=>{var A,P;if(E.type==="tasks"){const I=Array.isArray((A=E.payload)==null?void 0:A.tasks)?E.payload.tasks:[],U=typeof((P=E.payload)==null?void 0:P.workspaceId)=="string"&&E.payload.workspaceId?E.payload.workspaceId:"";return s(U?Q=>[...Q.filter($=>$.workspaceId!==U),...I]:Q=>{const $=new Set(I.map(W=>W.id));return[...Q.filter(W=>!$.has(W.id)),...I]}),!0}return!1},[]),S=y.useCallback(async(E,A,P,I,U,Q,$,W,pe)=>{try{await Ne.createTask({workspaceId:E,title:A,description:P||"",dependsOn:I||[],parentTaskId:U||"",defaultPersonaId:Q||void 0,canDecompose:$??void 0}),W==null||W()}catch(H){const ie=H instanceof wi?H.message:"Failed to create task";pe==null||pe(ie)}},[]),k=y.useCallback(async(E,A,P,I)=>{d(E);try{await Ne.startTask({taskId:E,personaId:A||"",environmentId:P||"",notes:I||""})}catch(U){if(U instanceof wi&&U.code===fx.ResourceExhausted)return;d(void 0)}},[]),w=y.useCallback(async E=>{try{await Ne.stopTask({id:E})}catch{}},[]),N=y.useCallback(async E=>{try{await Ne.completeTask({id:E})}catch{}},[]),T=y.useCallback(async E=>{try{await Ne.resumeTask({id:E})}catch{}},[]),C=y.useCallback(async(E,A,P,I,U)=>{try{await Ne.updateTask({id:E,title:A,description:P,dependsOn:I,...U!==void 0?{defaultPersonaId:U}:{}})}catch{}},[]),D=y.useCallback(async E=>{try{await Ne.deleteTask({id:E})}catch{}},[]);return{tasks:t,tasksLoading:o,taskStartingId:c,loadTasks:p,loadAllTasks:m,createTask:S,startTask:k,stopTask:w,completeTask:N,resumeTask:T,updateTask:C,deleteTask:D,handleEvent:v,onDisconnect:b,handleLegacyMessage:x,domainHook:{onConnect:()=>m(),onDisconnect:b,handleEvent:v}}}function iz(){const[t,s]=y.useState([]),[o,r]=y.useState(void 0),[c,d]=y.useState(!1),{loading:u,track:p}=Ga(),m=y.useCallback(async k=>{try{const w=await p(Ne.queryFindings({workspaceId:k}));s(w.findings.map(Sp))}catch{}},[p]),g=y.useCallback(async()=>{try{const k=await p(Ne.queryFindings({workspaceId:""}));s(k.findings.map(Sp))}catch{}},[p]),v=y.useCallback(async k=>{r(void 0),d(!0);try{const w=await Ne.getFinding({id:k});r(Sp(w))}catch{r(void 0)}finally{d(!1)}},[]),b=y.useCallback(k=>{if(k.type==="finding.posted"){const w=typeof k.payload.workspaceId=="string"?k.payload.workspaceId:"";return w&&m(w).catch(()=>{}),!0}return!1},[m]),x=y.useCallback(async(k,w,N,T,C)=>{try{await Ne.postFinding({workspaceId:k,title:w,content:N,category:T??"general",tags:C??[]})}catch{}},[]);return{findings:t,selectedFinding:o,findingLoading:c,findingsLoading:u,loadFindings:m,loadAllFindings:g,loadFinding:v,postFinding:x,handleEvent:b,domainHook:{onConnect:()=>g(),onDisconnect:()=>{},handleEvent:b}}}function oz(){const[t,s]=y.useState([]),{loading:o,track:r}=Ga(),c=y.useCallback(async()=>{try{const g=await r(Ne.listTokens({}));s(g.tokens.map(J7))}catch{}},[r]),d=y.useCallback(g=>g.type==="token.changed"?(c().catch(()=>{}),!0):!1,[c]),u=y.useCallback(async(g,v,b,x,S)=>{try{await Ne.setToken({name:g,value:v,type:b,envVar:x,filePath:S})}catch{}},[]),p=y.useCallback(async g=>{try{await Ne.deleteToken({name:g})}catch{}},[]);return{tokens:t,tokensLoading:o,loadTokens:c,setToken:u,deleteToken:p,handleEvent:d,domainHook:{onConnect:()=>c(),onDisconnect:()=>{},handleEvent:d}}}function rz(){const[t,s]=y.useState({claude:"off",github:"off",copilot:"off",codex:"off",goose:"off"}),{loading:o,track:r}=Ga(),c=y.useCallback(async()=>{try{const m=await r(Ne.getCredentialProviders({}));s(W7(m))}catch{}},[r]),d=y.useCallback(m=>m.type==="credential.providers_changed"?(m7(m.payload)&&s(m.payload),!0):!1,[]),u=y.useCallback(async m=>{const g=[{provider:"claude",value:m.claude},{provider:"github",value:m.github},{provider:"copilot",value:m.copilot},{provider:"codex",value:m.codex},{provider:"goose",value:m.goose}];await Promise.allSettled(g.map(({provider:v,value:b})=>Ne.setCredentialProvider({provider:v,value:b})))},[]);return{credentialProviders:t,credentialsLoading:o,loadCredentials:c,updateCredentialProviders:u,handleEvent:d,domainHook:{onConnect:()=>c(),onDisconnect:()=>{},handleEvent:d}}}function lz(){const[t,s]=y.useState([]),[o,r]=y.useState(""),[c,d]=y.useState(""),[u,p]=y.useState(!1),m=y.useCallback(async()=>{try{const b=await Ne.listCodespaces({});s(b.codespaces.map(X7)),d(b.error)}catch{}},[]),g=y.useCallback(async(b,x)=>{p(!0),r("");try{await Ne.createCodespace({repo:b,machine:x??""}),p(!1),await m()}catch(S){p(!1);const k=S instanceof wi?S.message:"Failed to create codespace";r(k)}},[m]);return{codespaces:t,codespaceError:o,codespaceListError:c,codespaceCreating:u,listCodespaces:m,createCodespace:g,domainHook:{onConnect:()=>m(),onDisconnect:()=>{},handleEvent:()=>!1}}}function cz(){const[t,s]=y.useState([]),{loading:o,track:r}=Ga(),c=y.useCallback(async()=>{try{const v=await r(Ne.listPersonas({}));s(v.personas.map(Tp))}catch{}},[r]),d=y.useCallback(v=>{switch(v.type){case"persona.created":case"persona.updated":case"persona.deleted":return c().catch(()=>{}),!0;default:return!1}},[c]),u=y.useCallback(async(v,b,x,S,k,w,N,T,C)=>{const D=await Ne.createPersona({name:v,description:b,systemPrompt:x,runtime:S||"",model:k||"",maxTurns:w||0,type:N||"agent",script:T||"",allowedMcpTools:C||[]}),B=Tp(D);return s(E=>[...E.filter(A=>A.id!==B.id),B]),B},[]),p=y.useCallback(async(v,b,x,S,k,w,N,T,C,D)=>{const B={id:v};b!==void 0&&(B.name=b),x!==void 0&&(B.description=x),S!==void 0&&(B.systemPrompt=S),k!==void 0&&(B.runtime=k),w!==void 0&&(B.model=w),N!==void 0&&(B.maxTurns=N),T!==void 0&&(B.type=T),C!==void 0&&(B.script=C),D!==void 0&&(B.allowedMcpTools={tools:D});const E=await Ne.updatePersona(B),A=Tp(E);return s(P=>P.map(I=>I.id===A.id?A:I)),A},[]),m=y.useCallback(async v=>{await Ne.deletePersona({id:v}),s(b=>b.filter(x=>x.id!==v))},[]);return{personas:t,personasLoading:o,loadPersonas:c,createPersona:u,updatePersona:p,deletePersona:m,handleEvent:d,domainHook:{onConnect:()=>c(),onDisconnect:()=>{},handleEvent:d}}}function dz(t){if(t)try{return JSON.parse(t)}catch{return}}function uz(){const[t,s]=y.useState(new Map),[o,r]=y.useState([]),[c,d]=y.useState(void 0),[u,p]=y.useState(void 0),[m,g]=y.useState(!1),[v,b]=y.useState(""),x=y.useRef(""),S=y.useCallback(async E=>{const A=E??"";x.current=A,b(""),g(!0);try{const P=await Ne.listRecentKnowledgeNodes({limit:30,workspaceId:A}),I=new Map,U=[];for(const Q of P.nodes)I.set(Q.id,Hc(Q));for(const Q of P.edges)U.push(wp(Q));for(const Q of U){const $=I.get(Q.source);$&&($.val+=1);const W=I.get(Q.target);W&&(W.val+=1)}s(I),r(U)}catch{}finally{g(!1)}},[]),k=y.useCallback(async E=>{if(E.trim()){b(E),p(void 0),d(void 0),g(!0);try{const A=await Ne.searchKnowledge({query:E,limit:20,workspaceId:x.current}),P=new Map,I=[];for(const U of A.results){U.node&&P.set(U.node.id,Hc(U.node,U.edges.length));for(const Q of U.edges)I.push(wp(Q))}s(P),r(I)}catch{}finally{g(!1)}}},[]),w=y.useCallback(()=>{S(x.current).catch(()=>{})},[S]),N=y.useCallback(async E=>{p(E);try{const A=await Ne.getKnowledgeNode({id:E});if(!A.node){d(void 0);return}d({node:Hc(A.node,A.edges.length),edges:A.edges.map(P=>({fromId:P.fromId,toId:P.toId,type:P.type,metadata:dz(P.metadataJson)}))})}catch{d(void 0)}},[]),T=y.useCallback(()=>{p(void 0),d(void 0)},[]),C=y.useCallback(async E=>{try{const A=await Ne.expandKnowledgeNode({id:E,depth:1});s(P=>{const I=new Map(P);for(const U of A.nodes)I.has(U.id)||I.set(U.id,Hc(U));return I}),r(P=>{const I=new Set(P.map(Q=>`${Q.source}:${Q.target}:${Q.type}`)),U=[];for(const Q of A.edges){const $=wp(Q),W=`${$.source}:${$.target}:${$.type}`;I.has(W)||U.push($)}return[...P,...U]})}catch{}},[]),D=y.useCallback(E=>!1,[]),B={onConnect:async()=>{},onDisconnect:()=>{},handleEvent:D};return{graphData:{nodes:[...t.values()],links:o},selectedNode:c,selectedId:u,loading:m,searchQuery:v,search:k,clearSearch:w,selectNode:N,clearSelection:T,expandNode:C,loadRecent:S,handleEvent:D,domainHook:B}}function fz(){const t=y.useRef("default");y.useEffect(()=>{typeof Notification>"u"||(t.current=Notification.permission)},[]);function s(r){if(r.type!=="notification.escalated")return!1;if(typeof Notification>"u")return!0;if(t.current==="default")return Notification.requestPermission().then(u=>{t.current=u}).catch(()=>{}),!0;if(t.current!=="granted")return!0;const c=r.payload,d=new Notification(c.title||"Agent needs input",{body:c.message||"An agent is waiting for your input.",tag:c.escalationId,icon:"/icon-192x192.png"});return d.onclick=()=>{window.focus(),c.taskUrl&&(window.location.href=c.taskUrl),d.close()},!0}return{handleEvent:s,domainHook:{onConnect:async()=>{},onDisconnect:()=>{},handleEvent:s}}}function pz(){const[t,s]=y.useState(""),[o,r]=y.useState(void 0),[c,d]=y.useState({}),{pluginNames:u}=ih(),p=F7(u),m=ez(),g=nz(),v=sz(),b=az(),x=iz(),S=oz(),k=rz(),w=lz(),N=cz(),T=uz(),C=fz(),D=[...p.has("environments")?[m.domainHook]:[],...p.has("sessions")?[g.domainHook]:[],...p.has("workspaces")?[v.domainHook]:[],...p.has("tasks")?[b.domainHook]:[],...p.has("findings")?[x.domainHook]:[],...p.has("tokens")?[S.domainHook]:[],...p.has("credentials")?[k.domainHook]:[],...p.has("codespaces")?[w.domainHook]:[],...p.has("personas")?[N.domainHook]:[],...p.has("knowledge")?[T.domainHook]:[],...p.has("notifications")?[C.domainHook]:[]],{connected:B}=U7({onSessionEvent:H=>{g.handleSessionEvent({sessionId:H.sessionId,eventType:px(H.type),timestamp:H.timestamp,content:H.content,raw:H.raw||void 0})},onDomainEvent:H=>{try{const ie=JSON.parse(H.payloadJson);Q({id:H.id,type:H.type,timestamp:H.timestamp,payload:ie})}catch{console.warn("[grackle] Failed to parse domain event payloadJson:",H.payloadJson)}},onConnect:$,onDisconnect:W}),E="default_persona_id",A="onboarding_completed",P=y.useCallback(async H=>{const ie=await Ne.setSetting({key:E,value:H});s(ie.value)},[]),I=y.useCallback(async()=>{r(!0);try{await Ne.setSetting({key:A,value:"true"})}catch{}},[]),U=y.useCallback(async(H,ie)=>{try{const L=await Ne.getUsage({scope:H,id:ie}),Z=`${H}:${ie}`;d(J=>({...J,[Z]:Q7(L)}))}catch{}},[]);function Q(H){const ie=H.payload.key,L=H.payload.value;if(H.type==="setting.changed"){ie===E&&s(L??""),ie===A&&r(L==="true");return}for(const Z of D)if(Z.handleEvent(H))break;(H.type==="environment.removed"||H.type==="environment.changed"||H.type==="task.started")&&g.loadSessions().catch(()=>{})}async function $(){for(const H of D)H.onConnect().catch(()=>{});try{const H=await Ne.getSetting({key:E});s(H.value)}catch{}try{const H=await Ne.getSetting({key:A});r(H.value==="true")}catch{}}function W(){D.forEach(H=>H.onDisconnect())}const pe=y.useCallback(()=>{m.loadEnvironments().catch(()=>{}),g.loadSessions().catch(()=>{}),v.loadWorkspaces().catch(()=>{}),S.loadTokens().catch(()=>{})},[m.loadEnvironments,g.loadSessions,v.loadWorkspaces,S.loadTokens]);return{connected:B,environments:{environments:m.environments,environmentsLoading:m.environmentsLoading,provisionStatus:m.provisionStatus,operationError:m.operationError,clearOperationError:m.clearOperationError,loadEnvironments:m.loadEnvironments,addEnvironment:m.addEnvironment,updateEnvironment:m.updateEnvironment,provisionEnvironment:m.provisionEnvironment,stopEnvironment:m.stopEnvironment,removeEnvironment:m.removeEnvironment,domainHook:m.domainHook},sessions:{sessions:g.sessions,sessionsLoading:g.sessionsLoading,events:g.events,eventsDropped:g.eventsDropped,lastSpawnedId:g.lastSpawnedId,taskSessions:g.taskSessions,spawn:g.spawn,sendInput:g.sendInput,kill:g.kill,stopGraceful:g.stopGraceful,loadSessionEvents:g.loadSessionEvents,clearEvents:g.clearEvents,loadTaskSessions:g.loadTaskSessions,domainHook:g.domainHook},workspaces:{workspaces:v.workspaces,workspacesLoading:v.workspacesLoading,workspaceCreating:v.workspaceCreating,loadWorkspaces:v.loadWorkspaces,createWorkspace:v.createWorkspace,archiveWorkspace:v.archiveWorkspace,updateWorkspace:v.updateWorkspace,linkEnvironment:v.linkEnvironment,unlinkEnvironment:v.unlinkEnvironment,linkOperationError:v.linkOperationError,clearLinkOperationError:v.clearLinkOperationError,domainHook:v.domainHook},tasks:{tasks:b.tasks,tasksLoading:b.tasksLoading,taskStartingId:b.taskStartingId,loadTasks:b.loadTasks,loadAllTasks:b.loadAllTasks,createTask:b.createTask,startTask:b.startTask,stopTask:b.stopTask,completeTask:b.completeTask,resumeTask:b.resumeTask,updateTask:b.updateTask,deleteTask:b.deleteTask,domainHook:b.domainHook},findings:{findings:x.findings,selectedFinding:x.selectedFinding,findingLoading:x.findingLoading,findingsLoading:x.findingsLoading,loadFindings:x.loadFindings,loadAllFindings:x.loadAllFindings,loadFinding:x.loadFinding,postFinding:x.postFinding,domainHook:x.domainHook},tokens:{tokens:S.tokens,tokensLoading:S.tokensLoading,loadTokens:S.loadTokens,setToken:S.setToken,deleteToken:S.deleteToken,domainHook:S.domainHook},credentials:{credentialProviders:k.credentialProviders,credentialsLoading:k.credentialsLoading,updateCredentialProviders:k.updateCredentialProviders,domainHook:k.domainHook},codespaces:{codespaces:w.codespaces,codespaceError:w.codespaceError,codespaceListError:w.codespaceListError,codespaceCreating:w.codespaceCreating,listCodespaces:w.listCodespaces,createCodespace:w.createCodespace,domainHook:w.domainHook},personas:{personas:N.personas,personasLoading:N.personasLoading,createPersona:N.createPersona,updatePersona:N.updatePersona,deletePersona:N.deletePersona,domainHook:N.domainHook},knowledge:T,appDefaultPersonaId:t,setAppDefaultPersonaId:P,onboardingCompleted:o,completeOnboarding:I,usageCache:c,loadUsage:U,refresh:pe}}function mz({children:t}){const s=pz();return i.jsx(th.Provider,{value:s,children:t})}function hz(t,s){const o=y.useRef(null);y.useEffect(()=>{const r=o.current;if(o.current=t,r===null)return;const c=new Map;for(const u of r)c.set(u.id,u);const d=new Set;for(const u of t){d.add(u.id);const p=c.get(u.id);if(p&&p.status!==u.status&&u.status!=="sleeping"){if(u.status==="connecting"){s("Provisioning environment…","info");continue}u.status==="connected"?s("Environment connected","success"):u.status==="error"?s("Environment provision failed","error"):u.status==="disconnected"&&(p.status==="connected"?s("Environment disconnected","warning"):s("Environment stopped","info"))}}for(const u of r)d.has(u.id)||s("Environment removed","info")},[t,s])}function gz(t,s,o){const r=y.useRef(t);y.useEffect(()=>{t&&t!==r.current&&(o(t,"error"),s()),r.current=t},[t,s,o])}const vz={working:{message:"Task is now running",variant:"info"},paused:{message:"Task paused",variant:"warning"},complete:{message:"Task complete",variant:"success"},failed:{message:"Task failed to complete",variant:"error"}};function yz(t){return vz[t]}function bz(t,s){if(t===void 0)return[];const o=[],r=new Map;for(const d of t)r.set(d.id,d);const c=new Set;for(const d of s){c.add(d.id);const u=r.get(d.id);if(!u||u.status===d.status)continue;const p=yz(d.status);p&&o.push(p)}for(const d of t)c.has(d.id)||o.push({message:"Task deleted",variant:"info"});return o}function xz(t,s){const o=y.useRef(void 0);y.useEffect(()=>{const r=o.current;o.current=t;const c=bz(r,t);for(const d of c)s(d.message,d.variant)},[t,s])}const _z="_dashboard_16pzm_1",kz="_kpiStrip_16pzm_11",Sz="_kpiCard_16pzm_23",Tz="_kpiValue_16pzm_68",wz="_kpiLabel_16pzm_76",jz="_bodyGrid_16pzm_84",Nz="_section_16pzm_96",Cz="_sectionHeader_16pzm_109",Ez="_sectionIcon_16pzm_118",Az="_sectionTitle_16pzm_123",Dz="_sectionCount_16pzm_131",Rz="_sectionBody_16pzm_138",Mz="_emptyHint_16pzm_143",Iz="_sessionRow_16pzm_150",Oz="_sessionPrompt_16pzm_177",Bz="_sessionEnv_16pzm_186",Lz="_sessionRuntime_16pzm_192",zz="_sessionStatus_16pzm_198",$z="_statusDot_16pzm_207",Uz="_attentionRow_16pzm_233",Pz="_attentionTitle_16pzm_259",Hz="_attentionMeta_16pzm_267",Vz="_reasonBadge_16pzm_274",qz="_bottomGrid_16pzm_301",Gz="_envRow_16pzm_312",Fz="_envName_16pzm_323",Zz="_envStatusBadge_16pzm_333",Kz="_workspaceRow_16pzm_369",Yz="_workspaceTop_16pzm_395",Jz="_workspaceName_16pzm_401",Wz="_workspaceCounts_16pzm_407",Xz="_progressBar_16pzm_415",Qz="_progressFill_16pzm_422",ue={dashboard:_z,kpiStrip:kz,kpiCard:Sz,kpiValue:Tz,kpiLabel:wz,bodyGrid:jz,section:Nz,sectionHeader:Cz,sectionIcon:Ez,sectionTitle:Az,sectionCount:Dz,sectionBody:Rz,emptyHint:Mz,sessionRow:Iz,sessionPrompt:Oz,sessionEnv:Bz,sessionRuntime:Lz,sessionStatus:zz,statusDot:$z,attentionRow:Uz,attentionTitle:Pz,attentionMeta:Hz,reasonBadge:Vz,bottomGrid:qz,envRow:Gz,envName:Fz,envStatusBadge:Zz,workspaceRow:Kz,workspaceTop:Yz,workspaceName:Jz,workspaceCounts:Wz,progressBar:Xz,progressFill:Qz};function e$(){return i.jsxs("div",{className:ue.dashboard,"aria-hidden":"true",children:[i.jsx("div",{className:ue.kpiStrip,children:Array.from({length:4},(t,s)=>i.jsxs("div",{className:ue.kpiCard,children:[i.jsx(we,{width:"3rem",height:"2rem"}),i.jsx(we,{width:"80%",height:"0.75rem"})]},s))}),i.jsxs("div",{className:ue.bodyGrid,children:[i.jsxs("div",{className:ue.section,children:[i.jsxs("div",{className:ue.sectionHeader,children:[i.jsx(we,{width:"1rem",height:"1rem",variant:"circular"}),i.jsx(we,{width:"8rem",height:"0.75rem"}),i.jsx("span",{className:ue.sectionCount,children:i.jsx(we,{width:"1rem",height:"0.75rem"})})]}),i.jsx("div",{className:ue.sectionBody,children:Array.from({length:3},(t,s)=>i.jsxs("div",{className:ue.sessionRow,style:{cursor:"default"},children:[i.jsx(we,{width:"60%",height:"0.875rem"}),i.jsx(we,{width:"4rem",height:"0.75rem"}),i.jsx(we,{width:"3rem",height:"0.75rem"}),i.jsx(we,{width:"3rem",height:"0.75rem"})]},s))})]}),i.jsxs("div",{className:ue.section,children:[i.jsxs("div",{className:ue.sectionHeader,children:[i.jsx(we,{width:"1rem",height:"1rem",variant:"circular"}),i.jsx(we,{width:"8rem",height:"0.75rem"}),i.jsx("span",{className:ue.sectionCount,children:i.jsx(we,{width:"1rem",height:"0.75rem"})})]}),i.jsx("div",{className:ue.sectionBody,children:Array.from({length:2},(t,s)=>i.jsxs("div",{className:ue.attentionRow,style:{cursor:"default"},children:[i.jsxs("div",{className:ue.attentionTitle,children:[i.jsx(we,{width:"3rem",height:"0.875rem",borderRadius:"var(--radius-sm)"}),i.jsx(we,{width:"70%",height:"0.875rem"})]}),i.jsx("div",{className:ue.attentionMeta,children:i.jsx(we,{width:"5rem",height:"0.625rem"})})]},s))})]})]}),i.jsxs("div",{className:ue.bottomGrid,children:[i.jsxs("div",{className:ue.section,children:[i.jsxs("div",{className:ue.sectionHeader,children:[i.jsx(we,{width:"1rem",height:"1rem",variant:"circular"}),i.jsx(we,{width:"9rem",height:"0.75rem"}),i.jsx("span",{className:ue.sectionCount,children:i.jsx(we,{width:"1rem",height:"0.75rem"})})]}),i.jsx("div",{className:ue.sectionBody,children:Array.from({length:2},(t,s)=>i.jsxs("div",{className:ue.envRow,children:[i.jsx(we,{width:"60%",height:"0.875rem"}),i.jsx(we,{width:"4rem",height:"0.875rem",borderRadius:"var(--radius-sm)"})]},s))})]}),i.jsxs("div",{className:ue.section,children:[i.jsxs("div",{className:ue.sectionHeader,children:[i.jsx(we,{width:"1rem",height:"1rem",variant:"circular"}),i.jsx(we,{width:"6rem",height:"0.75rem"}),i.jsx("span",{className:ue.sectionCount,children:i.jsx(we,{width:"1rem",height:"0.75rem"})})]}),i.jsx("div",{className:ue.sectionBody,children:Array.from({length:2},(t,s)=>i.jsxs("div",{className:ue.workspaceRow,style:{cursor:"default"},children:[i.jsxs("div",{className:ue.workspaceTop,children:[i.jsx(we,{width:"50%",height:"0.875rem"}),i.jsx(we,{width:"2rem",height:"0.75rem"})]}),i.jsx("div",{className:ue.progressBar,children:i.jsx("div",{className:ue.progressFill,style:{width:"0%"}})})]},s))})]})]})]})}const t$={hidden:{opacity:0,y:12},visible:t=>({opacity:1,y:0,transition:{delay:t*.06,duration:.3,ease:"easeOut"}})},Vc={hidden:{opacity:0,y:16},visible:t=>({opacity:1,y:0,transition:{delay:.15+t*.08,duration:.35,ease:"easeOut"}})};function n$(t,s,o,r){const c=[`${t} of ${s} tasks completed`];return o>0&&c.push(`${o} in progress`),r>0&&c.push(`${r} failed`),c.join(", ")}function qc({value:t,label:s,accent:o,index:r,testId:c}){return i.jsxs(Rt.div,{className:ue.kpiCard,"data-accent":o,"data-testid":c,variants:t$,initial:"hidden",animate:"visible",custom:r,children:[i.jsx("span",{className:ue.kpiValue,children:t}),i.jsx("span",{className:ue.kpiLabel,children:s})]})}function s$(){const{workspaces:{workspaces:t,workspacesLoading:s},tasks:{tasks:o,tasksLoading:r,loadTasks:c},sessions:{sessions:d,sessionsLoading:u},environments:{environments:p,environmentsLoading:m}}=mt(),g=kt(),v=y.useRef(new Set);y.useEffect(()=>{for(const N of t)v.current.has(N.id)||(v.current.add(N.id),c(N.id).catch(()=>{}))},[t,c]);const b=y.useMemo(()=>w7(d,o,p),[d,o,p]),x=y.useMemo(()=>N7(d,p),[d,p]),S=y.useMemo(()=>j7(o,t),[o,t]),k=y.useMemo(()=>C7(t,o),[t,o,p]);return d.length===0&&o.length===0&&p.length===0&&t.length===0&&(u||r||m||s)?i.jsx(e$,{}):i.jsxs("div",{className:ue.dashboard,"data-testid":"dashboard",children:[i.jsxs("div",{className:ue.kpiStrip,"data-testid":"dashboard-kpi-strip",children:[i.jsx(qc,{value:b.activeSessions,label:"Active Sessions",accent:"green",index:0,testId:"kpi-active-sessions"}),i.jsx(qc,{value:b.blockedTasks,label:"Blocked Tasks",accent:"yellow",index:1,testId:"kpi-blocked-tasks"}),i.jsx(qc,{value:b.attentionTasks,label:"Needs Attention",accent:"red",index:2,testId:"kpi-attention-tasks"}),i.jsx(qc,{value:b.unhealthyEnvironments,label:"Unhealthy Envs",accent:"blue",index:3,testId:"kpi-unhealthy-envs"})]}),i.jsxs("div",{className:ue.bodyGrid,children:[i.jsxs(Rt.div,{className:ue.section,variants:Vc,initial:"hidden",animate:"visible",custom:0,"data-testid":"dashboard-active-sessions",children:[i.jsxs("div",{className:ue.sectionHeader,children:[i.jsx("span",{className:ue.sectionIcon,"aria-hidden":"true",children:"●"}),i.jsx("span",{className:ue.sectionTitle,children:"Active Sessions"}),i.jsx("span",{className:ue.sectionCount,children:x.length})]}),i.jsx("div",{className:ue.sectionBody,children:x.length===0?i.jsx("div",{className:ue.emptyHint,children:"No active sessions"}):x.map(({session:N,environmentName:T})=>i.jsxs("button",{type:"button",className:ue.sessionRow,onClick:()=>g(gm(N.id)),"data-testid":"session-row",children:[i.jsx("span",{className:ue.sessionPrompt,title:N.prompt,children:N.prompt||"—"}),i.jsx("span",{className:ue.sessionEnv,children:T}),i.jsx("span",{className:ue.sessionRuntime,children:N.runtime}),i.jsxs("span",{className:ue.sessionStatus,children:[i.jsx("span",{className:ue.statusDot,"data-status":N.status}),N.status]})]},N.id))})]}),i.jsxs(Rt.div,{className:ue.section,variants:Vc,initial:"hidden",animate:"visible",custom:1,"data-testid":"dashboard-needs-attention",children:[i.jsxs("div",{className:ue.sectionHeader,children:[i.jsx("span",{className:ue.sectionIcon,"aria-hidden":"true",children:"⚑"}),i.jsx("span",{className:ue.sectionTitle,children:"Needs Attention"}),i.jsx("span",{className:ue.sectionCount,children:S.length})]}),i.jsx("div",{className:ue.sectionBody,children:S.length===0?i.jsx("div",{className:ue.emptyHint,children:"All clear"}):S.map(({task:N,reason:T,workspaceName:C})=>i.jsxs("button",{type:"button",className:ue.attentionRow,onClick:()=>g(On(N.id)),"data-testid":"attention-row",children:[i.jsxs("div",{className:ue.attentionTitle,children:[i.jsx("span",{className:ue.reasonBadge,"data-reason":T,children:T}),N.title]}),i.jsx("div",{className:ue.attentionMeta,children:i.jsx("span",{children:C})})]},N.id))})]})]}),i.jsxs("div",{className:ue.bottomGrid,children:[i.jsxs(Rt.div,{className:ue.section,variants:Vc,initial:"hidden",animate:"visible",custom:2,"data-testid":"dashboard-env-health",children:[i.jsxs("div",{className:ue.sectionHeader,children:[i.jsx("span",{className:ue.sectionIcon,"aria-hidden":"true",children:"◈"}),i.jsx("span",{className:ue.sectionTitle,children:"Environment Health"}),i.jsx("span",{className:ue.sectionCount,children:p.length})]}),i.jsx("div",{className:ue.sectionBody,children:p.length===0?i.jsx("div",{className:ue.emptyHint,children:"No environments configured"}):p.map(N=>i.jsxs("div",{className:ue.envRow,"data-testid":"dashboard-env-row",children:[i.jsx("span",{className:ue.envName,children:N.displayName}),i.jsx("span",{className:ue.envStatusBadge,"data-status":N.status,children:N.status})]},N.id))})]}),i.jsxs(Rt.div,{className:ue.section,variants:Vc,initial:"hidden",animate:"visible",custom:3,"data-testid":"dashboard-workspace-snapshot",children:[i.jsxs("div",{className:ue.sectionHeader,children:[i.jsx("span",{className:ue.sectionIcon,"aria-hidden":"true",children:"▦"}),i.jsx("span",{className:ue.sectionTitle,children:"Workspaces"}),i.jsx("span",{className:ue.sectionCount,children:t.length})]}),i.jsx("div",{className:ue.sectionBody,children:k.length===0?i.jsx("div",{className:ue.emptyHint,children:"No workspaces yet"}):k.map(({workspace:N,totalTasks:T,completedTasks:C,workingTasks:D,failedTasks:B})=>{const E=T>0?Math.round(C/T*100):0;return i.jsxs("button",{type:"button",className:ue.workspaceRow,onClick:()=>g($a(N.id,N.environmentId)),"data-testid":"workspace-row",children:[i.jsxs("div",{className:ue.workspaceTop,children:[i.jsx("span",{className:ue.workspaceName,children:N.name}),i.jsxs("span",{className:ue.workspaceCounts,"aria-label":n$(C,T,D,B),children:[C,"/",T,D>0&&i.jsxs("span",{style:{color:"var(--accent-green)"},"aria-hidden":"true",children:["▸",D]}),B>0&&i.jsxs("span",{style:{color:"var(--accent-red)"},"aria-hidden":"true",children:["✗",B]})]})]}),T>0&&i.jsx("div",{className:ue.progressBar,children:i.jsx("div",{className:ue.progressFill,style:{width:`${E}%`}})})]},N.id)})})]})]})]})}const a$="_panelContainer_1udy7_1",i$="_emptyState_1udy7_8",o$="_workspaceSummary_1udy7_17",r$="_workspaceSummaryTitle_1udy7_28",l$="_workspaceSummarySubtitle_1udy7_32",c$="_header_1udy7_36",d$="_headerInfo_1udy7_71",u$="_headerTitle_1udy7_106",f$="_taskStatusBadge_1udy7_128",p$="_taskBranch_1udy7_137",m$="_taskBlockedBadge_1udy7_143",h$="_tabBar_1udy7_277",g$="_tab_1udy7_277",v$="_active_1udy7_303",y$="_eventScroll_1udy7_308",b$="_tabContent_1udy7_314",x$="_noContext_1udy7_319",_$="_overviewContent_1udy7_325",k$="_overviewDashboard_1udy7_334",S$="_overviewHero_1udy7_340",T$="_overviewSection_1udy7_347",w$="_overviewLabel_1udy7_353",j$="_envRow_1udy7_360",N$="_timeline_1udy7_366",C$="_timelineRow_1udy7_372",E$="_waitingMessage_1udy7_379",A$="_errorMessage_1udy7_383",D$="_emptyCta_1udy7_387",R$="_ctaTitle_1udy7_399",M$="_ctaDescription_1udy7_405",I$="_ctaButton_1udy7_412",O$="_workspaceHeader_1udy7_533",B$="_workspaceName_1udy7_558",L$="_workspaceMeta_1udy7_571",z$="_metaRow_1udy7_579",$$="_metaLabel_1udy7_592",U$="_metaValue_1udy7_607",P$="_archiveButton_1udy7_617",H$="_repoLink_1udy7_647",V$="_metaToggle_1udy7_657",q$="_metaToggleArrow_1udy7_678",G$="_metaToggleArrowOpen_1udy7_683",F$="_progressBarContainer_1udy7_687",Z$="_progressBar_1udy7_687",K$="_progressFill_1udy7_703",Y$="_progressLabel_1udy7_710",J$="_metaTimestamps_1udy7_717",W$="_metaTimestamp_1udy7_717",X$="_metaPlaceholder_1udy7_739",Q$="_linkedEnvList_1udy7_744",eU="_linkedEnvChip_1udy7_750",tU="_chipDismiss_1udy7_762",nU="_linkError_1udy7_777",sU="_linkEnvSelect_1udy7_782",Y={panelContainer:a$,emptyState:i$,workspaceSummary:o$,workspaceSummaryTitle:r$,workspaceSummarySubtitle:l$,header:c$,headerInfo:d$,headerTitle:u$,taskStatusBadge:f$,taskBranch:p$,taskBlockedBadge:m$,tabBar:h$,tab:g$,active:v$,eventScroll:y$,tabContent:b$,noContext:x$,overviewContent:_$,overviewDashboard:k$,overviewHero:S$,overviewSection:T$,overviewLabel:w$,envRow:j$,timeline:N$,timelineRow:C$,waitingMessage:E$,errorMessage:A$,emptyCta:D$,ctaTitle:R$,ctaDescription:M$,ctaButton:I$,workspaceHeader:O$,workspaceName:B$,workspaceMeta:L$,metaRow:z$,metaLabel:$$,metaValue:U$,archiveButton:P$,repoLink:H$,metaToggle:V$,metaToggleArrow:q$,metaToggleArrowOpen:G$,progressBarContainer:F$,progressBar:Z$,progressFill:K$,progressLabel:Y$,metaTimestamps:J$,metaTimestamp:W$,metaPlaceholder:X$,linkedEnvList:Q$,linkedEnvChip:eU,chipDismiss:tU,linkError:nU,linkEnvSelect:sU};function aU(){return i.jsx("div",{className:Y.emptyState,children:"Select a task or click + to create one"})}function iU(){return i.jsx("div",{className:Y.emptyState,children:"Select an environment to manage its workspaces, or add a new one."})}function oU(){const{workspaces:{workspaces:t},environments:{environments:s}}=mt(),o=kt(),r=s.length>0;return t.length>0?i.jsx(s$,{}):i.jsxs("div",{className:Y.emptyCta,"data-testid":"welcome-cta",children:[i.jsx("div",{className:Y.ctaTitle,children:"Welcome to Grackle"}),i.jsx("div",{className:Y.ctaDescription,children:"Organize your work into workspaces and let agents tackle the tasks."}),i.jsx("button",{className:Y.ctaButton,onClick:()=>o(zx),disabled:!r,"data-testid":"welcome-create-button",children:"Create Your First Workspace"}),!r&&i.jsx("div",{className:Y.ctaDescription,children:"Add an environment first before creating a workspace."})]})}const rU="_panelContainer_19poq_1",lU="_chatHeader_19poq_8",cU="_chatHeaderInfo_19poq_37",dU="_emptyState_19poq_43",uU="_emptyTitle_19poq_55",fU="_emptyDescription_19poq_61",pU="_emptyHint_19poq_67",Ba={panelContainer:rU,chatHeader:lU,chatHeaderInfo:cU,emptyState:dU,emptyTitle:uU,emptyDescription:fU,emptyHint:pU};function mU(){return i.jsx("div",{className:Ba.panelContainer,"aria-hidden":"true",children:i.jsxs("div",{style:{flex:1,overflow:"hidden",padding:"var(--space-md)",display:"flex",flexDirection:"column",gap:"var(--space-md)"},children:[i.jsx(we,{width:"65%",height:"2.5rem",borderRadius:"var(--radius-sm)"}),i.jsx(we,{width:"85%",height:"4rem",borderRadius:"var(--radius-sm)"}),i.jsx(we,{width:"45%",height:"2rem",borderRadius:"var(--radius-sm)"}),i.jsx(we,{width:"75%",height:"3rem",borderRadius:"var(--radius-sm)"}),i.jsx(we,{width:"55%",height:"2.5rem",borderRadius:"var(--radius-sm)"})]})})}function hU({hasLocalEnvironment:t}){return i.jsxs("div",{className:Ba.emptyState,"data-testid":"chat-empty-state",children:[i.jsx("div",{className:Ba.emptyTitle,children:"Welcome to Grackle"}),i.jsx("div",{className:Ba.emptyDescription,children:t?"Type a message below to start chatting with the System agent. It can help you plan work, create tasks, and coordinate agents.":"Add a local environment in Settings to start chatting."}),!t&&i.jsx("div",{className:Ba.emptyHint,children:"Go to Settings → Environments to add one."})]})}function gU(){const{tasks:{tasks:t,tasksLoading:s,startTask:o},sessions:{sessions:r,sessionsLoading:c,events:d,eventsDropped:u,taskSessions:p,loadTaskSessions:m,loadSessionEvents:g,kill:v,stopGraceful:b,sendInput:x,spawn:S},environments:{environments:k,provisionEnvironment:w},personas:{personas:N}}=mt(),{showToast:T}=Sn(),C=y.useRef(void 0),[D,B]=y.useState(),E=t.find(W=>W.id===Rr),A=E!=null&&E.latestSessionId?r.find(W=>W.id===E.latestSessionId)??(p[Rr]??[]).find(W=>W.id===E.latestSessionId):void 0;y.useEffect(()=>{m(Rr).catch(()=>{})},[m]),y.useEffect(()=>{E!=null&&E.latestSessionId&&m(Rr).catch(()=>{})},[E==null?void 0:E.latestSessionId,m]),y.useEffect(()=>{A&&A.id!==C.current&&(C.current=A.id,g(A.id).catch(()=>{}))},[A==null?void 0:A.id,g]);const P=y.useMemo(()=>{if(!A)return[];const W=d.filter(pe=>pe.sessionId===A.id);return ah(sh(W))},[d,A==null?void 0:A.id]),I=k.find(W=>W.adapterType==="local"&&W.status==="connected"),U=A!==void 0&&A.status!=="stopped"&&A.status!=="suspended",Q=(A==null?void 0:A.status)==="idle";y.useEffect(()=>{D&&A&&Q&&(x(A.id,D).catch(()=>{}),B(void 0))},[D,Q,A==null?void 0:A.id,x]);const $=y.useCallback((W,pe,H,ie)=>{ie&&B(ie),o(W,pe,H).catch(()=>{})},[o]);return!E&&(c||s)?i.jsx(mU,{}):i.jsxs("div",{className:Ba.panelContainer,"data-testid":"chat-page",children:[U&&i.jsxs("div",{className:Ba.chatHeader,children:[i.jsxs("span",{className:Ba.chatHeaderInfo,children:["Session: ",A.id.slice(0,8)," | ",A.runtime," | ",A.status]}),i.jsx(Ux,{label:"Stop",onClick:()=>{b(A.id).catch(()=>{})},variant:"danger",size:"sm","data-testid":"stop-split-button",options:[{label:"Stop",description:"Graceful shutdown",onClick:()=>{b(A.id).catch(()=>{})}},{label:"Kill",description:"Force kill",onClick:()=>{v(A.id).catch(()=>{})}}]})]}),i.jsx(Xm,{events:P,eventsDropped:u,emptyState:i.jsx(hU,{hasLocalEnvironment:!!I}),onShowToast:T}),I&&U&&i.jsx(Qr,{mode:"send",sessionId:A.id,environmentId:A.environmentId,personas:N,environments:k,onSendInput:(W,pe)=>{x(W,pe).catch(()=>{})},onSpawn:(W,pe,H)=>{S(W,pe,H).catch(()=>{})},onStartTask:(W,pe,H)=>{o(W,pe,H).catch(()=>{})},onProvisionEnvironment:W=>{w(W).catch(()=>{})},onShowToast:T}),I&&!U&&i.jsx(Qr,{mode:"start",taskId:Rr,environmentId:I.id,personas:N,environments:k,onSendInput:(W,pe)=>{x(W,pe).catch(()=>{})},onSpawn:(W,pe,H)=>{S(W,pe,H).catch(()=>{})},onStartTask:$,onProvisionEnvironment:W=>{w(W).catch(()=>{})},onShowToast:T})]})}function vU(){const t=y7(),[s]=hm(),o=s.get("env")??"",{sessions:{sendInput:r,spawn:c},tasks:{startTask:d},personas:{personas:u},environments:{environments:p,provisionEnvironment:m}}=mt(),{showToast:g}=Sn();return i.jsxs("div",{className:Y.panelContainer,children:[i.jsx(Ns,{segments:t}),i.jsx("div",{className:Y.emptyState,children:"Enter a prompt below to start a new session"}),i.jsx(Qr,{mode:"spawn",environmentId:o,showPersonaSelect:!0,personas:u,environments:p,onSendInput:(v,b)=>{r(v,b).catch(()=>{})},onSpawn:(v,b,x)=>{c(v,b,x).catch(()=>{})},onStartTask:(v,b,x)=>{d(v,b,x).catch(()=>{})},onProvisionEnvironment:v=>{m(v).catch(()=>{})},onShowToast:g})]})}function yU(){return i.jsxs("div",{className:Y.panelContainer,"aria-hidden":"true",children:[i.jsxs("div",{className:Y.header,children:[i.jsx("span",{children:i.jsx(we,{width:"10rem",height:"0.875rem"})}),i.jsx("span",{className:Y.headerInfo,children:i.jsx(we,{width:"16rem",height:"0.875rem"})})]}),i.jsx("div",{className:Y.eventScroll,children:i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-md)"},children:[i.jsx(we,{width:"70%",height:"2.5rem",borderRadius:"var(--radius-sm)"}),i.jsx(we,{width:"90%",height:"4rem",borderRadius:"var(--radius-sm)"}),i.jsx(we,{width:"50%",height:"2rem",borderRadius:"var(--radius-sm)"}),i.jsx(we,{width:"80%",height:"3.5rem",borderRadius:"var(--radius-sm)"}),i.jsx(we,{width:"60%",height:"2.5rem",borderRadius:"var(--radius-sm)"})]})})]})}function bU({sessionId:t,session:s,isActive:o,onStop:r,onKill:c}){return i.jsxs("div",{className:Y.header,children:[i.jsxs("span",{children:["Session: ",t.slice(0,8),s&&` | ${s.runtime} | ${s.endReason||s.status}`,s!=null&&s.inputTokens||s!=null&&s.outputTokens||s!=null&&s.costMillicents?` | ${Mo((s.inputTokens??0)+(s.outputTokens??0))} tokens · ${Ss(s.costMillicents??0)}`:""]}),i.jsxs("span",{className:Y.headerInfo,children:[s&&i.jsx("span",{children:s.prompt.length>60?s.prompt.slice(0,60)+"...":s.prompt}),o&&i.jsx(Ux,{label:"Stop",onClick:r,variant:"danger",size:"sm","data-testid":"stop-split-button",options:[{label:"Stop",description:"Graceful shutdown",onClick:r},{label:"Kill",description:"Force kill",onClick:c}]})]})]})}function xU({session:t}){const s=t&&(t.status==="stopped"||t.status==="suspended"),o=s?`Session ${t.endReason||t.status} with no events recorded.`:"Waiting for events...";return i.jsx("div",{className:s?Y.errorMessage:Y.waitingMessage,children:o})}function _U(){const{sessionId:t}=fs(),{sessions:{events:s,eventsDropped:o,sessions:r,sessionsLoading:c,kill:d,stopGraceful:u,loadSessionEvents:p,sendInput:m,spawn:g},tasks:{startTask:v},personas:{personas:b},environments:{environments:x,provisionEnvironment:S}}=mt(),{showToast:k}=Sn(),w=y.useRef(void 0),N=b7(t),T=r.find(B=>B.id===t)??void 0,C=y.useMemo(()=>{const B=t?s.filter(E=>E.sessionId===t):[];return ah(sh(B))},[s,t]);if(y.useEffect(()=>{t&&t!==w.current&&(w.current=t,p(t).catch(()=>{}))},[t,p]),!T&&c)return i.jsx(yU,{});if(!t)return i.jsx("div",{className:Y.emptyState,children:"No session selected"});const D=(T==null?void 0:T.status)==="running"||(T==null?void 0:T.status)==="idle";return i.jsxs("div",{className:Y.panelContainer,children:[i.jsx(Ns,{segments:N}),i.jsx(bU,{sessionId:t,session:T,isActive:D,onStop:()=>{u(t).catch(()=>{})},onKill:()=>{d(t).catch(()=>{})}}),i.jsx(Xm,{events:C,eventsDropped:o,emptyState:i.jsx(xU,{session:T}),onShowToast:k}),D&&i.jsx(Qr,{mode:"send",sessionId:t,environmentId:T.environmentId,personas:b,environments:x,onSendInput:(B,E)=>{m(B,E).catch(()=>{})},onSpawn:(B,E,A)=>{g(B,E,A).catch(()=>{})},onStartTask:(B,E,A)=>{v(B,E,A).catch(()=>{})},onProvisionEnvironment:B=>{S(B).catch(()=>{})},onShowToast:k})]})}function kU(t){if(!t)return!1;const s=t.tagName;return!!(s==="INPUT"||s==="TEXTAREA"||s==="SELECT"||t.isContentEditable)}function Qs(t,s){const o=y.useRef(s);o.current=s;const{key:r,ctrl:c=!1,shift:d=!1,suppressInInputs:u=!0,enabled:p=!0}=t;y.useEffect(()=>{if(!p)return;const m=g=>{if(u&&kU(document.activeElement??void 0))return;const v=g.ctrlKey||g.metaKey;c===v&&(d&&!g.shiftKey||g.key===r&&o.current())};return document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m)}},[r,c,d,u,p])}function SU(){return i.jsxs("div",{className:Y.panelContainer,"aria-hidden":"true",children:[i.jsx("div",{className:Y.workspaceHeader,children:i.jsx("span",{className:Y.workspaceName,children:i.jsx(we,{width:"12rem",height:"1.25rem"})})}),i.jsx("div",{className:Y.metaToggle,style:{cursor:"default"},children:i.jsx(we,{width:"4rem",height:"0.625rem"})}),i.jsxs("div",{className:Y.progressBarContainer,children:[i.jsx("div",{className:Y.progressBar,children:i.jsx("div",{className:Y.progressFill,style:{width:"0%"}})}),i.jsx(we,{width:"2rem",height:"0.625rem"})]}),i.jsxs("div",{className:Y.tabBar,role:"tablist","aria-label":"Workspace view",children:[i.jsx("span",{className:`${Y.tab} ${Y.active}`,children:"Graph"}),i.jsx("span",{className:Y.tab,children:"Board"}),i.jsx("span",{className:Y.tab,children:"Tasks"})]}),i.jsx("div",{className:Y.overviewContent,children:Array.from({length:3},(t,s)=>i.jsx(dd,{lines:2},s))})]})}function tx(t){if(!t)return"";const s=new Date(t);if(isNaN(s.getTime()))return"";const r=Date.now()-s.getTime();if(r<0)return"just now";const c=Math.floor(r/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const d=Math.floor(c/60);if(d<24)return`${d}h ago`;const u=Math.floor(d/24);return u<30?`${u}d ago`:s.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}const Np=100;function TU(t){try{const s=new URL(t);return s.protocol!=="http:"&&s.protocol!=="https:"?void 0:s.toString()}catch{return}}function wU(){const{workspaceId:t,environmentId:s}=fs(),o=kt(),{tasks:{tasks:r},environments:{environments:c},workspaces:{workspaces:d,workspacesLoading:u,archiveWorkspace:p,updateWorkspace:m,linkEnvironment:g,unlinkEnvironment:v,linkOperationError:b,clearLinkOperationError:x},personas:{personas:S},sessions:{sessions:k},usageCache:w,loadUsage:N}=mt(),{resolvedThemeId:T}=B1(),[C,D]=y.useState("tasks"),[B,E]=y.useState(!1),[A,P]=y.useState(null),[I,U]=y.useState(!1),Q=y.useRef(void 0),$=d.find(X=>X.id===t),W=s??($==null?void 0:$.environmentId)??"",pe=x7(t,W,d,c);Qs({key:"1"},()=>D("graph")),Qs({key:"2"},()=>D("board")),Qs({key:"3"},()=>D("tasks")),y.useEffect(()=>{const X=Q.current;Q.current=t,!(X===void 0||X===t)&&A!==null&&P(null)},[t,A]);const H=k.reduce((X,ge)=>X+(ge.costMillicents??0),0);y.useEffect(()=>{t&&N("workspace",t).catch(()=>{})},[t,N,H]);const ie=t?w[`workspace:${t}`]:void 0,L=r.filter(X=>X.workspaceId===t),Z=L.filter(X=>X.status==="complete").length,J=L.length,ce=J>0?Math.round(Z/J*100):0;return!$&&u?i.jsx(SU,{}):i.jsxs("div",{className:Y.panelContainer,children:[i.jsx(Ns,{segments:pe}),i.jsxs("div",{className:Y.workspaceHeader,children:[i.jsx("span",{className:Y.workspaceName,"data-testid":"workspace-name",children:i.jsx(ln,{value:($==null?void 0:$.name)||"",onSave:X=>{$&&m($.id,{name:X}).catch(()=>{})},validate:X=>{const ge=X.trim();if(!ge)return"Name is required";if(ge.length>Np)return`Max ${Np} characters`},maxLength:Np,fieldId:"name",activeFieldId:A,onActivate:P,ariaLabel:"Workspace name",renderDisplay:X=>X||t||void 0,"data-testid":"edit-name"})}),i.jsx("button",{className:Y.archiveButton,onClick:()=>E(!0),title:"Archive workspace","data-testid":"archive-workspace-button",children:"Archive"})]}),i.jsxs("button",{className:Y.metaToggle,onClick:()=>U(!I),"aria-expanded":!I,"aria-controls":"workspace-meta-panel","data-testid":"meta-toggle",children:[i.jsx("span",{className:`${Y.metaToggleArrow} ${I?"":Y.metaToggleArrowOpen}`,children:"▶"}),"Details"]}),!I&&i.jsxs("div",{className:Y.workspaceMeta,"data-testid":"workspace-meta",id:"workspace-meta-panel",children:[i.jsxs("div",{className:Y.metaRow,children:[i.jsx("span",{className:Y.metaLabel,children:"Description"}),i.jsx("div",{className:Y.metaValue,children:i.jsx(Xp,{value:($==null?void 0:$.description)||"",onSave:X=>{$&&m($.id,{description:X}).catch(()=>{})},fieldId:"description",activeFieldId:A,onActivate:P,renderDisplay:X=>X?i.jsx("span",{className:Y.overviewMarkdown,children:i.jsx(hd,{remarkPlugins:[gd],children:X})}):void 0,placeholder:"No description",ariaLabel:"Workspace description","data-testid":"edit-description"})})]}),i.jsxs("div",{className:Y.metaRow,children:[i.jsx("span",{className:Y.metaLabel,children:"Repository"}),i.jsx("div",{className:Y.metaValue,children:i.jsx(ln,{value:($==null?void 0:$.repoUrl)||"",onSave:X=>{$&&m($.id,{repoUrl:X}).catch(()=>{})},validate:X=>{const ge=X.trim();if(ge&&!/^https?:\/\/.+/.test(ge))return"Must be a valid http(s) URL"},fieldId:"repoUrl",activeFieldId:A,onActivate:P,renderDisplay:X=>{const ge=TU(X);return ge?i.jsx("a",{className:Y.repoLink,href:ge,target:"_blank",rel:"noopener noreferrer",onClick:fe=>fe.stopPropagation(),children:X}):X?i.jsx("span",{children:X}):void 0},placeholder:"No repository",ariaLabel:"Workspace repository URL","data-testid":"edit-repo"})})]}),i.jsxs("div",{className:Y.metaRow,children:[i.jsx("span",{className:Y.metaLabel,children:"Environment"}),i.jsx("div",{className:Y.metaValue,children:i.jsx(B6,{value:($==null?void 0:$.environmentId)||"",onSave:X=>{$&&X&&m($.id,{environmentId:X}).catch(()=>{})},environments:c,fieldId:"environmentId",activeFieldId:A,onActivate:P,placeholder:"Select environment",ariaLabel:"Workspace environment","data-testid":"edit-env"})})]}),i.jsxs("div",{className:Y.metaRow,children:[i.jsx("span",{className:Y.metaLabel,children:"Linked Envs"}),i.jsx("div",{className:Y.metaValue,"data-testid":"linked-environments",children:$?i.jsxs("span",{className:Y.linkedEnvList,children:[(()=>{const X=[...new Set($.linkedEnvironmentIds.filter(ge=>ge!==$.environmentId))];return X.length===0?i.jsx("span",{className:Y.metaPlaceholder,children:"None"}):X.map(ge=>{const fe=c.find(Ce=>Ce.id===ge);return i.jsxs("span",{className:Y.linkedEnvChip,"data-testid":`linked-env-${ge}`,children:[(fe==null?void 0:fe.displayName)||ge,i.jsx("button",{className:Y.chipDismiss,onClick:()=>{v($.id,ge).catch(()=>{})},title:`Unlink ${(fe==null?void 0:fe.displayName)||ge}`,"aria-label":`Unlink ${(fe==null?void 0:fe.displayName)||ge}`,"data-testid":`unlink-env-${ge}`,children:"x"})]},ge)})})(),(()=>{const X=new Set($.linkedEnvironmentIds),ge=c.filter(fe=>fe.id!==$.environmentId&&!X.has(fe.id));return ge.length===0?null:i.jsxs("select",{className:Y.linkEnvSelect,value:"",onChange:fe=>{fe.target.value&&g($.id,fe.target.value).catch(()=>{})},"aria-label":"Link environment","data-testid":"link-env-select",children:[i.jsx("option",{value:"",children:"+ Link"}),ge.map(fe=>i.jsx("option",{value:fe.id,children:fe.displayName||fe.id},fe.id))]})})(),b&&i.jsxs("span",{className:Y.linkError,"data-testid":"link-operation-error",role:"alert",children:[b,i.jsx("button",{className:Y.chipDismiss,onClick:x,"aria-label":"Dismiss error","data-testid":"dismiss-link-error",children:"x"})]})]}):i.jsx("span",{className:Y.metaPlaceholder,children:"None"})})]}),i.jsxs("div",{className:Y.metaRow,children:[i.jsx("span",{className:Y.metaLabel,children:"Persona"}),i.jsx("div",{className:Y.metaValue,children:i.jsx(ud,{value:($==null?void 0:$.defaultPersonaId)||"",onSave:X=>{$&&m($.id,{defaultPersonaId:X}).catch(()=>{})},options:[{value:"",label:"(Inherit)"},...S.map(X=>({value:X.id,label:X.name}))],fieldId:"defaultPersonaId",activeFieldId:A,onActivate:P,renderDisplay:X=>{const ge=S.find(fe=>fe.id===X);if(ge)return i.jsx("span",{children:ge.name})},placeholder:($==null?void 0:$.defaultPersonaId)||"(Inherit)",ariaLabel:"Workspace default persona","data-testid":"edit-persona"})})]}),i.jsxs("div",{className:Y.metaRow,children:[i.jsx("span",{className:Y.metaLabel,children:"Worktrees"}),i.jsx("div",{className:Y.metaValue,children:i.jsx(C6,{checked:($==null?void 0:$.useWorktrees)??!0,onChange:X=>{$&&m($.id,{useWorktrees:X}).catch(()=>{})},label:"Enable worktree isolation","data-testid":"worktree-toggle"})})]}),i.jsxs("div",{className:Y.metaRow,children:[i.jsx("span",{className:Y.metaLabel,children:"Working Dir"}),i.jsx("div",{className:Y.metaValue,children:i.jsx(ln,{value:($==null?void 0:$.workingDirectory)||"",onSave:X=>{$&&m($.id,{workingDirectory:X}).catch(()=>{})},fieldId:"workingDirectory",activeFieldId:A,onActivate:P,placeholder:"Default (server default)",ariaLabel:"Working directory","data-testid":"edit-working-directory"})})]}),$&&i.jsxs("div",{className:Y.metaTimestamps,children:[i.jsxs("span",{className:Y.metaTimestamp,children:["Created ",tx($.createdAt)]}),$.updatedAt&&$.updatedAt!==$.createdAt&&i.jsxs("span",{className:Y.metaTimestamp,children:["· Updated ",tx($.updatedAt)]})]})]}),J>0&&i.jsxs("div",{className:Y.progressBarContainer,"data-testid":"progress-bar",children:[i.jsx("div",{className:Y.progressBar,children:i.jsx("div",{className:Y.progressFill,style:{width:`${ce}%`}})}),i.jsxs("span",{className:Y.progressLabel,children:[Z,"/",J]})]}),ie&&ie.costMillicents>0&&i.jsx("div",{className:Y.progressBarContainer,children:i.jsxs("span",{className:Y.progressLabel,children:["Usage: ",Ss(ie.costMillicents)," (",ie.sessionCount," session",ie.sessionCount!==1?"s":"",")"]})}),$&&($.tokenBudget>0||$.costBudgetMillicents>0)&&i.jsx("div",{className:Y.progressBarContainer,children:i.jsxs("span",{className:Y.progressLabel,children:["Budget:"," ",$.tokenBudget>0&&i.jsxs(i.Fragment,{children:["Tokens: ",Mo(((ie==null?void 0:ie.inputTokens)??0)+((ie==null?void 0:ie.outputTokens)??0))," / ",Mo($.tokenBudget)]}),$.tokenBudget>0&&$.costBudgetMillicents>0&&" | ",$.costBudgetMillicents>0&&i.jsxs(i.Fragment,{children:["Cost: ",Ss((ie==null?void 0:ie.costMillicents)??0)," / ",Ss($.costBudgetMillicents)]})]})}),i.jsxs("div",{className:Y.tabBar,role:"tablist","aria-label":"Workspace view",children:[i.jsx("button",{role:"tab","aria-selected":C==="graph",className:`${Y.tab} ${C==="graph"?Y.active:""}`,onClick:()=>D("graph"),children:"Graph"}),i.jsx("button",{role:"tab","aria-selected":C==="board",className:`${Y.tab} ${C==="board"?Y.active:""}`,onClick:()=>D("board"),"data-testid":"board-tab",children:"Board"}),i.jsx("button",{role:"tab","aria-selected":C==="tasks",className:`${Y.tab} ${C==="tasks"?Y.active:""}`,onClick:()=>D("tasks"),children:"Tasks"})]}),C==="tasks"&&J>0&&i.jsxs("div",{className:Y.workspaceSummary,children:[i.jsx("span",{className:Y.workspaceSummaryTitle,children:`${Z}/${J} tasks complete`}),i.jsx("span",{className:Y.workspaceSummarySubtitle,children:"Select a task or click + to create one"})]}),C==="tasks"&&J===0&&i.jsxs("div",{className:Y.emptyCta,children:[i.jsx("button",{className:Y.ctaButton,onClick:()=>o(Di(t,void 0,W)),children:"Create Task"}),i.jsx("div",{className:Y.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}),C==="board"&&i.jsx(V8,{workspaceId:t,environmentId:W,tasks:r,sessions:k,personas:S,environments:c}),C==="graph"&&i.jsx(pN,{workspaceId:t,environmentId:W,tasks:r,resolvedThemeId:T}),i.jsx(Ci,{isOpen:B,title:"Archive Workspace?",description:"This will hide the workspace from the sidebar. Tasks will not be deleted.",confirmLabel:"Archive",onConfirm:()=>{$&&(p($.id).catch(()=>{}),o("/",{replace:!0})),E(!1)},onCancel:()=>E(!1)})]})}const jU="_container_3pgew_1",NU="_header_3pgew_8",CU="_headerTitle_3pgew_35",EU="_headerActions_3pgew_44",AU="_body_3pgew_51",DU="_btnPrimary_3pgew_63",RU="_btnGhost_3pgew_94",MU="_error_3pgew_116",Ma={container:jU,header:NU,headerTitle:CU,headerActions:EU,body:AU,btnPrimary:DU,btnGhost:RU,error:MU};function IU(t){const s={};return t.name.trim()||(s.name="Name is required"),t.repoUrl.trim()&&!/^https?:\/\/.+/i.test(t.repoUrl.trim())&&(s.repoUrl="Must be a valid http(s) URL"),t.environmentId||(s.environmentId="Environment is required"),Object.keys(s).length>0?s:void 0}const OU=[{label:"Home",url:Ni},{label:"New Workspace",url:void 0}];function BU(){const[t]=hm(),s=t.get("environment")??void 0,{environments:{environments:o},personas:{personas:r},workspaces:{createWorkspace:c,workspaceCreating:d}}=mt(),{showToast:u}=Sn(),p=kt(),[m,g]=y.useState(()=>{var N;return e7(void 0,s||((N=o[0])==null?void 0:N.id))}),[v,b]=y.useState(),[x,S]=y.useState();y.useEffect(()=>{s||m.environmentId||o.length===0||g(N=>{var T;return N.environmentId?N:{...N,environmentId:((T=o[0])==null?void 0:T.id)??""}})},[o,s,m.environmentId]);const k=()=>{const N=IU(m);if(N){b(N),S(void 0);return}b(void 0),S(void 0),c(m.name.trim(),m.description,m.repoUrl.trim(),m.environmentId,m.defaultPersonaId,m.useWorktrees,m.workingDirectory,()=>{u("Workspace created","success"),p(Ni,{replace:!0})},T=>{S(T)}).catch(()=>{})},w=()=>{p(s?ji(s):Ni,{replace:!0})};return i.jsxs("div",{className:Ma.container,children:[i.jsxs("div",{className:Ma.header,children:[i.jsx("div",{className:Ma.headerTitle,children:i.jsx(Ns,{segments:OU})}),i.jsxs("div",{className:Ma.headerActions,children:[i.jsx("button",{className:Ma.btnGhost,onClick:w,disabled:d,"data-testid":"workspace-create-cancel",children:"Cancel"}),i.jsx("button",{className:Ma.btnPrimary,onClick:k,disabled:d||!m.name.trim()||!m.environmentId,"data-testid":"workspace-create-save",children:d?i.jsx(g1,{size:"sm",label:"Creating"}):"Create Workspace"})]})]}),i.jsxs("div",{className:Ma.body,children:[i.jsx(n7,{values:m,onChange:N=>{g(N),b(void 0),S(void 0)},environments:o,personas:r,errors:v,disabled:d,autoFocusName:!0}),x&&i.jsx("div",{className:Ma.error,"data-testid":"workspace-create-submit-error",children:x})]})]})}function nx(){const{workspaceId:t,environmentId:s}=fs(),[o]=hm(),r=t??o.get("workspace")??"",c=o.get("parent")??void 0,{tasks:{tasks:d,createTask:u,updateTask:p},workspaces:{workspaces:m},personas:{personas:g}}=mt(),{showToast:v}=Sn();return i.jsx(E1,{mode:"new",workspaceId:r,parentTaskId:c,environmentId:s,tasks:d,workspaces:m,personas:g,onCreateTask:(b,x,S,k,w,N,T,C,D)=>{u(b,x,S,k,w,N,T,C,D).catch(()=>{})},onUpdateTask:(b,x,S,k,w)=>{p(b,x,S,k,w).catch(()=>{})},onShowToast:v})}function LU(){return i.jsxs("div",{className:Y.panelContainer,"aria-hidden":"true",children:[i.jsx("div",{className:Y.header,children:i.jsxs("span",{className:Y.headerTitle,children:[i.jsx(we,{width:"12rem",height:"1rem"}),i.jsx(we,{width:"4rem",height:"1rem",borderRadius:"var(--radius-full)"})]})}),i.jsxs("div",{className:Y.tabBar,role:"tablist","aria-label":"Task view",children:[i.jsx("span",{className:`${Y.tab} ${Y.active}`,children:"Overview"}),i.jsx("span",{className:Y.tab,children:"Stream"}),i.jsx("span",{className:Y.tab,children:"Findings"})]}),i.jsx("div",{className:Y.overviewContent,children:i.jsxs("div",{className:Y.overviewDashboard,children:[i.jsx("div",{className:Y.overviewHero,children:i.jsx(we,{width:"5rem",height:"1.5rem",borderRadius:"var(--radius-full)"})}),i.jsxs("div",{className:Y.overviewSection,children:[i.jsx("div",{className:Y.overviewLabel,children:"Description"}),i.jsx(Wp,{lines:2})]}),i.jsxs("div",{className:Y.overviewSection,children:[i.jsx("div",{className:Y.overviewLabel,children:"Environment"}),i.jsxs("div",{className:Y.envRow,children:[i.jsx(we,{width:"0.5rem",height:"0.5rem",variant:"circular"}),i.jsx(we,{width:"8rem",height:"0.875rem"})]})]}),i.jsxs("div",{className:Y.overviewSection,children:[i.jsx("div",{className:Y.overviewLabel,children:"Dependencies"}),i.jsx(Wp,{lines:2})]}),i.jsxs("div",{className:Y.overviewSection,children:[i.jsx("div",{className:Y.overviewLabel,children:"Timeline"}),i.jsx("div",{className:Y.timeline,children:Array.from({length:4},(t,s)=>i.jsxs("div",{className:Y.timelineRow,children:[i.jsx(we,{width:"4rem",height:"0.75rem"}),i.jsx(we,{width:"10rem",height:"0.75rem"})]},s))})]})]})})]})}function Ia(){const{taskId:t,workspaceId:s,environmentId:o}=fs(),r=Zt(),c=kt(),{showToast:d}=Sn(),{sessions:{events:u,eventsDropped:p,sessions:m,loadSessionEvents:g,taskSessions:v,loadTaskSessions:b,sendInput:x,spawn:S,kill:k},tasks:{tasks:w,tasksLoading:N,startTask:T,stopTask:C,resumeTask:D,deleteTask:B,createTask:E,updateTask:A},environments:{environments:P,provisionEnvironment:I},findings:{findings:U,loadFindings:Q},workspaces:{workspaces:$},personas:{personas:W},usageCache:pe,loadUsage:H}=mt(),ie=y.useRef(void 0),L=y.useRef(void 0),Z=y.useRef(void 0),J=y.useRef(void 0),ce=y.useRef(void 0),X=r.pathname.endsWith("/stream")?"stream":r.pathname.endsWith("/findings")?"findings":"overview",ge=r.pathname.endsWith("/edit"),[fe,Ce]=y.useState(X),[Ze,me]=y.useState(!1),[_e,ve]=y.useState(void 0),[Le,Mt]=y.useState(""),[Tn,oe]=y.useState(ge),Ve=y.useRef(X),qt=y.useRef(ge),te=w.find(Re=>Re.id===t),ht=(te==null?void 0:te.workspaceId)||void 0,at=$.find(Re=>Re.id===ht);y.useEffect(()=>{X!==Ve.current&&(Ve.current=X,X!==fe&&Ce(X))},[X,fe]),y.useEffect(()=>{ge!==qt.current&&(qt.current=ge,ge!==Tn&&oe(ge))},[ge,Tn]),y.useEffect(()=>{if(Le===""){if(at!=null&&at.environmentId)Mt(at.environmentId);else if(P.length>0){const Re=P.find(Je=>Je.status==="connected");Mt((Re==null?void 0:Re.id)??P[0].id)}}},[Le,at==null?void 0:at.environmentId,P]);const Kt=te?v[te.id]??[]:[];let gt;_e&&Kt.some(Re=>Re.id===_e)?gt=_e:gt=(te==null?void 0:te.latestSessionId)||void 0;const ps=()=>{me(!0)},aa=()=>{if(!te)return;B(te.id).catch(()=>{}),me(!1);const Re=o??(at==null?void 0:at.environmentId);c(te.workspaceId&&Re?$a(te.workspaceId,Re):"/",{replace:!0})};y.useEffect(()=>{(te==null?void 0:te.id)!==L.current&&(L.current=te==null?void 0:te.id,ve(void 0),Mt(""),oe(ge))},[te==null?void 0:te.id,ge]),y.useEffect(()=>{if(!(te!=null&&te.id))return;const Re=te.id!==J.current,Je=te.latestSessionId!==ce.current;(Re||Je)&&(J.current=te.id,ce.current=te.latestSessionId,b(te.id).catch(()=>{}))},[te==null?void 0:te.id,te==null?void 0:te.latestSessionId,b]),y.useEffect(()=>{if((te==null?void 0:te.status)!==Z.current){const Re=Z.current===void 0;Z.current=te==null?void 0:te.status;const Je=(te==null?void 0:te.status)==="not_started"?"overview":(te==null?void 0:te.status)==="working"||(te==null?void 0:te.status)==="paused"?"stream":(te==null?void 0:te.status)==="complete"?"findings":void 0;Je&&Je!==fe&&!(Re&&X!=="overview")&&Ce(Je)}},[te==null?void 0:te.status,fe,X]);const es=y.useMemo(()=>new Map(w.map(Re=>[Re.id,Re])),[w]),Fa=y.useMemo(()=>{const Re=gt?u.filter(Je=>Je.sessionId===gt):[];return ah(sh(Re))},[u,gt]),ia=te?te.dependsOn.some(Re=>{const Je=es.get(Re);return Je!==void 0&&Je.status!=="complete"}):!1,Yt=y.useMemo(()=>_7(t,o,$,P,es),[t,o,$,P,es]);y.useEffect(()=>{gt&>!==ie.current&&(ie.current=gt,g(gt).catch(()=>{}))},[gt,g]),y.useEffect(()=>{fe==="findings"&&ht&&Q(ht).catch(()=>{})},[fe,ht,Q]);const Mi=Kt.reduce((Re,Je)=>Re+(Je.costMillicents??0),0);y.useEffect(()=>{te&&(H("task",te.id).catch(()=>{}),te.childTaskIds.length>0&&H("task_tree",te.id).catch(()=>{}))},[te==null?void 0:te.id,te==null?void 0:te.childTaskIds.length,H,Mi]);const oa=te?`task:${te.id}`:"",Za=oa in pe?pe[oa]:void 0,ms=te?`task_tree:${te.id}`:"",Ii=te&&te.childTaskIds.length>0&&ms in pe?pe[ms]:void 0,wn=Re=>{Ce(Re),c(On(t,Re==="overview"?void 0:Re,s,o))};return Qs({key:"1"},()=>wn("overview")),Qs({key:"2"},()=>wn("stream")),Qs({key:"3"},()=>wn("findings")),!te&&N?i.jsx(LU,{}):i.jsxs("div",{className:Y.panelContainer,children:[i.jsx(Ns,{segments:Yt}),i.jsxs("div",{className:Y.header,children:[i.jsxs("span",{className:Y.headerTitle,children:[i.jsx("span",{"data-testid":"task-title",children:(te==null?void 0:te.title)||t}),te&&i.jsx("span",{className:Y.taskStatusBadge,"data-testid":"task-status",children:te.status}),(te==null?void 0:te.branch)&&i.jsx("span",{className:Y.taskBranch,children:te.branch}),ia&&i.jsx("span",{className:Y.taskBlockedBadge,children:"blocked"})]}),te&&i.jsx(bB,{task:te,sessionId:gt,isBlocked:ia,onStart:()=>{T(te.id,void 0,Le).catch(()=>{})},onResume:()=>{D(te.id).catch(()=>{})},onStop:()=>{C(te.id).catch(()=>{})},onPause:()=>{gt&&k(gt).catch(()=>{})},onDelete:ps,onEdit:()=>oe(!0)})]}),i.jsxs("div",{className:Y.tabBar,role:"tablist","aria-label":"Task view",children:[i.jsx("button",{role:"tab","aria-selected":fe==="overview",className:`${Y.tab} ${fe==="overview"?Y.active:""}`,onClick:()=>wn("overview"),children:"Overview"}),i.jsx("button",{role:"tab","aria-selected":fe==="stream",className:`${Y.tab} ${fe==="stream"?Y.active:""}`,onClick:()=>wn("stream"),children:"Stream"}),i.jsx("button",{role:"tab","aria-selected":fe==="findings",className:`${Y.tab} ${fe==="findings"?Y.active:""}`,onClick:()=>wn("findings"),children:"Findings"})]}),i.jsxs(us,{mode:"wait",children:[fe==="overview"&&i.jsx(Rt.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},className:Y.overviewContent,"data-testid":"task-overview",children:Tn&&te?i.jsx(E1,{mode:"edit",taskId:te.id,workspaceId:ht,environmentId:o,tasks:w,workspaces:$,personas:W,onCreateTask:(Re,Je,Jt,St,un,Wt,Oi,Bi,Li)=>{E(Re,Je,Jt,St,un,Wt,Oi,Bi,Li).catch(()=>{})},onUpdateTask:(Re,Je,Jt,St,un)=>{A(Re,Je,Jt,St,un).catch(()=>{})},onEditDone:()=>{ge?c(On(te.id,void 0,s,o),{replace:!0}):oe(!1)},onShowToast:d}):te?i.jsx(oL,{task:te,tasksById:es,environments:P,workspaces:$,taskSessions:Kt,selectedEnvId:Le,taskUsage:Za,treeUsage:Ii}):i.jsx("div",{className:Y.waitingMessage,children:"No additional details"})},"overview"),fe==="stream"&&i.jsxs(Rt.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},style:{display:"flex",flexDirection:"column",flex:1,overflow:"hidden"},children:[i.jsx(M3,{taskSessions:Kt,selectedSessionId:gt,onSelect:Re=>ve(Re)}),i.jsx(Xm,{events:Fa,eventsDropped:p,emptyState:!gt&&te?ia?i.jsx("div",{className:Y.emptyCta,"data-testid":"stream-blocked-message",children:i.jsx("div",{className:Y.ctaDescription,children:"This task is blocked by incomplete dependencies"})}):i.jsxs("div",{className:Y.emptyCta,children:[i.jsx("button",{"data-testid":"stream-start-cta",className:Y.ctaButton,onClick:()=>{T(te.id,void 0,Le).catch(()=>{})},children:"Start Task"}),i.jsx("div",{className:Y.ctaDescription,children:"Click to begin agent execution"})]}):gt&&Fa.length===0?i.jsx("div",{className:Y.waitingMessage,children:"Waiting for events..."}):void 0,onShowToast:d})]},"stream"),fe==="findings"&&i.jsx(Rt.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},className:Y.tabContent,children:ht?i.jsx(N1,{findings:U.filter(Re=>Re.workspaceId===ht)}):i.jsx("div",{className:Y.noContext,children:"Navigate to a task within a workspace to view findings"})},"findings")]}),(()=>{if(!te||te.status!=="working"&&te.status!=="paused")return;const Re=gt?m.find(Je=>Je.id===gt):void 0;if(!(!Re||Re.status==="stopped"))return i.jsx(Qr,{mode:"send",sessionId:Re.id,environmentId:Re.environmentId,personas:W,environments:P,onSendInput:(Je,Jt)=>{x(Je,Jt).catch(()=>{})},onSpawn:(Je,Jt,St)=>{S(Je,Jt,St).catch(()=>{})},onStartTask:(Je,Jt,St)=>{T(Je,Jt,St).catch(()=>{})},onProvisionEnvironment:Je=>{I(Je).catch(()=>{})},onShowToast:d})})(),te&&i.jsx(Ci,{isOpen:Ze,title:"Delete Task?",description:`"${te.title}" will be permanently removed.`,onConfirm:aa,onCancel:()=>me(!1)})]})}function zU(){const{environments:{environments:t,addEnvironment:s,updateEnvironment:o},codespaces:{codespaces:r,codespaceError:c,codespaceListError:d,codespaceCreating:u,listCodespaces:p,createCodespace:m}}=mt(),{showToast:g}=Sn();return i.jsx(A1,{mode:"new",environments:t,onAddEnvironment:(v,b,x)=>{s(v,b,x).catch(()=>{})},onUpdateEnvironment:(v,b)=>{o(v,b).catch(()=>{})},onListCodespaces:()=>{p().catch(()=>{})},codespaces:r,codespaceError:c,codespaceListError:d,codespaceCreating:u,onCreateCodespace:(v,b)=>{m(v,b).catch(()=>{})},onShowToast:g})}function $U(){const{environmentId:t}=fs(),{environments:{environments:s,addEnvironment:o,updateEnvironment:r},codespaces:{codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,listCodespaces:m,createCodespace:g}}=mt(),{showToast:v}=Sn();return i.jsx(A1,{mode:"edit",environmentId:t,environments:s,onAddEnvironment:(b,x,S)=>{o(b,x,S).catch(()=>{})},onUpdateEnvironment:(b,x)=>{r(b,x).catch(()=>{})},onListCodespaces:()=>{m().catch(()=>{})},codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:(b,x)=>{g(b,x).catch(()=>{})},onShowToast:v})}const UU="_layout_11u79_1",PU="_content_11u79_8",HU="_tabPanel_11u79_14",Xr={layout:UU,content:PU,tabPanel:HU};function VU(){const t=v7();return i.jsxs("div",{className:Xr.layout,children:[i.jsx(Ns,{segments:t}),i.jsx("div",{className:Xr.content,children:i.jsx(Va,{})})]})}const qU="_container_144a4_1",GU="_envHeader_144a4_6",FU="_envTitleRow_144a4_10",ZU="_statusDot_144a4_16",KU="_envName_144a4_21",YU="_statusBadge_144a4_27",JU="_envMeta_144a4_33",WU="_metaTag_144a4_39",XU="_actions_144a4_51",QU="_provisionMessage_144a4_59",eP="_errorMessage_144a4_64",tP="_section_144a4_69",nP="_sectionHeader_144a4_73",sP="_cardList_144a4_121",aP="_card_144a4_121",iP="_cardHeader_144a4_138",oP="_cardName_144a4_144",rP="_cardActions_144a4_149",lP="_cardDescription_144a4_154",cP="_cardMeta_144a4_160",dP="_repoLink_144a4_166",uP="_empty_144a4_174",fP="_errorHint_144a4_180",pP="_btnPrimary_144a4_186",mP="_btnOutline_144a4_220",hP="_btnSmall_144a4_247",gP="_btnDanger_144a4_273",Se={container:qU,envHeader:GU,envTitleRow:FU,statusDot:ZU,envName:KU,statusBadge:YU,envMeta:JU,metaTag:WU,actions:XU,provisionMessage:QU,errorMessage:eP,section:tP,sectionHeader:nP,cardList:sP,card:aP,cardHeader:iP,cardName:oP,cardActions:rP,cardDescription:lP,cardMeta:cP,repoLink:dP,empty:uP,errorHint:fP,btnPrimary:pP,btnOutline:mP,btnSmall:hP,btnDanger:gP};function vP(){return i.jsxs("div",{className:Se.container,"aria-hidden":"true",children:[i.jsxs("div",{className:Se.envHeader,children:[i.jsxs("div",{className:Se.envTitleRow,children:[i.jsx(we,{width:"0.875rem",height:"0.875rem",variant:"circular"}),i.jsx(we,{width:"12rem",height:"1.5rem"}),i.jsx(we,{width:"4rem",height:"0.875rem"})]}),i.jsxs("div",{className:Se.envMeta,children:[i.jsx(we,{width:"6rem",height:"1.25rem",borderRadius:"var(--radius-sm)"}),i.jsx(we,{width:"5rem",height:"1.25rem",borderRadius:"var(--radius-sm)"}),i.jsx(we,{width:"4.5rem",height:"1.25rem",borderRadius:"var(--radius-sm)"})]})]}),i.jsxs("div",{className:Se.actions,children:[i.jsx(we,{width:"5rem",height:"2rem",borderRadius:"var(--radius-sm)"}),i.jsx(we,{width:"4rem",height:"2rem",borderRadius:"var(--radius-sm)"})]}),i.jsxs("div",{className:Se.section,children:[i.jsx("div",{className:Se.sectionHeader,children:i.jsx("h3",{style:{margin:0},children:"Workspaces"})}),i.jsxs("div",{className:Se.cardList,children:[i.jsx(dd,{lines:2}),i.jsx(dd,{lines:2})]})]})]})}const yP={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function bP(){const{environmentId:t}=fs(),s=kt(),{environments:{environments:o,environmentsLoading:r,provisionStatus:c,provisionEnvironment:d,stopEnvironment:u,removeEnvironment:p},workspaces:{workspaces:m,archiveWorkspace:g,linkEnvironment:v,unlinkEnvironment:b,linkOperationError:x,clearLinkOperationError:S},sessions:{sessions:k}}=mt(),[w,N]=y.useState(!1),[T,C]=y.useState(!1),[D,B]=y.useState(void 0),E=o.find(J=>J.id===t);if(!E&&r)return i.jsx(vP,{});if(!t||!E)return i.jsx(ds,{to:Ro,replace:!0});const A=m.filter(J=>J.environmentId===E.id),P=m.filter(J=>J.linkedEnvironmentIds.includes(E.id)&&J.environmentId!==E.id).filter((J,ce,X)=>X.findIndex(ge=>ge.id===J.id)===ce),I=k.filter(J=>J.environmentId===E.id),U=I.reduce((J,ce)=>J+(ce.costMillicents??0),0),Q=yP[E.status]||"var(--text-tertiary)",$=E.status==="connected",W=E.status==="connecting",pe=E.status==="disconnected"||E.status==="error"||E.status==="sleeping",H=E.id in c?c[E.id]:void 0,ie=()=>{p(E.id).catch(()=>{}),N(!1),s(Ro,{replace:!0})},L=()=>{C(!1),d(E.id,!0).catch(()=>{})},Z=J=>{g(J).catch(()=>{}),B(void 0)};return i.jsxs("div",{className:Se.container,children:[i.jsx(Ci,{isOpen:w,title:"Delete Environment?",description:`"${E.displayName||E.id}" will be permanently removed along with all its data.`,onConfirm:ie,onCancel:()=>N(!1)}),i.jsx(Ci,{isOpen:T,title:"Reprovision Environment?",description:"This will kill any active session and force a fresh provision cycle. The environment will be temporarily disconnected.",confirmLabel:"Reprovision",onConfirm:L,onCancel:()=>C(!1)}),i.jsxs("div",{className:Se.envHeader,children:[i.jsxs("div",{className:Se.envTitleRow,children:[i.jsx("span",{className:Se.statusDot,style:{color:Q},children:"●"}),i.jsx("h2",{className:Se.envName,children:E.displayName||E.id}),i.jsx("span",{className:Se.statusBadge,style:{color:Q},children:E.status})]}),i.jsxs("div",{className:Se.envMeta,children:[i.jsxs("span",{className:Se.metaTag,children:["Adapter: ",E.adapterType]}),I.length>0&&i.jsxs("span",{className:Se.metaTag,children:[I.length," session",I.length!==1?"s":""]}),U>0&&i.jsxs("span",{className:Se.metaTag,children:["Cost: ",Ss(U)]})]})]}),i.jsxs("div",{className:Se.actions,children:[$&&i.jsxs(i.Fragment,{children:[i.jsx("button",{className:Se.btnPrimary,onClick:()=>s(Bx(E.id)),children:"New Chat"}),i.jsx("button",{className:Se.btnOutline,onClick:()=>{u(E.id).catch(()=>{})},children:"Stop"}),i.jsx("button",{className:Se.btnOutline,onClick:()=>C(!0),disabled:H!==void 0,"data-testid":"env-reprovision-btn",children:"Reprovision"})]}),pe&&i.jsx("button",{className:Se.btnPrimary,onClick:()=>{d(E.id).catch(()=>{})},children:E.status==="error"?"Retry":E.status==="sleeping"?"Wake":"Connect"}),W&&H!==void 0&&i.jsx("span",{className:Se.provisionMessage,children:H.message}),E.status==="error"&&(H==null?void 0:H.stage)==="error"&&i.jsx("span",{className:Se.errorMessage,children:H.message}),i.jsx("button",{className:Se.btnOutline,onClick:()=>s(sN(E.id)),"data-testid":"env-edit-btn",children:"Edit Config"}),i.jsx("button",{className:Se.btnDanger,onClick:()=>N(!0),children:"Delete"})]}),i.jsxs("div",{className:Se.section,children:[i.jsxs("div",{className:Se.sectionHeader,children:[i.jsx("h3",{children:"Workspaces"}),i.jsx("button",{className:Se.btnPrimary,onClick:()=>s(`${zx}?environment=${encodeURIComponent(E.id)}`),"data-testid":"workspace-create-button",children:"+ New Workspace"})]}),A.length===0&&i.jsx("p",{className:Se.empty,children:"No workspaces yet. Create one to get started."}),i.jsx("div",{className:Se.cardList,children:A.map(J=>i.jsx(xP,{workspace:J,confirmArchiveId:D,onOpen:()=>s($a(J.id,E.id)),onArchive:()=>B(J.id),onConfirmArchive:()=>Z(J.id),onCancelArchive:()=>B(void 0)},J.id))})]}),i.jsxs("div",{className:Se.section,children:[i.jsxs("div",{className:Se.sectionHeader,children:[i.jsx("h3",{children:"Linked Workspaces"}),(()=>{const J=m.filter(ce=>ce.environmentId!==E.id&&!ce.linkedEnvironmentIds.includes(E.id)&&ce.status==="active");return J.length===0?null:i.jsxs("select",{className:Se.btnPrimary,value:"",onChange:ce=>{ce.target.value&&v(ce.target.value,E.id).catch(()=>{})},"aria-label":"Link a workspace","data-testid":"link-workspace-select",children:[i.jsx("option",{value:"",children:"+ Link Workspace"}),J.map(ce=>i.jsx("option",{value:ce.id,children:ce.name},ce.id))]})})()]}),P.length===0&&i.jsx("p",{className:Se.empty,"data-testid":"linked-workspaces-empty",children:"No workspaces are linked to this environment."}),x&&i.jsxs("p",{className:Se.errorHint,"data-testid":"link-operation-error",role:"alert",children:[x,i.jsx("button",{className:Se.btnSmall,onClick:S,"aria-label":"Dismiss error","data-testid":"dismiss-link-error",children:"Dismiss"})]}),i.jsx("div",{className:Se.cardList,"data-testid":"linked-workspaces-list",children:P.map(J=>{var ce;return i.jsxs("div",{className:Se.card,"data-testid":`linked-workspace-card-${J.id}`,children:[i.jsxs("div",{className:Se.cardHeader,children:[i.jsx("strong",{className:Se.cardName,children:J.name}),i.jsxs("div",{className:Se.cardActions,children:[i.jsx("button",{className:Se.btnSmall,onClick:()=>s($a(J.id,J.environmentId)),children:"Open"}),i.jsx("button",{className:Se.btnSmall,onClick:()=>{b(J.id,E.id).catch(()=>{})},"data-testid":`unlink-workspace-${J.id}`,children:"Unlink"})]})]}),J.description&&i.jsx("p",{className:Se.cardDescription,children:J.description}),i.jsxs("div",{className:Se.cardMeta,children:["Primary: ",((ce=o.find(X=>X.id===J.environmentId))==null?void 0:ce.displayName)||J.environmentId]})]},J.id)})})]})]})}function xP({workspace:t,confirmArchiveId:s,onOpen:o,onArchive:r,onConfirmArchive:c,onCancelArchive:d}){const u=s===t.id,p=t.repoUrl&&/^https?:\/\//.test(t.repoUrl);return i.jsxs("div",{className:Se.card,"data-testid":"workspace-card",children:[i.jsxs("div",{className:Se.cardHeader,children:[i.jsx("strong",{className:Se.cardName,children:t.name}),i.jsxs("div",{className:Se.cardActions,children:[i.jsx("button",{className:Se.btnSmall,onClick:o,children:"Open"}),u?i.jsxs(i.Fragment,{children:[i.jsx("button",{className:Se.btnDanger,onClick:c,children:"Confirm"}),i.jsx("button",{className:Se.btnSmall,onClick:d,children:"Cancel"})]}):i.jsx("button",{className:Se.btnSmall,onClick:r,children:"Archive"})]})]}),t.description&&i.jsx("p",{className:Se.cardDescription,children:t.description}),t.repoUrl&&i.jsx("div",{className:Se.cardMeta,children:p?i.jsx("a",{href:t.repoUrl,target:"_blank",rel:"noopener noreferrer",className:Se.repoLink,children:t.repoUrl}):i.jsx("span",{children:t.repoUrl})})]})}const _P={credentials:"Credentials",personas:"Personas",appearance:"Appearance",about:"About",shortcuts:"Shortcuts"};function kP(){const s=Zt().pathname.replace(/^\/settings\/?/,"").split("/")[0],o=_P[s],r=g7(o);return i.jsxs("div",{className:Xr.layout,children:[i.jsx(Ns,{segments:r}),i.jsx("div",{className:Xr.content,children:i.jsx("div",{className:Xr.tabPanel,children:i.jsx(Va,{})},s)})]})}function SP(){const{tokens:{tokens:t,setToken:s,deleteToken:o},credentials:{credentialProviders:r,updateCredentialProviders:c}}=mt(),{showToast:d}=Sn();return i.jsxs(i.Fragment,{children:[i.jsx(LL,{credentialProviders:r,onUpdateCredentialProviders:u=>{c(u).catch(()=>{})}}),i.jsx(GO,{tokens:t,onSetToken:(u,p,m,g,v)=>{s(u,p,m,g,v).catch(()=>{})},onDeleteToken:u=>{o(u).catch(()=>{})},onShowToast:d})]})}function TP(){const{personas:{personas:t,deletePersona:s},appDefaultPersonaId:o,setAppDefaultPersonaId:r}=mt(),{showToast:c}=Sn(),d=kt();return i.jsx(JL,{personas:t,appDefaultPersonaId:o,onDeletePersona:async u=>{try{await s(u)}catch(p){throw console.error("Failed to delete persona",{personaId:u,error:p}),c("Failed to delete persona","error"),p}},onSetAppDefaultPersonaId:async u=>{try{await r(u)}catch(p){console.error("Failed to set app default persona ID",{personaId:u,error:p}),c("Failed to set app default persona","error")}},onNavigateToNew:()=>d(iN),onNavigateToPersona:u=>d(Lx(u))})}const wP="_container_1ooin_1",jP="_form_1ooin_7",NP="_formActions_1ooin_75",CP="_editableSection_1ooin_82",EP="_defaultBadge_1ooin_93",AP="_typeToggle_1ooin_107",DP="_scriptEditor_1ooin_121",RP="_optional_1ooin_128",ls={container:wP,form:jP,formActions:NP,editableSection:CP,defaultBadge:EP,typeToggle:AP,scriptEditor:DP,optional:RP},sx=[{value:"claude-code",label:"claude-code"},{value:"codex",label:"codex"},{value:"copilot",label:"copilot"},{value:"goose",label:"goose"},{value:"stub",label:"stub"},{value:"claude-code-acp",label:"claude-code-acp (experimental)"},{value:"codex-acp",label:"codex-acp (experimental)"},{value:"copilot-acp",label:"copilot-acp (experimental)"}],ax=[{value:"genaiscript",label:"genaiscript"}],MP="0";function ix(){const{personaId:t}=fs(),s=kt(),{showToast:o}=Sn(),{personas:{personas:r,createPersona:c,updatePersona:d,deletePersona:u},appDefaultPersonaId:p,setAppDefaultPersonaId:m}=mt(),g=t===void 0,v=g?void 0:r.find(x=>x.id===t);if(!g&&r.length>0&&!v)return i.jsx(ds,{to:qf,replace:!0});const b=[{label:"Settings",url:Do},{label:"Personas",url:qf},{label:g?"New Persona":(v==null?void 0:v.name)??"Persona",url:void 0}];return i.jsxs("div",{className:ls.container,children:[i.jsx(Ns,{segments:b}),i.jsx(IP,{existing:v,isNew:g,appDefaultPersonaId:p,onCreatePersona:c,onUpdatePersona:d,onDeletePersona:u,onSetAppDefaultPersonaId:m,onDone:()=>{s(qf)},showToast:o})]})}function IP({existing:t,isNew:s,appDefaultPersonaId:o,onCreatePersona:r,onUpdatePersona:c,onDeletePersona:d,onSetAppDefaultPersonaId:u,onDone:p,showToast:m}){const g=kt(),[v,b]=y.useState((t==null?void 0:t.name)??""),[x,S]=y.useState((t==null?void 0:t.description)??""),[k,w]=y.useState((t==null?void 0:t.systemPrompt)??""),[N,T]=y.useState((t==null?void 0:t.runtime)??"claude-code"),[C,D]=y.useState((t==null?void 0:t.model)??"sonnet"),[B,E]=y.useState((t==null?void 0:t.maxTurns)??0),[A,P]=y.useState((t==null?void 0:t.type)==="script"?"script":"agent"),[I,U]=y.useState((t==null?void 0:t.script)??""),[Q,$]=y.useState((t==null?void 0:t.allowedMcpTools)??[]),[W,pe]=y.useState(!1),[H,ie]=y.useState(null),[L,Z]=y.useState(!!s);y.useEffect(()=>{if(!s&&t&&!L){Z(!0),b(t.name),S(t.description),w(t.systemPrompt);const oe=t.type==="script"?"script":"agent";T(oe==="script"?t.runtime||"genaiscript":t.runtime),D(t.model),E(t.maxTurns),P(oe),U(t.script||""),$(t.allowedMcpTools)}},[s,t,L]);const J=oe=>{P(oe),oe==="script"?T("genaiscript"):N==="genaiscript"&&T("claude-code")},ce=!s&&t===void 0,X=v.trim().length>0&&!ce&&k.trim().length>0&&(A==="script"?I.trim().length>0:!!N&&!!C),ge=s&&X,fe=!s&&o===(t==null?void 0:t.id),Ce=!s&&t&&!fe&&A==="agent"&&!!N&&!!C,Ze=(oe,Ve)=>{if(!oe.trim())return`${Ve} is required`},me=oe=>{if(oe.preventDefault(),!(ce||!X)){if(t){c(t.id,v,x,k,N,C,B,A,I).then(()=>{m("Persona updated","success"),p()},()=>{m("Failed to save persona","error")});return}r(v,x,k,N,C,B,A,I,Q).then(Ve=>{m("Persona created","success"),g(Lx(Ve.id),{replace:!0})},()=>{m("Failed to save persona","error")})}},_e=()=>{t&&d(t.id).then(()=>{m("Persona deleted","success"),p()},()=>{m("Failed to delete persona","error")})},ve=async(oe,Ve,qt,te)=>oe().then(()=>{Ve(),m(qt,"success")},()=>{m(te,"error")}),Le=(oe,Ve)=>{if(!t)return;const qt=oe==="type"?String(Ve):A,te=oe==="runtime"?String(Ve):oe==="type"?String(Ve)==="script"?"genaiscript":N==="genaiscript"?"claude-code":N:N,ht=oe==="model"?String(Ve):C,at=oe==="maxTurns"?Number(Ve):B,Kt=oe==="systemPrompt"?String(Ve):k,gt=oe==="script"?String(Ve):I;ve(()=>c(t.id,oe==="name"?String(Ve):v,oe==="description"?String(Ve):x,Kt,te,ht,at,qt,gt),()=>{if(oe==="type"){const ps=String(Ve)==="script"?"script":"agent";P(ps),T(te)}oe==="runtime"&&T(String(Ve)),oe==="name"&&b(String(Ve)),oe==="description"&&S(String(Ve)),oe==="systemPrompt"&&w(String(Ve)),oe==="model"&&D(String(Ve)),oe==="maxTurns"&&E(Number(Ve)),oe==="script"&&U(String(Ve))},"Persona updated","Failed to update persona").catch(()=>{})},Mt=oe=>{me(oe)},Tn=()=>{t&&u(t.id).then(()=>{m("Set as app default","success")},()=>{m("Failed to set app default","error")})};return i.jsxs(i.Fragment,{children:[ce?i.jsxs("div",{className:ls.form,children:[i.jsx("h3",{children:"Edit Persona"}),i.jsx("p",{children:"Loading persona..."})]}):s?i.jsxs("form",{onSubmit:Mt,className:ls.form,children:[i.jsx("h3",{children:"Create Persona"}),i.jsxs("div",{className:ls.typeToggle,"data-testid":"persona-type-toggle",children:[i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:"personaType",value:"agent",checked:A==="agent",onChange:()=>J("agent")}),"Agent"]}),i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:"personaType",value:"script",checked:A==="script",onChange:()=>J("script")}),"Script"]})]}),i.jsxs("label",{children:["Name",i.jsx("input",{type:"text",value:v,onChange:oe=>b(oe.target.value),placeholder:A==="script"?"e.g. Nightly Report":"e.g. Frontend Engineer",required:!0,"data-testid":"persona-detail-name"})]}),i.jsxs("label",{children:["Description",i.jsx("input",{type:"text",value:x,onChange:oe=>S(oe.target.value),placeholder:"Brief description...","data-testid":"persona-detail-description"})]}),i.jsxs("label",{children:["Runtime",i.jsx("select",{value:N,onChange:oe=>T(oe.target.value),"data-testid":"persona-runtime-select",children:(A==="script"?ax:sx).map(oe=>i.jsx("option",{value:oe.value,children:oe.label},oe.value))})]}),A==="agent"&&i.jsxs(i.Fragment,{children:[i.jsxs("label",{children:["Model",i.jsx("input",{type:"text",value:C,onChange:oe=>D(oe.target.value),placeholder:"e.g. sonnet","data-testid":"persona-detail-model"})]}),i.jsxs("label",{children:["Max Turns",i.jsx("input",{type:"number",value:B,onChange:oe=>E(parseInt(oe.target.value,10)||0),min:0,"data-testid":"persona-detail-max-turns"})]}),i.jsxs("label",{children:["System Prompt",i.jsx("textarea",{value:k,onChange:oe=>w(oe.target.value),placeholder:"You are a senior frontend engineer...",rows:10,required:!0,"data-testid":"persona-detail-prompt"})]})]}),A==="script"&&i.jsxs(i.Fragment,{children:[i.jsxs("label",{children:["Model ",i.jsx("span",{className:ls.optional,children:"(optional)"}),i.jsx("input",{type:"text",value:C,onChange:oe=>D(oe.target.value),placeholder:"e.g. sonnet (leave empty for script-only)","data-testid":"persona-detail-model"})]}),i.jsxs("label",{children:["System Prompt",i.jsx("textarea",{value:k,onChange:oe=>w(oe.target.value),placeholder:"Context for the script...",rows:4,required:!0,"data-testid":"persona-detail-prompt"})]}),i.jsxs("label",{children:["Script",i.jsx("textarea",{value:I,onChange:oe=>U(oe.target.value),placeholder:`script({ model: "openai:gpt-4o" });
|
|
702
702
|
|
|
703
703
|
const grackle = await host.mcpServer({
|
|
704
704
|
id: "grackle",
|
|
@@ -712,4 +712,4 @@ const grackle = await host.mcpServer({
|
|
|
712
712
|
url: env.vars.GRACKLE_MCP_URL,
|
|
713
713
|
});
|
|
714
714
|
|
|
715
|
-
$\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),A==="agent"&&i.jsxs("div",{children:[i.jsx("label",{children:"Allowed MCP Tools"}),i.jsx(Fb,{selectedTools:Q,onChange:oe=>{$(oe),ve(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,oe),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!Ce&&!fe&&i.jsx("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--text-tertiary)",marginTop:"var(--space-xs)"},children:"Only agent personas with a runtime and model can be set as app default."})]}):null,i.jsx(Ci,{isOpen:W,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:_e,onCancel:()=>pe(!1)})]})}function OP(){const{themeId:t,resolvedThemeId:s,setTheme:o,preferSystem:r,setPreferSystem:c}=B1();return i.jsx(FO,{themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c})}function BP(){const[t,s]=y.useState(void 0);return y.useEffect(()=>{let o=!1;return(async()=>{try{const c=await Ne.getVersionStatus({});o||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{o=!0}},[]),t}function LP(){const{connected:t,environments:{environments:s},sessions:{sessions:o}}=mt(),r=BP();return i.jsxs(i.Fragment,{children:[r&&i.jsx(JI,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),i.jsx(ZO,{connected:t,environments:s,sessions:o})]})}function zP(){return i.jsx(OL,{})}const ox=Di();function $P(){const t=kt();return Qs({key:"?"},()=>{t(oN)}),Qs({key:"n"},()=>{t(ox)}),Qs({key:"N"},()=>{t(ox)}),i.jsx(i.Fragment,{})}function hl(t){const s=u7();y.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function UP(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=mt(),o=y.useMemo(()=>i.jsx(jI,{workspaces:t,tasks:s}),[t,s]);return hl(o),i.jsx(Va,{})}function PP(){const{environments:{environments:t}}=mt(),s=y.useMemo(()=>i.jsx(B5,{environments:t}),[t]);return hl(s),i.jsx(Va,{})}function HP(){const t=y.useMemo(()=>i.jsx(v8,{}),[]);return hl(t),i.jsx(Va,{})}function VP(){const{findings:{findings:t,loadFindings:s,loadAllFindings:o}}=mt(),{workspaceId:r,environmentId:c}=fs();y.useEffect(()=>{r?s(r).catch(()=>{}):o().catch(()=>{})},[r,s,o]);const d=y.useMemo(()=>i.jsx(Z5,{findings:t,workspaceId:r,environmentId:c}),[t,r,c]);return hl(d),i.jsx(Va,{})}function qP(){const{knowledge:t,workspaces:{workspaces:s}}=mt(),o=y.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=y.useCallback(()=>{t.clearSearch()},[t]),c=y.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=y.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=y.useMemo(()=>i.jsx(Y6,{nodes:t.graphData.nodes,workspaces:s,loading:t.loading,searchQuery:t.searchQuery,onSearch:o,onClearSearch:r,onSelectNode:c,onWorkspaceChange:d}),[t,s,o,r,c,d]);return hl(u),i.jsx(Va,{})}const GP="_container_ce571_1",FP="_title_ce571_6",md={container:GP,title:FP};function ZP(){return i.jsxs("div",{className:md.container,"aria-hidden":"true",children:[i.jsx("h1",{className:md.title,children:"Findings"}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:Array.from({length:4},(t,s)=>i.jsx(dd,{lines:3},s))})]})}function rx(){const{environmentId:t,workspaceId:s}=fs(),{findings:{findings:o,findingsLoading:r,loadFindings:c},workspaces:{workspaces:d},environments:{environments:u}}=mt(),p=kt();y.useEffect(()=>{s&&c(s).catch(()=>{})},[s,c]);const m=y.useCallback(v=>{p(Mp(v,s,t))},[p,s,t]);if(r)return i.jsx(ZP,{});const g=s&&t?V1("Findings",s,t,d,u).slice(0,-1):S7();return i.jsxs("div",{className:md.container,"data-testid":"findings-list-page",children:[i.jsx(Ns,{segments:g}),i.jsx("h1",{className:md.title,children:"Findings"}),i.jsx(N1,{findings:o,onFindingClick:m})]})}const KP="_container_1wwpb_1",YP="_notFound_1wwpb_6",JP="_header_1wwpb_12",WP="_categoryBadge_1wwpb_19",XP="_title_1wwpb_28",QP="_content_1wwpb_35",e9="_tags_1wwpb_77",t9="_tag_1wwpb_77",n9="_meta_1wwpb_92",s9="_metaTimestamp_1wwpb_100",a9="_metaLink_1wwpb_105",mn={container:KP,notFound:YP,header:JP,categoryBadge:WP,title:XP,content:QP,tags:e9,tag:t9,meta:n9,metaTimestamp:s9,metaLink:a9};function lx(){const{findingId:t,environmentId:s,workspaceId:o}=fs(),{findings:{selectedFinding:r,findingLoading:c,loadFinding:d},workspaces:{workspaces:u},environments:{environments:p}}=mt(),m=kt();if(y.useEffect(()=>{t&&d(t).catch(()=>{})},[t,d]),c)return i.jsx("div",{className:mn.container,"data-testid":"finding-detail-page",children:i.jsx("div",{className:mn.notFound,children:"Loading..."})});if(!r)return i.jsx("div",{className:mn.container,"data-testid":"finding-detail-page",children:i.jsx("div",{className:mn.notFound,children:"Finding not found."})});const g=V1(r.title,o,s,u,p),v=fd(r.category);return i.jsxs("div",{className:mn.container,"data-testid":"finding-detail-page",children:[i.jsx(Ns,{segments:g}),i.jsxs("div",{className:mn.header,children:[i.jsx("span",{className:mn.categoryBadge,style:{background:v.bg,color:v.text},children:r.category}),i.jsx("h1",{className:mn.title,children:r.title})]}),r.content&&i.jsx("div",{className:mn.content,children:i.jsx(hd,{remarkPlugins:[gd],children:r.content})}),r.tags.length>0&&i.jsx("div",{className:mn.tags,children:r.tags.map(b=>i.jsx("span",{className:mn.tag,children:b},b))}),i.jsxs("div",{className:mn.meta,children:[i.jsx("span",{className:mn.metaTimestamp,title:r.createdAt,children:eh(r.createdAt)}),r.taskId&&i.jsx("button",{type:"button",className:mn.metaLink,onClick:()=>{m(On(r.taskId))},children:"View Task"}),r.sessionId&&i.jsx("button",{type:"button",className:mn.metaLink,onClick:()=>{m(gm(r.sessionId))},children:"View Session"})]})]})}const i9="_wizard_1260s_1",o9="_container_1260s_10",r9="_stepContent_1260s_19",l9="_logoArea_1260s_28",c9="_logoImage_1260s_32",d9="_heading_1260s_41",u9="_tagline_1260s_49",f9="_subtitle_1260s_56",p9="_featureList_1260s_64",m9="_runtimeGrid_1260s_89",h9="_runtimeCard_1260s_101",g9="_runtimeName_1260s_133",v9="_runtimeDescription_1260s_139",y9="_buttonRow_1260s_144",b9="_primaryButton_1260s_151",x9="_ghostButton_1260s_185",_9="_dots_1260s_213",k9="_dot_1260s_213",Fe={wizard:i9,container:o9,stepContent:r9,logoArea:l9,logoImage:c9,heading:d9,tagline:u9,subtitle:f9,featureList:p9,runtimeGrid:m9,runtimeCard:h9,runtimeName:g9,runtimeDescription:v9,buttonRow:y9,primaryButton:b9,ghostButton:x9,dots:_9,dot:k9};function S9({onNext:t}){return i.jsxs("div",{className:Fe.stepContent,"data-testid":"setup-welcome",children:[i.jsx("div",{className:Fe.logoArea,children:i.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:Fe.logoImage})}),i.jsx("h1",{className:Fe.heading,children:"Welcome to Grackle"}),i.jsx("p",{className:Fe.tagline,children:"Multi-agent orchestration for software teams"}),i.jsx("button",{type:"button",className:Fe.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function T9({onNext:t,onBack:s}){return i.jsxs("div",{className:Fe.stepContent,"data-testid":"setup-about",children:[i.jsx("h2",{className:Fe.heading,children:"What is Grackle?"}),i.jsxs("ul",{className:Fe.featureList,children:[i.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),i.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),i.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),i.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),i.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),i.jsxs("div",{className:Fe.buttonRow,children:[i.jsx("button",{type:"button",className:Fe.ghostButton,onClick:s,children:"Back"}),i.jsx("button",{type:"button",className:Fe.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const w9=[{id:"claude-code",name:"Claude Code",description:"Anthropic's agentic coding tool"},{id:"copilot",name:"Copilot Coding Agent",description:"GitHub's AI pair programmer"},{id:"codex",name:"Codex CLI",description:"OpenAI's coding agent"},{id:"goose",name:"Goose",description:"Block's open-source AI coding agent"}];function j9({currentRuntime:t,onFinish:s,onBack:o,finishDisabled:r}){const[c,d]=y.useState(t||"claude-code");return y.useEffect(()=>{t&&d(t)},[t]),i.jsxs("div",{className:Fe.stepContent,"data-testid":"setup-runtime",children:[i.jsx("h2",{className:Fe.heading,children:"Choose Your Runtime"}),i.jsx("p",{className:Fe.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),i.jsx("div",{className:Fe.runtimeGrid,children:w9.map(u=>i.jsxs("button",{type:"button",className:Fe.runtimeCard,"data-selected":c===u.id,"aria-pressed":c===u.id,"data-testid":`runtime-card-${u.id}`,onClick:()=>d(u.id),children:[i.jsx("span",{className:Fe.runtimeName,children:u.name}),i.jsx("span",{className:Fe.runtimeDescription,children:u.description})]},u.id))}),i.jsxs("div",{className:Fe.buttonRow,children:[i.jsx("button",{type:"button",className:Fe.ghostButton,onClick:o,children:"Back"}),i.jsx("button",{type:"button",className:Fe.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function N9(){return typeof Notification<"u"}function C9({onFinish:t,onBack:s,finishDisabled:o}){const r=N9(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return i.jsxs("div",{className:Fe.stepContent,"data-testid":"setup-notifications",children:[i.jsx("h2",{className:Fe.heading,children:"Stay in the Loop"}),i.jsx("p",{className:Fe.subtitle,children:"Grackle can send you a browser notification when an agent needs your input, so you never miss an important moment."}),c?i.jsx("p",{className:Fe.subtitle,children:Notification.permission==="granted"?"Notifications are already enabled.":"Notifications have been blocked. You can change this in your browser settings."}):null,i.jsxs("div",{className:Fe.buttonRow,children:[i.jsx("button",{type:"button",className:Fe.ghostButton,onClick:s,disabled:o,children:"Back"}),!c&&r?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:Fe.ghostButton,onClick:t,disabled:o,"data-testid":"setup-notifications-skip",children:"Skip"}),i.jsx("button",{type:"button",className:Fe.primaryButton,onClick:d,disabled:o,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):i.jsx("button",{type:"button",className:Fe.primaryButton,onClick:t,disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const E9=4,cx={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function A9(){const{personas:{personas:t,updatePersona:s},completeOnboarding:o,onboardingCompleted:r}=mt(),{showToast:c}=Sn(),d=kt(),[u,p]=y.useState(0),[m,g]=y.useState("claude-code"),[v,b]=y.useState(!1),x=t.find(w=>w.id==="claude-code"),S=y.useCallback(w=>{g(w),p(3)},[]),k=y.useCallback(()=>{const w=m;b(!0);const N=[];if(x&&w!==x.runtime){const C=cx[w]??"sonnet";N.push(s(x.id,void 0,void 0,void 0,w,C))}const T=t.find(C=>C.id===Q0);if(T&&w!==T.runtime){const C=cx[w]??"sonnet";N.push(s(Q0,void 0,void 0,void 0,w,C))}Promise.all(N).then(()=>o()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),b(!1)})},[m,x,t,s,o,d,c]);return r===!0?i.jsx(ds,{to:"/",replace:!0}):i.jsx("div",{className:Fe.wizard,"data-testid":"setup-wizard",children:i.jsxs("div",{className:Fe.container,children:[i.jsx(us,{mode:"wait",children:i.jsxs(Rt.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&i.jsx(S9,{onNext:()=>p(1)}),u===1&&i.jsx(T9,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&i.jsx(j9,{currentRuntime:m,onFinish:S,onBack:()=>p(1),finishDisabled:!x}),u===3&&i.jsx(C9,{onFinish:k,onBack:()=>p(2),finishDisabled:v})]},u)}),i.jsx("div",{className:Fe.dots,children:Array.from({length:E9},(w,N)=>i.jsx("span",{className:Fe.dot,"data-active":N===u},N))})]})})}const D9="_root_zndgp_1",R9="_body_zndgp_7",M9="_main_zndgp_19",I9="_sidebarWrapper_zndgp_26",O9="_overlay_zndgp_51",Fr={root:D9,body:R9,main:M9,sidebarWrapper:I9,overlay:O9},B9=y.lazy(()=>OT(()=>import("./KnowledgePage-DdmfoRgM.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.KnowledgePage}))),Z1=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function L9({tabs:t}){const{connected:s,environments:{environments:o},sessions:{sessions:r},tasks:{tasks:c}}=mt(),{toasts:d,dismissToast:u}=Sn(),p=Zt(),m=d7(),g=m!==void 0,[v,b]=y.useState(!1),x=y.useCallback(()=>b(S=>!S),[]);return y.useEffect(()=>{b(!1)},[p.pathname]),y.useEffect(()=>{if(!v)return;const S=k=>{k.key==="Escape"&&b(!1)};return document.addEventListener("keydown",S),()=>{document.removeEventListener("keydown",S)}},[v]),i.jsxs(i.Fragment,{children:[i.jsx(i5,{connected:s,environments:o,sessions:r,onToggleSidebar:g?x:void 0,sidebarOpen:v}),i.jsx(f5,{tabs:t}),i.jsxs("div",{className:Fr.body,children:[g&&i.jsx("div",{className:Fr.sidebarWrapper,"data-sidebar-open":v,children:i.jsx(y5,{content:m})}),g&&v&&i.jsx("div",{className:Fr.overlay,"data-testid":"drawer-overlay",onClick:()=>b(!1)}),i.jsxs("div",{className:Fr.main,children:[i.jsx(Va,{}),i.jsx(j5,{sessions:r,tasks:c,environments:o})]})]}),i.jsx($I,{toasts:d,onDismiss:u}),i.jsx($P,{})]})}function z9(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:o,clearOperationError:r},tasks:{tasks:c},connected:d,onboardingCompleted:u}=mt(),{pluginNames:p}=ih(),{showToast:m}=Sn();hz(s,m),xz(c,m),gz(o,r,m);const g=kt(),v=Zt();if(y.useEffect(()=>{t&&!v.pathname.includes("/tasks/")&&g(gm(t),{replace:!0})},[t,g,v.pathname]),d&&u===!1)return i.jsx(ds,{to:"/setup",replace:!0});const b=G7(p);return i.jsx(c7,{children:i.jsxs("div",{className:Fr.root,children:[Z1&&i.jsx(BN,{}),i.jsx(L9,{tabs:b})]})})}function Cp(){const{workspaceId:t}=fs(),{workspaces:{workspaces:s}}=mt(),o=Zt(),r=s.find(m=>m.id===t);if(!(r!=null&&r.environmentId))return s.length===0?void 0:i.jsx(ds,{to:"/environments",replace:!0});const c=encodeURIComponent(t),d=`/workspaces/${c}`,u=o.pathname.startsWith(d)?o.pathname.slice(d.length):"",p=`/environments/${encodeURIComponent(r.environmentId)}/workspaces/${c}${u}${o.search}${o.hash}`;return i.jsx(ds,{to:p,replace:!0})}function $9(){const{pluginNames:t}=ih(),s=t.includes("orchestration"),o=t.includes("knowledge");return i.jsxs(_j,{children:[i.jsx(Ae,{path:"setup",element:i.jsx(A9,{})}),i.jsxs(Ae,{element:i.jsx(z9,{}),children:[i.jsx(Ae,{index:!0,element:i.jsx(oU,{})}),i.jsx(Ae,{path:"chat",element:i.jsx(gU,{})}),i.jsx(Ae,{path:"sessions/new",element:i.jsx(vU,{})}),i.jsx(Ae,{path:"sessions/:sessionId",element:i.jsx(_U,{})}),o&&i.jsx(Ae,{element:i.jsx(qP,{}),children:i.jsx(Ae,{path:"knowledge",element:i.jsx(y.Suspense,{fallback:i.jsx(v1,{}),children:i.jsx(B9,{})})})}),s&&i.jsxs(Ae,{element:i.jsx(UP,{}),children:[i.jsx(Ae,{path:"tasks",element:i.jsx(aU,{})}),i.jsx(Ae,{path:"tasks/new",element:i.jsx(nx,{})}),i.jsx(Ae,{path:"tasks/:taskId",element:i.jsx(Ia,{})}),i.jsx(Ae,{path:"tasks/:taskId/edit",element:i.jsx(Ia,{})}),i.jsx(Ae,{path:"tasks/:taskId/stream",element:i.jsx(Ia,{})}),i.jsx(Ae,{path:"tasks/:taskId/findings",element:i.jsx(Ia,{})})]}),s&&i.jsxs(Ae,{element:i.jsx(VP,{}),children:[i.jsx(Ae,{path:"findings",element:i.jsx(rx,{})}),i.jsx(Ae,{path:"findings/:findingId",element:i.jsx(lx,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/findings",element:i.jsx(rx,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/findings/:findingId",element:i.jsx(lx,{})})]}),i.jsxs(Ae,{element:i.jsx(PP,{}),children:[i.jsx(Ae,{path:"workspaces",element:i.jsx(ds,{to:"/environments",replace:!0})}),i.jsx(Ae,{path:"workspaces/new",element:i.jsx(BU,{})}),i.jsx(Ae,{path:"workspaces/:workspaceId",element:i.jsx(Cp,{})}),i.jsx(Ae,{path:"workspaces/:workspaceId/tasks/:taskId",element:i.jsx(Cp,{})}),i.jsx(Ae,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:i.jsx(Cp,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId",element:i.jsx(wU,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:i.jsx(nx,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:i.jsx(Ia,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:i.jsx(Ia,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:i.jsx(Ia,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings",element:i.jsx(Ia,{})}),i.jsxs(Ae,{path:"environments",element:i.jsx(VU,{}),children:[i.jsx(Ae,{index:!0,element:i.jsx(iU,{})}),i.jsx(Ae,{path:"new",element:i.jsx(zU,{})}),i.jsx(Ae,{path:":environmentId",element:i.jsx(bP,{})}),i.jsx(Ae,{path:":environmentId/edit",element:i.jsx($U,{})})]})]}),i.jsx(Ae,{element:i.jsx(HP,{}),children:i.jsxs(Ae,{path:"settings",element:i.jsx(kP,{}),children:[i.jsx(Ae,{index:!0,element:i.jsx(ds,{to:"credentials",replace:!0})}),i.jsx(Ae,{path:"environments",element:i.jsx(ds,{to:"/environments",replace:!0})}),i.jsx(Ae,{path:"credentials",element:i.jsx(SP,{})}),i.jsx(Ae,{path:"tokens",element:i.jsx(ds,{to:"../credentials",replace:!0})}),i.jsx(Ae,{path:"personas",element:i.jsx(TP,{})}),i.jsx(Ae,{path:"personas/new",element:i.jsx(ix,{})}),i.jsx(Ae,{path:"personas/:personaId",element:i.jsx(ix,{})}),i.jsx(Ae,{path:"appearance",element:i.jsx(OP,{})}),i.jsx(Ae,{path:"shortcuts",element:i.jsx(zP,{})}),i.jsx(Ae,{path:"about",element:i.jsx(LP,{})})]})}),i.jsx(Ae,{path:"*",element:i.jsx(ds,{to:"/",replace:!0})})]})]})}const U9=1e4;function P9(){const{onboardingCompleted:t}=mt(),[s,o]=y.useState(!1);y.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>o(!0),U9);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return i.jsx(us,{mode:"wait",children:r?i.jsx(Rt.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:i.jsx(v1,{})},"splash"):i.jsx(Rt.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:i.jsx(Fj,{basename:"/".replace(/\/$/,""),children:i.jsx($9,{})})},"app")})}function H9(){const t=Z1?z7:mz;return i.jsx(P7,{children:i.jsx(l7,{children:i.jsx(a7,{children:i.jsx(t,{children:i.jsx(P9,{})})})})})}RT.createRoot(document.getElementById("root")).render(i.jsx(y.StrictMode,{children:i.jsx(H9,{})}));export{Ns as B,$x as K,mt as a,Mp as f,gm as s,On as t,kt as u};
|
|
715
|
+
$\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),A==="agent"&&i.jsxs("div",{children:[i.jsx("label",{children:"Allowed MCP Tools"}),i.jsx(Fb,{selectedTools:Q,onChange:oe=>{$(oe),ve(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,oe),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!Ce&&!fe&&i.jsx("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--text-tertiary)",marginTop:"var(--space-xs)"},children:"Only agent personas with a runtime and model can be set as app default."})]}):null,i.jsx(Ci,{isOpen:W,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:_e,onCancel:()=>pe(!1)})]})}function OP(){const{themeId:t,resolvedThemeId:s,setTheme:o,preferSystem:r,setPreferSystem:c}=B1();return i.jsx(FO,{themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c})}function BP(){const[t,s]=y.useState(void 0);return y.useEffect(()=>{let o=!1;return(async()=>{try{const c=await Ne.getVersionStatus({});o||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{o=!0}},[]),t}function LP(){const{connected:t,environments:{environments:s},sessions:{sessions:o}}=mt(),r=BP();return i.jsxs(i.Fragment,{children:[r&&i.jsx(JI,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),i.jsx(ZO,{connected:t,environments:s,sessions:o})]})}function zP(){return i.jsx(OL,{})}const ox=Di();function $P(){const t=kt();return Qs({key:"?"},()=>{t(oN)}),Qs({key:"n"},()=>{t(ox)}),Qs({key:"N"},()=>{t(ox)}),i.jsx(i.Fragment,{})}function hl(t){const s=u7();y.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function UP(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=mt(),o=y.useMemo(()=>i.jsx(jI,{workspaces:t,tasks:s}),[t,s]);return hl(o),i.jsx(Va,{})}function PP(){const{environments:{environments:t}}=mt(),s=y.useMemo(()=>i.jsx(B5,{environments:t}),[t]);return hl(s),i.jsx(Va,{})}function HP(){const t=y.useMemo(()=>i.jsx(v8,{}),[]);return hl(t),i.jsx(Va,{})}function VP(){const{findings:{findings:t,loadFindings:s,loadAllFindings:o}}=mt(),{workspaceId:r,environmentId:c}=fs();y.useEffect(()=>{r?s(r).catch(()=>{}):o().catch(()=>{})},[r,s,o]);const d=y.useMemo(()=>i.jsx(Z5,{findings:t,workspaceId:r,environmentId:c}),[t,r,c]);return hl(d),i.jsx(Va,{})}function qP(){const{knowledge:t,workspaces:{workspaces:s}}=mt(),o=y.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=y.useCallback(()=>{t.clearSearch()},[t]),c=y.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=y.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=y.useMemo(()=>i.jsx(Y6,{nodes:t.graphData.nodes,workspaces:s,loading:t.loading,searchQuery:t.searchQuery,onSearch:o,onClearSearch:r,onSelectNode:c,onWorkspaceChange:d}),[t,s,o,r,c,d]);return hl(u),i.jsx(Va,{})}const GP="_container_ce571_1",FP="_title_ce571_6",md={container:GP,title:FP};function ZP(){return i.jsxs("div",{className:md.container,"aria-hidden":"true",children:[i.jsx("h1",{className:md.title,children:"Findings"}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:Array.from({length:4},(t,s)=>i.jsx(dd,{lines:3},s))})]})}function rx(){const{environmentId:t,workspaceId:s}=fs(),{findings:{findings:o,findingsLoading:r,loadFindings:c},workspaces:{workspaces:d},environments:{environments:u}}=mt(),p=kt();y.useEffect(()=>{s&&c(s).catch(()=>{})},[s,c]);const m=y.useCallback(v=>{p(Mp(v,s,t))},[p,s,t]);if(r)return i.jsx(ZP,{});const g=s&&t?V1("Findings",s,t,d,u).slice(0,-1):S7();return i.jsxs("div",{className:md.container,"data-testid":"findings-list-page",children:[i.jsx(Ns,{segments:g}),i.jsx("h1",{className:md.title,children:"Findings"}),i.jsx(N1,{findings:o,onFindingClick:m})]})}const KP="_container_1wwpb_1",YP="_notFound_1wwpb_6",JP="_header_1wwpb_12",WP="_categoryBadge_1wwpb_19",XP="_title_1wwpb_28",QP="_content_1wwpb_35",e9="_tags_1wwpb_77",t9="_tag_1wwpb_77",n9="_meta_1wwpb_92",s9="_metaTimestamp_1wwpb_100",a9="_metaLink_1wwpb_105",mn={container:KP,notFound:YP,header:JP,categoryBadge:WP,title:XP,content:QP,tags:e9,tag:t9,meta:n9,metaTimestamp:s9,metaLink:a9};function lx(){const{findingId:t,environmentId:s,workspaceId:o}=fs(),{findings:{selectedFinding:r,findingLoading:c,loadFinding:d},workspaces:{workspaces:u},environments:{environments:p}}=mt(),m=kt();if(y.useEffect(()=>{t&&d(t).catch(()=>{})},[t,d]),c)return i.jsx("div",{className:mn.container,"data-testid":"finding-detail-page",children:i.jsx("div",{className:mn.notFound,children:"Loading..."})});if(!r)return i.jsx("div",{className:mn.container,"data-testid":"finding-detail-page",children:i.jsx("div",{className:mn.notFound,children:"Finding not found."})});const g=V1(r.title,o,s,u,p),v=fd(r.category);return i.jsxs("div",{className:mn.container,"data-testid":"finding-detail-page",children:[i.jsx(Ns,{segments:g}),i.jsxs("div",{className:mn.header,children:[i.jsx("span",{className:mn.categoryBadge,style:{background:v.bg,color:v.text},children:r.category}),i.jsx("h1",{className:mn.title,children:r.title})]}),r.content&&i.jsx("div",{className:mn.content,children:i.jsx(hd,{remarkPlugins:[gd],children:r.content})}),r.tags.length>0&&i.jsx("div",{className:mn.tags,children:r.tags.map(b=>i.jsx("span",{className:mn.tag,children:b},b))}),i.jsxs("div",{className:mn.meta,children:[i.jsx("span",{className:mn.metaTimestamp,title:r.createdAt,children:eh(r.createdAt)}),r.taskId&&i.jsx("button",{type:"button",className:mn.metaLink,onClick:()=>{m(On(r.taskId))},children:"View Task"}),r.sessionId&&i.jsx("button",{type:"button",className:mn.metaLink,onClick:()=>{m(gm(r.sessionId))},children:"View Session"})]})]})}const i9="_wizard_1260s_1",o9="_container_1260s_10",r9="_stepContent_1260s_19",l9="_logoArea_1260s_28",c9="_logoImage_1260s_32",d9="_heading_1260s_41",u9="_tagline_1260s_49",f9="_subtitle_1260s_56",p9="_featureList_1260s_64",m9="_runtimeGrid_1260s_89",h9="_runtimeCard_1260s_101",g9="_runtimeName_1260s_133",v9="_runtimeDescription_1260s_139",y9="_buttonRow_1260s_144",b9="_primaryButton_1260s_151",x9="_ghostButton_1260s_185",_9="_dots_1260s_213",k9="_dot_1260s_213",Fe={wizard:i9,container:o9,stepContent:r9,logoArea:l9,logoImage:c9,heading:d9,tagline:u9,subtitle:f9,featureList:p9,runtimeGrid:m9,runtimeCard:h9,runtimeName:g9,runtimeDescription:v9,buttonRow:y9,primaryButton:b9,ghostButton:x9,dots:_9,dot:k9};function S9({onNext:t}){return i.jsxs("div",{className:Fe.stepContent,"data-testid":"setup-welcome",children:[i.jsx("div",{className:Fe.logoArea,children:i.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:Fe.logoImage})}),i.jsx("h1",{className:Fe.heading,children:"Welcome to Grackle"}),i.jsx("p",{className:Fe.tagline,children:"Multi-agent orchestration for software teams"}),i.jsx("button",{type:"button",className:Fe.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function T9({onNext:t,onBack:s}){return i.jsxs("div",{className:Fe.stepContent,"data-testid":"setup-about",children:[i.jsx("h2",{className:Fe.heading,children:"What is Grackle?"}),i.jsxs("ul",{className:Fe.featureList,children:[i.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),i.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),i.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),i.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),i.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),i.jsxs("div",{className:Fe.buttonRow,children:[i.jsx("button",{type:"button",className:Fe.ghostButton,onClick:s,children:"Back"}),i.jsx("button",{type:"button",className:Fe.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const w9=[{id:"claude-code",name:"Claude Code",description:"Anthropic's agentic coding tool"},{id:"copilot",name:"Copilot Coding Agent",description:"GitHub's AI pair programmer"},{id:"codex",name:"Codex CLI",description:"OpenAI's coding agent"},{id:"goose",name:"Goose",description:"Block's open-source AI coding agent"}];function j9({currentRuntime:t,onFinish:s,onBack:o,finishDisabled:r}){const[c,d]=y.useState(t||"claude-code");return y.useEffect(()=>{t&&d(t)},[t]),i.jsxs("div",{className:Fe.stepContent,"data-testid":"setup-runtime",children:[i.jsx("h2",{className:Fe.heading,children:"Choose Your Runtime"}),i.jsx("p",{className:Fe.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),i.jsx("div",{className:Fe.runtimeGrid,children:w9.map(u=>i.jsxs("button",{type:"button",className:Fe.runtimeCard,"data-selected":c===u.id,"aria-pressed":c===u.id,"data-testid":`runtime-card-${u.id}`,onClick:()=>d(u.id),children:[i.jsx("span",{className:Fe.runtimeName,children:u.name}),i.jsx("span",{className:Fe.runtimeDescription,children:u.description})]},u.id))}),i.jsxs("div",{className:Fe.buttonRow,children:[i.jsx("button",{type:"button",className:Fe.ghostButton,onClick:o,children:"Back"}),i.jsx("button",{type:"button",className:Fe.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function N9(){return typeof Notification<"u"}function C9({onFinish:t,onBack:s,finishDisabled:o}){const r=N9(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return i.jsxs("div",{className:Fe.stepContent,"data-testid":"setup-notifications",children:[i.jsx("h2",{className:Fe.heading,children:"Stay in the Loop"}),i.jsx("p",{className:Fe.subtitle,children:"Grackle can send you a browser notification when an agent needs your input, so you never miss an important moment."}),c?i.jsx("p",{className:Fe.subtitle,children:Notification.permission==="granted"?"Notifications are already enabled.":"Notifications have been blocked. You can change this in your browser settings."}):null,i.jsxs("div",{className:Fe.buttonRow,children:[i.jsx("button",{type:"button",className:Fe.ghostButton,onClick:s,disabled:o,children:"Back"}),!c&&r?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:Fe.ghostButton,onClick:t,disabled:o,"data-testid":"setup-notifications-skip",children:"Skip"}),i.jsx("button",{type:"button",className:Fe.primaryButton,onClick:d,disabled:o,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):i.jsx("button",{type:"button",className:Fe.primaryButton,onClick:t,disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const E9=4,cx={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function A9(){const{personas:{personas:t,updatePersona:s},completeOnboarding:o,onboardingCompleted:r}=mt(),{showToast:c}=Sn(),d=kt(),[u,p]=y.useState(0),[m,g]=y.useState("claude-code"),[v,b]=y.useState(!1),x=t.find(w=>w.id==="claude-code"),S=y.useCallback(w=>{g(w),p(3)},[]),k=y.useCallback(()=>{const w=m;b(!0);const N=[];if(x&&w!==x.runtime){const C=cx[w]??"sonnet";N.push(s(x.id,void 0,void 0,void 0,w,C))}const T=t.find(C=>C.id===Q0);if(T&&w!==T.runtime){const C=cx[w]??"sonnet";N.push(s(Q0,void 0,void 0,void 0,w,C))}Promise.all(N).then(()=>o()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),b(!1)})},[m,x,t,s,o,d,c]);return r===!0?i.jsx(ds,{to:"/",replace:!0}):i.jsx("div",{className:Fe.wizard,"data-testid":"setup-wizard",children:i.jsxs("div",{className:Fe.container,children:[i.jsx(us,{mode:"wait",children:i.jsxs(Rt.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&i.jsx(S9,{onNext:()=>p(1)}),u===1&&i.jsx(T9,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&i.jsx(j9,{currentRuntime:m,onFinish:S,onBack:()=>p(1),finishDisabled:!x}),u===3&&i.jsx(C9,{onFinish:k,onBack:()=>p(2),finishDisabled:v})]},u)}),i.jsx("div",{className:Fe.dots,children:Array.from({length:E9},(w,N)=>i.jsx("span",{className:Fe.dot,"data-active":N===u},N))})]})})}const D9="_root_zndgp_1",R9="_body_zndgp_7",M9="_main_zndgp_19",I9="_sidebarWrapper_zndgp_26",O9="_overlay_zndgp_51",Fr={root:D9,body:R9,main:M9,sidebarWrapper:I9,overlay:O9},B9=y.lazy(()=>OT(()=>import("./KnowledgePage-BLz5X1AT.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.KnowledgePage}))),Z1=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function L9({tabs:t}){const{connected:s,environments:{environments:o},sessions:{sessions:r},tasks:{tasks:c}}=mt(),{toasts:d,dismissToast:u}=Sn(),p=Zt(),m=d7(),g=m!==void 0,[v,b]=y.useState(!1),x=y.useCallback(()=>b(S=>!S),[]);return y.useEffect(()=>{b(!1)},[p.pathname]),y.useEffect(()=>{if(!v)return;const S=k=>{k.key==="Escape"&&b(!1)};return document.addEventListener("keydown",S),()=>{document.removeEventListener("keydown",S)}},[v]),i.jsxs(i.Fragment,{children:[i.jsx(i5,{connected:s,environments:o,sessions:r,onToggleSidebar:g?x:void 0,sidebarOpen:v}),i.jsx(f5,{tabs:t}),i.jsxs("div",{className:Fr.body,children:[g&&i.jsx("div",{className:Fr.sidebarWrapper,"data-sidebar-open":v,children:i.jsx(y5,{content:m})}),g&&v&&i.jsx("div",{className:Fr.overlay,"data-testid":"drawer-overlay",onClick:()=>b(!1)}),i.jsxs("div",{className:Fr.main,children:[i.jsx(Va,{}),i.jsx(j5,{sessions:r,tasks:c,environments:o})]})]}),i.jsx($I,{toasts:d,onDismiss:u}),i.jsx($P,{})]})}function z9(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:o,clearOperationError:r},tasks:{tasks:c},connected:d,onboardingCompleted:u}=mt(),{pluginNames:p}=ih(),{showToast:m}=Sn();hz(s,m),xz(c,m),gz(o,r,m);const g=kt(),v=Zt();if(y.useEffect(()=>{t&&!v.pathname.includes("/tasks/")&&g(gm(t),{replace:!0})},[t,g,v.pathname]),d&&u===!1)return i.jsx(ds,{to:"/setup",replace:!0});const b=G7(p);return i.jsx(c7,{children:i.jsxs("div",{className:Fr.root,children:[Z1&&i.jsx(BN,{}),i.jsx(L9,{tabs:b})]})})}function Cp(){const{workspaceId:t}=fs(),{workspaces:{workspaces:s}}=mt(),o=Zt(),r=s.find(m=>m.id===t);if(!(r!=null&&r.environmentId))return s.length===0?void 0:i.jsx(ds,{to:"/environments",replace:!0});const c=encodeURIComponent(t),d=`/workspaces/${c}`,u=o.pathname.startsWith(d)?o.pathname.slice(d.length):"",p=`/environments/${encodeURIComponent(r.environmentId)}/workspaces/${c}${u}${o.search}${o.hash}`;return i.jsx(ds,{to:p,replace:!0})}function $9(){const{pluginNames:t}=ih(),s=t.includes("orchestration"),o=t.includes("knowledge");return i.jsxs(_j,{children:[i.jsx(Ae,{path:"setup",element:i.jsx(A9,{})}),i.jsxs(Ae,{element:i.jsx(z9,{}),children:[i.jsx(Ae,{index:!0,element:i.jsx(oU,{})}),i.jsx(Ae,{path:"chat",element:i.jsx(gU,{})}),i.jsx(Ae,{path:"sessions/new",element:i.jsx(vU,{})}),i.jsx(Ae,{path:"sessions/:sessionId",element:i.jsx(_U,{})}),o&&i.jsx(Ae,{element:i.jsx(qP,{}),children:i.jsx(Ae,{path:"knowledge",element:i.jsx(y.Suspense,{fallback:i.jsx(v1,{}),children:i.jsx(B9,{})})})}),s&&i.jsxs(Ae,{element:i.jsx(UP,{}),children:[i.jsx(Ae,{path:"tasks",element:i.jsx(aU,{})}),i.jsx(Ae,{path:"tasks/new",element:i.jsx(nx,{})}),i.jsx(Ae,{path:"tasks/:taskId",element:i.jsx(Ia,{})}),i.jsx(Ae,{path:"tasks/:taskId/edit",element:i.jsx(Ia,{})}),i.jsx(Ae,{path:"tasks/:taskId/stream",element:i.jsx(Ia,{})}),i.jsx(Ae,{path:"tasks/:taskId/findings",element:i.jsx(Ia,{})})]}),s&&i.jsxs(Ae,{element:i.jsx(VP,{}),children:[i.jsx(Ae,{path:"findings",element:i.jsx(rx,{})}),i.jsx(Ae,{path:"findings/:findingId",element:i.jsx(lx,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/findings",element:i.jsx(rx,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/findings/:findingId",element:i.jsx(lx,{})})]}),i.jsxs(Ae,{element:i.jsx(PP,{}),children:[i.jsx(Ae,{path:"workspaces",element:i.jsx(ds,{to:"/environments",replace:!0})}),i.jsx(Ae,{path:"workspaces/new",element:i.jsx(BU,{})}),i.jsx(Ae,{path:"workspaces/:workspaceId",element:i.jsx(Cp,{})}),i.jsx(Ae,{path:"workspaces/:workspaceId/tasks/:taskId",element:i.jsx(Cp,{})}),i.jsx(Ae,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:i.jsx(Cp,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId",element:i.jsx(wU,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:i.jsx(nx,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:i.jsx(Ia,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:i.jsx(Ia,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:i.jsx(Ia,{})}),i.jsx(Ae,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings",element:i.jsx(Ia,{})}),i.jsxs(Ae,{path:"environments",element:i.jsx(VU,{}),children:[i.jsx(Ae,{index:!0,element:i.jsx(iU,{})}),i.jsx(Ae,{path:"new",element:i.jsx(zU,{})}),i.jsx(Ae,{path:":environmentId",element:i.jsx(bP,{})}),i.jsx(Ae,{path:":environmentId/edit",element:i.jsx($U,{})})]})]}),i.jsx(Ae,{element:i.jsx(HP,{}),children:i.jsxs(Ae,{path:"settings",element:i.jsx(kP,{}),children:[i.jsx(Ae,{index:!0,element:i.jsx(ds,{to:"credentials",replace:!0})}),i.jsx(Ae,{path:"environments",element:i.jsx(ds,{to:"/environments",replace:!0})}),i.jsx(Ae,{path:"credentials",element:i.jsx(SP,{})}),i.jsx(Ae,{path:"tokens",element:i.jsx(ds,{to:"../credentials",replace:!0})}),i.jsx(Ae,{path:"personas",element:i.jsx(TP,{})}),i.jsx(Ae,{path:"personas/new",element:i.jsx(ix,{})}),i.jsx(Ae,{path:"personas/:personaId",element:i.jsx(ix,{})}),i.jsx(Ae,{path:"appearance",element:i.jsx(OP,{})}),i.jsx(Ae,{path:"shortcuts",element:i.jsx(zP,{})}),i.jsx(Ae,{path:"about",element:i.jsx(LP,{})})]})}),i.jsx(Ae,{path:"*",element:i.jsx(ds,{to:"/",replace:!0})})]})]})}const U9=1e4;function P9(){const{onboardingCompleted:t}=mt(),[s,o]=y.useState(!1);y.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>o(!0),U9);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return i.jsx(us,{mode:"wait",children:r?i.jsx(Rt.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:i.jsx(v1,{})},"splash"):i.jsx(Rt.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:i.jsx(Fj,{basename:"/".replace(/\/$/,""),children:i.jsx($9,{})})},"app")})}function H9(){const t=Z1?z7:mz;return i.jsx(P7,{children:i.jsx(l7,{children:i.jsx(a7,{children:i.jsx(t,{children:i.jsx(P9,{})})})})})}RT.createRoot(document.getElementById("root")).render(i.jsx(y.StrictMode,{children:i.jsx(H9,{})}));export{Ns as B,$x as K,mt as a,Mp as f,gm as s,On as t,kt as u};
|