@grackle-ai/web 0.108.2 → 0.108.4
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 +1 @@
|
|
|
1
|
-
import{t as nt,f as rt,b as A,z as it,s as T,h as st,k as X,j as N}from"./dagview-tHPW3Rz3.js";import{u as at,f as ot,s as ct,t as lt,a as ut,B as ft,K as ht}from"./index-DQtLa9c1.js";import"./grpc-DkqZhsre.js";import"./markdown-Yr3vTPLR.js";function dt(t,e){var n,o=1;t==null&&(t=0),e==null&&(e=0);function s(){var r,c=n.length,d,y=0,i=0;for(r=0;r<c;++r)d=n[r],y+=d.x,i+=d.y;for(y=(y/c-t)*o,i=(i/c-e)*o,r=0;r<c;++r)d=n[r],d.x-=y,d.y-=i}return s.initialize=function(r){n=r},s.x=function(r){return arguments.length?(t=+r,s):t},s.y=function(r){return arguments.length?(e=+r,s):e},s.strength=function(r){return arguments.length?(o=+r,s):o},s}function gt(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return q(this.cover(e,n),e,n,t)}function q(t,e,n,o){if(isNaN(e)||isNaN(n))return t;var s,r=t._root,c={data:o},d=t._x0,y=t._y0,i=t._x1,v=t._y1,w,_,h,p,l,a,u,f;if(!r)return t._root=c,t;for(;r.length;)if((l=e>=(w=(d+i)/2))?d=w:i=w,(a=n>=(_=(y+v)/2))?y=_:v=_,s=r,!(r=r[u=a<<1|l]))return s[u]=c,t;if(h=+t._x.call(null,r.data),p=+t._y.call(null,r.data),e===h&&n===p)return c.next=r,s?s[u]=c:t._root=c,t;do s=s?s[u]=new Array(4):t._root=new Array(4),(l=e>=(w=(d+i)/2))?d=w:i=w,(a=n>=(_=(y+v)/2))?y=_:v=_;while((u=a<<1|l)===(f=(p>=_)<<1|h>=w));return s[f]=r,s[u]=c,t}function xt(t){var e,n,o=t.length,s,r,c=new Array(o),d=new Array(o),y=1/0,i=1/0,v=-1/0,w=-1/0;for(n=0;n<o;++n)isNaN(s=+this._x.call(null,e=t[n]))||isNaN(r=+this._y.call(null,e))||(c[n]=s,d[n]=r,s<y&&(y=s),s>v&&(v=s),r<i&&(i=r),r>w&&(w=r));if(y>v||i>w)return this;for(this.cover(y,i).cover(v,w),n=0;n<o;++n)q(this,c[n],d[n],t[n]);return this}function _t(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,o=this._y0,s=this._x1,r=this._y1;if(isNaN(n))s=(n=Math.floor(t))+1,r=(o=Math.floor(e))+1;else{for(var c=s-n||1,d=this._root,y,i;n>t||t>=s||o>e||e>=r;)switch(i=(e<o)<<1|t<n,y=new Array(4),y[i]=d,d=y,c*=2,i){case 0:s=n+c,r=o+c;break;case 1:n=s-c,r=o+c;break;case 2:s=n+c,o=r-c;break;case 3:n=s-c,o=r-c;break}this._root&&this._root.length&&(this._root=d)}return this._x0=n,this._y0=o,this._x1=s,this._y1=r,this}function yt(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function vt(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function L(t,e,n,o,s){this.node=t,this.x0=e,this.y0=n,this.x1=o,this.y1=s}function mt(t,e,n){var o,s=this._x0,r=this._y0,c,d,y,i,v=this._x1,w=this._y1,_=[],h=this._root,p,l;for(h&&_.push(new L(h,s,r,v,w)),n==null?n=1/0:(s=t-n,r=e-n,v=t+n,w=e+n,n*=n);p=_.pop();)if(!(!(h=p.node)||(c=p.x0)>v||(d=p.y0)>w||(y=p.x1)<s||(i=p.y1)<r))if(h.length){var a=(c+y)/2,u=(d+i)/2;_.push(new L(h[3],a,u,y,i),new L(h[2],c,u,a,i),new L(h[1],a,d,y,u),new L(h[0],c,d,a,u)),(l=(e>=u)<<1|t>=a)&&(p=_[_.length-1],_[_.length-1]=_[_.length-1-l],_[_.length-1-l]=p)}else{var f=t-+this._x.call(null,h.data),m=e-+this._y.call(null,h.data),x=f*f+m*m;if(x<n){var b=Math.sqrt(n=x);s=t-b,r=e-b,v=t+b,w=e+b,o=h.data}}return o}function pt(t){if(isNaN(v=+this._x.call(null,t))||isNaN(w=+this._y.call(null,t)))return this;var e,n=this._root,o,s,r,c=this._x0,d=this._y0,y=this._x1,i=this._y1,v,w,_,h,p,l,a,u;if(!n)return this;if(n.length)for(;;){if((p=v>=(_=(c+y)/2))?c=_:y=_,(l=w>=(h=(d+i)/2))?d=h:i=h,e=n,!(n=n[a=l<<1|p]))return this;if(!n.length)break;(e[a+1&3]||e[a+2&3]||e[a+3&3])&&(o=e,u=a)}for(;n.data!==t;)if(s=n,!(n=n.next))return this;return(r=n.next)&&delete n.next,s?(r?s.next=r:delete s.next,this):e?(r?e[a]=r:delete e[a],(n=e[0]||e[1]||e[2]||e[3])&&n===(e[3]||e[2]||e[1]||e[0])&&!n.length&&(o?o[u]=n:this._root=n),this):(this._root=r,this)}function wt(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function Nt(){return this._root}function bt(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function kt(t){var e=[],n,o=this._root,s,r,c,d,y;for(o&&e.push(new L(o,this._x0,this._y0,this._x1,this._y1));n=e.pop();)if(!t(o=n.node,r=n.x0,c=n.y0,d=n.x1,y=n.y1)&&o.length){var i=(r+d)/2,v=(c+y)/2;(s=o[3])&&e.push(new L(s,i,v,d,y)),(s=o[2])&&e.push(new L(s,r,v,i,y)),(s=o[1])&&e.push(new L(s,i,c,d,v)),(s=o[0])&&e.push(new L(s,r,c,i,v))}return this}function jt(t){var e=[],n=[],o;for(this._root&&e.push(new L(this._root,this._x0,this._y0,this._x1,this._y1));o=e.pop();){var s=o.node;if(s.length){var r,c=o.x0,d=o.y0,y=o.x1,i=o.y1,v=(c+y)/2,w=(d+i)/2;(r=s[0])&&e.push(new L(r,c,d,v,w)),(r=s[1])&&e.push(new L(r,v,d,y,w)),(r=s[2])&&e.push(new L(r,c,w,v,i)),(r=s[3])&&e.push(new L(r,v,w,y,i))}n.push(o)}for(;o=n.pop();)t(o.node,o.x0,o.y0,o.x1,o.y1);return this}function At(t){return t[0]}function It(t){return arguments.length?(this._x=t,this):this._x}function Mt(t){return t[1]}function Ct(t){return arguments.length?(this._y=t,this):this._y}function U(t,e,n){var o=new P(e??At,n??Mt,NaN,NaN,NaN,NaN);return t==null?o:o.addAll(t)}function P(t,e,n,o,s,r){this._x=t,this._y=e,this._x0=n,this._y0=o,this._x1=s,this._y1=r,this._root=void 0}function Y(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var R=U.prototype=P.prototype;R.copy=function(){var t=new P(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,n,o;if(!e)return t;if(!e.length)return t._root=Y(e),t;for(n=[{source:e,target:t._root=new Array(4)}];e=n.pop();)for(var s=0;s<4;++s)(o=e.source[s])&&(o.length?n.push({source:o,target:e.target[s]=new Array(4)}):e.target[s]=Y(o));return t};R.add=gt;R.addAll=xt;R.cover=_t;R.data=yt;R.extent=vt;R.find=mt;R.remove=pt;R.removeAll=wt;R.root=Nt;R.size=bt;R.visit=kt;R.visitAfter=jt;R.x=It;R.y=Ct;function O(t){return function(){return t}}function S(t){return(t()-.5)*1e-6}function Lt(t){return t.x+t.vx}function Rt(t){return t.y+t.vy}function Et(t){var e,n,o,s=1,r=1;typeof t!="function"&&(t=O(t==null?1:+t));function c(){for(var i,v=e.length,w,_,h,p,l,a,u=0;u<r;++u)for(w=U(e,Lt,Rt).visitAfter(d),i=0;i<v;++i)_=e[i],l=n[_.index],a=l*l,h=_.x+_.vx,p=_.y+_.vy,w.visit(f);function f(m,x,b,I,C){var k=m.data,D=m.r,g=l+D;if(k){if(k.index>_.index){var j=h-k.x-k.vx,z=p-k.y-k.vy,B=j*j+z*z;B<g*g&&(j===0&&(j=S(o),B+=j*j),z===0&&(z=S(o),B+=z*z),B=(g-(B=Math.sqrt(B)))/B*s,_.vx+=(j*=B)*(g=(D*=D)/(a+D)),_.vy+=(z*=B)*g,k.vx-=j*(g=1-g),k.vy-=z*g)}return}return x>h+g||I<h-g||b>p+g||C<p-g}}function d(i){if(i.data)return i.r=n[i.data.index];for(var v=i.r=0;v<4;++v)i[v]&&i[v].r>i.r&&(i.r=i[v].r)}function y(){if(e){var i,v=e.length,w;for(n=new Array(v),i=0;i<v;++i)w=e[i],n[w.index]=+t(w,i,e)}}return c.initialize=function(i,v){e=i,o=v,y()},c.iterations=function(i){return arguments.length?(r=+i,c):r},c.strength=function(i){return arguments.length?(s=+i,c):s},c.radius=function(i){return arguments.length?(t=typeof i=="function"?i:O(+i),y(),c):t},c}function Dt(t){return t.index}function W(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function Bt(t){var e=Dt,n=w,o,s=O(30),r,c,d,y,i,v=1;t==null&&(t=[]);function w(a){return 1/Math.min(d[a.source.index],d[a.target.index])}function _(a){for(var u=0,f=t.length;u<v;++u)for(var m=0,x,b,I,C,k,D,g;m<f;++m)x=t[m],b=x.source,I=x.target,C=I.x+I.vx-b.x-b.vx||S(i),k=I.y+I.vy-b.y-b.vy||S(i),D=Math.sqrt(C*C+k*k),D=(D-r[m])/D*a*o[m],C*=D,k*=D,I.vx-=C*(g=y[m]),I.vy-=k*g,b.vx+=C*(g=1-g),b.vy+=k*g}function h(){if(c){var a,u=c.length,f=t.length,m=new Map(c.map((b,I)=>[e(b,I,c),b])),x;for(a=0,d=new Array(u);a<f;++a)x=t[a],x.index=a,typeof x.source!="object"&&(x.source=W(m,x.source)),typeof x.target!="object"&&(x.target=W(m,x.target)),d[x.source.index]=(d[x.source.index]||0)+1,d[x.target.index]=(d[x.target.index]||0)+1;for(a=0,y=new Array(f);a<f;++a)x=t[a],y[a]=d[x.source.index]/(d[x.source.index]+d[x.target.index]);o=new Array(f),p(),r=new Array(f),l()}}function p(){if(c)for(var a=0,u=t.length;a<u;++a)o[a]=+n(t[a],a,t)}function l(){if(c)for(var a=0,u=t.length;a<u;++a)r[a]=+s(t[a],a,t)}return _.initialize=function(a,u){c=a,i=u,h()},_.links=function(a){return arguments.length?(t=a,h(),_):t},_.id=function(a){return arguments.length?(e=a,_):e},_.iterations=function(a){return arguments.length?(v=+a,_):v},_.strength=function(a){return arguments.length?(n=typeof a=="function"?a:O(+a),p(),_):n},_.distance=function(a){return arguments.length?(s=typeof a=="function"?a:O(+a),l(),_):s},_}const zt=1664525,Tt=1013904223,Q=4294967296;function St(){let t=1;return()=>(t=(zt*t+Tt)%Q)/Q}function $t(t){return t.x}function Gt(t){return t.y}var Ot=10,Ft=Math.PI*(3-Math.sqrt(5));function Kt(t){var e,n=1,o=.001,s=1-Math.pow(o,1/300),r=0,c=.6,d=new Map,y=nt(w),i=rt("tick","end"),v=St();t==null&&(t=[]);function w(){_(),i.call("tick",e),n<o&&(y.stop(),i.call("end",e))}function _(l){var a,u=t.length,f;l===void 0&&(l=1);for(var m=0;m<l;++m)for(n+=(r-n)*s,d.forEach(function(x){x(n)}),a=0;a<u;++a)f=t[a],f.fx==null?f.x+=f.vx*=c:(f.x=f.fx,f.vx=0),f.fy==null?f.y+=f.vy*=c:(f.y=f.fy,f.vy=0);return e}function h(){for(var l=0,a=t.length,u;l<a;++l){if(u=t[l],u.index=l,u.fx!=null&&(u.x=u.fx),u.fy!=null&&(u.y=u.fy),isNaN(u.x)||isNaN(u.y)){var f=Ot*Math.sqrt(.5+l),m=l*Ft;u.x=f*Math.cos(m),u.y=f*Math.sin(m)}(isNaN(u.vx)||isNaN(u.vy))&&(u.vx=u.vy=0)}}function p(l){return l.initialize&&l.initialize(t,v),l}return h(),e={tick:_,restart:function(){return y.restart(w),e},stop:function(){return y.stop(),e},nodes:function(l){return arguments.length?(t=l,h(),d.forEach(p),e):t},alpha:function(l){return arguments.length?(n=+l,e):n},alphaMin:function(l){return arguments.length?(o=+l,e):o},alphaDecay:function(l){return arguments.length?(s=+l,e):+s},alphaTarget:function(l){return arguments.length?(r=+l,e):r},velocityDecay:function(l){return arguments.length?(c=1-l,e):1-c},randomSource:function(l){return arguments.length?(v=l,d.forEach(p),e):v},force:function(l,a){return arguments.length>1?(a==null?d.delete(l):d.set(l,p(a)),e):d.get(l)},find:function(l,a,u){var f=0,m=t.length,x,b,I,C,k;for(u==null?u=1/0:u*=u,f=0;f<m;++f)C=t[f],x=l-C.x,b=a-C.y,I=x*x+b*b,I<u&&(k=C,u=I);return k},on:function(l,a){return arguments.length>1?(i.on(l,a),e):i.on(l)}}}function Ht(){var t,e,n,o,s=O(-30),r,c=1,d=1/0,y=.81;function i(h){var p,l=t.length,a=U(t,$t,Gt).visitAfter(w);for(o=h,p=0;p<l;++p)e=t[p],a.visit(_)}function v(){if(t){var h,p=t.length,l;for(r=new Array(p),h=0;h<p;++h)l=t[h],r[l.index]=+s(l,h,t)}}function w(h){var p=0,l,a,u=0,f,m,x;if(h.length){for(f=m=x=0;x<4;++x)(l=h[x])&&(a=Math.abs(l.value))&&(p+=l.value,u+=a,f+=a*l.x,m+=a*l.y);h.x=f/u,h.y=m/u}else{l=h,l.x=l.data.x,l.y=l.data.y;do p+=r[l.data.index];while(l=l.next)}h.value=p}function _(h,p,l,a){if(!h.value)return!0;var u=h.x-e.x,f=h.y-e.y,m=a-p,x=u*u+f*f;if(m*m/y<x)return x<d&&(u===0&&(u=S(n),x+=u*u),f===0&&(f=S(n),x+=f*f),x<c&&(x=Math.sqrt(c*x)),e.vx+=u*h.value*o/x,e.vy+=f*h.value*o/x),!0;if(h.length||x>=d)return;(h.data!==e||h.next)&&(u===0&&(u=S(n),x+=u*u),f===0&&(f=S(n),x+=f*f),x<c&&(x=Math.sqrt(c*x)));do h.data!==e&&(m=r[h.data.index]*o/x,e.vx+=u*m,e.vy+=f*m);while(h=h.next)}return i.initialize=function(h,p){t=h,n=p,v()},i.strength=function(h){return arguments.length?(s=typeof h=="function"?h:O(+h),v(),i):s},i.distanceMin=function(h){return arguments.length?(c=h*h,i):Math.sqrt(c)},i.distanceMax=function(h){return arguments.length?(d=h*h,i):Math.sqrt(d)},i.theta=function(h){return arguments.length?(y=h*h,i):Math.sqrt(y)},i}const Ut="_graphContainer_13vy2_1",Pt="_svg_13vy2_10",Xt="_link_13vy2_18",Yt="_node_13vy2_30",Wt="_nodeCard_13vy2_37",Qt="_nodeLabel_13vy2_43",Vt="_selected_13vy2_47",Zt="_dimmed_13vy2_54",Jt="_dimmedLink_13vy2_59",qt="_nodeIndicator_13vy2_71",te="_nodeBadge_13vy2_85",E={graphContainer:Ut,svg:Pt,link:Xt,node:Yt,nodeCard:Wt,nodeLabel:Qt,selected:Vt,dimmed:Zt,dimmedLink:Jt,nodeIndicator:qt,nodeBadge:te},K={reference:"#4A9EFF",decision:"#22C55E",insight:"#EAB308",concept:"#A855F7",snippet:"#6B7280"};function V(t){return t.kind==="reference"?K.reference:K[t.category??"insight"]??K.insight}const $=200,G=52,Z=12,F=40,J=3;function ee(t,e){if(e.width<=0||e.height<=0)return;let n=1/0,o=-1/0,s=1/0,r=-1/0;for(const l of t){const a=l.x??0,u=l.y??0;a<n&&(n=a),a>o&&(o=a),u<s&&(s=u),u>r&&(r=u)}const c=n-$/2-F,d=o+$/2+F,y=s-G/2-F,i=r+G/2+F,v=d-c,w=i-y,_=Math.min(e.width/v,e.height/w,1),h=(c+d)/2,p=(y+i)/2;return{translateX:e.width/2-h*_,translateY:e.height/2-p*_,scale:_}}function ne({graphData:t,selectedNodeId:e,onNodeClick:n,onNodeDoubleClick:o}){const s=A.useRef(null),r=A.useRef(null),c=A.useRef(void 0),d=A.useRef(void 0),y=A.useRef(void 0),i=A.useRef(void 0),v=A.useRef(e);v.current=e;const w=A.useRef(!1),[_,h]=A.useState({width:800,height:600}),p=A.useRef(0);A.useEffect(()=>{var x;const f=((x=s.current)==null?void 0:x.parentElement)??null;if(!f)return;const m=new ResizeObserver(b=>{for(const I of b)h({width:I.contentRect.width,height:I.contentRect.height})});return m.observe(f),h({width:f.clientWidth,height:f.clientHeight}),()=>{m.disconnect()}},[]),A.useEffect(()=>{if(!s.current||!r.current)return;const f=s.current,m=r.current,x=it().scaleExtent([.1,4]).filter(b=>b.type!=="dblclick").on("zoom",b=>{T(m).attr("transform",String(b.transform))});return T(f).call(x),d.current=x,()=>{T(f).on(".zoom",null)}},[]);const l=A.useRef(n);l.current=n;const a=A.useRef(o);a.current=o,A.useEffect(()=>{if(!r.current)return;const f=r.current;if(c.current&&(c.current.stop(),c.current=void 0),w.current=!1,t.nodes.length===0){T(f).selectAll("*").remove();return}const m=t.nodes.map(g=>({...g})),x=new Map(m.map(g=>[g.id,g])),b=t.links.filter(g=>x.has(g.source)&&x.has(g.target)).map(g=>({source:g.source,target:g.target,type:g.type}));T(f).selectAll("*").remove();const I=T(f).selectAll("line").data(b).enter().append("line").attr("class",E.link);I.append("title").text(g=>g.type),y.current=I;const C=T(f).selectAll("g.kg-node").data(m).enter().append("g").attr("class",`kg-node ${E.node}`).on("click",(g,j)=>{p.current>J||l.current(j.id)}).on("dblclick",(g,j)=>{a.current(j.id)});i.current=C,C.append("rect").attr("class",E.nodeCard).attr("width",$).attr("height",G).attr("rx",Z).attr("ry",Z).style("--node-color",g=>V(g)),C.append("rect").attr("class",E.nodeIndicator).attr("width",4).attr("height",G).attr("rx",2).attr("fill",g=>V(g)),C.append("text").attr("class",E.nodeLabel).attr("x",$/2).attr("y",G/2-4).attr("text-anchor","middle").attr("dominant-baseline","central").text(g=>g.label.length>26?g.label.substring(0,24)+"...":g.label),C.append("text").attr("class",E.nodeBadge).attr("x",$/2).attr("y",G-8).attr("text-anchor","middle").text(g=>(g.kind==="reference"?g.sourceType??"ref":g.category??"").toUpperCase());const k=Kt(m).force("link",Bt(b).id(g=>g.id).distance(140)).force("charge",Ht().strength(-400)).force("center",dt(_.width/2,_.height/2)).force("collide",Et($/2+16)).on("tick",()=>{I.attr("x1",g=>g.source.x??0).attr("y1",g=>g.source.y??0).attr("x2",g=>g.target.x??0).attr("y2",g=>g.target.y??0),C.attr("transform",g=>`translate(${(g.x??0)-$/2},${(g.y??0)-G/2})`)});c.current=k;const D=st().on("start",(g,j)=>{j.fx=j.x,j.fy=j.y,p.current=0}).on("drag",(g,j)=>{j.fx=g.x,j.fy=g.y,p.current+=Math.abs(g.dx)+Math.abs(g.dy),p.current>J&&k.alphaTarget()===0&&k.alphaTarget(.3).restart()}).on("end",(g,j)=>{g.active||k.alphaTarget(0),j.fx=void 0,j.fy=void 0});return C.call(D),k.on("end",()=>{if(s.current&&d.current&&m.length>0&&!w.current&&!v.current){w.current=!0;const g=ee(m,_);if(!g)return;const{translateX:j,translateY:z,scale:B}=g,tt=d.current,et=X.translate(j,z).scale(B);T(s.current).transition().duration(500).call(tt.transform,et)}}),()=>{k.stop()}},[t,_]),A.useEffect(()=>{if(!r.current||!i.current||!y.current)return;if(!e){i.current.classed(E.dimmed,!1).classed(E.selected,!1),y.current.classed(E.dimmedLink,!1);return}const f=new Set([e]);y.current.each(m=>{const x=m.source.id,b=m.target.id;(x===e||b===e)&&(f.add(x),f.add(b))}),i.current.classed(E.selected,m=>m.id===e).classed(E.dimmed,m=>!f.has(m.id)),y.current.classed(E.dimmedLink,m=>{const x=m.source.id,b=m.target.id;return!f.has(x)||!f.has(b)})},[e,t]);const u=A.useCallback(()=>{if(!e||!c.current||!s.current||!d.current)return;const f=c.current.nodes().find(m=>m.id===e);if(f&&Number.isFinite(f.x)&&Number.isFinite(f.y)){const m=d.current,x=X.translate(_.width/2,_.height/2).scale(1.2).translate(-(f.x??0),-(f.y??0));T(s.current).transition().duration(500).call(m.transform,x)}},[e,_]);return A.useEffect(()=>{u()},[u]),N.jsx("div",{className:E.graphContainer,"data-testid":"knowledge-graph",children:N.jsxs("svg",{ref:s,width:_.width,height:_.height,className:E.svg,children:[N.jsx("defs",{children:N.jsxs("filter",{id:"glow",children:[N.jsx("feGaussianBlur",{stdDeviation:"3",result:"coloredBlur"}),N.jsxs("feMerge",{children:[N.jsx("feMergeNode",{in:"coloredBlur"}),N.jsx("feMergeNode",{in:"SourceGraphic"})]})]})}),N.jsx("g",{ref:r})]})})}const re="_panel_1ml6r_1",ie="_header_1ml6r_24",se="_title_1ml6r_32",ae="_closeButton_1ml6r_42",oe="_body_1ml6r_55",ce="_badge_1ml6r_61",le="_section_1ml6r_72",ue="_sectionLabel_1ml6r_76",fe="_content_1ml6r_84",he="_tags_1ml6r_92",de="_tag_1ml6r_92",ge="_viewLink_1ml6r_107",xe="_edgeList_1ml6r_121",_e="_edgeItem_1ml6r_127",ye="_edgeType_1ml6r_136",ve="_edgeNodeLink_1ml6r_142",me="_timestamps_1ml6r_154",M={panel:re,header:ie,title:se,closeButton:ae,body:oe,badge:ce,section:le,sectionLabel:ue,content:fe,tags:he,tag:de,viewLink:ge,edgeList:xe,edgeItem:_e,edgeType:ye,edgeNodeLink:ve,timestamps:me};function pe({detail:t,nodes:e,onClose:n,onSelectNode:o}){const s=at(),{node:r,edges:c}=t,d=A.useMemo(()=>new Map(e.map(i=>[i.id,i])),[e]);function y(){if(!(r.kind!=="reference"||!r.sourceId))switch(r.sourceType){case"task":s(lt(r.sourceId));break;case"session":s(ct(r.sourceId));break;case"finding":s(ot(r.sourceId));break}}return N.jsxs("div",{className:M.panel,"data-testid":"knowledge-detail-panel",children:[N.jsxs("div",{className:M.header,children:[N.jsx("h3",{className:M.title,children:r.label}),N.jsx("button",{className:M.closeButton,onClick:n,"aria-label":"Close",children:"×"})]}),N.jsxs("div",{className:M.body,children:[N.jsx("div",{className:M.badge,children:r.kind==="reference"?`Reference (${r.sourceType})`:r.category}),r.content&&N.jsxs("div",{className:M.section,children:[N.jsx("div",{className:M.sectionLabel,children:"Content"}),N.jsx("p",{className:M.content,children:r.content})]}),r.tags&&r.tags.length>0&&N.jsxs("div",{className:M.section,children:[N.jsx("div",{className:M.sectionLabel,children:"Tags"}),N.jsx("div",{className:M.tags,children:r.tags.map(i=>N.jsx("span",{className:M.tag,children:i},i))})]}),r.kind==="reference"&&r.sourceId&&N.jsx("div",{className:M.section,children:N.jsx("button",{className:M.viewLink,onClick:y,children:"View in Grackle →"})}),c.length>0&&N.jsxs("div",{className:M.section,children:[N.jsxs("div",{className:M.sectionLabel,children:["Edges (",c.length,")"]}),N.jsx("ul",{className:M.edgeList,children:c.map(i=>{var _;const v=i.fromId===r.id?i.toId:i.fromId,w=`${i.fromId}:${i.toId}:${i.type}`;return N.jsxs("li",{className:M.edgeItem,"data-testid":"edge-item",children:[N.jsx("span",{className:M.edgeType,"data-testid":"edge-type",children:i.type}),N.jsx("button",{className:M.edgeNodeLink,"data-testid":"edge-node-link",onClick:()=>{o(v)},children:((_=d.get(v))==null?void 0:_.label)??`${v.substring(0,8)}...`})]},w)})})]}),N.jsxs("div",{className:M.timestamps,children:[r.createdAt&&N.jsxs("div",{children:["Created: ",new Date(r.createdAt).toLocaleDateString()]}),r.updatedAt&&N.jsxs("div",{children:["Updated: ",new Date(r.updatedAt).toLocaleDateString()]})]})]})]})}const we="_layout_n9vg6_1",Ne="_graphArea_n9vg6_8",be="_empty_n9vg6_15",H={layout:we,graphArea:Ne,empty:be};function Me(){const{knowledge:t}=ut();A.useEffect(()=>{t.loadRecent().catch(()=>{})},[t]);const e=A.useCallback(r=>{t.selectNode(r).catch(()=>{})},[t]),n=A.useCallback(r=>{t.expandNode(r).catch(()=>{})},[t]),o=A.useCallback(()=>{t.clearSelection()},[t]),s=[{label:"Knowledge",url:ht}];return N.jsxs("div",{className:H.layout,"data-testid":"knowledge-page",children:[N.jsx(ft,{segments:s}),N.jsxs("div",{className:H.graphArea,children:[t.graphData.nodes.length===0&&!t.loading?N.jsxs("div",{className:H.empty,children:[N.jsx("p",{children:"No knowledge nodes found."}),N.jsx("p",{children:"Create knowledge via MCP tools or let agents discover it during tasks."})]}):N.jsx(ne,{graphData:t.graphData,selectedNodeId:t.selectedId,onNodeClick:e,onNodeDoubleClick:n}),t.selectedNode&&t.selectedId&&N.jsx(pe,{detail:t.selectedNode,nodes:t.graphData.nodes,onClose:o,onSelectNode:e})]})]})}export{Me as KnowledgePage};
|
|
1
|
+
import{t as nt,f as rt,b as A,z as it,s as T,h as st,k as X,j as N}from"./dagview-tHPW3Rz3.js";import{u as at,f as ot,s as ct,t as lt,a as ut,B as ft,K as ht}from"./index-DZjE3Vxz.js";import"./grpc-DkqZhsre.js";import"./markdown-Yr3vTPLR.js";function dt(t,e){var n,o=1;t==null&&(t=0),e==null&&(e=0);function s(){var r,c=n.length,d,y=0,i=0;for(r=0;r<c;++r)d=n[r],y+=d.x,i+=d.y;for(y=(y/c-t)*o,i=(i/c-e)*o,r=0;r<c;++r)d=n[r],d.x-=y,d.y-=i}return s.initialize=function(r){n=r},s.x=function(r){return arguments.length?(t=+r,s):t},s.y=function(r){return arguments.length?(e=+r,s):e},s.strength=function(r){return arguments.length?(o=+r,s):o},s}function gt(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return q(this.cover(e,n),e,n,t)}function q(t,e,n,o){if(isNaN(e)||isNaN(n))return t;var s,r=t._root,c={data:o},d=t._x0,y=t._y0,i=t._x1,v=t._y1,w,_,h,p,l,a,u,f;if(!r)return t._root=c,t;for(;r.length;)if((l=e>=(w=(d+i)/2))?d=w:i=w,(a=n>=(_=(y+v)/2))?y=_:v=_,s=r,!(r=r[u=a<<1|l]))return s[u]=c,t;if(h=+t._x.call(null,r.data),p=+t._y.call(null,r.data),e===h&&n===p)return c.next=r,s?s[u]=c:t._root=c,t;do s=s?s[u]=new Array(4):t._root=new Array(4),(l=e>=(w=(d+i)/2))?d=w:i=w,(a=n>=(_=(y+v)/2))?y=_:v=_;while((u=a<<1|l)===(f=(p>=_)<<1|h>=w));return s[f]=r,s[u]=c,t}function xt(t){var e,n,o=t.length,s,r,c=new Array(o),d=new Array(o),y=1/0,i=1/0,v=-1/0,w=-1/0;for(n=0;n<o;++n)isNaN(s=+this._x.call(null,e=t[n]))||isNaN(r=+this._y.call(null,e))||(c[n]=s,d[n]=r,s<y&&(y=s),s>v&&(v=s),r<i&&(i=r),r>w&&(w=r));if(y>v||i>w)return this;for(this.cover(y,i).cover(v,w),n=0;n<o;++n)q(this,c[n],d[n],t[n]);return this}function _t(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,o=this._y0,s=this._x1,r=this._y1;if(isNaN(n))s=(n=Math.floor(t))+1,r=(o=Math.floor(e))+1;else{for(var c=s-n||1,d=this._root,y,i;n>t||t>=s||o>e||e>=r;)switch(i=(e<o)<<1|t<n,y=new Array(4),y[i]=d,d=y,c*=2,i){case 0:s=n+c,r=o+c;break;case 1:n=s-c,r=o+c;break;case 2:s=n+c,o=r-c;break;case 3:n=s-c,o=r-c;break}this._root&&this._root.length&&(this._root=d)}return this._x0=n,this._y0=o,this._x1=s,this._y1=r,this}function yt(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function vt(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function L(t,e,n,o,s){this.node=t,this.x0=e,this.y0=n,this.x1=o,this.y1=s}function mt(t,e,n){var o,s=this._x0,r=this._y0,c,d,y,i,v=this._x1,w=this._y1,_=[],h=this._root,p,l;for(h&&_.push(new L(h,s,r,v,w)),n==null?n=1/0:(s=t-n,r=e-n,v=t+n,w=e+n,n*=n);p=_.pop();)if(!(!(h=p.node)||(c=p.x0)>v||(d=p.y0)>w||(y=p.x1)<s||(i=p.y1)<r))if(h.length){var a=(c+y)/2,u=(d+i)/2;_.push(new L(h[3],a,u,y,i),new L(h[2],c,u,a,i),new L(h[1],a,d,y,u),new L(h[0],c,d,a,u)),(l=(e>=u)<<1|t>=a)&&(p=_[_.length-1],_[_.length-1]=_[_.length-1-l],_[_.length-1-l]=p)}else{var f=t-+this._x.call(null,h.data),m=e-+this._y.call(null,h.data),x=f*f+m*m;if(x<n){var b=Math.sqrt(n=x);s=t-b,r=e-b,v=t+b,w=e+b,o=h.data}}return o}function pt(t){if(isNaN(v=+this._x.call(null,t))||isNaN(w=+this._y.call(null,t)))return this;var e,n=this._root,o,s,r,c=this._x0,d=this._y0,y=this._x1,i=this._y1,v,w,_,h,p,l,a,u;if(!n)return this;if(n.length)for(;;){if((p=v>=(_=(c+y)/2))?c=_:y=_,(l=w>=(h=(d+i)/2))?d=h:i=h,e=n,!(n=n[a=l<<1|p]))return this;if(!n.length)break;(e[a+1&3]||e[a+2&3]||e[a+3&3])&&(o=e,u=a)}for(;n.data!==t;)if(s=n,!(n=n.next))return this;return(r=n.next)&&delete n.next,s?(r?s.next=r:delete s.next,this):e?(r?e[a]=r:delete e[a],(n=e[0]||e[1]||e[2]||e[3])&&n===(e[3]||e[2]||e[1]||e[0])&&!n.length&&(o?o[u]=n:this._root=n),this):(this._root=r,this)}function wt(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function Nt(){return this._root}function bt(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function kt(t){var e=[],n,o=this._root,s,r,c,d,y;for(o&&e.push(new L(o,this._x0,this._y0,this._x1,this._y1));n=e.pop();)if(!t(o=n.node,r=n.x0,c=n.y0,d=n.x1,y=n.y1)&&o.length){var i=(r+d)/2,v=(c+y)/2;(s=o[3])&&e.push(new L(s,i,v,d,y)),(s=o[2])&&e.push(new L(s,r,v,i,y)),(s=o[1])&&e.push(new L(s,i,c,d,v)),(s=o[0])&&e.push(new L(s,r,c,i,v))}return this}function jt(t){var e=[],n=[],o;for(this._root&&e.push(new L(this._root,this._x0,this._y0,this._x1,this._y1));o=e.pop();){var s=o.node;if(s.length){var r,c=o.x0,d=o.y0,y=o.x1,i=o.y1,v=(c+y)/2,w=(d+i)/2;(r=s[0])&&e.push(new L(r,c,d,v,w)),(r=s[1])&&e.push(new L(r,v,d,y,w)),(r=s[2])&&e.push(new L(r,c,w,v,i)),(r=s[3])&&e.push(new L(r,v,w,y,i))}n.push(o)}for(;o=n.pop();)t(o.node,o.x0,o.y0,o.x1,o.y1);return this}function At(t){return t[0]}function It(t){return arguments.length?(this._x=t,this):this._x}function Mt(t){return t[1]}function Ct(t){return arguments.length?(this._y=t,this):this._y}function U(t,e,n){var o=new P(e??At,n??Mt,NaN,NaN,NaN,NaN);return t==null?o:o.addAll(t)}function P(t,e,n,o,s,r){this._x=t,this._y=e,this._x0=n,this._y0=o,this._x1=s,this._y1=r,this._root=void 0}function Y(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var R=U.prototype=P.prototype;R.copy=function(){var t=new P(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,n,o;if(!e)return t;if(!e.length)return t._root=Y(e),t;for(n=[{source:e,target:t._root=new Array(4)}];e=n.pop();)for(var s=0;s<4;++s)(o=e.source[s])&&(o.length?n.push({source:o,target:e.target[s]=new Array(4)}):e.target[s]=Y(o));return t};R.add=gt;R.addAll=xt;R.cover=_t;R.data=yt;R.extent=vt;R.find=mt;R.remove=pt;R.removeAll=wt;R.root=Nt;R.size=bt;R.visit=kt;R.visitAfter=jt;R.x=It;R.y=Ct;function O(t){return function(){return t}}function S(t){return(t()-.5)*1e-6}function Lt(t){return t.x+t.vx}function Rt(t){return t.y+t.vy}function Et(t){var e,n,o,s=1,r=1;typeof t!="function"&&(t=O(t==null?1:+t));function c(){for(var i,v=e.length,w,_,h,p,l,a,u=0;u<r;++u)for(w=U(e,Lt,Rt).visitAfter(d),i=0;i<v;++i)_=e[i],l=n[_.index],a=l*l,h=_.x+_.vx,p=_.y+_.vy,w.visit(f);function f(m,x,b,I,C){var k=m.data,D=m.r,g=l+D;if(k){if(k.index>_.index){var j=h-k.x-k.vx,z=p-k.y-k.vy,B=j*j+z*z;B<g*g&&(j===0&&(j=S(o),B+=j*j),z===0&&(z=S(o),B+=z*z),B=(g-(B=Math.sqrt(B)))/B*s,_.vx+=(j*=B)*(g=(D*=D)/(a+D)),_.vy+=(z*=B)*g,k.vx-=j*(g=1-g),k.vy-=z*g)}return}return x>h+g||I<h-g||b>p+g||C<p-g}}function d(i){if(i.data)return i.r=n[i.data.index];for(var v=i.r=0;v<4;++v)i[v]&&i[v].r>i.r&&(i.r=i[v].r)}function y(){if(e){var i,v=e.length,w;for(n=new Array(v),i=0;i<v;++i)w=e[i],n[w.index]=+t(w,i,e)}}return c.initialize=function(i,v){e=i,o=v,y()},c.iterations=function(i){return arguments.length?(r=+i,c):r},c.strength=function(i){return arguments.length?(s=+i,c):s},c.radius=function(i){return arguments.length?(t=typeof i=="function"?i:O(+i),y(),c):t},c}function Dt(t){return t.index}function W(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function Bt(t){var e=Dt,n=w,o,s=O(30),r,c,d,y,i,v=1;t==null&&(t=[]);function w(a){return 1/Math.min(d[a.source.index],d[a.target.index])}function _(a){for(var u=0,f=t.length;u<v;++u)for(var m=0,x,b,I,C,k,D,g;m<f;++m)x=t[m],b=x.source,I=x.target,C=I.x+I.vx-b.x-b.vx||S(i),k=I.y+I.vy-b.y-b.vy||S(i),D=Math.sqrt(C*C+k*k),D=(D-r[m])/D*a*o[m],C*=D,k*=D,I.vx-=C*(g=y[m]),I.vy-=k*g,b.vx+=C*(g=1-g),b.vy+=k*g}function h(){if(c){var a,u=c.length,f=t.length,m=new Map(c.map((b,I)=>[e(b,I,c),b])),x;for(a=0,d=new Array(u);a<f;++a)x=t[a],x.index=a,typeof x.source!="object"&&(x.source=W(m,x.source)),typeof x.target!="object"&&(x.target=W(m,x.target)),d[x.source.index]=(d[x.source.index]||0)+1,d[x.target.index]=(d[x.target.index]||0)+1;for(a=0,y=new Array(f);a<f;++a)x=t[a],y[a]=d[x.source.index]/(d[x.source.index]+d[x.target.index]);o=new Array(f),p(),r=new Array(f),l()}}function p(){if(c)for(var a=0,u=t.length;a<u;++a)o[a]=+n(t[a],a,t)}function l(){if(c)for(var a=0,u=t.length;a<u;++a)r[a]=+s(t[a],a,t)}return _.initialize=function(a,u){c=a,i=u,h()},_.links=function(a){return arguments.length?(t=a,h(),_):t},_.id=function(a){return arguments.length?(e=a,_):e},_.iterations=function(a){return arguments.length?(v=+a,_):v},_.strength=function(a){return arguments.length?(n=typeof a=="function"?a:O(+a),p(),_):n},_.distance=function(a){return arguments.length?(s=typeof a=="function"?a:O(+a),l(),_):s},_}const zt=1664525,Tt=1013904223,Q=4294967296;function St(){let t=1;return()=>(t=(zt*t+Tt)%Q)/Q}function $t(t){return t.x}function Gt(t){return t.y}var Ot=10,Ft=Math.PI*(3-Math.sqrt(5));function Kt(t){var e,n=1,o=.001,s=1-Math.pow(o,1/300),r=0,c=.6,d=new Map,y=nt(w),i=rt("tick","end"),v=St();t==null&&(t=[]);function w(){_(),i.call("tick",e),n<o&&(y.stop(),i.call("end",e))}function _(l){var a,u=t.length,f;l===void 0&&(l=1);for(var m=0;m<l;++m)for(n+=(r-n)*s,d.forEach(function(x){x(n)}),a=0;a<u;++a)f=t[a],f.fx==null?f.x+=f.vx*=c:(f.x=f.fx,f.vx=0),f.fy==null?f.y+=f.vy*=c:(f.y=f.fy,f.vy=0);return e}function h(){for(var l=0,a=t.length,u;l<a;++l){if(u=t[l],u.index=l,u.fx!=null&&(u.x=u.fx),u.fy!=null&&(u.y=u.fy),isNaN(u.x)||isNaN(u.y)){var f=Ot*Math.sqrt(.5+l),m=l*Ft;u.x=f*Math.cos(m),u.y=f*Math.sin(m)}(isNaN(u.vx)||isNaN(u.vy))&&(u.vx=u.vy=0)}}function p(l){return l.initialize&&l.initialize(t,v),l}return h(),e={tick:_,restart:function(){return y.restart(w),e},stop:function(){return y.stop(),e},nodes:function(l){return arguments.length?(t=l,h(),d.forEach(p),e):t},alpha:function(l){return arguments.length?(n=+l,e):n},alphaMin:function(l){return arguments.length?(o=+l,e):o},alphaDecay:function(l){return arguments.length?(s=+l,e):+s},alphaTarget:function(l){return arguments.length?(r=+l,e):r},velocityDecay:function(l){return arguments.length?(c=1-l,e):1-c},randomSource:function(l){return arguments.length?(v=l,d.forEach(p),e):v},force:function(l,a){return arguments.length>1?(a==null?d.delete(l):d.set(l,p(a)),e):d.get(l)},find:function(l,a,u){var f=0,m=t.length,x,b,I,C,k;for(u==null?u=1/0:u*=u,f=0;f<m;++f)C=t[f],x=l-C.x,b=a-C.y,I=x*x+b*b,I<u&&(k=C,u=I);return k},on:function(l,a){return arguments.length>1?(i.on(l,a),e):i.on(l)}}}function Ht(){var t,e,n,o,s=O(-30),r,c=1,d=1/0,y=.81;function i(h){var p,l=t.length,a=U(t,$t,Gt).visitAfter(w);for(o=h,p=0;p<l;++p)e=t[p],a.visit(_)}function v(){if(t){var h,p=t.length,l;for(r=new Array(p),h=0;h<p;++h)l=t[h],r[l.index]=+s(l,h,t)}}function w(h){var p=0,l,a,u=0,f,m,x;if(h.length){for(f=m=x=0;x<4;++x)(l=h[x])&&(a=Math.abs(l.value))&&(p+=l.value,u+=a,f+=a*l.x,m+=a*l.y);h.x=f/u,h.y=m/u}else{l=h,l.x=l.data.x,l.y=l.data.y;do p+=r[l.data.index];while(l=l.next)}h.value=p}function _(h,p,l,a){if(!h.value)return!0;var u=h.x-e.x,f=h.y-e.y,m=a-p,x=u*u+f*f;if(m*m/y<x)return x<d&&(u===0&&(u=S(n),x+=u*u),f===0&&(f=S(n),x+=f*f),x<c&&(x=Math.sqrt(c*x)),e.vx+=u*h.value*o/x,e.vy+=f*h.value*o/x),!0;if(h.length||x>=d)return;(h.data!==e||h.next)&&(u===0&&(u=S(n),x+=u*u),f===0&&(f=S(n),x+=f*f),x<c&&(x=Math.sqrt(c*x)));do h.data!==e&&(m=r[h.data.index]*o/x,e.vx+=u*m,e.vy+=f*m);while(h=h.next)}return i.initialize=function(h,p){t=h,n=p,v()},i.strength=function(h){return arguments.length?(s=typeof h=="function"?h:O(+h),v(),i):s},i.distanceMin=function(h){return arguments.length?(c=h*h,i):Math.sqrt(c)},i.distanceMax=function(h){return arguments.length?(d=h*h,i):Math.sqrt(d)},i.theta=function(h){return arguments.length?(y=h*h,i):Math.sqrt(y)},i}const Ut="_graphContainer_13vy2_1",Pt="_svg_13vy2_10",Xt="_link_13vy2_18",Yt="_node_13vy2_30",Wt="_nodeCard_13vy2_37",Qt="_nodeLabel_13vy2_43",Vt="_selected_13vy2_47",Zt="_dimmed_13vy2_54",Jt="_dimmedLink_13vy2_59",qt="_nodeIndicator_13vy2_71",te="_nodeBadge_13vy2_85",E={graphContainer:Ut,svg:Pt,link:Xt,node:Yt,nodeCard:Wt,nodeLabel:Qt,selected:Vt,dimmed:Zt,dimmedLink:Jt,nodeIndicator:qt,nodeBadge:te},K={reference:"#4A9EFF",decision:"#22C55E",insight:"#EAB308",concept:"#A855F7",snippet:"#6B7280"};function V(t){return t.kind==="reference"?K.reference:K[t.category??"insight"]??K.insight}const $=200,G=52,Z=12,F=40,J=3;function ee(t,e){if(e.width<=0||e.height<=0)return;let n=1/0,o=-1/0,s=1/0,r=-1/0;for(const l of t){const a=l.x??0,u=l.y??0;a<n&&(n=a),a>o&&(o=a),u<s&&(s=u),u>r&&(r=u)}const c=n-$/2-F,d=o+$/2+F,y=s-G/2-F,i=r+G/2+F,v=d-c,w=i-y,_=Math.min(e.width/v,e.height/w,1),h=(c+d)/2,p=(y+i)/2;return{translateX:e.width/2-h*_,translateY:e.height/2-p*_,scale:_}}function ne({graphData:t,selectedNodeId:e,onNodeClick:n,onNodeDoubleClick:o}){const s=A.useRef(null),r=A.useRef(null),c=A.useRef(void 0),d=A.useRef(void 0),y=A.useRef(void 0),i=A.useRef(void 0),v=A.useRef(e);v.current=e;const w=A.useRef(!1),[_,h]=A.useState({width:800,height:600}),p=A.useRef(0);A.useEffect(()=>{var x;const f=((x=s.current)==null?void 0:x.parentElement)??null;if(!f)return;const m=new ResizeObserver(b=>{for(const I of b)h({width:I.contentRect.width,height:I.contentRect.height})});return m.observe(f),h({width:f.clientWidth,height:f.clientHeight}),()=>{m.disconnect()}},[]),A.useEffect(()=>{if(!s.current||!r.current)return;const f=s.current,m=r.current,x=it().scaleExtent([.1,4]).filter(b=>b.type!=="dblclick").on("zoom",b=>{T(m).attr("transform",String(b.transform))});return T(f).call(x),d.current=x,()=>{T(f).on(".zoom",null)}},[]);const l=A.useRef(n);l.current=n;const a=A.useRef(o);a.current=o,A.useEffect(()=>{if(!r.current)return;const f=r.current;if(c.current&&(c.current.stop(),c.current=void 0),w.current=!1,t.nodes.length===0){T(f).selectAll("*").remove();return}const m=t.nodes.map(g=>({...g})),x=new Map(m.map(g=>[g.id,g])),b=t.links.filter(g=>x.has(g.source)&&x.has(g.target)).map(g=>({source:g.source,target:g.target,type:g.type}));T(f).selectAll("*").remove();const I=T(f).selectAll("line").data(b).enter().append("line").attr("class",E.link);I.append("title").text(g=>g.type),y.current=I;const C=T(f).selectAll("g.kg-node").data(m).enter().append("g").attr("class",`kg-node ${E.node}`).on("click",(g,j)=>{p.current>J||l.current(j.id)}).on("dblclick",(g,j)=>{a.current(j.id)});i.current=C,C.append("rect").attr("class",E.nodeCard).attr("width",$).attr("height",G).attr("rx",Z).attr("ry",Z).style("--node-color",g=>V(g)),C.append("rect").attr("class",E.nodeIndicator).attr("width",4).attr("height",G).attr("rx",2).attr("fill",g=>V(g)),C.append("text").attr("class",E.nodeLabel).attr("x",$/2).attr("y",G/2-4).attr("text-anchor","middle").attr("dominant-baseline","central").text(g=>g.label.length>26?g.label.substring(0,24)+"...":g.label),C.append("text").attr("class",E.nodeBadge).attr("x",$/2).attr("y",G-8).attr("text-anchor","middle").text(g=>(g.kind==="reference"?g.sourceType??"ref":g.category??"").toUpperCase());const k=Kt(m).force("link",Bt(b).id(g=>g.id).distance(140)).force("charge",Ht().strength(-400)).force("center",dt(_.width/2,_.height/2)).force("collide",Et($/2+16)).on("tick",()=>{I.attr("x1",g=>g.source.x??0).attr("y1",g=>g.source.y??0).attr("x2",g=>g.target.x??0).attr("y2",g=>g.target.y??0),C.attr("transform",g=>`translate(${(g.x??0)-$/2},${(g.y??0)-G/2})`)});c.current=k;const D=st().on("start",(g,j)=>{j.fx=j.x,j.fy=j.y,p.current=0}).on("drag",(g,j)=>{j.fx=g.x,j.fy=g.y,p.current+=Math.abs(g.dx)+Math.abs(g.dy),p.current>J&&k.alphaTarget()===0&&k.alphaTarget(.3).restart()}).on("end",(g,j)=>{g.active||k.alphaTarget(0),j.fx=void 0,j.fy=void 0});return C.call(D),k.on("end",()=>{if(s.current&&d.current&&m.length>0&&!w.current&&!v.current){w.current=!0;const g=ee(m,_);if(!g)return;const{translateX:j,translateY:z,scale:B}=g,tt=d.current,et=X.translate(j,z).scale(B);T(s.current).transition().duration(500).call(tt.transform,et)}}),()=>{k.stop()}},[t,_]),A.useEffect(()=>{if(!r.current||!i.current||!y.current)return;if(!e){i.current.classed(E.dimmed,!1).classed(E.selected,!1),y.current.classed(E.dimmedLink,!1);return}const f=new Set([e]);y.current.each(m=>{const x=m.source.id,b=m.target.id;(x===e||b===e)&&(f.add(x),f.add(b))}),i.current.classed(E.selected,m=>m.id===e).classed(E.dimmed,m=>!f.has(m.id)),y.current.classed(E.dimmedLink,m=>{const x=m.source.id,b=m.target.id;return!f.has(x)||!f.has(b)})},[e,t]);const u=A.useCallback(()=>{if(!e||!c.current||!s.current||!d.current)return;const f=c.current.nodes().find(m=>m.id===e);if(f&&Number.isFinite(f.x)&&Number.isFinite(f.y)){const m=d.current,x=X.translate(_.width/2,_.height/2).scale(1.2).translate(-(f.x??0),-(f.y??0));T(s.current).transition().duration(500).call(m.transform,x)}},[e,_]);return A.useEffect(()=>{u()},[u]),N.jsx("div",{className:E.graphContainer,"data-testid":"knowledge-graph",children:N.jsxs("svg",{ref:s,width:_.width,height:_.height,className:E.svg,children:[N.jsx("defs",{children:N.jsxs("filter",{id:"glow",children:[N.jsx("feGaussianBlur",{stdDeviation:"3",result:"coloredBlur"}),N.jsxs("feMerge",{children:[N.jsx("feMergeNode",{in:"coloredBlur"}),N.jsx("feMergeNode",{in:"SourceGraphic"})]})]})}),N.jsx("g",{ref:r})]})})}const re="_panel_1ml6r_1",ie="_header_1ml6r_24",se="_title_1ml6r_32",ae="_closeButton_1ml6r_42",oe="_body_1ml6r_55",ce="_badge_1ml6r_61",le="_section_1ml6r_72",ue="_sectionLabel_1ml6r_76",fe="_content_1ml6r_84",he="_tags_1ml6r_92",de="_tag_1ml6r_92",ge="_viewLink_1ml6r_107",xe="_edgeList_1ml6r_121",_e="_edgeItem_1ml6r_127",ye="_edgeType_1ml6r_136",ve="_edgeNodeLink_1ml6r_142",me="_timestamps_1ml6r_154",M={panel:re,header:ie,title:se,closeButton:ae,body:oe,badge:ce,section:le,sectionLabel:ue,content:fe,tags:he,tag:de,viewLink:ge,edgeList:xe,edgeItem:_e,edgeType:ye,edgeNodeLink:ve,timestamps:me};function pe({detail:t,nodes:e,onClose:n,onSelectNode:o}){const s=at(),{node:r,edges:c}=t,d=A.useMemo(()=>new Map(e.map(i=>[i.id,i])),[e]);function y(){if(!(r.kind!=="reference"||!r.sourceId))switch(r.sourceType){case"task":s(lt(r.sourceId));break;case"session":s(ct(r.sourceId));break;case"finding":s(ot(r.sourceId));break}}return N.jsxs("div",{className:M.panel,"data-testid":"knowledge-detail-panel",children:[N.jsxs("div",{className:M.header,children:[N.jsx("h3",{className:M.title,children:r.label}),N.jsx("button",{className:M.closeButton,onClick:n,"aria-label":"Close",children:"×"})]}),N.jsxs("div",{className:M.body,children:[N.jsx("div",{className:M.badge,children:r.kind==="reference"?`Reference (${r.sourceType})`:r.category}),r.content&&N.jsxs("div",{className:M.section,children:[N.jsx("div",{className:M.sectionLabel,children:"Content"}),N.jsx("p",{className:M.content,children:r.content})]}),r.tags&&r.tags.length>0&&N.jsxs("div",{className:M.section,children:[N.jsx("div",{className:M.sectionLabel,children:"Tags"}),N.jsx("div",{className:M.tags,children:r.tags.map(i=>N.jsx("span",{className:M.tag,children:i},i))})]}),r.kind==="reference"&&r.sourceId&&N.jsx("div",{className:M.section,children:N.jsx("button",{className:M.viewLink,onClick:y,children:"View in Grackle →"})}),c.length>0&&N.jsxs("div",{className:M.section,children:[N.jsxs("div",{className:M.sectionLabel,children:["Edges (",c.length,")"]}),N.jsx("ul",{className:M.edgeList,children:c.map(i=>{var _;const v=i.fromId===r.id?i.toId:i.fromId,w=`${i.fromId}:${i.toId}:${i.type}`;return N.jsxs("li",{className:M.edgeItem,"data-testid":"edge-item",children:[N.jsx("span",{className:M.edgeType,"data-testid":"edge-type",children:i.type}),N.jsx("button",{className:M.edgeNodeLink,"data-testid":"edge-node-link",onClick:()=>{o(v)},children:((_=d.get(v))==null?void 0:_.label)??`${v.substring(0,8)}...`})]},w)})})]}),N.jsxs("div",{className:M.timestamps,children:[r.createdAt&&N.jsxs("div",{children:["Created: ",new Date(r.createdAt).toLocaleDateString()]}),r.updatedAt&&N.jsxs("div",{children:["Updated: ",new Date(r.updatedAt).toLocaleDateString()]})]})]})]})}const we="_layout_n9vg6_1",Ne="_graphArea_n9vg6_8",be="_empty_n9vg6_15",H={layout:we,graphArea:Ne,empty:be};function Me(){const{knowledge:t}=ut();A.useEffect(()=>{t.loadRecent().catch(()=>{})},[t]);const e=A.useCallback(r=>{t.selectNode(r).catch(()=>{})},[t]),n=A.useCallback(r=>{t.expandNode(r).catch(()=>{})},[t]),o=A.useCallback(()=>{t.clearSelection()},[t]),s=[{label:"Knowledge",url:ht}];return N.jsxs("div",{className:H.layout,"data-testid":"knowledge-page",children:[N.jsx(ft,{segments:s}),N.jsxs("div",{className:H.graphArea,children:[t.graphData.nodes.length===0&&!t.loading?N.jsxs("div",{className:H.empty,children:[N.jsx("p",{children:"No knowledge nodes found."}),N.jsx("p",{children:"Create knowledge via MCP tools or let agents discover it during tasks."})]}):N.jsx(ne,{graphData:t.graphData,selectedNodeId:t.selectedId,onNodeClick:e,onNodeDoubleClick:n}),t.selectedNode&&t.selectedId&&N.jsx(pe,{detail:t.selectedNode,nodes:t.graphData.nodes,onClose:o,onSelectNode:e})]})]})}export{Me as KnowledgePage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KnowledgePage-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KnowledgePage-CD_LfPMg.js","assets/dagview-tHPW3Rz3.js","assets/grpc-DkqZhsre.js","assets/markdown-Yr3vTPLR.js","assets/KnowledgePage-BmY14aDt.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{r as w2,a as N2,b as y,j as a,d as fy,H as py,P as my,i as C2,B as E2,c as A2,C as D2,M as R2,e as M2}from"./dagview-tHPW3Rz3.js";import{c as I2,a as Cd,G as O2,b as L2,d as B2,e as $2,f as z2,M as H2,A as E_,D as A_,W as P2,O as U2,g as V2,C as da,h as D_,i as R_,w as q2,t as G2,p as $c,j as F2,R as zr,S as hy}from"./grpc-DkqZhsre.js";import{v as Z2,r as K2,t as zc,i as Y2,f as J2,M as Ed,a as Ad}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 tp={exports:{}},Hr={},np={exports:{}},sp={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* scheduler.production.js
|
|
@@ -310,7 +310,7 @@ ${r.content}`);break}}}return s.join(`
|
|
|
310
310
|
|
|
311
311
|
${r}
|
|
312
312
|
|
|
313
|
-
--- End forwarded ---`}function l5(t){return t.replace(/[\r\n]+/g," ").trim().replace(/---/g,"—")}function c5({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(S=>{r(!0),S!==void 0?(d(new Set([S])),u.current=S):(d(new Set),u.current=void 0)},[]),g=y.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=y.useCallback((S,j)=>{if(j&&u.current!==void 0){const w=Math.min(u.current,S),T=Math.max(u.current,S);d(C=>{const A=new Set(C);for(let L=w;L<=T;L++)L<t.length&&hl(t[L])&&A.add(L);return A})}else d(w=>{const T=new Set(w);return T.has(S)?T.delete(S):T.add(S),T.size===0?(r(!1),u.current=void 0):u.current=S,T})},[t]),_=y.useCallback(()=>{const S=new Set;for(let j=0;j<t.length;j++)hl(t[j])&&S.add(j);d(S)},[t]),b=y.useCallback(()=>{d(new Set)},[]),x=y.useCallback(async()=>{const j=[...c].sort((T,C)=>T-C).filter(T=>T<t.length).map(T=>t[T]);if(j.length===0)return!1;const w=s(j);try{return await navigator.clipboard.writeText(w),!0}catch{return!1}},[c,t,s]);return{isSelecting:o,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:_,deselectAll:b,copySelected:x}}const d5="_wrapper_1cdza_1",u5="_scrollContainer_1cdza_9",f5="_selectingPadding_1cdza_16",p5="_toolbar_1cdza_20",m5="_directionToggle_1cdza_27",h5="_scrollToAnchor_1cdza_65",g5="_scrollToAnchorBottom_1cdza_89",v5="_scrollToAnchorTop_1cdza_93",y5="_eventOverflowWarning_1cdza_97",oa={wrapper:d5,scrollContainer:u5,selectingPadding:f5,toolbar:p5,directionToggle:m5,scrollToAnchor:h5,scrollToAnchorBottom:g5,scrollToAnchorTop:v5,eventOverflowWarning:y5},b5=10*1024,_5=new Set(["running","idle"]);function x5(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 H1="grackle-stream-direction";function k5(){try{return localStorage.getItem(H1)==="reversed"}catch{return!1}}function S5({eventsDropped:t}){return t<=0?a.jsx(a.Fragment,{}):a.jsxs("div",{className:oa.eventOverflowWarning,role:"alert",children:[a.jsx(wm,{size:Ut,"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 al({events:t,eventsDropped:s,emptyState:o,onShowToast:r,sessions:c,currentSessionId:d,environments:u,personas:p,onForward:m}){const g=y.useRef(null),[v,_]=y.useState(k5),b=O3(),[x,S]=y.useState(!1),[j,w]=y.useState(!1),[T,C]=y.useState(void 0),A=c5({events:t,formatForClipboard:z1}),L=y.useMemo(()=>t.filter(hl).length,[t]),E=y.useMemo(()=>c?c.filter(q=>_5.has(q.status)&&q.id!==d):[],[c,d]),M=y.useMemo(()=>v?[...t].reverse():t,[t,v]),{isAtAnchor:H,scrollToAnchor:D}=a5({scrollRef:g,contentLength:t.length,isReversed:v,paused:A.isSelecting}),z=()=>{const q=!v;_(q);try{localStorage.setItem(H1,q?"reversed":"default")}catch{}};y.useEffect(()=>{if(!A.isSelecting)return;const q=le=>{le.key==="Escape"&&!x&&!j&&A.cancelSelection()};return window.addEventListener("keydown",q),()=>{window.removeEventListener("keydown",q)}},[A.isSelecting,A.cancelSelection,x,j]);const Y=y.useCallback(async()=>{await A.copySelected()&&(r==null||r(`Copied ${A.selectedCount} message${A.selectedCount===1?"":"s"} to clipboard`,"success"))},[A,r]),V=y.useCallback(()=>[...A.selectedIndices].sort((le,de)=>le-de).filter(le=>le<t.length).map(le=>t[le]),[A.selectedIndices,t]),Q=y.useCallback(q=>{if(!q)return"this session";const le=c==null?void 0:c.find(xe=>xe.id===q);if(!le)return q.slice(0,8);const de=u==null?void 0:u.find(xe=>xe.id===le.environmentId);return(de==null?void 0:de.displayName)??le.environmentId.slice(0,8)},[c,u]),ge=y.useCallback(async(q,le)=>{if(!m)return;const de=Q(q);try{await m(q,le);const xe=A.selectedCount;r==null||r(`Forwarded ${xe} message${xe===1?"":"s"} to ${de}`,"success"),A.cancelSelection()}catch{r==null||r("Failed to forward messages","error")}},[m,Q,r,A]),X=y.useCallback(q=>{S(!1);const le=V(),de=Q(d),xe=r5(de,le);if(new TextEncoder().encode(xe).length>b5){C({sessionId:q,text:xe}),w(!0);return}ge(q,xe).catch(()=>{})},[V,Q,d,ge]),re=y.useCallback(()=>{w(!1),T&&(ge(T.sessionId,T.text).catch(()=>{}),C(void 0))},[T,ge]),B=y.useCallback(()=>{w(!1),C(void 0)},[]),R=b?0:.2,Z=v?-8:8,me=T?Math.round(new TextEncoder().encode(T.text).length/1024):0;return a.jsxs("div",{className:oa.wrapper,children:[a.jsx("div",{className:oa.toolbar,children:a.jsx(Oi,{text:v?"Showing newest first":"Showing oldest first",children:a.jsx("button",{className:oa.directionToggle,onClick:z,"aria-label":v?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:v?a.jsx(Sy,{size:Ut,"aria-hidden":"true"}):a.jsx(jy,{size:Ut,"aria-hidden":"true"})})})}),a.jsxs("div",{ref:g,className:`${oa.scrollContainer} ${A.isSelecting?oa.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&o,a.jsx(S5,{eventsDropped:s}),a.jsx(ls,{initial:!1,children:M.map((q,le)=>{const de=v?t.length-1-le:le;return a.jsx(At.div,{initial:{opacity:0,y:Z},animate:{opacity:1,y:0},transition:{duration:R,ease:"easeOut"},children:a.jsx(j6,{copyText:o5(q),isContentBearing:hl(q),isSelecting:A.isSelecting,isSelected:A.selectedIndices.has(de),checkboxLabel:x5(q),onSelect:()=>{A.enterSelectionMode(de)},onToggle:xe=>{A.toggleEvent(de,xe)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:a.jsx(cD,{event:q,toolUseCtx:q.toolUseCtx,settled:q.settled})})},`${q.sessionId}-${q.timestamp}-${de}`)})})]}),a.jsx(ls,{children:A.isSelecting&&a.jsx(M6,{selectedCount:A.selectedCount,totalSelectable:L,onSelectAll:A.selectAll,onDeselectAll:A.deselectAll,onCopy:()=>{Y().catch(()=>{})},onForward:m!==void 0?()=>{S(!0)}:void 0,forwardDisabled:E.length===0,onCancel:A.cancelSelection})}),a.jsx(t5,{isOpen:x,sessions:E,environments:u??[],personas:p,onSelect:X,onCancel:()=>{S(!1)}}),a.jsx(ks,{isOpen:j,title:"Send large message?",description:`This will forward a large message (${me} KB). Continue?`,confirmLabel:"Send",onConfirm:re,onCancel:B}),a.jsx(ls,{children:!H&&a.jsxs(At.button,{className:`${oa.scrollToAnchor} ${v?oa.scrollToAnchorTop:oa.scrollToAnchorBottom}`,onClick:D,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:[v?a.jsx(jy,{size:Ut,"aria-hidden":"true"}):a.jsx(Sy,{size:Ut,"aria-hidden":"true"})," New events"]})})]})}function gh(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]=y.useState(""),x=y.useRef(!1),S=d===c,j=y.useCallback(H=>{v(H),b("")},[]),w=y.useCallback(()=>{b("")},[]),T=y.useCallback(()=>{x.current=!1,u==null||u(null),v(""),b("")},[u]),C=y.useCallback(()=>{const H=m?g.trim():g;if(r){const z=r(g);if(z){b(z);return}}const D=m?s.trim():s;if(H===D){T();return}o(H),T()},[g,s,m,r,o,T]),A=y.useCallback(()=>{x.current=!0,u==null||u(c),v(s),b("")},[c,s,u]),L=y.useCallback(H=>{if(x.current){x.current=!1;return}H.relatedTarget instanceof HTMLElement&&H.relatedTarget.dataset.editAction===c||C()},[c,C]),E=y.useCallback(H=>{H.key==="Escape"?T():H.key==="Enter"&&p&&C()},[T,p,C]),M=(()=>{if(!S)return!1;const H=m?s.trim():s;return(m?g.trim():g)!==H})();return y.useEffect(()=>{!S&&(g!==""||_!=="")&&(v(""),b(""))},[S,g,_]),{isEditing:S,draft:g,error:_,isDirty:M,startEdit:A,cancelEdit:T,save:C,setDraft:j,clearError:w,handleBlur:L,handleKeyDown:E,ignoreInitialBlurRef:x}}const j5="_editFieldWrapper_yuzty_1",T5="_editInput_yuzty_10",w5="_editTextarea_yuzty_42",N5="_editSelect_yuzty_78",C5="_editError_yuzty_111",E5="_editInputInvalid_yuzty_118",A5="_editHint_yuzty_123",D5="_unsavedDot_yuzty_132",R5="_metaValueClickable_yuzty_140",M5="_editButton_yuzty_159",I5="_metaPlaceholder_yuzty_175",O5="_worktreeToggle_yuzty_180",at={editFieldWrapper:j5,editInput:T5,editTextarea:w5,editSelect:N5,editError:C5,editInputInvalid:E5,editHint:A5,unsavedDot:D5,metaValueClickable:R5,editButton:M5,metaPlaceholder:I5,worktreeToggle:O5};function Yt(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:_,ariaLabel:b,"data-testid":x}=t,S=y.useRef(null),j=gh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(j.isEditing){const T=window.setTimeout(()=>{var C;(C=S.current)==null||C.focus()},0);return()=>window.clearTimeout(T)}},[j.isEditing]),c==="create"){const T=A=>{m==null||m(A.target.value)},C=r==null?void 0:r(s);return a.jsxs("div",{className:at.editFieldWrapper,children:[a.jsx("input",{className:`${at.editInput} ${C?at.editInputInvalid:""}`,value:s,onChange:T,maxLength:_,placeholder:v,"aria-label":b,"data-testid":x?`${x}-input`:void 0}),C&&a.jsx("span",{className:at.editError,"data-testid":"edit-error",children:C})]})}if(j.isEditing)return a.jsxs("div",{className:at.editFieldWrapper,children:[a.jsx("input",{ref:S,className:`${at.editInput} ${j.error?at.editInputInvalid:""}`,value:j.draft,onChange:T=>j.setDraft(T.target.value),onBlur:j.handleBlur,onKeyDown:j.handleKeyDown,maxLength:_,placeholder:v,"aria-label":b,"data-testid":x?`${x}-input`:void 0}),j.isDirty&&a.jsx("span",{className:at.unsavedDot,title:"Unsaved changes"}),j.error&&a.jsx("span",{className:at.editError,"data-testid":"edit-error",children:j.error}),a.jsx("span",{className:at.editHint,children:"Enter to save · Esc to cancel"})]});const w=g==null?void 0:g(s);return a.jsxs("span",{role:"button",tabIndex:0,className:at.metaValueClickable,onClick:()=>j.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),j.startEdit())},title:"Click to edit","aria-label":b,"data-testid":x?`${x}-button`:void 0,children:[w!==void 0?w:s?a.jsx("span",{children:s}):a.jsx("span",{className:at.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:at.editButton,"aria-hidden":"true",children:"✏️"})]})}function ym(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:_,"data-testid":b}=t,x=y.useRef(null),S=gh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(S.isEditing){const w=window.setTimeout(()=>{var T;(T=x.current)==null||T.focus()},0);return()=>window.clearTimeout(w)}},[S.isEditing]),c==="create"){const w=C=>{m==null||m(C.target.value)},T=r==null?void 0:r(s);return a.jsxs("div",{className:at.editFieldWrapper,children:[a.jsx("textarea",{className:`${at.editTextarea} ${T?at.editInputInvalid:""}`,value:s,onChange:w,placeholder:v,"aria-label":_,"data-testid":b?`${b}-input`:void 0}),T&&a.jsx("span",{className:at.editError,"data-testid":"edit-error",children:T})]})}if(S.isEditing)return a.jsxs("div",{className:at.editFieldWrapper,children:[a.jsx("textarea",{ref:x,className:`${at.editTextarea} ${S.error?at.editInputInvalid:""}`,value:S.draft,onChange:w=>S.setDraft(w.target.value),onBlur:S.handleBlur,onKeyDown:S.handleKeyDown,title:_,"aria-label":_,"data-testid":b?`${b}-input`:void 0}),S.isDirty&&a.jsx("span",{className:at.unsavedDot,title:"Unsaved changes"}),S.error&&a.jsx("span",{className:at.editError,"data-testid":"edit-error",children:S.error}),a.jsx("span",{className:at.editHint,children:"Tab to save · Esc to cancel"})]});const j=g==null?void 0:g(s);return a.jsxs("span",{role:"button",tabIndex:0,className:at.metaValueClickable,onClick:()=>S.startEdit(),onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),S.startEdit())},title:"Click to edit","aria-label":_,"data-testid":b?`${b}-button`:void 0,children:[j!==void 0?j:s?a.jsx("span",{children:s}):a.jsx("span",{className:at.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:at.editButton,"aria-hidden":"true",children:"✏️"})]})}function jd(t){var A;const{value:s,onSave:o,mode:r="edit",options:c,fieldId:d="select",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:_,"data-testid":b}=t,x=y.useRef(null),S=gh({value:s,onSave:o,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(S.isEditing){const L=window.setTimeout(()=>{var E;(E=x.current)==null||E.focus()},0);return()=>window.clearTimeout(L)}},[S.isEditing]);const j=y.useCallback(L=>{const E=L.target.value;S.ignoreInitialBlurRef.current=!1,E!==s&&o(E),S.cancelEdit()},[s,o,S]),w=y.useCallback(L=>{if(S.ignoreInitialBlurRef.current){S.ignoreInitialBlurRef.current=!1;return}L.relatedTarget instanceof HTMLElement&&L.relatedTarget.dataset.editAction===d||S.cancelEdit()},[d,S]);if(r==="create")return a.jsx("select",{className:at.editSelect,value:s,onChange:L=>m==null?void 0:m(L.target.value),"aria-label":_,"data-testid":b?`${b}-select`:void 0,children:c.map(L=>a.jsx("option",{value:L.value,children:L.label},L.value))});if(S.isEditing)return a.jsx("select",{ref:x,className:at.editSelect,value:S.draft,onChange:j,onBlur:w,title:_,"aria-label":_,"data-testid":b?`${b}-select`:void 0,children:c.map(L=>a.jsx("option",{value:L.value,children:L.label},L.value))});const T=g==null?void 0:g(s),C=(A=c.find(L=>L.value===s))==null?void 0:A.label;return a.jsxs("button",{type:"button",className:at.metaValueClickable,onClick:()=>S.startEdit(),title:"Click to change","aria-label":_,"data-testid":b?`${b}-button`:void 0,children:[T!==void 0?T:C?a.jsx("span",{children:C}):a.jsx("span",{className:at.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:at.editButton,"aria-hidden":"true",children:"✏️"})]})}function L5(t){const{checked:s,onChange:o,label:r,ariaLabel:c,"data-testid":d}=t;return a.jsxs("label",{className:at.worktreeToggle,"data-testid":d,children:[a.jsx("input",{type:"checkbox",checked:s,onChange:u=>o(u.target.checked),"aria-label":c}),a.jsx("span",{children:r})]})}const B5="_nav_1snmp_1",$5="_searchForm_1snmp_8",z5="_searchInput_1snmp_15",H5="_searchButton_1snmp_33",P5="_clearButton_1snmp_68",U5="_workspaceSelect_1snmp_85",V5="_listHeader_1snmp_99",q5="_nodeList_1snmp_108",G5="_nodeItem_1snmp_116",F5="_indicator_1snmp_129",Z5="_label_1snmp_136",K5="_badge_1snmp_145",ns={nav:B5,searchForm:$5,searchInput:z5,searchButton:H5,clearButton:P5,workspaceSelect:U5,listHeader:V5,nodeList:q5,nodeItem:G5,indicator:F5,label:Z5,badge:K5};function Y5({nodes:t,workspaces:s,loading:o,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=y.useState(""),v=y.useCallback(S=>{S.preventDefault(),m.trim()&&c(m.trim())},[m,c]),_=y.useCallback(()=>{g(""),d()},[d]),b=y.useCallback(S=>{u(S)},[u]),x=y.useCallback(S=>{g(""),p(S)},[p]);return a.jsxs("div",{className:ns.nav,"data-testid":"knowledge-nav",children:[a.jsxs("form",{className:ns.searchForm,onSubmit:v,children:[a.jsx("input",{className:ns.searchInput,type:"text",placeholder:"Search...",value:m,onChange:S=>{g(S.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),a.jsx("button",{type:"submit",className:ns.searchButton,disabled:o,children:"Go"})]}),r&&a.jsx("button",{type:"button",className:ns.clearButton,onClick:_,children:"Clear search"}),a.jsxs("select",{className:ns.workspaceSelect,onChange:S=>{x(S.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[a.jsx("option",{value:"",children:"All workspaces"}),s.map(S=>a.jsx("option",{value:S.id,children:S.name},S.id))]}),a.jsxs("div",{className:ns.listHeader,children:["Nodes (",t.length,")"]}),a.jsx("ul",{className:ns.nodeList,children:t.map(S=>a.jsxs("li",{className:ns.nodeItem,onClick:()=>{b(S.id)},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),b(S.id))},role:"button",tabIndex:0,children:[a.jsx("span",{className:ns.indicator,style:{backgroundColor:S.kind==="reference"?"#4A9EFF":S.category==="decision"?"#22C55E":S.category==="concept"?"#A855F7":S.category==="snippet"?"#6B7280":"#EAB308"}}),a.jsx("span",{className:ns.label,children:S.label}),a.jsx("span",{className:ns.badge,children:S.kind==="reference"?S.sourceType:S.category})]},S.id))})]})}const J5="_container_bwu10_1",W5="_hamburger_bwu10_33",X5="_brand_bwu10_49",Q5="_brandLogo_bwu10_68",eI="_info_bwu10_75",tI="_connectionLabel_bwu10_90",nI="_connectionDot_bwu10_103",sI="_connected_bwu10_106",aI="_disconnected_bwu10_110",iI="_connecting_bwu10_113",Ms={container:J5,hamburger:W5,brand:X5,brandLogo:Q5,info:eI,connectionLabel:tI,connectionDot:nI,connected:sI,disconnected:aI,connecting:iI},oI={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},rI={connected:Ms.connected,connecting:Ms.connecting,disconnected:Ms.disconnected};function lI({connectionStatus:t,environments:s,sessions:o,onToggleSidebar:r,sidebarOpen:c}){const d=dt(),u=s.length,p=s.filter(v=>v.status==="connected").length,m=o.filter(v=>["running","idle"].includes(v.status)).length,g=oI[t];return a.jsxs("div",{className:Ms.container,children:[r&&a.jsx("button",{type:"button",className:Ms.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:a.jsx(fT,{size:Et,"aria-hidden":"true"})}),a.jsx(Oi,{text:"Home",placement:"bottom",children:a.jsxs("button",{type:"button",className:Ms.brand,onClick:()=>d(Ii),"data-testid":"statusbar-brand",children:[a.jsx("img",{src:"/icon-192x192.png",alt:"",className:Ms.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),a.jsxs("div",{className:Ms.info,children:[a.jsxs("span",{"aria-label":g,children:[a.jsx("span",{className:`${Ms.connectionDot} ${rI[t]}`,"aria-hidden":"true",children:a.jsx(Ja,{size:Nm,fill:"currentColor"})})," ",a.jsx("span",{className:Ms.connectionLabel,"aria-hidden":"true",children:g})]}),a.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),a.jsxs("span",{children:[m," active"]})]})]})}const cI="_nav_13gkc_1",dI="_tab_13gkc_35",uI="_tabIcon_13gkc_68",fI="_tabLabel_13gkc_79",pI="_tabActive_13gkc_84",Gr={nav:cI,tab:dI,tabIcon:uI,tabLabel:fI,tabActive:pI},ld=[{view:"dashboard",label:"Dashboard",icon:a.jsx(Qj,{size:Et}),route:Ii,testId:"sidebar-tab-dashboard"},{view:"chat",label:"Chat",icon:a.jsx(L_,{size:Et}),route:cl,testId:"sidebar-tab-chat"},{view:"tasks",label:"Tasks",icon:a.jsx(Lj,{size:Et}),route:GN,testId:"sidebar-tab-tasks"},{view:"environments",label:"Environments",icon:a.jsx(hT,{size:Et}),route:Bo,testId:"sidebar-tab-environments"},{view:"knowledge",label:"Knowledge",icon:a.jsx(Cj,{size:Et}),route:ix,testId:"sidebar-tab-knowledge"},{view:"findings",label:"Findings",icon:a.jsx(fd,{size:Et}),route:$d,testId:"sidebar-tab-findings"},{view:"settings",label:"Settings",icon:a.jsx(AT,{size:Et}),route:zN,testId:"sidebar-tab-settings"}];function mI(t){return t===Ii||t==="/"?"dashboard":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(ix)?"knowledge":t.startsWith($d)?"findings":t.startsWith(Ai)?"settings":"tasks"}function hI({tabs:t=ld}){const s=Wt(),o=dt(),r=y.useRef(null),c=mI(s.pathname),d=y.useCallback(p=>{o(p.route)},[o]),u=y.useCallback(p=>{var b,x;const m=(b=r.current)==null?void 0:b.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(S=>S===document.activeElement),v=g>=0?g:t.findIndex(S=>S.view===c);let _=v;if(p.key==="ArrowRight"||p.key==="j"||p.key==="J")p.preventDefault(),_=(v+1)%t.length;else if(p.key==="ArrowLeft"||p.key==="k"||p.key==="K")p.preventDefault(),_=(v-1+t.length)%t.length;else if(p.key==="Home")p.preventDefault(),_=0;else if(p.key==="End")p.preventDefault(),_=t.length-1;else return;o(t[_].route),(x=m[_])==null||x.focus()},[c,o,t]);return a.jsx("nav",{className:Gr.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 a.jsx(Oi,{text:p.label,placement:"bottom",children:a.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Gr.tab} ${m?Gr.tabActive:""}`,onClick:()=>d(p),"data-testid":p.testId,"aria-label":p.label,children:[a.jsx("span",{className:Gr.tabIcon,"aria-hidden":"true",children:p.icon}),a.jsx("span",{className:Gr.tabLabel,children:p.label})]})},p.view)})})}const gI="_container_pi6ii_1",vI="_content_pi6ii_66",s_={container:gI,content:vI},yI=320,P1=220,U1=600,V1="grackle-sidebar-width";function bI(){try{const t=localStorage.getItem(V1);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=P1&&s<=U1)return s}}catch{}return yI}function _I(t){try{localStorage.setItem(V1,String(t))}catch{}}function xI({content:t}){const[s]=y.useState(bI),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>=P1&&m<=U1&&_I(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return a.jsx("div",{className:s_.container,ref:o,"data-testid":"sidebar",style:{width:s},children:a.jsx("div",{className:s_.content,children:t})})}const kI="_bar_tnfsh_1",SI="_btnPrimary_tnfsh_32",jI="_statusText_tnfsh_85",TI="_statusCompleted_tnfsh_90",wI="_statusFailed_tnfsh_94",NI="_statusBlocked_tnfsh_98",CI="_hintText_tnfsh_103",Ct={bar:kI,btnPrimary:SI,statusText:jI,statusCompleted:TI,statusFailed:wI,statusBlocked:NI,hintText:CI};function EI({sessions:t,tasks:s,environments:o}){const r=dt(),c=Wt(),d=Dt("/sessions/:sessionId"),u=Dt("/tasks/:taskId"),p=Dt("/tasks/:taskId/stream"),m=Dt("/tasks/:taskId/findings"),g=Dt("/tasks/:taskId/edit"),v=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),_=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),b=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings"),x=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),S=Dt("/sessions/new"),j=Dt("/environments/:environmentId/workspaces/:workspaceId"),w=Dt("/tasks/new"),T=Dt("/chat"),C=Dt("/"),A=Dt("/settings/*"),L=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)??(_==null?void 0:_.params.taskId)??(b==null?void 0:b.params.taskId)??(x==null?void 0:x.params.taskId),M=v??_??b??x,H=(M==null?void 0:M.params.environmentId)??(j==null?void 0:j.params.environmentId),D=c.pathname.startsWith("/environments")&&!j&&!M,z=!!T,Y=!!S,V=!!j&&!v&&!_&&!b&&!x,Q=!!w;if(!!C&&!Y&&!V&&!Q||!!A||(!!g||!!x)||Q||D||Y)return a.jsx(a.Fragment,{});if(z)return o.find(R=>R.adapterType==="local"&&R.status==="connected")?a.jsx(a.Fragment,{}):a.jsx("div",{className:Ct.bar,children:a.jsx("span",{className:Ct.hintText,children:"Add a local environment to start chatting"})});if(V)return a.jsx("div",{className:Ct.bar,children:a.jsx("span",{className:Ct.hintText,children:"Select a task or click + to create one"})});if(E){const B=s.find(me=>me.id===E);if(!B)return a.jsx("div",{className:Ct.bar,children:a.jsx("span",{className:Ct.hintText,children:"Loading..."})});const R=new Map(s.map(me=>[me.id,me])),Z=B.dependsOn.some(me=>{const q=R.get(me);return q!==void 0&&q.status!=="complete"});if(B.status==="not_started"){const me=Z?B.dependsOn.map(q=>R.get(q)).filter(q=>q&&q.status!=="complete").map(q=>q.title):[];return a.jsx("div",{className:Ct.bar,children:Z?a.jsxs("span",{className:Ct.statusBlocked,children:["Blocked by: ",me.join(", ")]}):a.jsx("span",{className:Ct.hintText,children:"Use the buttons above to start or manage this task"})})}if(B.status==="working"||B.status==="paused"){const me=B.latestSessionId||void 0,q=me?t.find(de=>de.id===me):void 0;return q&&q.status!=="stopped"?a.jsx(a.Fragment,{}):a.jsx("div",{className:Ct.bar,children:a.jsx("span",{className:Ct.hintText,children:"Waiting for agent..."})})}if(B.status==="complete")return a.jsxs("div",{className:Ct.bar,children:[a.jsx("span",{className:`${Ct.statusText} ${Ct.statusCompleted}`,children:"Task completed"}),a.jsx("button",{onClick:()=>r($i(B.workspaceId,void 0,H)),className:Ct.btnPrimary,children:"+ New Task"})]});if(B.status==="failed")return a.jsx("div",{className:Ct.bar,children:a.jsx("span",{className:`${Ct.statusText} ${Ct.statusFailed}`,children:"Task failed"})})}if(L){const B=t.find(me=>me.id===L),R=(B==null?void 0:B.status)==="stopped";if(B!==void 0&&!R)return a.jsx(a.Fragment,{});if(R)return a.jsxs("div",{className:Ct.bar,children:[a.jsxs("span",{className:`${Ct.statusText} ${Ct.hintText}`,children:["Session ",B.endReason||B.status]}),a.jsx("button",{onClick:()=>r(tx(B.environmentId)),className:Ct.btnPrimary,children:"+ New Chat"})]})}return a.jsx("div",{className:Ct.bar,children:a.jsx("span",{className:Ct.hintText,children:"Loading..."})})}const AI="_nav_14i94_1",DI="_tab_14i94_24",RI="_tabActive_14i94_62",MI="_tabLabel_14i94_75",II="_statusDot_14i94_81",OI="_pulse_14i94_87",LI="_addButton_14i94_99",BI="_empty_14i94_132",qa={nav:AI,tab:DI,tabActive:RI,tabLabel:MI,statusDot:II,pulse:OI,addButton:LI,empty:BI},$I={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function zI({environments:t}){const s=dt(),o=y.useRef(null),r=Dt("/environments/:environmentId"),c=Dt("/environments/:environmentId/edit"),d=Dt("/environments/:environmentId/workspaces/:workspaceId"),u=Dt("/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(b=>{s(Mi(b))},[s]),v=y.useCallback(b=>{var T;const x=(T=o.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!x||x.length===0)return;const S=Array.from(x).findIndex(C=>C===document.activeElement),j=S>=0?S:t.findIndex(C=>C.id===m);let w=j;if(b.key==="ArrowDown"||b.key==="j"||b.key==="J")b.preventDefault(),w=(j+1)%x.length;else if(b.key==="ArrowUp"||b.key==="k"||b.key==="K")b.preventDefault(),w=(j-1+x.length)%x.length;else if(b.key==="Home")b.preventDefault(),w=0;else if(b.key==="End")b.preventDefault(),w=x.length-1;else return;w<t.length&&s(Mi(t[w].id)),x[w].focus()},[m,t,s]),_=m??(t.length>0?t[0].id:void 0);return a.jsxs("div",{className:qa.nav,"data-testid":"environment-nav",children:[a.jsx("nav",{ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(b=>{const x=b.id===m,S=b.id===_,j=$I[b.status]||"var(--text-tertiary)",w=b.status==="connected";return a.jsxs("button",{role:"tab",type:"button","aria-selected":x,tabIndex:S?0:-1,className:`${qa.tab} ${x?qa.tabActive:""}`,onClick:()=>g(b.id),"data-testid":"env-nav-item",children:[a.jsx("span",{className:`${qa.statusDot} ${w?qa.pulse:""}`,style:{color:j},"aria-hidden":"true",children:a.jsx(Ja,{size:Nm,fill:"currentColor"})}),a.jsx("span",{className:qa.tabLabel,title:b.displayName||b.id,children:b.displayName||b.id})]},b.id)})}),a.jsx("button",{type:"button",className:qa.addButton,onClick:()=>s(BN),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&a.jsx("div",{className:qa.empty,children:"No environments yet."})]})}function Uo(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()}`}function q1(t){const s=new Date(t);if(Number.isNaN(s.getTime()))return"—";const o=new Date,r=s.getTime()-o.getTime();if(r<=0)return"overdue";const c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return`in ${c}s`;if(d<60)return`in ${d}m`;if(u<24)return`in ${u}h`;if(p<7)return`in ${p} day${p===1?"":"s"}`;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 a_={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 Td(t){return a_[t]||a_.general}const HI="_nav_dlm8m_1",PI="_categoryPills_dlm8m_24",UI="_categoryPill_dlm8m_24",VI="_tab_dlm8m_42",qI="_tabActive_dlm8m_80",GI="_tabContent_dlm8m_93",FI="_tabLabel_dlm8m_100",ZI="_tabMeta_dlm8m_106",KI="_categoryDot_dlm8m_111",YI="_empty_dlm8m_118",Ds={nav:HI,categoryPills:PI,categoryPill:UI,tab:VI,tabActive:qI,tabContent:GI,tabLabel:FI,tabMeta:ZI,categoryDot:KI,empty:YI};function JI({findings:t,workspaceId:s,environmentId:o}){const r=dt(),c=y.useRef(null),d=Dt("/findings/:findingId"),u=Dt("/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 b=new Set(t.map(x=>x.category).filter(Boolean));return Array.from(b).sort()},[t]),g=y.useCallback(b=>{r(Qp(b,s,o))},[r,s,o]),v=y.useCallback(b=>{var T;const x=(T=c.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!x||x.length===0)return;const S=Array.from(x).findIndex(C=>C===document.activeElement),j=S>=0?S:t.findIndex(C=>C.id===p);let w=j;if(b.key==="ArrowDown"||b.key==="j"||b.key==="J")b.preventDefault(),w=(j+1)%x.length;else if(b.key==="ArrowUp"||b.key==="k"||b.key==="K")b.preventDefault(),w=(j-1+x.length)%x.length;else if(b.key==="Home")b.preventDefault(),w=0;else if(b.key==="End")b.preventDefault(),w=x.length-1;else return;w<t.length&&r(Qp(t[w].id,s,o)),x[w].focus()},[p,t,r,s,o]),_=p??(t.length>0?t[0].id:void 0);return a.jsxs("div",{className:Ds.nav,"data-testid":"findings-nav",children:[m.length>1&&a.jsx("div",{className:Ds.categoryPills,"data-testid":"findings-nav-categories",children:m.map(b=>a.jsx("span",{className:Ds.categoryPill,style:{color:Td(b).text},children:b},b))}),a.jsx("nav",{ref:c,role:"tablist","aria-orientation":"vertical","aria-label":"Findings",onKeyDown:v,children:t.map(b=>{const x=b.id===p,S=b.id===_;return a.jsxs("button",{role:"tab",type:"button","aria-selected":x,tabIndex:S?0:-1,className:`${Ds.tab} ${x?Ds.tabActive:""}`,onClick:()=>g(b.id),"data-testid":"finding-nav-item",children:[a.jsx("span",{className:Ds.categoryDot,style:{color:Td(b.category).text},"aria-hidden":"true",children:a.jsx(Ja,{size:Nm,fill:"currentColor"})}),a.jsxs("span",{className:Ds.tabContent,children:[a.jsx("span",{className:Ds.tabLabel,title:b.title,children:b.title}),a.jsx("span",{className:Ds.tabMeta,title:b.createdAt,children:Uo(b.createdAt)})]})]},b.id)})}),t.length===0&&a.jsx("div",{className:Ds.empty,children:"No findings yet. Agents will post discoveries here."})]})}function WI(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 G1({text:t,indices:s,highlightClass:o}){if(!s||s.length===0)return a.jsx(a.Fragment,{children:t});const r=WI(s),c=[];let d=0;for(const[u,p]of r)u>d&&c.push(a.jsx("span",{children:t.slice(d,u)},`p${d}`)),c.push(a.jsx("mark",{className:o,children:t.slice(u,p+1)},`m${u}`)),d=p+1;return d<t.length&&c.push(a.jsx("span",{children:t.slice(d)},`p${d}`)),a.jsx(a.Fragment,{children:c})}function XI(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 QI(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 PT){c.add(d);const u=o.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=Wa(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=Wa(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const eO="_container_z4i38_1",tO="_header_z4i38_5",nO="_headerActions_z4i38_17",sO="_searchInput_z4i38_23",aO="_searchHighlight_z4i38_56",iO="_groupToggle_z4i38_62",oO="_groupToggleActive_z4i38_89",rO="_addButton_z4i38_93",lO="_taskRow_z4i38_120",cO="_selected_z4i38_140",dO="_expandArrow_z4i38_150",uO="_expanded_z4i38_157",fO="_leafSpacer_z4i38_161",pO="_taskStatusIcon_z4i38_166",mO="_taskTitle_z4i38_170",hO="_workspaceBadge_z4i38_177",gO="_childCountBadge_z4i38_195",vO="_dependencyBadge_z4i38_208",yO="_blockedBadge_z4i38_220",bO="_addChildButton_z4i38_225",_O="_emptyState_z4i38_268",xO="_statusGroupHeader_z4i38_275",kO="_statusGroupIcon_z4i38_294",SO="_statusGroupLabel_z4i38_298",jO="_statusGroupCount_z4i38_303",Ye={container:eO,header:tO,headerActions:nO,searchInput:sO,searchHighlight:aO,groupToggle:iO,groupToggleActive:oO,addButton:rO,taskRow:lO,selected:cO,expandArrow:dO,expanded:uO,leafSpacer:fO,taskStatusIcon:pO,taskTitle:mO,workspaceBadge:hO,childCountBadge:gO,dependencyBadge:vO,blockedBadge:yO,addChildButton:bO,emptyState:_O,statusGroupHeader:xO,statusGroupIcon:kO,statusGroupLabel:SO,statusGroupCount:jO},TO=[{name:"title",weight:2},{name:"description",weight:1}],F1=16,wO=16,Z1="grackle-task-group-by-status";function i_(){try{return localStorage.getItem(Z1)==="true"}catch{return!1}}function NO(t){try{localStorage.setItem(Z1,String(t))}catch{}}function CO({group:t,isExpanded:s,onToggle:o,selectedTaskId:r,navigate:c,titleHighlights:d,workspaceNames:u}){return a.jsxs("div",{"data-testid":`status-group-${t.status}`,children:[a.jsxs("div",{className:Ye.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:o,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),o())},children:[a.jsx("span",{className:`${Ye.expandArrow} ${s?Ye.expanded:""}`,"aria-hidden":"true",children:a.jsx(ma,{size:it})}),a.jsx("span",{className:Ye.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),a.jsx("span",{className:Ye.statusGroupLabel,children:t.label}),a.jsx("span",{className:Ye.statusGroupCount,children:t.tasks.length})]}),a.jsx(ls,{children:s&&a.jsx(At.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=Wa(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return a.jsxs("div",{onClick:()=>c(Hn(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:_=>{_.currentTarget===_.target&&(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),c(Hn(p.id)))},className:`${Ye.taskRow} ${g?Ye.selected:""}`,style:{"--task-indent":`${F1}px`},"data-task-id":p.id,children:[a.jsx("span",{className:Ye.leafSpacer}),a.jsx("span",{className:Ye.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${gl(p.status)}`,children:m.icon}),a.jsx("span",{className:Ye.taskTitle,title:p.title,children:a.jsx(G1,{text:p.title,indices:d.get(p.id),highlightClass:Ye.searchHighlight})}),v&&a.jsx("span",{className:Ye.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function K1({node:t,depth:s,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=Wa(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(T=>u.get(T)!=="complete"),_=o.has(t.id),b=t.children.length>0,x=c===t.id,S=F1+s*wO,w=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{onClick:()=>d(Hn(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:T=>{T.currentTarget===T.target&&(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),d(Hn(t.id)))},className:`${Ye.taskRow} ${x?Ye.selected:""}`,style:{"--task-indent":`${S}px`},"data-task-id":t.id,children:[b&&a.jsx("span",{className:`${Ye.expandArrow} ${_?Ye.expanded:""}`,role:"button",tabIndex:0,"aria-label":_?"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:a.jsx(ma,{size:it,"aria-hidden":"true"})}),!b&&a.jsx("span",{className:Ye.leafSpacer}),a.jsx("span",{className:Ye.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${gl(t.status)}`,children:g.icon}),a.jsx("span",{className:Ye.taskTitle,title:t.title,children:a.jsx(G1,{text:t.title,indices:p.get(t.id),highlightClass:Ye.searchHighlight})}),w&&a.jsx("span",{className:Ye.workspaceBadge,title:w,children:w}),b&&a.jsxs("span",{className:Ye.childCountBadge,children:[t.children.filter(T=>T.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&a.jsx("span",{className:`${Ye.dependencyBadge} ${v?Ye.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<H2&&a.jsx(Oi,{text:"Add child task",children:a.jsx("button",{onClick:T=>{T.stopPropagation(),d($i(t.workspaceId,t.id))},"aria-label":"Add child task",className:Ye.addChildButton,children:"+"})})]}),a.jsx(ls,{children:b&&_&&a.jsx(At.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=>a.jsx(K1,{node:T,depth:s+1,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},T.id))})})]})}function EO({workspaces:t,tasks:s}){const o=dt(),[r,c]=y.useState(new Set),[d,u]=y.useState(new Set),[p,m]=y.useState(i_),[g,v]=y.useState(i_),[_,b]=y.useState(new Map),x=Dt("/tasks/:taskId/*"),S=(x==null?void 0:x.params.taskId)!=="new"?x==null?void 0:x.params.taskId:void 0,j=y.useMemo(()=>new Map(s.map(X=>[X.id,X.status])),[s]),w=y.useMemo(()=>new Map(t.map(X=>[X.id,X.name])),[t]),T=()=>{const X=!p;NO(X),m(X),X&&(v(!0),b(new Map))},C=X=>{b(re=>{const B=new Map(re),R=B.has(X)?B.get(X):g;return B.set(X,!R),B})},A=X=>_.has(X)?_.get(X):g,L=X=>{c(re=>{const B=new Set(re);return B.has(X)?(B.delete(X),u(R=>new Set(R).add(X))):(B.add(X),u(R=>{const Z=new Set(R);return Z.delete(X),Z})),B})};y.useEffect(()=>{const X=new Set(s.filter(re=>re.parentTaskId).map(re=>re.parentTaskId));X.size>0&&c(re=>{const B=new Set(re);for(const R of X)d.has(R)||B.add(R);return B})},[s,d]);const[E,M]=y.useState(""),{directMatchTaskIds:H,treeMatchTaskIds:D,titleHighlights:z}=y.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const X=z2(s,E,TO),re=new Set(X.map(me=>me.item.id)),B=new Map;for(const me of X){const q=me.matches.find(le=>le.key==="title");q&&B.set(me.item.id,q.indices)}const R=new Set(re),Z=new Map(s.map(me=>[me.id,me]));for(const me of[...re]){let q=Z.get(me);for(;q!=null&&q.parentTaskId;)R.add(q.parentTaskId),q=Z.get(q.parentTaskId)}return{directMatchTaskIds:re,treeMatchTaskIds:R,titleHighlights:B}},[E,s]),Y=H!==null,V=Y?p?H:D:null,Q=V?s.filter(X=>V.has(X.id)):s,ge=p?[]:XI(Q);return a.jsxs("div",{className:Ye.container,children:[a.jsxs("div",{className:Ye.header,children:[a.jsx("span",{children:"Tasks"}),a.jsxs("div",{className:Ye.headerActions,children:[a.jsx(Oi,{text:p?"Switch to tree view":"Group tasks by status",children:a.jsx("button",{className:`${Ye.groupToggle} ${p?Ye.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:a.jsx(lT,{size:Ut})})}),a.jsx(Oi,{text:"New task",children:a.jsx("button",{className:Ye.addButton,onClick:()=>o($i()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&a.jsx("input",{type:"text",value:E,onChange:X=>M(X.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:Ye.searchInput,"data-testid":"sidebar-search"}),p?QI(Q,j).map(X=>a.jsx(CO,{group:X,isExpanded:A(X.status),onToggle:()=>C(X.status),selectedTaskId:S,navigate:o,titleHighlights:z,workspaceNames:w},X.status)):ge.map(X=>a.jsx(K1,{node:X,depth:0,expandedTasks:r,toggleTask:L,selectedTaskId:S,navigate:o,taskStatusById:j,titleHighlights:z,workspaceNames:w},X.id)),Q.length===0&&!Y&&a.jsx("div",{className:Ye.emptyState,children:"No tasks yet. Click + to create one."}),Q.length===0&&Y&&a.jsx("div",{className:Ye.emptyState,children:"No matching tasks"})]})}const AO="_toast_ed2dk_1",DO="_success_ed2dk_18",RO="_icon_ed2dk_22",MO="_error_ed2dk_25",IO="_warning_ed2dk_32",OO="_info_ed2dk_38",LO="_message_ed2dk_53",BO="_close_ed2dk_60",Fr={toast:AO,success:DO,icon:RO,error:MO,warning:IO,info:OO,message:LO,close:BO},$O={success:a.jsx(Li,{size:Et}),error:a.jsx($s,{size:Et}),warning:a.jsx(wm,{size:Et}),info:a.jsx(Tm,{size:Et})};function zO({toast:t,onDismiss:s}){return y.useEffect(()=>{const o=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(o)},[t.id,t.duration,s]),a.jsxs(At.div,{className:`${Fr.toast} ${Fr[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:[a.jsx("span",{className:Fr.icon,"aria-hidden":"true",children:$O[t.variant]}),a.jsx("span",{className:Fr.message,children:t.message}),a.jsx("button",{type:"button",className:Fr.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:a.jsx($s,{size:Ut,"aria-hidden":"true"})})]})}const HO="_container_qqse2_1",PO={container:HO};function UO({toasts:t,onDismiss:s}){return a.jsx("div",{className:PO.container,"data-testid":"toast-container",children:a.jsx(ls,{children:t.map(o=>a.jsx(zO,{toast:o,onDismiss:s},o.id))})})}const VO="_callout_e5awm_1",qO="_success_e5awm_11",GO="_icon_e5awm_15",FO="_error_e5awm_18",ZO="_warning_e5awm_25",KO="_info_e5awm_32",YO="_content_e5awm_48",JO="_close_e5awm_53",Zr={callout:VO,success:qO,icon:GO,error:FO,warning:ZO,info:KO,content:YO,close:JO},WO={success:a.jsx(Li,{size:Et}),error:a.jsx($s,{size:Et}),warning:a.jsx(wm,{size:Et}),info:a.jsx(Tm,{size:Et})};function XO({variant:t="info",children:s,dismissible:o=!1,className:r}){const[c,d]=y.useState(!1);return a.jsx(a.Fragment,{children:!c&&a.jsxs("div",{className:[Zr.callout,Zr[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[a.jsx("span",{className:Zr.icon,"aria-hidden":"true",children:WO[t]}),a.jsx("span",{className:Zr.content,children:s}),o&&a.jsx("button",{type:"button",className:Zr.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:a.jsx($s,{size:Ut,"aria-hidden":"true"})})]})})}function QO({currentVersion:t,latestVersion:s,updateAvailable:o,isDocker:r}){if(!o)return a.jsx(a.Fragment,{});const c=r?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return a.jsx("div",{"data-testid":"update-banner",children:a.jsxs(XO,{variant:"info",dismissible:!0,children:[a.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",t,")."," ","Run: ",a.jsx("code",{children:c})]})})}const eL="_container_de44x_1",tL="_emptyState_de44x_8",nL="_card_de44x_14",sL="_cardClickable_de44x_34",aL="_cardHeader_de44x_42",iL="_categoryBadge_de44x_54",oL="_findingTitle_de44x_62",rL="_findingDate_de44x_68",lL="_findingContent_de44x_80",cL="_tags_de44x_86",dL="_tag_de44x_86",bs={container:eL,emptyState:tL,card:nL,cardClickable:sL,cardHeader:aL,categoryBadge:iL,findingTitle:oL,findingDate:rL,findingContent:lL,tags:cL,tag:dL};function Y1({findings:t,onFindingClick:s}){return t.length===0?a.jsx("div",{className:bs.emptyState,children:"No findings yet. Agents will post discoveries here."}):a.jsx("div",{className:bs.container,children:t.map((o,r)=>{const c=Td(o.category),d=s?At.button:At.div;return a.jsxs(d,{type:s?"button":void 0,className:`${bs.card} ${s?bs.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:[a.jsxs("div",{className:bs.cardHeader,children:[a.jsx("span",{className:bs.categoryBadge,style:{background:c.bg,color:c.text},children:o.category}),a.jsx("span",{className:bs.findingTitle,children:o.title}),a.jsx("span",{className:bs.findingDate,title:o.createdAt,children:Uo(o.createdAt)})]}),a.jsx("div",{className:bs.findingContent,children:o.content.length>300?o.content.slice(0,300)+"...":o.content}),o.tags.length>0&&a.jsx("div",{className:bs.tags,children:o.tags.map(u=>a.jsx("span",{className:bs.tag,style:{color:c.text,textShadow:`0 0 8px ${c.text}`},children:u},u))})]},o.id)})})}const uL="_container_m1fsr_1",fL="_heading_m1fsr_7",pL="_section_m1fsr_14",mL="_sectionTitle_m1fsr_26",hL="_sectionDescription_m1fsr_35",gL="_emptyState_m1fsr_41",vL="_tokenList_m1fsr_48",yL="_tokenRow_m1fsr_55",bL="_tokenBadge_m1fsr_68",_L="_tokenName_m1fsr_83",xL="_tokenTarget_m1fsr_90",kL="_deleteButton_m1fsr_99",SL="_addForm_m1fsr_113",jL="_formRow_m1fsr_119",TL="_input_m1fsr_125",wL="_select_m1fsr_155",NL="_addButton_m1fsr_187",CL="_emptyStateInfo_m1fsr_221",EL="_themeOptions_m1fsr_229",AL="_themeOption_m1fsr_229",DL="_themeOptionSelected_m1fsr_254",RL="_themeOptionHeader_m1fsr_259",ML="_themeOptionLabel_m1fsr_266",IL="_themeOptionDesc_m1fsr_273",OL="_variantToggle_m1fsr_279",LL="_variantButton_m1fsr_286",BL="_variantActive_m1fsr_305",$L="_themeSwatches_m1fsr_311",zL="_themeSwatch_m1fsr_311",HL="_systemToggle_m1fsr_325",PL="_systemToggleHint_m1fsr_341",UL="_themeActive_m1fsr_348",VL="_aboutGrid_m1fsr_354",qL="_aboutItem_m1fsr_360",GL="_aboutLabel_m1fsr_373",FL="_aboutValue_m1fsr_379",ZL="_aboutDot_m1fsr_387",KL="_aboutDotConnected_m1fsr_394",YL="_aboutDotDisconnected_m1fsr_398",JL="_aboutDotConnecting_m1fsr_402",ue={container:uL,heading:fL,section:pL,sectionTitle:mL,sectionDescription:hL,emptyState:gL,tokenList:vL,tokenRow:yL,tokenBadge:bL,tokenName:_L,tokenTarget:xL,deleteButton:kL,addForm:SL,formRow:jL,input:TL,select:wL,addButton:NL,emptyStateInfo:CL,themeOptions:EL,themeOption:AL,themeOptionSelected:DL,themeOptionHeader:RL,themeOptionLabel:ML,themeOptionDesc:IL,variantToggle:OL,variantButton:LL,variantActive:BL,themeSwatches:$L,themeSwatch:zL,systemToggle:HL,systemToggleHint:PL,themeActive:UL,aboutGrid:VL,aboutItem:qL,aboutLabel:GL,aboutValue:FL,aboutDot:ZL,aboutDotConnected:KL,aboutDotDisconnected:YL,aboutDotConnecting:JL},WL=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function XL({tokens:t,onSetToken:s,onDeleteToken:o,onShowToast:r}){const[c,d]=y.useState(""),[u,p]=y.useState(""),[m,g]=y.useState("env_var"),[v,_]=y.useState(""),[b,x]=y.useState(null),S=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(""),_("")},j=T=>{x(T)},w=()=>{b&&(o(b),r==null||r("Token deleted","info")),x(null)};return a.jsxs(a.Fragment,{children:[a.jsx(ks,{isOpen:b!==null,title:"Delete Token?",description:b?`"${b}" will be permanently removed.`:void 0,onConfirm:w,onCancel:()=>x(null)}),a.jsxs("section",{className:ue.section,children:[a.jsx("h3",{className:ue.sectionTitle,children:"Tokens"}),a.jsx("p",{className:ue.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?a.jsx("div",{className:ue.emptyStateInfo,children:"Add your first API token to enable service integrations."}):a.jsx("div",{className:ue.tokenList,children:t.map(T=>a.jsxs("div",{className:ue.tokenRow,children:[a.jsx("span",{className:ue.tokenBadge,children:T.tokenType}),a.jsx("span",{className:ue.tokenName,children:T.name}),a.jsx("span",{className:ue.tokenTarget,children:T.tokenType==="env_var"?T.envVar:T.filePath}),a.jsx("button",{className:ue.deleteButton,onClick:()=>j(T.name),title:`Delete ${T.name}`,"aria-label":`Delete ${T.name}`,children:a.jsx($s,{size:Ut,"aria-hidden":"true"})})]},T.name))}),a.jsxs("form",{className:ue.addForm,onSubmit:S,children:[a.jsxs("div",{className:ue.formRow,children:[a.jsx("input",{className:ue.input,type:"text",placeholder:"Token name",value:c,onChange:T=>d(T.target.value)}),a.jsx("input",{className:ue.input,type:"password",placeholder:"Value",value:u,onChange:T=>p(T.target.value)})]}),a.jsxs("div",{className:ue.formRow,children:[a.jsx("select",{className:ue.select,value:m,onChange:T=>g(T.target.value),children:WL.map(T=>a.jsx("option",{value:T.value,children:T.label},T.value))}),a.jsx("input",{className:ue.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=>_(T.target.value)}),a.jsx("button",{className:ue.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const Gd=[{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"]}],J1=new Set(Gd.map(t=>t.id)),o_="grackle";function bm(t){return Gd.find(s=>s.id===t)}function QL({themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c}){return a.jsxs("section",{className:ue.section,children:[a.jsx("h3",{className:ue.sectionTitle,children:"Appearance"}),a.jsx("p",{className:ue.sectionDescription,children:"Choose how Grackle looks across the app."}),a.jsx("div",{className:ue.themeOptions,children:Gd.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 a.jsxs("button",{type:"button",className:`${ue.themeOption} ${p?ue.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>o(d.id),children:[a.jsxs("span",{className:ue.themeOptionHeader,children:[a.jsxs("span",{children:[a.jsx("span",{className:ue.themeOptionLabel,children:d.label}),a.jsx("span",{className:ue.themeOptionDesc,children:d.description})]}),u&&a.jsxs("span",{className:ue.variantToggle,children:[a.jsx("span",{role:"button",tabIndex:0,className:`${ue.variantButton} ${p&&m?ue.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:"☼"}),a.jsx("span",{role:"button",tabIndex:0,className:`${ue.variantButton} ${p&&!m?ue.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&&a.jsx("span",{className:ue.themeSwatches,children:d.swatches.map((g,v)=>a.jsx("span",{className:ue.themeSwatch,style:{background:g}},v))})]},d.id)})}),a.jsxs("label",{className:ue.systemToggle,children:[a.jsx("input",{type:"checkbox",checked:r,onChange:d=>c(d.target.checked)}),a.jsx("span",{children:"Match system light/dark preference"})]}),a.jsx("p",{className:ue.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),a.jsxs("p",{className:ue.themeActive,children:["Active theme: ",a.jsx("strong",{children:s})]})]})}const eB={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},tB={connected:ue.aboutDotConnected,connecting:ue.aboutDotConnecting,disconnected:ue.aboutDotDisconnected};function nB({connectionStatus: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 a.jsxs("section",{className:ue.section,"data-testid":"about-panel",children:[a.jsx("h3",{className:ue.sectionTitle,children:"About"}),a.jsx("p",{className:ue.sectionDescription,children:"Connection status and application information."}),a.jsxs("div",{className:ue.aboutGrid,children:[a.jsxs("div",{className:ue.aboutItem,children:[a.jsx("span",{className:ue.aboutLabel,children:"Connection"}),a.jsxs("span",{className:ue.aboutValue,children:[a.jsx("span",{className:`${ue.aboutDot} ${tB[t]}`}),eB[t]]})]}),a.jsxs("div",{className:ue.aboutItem,children:[a.jsx("span",{className:ue.aboutLabel,children:"Environments"}),a.jsxs("span",{className:ue.aboutValue,children:[r,"/",c," connected"]})]}),a.jsxs("div",{className:ue.aboutItem,children:[a.jsx("span",{className:ue.aboutLabel,children:"Active Sessions"}),a.jsx("span",{className:ue.aboutValue,children:d})]}),a.jsxs("div",{className:ue.aboutItem,children:[a.jsx("span",{className:ue.aboutLabel,children:"Version"}),a.jsx("span",{className:ue.aboutValue,children:"0.108.1"})]})]})]})}const sB="_container_cddyd_1",aB="_header_cddyd_8",iB="_headerTitle_cddyd_35",oB="_badge_cddyd_44",rB="_headerActions_cddyd_54",lB="_body_cddyd_61",cB="_formContent_cddyd_73",dB="_section_cddyd_85",uB="_label_cddyd_91",fB="_titleInput_cddyd_98",pB="_descriptionTextarea_cddyd_131",mB="_parentContext_cddyd_167",hB="_parentLabel_cddyd_175",gB="_parentName_cddyd_182",vB="_personaSelect_cddyd_186",yB="_depList_cddyd_220",bB="_depItem_cddyd_226",_B="_depItemSelected_cddyd_248",xB="_noDeps_cddyd_252",kB="_btnPrimary_cddyd_258",SB="_btnGhost_cddyd_289",st={container:sB,header:aB,headerTitle:iB,badge:oB,headerActions:rB,body:lB,formContent:cB,section:dB,label:uB,titleInput:fB,descriptionTextarea:pB,parentContext:mB,parentLabel:hB,parentName:gB,personaSelect:vB,depList:yB,depItem:bB,depItemSelected:_B,noDeps:xB,btnPrimary:kB,btnGhost:SB};function W1({mode:t,taskId:s,workspaceId:o,parentTaskId:r,environmentId:c,tasks:d,workspaces:u,personas:p,onCreateTask:m,onUpdateTask:g,onEditDone:v,onShowToast:_}){const b=dt(),x=t==="edit",S=x&&s?d.find(Se=>Se.id===s):void 0,j=x?(S==null?void 0:S.workspaceId)??"":o??"",[w,T]=y.useState(j),C=j||w,A=u.find(Se=>Se.id===C),L=c??(A==null?void 0:A.linkedEnvironmentIds[0]),E=!x&&!o,M=x?(S==null?void 0:S.parentTaskId)??"":r??"",H=M?d.find(Se=>Se.id===M):void 0,[D,z]=y.useState((S==null?void 0:S.title)??""),[Y,V]=y.useState((S==null?void 0:S.description)??""),[Q,ge]=y.useState((S==null?void 0:S.dependsOn)??[]),[X,re]=y.useState((S==null?void 0:S.defaultPersonaId)??""),[B,R]=y.useState((S==null?void 0:S.canDecompose)??!1),[Z,me]=y.useState(!1),q=y.useRef(!1);y.useEffect(()=>{x&&S&&!q.current&&(q.current=!0,z(S.title),V(S.description),ge(S.dependsOn),re(S.defaultPersonaId),R(S.canDecompose))},[x,S]);const le=d.filter(Se=>Se.workspaceId===C&&(!x||Se.id!==s)&&Se.id!==M),de=D.trim().length>0&&(!x||S!==void 0)&&C.length>0,xe=Se=>{ge(fe=>fe.includes(Se)?fe.filter(be=>be!==Se):[...fe,Se])},ke=()=>{!de||Z||x&&S===void 0||(x&&s?(g(s,D.trim(),Y,Q,X),_==null||_("Task updated","success"),v?v():b(Hn(s,void 0,C,L),{replace:!0})):(me(!0),m(C,D.trim(),Y,Q.length>0?Q:void 0,M||void 0,X,B,()=>{_==null||_("Task created","success"),b(o?Ri(o,L):"/tasks",{replace:!0})},Se=>{_==null||_(Se,"error"),me(!1)})))},Ze=()=>{if(v){v();return}b(x&&s?Hn(s,void 0,C,L):o?Ri(o,L):"/tasks")},Xe=x?"edit task":M?"child task":"new task";return a.jsxs("div",{className:st.container,children:[a.jsxs("div",{className:st.header,children:[a.jsxs("div",{className:st.headerTitle,children:[a.jsx("span",{className:st.badge,children:Xe}),H&&a.jsxs("span",{className:st.parentContext,children:[a.jsx("span",{className:st.parentLabel,children:"Child of"}),a.jsx("span",{className:st.parentName,children:H.title})]})]}),a.jsxs("div",{className:st.headerActions,children:[a.jsx("button",{onClick:ke,disabled:!de||Z,className:st.btnPrimary,"data-testid":"task-edit-save",children:Z?"Creating…":x?"Save Changes":"Create"}),a.jsx("button",{onClick:Ze,className:st.btnGhost,children:"Cancel"})]})]}),a.jsx("div",{className:st.body,children:a.jsxs("div",{className:st.formContent,children:[E&&a.jsxs("div",{className:st.section,children:[a.jsx("label",{className:st.label,htmlFor:"task-edit-workspace",children:"Workspace"}),a.jsxs("select",{id:"task-edit-workspace",value:w,onChange:Se=>T(Se.target.value),className:st.personaSelect,"data-testid":"task-edit-workspace",children:[a.jsx("option",{value:"",children:"Select a workspace..."}),u.map(Se=>a.jsx("option",{value:Se.id,children:Se.name},Se.id))]})]}),a.jsxs("div",{className:st.section,children:[a.jsx("label",{className:st.label,htmlFor:"task-edit-title",children:"Title"}),a.jsx("input",{id:"task-edit-title",type:"text",value:D,onChange:Se=>z(Se.target.value),placeholder:"Task title...",autoFocus:!0,className:st.titleInput,"data-testid":"task-edit-title",onKeyDown:Se=>{Se.key==="Enter"&&de&&ke()}})]}),a.jsxs("div",{className:st.section,children:[a.jsx("label",{className:st.label,htmlFor:"task-edit-description",children:"Description"}),a.jsx("textarea",{id:"task-edit-description",value:Y,onChange:Se=>V(Se.target.value),placeholder:"Describe the task... (markdown supported)",className:st.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),a.jsxs("div",{className:st.section,children:[a.jsx("label",{className:st.label,htmlFor:"task-edit-persona",children:"Default Persona"}),a.jsxs("select",{id:"task-edit-persona",value:X,onChange:Se=>re(Se.target.value),className:st.personaSelect,"data-testid":"task-edit-persona",children:[a.jsx("option",{value:"",children:"(Inherit)"}),p.map(Se=>a.jsx("option",{value:Se.id,children:Se.name},Se.id))]})]}),!x&&a.jsx("div",{className:st.section,children:a.jsxs("label",{className:st.depItem,"data-testid":"task-edit-can-decompose",children:[a.jsx("input",{type:"checkbox",checked:B,onChange:Se=>R(Se.target.checked)}),"Can spawn subtasks"]})}),a.jsxs("div",{className:st.section,children:[a.jsx("div",{className:st.label,children:"Dependencies"}),le.length===0?a.jsx("div",{className:st.noDeps,children:"No other tasks in this workspace"}):a.jsx("div",{className:st.depList,children:le.map(Se=>{const fe=Q.includes(Se.id);return a.jsxs("label",{className:`${st.depItem} ${fe?st.depItemSelected:""}`,"data-testid":`dep-option-${Se.id}`,children:[a.jsx("input",{type:"checkbox",checked:fe,onChange:()=>xe(Se.id)}),Se.title,a.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",Se.status,")"]})]},Se.id)})})]})]})})]})}const jB="_actionButtons_1rjka_1",TB="_btnPrimary_1rjka_8",wB="_btnDanger_1rjka_39",NB="_btnGhost_1rjka_78",en={actionButtons:jB,btnPrimary:TB,btnDanger:wB,btnGhost:NB};function CB({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?a.jsxs("div",{className:en.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:m,className:en.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),a.jsx("button",{onClick:p,className:en.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):a.jsxs("div",{className:en.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{"data-testid":"task-header-start",onClick:r,className:en.btnPrimary,children:"Start"}),a.jsx("button",{onClick:m,className:en.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),a.jsx("button",{onClick:p,className:en.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return a.jsxs("div",{className:en.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:d,className:en.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),a.jsx("button",{onClick:u,disabled:!s,className:en.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused")return a.jsxs("div",{className:en.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:d,className:en.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),a.jsx("button",{onClick:c,className:en.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),a.jsx("button",{onClick:p,className:en.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="complete")return a.jsx("div",{className:en.actionButtons,"data-testid":"task-action-buttons",children:a.jsx("button",{onClick:p,className:en.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return a.jsxs("div",{className:en.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:r,className:en.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),a.jsx("button",{onClick:p,className:en.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const EB="_workpadSection_y8nj9_1",AB="_workpadLabel_y8nj9_9",DB="_workpadStatus_y8nj9_17",RB="_workpadSummary_y8nj9_23",MB="_workpadExtra_y8nj9_29",Ga={workpadSection:EB,workpadLabel:AB,workpadStatus:DB,workpadSummary:RB,workpadExtra:MB};function IB({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 a.jsxs("div",{className:Ga.workpadSection,"data-testid":"workpad-panel",children:[a.jsx("div",{className:Ga.workpadLabel,children:"Workpad"}),a.jsx("div",{className:Ga.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return a.jsxs("div",{className:Ga.workpadSection,"data-testid":"workpad-panel",children:[a.jsx("div",{className:Ga.workpadLabel,children:"Workpad"}),s.status&&a.jsx("div",{className:Ga.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&a.jsx("div",{className:Ga.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&a.jsx("div",{className:Ga.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const OB="_overviewDashboard_r05qm_1",LB="_overviewHero_r05qm_7",BB="_statusBadge_r05qm_14",$B="_statusPending_r05qm_26",zB="_statusAssigned_r05qm_31",HB="_statusInProgress_r05qm_36",PB="_statusReview_r05qm_41",UB="_statusDone_r05qm_46",VB="_statusFailed_r05qm_51",qB="_statusWaitingInput_r05qm_56",GB="_overviewBranchPill_r05qm_61",FB="_branchLink_r05qm_76",ZB="_overviewSection_r05qm_87",KB="_overviewLabel_r05qm_93",YB="_overviewValue_r05qm_100",JB="_overviewMuted_r05qm_105",WB="_overviewMarkdown_r05qm_111",XB="_envRow_r05qm_180",QB="_envDot_r05qm_186",e8="_envDotGreen_r05qm_193",t8="_envDotYellow_r05qm_197",n8="_envDotRed_r05qm_201",s8="_envDotGray_r05qm_205",a8="_depList_r05qm_209",i8="_depItem_r05qm_215",o8="_depBlocked_r05qm_222",r8="_depDone_r05qm_226",l8="_timeline_r05qm_230",c8="_timelineRow_r05qm_236",d8="_timelineKey_r05qm_243",u8="_timelineValue_r05qm_249",f8="_timelineDelta_r05qm_253",p8="_reviewNotes_r05qm_264",ye={overviewDashboard:OB,overviewHero:LB,statusBadge:BB,statusPending:$B,statusAssigned:zB,statusInProgress:HB,statusReview:PB,statusDone:UB,statusFailed:VB,statusWaitingInput:qB,overviewBranchPill:GB,branchLink:FB,overviewSection:ZB,overviewLabel:KB,overviewValue:YB,overviewMuted:JB,overviewMarkdown:WB,envRow:XB,envDot:QB,envDotGreen:e8,envDotYellow:t8,envDotRed:n8,envDotGray:s8,depList:a8,depItem:i8,depBlocked:o8,depDone:r8,timeline:l8,timelineRow:c8,timelineKey:d8,timelineValue:u8,timelineDelta:f8,reviewNotes:p8};function Yc(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 Lp(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 r_(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?ye.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?ye.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?ye.envDotRed:ye.envDotGray}function m8({status:t}){const s=Wa(t),o=HT(t);return a.jsx("span",{className:`${ye.statusBadge} ${ye[o]??ye.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function h8({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(S=>S.id===g):void 0,_=r.find(S=>S.id===t.workspaceId),b=o.find(S=>S.id===d),x=t.branch&&(_!=null&&_.repoUrl)?`${_.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return a.jsxs("div",{className:ye.overviewDashboard,"data-testid":"task-overview-panel",children:[a.jsxs("div",{className:ye.overviewHero,children:[a.jsx(m8,{status:t.status}),t.branch&&a.jsx("span",{className:ye.overviewBranchPill,"data-testid":"task-overview-branch",children:x?a.jsxs("a",{href:x,target:"_blank",rel:"noreferrer noopener",className:ye.branchLink,children:["🔗"," ",t.branch]}):a.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&a.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-description",children:[a.jsx("div",{className:ye.overviewLabel,children:"Description"}),a.jsx("div",{className:ye.overviewMarkdown,children:a.jsx(Ed,{remarkPlugins:[Ad],children:t.description})})]}),t.workpad&&a.jsx(IB,{workpad:t.workpad}),a.jsxs("div",{className:ye.overviewSection,children:[a.jsx("div",{className:ye.overviewLabel,children:"Environment"}),g&&v?a.jsxs("div",{className:ye.envRow,"data-testid":"task-overview-environment",children:[a.jsx("span",{className:`${ye.envDot} ${r_(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),a.jsx("span",{className:ye.overviewValue,children:v.displayName})]}):b?a.jsxs("div",{className:ye.envRow,"data-testid":"task-overview-environment",children:[a.jsx("span",{className:`${ye.envDot} ${r_(b.status)}`,title:b.status,"aria-label":`Status: ${b.status}`,role:"img"}),a.jsx("span",{className:ye.overviewValue,children:b.displayName}),a.jsx("span",{className:ye.overviewMuted,children:"(workspace default)"})]}):a.jsx("div",{className:ye.overviewMuted,children:"Set in workspace settings"})]}),a.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-dependencies",children:[a.jsx("div",{className:ye.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?a.jsx("div",{className:ye.overviewMuted,children:"None"}):a.jsx("div",{className:ye.depList,children:t.dependsOn.map(S=>{const j=s.get(S),w=(j==null?void 0:j.status)==="complete";return a.jsxs("div",{className:`${ye.depItem} ${w?ye.depDone:ye.depBlocked}`,children:[a.jsx("span",{children:w?"✓":"○"}),a.jsx("span",{children:(j==null?void 0:j.title)??S})]},S)})})]}),a.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-timeline",children:[a.jsx("div",{className:ye.overviewLabel,children:"Timeline"}),a.jsxs("div",{className:ye.timeline,children:[t.createdAt&&a.jsxs("div",{className:ye.timelineRow,children:[a.jsx("span",{className:ye.timelineKey,children:"Created"}),a.jsx("span",{className:ye.timelineValue,children:Yc(t.createdAt)})]}),t.assignedAt&&(()=>{const S=Lp(t.createdAt,t.assignedAt);return a.jsxs("div",{className:ye.timelineRow,children:[a.jsx("span",{className:ye.timelineKey,children:"Assigned"}),a.jsx("span",{className:ye.timelineValue,children:Yc(t.assignedAt)}),S!==void 0&&a.jsx("span",{className:ye.timelineDelta,children:S})]})})(),t.startedAt&&(()=>{const S=Lp(t.assignedAt??t.createdAt,t.startedAt);return a.jsxs("div",{className:ye.timelineRow,children:[a.jsx("span",{className:ye.timelineKey,children:"Started"}),a.jsx("span",{className:ye.timelineValue,children:Yc(t.startedAt)}),S!==void 0&&a.jsx("span",{className:ye.timelineDelta,children:S})]})})(),t.completedAt&&(()=>{const S=Lp(t.startedAt,t.completedAt);return a.jsxs("div",{className:ye.timelineRow,children:[a.jsx("span",{className:ye.timelineKey,children:"Completed"}),a.jsx("span",{className:ye.timelineValue,children:Yc(t.completedAt)}),S!==void 0&&a.jsx("span",{className:ye.timelineDelta,children:S})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&a.jsx("div",{className:ye.overviewMuted,children:"No timing data"})]})]}),u&&u.costMillicents>0&&a.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-usage",children:[a.jsx("div",{className:ye.overviewLabel,children:"Usage"}),a.jsxs("div",{className:ye.timeline,children:[a.jsxs("div",{className:ye.timelineRow,children:[a.jsx("span",{className:ye.timelineKey,children:"Cost"}),a.jsx("span",{className:ye.timelineValue,children:Is(u.costMillicents)}),a.jsxs("span",{className:ye.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costMillicents>u.costMillicents&&a.jsxs("div",{className:ye.timelineRow,children:[a.jsx("span",{className:ye.timelineKey,children:"Total (incl. subtasks)"}),a.jsx("span",{className:ye.timelineValue,children:Is(p.costMillicents)}),a.jsxs("span",{className:ye.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),(t.tokenBudget>0||t.costBudgetMillicents>0)&&a.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-budget",children:[a.jsx("div",{className:ye.overviewLabel,children:"Budget"}),a.jsxs("div",{className:ye.timeline,children:[t.tokenBudget>0&&a.jsxs("div",{className:ye.timelineRow,children:[a.jsx("span",{className:ye.timelineKey,children:"Tokens"}),a.jsxs("span",{className:ye.timelineValue,children:[$o(((u==null?void 0:u.inputTokens)??0)+((u==null?void 0:u.outputTokens)??0))," / ",$o(t.tokenBudget)]})]}),t.costBudgetMillicents>0&&a.jsxs("div",{className:ye.timelineRow,children:[a.jsx("span",{className:ye.timelineKey,children:"Cost"}),a.jsxs("span",{className:ye.timelineValue,children:[Is((u==null?void 0:u.costMillicents)??0)," / ",Is(t.costBudgetMillicents)]})]})]})]}),t.reviewNotes&&a.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-review-notes",children:[a.jsx("div",{className:ye.overviewLabel,children:"Review Notes"}),a.jsx("div",{className:ye.reviewNotes,children:t.reviewNotes})]})]})}function g8({plugins:t,loading:s,onSetPluginEnabled:o}){return a.jsxs("div",{className:ue.container,"data-testid":"plugins-panel",children:[a.jsx("h2",{className:ue.heading,children:"Plugins"}),a.jsxs("div",{className:ue.section,children:[a.jsx("p",{className:ue.sectionDescription,children:"Enable or disable optional Grackle plugins. A server restart is required for changes to take effect."}),s&&a.jsx("p",{className:ue.emptyState,children:"Loading plugins..."}),!s&&t.length===0&&a.jsx("p",{className:ue.emptyState,children:"No plugins found."}),!s&&t.map(r=>{const c=r.enabled!==r.loaded;return a.jsxs("div",{className:ue.tokenRow,"data-testid":`plugin-row-${r.name}`,children:[a.jsxs("div",{style:{flex:1},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[a.jsx("span",{className:ue.tokenName,children:r.name}),r.required&&a.jsx("span",{className:ue.tokenBadge,title:"Required — cannot be disabled",children:"required"})]}),a.jsx("div",{className:ue.tokenTarget,children:r.description}),c&&a.jsx("div",{style:{fontSize:"var(--font-size-xs)",color:"var(--accent-yellow)",marginTop:"2px"},"data-testid":`plugin-restart-notice-${r.name}`,children:"Restart Grackle to apply changes"})]}),a.jsx("label",{style:{display:"flex",alignItems:"center",gap:"6px",cursor:r.required?"not-allowed":"pointer"},title:r.required?"Core is required and cannot be disabled":void 0,children:a.jsx("input",{type:"checkbox",checked:r.enabled,disabled:r.required,onChange:d=>o(r.name,d.target.checked),"data-testid":`plugin-toggle-${r.name}`,"aria-label":`Enable or disable ${r.name} plugin`,style:{accentColor:"var(--accent-green)",width:"16px",height:"16px"}})})]},r.name)})]})]})}function v8({githubAccounts:t,githubAccountsLoading:s,onAddGitHubAccount:o,onUpdateGitHubAccount:r,onRemoveGitHubAccount:c,onImportGitHubAccounts:d,onShowToast:u}){const[p,m]=y.useState(""),[g,v]=y.useState(""),[_,b]=y.useState(!1),[x,S]=y.useState(!1),[j,w]=y.useState(!1),[T,C]=y.useState(null),A=t.find(D=>D.id===T),L=async D=>{if(D.preventDefault(),!(!p.trim()||!g.trim())){S(!0);try{await o(p.trim(),g.trim(),"",_),u==null||u("GitHub account added","success"),m(""),v(""),b(!1)}catch(z){const Y=z instanceof Error?z.message:"Failed to add account";u==null||u(Y,"error")}finally{S(!1)}}},E=async D=>{try{await r(D,{isDefault:!0}),u==null||u("Default account updated","success")}catch(z){const Y=z instanceof Error?z.message:"Failed to update account";u==null||u(Y,"error")}},M=async()=>{if(T)try{await c(T),u==null||u("GitHub account removed","info")}catch(D){const z=D instanceof Error?D.message:"Failed to remove account";u==null||u(z,"error")}finally{C(null)}},H=async()=>{w(!0);try{const D=await d();D.imported>0?u==null||u(`Imported ${D.imported} account(s): ${D.usernames.join(", ")}`,"success"):u==null||u("No new accounts to import","info")}catch(D){const z=D instanceof Error?D.message:"Import failed";u==null||u(z,"error")}finally{w(!1)}};return a.jsxs(a.Fragment,{children:[a.jsx(ks,{isOpen:T!==null,title:"Remove GitHub Account?",description:A?`"${A.label}"${A.username?` (@${A.username})`:""} will be permanently removed.`:void 0,onConfirm:()=>{M().catch(()=>{})},onCancel:()=>C(null)}),a.jsxs("section",{className:ue.section,"data-testid":"github-accounts-panel",children:[a.jsx("h3",{className:ue.sectionTitle,children:"GitHub Accounts"}),a.jsx("p",{className:ue.sectionDescription,children:"Register multiple GitHub accounts to use different identities per environment. The default account is used when no specific account is assigned."}),s&&t.length===0?a.jsx("div",{className:ue.emptyState,children:"Loading..."}):t.length===0?a.jsx("div",{className:ue.emptyStateInfo,children:"No GitHub accounts registered. Add one below or import from the gh CLI."}):a.jsx("div",{className:ue.tokenList,children:t.map(D=>a.jsxs("div",{className:ue.tokenRow,"data-testid":`github-account-row-${D.id}`,children:[D.isDefault&&a.jsx("span",{className:ue.tokenBadge,title:"Default account",children:"default"}),a.jsx("span",{className:ue.tokenName,children:D.label}),D.username&&a.jsxs("span",{className:ue.tokenTarget,children:["@",D.username]}),!D.isDefault&&a.jsx("button",{className:ue.deleteButton,onClick:()=>{E(D.id).catch(()=>{})},title:"Set as default","aria-label":`Set ${D.label} as default`,"data-testid":`github-account-set-default-${D.id}`,children:a.jsx(IT,{size:Ut,"aria-hidden":"true"})}),a.jsx("button",{className:ue.deleteButton,onClick:()=>C(D.id),title:`Remove ${D.label}`,"aria-label":`Remove ${D.label}`,"data-testid":`github-account-remove-${D.id}`,children:a.jsx($s,{size:Ut,"aria-hidden":"true"})})]},D.id))}),a.jsxs("form",{className:ue.addForm,onSubmit:D=>{L(D).catch(()=>{})},children:[a.jsxs("div",{className:ue.formRow,children:[a.jsx("input",{className:ue.input,type:"text",placeholder:"Label (e.g. personal, work)",value:p,onChange:D=>m(D.target.value),"data-testid":"github-account-label-input"}),a.jsx("input",{className:ue.input,type:"password",placeholder:"Personal access token",value:g,onChange:D=>v(D.target.value),"data-testid":"github-account-token-input"})]}),a.jsxs("div",{className:ue.formRow,children:[a.jsxs("label",{className:ue.tokenTarget,style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:_,onChange:D=>b(D.target.checked),"data-testid":"github-account-default-checkbox"}),"Set as default"]}),a.jsx("button",{className:ue.addButton,type:"submit",disabled:!p.trim()||!g.trim()||x,"data-testid":"github-account-add-button",children:x?"Adding...":"Add Account"}),a.jsx("button",{className:ue.addButton,type:"button",onClick:()=>{H().catch(()=>{})},disabled:j,"data-testid":"github-account-import-button",children:j?"Importing...":"Import from gh CLI"})]})]})]})]})}const y8="_container_legrg_1",b8="_header_legrg_8",_8="_headerTitle_legrg_35",x8="_badge_legrg_44",k8="_headerActions_legrg_54",S8="_body_legrg_61",j8="_formContent_legrg_73",T8="_section_legrg_85",w8="_label_legrg_91",N8="_nameInput_legrg_98",C8="_fieldInput_legrg_131",E8="_adapterSelect_legrg_164",A8="_readOnlyValue_legrg_198",D8="_codespaceSection_legrg_204",R8="_codespaceActions_legrg_210",M8="_creatingHint_legrg_216",I8="_errorHint_legrg_222",O8="_btnPrimary_legrg_235",L8="_btnGhost_legrg_266",oe={container:y8,header:b8,headerTitle:_8,badge:x8,headerActions:k8,body:S8,formContent:j8,section:T8,label:w8,nameInput:N8,fieldInput:C8,adapterSelect:E8,readOnlyValue:A8,codespaceSection:D8,codespaceActions:R8,creatingHint:M8,errorHint:I8,btnPrimary:O8,btnGhost:L8},cd=1,dd=65535;function Bp(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=cd&&s<=dd}function $p(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function B8({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]=y.useState(""),[x,S]=y.useState("");return g==="create"?a.jsxs("div",{className:oe.codespaceSection,children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Repository"}),a.jsx("input",{type:"text",value:_,onChange:j=>b(j.target.value),placeholder:"owner/repo",className:oe.fieldInput,"data-testid":"env-codespace-repo"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Machine Type"}),a.jsx("input",{type:"text",value:x,onChange:j=>S(j.target.value),placeholder:"Machine type (optional)...",className:oe.fieldInput,"data-testid":"env-codespace-machine"})]}),a.jsxs("div",{className:oe.codespaceActions,children:[a.jsx("button",{onClick:()=>{_.trim()&&(m(_.trim(),x.trim()||void 0),v("pick"),b(""),S(""))},disabled:!_.trim(),className:oe.btnPrimary,children:"Create"}),a.jsx("button",{onClick:()=>{v("pick"),b(""),S("")},className:oe.btnGhost,children:"Cancel"})]})]}):a.jsx("div",{className:oe.codespaceSection,children:a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Codespace"}),!u&&a.jsxs("select",{value:t,onChange:j=>{j.target.value==="__create__"?(v("create"),s("")):(s(j.target.value),j.target.value&&!o.trim()&&r(j.target.value))},disabled:p,className:oe.adapterSelect,"data-testid":"env-codespace-select",children:[a.jsx("option",{value:"",children:"Select a codespace..."}),c.map(j=>a.jsxs("option",{value:j.name,children:[j.name," (",j.repository,") — ",j.state]},j.name)),a.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&a.jsx("span",{className:oe.creatingHint,children:"Creating codespace..."}),u&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:oe.errorHint,children:u}),a.jsx("input",{type:"text",value:t,onChange:j=>s(j.target.value),placeholder:"Or enter codespace name manually...",className:oe.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&a.jsx("span",{className:oe.errorHint,children:d})]})})}function X1({mode:t,environmentId:s,environments:o,githubAccounts:r,onAddEnvironment:c,onUpdateEnvironment:d,onListCodespaces:u,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:_,onShowToast:b}){const x=dt(),S=t==="edit",j=S&&s?o.find(fe=>fe.id===s):void 0,[w,T]=y.useState(""),[C,A]=y.useState("local"),[L,E]=y.useState(""),[M,H]=y.useState(""),[D,z]=y.useState(""),[Y,V]=y.useState(""),[Q,ge]=y.useState(""),[X,re]=y.useState(""),[B,R]=y.useState(""),[Z,me]=y.useState(""),[q,le]=y.useState(null),de=y.useCallback(()=>{const fe={};if(C==="local"){if(L.trim()&&(fe.host=L.trim()),M.trim()){const be=Number(M);Number.isInteger(be)&&(fe.port=be)}}else if(C==="ssh"){if(fe.host=L.trim(),D.trim()&&(fe.user=D.trim()),M.trim()){const be=Number(M);Number.isInteger(be)&&(fe.sshPort=be)}Y.trim()&&(fe.identityFile=Y.trim())}else C==="docker"?(Q.trim()&&(fe.image=Q.trim()),X.trim()&&(fe.repo=X.trim())):C==="codespace"&&(fe.codespaceName=B.trim());return fe},[C,L,M,D,Y,Q,X,B]),xe=()=>!(!w.trim()||C==="ssh"&&!L.trim()||C==="codespace"&&!B.trim()||(C==="local"||C==="ssh")&&!Bp(M)),ke=()=>{xe()&&(c(w.trim(),C,de(),Z||void 0),b==null||b("Environment added successfully","success"),x(Bo,{replace:!0}))},Ze=()=>{x(s?Mi(s):Bo)},Xe=y.useCallback((fe,be)=>{if(!j||!s)return;const Vt=$p(j.adapterConfig),ie=be.trim();ie?Vt[fe]=ie:delete Vt[fe],d(s,{adapterConfig:Vt})},[j,s,d]),Se=y.useCallback((fe,be)=>{if(!j||!s)return;const Vt=$p(j.adapterConfig);if(be.trim()){const ie=Number(be);Number.isInteger(ie)&&ie>=cd&&ie<=dd&&(Vt[fe]=ie)}else delete Vt[fe];d(s,{adapterConfig:Vt})},[j,s,d]);if(S){if(!j)return a.jsxs("div",{className:oe.container,children:[a.jsxs("div",{className:oe.header,children:[a.jsx("div",{className:oe.headerTitle,children:a.jsx("span",{className:oe.badge,children:"edit environment"})}),a.jsx("div",{className:oe.headerActions,children:a.jsx("button",{onClick:Ze,className:oe.btnGhost,children:"Back"})})]}),a.jsx("div",{className:oe.body,children:a.jsx("div",{className:oe.formContent,children:a.jsx("span",{className:oe.readOnlyValue,children:"Environment not found"})})})]});const fe=$p(j.adapterConfig);return a.jsxs("div",{className:oe.container,"data-testid":"env-edit-panel",children:[a.jsxs("div",{className:oe.header,children:[a.jsx("div",{className:oe.headerTitle,children:a.jsx("span",{className:oe.badge,children:"edit environment"})}),a.jsx("div",{className:oe.headerActions,children:a.jsx("button",{onClick:Ze,className:oe.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),a.jsx("div",{className:oe.body,children:a.jsxs("div",{className:oe.formContent,children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Name"}),a.jsx(Yt,{value:j.displayName,onSave:be=>{s&&d(s,{displayName:be})},validate:be=>be.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:q,onActivate:le,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Adapter Type"}),a.jsx("span",{className:oe.readOnlyValue,"data-testid":"env-edit-adapter-type",children:j.adapterType})]}),(j.adapterType==="codespace"||j.adapterType==="docker")&&(r.length>0||!!j.githubAccountId)&&a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"GitHub Account"}),a.jsxs("select",{value:j.githubAccountId||"",onChange:be=>{s&&d(s,{githubAccountId:be.target.value})},className:oe.adapterSelect,"data-testid":"env-edit-github-account",children:[a.jsx("option",{value:"",children:"(Default)"}),r.map(be=>a.jsxs("option",{value:be.id,children:[be.label,be.username?` (@${be.username})`:"",be.isDefault?" — default":""]},be.id))]})]}),j.adapterType==="local"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Host"}),a.jsx(Yt,{value:String(fe.host??""),onSave:be=>Xe("host",be),mode:"edit",fieldId:"host",activeFieldId:q,onActivate:le,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Port"}),a.jsx(Yt,{value:String(fe.port??""),onSave:be=>Se("port",be),validate:be=>Bp(be)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:q,onActivate:le,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),j.adapterType==="ssh"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Host"}),a.jsx(Yt,{value:String(fe.host??""),onSave:be=>Xe("host",be),validate:be=>be.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:q,onActivate:le,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"User"}),a.jsx(Yt,{value:String(fe.user??""),onSave:be=>Xe("user",be),mode:"edit",fieldId:"user",activeFieldId:q,onActivate:le,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"SSH Port"}),a.jsx(Yt,{value:String(fe.sshPort??""),onSave:be=>Se("sshPort",be),validate:be=>Bp(be)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:q,onActivate:le,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Identity File"}),a.jsx(Yt,{value:String(fe.identityFile??""),onSave:be=>Xe("identityFile",be),mode:"edit",fieldId:"identityFile",activeFieldId:q,onActivate:le,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),j.adapterType==="docker"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Image"}),a.jsx(Yt,{value:String(fe.image??""),onSave:be=>Xe("image",be),mode:"edit",fieldId:"image",activeFieldId:q,onActivate:le,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Repo"}),a.jsx(Yt,{value:String(fe.repo??""),onSave:be=>Xe("repo",be),mode:"edit",fieldId:"repo",activeFieldId:q,onActivate:le,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),j.adapterType==="codespace"&&a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Codespace Name"}),a.jsx(Yt,{value:String(fe.codespaceName??""),onSave:be=>Xe("codespaceName",be),validate:be=>be.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:q,onActivate:le,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return a.jsxs("div",{className:oe.container,"data-testid":"env-create-panel",children:[a.jsxs("div",{className:oe.header,children:[a.jsx("div",{className:oe.headerTitle,children:a.jsx("span",{className:oe.badge,children:"new environment"})}),a.jsxs("div",{className:oe.headerActions,children:[a.jsx("button",{onClick:ke,disabled:!xe(),className:oe.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),a.jsx("button",{onClick:Ze,className:oe.btnGhost,children:"Cancel"})]})]}),a.jsx("div",{className:oe.body,children:a.jsxs("div",{className:oe.formContent,children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-name",children:"Name"}),a.jsx("input",{id:"env-create-name",type:"text",value:w,onChange:fe=>T(fe.target.value),placeholder:"Environment name...",autoFocus:!0,className:oe.nameInput,"data-testid":"env-create-name",onKeyDown:fe=>{fe.key==="Enter"&&xe()&&ke()}})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),a.jsxs("select",{id:"env-create-adapter",value:C,onChange:fe=>{A(fe.target.value),fe.target.value==="codespace"&&u(Z||void 0)},className:oe.adapterSelect,"data-testid":"env-create-adapter",children:[a.jsx("option",{value:"local",children:"local"}),a.jsx("option",{value:"ssh",children:"ssh"}),a.jsx("option",{value:"docker",children:"docker"}),a.jsx("option",{value:"codespace",children:"codespace"})]})]}),(C==="codespace"||C==="docker")&&r.length>0&&a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-github-account",children:"GitHub Account"}),a.jsxs("select",{id:"env-create-github-account",value:Z,onChange:fe=>{me(fe.target.value),C==="codespace"&&u(fe.target.value||void 0)},className:oe.adapterSelect,"data-testid":"env-create-github-account",children:[a.jsx("option",{value:"",children:"(Default)"}),r.map(fe=>a.jsxs("option",{value:fe.id,children:[fe.label," (@",fe.username,")",fe.isDefault?" — default":""]},fe.id))]})]}),C==="local"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-host",children:"Host"}),a.jsx("input",{id:"env-create-host",type:"text",value:L,onChange:fe=>E(fe.target.value),placeholder:"Host (optional)...",className:oe.fieldInput,"data-testid":"env-create-host"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-port",children:"Port"}),a.jsx("input",{id:"env-create-port",type:"number",min:cd,max:dd,value:M,onChange:fe=>H(fe.target.value),placeholder:"Port (optional)...",className:oe.fieldInput,"data-testid":"env-create-port"})]})]}),C==="ssh"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-host",children:"Host"}),a.jsx("input",{id:"env-create-host",type:"text",value:L,onChange:fe=>E(fe.target.value),placeholder:"Host (required)...",className:oe.fieldInput,"data-testid":"env-create-host"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-user",children:"User"}),a.jsx("input",{id:"env-create-user",type:"text",value:D,onChange:fe=>z(fe.target.value),placeholder:"User (optional)...",className:oe.fieldInput,"data-testid":"env-create-user"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-port",children:"SSH Port"}),a.jsx("input",{id:"env-create-port",type:"number",min:cd,max:dd,value:M,onChange:fe=>H(fe.target.value),placeholder:"SSH port (optional)...",className:oe.fieldInput,"data-testid":"env-create-port"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-identity",children:"Identity File"}),a.jsx("input",{id:"env-create-identity",type:"text",value:Y,onChange:fe=>V(fe.target.value),placeholder:"Identity file (optional)...",className:oe.fieldInput,"data-testid":"env-create-identity"})]})]}),C==="docker"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-image",children:"Image"}),a.jsx("input",{id:"env-create-image",type:"text",value:Q,onChange:fe=>ge(fe.target.value),placeholder:"Image (optional)...",className:oe.fieldInput,"data-testid":"env-create-image"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-repo",children:"Repo"}),a.jsx("input",{id:"env-create-repo",type:"text",value:X,onChange:fe=>re(fe.target.value),placeholder:"Repo (optional)...",className:oe.fieldInput,"data-testid":"env-create-repo"})]})]}),C==="codespace"&&a.jsx(B8,{codespaceName:B,onCodespaceNameChange:R,envName:w,onEnvNameChange:T,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:_})]})})]})}const $8="_group_1iprv_1",z8="_groupTitle_1iprv_8",H8="_shortcutList_1iprv_17",P8="_shortcutRow_1iprv_23",U8="_keys_1iprv_36",V8="_kbd_1iprv_43",q8="_description_1iprv_60",wi={group:$8,groupTitle:z8,shortcutList:H8,shortcutRow:P8,keys:U8,kbd:V8,description:q8},G8=[{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 F8(){return a.jsxs("section",{className:ue.section,"data-testid":"keyboard-shortcuts-panel",children:[a.jsx("h3",{className:ue.sectionTitle,children:"Keyboard Shortcuts"}),a.jsx("p",{className:ue.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),G8.map(t=>a.jsxs("div",{className:wi.group,children:[a.jsx("h4",{className:wi.groupTitle,children:t.title}),a.jsx("div",{className:wi.shortcutList,children:t.shortcuts.map(s=>a.jsxs("div",{className:wi.shortcutRow,children:[a.jsx("span",{className:wi.keys,children:s.keys.map(o=>a.jsx("kbd",{className:wi.kbd,children:o},o))}),a.jsx("span",{className:wi.description,children:s.description})]},s.description))})]},t.title))]})}const Z8=[{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 K8({credentialProviders:t,onUpdateCredentialProviders:s}){const o=(r,c)=>{const d={...t};r==="claude"?d.claude=c:d[r]=c,s(d)};return a.jsxs("section",{className:ue.section,children:[a.jsx("h3",{className:ue.sectionTitle,children:"Credential Providers"}),a.jsx("p",{className:ue.sectionDescription,children:"Enable providers to automatically forward credentials to environments at task start. Credentials are read fresh from the host each time."}),a.jsx("div",{className:ue.tokenList,children:Z8.map(r=>a.jsxs("div",{className:ue.tokenRow,children:[a.jsx("span",{className:ue.tokenName,children:r.label}),a.jsx("span",{className:ue.tokenTarget,children:r.description}),a.jsx("select",{className:ue.select,value:t[r.key],onChange:c=>o(r.key,c.target.value),children:r.options.map(c=>a.jsx("option",{value:c.value,children:c.label},c.value))})]},r.key))})]})}const Y8="_container_10efq_1",J8="_header_10efq_7",W8="_list_10efq_105",X8="_card_10efq_111",Q8="_cardHeader_10efq_125",e7="_cardTitle_10efq_135",t7="_defaultBadge_10efq_141",n7="_cardActions_10efq_155",s7="_description_10efq_160",a7="_meta_10efq_166",i7="_empty_10efq_212",o7="_typeBadge_10efq_362",ss={container:Y8,header:J8,list:W8,card:X8,cardHeader:Q8,cardTitle:e7,defaultBadge:t7,cardActions:n7,description:s7,meta:a7,empty:i7,typeBadge:o7};function r7({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 a.jsxs("div",{className:ss.container,children:[a.jsxs("div",{className:ss.header,children:[a.jsx("h2",{children:"Personas"}),a.jsx(rn,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?a.jsx("p",{className:ss.empty,children:"No personas yet. Create one to get started."}):a.jsx("div",{className:ss.list,children:t.map(v=>{const _=s===v.id,b=v.type==="script";return a.jsxs("div",{className:ss.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:x=>{x.currentTarget===x.target&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),d(v.id))},children:[a.jsxs("div",{className:ss.cardHeader,children:[a.jsxs("span",{className:ss.cardTitle,children:[a.jsx("strong",{children:v.name}),a.jsx("span",{className:ss.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:b?"Script":"Agent"}),_&&a.jsx("span",{className:ss.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),a.jsxs("div",{className:ss.cardActions,onClick:x=>x.stopPropagation(),children:[!_&&a.jsx(rn,{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"}),a.jsx(rn,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),a.jsx(rn,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&a.jsx("p",{className:ss.description,children:v.description}),a.jsxs("div",{className:ss.meta,children:[v.runtime&&a.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&a.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&a.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),a.jsx(ks,{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 l7="_container_uy08i_1",c7="_header_uy08i_7",d7="_count_uy08i_13",u7="_presets_uy08i_18",f7="_presetButton_uy08i_24",p7="_filterInput_uy08i_41",m7="_groups_uy08i_53",h7="_group_uy08i_53",g7="_groupHeader_uy08i_68",v7="_groupName_uy08i_77",y7="_groupCount_uy08i_81",b7="_toolList_uy08i_87",_7="_toolItem_uy08i_95",x7="_toolName_uy08i_103",_n={container:l7,header:c7,count:d7,presets:u7,presetButton:f7,filterInput:p7,groups:m7,group:h7,groupHeader:g7,groupName:v7,groupCount:y7,toolList:b7,toolItem:_7,toolName:x7},k7=(()=>{const t=new Map;for(const s of E_){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()}))})(),S7=[{name:"default",label:"Default",tools:A_},{name:"worker",label:"Worker",tools:P2},{name:"orchestrator",label:"Orchestrator",tools:U2},{name:"admin",label:"Admin",tools:V2}];function l_({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 _=new Set(d);_.has(v)?_.delete(v):_.add(v),s([..._].sort())},[d,s,o]),p=y.useCallback((v,_)=>{if(o)return;const b=new Set(d);for(const x of v)_?b.delete(x):b.add(x);s([...b].sort())},[d,s,o]),m=y.useCallback(v=>{o||s([...v].sort())},[s,o]),g=r.toLowerCase();return a.jsxs("div",{className:_n.container,"data-testid":"mcp-tool-selector",children:[a.jsx("div",{className:_n.header,children:a.jsx("span",{className:_n.count,children:t.length===0?`Using default (${A_.length} tools)`:`${t.length} of ${E_.size} tools selected`})}),a.jsxs("div",{className:_n.presets,"data-testid":"mcp-tool-presets",children:[S7.map(v=>a.jsx("button",{type:"button",className:_n.presetButton,disabled:o,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),a.jsx("button",{type:"button",className:_n.presetButton,disabled:o,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),a.jsx("input",{type:"text",className:_n.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:o,"data-testid":"mcp-tool-filter"}),a.jsx("div",{className:_n.groups,children:k7.map(({group:v,tools:_})=>{const b=g?_.filter(S=>S.toLowerCase().includes(g)):_;if(b.length===0)return null;const x=b.every(S=>d.has(S));return a.jsxs("div",{className:_n.group,"data-testid":`tool-group-${v}`,children:[a.jsxs("label",{className:_n.groupHeader,children:[a.jsx("input",{type:"checkbox",checked:x,onChange:()=>p(b,x),disabled:o,"data-testid":`group-toggle-${v}`}),a.jsx("span",{className:_n.groupName,children:v}),a.jsxs("span",{className:_n.groupCount,children:["(",b.filter(S=>d.has(S)).length,"/",b.length,")"]})]}),a.jsx("div",{className:_n.toolList,children:b.map(S=>a.jsxs("label",{className:_n.toolItem,children:[a.jsx("input",{type:"checkbox",checked:d.has(S),onChange:()=>u(S),disabled:o,"data-testid":`tool-${S}`}),a.jsx("span",{className:_n.toolName,children:S})]},S))})]},v)})})]})}const j7="_container_1gfuq_1",T7="_header_1gfuq_7",w7="_list_1gfuq_19",N7="_card_1gfuq_25",C7="_cardHeader_1gfuq_40",E7="_cardTitle_1gfuq_46",A7="_statusBadge_1gfuq_56",D7="_enabled_1gfuq_68",R7="_disabled_1gfuq_71",M7="_cardActions_1gfuq_75",I7="_cardMeta_1gfuq_80",O7="_empty_1gfuq_98",as={container:j7,header:T7,list:w7,card:N7,cardHeader:C7,cardTitle:E7,statusBadge:A7,enabled:D7,disabled:R7,cardActions:M7,cardMeta:I7,empty:O7};function L7({schedules:t,personas:s,onDeleteSchedule:o,onToggleEnabled:r,onNavigateToNew:c,onNavigateToSchedule:d}){const[u,p]=y.useState(null),m=u?t.find(b=>b.id===u):void 0,g=async b=>{await o(b),p(null)},v=y.useMemo(()=>{const b=new Map;for(const x of s)b.set(x.id,x.name);return b},[s]),_=b=>v.get(b)??b;return a.jsxs("div",{className:as.container,children:[a.jsxs("div",{className:as.header,children:[a.jsx("h2",{children:"Schedules"}),a.jsx(rn,{variant:"primary",size:"md",onClick:c,"data-testid":"schedule-new-button",children:"+ New Schedule"})]}),t.length===0?a.jsx("p",{className:as.empty,"data-testid":"schedule-empty-state",children:"No schedules yet. Create one to run tasks on a recurring cadence."}):a.jsx("div",{className:as.list,children:t.map(b=>a.jsxs("div",{className:as.card,"data-testid":`schedule-card-${b.id}`,onClick:()=>d(b.id),role:"button",tabIndex:0,onKeyDown:x=>{x.currentTarget===x.target&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),d(b.id))},children:[a.jsxs("div",{className:as.cardHeader,children:[a.jsxs("span",{className:as.cardTitle,children:[a.jsx("strong",{children:b.title}),a.jsx("span",{className:`${as.statusBadge} ${b.enabled?as.enabled:as.disabled}`,"data-testid":`schedule-status-badge-${b.id}`,children:b.enabled?"Enabled":"Disabled"})]}),a.jsxs("div",{className:as.cardActions,onClick:x=>x.stopPropagation(),children:[a.jsx(rn,{variant:"ghost",size:"sm",onClick:()=>{(async()=>{await r(b.id,{enabled:!b.enabled})})().catch(()=>{})},"data-testid":`schedule-toggle-${b.id}`,title:b.enabled?"Disable schedule":"Enable schedule",children:b.enabled?"Disable":"Enable"}),a.jsx(rn,{variant:"ghost",size:"sm",onClick:()=>d(b.id),"data-testid":`schedule-edit-${b.id}`,children:"Edit"}),a.jsx(rn,{variant:"ghost",size:"sm",onClick:()=>p(b.id),"data-testid":`schedule-delete-${b.id}`,children:"Delete"})]})]}),a.jsxs("div",{className:as.cardMeta,children:[a.jsx("span",{"data-testid":`schedule-expression-${b.id}`,children:b.scheduleExpression}),b.personaId&&a.jsxs("span",{"data-testid":`schedule-persona-${b.id}`,children:["Persona: ",_(b.personaId)]}),a.jsxs("span",{"data-testid":`schedule-last-run-${b.id}`,children:["Last run: ",b.lastRunAt?Uo(b.lastRunAt):"Never"]}),b.enabled&&b.nextRunAt?a.jsxs("span",{"data-testid":`schedule-next-run-${b.id}`,children:["Next run: ",q1(b.nextRunAt)]}):null,b.runCount>0&&a.jsxs("span",{"data-testid":`schedule-run-count-${b.id}`,children:["Runs: ",b.runCount]})]})]},b.id))}),a.jsx(ks,{isOpen:u!==null,title:"Delete Schedule?",description:`"${(m==null?void 0:m.title)??""}" will be permanently removed. Tasks already created by this schedule will not be affected.`,confirmLabel:"Delete",onConfirm:()=>{u&&g(u).catch(()=>{})},onCancel:()=>p(null)})]})}const B7="_nav_1bhou_1",$7="_tab_1bhou_24",z7="_tabIcon_1bhou_62",H7="_tabActive_1bhou_68",Jc={nav:B7,tab:$7,tabIcon:z7,tabActive:H7},ia=[{path:"credentials",label:"Credentials",icon:a.jsx(nT,{size:Et})},{path:"github-accounts",label:"GitHub Accounts",icon:a.jsx(Wj,{size:Et})},{path:"personas",label:"Personas",icon:a.jsx(BT,{size:Et})},{path:"schedules",label:"Schedules",icon:a.jsx(Aj,{size:Et})},{path:"appearance",label:"Appearance",icon:a.jsx(vT,{size:Et})},{path:"shortcuts",label:"Shortcuts",icon:a.jsx(aT,{size:Et})},{path:"plugins",label:"Plugins",icon:a.jsx(ST,{size:Et})},{path:"about",label:"About",icon:a.jsx(Tm,{size:Et})}];function P7(){var u;const t=Wt(),s=dt(),o=y.useRef(null),r=((u=ia.find(p=>{const m=`${Ai}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??ia[0].path,c=y.useCallback(p=>{s(`${Ai}/${p}`)},[s]),d=y.useCallback(p=>{var x,S;const m=(x=o.current)==null?void 0:x.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(j=>j===document.activeElement),v=g>=0?g:ia.findIndex(j=>j.path===r);let _=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),_=(v+1)%ia.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),_=(v-1+ia.length)%ia.length;else if(p.key==="Home")p.preventDefault(),_=0;else if(p.key==="End")p.preventDefault(),_=ia.length-1;else return;const b=ia[_].path;s(`${Ai}/${b}`),(S=m[_])==null||S.focus()},[r,s]);return a.jsx("nav",{className:Jc.nav,ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:ia.map(p=>{const m=p.path===r;return a.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Jc.tab} ${m?Jc.tabActive:""}`,onClick:()=>c(p.path),children:[a.jsx("span",{className:Jc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}const U7="_container_1dqrb_1",V7="_header_1dqrb_5",q7="_refreshButton_1dqrb_17",G7="_streamRow_1dqrb_32",F7="_selected_1dqrb_49",Z7="_systemRow_1dqrb_53 _streamRow_1dqrb_32",K7="_streamIcon_1dqrb_60",Y7="_streamName_1dqrb_65",J7="_subscriberBadge_1dqrb_74",W7="_emptyState_1dqrb_88",X7="_loading_1dqrb_95",xn={container:U7,header:V7,refreshButton:q7,streamRow:G7,selected:F7,systemRow:Z7,streamIcon:K7,streamName:Y7,subscriberBadge:J7,emptyState:W7,loading:X7},c_=14;function Q7({streams:t,loading:s,streamsLoadError:o=!1,streamsLoadedOnce:r=!0,onRefresh:c}){const d=dt(),u=Wt(),p=Dt("/chat/:streamId"),m=p==null?void 0:p.params.streamId,g=!m&&u.pathname===cl,v=[...t].sort((x,S)=>x.name.localeCompare(S.name)),_=y.useCallback(()=>{d(cl)},[d]),b=y.useCallback(x=>{d(qN(x))},[d]);return a.jsxs("div",{className:xn.container,"data-testid":"stream-list",children:[a.jsxs("div",{className:xn.header,children:[a.jsx("span",{children:"Streams"}),c&&a.jsx("button",{className:xn.refreshButton,onClick:c,"aria-label":"Refresh streams","data-testid":"stream-list-refresh",children:a.jsx(NT,{size:12})})]}),a.jsxs("button",{type:"button",className:`${xn.systemRow}${g?` ${xn.selected}`:""}`,onClick:_,"data-testid":"stream-list-system-row","aria-current":g?"page":void 0,children:[a.jsx(L_,{size:c_,className:xn.streamIcon}),a.jsx("span",{className:xn.streamName,children:"System"})]}),s&&v.length===0&&a.jsx("div",{className:xn.loading,children:"Loading..."}),!s&&o&&a.jsx("div",{className:xn.emptyState,"data-testid":"stream-list-error",children:"Unable to load streams"}),!s&&!o&&r&&v.length===0&&a.jsx("div",{className:xn.emptyState,children:"No streams"}),v.map(x=>{const S=m===x.id;return a.jsxs("button",{type:"button",className:`${xn.streamRow}${S?` ${xn.selected}`:""}`,onClick:()=>b(x.id),"data-testid":`stream-list-row-${x.id}`,"aria-current":S?"page":void 0,children:[a.jsx(TT,{size:c_,className:xn.streamIcon}),a.jsx("span",{className:xn.streamName,children:x.name}),x.subscriberCount>0&&a.jsx("span",{className:xn.subscriberBadge,children:x.subscriberCount})]},x.id)})]})}const e$="_panel_1au81_1",t$="_header_1au81_24",n$="_title_1au81_33",s$="_closeButton_1au81_43",a$="_body_1au81_57",i$="_section_1au81_63",o$="_sectionLabel_1au81_67",r$="_metaRow_1au81_76",l$="_metaKey_1au81_84",c$="_metaValue_1au81_90",d$="_subscriberCard_1au81_99",u$="_subscriberHeader_1au81_107",f$="_sessionLink_1au81_114",p$="_badges_1au81_132",m$="_badgeRw_1au81_150 _badge_1au81_132",h$="_badgeR_1au81_150 _badge_1au81_132",g$="_badgeW_1au81_162 _badge_1au81_132",v$="_badgeAsync_1au81_168 _badge_1au81_132",y$="_badgeSync_1au81_174 _badge_1au81_132",b$="_badgeDetach_1au81_178 _badge_1au81_132",_$="_spawnTag_1au81_184 _badge_1au81_132",x$="_fdNumber_1au81_189",k$="_emptySubscribers_1au81_195",lt={panel:e$,header:t$,title:n$,closeButton:s$,body:a$,section:i$,sectionLabel:o$,metaRow:r$,metaKey:l$,metaValue:c$,subscriberCard:d$,subscriberHeader:u$,sessionLink:f$,badges:p$,badgeRw:m$,badgeR:h$,badgeW:g$,badgeAsync:v$,badgeSync:y$,badgeDetach:b$,spawnTag:_$,fdNumber:x$,emptySubscribers:k$};function S$({permission:t}){const s=t==="rw"?lt.badgeRw:t==="r"?lt.badgeR:lt.badgeW;return a.jsx("span",{className:s,children:t})}function j$({mode:t}){const s=t==="async"?lt.badgeAsync:t==="detach"?lt.badgeDetach:lt.badgeSync;return a.jsx("span",{className:s,children:t})}function T$({stream:t,onClose:s}){const o=dt();return y.useEffect(()=>{const r=c=>{c.key==="Escape"&&s()};return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[s]),a.jsxs("div",{className:lt.panel,"data-testid":"stream-detail-panel",children:[a.jsxs("div",{className:lt.header,children:[a.jsx("h3",{className:lt.title,children:t.name}),a.jsx("button",{className:lt.closeButton,onClick:s,"aria-label":"Close stream details",children:"×"})]}),a.jsxs("div",{className:lt.body,children:[a.jsxs("div",{className:lt.section,children:[a.jsx("div",{className:lt.sectionLabel,children:"Overview"}),a.jsxs("div",{className:lt.metaRow,children:[a.jsx("span",{className:lt.metaKey,children:"Stream ID"}),a.jsx("span",{className:lt.metaValue,children:t.id})]}),a.jsxs("div",{className:lt.metaRow,children:[a.jsx("span",{className:lt.metaKey,children:"Subscribers"}),a.jsx("span",{className:lt.metaValue,children:t.subscriberCount})]}),a.jsxs("div",{className:lt.metaRow,children:[a.jsx("span",{className:lt.metaKey,children:"Buffered"}),a.jsxs("span",{className:lt.metaValue,children:[t.messageBufferDepth," msgs"]})]})]}),a.jsxs("div",{className:lt.section,children:[a.jsx("div",{className:lt.sectionLabel,children:"Subscribers"}),t.subscribers.length===0?a.jsx("div",{className:lt.emptySubscribers,children:"No active subscribers"}):t.subscribers.map(r=>a.jsxs("div",{className:lt.subscriberCard,"data-testid":`subscriber-card-${r.subscriptionId}`,children:[a.jsxs("div",{className:lt.subscriberHeader,children:[a.jsxs("span",{className:lt.fdNumber,children:["fd ",r.fd]}),a.jsxs("button",{className:lt.sessionLink,onClick:()=>{o(Bd(r.sessionId))},title:r.sessionId,children:[r.sessionId.slice(0,12),"…"]})]}),a.jsxs("div",{className:lt.badges,children:[a.jsx(S$,{permission:r.permission}),a.jsx(j$,{mode:r.deliveryMode}),r.createdBySpawn&&a.jsx("span",{className:lt.spawnTag,children:"spawn"})]})]},r.subscriptionId))]})]})]})}function w$({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(Ty.map(d=>[d,[]]));for(const d of t){const u=gl(d.status),p=d.dependsOn.length>0&&d.dependsOn.some(S=>s.get(S)!=="complete"),m=r.get(d.id)??[],g=m.length,v=m.filter(S=>S.status==="complete").length;let _;if(u==="paused"&&o){const S=o.get(d.id);S==="idle"?_="Needs input":S==="completed"&&(_="Ready to complete")}const b={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:_},x=c.get(u);x?x.push(b):c.get("not_started").push(b)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return Ty.map(d=>{const u=Wa(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const N$="_boardContainer_1c4y1_1",C$="_column_1c4y1_17",E$="_columnHeader_1c4y1_34",A$="_columnIcon_1c4y1_47",D$="_columnLabel_1c4y1_52",R$="_columnCount_1c4y1_57",M$="_cardList_1c4y1_67",I$="_emptyPlaceholder_1c4y1_76",O$="_card_1c4y1_67",L$="_cardHeader_1c4y1_107",B$="_cardStatusIcon_1c4y1_113",$$="_cardTitle_1c4y1_119",z$="_cardBadges_1c4y1_127",H$="_badge_1c4y1_134",P$="_blockedBadge_1c4y1_146",U$="_childBadge_1c4y1_151",V$="_depBadge_1c4y1_155",q$="_parentBadge_1c4y1_159",G$="_pausedSubBadge_1c4y1_166",F$="_personaBadge_1c4y1_170",Z$="_envBadge_1c4y1_174",K$="_emptyCta_1c4y1_178",Y$="_ctaButton_1c4y1_188",J$="_ctaDescription_1c4y1_204",ct={boardContainer:N$,column:C$,columnHeader:E$,columnIcon:A$,columnLabel:D$,columnCount:R$,cardList:M$,emptyPlaceholder:I$,card:O$,cardHeader:L$,cardStatusIcon:B$,cardTitle:$$,cardBadges:z$,badge:H$,blockedBadge:P$,childBadge:U$,depBadge:V$,parentBadge:q$,pausedSubBadge:G$,personaBadge:F$,envBadge:Z$,emptyCta:K$,ctaButton:Y$,ctaDescription:J$};function W$({workspaceId:t,environmentId:s,tasks:o,sessions:r,personas:c,environments:d}){const u=dt(),p=y.useMemo(()=>o.filter(b=>b.workspaceId===t),[o,t]),m=y.useMemo(()=>new Map(o.map(b=>[b.id,b.status])),[o]),g=y.useMemo(()=>new Map(p.map(b=>[b.id,b])),[p]),v=y.useMemo(()=>{const b=new Map(r.map(C=>[C.id,C])),x=new Map(c.map(C=>[C.id,C])),S=new Map(d.map(C=>[C.id,C])),j=new Map,w=new Map,T=new Map;for(const C of p)if(C.latestSessionId){const A=b.get(C.latestSessionId);if(A){if(j.set(C.id,A.endReason||A.status),A.personaId){const L=x.get(A.personaId);L&&w.set(C.id,L.name)}if(A.environmentId){const L=S.get(A.environmentId);L&&T.set(C.id,L.displayName)}}}return{sessionStatusByTaskId:j,personaNameByTaskId:w,environmentNameByTaskId:T}},[p,r,c,d]),_=y.useMemo(()=>w$({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?a.jsxs("div",{className:ct.emptyCta,"data-testid":"board-empty-cta",children:[a.jsx("button",{className:ct.ctaButton,onClick:()=>u($i(t,void 0,s)),children:"Create Task"}),a.jsx("div",{className:ct.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):a.jsx("div",{className:ct.boardContainer,"data-testid":"board-container",children:_.map(b=>a.jsxs("section",{className:ct.column,"data-testid":`board-column-${b.status}`,"aria-label":`${b.label}, ${b.tasks.length} ${b.tasks.length===1?"task":"tasks"}`,children:[a.jsxs("div",{className:ct.columnHeader,children:[a.jsx("span",{className:ct.columnIcon,style:{color:b.style.color},children:b.style.icon}),a.jsx("span",{className:ct.columnLabel,children:b.label}),a.jsx("span",{className:ct.columnCount,"data-testid":`board-count-${b.status}`,children:b.tasks.length})]}),a.jsx("div",{className:ct.cardList,children:b.tasks.length===0?a.jsx("div",{className:ct.emptyPlaceholder,children:"No tasks"}):a.jsx(ls,{mode:"popLayout",children:b.tasks.map(x=>a.jsx(At.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:a.jsx(X$,{boardTask:x,tasksById:g,personaName:v.personaNameByTaskId.get(x.task.id),envName:v.environmentNameByTaskId.get(x.task.id),onClick:()=>u(Hn(x.task.id,void 0,t,s))})},x.task.id))})})]},b.status))})}function X$({boardTask:t,tasksById:s,personaName:o,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=Wa(d.status),_=d.parentTaskId?s.get(d.parentTaskId):void 0;return a.jsxs("div",{className:ct.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c())},children:[a.jsxs("div",{className:ct.cardHeader,children:[a.jsx("span",{className:ct.cardStatusIcon,style:{color:v.color},children:v.icon}),a.jsx("span",{className:ct.cardTitle,children:d.title})]}),a.jsxs("div",{className:ct.cardBadges,children:[_&&a.jsx("span",{className:`${ct.badge} ${ct.parentBadge}`,title:_.title,children:_.title}),p>0&&a.jsxs("span",{className:`${ct.badge} ${ct.childBadge}`,children:[m,"/",p]}),u&&a.jsx("span",{className:`${ct.badge} ${ct.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&a.jsx("span",{className:`${ct.badge} ${ct.depBadge}`,children:"dep"}),g&&a.jsx("span",{className:`${ct.badge} ${ct.pausedSubBadge}`,children:g}),o&&a.jsx("span",{className:`${ct.badge} ${ct.personaBadge}`,children:o}),r&&a.jsx("span",{className:`${ct.badge} ${ct.envBadge}`,children:r})]})]})}const Q$="_formContent_ymnez_1",ez="_section_ymnez_13",tz="_label_ymnez_19",nz="_titleInput_ymnez_26",sz="_descriptionTextarea_ymnez_58",az="_selectField_ymnez_94",iz="_checkboxRow_ymnez_128",oz="_checkboxLabel_ymnez_141",rz="_fieldError_ymnez_146",kt={formContent:Q$,section:ez,label:tz,titleInput:nz,descriptionTextarea:sz,selectField:az,checkboxRow:iz,checkboxLabel:oz,fieldError:rz};function lz(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.linkedEnvironmentIds[0])??s??"",defaultPersonaId:(t==null?void 0:t.defaultPersonaId)??"",useWorktrees:(t==null?void 0:t.useWorktrees)??!0,workingDirectory:(t==null?void 0:t.workingDirectory)??""}}const cz=100;function dz({values:t,onChange:s,environments:o,personas:r,errors:c,disabled:d,autoFocusName:u}){const p=(m,g)=>{s({...t,[m]:g})};return a.jsxs("div",{className:kt.formContent,children:[a.jsxs("div",{className:kt.section,children:[a.jsx("label",{className:kt.label,htmlFor:"ws-name",children:"Name"}),a.jsx("input",{id:"ws-name",className:kt.titleInput,type:"text",value:t.name,onChange:m=>p("name",m.target.value),placeholder:"Workspace name",maxLength:cz,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&a.jsx("span",{className:kt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),a.jsxs("div",{className:kt.section,children:[a.jsx("label",{className:kt.label,htmlFor:"ws-description",children:"Description"}),a.jsx("textarea",{id:"ws-description",className:kt.descriptionTextarea,value:t.description,onChange:m=>p("description",m.target.value),placeholder:"Optional description (Markdown supported)",disabled:d,"data-testid":"workspace-form-description"})]}),a.jsxs("div",{className:kt.section,children:[a.jsx("label",{className:kt.label,htmlFor:"ws-repo",children:"Repository URL"}),a.jsx("input",{id:"ws-repo",className:kt.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)&&a.jsx("span",{className:kt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),a.jsxs("div",{className:kt.section,children:[a.jsx("label",{className:kt.label,htmlFor:"ws-environment",children:"Environment"}),a.jsxs("select",{id:"ws-environment",className:kt.selectField,value:t.environmentId,onChange:m=>p("environmentId",m.target.value),disabled:d,"data-testid":"workspace-form-environment",children:[a.jsx("option",{value:"",children:"Select environment…"}),o.map(m=>a.jsx("option",{value:m.id,children:m.displayName||m.id},m.id))]}),(c==null?void 0:c.environmentId)&&a.jsx("span",{className:kt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),a.jsxs("div",{className:kt.section,children:[a.jsx("label",{className:kt.label,htmlFor:"ws-persona",children:"Default Persona"}),a.jsxs("select",{id:"ws-persona",className:kt.selectField,value:t.defaultPersonaId,onChange:m=>p("defaultPersonaId",m.target.value),disabled:d,"data-testid":"workspace-form-persona",children:[a.jsx("option",{value:"",children:"(Inherit)"}),r.map(m=>a.jsx("option",{value:m.id,children:m.name},m.id))]})]}),a.jsx("div",{className:kt.section,children:a.jsxs("label",{className:kt.checkboxRow,children:[a.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:m=>p("useWorktrees",m.target.checked),disabled:d,"data-testid":"workspace-form-worktrees"}),a.jsx("span",{className:kt.checkboxLabel,children:"Enable worktree isolation"})]})}),a.jsxs("div",{className:kt.section,children:[a.jsx("label",{className:kt.label,htmlFor:"ws-workdir",children:"Working Directory"}),a.jsx("input",{id:"ws-workdir",className:kt.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 Q1=y.createContext(void 0),uz=4e3;function fz({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=uz)=>{const g=`toast-${++r.current}`;o(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return a.jsx(Q1.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function hn(){const t=y.useContext(Q1);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const _m="grackle-theme",ek="grackle-prefer-system",tk="(prefers-color-scheme: dark)";let Xr=[],ud;function zp(){ud=void 0;for(const t of Xr)t()}function xm(){return typeof window>"u"?!1:window.matchMedia(tk).matches}function il(){if(typeof localStorage>"u")return o_;try{const t=localStorage.getItem(_m);if(t!==null&&J1.has(t))return t}catch{}return o_}function wd(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(ek)==="true"}catch{return!1}}function km(t){return Gd.find(s=>s.variantLightId===t||s.variantDarkId===t)}function nk(t,s){const o=bm(t);if(o!=null&&o.variantDarkId)return s&&o.variantLightId?xm()?o.variantDarkId:o.variantLightId:o.variantDarkId;if(o!=null&&o.hidden&&s){const r=km(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return xm()?r.variantDarkId:r.variantLightId}return t}function Do(t,s,o=!1){o&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=nk(t,s),o&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&Do(il(),wd());function pz(){return ud===void 0&&(ud={themeId:il(),systemDark:xm(),preferSystem:wd()}),ud}function mz(t){return Xr=[...Xr,t],()=>{Xr=Xr.filter(s=>s!==t)}}function hz(){const t=y.useSyncExternalStore(mz,pz),{themeId:s,preferSystem:o}=t,r=nk(s,o),c=y.useCallback(u=>{if(J1.has(u)){try{localStorage.setItem(_m,u)}catch{}Do(u,wd(),!0),zp()}},[]),d=y.useCallback(u=>{try{localStorage.setItem(ek,u?"true":"false")}catch{}if(u){const p=il(),m=bm(p);if(m!=null&&m.hidden){const g=km(p);if(g)try{localStorage.setItem(_m,g.id)}catch{}}}Do(il(),u,!0),zp()},[]);return y.useEffect(()=>{Do(s,o)},[s,o]),y.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(tk),p=()=>{const m=il(),g=wd();if(g){const v=bm(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&Do(m,g),v!=null&&v.hidden){const _=km(m);_!=null&&_.variantDarkId&&_.variantLightId&&Do(m,g)}}zp()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:o,setPreferSystem:d}}const sk=y.createContext(void 0);function gz({children:t}){const s=hz();return a.jsx(sk.Provider,{value:s,children:t})}function ak(){const t=y.useContext(sk);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const ik=y.createContext(void 0),ok=y.createContext(void 0);function vz({children:t}){const[s,o]=y.useState(void 0),r=y.useCallback(c=>{o(c)},[]);return a.jsx(ok.Provider,{value:r,children:a.jsx(ik.Provider,{value:s,children:t})})}function yz(){return y.useContext(ik)}function bz(){const t=y.useContext(ok);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const vh=y.createContext(void 0);function ot(){const t=y.useContext(vh);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function rk(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function lk(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function _z(t){return rk(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 xz=new Set(["off","subscription","api_key"]),Wc=new Set(["off","on"]);function kz(t){return rk(t)&&xz.has(t.claude)&&Wc.has(t.github)&&Wc.has(t.copilot)&&Wc.has(t.codex)&&Wc.has(t.goose)}function ck(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 dk(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 Ao=5e3;function Sz(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 pa={label:"Home",url:Ii};function jz(t){return t?[pa,{label:"Settings",url:Ai},{label:t,url:void 0}]:[pa,{label:"Settings",url:void 0}]}const yh={label:"Environments",url:Bo};function Tz(){return[pa,{label:"Environments",url:void 0}]}function wz(){return[pa,{label:"New Chat",url:void 0}]}function Nz(t){return[pa,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function Cz(t,s,o,r){const c=o.find(u=>u.id===t),d=r.find(u=>u.id===s);return[pa,yh,{label:(d==null?void 0:d.displayName)??"Environment",url:Mi(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function Ez(t,s,o,r,c){const d=Sz(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?o.find(x=>x.id===p):void 0,g=s??(m==null?void 0:m.linkedEnvironmentIds[0]),v=g?r.find(x=>x.id===g):void 0,_=[pa];v&&g&&(_.push(yh),_.push({label:v.displayName,url:Mi(g)})),m&&g&&_.push({label:m.name,url:Ri(m.id,g)});for(let x=0;x<d.length-1;x++)_.push({label:d[x].title,url:Hn(d[x].id,void 0,p,g)});const b=d[d.length-1];return _.push({label:(b==null?void 0:b.title)??t,url:void 0}),_}const Az={label:"Findings",url:$d};function Dz(){return[pa,{label:"Findings",url:void 0}]}function uk(t,s,o,r,c){const d=[pa];if(s&&o){const u=r.find(m=>m.id===s),p=c.find(m=>m.id===o);d.push(yh),p&&d.push({label:p.displayName,url:Mi(o)}),u&&d.push({label:u.name,url:Ri(s,o)}),d.push({label:"Findings",url:FN(s,o)})}else d.push(Az);return d.push({label:t,url:void 0}),d}function bh(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 Xc(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 Rz(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 _h(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 _=s.get(v),b=_?Xc(_):void 0;if(b)try{const x=JSON.parse(v.content);o.set(b,{tool:x.tool,args:x.args})}catch{}}const r=new Set,c=new Set,d=t.map((v,_)=>{if(v.eventType!=="tool_result")return v;const b=s.get(v),x=b?Rz(b):void 0;if(!x)return v;const S=o.get(x);if(!S)return v;r.add(x),c.add(_);let j;const w=v.content.trim();if(w.startsWith("{"))try{const T=JSON.parse(w);typeof T.detailedContent=="string"&&(j=T.detailedContent)}catch{}return{...v,toolUseCtx:{...S,detailedResult:j}}}),u=[];for(let v=0;v<d.length;v++){if(d[v].eventType!=="tool_use")continue;const _=s.get(d[v]),b=_?Xc(_):void 0;b&&r.has(b)||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 _=p[m];if(_!==v+1)continue;const b=d[v],x=d[_];let S;try{const j=JSON.parse(b.content);S={tool:j.tool,args:j.args}}catch{}if(S){let j;const w=x.content.trim();if(w.startsWith("{"))try{const A=JSON.parse(w);typeof A.detailedContent=="string"&&(j=A.detailedContent)}catch{}d[_]={...x,toolUseCtx:{...S,detailedResult:j}},c.add(_);const T=s.get(b),C=T?Xc(T):void 0;C?r.add(C):(r.add(`__seq_${v}`),s.set(b,{...T??{},__seqId:`__seq_${v}`})),m++}}const g=d.filter(v=>{if(v.eventType!=="tool_use")return!0;const _=s.get(v);if(!_)return!0;const b=Xc(_);if(b&&r.has(b))return!1;const x=_.__seqId;return!(x&&r.has(x))});for(let v=0;v<g.length;v++){if(g[v].eventType!=="tool_use")continue;let _=!1;for(let b=v+1;b<g.length;b++)if(g[b].eventType!=="tool_use"){_=!0;break}_&&(g[v]={...g[v],settled:!0})}return g}function Mz(t,s,o){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=fk(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 fk(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 Iz(t,s){var u;const o=new Map;for(const p of s)o.set(p.id,p);const r=fk(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 Oz(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 Lz(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 Rs=[{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
|
|
313
|
+
--- End forwarded ---`}function l5(t){return t.replace(/[\r\n]+/g," ").trim().replace(/---/g,"—")}function c5({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(S=>{r(!0),S!==void 0?(d(new Set([S])),u.current=S):(d(new Set),u.current=void 0)},[]),g=y.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=y.useCallback((S,j)=>{if(j&&u.current!==void 0){const w=Math.min(u.current,S),T=Math.max(u.current,S);d(C=>{const A=new Set(C);for(let L=w;L<=T;L++)L<t.length&&hl(t[L])&&A.add(L);return A})}else d(w=>{const T=new Set(w);return T.has(S)?T.delete(S):T.add(S),T.size===0?(r(!1),u.current=void 0):u.current=S,T})},[t]),_=y.useCallback(()=>{const S=new Set;for(let j=0;j<t.length;j++)hl(t[j])&&S.add(j);d(S)},[t]),b=y.useCallback(()=>{d(new Set)},[]),x=y.useCallback(async()=>{const j=[...c].sort((T,C)=>T-C).filter(T=>T<t.length).map(T=>t[T]);if(j.length===0)return!1;const w=s(j);try{return await navigator.clipboard.writeText(w),!0}catch{return!1}},[c,t,s]);return{isSelecting:o,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:_,deselectAll:b,copySelected:x}}const d5="_wrapper_1cdza_1",u5="_scrollContainer_1cdza_9",f5="_selectingPadding_1cdza_16",p5="_toolbar_1cdza_20",m5="_directionToggle_1cdza_27",h5="_scrollToAnchor_1cdza_65",g5="_scrollToAnchorBottom_1cdza_89",v5="_scrollToAnchorTop_1cdza_93",y5="_eventOverflowWarning_1cdza_97",oa={wrapper:d5,scrollContainer:u5,selectingPadding:f5,toolbar:p5,directionToggle:m5,scrollToAnchor:h5,scrollToAnchorBottom:g5,scrollToAnchorTop:v5,eventOverflowWarning:y5},b5=10*1024,_5=new Set(["running","idle"]);function x5(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 H1="grackle-stream-direction";function k5(){try{return localStorage.getItem(H1)==="reversed"}catch{return!1}}function S5({eventsDropped:t}){return t<=0?a.jsx(a.Fragment,{}):a.jsxs("div",{className:oa.eventOverflowWarning,role:"alert",children:[a.jsx(wm,{size:Ut,"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 al({events:t,eventsDropped:s,emptyState:o,onShowToast:r,sessions:c,currentSessionId:d,environments:u,personas:p,onForward:m}){const g=y.useRef(null),[v,_]=y.useState(k5),b=O3(),[x,S]=y.useState(!1),[j,w]=y.useState(!1),[T,C]=y.useState(void 0),A=c5({events:t,formatForClipboard:z1}),L=y.useMemo(()=>t.filter(hl).length,[t]),E=y.useMemo(()=>c?c.filter(q=>_5.has(q.status)&&q.id!==d):[],[c,d]),M=y.useMemo(()=>v?[...t].reverse():t,[t,v]),{isAtAnchor:H,scrollToAnchor:D}=a5({scrollRef:g,contentLength:t.length,isReversed:v,paused:A.isSelecting}),z=()=>{const q=!v;_(q);try{localStorage.setItem(H1,q?"reversed":"default")}catch{}};y.useEffect(()=>{if(!A.isSelecting)return;const q=le=>{le.key==="Escape"&&!x&&!j&&A.cancelSelection()};return window.addEventListener("keydown",q),()=>{window.removeEventListener("keydown",q)}},[A.isSelecting,A.cancelSelection,x,j]);const Y=y.useCallback(async()=>{await A.copySelected()&&(r==null||r(`Copied ${A.selectedCount} message${A.selectedCount===1?"":"s"} to clipboard`,"success"))},[A,r]),V=y.useCallback(()=>[...A.selectedIndices].sort((le,de)=>le-de).filter(le=>le<t.length).map(le=>t[le]),[A.selectedIndices,t]),Q=y.useCallback(q=>{if(!q)return"this session";const le=c==null?void 0:c.find(xe=>xe.id===q);if(!le)return q.slice(0,8);const de=u==null?void 0:u.find(xe=>xe.id===le.environmentId);return(de==null?void 0:de.displayName)??le.environmentId.slice(0,8)},[c,u]),ge=y.useCallback(async(q,le)=>{if(!m)return;const de=Q(q);try{await m(q,le);const xe=A.selectedCount;r==null||r(`Forwarded ${xe} message${xe===1?"":"s"} to ${de}`,"success"),A.cancelSelection()}catch{r==null||r("Failed to forward messages","error")}},[m,Q,r,A]),X=y.useCallback(q=>{S(!1);const le=V(),de=Q(d),xe=r5(de,le);if(new TextEncoder().encode(xe).length>b5){C({sessionId:q,text:xe}),w(!0);return}ge(q,xe).catch(()=>{})},[V,Q,d,ge]),re=y.useCallback(()=>{w(!1),T&&(ge(T.sessionId,T.text).catch(()=>{}),C(void 0))},[T,ge]),B=y.useCallback(()=>{w(!1),C(void 0)},[]),R=b?0:.2,Z=v?-8:8,me=T?Math.round(new TextEncoder().encode(T.text).length/1024):0;return a.jsxs("div",{className:oa.wrapper,children:[a.jsx("div",{className:oa.toolbar,children:a.jsx(Oi,{text:v?"Showing newest first":"Showing oldest first",children:a.jsx("button",{className:oa.directionToggle,onClick:z,"aria-label":v?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:v?a.jsx(Sy,{size:Ut,"aria-hidden":"true"}):a.jsx(jy,{size:Ut,"aria-hidden":"true"})})})}),a.jsxs("div",{ref:g,className:`${oa.scrollContainer} ${A.isSelecting?oa.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&o,a.jsx(S5,{eventsDropped:s}),a.jsx(ls,{initial:!1,children:M.map((q,le)=>{const de=v?t.length-1-le:le;return a.jsx(At.div,{initial:{opacity:0,y:Z},animate:{opacity:1,y:0},transition:{duration:R,ease:"easeOut"},children:a.jsx(j6,{copyText:o5(q),isContentBearing:hl(q),isSelecting:A.isSelecting,isSelected:A.selectedIndices.has(de),checkboxLabel:x5(q),onSelect:()=>{A.enterSelectionMode(de)},onToggle:xe=>{A.toggleEvent(de,xe)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:a.jsx(cD,{event:q,toolUseCtx:q.toolUseCtx,settled:q.settled})})},`${q.sessionId}-${q.timestamp}-${de}`)})})]}),a.jsx(ls,{children:A.isSelecting&&a.jsx(M6,{selectedCount:A.selectedCount,totalSelectable:L,onSelectAll:A.selectAll,onDeselectAll:A.deselectAll,onCopy:()=>{Y().catch(()=>{})},onForward:m!==void 0?()=>{S(!0)}:void 0,forwardDisabled:E.length===0,onCancel:A.cancelSelection})}),a.jsx(t5,{isOpen:x,sessions:E,environments:u??[],personas:p,onSelect:X,onCancel:()=>{S(!1)}}),a.jsx(ks,{isOpen:j,title:"Send large message?",description:`This will forward a large message (${me} KB). Continue?`,confirmLabel:"Send",onConfirm:re,onCancel:B}),a.jsx(ls,{children:!H&&a.jsxs(At.button,{className:`${oa.scrollToAnchor} ${v?oa.scrollToAnchorTop:oa.scrollToAnchorBottom}`,onClick:D,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:[v?a.jsx(jy,{size:Ut,"aria-hidden":"true"}):a.jsx(Sy,{size:Ut,"aria-hidden":"true"})," New events"]})})]})}function gh(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]=y.useState(""),x=y.useRef(!1),S=d===c,j=y.useCallback(H=>{v(H),b("")},[]),w=y.useCallback(()=>{b("")},[]),T=y.useCallback(()=>{x.current=!1,u==null||u(null),v(""),b("")},[u]),C=y.useCallback(()=>{const H=m?g.trim():g;if(r){const z=r(g);if(z){b(z);return}}const D=m?s.trim():s;if(H===D){T();return}o(H),T()},[g,s,m,r,o,T]),A=y.useCallback(()=>{x.current=!0,u==null||u(c),v(s),b("")},[c,s,u]),L=y.useCallback(H=>{if(x.current){x.current=!1;return}H.relatedTarget instanceof HTMLElement&&H.relatedTarget.dataset.editAction===c||C()},[c,C]),E=y.useCallback(H=>{H.key==="Escape"?T():H.key==="Enter"&&p&&C()},[T,p,C]),M=(()=>{if(!S)return!1;const H=m?s.trim():s;return(m?g.trim():g)!==H})();return y.useEffect(()=>{!S&&(g!==""||_!=="")&&(v(""),b(""))},[S,g,_]),{isEditing:S,draft:g,error:_,isDirty:M,startEdit:A,cancelEdit:T,save:C,setDraft:j,clearError:w,handleBlur:L,handleKeyDown:E,ignoreInitialBlurRef:x}}const j5="_editFieldWrapper_yuzty_1",T5="_editInput_yuzty_10",w5="_editTextarea_yuzty_42",N5="_editSelect_yuzty_78",C5="_editError_yuzty_111",E5="_editInputInvalid_yuzty_118",A5="_editHint_yuzty_123",D5="_unsavedDot_yuzty_132",R5="_metaValueClickable_yuzty_140",M5="_editButton_yuzty_159",I5="_metaPlaceholder_yuzty_175",O5="_worktreeToggle_yuzty_180",at={editFieldWrapper:j5,editInput:T5,editTextarea:w5,editSelect:N5,editError:C5,editInputInvalid:E5,editHint:A5,unsavedDot:D5,metaValueClickable:R5,editButton:M5,metaPlaceholder:I5,worktreeToggle:O5};function Yt(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:_,ariaLabel:b,"data-testid":x}=t,S=y.useRef(null),j=gh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(j.isEditing){const T=window.setTimeout(()=>{var C;(C=S.current)==null||C.focus()},0);return()=>window.clearTimeout(T)}},[j.isEditing]),c==="create"){const T=A=>{m==null||m(A.target.value)},C=r==null?void 0:r(s);return a.jsxs("div",{className:at.editFieldWrapper,children:[a.jsx("input",{className:`${at.editInput} ${C?at.editInputInvalid:""}`,value:s,onChange:T,maxLength:_,placeholder:v,"aria-label":b,"data-testid":x?`${x}-input`:void 0}),C&&a.jsx("span",{className:at.editError,"data-testid":"edit-error",children:C})]})}if(j.isEditing)return a.jsxs("div",{className:at.editFieldWrapper,children:[a.jsx("input",{ref:S,className:`${at.editInput} ${j.error?at.editInputInvalid:""}`,value:j.draft,onChange:T=>j.setDraft(T.target.value),onBlur:j.handleBlur,onKeyDown:j.handleKeyDown,maxLength:_,placeholder:v,"aria-label":b,"data-testid":x?`${x}-input`:void 0}),j.isDirty&&a.jsx("span",{className:at.unsavedDot,title:"Unsaved changes"}),j.error&&a.jsx("span",{className:at.editError,"data-testid":"edit-error",children:j.error}),a.jsx("span",{className:at.editHint,children:"Enter to save · Esc to cancel"})]});const w=g==null?void 0:g(s);return a.jsxs("span",{role:"button",tabIndex:0,className:at.metaValueClickable,onClick:()=>j.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),j.startEdit())},title:"Click to edit","aria-label":b,"data-testid":x?`${x}-button`:void 0,children:[w!==void 0?w:s?a.jsx("span",{children:s}):a.jsx("span",{className:at.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:at.editButton,"aria-hidden":"true",children:"✏️"})]})}function ym(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:_,"data-testid":b}=t,x=y.useRef(null),S=gh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(S.isEditing){const w=window.setTimeout(()=>{var T;(T=x.current)==null||T.focus()},0);return()=>window.clearTimeout(w)}},[S.isEditing]),c==="create"){const w=C=>{m==null||m(C.target.value)},T=r==null?void 0:r(s);return a.jsxs("div",{className:at.editFieldWrapper,children:[a.jsx("textarea",{className:`${at.editTextarea} ${T?at.editInputInvalid:""}`,value:s,onChange:w,placeholder:v,"aria-label":_,"data-testid":b?`${b}-input`:void 0}),T&&a.jsx("span",{className:at.editError,"data-testid":"edit-error",children:T})]})}if(S.isEditing)return a.jsxs("div",{className:at.editFieldWrapper,children:[a.jsx("textarea",{ref:x,className:`${at.editTextarea} ${S.error?at.editInputInvalid:""}`,value:S.draft,onChange:w=>S.setDraft(w.target.value),onBlur:S.handleBlur,onKeyDown:S.handleKeyDown,title:_,"aria-label":_,"data-testid":b?`${b}-input`:void 0}),S.isDirty&&a.jsx("span",{className:at.unsavedDot,title:"Unsaved changes"}),S.error&&a.jsx("span",{className:at.editError,"data-testid":"edit-error",children:S.error}),a.jsx("span",{className:at.editHint,children:"Tab to save · Esc to cancel"})]});const j=g==null?void 0:g(s);return a.jsxs("span",{role:"button",tabIndex:0,className:at.metaValueClickable,onClick:()=>S.startEdit(),onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),S.startEdit())},title:"Click to edit","aria-label":_,"data-testid":b?`${b}-button`:void 0,children:[j!==void 0?j:s?a.jsx("span",{children:s}):a.jsx("span",{className:at.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:at.editButton,"aria-hidden":"true",children:"✏️"})]})}function jd(t){var A;const{value:s,onSave:o,mode:r="edit",options:c,fieldId:d="select",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:_,"data-testid":b}=t,x=y.useRef(null),S=gh({value:s,onSave:o,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(S.isEditing){const L=window.setTimeout(()=>{var E;(E=x.current)==null||E.focus()},0);return()=>window.clearTimeout(L)}},[S.isEditing]);const j=y.useCallback(L=>{const E=L.target.value;S.ignoreInitialBlurRef.current=!1,E!==s&&o(E),S.cancelEdit()},[s,o,S]),w=y.useCallback(L=>{if(S.ignoreInitialBlurRef.current){S.ignoreInitialBlurRef.current=!1;return}L.relatedTarget instanceof HTMLElement&&L.relatedTarget.dataset.editAction===d||S.cancelEdit()},[d,S]);if(r==="create")return a.jsx("select",{className:at.editSelect,value:s,onChange:L=>m==null?void 0:m(L.target.value),"aria-label":_,"data-testid":b?`${b}-select`:void 0,children:c.map(L=>a.jsx("option",{value:L.value,children:L.label},L.value))});if(S.isEditing)return a.jsx("select",{ref:x,className:at.editSelect,value:S.draft,onChange:j,onBlur:w,title:_,"aria-label":_,"data-testid":b?`${b}-select`:void 0,children:c.map(L=>a.jsx("option",{value:L.value,children:L.label},L.value))});const T=g==null?void 0:g(s),C=(A=c.find(L=>L.value===s))==null?void 0:A.label;return a.jsxs("button",{type:"button",className:at.metaValueClickable,onClick:()=>S.startEdit(),title:"Click to change","aria-label":_,"data-testid":b?`${b}-button`:void 0,children:[T!==void 0?T:C?a.jsx("span",{children:C}):a.jsx("span",{className:at.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:at.editButton,"aria-hidden":"true",children:"✏️"})]})}function L5(t){const{checked:s,onChange:o,label:r,ariaLabel:c,"data-testid":d}=t;return a.jsxs("label",{className:at.worktreeToggle,"data-testid":d,children:[a.jsx("input",{type:"checkbox",checked:s,onChange:u=>o(u.target.checked),"aria-label":c}),a.jsx("span",{children:r})]})}const B5="_nav_1snmp_1",$5="_searchForm_1snmp_8",z5="_searchInput_1snmp_15",H5="_searchButton_1snmp_33",P5="_clearButton_1snmp_68",U5="_workspaceSelect_1snmp_85",V5="_listHeader_1snmp_99",q5="_nodeList_1snmp_108",G5="_nodeItem_1snmp_116",F5="_indicator_1snmp_129",Z5="_label_1snmp_136",K5="_badge_1snmp_145",ns={nav:B5,searchForm:$5,searchInput:z5,searchButton:H5,clearButton:P5,workspaceSelect:U5,listHeader:V5,nodeList:q5,nodeItem:G5,indicator:F5,label:Z5,badge:K5};function Y5({nodes:t,workspaces:s,loading:o,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=y.useState(""),v=y.useCallback(S=>{S.preventDefault(),m.trim()&&c(m.trim())},[m,c]),_=y.useCallback(()=>{g(""),d()},[d]),b=y.useCallback(S=>{u(S)},[u]),x=y.useCallback(S=>{g(""),p(S)},[p]);return a.jsxs("div",{className:ns.nav,"data-testid":"knowledge-nav",children:[a.jsxs("form",{className:ns.searchForm,onSubmit:v,children:[a.jsx("input",{className:ns.searchInput,type:"text",placeholder:"Search...",value:m,onChange:S=>{g(S.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),a.jsx("button",{type:"submit",className:ns.searchButton,disabled:o,children:"Go"})]}),r&&a.jsx("button",{type:"button",className:ns.clearButton,onClick:_,children:"Clear search"}),a.jsxs("select",{className:ns.workspaceSelect,onChange:S=>{x(S.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[a.jsx("option",{value:"",children:"All workspaces"}),s.map(S=>a.jsx("option",{value:S.id,children:S.name},S.id))]}),a.jsxs("div",{className:ns.listHeader,children:["Nodes (",t.length,")"]}),a.jsx("ul",{className:ns.nodeList,children:t.map(S=>a.jsxs("li",{className:ns.nodeItem,onClick:()=>{b(S.id)},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),b(S.id))},role:"button",tabIndex:0,children:[a.jsx("span",{className:ns.indicator,style:{backgroundColor:S.kind==="reference"?"#4A9EFF":S.category==="decision"?"#22C55E":S.category==="concept"?"#A855F7":S.category==="snippet"?"#6B7280":"#EAB308"}}),a.jsx("span",{className:ns.label,children:S.label}),a.jsx("span",{className:ns.badge,children:S.kind==="reference"?S.sourceType:S.category})]},S.id))})]})}const J5="_container_bwu10_1",W5="_hamburger_bwu10_33",X5="_brand_bwu10_49",Q5="_brandLogo_bwu10_68",eI="_info_bwu10_75",tI="_connectionLabel_bwu10_90",nI="_connectionDot_bwu10_103",sI="_connected_bwu10_106",aI="_disconnected_bwu10_110",iI="_connecting_bwu10_113",Ms={container:J5,hamburger:W5,brand:X5,brandLogo:Q5,info:eI,connectionLabel:tI,connectionDot:nI,connected:sI,disconnected:aI,connecting:iI},oI={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},rI={connected:Ms.connected,connecting:Ms.connecting,disconnected:Ms.disconnected};function lI({connectionStatus:t,environments:s,sessions:o,onToggleSidebar:r,sidebarOpen:c}){const d=dt(),u=s.length,p=s.filter(v=>v.status==="connected").length,m=o.filter(v=>["running","idle"].includes(v.status)).length,g=oI[t];return a.jsxs("div",{className:Ms.container,children:[r&&a.jsx("button",{type:"button",className:Ms.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:a.jsx(fT,{size:Et,"aria-hidden":"true"})}),a.jsx(Oi,{text:"Home",placement:"bottom",children:a.jsxs("button",{type:"button",className:Ms.brand,onClick:()=>d(Ii),"data-testid":"statusbar-brand",children:[a.jsx("img",{src:"/icon-192x192.png",alt:"",className:Ms.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),a.jsxs("div",{className:Ms.info,children:[a.jsxs("span",{"aria-label":g,children:[a.jsx("span",{className:`${Ms.connectionDot} ${rI[t]}`,"aria-hidden":"true",children:a.jsx(Ja,{size:Nm,fill:"currentColor"})})," ",a.jsx("span",{className:Ms.connectionLabel,"aria-hidden":"true",children:g})]}),a.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),a.jsxs("span",{children:[m," active"]})]})]})}const cI="_nav_13gkc_1",dI="_tab_13gkc_35",uI="_tabIcon_13gkc_68",fI="_tabLabel_13gkc_79",pI="_tabActive_13gkc_84",Gr={nav:cI,tab:dI,tabIcon:uI,tabLabel:fI,tabActive:pI},ld=[{view:"dashboard",label:"Dashboard",icon:a.jsx(Qj,{size:Et}),route:Ii,testId:"sidebar-tab-dashboard"},{view:"chat",label:"Chat",icon:a.jsx(L_,{size:Et}),route:cl,testId:"sidebar-tab-chat"},{view:"tasks",label:"Tasks",icon:a.jsx(Lj,{size:Et}),route:GN,testId:"sidebar-tab-tasks"},{view:"environments",label:"Environments",icon:a.jsx(hT,{size:Et}),route:Bo,testId:"sidebar-tab-environments"},{view:"knowledge",label:"Knowledge",icon:a.jsx(Cj,{size:Et}),route:ix,testId:"sidebar-tab-knowledge"},{view:"findings",label:"Findings",icon:a.jsx(fd,{size:Et}),route:$d,testId:"sidebar-tab-findings"},{view:"settings",label:"Settings",icon:a.jsx(AT,{size:Et}),route:zN,testId:"sidebar-tab-settings"}];function mI(t){return t===Ii||t==="/"?"dashboard":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(ix)?"knowledge":t.startsWith($d)?"findings":t.startsWith(Ai)?"settings":"tasks"}function hI({tabs:t=ld}){const s=Wt(),o=dt(),r=y.useRef(null),c=mI(s.pathname),d=y.useCallback(p=>{o(p.route)},[o]),u=y.useCallback(p=>{var b,x;const m=(b=r.current)==null?void 0:b.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(S=>S===document.activeElement),v=g>=0?g:t.findIndex(S=>S.view===c);let _=v;if(p.key==="ArrowRight"||p.key==="j"||p.key==="J")p.preventDefault(),_=(v+1)%t.length;else if(p.key==="ArrowLeft"||p.key==="k"||p.key==="K")p.preventDefault(),_=(v-1+t.length)%t.length;else if(p.key==="Home")p.preventDefault(),_=0;else if(p.key==="End")p.preventDefault(),_=t.length-1;else return;o(t[_].route),(x=m[_])==null||x.focus()},[c,o,t]);return a.jsx("nav",{className:Gr.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 a.jsx(Oi,{text:p.label,placement:"bottom",children:a.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Gr.tab} ${m?Gr.tabActive:""}`,onClick:()=>d(p),"data-testid":p.testId,"aria-label":p.label,children:[a.jsx("span",{className:Gr.tabIcon,"aria-hidden":"true",children:p.icon}),a.jsx("span",{className:Gr.tabLabel,children:p.label})]})},p.view)})})}const gI="_container_pi6ii_1",vI="_content_pi6ii_66",s_={container:gI,content:vI},yI=320,P1=220,U1=600,V1="grackle-sidebar-width";function bI(){try{const t=localStorage.getItem(V1);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=P1&&s<=U1)return s}}catch{}return yI}function _I(t){try{localStorage.setItem(V1,String(t))}catch{}}function xI({content:t}){const[s]=y.useState(bI),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>=P1&&m<=U1&&_I(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return a.jsx("div",{className:s_.container,ref:o,"data-testid":"sidebar",style:{width:s},children:a.jsx("div",{className:s_.content,children:t})})}const kI="_bar_tnfsh_1",SI="_btnPrimary_tnfsh_32",jI="_statusText_tnfsh_85",TI="_statusCompleted_tnfsh_90",wI="_statusFailed_tnfsh_94",NI="_statusBlocked_tnfsh_98",CI="_hintText_tnfsh_103",Ct={bar:kI,btnPrimary:SI,statusText:jI,statusCompleted:TI,statusFailed:wI,statusBlocked:NI,hintText:CI};function EI({sessions:t,tasks:s,environments:o}){const r=dt(),c=Wt(),d=Dt("/sessions/:sessionId"),u=Dt("/tasks/:taskId"),p=Dt("/tasks/:taskId/stream"),m=Dt("/tasks/:taskId/findings"),g=Dt("/tasks/:taskId/edit"),v=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),_=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),b=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings"),x=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),S=Dt("/sessions/new"),j=Dt("/environments/:environmentId/workspaces/:workspaceId"),w=Dt("/tasks/new"),T=Dt("/chat"),C=Dt("/"),A=Dt("/settings/*"),L=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)??(_==null?void 0:_.params.taskId)??(b==null?void 0:b.params.taskId)??(x==null?void 0:x.params.taskId),M=v??_??b??x,H=(M==null?void 0:M.params.environmentId)??(j==null?void 0:j.params.environmentId),D=c.pathname.startsWith("/environments")&&!j&&!M,z=!!T,Y=!!S,V=!!j&&!v&&!_&&!b&&!x,Q=!!w;if(!!C&&!Y&&!V&&!Q||!!A||(!!g||!!x)||Q||D||Y)return a.jsx(a.Fragment,{});if(z)return o.find(R=>R.adapterType==="local"&&R.status==="connected")?a.jsx(a.Fragment,{}):a.jsx("div",{className:Ct.bar,children:a.jsx("span",{className:Ct.hintText,children:"Add a local environment to start chatting"})});if(V)return a.jsx("div",{className:Ct.bar,children:a.jsx("span",{className:Ct.hintText,children:"Select a task or click + to create one"})});if(E){const B=s.find(me=>me.id===E);if(!B)return a.jsx("div",{className:Ct.bar,children:a.jsx("span",{className:Ct.hintText,children:"Loading..."})});const R=new Map(s.map(me=>[me.id,me])),Z=B.dependsOn.some(me=>{const q=R.get(me);return q!==void 0&&q.status!=="complete"});if(B.status==="not_started"){const me=Z?B.dependsOn.map(q=>R.get(q)).filter(q=>q&&q.status!=="complete").map(q=>q.title):[];return a.jsx("div",{className:Ct.bar,children:Z?a.jsxs("span",{className:Ct.statusBlocked,children:["Blocked by: ",me.join(", ")]}):a.jsx("span",{className:Ct.hintText,children:"Use the buttons above to start or manage this task"})})}if(B.status==="working"||B.status==="paused"){const me=B.latestSessionId||void 0,q=me?t.find(de=>de.id===me):void 0;return q&&q.status!=="stopped"?a.jsx(a.Fragment,{}):a.jsx("div",{className:Ct.bar,children:a.jsx("span",{className:Ct.hintText,children:"Waiting for agent..."})})}if(B.status==="complete")return a.jsxs("div",{className:Ct.bar,children:[a.jsx("span",{className:`${Ct.statusText} ${Ct.statusCompleted}`,children:"Task completed"}),a.jsx("button",{onClick:()=>r($i(B.workspaceId,void 0,H)),className:Ct.btnPrimary,children:"+ New Task"})]});if(B.status==="failed")return a.jsx("div",{className:Ct.bar,children:a.jsx("span",{className:`${Ct.statusText} ${Ct.statusFailed}`,children:"Task failed"})})}if(L){const B=t.find(me=>me.id===L),R=(B==null?void 0:B.status)==="stopped";if(B!==void 0&&!R)return a.jsx(a.Fragment,{});if(R)return a.jsxs("div",{className:Ct.bar,children:[a.jsxs("span",{className:`${Ct.statusText} ${Ct.hintText}`,children:["Session ",B.endReason||B.status]}),a.jsx("button",{onClick:()=>r(tx(B.environmentId)),className:Ct.btnPrimary,children:"+ New Chat"})]})}return a.jsx("div",{className:Ct.bar,children:a.jsx("span",{className:Ct.hintText,children:"Loading..."})})}const AI="_nav_14i94_1",DI="_tab_14i94_24",RI="_tabActive_14i94_62",MI="_tabLabel_14i94_75",II="_statusDot_14i94_81",OI="_pulse_14i94_87",LI="_addButton_14i94_99",BI="_empty_14i94_132",qa={nav:AI,tab:DI,tabActive:RI,tabLabel:MI,statusDot:II,pulse:OI,addButton:LI,empty:BI},$I={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function zI({environments:t}){const s=dt(),o=y.useRef(null),r=Dt("/environments/:environmentId"),c=Dt("/environments/:environmentId/edit"),d=Dt("/environments/:environmentId/workspaces/:workspaceId"),u=Dt("/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(b=>{s(Mi(b))},[s]),v=y.useCallback(b=>{var T;const x=(T=o.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!x||x.length===0)return;const S=Array.from(x).findIndex(C=>C===document.activeElement),j=S>=0?S:t.findIndex(C=>C.id===m);let w=j;if(b.key==="ArrowDown"||b.key==="j"||b.key==="J")b.preventDefault(),w=(j+1)%x.length;else if(b.key==="ArrowUp"||b.key==="k"||b.key==="K")b.preventDefault(),w=(j-1+x.length)%x.length;else if(b.key==="Home")b.preventDefault(),w=0;else if(b.key==="End")b.preventDefault(),w=x.length-1;else return;w<t.length&&s(Mi(t[w].id)),x[w].focus()},[m,t,s]),_=m??(t.length>0?t[0].id:void 0);return a.jsxs("div",{className:qa.nav,"data-testid":"environment-nav",children:[a.jsx("nav",{ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(b=>{const x=b.id===m,S=b.id===_,j=$I[b.status]||"var(--text-tertiary)",w=b.status==="connected";return a.jsxs("button",{role:"tab",type:"button","aria-selected":x,tabIndex:S?0:-1,className:`${qa.tab} ${x?qa.tabActive:""}`,onClick:()=>g(b.id),"data-testid":"env-nav-item",children:[a.jsx("span",{className:`${qa.statusDot} ${w?qa.pulse:""}`,style:{color:j},"aria-hidden":"true",children:a.jsx(Ja,{size:Nm,fill:"currentColor"})}),a.jsx("span",{className:qa.tabLabel,title:b.displayName||b.id,children:b.displayName||b.id})]},b.id)})}),a.jsx("button",{type:"button",className:qa.addButton,onClick:()=>s(BN),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&a.jsx("div",{className:qa.empty,children:"No environments yet."})]})}function Uo(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()}`}function q1(t){const s=new Date(t);if(Number.isNaN(s.getTime()))return"—";const o=new Date,r=s.getTime()-o.getTime();if(r<=0)return"overdue";const c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return`in ${c}s`;if(d<60)return`in ${d}m`;if(u<24)return`in ${u}h`;if(p<7)return`in ${p} day${p===1?"":"s"}`;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 a_={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 Td(t){return a_[t]||a_.general}const HI="_nav_dlm8m_1",PI="_categoryPills_dlm8m_24",UI="_categoryPill_dlm8m_24",VI="_tab_dlm8m_42",qI="_tabActive_dlm8m_80",GI="_tabContent_dlm8m_93",FI="_tabLabel_dlm8m_100",ZI="_tabMeta_dlm8m_106",KI="_categoryDot_dlm8m_111",YI="_empty_dlm8m_118",Ds={nav:HI,categoryPills:PI,categoryPill:UI,tab:VI,tabActive:qI,tabContent:GI,tabLabel:FI,tabMeta:ZI,categoryDot:KI,empty:YI};function JI({findings:t,workspaceId:s,environmentId:o}){const r=dt(),c=y.useRef(null),d=Dt("/findings/:findingId"),u=Dt("/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 b=new Set(t.map(x=>x.category).filter(Boolean));return Array.from(b).sort()},[t]),g=y.useCallback(b=>{r(Qp(b,s,o))},[r,s,o]),v=y.useCallback(b=>{var T;const x=(T=c.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!x||x.length===0)return;const S=Array.from(x).findIndex(C=>C===document.activeElement),j=S>=0?S:t.findIndex(C=>C.id===p);let w=j;if(b.key==="ArrowDown"||b.key==="j"||b.key==="J")b.preventDefault(),w=(j+1)%x.length;else if(b.key==="ArrowUp"||b.key==="k"||b.key==="K")b.preventDefault(),w=(j-1+x.length)%x.length;else if(b.key==="Home")b.preventDefault(),w=0;else if(b.key==="End")b.preventDefault(),w=x.length-1;else return;w<t.length&&r(Qp(t[w].id,s,o)),x[w].focus()},[p,t,r,s,o]),_=p??(t.length>0?t[0].id:void 0);return a.jsxs("div",{className:Ds.nav,"data-testid":"findings-nav",children:[m.length>1&&a.jsx("div",{className:Ds.categoryPills,"data-testid":"findings-nav-categories",children:m.map(b=>a.jsx("span",{className:Ds.categoryPill,style:{color:Td(b).text},children:b},b))}),a.jsx("nav",{ref:c,role:"tablist","aria-orientation":"vertical","aria-label":"Findings",onKeyDown:v,children:t.map(b=>{const x=b.id===p,S=b.id===_;return a.jsxs("button",{role:"tab",type:"button","aria-selected":x,tabIndex:S?0:-1,className:`${Ds.tab} ${x?Ds.tabActive:""}`,onClick:()=>g(b.id),"data-testid":"finding-nav-item",children:[a.jsx("span",{className:Ds.categoryDot,style:{color:Td(b.category).text},"aria-hidden":"true",children:a.jsx(Ja,{size:Nm,fill:"currentColor"})}),a.jsxs("span",{className:Ds.tabContent,children:[a.jsx("span",{className:Ds.tabLabel,title:b.title,children:b.title}),a.jsx("span",{className:Ds.tabMeta,title:b.createdAt,children:Uo(b.createdAt)})]})]},b.id)})}),t.length===0&&a.jsx("div",{className:Ds.empty,children:"No findings yet. Agents will post discoveries here."})]})}function WI(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 G1({text:t,indices:s,highlightClass:o}){if(!s||s.length===0)return a.jsx(a.Fragment,{children:t});const r=WI(s),c=[];let d=0;for(const[u,p]of r)u>d&&c.push(a.jsx("span",{children:t.slice(d,u)},`p${d}`)),c.push(a.jsx("mark",{className:o,children:t.slice(u,p+1)},`m${u}`)),d=p+1;return d<t.length&&c.push(a.jsx("span",{children:t.slice(d)},`p${d}`)),a.jsx(a.Fragment,{children:c})}function XI(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 QI(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 PT){c.add(d);const u=o.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=Wa(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=Wa(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const eO="_container_z4i38_1",tO="_header_z4i38_5",nO="_headerActions_z4i38_17",sO="_searchInput_z4i38_23",aO="_searchHighlight_z4i38_56",iO="_groupToggle_z4i38_62",oO="_groupToggleActive_z4i38_89",rO="_addButton_z4i38_93",lO="_taskRow_z4i38_120",cO="_selected_z4i38_140",dO="_expandArrow_z4i38_150",uO="_expanded_z4i38_157",fO="_leafSpacer_z4i38_161",pO="_taskStatusIcon_z4i38_166",mO="_taskTitle_z4i38_170",hO="_workspaceBadge_z4i38_177",gO="_childCountBadge_z4i38_195",vO="_dependencyBadge_z4i38_208",yO="_blockedBadge_z4i38_220",bO="_addChildButton_z4i38_225",_O="_emptyState_z4i38_268",xO="_statusGroupHeader_z4i38_275",kO="_statusGroupIcon_z4i38_294",SO="_statusGroupLabel_z4i38_298",jO="_statusGroupCount_z4i38_303",Ye={container:eO,header:tO,headerActions:nO,searchInput:sO,searchHighlight:aO,groupToggle:iO,groupToggleActive:oO,addButton:rO,taskRow:lO,selected:cO,expandArrow:dO,expanded:uO,leafSpacer:fO,taskStatusIcon:pO,taskTitle:mO,workspaceBadge:hO,childCountBadge:gO,dependencyBadge:vO,blockedBadge:yO,addChildButton:bO,emptyState:_O,statusGroupHeader:xO,statusGroupIcon:kO,statusGroupLabel:SO,statusGroupCount:jO},TO=[{name:"title",weight:2},{name:"description",weight:1}],F1=16,wO=16,Z1="grackle-task-group-by-status";function i_(){try{return localStorage.getItem(Z1)==="true"}catch{return!1}}function NO(t){try{localStorage.setItem(Z1,String(t))}catch{}}function CO({group:t,isExpanded:s,onToggle:o,selectedTaskId:r,navigate:c,titleHighlights:d,workspaceNames:u}){return a.jsxs("div",{"data-testid":`status-group-${t.status}`,children:[a.jsxs("div",{className:Ye.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:o,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),o())},children:[a.jsx("span",{className:`${Ye.expandArrow} ${s?Ye.expanded:""}`,"aria-hidden":"true",children:a.jsx(ma,{size:it})}),a.jsx("span",{className:Ye.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),a.jsx("span",{className:Ye.statusGroupLabel,children:t.label}),a.jsx("span",{className:Ye.statusGroupCount,children:t.tasks.length})]}),a.jsx(ls,{children:s&&a.jsx(At.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=Wa(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return a.jsxs("div",{onClick:()=>c(Hn(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:_=>{_.currentTarget===_.target&&(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),c(Hn(p.id)))},className:`${Ye.taskRow} ${g?Ye.selected:""}`,style:{"--task-indent":`${F1}px`},"data-task-id":p.id,children:[a.jsx("span",{className:Ye.leafSpacer}),a.jsx("span",{className:Ye.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${gl(p.status)}`,children:m.icon}),a.jsx("span",{className:Ye.taskTitle,title:p.title,children:a.jsx(G1,{text:p.title,indices:d.get(p.id),highlightClass:Ye.searchHighlight})}),v&&a.jsx("span",{className:Ye.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function K1({node:t,depth:s,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=Wa(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(T=>u.get(T)!=="complete"),_=o.has(t.id),b=t.children.length>0,x=c===t.id,S=F1+s*wO,w=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{onClick:()=>d(Hn(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:T=>{T.currentTarget===T.target&&(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),d(Hn(t.id)))},className:`${Ye.taskRow} ${x?Ye.selected:""}`,style:{"--task-indent":`${S}px`},"data-task-id":t.id,children:[b&&a.jsx("span",{className:`${Ye.expandArrow} ${_?Ye.expanded:""}`,role:"button",tabIndex:0,"aria-label":_?"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:a.jsx(ma,{size:it,"aria-hidden":"true"})}),!b&&a.jsx("span",{className:Ye.leafSpacer}),a.jsx("span",{className:Ye.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${gl(t.status)}`,children:g.icon}),a.jsx("span",{className:Ye.taskTitle,title:t.title,children:a.jsx(G1,{text:t.title,indices:p.get(t.id),highlightClass:Ye.searchHighlight})}),w&&a.jsx("span",{className:Ye.workspaceBadge,title:w,children:w}),b&&a.jsxs("span",{className:Ye.childCountBadge,children:[t.children.filter(T=>T.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&a.jsx("span",{className:`${Ye.dependencyBadge} ${v?Ye.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<H2&&a.jsx(Oi,{text:"Add child task",children:a.jsx("button",{onClick:T=>{T.stopPropagation(),d($i(t.workspaceId,t.id))},"aria-label":"Add child task",className:Ye.addChildButton,children:"+"})})]}),a.jsx(ls,{children:b&&_&&a.jsx(At.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=>a.jsx(K1,{node:T,depth:s+1,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},T.id))})})]})}function EO({workspaces:t,tasks:s}){const o=dt(),[r,c]=y.useState(new Set),[d,u]=y.useState(new Set),[p,m]=y.useState(i_),[g,v]=y.useState(i_),[_,b]=y.useState(new Map),x=Dt("/tasks/:taskId/*"),S=(x==null?void 0:x.params.taskId)!=="new"?x==null?void 0:x.params.taskId:void 0,j=y.useMemo(()=>new Map(s.map(X=>[X.id,X.status])),[s]),w=y.useMemo(()=>new Map(t.map(X=>[X.id,X.name])),[t]),T=()=>{const X=!p;NO(X),m(X),X&&(v(!0),b(new Map))},C=X=>{b(re=>{const B=new Map(re),R=B.has(X)?B.get(X):g;return B.set(X,!R),B})},A=X=>_.has(X)?_.get(X):g,L=X=>{c(re=>{const B=new Set(re);return B.has(X)?(B.delete(X),u(R=>new Set(R).add(X))):(B.add(X),u(R=>{const Z=new Set(R);return Z.delete(X),Z})),B})};y.useEffect(()=>{const X=new Set(s.filter(re=>re.parentTaskId).map(re=>re.parentTaskId));X.size>0&&c(re=>{const B=new Set(re);for(const R of X)d.has(R)||B.add(R);return B})},[s,d]);const[E,M]=y.useState(""),{directMatchTaskIds:H,treeMatchTaskIds:D,titleHighlights:z}=y.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const X=z2(s,E,TO),re=new Set(X.map(me=>me.item.id)),B=new Map;for(const me of X){const q=me.matches.find(le=>le.key==="title");q&&B.set(me.item.id,q.indices)}const R=new Set(re),Z=new Map(s.map(me=>[me.id,me]));for(const me of[...re]){let q=Z.get(me);for(;q!=null&&q.parentTaskId;)R.add(q.parentTaskId),q=Z.get(q.parentTaskId)}return{directMatchTaskIds:re,treeMatchTaskIds:R,titleHighlights:B}},[E,s]),Y=H!==null,V=Y?p?H:D:null,Q=V?s.filter(X=>V.has(X.id)):s,ge=p?[]:XI(Q);return a.jsxs("div",{className:Ye.container,children:[a.jsxs("div",{className:Ye.header,children:[a.jsx("span",{children:"Tasks"}),a.jsxs("div",{className:Ye.headerActions,children:[a.jsx(Oi,{text:p?"Switch to tree view":"Group tasks by status",children:a.jsx("button",{className:`${Ye.groupToggle} ${p?Ye.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:a.jsx(lT,{size:Ut})})}),a.jsx(Oi,{text:"New task",children:a.jsx("button",{className:Ye.addButton,onClick:()=>o($i()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&a.jsx("input",{type:"text",value:E,onChange:X=>M(X.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:Ye.searchInput,"data-testid":"sidebar-search"}),p?QI(Q,j).map(X=>a.jsx(CO,{group:X,isExpanded:A(X.status),onToggle:()=>C(X.status),selectedTaskId:S,navigate:o,titleHighlights:z,workspaceNames:w},X.status)):ge.map(X=>a.jsx(K1,{node:X,depth:0,expandedTasks:r,toggleTask:L,selectedTaskId:S,navigate:o,taskStatusById:j,titleHighlights:z,workspaceNames:w},X.id)),Q.length===0&&!Y&&a.jsx("div",{className:Ye.emptyState,children:"No tasks yet. Click + to create one."}),Q.length===0&&Y&&a.jsx("div",{className:Ye.emptyState,children:"No matching tasks"})]})}const AO="_toast_ed2dk_1",DO="_success_ed2dk_18",RO="_icon_ed2dk_22",MO="_error_ed2dk_25",IO="_warning_ed2dk_32",OO="_info_ed2dk_38",LO="_message_ed2dk_53",BO="_close_ed2dk_60",Fr={toast:AO,success:DO,icon:RO,error:MO,warning:IO,info:OO,message:LO,close:BO},$O={success:a.jsx(Li,{size:Et}),error:a.jsx($s,{size:Et}),warning:a.jsx(wm,{size:Et}),info:a.jsx(Tm,{size:Et})};function zO({toast:t,onDismiss:s}){return y.useEffect(()=>{const o=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(o)},[t.id,t.duration,s]),a.jsxs(At.div,{className:`${Fr.toast} ${Fr[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:[a.jsx("span",{className:Fr.icon,"aria-hidden":"true",children:$O[t.variant]}),a.jsx("span",{className:Fr.message,children:t.message}),a.jsx("button",{type:"button",className:Fr.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:a.jsx($s,{size:Ut,"aria-hidden":"true"})})]})}const HO="_container_qqse2_1",PO={container:HO};function UO({toasts:t,onDismiss:s}){return a.jsx("div",{className:PO.container,"data-testid":"toast-container",children:a.jsx(ls,{children:t.map(o=>a.jsx(zO,{toast:o,onDismiss:s},o.id))})})}const VO="_callout_e5awm_1",qO="_success_e5awm_11",GO="_icon_e5awm_15",FO="_error_e5awm_18",ZO="_warning_e5awm_25",KO="_info_e5awm_32",YO="_content_e5awm_48",JO="_close_e5awm_53",Zr={callout:VO,success:qO,icon:GO,error:FO,warning:ZO,info:KO,content:YO,close:JO},WO={success:a.jsx(Li,{size:Et}),error:a.jsx($s,{size:Et}),warning:a.jsx(wm,{size:Et}),info:a.jsx(Tm,{size:Et})};function XO({variant:t="info",children:s,dismissible:o=!1,className:r}){const[c,d]=y.useState(!1);return a.jsx(a.Fragment,{children:!c&&a.jsxs("div",{className:[Zr.callout,Zr[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[a.jsx("span",{className:Zr.icon,"aria-hidden":"true",children:WO[t]}),a.jsx("span",{className:Zr.content,children:s}),o&&a.jsx("button",{type:"button",className:Zr.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:a.jsx($s,{size:Ut,"aria-hidden":"true"})})]})})}function QO({currentVersion:t,latestVersion:s,updateAvailable:o,isDocker:r}){if(!o)return a.jsx(a.Fragment,{});const c=r?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return a.jsx("div",{"data-testid":"update-banner",children:a.jsxs(XO,{variant:"info",dismissible:!0,children:[a.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",t,")."," ","Run: ",a.jsx("code",{children:c})]})})}const eL="_container_de44x_1",tL="_emptyState_de44x_8",nL="_card_de44x_14",sL="_cardClickable_de44x_34",aL="_cardHeader_de44x_42",iL="_categoryBadge_de44x_54",oL="_findingTitle_de44x_62",rL="_findingDate_de44x_68",lL="_findingContent_de44x_80",cL="_tags_de44x_86",dL="_tag_de44x_86",bs={container:eL,emptyState:tL,card:nL,cardClickable:sL,cardHeader:aL,categoryBadge:iL,findingTitle:oL,findingDate:rL,findingContent:lL,tags:cL,tag:dL};function Y1({findings:t,onFindingClick:s}){return t.length===0?a.jsx("div",{className:bs.emptyState,children:"No findings yet. Agents will post discoveries here."}):a.jsx("div",{className:bs.container,children:t.map((o,r)=>{const c=Td(o.category),d=s?At.button:At.div;return a.jsxs(d,{type:s?"button":void 0,className:`${bs.card} ${s?bs.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:[a.jsxs("div",{className:bs.cardHeader,children:[a.jsx("span",{className:bs.categoryBadge,style:{background:c.bg,color:c.text},children:o.category}),a.jsx("span",{className:bs.findingTitle,children:o.title}),a.jsx("span",{className:bs.findingDate,title:o.createdAt,children:Uo(o.createdAt)})]}),a.jsx("div",{className:bs.findingContent,children:o.content.length>300?o.content.slice(0,300)+"...":o.content}),o.tags.length>0&&a.jsx("div",{className:bs.tags,children:o.tags.map(u=>a.jsx("span",{className:bs.tag,style:{color:c.text,textShadow:`0 0 8px ${c.text}`},children:u},u))})]},o.id)})})}const uL="_container_m1fsr_1",fL="_heading_m1fsr_7",pL="_section_m1fsr_14",mL="_sectionTitle_m1fsr_26",hL="_sectionDescription_m1fsr_35",gL="_emptyState_m1fsr_41",vL="_tokenList_m1fsr_48",yL="_tokenRow_m1fsr_55",bL="_tokenBadge_m1fsr_68",_L="_tokenName_m1fsr_83",xL="_tokenTarget_m1fsr_90",kL="_deleteButton_m1fsr_99",SL="_addForm_m1fsr_113",jL="_formRow_m1fsr_119",TL="_input_m1fsr_125",wL="_select_m1fsr_155",NL="_addButton_m1fsr_187",CL="_emptyStateInfo_m1fsr_221",EL="_themeOptions_m1fsr_229",AL="_themeOption_m1fsr_229",DL="_themeOptionSelected_m1fsr_254",RL="_themeOptionHeader_m1fsr_259",ML="_themeOptionLabel_m1fsr_266",IL="_themeOptionDesc_m1fsr_273",OL="_variantToggle_m1fsr_279",LL="_variantButton_m1fsr_286",BL="_variantActive_m1fsr_305",$L="_themeSwatches_m1fsr_311",zL="_themeSwatch_m1fsr_311",HL="_systemToggle_m1fsr_325",PL="_systemToggleHint_m1fsr_341",UL="_themeActive_m1fsr_348",VL="_aboutGrid_m1fsr_354",qL="_aboutItem_m1fsr_360",GL="_aboutLabel_m1fsr_373",FL="_aboutValue_m1fsr_379",ZL="_aboutDot_m1fsr_387",KL="_aboutDotConnected_m1fsr_394",YL="_aboutDotDisconnected_m1fsr_398",JL="_aboutDotConnecting_m1fsr_402",ue={container:uL,heading:fL,section:pL,sectionTitle:mL,sectionDescription:hL,emptyState:gL,tokenList:vL,tokenRow:yL,tokenBadge:bL,tokenName:_L,tokenTarget:xL,deleteButton:kL,addForm:SL,formRow:jL,input:TL,select:wL,addButton:NL,emptyStateInfo:CL,themeOptions:EL,themeOption:AL,themeOptionSelected:DL,themeOptionHeader:RL,themeOptionLabel:ML,themeOptionDesc:IL,variantToggle:OL,variantButton:LL,variantActive:BL,themeSwatches:$L,themeSwatch:zL,systemToggle:HL,systemToggleHint:PL,themeActive:UL,aboutGrid:VL,aboutItem:qL,aboutLabel:GL,aboutValue:FL,aboutDot:ZL,aboutDotConnected:KL,aboutDotDisconnected:YL,aboutDotConnecting:JL},WL=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function XL({tokens:t,onSetToken:s,onDeleteToken:o,onShowToast:r}){const[c,d]=y.useState(""),[u,p]=y.useState(""),[m,g]=y.useState("env_var"),[v,_]=y.useState(""),[b,x]=y.useState(null),S=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(""),_("")},j=T=>{x(T)},w=()=>{b&&(o(b),r==null||r("Token deleted","info")),x(null)};return a.jsxs(a.Fragment,{children:[a.jsx(ks,{isOpen:b!==null,title:"Delete Token?",description:b?`"${b}" will be permanently removed.`:void 0,onConfirm:w,onCancel:()=>x(null)}),a.jsxs("section",{className:ue.section,children:[a.jsx("h3",{className:ue.sectionTitle,children:"Tokens"}),a.jsx("p",{className:ue.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?a.jsx("div",{className:ue.emptyStateInfo,children:"Add your first API token to enable service integrations."}):a.jsx("div",{className:ue.tokenList,children:t.map(T=>a.jsxs("div",{className:ue.tokenRow,children:[a.jsx("span",{className:ue.tokenBadge,children:T.tokenType}),a.jsx("span",{className:ue.tokenName,children:T.name}),a.jsx("span",{className:ue.tokenTarget,children:T.tokenType==="env_var"?T.envVar:T.filePath}),a.jsx("button",{className:ue.deleteButton,onClick:()=>j(T.name),title:`Delete ${T.name}`,"aria-label":`Delete ${T.name}`,children:a.jsx($s,{size:Ut,"aria-hidden":"true"})})]},T.name))}),a.jsxs("form",{className:ue.addForm,onSubmit:S,children:[a.jsxs("div",{className:ue.formRow,children:[a.jsx("input",{className:ue.input,type:"text",placeholder:"Token name",value:c,onChange:T=>d(T.target.value)}),a.jsx("input",{className:ue.input,type:"password",placeholder:"Value",value:u,onChange:T=>p(T.target.value)})]}),a.jsxs("div",{className:ue.formRow,children:[a.jsx("select",{className:ue.select,value:m,onChange:T=>g(T.target.value),children:WL.map(T=>a.jsx("option",{value:T.value,children:T.label},T.value))}),a.jsx("input",{className:ue.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=>_(T.target.value)}),a.jsx("button",{className:ue.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const Gd=[{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"]}],J1=new Set(Gd.map(t=>t.id)),o_="grackle";function bm(t){return Gd.find(s=>s.id===t)}function QL({themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c}){return a.jsxs("section",{className:ue.section,children:[a.jsx("h3",{className:ue.sectionTitle,children:"Appearance"}),a.jsx("p",{className:ue.sectionDescription,children:"Choose how Grackle looks across the app."}),a.jsx("div",{className:ue.themeOptions,children:Gd.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 a.jsxs("button",{type:"button",className:`${ue.themeOption} ${p?ue.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>o(d.id),children:[a.jsxs("span",{className:ue.themeOptionHeader,children:[a.jsxs("span",{children:[a.jsx("span",{className:ue.themeOptionLabel,children:d.label}),a.jsx("span",{className:ue.themeOptionDesc,children:d.description})]}),u&&a.jsxs("span",{className:ue.variantToggle,children:[a.jsx("span",{role:"button",tabIndex:0,className:`${ue.variantButton} ${p&&m?ue.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:"☼"}),a.jsx("span",{role:"button",tabIndex:0,className:`${ue.variantButton} ${p&&!m?ue.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&&a.jsx("span",{className:ue.themeSwatches,children:d.swatches.map((g,v)=>a.jsx("span",{className:ue.themeSwatch,style:{background:g}},v))})]},d.id)})}),a.jsxs("label",{className:ue.systemToggle,children:[a.jsx("input",{type:"checkbox",checked:r,onChange:d=>c(d.target.checked)}),a.jsx("span",{children:"Match system light/dark preference"})]}),a.jsx("p",{className:ue.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),a.jsxs("p",{className:ue.themeActive,children:["Active theme: ",a.jsx("strong",{children:s})]})]})}const eB={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},tB={connected:ue.aboutDotConnected,connecting:ue.aboutDotConnecting,disconnected:ue.aboutDotDisconnected};function nB({connectionStatus: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 a.jsxs("section",{className:ue.section,"data-testid":"about-panel",children:[a.jsx("h3",{className:ue.sectionTitle,children:"About"}),a.jsx("p",{className:ue.sectionDescription,children:"Connection status and application information."}),a.jsxs("div",{className:ue.aboutGrid,children:[a.jsxs("div",{className:ue.aboutItem,children:[a.jsx("span",{className:ue.aboutLabel,children:"Connection"}),a.jsxs("span",{className:ue.aboutValue,children:[a.jsx("span",{className:`${ue.aboutDot} ${tB[t]}`}),eB[t]]})]}),a.jsxs("div",{className:ue.aboutItem,children:[a.jsx("span",{className:ue.aboutLabel,children:"Environments"}),a.jsxs("span",{className:ue.aboutValue,children:[r,"/",c," connected"]})]}),a.jsxs("div",{className:ue.aboutItem,children:[a.jsx("span",{className:ue.aboutLabel,children:"Active Sessions"}),a.jsx("span",{className:ue.aboutValue,children:d})]}),a.jsxs("div",{className:ue.aboutItem,children:[a.jsx("span",{className:ue.aboutLabel,children:"Version"}),a.jsx("span",{className:ue.aboutValue,children:"0.108.3"})]})]})]})}const sB="_container_cddyd_1",aB="_header_cddyd_8",iB="_headerTitle_cddyd_35",oB="_badge_cddyd_44",rB="_headerActions_cddyd_54",lB="_body_cddyd_61",cB="_formContent_cddyd_73",dB="_section_cddyd_85",uB="_label_cddyd_91",fB="_titleInput_cddyd_98",pB="_descriptionTextarea_cddyd_131",mB="_parentContext_cddyd_167",hB="_parentLabel_cddyd_175",gB="_parentName_cddyd_182",vB="_personaSelect_cddyd_186",yB="_depList_cddyd_220",bB="_depItem_cddyd_226",_B="_depItemSelected_cddyd_248",xB="_noDeps_cddyd_252",kB="_btnPrimary_cddyd_258",SB="_btnGhost_cddyd_289",st={container:sB,header:aB,headerTitle:iB,badge:oB,headerActions:rB,body:lB,formContent:cB,section:dB,label:uB,titleInput:fB,descriptionTextarea:pB,parentContext:mB,parentLabel:hB,parentName:gB,personaSelect:vB,depList:yB,depItem:bB,depItemSelected:_B,noDeps:xB,btnPrimary:kB,btnGhost:SB};function W1({mode:t,taskId:s,workspaceId:o,parentTaskId:r,environmentId:c,tasks:d,workspaces:u,personas:p,onCreateTask:m,onUpdateTask:g,onEditDone:v,onShowToast:_}){const b=dt(),x=t==="edit",S=x&&s?d.find(Se=>Se.id===s):void 0,j=x?(S==null?void 0:S.workspaceId)??"":o??"",[w,T]=y.useState(j),C=j||w,A=u.find(Se=>Se.id===C),L=c??(A==null?void 0:A.linkedEnvironmentIds[0]),E=!x&&!o,M=x?(S==null?void 0:S.parentTaskId)??"":r??"",H=M?d.find(Se=>Se.id===M):void 0,[D,z]=y.useState((S==null?void 0:S.title)??""),[Y,V]=y.useState((S==null?void 0:S.description)??""),[Q,ge]=y.useState((S==null?void 0:S.dependsOn)??[]),[X,re]=y.useState((S==null?void 0:S.defaultPersonaId)??""),[B,R]=y.useState((S==null?void 0:S.canDecompose)??!1),[Z,me]=y.useState(!1),q=y.useRef(!1);y.useEffect(()=>{x&&S&&!q.current&&(q.current=!0,z(S.title),V(S.description),ge(S.dependsOn),re(S.defaultPersonaId),R(S.canDecompose))},[x,S]);const le=d.filter(Se=>Se.workspaceId===C&&(!x||Se.id!==s)&&Se.id!==M),de=D.trim().length>0&&(!x||S!==void 0)&&C.length>0,xe=Se=>{ge(fe=>fe.includes(Se)?fe.filter(be=>be!==Se):[...fe,Se])},ke=()=>{!de||Z||x&&S===void 0||(x&&s?(g(s,D.trim(),Y,Q,X),_==null||_("Task updated","success"),v?v():b(Hn(s,void 0,C,L),{replace:!0})):(me(!0),m(C,D.trim(),Y,Q.length>0?Q:void 0,M||void 0,X,B,()=>{_==null||_("Task created","success"),b(o?Ri(o,L):"/tasks",{replace:!0})},Se=>{_==null||_(Se,"error"),me(!1)})))},Ze=()=>{if(v){v();return}b(x&&s?Hn(s,void 0,C,L):o?Ri(o,L):"/tasks")},Xe=x?"edit task":M?"child task":"new task";return a.jsxs("div",{className:st.container,children:[a.jsxs("div",{className:st.header,children:[a.jsxs("div",{className:st.headerTitle,children:[a.jsx("span",{className:st.badge,children:Xe}),H&&a.jsxs("span",{className:st.parentContext,children:[a.jsx("span",{className:st.parentLabel,children:"Child of"}),a.jsx("span",{className:st.parentName,children:H.title})]})]}),a.jsxs("div",{className:st.headerActions,children:[a.jsx("button",{onClick:ke,disabled:!de||Z,className:st.btnPrimary,"data-testid":"task-edit-save",children:Z?"Creating…":x?"Save Changes":"Create"}),a.jsx("button",{onClick:Ze,className:st.btnGhost,children:"Cancel"})]})]}),a.jsx("div",{className:st.body,children:a.jsxs("div",{className:st.formContent,children:[E&&a.jsxs("div",{className:st.section,children:[a.jsx("label",{className:st.label,htmlFor:"task-edit-workspace",children:"Workspace"}),a.jsxs("select",{id:"task-edit-workspace",value:w,onChange:Se=>T(Se.target.value),className:st.personaSelect,"data-testid":"task-edit-workspace",children:[a.jsx("option",{value:"",children:"Select a workspace..."}),u.map(Se=>a.jsx("option",{value:Se.id,children:Se.name},Se.id))]})]}),a.jsxs("div",{className:st.section,children:[a.jsx("label",{className:st.label,htmlFor:"task-edit-title",children:"Title"}),a.jsx("input",{id:"task-edit-title",type:"text",value:D,onChange:Se=>z(Se.target.value),placeholder:"Task title...",autoFocus:!0,className:st.titleInput,"data-testid":"task-edit-title",onKeyDown:Se=>{Se.key==="Enter"&&de&&ke()}})]}),a.jsxs("div",{className:st.section,children:[a.jsx("label",{className:st.label,htmlFor:"task-edit-description",children:"Description"}),a.jsx("textarea",{id:"task-edit-description",value:Y,onChange:Se=>V(Se.target.value),placeholder:"Describe the task... (markdown supported)",className:st.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),a.jsxs("div",{className:st.section,children:[a.jsx("label",{className:st.label,htmlFor:"task-edit-persona",children:"Default Persona"}),a.jsxs("select",{id:"task-edit-persona",value:X,onChange:Se=>re(Se.target.value),className:st.personaSelect,"data-testid":"task-edit-persona",children:[a.jsx("option",{value:"",children:"(Inherit)"}),p.map(Se=>a.jsx("option",{value:Se.id,children:Se.name},Se.id))]})]}),!x&&a.jsx("div",{className:st.section,children:a.jsxs("label",{className:st.depItem,"data-testid":"task-edit-can-decompose",children:[a.jsx("input",{type:"checkbox",checked:B,onChange:Se=>R(Se.target.checked)}),"Can spawn subtasks"]})}),a.jsxs("div",{className:st.section,children:[a.jsx("div",{className:st.label,children:"Dependencies"}),le.length===0?a.jsx("div",{className:st.noDeps,children:"No other tasks in this workspace"}):a.jsx("div",{className:st.depList,children:le.map(Se=>{const fe=Q.includes(Se.id);return a.jsxs("label",{className:`${st.depItem} ${fe?st.depItemSelected:""}`,"data-testid":`dep-option-${Se.id}`,children:[a.jsx("input",{type:"checkbox",checked:fe,onChange:()=>xe(Se.id)}),Se.title,a.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",Se.status,")"]})]},Se.id)})})]})]})})]})}const jB="_actionButtons_1rjka_1",TB="_btnPrimary_1rjka_8",wB="_btnDanger_1rjka_39",NB="_btnGhost_1rjka_78",en={actionButtons:jB,btnPrimary:TB,btnDanger:wB,btnGhost:NB};function CB({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?a.jsxs("div",{className:en.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:m,className:en.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),a.jsx("button",{onClick:p,className:en.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):a.jsxs("div",{className:en.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{"data-testid":"task-header-start",onClick:r,className:en.btnPrimary,children:"Start"}),a.jsx("button",{onClick:m,className:en.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),a.jsx("button",{onClick:p,className:en.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return a.jsxs("div",{className:en.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:d,className:en.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),a.jsx("button",{onClick:u,disabled:!s,className:en.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused")return a.jsxs("div",{className:en.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:d,className:en.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),a.jsx("button",{onClick:c,className:en.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),a.jsx("button",{onClick:p,className:en.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="complete")return a.jsx("div",{className:en.actionButtons,"data-testid":"task-action-buttons",children:a.jsx("button",{onClick:p,className:en.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return a.jsxs("div",{className:en.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:r,className:en.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),a.jsx("button",{onClick:p,className:en.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const EB="_workpadSection_y8nj9_1",AB="_workpadLabel_y8nj9_9",DB="_workpadStatus_y8nj9_17",RB="_workpadSummary_y8nj9_23",MB="_workpadExtra_y8nj9_29",Ga={workpadSection:EB,workpadLabel:AB,workpadStatus:DB,workpadSummary:RB,workpadExtra:MB};function IB({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 a.jsxs("div",{className:Ga.workpadSection,"data-testid":"workpad-panel",children:[a.jsx("div",{className:Ga.workpadLabel,children:"Workpad"}),a.jsx("div",{className:Ga.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return a.jsxs("div",{className:Ga.workpadSection,"data-testid":"workpad-panel",children:[a.jsx("div",{className:Ga.workpadLabel,children:"Workpad"}),s.status&&a.jsx("div",{className:Ga.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&a.jsx("div",{className:Ga.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&a.jsx("div",{className:Ga.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const OB="_overviewDashboard_r05qm_1",LB="_overviewHero_r05qm_7",BB="_statusBadge_r05qm_14",$B="_statusPending_r05qm_26",zB="_statusAssigned_r05qm_31",HB="_statusInProgress_r05qm_36",PB="_statusReview_r05qm_41",UB="_statusDone_r05qm_46",VB="_statusFailed_r05qm_51",qB="_statusWaitingInput_r05qm_56",GB="_overviewBranchPill_r05qm_61",FB="_branchLink_r05qm_76",ZB="_overviewSection_r05qm_87",KB="_overviewLabel_r05qm_93",YB="_overviewValue_r05qm_100",JB="_overviewMuted_r05qm_105",WB="_overviewMarkdown_r05qm_111",XB="_envRow_r05qm_180",QB="_envDot_r05qm_186",e8="_envDotGreen_r05qm_193",t8="_envDotYellow_r05qm_197",n8="_envDotRed_r05qm_201",s8="_envDotGray_r05qm_205",a8="_depList_r05qm_209",i8="_depItem_r05qm_215",o8="_depBlocked_r05qm_222",r8="_depDone_r05qm_226",l8="_timeline_r05qm_230",c8="_timelineRow_r05qm_236",d8="_timelineKey_r05qm_243",u8="_timelineValue_r05qm_249",f8="_timelineDelta_r05qm_253",p8="_reviewNotes_r05qm_264",ye={overviewDashboard:OB,overviewHero:LB,statusBadge:BB,statusPending:$B,statusAssigned:zB,statusInProgress:HB,statusReview:PB,statusDone:UB,statusFailed:VB,statusWaitingInput:qB,overviewBranchPill:GB,branchLink:FB,overviewSection:ZB,overviewLabel:KB,overviewValue:YB,overviewMuted:JB,overviewMarkdown:WB,envRow:XB,envDot:QB,envDotGreen:e8,envDotYellow:t8,envDotRed:n8,envDotGray:s8,depList:a8,depItem:i8,depBlocked:o8,depDone:r8,timeline:l8,timelineRow:c8,timelineKey:d8,timelineValue:u8,timelineDelta:f8,reviewNotes:p8};function Yc(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 Lp(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 r_(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?ye.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?ye.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?ye.envDotRed:ye.envDotGray}function m8({status:t}){const s=Wa(t),o=HT(t);return a.jsx("span",{className:`${ye.statusBadge} ${ye[o]??ye.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function h8({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(S=>S.id===g):void 0,_=r.find(S=>S.id===t.workspaceId),b=o.find(S=>S.id===d),x=t.branch&&(_!=null&&_.repoUrl)?`${_.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return a.jsxs("div",{className:ye.overviewDashboard,"data-testid":"task-overview-panel",children:[a.jsxs("div",{className:ye.overviewHero,children:[a.jsx(m8,{status:t.status}),t.branch&&a.jsx("span",{className:ye.overviewBranchPill,"data-testid":"task-overview-branch",children:x?a.jsxs("a",{href:x,target:"_blank",rel:"noreferrer noopener",className:ye.branchLink,children:["🔗"," ",t.branch]}):a.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&a.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-description",children:[a.jsx("div",{className:ye.overviewLabel,children:"Description"}),a.jsx("div",{className:ye.overviewMarkdown,children:a.jsx(Ed,{remarkPlugins:[Ad],children:t.description})})]}),t.workpad&&a.jsx(IB,{workpad:t.workpad}),a.jsxs("div",{className:ye.overviewSection,children:[a.jsx("div",{className:ye.overviewLabel,children:"Environment"}),g&&v?a.jsxs("div",{className:ye.envRow,"data-testid":"task-overview-environment",children:[a.jsx("span",{className:`${ye.envDot} ${r_(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),a.jsx("span",{className:ye.overviewValue,children:v.displayName})]}):b?a.jsxs("div",{className:ye.envRow,"data-testid":"task-overview-environment",children:[a.jsx("span",{className:`${ye.envDot} ${r_(b.status)}`,title:b.status,"aria-label":`Status: ${b.status}`,role:"img"}),a.jsx("span",{className:ye.overviewValue,children:b.displayName}),a.jsx("span",{className:ye.overviewMuted,children:"(workspace default)"})]}):a.jsx("div",{className:ye.overviewMuted,children:"Set in workspace settings"})]}),a.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-dependencies",children:[a.jsx("div",{className:ye.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?a.jsx("div",{className:ye.overviewMuted,children:"None"}):a.jsx("div",{className:ye.depList,children:t.dependsOn.map(S=>{const j=s.get(S),w=(j==null?void 0:j.status)==="complete";return a.jsxs("div",{className:`${ye.depItem} ${w?ye.depDone:ye.depBlocked}`,children:[a.jsx("span",{children:w?"✓":"○"}),a.jsx("span",{children:(j==null?void 0:j.title)??S})]},S)})})]}),a.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-timeline",children:[a.jsx("div",{className:ye.overviewLabel,children:"Timeline"}),a.jsxs("div",{className:ye.timeline,children:[t.createdAt&&a.jsxs("div",{className:ye.timelineRow,children:[a.jsx("span",{className:ye.timelineKey,children:"Created"}),a.jsx("span",{className:ye.timelineValue,children:Yc(t.createdAt)})]}),t.assignedAt&&(()=>{const S=Lp(t.createdAt,t.assignedAt);return a.jsxs("div",{className:ye.timelineRow,children:[a.jsx("span",{className:ye.timelineKey,children:"Assigned"}),a.jsx("span",{className:ye.timelineValue,children:Yc(t.assignedAt)}),S!==void 0&&a.jsx("span",{className:ye.timelineDelta,children:S})]})})(),t.startedAt&&(()=>{const S=Lp(t.assignedAt??t.createdAt,t.startedAt);return a.jsxs("div",{className:ye.timelineRow,children:[a.jsx("span",{className:ye.timelineKey,children:"Started"}),a.jsx("span",{className:ye.timelineValue,children:Yc(t.startedAt)}),S!==void 0&&a.jsx("span",{className:ye.timelineDelta,children:S})]})})(),t.completedAt&&(()=>{const S=Lp(t.startedAt,t.completedAt);return a.jsxs("div",{className:ye.timelineRow,children:[a.jsx("span",{className:ye.timelineKey,children:"Completed"}),a.jsx("span",{className:ye.timelineValue,children:Yc(t.completedAt)}),S!==void 0&&a.jsx("span",{className:ye.timelineDelta,children:S})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&a.jsx("div",{className:ye.overviewMuted,children:"No timing data"})]})]}),u&&u.costMillicents>0&&a.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-usage",children:[a.jsx("div",{className:ye.overviewLabel,children:"Usage"}),a.jsxs("div",{className:ye.timeline,children:[a.jsxs("div",{className:ye.timelineRow,children:[a.jsx("span",{className:ye.timelineKey,children:"Cost"}),a.jsx("span",{className:ye.timelineValue,children:Is(u.costMillicents)}),a.jsxs("span",{className:ye.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costMillicents>u.costMillicents&&a.jsxs("div",{className:ye.timelineRow,children:[a.jsx("span",{className:ye.timelineKey,children:"Total (incl. subtasks)"}),a.jsx("span",{className:ye.timelineValue,children:Is(p.costMillicents)}),a.jsxs("span",{className:ye.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),(t.tokenBudget>0||t.costBudgetMillicents>0)&&a.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-budget",children:[a.jsx("div",{className:ye.overviewLabel,children:"Budget"}),a.jsxs("div",{className:ye.timeline,children:[t.tokenBudget>0&&a.jsxs("div",{className:ye.timelineRow,children:[a.jsx("span",{className:ye.timelineKey,children:"Tokens"}),a.jsxs("span",{className:ye.timelineValue,children:[$o(((u==null?void 0:u.inputTokens)??0)+((u==null?void 0:u.outputTokens)??0))," / ",$o(t.tokenBudget)]})]}),t.costBudgetMillicents>0&&a.jsxs("div",{className:ye.timelineRow,children:[a.jsx("span",{className:ye.timelineKey,children:"Cost"}),a.jsxs("span",{className:ye.timelineValue,children:[Is((u==null?void 0:u.costMillicents)??0)," / ",Is(t.costBudgetMillicents)]})]})]})]}),t.reviewNotes&&a.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-review-notes",children:[a.jsx("div",{className:ye.overviewLabel,children:"Review Notes"}),a.jsx("div",{className:ye.reviewNotes,children:t.reviewNotes})]})]})}function g8({plugins:t,loading:s,onSetPluginEnabled:o}){return a.jsxs("div",{className:ue.container,"data-testid":"plugins-panel",children:[a.jsx("h2",{className:ue.heading,children:"Plugins"}),a.jsxs("div",{className:ue.section,children:[a.jsx("p",{className:ue.sectionDescription,children:"Enable or disable optional Grackle plugins. A server restart is required for changes to take effect."}),s&&a.jsx("p",{className:ue.emptyState,children:"Loading plugins..."}),!s&&t.length===0&&a.jsx("p",{className:ue.emptyState,children:"No plugins found."}),!s&&t.map(r=>{const c=r.enabled!==r.loaded;return a.jsxs("div",{className:ue.tokenRow,"data-testid":`plugin-row-${r.name}`,children:[a.jsxs("div",{style:{flex:1},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[a.jsx("span",{className:ue.tokenName,children:r.name}),r.required&&a.jsx("span",{className:ue.tokenBadge,title:"Required — cannot be disabled",children:"required"})]}),a.jsx("div",{className:ue.tokenTarget,children:r.description}),c&&a.jsx("div",{style:{fontSize:"var(--font-size-xs)",color:"var(--accent-yellow)",marginTop:"2px"},"data-testid":`plugin-restart-notice-${r.name}`,children:"Restart Grackle to apply changes"})]}),a.jsx("label",{style:{display:"flex",alignItems:"center",gap:"6px",cursor:r.required?"not-allowed":"pointer"},title:r.required?"Core is required and cannot be disabled":void 0,children:a.jsx("input",{type:"checkbox",checked:r.enabled,disabled:r.required,onChange:d=>o(r.name,d.target.checked),"data-testid":`plugin-toggle-${r.name}`,"aria-label":`Enable or disable ${r.name} plugin`,style:{accentColor:"var(--accent-green)",width:"16px",height:"16px"}})})]},r.name)})]})]})}function v8({githubAccounts:t,githubAccountsLoading:s,onAddGitHubAccount:o,onUpdateGitHubAccount:r,onRemoveGitHubAccount:c,onImportGitHubAccounts:d,onShowToast:u}){const[p,m]=y.useState(""),[g,v]=y.useState(""),[_,b]=y.useState(!1),[x,S]=y.useState(!1),[j,w]=y.useState(!1),[T,C]=y.useState(null),A=t.find(D=>D.id===T),L=async D=>{if(D.preventDefault(),!(!p.trim()||!g.trim())){S(!0);try{await o(p.trim(),g.trim(),"",_),u==null||u("GitHub account added","success"),m(""),v(""),b(!1)}catch(z){const Y=z instanceof Error?z.message:"Failed to add account";u==null||u(Y,"error")}finally{S(!1)}}},E=async D=>{try{await r(D,{isDefault:!0}),u==null||u("Default account updated","success")}catch(z){const Y=z instanceof Error?z.message:"Failed to update account";u==null||u(Y,"error")}},M=async()=>{if(T)try{await c(T),u==null||u("GitHub account removed","info")}catch(D){const z=D instanceof Error?D.message:"Failed to remove account";u==null||u(z,"error")}finally{C(null)}},H=async()=>{w(!0);try{const D=await d();D.imported>0?u==null||u(`Imported ${D.imported} account(s): ${D.usernames.join(", ")}`,"success"):u==null||u("No new accounts to import","info")}catch(D){const z=D instanceof Error?D.message:"Import failed";u==null||u(z,"error")}finally{w(!1)}};return a.jsxs(a.Fragment,{children:[a.jsx(ks,{isOpen:T!==null,title:"Remove GitHub Account?",description:A?`"${A.label}"${A.username?` (@${A.username})`:""} will be permanently removed.`:void 0,onConfirm:()=>{M().catch(()=>{})},onCancel:()=>C(null)}),a.jsxs("section",{className:ue.section,"data-testid":"github-accounts-panel",children:[a.jsx("h3",{className:ue.sectionTitle,children:"GitHub Accounts"}),a.jsx("p",{className:ue.sectionDescription,children:"Register multiple GitHub accounts to use different identities per environment. The default account is used when no specific account is assigned."}),s&&t.length===0?a.jsx("div",{className:ue.emptyState,children:"Loading..."}):t.length===0?a.jsx("div",{className:ue.emptyStateInfo,children:"No GitHub accounts registered. Add one below or import from the gh CLI."}):a.jsx("div",{className:ue.tokenList,children:t.map(D=>a.jsxs("div",{className:ue.tokenRow,"data-testid":`github-account-row-${D.id}`,children:[D.isDefault&&a.jsx("span",{className:ue.tokenBadge,title:"Default account",children:"default"}),a.jsx("span",{className:ue.tokenName,children:D.label}),D.username&&a.jsxs("span",{className:ue.tokenTarget,children:["@",D.username]}),!D.isDefault&&a.jsx("button",{className:ue.deleteButton,onClick:()=>{E(D.id).catch(()=>{})},title:"Set as default","aria-label":`Set ${D.label} as default`,"data-testid":`github-account-set-default-${D.id}`,children:a.jsx(IT,{size:Ut,"aria-hidden":"true"})}),a.jsx("button",{className:ue.deleteButton,onClick:()=>C(D.id),title:`Remove ${D.label}`,"aria-label":`Remove ${D.label}`,"data-testid":`github-account-remove-${D.id}`,children:a.jsx($s,{size:Ut,"aria-hidden":"true"})})]},D.id))}),a.jsxs("form",{className:ue.addForm,onSubmit:D=>{L(D).catch(()=>{})},children:[a.jsxs("div",{className:ue.formRow,children:[a.jsx("input",{className:ue.input,type:"text",placeholder:"Label (e.g. personal, work)",value:p,onChange:D=>m(D.target.value),"data-testid":"github-account-label-input"}),a.jsx("input",{className:ue.input,type:"password",placeholder:"Personal access token",value:g,onChange:D=>v(D.target.value),"data-testid":"github-account-token-input"})]}),a.jsxs("div",{className:ue.formRow,children:[a.jsxs("label",{className:ue.tokenTarget,style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:_,onChange:D=>b(D.target.checked),"data-testid":"github-account-default-checkbox"}),"Set as default"]}),a.jsx("button",{className:ue.addButton,type:"submit",disabled:!p.trim()||!g.trim()||x,"data-testid":"github-account-add-button",children:x?"Adding...":"Add Account"}),a.jsx("button",{className:ue.addButton,type:"button",onClick:()=>{H().catch(()=>{})},disabled:j,"data-testid":"github-account-import-button",children:j?"Importing...":"Import from gh CLI"})]})]})]})]})}const y8="_container_legrg_1",b8="_header_legrg_8",_8="_headerTitle_legrg_35",x8="_badge_legrg_44",k8="_headerActions_legrg_54",S8="_body_legrg_61",j8="_formContent_legrg_73",T8="_section_legrg_85",w8="_label_legrg_91",N8="_nameInput_legrg_98",C8="_fieldInput_legrg_131",E8="_adapterSelect_legrg_164",A8="_readOnlyValue_legrg_198",D8="_codespaceSection_legrg_204",R8="_codespaceActions_legrg_210",M8="_creatingHint_legrg_216",I8="_errorHint_legrg_222",O8="_btnPrimary_legrg_235",L8="_btnGhost_legrg_266",oe={container:y8,header:b8,headerTitle:_8,badge:x8,headerActions:k8,body:S8,formContent:j8,section:T8,label:w8,nameInput:N8,fieldInput:C8,adapterSelect:E8,readOnlyValue:A8,codespaceSection:D8,codespaceActions:R8,creatingHint:M8,errorHint:I8,btnPrimary:O8,btnGhost:L8},cd=1,dd=65535;function Bp(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=cd&&s<=dd}function $p(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function B8({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]=y.useState(""),[x,S]=y.useState("");return g==="create"?a.jsxs("div",{className:oe.codespaceSection,children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Repository"}),a.jsx("input",{type:"text",value:_,onChange:j=>b(j.target.value),placeholder:"owner/repo",className:oe.fieldInput,"data-testid":"env-codespace-repo"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Machine Type"}),a.jsx("input",{type:"text",value:x,onChange:j=>S(j.target.value),placeholder:"Machine type (optional)...",className:oe.fieldInput,"data-testid":"env-codespace-machine"})]}),a.jsxs("div",{className:oe.codespaceActions,children:[a.jsx("button",{onClick:()=>{_.trim()&&(m(_.trim(),x.trim()||void 0),v("pick"),b(""),S(""))},disabled:!_.trim(),className:oe.btnPrimary,children:"Create"}),a.jsx("button",{onClick:()=>{v("pick"),b(""),S("")},className:oe.btnGhost,children:"Cancel"})]})]}):a.jsx("div",{className:oe.codespaceSection,children:a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Codespace"}),!u&&a.jsxs("select",{value:t,onChange:j=>{j.target.value==="__create__"?(v("create"),s("")):(s(j.target.value),j.target.value&&!o.trim()&&r(j.target.value))},disabled:p,className:oe.adapterSelect,"data-testid":"env-codespace-select",children:[a.jsx("option",{value:"",children:"Select a codespace..."}),c.map(j=>a.jsxs("option",{value:j.name,children:[j.name," (",j.repository,") — ",j.state]},j.name)),a.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&a.jsx("span",{className:oe.creatingHint,children:"Creating codespace..."}),u&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:oe.errorHint,children:u}),a.jsx("input",{type:"text",value:t,onChange:j=>s(j.target.value),placeholder:"Or enter codespace name manually...",className:oe.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&a.jsx("span",{className:oe.errorHint,children:d})]})})}function X1({mode:t,environmentId:s,environments:o,githubAccounts:r,onAddEnvironment:c,onUpdateEnvironment:d,onListCodespaces:u,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:_,onShowToast:b}){const x=dt(),S=t==="edit",j=S&&s?o.find(fe=>fe.id===s):void 0,[w,T]=y.useState(""),[C,A]=y.useState("local"),[L,E]=y.useState(""),[M,H]=y.useState(""),[D,z]=y.useState(""),[Y,V]=y.useState(""),[Q,ge]=y.useState(""),[X,re]=y.useState(""),[B,R]=y.useState(""),[Z,me]=y.useState(""),[q,le]=y.useState(null),de=y.useCallback(()=>{const fe={};if(C==="local"){if(L.trim()&&(fe.host=L.trim()),M.trim()){const be=Number(M);Number.isInteger(be)&&(fe.port=be)}}else if(C==="ssh"){if(fe.host=L.trim(),D.trim()&&(fe.user=D.trim()),M.trim()){const be=Number(M);Number.isInteger(be)&&(fe.sshPort=be)}Y.trim()&&(fe.identityFile=Y.trim())}else C==="docker"?(Q.trim()&&(fe.image=Q.trim()),X.trim()&&(fe.repo=X.trim())):C==="codespace"&&(fe.codespaceName=B.trim());return fe},[C,L,M,D,Y,Q,X,B]),xe=()=>!(!w.trim()||C==="ssh"&&!L.trim()||C==="codespace"&&!B.trim()||(C==="local"||C==="ssh")&&!Bp(M)),ke=()=>{xe()&&(c(w.trim(),C,de(),Z||void 0),b==null||b("Environment added successfully","success"),x(Bo,{replace:!0}))},Ze=()=>{x(s?Mi(s):Bo)},Xe=y.useCallback((fe,be)=>{if(!j||!s)return;const Vt=$p(j.adapterConfig),ie=be.trim();ie?Vt[fe]=ie:delete Vt[fe],d(s,{adapterConfig:Vt})},[j,s,d]),Se=y.useCallback((fe,be)=>{if(!j||!s)return;const Vt=$p(j.adapterConfig);if(be.trim()){const ie=Number(be);Number.isInteger(ie)&&ie>=cd&&ie<=dd&&(Vt[fe]=ie)}else delete Vt[fe];d(s,{adapterConfig:Vt})},[j,s,d]);if(S){if(!j)return a.jsxs("div",{className:oe.container,children:[a.jsxs("div",{className:oe.header,children:[a.jsx("div",{className:oe.headerTitle,children:a.jsx("span",{className:oe.badge,children:"edit environment"})}),a.jsx("div",{className:oe.headerActions,children:a.jsx("button",{onClick:Ze,className:oe.btnGhost,children:"Back"})})]}),a.jsx("div",{className:oe.body,children:a.jsx("div",{className:oe.formContent,children:a.jsx("span",{className:oe.readOnlyValue,children:"Environment not found"})})})]});const fe=$p(j.adapterConfig);return a.jsxs("div",{className:oe.container,"data-testid":"env-edit-panel",children:[a.jsxs("div",{className:oe.header,children:[a.jsx("div",{className:oe.headerTitle,children:a.jsx("span",{className:oe.badge,children:"edit environment"})}),a.jsx("div",{className:oe.headerActions,children:a.jsx("button",{onClick:Ze,className:oe.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),a.jsx("div",{className:oe.body,children:a.jsxs("div",{className:oe.formContent,children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Name"}),a.jsx(Yt,{value:j.displayName,onSave:be=>{s&&d(s,{displayName:be})},validate:be=>be.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:q,onActivate:le,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Adapter Type"}),a.jsx("span",{className:oe.readOnlyValue,"data-testid":"env-edit-adapter-type",children:j.adapterType})]}),(j.adapterType==="codespace"||j.adapterType==="docker")&&(r.length>0||!!j.githubAccountId)&&a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"GitHub Account"}),a.jsxs("select",{value:j.githubAccountId||"",onChange:be=>{s&&d(s,{githubAccountId:be.target.value})},className:oe.adapterSelect,"data-testid":"env-edit-github-account",children:[a.jsx("option",{value:"",children:"(Default)"}),r.map(be=>a.jsxs("option",{value:be.id,children:[be.label,be.username?` (@${be.username})`:"",be.isDefault?" — default":""]},be.id))]})]}),j.adapterType==="local"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Host"}),a.jsx(Yt,{value:String(fe.host??""),onSave:be=>Xe("host",be),mode:"edit",fieldId:"host",activeFieldId:q,onActivate:le,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Port"}),a.jsx(Yt,{value:String(fe.port??""),onSave:be=>Se("port",be),validate:be=>Bp(be)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:q,onActivate:le,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),j.adapterType==="ssh"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Host"}),a.jsx(Yt,{value:String(fe.host??""),onSave:be=>Xe("host",be),validate:be=>be.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:q,onActivate:le,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"User"}),a.jsx(Yt,{value:String(fe.user??""),onSave:be=>Xe("user",be),mode:"edit",fieldId:"user",activeFieldId:q,onActivate:le,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"SSH Port"}),a.jsx(Yt,{value:String(fe.sshPort??""),onSave:be=>Se("sshPort",be),validate:be=>Bp(be)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:q,onActivate:le,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Identity File"}),a.jsx(Yt,{value:String(fe.identityFile??""),onSave:be=>Xe("identityFile",be),mode:"edit",fieldId:"identityFile",activeFieldId:q,onActivate:le,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),j.adapterType==="docker"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Image"}),a.jsx(Yt,{value:String(fe.image??""),onSave:be=>Xe("image",be),mode:"edit",fieldId:"image",activeFieldId:q,onActivate:le,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Repo"}),a.jsx(Yt,{value:String(fe.repo??""),onSave:be=>Xe("repo",be),mode:"edit",fieldId:"repo",activeFieldId:q,onActivate:le,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),j.adapterType==="codespace"&&a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,children:"Codespace Name"}),a.jsx(Yt,{value:String(fe.codespaceName??""),onSave:be=>Xe("codespaceName",be),validate:be=>be.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:q,onActivate:le,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return a.jsxs("div",{className:oe.container,"data-testid":"env-create-panel",children:[a.jsxs("div",{className:oe.header,children:[a.jsx("div",{className:oe.headerTitle,children:a.jsx("span",{className:oe.badge,children:"new environment"})}),a.jsxs("div",{className:oe.headerActions,children:[a.jsx("button",{onClick:ke,disabled:!xe(),className:oe.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),a.jsx("button",{onClick:Ze,className:oe.btnGhost,children:"Cancel"})]})]}),a.jsx("div",{className:oe.body,children:a.jsxs("div",{className:oe.formContent,children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-name",children:"Name"}),a.jsx("input",{id:"env-create-name",type:"text",value:w,onChange:fe=>T(fe.target.value),placeholder:"Environment name...",autoFocus:!0,className:oe.nameInput,"data-testid":"env-create-name",onKeyDown:fe=>{fe.key==="Enter"&&xe()&&ke()}})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),a.jsxs("select",{id:"env-create-adapter",value:C,onChange:fe=>{A(fe.target.value),fe.target.value==="codespace"&&u(Z||void 0)},className:oe.adapterSelect,"data-testid":"env-create-adapter",children:[a.jsx("option",{value:"local",children:"local"}),a.jsx("option",{value:"ssh",children:"ssh"}),a.jsx("option",{value:"docker",children:"docker"}),a.jsx("option",{value:"codespace",children:"codespace"})]})]}),(C==="codespace"||C==="docker")&&r.length>0&&a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-github-account",children:"GitHub Account"}),a.jsxs("select",{id:"env-create-github-account",value:Z,onChange:fe=>{me(fe.target.value),C==="codespace"&&u(fe.target.value||void 0)},className:oe.adapterSelect,"data-testid":"env-create-github-account",children:[a.jsx("option",{value:"",children:"(Default)"}),r.map(fe=>a.jsxs("option",{value:fe.id,children:[fe.label," (@",fe.username,")",fe.isDefault?" — default":""]},fe.id))]})]}),C==="local"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-host",children:"Host"}),a.jsx("input",{id:"env-create-host",type:"text",value:L,onChange:fe=>E(fe.target.value),placeholder:"Host (optional)...",className:oe.fieldInput,"data-testid":"env-create-host"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-port",children:"Port"}),a.jsx("input",{id:"env-create-port",type:"number",min:cd,max:dd,value:M,onChange:fe=>H(fe.target.value),placeholder:"Port (optional)...",className:oe.fieldInput,"data-testid":"env-create-port"})]})]}),C==="ssh"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-host",children:"Host"}),a.jsx("input",{id:"env-create-host",type:"text",value:L,onChange:fe=>E(fe.target.value),placeholder:"Host (required)...",className:oe.fieldInput,"data-testid":"env-create-host"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-user",children:"User"}),a.jsx("input",{id:"env-create-user",type:"text",value:D,onChange:fe=>z(fe.target.value),placeholder:"User (optional)...",className:oe.fieldInput,"data-testid":"env-create-user"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-port",children:"SSH Port"}),a.jsx("input",{id:"env-create-port",type:"number",min:cd,max:dd,value:M,onChange:fe=>H(fe.target.value),placeholder:"SSH port (optional)...",className:oe.fieldInput,"data-testid":"env-create-port"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-identity",children:"Identity File"}),a.jsx("input",{id:"env-create-identity",type:"text",value:Y,onChange:fe=>V(fe.target.value),placeholder:"Identity file (optional)...",className:oe.fieldInput,"data-testid":"env-create-identity"})]})]}),C==="docker"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-image",children:"Image"}),a.jsx("input",{id:"env-create-image",type:"text",value:Q,onChange:fe=>ge(fe.target.value),placeholder:"Image (optional)...",className:oe.fieldInput,"data-testid":"env-create-image"})]}),a.jsxs("div",{className:oe.section,children:[a.jsx("label",{className:oe.label,htmlFor:"env-create-repo",children:"Repo"}),a.jsx("input",{id:"env-create-repo",type:"text",value:X,onChange:fe=>re(fe.target.value),placeholder:"Repo (optional)...",className:oe.fieldInput,"data-testid":"env-create-repo"})]})]}),C==="codespace"&&a.jsx(B8,{codespaceName:B,onCodespaceNameChange:R,envName:w,onEnvNameChange:T,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:_})]})})]})}const $8="_group_1iprv_1",z8="_groupTitle_1iprv_8",H8="_shortcutList_1iprv_17",P8="_shortcutRow_1iprv_23",U8="_keys_1iprv_36",V8="_kbd_1iprv_43",q8="_description_1iprv_60",wi={group:$8,groupTitle:z8,shortcutList:H8,shortcutRow:P8,keys:U8,kbd:V8,description:q8},G8=[{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 F8(){return a.jsxs("section",{className:ue.section,"data-testid":"keyboard-shortcuts-panel",children:[a.jsx("h3",{className:ue.sectionTitle,children:"Keyboard Shortcuts"}),a.jsx("p",{className:ue.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),G8.map(t=>a.jsxs("div",{className:wi.group,children:[a.jsx("h4",{className:wi.groupTitle,children:t.title}),a.jsx("div",{className:wi.shortcutList,children:t.shortcuts.map(s=>a.jsxs("div",{className:wi.shortcutRow,children:[a.jsx("span",{className:wi.keys,children:s.keys.map(o=>a.jsx("kbd",{className:wi.kbd,children:o},o))}),a.jsx("span",{className:wi.description,children:s.description})]},s.description))})]},t.title))]})}const Z8=[{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 K8({credentialProviders:t,onUpdateCredentialProviders:s}){const o=(r,c)=>{const d={...t};r==="claude"?d.claude=c:d[r]=c,s(d)};return a.jsxs("section",{className:ue.section,children:[a.jsx("h3",{className:ue.sectionTitle,children:"Credential Providers"}),a.jsx("p",{className:ue.sectionDescription,children:"Enable providers to automatically forward credentials to environments at task start. Credentials are read fresh from the host each time."}),a.jsx("div",{className:ue.tokenList,children:Z8.map(r=>a.jsxs("div",{className:ue.tokenRow,children:[a.jsx("span",{className:ue.tokenName,children:r.label}),a.jsx("span",{className:ue.tokenTarget,children:r.description}),a.jsx("select",{className:ue.select,value:t[r.key],onChange:c=>o(r.key,c.target.value),children:r.options.map(c=>a.jsx("option",{value:c.value,children:c.label},c.value))})]},r.key))})]})}const Y8="_container_10efq_1",J8="_header_10efq_7",W8="_list_10efq_105",X8="_card_10efq_111",Q8="_cardHeader_10efq_125",e7="_cardTitle_10efq_135",t7="_defaultBadge_10efq_141",n7="_cardActions_10efq_155",s7="_description_10efq_160",a7="_meta_10efq_166",i7="_empty_10efq_212",o7="_typeBadge_10efq_362",ss={container:Y8,header:J8,list:W8,card:X8,cardHeader:Q8,cardTitle:e7,defaultBadge:t7,cardActions:n7,description:s7,meta:a7,empty:i7,typeBadge:o7};function r7({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 a.jsxs("div",{className:ss.container,children:[a.jsxs("div",{className:ss.header,children:[a.jsx("h2",{children:"Personas"}),a.jsx(rn,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?a.jsx("p",{className:ss.empty,children:"No personas yet. Create one to get started."}):a.jsx("div",{className:ss.list,children:t.map(v=>{const _=s===v.id,b=v.type==="script";return a.jsxs("div",{className:ss.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:x=>{x.currentTarget===x.target&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),d(v.id))},children:[a.jsxs("div",{className:ss.cardHeader,children:[a.jsxs("span",{className:ss.cardTitle,children:[a.jsx("strong",{children:v.name}),a.jsx("span",{className:ss.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:b?"Script":"Agent"}),_&&a.jsx("span",{className:ss.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),a.jsxs("div",{className:ss.cardActions,onClick:x=>x.stopPropagation(),children:[!_&&a.jsx(rn,{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"}),a.jsx(rn,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),a.jsx(rn,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&a.jsx("p",{className:ss.description,children:v.description}),a.jsxs("div",{className:ss.meta,children:[v.runtime&&a.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&a.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&a.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),a.jsx(ks,{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 l7="_container_uy08i_1",c7="_header_uy08i_7",d7="_count_uy08i_13",u7="_presets_uy08i_18",f7="_presetButton_uy08i_24",p7="_filterInput_uy08i_41",m7="_groups_uy08i_53",h7="_group_uy08i_53",g7="_groupHeader_uy08i_68",v7="_groupName_uy08i_77",y7="_groupCount_uy08i_81",b7="_toolList_uy08i_87",_7="_toolItem_uy08i_95",x7="_toolName_uy08i_103",_n={container:l7,header:c7,count:d7,presets:u7,presetButton:f7,filterInput:p7,groups:m7,group:h7,groupHeader:g7,groupName:v7,groupCount:y7,toolList:b7,toolItem:_7,toolName:x7},k7=(()=>{const t=new Map;for(const s of E_){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()}))})(),S7=[{name:"default",label:"Default",tools:A_},{name:"worker",label:"Worker",tools:P2},{name:"orchestrator",label:"Orchestrator",tools:U2},{name:"admin",label:"Admin",tools:V2}];function l_({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 _=new Set(d);_.has(v)?_.delete(v):_.add(v),s([..._].sort())},[d,s,o]),p=y.useCallback((v,_)=>{if(o)return;const b=new Set(d);for(const x of v)_?b.delete(x):b.add(x);s([...b].sort())},[d,s,o]),m=y.useCallback(v=>{o||s([...v].sort())},[s,o]),g=r.toLowerCase();return a.jsxs("div",{className:_n.container,"data-testid":"mcp-tool-selector",children:[a.jsx("div",{className:_n.header,children:a.jsx("span",{className:_n.count,children:t.length===0?`Using default (${A_.length} tools)`:`${t.length} of ${E_.size} tools selected`})}),a.jsxs("div",{className:_n.presets,"data-testid":"mcp-tool-presets",children:[S7.map(v=>a.jsx("button",{type:"button",className:_n.presetButton,disabled:o,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),a.jsx("button",{type:"button",className:_n.presetButton,disabled:o,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),a.jsx("input",{type:"text",className:_n.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:o,"data-testid":"mcp-tool-filter"}),a.jsx("div",{className:_n.groups,children:k7.map(({group:v,tools:_})=>{const b=g?_.filter(S=>S.toLowerCase().includes(g)):_;if(b.length===0)return null;const x=b.every(S=>d.has(S));return a.jsxs("div",{className:_n.group,"data-testid":`tool-group-${v}`,children:[a.jsxs("label",{className:_n.groupHeader,children:[a.jsx("input",{type:"checkbox",checked:x,onChange:()=>p(b,x),disabled:o,"data-testid":`group-toggle-${v}`}),a.jsx("span",{className:_n.groupName,children:v}),a.jsxs("span",{className:_n.groupCount,children:["(",b.filter(S=>d.has(S)).length,"/",b.length,")"]})]}),a.jsx("div",{className:_n.toolList,children:b.map(S=>a.jsxs("label",{className:_n.toolItem,children:[a.jsx("input",{type:"checkbox",checked:d.has(S),onChange:()=>u(S),disabled:o,"data-testid":`tool-${S}`}),a.jsx("span",{className:_n.toolName,children:S})]},S))})]},v)})})]})}const j7="_container_1gfuq_1",T7="_header_1gfuq_7",w7="_list_1gfuq_19",N7="_card_1gfuq_25",C7="_cardHeader_1gfuq_40",E7="_cardTitle_1gfuq_46",A7="_statusBadge_1gfuq_56",D7="_enabled_1gfuq_68",R7="_disabled_1gfuq_71",M7="_cardActions_1gfuq_75",I7="_cardMeta_1gfuq_80",O7="_empty_1gfuq_98",as={container:j7,header:T7,list:w7,card:N7,cardHeader:C7,cardTitle:E7,statusBadge:A7,enabled:D7,disabled:R7,cardActions:M7,cardMeta:I7,empty:O7};function L7({schedules:t,personas:s,onDeleteSchedule:o,onToggleEnabled:r,onNavigateToNew:c,onNavigateToSchedule:d}){const[u,p]=y.useState(null),m=u?t.find(b=>b.id===u):void 0,g=async b=>{await o(b),p(null)},v=y.useMemo(()=>{const b=new Map;for(const x of s)b.set(x.id,x.name);return b},[s]),_=b=>v.get(b)??b;return a.jsxs("div",{className:as.container,children:[a.jsxs("div",{className:as.header,children:[a.jsx("h2",{children:"Schedules"}),a.jsx(rn,{variant:"primary",size:"md",onClick:c,"data-testid":"schedule-new-button",children:"+ New Schedule"})]}),t.length===0?a.jsx("p",{className:as.empty,"data-testid":"schedule-empty-state",children:"No schedules yet. Create one to run tasks on a recurring cadence."}):a.jsx("div",{className:as.list,children:t.map(b=>a.jsxs("div",{className:as.card,"data-testid":`schedule-card-${b.id}`,onClick:()=>d(b.id),role:"button",tabIndex:0,onKeyDown:x=>{x.currentTarget===x.target&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),d(b.id))},children:[a.jsxs("div",{className:as.cardHeader,children:[a.jsxs("span",{className:as.cardTitle,children:[a.jsx("strong",{children:b.title}),a.jsx("span",{className:`${as.statusBadge} ${b.enabled?as.enabled:as.disabled}`,"data-testid":`schedule-status-badge-${b.id}`,children:b.enabled?"Enabled":"Disabled"})]}),a.jsxs("div",{className:as.cardActions,onClick:x=>x.stopPropagation(),children:[a.jsx(rn,{variant:"ghost",size:"sm",onClick:()=>{(async()=>{await r(b.id,{enabled:!b.enabled})})().catch(()=>{})},"data-testid":`schedule-toggle-${b.id}`,title:b.enabled?"Disable schedule":"Enable schedule",children:b.enabled?"Disable":"Enable"}),a.jsx(rn,{variant:"ghost",size:"sm",onClick:()=>d(b.id),"data-testid":`schedule-edit-${b.id}`,children:"Edit"}),a.jsx(rn,{variant:"ghost",size:"sm",onClick:()=>p(b.id),"data-testid":`schedule-delete-${b.id}`,children:"Delete"})]})]}),a.jsxs("div",{className:as.cardMeta,children:[a.jsx("span",{"data-testid":`schedule-expression-${b.id}`,children:b.scheduleExpression}),b.personaId&&a.jsxs("span",{"data-testid":`schedule-persona-${b.id}`,children:["Persona: ",_(b.personaId)]}),a.jsxs("span",{"data-testid":`schedule-last-run-${b.id}`,children:["Last run: ",b.lastRunAt?Uo(b.lastRunAt):"Never"]}),b.enabled&&b.nextRunAt?a.jsxs("span",{"data-testid":`schedule-next-run-${b.id}`,children:["Next run: ",q1(b.nextRunAt)]}):null,b.runCount>0&&a.jsxs("span",{"data-testid":`schedule-run-count-${b.id}`,children:["Runs: ",b.runCount]})]})]},b.id))}),a.jsx(ks,{isOpen:u!==null,title:"Delete Schedule?",description:`"${(m==null?void 0:m.title)??""}" will be permanently removed. Tasks already created by this schedule will not be affected.`,confirmLabel:"Delete",onConfirm:()=>{u&&g(u).catch(()=>{})},onCancel:()=>p(null)})]})}const B7="_nav_1bhou_1",$7="_tab_1bhou_24",z7="_tabIcon_1bhou_62",H7="_tabActive_1bhou_68",Jc={nav:B7,tab:$7,tabIcon:z7,tabActive:H7},ia=[{path:"credentials",label:"Credentials",icon:a.jsx(nT,{size:Et})},{path:"github-accounts",label:"GitHub Accounts",icon:a.jsx(Wj,{size:Et})},{path:"personas",label:"Personas",icon:a.jsx(BT,{size:Et})},{path:"schedules",label:"Schedules",icon:a.jsx(Aj,{size:Et})},{path:"appearance",label:"Appearance",icon:a.jsx(vT,{size:Et})},{path:"shortcuts",label:"Shortcuts",icon:a.jsx(aT,{size:Et})},{path:"plugins",label:"Plugins",icon:a.jsx(ST,{size:Et})},{path:"about",label:"About",icon:a.jsx(Tm,{size:Et})}];function P7(){var u;const t=Wt(),s=dt(),o=y.useRef(null),r=((u=ia.find(p=>{const m=`${Ai}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??ia[0].path,c=y.useCallback(p=>{s(`${Ai}/${p}`)},[s]),d=y.useCallback(p=>{var x,S;const m=(x=o.current)==null?void 0:x.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(j=>j===document.activeElement),v=g>=0?g:ia.findIndex(j=>j.path===r);let _=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),_=(v+1)%ia.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),_=(v-1+ia.length)%ia.length;else if(p.key==="Home")p.preventDefault(),_=0;else if(p.key==="End")p.preventDefault(),_=ia.length-1;else return;const b=ia[_].path;s(`${Ai}/${b}`),(S=m[_])==null||S.focus()},[r,s]);return a.jsx("nav",{className:Jc.nav,ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:ia.map(p=>{const m=p.path===r;return a.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Jc.tab} ${m?Jc.tabActive:""}`,onClick:()=>c(p.path),children:[a.jsx("span",{className:Jc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}const U7="_container_1dqrb_1",V7="_header_1dqrb_5",q7="_refreshButton_1dqrb_17",G7="_streamRow_1dqrb_32",F7="_selected_1dqrb_49",Z7="_systemRow_1dqrb_53 _streamRow_1dqrb_32",K7="_streamIcon_1dqrb_60",Y7="_streamName_1dqrb_65",J7="_subscriberBadge_1dqrb_74",W7="_emptyState_1dqrb_88",X7="_loading_1dqrb_95",xn={container:U7,header:V7,refreshButton:q7,streamRow:G7,selected:F7,systemRow:Z7,streamIcon:K7,streamName:Y7,subscriberBadge:J7,emptyState:W7,loading:X7},c_=14;function Q7({streams:t,loading:s,streamsLoadError:o=!1,streamsLoadedOnce:r=!0,onRefresh:c}){const d=dt(),u=Wt(),p=Dt("/chat/:streamId"),m=p==null?void 0:p.params.streamId,g=!m&&u.pathname===cl,v=[...t].sort((x,S)=>x.name.localeCompare(S.name)),_=y.useCallback(()=>{d(cl)},[d]),b=y.useCallback(x=>{d(qN(x))},[d]);return a.jsxs("div",{className:xn.container,"data-testid":"stream-list",children:[a.jsxs("div",{className:xn.header,children:[a.jsx("span",{children:"Streams"}),c&&a.jsx("button",{className:xn.refreshButton,onClick:c,"aria-label":"Refresh streams","data-testid":"stream-list-refresh",children:a.jsx(NT,{size:12})})]}),a.jsxs("button",{type:"button",className:`${xn.systemRow}${g?` ${xn.selected}`:""}`,onClick:_,"data-testid":"stream-list-system-row","aria-current":g?"page":void 0,children:[a.jsx(L_,{size:c_,className:xn.streamIcon}),a.jsx("span",{className:xn.streamName,children:"System"})]}),s&&v.length===0&&a.jsx("div",{className:xn.loading,children:"Loading..."}),!s&&o&&a.jsx("div",{className:xn.emptyState,"data-testid":"stream-list-error",children:"Unable to load streams"}),!s&&!o&&r&&v.length===0&&a.jsx("div",{className:xn.emptyState,children:"No streams"}),v.map(x=>{const S=m===x.id;return a.jsxs("button",{type:"button",className:`${xn.streamRow}${S?` ${xn.selected}`:""}`,onClick:()=>b(x.id),"data-testid":`stream-list-row-${x.id}`,"aria-current":S?"page":void 0,children:[a.jsx(TT,{size:c_,className:xn.streamIcon}),a.jsx("span",{className:xn.streamName,children:x.name}),x.subscriberCount>0&&a.jsx("span",{className:xn.subscriberBadge,children:x.subscriberCount})]},x.id)})]})}const e$="_panel_1au81_1",t$="_header_1au81_24",n$="_title_1au81_33",s$="_closeButton_1au81_43",a$="_body_1au81_57",i$="_section_1au81_63",o$="_sectionLabel_1au81_67",r$="_metaRow_1au81_76",l$="_metaKey_1au81_84",c$="_metaValue_1au81_90",d$="_subscriberCard_1au81_99",u$="_subscriberHeader_1au81_107",f$="_sessionLink_1au81_114",p$="_badges_1au81_132",m$="_badgeRw_1au81_150 _badge_1au81_132",h$="_badgeR_1au81_150 _badge_1au81_132",g$="_badgeW_1au81_162 _badge_1au81_132",v$="_badgeAsync_1au81_168 _badge_1au81_132",y$="_badgeSync_1au81_174 _badge_1au81_132",b$="_badgeDetach_1au81_178 _badge_1au81_132",_$="_spawnTag_1au81_184 _badge_1au81_132",x$="_fdNumber_1au81_189",k$="_emptySubscribers_1au81_195",lt={panel:e$,header:t$,title:n$,closeButton:s$,body:a$,section:i$,sectionLabel:o$,metaRow:r$,metaKey:l$,metaValue:c$,subscriberCard:d$,subscriberHeader:u$,sessionLink:f$,badges:p$,badgeRw:m$,badgeR:h$,badgeW:g$,badgeAsync:v$,badgeSync:y$,badgeDetach:b$,spawnTag:_$,fdNumber:x$,emptySubscribers:k$};function S$({permission:t}){const s=t==="rw"?lt.badgeRw:t==="r"?lt.badgeR:lt.badgeW;return a.jsx("span",{className:s,children:t})}function j$({mode:t}){const s=t==="async"?lt.badgeAsync:t==="detach"?lt.badgeDetach:lt.badgeSync;return a.jsx("span",{className:s,children:t})}function T$({stream:t,onClose:s}){const o=dt();return y.useEffect(()=>{const r=c=>{c.key==="Escape"&&s()};return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[s]),a.jsxs("div",{className:lt.panel,"data-testid":"stream-detail-panel",children:[a.jsxs("div",{className:lt.header,children:[a.jsx("h3",{className:lt.title,children:t.name}),a.jsx("button",{className:lt.closeButton,onClick:s,"aria-label":"Close stream details",children:"×"})]}),a.jsxs("div",{className:lt.body,children:[a.jsxs("div",{className:lt.section,children:[a.jsx("div",{className:lt.sectionLabel,children:"Overview"}),a.jsxs("div",{className:lt.metaRow,children:[a.jsx("span",{className:lt.metaKey,children:"Stream ID"}),a.jsx("span",{className:lt.metaValue,children:t.id})]}),a.jsxs("div",{className:lt.metaRow,children:[a.jsx("span",{className:lt.metaKey,children:"Subscribers"}),a.jsx("span",{className:lt.metaValue,children:t.subscriberCount})]}),a.jsxs("div",{className:lt.metaRow,children:[a.jsx("span",{className:lt.metaKey,children:"Buffered"}),a.jsxs("span",{className:lt.metaValue,children:[t.messageBufferDepth," msgs"]})]})]}),a.jsxs("div",{className:lt.section,children:[a.jsx("div",{className:lt.sectionLabel,children:"Subscribers"}),t.subscribers.length===0?a.jsx("div",{className:lt.emptySubscribers,children:"No active subscribers"}):t.subscribers.map(r=>a.jsxs("div",{className:lt.subscriberCard,"data-testid":`subscriber-card-${r.subscriptionId}`,children:[a.jsxs("div",{className:lt.subscriberHeader,children:[a.jsxs("span",{className:lt.fdNumber,children:["fd ",r.fd]}),a.jsxs("button",{className:lt.sessionLink,onClick:()=>{o(Bd(r.sessionId))},title:r.sessionId,children:[r.sessionId.slice(0,12),"…"]})]}),a.jsxs("div",{className:lt.badges,children:[a.jsx(S$,{permission:r.permission}),a.jsx(j$,{mode:r.deliveryMode}),r.createdBySpawn&&a.jsx("span",{className:lt.spawnTag,children:"spawn"})]})]},r.subscriptionId))]})]})]})}function w$({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(Ty.map(d=>[d,[]]));for(const d of t){const u=gl(d.status),p=d.dependsOn.length>0&&d.dependsOn.some(S=>s.get(S)!=="complete"),m=r.get(d.id)??[],g=m.length,v=m.filter(S=>S.status==="complete").length;let _;if(u==="paused"&&o){const S=o.get(d.id);S==="idle"?_="Needs input":S==="completed"&&(_="Ready to complete")}const b={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:_},x=c.get(u);x?x.push(b):c.get("not_started").push(b)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return Ty.map(d=>{const u=Wa(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const N$="_boardContainer_1c4y1_1",C$="_column_1c4y1_17",E$="_columnHeader_1c4y1_34",A$="_columnIcon_1c4y1_47",D$="_columnLabel_1c4y1_52",R$="_columnCount_1c4y1_57",M$="_cardList_1c4y1_67",I$="_emptyPlaceholder_1c4y1_76",O$="_card_1c4y1_67",L$="_cardHeader_1c4y1_107",B$="_cardStatusIcon_1c4y1_113",$$="_cardTitle_1c4y1_119",z$="_cardBadges_1c4y1_127",H$="_badge_1c4y1_134",P$="_blockedBadge_1c4y1_146",U$="_childBadge_1c4y1_151",V$="_depBadge_1c4y1_155",q$="_parentBadge_1c4y1_159",G$="_pausedSubBadge_1c4y1_166",F$="_personaBadge_1c4y1_170",Z$="_envBadge_1c4y1_174",K$="_emptyCta_1c4y1_178",Y$="_ctaButton_1c4y1_188",J$="_ctaDescription_1c4y1_204",ct={boardContainer:N$,column:C$,columnHeader:E$,columnIcon:A$,columnLabel:D$,columnCount:R$,cardList:M$,emptyPlaceholder:I$,card:O$,cardHeader:L$,cardStatusIcon:B$,cardTitle:$$,cardBadges:z$,badge:H$,blockedBadge:P$,childBadge:U$,depBadge:V$,parentBadge:q$,pausedSubBadge:G$,personaBadge:F$,envBadge:Z$,emptyCta:K$,ctaButton:Y$,ctaDescription:J$};function W$({workspaceId:t,environmentId:s,tasks:o,sessions:r,personas:c,environments:d}){const u=dt(),p=y.useMemo(()=>o.filter(b=>b.workspaceId===t),[o,t]),m=y.useMemo(()=>new Map(o.map(b=>[b.id,b.status])),[o]),g=y.useMemo(()=>new Map(p.map(b=>[b.id,b])),[p]),v=y.useMemo(()=>{const b=new Map(r.map(C=>[C.id,C])),x=new Map(c.map(C=>[C.id,C])),S=new Map(d.map(C=>[C.id,C])),j=new Map,w=new Map,T=new Map;for(const C of p)if(C.latestSessionId){const A=b.get(C.latestSessionId);if(A){if(j.set(C.id,A.endReason||A.status),A.personaId){const L=x.get(A.personaId);L&&w.set(C.id,L.name)}if(A.environmentId){const L=S.get(A.environmentId);L&&T.set(C.id,L.displayName)}}}return{sessionStatusByTaskId:j,personaNameByTaskId:w,environmentNameByTaskId:T}},[p,r,c,d]),_=y.useMemo(()=>w$({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?a.jsxs("div",{className:ct.emptyCta,"data-testid":"board-empty-cta",children:[a.jsx("button",{className:ct.ctaButton,onClick:()=>u($i(t,void 0,s)),children:"Create Task"}),a.jsx("div",{className:ct.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):a.jsx("div",{className:ct.boardContainer,"data-testid":"board-container",children:_.map(b=>a.jsxs("section",{className:ct.column,"data-testid":`board-column-${b.status}`,"aria-label":`${b.label}, ${b.tasks.length} ${b.tasks.length===1?"task":"tasks"}`,children:[a.jsxs("div",{className:ct.columnHeader,children:[a.jsx("span",{className:ct.columnIcon,style:{color:b.style.color},children:b.style.icon}),a.jsx("span",{className:ct.columnLabel,children:b.label}),a.jsx("span",{className:ct.columnCount,"data-testid":`board-count-${b.status}`,children:b.tasks.length})]}),a.jsx("div",{className:ct.cardList,children:b.tasks.length===0?a.jsx("div",{className:ct.emptyPlaceholder,children:"No tasks"}):a.jsx(ls,{mode:"popLayout",children:b.tasks.map(x=>a.jsx(At.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:a.jsx(X$,{boardTask:x,tasksById:g,personaName:v.personaNameByTaskId.get(x.task.id),envName:v.environmentNameByTaskId.get(x.task.id),onClick:()=>u(Hn(x.task.id,void 0,t,s))})},x.task.id))})})]},b.status))})}function X$({boardTask:t,tasksById:s,personaName:o,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=Wa(d.status),_=d.parentTaskId?s.get(d.parentTaskId):void 0;return a.jsxs("div",{className:ct.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c())},children:[a.jsxs("div",{className:ct.cardHeader,children:[a.jsx("span",{className:ct.cardStatusIcon,style:{color:v.color},children:v.icon}),a.jsx("span",{className:ct.cardTitle,children:d.title})]}),a.jsxs("div",{className:ct.cardBadges,children:[_&&a.jsx("span",{className:`${ct.badge} ${ct.parentBadge}`,title:_.title,children:_.title}),p>0&&a.jsxs("span",{className:`${ct.badge} ${ct.childBadge}`,children:[m,"/",p]}),u&&a.jsx("span",{className:`${ct.badge} ${ct.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&a.jsx("span",{className:`${ct.badge} ${ct.depBadge}`,children:"dep"}),g&&a.jsx("span",{className:`${ct.badge} ${ct.pausedSubBadge}`,children:g}),o&&a.jsx("span",{className:`${ct.badge} ${ct.personaBadge}`,children:o}),r&&a.jsx("span",{className:`${ct.badge} ${ct.envBadge}`,children:r})]})]})}const Q$="_formContent_ymnez_1",ez="_section_ymnez_13",tz="_label_ymnez_19",nz="_titleInput_ymnez_26",sz="_descriptionTextarea_ymnez_58",az="_selectField_ymnez_94",iz="_checkboxRow_ymnez_128",oz="_checkboxLabel_ymnez_141",rz="_fieldError_ymnez_146",kt={formContent:Q$,section:ez,label:tz,titleInput:nz,descriptionTextarea:sz,selectField:az,checkboxRow:iz,checkboxLabel:oz,fieldError:rz};function lz(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.linkedEnvironmentIds[0])??s??"",defaultPersonaId:(t==null?void 0:t.defaultPersonaId)??"",useWorktrees:(t==null?void 0:t.useWorktrees)??!0,workingDirectory:(t==null?void 0:t.workingDirectory)??""}}const cz=100;function dz({values:t,onChange:s,environments:o,personas:r,errors:c,disabled:d,autoFocusName:u}){const p=(m,g)=>{s({...t,[m]:g})};return a.jsxs("div",{className:kt.formContent,children:[a.jsxs("div",{className:kt.section,children:[a.jsx("label",{className:kt.label,htmlFor:"ws-name",children:"Name"}),a.jsx("input",{id:"ws-name",className:kt.titleInput,type:"text",value:t.name,onChange:m=>p("name",m.target.value),placeholder:"Workspace name",maxLength:cz,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&a.jsx("span",{className:kt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),a.jsxs("div",{className:kt.section,children:[a.jsx("label",{className:kt.label,htmlFor:"ws-description",children:"Description"}),a.jsx("textarea",{id:"ws-description",className:kt.descriptionTextarea,value:t.description,onChange:m=>p("description",m.target.value),placeholder:"Optional description (Markdown supported)",disabled:d,"data-testid":"workspace-form-description"})]}),a.jsxs("div",{className:kt.section,children:[a.jsx("label",{className:kt.label,htmlFor:"ws-repo",children:"Repository URL"}),a.jsx("input",{id:"ws-repo",className:kt.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)&&a.jsx("span",{className:kt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),a.jsxs("div",{className:kt.section,children:[a.jsx("label",{className:kt.label,htmlFor:"ws-environment",children:"Environment"}),a.jsxs("select",{id:"ws-environment",className:kt.selectField,value:t.environmentId,onChange:m=>p("environmentId",m.target.value),disabled:d,"data-testid":"workspace-form-environment",children:[a.jsx("option",{value:"",children:"Select environment…"}),o.map(m=>a.jsx("option",{value:m.id,children:m.displayName||m.id},m.id))]}),(c==null?void 0:c.environmentId)&&a.jsx("span",{className:kt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),a.jsxs("div",{className:kt.section,children:[a.jsx("label",{className:kt.label,htmlFor:"ws-persona",children:"Default Persona"}),a.jsxs("select",{id:"ws-persona",className:kt.selectField,value:t.defaultPersonaId,onChange:m=>p("defaultPersonaId",m.target.value),disabled:d,"data-testid":"workspace-form-persona",children:[a.jsx("option",{value:"",children:"(Inherit)"}),r.map(m=>a.jsx("option",{value:m.id,children:m.name},m.id))]})]}),a.jsx("div",{className:kt.section,children:a.jsxs("label",{className:kt.checkboxRow,children:[a.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:m=>p("useWorktrees",m.target.checked),disabled:d,"data-testid":"workspace-form-worktrees"}),a.jsx("span",{className:kt.checkboxLabel,children:"Enable worktree isolation"})]})}),a.jsxs("div",{className:kt.section,children:[a.jsx("label",{className:kt.label,htmlFor:"ws-workdir",children:"Working Directory"}),a.jsx("input",{id:"ws-workdir",className:kt.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 Q1=y.createContext(void 0),uz=4e3;function fz({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=uz)=>{const g=`toast-${++r.current}`;o(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return a.jsx(Q1.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function hn(){const t=y.useContext(Q1);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const _m="grackle-theme",ek="grackle-prefer-system",tk="(prefers-color-scheme: dark)";let Xr=[],ud;function zp(){ud=void 0;for(const t of Xr)t()}function xm(){return typeof window>"u"?!1:window.matchMedia(tk).matches}function il(){if(typeof localStorage>"u")return o_;try{const t=localStorage.getItem(_m);if(t!==null&&J1.has(t))return t}catch{}return o_}function wd(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(ek)==="true"}catch{return!1}}function km(t){return Gd.find(s=>s.variantLightId===t||s.variantDarkId===t)}function nk(t,s){const o=bm(t);if(o!=null&&o.variantDarkId)return s&&o.variantLightId?xm()?o.variantDarkId:o.variantLightId:o.variantDarkId;if(o!=null&&o.hidden&&s){const r=km(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return xm()?r.variantDarkId:r.variantLightId}return t}function Do(t,s,o=!1){o&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=nk(t,s),o&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&Do(il(),wd());function pz(){return ud===void 0&&(ud={themeId:il(),systemDark:xm(),preferSystem:wd()}),ud}function mz(t){return Xr=[...Xr,t],()=>{Xr=Xr.filter(s=>s!==t)}}function hz(){const t=y.useSyncExternalStore(mz,pz),{themeId:s,preferSystem:o}=t,r=nk(s,o),c=y.useCallback(u=>{if(J1.has(u)){try{localStorage.setItem(_m,u)}catch{}Do(u,wd(),!0),zp()}},[]),d=y.useCallback(u=>{try{localStorage.setItem(ek,u?"true":"false")}catch{}if(u){const p=il(),m=bm(p);if(m!=null&&m.hidden){const g=km(p);if(g)try{localStorage.setItem(_m,g.id)}catch{}}}Do(il(),u,!0),zp()},[]);return y.useEffect(()=>{Do(s,o)},[s,o]),y.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(tk),p=()=>{const m=il(),g=wd();if(g){const v=bm(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&Do(m,g),v!=null&&v.hidden){const _=km(m);_!=null&&_.variantDarkId&&_.variantLightId&&Do(m,g)}}zp()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:o,setPreferSystem:d}}const sk=y.createContext(void 0);function gz({children:t}){const s=hz();return a.jsx(sk.Provider,{value:s,children:t})}function ak(){const t=y.useContext(sk);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const ik=y.createContext(void 0),ok=y.createContext(void 0);function vz({children:t}){const[s,o]=y.useState(void 0),r=y.useCallback(c=>{o(c)},[]);return a.jsx(ok.Provider,{value:r,children:a.jsx(ik.Provider,{value:s,children:t})})}function yz(){return y.useContext(ik)}function bz(){const t=y.useContext(ok);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const vh=y.createContext(void 0);function ot(){const t=y.useContext(vh);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function rk(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function lk(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function _z(t){return rk(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 xz=new Set(["off","subscription","api_key"]),Wc=new Set(["off","on"]);function kz(t){return rk(t)&&xz.has(t.claude)&&Wc.has(t.github)&&Wc.has(t.copilot)&&Wc.has(t.codex)&&Wc.has(t.goose)}function ck(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 dk(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 Ao=5e3;function Sz(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 pa={label:"Home",url:Ii};function jz(t){return t?[pa,{label:"Settings",url:Ai},{label:t,url:void 0}]:[pa,{label:"Settings",url:void 0}]}const yh={label:"Environments",url:Bo};function Tz(){return[pa,{label:"Environments",url:void 0}]}function wz(){return[pa,{label:"New Chat",url:void 0}]}function Nz(t){return[pa,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function Cz(t,s,o,r){const c=o.find(u=>u.id===t),d=r.find(u=>u.id===s);return[pa,yh,{label:(d==null?void 0:d.displayName)??"Environment",url:Mi(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function Ez(t,s,o,r,c){const d=Sz(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?o.find(x=>x.id===p):void 0,g=s??(m==null?void 0:m.linkedEnvironmentIds[0]),v=g?r.find(x=>x.id===g):void 0,_=[pa];v&&g&&(_.push(yh),_.push({label:v.displayName,url:Mi(g)})),m&&g&&_.push({label:m.name,url:Ri(m.id,g)});for(let x=0;x<d.length-1;x++)_.push({label:d[x].title,url:Hn(d[x].id,void 0,p,g)});const b=d[d.length-1];return _.push({label:(b==null?void 0:b.title)??t,url:void 0}),_}const Az={label:"Findings",url:$d};function Dz(){return[pa,{label:"Findings",url:void 0}]}function uk(t,s,o,r,c){const d=[pa];if(s&&o){const u=r.find(m=>m.id===s),p=c.find(m=>m.id===o);d.push(yh),p&&d.push({label:p.displayName,url:Mi(o)}),u&&d.push({label:u.name,url:Ri(s,o)}),d.push({label:"Findings",url:FN(s,o)})}else d.push(Az);return d.push({label:t,url:void 0}),d}function bh(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 Xc(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 Rz(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 _h(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 _=s.get(v),b=_?Xc(_):void 0;if(b)try{const x=JSON.parse(v.content);o.set(b,{tool:x.tool,args:x.args})}catch{}}const r=new Set,c=new Set,d=t.map((v,_)=>{if(v.eventType!=="tool_result")return v;const b=s.get(v),x=b?Rz(b):void 0;if(!x)return v;const S=o.get(x);if(!S)return v;r.add(x),c.add(_);let j;const w=v.content.trim();if(w.startsWith("{"))try{const T=JSON.parse(w);typeof T.detailedContent=="string"&&(j=T.detailedContent)}catch{}return{...v,toolUseCtx:{...S,detailedResult:j}}}),u=[];for(let v=0;v<d.length;v++){if(d[v].eventType!=="tool_use")continue;const _=s.get(d[v]),b=_?Xc(_):void 0;b&&r.has(b)||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 _=p[m];if(_!==v+1)continue;const b=d[v],x=d[_];let S;try{const j=JSON.parse(b.content);S={tool:j.tool,args:j.args}}catch{}if(S){let j;const w=x.content.trim();if(w.startsWith("{"))try{const A=JSON.parse(w);typeof A.detailedContent=="string"&&(j=A.detailedContent)}catch{}d[_]={...x,toolUseCtx:{...S,detailedResult:j}},c.add(_);const T=s.get(b),C=T?Xc(T):void 0;C?r.add(C):(r.add(`__seq_${v}`),s.set(b,{...T??{},__seqId:`__seq_${v}`})),m++}}const g=d.filter(v=>{if(v.eventType!=="tool_use")return!0;const _=s.get(v);if(!_)return!0;const b=Xc(_);if(b&&r.has(b))return!1;const x=_.__seqId;return!(x&&r.has(x))});for(let v=0;v<g.length;v++){if(g[v].eventType!=="tool_use")continue;let _=!1;for(let b=v+1;b<g.length;b++)if(g[b].eventType!=="tool_use"){_=!0;break}_&&(g[v]={...g[v],settled:!0})}return g}function Mz(t,s,o){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=fk(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 fk(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 Iz(t,s){var u;const o=new Map;for(const p of s)o.set(p.id,p);const r=fk(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 Oz(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 Lz(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 Rs=[{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
|
|
314
314
|
export function verifyToken(req: Request, res: Response, next: NextFunction): void {
|
|
315
315
|
const header = req.headers.authorization;
|
|
316
316
|
if (!header?.startsWith("Bearer ")) {
|
|
@@ -751,4 +751,4 @@ const grackle = await host.mcpServer({
|
|
|
751
751
|
url: env.vars.GRACKLE_MCP_URL,
|
|
752
752
|
});
|
|
753
753
|
|
|
754
|
-
$\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),M==="agent"&&a.jsxs("div",{children:[a.jsx("label",{children:"Allowed MCP Tools"}),a.jsx(l_,{selectedTools:Y,onChange:ie=>{V(ie),Se(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,ie),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!xe&&!de&&a.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,a.jsx(ks,{isOpen:Q,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:Xe,onCancel:()=>ge(!1)})]})}function QU(){const{schedules:{schedules:t,deleteSchedule:s,updateSchedule:o},personas:{personas:r}}=ot(),{showToast:c}=hn(),d=dt();return a.jsx(L7,{schedules:t,personas:r,onDeleteSchedule:async u=>{try{await s(u)}catch(p){throw console.error("Failed to delete schedule",{scheduleId:u,error:p}),c("Failed to delete schedule","error"),p}},onToggleEnabled:async(u,p)=>{try{return await o(u,p)}catch(m){throw console.error("Failed to update schedule",{scheduleId:u,error:m}),c("Failed to update schedule","error"),m}},onNavigateToNew:()=>d(PN),onNavigateToSchedule:u=>d(sx(u))})}const eV="_container_1g4qh_1",tV="_form_1g4qh_7",nV="_formActions_1g4qh_66",sV="_editableSection_1g4qh_73",aV="_helperText_1g4qh_84",iV="_metaSection_1g4qh_90",oV="_optional_1g4qh_108",rV="_readonlyValue_1g4qh_113",Bn={container:eV,form:tV,formActions:nV,editableSection:sV,helperText:aV,metaSection:iV,optional:oV,readonlyValue:rV};function j_(){const{scheduleId:t}=Vn(),s=dt(),{showToast:o}=hn(),{schedules:{schedules:r,schedulesLoading:c,createSchedule:d,updateSchedule:u,deleteSchedule:p},personas:{personas:m},workspaces:{workspaces:g}}=ot(),v=t===void 0,_=v?void 0:r.find(x=>x.id===t);if(!v&&!c&&r.length>0&&!_)return a.jsx(rs,{to:lp,replace:!0});const b=[{label:"Settings",url:Ai},{label:"Schedules",url:lp},{label:v?"New Schedule":(_==null?void 0:_.title)??"Schedule",url:void 0}];return a.jsxs("div",{className:Bn.container,children:[a.jsx(Ss,{segments:b}),a.jsx(lV,{existing:_,isNew:v,personas:m,workspaces:g,onCreateSchedule:d,onUpdateSchedule:u,onDeleteSchedule:p,onDone:()=>{s(lp)},showToast:o})]})}function lV({existing:t,isNew:s,personas:o,workspaces:r,onCreateSchedule:c,onUpdateSchedule:d,onDeleteSchedule:u,onDone:p,showToast:m}){var B;const g=dt(),[v,_]=y.useState((t==null?void 0:t.title)??""),[b,x]=y.useState((t==null?void 0:t.description)??""),[S,j]=y.useState((t==null?void 0:t.scheduleExpression)??""),[w,T]=y.useState((t==null?void 0:t.personaId)??""),[C,A]=y.useState((t==null?void 0:t.workspaceId)??""),[L,E]=y.useState(!1),[M,H]=y.useState(null);y.useEffect(()=>{s||t&&M===null&&(_(t.title),x(t.description),j(t.scheduleExpression),T(t.personaId),A(t.workspaceId))},[s,t,M]);const D=!s&&t===void 0,z=s&&v.trim().length>0&&S.trim().length>0&&w.length>0,Y=o.map(R=>({value:R.id,label:R.name})),V=[{value:"",label:"System-level (no workspace)"},...r.map(R=>({value:R.id,label:R.name}))],Q=R=>{R.preventDefault(),z&&c(v,b,S,w,C||void 0).then(Z=>{m("Schedule created","success"),g(sx(Z.id),{replace:!0})},()=>{m("Failed to create schedule","error")})},ge=(R,Z)=>{t&&d(t.id,{[R]:Z}).then(()=>{m("Schedule updated","success"),R==="title"&&_(String(Z)),R==="description"&&x(String(Z)),R==="scheduleExpression"&&j(String(Z)),R==="personaId"&&T(String(Z))},()=>{m("Failed to update schedule","error")})},X=()=>{if(!t)return;const R=!t.enabled;d(t.id,{enabled:R}).then(()=>{m(R?"Schedule enabled":"Schedule disabled","success")},()=>{m("Failed to update schedule","error")})},re=()=>{t&&u(t.id).then(()=>{m("Schedule deleted","success"),p()},()=>{m("Failed to delete schedule","error")})};return a.jsxs(a.Fragment,{children:[D?a.jsxs("div",{className:Bn.form,children:[a.jsx("h3",{children:"Edit Schedule"}),a.jsx("p",{children:"Loading schedule..."})]}):s?a.jsxs("form",{onSubmit:Q,className:Bn.form,children:[a.jsx("h3",{children:"Create Schedule"}),a.jsxs("label",{children:["Title",a.jsx("input",{type:"text",value:v,onChange:R=>_(R.target.value),placeholder:"e.g. Nightly Review",required:!0,"data-testid":"schedule-detail-title"})]}),a.jsxs("label",{children:["Description ",a.jsx("span",{className:Bn.optional,children:"(optional)"}),a.jsx("input",{type:"text",value:b,onChange:R=>x(R.target.value),placeholder:"Brief description...","data-testid":"schedule-detail-description"})]}),a.jsxs("label",{children:["Schedule Expression",a.jsx("input",{type:"text",value:S,onChange:R=>j(R.target.value),placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",required:!0,"data-testid":"schedule-detail-expression"}),a.jsxs("p",{className:Bn.helperText,children:["Interval: ",a.jsx("code",{children:"30s"}),", ",a.jsx("code",{children:"5m"}),", ",a.jsx("code",{children:"1h"}),", ",a.jsx("code",{children:"1d"})," (min 10s) | Cron: ",a.jsx("code",{children:"0 9 * * MON"})," (standard 5-field cron syntax)"]})]}),a.jsxs("label",{children:["Persona",a.jsxs("select",{value:w,onChange:R=>T(R.target.value),required:!0,"data-testid":"schedule-detail-persona",children:[a.jsx("option",{value:"",children:"Select a persona..."}),Y.map(R=>a.jsx("option",{value:R.value,children:R.label},R.value))]})]}),a.jsxs("label",{children:["Workspace ",a.jsx("span",{className:Bn.optional,children:"(optional)"}),a.jsx("select",{value:C,onChange:R=>A(R.target.value),"data-testid":"schedule-detail-workspace",children:V.map(R=>a.jsx("option",{value:R.value,children:R.label},R.value))})]}),a.jsxs("div",{className:Bn.formActions,children:[a.jsx(rn,{type:"submit",variant:"primary",size:"md",disabled:!z,"data-testid":"schedule-detail-save",children:"Create"}),a.jsx(rn,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Cancel"})]})]}):t?a.jsxs("div",{className:Bn.form,children:[a.jsx("h3",{children:"Edit Schedule"}),a.jsxs("div",{className:Bn.formActions,children:[a.jsx(rn,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Back to Schedules"}),a.jsx(rn,{type:"button",variant:t.enabled?"ghost":"primary",size:"md",onClick:X,"data-testid":"schedule-detail-toggle",children:t.enabled?"Disable":"Enable"}),a.jsx(rn,{type:"button",variant:"danger",size:"md",onClick:()=>E(!0),"data-testid":"schedule-detail-delete",children:"Delete"})]}),a.jsxs("div",{className:Bn.editableSection,children:[a.jsxs("label",{children:["Title",a.jsx(Yt,{value:v,onSave:R=>{ge("title",R)},validate:R=>R.trim()?void 0:"Title is required",fieldId:"schedule-title",activeFieldId:M,onActivate:H,ariaLabel:"Schedule title","data-testid":"schedule-detail-title"})]}),a.jsxs("label",{children:["Description",a.jsx(Yt,{value:b,onSave:R=>{ge("description",R)},fieldId:"schedule-description",activeFieldId:M,onActivate:H,placeholder:"Brief description...",ariaLabel:"Schedule description","data-testid":"schedule-detail-description"})]}),a.jsxs("label",{children:["Schedule Expression",a.jsx(Yt,{value:S,onSave:R=>{ge("scheduleExpression",R)},validate:R=>R.trim()?void 0:"Schedule expression is required",fieldId:"schedule-expression",activeFieldId:M,onActivate:H,placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",ariaLabel:"Schedule expression","data-testid":"schedule-detail-expression"})]}),a.jsxs("label",{children:["Persona",a.jsx(jd,{value:w,onSave:R=>{ge("personaId",R)},options:Y,fieldId:"schedule-persona",activeFieldId:M,onActivate:H,ariaLabel:"Schedule persona","data-testid":"schedule-detail-persona"})]}),a.jsxs("label",{children:["Workspace ",a.jsx("span",{className:Bn.optional,children:"(optional — set at creation)"}),a.jsx("span",{className:Bn.readonlyValue,"data-testid":"schedule-detail-workspace",children:((B=r.find(R=>R.id===t.workspaceId))==null?void 0:B.name)??"System-level (no workspace)"})]})]}),a.jsxs("div",{className:Bn.metaSection,children:[t.lastRunAt?a.jsxs("span",{children:["Last run: ",Uo(t.lastRunAt)]}):a.jsx("span",{children:"Last run: Never"}),t.enabled&&t.nextRunAt?a.jsxs("span",{children:["Next run: ",q1(t.nextRunAt)]}):null,t.runCount>0&&a.jsxs("span",{children:["Total runs: ",t.runCount]}),a.jsxs("span",{children:["Created: ",Uo(t.createdAt)]})]})]}):null,a.jsx(ks,{isOpen:L,title:"Delete Schedule?",description:`"${t==null?void 0:t.title}" will be permanently removed. Tasks already created by this schedule will not be affected.`,confirmLabel:"Delete",onConfirm:re,onCancel:()=>E(!1)})]})}function cV(){const{themeId:t,resolvedThemeId:s,setTheme:o,preferSystem:r,setPreferSystem:c}=ak();return a.jsx(QL,{themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c})}function dV(){const[t,s]=y.useState(void 0);return y.useEffect(()=>{let o=!1;return(async()=>{try{const c=await Be.getVersionStatus({});o||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{o=!0}},[]),t}function uV(){const{connectionStatus:t,environments:{environments:s},sessions:{sessions:o}}=ot(),r=dV();return a.jsxs(a.Fragment,{children:[r&&a.jsx(QO,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),a.jsx(nB,{connectionStatus:t,environments:s,sessions:o})]})}function fV(){return a.jsx(F8,{})}function pV(){const{plugins:{plugins:t,pluginsLoading:s,setPluginEnabled:o}}=ot();return a.jsx(g8,{plugins:t,loading:s,onSetPluginEnabled:(r,c)=>{o(r,c).catch(()=>{})}})}const T_=$i();function mV(){const t=dt();return ca({key:"?"},()=>{t(UN)}),ca({key:"n"},()=>{t(T_)}),ca({key:"N"},()=>{t(T_)}),a.jsx(a.Fragment,{})}function Ko(t){const s=bz();y.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function hV(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=ot(),o=y.useMemo(()=>a.jsx(EO,{workspaces:t,tasks:s}),[t,s]);return Ko(o),a.jsx(ha,{})}function gV(){const{environments:{environments:t}}=ot(),s=y.useMemo(()=>a.jsx(zI,{environments:t}),[t]);return Ko(s),a.jsx(ha,{})}function vV(){const t=y.useMemo(()=>a.jsx(P7,{}),[]);return Ko(t),a.jsx(ha,{})}function yV(){const{findings:{findings:t,loadFindings:s,loadAllFindings:o}}=ot(),{workspaceId:r,environmentId:c}=Vn();y.useEffect(()=>{r?s(r).catch(()=>{}):o().catch(()=>{})},[r,s,o]);const d=y.useMemo(()=>a.jsx(JI,{findings:t,workspaceId:r,environmentId:c}),[t,r,c]);return Ko(d),a.jsx(ha,{})}function bV(){const{knowledge:t,workspaces:{workspaces:s}}=ot(),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(()=>a.jsx(Y5,{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 Ko(u),a.jsx(ha,{})}function _V(){const{streams:{streams:t,streamsLoading:s,streamsLoadError:o,streamsLoadedOnce:r,loadStreams:c}}=ot(),d=y.useCallback(()=>{c().catch(()=>{})},[c]),u=y.useMemo(()=>a.jsx(Q7,{streams:t,loading:s,streamsLoadError:o,streamsLoadedOnce:r,onRefresh:d}),[t,s,o,r,d]);return Ko(u),a.jsx(ha,{})}const xV="_container_ce571_1",kV="_title_ce571_6",Nd={container:xV,title:kV};function SV(){return a.jsxs("div",{className:Nd.container,"aria-hidden":"true",children:[a.jsx("h1",{className:Nd.title,children:"Findings"}),a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:Array.from({length:4},(t,s)=>a.jsx(Sd,{lines:3},s))})]})}function w_(){const{environmentId:t,workspaceId:s}=Vn(),{findings:{findings:o,findingsLoading:r,loadFindings:c},workspaces:{workspaces:d},environments:{environments:u}}=ot(),p=dt();y.useEffect(()=>{s&&c(s).catch(()=>{})},[s,c]);const m=y.useCallback(v=>{p(Qp(v,s,t))},[p,s,t]);if(r)return a.jsx(SV,{});const g=s&&t?uk("Findings",s,t,d,u).slice(0,-1):Dz();return a.jsxs("div",{className:Nd.container,"data-testid":"findings-list-page",children:[a.jsx(Ss,{segments:g}),a.jsx("h1",{className:Nd.title,children:"Findings"}),a.jsx(Y1,{findings:o,onFindingClick:m})]})}const jV="_container_1wwpb_1",TV="_notFound_1wwpb_6",wV="_header_1wwpb_12",NV="_categoryBadge_1wwpb_19",CV="_title_1wwpb_28",EV="_content_1wwpb_35",AV="_tags_1wwpb_77",DV="_tag_1wwpb_77",RV="_meta_1wwpb_92",MV="_metaTimestamp_1wwpb_100",IV="_metaLink_1wwpb_105",kn={container:jV,notFound:TV,header:wV,categoryBadge:NV,title:CV,content:EV,tags:AV,tag:DV,meta:RV,metaTimestamp:MV,metaLink:IV};function N_(){const{findingId:t,environmentId:s,workspaceId:o}=Vn(),{findings:{selectedFinding:r,findingLoading:c,loadFinding:d},workspaces:{workspaces:u},environments:{environments:p}}=ot(),m=dt();if(y.useEffect(()=>{t&&d(t).catch(()=>{})},[t,d]),c)return a.jsx("div",{className:kn.container,"data-testid":"finding-detail-page",children:a.jsx("div",{className:kn.notFound,children:"Loading..."})});if(!r)return a.jsx("div",{className:kn.container,"data-testid":"finding-detail-page",children:a.jsx("div",{className:kn.notFound,children:"Finding not found."})});const g=uk(r.title,o,s,u,p),v=Td(r.category);return a.jsxs("div",{className:kn.container,"data-testid":"finding-detail-page",children:[a.jsx(Ss,{segments:g}),a.jsxs("div",{className:kn.header,children:[a.jsx("span",{className:kn.categoryBadge,style:{background:v.bg,color:v.text},children:r.category}),a.jsx("h1",{className:kn.title,children:r.title})]}),r.content&&a.jsx("div",{className:kn.content,children:a.jsx(Ed,{remarkPlugins:[Ad],children:r.content})}),r.tags.length>0&&a.jsx("div",{className:kn.tags,children:r.tags.map(_=>a.jsx("span",{className:kn.tag,children:_},_))}),a.jsxs("div",{className:kn.meta,children:[a.jsx("span",{className:kn.metaTimestamp,title:r.createdAt,children:Uo(r.createdAt)}),r.taskId&&a.jsx("button",{type:"button",className:kn.metaLink,onClick:()=>{m(Hn(r.taskId))},children:"View Task"}),r.sessionId&&a.jsx("button",{type:"button",className:kn.metaLink,onClick:()=>{m(Bd(r.sessionId))},children:"View Session"})]})]})}const OV="_wizard_1260s_1",LV="_container_1260s_10",BV="_stepContent_1260s_19",$V="_logoArea_1260s_28",zV="_logoImage_1260s_32",HV="_heading_1260s_41",PV="_tagline_1260s_49",UV="_subtitle_1260s_56",VV="_featureList_1260s_64",qV="_runtimeGrid_1260s_89",GV="_runtimeCard_1260s_101",FV="_runtimeName_1260s_133",ZV="_runtimeDescription_1260s_139",KV="_buttonRow_1260s_144",YV="_primaryButton_1260s_151",JV="_ghostButton_1260s_185",WV="_dots_1260s_213",XV="_dot_1260s_213",Je={wizard:OV,container:LV,stepContent:BV,logoArea:$V,logoImage:zV,heading:HV,tagline:PV,subtitle:UV,featureList:VV,runtimeGrid:qV,runtimeCard:GV,runtimeName:FV,runtimeDescription:ZV,buttonRow:KV,primaryButton:YV,ghostButton:JV,dots:WV,dot:XV};function QV({onNext:t}){return a.jsxs("div",{className:Je.stepContent,"data-testid":"setup-welcome",children:[a.jsx("div",{className:Je.logoArea,children:a.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:Je.logoImage})}),a.jsx("h1",{className:Je.heading,children:"Welcome to Grackle"}),a.jsx("p",{className:Je.tagline,children:"Multi-agent orchestration for software teams"}),a.jsx("button",{type:"button",className:Je.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function eq({onNext:t,onBack:s}){return a.jsxs("div",{className:Je.stepContent,"data-testid":"setup-about",children:[a.jsx("h2",{className:Je.heading,children:"What is Grackle?"}),a.jsxs("ul",{className:Je.featureList,children:[a.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),a.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),a.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),a.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),a.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),a.jsxs("div",{className:Je.buttonRow,children:[a.jsx("button",{type:"button",className:Je.ghostButton,onClick:s,children:"Back"}),a.jsx("button",{type:"button",className:Je.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const tq=[{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 nq({currentRuntime:t,onFinish:s,onBack:o,finishDisabled:r}){const[c,d]=y.useState(t||"claude-code");return y.useEffect(()=>{t&&d(t)},[t]),a.jsxs("div",{className:Je.stepContent,"data-testid":"setup-runtime",children:[a.jsx("h2",{className:Je.heading,children:"Choose Your Runtime"}),a.jsx("p",{className:Je.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),a.jsx("div",{className:Je.runtimeGrid,children:tq.map(u=>a.jsxs("button",{type:"button",className:Je.runtimeCard,"data-selected":c===u.id,"aria-pressed":c===u.id,"data-testid":`runtime-card-${u.id}`,onClick:()=>d(u.id),children:[a.jsx("span",{className:Je.runtimeName,children:u.name}),a.jsx("span",{className:Je.runtimeDescription,children:u.description})]},u.id))}),a.jsxs("div",{className:Je.buttonRow,children:[a.jsx("button",{type:"button",className:Je.ghostButton,onClick:o,children:"Back"}),a.jsx("button",{type:"button",className:Je.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function sq(){return typeof Notification<"u"}function aq({onFinish:t,onBack:s,finishDisabled:o}){const r=sq(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return a.jsxs("div",{className:Je.stepContent,"data-testid":"setup-notifications",children:[a.jsx("h2",{className:Je.heading,children:"Stay in the Loop"}),a.jsx("p",{className:Je.subtitle,children:"Grackle can send you a browser notification when an agent needs your input, so you never miss an important moment."}),c?a.jsx("p",{className:Je.subtitle,children:Notification.permission==="granted"?"Notifications are already enabled.":"Notifications have been blocked. You can change this in your browser settings."}):null,a.jsxs("div",{className:Je.buttonRow,children:[a.jsx("button",{type:"button",className:Je.ghostButton,onClick:s,disabled:o,children:"Back"}),!c&&r?a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:Je.ghostButton,onClick:t,disabled:o,"data-testid":"setup-notifications-skip",children:"Skip"}),a.jsx("button",{type:"button",className:Je.primaryButton,onClick:d,disabled:o,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):a.jsx("button",{type:"button",className:Je.primaryButton,onClick:t,disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const iq=4,C_={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function oq(){const{personas:{personas:t,updatePersona:s},completeOnboarding:o,onboardingCompleted:r}=ot(),{showToast:c}=hn(),d=dt(),[u,p]=y.useState(0),[m,g]=y.useState("claude-code"),[v,_]=y.useState(!1),b=t.find(j=>j.id==="claude-code"),x=y.useCallback(j=>{g(j),p(3)},[]),S=y.useCallback(()=>{const j=m;_(!0);const w=[];if(b&&j!==b.runtime){const C=C_[j]??"sonnet";w.push(s(b.id,void 0,void 0,void 0,j,C))}const T=t.find(C=>C.id===hy);if(T&&j!==T.runtime){const C=C_[j]??"sonnet";w.push(s(hy,void 0,void 0,void 0,j,C))}Promise.all(w).then(()=>o()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),_(!1)})},[m,b,t,s,o,d,c]);return r===!0?a.jsx(rs,{to:"/",replace:!0}):a.jsx("div",{className:Je.wizard,"data-testid":"setup-wizard",children:a.jsxs("div",{className:Je.container,children:[a.jsx(ls,{mode:"wait",children:a.jsxs(At.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&a.jsx(QV,{onNext:()=>p(1)}),u===1&&a.jsx(eq,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&a.jsx(nq,{currentRuntime:m,onFinish:x,onBack:()=>p(1),finishDisabled:!b}),u===3&&a.jsx(aq,{onFinish:S,onBack:()=>p(2),finishDisabled:v})]},u)}),a.jsx("div",{className:Je.dots,children:Array.from({length:iq},(j,w)=>a.jsx("span",{className:Je.dot,"data-active":w===u},w))})]})})}const rq="_root_zndgp_1",lq="_body_zndgp_7",cq="_main_zndgp_19",dq="_sidebarWrapper_zndgp_26",uq="_overlay_zndgp_51",Qr={root:rq,body:lq,main:cq,sidebarWrapper:dq,overlay:uq},fq=y.lazy(()=>aj(()=>import("./KnowledgePage-Dbm26xG_.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.KnowledgePage}))),gk=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function pq({tabs:t}){const{connectionStatus:s,environments:{environments:o},sessions:{sessions:r},tasks:{tasks:c}}=ot(),{toasts:d,dismissToast:u}=hn(),p=Wt(),m=yz(),g=m!==void 0,[v,_]=y.useState(!1),b=y.useCallback(()=>_(x=>!x),[]);return y.useEffect(()=>{_(!1)},[p.pathname]),y.useEffect(()=>{if(!v)return;const x=S=>{S.key==="Escape"&&_(!1)};return document.addEventListener("keydown",x),()=>{document.removeEventListener("keydown",x)}},[v]),a.jsxs(a.Fragment,{children:[a.jsx(lI,{connectionStatus:s,environments:o,sessions:r,onToggleSidebar:g?b:void 0,sidebarOpen:v}),a.jsx(hI,{tabs:t}),a.jsxs("div",{className:Qr.body,children:[g&&a.jsx("div",{className:Qr.sidebarWrapper,"data-sidebar-open":v,children:a.jsx(xI,{content:m})}),g&&v&&a.jsx("div",{className:Qr.overlay,"data-testid":"drawer-overlay",onClick:()=>_(!1)}),a.jsxs("div",{className:Qr.main,children:[a.jsx(ha,{}),a.jsx(EI,{sessions:r,tasks:c,environments:o})]})]}),a.jsx(UO,{toasts:d,onDismiss:u}),a.jsx(mV,{})]})}function mq(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:o,clearOperationError:r},tasks:{tasks:c},connectionStatus:d,onboardingCompleted:u}=ot(),{pluginNames:p}=xh(),{showToast:m}=hn();EH(s,m),IH(c,m),AH(o,r,m);const g=dt(),v=Wt();if(y.useEffect(()=>{t&&!v.pathname.includes("/tasks/")&&g(Bd(t),{replace:!0})},[t,g,v.pathname]),d==="connected"&&u===!1)return a.jsx(rs,{to:"/setup",replace:!0});const _=Qz(p);return a.jsx(vz,{children:a.jsxs("div",{className:Qr.root,children:[gk&&a.jsx(yC,{}),a.jsx(pq,{tabs:_})]})})}function Kp(){const{workspaceId:t}=Vn(),{workspaces:{workspaces:s}}=ot(),o=Wt(),r=s.find(g=>g.id===t),c=r!=null&&r.linkedEnvironmentIds?[...r.linkedEnvironmentIds].sort()[0]:void 0;if(!c)return s.length===0?void 0:a.jsx(rs,{to:"/environments",replace:!0});const d=encodeURIComponent(t),u=`/workspaces/${d}`,p=o.pathname.startsWith(u)?o.pathname.slice(u.length):"",m=`/environments/${encodeURIComponent(c)}/workspaces/${d}${p}${o.search}${o.hash}`;return a.jsx(rs,{to:m,replace:!0})}function hq(){const{pluginNames:t}=xh(),s=t.includes("orchestration"),o=t.includes("knowledge");return a.jsxs(nN,{children:[a.jsx(we,{path:"setup",element:a.jsx(oq,{})}),a.jsxs(we,{element:a.jsx(mq,{}),children:[a.jsx(we,{index:!0,element:a.jsx(_P,{})}),a.jsx(we,{path:"sessions/new",element:a.jsx(IP,{})}),a.jsxs(we,{element:a.jsx(_V,{}),children:[a.jsx(we,{path:"chat",element:a.jsx(y_,{})}),a.jsx(we,{path:"chat/:streamId",element:a.jsx(y_,{})})]}),a.jsx(we,{path:"sessions/:sessionId",element:a.jsx($P,{})}),o&&a.jsx(we,{element:a.jsx(bV,{}),children:a.jsx(we,{path:"knowledge",element:a.jsx(y.Suspense,{fallback:a.jsx(B1,{}),children:a.jsx(fq,{})})})}),s&&a.jsxs(we,{element:a.jsx(hV,{}),children:[a.jsx(we,{path:"tasks",element:a.jsx(yP,{})}),a.jsx(we,{path:"tasks/new",element:a.jsx(__,{})}),a.jsx(we,{path:"tasks/:taskId",element:a.jsx(Ka,{})}),a.jsx(we,{path:"tasks/:taskId/edit",element:a.jsx(Ka,{})}),a.jsx(we,{path:"tasks/:taskId/stream",element:a.jsx(Ka,{})}),a.jsx(we,{path:"tasks/:taskId/findings",element:a.jsx(Ka,{})})]}),s&&a.jsxs(we,{element:a.jsx(yV,{}),children:[a.jsx(we,{path:"findings",element:a.jsx(w_,{})}),a.jsx(we,{path:"findings/:findingId",element:a.jsx(N_,{})}),a.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/findings",element:a.jsx(w_,{})}),a.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/findings/:findingId",element:a.jsx(N_,{})})]}),a.jsxs(we,{element:a.jsx(gV,{}),children:[a.jsx(we,{path:"workspaces",element:a.jsx(rs,{to:"/environments",replace:!0})}),a.jsx(we,{path:"workspaces/new",element:a.jsx(QP,{})}),a.jsx(we,{path:"workspaces/:workspaceId",element:a.jsx(Kp,{})}),a.jsx(we,{path:"workspaces/:workspaceId/tasks/:taskId",element:a.jsx(Kp,{})}),a.jsx(we,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:a.jsx(Kp,{})}),a.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId",element:a.jsx(UP,{})}),a.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:a.jsx(__,{})}),a.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:a.jsx(Ka,{})}),a.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:a.jsx(Ka,{})}),a.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:a.jsx(Ka,{})}),a.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings",element:a.jsx(Ka,{})}),a.jsxs(we,{path:"environments",element:a.jsx(oU,{}),children:[a.jsx(we,{index:!0,element:a.jsx(bP,{})}),a.jsx(we,{path:"new",element:a.jsx(tU,{})}),a.jsx(we,{path:":environmentId",element:a.jsx(LU,{})}),a.jsx(we,{path:":environmentId/edit",element:a.jsx(nU,{})})]})]}),a.jsx(we,{element:a.jsx(vV,{}),children:a.jsxs(we,{path:"settings",element:a.jsx(zU,{}),children:[a.jsx(we,{index:!0,element:a.jsx(rs,{to:"credentials",replace:!0})}),a.jsx(we,{path:"environments",element:a.jsx(rs,{to:"/environments",replace:!0})}),a.jsx(we,{path:"credentials",element:a.jsx(HU,{})}),a.jsx(we,{path:"github-accounts",element:a.jsx(PU,{})}),a.jsx(we,{path:"tokens",element:a.jsx(rs,{to:"../credentials",replace:!0})}),a.jsx(we,{path:"personas",element:a.jsx(UU,{})}),a.jsx(we,{path:"personas/new",element:a.jsx(S_,{})}),a.jsx(we,{path:"personas/:personaId",element:a.jsx(S_,{})}),a.jsx(we,{path:"schedules",element:a.jsx(QU,{})}),a.jsx(we,{path:"schedules/new",element:a.jsx(j_,{})}),a.jsx(we,{path:"schedules/:scheduleId",element:a.jsx(j_,{})}),a.jsx(we,{path:"appearance",element:a.jsx(cV,{})}),a.jsx(we,{path:"shortcuts",element:a.jsx(fV,{})}),a.jsx(we,{path:"plugins",element:a.jsx(pV,{})}),a.jsx(we,{path:"about",element:a.jsx(uV,{})})]})}),a.jsx(we,{path:"*",element:a.jsx(rs,{to:"/",replace:!0})})]})]})}const gq=1e4;function vq(){const{onboardingCompleted:t}=ot(),[s,o]=y.useState(!1);y.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>o(!0),gq);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return a.jsx(ls,{mode:"wait",children:r?a.jsx(At.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:a.jsx(B1,{})},"splash"):a.jsx(At.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:a.jsx(NN,{basename:"/".replace(/\/$/,""),children:a.jsx(hq,{})})},"app")})}function yq(){const t=gk?Fz:CH;return a.jsx(Yz,{children:a.jsx(gz,{children:a.jsx(fz,{children:a.jsx(t,{children:a.jsx(vq,{})})})})})}tj.createRoot(document.getElementById("root")).render(a.jsx(y.StrictMode,{children:a.jsx(yq,{})}));export{Ss as B,ix as K,ot as a,Qp as f,Bd as s,Hn as t,dt as u};
|
|
754
|
+
$\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),M==="agent"&&a.jsxs("div",{children:[a.jsx("label",{children:"Allowed MCP Tools"}),a.jsx(l_,{selectedTools:Y,onChange:ie=>{V(ie),Se(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,ie),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!xe&&!de&&a.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,a.jsx(ks,{isOpen:Q,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:Xe,onCancel:()=>ge(!1)})]})}function QU(){const{schedules:{schedules:t,deleteSchedule:s,updateSchedule:o},personas:{personas:r}}=ot(),{showToast:c}=hn(),d=dt();return a.jsx(L7,{schedules:t,personas:r,onDeleteSchedule:async u=>{try{await s(u)}catch(p){throw console.error("Failed to delete schedule",{scheduleId:u,error:p}),c("Failed to delete schedule","error"),p}},onToggleEnabled:async(u,p)=>{try{return await o(u,p)}catch(m){throw console.error("Failed to update schedule",{scheduleId:u,error:m}),c("Failed to update schedule","error"),m}},onNavigateToNew:()=>d(PN),onNavigateToSchedule:u=>d(sx(u))})}const eV="_container_1g4qh_1",tV="_form_1g4qh_7",nV="_formActions_1g4qh_66",sV="_editableSection_1g4qh_73",aV="_helperText_1g4qh_84",iV="_metaSection_1g4qh_90",oV="_optional_1g4qh_108",rV="_readonlyValue_1g4qh_113",Bn={container:eV,form:tV,formActions:nV,editableSection:sV,helperText:aV,metaSection:iV,optional:oV,readonlyValue:rV};function j_(){const{scheduleId:t}=Vn(),s=dt(),{showToast:o}=hn(),{schedules:{schedules:r,schedulesLoading:c,createSchedule:d,updateSchedule:u,deleteSchedule:p},personas:{personas:m},workspaces:{workspaces:g}}=ot(),v=t===void 0,_=v?void 0:r.find(x=>x.id===t);if(!v&&!c&&r.length>0&&!_)return a.jsx(rs,{to:lp,replace:!0});const b=[{label:"Settings",url:Ai},{label:"Schedules",url:lp},{label:v?"New Schedule":(_==null?void 0:_.title)??"Schedule",url:void 0}];return a.jsxs("div",{className:Bn.container,children:[a.jsx(Ss,{segments:b}),a.jsx(lV,{existing:_,isNew:v,personas:m,workspaces:g,onCreateSchedule:d,onUpdateSchedule:u,onDeleteSchedule:p,onDone:()=>{s(lp)},showToast:o})]})}function lV({existing:t,isNew:s,personas:o,workspaces:r,onCreateSchedule:c,onUpdateSchedule:d,onDeleteSchedule:u,onDone:p,showToast:m}){var B;const g=dt(),[v,_]=y.useState((t==null?void 0:t.title)??""),[b,x]=y.useState((t==null?void 0:t.description)??""),[S,j]=y.useState((t==null?void 0:t.scheduleExpression)??""),[w,T]=y.useState((t==null?void 0:t.personaId)??""),[C,A]=y.useState((t==null?void 0:t.workspaceId)??""),[L,E]=y.useState(!1),[M,H]=y.useState(null);y.useEffect(()=>{s||t&&M===null&&(_(t.title),x(t.description),j(t.scheduleExpression),T(t.personaId),A(t.workspaceId))},[s,t,M]);const D=!s&&t===void 0,z=s&&v.trim().length>0&&S.trim().length>0&&w.length>0,Y=o.map(R=>({value:R.id,label:R.name})),V=[{value:"",label:"System-level (no workspace)"},...r.map(R=>({value:R.id,label:R.name}))],Q=R=>{R.preventDefault(),z&&c(v,b,S,w,C||void 0).then(Z=>{m("Schedule created","success"),g(sx(Z.id),{replace:!0})},()=>{m("Failed to create schedule","error")})},ge=(R,Z)=>{t&&d(t.id,{[R]:Z}).then(()=>{m("Schedule updated","success"),R==="title"&&_(String(Z)),R==="description"&&x(String(Z)),R==="scheduleExpression"&&j(String(Z)),R==="personaId"&&T(String(Z))},()=>{m("Failed to update schedule","error")})},X=()=>{if(!t)return;const R=!t.enabled;d(t.id,{enabled:R}).then(()=>{m(R?"Schedule enabled":"Schedule disabled","success")},()=>{m("Failed to update schedule","error")})},re=()=>{t&&u(t.id).then(()=>{m("Schedule deleted","success"),p()},()=>{m("Failed to delete schedule","error")})};return a.jsxs(a.Fragment,{children:[D?a.jsxs("div",{className:Bn.form,children:[a.jsx("h3",{children:"Edit Schedule"}),a.jsx("p",{children:"Loading schedule..."})]}):s?a.jsxs("form",{onSubmit:Q,className:Bn.form,children:[a.jsx("h3",{children:"Create Schedule"}),a.jsxs("label",{children:["Title",a.jsx("input",{type:"text",value:v,onChange:R=>_(R.target.value),placeholder:"e.g. Nightly Review",required:!0,"data-testid":"schedule-detail-title"})]}),a.jsxs("label",{children:["Description ",a.jsx("span",{className:Bn.optional,children:"(optional)"}),a.jsx("input",{type:"text",value:b,onChange:R=>x(R.target.value),placeholder:"Brief description...","data-testid":"schedule-detail-description"})]}),a.jsxs("label",{children:["Schedule Expression",a.jsx("input",{type:"text",value:S,onChange:R=>j(R.target.value),placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",required:!0,"data-testid":"schedule-detail-expression"}),a.jsxs("p",{className:Bn.helperText,children:["Interval: ",a.jsx("code",{children:"30s"}),", ",a.jsx("code",{children:"5m"}),", ",a.jsx("code",{children:"1h"}),", ",a.jsx("code",{children:"1d"})," (min 10s) | Cron: ",a.jsx("code",{children:"0 9 * * MON"})," (standard 5-field cron syntax)"]})]}),a.jsxs("label",{children:["Persona",a.jsxs("select",{value:w,onChange:R=>T(R.target.value),required:!0,"data-testid":"schedule-detail-persona",children:[a.jsx("option",{value:"",children:"Select a persona..."}),Y.map(R=>a.jsx("option",{value:R.value,children:R.label},R.value))]})]}),a.jsxs("label",{children:["Workspace ",a.jsx("span",{className:Bn.optional,children:"(optional)"}),a.jsx("select",{value:C,onChange:R=>A(R.target.value),"data-testid":"schedule-detail-workspace",children:V.map(R=>a.jsx("option",{value:R.value,children:R.label},R.value))})]}),a.jsxs("div",{className:Bn.formActions,children:[a.jsx(rn,{type:"submit",variant:"primary",size:"md",disabled:!z,"data-testid":"schedule-detail-save",children:"Create"}),a.jsx(rn,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Cancel"})]})]}):t?a.jsxs("div",{className:Bn.form,children:[a.jsx("h3",{children:"Edit Schedule"}),a.jsxs("div",{className:Bn.formActions,children:[a.jsx(rn,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Back to Schedules"}),a.jsx(rn,{type:"button",variant:t.enabled?"ghost":"primary",size:"md",onClick:X,"data-testid":"schedule-detail-toggle",children:t.enabled?"Disable":"Enable"}),a.jsx(rn,{type:"button",variant:"danger",size:"md",onClick:()=>E(!0),"data-testid":"schedule-detail-delete",children:"Delete"})]}),a.jsxs("div",{className:Bn.editableSection,children:[a.jsxs("label",{children:["Title",a.jsx(Yt,{value:v,onSave:R=>{ge("title",R)},validate:R=>R.trim()?void 0:"Title is required",fieldId:"schedule-title",activeFieldId:M,onActivate:H,ariaLabel:"Schedule title","data-testid":"schedule-detail-title"})]}),a.jsxs("label",{children:["Description",a.jsx(Yt,{value:b,onSave:R=>{ge("description",R)},fieldId:"schedule-description",activeFieldId:M,onActivate:H,placeholder:"Brief description...",ariaLabel:"Schedule description","data-testid":"schedule-detail-description"})]}),a.jsxs("label",{children:["Schedule Expression",a.jsx(Yt,{value:S,onSave:R=>{ge("scheduleExpression",R)},validate:R=>R.trim()?void 0:"Schedule expression is required",fieldId:"schedule-expression",activeFieldId:M,onActivate:H,placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",ariaLabel:"Schedule expression","data-testid":"schedule-detail-expression"})]}),a.jsxs("label",{children:["Persona",a.jsx(jd,{value:w,onSave:R=>{ge("personaId",R)},options:Y,fieldId:"schedule-persona",activeFieldId:M,onActivate:H,ariaLabel:"Schedule persona","data-testid":"schedule-detail-persona"})]}),a.jsxs("label",{children:["Workspace ",a.jsx("span",{className:Bn.optional,children:"(optional — set at creation)"}),a.jsx("span",{className:Bn.readonlyValue,"data-testid":"schedule-detail-workspace",children:((B=r.find(R=>R.id===t.workspaceId))==null?void 0:B.name)??"System-level (no workspace)"})]})]}),a.jsxs("div",{className:Bn.metaSection,children:[t.lastRunAt?a.jsxs("span",{children:["Last run: ",Uo(t.lastRunAt)]}):a.jsx("span",{children:"Last run: Never"}),t.enabled&&t.nextRunAt?a.jsxs("span",{children:["Next run: ",q1(t.nextRunAt)]}):null,t.runCount>0&&a.jsxs("span",{children:["Total runs: ",t.runCount]}),a.jsxs("span",{children:["Created: ",Uo(t.createdAt)]})]})]}):null,a.jsx(ks,{isOpen:L,title:"Delete Schedule?",description:`"${t==null?void 0:t.title}" will be permanently removed. Tasks already created by this schedule will not be affected.`,confirmLabel:"Delete",onConfirm:re,onCancel:()=>E(!1)})]})}function cV(){const{themeId:t,resolvedThemeId:s,setTheme:o,preferSystem:r,setPreferSystem:c}=ak();return a.jsx(QL,{themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c})}function dV(){const[t,s]=y.useState(void 0);return y.useEffect(()=>{let o=!1;return(async()=>{try{const c=await Be.getVersionStatus({});o||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{o=!0}},[]),t}function uV(){const{connectionStatus:t,environments:{environments:s},sessions:{sessions:o}}=ot(),r=dV();return a.jsxs(a.Fragment,{children:[r&&a.jsx(QO,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),a.jsx(nB,{connectionStatus:t,environments:s,sessions:o})]})}function fV(){return a.jsx(F8,{})}function pV(){const{plugins:{plugins:t,pluginsLoading:s,setPluginEnabled:o}}=ot();return a.jsx(g8,{plugins:t,loading:s,onSetPluginEnabled:(r,c)=>{o(r,c).catch(()=>{})}})}const T_=$i();function mV(){const t=dt();return ca({key:"?"},()=>{t(UN)}),ca({key:"n"},()=>{t(T_)}),ca({key:"N"},()=>{t(T_)}),a.jsx(a.Fragment,{})}function Ko(t){const s=bz();y.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function hV(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=ot(),o=y.useMemo(()=>a.jsx(EO,{workspaces:t,tasks:s}),[t,s]);return Ko(o),a.jsx(ha,{})}function gV(){const{environments:{environments:t}}=ot(),s=y.useMemo(()=>a.jsx(zI,{environments:t}),[t]);return Ko(s),a.jsx(ha,{})}function vV(){const t=y.useMemo(()=>a.jsx(P7,{}),[]);return Ko(t),a.jsx(ha,{})}function yV(){const{findings:{findings:t,loadFindings:s,loadAllFindings:o}}=ot(),{workspaceId:r,environmentId:c}=Vn();y.useEffect(()=>{r?s(r).catch(()=>{}):o().catch(()=>{})},[r,s,o]);const d=y.useMemo(()=>a.jsx(JI,{findings:t,workspaceId:r,environmentId:c}),[t,r,c]);return Ko(d),a.jsx(ha,{})}function bV(){const{knowledge:t,workspaces:{workspaces:s}}=ot(),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(()=>a.jsx(Y5,{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 Ko(u),a.jsx(ha,{})}function _V(){const{streams:{streams:t,streamsLoading:s,streamsLoadError:o,streamsLoadedOnce:r,loadStreams:c}}=ot(),d=y.useCallback(()=>{c().catch(()=>{})},[c]),u=y.useMemo(()=>a.jsx(Q7,{streams:t,loading:s,streamsLoadError:o,streamsLoadedOnce:r,onRefresh:d}),[t,s,o,r,d]);return Ko(u),a.jsx(ha,{})}const xV="_container_ce571_1",kV="_title_ce571_6",Nd={container:xV,title:kV};function SV(){return a.jsxs("div",{className:Nd.container,"aria-hidden":"true",children:[a.jsx("h1",{className:Nd.title,children:"Findings"}),a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:Array.from({length:4},(t,s)=>a.jsx(Sd,{lines:3},s))})]})}function w_(){const{environmentId:t,workspaceId:s}=Vn(),{findings:{findings:o,findingsLoading:r,loadFindings:c},workspaces:{workspaces:d},environments:{environments:u}}=ot(),p=dt();y.useEffect(()=>{s&&c(s).catch(()=>{})},[s,c]);const m=y.useCallback(v=>{p(Qp(v,s,t))},[p,s,t]);if(r)return a.jsx(SV,{});const g=s&&t?uk("Findings",s,t,d,u).slice(0,-1):Dz();return a.jsxs("div",{className:Nd.container,"data-testid":"findings-list-page",children:[a.jsx(Ss,{segments:g}),a.jsx("h1",{className:Nd.title,children:"Findings"}),a.jsx(Y1,{findings:o,onFindingClick:m})]})}const jV="_container_1wwpb_1",TV="_notFound_1wwpb_6",wV="_header_1wwpb_12",NV="_categoryBadge_1wwpb_19",CV="_title_1wwpb_28",EV="_content_1wwpb_35",AV="_tags_1wwpb_77",DV="_tag_1wwpb_77",RV="_meta_1wwpb_92",MV="_metaTimestamp_1wwpb_100",IV="_metaLink_1wwpb_105",kn={container:jV,notFound:TV,header:wV,categoryBadge:NV,title:CV,content:EV,tags:AV,tag:DV,meta:RV,metaTimestamp:MV,metaLink:IV};function N_(){const{findingId:t,environmentId:s,workspaceId:o}=Vn(),{findings:{selectedFinding:r,findingLoading:c,loadFinding:d},workspaces:{workspaces:u},environments:{environments:p}}=ot(),m=dt();if(y.useEffect(()=>{t&&d(t).catch(()=>{})},[t,d]),c)return a.jsx("div",{className:kn.container,"data-testid":"finding-detail-page",children:a.jsx("div",{className:kn.notFound,children:"Loading..."})});if(!r)return a.jsx("div",{className:kn.container,"data-testid":"finding-detail-page",children:a.jsx("div",{className:kn.notFound,children:"Finding not found."})});const g=uk(r.title,o,s,u,p),v=Td(r.category);return a.jsxs("div",{className:kn.container,"data-testid":"finding-detail-page",children:[a.jsx(Ss,{segments:g}),a.jsxs("div",{className:kn.header,children:[a.jsx("span",{className:kn.categoryBadge,style:{background:v.bg,color:v.text},children:r.category}),a.jsx("h1",{className:kn.title,children:r.title})]}),r.content&&a.jsx("div",{className:kn.content,children:a.jsx(Ed,{remarkPlugins:[Ad],children:r.content})}),r.tags.length>0&&a.jsx("div",{className:kn.tags,children:r.tags.map(_=>a.jsx("span",{className:kn.tag,children:_},_))}),a.jsxs("div",{className:kn.meta,children:[a.jsx("span",{className:kn.metaTimestamp,title:r.createdAt,children:Uo(r.createdAt)}),r.taskId&&a.jsx("button",{type:"button",className:kn.metaLink,onClick:()=>{m(Hn(r.taskId))},children:"View Task"}),r.sessionId&&a.jsx("button",{type:"button",className:kn.metaLink,onClick:()=>{m(Bd(r.sessionId))},children:"View Session"})]})]})}const OV="_wizard_1260s_1",LV="_container_1260s_10",BV="_stepContent_1260s_19",$V="_logoArea_1260s_28",zV="_logoImage_1260s_32",HV="_heading_1260s_41",PV="_tagline_1260s_49",UV="_subtitle_1260s_56",VV="_featureList_1260s_64",qV="_runtimeGrid_1260s_89",GV="_runtimeCard_1260s_101",FV="_runtimeName_1260s_133",ZV="_runtimeDescription_1260s_139",KV="_buttonRow_1260s_144",YV="_primaryButton_1260s_151",JV="_ghostButton_1260s_185",WV="_dots_1260s_213",XV="_dot_1260s_213",Je={wizard:OV,container:LV,stepContent:BV,logoArea:$V,logoImage:zV,heading:HV,tagline:PV,subtitle:UV,featureList:VV,runtimeGrid:qV,runtimeCard:GV,runtimeName:FV,runtimeDescription:ZV,buttonRow:KV,primaryButton:YV,ghostButton:JV,dots:WV,dot:XV};function QV({onNext:t}){return a.jsxs("div",{className:Je.stepContent,"data-testid":"setup-welcome",children:[a.jsx("div",{className:Je.logoArea,children:a.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:Je.logoImage})}),a.jsx("h1",{className:Je.heading,children:"Welcome to Grackle"}),a.jsx("p",{className:Je.tagline,children:"Multi-agent orchestration for software teams"}),a.jsx("button",{type:"button",className:Je.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function eq({onNext:t,onBack:s}){return a.jsxs("div",{className:Je.stepContent,"data-testid":"setup-about",children:[a.jsx("h2",{className:Je.heading,children:"What is Grackle?"}),a.jsxs("ul",{className:Je.featureList,children:[a.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),a.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),a.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),a.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),a.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),a.jsxs("div",{className:Je.buttonRow,children:[a.jsx("button",{type:"button",className:Je.ghostButton,onClick:s,children:"Back"}),a.jsx("button",{type:"button",className:Je.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const tq=[{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 nq({currentRuntime:t,onFinish:s,onBack:o,finishDisabled:r}){const[c,d]=y.useState(t||"claude-code");return y.useEffect(()=>{t&&d(t)},[t]),a.jsxs("div",{className:Je.stepContent,"data-testid":"setup-runtime",children:[a.jsx("h2",{className:Je.heading,children:"Choose Your Runtime"}),a.jsx("p",{className:Je.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),a.jsx("div",{className:Je.runtimeGrid,children:tq.map(u=>a.jsxs("button",{type:"button",className:Je.runtimeCard,"data-selected":c===u.id,"aria-pressed":c===u.id,"data-testid":`runtime-card-${u.id}`,onClick:()=>d(u.id),children:[a.jsx("span",{className:Je.runtimeName,children:u.name}),a.jsx("span",{className:Je.runtimeDescription,children:u.description})]},u.id))}),a.jsxs("div",{className:Je.buttonRow,children:[a.jsx("button",{type:"button",className:Je.ghostButton,onClick:o,children:"Back"}),a.jsx("button",{type:"button",className:Je.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function sq(){return typeof Notification<"u"}function aq({onFinish:t,onBack:s,finishDisabled:o}){const r=sq(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return a.jsxs("div",{className:Je.stepContent,"data-testid":"setup-notifications",children:[a.jsx("h2",{className:Je.heading,children:"Stay in the Loop"}),a.jsx("p",{className:Je.subtitle,children:"Grackle can send you a browser notification when an agent needs your input, so you never miss an important moment."}),c?a.jsx("p",{className:Je.subtitle,children:Notification.permission==="granted"?"Notifications are already enabled.":"Notifications have been blocked. You can change this in your browser settings."}):null,a.jsxs("div",{className:Je.buttonRow,children:[a.jsx("button",{type:"button",className:Je.ghostButton,onClick:s,disabled:o,children:"Back"}),!c&&r?a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:Je.ghostButton,onClick:t,disabled:o,"data-testid":"setup-notifications-skip",children:"Skip"}),a.jsx("button",{type:"button",className:Je.primaryButton,onClick:d,disabled:o,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):a.jsx("button",{type:"button",className:Je.primaryButton,onClick:t,disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const iq=4,C_={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function oq(){const{personas:{personas:t,updatePersona:s},completeOnboarding:o,onboardingCompleted:r}=ot(),{showToast:c}=hn(),d=dt(),[u,p]=y.useState(0),[m,g]=y.useState("claude-code"),[v,_]=y.useState(!1),b=t.find(j=>j.id==="claude-code"),x=y.useCallback(j=>{g(j),p(3)},[]),S=y.useCallback(()=>{const j=m;_(!0);const w=[];if(b&&j!==b.runtime){const C=C_[j]??"sonnet";w.push(s(b.id,void 0,void 0,void 0,j,C))}const T=t.find(C=>C.id===hy);if(T&&j!==T.runtime){const C=C_[j]??"sonnet";w.push(s(hy,void 0,void 0,void 0,j,C))}Promise.all(w).then(()=>o()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),_(!1)})},[m,b,t,s,o,d,c]);return r===!0?a.jsx(rs,{to:"/",replace:!0}):a.jsx("div",{className:Je.wizard,"data-testid":"setup-wizard",children:a.jsxs("div",{className:Je.container,children:[a.jsx(ls,{mode:"wait",children:a.jsxs(At.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&a.jsx(QV,{onNext:()=>p(1)}),u===1&&a.jsx(eq,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&a.jsx(nq,{currentRuntime:m,onFinish:x,onBack:()=>p(1),finishDisabled:!b}),u===3&&a.jsx(aq,{onFinish:S,onBack:()=>p(2),finishDisabled:v})]},u)}),a.jsx("div",{className:Je.dots,children:Array.from({length:iq},(j,w)=>a.jsx("span",{className:Je.dot,"data-active":w===u},w))})]})})}const rq="_root_zndgp_1",lq="_body_zndgp_7",cq="_main_zndgp_19",dq="_sidebarWrapper_zndgp_26",uq="_overlay_zndgp_51",Qr={root:rq,body:lq,main:cq,sidebarWrapper:dq,overlay:uq},fq=y.lazy(()=>aj(()=>import("./KnowledgePage-CD_LfPMg.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.KnowledgePage}))),gk=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function pq({tabs:t}){const{connectionStatus:s,environments:{environments:o},sessions:{sessions:r},tasks:{tasks:c}}=ot(),{toasts:d,dismissToast:u}=hn(),p=Wt(),m=yz(),g=m!==void 0,[v,_]=y.useState(!1),b=y.useCallback(()=>_(x=>!x),[]);return y.useEffect(()=>{_(!1)},[p.pathname]),y.useEffect(()=>{if(!v)return;const x=S=>{S.key==="Escape"&&_(!1)};return document.addEventListener("keydown",x),()=>{document.removeEventListener("keydown",x)}},[v]),a.jsxs(a.Fragment,{children:[a.jsx(lI,{connectionStatus:s,environments:o,sessions:r,onToggleSidebar:g?b:void 0,sidebarOpen:v}),a.jsx(hI,{tabs:t}),a.jsxs("div",{className:Qr.body,children:[g&&a.jsx("div",{className:Qr.sidebarWrapper,"data-sidebar-open":v,children:a.jsx(xI,{content:m})}),g&&v&&a.jsx("div",{className:Qr.overlay,"data-testid":"drawer-overlay",onClick:()=>_(!1)}),a.jsxs("div",{className:Qr.main,children:[a.jsx(ha,{}),a.jsx(EI,{sessions:r,tasks:c,environments:o})]})]}),a.jsx(UO,{toasts:d,onDismiss:u}),a.jsx(mV,{})]})}function mq(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:o,clearOperationError:r},tasks:{tasks:c},connectionStatus:d,onboardingCompleted:u}=ot(),{pluginNames:p}=xh(),{showToast:m}=hn();EH(s,m),IH(c,m),AH(o,r,m);const g=dt(),v=Wt();if(y.useEffect(()=>{t&&!v.pathname.includes("/tasks/")&&g(Bd(t),{replace:!0})},[t,g,v.pathname]),d==="connected"&&u===!1)return a.jsx(rs,{to:"/setup",replace:!0});const _=Qz(p);return a.jsx(vz,{children:a.jsxs("div",{className:Qr.root,children:[gk&&a.jsx(yC,{}),a.jsx(pq,{tabs:_})]})})}function Kp(){const{workspaceId:t}=Vn(),{workspaces:{workspaces:s}}=ot(),o=Wt(),r=s.find(g=>g.id===t),c=r!=null&&r.linkedEnvironmentIds?[...r.linkedEnvironmentIds].sort()[0]:void 0;if(!c)return s.length===0?void 0:a.jsx(rs,{to:"/environments",replace:!0});const d=encodeURIComponent(t),u=`/workspaces/${d}`,p=o.pathname.startsWith(u)?o.pathname.slice(u.length):"",m=`/environments/${encodeURIComponent(c)}/workspaces/${d}${p}${o.search}${o.hash}`;return a.jsx(rs,{to:m,replace:!0})}function hq(){const{pluginNames:t}=xh(),s=t.includes("orchestration"),o=t.includes("knowledge");return a.jsxs(nN,{children:[a.jsx(we,{path:"setup",element:a.jsx(oq,{})}),a.jsxs(we,{element:a.jsx(mq,{}),children:[a.jsx(we,{index:!0,element:a.jsx(_P,{})}),a.jsx(we,{path:"sessions/new",element:a.jsx(IP,{})}),a.jsxs(we,{element:a.jsx(_V,{}),children:[a.jsx(we,{path:"chat",element:a.jsx(y_,{})}),a.jsx(we,{path:"chat/:streamId",element:a.jsx(y_,{})})]}),a.jsx(we,{path:"sessions/:sessionId",element:a.jsx($P,{})}),o&&a.jsx(we,{element:a.jsx(bV,{}),children:a.jsx(we,{path:"knowledge",element:a.jsx(y.Suspense,{fallback:a.jsx(B1,{}),children:a.jsx(fq,{})})})}),s&&a.jsxs(we,{element:a.jsx(hV,{}),children:[a.jsx(we,{path:"tasks",element:a.jsx(yP,{})}),a.jsx(we,{path:"tasks/new",element:a.jsx(__,{})}),a.jsx(we,{path:"tasks/:taskId",element:a.jsx(Ka,{})}),a.jsx(we,{path:"tasks/:taskId/edit",element:a.jsx(Ka,{})}),a.jsx(we,{path:"tasks/:taskId/stream",element:a.jsx(Ka,{})}),a.jsx(we,{path:"tasks/:taskId/findings",element:a.jsx(Ka,{})})]}),s&&a.jsxs(we,{element:a.jsx(yV,{}),children:[a.jsx(we,{path:"findings",element:a.jsx(w_,{})}),a.jsx(we,{path:"findings/:findingId",element:a.jsx(N_,{})}),a.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/findings",element:a.jsx(w_,{})}),a.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/findings/:findingId",element:a.jsx(N_,{})})]}),a.jsxs(we,{element:a.jsx(gV,{}),children:[a.jsx(we,{path:"workspaces",element:a.jsx(rs,{to:"/environments",replace:!0})}),a.jsx(we,{path:"workspaces/new",element:a.jsx(QP,{})}),a.jsx(we,{path:"workspaces/:workspaceId",element:a.jsx(Kp,{})}),a.jsx(we,{path:"workspaces/:workspaceId/tasks/:taskId",element:a.jsx(Kp,{})}),a.jsx(we,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:a.jsx(Kp,{})}),a.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId",element:a.jsx(UP,{})}),a.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:a.jsx(__,{})}),a.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:a.jsx(Ka,{})}),a.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:a.jsx(Ka,{})}),a.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:a.jsx(Ka,{})}),a.jsx(we,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings",element:a.jsx(Ka,{})}),a.jsxs(we,{path:"environments",element:a.jsx(oU,{}),children:[a.jsx(we,{index:!0,element:a.jsx(bP,{})}),a.jsx(we,{path:"new",element:a.jsx(tU,{})}),a.jsx(we,{path:":environmentId",element:a.jsx(LU,{})}),a.jsx(we,{path:":environmentId/edit",element:a.jsx(nU,{})})]})]}),a.jsx(we,{element:a.jsx(vV,{}),children:a.jsxs(we,{path:"settings",element:a.jsx(zU,{}),children:[a.jsx(we,{index:!0,element:a.jsx(rs,{to:"credentials",replace:!0})}),a.jsx(we,{path:"environments",element:a.jsx(rs,{to:"/environments",replace:!0})}),a.jsx(we,{path:"credentials",element:a.jsx(HU,{})}),a.jsx(we,{path:"github-accounts",element:a.jsx(PU,{})}),a.jsx(we,{path:"tokens",element:a.jsx(rs,{to:"../credentials",replace:!0})}),a.jsx(we,{path:"personas",element:a.jsx(UU,{})}),a.jsx(we,{path:"personas/new",element:a.jsx(S_,{})}),a.jsx(we,{path:"personas/:personaId",element:a.jsx(S_,{})}),a.jsx(we,{path:"schedules",element:a.jsx(QU,{})}),a.jsx(we,{path:"schedules/new",element:a.jsx(j_,{})}),a.jsx(we,{path:"schedules/:scheduleId",element:a.jsx(j_,{})}),a.jsx(we,{path:"appearance",element:a.jsx(cV,{})}),a.jsx(we,{path:"shortcuts",element:a.jsx(fV,{})}),a.jsx(we,{path:"plugins",element:a.jsx(pV,{})}),a.jsx(we,{path:"about",element:a.jsx(uV,{})})]})}),a.jsx(we,{path:"*",element:a.jsx(rs,{to:"/",replace:!0})})]})]})}const gq=1e4;function vq(){const{onboardingCompleted:t}=ot(),[s,o]=y.useState(!1);y.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>o(!0),gq);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return a.jsx(ls,{mode:"wait",children:r?a.jsx(At.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:a.jsx(B1,{})},"splash"):a.jsx(At.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:a.jsx(NN,{basename:"/".replace(/\/$/,""),children:a.jsx(hq,{})})},"app")})}function yq(){const t=gk?Fz:CH;return a.jsx(Yz,{children:a.jsx(gz,{children:a.jsx(fz,{children:a.jsx(t,{children:a.jsx(vq,{})})})})})}tj.createRoot(document.getElementById("root")).render(a.jsx(y.StrictMode,{children:a.jsx(yq,{})}));export{Ss as B,ix as K,ot as a,Qp as f,Bd as s,Hn as t,dt as u};
|
package/dist/index.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
|
11
11
|
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
|
|
12
12
|
<link rel="manifest" href="/manifest.json" />
|
|
13
|
-
<script type="module" crossorigin src="/assets/index-
|
|
13
|
+
<script type="module" crossorigin src="/assets/index-DZjE3Vxz.js"></script>
|
|
14
14
|
<link rel="modulepreload" crossorigin href="/assets/dagview-tHPW3Rz3.js">
|
|
15
15
|
<link rel="modulepreload" crossorigin href="/assets/grpc-DkqZhsre.js">
|
|
16
16
|
<link rel="modulepreload" crossorigin href="/assets/markdown-Yr3vTPLR.js">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grackle-ai/web",
|
|
3
|
-
"version": "0.108.
|
|
3
|
+
"version": "0.108.4",
|
|
4
4
|
"description": "React web UI for the Grackle multi-agent coordination platform",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"rehype-prism-plus": "^2.0.0",
|
|
39
39
|
"remark-gfm": "^4.0.0",
|
|
40
40
|
"react-router": "^7.0.0",
|
|
41
|
-
"@grackle-ai/common": "0.108.
|
|
42
|
-
"@grackle-ai/web-components": "0.108.
|
|
41
|
+
"@grackle-ai/common": "0.108.4",
|
|
42
|
+
"@grackle-ai/web-components": "0.108.4"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@rushstack/heft": "1.2.7",
|