@grackle-ai/web 0.119.0 → 0.120.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{KnowledgePage-t836uaLl.js → KnowledgePage-C3ucJMNK.js} +1 -1
- package/dist/assets/McpAppWidget-Cmfb963w.js +39 -0
- package/dist/assets/grpc-3bXYIKhE.js +40 -0
- package/dist/assets/{index-Bw0E0QX1.js → index-Cd2GfJNe.js} +5 -5
- package/dist/index.html +2 -2
- package/package.json +3 -3
- package/dist/assets/McpAppWidget-DbYqtOnr.js +0 -77
- package/dist/assets/grpc-dfCZg-0u.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/McpAppWidget-
|
|
2
|
-
import{r as _2,a as x2,b as y,j as i,d as ty,H as ny,P as sy,i as k2,B as S2,c as T2,C as j2,M as w2,e as N2}from"./dagview-tHPW3Rz3.js";import{c as C2,a as hd,G as E2,b as A2,d as D2,e as M2,f as R2,M as I2,D as y_,A as b_,W as O2,O as B2,g as L2,C as ra,h as __,i as x_,w as z2,t as $2,p as Cc,j as H2,R as Ec,S as ay}from"./grpc-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/McpAppWidget-Cmfb963w.js","assets/dagview-tHPW3Rz3.js","assets/grpc-3bXYIKhE.js","assets/KnowledgePage-C3ucJMNK.js","assets/markdown-Yr3vTPLR.js","assets/KnowledgePage-BmY14aDt.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as _2,a as x2,b as y,j as i,d as ty,H as ny,P as sy,i as k2,B as S2,c as T2,C as j2,M as w2,e as N2}from"./dagview-tHPW3Rz3.js";import{c as C2,a as hd,G as E2,b as A2,d as D2,e as M2,f as R2,M as I2,D as y_,A as b_,W as O2,O as B2,g as L2,C as ra,h as __,i as x_,w as z2,t as $2,p as Cc,j as H2,R as Ec,S as ay}from"./grpc-3bXYIKhE.js";import{v as P2,r as U2,t as Ac,i as V2,f as q2,M as um,a as fm}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 Uf={exports:{}},Rr={},Vf={exports:{}},qf={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* scheduler.production.js
|
|
5
5
|
*
|
|
@@ -297,7 +297,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
297
297
|
`))??[],v=g.length>op,b=c?o:g.slice(0,op).join(`
|
|
298
298
|
`);let _="";if(s!=null)try{_=JSON.stringify(s,null,2)}catch{_=String(s)}return i.jsxs("div",{className:`${L.card} ${r?L.cardRed:L.cardBlue} ${m?L.inProgress:""}`,"data-testid":"tool-card-generic",children:[i.jsxs("div",{className:L.header,children:[i.jsx("span",{className:L.icon,children:i.jsx(RT,{size:zt,"aria-hidden":"true"})}),i.jsx("span",{className:L.toolName,style:{color:"var(--accent-blue)"},children:u}),p&&i.jsx("span",{className:L.fileName,children:p})]}),m&&_&&i.jsx("pre",{className:L.pre,"data-testid":"tool-card-args",children:_}),r&&o&&i.jsx("pre",{className:L.pre,"data-testid":"tool-card-error",children:o}),!r&&!m&&o&&i.jsxs(i.Fragment,{children:[i.jsx("pre",{className:L.pre,"data-testid":"tool-card-result",children:b}),v&&i.jsxs("button",{type:"button",className:L.bodyToggle,onClick:()=>{d(k=>!k)},"aria-expanded":c,"data-testid":"tool-card-toggle",children:[i.jsx("span",{className:`${L.chevron} ${c?L.chevronExpanded:""}`,"aria-hidden":"true",children:i.jsx(da,{size:Ze})}),c?"collapse":`${g.length-op} more lines`]})]})]})}const pA="_badgePill_o7eqc_1",mA="_modelBadge_o7eqc_14",hA="_backgroundBadge_o7eqc_26",gA="_backgroundDot_o7eqc_36",vA="_backgroundDotPulsing_o7eqc_41",yA="_description_o7eqc_55",bA="_statusLine_o7eqc_62",_A="_statusCompleted_o7eqc_72",xA="_statusRunning_o7eqc_77",kA="_statusError_o7eqc_83",SA="_promptToggle_o7eqc_88",ps={badgePill:pA,modelBadge:mA,backgroundBadge:hA,backgroundDot:gA,backgroundDotPulsing:vA,description:yA,statusLine:bA,statusCompleted:_A,statusRunning:xA,statusError:kA,promptToggle:SA};function TA(t,s){if(s==null||typeof s!="object")return{};const o=s;return t.toLowerCase()==="read_agent"?{agentId:typeof o.agent_id=="string"?o.agent_id:void 0,isPoll:!0}:typeof o.agent_type=="string"||typeof o.name=="string"?{agentType:typeof o.agent_type=="string"?o.agent_type:void 0,description:typeof o.description=="string"?o.description:void 0,prompt:typeof o.prompt=="string"?o.prompt:void 0,isBackground:o.mode==="background",agentName:typeof o.name=="string"?o.name:void 0}:{agentType:typeof o.subagent_type=="string"?o.subagent_type:void 0,description:typeof o.description=="string"?o.description:void 0,prompt:typeof o.prompt=="string"?o.prompt:void 0,isBackground:o.run_in_background===!0,model:typeof o.model=="string"?o.model:void 0,isResume:typeof o.resume=="string"&&o.resume.length>0}}const jA=/^Agent\s+(completed|running|failed|error)\.\s*agent_id:\s*(\S+),?\s*([^\n]*)(?:\n\n([\s\S]*))?$/i;function wA(t){const s=jA.exec(t);if(!s)return;const o=s[4];return{status:s[1].toLowerCase(),agentId:s[2].replace(/,$/,""),metadata:s[3].trim(),content:o?o.trim():void 0}}const rp=5;function NA({tool:t,args:s,result:o,isError:r}){const[c,d]=y.useState(!1),[u,p]=y.useState(!1),m=TA(t,s),g=o===void 0,v=m.isPoll&&o?wA(o):void 0,b=(v==null?void 0:v.content)??o,_=(b==null?void 0:b.split(`
|
|
299
299
|
`))??[],k=_.length>rp,S=c?b:_.slice(0,rp).join(`
|
|
300
|
-
`),T=m.isPoll?"Subagent":"Agent";return i.jsxs("div",{className:`${L.card} ${r?L.cardRed:L.cardTeal} ${g?L.inProgress:""}`,"data-testid":"tool-card-agent",children:[i.jsxs("div",{className:L.header,children:[i.jsx("span",{className:L.icon,style:{color:"var(--accent-teal, #2dd4bf)"},children:"▶"}),i.jsx("span",{className:L.toolName,style:{color:"var(--accent-teal, #2dd4bf)"},children:T}),m.agentType&&i.jsx("span",{className:ps.badgePill,"data-testid":"tool-card-agent-type",children:m.agentType}),m.model&&i.jsx("span",{className:ps.modelBadge,"data-testid":"tool-card-agent-model",children:m.model}),m.isBackground&&i.jsxs("span",{className:ps.backgroundBadge,"data-testid":"tool-card-agent-background",children:[i.jsx("span",{className:g?ps.backgroundDotPulsing:ps.backgroundDot,children:"●"}),"BG"]}),m.agentName&&i.jsx("span",{className:L.fileName,"data-testid":"tool-card-agent-name",children:m.agentName}),m.agentId&&i.jsx("span",{className:L.fileName,"data-testid":"tool-card-agent-id",children:m.agentId}),i.jsx("span",{className:L.spacer}),g&&!m.isBackground&&i.jsx("span",{className:L.exitPending,"data-testid":"tool-card-pending",children:"●"})]}),m.description&&i.jsx("div",{className:ps.description,"data-testid":"tool-card-agent-description",children:m.isResume?`Resuming: ${m.description}`:m.description}),v&&i.jsxs("div",{className:ps.statusLine,"data-testid":"tool-card-agent-status",children:[i.jsx("span",{className:v.status==="completed"?ps.statusCompleted:v.status==="running"?ps.statusRunning:ps.statusError,children:v.status}),v.metadata&&i.jsx("span",{children:v.metadata})]}),m.prompt&&i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",className:ps.promptToggle,onClick:()=>{p(j=>!j)},"aria-expanded":u,"data-testid":"tool-card-prompt-toggle",children:[i.jsx("span",{className:`${L.chevron} ${u?L.chevronExpanded:""}`,children:"▸"}),"prompt"]}),u&&i.jsx("pre",{className:L.pre,"data-testid":"tool-card-prompt",children:m.prompt})]}),r&&o&&i.jsx("pre",{className:L.pre,"data-testid":"tool-card-error",children:o}),!r&&!g&&b&&i.jsxs(i.Fragment,{children:[i.jsx("pre",{className:L.pre,"data-testid":"tool-card-result",children:S}),k&&i.jsxs("button",{type:"button",className:L.bodyToggle,onClick:()=>{d(j=>!j)},"aria-expanded":c,"data-testid":"tool-card-toggle",children:[i.jsx("span",{className:`${L.chevron} ${c?L.chevronExpanded:""}`,children:"▸"}),c?"collapse":`${_.length-rp} more lines`]})]})]})}function lp(t){switch(OC(t.tool)){case"file-read":return i.jsx(Ty,{...t});case"file-edit":return i.jsx(_E,{...t});case"file-write":return i.jsx(Ty,{...t,writeVariant:!0});case"shell":return i.jsx(jE,{...t});case"search":return i.jsx(NE,{...t});case"todo":return i.jsx(FE,{...t});case"metadata":return i.jsx(ZE,{...t});case"task":return i.jsx(XE,{...t});case"workpad":return i.jsx(tA,{...t});case"knowledge":return i.jsx(aA,{...t});case"ipc":return i.jsx(rA,{...t});case"tool-search":return i.jsx(cA,{...t});case"agent":return i.jsx(NA,{...t});default:return i.jsx(fA,{...t})}}const CA="_systemContextEvent_1kdcc_1",EA="_systemContextHeader_1kdcc_7",AA="_systemContextBadge_1kdcc_28",DA="_systemContextToggle_1kdcc_37",MA="_systemContextPre_1kdcc_43",RA="_systemContextEllipsis_1kdcc_54",IA="_systemEvent_1kdcc_58",OA="_systemTimestamp_1kdcc_65",BA="_textEvent_1kdcc_69",LA="_codeBlockWrapper_1kdcc_156",zA="_codeBlockCopyButton_1kdcc_159",$A="_errorEvent_1kdcc_163",HA="_statusEvent_1kdcc_171",PA="_userInputEvent_1kdcc_180",UA="_userInputContent_1kdcc_186",VA="_signalEvent_1kdcc_293",qA="_signalBadge_1kdcc_304",GA="_signalContent_1kdcc_313",FA="_usageEvent_1kdcc_318",KA="_usageBadge_1kdcc_325",ZA="_defaultEvent_1kdcc_334",Lt={systemContextEvent:CA,systemContextHeader:EA,systemContextBadge:AA,systemContextToggle:DA,systemContextPre:MA,systemContextEllipsis:RA,systemEvent:IA,systemTimestamp:OA,textEvent:BA,codeBlockWrapper:LA,codeBlockCopyButton:zA,errorEvent:$A,statusEvent:HA,userInputEvent:PA,userInputContent:UA,signalEvent:VA,signalBadge:qA,signalContent:GA,usageEvent:FA,usageBadge:KA,defaultEvent:ZA},Ny=y.lazy(()=>k_(()=>import("./McpAppWidget-
|
|
300
|
+
`),T=m.isPoll?"Subagent":"Agent";return i.jsxs("div",{className:`${L.card} ${r?L.cardRed:L.cardTeal} ${g?L.inProgress:""}`,"data-testid":"tool-card-agent",children:[i.jsxs("div",{className:L.header,children:[i.jsx("span",{className:L.icon,style:{color:"var(--accent-teal, #2dd4bf)"},children:"▶"}),i.jsx("span",{className:L.toolName,style:{color:"var(--accent-teal, #2dd4bf)"},children:T}),m.agentType&&i.jsx("span",{className:ps.badgePill,"data-testid":"tool-card-agent-type",children:m.agentType}),m.model&&i.jsx("span",{className:ps.modelBadge,"data-testid":"tool-card-agent-model",children:m.model}),m.isBackground&&i.jsxs("span",{className:ps.backgroundBadge,"data-testid":"tool-card-agent-background",children:[i.jsx("span",{className:g?ps.backgroundDotPulsing:ps.backgroundDot,children:"●"}),"BG"]}),m.agentName&&i.jsx("span",{className:L.fileName,"data-testid":"tool-card-agent-name",children:m.agentName}),m.agentId&&i.jsx("span",{className:L.fileName,"data-testid":"tool-card-agent-id",children:m.agentId}),i.jsx("span",{className:L.spacer}),g&&!m.isBackground&&i.jsx("span",{className:L.exitPending,"data-testid":"tool-card-pending",children:"●"})]}),m.description&&i.jsx("div",{className:ps.description,"data-testid":"tool-card-agent-description",children:m.isResume?`Resuming: ${m.description}`:m.description}),v&&i.jsxs("div",{className:ps.statusLine,"data-testid":"tool-card-agent-status",children:[i.jsx("span",{className:v.status==="completed"?ps.statusCompleted:v.status==="running"?ps.statusRunning:ps.statusError,children:v.status}),v.metadata&&i.jsx("span",{children:v.metadata})]}),m.prompt&&i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",className:ps.promptToggle,onClick:()=>{p(j=>!j)},"aria-expanded":u,"data-testid":"tool-card-prompt-toggle",children:[i.jsx("span",{className:`${L.chevron} ${u?L.chevronExpanded:""}`,children:"▸"}),"prompt"]}),u&&i.jsx("pre",{className:L.pre,"data-testid":"tool-card-prompt",children:m.prompt})]}),r&&o&&i.jsx("pre",{className:L.pre,"data-testid":"tool-card-error",children:o}),!r&&!g&&b&&i.jsxs(i.Fragment,{children:[i.jsx("pre",{className:L.pre,"data-testid":"tool-card-result",children:S}),k&&i.jsxs("button",{type:"button",className:L.bodyToggle,onClick:()=>{d(j=>!j)},"aria-expanded":c,"data-testid":"tool-card-toggle",children:[i.jsx("span",{className:`${L.chevron} ${c?L.chevronExpanded:""}`,children:"▸"}),c?"collapse":`${_.length-rp} more lines`]})]})]})}function lp(t){switch(OC(t.tool)){case"file-read":return i.jsx(Ty,{...t});case"file-edit":return i.jsx(_E,{...t});case"file-write":return i.jsx(Ty,{...t,writeVariant:!0});case"shell":return i.jsx(jE,{...t});case"search":return i.jsx(NE,{...t});case"todo":return i.jsx(FE,{...t});case"metadata":return i.jsx(ZE,{...t});case"task":return i.jsx(XE,{...t});case"workpad":return i.jsx(tA,{...t});case"knowledge":return i.jsx(aA,{...t});case"ipc":return i.jsx(rA,{...t});case"tool-search":return i.jsx(cA,{...t});case"agent":return i.jsx(NA,{...t});default:return i.jsx(fA,{...t})}}const CA="_systemContextEvent_1kdcc_1",EA="_systemContextHeader_1kdcc_7",AA="_systemContextBadge_1kdcc_28",DA="_systemContextToggle_1kdcc_37",MA="_systemContextPre_1kdcc_43",RA="_systemContextEllipsis_1kdcc_54",IA="_systemEvent_1kdcc_58",OA="_systemTimestamp_1kdcc_65",BA="_textEvent_1kdcc_69",LA="_codeBlockWrapper_1kdcc_156",zA="_codeBlockCopyButton_1kdcc_159",$A="_errorEvent_1kdcc_163",HA="_statusEvent_1kdcc_171",PA="_userInputEvent_1kdcc_180",UA="_userInputContent_1kdcc_186",VA="_signalEvent_1kdcc_293",qA="_signalBadge_1kdcc_304",GA="_signalContent_1kdcc_313",FA="_usageEvent_1kdcc_318",KA="_usageBadge_1kdcc_325",ZA="_defaultEvent_1kdcc_334",Lt={systemContextEvent:CA,systemContextHeader:EA,systemContextBadge:AA,systemContextToggle:DA,systemContextPre:MA,systemContextEllipsis:RA,systemEvent:IA,systemTimestamp:OA,textEvent:BA,codeBlockWrapper:LA,codeBlockCopyButton:zA,errorEvent:$A,statusEvent:HA,userInputEvent:PA,userInputContent:UA,signalEvent:VA,signalBadge:qA,signalContent:GA,usageEvent:FA,usageBadge:KA,defaultEvent:ZA},Ny=y.lazy(()=>k_(()=>import("./McpAppWidget-Cmfb963w.js"),__vite__mapDeps([0,1,2])).then(t=>({default:t.McpAppWidget}))),Cy=3;function YA({content:t}){const[s,o]=y.useState(!1),r=t.split(`
|
|
301
301
|
`),c=r.length>Cy,d=s?t:r.slice(0,Cy).join(`
|
|
302
302
|
`);return i.jsxs("div",{className:Lt.systemContextEvent,"data-testid":"system-context-event",children:[i.jsxs("button",{type:"button",className:Lt.systemContextHeader,onClick:()=>{o(u=>!u)},"aria-expanded":s,children:[i.jsx("span",{className:Lt.systemContextBadge,children:"SYSTEM PROMPT"}),c&&i.jsx("span",{className:Lt.systemContextToggle,"aria-hidden":"true",children:s?i.jsx(T_,{size:Ze}):i.jsx(da,{size:Ze})})]}),i.jsxs("pre",{className:Lt.systemContextPre,children:[d,!s&&c&&i.jsx("span",{className:Lt.systemContextEllipsis,children:"…"})]})]})}function JA({time:t,content:s}){return i.jsxs("div",{className:Lt.systemEvent,children:[i.jsxs("span",{className:Lt.systemTimestamp,children:["[",t,"]"]})," ",s]})}function $p(t){return typeof t=="string"?t:typeof t=="number"?String(t):Array.isArray(t)?t.map($p).join(""):t!=null&&typeof t=="object"&&"props"in t?$p(t.props.children):""}function WA({children:t,node:s,...o}){const r=$p(t);return i.jsxs("div",{className:Lt.codeBlockWrapper,children:[i.jsx("pre",{...o,children:t}),i.jsx(pC,{text:r,"data-testid":"copy-code-block",className:Lt.codeBlockCopyButton})]})}const XA={pre:WA};function X_({content:t}){return i.jsx(um,{remarkPlugins:[fm],rehypePlugins:[RC],components:XA,children:t})}function QA({content:t}){return i.jsx("div",{className:Lt.textEvent,children:i.jsx(X_,{content:t})})}function eD({content:t}){return i.jsxs("div",{className:Lt.errorEvent,children:["Error: ",t]})}function tD({content:t}){return i.jsxs("div",{className:Lt.statusEvent,children:["--- ",t," ---"]})}function nD({content:t}){return i.jsx("div",{className:Lt.userInputEvent,children:i.jsx("div",{className:Lt.userInputContent,"data-testid":"user-input-content",children:i.jsx(X_,{content:t})})})}function sD({content:t}){return i.jsxs("div",{className:Lt.signalEvent,"data-testid":"signal-event",children:[i.jsx("span",{className:Lt.signalBadge,children:"SIGNAL"}),i.jsx("span",{className:Lt.signalContent,children:t})]})}function aD({content:t}){let s=t;try{const o=JSON.parse(t),r=Number(o.input_tokens)||0,c=Number(o.output_tokens)||0,d=Oo(r+c),u=As(Number(o.cost_millicents)||0);s=`${d} tokens · ${u}`}catch{}return i.jsx("div",{className:Lt.usageEvent,"data-testid":"usage-event",children:i.jsx("span",{className:Lt.usageBadge,children:s})})}function Or({content:t}){return i.jsx("div",{className:Lt.defaultEvent,children:t})}function iD({event:t,toolUseCtx:s,settled:o,sandboxProxyUrl:r}){const c=new Date(t.timestamp).toLocaleTimeString();switch(t.eventType){case"widget":{if(!r)return i.jsx(Or,{content:t.content});let d={};try{d=JSON.parse(t.content)}catch{}const u=d.rendererKind??"mcp-app-html";if(u==="grackle-react"&&d.html){const m=`<!doctype html><html><head><meta charset="utf-8"></head><body><div id="grackle-root"></div><script type="module" src="${new URL(r,window.location.href).origin}/runtime.js"><\/script></body></html>`;return i.jsx(y.Suspense,{fallback:i.jsx(Or,{content:"Loading widget..."}),children:i.jsx(Ny,{widgetHtml:m,sandboxProxyUrl:r,csp:d.csp,toolInput:{source:d.html,props:d.toolInput??{}}})})}return u!=="mcp-app-html"||!d.html?i.jsx(Or,{content:t.content}):i.jsx(y.Suspense,{fallback:i.jsx(Or,{content:"Loading widget..."}),children:i.jsx(Ny,{widgetHtml:d.html,sandboxProxyUrl:r,csp:d.csp,toolInput:d.toolInput,toolResult:d.toolResult})})}case"system":{if(t.raw)try{if(JSON.parse(t.raw).systemContext===!0)return i.jsx(YA,{content:t.content})}catch{}return i.jsx(JA,{time:c,content:t.content})}case"text":case"output":return i.jsx(QA,{content:t.content});case"tool_use":{let d="",u={};try{const p=JSON.parse(t.content);d=p.tool||"",u=p.args}catch{}return i.jsx(lp,{tool:d,args:u,result:o?"":void 0})}case"tool_result":{let d=!1;if(t.raw)try{d=JSON.parse(t.raw).is_error===!0}catch{}let u=t.content;if(t.content.trimStart().startsWith("{"))try{const p=JSON.parse(t.content);typeof p.content=="string"&&(u=p.content)}catch{}return s?i.jsx(lp,{tool:s.tool,args:s.args,result:u,isError:d,detailedResult:s.detailedResult}):i.jsx(lp,{tool:"Tool output",args:void 0,result:u,isError:d})}case"error":return i.jsx(eD,{content:t.content});case"status":return i.jsx(tD,{content:t.content});case"user_input":return i.jsx(nD,{content:t.content});case"signal":return i.jsx(sD,{content:t.content});case"usage":return i.jsx(aD,{content:t.content});default:return i.jsx(Or,{content:t.content})}}const Tm=y.createContext({});function jm(t){const s=y.useRef(null);return s.current===null&&(s.current=t()),s.current}const kd=y.createContext(null),wm=y.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});class oD extends y.Component{getSnapshotBeforeUpdate(s){const o=this.props.childRef.current;if(o&&s.isPresent&&!this.props.isPresent){const r=this.props.sizeRef.current;r.height=o.offsetHeight||0,r.width=o.offsetWidth||0,r.top=o.offsetTop,r.left=o.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}}function rD({children:t,isPresent:s}){const o=y.useId(),r=y.useRef(null),c=y.useRef({width:0,height:0,top:0,left:0}),{nonce:d}=y.useContext(wm);return y.useInsertionEffect(()=>{const{width:u,height:p,top:m,left:g}=c.current;if(s||!r.current||!u||!p)return;r.current.dataset.motionPopId=o;const v=document.createElement("style");return d&&(v.nonce=d),document.head.appendChild(v),v.sheet&&v.sheet.insertRule(`
|
|
303
303
|
[data-motion-pop-id="${o}"] {
|
|
@@ -322,7 +322,7 @@ ${r.content}`);break}}}return s.join(`
|
|
|
322
322
|
|
|
323
323
|
${r}
|
|
324
324
|
|
|
325
|
-
--- End forwarded ---`}function a5(t){return t.replace(/[\r\n]+/g," ").trim().replace(/---/g,"—")}function i5({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,T)=>{if(T&&u.current!==void 0){const j=Math.min(u.current,S),w=Math.max(u.current,S);d(C=>{const D=new Set(C);for(let A=j;A<=w;A++)A<t.length&&ol(t[A])&&D.add(A);return D})}else d(j=>{const w=new Set(j);return w.has(S)?w.delete(S):w.add(S),w.size===0?(r(!1),u.current=void 0):u.current=S,w})},[t]),b=y.useCallback(()=>{const S=new Set;for(let T=0;T<t.length;T++)ol(t[T])&&S.add(T);d(S)},[t]),_=y.useCallback(()=>{d(new Set)},[]),k=y.useCallback(async()=>{const T=[...c].sort((w,C)=>w-C).filter(w=>w<t.length).map(w=>t[w]);if(T.length===0)return!1;const j=s(T);try{return await navigator.clipboard.writeText(j),!0}catch{return!1}},[c,t,s]);return{isSelecting:o,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:b,deselectAll:_,copySelected:k}}const o5="_wrapper_1cdza_1",r5="_scrollContainer_1cdza_9",l5="_selectingPadding_1cdza_16",c5="_toolbar_1cdza_20",d5="_directionToggle_1cdza_27",u5="_scrollToAnchor_1cdza_65",f5="_scrollToAnchorBottom_1cdza_89",p5="_scrollToAnchorTop_1cdza_93",m5="_eventOverflowWarning_1cdza_97",sa={wrapper:o5,scrollContainer:r5,selectingPadding:l5,toolbar:c5,directionToggle:d5,scrollToAnchor:u5,scrollToAnchorBottom:f5,scrollToAnchorTop:p5,eventOverflowWarning:m5},h5=10*1024,g5=new Set(["running","idle"]);function v5(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 M1="grackle-stream-direction";function y5(){try{return localStorage.getItem(M1)==="reversed"}catch{return!1}}function b5({eventsDropped:t}){return t<=0?i.jsx(i.Fragment,{}):i.jsxs("div",{className:sa.eventOverflowWarning,role:"alert",children:[i.jsx(mm,{size:zt,"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 ih({events:t,eventsDropped:s,emptyState:o,onShowToast:r,sessions:c,currentSessionId:d,environments:u,personas:p,onForward:m,sandboxProxyUrl:g}){const v=y.useRef(null),[b,_]=y.useState(y5),k=D3(),[S,T]=y.useState(!1),[j,w]=y.useState(!1),[C,D]=y.useState(void 0),A=i5({events:t,formatForClipboard:D1}),E=y.useMemo(()=>t.filter(ol).length,[t]),R=y.useMemo(()=>c?c.filter(ce=>g5.has(ce.status)&&ce.id!==d):[],[c,d]),O=y.useMemo(()=>b?[...t].reverse():t,[t,b]),{isAtAnchor:M,scrollToAnchor:$}=e5({scrollRef:v,contentLength:t.length,isReversed:b,paused:A.isSelecting}),Y=()=>{const ce=!b;_(ce);try{localStorage.setItem(M1,ce?"reversed":"default")}catch{}};y.useEffect(()=>{if(!A.isSelecting)return;const ce=me=>{me.key==="Escape"&&!S&&!j&&A.cancelSelection()};return window.addEventListener("keydown",ce),()=>{window.removeEventListener("keydown",ce)}},[A.isSelecting,A.cancelSelection,S,j]);const V=y.useCallback(async()=>{await A.copySelected()&&(r==null||r(`Copied ${A.selectedCount} message${A.selectedCount===1?"":"s"} to clipboard`,"success"))},[A,r]),ee=y.useCallback(()=>[...A.selectedIndices].sort((me,ke)=>me-ke).filter(me=>me<t.length).map(me=>t[me]),[A.selectedIndices,t]),le=y.useCallback(ce=>{if(!ce)return"this session";const me=c==null?void 0:c.find(De=>De.id===ce);if(!me)return ce.slice(0,8);const ke=u==null?void 0:u.find(De=>De.id===me.environmentId);return(ke==null?void 0:ke.displayName)??me.environmentId.slice(0,8)},[c,u]),Z=y.useCallback(async(ce,me)=>{if(!m)return;const ke=le(ce);try{await m(ce,me);const De=A.selectedCount;r==null||r(`Forwarded ${De} message${De===1?"":"s"} to ${ke}`,"success"),A.cancelSelection()}catch{r==null||r("Failed to forward messages","error")}},[m,le,r,A]),ae=y.useCallback(ce=>{T(!1);const me=ee(),ke=le(d),De=s5(ke,me);if(new TextEncoder().encode(De).length>h5){D({sessionId:ce,text:De}),w(!0);return}Z(ce,De).catch(()=>{})},[ee,le,d,Z]),H=y.useCallback(()=>{w(!1),C&&(Z(C.sessionId,C.text).catch(()=>{}),D(void 0))},[C,Z]),B=y.useCallback(()=>{w(!1),D(void 0)},[]),F=k?0:.2,ge=b?-8:8,ne=C?Math.round(new TextEncoder().encode(C.text).length/1024):0;return i.jsxs("div",{className:sa.wrapper,children:[i.jsx("div",{className:sa.toolbar,children:i.jsx(wi,{text:b?"Showing newest first":"Showing oldest first",children:i.jsx("button",{className:sa.directionToggle,onClick:Y,"aria-label":b?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:b?i.jsx(fy,{size:zt,"aria-hidden":"true"}):i.jsx(py,{size:zt,"aria-hidden":"true"})})})}),i.jsxs("div",{ref:v,className:`${sa.scrollContainer} ${A.isSelecting?sa.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&o,i.jsx(b5,{eventsDropped:s}),i.jsx(as,{initial:!1,children:O.map((ce,me)=>{const ke=b?t.length-1-me:me;return i.jsx($t.div,{initial:{opacity:0,y:ge},animate:{opacity:1,y:0},transition:{duration:F,ease:"easeOut"},children:i.jsx(_6,{copyText:n5(ce),isContentBearing:ol(ce),isSelecting:A.isSelecting,isSelected:A.selectedIndices.has(ke),checkboxLabel:v5(ce),onSelect:()=>{A.enterSelectionMode(ke)},onToggle:De=>{A.toggleEvent(ke,De)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:i.jsx(iD,{event:ce,toolUseCtx:ce.toolUseCtx,settled:ce.settled,sandboxProxyUrl:g})})},`${ce.sessionId}-${ce.timestamp}-${ke}`)})})]}),i.jsx(as,{children:A.isSelecting&&i.jsx(E6,{selectedCount:A.selectedCount,totalSelectable:E,onSelectAll:A.selectAll,onDeselectAll:A.deselectAll,onCopy:()=>{V().catch(()=>{})},onForward:m!==void 0?()=>{T(!0)}:void 0,forwardDisabled:R.length===0,onCancel:A.cancelSelection})}),i.jsx(W6,{isOpen:S,sessions:R,environments:u??[],personas:p,onSelect:ae,onCancel:()=>{T(!1)}}),i.jsx(ys,{isOpen:j,title:"Send large message?",description:`This will forward a large message (${ne} KB). Continue?`,confirmLabel:"Send",onConfirm:H,onCancel:B}),i.jsx(as,{children:!M&&i.jsxs($t.button,{className:`${sa.scrollToAnchor} ${b?sa.scrollToAnchorTop:sa.scrollToAnchorBottom}`,onClick:$,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:[b?i.jsx(py,{size:zt,"aria-hidden":"true"}):i.jsx(fy,{size:zt,"aria-hidden":"true"})," New events"]})})]})}function oh(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(""),k=y.useRef(!1),S=d===c,T=y.useCallback(O=>{v(O),_("")},[]),j=y.useCallback(()=>{_("")},[]),w=y.useCallback(()=>{k.current=!1,u==null||u(null),v(""),_("")},[u]),C=y.useCallback(()=>{const O=m?g.trim():g;if(r){const $=r(g);if($){_($);return}}const M=m?s.trim():s;if(O===M){w();return}o(O),w()},[g,s,m,r,o,w]),D=y.useCallback(()=>{k.current=!0,u==null||u(c),v(s),_("")},[c,s,u]),A=y.useCallback(O=>{if(k.current){k.current=!1;return}O.relatedTarget instanceof HTMLElement&&O.relatedTarget.dataset.editAction===c||C()},[c,C]),E=y.useCallback(O=>{O.key==="Escape"?w():O.key==="Enter"&&p&&C()},[w,p,C]),R=(()=>{if(!S)return!1;const O=m?s.trim():s;return(m?g.trim():g)!==O})();return y.useEffect(()=>{!S&&(g!==""||b!=="")&&(v(""),_(""))},[S,g,b]),{isEditing:S,draft:g,error:b,isDirty:R,startEdit:D,cancelEdit:w,save:C,setDraft:T,clearError:j,handleBlur:A,handleKeyDown:E,ignoreInitialBlurRef:k}}const _5="_editFieldWrapper_yuzty_1",x5="_editInput_yuzty_10",k5="_editTextarea_yuzty_42",S5="_editSelect_yuzty_78",T5="_editError_yuzty_111",j5="_editInputInvalid_yuzty_118",w5="_editHint_yuzty_123",N5="_unsavedDot_yuzty_132",C5="_metaValueClickable_yuzty_140",E5="_editButton_yuzty_159",A5="_metaPlaceholder_yuzty_175",D5="_worktreeToggle_yuzty_180",it={editFieldWrapper:_5,editInput:x5,editTextarea:k5,editSelect:S5,editError:T5,editInputInvalid:j5,editHint:w5,unsavedDot:N5,metaValueClickable:C5,editButton:E5,metaPlaceholder:A5,worktreeToggle:D5};function Bt(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="text",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,maxLength:b,ariaLabel:_,"data-testid":k}=t,S=y.useRef(null),T=oh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(T.isEditing){const w=window.setTimeout(()=>{var C;(C=S.current)==null||C.focus()},0);return()=>window.clearTimeout(w)}},[T.isEditing]),c==="create"){const w=D=>{m==null||m(D.target.value)},C=r==null?void 0:r(s);return i.jsxs("div",{className:it.editFieldWrapper,children:[i.jsx("input",{className:`${it.editInput} ${C?it.editInputInvalid:""}`,value:s,onChange:w,maxLength:b,placeholder:v,"aria-label":_,"data-testid":k?`${k}-input`:void 0}),C&&i.jsx("span",{className:it.editError,"data-testid":"edit-error",children:C})]})}if(T.isEditing)return i.jsxs("div",{className:it.editFieldWrapper,children:[i.jsx("input",{ref:S,className:`${it.editInput} ${T.error?it.editInputInvalid:""}`,value:T.draft,onChange:w=>T.setDraft(w.target.value),onBlur:T.handleBlur,onKeyDown:T.handleKeyDown,maxLength:b,placeholder:v,"aria-label":_,"data-testid":k?`${k}-input`:void 0}),T.isDirty&&i.jsx("span",{className:it.unsavedDot,title:"Unsaved changes"}),T.error&&i.jsx("span",{className:it.editError,"data-testid":"edit-error",children:T.error}),i.jsx("span",{className:it.editHint,children:"Enter to save · Esc to cancel"})]});const j=g==null?void 0:g(s);return i.jsxs("span",{role:"button",tabIndex:0,className:it.metaValueClickable,onClick:()=>T.startEdit(),onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),T.startEdit())},title:"Click to edit","aria-label":_,"data-testid":k?`${k}-button`:void 0,children:[j!==void 0?j:s?i.jsx("span",{children:s}):i.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function sm(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="textarea",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":_}=t,k=y.useRef(null),S=oh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(S.isEditing){const j=window.setTimeout(()=>{var w;(w=k.current)==null||w.focus()},0);return()=>window.clearTimeout(j)}},[S.isEditing]),c==="create"){const j=C=>{m==null||m(C.target.value)},w=r==null?void 0:r(s);return i.jsxs("div",{className:it.editFieldWrapper,children:[i.jsx("textarea",{className:`${it.editTextarea} ${w?it.editInputInvalid:""}`,value:s,onChange:j,placeholder:v,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),w&&i.jsx("span",{className:it.editError,"data-testid":"edit-error",children:w})]})}if(S.isEditing)return i.jsxs("div",{className:it.editFieldWrapper,children:[i.jsx("textarea",{ref:k,className:`${it.editTextarea} ${S.error?it.editInputInvalid:""}`,value:S.draft,onChange:j=>S.setDraft(j.target.value),onBlur:S.handleBlur,onKeyDown:S.handleKeyDown,title:b,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),S.isDirty&&i.jsx("span",{className:it.unsavedDot,title:"Unsaved changes"}),S.error&&i.jsx("span",{className:it.editError,"data-testid":"edit-error",children:S.error}),i.jsx("span",{className:it.editHint,children:"Tab to save · Esc to cancel"})]});const T=g==null?void 0:g(s);return i.jsxs("span",{role:"button",tabIndex:0,className:it.metaValueClickable,onClick:()=>S.startEdit(),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),S.startEdit())},title:"Click to edit","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[T!==void 0?T:s?i.jsx("span",{children:s}):i.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function pd(t){var D;const{value:s,onSave:o,mode:r="edit",options:c,fieldId:d="select",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":_}=t,k=y.useRef(null),S=oh({value:s,onSave:o,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(S.isEditing){const A=window.setTimeout(()=>{var E;(E=k.current)==null||E.focus()},0);return()=>window.clearTimeout(A)}},[S.isEditing]);const T=y.useCallback(A=>{const E=A.target.value;S.ignoreInitialBlurRef.current=!1,E!==s&&o(E),S.cancelEdit()},[s,o,S]),j=y.useCallback(A=>{if(S.ignoreInitialBlurRef.current){S.ignoreInitialBlurRef.current=!1;return}A.relatedTarget instanceof HTMLElement&&A.relatedTarget.dataset.editAction===d||S.cancelEdit()},[d,S]);if(r==="create")return i.jsx("select",{className:it.editSelect,value:s,onChange:A=>m==null?void 0:m(A.target.value),"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(A=>i.jsx("option",{value:A.value,children:A.label},A.value))});if(S.isEditing)return i.jsx("select",{ref:k,className:it.editSelect,value:S.draft,onChange:T,onBlur:j,title:b,"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(A=>i.jsx("option",{value:A.value,children:A.label},A.value))});const w=g==null?void 0:g(s),C=(D=c.find(A=>A.value===s))==null?void 0:D.label;return i.jsxs("button",{type:"button",className:it.metaValueClickable,onClick:()=>S.startEdit(),title:"Click to change","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[w!==void 0?w:C?i.jsx("span",{children:C}):i.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function M5(t){const{checked:s,onChange:o,label:r,ariaLabel:c,"data-testid":d}=t;return i.jsxs("label",{className:it.worktreeToggle,"data-testid":d,children:[i.jsx("input",{type:"checkbox",checked:s,onChange:u=>o(u.target.checked),"aria-label":c}),i.jsx("span",{children:r})]})}const R5="_nav_1snmp_1",I5="_searchForm_1snmp_8",O5="_searchInput_1snmp_15",B5="_searchButton_1snmp_33",L5="_clearButton_1snmp_68",z5="_workspaceSelect_1snmp_85",$5="_listHeader_1snmp_99",H5="_nodeList_1snmp_108",P5="_nodeItem_1snmp_116",U5="_indicator_1snmp_129",V5="_label_1snmp_136",q5="_badge_1snmp_145",Qn={nav:R5,searchForm:I5,searchInput:O5,searchButton:B5,clearButton:L5,workspaceSelect:z5,listHeader:$5,nodeList:H5,nodeItem:P5,indicator:U5,label:V5,badge:q5};function G5({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]),b=y.useCallback(()=>{g(""),d()},[d]),_=y.useCallback(S=>{u(S)},[u]),k=y.useCallback(S=>{g(""),p(S)},[p]);return i.jsxs("div",{className:Qn.nav,"data-testid":"knowledge-nav",children:[i.jsxs("form",{className:Qn.searchForm,onSubmit:v,children:[i.jsx("input",{className:Qn.searchInput,type:"text",placeholder:"Search...",value:m,onChange:S=>{g(S.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),i.jsx("button",{type:"submit",className:Qn.searchButton,disabled:o,children:"Go"})]}),r&&i.jsx("button",{type:"button",className:Qn.clearButton,onClick:b,children:"Clear search"}),i.jsxs("select",{className:Qn.workspaceSelect,onChange:S=>{k(S.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[i.jsx("option",{value:"",children:"All workspaces"}),s.map(S=>i.jsx("option",{value:S.id,children:S.name},S.id))]}),i.jsxs("div",{className:Qn.listHeader,children:["Nodes (",t.length,")"]}),i.jsx("ul",{className:Qn.nodeList,children:t.map(S=>i.jsxs("li",{className:Qn.nodeItem,onClick:()=>{_(S.id)},onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),_(S.id))},role:"button",tabIndex:0,children:[i.jsx("span",{className:Qn.indicator,style:{backgroundColor:S.kind==="reference"?"#4A9EFF":S.category==="decision"?"#22C55E":S.category==="concept"?"#A855F7":S.category==="snippet"?"#6B7280":"#EAB308"}}),i.jsx("span",{className:Qn.label,children:S.label}),i.jsx("span",{className:Qn.badge,children:S.kind==="reference"?S.sourceType:S.category})]},S.id))})]})}const F5="_container_bwu10_1",K5="_hamburger_bwu10_33",Z5="_brand_bwu10_49",Y5="_brandLogo_bwu10_68",J5="_info_bwu10_75",W5="_connectionLabel_bwu10_90",X5="_connectionDot_bwu10_103",Q5="_connected_bwu10_106",eI="_disconnected_bwu10_110",tI="_connecting_bwu10_113",Es={container:F5,hamburger:K5,brand:Z5,brandLogo:Y5,info:J5,connectionLabel:W5,connectionDot:X5,connected:Q5,disconnected:eI,connecting:tI},nI={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},sI={connected:Es.connected,connecting:Es.connecting,disconnected:Es.disconnected};function aI({connectionStatus:t,environments:s,sessions:o,onToggleSidebar:r,sidebarOpen:c}){const d=vt(),u=s.length,p=s.filter(v=>v.status==="connected").length,m=o.filter(v=>["running","idle"].includes(v.status)).length,g=nI[t];return i.jsxs("div",{className:Es.container,children:[r&&i.jsx("button",{type:"button",className:Es.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:i.jsx(dj,{size:wt,"aria-hidden":"true"})}),i.jsx(wi,{text:"Home",placement:"bottom",children:i.jsxs("button",{type:"button",className:Es.brand,onClick:()=>d(Po),"data-testid":"statusbar-brand",children:[i.jsx("img",{src:Cd("icon-192x192.png"),alt:"",className:Es.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),i.jsxs("div",{className:Es.info,children:[i.jsxs("span",{"aria-label":g,children:[i.jsx("span",{className:`${Es.connectionDot} ${sI[t]}`,"aria-hidden":"true",children:i.jsx(Ti,{size:w_,fill:"currentColor"})})," ",i.jsx("span",{className:Es.connectionLabel,"aria-hidden":"true",children:g})]}),i.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),i.jsxs("span",{children:[m," active"]})]})]})}const iI="_nav_gx5h3_1",oI="_tab_gx5h3_35",rI="_tabIcon_gx5h3_68",lI="_tabLabel_gx5h3_79",cI="_tabActive_gx5h3_84",dI="_tabEnd_gx5h3_90",To={nav:iI,tab:oI,tabIcon:rI,tabLabel:lI,tabActive:cI,tabEnd:dI},Qc=[{view:"dashboard",label:"Dashboard",icon:i.jsx(WT,{size:wt}),route:Po,testId:"sidebar-tab-dashboard",order:0},{view:"tasks",label:"Tasks",icon:i.jsx(AT,{size:wt}),route:FN,testId:"sidebar-tab-tasks",order:1},{view:"environments",label:"Environments",icon:i.jsx(gj,{size:wt}),route:Ro,testId:"sidebar-tab-environments",order:2},{view:"chat",label:"Root",icon:i.jsx(fj,{size:wt}),route:GN,testId:"sidebar-tab-chat",order:3},{view:"knowledge",label:"Knowledge",icon:i.jsx(kT,{size:wt}),route:J_,testId:"sidebar-tab-knowledge",order:5},{view:"coordination",label:"Coordination",icon:i.jsx(yj,{size:wt}),route:Z_,testId:"sidebar-tab-coordination",order:6},{view:"settings",label:"Settings",icon:i.jsx(Dj,{size:wt}),route:HN,testId:"sidebar-tab-settings",align:"end"}];function uI(t){return t===Po||t==="/"?"dashboard":t.startsWith(Z_)?"coordination":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(J_)?"knowledge":t.startsWith(ki)?"settings":"tasks"}function fI({tabs:t=Qc}){var g;const s=Jt(),o=vt(),r=y.useRef(null),c=uI(s.pathname),d=y.useMemo(()=>{const v=(b,_)=>(b.order??Number.MAX_SAFE_INTEGER)-(_.order??Number.MAX_SAFE_INTEGER);return[...t.filter(b=>b.align!=="end").sort(v),...t.filter(b=>b.align==="end")]},[t]),u=(g=d.find(v=>v.align==="end"))==null?void 0:g.view,p=y.useCallback(v=>{o(v.route)},[o]),m=y.useCallback(v=>{var T,j;const b=(T=r.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!b)return;const _=Array.from(b).findIndex(w=>w===document.activeElement),k=_>=0?_:d.findIndex(w=>w.view===c);let S=k;if(v.key==="ArrowRight"||v.key==="j"||v.key==="J")v.preventDefault(),S=(k+1)%d.length;else if(v.key==="ArrowLeft"||v.key==="k"||v.key==="K")v.preventDefault(),S=(k-1+d.length)%d.length;else if(v.key==="Home")v.preventDefault(),S=0;else if(v.key==="End")v.preventDefault(),S=d.length-1;else return;o(d[S].route),(j=b[S])==null||j.focus()},[c,o,d]);return i.jsx("nav",{className:To.nav,ref:r,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:m,"data-testid":"sidebar-nav",children:d.map(v=>{const b=v.view===c,_=v.view===u;return i.jsx(wi,{text:v.label,placement:"bottom",className:_?To.tabEnd:void 0,children:i.jsxs("button",{role:"tab",type:"button","aria-selected":b,tabIndex:b?0:-1,className:`${To.tab} ${b?To.tabActive:""}`,onClick:()=>p(v),"data-testid":v.testId,"aria-label":v.label,children:[i.jsx("span",{className:To.tabIcon,"aria-hidden":"true",children:v.icon}),i.jsx("span",{className:To.tabLabel,children:v.label})]})},v.view)})})}const pI="_container_pi6ii_1",mI="_content_pi6ii_66",Kb={container:pI,content:mI},hI=320,R1=220,I1=600,O1="grackle-sidebar-width";function gI(){try{const t=localStorage.getItem(O1);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=R1&&s<=I1)return s}}catch{}return hI}function vI(t){try{localStorage.setItem(O1,String(t))}catch{}}function yI({content:t}){const[s]=y.useState(gI),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>=R1&&m<=I1&&vI(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return i.jsx("div",{className:Kb.container,ref:o,"data-testid":"sidebar",style:{width:s},children:i.jsx("div",{className:Kb.content,children:t})})}const bI="_bar_tnfsh_1",_I="_btnPrimary_tnfsh_32",xI="_statusText_tnfsh_85",kI="_statusCompleted_tnfsh_90",SI="_statusFailed_tnfsh_94",TI="_statusBlocked_tnfsh_98",jI="_hintText_tnfsh_103",jt={bar:bI,btnPrimary:_I,statusText:xI,statusCompleted:kI,statusFailed:SI,statusBlocked:TI,hintText:jI};function wI({sessions:t,tasks:s,environments:o}){const r=vt(),c=Jt(),d=nn("/sessions/:sessionId"),u=nn("/tasks/:taskId"),p=nn("/tasks/:taskId/stream"),m=nn("/tasks/:taskId/edit"),g=nn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),v=nn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),b=nn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),_=nn("/sessions/new"),k=nn("/environments/:environmentId/workspaces/:workspaceId"),S=nn("/tasks/new"),T=nn("/chat"),j=nn("/"),w=nn("/settings/*"),C=d==null?void 0:d.params.sessionId,D=(u==null?void 0:u.params.taskId)??(p==null?void 0:p.params.taskId)??(g==null?void 0:g.params.taskId)??(v==null?void 0:v.params.taskId)??(b==null?void 0:b.params.taskId),A=g??v??b,E=(A==null?void 0:A.params.environmentId)??(k==null?void 0:k.params.environmentId),R=c.pathname.startsWith("/environments")&&!k&&!A,O=!!T,M=!!_,$=!!k&&!g&&!v&&!b,Y=!!S;if(!!j&&!M&&!$&&!Y||!!w||(!!m||!!b)||Y||R||M)return i.jsx(i.Fragment,{});if(O)return o.find(ae=>ae.adapterType==="local"&&ae.status==="connected")?i.jsx(i.Fragment,{}):i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Add a local environment to start chatting"})});if($)return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Select a task or click + to create one"})});if(D){const Z=s.find(B=>B.id===D);if(!Z)return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Loading..."})});const ae=new Map(s.map(B=>[B.id,B])),H=Z.dependsOn.some(B=>{const F=ae.get(B);return F!==void 0&&F.status!=="complete"});if(Z.status==="not_started"){const B=H?Z.dependsOn.map(F=>ae.get(F)).filter(F=>F&&F.status!=="complete").map(F=>F.title):[];return i.jsx("div",{className:jt.bar,children:H?i.jsxs("span",{className:jt.statusBlocked,children:["Blocked by: ",B.join(", ")]}):i.jsx("span",{className:jt.hintText,children:"Use the buttons above to start or manage this task"})})}if(Z.status==="working"||Z.status==="paused"){const B=Z.latestSessionId||void 0,F=B?t.find(ne=>ne.id===B):void 0;return F&&F.status!=="stopped"?i.jsx(i.Fragment,{}):i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Waiting for agent..."})})}if(Z.status==="complete")return i.jsxs("div",{className:jt.bar,children:[i.jsx("span",{className:`${jt.statusText} ${jt.statusCompleted}`,children:"Task completed"}),i.jsx("button",{onClick:()=>r(Di(Z.workspaceId,void 0,E)),className:jt.btnPrimary,children:"+ New Task"})]});if(Z.status==="failed")return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:`${jt.statusText} ${jt.statusFailed}`,children:"Task failed"})})}if(C){const Z=t.find(B=>B.id===C),ae=(Z==null?void 0:Z.status)==="stopped";if(Z!==void 0&&!ae)return i.jsx(i.Fragment,{});if(ae)return i.jsxs("div",{className:jt.bar,children:[i.jsxs("span",{className:`${jt.statusText} ${jt.hintText}`,children:["Session ",Z.endReason||Z.status]}),i.jsx("button",{onClick:()=>r(G_(Z.environmentId)),className:jt.btnPrimary,children:"+ New Chat"})]})}return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Loading..."})})}const NI="_nav_14i94_1",CI="_tab_14i94_24",EI="_tabActive_14i94_62",AI="_tabLabel_14i94_75",DI="_statusDot_14i94_81",MI="_pulse_14i94_87",RI="_addButton_14i94_99",II="_empty_14i94_132",Ha={nav:NI,tab:CI,tabActive:EI,tabLabel:AI,statusDot:DI,pulse:MI,addButton:RI,empty:II},OI={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function BI({environments:t}){const s=vt(),o=y.useRef(null),r=nn("/environments/:environmentId"),c=nn("/environments/:environmentId/edit"),d=nn("/environments/:environmentId/workspaces/:workspaceId"),u=nn("/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(_=>{s(Io(_))},[s]),v=y.useCallback(_=>{var w;const k=(w=o.current)==null?void 0:w.querySelectorAll('[role="tab"]');if(!k||k.length===0)return;const S=Array.from(k).findIndex(C=>C===document.activeElement),T=S>=0?S:t.findIndex(C=>C.id===m);let j=T;if(_.key==="ArrowDown"||_.key==="j"||_.key==="J")_.preventDefault(),j=(T+1)%k.length;else if(_.key==="ArrowUp"||_.key==="k"||_.key==="K")_.preventDefault(),j=(T-1+k.length)%k.length;else if(_.key==="Home")_.preventDefault(),j=0;else if(_.key==="End")_.preventDefault(),j=k.length-1;else return;j<t.length&&s(Io(t[j].id)),k[j].focus()},[m,t,s]),b=m??(t.length>0?t[0].id:void 0);return i.jsxs("div",{className:Ha.nav,"data-testid":"environment-nav",children:[i.jsx("nav",{ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(_=>{const k=_.id===m,S=_.id===b,T=OI[_.status]||"var(--text-tertiary)",j=_.status==="connected";return i.jsxs("button",{role:"tab",type:"button","aria-selected":k,tabIndex:S?0:-1,className:`${Ha.tab} ${k?Ha.tabActive:""}`,onClick:()=>g(_.id),"data-testid":"env-nav-item",children:[i.jsx("span",{className:`${Ha.statusDot} ${j?Ha.pulse:""}`,style:{color:T},"aria-hidden":"true",children:i.jsx(Ti,{size:w_,fill:"currentColor"})}),i.jsx("span",{className:Ha.tabLabel,title:_.displayName||_.id,children:_.displayName||_.id})]},_.id)})}),i.jsx("button",{type:"button",className:Ha.addButton,onClick:()=>s(zN),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&i.jsx("div",{className:Ha.empty,children:"No environments yet."})]})}function LI(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 B1({text:t,indices:s,highlightClass:o}){if(!s||s.length===0)return i.jsx(i.Fragment,{children:t});const r=LI(s),c=[];let d=0;for(const[u,p]of r)u>d&&c.push(i.jsx("span",{children:t.slice(d,u)},`p${d}`)),c.push(i.jsx("mark",{className:o,children:t.slice(u,p+1)},`m${u}`)),d=p+1;return d<t.length&&c.push(i.jsx("span",{children:t.slice(d)},`p${d}`)),i.jsx(i.Fragment,{children:c})}function zI(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 $I(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 Uj){c.add(d);const u=o.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=Ka(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=Ka(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const HI="_container_z4i38_1",PI="_header_z4i38_5",UI="_headerActions_z4i38_17",VI="_searchInput_z4i38_23",qI="_searchHighlight_z4i38_56",GI="_groupToggle_z4i38_62",FI="_groupToggleActive_z4i38_89",KI="_addButton_z4i38_93",ZI="_taskRow_z4i38_120",YI="_selected_z4i38_140",JI="_expandArrow_z4i38_150",WI="_expanded_z4i38_157",XI="_leafSpacer_z4i38_161",QI="_taskStatusIcon_z4i38_166",eO="_taskTitle_z4i38_170",tO="_workspaceBadge_z4i38_177",nO="_childCountBadge_z4i38_195",sO="_dependencyBadge_z4i38_208",aO="_blockedBadge_z4i38_220",iO="_addChildButton_z4i38_225",oO="_emptyState_z4i38_268",rO="_statusGroupHeader_z4i38_275",lO="_statusGroupIcon_z4i38_294",cO="_statusGroupLabel_z4i38_298",dO="_statusGroupCount_z4i38_303",Je={container:HI,header:PI,headerActions:UI,searchInput:VI,searchHighlight:qI,groupToggle:GI,groupToggleActive:FI,addButton:KI,taskRow:ZI,selected:YI,expandArrow:JI,expanded:WI,leafSpacer:XI,taskStatusIcon:QI,taskTitle:eO,workspaceBadge:tO,childCountBadge:nO,dependencyBadge:sO,blockedBadge:aO,addChildButton:iO,emptyState:oO,statusGroupHeader:rO,statusGroupIcon:lO,statusGroupLabel:cO,statusGroupCount:dO},uO=[{name:"title",weight:2},{name:"description",weight:1}],L1=16,fO=16,z1="grackle-task-group-by-status";function Zb(){try{return localStorage.getItem(z1)==="true"}catch{return!1}}function pO(t){try{localStorage.setItem(z1,String(t))}catch{}}function mO({group:t,isExpanded:s,onToggle:o,selectedTaskId:r,navigate:c,titleHighlights:d,workspaceNames:u}){return i.jsxs("div",{"data-testid":`status-group-${t.status}`,children:[i.jsxs("div",{className:Je.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:o,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),o())},children:[i.jsx("span",{className:`${Je.expandArrow} ${s?Je.expanded:""}`,"aria-hidden":"true",children:i.jsx(da,{size:Ze})}),i.jsx("span",{className:Je.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),i.jsx("span",{className:Je.statusGroupLabel,children:t.label}),i.jsx("span",{className:Je.statusGroupCount,children:t.tasks.length})]}),i.jsx(as,{children:s&&i.jsx($t.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=Ka(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return i.jsxs("div",{onClick:()=>c(os(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:b=>{b.currentTarget===b.target&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c(os(p.id)))},className:`${Je.taskRow} ${g?Je.selected:""}`,style:{"--task-indent":`${L1}px`},"data-task-id":p.id,children:[i.jsx("span",{className:Je.leafSpacer}),i.jsx("span",{className:Je.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${rl(p.status)}`,children:m.icon}),i.jsx("span",{className:Je.taskTitle,title:p.title,children:i.jsx(B1,{text:p.title,indices:d.get(p.id),highlightClass:Je.searchHighlight})}),v&&i.jsx("span",{className:Je.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function $1({node:t,depth:s,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=Ka(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(w=>u.get(w)!=="complete"),b=o.has(t.id),_=t.children.length>0,k=c===t.id,S=L1+s*fO,j=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{onClick:()=>d(os(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:w=>{w.currentTarget===w.target&&(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),d(os(t.id)))},className:`${Je.taskRow} ${k?Je.selected:""}`,style:{"--task-indent":`${S}px`},"data-task-id":t.id,children:[_&&i.jsx("span",{className:`${Je.expandArrow} ${b?Je.expanded:""}`,role:"button",tabIndex:0,"aria-label":b?"Collapse task":"Expand task",onClick:w=>{w.stopPropagation(),r(t.id)},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),w.stopPropagation(),r(t.id))},children:i.jsx(da,{size:Ze,"aria-hidden":"true"})}),!_&&i.jsx("span",{className:Je.leafSpacer}),i.jsx("span",{className:Je.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${rl(t.status)}`,children:g.icon}),i.jsx("span",{className:Je.taskTitle,title:t.title,children:i.jsx(B1,{text:t.title,indices:p.get(t.id),highlightClass:Je.searchHighlight})}),j&&i.jsx("span",{className:Je.workspaceBadge,title:j,children:j}),_&&i.jsxs("span",{className:Je.childCountBadge,children:[t.children.filter(w=>w.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&i.jsx("span",{className:`${Je.dependencyBadge} ${v?Je.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<I2&&i.jsx(wi,{text:"Add child task",children:i.jsx("button",{onClick:w=>{w.stopPropagation(),d(Di(t.workspaceId,t.id))},"aria-label":"Add child task",className:Je.addChildButton,children:"+"})})]}),i.jsx(as,{children:_&&b&&i.jsx($t.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(w=>i.jsx($1,{node:w,depth:s+1,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},w.id))})})]})}function hO({workspaces:t,tasks:s}){const o=vt(),[r,c]=y.useState(new Set),[d,u]=y.useState(new Set),[p,m]=y.useState(Zb),[g,v]=y.useState(Zb),[b,_]=y.useState(new Map),k=nn("/tasks/:taskId/*"),S=(k==null?void 0:k.params.taskId)!=="new"?k==null?void 0:k.params.taskId:void 0,T=y.useMemo(()=>new Map(s.map(Z=>[Z.id,Z.status])),[s]),j=y.useMemo(()=>new Map(t.map(Z=>[Z.id,Z.name])),[t]),w=()=>{const Z=!p;pO(Z),m(Z),Z&&(v(!0),_(new Map))},C=Z=>{_(ae=>{const H=new Map(ae),B=H.has(Z)?H.get(Z):g;return H.set(Z,!B),H})},D=Z=>b.has(Z)?b.get(Z):g,A=Z=>{c(ae=>{const H=new Set(ae);return H.has(Z)?(H.delete(Z),u(B=>new Set(B).add(Z))):(H.add(Z),u(B=>{const F=new Set(B);return F.delete(Z),F})),H})};y.useEffect(()=>{const Z=new Set(s.filter(ae=>ae.parentTaskId).map(ae=>ae.parentTaskId));Z.size>0&&c(ae=>{const H=new Set(ae);for(const B of Z)d.has(B)||H.add(B);return H})},[s,d]);const[E,R]=y.useState(""),{directMatchTaskIds:O,treeMatchTaskIds:M,titleHighlights:$}=y.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const Z=R2(s,E,uO),ae=new Set(Z.map(ge=>ge.item.id)),H=new Map;for(const ge of Z){const ne=ge.matches.find(ce=>ce.key==="title");ne&&H.set(ge.item.id,ne.indices)}const B=new Set(ae),F=new Map(s.map(ge=>[ge.id,ge]));for(const ge of[...ae]){let ne=F.get(ge);for(;ne!=null&&ne.parentTaskId;)B.add(ne.parentTaskId),ne=F.get(ne.parentTaskId)}return{directMatchTaskIds:ae,treeMatchTaskIds:B,titleHighlights:H}},[E,s]),Y=O!==null,V=Y?p?O:M:null,ee=V?s.filter(Z=>V.has(Z.id)):s,le=p?[]:zI(ee);return i.jsxs("div",{className:Je.container,children:[i.jsxs("div",{className:Je.header,children:[i.jsx("span",{children:"Tasks"}),i.jsxs("div",{className:Je.headerActions,children:[i.jsx(wi,{text:p?"Switch to tree view":"Group tasks by status",children:i.jsx("button",{className:`${Je.groupToggle} ${p?Je.groupToggleActive:""}`,onClick:w,"aria-label":p?"Switch to tree view":"Group tasks by status","aria-pressed":p,"data-testid":"task-group-by-status-toggle",children:i.jsx(oj,{size:zt})})}),i.jsx(wi,{text:"New task",children:i.jsx("button",{className:Je.addButton,onClick:()=>o(Di()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&i.jsx("input",{type:"text",value:E,onChange:Z=>R(Z.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:Je.searchInput,"data-testid":"sidebar-search"}),p?$I(ee,T).map(Z=>i.jsx(mO,{group:Z,isExpanded:D(Z.status),onToggle:()=>C(Z.status),selectedTaskId:S,navigate:o,titleHighlights:$,workspaceNames:j},Z.status)):le.map(Z=>i.jsx($1,{node:Z,depth:0,expandedTasks:r,toggleTask:A,selectedTaskId:S,navigate:o,taskStatusById:T,titleHighlights:$,workspaceNames:j},Z.id)),ee.length===0&&!Y&&i.jsx("div",{className:Je.emptyState,children:"No tasks yet. Click + to create one."}),ee.length===0&&Y&&i.jsx("div",{className:Je.emptyState,children:"No matching tasks"})]})}const gO="_toast_ed2dk_1",vO="_success_ed2dk_18",yO="_icon_ed2dk_22",bO="_error_ed2dk_25",_O="_warning_ed2dk_32",xO="_info_ed2dk_38",kO="_message_ed2dk_53",SO="_close_ed2dk_60",$r={toast:gO,success:vO,icon:yO,error:bO,warning:_O,info:xO,message:kO,close:SO},TO={success:i.jsx(Ci,{size:wt}),error:i.jsx(Is,{size:wt}),warning:i.jsx(mm,{size:wt}),info:i.jsx(pm,{size:wt})};function jO({toast:t,onDismiss:s}){return y.useEffect(()=>{const o=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(o)},[t.id,t.duration,s]),i.jsxs($t.div,{className:`${$r.toast} ${$r[t.variant]}`,role:"status",initial:{opacity:0,y:-16,scale:.94},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.94},transition:{duration:.2,ease:"easeOut"},layout:!0,children:[i.jsx("span",{className:$r.icon,"aria-hidden":"true",children:TO[t.variant]}),i.jsx("span",{className:$r.message,children:t.message}),i.jsx("button",{type:"button",className:$r.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:i.jsx(Is,{size:zt,"aria-hidden":"true"})})]})}const wO="_container_qqse2_1",NO={container:wO};function CO({toasts:t,onDismiss:s}){return i.jsx("div",{className:NO.container,"data-testid":"toast-container",children:i.jsx(as,{children:t.map(o=>i.jsx(jO,{toast:o,onDismiss:s},o.id))})})}const EO="_callout_e5awm_1",AO="_success_e5awm_11",DO="_icon_e5awm_15",MO="_error_e5awm_18",RO="_warning_e5awm_25",IO="_info_e5awm_32",OO="_content_e5awm_48",BO="_close_e5awm_53",Hr={callout:EO,success:AO,icon:DO,error:MO,warning:RO,info:IO,content:OO,close:BO},LO={success:i.jsx(Ci,{size:wt}),error:i.jsx(Is,{size:wt}),warning:i.jsx(mm,{size:wt}),info:i.jsx(pm,{size:wt})};function zO({variant:t="info",children:s,dismissible:o=!1,className:r}){const[c,d]=y.useState(!1);return i.jsx(i.Fragment,{children:!c&&i.jsxs("div",{className:[Hr.callout,Hr[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[i.jsx("span",{className:Hr.icon,"aria-hidden":"true",children:LO[t]}),i.jsx("span",{className:Hr.content,children:s}),o&&i.jsx("button",{type:"button",className:Hr.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:i.jsx(Is,{size:zt,"aria-hidden":"true"})})]})})}function $O({currentVersion:t,latestVersion:s,updateAvailable:o,isDocker:r}){if(!o)return i.jsx(i.Fragment,{});const c=r?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return i.jsx("div",{"data-testid":"update-banner",children:i.jsxs(zO,{variant:"info",dismissible:!0,children:[i.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",t,")."," ","Run: ",i.jsx("code",{children:c})]})})}const HO="_container_m1fsr_1",PO="_heading_m1fsr_7",UO="_section_m1fsr_14",VO="_sectionTitle_m1fsr_26",qO="_sectionDescription_m1fsr_35",GO="_emptyState_m1fsr_41",FO="_tokenList_m1fsr_48",KO="_tokenRow_m1fsr_55",ZO="_tokenBadge_m1fsr_68",YO="_tokenName_m1fsr_83",JO="_tokenTarget_m1fsr_90",WO="_deleteButton_m1fsr_99",XO="_addForm_m1fsr_113",QO="_formRow_m1fsr_119",eB="_input_m1fsr_125",tB="_select_m1fsr_155",nB="_addButton_m1fsr_187",sB="_emptyStateInfo_m1fsr_221",aB="_themeOptions_m1fsr_229",iB="_themeOption_m1fsr_229",oB="_themeOptionSelected_m1fsr_254",rB="_themeOptionHeader_m1fsr_259",lB="_themeOptionLabel_m1fsr_266",cB="_themeOptionDesc_m1fsr_273",dB="_variantToggle_m1fsr_279",uB="_variantButton_m1fsr_286",fB="_variantActive_m1fsr_305",pB="_themeSwatches_m1fsr_311",mB="_themeSwatch_m1fsr_311",hB="_systemToggle_m1fsr_325",gB="_systemToggleHint_m1fsr_341",vB="_themeActive_m1fsr_348",yB="_aboutGrid_m1fsr_354",bB="_aboutItem_m1fsr_360",_B="_aboutLabel_m1fsr_373",xB="_aboutValue_m1fsr_379",kB="_aboutDot_m1fsr_387",SB="_aboutDotConnected_m1fsr_394",TB="_aboutDotDisconnected_m1fsr_398",jB="_aboutDotConnecting_m1fsr_402",fe={container:HO,heading:PO,section:UO,sectionTitle:VO,sectionDescription:qO,emptyState:GO,tokenList:FO,tokenRow:KO,tokenBadge:ZO,tokenName:YO,tokenTarget:JO,deleteButton:WO,addForm:XO,formRow:QO,input:eB,select:tB,addButton:nB,emptyStateInfo:sB,themeOptions:aB,themeOption:iB,themeOptionSelected:oB,themeOptionHeader:rB,themeOptionLabel:lB,themeOptionDesc:cB,variantToggle:dB,variantButton:uB,variantActive:fB,themeSwatches:pB,themeSwatch:mB,systemToggle:hB,systemToggleHint:gB,themeActive:vB,aboutGrid:yB,aboutItem:bB,aboutLabel:_B,aboutValue:xB,aboutDot:kB,aboutDotConnected:SB,aboutDotDisconnected:TB,aboutDotConnecting:jB},wB=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function NB({tokens:t,onSetToken:s,onDeleteToken:o,onShowToast:r}){const[c,d]=y.useState(""),[u,p]=y.useState(""),[m,g]=y.useState("env_var"),[v,b]=y.useState(""),[_,k]=y.useState(null),S=w=>{if(w.preventDefault(),!c||!u)return;const C=m==="env_var"?v||c.toUpperCase()+"_TOKEN":"";s(c,u,m,C,m==="file"?v:""),r==null||r("Token saved successfully","success"),d(""),p(""),b("")},T=w=>{k(w)},j=()=>{_&&(o(_),r==null||r("Token deleted","info")),k(null)};return i.jsxs(i.Fragment,{children:[i.jsx(ys,{isOpen:_!==null,title:"Delete Token?",description:_?`"${_}" will be permanently removed.`:void 0,onConfirm:j,onCancel:()=>k(null)}),i.jsxs("section",{className:fe.section,children:[i.jsx("h3",{className:fe.sectionTitle,children:"Tokens"}),i.jsx("p",{className:fe.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?i.jsx("div",{className:fe.emptyStateInfo,children:"Add your first API token to enable service integrations."}):i.jsx("div",{className:fe.tokenList,children:t.map(w=>i.jsxs("div",{className:fe.tokenRow,children:[i.jsx("span",{className:fe.tokenBadge,children:w.tokenType}),i.jsx("span",{className:fe.tokenName,children:w.name}),i.jsx("span",{className:fe.tokenTarget,children:w.tokenType==="env_var"?w.envVar:w.filePath}),i.jsx("button",{className:fe.deleteButton,onClick:()=>T(w.name),title:`Delete ${w.name}`,"aria-label":`Delete ${w.name}`,children:i.jsx(Is,{size:zt,"aria-hidden":"true"})})]},w.name))}),i.jsxs("form",{className:fe.addForm,onSubmit:S,children:[i.jsxs("div",{className:fe.formRow,children:[i.jsx("input",{className:fe.input,type:"text",placeholder:"Token name",value:c,onChange:w=>d(w.target.value)}),i.jsx("input",{className:fe.input,type:"password",placeholder:"Value",value:u,onChange:w=>p(w.target.value)})]}),i.jsxs("div",{className:fe.formRow,children:[i.jsx("select",{className:fe.select,value:m,onChange:w=>g(w.target.value),children:wB.map(w=>i.jsx("option",{value:w.value,children:w.label},w.value))}),i.jsx("input",{className:fe.input,type:"text",placeholder:m==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:v,onChange:w=>b(w.target.value)}),i.jsx("button",{className:fe.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const Ed=[{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"]}],H1=new Set(Ed.map(t=>t.id)),Yb="grackle";function am(t){return Ed.find(s=>s.id===t)}function CB({themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c}){return i.jsxs("section",{className:fe.section,children:[i.jsx("h3",{className:fe.sectionTitle,children:"Appearance"}),i.jsx("p",{className:fe.sectionDescription,children:"Choose how Grackle looks across the app."}),i.jsx("div",{className:fe.themeOptions,children:Ed.filter(d=>!d.hidden).map(d=>{const u=!!(d.variantLightId&&d.variantDarkId),p=u?t===d.id||t===d.variantLightId||t===d.variantDarkId:t===d.id,m=u&&s===d.variantLightId;return i.jsxs("button",{type:"button",className:`${fe.themeOption} ${p?fe.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>o(d.id),children:[i.jsxs("span",{className:fe.themeOptionHeader,children:[i.jsxs("span",{children:[i.jsx("span",{className:fe.themeOptionLabel,children:d.label}),i.jsx("span",{className:fe.themeOptionDesc,children:d.description})]}),u&&i.jsxs("span",{className:fe.variantToggle,children:[i.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${p&&m?fe.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantLightId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantLightId))},"aria-label":"Light variant","aria-pressed":p&&m,children:"☼"}),i.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${p&&!m?fe.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantDarkId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantDarkId))},"aria-label":"Dark variant","aria-pressed":p&&!m,children:"☾"})]})]}),d.swatches&&i.jsx("span",{className:fe.themeSwatches,children:d.swatches.map((g,v)=>i.jsx("span",{className:fe.themeSwatch,style:{background:g}},v))})]},d.id)})}),i.jsxs("label",{className:fe.systemToggle,children:[i.jsx("input",{type:"checkbox",checked:r,onChange:d=>c(d.target.checked)}),i.jsx("span",{children:"Match system light/dark preference"})]}),i.jsx("p",{className:fe.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),i.jsxs("p",{className:fe.themeActive,children:["Active theme: ",i.jsx("strong",{children:s})]})]})}const EB={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},AB={connected:fe.aboutDotConnected,connecting:fe.aboutDotConnecting,disconnected:fe.aboutDotDisconnected};function DB({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 i.jsxs("section",{className:fe.section,"data-testid":"about-panel",children:[i.jsx("h3",{className:fe.sectionTitle,children:"About"}),i.jsx("p",{className:fe.sectionDescription,children:"Connection status and application information."}),i.jsxs("div",{className:fe.aboutGrid,children:[i.jsxs("div",{className:fe.aboutItem,children:[i.jsx("span",{className:fe.aboutLabel,children:"Connection"}),i.jsxs("span",{className:fe.aboutValue,children:[i.jsx("span",{className:`${fe.aboutDot} ${AB[t]}`}),EB[t]]})]}),i.jsxs("div",{className:fe.aboutItem,children:[i.jsx("span",{className:fe.aboutLabel,children:"Environments"}),i.jsxs("span",{className:fe.aboutValue,children:[r,"/",c," connected"]})]}),i.jsxs("div",{className:fe.aboutItem,children:[i.jsx("span",{className:fe.aboutLabel,children:"Active Sessions"}),i.jsx("span",{className:fe.aboutValue,children:d})]}),i.jsxs("div",{className:fe.aboutItem,children:[i.jsx("span",{className:fe.aboutLabel,children:"Version"}),i.jsx("span",{className:fe.aboutValue,children:"0.118.0"})]})]})]})}const MB="_container_cddyd_1",RB="_header_cddyd_8",IB="_headerTitle_cddyd_35",OB="_badge_cddyd_44",BB="_headerActions_cddyd_54",LB="_body_cddyd_61",zB="_formContent_cddyd_73",$B="_section_cddyd_85",HB="_label_cddyd_91",PB="_titleInput_cddyd_98",UB="_descriptionTextarea_cddyd_131",VB="_parentContext_cddyd_167",qB="_parentLabel_cddyd_175",GB="_parentName_cddyd_182",FB="_personaSelect_cddyd_186",KB="_depList_cddyd_220",ZB="_depItem_cddyd_226",YB="_depItemSelected_cddyd_248",JB="_noDeps_cddyd_252",WB="_btnPrimary_cddyd_258",XB="_btnGhost_cddyd_289",at={container:MB,header:RB,headerTitle:IB,badge:OB,headerActions:BB,body:LB,formContent:zB,section:$B,label:HB,titleInput:PB,descriptionTextarea:UB,parentContext:VB,parentLabel:qB,parentName:GB,personaSelect:FB,depList:KB,depItem:ZB,depItemSelected:YB,noDeps:JB,btnPrimary:WB,btnGhost:XB};function P1({mode:t,taskId:s,workspaceId:o,parentTaskId:r,environmentId:c,tasks:d,workspaces:u,personas:p,onCreateTask:m,onUpdateTask:g,onEditDone:v,onShowToast:b}){const _=vt(),k=t==="edit",S=k&&s?d.find(_e=>_e.id===s):void 0,T=k?(S==null?void 0:S.workspaceId)??"":o??"",[j,w]=y.useState(T),C=T||j,D=u.find(_e=>_e.id===C),A=c??(D==null?void 0:D.linkedEnvironmentIds[0]),E=!k&&!o,R=k?(S==null?void 0:S.parentTaskId)??"":r??"",O=R?d.find(_e=>_e.id===R):void 0,[M,$]=y.useState((S==null?void 0:S.title)??""),[Y,V]=y.useState((S==null?void 0:S.description)??""),[ee,le]=y.useState((S==null?void 0:S.dependsOn)??[]),[Z,ae]=y.useState((S==null?void 0:S.defaultPersonaId)??""),[H,B]=y.useState((S==null?void 0:S.canDecompose)??!1),[F,ge]=y.useState(!1),ne=y.useRef(!1);y.useEffect(()=>{k&&S&&!ne.current&&(ne.current=!0,$(S.title),V(S.description),le(S.dependsOn),ae(S.defaultPersonaId),B(S.canDecompose))},[k,S]);const ce=d.filter(_e=>_e.workspaceId===C&&(!k||_e.id!==s)&&_e.id!==R),me=M.trim().length>0&&(!k||S!==void 0)&&C.length>0,ke=_e=>{le(Oe=>Oe.includes(_e)?Oe.filter(Ht=>Ht!==_e):[...Oe,_e])},De=()=>{!me||F||k&&S===void 0||(k&&s?(g(s,M.trim(),Y,ee,Z),b==null||b("Task updated","success"),v?v():_(os(s,void 0,C,A),{replace:!0})):(ge(!0),m(C,M.trim(),Y,ee.length>0?ee:void 0,R||void 0,Z,H,()=>{b==null||b("Task created","success"),_(o?ji(o,A):"/tasks",{replace:!0})},_e=>{b==null||b(_e,"error"),ge(!1)})))},ot=()=>{if(v){v();return}_(k&&s?os(s,void 0,C,A):o?ji(o,A):"/tasks")},yt=k?"edit task":R?"child task":"new task";return i.jsxs("div",{className:at.container,children:[i.jsxs("div",{className:at.header,children:[i.jsxs("div",{className:at.headerTitle,children:[i.jsx("span",{className:at.badge,children:yt}),O&&i.jsxs("span",{className:at.parentContext,children:[i.jsx("span",{className:at.parentLabel,children:"Child of"}),i.jsx("span",{className:at.parentName,children:O.title})]})]}),i.jsxs("div",{className:at.headerActions,children:[i.jsx("button",{onClick:De,disabled:!me||F,className:at.btnPrimary,"data-testid":"task-edit-save",children:F?"Creating…":k?"Save Changes":"Create"}),i.jsx("button",{onClick:ot,className:at.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:at.body,children:i.jsxs("div",{className:at.formContent,children:[E&&i.jsxs("div",{className:at.section,children:[i.jsx("label",{className:at.label,htmlFor:"task-edit-workspace",children:"Workspace"}),i.jsxs("select",{id:"task-edit-workspace",value:j,onChange:_e=>w(_e.target.value),className:at.personaSelect,"data-testid":"task-edit-workspace",children:[i.jsx("option",{value:"",children:"Select a workspace..."}),u.map(_e=>i.jsx("option",{value:_e.id,children:_e.name},_e.id))]})]}),i.jsxs("div",{className:at.section,children:[i.jsx("label",{className:at.label,htmlFor:"task-edit-title",children:"Title"}),i.jsx("input",{id:"task-edit-title",type:"text",value:M,onChange:_e=>$(_e.target.value),placeholder:"Task title...",autoFocus:!0,className:at.titleInput,"data-testid":"task-edit-title",onKeyDown:_e=>{_e.key==="Enter"&&me&&De()}})]}),i.jsxs("div",{className:at.section,children:[i.jsx("label",{className:at.label,htmlFor:"task-edit-description",children:"Description"}),i.jsx("textarea",{id:"task-edit-description",value:Y,onChange:_e=>V(_e.target.value),placeholder:"Describe the task... (markdown supported)",className:at.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),i.jsxs("div",{className:at.section,children:[i.jsx("label",{className:at.label,htmlFor:"task-edit-persona",children:"Default Persona"}),i.jsxs("select",{id:"task-edit-persona",value:Z,onChange:_e=>ae(_e.target.value),className:at.personaSelect,"data-testid":"task-edit-persona",children:[i.jsx("option",{value:"",children:"(Inherit)"}),p.map(_e=>i.jsx("option",{value:_e.id,children:_e.name},_e.id))]})]}),!k&&i.jsx("div",{className:at.section,children:i.jsxs("label",{className:at.depItem,"data-testid":"task-edit-can-decompose",children:[i.jsx("input",{type:"checkbox",checked:H,onChange:_e=>B(_e.target.checked)}),"Can spawn subtasks"]})}),i.jsxs("div",{className:at.section,children:[i.jsx("div",{className:at.label,children:"Dependencies"}),ce.length===0?i.jsx("div",{className:at.noDeps,children:"No other tasks in this workspace"}):i.jsx("div",{className:at.depList,children:ce.map(_e=>{const Oe=ee.includes(_e.id);return i.jsxs("label",{className:`${at.depItem} ${Oe?at.depItemSelected:""}`,"data-testid":`dep-option-${_e.id}`,children:[i.jsx("input",{type:"checkbox",checked:Oe,onChange:()=>ke(_e.id)}),_e.title,i.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",_e.status,")"]})]},_e.id)})})]})]})})]})}const QB="_actionButtons_1rjka_1",eL="_btnPrimary_1rjka_8",tL="_btnDanger_1rjka_39",nL="_btnGhost_1rjka_78",Zt={actionButtons:QB,btnPrimary:eL,btnDanger:tL,btnGhost:nL};function sL({task:t,sessionId:s,isBlocked:o,onStart:r,onResume:c,onStop:d,onPause:u,onDelete:p,onEdit:m}){if(t.status==="not_started")return o?i.jsxs("div",{className:Zt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:m,className:Zt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Zt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):i.jsxs("div",{className:Zt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{"data-testid":"task-header-start",onClick:r,className:Zt.btnPrimary,children:"Start"}),i.jsx("button",{onClick:m,className:Zt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Zt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return i.jsxs("div",{className:Zt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Zt.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:u,disabled:!s,className:Zt.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused")return i.jsxs("div",{className:Zt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Zt.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:c,className:Zt.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),i.jsx("button",{onClick:p,className:Zt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="complete")return i.jsx("div",{className:Zt.actionButtons,"data-testid":"task-action-buttons",children:i.jsx("button",{onClick:p,className:Zt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return i.jsxs("div",{className:Zt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:r,className:Zt.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),i.jsx("button",{onClick:p,className:Zt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const aL="_workpadSection_y8nj9_1",iL="_workpadLabel_y8nj9_9",oL="_workpadStatus_y8nj9_17",rL="_workpadSummary_y8nj9_23",lL="_workpadExtra_y8nj9_29",Pa={workpadSection:aL,workpadLabel:iL,workpadStatus:oL,workpadSummary:rL,workpadExtra:lL};function cL({workpad:t}){if(!t)return;let s;try{const o=JSON.parse(t);if(o==null||typeof o!="object"||Array.isArray(o))return;s=o}catch{return i.jsxs("div",{className:Pa.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:Pa.workpadLabel,children:"Workpad"}),i.jsx("div",{className:Pa.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return i.jsxs("div",{className:Pa.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:Pa.workpadLabel,children:"Workpad"}),s.status&&i.jsx("div",{className:Pa.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&i.jsx("div",{className:Pa.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&i.jsx("div",{className:Pa.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const dL="_overviewDashboard_r05qm_1",uL="_overviewHero_r05qm_7",fL="_statusBadge_r05qm_14",pL="_statusPending_r05qm_26",mL="_statusAssigned_r05qm_31",hL="_statusInProgress_r05qm_36",gL="_statusReview_r05qm_41",vL="_statusDone_r05qm_46",yL="_statusFailed_r05qm_51",bL="_statusWaitingInput_r05qm_56",_L="_overviewBranchPill_r05qm_61",xL="_branchLink_r05qm_76",kL="_overviewSection_r05qm_87",SL="_overviewLabel_r05qm_93",TL="_overviewValue_r05qm_100",jL="_overviewMuted_r05qm_105",wL="_overviewMarkdown_r05qm_111",NL="_envRow_r05qm_180",CL="_envDot_r05qm_186",EL="_envDotGreen_r05qm_193",AL="_envDotYellow_r05qm_197",DL="_envDotRed_r05qm_201",ML="_envDotGray_r05qm_205",RL="_depList_r05qm_209",IL="_depItem_r05qm_215",OL="_depBlocked_r05qm_222",BL="_depDone_r05qm_226",LL="_timeline_r05qm_230",zL="_timelineRow_r05qm_236",$L="_timelineKey_r05qm_243",HL="_timelineValue_r05qm_249",PL="_timelineDelta_r05qm_253",UL="_reviewNotes_r05qm_264",be={overviewDashboard:dL,overviewHero:uL,statusBadge:fL,statusPending:pL,statusAssigned:mL,statusInProgress:hL,statusReview:gL,statusDone:vL,statusFailed:yL,statusWaitingInput:bL,overviewBranchPill:_L,branchLink:xL,overviewSection:kL,overviewLabel:SL,overviewValue:TL,overviewMuted:jL,overviewMarkdown:wL,envRow:NL,envDot:CL,envDotGreen:EL,envDotYellow:AL,envDotRed:DL,envDotGray:ML,depList:RL,depItem:IL,depBlocked:OL,depDone:BL,timeline:LL,timelineRow:zL,timelineKey:$L,timelineValue:HL,timelineDelta:PL,reviewNotes:UL};function Hc(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 kp(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 Jb(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?be.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?be.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?be.envDotRed:be.envDotGray}function VL({status:t}){const s=Ka(t),o=Pj(t);return i.jsx("span",{className:`${be.statusBadge} ${be[o]??be.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function qL({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,b=r.find(S=>S.id===t.workspaceId),_=o.find(S=>S.id===d),k=t.branch&&(b!=null&&b.repoUrl)?`${b.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return i.jsxs("div",{className:be.overviewDashboard,"data-testid":"task-overview-panel",children:[i.jsxs("div",{className:be.overviewHero,children:[i.jsx(VL,{status:t.status}),t.branch&&i.jsx("span",{className:be.overviewBranchPill,"data-testid":"task-overview-branch",children:k?i.jsxs("a",{href:k,target:"_blank",rel:"noreferrer noopener",className:be.branchLink,children:["🔗"," ",t.branch]}):i.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&i.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-description",children:[i.jsx("div",{className:be.overviewLabel,children:"Description"}),i.jsx("div",{className:be.overviewMarkdown,children:i.jsx(um,{remarkPlugins:[fm],children:t.description})})]}),t.workpad&&i.jsx(cL,{workpad:t.workpad}),i.jsxs("div",{className:be.overviewSection,children:[i.jsx("div",{className:be.overviewLabel,children:"Environment"}),g&&v?i.jsxs("div",{className:be.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${be.envDot} ${Jb(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),i.jsx("span",{className:be.overviewValue,children:v.displayName})]}):_?i.jsxs("div",{className:be.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${be.envDot} ${Jb(_.status)}`,title:_.status,"aria-label":`Status: ${_.status}`,role:"img"}),i.jsx("span",{className:be.overviewValue,children:_.displayName}),i.jsx("span",{className:be.overviewMuted,children:"(workspace default)"})]}):i.jsx("div",{className:be.overviewMuted,children:"Set in workspace settings"})]}),i.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-dependencies",children:[i.jsx("div",{className:be.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?i.jsx("div",{className:be.overviewMuted,children:"None"}):i.jsx("div",{className:be.depList,children:t.dependsOn.map(S=>{const T=s.get(S),j=(T==null?void 0:T.status)==="complete";return i.jsxs("div",{className:`${be.depItem} ${j?be.depDone:be.depBlocked}`,children:[i.jsx("span",{children:j?"✓":"○"}),i.jsx("span",{children:(T==null?void 0:T.title)??S})]},S)})})]}),i.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-timeline",children:[i.jsx("div",{className:be.overviewLabel,children:"Timeline"}),i.jsxs("div",{className:be.timeline,children:[t.createdAt&&i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Created"}),i.jsx("span",{className:be.timelineValue,children:Hc(t.createdAt)})]}),t.assignedAt&&(()=>{const S=kp(t.createdAt,t.assignedAt);return i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Assigned"}),i.jsx("span",{className:be.timelineValue,children:Hc(t.assignedAt)}),S!==void 0&&i.jsx("span",{className:be.timelineDelta,children:S})]})})(),t.startedAt&&(()=>{const S=kp(t.assignedAt??t.createdAt,t.startedAt);return i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Started"}),i.jsx("span",{className:be.timelineValue,children:Hc(t.startedAt)}),S!==void 0&&i.jsx("span",{className:be.timelineDelta,children:S})]})})(),t.completedAt&&(()=>{const S=kp(t.startedAt,t.completedAt);return i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Completed"}),i.jsx("span",{className:be.timelineValue,children:Hc(t.completedAt)}),S!==void 0&&i.jsx("span",{className:be.timelineDelta,children:S})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&i.jsx("div",{className:be.overviewMuted,children:"No timing data"})]})]}),u&&u.costMillicents>0&&i.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-usage",children:[i.jsx("div",{className:be.overviewLabel,children:"Usage"}),i.jsxs("div",{className:be.timeline,children:[i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Cost"}),i.jsx("span",{className:be.timelineValue,children:As(u.costMillicents)}),i.jsxs("span",{className:be.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costMillicents>u.costMillicents&&i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Total (incl. subtasks)"}),i.jsx("span",{className:be.timelineValue,children:As(p.costMillicents)}),i.jsxs("span",{className:be.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),(t.tokenBudget>0||t.costBudgetMillicents>0)&&i.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-budget",children:[i.jsx("div",{className:be.overviewLabel,children:"Budget"}),i.jsxs("div",{className:be.timeline,children:[t.tokenBudget>0&&i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Tokens"}),i.jsxs("span",{className:be.timelineValue,children:[Oo(((u==null?void 0:u.inputTokens)??0)+((u==null?void 0:u.outputTokens)??0))," / ",Oo(t.tokenBudget)]})]}),t.costBudgetMillicents>0&&i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Cost"}),i.jsxs("span",{className:be.timelineValue,children:[As((u==null?void 0:u.costMillicents)??0)," / ",As(t.costBudgetMillicents)]})]})]})]}),t.reviewNotes&&i.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-review-notes",children:[i.jsx("div",{className:be.overviewLabel,children:"Review Notes"}),i.jsx("div",{className:be.reviewNotes,children:t.reviewNotes})]})]})}function GL({plugins:t,loading:s,onSetPluginEnabled:o}){return i.jsxs("div",{className:fe.container,"data-testid":"plugins-panel",children:[i.jsx("h2",{className:fe.heading,children:"Plugins"}),i.jsxs("div",{className:fe.section,children:[i.jsx("p",{className:fe.sectionDescription,children:"Enable or disable optional Grackle plugins. A server restart is required for changes to take effect."}),s&&i.jsx("p",{className:fe.emptyState,children:"Loading plugins..."}),!s&&t.length===0&&i.jsx("p",{className:fe.emptyState,children:"No plugins found."}),!s&&t.map(r=>{const c=r.enabled!==r.loaded;return i.jsxs("div",{className:fe.tokenRow,"data-testid":`plugin-row-${r.name}`,children:[i.jsxs("div",{style:{flex:1},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[i.jsx("span",{className:fe.tokenName,children:r.name}),r.required&&i.jsx("span",{className:fe.tokenBadge,title:"Required — cannot be disabled",children:"required"})]}),i.jsx("div",{className:fe.tokenTarget,children:r.description}),c&&i.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"})]}),i.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:i.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 FL({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),[k,S]=y.useState(!1),[T,j]=y.useState(!1),[w,C]=y.useState(null),D=t.find(M=>M.id===w),A=async M=>{if(M.preventDefault(),!(!p.trim()||!g.trim())){S(!0);try{await o(p.trim(),g.trim(),"",b),u==null||u("GitHub account added","success"),m(""),v(""),_(!1)}catch($){const Y=$ instanceof Error?$.message:"Failed to add account";u==null||u(Y,"error")}finally{S(!1)}}},E=async M=>{try{await r(M,{isDefault:!0}),u==null||u("Default account updated","success")}catch($){const Y=$ instanceof Error?$.message:"Failed to update account";u==null||u(Y,"error")}},R=async()=>{if(w)try{await c(w),u==null||u("GitHub account removed","info")}catch(M){const $=M instanceof Error?M.message:"Failed to remove account";u==null||u($,"error")}finally{C(null)}},O=async()=>{j(!0);try{const M=await d();M.imported>0?u==null||u(`Imported ${M.imported} account(s): ${M.usernames.join(", ")}`,"success"):u==null||u("No new accounts to import","info")}catch(M){const $=M instanceof Error?M.message:"Import failed";u==null||u($,"error")}finally{j(!1)}};return i.jsxs(i.Fragment,{children:[i.jsx(ys,{isOpen:w!==null,title:"Remove GitHub Account?",description:D?`"${D.label}"${D.username?` (@${D.username})`:""} will be permanently removed.`:void 0,onConfirm:()=>{R().catch(()=>{})},onCancel:()=>C(null)}),i.jsxs("section",{className:fe.section,"data-testid":"github-accounts-panel",children:[i.jsx("h3",{className:fe.sectionTitle,children:"GitHub Accounts"}),i.jsx("p",{className:fe.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?i.jsx("div",{className:fe.emptyState,children:"Loading..."}):t.length===0?i.jsx("div",{className:fe.emptyStateInfo,children:"No GitHub accounts registered. Add one below or import from the gh CLI."}):i.jsx("div",{className:fe.tokenList,children:t.map(M=>i.jsxs("div",{className:fe.tokenRow,"data-testid":`github-account-row-${M.id}`,children:[M.isDefault&&i.jsx("span",{className:fe.tokenBadge,title:"Default account",children:"default"}),i.jsx("span",{className:fe.tokenName,children:M.label}),M.username&&i.jsxs("span",{className:fe.tokenTarget,children:["@",M.username]}),!M.isDefault&&i.jsx("button",{className:fe.deleteButton,onClick:()=>{E(M.id).catch(()=>{})},title:"Set as default","aria-label":`Set ${M.label} as default`,"data-testid":`github-account-set-default-${M.id}`,children:i.jsx(Oj,{size:zt,"aria-hidden":"true"})}),i.jsx("button",{className:fe.deleteButton,onClick:()=>C(M.id),title:`Remove ${M.label}`,"aria-label":`Remove ${M.label}`,"data-testid":`github-account-remove-${M.id}`,children:i.jsx(Is,{size:zt,"aria-hidden":"true"})})]},M.id))}),i.jsxs("form",{className:fe.addForm,onSubmit:M=>{A(M).catch(()=>{})},children:[i.jsxs("div",{className:fe.formRow,children:[i.jsx("input",{className:fe.input,type:"text",placeholder:"Label (e.g. personal, work)",value:p,onChange:M=>m(M.target.value),"data-testid":"github-account-label-input"}),i.jsx("input",{className:fe.input,type:"password",placeholder:"Personal access token",value:g,onChange:M=>v(M.target.value),"data-testid":"github-account-token-input"})]}),i.jsxs("div",{className:fe.formRow,children:[i.jsxs("label",{className:fe.tokenTarget,style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[i.jsx("input",{type:"checkbox",checked:b,onChange:M=>_(M.target.checked),"data-testid":"github-account-default-checkbox"}),"Set as default"]}),i.jsx("button",{className:fe.addButton,type:"submit",disabled:!p.trim()||!g.trim()||k,"data-testid":"github-account-add-button",children:k?"Adding...":"Add Account"}),i.jsx("button",{className:fe.addButton,type:"button",onClick:()=>{O().catch(()=>{})},disabled:T,"data-testid":"github-account-import-button",children:T?"Importing...":"Import from gh CLI"})]})]})]})]})}const KL="_container_legrg_1",ZL="_header_legrg_8",YL="_headerTitle_legrg_35",JL="_badge_legrg_44",WL="_headerActions_legrg_54",XL="_body_legrg_61",QL="_formContent_legrg_73",e8="_section_legrg_85",t8="_label_legrg_91",n8="_nameInput_legrg_98",s8="_fieldInput_legrg_131",a8="_adapterSelect_legrg_164",i8="_readOnlyValue_legrg_198",o8="_codespaceSection_legrg_204",r8="_codespaceActions_legrg_210",l8="_creatingHint_legrg_216",c8="_errorHint_legrg_222",d8="_btnPrimary_legrg_235",u8="_btnGhost_legrg_266",oe={container:KL,header:ZL,headerTitle:YL,badge:JL,headerActions:WL,body:XL,formContent:QL,section:e8,label:t8,nameInput:n8,fieldInput:s8,adapterSelect:a8,readOnlyValue:i8,codespaceSection:o8,codespaceActions:r8,creatingHint:l8,errorHint:c8,btnPrimary:d8,btnGhost:u8},ed=1,td=65535;function Sp(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=ed&&s<=td}function Tp(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function f8({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(""),[k,S]=y.useState("");return g==="create"?i.jsxs("div",{className:oe.codespaceSection,children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Repository"}),i.jsx("input",{type:"text",value:b,onChange:T=>_(T.target.value),placeholder:"owner/repo",className:oe.fieldInput,"data-testid":"env-codespace-repo"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Machine Type"}),i.jsx("input",{type:"text",value:k,onChange:T=>S(T.target.value),placeholder:"Machine type (optional)...",className:oe.fieldInput,"data-testid":"env-codespace-machine"})]}),i.jsxs("div",{className:oe.codespaceActions,children:[i.jsx("button",{onClick:()=>{b.trim()&&(m(b.trim(),k.trim()||void 0),v("pick"),_(""),S(""))},disabled:!b.trim(),className:oe.btnPrimary,children:"Create"}),i.jsx("button",{onClick:()=>{v("pick"),_(""),S("")},className:oe.btnGhost,children:"Cancel"})]})]}):i.jsx("div",{className:oe.codespaceSection,children:i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Codespace"}),!u&&i.jsxs("select",{value:t,onChange:T=>{T.target.value==="__create__"?(v("create"),s("")):(s(T.target.value),T.target.value&&!o.trim()&&r(T.target.value))},disabled:p,className:oe.adapterSelect,"data-testid":"env-codespace-select",children:[i.jsx("option",{value:"",children:"Select a codespace..."}),c.map(T=>i.jsxs("option",{value:T.name,children:[T.name," (",T.repository,") — ",T.state]},T.name)),i.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&i.jsx("span",{className:oe.creatingHint,children:"Creating codespace..."}),u&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:oe.errorHint,children:u}),i.jsx("input",{type:"text",value:t,onChange:T=>s(T.target.value),placeholder:"Or enter codespace name manually...",className:oe.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&i.jsx("span",{className:oe.errorHint,children:d})]})})}function U1({mode:t,environmentId:s,environments:o,githubAccounts:r,onAddEnvironment:c,onUpdateEnvironment:d,onListCodespaces:u,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:b,onListDockerContainers:_,dockerContainers:k,dockerContainersError:S,onShowToast:T}){const j=vt(),w=t==="edit",C=w&&s?o.find(re=>re.id===s):void 0,[D,A]=y.useState(""),[E,R]=y.useState("local"),[O,M]=y.useState(""),[$,Y]=y.useState(""),[V,ee]=y.useState(""),[le,Z]=y.useState(""),[ae,H]=y.useState(""),[B,F]=y.useState(""),[ge,ne]=y.useState(""),[ce,me]=y.useState(""),[ke,De]=y.useState("create"),[ot,yt]=y.useState(""),[_e,Oe]=y.useState(null),Ht=y.useCallback(()=>{const re={};if(E==="local"){if(O.trim()&&(re.host=O.trim()),$.trim()){const ve=Number($);Number.isInteger(ve)&&(re.port=ve)}}else if(E==="ssh"){if(re.host=O.trim(),V.trim()&&(re.user=V.trim()),$.trim()){const ve=Number($);Number.isInteger(ve)&&(re.sshPort=ve)}le.trim()&&(re.identityFile=le.trim())}else E==="docker"?ke==="attach"?ot.trim()&&(re.attach=ot.trim()):(ae.trim()&&(re.image=ae.trim()),B.trim()&&(re.repo=B.trim())):E==="codespace"&&(re.codespaceName=ge.trim());return re},[E,O,$,V,le,ae,B,ge,ke,ot]),Nt=()=>!(!D.trim()||E==="ssh"&&!O.trim()||E==="codespace"&&!ge.trim()||E==="docker"&&ke==="attach"&&!ot.trim()||(E==="local"||E==="ssh")&&!Sp($)),ue=()=>{Nt()&&(c(D.trim(),E,Ht(),ce||void 0),T==null||T("Environment added successfully","success"),j(Ro,{replace:!0}))},Re=()=>{j(s?Io(s):Ro)},Q=y.useCallback((re,ve)=>{if(!C||!s)return;const Xe=Tp(C.adapterConfig),an=ve.trim();an?Xe[re]=an:delete Xe[re],d(s,{adapterConfig:Xe})},[C,s,d]),et=y.useCallback((re,ve)=>{if(!C||!s)return;const Xe=Tp(C.adapterConfig);if(ve.trim()){const an=Number(ve);Number.isInteger(an)&&an>=ed&&an<=td&&(Xe[re]=an)}else delete Xe[re];d(s,{adapterConfig:Xe})},[C,s,d]);if(w){if(!C)return i.jsxs("div",{className:oe.container,children:[i.jsxs("div",{className:oe.header,children:[i.jsx("div",{className:oe.headerTitle,children:i.jsx("span",{className:oe.badge,children:"edit environment"})}),i.jsx("div",{className:oe.headerActions,children:i.jsx("button",{onClick:Re,className:oe.btnGhost,children:"Back"})})]}),i.jsx("div",{className:oe.body,children:i.jsx("div",{className:oe.formContent,children:i.jsx("span",{className:oe.readOnlyValue,children:"Environment not found"})})})]});const re=Tp(C.adapterConfig);return i.jsxs("div",{className:oe.container,"data-testid":"env-edit-panel",children:[i.jsxs("div",{className:oe.header,children:[i.jsx("div",{className:oe.headerTitle,children:i.jsx("span",{className:oe.badge,children:"edit environment"})}),i.jsx("div",{className:oe.headerActions,children:i.jsx("button",{onClick:Re,className:oe.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),i.jsx("div",{className:oe.body,children:i.jsxs("div",{className:oe.formContent,children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Name"}),i.jsx(Bt,{value:C.displayName,onSave:ve=>{s&&d(s,{displayName:ve})},validate:ve=>ve.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:_e,onActivate:Oe,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Adapter Type"}),i.jsx("span",{className:oe.readOnlyValue,"data-testid":"env-edit-adapter-type",children:C.adapterType})]}),(C.adapterType==="codespace"||C.adapterType==="docker")&&(r.length>0||!!C.githubAccountId)&&i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"GitHub Account"}),i.jsxs("select",{value:C.githubAccountId||"",onChange:ve=>{s&&d(s,{githubAccountId:ve.target.value})},className:oe.adapterSelect,"data-testid":"env-edit-github-account",children:[i.jsx("option",{value:"",children:"(Default)"}),r.map(ve=>i.jsxs("option",{value:ve.id,children:[ve.label,ve.username?` (@${ve.username})`:"",ve.isDefault?" — default":""]},ve.id))]})]}),C.adapterType==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Host"}),i.jsx(Bt,{value:String(re.host??""),onSave:ve=>Q("host",ve),mode:"edit",fieldId:"host",activeFieldId:_e,onActivate:Oe,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Port"}),i.jsx(Bt,{value:String(re.port??""),onSave:ve=>et("port",ve),validate:ve=>Sp(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:_e,onActivate:Oe,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),C.adapterType==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Host"}),i.jsx(Bt,{value:String(re.host??""),onSave:ve=>Q("host",ve),validate:ve=>ve.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:_e,onActivate:Oe,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"User"}),i.jsx(Bt,{value:String(re.user??""),onSave:ve=>Q("user",ve),mode:"edit",fieldId:"user",activeFieldId:_e,onActivate:Oe,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"SSH Port"}),i.jsx(Bt,{value:String(re.sshPort??""),onSave:ve=>et("sshPort",ve),validate:ve=>Sp(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:_e,onActivate:Oe,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Identity File"}),i.jsx(Bt,{value:String(re.identityFile??""),onSave:ve=>Q("identityFile",ve),mode:"edit",fieldId:"identityFile",activeFieldId:_e,onActivate:Oe,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),C.adapterType==="docker"&&re.attach!==void 0&&i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Attach (container)"}),i.jsx(Bt,{value:String(re.attach??""),onSave:ve=>Q("attach",ve),validate:ve=>ve.trim()===""?"Container name is required":void 0,mode:"edit",fieldId:"attach",activeFieldId:_e,onActivate:Oe,placeholder:"container name or ID",ariaLabel:"Attach container","data-testid":"env-edit-attach"})]}),C.adapterType==="docker"&&re.attach===void 0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Image"}),i.jsx(Bt,{value:String(re.image??""),onSave:ve=>Q("image",ve),mode:"edit",fieldId:"image",activeFieldId:_e,onActivate:Oe,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Repo"}),i.jsx(Bt,{value:String(re.repo??""),onSave:ve=>Q("repo",ve),mode:"edit",fieldId:"repo",activeFieldId:_e,onActivate:Oe,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),C.adapterType==="codespace"&&i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Codespace Name"}),i.jsx(Bt,{value:String(re.codespaceName??""),onSave:ve=>Q("codespaceName",ve),validate:ve=>ve.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:_e,onActivate:Oe,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return i.jsxs("div",{className:oe.container,"data-testid":"env-create-panel",children:[i.jsxs("div",{className:oe.header,children:[i.jsx("div",{className:oe.headerTitle,children:i.jsx("span",{className:oe.badge,children:"new environment"})}),i.jsxs("div",{className:oe.headerActions,children:[i.jsx("button",{onClick:ue,disabled:!Nt(),className:oe.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),i.jsx("button",{onClick:Re,className:oe.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:oe.body,children:i.jsxs("div",{className:oe.formContent,children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-name",children:"Name"}),i.jsx("input",{id:"env-create-name",type:"text",value:D,onChange:re=>A(re.target.value),placeholder:"Environment name...",autoFocus:!0,className:oe.nameInput,"data-testid":"env-create-name",onKeyDown:re=>{re.key==="Enter"&&Nt()&&ue()}})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),i.jsxs("select",{id:"env-create-adapter",value:E,onChange:re=>{R(re.target.value),re.target.value==="codespace"&&u(ce||void 0)},className:oe.adapterSelect,"data-testid":"env-create-adapter",children:[i.jsx("option",{value:"local",children:"local"}),i.jsx("option",{value:"ssh",children:"ssh"}),i.jsx("option",{value:"docker",children:"docker"}),i.jsx("option",{value:"codespace",children:"codespace"})]})]}),(E==="codespace"||E==="docker")&&r.length>0&&i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-github-account",children:"GitHub Account"}),i.jsxs("select",{id:"env-create-github-account",value:ce,onChange:re=>{me(re.target.value),E==="codespace"&&u(re.target.value||void 0)},className:oe.adapterSelect,"data-testid":"env-create-github-account",children:[i.jsx("option",{value:"",children:"(Default)"}),r.map(re=>i.jsxs("option",{value:re.id,children:[re.label," (@",re.username,")",re.isDefault?" — default":""]},re.id))]})]}),E==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:O,onChange:re=>M(re.target.value),placeholder:"Host (optional)...",className:oe.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-port",children:"Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:ed,max:td,value:$,onChange:re=>Y(re.target.value),placeholder:"Port (optional)...",className:oe.fieldInput,"data-testid":"env-create-port"})]})]}),E==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:O,onChange:re=>M(re.target.value),placeholder:"Host (required)...",className:oe.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-user",children:"User"}),i.jsx("input",{id:"env-create-user",type:"text",value:V,onChange:re=>ee(re.target.value),placeholder:"User (optional)...",className:oe.fieldInput,"data-testid":"env-create-user"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-port",children:"SSH Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:ed,max:td,value:$,onChange:re=>Y(re.target.value),placeholder:"SSH port (optional)...",className:oe.fieldInput,"data-testid":"env-create-port"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-identity",children:"Identity File"}),i.jsx("input",{id:"env-create-identity",type:"text",value:le,onChange:re=>Z(re.target.value),placeholder:"Identity file (optional)...",className:oe.fieldInput,"data-testid":"env-create-identity"})]})]}),E==="docker"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-docker-mode",children:"Source"}),i.jsxs("select",{id:"env-docker-mode",value:ke,onChange:re=>{const ve=re.target.value;De(ve),ve==="attach"&&_()},className:oe.adapterSelect,"data-testid":"env-docker-mode",children:[i.jsx("option",{value:"create",children:"Create new container"}),i.jsx("option",{value:"attach",children:"Attach to existing container"})]})]}),ke==="create"?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-image",children:"Image"}),i.jsx("input",{id:"env-create-image",type:"text",value:ae,onChange:re=>H(re.target.value),placeholder:"Image (optional)...",className:oe.fieldInput,"data-testid":"env-create-image"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-repo",children:"Repo"}),i.jsx("input",{id:"env-create-repo",type:"text",value:B,onChange:re=>F(re.target.value),placeholder:"Repo (optional)...",className:oe.fieldInput,"data-testid":"env-create-repo"})]})]}):i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Container"}),!S&&k.length>0&&i.jsxs("select",{value:ot,onChange:re=>{yt(re.target.value),re.target.value&&!D.trim()&&A(re.target.value)},className:oe.adapterSelect,"data-testid":"env-docker-container-select",children:[i.jsx("option",{value:"",children:"Select a container..."}),k.map(re=>i.jsxs("option",{value:re.name,children:[re.name," (",re.image,") ",re.status]},re.id))]}),(S||k.length===0)&&i.jsxs(i.Fragment,{children:[S?i.jsx("span",{className:oe.errorHint,children:S}):i.jsx("span",{className:oe.creatingHint,children:"No running containers found."}),i.jsx("input",{type:"text",value:ot,onChange:re=>{yt(re.target.value),re.target.value&&!D.trim()&&A(re.target.value)},placeholder:"Enter container name/ID...",className:oe.fieldInput,"data-testid":"env-docker-container-manual"})]})]})]}),E==="codespace"&&i.jsx(f8,{codespaceName:ge,onCodespaceNameChange:ne,envName:D,onEnvNameChange:A,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:b})]})})]})}const p8="_group_1iprv_1",m8="_groupTitle_1iprv_8",h8="_shortcutList_1iprv_17",g8="_shortcutRow_1iprv_23",v8="_keys_1iprv_36",y8="_kbd_1iprv_43",b8="_description_1iprv_60",yi={group:p8,groupTitle:m8,shortcutList:h8,shortcutRow:g8,keys:v8,kbd:y8,description:b8},_8=[{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"}]},{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:"Root",shortcuts:[{keys:["Ctrl/Cmd","Enter"],description:"Send message (when the composer is focused)"},{keys:["Enter"],description:"Insert a new line in the message composer"}]}];function x8(){return i.jsxs("section",{className:fe.section,"data-testid":"keyboard-shortcuts-panel",children:[i.jsx("h3",{className:fe.sectionTitle,children:"Keyboard Shortcuts"}),i.jsx("p",{className:fe.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),_8.map(t=>i.jsxs("div",{className:yi.group,children:[i.jsx("h4",{className:yi.groupTitle,children:t.title}),i.jsx("div",{className:yi.shortcutList,children:t.shortcuts.map(s=>i.jsxs("div",{className:yi.shortcutRow,children:[i.jsx("span",{className:yi.keys,children:s.keys.map(o=>i.jsx("kbd",{className:yi.kbd,children:o},o))}),i.jsx("span",{className:yi.description,children:s.description})]},s.description))})]},t.title))]})}const k8=[{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 S8({credentialProviders:t,onUpdateCredentialProviders:s}){const o=(r,c)=>{const d={...t};r==="claude"?d.claude=c:d[r]=c,s(d)};return i.jsxs("section",{className:fe.section,children:[i.jsx("h3",{className:fe.sectionTitle,children:"Credential Providers"}),i.jsx("p",{className:fe.sectionDescription,children:"Enable providers to automatically forward credentials to environments at task start. Credentials are read fresh from the host each time."}),i.jsx("div",{className:fe.tokenList,children:k8.map(r=>i.jsxs("div",{className:fe.tokenRow,children:[i.jsx("span",{className:fe.tokenName,children:r.label}),i.jsx("span",{className:fe.tokenTarget,children:r.description}),i.jsx("select",{className:fe.select,value:t[r.key],onChange:c=>o(r.key,c.target.value),children:r.options.map(c=>i.jsx("option",{value:c.value,children:c.label},c.value))})]},r.key))})]})}const T8="_container_10efq_1",j8="_header_10efq_7",w8="_list_10efq_105",N8="_card_10efq_111",C8="_cardHeader_10efq_125",E8="_cardTitle_10efq_135",A8="_defaultBadge_10efq_141",D8="_cardActions_10efq_155",M8="_description_10efq_160",R8="_meta_10efq_166",I8="_empty_10efq_212",O8="_typeBadge_10efq_362",es={container:T8,header:j8,list:w8,card:N8,cardHeader:C8,cardTitle:E8,defaultBadge:A8,cardActions:D8,description:M8,meta:R8,empty:I8,typeBadge:O8};function B8({personas:t,appDefaultPersonaId:s,onDeletePersona:o,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=y.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await o(v),p(null)};return i.jsxs("div",{className:es.container,children:[i.jsxs("div",{className:es.header,children:[i.jsx("h2",{children:"Personas"}),i.jsx(sn,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?i.jsx("p",{className:es.empty,children:"No personas yet. Create one to get started."}):i.jsx("div",{className:es.list,children:t.map(v=>{const b=s===v.id,_=v.type==="script";return i.jsxs("div",{className:es.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:k=>{k.currentTarget===k.target&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(v.id))},children:[i.jsxs("div",{className:es.cardHeader,children:[i.jsxs("span",{className:es.cardTitle,children:[i.jsx("strong",{children:v.name}),i.jsx("span",{className:es.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:_?"Script":"Agent"}),b&&i.jsx("span",{className:es.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),i.jsxs("div",{className:es.cardActions,onClick:k=>k.stopPropagation(),children:[!b&&i.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>{r(v.id).catch(()=>{})},"data-testid":`persona-set-default-${v.id}`,title:"Set as app default persona",children:"Set Default"}),i.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),i.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&i.jsx("p",{className:es.description,children:v.description}),i.jsxs("div",{className:es.meta,children:[v.runtime&&i.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&i.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&i.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),i.jsx(ys,{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 L8="_container_uy08i_1",z8="_header_uy08i_7",$8="_count_uy08i_13",H8="_presets_uy08i_18",P8="_presetButton_uy08i_24",U8="_filterInput_uy08i_41",V8="_groups_uy08i_53",q8="_group_uy08i_53",G8="_groupHeader_uy08i_68",F8="_groupName_uy08i_77",K8="_groupCount_uy08i_81",Z8="_toolList_uy08i_87",Y8="_toolItem_uy08i_95",J8="_toolName_uy08i_103",yn={container:L8,header:z8,count:$8,presets:H8,presetButton:P8,filterInput:U8,groups:V8,group:q8,groupHeader:G8,groupName:F8,groupCount:K8,toolList:Z8,toolItem:Y8,toolName:J8},W8=(()=>{const t=new Map;for(const s of b_){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()}))})(),X8=[{name:"default",label:"Default",tools:y_},{name:"worker",label:"Worker",tools:O2},{name:"orchestrator",label:"Orchestrator",tools:B2},{name:"admin",label:"Admin",tools:L2}];function Wb({selectedTools:t,onChange:s,disabled:o}){const[r,c]=y.useState(""),d=y.useMemo(()=>new Set(t),[t]),u=y.useCallback(v=>{if(o)return;const b=new Set(d);b.has(v)?b.delete(v):b.add(v),s([...b].sort())},[d,s,o]),p=y.useCallback((v,b)=>{if(o)return;const _=new Set(d);for(const k of v)b?_.delete(k):_.add(k);s([..._].sort())},[d,s,o]),m=y.useCallback(v=>{o||s([...v].sort())},[s,o]),g=r.toLowerCase();return i.jsxs("div",{className:yn.container,"data-testid":"mcp-tool-selector",children:[i.jsx("div",{className:yn.header,children:i.jsx("span",{className:yn.count,children:t.length===0?`Using default (${y_.length} tools)`:`${t.length} of ${b_.size} tools selected`})}),i.jsxs("div",{className:yn.presets,"data-testid":"mcp-tool-presets",children:[X8.map(v=>i.jsx("button",{type:"button",className:yn.presetButton,disabled:o,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),i.jsx("button",{type:"button",className:yn.presetButton,disabled:o,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),i.jsx("input",{type:"text",className:yn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:o,"data-testid":"mcp-tool-filter"}),i.jsx("div",{className:yn.groups,children:W8.map(({group:v,tools:b})=>{const _=g?b.filter(S=>S.toLowerCase().includes(g)):b;if(_.length===0)return null;const k=_.every(S=>d.has(S));return i.jsxs("div",{className:yn.group,"data-testid":`tool-group-${v}`,children:[i.jsxs("label",{className:yn.groupHeader,children:[i.jsx("input",{type:"checkbox",checked:k,onChange:()=>p(_,k),disabled:o,"data-testid":`group-toggle-${v}`}),i.jsx("span",{className:yn.groupName,children:v}),i.jsxs("span",{className:yn.groupCount,children:["(",_.filter(S=>d.has(S)).length,"/",_.length,")"]})]}),i.jsx("div",{className:yn.toolList,children:_.map(S=>i.jsxs("label",{className:yn.toolItem,children:[i.jsx("input",{type:"checkbox",checked:d.has(S),onChange:()=>u(S),disabled:o,"data-testid":`tool-${S}`}),i.jsx("span",{className:yn.toolName,children:S})]},S))})]},v)})})]})}function im(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 V1(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 Q8="_container_1gfuq_1",e7="_header_1gfuq_7",t7="_list_1gfuq_19",n7="_card_1gfuq_25",s7="_cardHeader_1gfuq_40",a7="_cardTitle_1gfuq_46",i7="_statusBadge_1gfuq_56",o7="_enabled_1gfuq_68",r7="_disabled_1gfuq_71",l7="_cardActions_1gfuq_75",c7="_cardMeta_1gfuq_80",d7="_empty_1gfuq_98",ts={container:Q8,header:e7,list:t7,card:n7,cardHeader:s7,cardTitle:a7,statusBadge:i7,enabled:o7,disabled:r7,cardActions:l7,cardMeta:c7,empty:d7};function u7({schedules:t,personas:s,onDeleteSchedule:o,onToggleEnabled:r,onNavigateToNew:c,onNavigateToSchedule:d}){const[u,p]=y.useState(null),m=u?t.find(_=>_.id===u):void 0,g=async _=>{await o(_),p(null)},v=y.useMemo(()=>{const _=new Map;for(const k of s)_.set(k.id,k.name);return _},[s]),b=_=>v.get(_)??_;return i.jsxs("div",{className:ts.container,children:[i.jsxs("div",{className:ts.header,children:[i.jsx("h2",{children:"Schedules"}),i.jsx(sn,{variant:"primary",size:"md",onClick:c,"data-testid":"schedule-new-button",children:"+ New Schedule"})]}),t.length===0?i.jsx("p",{className:ts.empty,"data-testid":"schedule-empty-state",children:"No schedules yet. Create one to run tasks on a recurring cadence."}):i.jsx("div",{className:ts.list,children:t.map(_=>i.jsxs("div",{className:ts.card,"data-testid":`schedule-card-${_.id}`,onClick:()=>d(_.id),role:"button",tabIndex:0,onKeyDown:k=>{k.currentTarget===k.target&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(_.id))},children:[i.jsxs("div",{className:ts.cardHeader,children:[i.jsxs("span",{className:ts.cardTitle,children:[i.jsx("strong",{children:_.title}),i.jsx("span",{className:`${ts.statusBadge} ${_.enabled?ts.enabled:ts.disabled}`,"data-testid":`schedule-status-badge-${_.id}`,children:_.enabled?"Enabled":"Disabled"})]}),i.jsxs("div",{className:ts.cardActions,onClick:k=>k.stopPropagation(),children:[i.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>{(async()=>{await r(_.id,{enabled:!_.enabled})})().catch(()=>{})},"data-testid":`schedule-toggle-${_.id}`,title:_.enabled?"Disable schedule":"Enable schedule",children:_.enabled?"Disable":"Enable"}),i.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>d(_.id),"data-testid":`schedule-edit-${_.id}`,children:"Edit"}),i.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>p(_.id),"data-testid":`schedule-delete-${_.id}`,children:"Delete"})]})]}),i.jsxs("div",{className:ts.cardMeta,children:[i.jsx("span",{"data-testid":`schedule-expression-${_.id}`,children:_.scheduleExpression}),_.personaId&&i.jsxs("span",{"data-testid":`schedule-persona-${_.id}`,children:["Persona: ",b(_.personaId)]}),i.jsxs("span",{"data-testid":`schedule-last-run-${_.id}`,children:["Last run: ",_.lastRunAt?im(_.lastRunAt):"Never"]}),_.enabled&&_.nextRunAt?i.jsxs("span",{"data-testid":`schedule-next-run-${_.id}`,children:["Next run: ",V1(_.nextRunAt)]}):null,_.runCount>0&&i.jsxs("span",{"data-testid":`schedule-run-count-${_.id}`,children:["Runs: ",_.runCount]})]})]},_.id))}),i.jsx(ys,{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 f7="_nav_1bhou_1",p7="_tab_1bhou_24",m7="_tabIcon_1bhou_62",h7="_tabActive_1bhou_68",Pc={nav:f7,tab:p7,tabIcon:m7,tabActive:h7},na=[{path:"credentials",label:"Credentials",icon:i.jsx(ej,{size:wt})},{path:"github-accounts",label:"GitHub Accounts",icon:i.jsx(KT,{size:wt})},{path:"personas",label:"Personas",icon:i.jsx(zj,{size:wt})},{path:"schedules",label:"Schedules",icon:i.jsx(TT,{size:wt})},{path:"appearance",label:"Appearance",icon:i.jsx(_j,{size:wt})},{path:"shortcuts",label:"Shortcuts",icon:i.jsx(nj,{size:wt})},{path:"plugins",label:"Plugins",icon:i.jsx(wj,{size:wt})},{path:"about",label:"About",icon:i.jsx(pm,{size:wt})}];function g7(){var u;const t=Jt(),s=vt(),o=y.useRef(null),r=((u=na.find(p=>{const m=`${ki}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??na[0].path,c=y.useCallback(p=>{s(`${ki}/${p}`)},[s]),d=y.useCallback(p=>{var k,S;const m=(k=o.current)==null?void 0:k.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(T=>T===document.activeElement),v=g>=0?g:na.findIndex(T=>T.path===r);let b=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),b=(v+1)%na.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),b=(v-1+na.length)%na.length;else if(p.key==="Home")p.preventDefault(),b=0;else if(p.key==="End")p.preventDefault(),b=na.length-1;else return;const _=na[b].path;s(`${ki}/${_}`),(S=m[b])==null||S.focus()},[r,s]);return i.jsx("nav",{className:Pc.nav,ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:na.map(p=>{const m=p.path===r;return i.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Pc.tab} ${m?Pc.tabActive:""}`,onClick:()=>c(p.path),children:[i.jsx("span",{className:Pc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}const v7=["lifecycle:","pipe:","stdin:"];function q1(t){return t.selfEcho?"chatroom":t.name.startsWith("pipe:")?"pipe":"channel"}function y7(t,s){let o=!1;for(const r of t.subscribers){const c=s.get(r.sessionId);if(c&&(o=!0,c.taskId))return{kind:"task",taskId:c.taskId}}return o?{kind:"unattached"}:{kind:"external"}}function b7(t,s){const o=new Map(s.map(u=>[u.id,u])),r=new Map,c=[];for(const u of t){const p=y7(u,o);if(p.kind==="task"){const m=r.get(p.taskId);m?m.push(u):r.set(p.taskId,[u])}else c.push(u)}const d=Array.from(r,([u,p])=>({taskId:u,streams:p}));return c.length>0&&d.push({taskId:void 0,streams:c}),d}const _7="_container_16qkd_1",x7="_header_16qkd_7",k7="_title_16qkd_15",S7="_headerActions_16qkd_21",T7="_internalsToggle_16qkd_27",j7="_refreshButton_16qkd_37",w7="_state_16qkd_52",N7="_group_16qkd_59",C7="_groupHeader_16qkd_63",E7="_row_16qkd_72",A7="_selected_16qkd_92",D7="_kindBadge_16qkd_96",M7="_kindChatroom_16qkd_108",R7="_kindPipe_16qkd_114",I7="_kindChannel_16qkd_120",O7="_streamName_16qkd_126",B7="_meta_16qkd_135",Yt={container:_7,header:x7,title:k7,headerActions:S7,internalsToggle:T7,refreshButton:j7,state:w7,group:N7,groupHeader:C7,row:E7,selected:A7,kindBadge:D7,kindChatroom:M7,kindPipe:R7,kindChannel:I7,streamName:O7,meta:B7},L7={chatroom:"Chatroom",pipe:"Pipe",channel:"Channel"};function z7({kind:t}){return t==="chatroom"?i.jsx(mj,{size:Ze,"aria-hidden":"true"}):t==="pipe"?i.jsx(GT,{size:Ze,"aria-hidden":"true"}):i.jsx(YT,{size:Ze,"aria-hidden":"true"})}function $7({streams:t,sessions:s,tasks:o,loading:r,loadError:c=!1,loadedOnce:d=!0,showInternals:u,onToggleInternals:p,selectedStreamId:m,onSelectStream:g,onRefresh:v}){const b=b7(t,s),_={chatroom:Yt.kindChatroom,pipe:Yt.kindPipe,channel:Yt.kindChannel},k=S=>{var T;return((T=o.find(j=>j.id===S))==null?void 0:T.title)??S};return i.jsxs("div",{className:Yt.container,"data-testid":"coordination-list",children:[i.jsxs("div",{className:Yt.header,children:[i.jsx("span",{className:Yt.title,children:"Coordination"}),i.jsxs("div",{className:Yt.headerActions,children:[i.jsxs("label",{className:Yt.internalsToggle,children:[i.jsx("input",{type:"checkbox",checked:u,onChange:S=>p(S.target.checked),"data-testid":"coordination-show-internals"}),"Show internals"]}),v&&i.jsx("button",{type:"button",className:Yt.refreshButton,onClick:v,"aria-label":"Refresh streams","data-testid":"coordination-refresh",children:i.jsx(Cj,{size:Ze,"aria-hidden":"true"})})]})]}),r&&t.length===0&&i.jsxs("div",{className:Yt.state,children:["Loading","…"]}),!r&&c&&i.jsx("div",{className:Yt.state,"data-testid":"coordination-error",children:"Unable to load streams"}),!r&&!c&&d&&t.length===0&&i.jsx("div",{className:Yt.state,"data-testid":"coordination-empty",children:"No active streams"}),b.map(S=>i.jsxs("div",{className:Yt.group,children:[i.jsx("div",{className:Yt.groupHeader,children:S.taskId?k(S.taskId):"Unattached / external (CLI · MCP)"}),S.streams.map(T=>{const j=q1(T),w=T.id===m;return i.jsxs("button",{type:"button",className:`${Yt.row}${w?` ${Yt.selected}`:""}`,onClick:()=>g(T.id),"data-testid":`coordination-row-${T.id}`,"aria-current":w?"page":void 0,children:[i.jsxs("span",{className:`${Yt.kindBadge} ${_[j]}`,children:[i.jsx(z7,{kind:j})," ",L7[j]]}),i.jsx("span",{className:Yt.streamName,children:T.name}),i.jsxs("span",{className:Yt.meta,children:[T.subscriberCount," ",T.subscriberCount===1?"sub":"subs"," ","·"," ",T.messageBufferDepth," buffered"]})]},T.id)})]},S.taskId??"__orphans__"))]})}const H7="_transcript_1p4cm_1",P7="_message_1p4cm_10",U7="_meta_1p4cm_16",V7="_sender_1p4cm_24",q7="_time_1p4cm_29",G7="_content_1p4cm_34",F7="_state_1p4cm_42",Ua={transcript:H7,message:P7,meta:U7,sender:V7,time:q7,content:G7,state:F7};function K7(t){const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleTimeString()}function Z7({messages:t,loading:s=!1}){return s?i.jsx("div",{className:Ua.state,"data-testid":"stream-transcript-loading",children:"Loading transcript…"}):t.length===0?i.jsx("div",{className:Ua.state,"data-testid":"stream-transcript-empty",children:"No messages yet."}):i.jsx("div",{className:Ua.transcript,"data-testid":"stream-transcript",children:t.map(o=>i.jsxs("div",{className:Ua.message,"data-testid":"stream-transcript-message",children:[i.jsxs("div",{className:Ua.meta,children:[i.jsx("span",{className:Ua.sender,title:o.senderId,children:o.senderId.slice(0,12)}),i.jsx("span",{className:Ua.time,children:K7(o.timestamp)})]}),i.jsx("div",{className:Ua.content,children:o.content})]},o.seq))})}const Y7="_panel_iibrt_1",J7="_header_iibrt_24",W7="_title_iibrt_33",X7="_closeButton_iibrt_43",Q7="_body_iibrt_57",ez="_section_iibrt_63",tz="_sectionLabel_iibrt_67",nz="_metaRow_iibrt_76",sz="_metaKey_iibrt_84",az="_metaValue_iibrt_90",iz="_subscriberCard_iibrt_99",oz="_subscriberHeader_iibrt_107",rz="_sessionLink_iibrt_114",lz="_badges_iibrt_132",cz="_badgeRw_iibrt_150 _badge_iibrt_132",dz="_badgeR_iibrt_150 _badge_iibrt_132",uz="_badgeW_iibrt_162 _badge_iibrt_132",fz="_badgeAsync_iibrt_168 _badge_iibrt_132",pz="_badgeSync_iibrt_174 _badge_iibrt_132",mz="_badgeDetach_iibrt_178 _badge_iibrt_132",hz="_spawnTag_iibrt_184 _badge_iibrt_132",gz="_fdNumber_iibrt_189",vz="_emptySubscribers_iibrt_195",yz="_metaValueMono_iibrt_201 _metaValue_iibrt_90",bz="_advanced_iibrt_216",_z="_advancedSummary_iibrt_220",Pe={panel:Y7,header:J7,title:W7,closeButton:X7,body:Q7,section:ez,sectionLabel:tz,metaRow:nz,metaKey:sz,metaValue:az,subscriberCard:iz,subscriberHeader:oz,sessionLink:rz,badges:lz,badgeRw:cz,badgeR:dz,badgeW:uz,badgeAsync:fz,badgeSync:pz,badgeDetach:mz,spawnTag:hz,fdNumber:gz,emptySubscribers:vz,metaValueMono:yz,advanced:bz,advancedSummary:_z},xz={chatroom:"Chatroom",pipe:"Pipe",channel:"Channel"};function kz({permission:t}){const s=t==="rw"?Pe.badgeRw:t==="r"?Pe.badgeR:Pe.badgeW;return i.jsx("span",{className:s,children:t})}function Sz({mode:t}){const s=t==="async"?Pe.badgeAsync:t==="detach"?Pe.badgeDetach:Pe.badgeSync;return i.jsx("span",{className:s,children:t})}function Tz({stream:t,messages:s,transcriptLoading:o,onClose:r}){const c=vt();return y.useEffect(()=>{const d=u=>{u.key==="Escape"&&r()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[r]),i.jsxs("div",{className:Pe.panel,"data-testid":"stream-detail-panel",children:[i.jsxs("div",{className:Pe.header,children:[i.jsx("h3",{className:Pe.title,children:t.name}),i.jsx("button",{type:"button",className:Pe.closeButton,onClick:r,"aria-label":"Close stream details",children:"×"})]}),i.jsxs("div",{className:Pe.body,children:[i.jsxs("div",{className:Pe.section,children:[i.jsx("div",{className:Pe.sectionLabel,children:"Overview"}),i.jsxs("div",{className:Pe.metaRow,children:[i.jsx("span",{className:Pe.metaKey,children:"Kind"}),i.jsx("span",{className:Pe.metaValue,children:xz[q1(t)]})]}),i.jsxs("div",{className:Pe.metaRow,children:[i.jsx("span",{className:Pe.metaKey,children:"Participants"}),i.jsx("span",{className:Pe.metaValue,children:t.subscriberCount})]}),i.jsxs("div",{className:Pe.metaRow,children:[i.jsx("span",{className:Pe.metaKey,children:"Buffered"}),i.jsxs("span",{className:Pe.metaValue,children:[t.messageBufferDepth," msgs"]})]})]}),i.jsxs("div",{className:Pe.section,children:[i.jsx("div",{className:Pe.sectionLabel,children:"Participants"}),t.subscribers.length===0?i.jsx("div",{className:Pe.emptySubscribers,children:"No active subscribers"}):t.subscribers.map(d=>i.jsxs("div",{className:Pe.subscriberCard,"data-testid":`subscriber-card-${d.subscriptionId}`,children:[i.jsxs("button",{type:"button",className:Pe.sessionLink,onClick:()=>{c(Sm(d.sessionId))},title:d.sessionId,children:[d.sessionId.slice(0,12),"…"]}),d.createdBySpawn&&i.jsx("span",{className:Pe.spawnTag,children:"spawn"})]},d.subscriptionId))]}),i.jsxs("div",{className:Pe.section,children:[i.jsx("div",{className:Pe.sectionLabel,children:"Conversation"}),i.jsx(Z7,{messages:s??[],loading:o??!1})]}),i.jsxs("details",{className:Pe.advanced,"data-testid":"stream-advanced",children:[i.jsx("summary",{className:Pe.advancedSummary,children:"Advanced"}),i.jsxs("div",{className:Pe.metaRow,children:[i.jsx("span",{className:Pe.metaKey,children:"Stream ID"}),i.jsx("span",{className:Pe.metaValueMono,children:t.id})]}),t.subscribers.map(d=>i.jsxs("div",{className:Pe.subscriberCard,children:[i.jsxs("div",{className:Pe.subscriberHeader,children:[i.jsxs("span",{className:Pe.fdNumber,children:["fd ",d.fd]}),i.jsxs("span",{className:Pe.metaValueMono,title:d.subscriptionId,children:[d.subscriptionId.slice(0,12),"…"]})]}),i.jsxs("div",{className:Pe.badges,children:[i.jsx(kz,{permission:d.permission}),i.jsx(Sz,{mode:d.deliveryMode})]})]},d.subscriptionId))]})]})]})}function jz({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(my.map(d=>[d,[]]));for(const d of t){const u=rl(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 b;if(u==="paused"&&o){const S=o.get(d.id);S==="idle"?b="Needs input":S==="completed"&&(b="Ready to complete")}const _={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:b},k=c.get(u);k?k.push(_):c.get("not_started").push(_)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return my.map(d=>{const u=Ka(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const wz="_boardContainer_1c4y1_1",Nz="_column_1c4y1_17",Cz="_columnHeader_1c4y1_34",Ez="_columnIcon_1c4y1_47",Az="_columnLabel_1c4y1_52",Dz="_columnCount_1c4y1_57",Mz="_cardList_1c4y1_67",Rz="_emptyPlaceholder_1c4y1_76",Iz="_card_1c4y1_67",Oz="_cardHeader_1c4y1_107",Bz="_cardStatusIcon_1c4y1_113",Lz="_cardTitle_1c4y1_119",zz="_cardBadges_1c4y1_127",$z="_badge_1c4y1_134",Hz="_blockedBadge_1c4y1_146",Pz="_childBadge_1c4y1_151",Uz="_depBadge_1c4y1_155",Vz="_parentBadge_1c4y1_159",qz="_pausedSubBadge_1c4y1_166",Gz="_personaBadge_1c4y1_170",Fz="_envBadge_1c4y1_174",Kz="_emptyCta_1c4y1_178",Zz="_ctaButton_1c4y1_188",Yz="_ctaDescription_1c4y1_204",lt={boardContainer:wz,column:Nz,columnHeader:Cz,columnIcon:Ez,columnLabel:Az,columnCount:Dz,cardList:Mz,emptyPlaceholder:Rz,card:Iz,cardHeader:Oz,cardStatusIcon:Bz,cardTitle:Lz,cardBadges:zz,badge:$z,blockedBadge:Hz,childBadge:Pz,depBadge:Uz,parentBadge:Vz,pausedSubBadge:qz,personaBadge:Gz,envBadge:Fz,emptyCta:Kz,ctaButton:Zz,ctaDescription:Yz};function Jz({workspaceId:t,environmentId:s,tasks:o,sessions:r,personas:c,environments:d}){const u=vt(),p=y.useMemo(()=>o.filter(_=>_.workspaceId===t),[o,t]),m=y.useMemo(()=>new Map(o.map(_=>[_.id,_.status])),[o]),g=y.useMemo(()=>new Map(p.map(_=>[_.id,_])),[p]),v=y.useMemo(()=>{const _=new Map(r.map(C=>[C.id,C])),k=new Map(c.map(C=>[C.id,C])),S=new Map(d.map(C=>[C.id,C])),T=new Map,j=new Map,w=new Map;for(const C of p)if(C.latestSessionId){const D=_.get(C.latestSessionId);if(D){if(T.set(C.id,D.endReason||D.status),D.personaId){const A=k.get(D.personaId);A&&j.set(C.id,A.name)}if(D.environmentId){const A=S.get(D.environmentId);A&&w.set(C.id,A.displayName)}}}return{sessionStatusByTaskId:T,personaNameByTaskId:j,environmentNameByTaskId:w}},[p,r,c,d]),b=y.useMemo(()=>jz({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?i.jsxs("div",{className:lt.emptyCta,"data-testid":"board-empty-cta",children:[i.jsx("button",{className:lt.ctaButton,onClick:()=>u(Di(t,void 0,s)),children:"Create Task"}),i.jsx("div",{className:lt.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):i.jsx("div",{className:lt.boardContainer,"data-testid":"board-container",children:b.map(_=>i.jsxs("section",{className:lt.column,"data-testid":`board-column-${_.status}`,"aria-label":`${_.label}, ${_.tasks.length} ${_.tasks.length===1?"task":"tasks"}`,children:[i.jsxs("div",{className:lt.columnHeader,children:[i.jsx("span",{className:lt.columnIcon,style:{color:_.style.color},children:_.style.icon}),i.jsx("span",{className:lt.columnLabel,children:_.label}),i.jsx("span",{className:lt.columnCount,"data-testid":`board-count-${_.status}`,children:_.tasks.length})]}),i.jsx("div",{className:lt.cardList,children:_.tasks.length===0?i.jsx("div",{className:lt.emptyPlaceholder,children:"No tasks"}):i.jsx(as,{mode:"popLayout",children:_.tasks.map(k=>i.jsx($t.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:i.jsx(Wz,{boardTask:k,tasksById:g,personaName:v.personaNameByTaskId.get(k.task.id),envName:v.environmentNameByTaskId.get(k.task.id),onClick:()=>u(os(k.task.id,void 0,t,s))})},k.task.id))})})]},_.status))})}function Wz({boardTask:t,tasksById:s,personaName:o,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=Ka(d.status),b=d.parentTaskId?s.get(d.parentTaskId):void 0;return i.jsxs("div",{className:lt.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),c())},children:[i.jsxs("div",{className:lt.cardHeader,children:[i.jsx("span",{className:lt.cardStatusIcon,style:{color:v.color},children:v.icon}),i.jsx("span",{className:lt.cardTitle,children:d.title})]}),i.jsxs("div",{className:lt.cardBadges,children:[b&&i.jsx("span",{className:`${lt.badge} ${lt.parentBadge}`,title:b.title,children:b.title}),p>0&&i.jsxs("span",{className:`${lt.badge} ${lt.childBadge}`,children:[m,"/",p]}),u&&i.jsx("span",{className:`${lt.badge} ${lt.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&i.jsx("span",{className:`${lt.badge} ${lt.depBadge}`,children:"dep"}),g&&i.jsx("span",{className:`${lt.badge} ${lt.pausedSubBadge}`,children:g}),o&&i.jsx("span",{className:`${lt.badge} ${lt.personaBadge}`,children:o}),r&&i.jsx("span",{className:`${lt.badge} ${lt.envBadge}`,children:r})]})]})}const Xz="_formContent_ymnez_1",Qz="_section_ymnez_13",e$="_label_ymnez_19",t$="_titleInput_ymnez_26",n$="_descriptionTextarea_ymnez_58",s$="_selectField_ymnez_94",a$="_checkboxRow_ymnez_128",i$="_checkboxLabel_ymnez_141",o$="_fieldError_ymnez_146",xt={formContent:Xz,section:Qz,label:e$,titleInput:t$,descriptionTextarea:n$,selectField:s$,checkboxRow:a$,checkboxLabel:i$,fieldError:o$};function r$(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 l$=100;function c$({values:t,onChange:s,environments:o,personas:r,errors:c,disabled:d,autoFocusName:u}){const p=(m,g)=>{s({...t,[m]:g})};return i.jsxs("div",{className:xt.formContent,children:[i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-name",children:"Name"}),i.jsx("input",{id:"ws-name",className:xt.titleInput,type:"text",value:t.name,onChange:m=>p("name",m.target.value),placeholder:"Workspace name",maxLength:l$,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&i.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-description",children:"Description"}),i.jsx("textarea",{id:"ws-description",className:xt.descriptionTextarea,value:t.description,onChange:m=>p("description",m.target.value),placeholder:"Optional description (Markdown supported)",disabled:d,"data-testid":"workspace-form-description"})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-repo",children:"Repository URL"}),i.jsx("input",{id:"ws-repo",className:xt.titleInput,type:"text",value:t.repoUrl,onChange:m=>p("repoUrl",m.target.value),placeholder:"https://github.com/org/repo",disabled:d,"data-testid":"workspace-form-repo"}),(c==null?void 0:c.repoUrl)&&i.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-environment",children:"Environment"}),i.jsxs("select",{id:"ws-environment",className:xt.selectField,value:t.environmentId,onChange:m=>p("environmentId",m.target.value),disabled:d,"data-testid":"workspace-form-environment",children:[i.jsx("option",{value:"",children:"Select environment…"}),o.map(m=>i.jsx("option",{value:m.id,children:m.displayName||m.id},m.id))]}),(c==null?void 0:c.environmentId)&&i.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-persona",children:"Default Persona"}),i.jsxs("select",{id:"ws-persona",className:xt.selectField,value:t.defaultPersonaId,onChange:m=>p("defaultPersonaId",m.target.value),disabled:d,"data-testid":"workspace-form-persona",children:[i.jsx("option",{value:"",children:"(Inherit)"}),r.map(m=>i.jsx("option",{value:m.id,children:m.name},m.id))]})]}),i.jsx("div",{className:xt.section,children:i.jsxs("label",{className:xt.checkboxRow,children:[i.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:m=>p("useWorktrees",m.target.checked),disabled:d,"data-testid":"workspace-form-worktrees"}),i.jsx("span",{className:xt.checkboxLabel,children:"Enable worktree isolation"})]})}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-workdir",children:"Working Directory"}),i.jsx("input",{id:"ws-workdir",className:xt.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 G1=y.createContext(void 0),d$=4e3;function u$({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=d$)=>{const g=`toast-${++r.current}`;o(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return i.jsx(G1.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function pn(){const t=y.useContext(G1);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const om="grackle-theme",F1="grackle-prefer-system",K1="(prefers-color-scheme: dark)";let Gr=[],nd;function jp(){nd=void 0;for(const t of Gr)t()}function rm(){return typeof window>"u"?!1:window.matchMedia(K1).matches}function Wr(){if(typeof localStorage>"u")return Yb;try{const t=localStorage.getItem(om);if(t!==null&&H1.has(t))return t}catch{}return Yb}function md(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(F1)==="true"}catch{return!1}}function lm(t){return Ed.find(s=>s.variantLightId===t||s.variantDarkId===t)}function Z1(t,s){const o=am(t);if(o!=null&&o.variantDarkId)return s&&o.variantLightId?rm()?o.variantDarkId:o.variantLightId:o.variantDarkId;if(o!=null&&o.hidden&&s){const r=lm(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return rm()?r.variantDarkId:r.variantLightId}return t}function No(t,s,o=!1){o&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=Z1(t,s),o&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&No(Wr(),md());function f$(){return nd===void 0&&(nd={themeId:Wr(),systemDark:rm(),preferSystem:md()}),nd}function p$(t){return Gr=[...Gr,t],()=>{Gr=Gr.filter(s=>s!==t)}}function m$(){const t=y.useSyncExternalStore(p$,f$),{themeId:s,preferSystem:o}=t,r=Z1(s,o),c=y.useCallback(u=>{if(H1.has(u)){try{localStorage.setItem(om,u)}catch{}No(u,md(),!0),jp()}},[]),d=y.useCallback(u=>{try{localStorage.setItem(F1,u?"true":"false")}catch{}if(u){const p=Wr(),m=am(p);if(m!=null&&m.hidden){const g=lm(p);if(g)try{localStorage.setItem(om,g.id)}catch{}}}No(Wr(),u,!0),jp()},[]);return y.useEffect(()=>{No(s,o)},[s,o]),y.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(K1),p=()=>{const m=Wr(),g=md();if(g){const v=am(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&No(m,g),v!=null&&v.hidden){const b=lm(m);b!=null&&b.variantDarkId&&b.variantLightId&&No(m,g)}}jp()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:o,setPreferSystem:d}}const Y1=y.createContext(void 0);function h$({children:t}){const s=m$();return i.jsx(Y1.Provider,{value:s,children:t})}function J1(){const t=y.useContext(Y1);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const W1=y.createContext(void 0),X1=y.createContext(void 0);function g$({children:t}){const[s,o]=y.useState(void 0),r=y.useCallback(c=>{o(c)},[]);return i.jsx(X1.Provider,{value:r,children:i.jsx(W1.Provider,{value:s,children:t})})}function v$(){return y.useContext(W1)}function y$(){const t=y.useContext(X1);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const rh=y.createContext(void 0);function ut(){const t=y.useContext(rh);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function Q1(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function ek(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function b$(t){return Q1(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 _$=new Set(["off","subscription","api_key"]),Uc=new Set(["off","on"]);function x$(t){return Q1(t)&&_$.has(t.claude)&&Uc.has(t.github)&&Uc.has(t.copilot)&&Uc.has(t.codex)&&Uc.has(t.goose)}function tk(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 nk(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 jo=5e3;function k$(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 Ni={label:"Home",url:Po};function S$(t){return t?[Ni,{label:"Settings",url:ki},{label:t,url:void 0}]:[Ni,{label:"Settings",url:void 0}]}const sk={label:"Environments",url:Ro};function T$(){return[Ni,{label:"Environments",url:void 0}]}function j$(){return[Ni,{label:"New Chat",url:void 0}]}function w$(t){return[Ni,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function N$(t,s,o,r){const c=o.find(u=>u.id===t),d=r.find(u=>u.id===s);return[Ni,sk,{label:(d==null?void 0:d.displayName)??"Environment",url:Io(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function C$(t,s,o,r,c){const d=k$(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?o.find(k=>k.id===p):void 0,g=s??(m==null?void 0:m.linkedEnvironmentIds[0]),v=g?r.find(k=>k.id===g):void 0,b=[Ni];v&&g&&(b.push(sk),b.push({label:v.displayName,url:Io(g)})),m&&g&&b.push({label:m.name,url:ji(m.id,g)});for(let k=0;k<d.length-1;k++)b.push({label:d[k].title,url:os(d[k].id,void 0,p,g)});const _=d[d.length-1];return b.push({label:(_==null?void 0:_.title)??t,url:void 0}),b}function lh(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 Vc(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 E$(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 ch(t){const s=new Map;for(const v of t)if(v.raw)try{s.set(v,JSON.parse(v.raw))}catch{}const o=new Map;for(const v of t){if(v.eventType!=="tool_use")continue;const b=s.get(v),_=b?Vc(b):void 0;if(_)try{const k=JSON.parse(v.content);o.set(_,{tool:k.tool,args:k.args})}catch{}}const r=new Set,c=new Set,d=t.map((v,b)=>{if(v.eventType!=="tool_result")return v;const _=s.get(v),k=_?E$(_):void 0;if(!k)return v;const S=o.get(k);if(!S)return v;r.add(k),c.add(b);let T;const j=v.content.trim();if(j.startsWith("{"))try{const w=JSON.parse(j);typeof w.detailedContent=="string"&&(T=w.detailedContent)}catch{}return{...v,toolUseCtx:{...S,detailedResult:T}}}),u=[];for(let v=0;v<d.length;v++){if(d[v].eventType!=="tool_use")continue;const b=s.get(d[v]),_=b?Vc(b):void 0;_&&r.has(_)||u.push(v)}const p=[];for(let v=0;v<d.length;v++)d[v].eventType!=="tool_result"||c.has(v)||p.push(v);let m=0;for(const v of u){for(;m<p.length&&p[m]<v;)m++;if(m>=p.length)break;const b=p[m];if(b!==v+1)continue;const _=d[v],k=d[b];let S;try{const T=JSON.parse(_.content);S={tool:T.tool,args:T.args}}catch{}if(S){let T;const j=k.content.trim();if(j.startsWith("{"))try{const D=JSON.parse(j);typeof D.detailedContent=="string"&&(T=D.detailedContent)}catch{}d[b]={...k,toolUseCtx:{...S,detailedResult:T}},c.add(b);const w=s.get(_),C=w?Vc(w):void 0;C?r.add(C):(r.add(`__seq_${v}`),s.set(_,{...w??{},__seqId:`__seq_${v}`})),m++}}const g=d.filter(v=>{if(v.eventType!=="tool_use")return!0;const b=s.get(v);if(!b)return!0;const _=Vc(b);if(_&&r.has(_))return!1;const k=b.__seqId;return!(k&&r.has(k))});for(let v=0;v<g.length;v++){if(g[v].eventType!=="tool_use")continue;let b=!1;for(let _=v+1;_<g.length;_++)if(g[_].eventType!=="tool_use"){b=!0;break}b&&(g[v]={...g[v],settled:!0})}return g}function A$(t,s,o){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=ak(s),d=s.filter(m=>cm(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||cm(m,c)).length,p=o.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function ak(t){const s=new Map;for(const o of t)s.set(o.id,o.status);return s}function cm(t,s){return t.dependsOn.some(o=>s.get(o)!=="complete")}function D$(t,s){var u;const o=new Map;for(const p of s)o.set(p.id,p);const r=ak(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}):cm(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 M$(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 R$(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 Cs=[{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
|
|
325
|
+
--- End forwarded ---`}function a5(t){return t.replace(/[\r\n]+/g," ").trim().replace(/---/g,"—")}function i5({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,T)=>{if(T&&u.current!==void 0){const j=Math.min(u.current,S),w=Math.max(u.current,S);d(C=>{const D=new Set(C);for(let A=j;A<=w;A++)A<t.length&&ol(t[A])&&D.add(A);return D})}else d(j=>{const w=new Set(j);return w.has(S)?w.delete(S):w.add(S),w.size===0?(r(!1),u.current=void 0):u.current=S,w})},[t]),b=y.useCallback(()=>{const S=new Set;for(let T=0;T<t.length;T++)ol(t[T])&&S.add(T);d(S)},[t]),_=y.useCallback(()=>{d(new Set)},[]),k=y.useCallback(async()=>{const T=[...c].sort((w,C)=>w-C).filter(w=>w<t.length).map(w=>t[w]);if(T.length===0)return!1;const j=s(T);try{return await navigator.clipboard.writeText(j),!0}catch{return!1}},[c,t,s]);return{isSelecting:o,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:b,deselectAll:_,copySelected:k}}const o5="_wrapper_1cdza_1",r5="_scrollContainer_1cdza_9",l5="_selectingPadding_1cdza_16",c5="_toolbar_1cdza_20",d5="_directionToggle_1cdza_27",u5="_scrollToAnchor_1cdza_65",f5="_scrollToAnchorBottom_1cdza_89",p5="_scrollToAnchorTop_1cdza_93",m5="_eventOverflowWarning_1cdza_97",sa={wrapper:o5,scrollContainer:r5,selectingPadding:l5,toolbar:c5,directionToggle:d5,scrollToAnchor:u5,scrollToAnchorBottom:f5,scrollToAnchorTop:p5,eventOverflowWarning:m5},h5=10*1024,g5=new Set(["running","idle"]);function v5(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 M1="grackle-stream-direction";function y5(){try{return localStorage.getItem(M1)==="reversed"}catch{return!1}}function b5({eventsDropped:t}){return t<=0?i.jsx(i.Fragment,{}):i.jsxs("div",{className:sa.eventOverflowWarning,role:"alert",children:[i.jsx(mm,{size:zt,"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 ih({events:t,eventsDropped:s,emptyState:o,onShowToast:r,sessions:c,currentSessionId:d,environments:u,personas:p,onForward:m,sandboxProxyUrl:g}){const v=y.useRef(null),[b,_]=y.useState(y5),k=D3(),[S,T]=y.useState(!1),[j,w]=y.useState(!1),[C,D]=y.useState(void 0),A=i5({events:t,formatForClipboard:D1}),E=y.useMemo(()=>t.filter(ol).length,[t]),R=y.useMemo(()=>c?c.filter(ce=>g5.has(ce.status)&&ce.id!==d):[],[c,d]),O=y.useMemo(()=>b?[...t].reverse():t,[t,b]),{isAtAnchor:M,scrollToAnchor:$}=e5({scrollRef:v,contentLength:t.length,isReversed:b,paused:A.isSelecting}),Y=()=>{const ce=!b;_(ce);try{localStorage.setItem(M1,ce?"reversed":"default")}catch{}};y.useEffect(()=>{if(!A.isSelecting)return;const ce=me=>{me.key==="Escape"&&!S&&!j&&A.cancelSelection()};return window.addEventListener("keydown",ce),()=>{window.removeEventListener("keydown",ce)}},[A.isSelecting,A.cancelSelection,S,j]);const V=y.useCallback(async()=>{await A.copySelected()&&(r==null||r(`Copied ${A.selectedCount} message${A.selectedCount===1?"":"s"} to clipboard`,"success"))},[A,r]),ee=y.useCallback(()=>[...A.selectedIndices].sort((me,ke)=>me-ke).filter(me=>me<t.length).map(me=>t[me]),[A.selectedIndices,t]),le=y.useCallback(ce=>{if(!ce)return"this session";const me=c==null?void 0:c.find(De=>De.id===ce);if(!me)return ce.slice(0,8);const ke=u==null?void 0:u.find(De=>De.id===me.environmentId);return(ke==null?void 0:ke.displayName)??me.environmentId.slice(0,8)},[c,u]),Z=y.useCallback(async(ce,me)=>{if(!m)return;const ke=le(ce);try{await m(ce,me);const De=A.selectedCount;r==null||r(`Forwarded ${De} message${De===1?"":"s"} to ${ke}`,"success"),A.cancelSelection()}catch{r==null||r("Failed to forward messages","error")}},[m,le,r,A]),ae=y.useCallback(ce=>{T(!1);const me=ee(),ke=le(d),De=s5(ke,me);if(new TextEncoder().encode(De).length>h5){D({sessionId:ce,text:De}),w(!0);return}Z(ce,De).catch(()=>{})},[ee,le,d,Z]),H=y.useCallback(()=>{w(!1),C&&(Z(C.sessionId,C.text).catch(()=>{}),D(void 0))},[C,Z]),B=y.useCallback(()=>{w(!1),D(void 0)},[]),F=k?0:.2,ge=b?-8:8,ne=C?Math.round(new TextEncoder().encode(C.text).length/1024):0;return i.jsxs("div",{className:sa.wrapper,children:[i.jsx("div",{className:sa.toolbar,children:i.jsx(wi,{text:b?"Showing newest first":"Showing oldest first",children:i.jsx("button",{className:sa.directionToggle,onClick:Y,"aria-label":b?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:b?i.jsx(fy,{size:zt,"aria-hidden":"true"}):i.jsx(py,{size:zt,"aria-hidden":"true"})})})}),i.jsxs("div",{ref:v,className:`${sa.scrollContainer} ${A.isSelecting?sa.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&o,i.jsx(b5,{eventsDropped:s}),i.jsx(as,{initial:!1,children:O.map((ce,me)=>{const ke=b?t.length-1-me:me;return i.jsx($t.div,{initial:{opacity:0,y:ge},animate:{opacity:1,y:0},transition:{duration:F,ease:"easeOut"},children:i.jsx(_6,{copyText:n5(ce),isContentBearing:ol(ce),isSelecting:A.isSelecting,isSelected:A.selectedIndices.has(ke),checkboxLabel:v5(ce),onSelect:()=>{A.enterSelectionMode(ke)},onToggle:De=>{A.toggleEvent(ke,De)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:i.jsx(iD,{event:ce,toolUseCtx:ce.toolUseCtx,settled:ce.settled,sandboxProxyUrl:g})})},`${ce.sessionId}-${ce.timestamp}-${ke}`)})})]}),i.jsx(as,{children:A.isSelecting&&i.jsx(E6,{selectedCount:A.selectedCount,totalSelectable:E,onSelectAll:A.selectAll,onDeselectAll:A.deselectAll,onCopy:()=>{V().catch(()=>{})},onForward:m!==void 0?()=>{T(!0)}:void 0,forwardDisabled:R.length===0,onCancel:A.cancelSelection})}),i.jsx(W6,{isOpen:S,sessions:R,environments:u??[],personas:p,onSelect:ae,onCancel:()=>{T(!1)}}),i.jsx(ys,{isOpen:j,title:"Send large message?",description:`This will forward a large message (${ne} KB). Continue?`,confirmLabel:"Send",onConfirm:H,onCancel:B}),i.jsx(as,{children:!M&&i.jsxs($t.button,{className:`${sa.scrollToAnchor} ${b?sa.scrollToAnchorTop:sa.scrollToAnchorBottom}`,onClick:$,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:[b?i.jsx(py,{size:zt,"aria-hidden":"true"}):i.jsx(fy,{size:zt,"aria-hidden":"true"})," New events"]})})]})}function oh(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(""),k=y.useRef(!1),S=d===c,T=y.useCallback(O=>{v(O),_("")},[]),j=y.useCallback(()=>{_("")},[]),w=y.useCallback(()=>{k.current=!1,u==null||u(null),v(""),_("")},[u]),C=y.useCallback(()=>{const O=m?g.trim():g;if(r){const $=r(g);if($){_($);return}}const M=m?s.trim():s;if(O===M){w();return}o(O),w()},[g,s,m,r,o,w]),D=y.useCallback(()=>{k.current=!0,u==null||u(c),v(s),_("")},[c,s,u]),A=y.useCallback(O=>{if(k.current){k.current=!1;return}O.relatedTarget instanceof HTMLElement&&O.relatedTarget.dataset.editAction===c||C()},[c,C]),E=y.useCallback(O=>{O.key==="Escape"?w():O.key==="Enter"&&p&&C()},[w,p,C]),R=(()=>{if(!S)return!1;const O=m?s.trim():s;return(m?g.trim():g)!==O})();return y.useEffect(()=>{!S&&(g!==""||b!=="")&&(v(""),_(""))},[S,g,b]),{isEditing:S,draft:g,error:b,isDirty:R,startEdit:D,cancelEdit:w,save:C,setDraft:T,clearError:j,handleBlur:A,handleKeyDown:E,ignoreInitialBlurRef:k}}const _5="_editFieldWrapper_yuzty_1",x5="_editInput_yuzty_10",k5="_editTextarea_yuzty_42",S5="_editSelect_yuzty_78",T5="_editError_yuzty_111",j5="_editInputInvalid_yuzty_118",w5="_editHint_yuzty_123",N5="_unsavedDot_yuzty_132",C5="_metaValueClickable_yuzty_140",E5="_editButton_yuzty_159",A5="_metaPlaceholder_yuzty_175",D5="_worktreeToggle_yuzty_180",it={editFieldWrapper:_5,editInput:x5,editTextarea:k5,editSelect:S5,editError:T5,editInputInvalid:j5,editHint:w5,unsavedDot:N5,metaValueClickable:C5,editButton:E5,metaPlaceholder:A5,worktreeToggle:D5};function Bt(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="text",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,maxLength:b,ariaLabel:_,"data-testid":k}=t,S=y.useRef(null),T=oh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(T.isEditing){const w=window.setTimeout(()=>{var C;(C=S.current)==null||C.focus()},0);return()=>window.clearTimeout(w)}},[T.isEditing]),c==="create"){const w=D=>{m==null||m(D.target.value)},C=r==null?void 0:r(s);return i.jsxs("div",{className:it.editFieldWrapper,children:[i.jsx("input",{className:`${it.editInput} ${C?it.editInputInvalid:""}`,value:s,onChange:w,maxLength:b,placeholder:v,"aria-label":_,"data-testid":k?`${k}-input`:void 0}),C&&i.jsx("span",{className:it.editError,"data-testid":"edit-error",children:C})]})}if(T.isEditing)return i.jsxs("div",{className:it.editFieldWrapper,children:[i.jsx("input",{ref:S,className:`${it.editInput} ${T.error?it.editInputInvalid:""}`,value:T.draft,onChange:w=>T.setDraft(w.target.value),onBlur:T.handleBlur,onKeyDown:T.handleKeyDown,maxLength:b,placeholder:v,"aria-label":_,"data-testid":k?`${k}-input`:void 0}),T.isDirty&&i.jsx("span",{className:it.unsavedDot,title:"Unsaved changes"}),T.error&&i.jsx("span",{className:it.editError,"data-testid":"edit-error",children:T.error}),i.jsx("span",{className:it.editHint,children:"Enter to save · Esc to cancel"})]});const j=g==null?void 0:g(s);return i.jsxs("span",{role:"button",tabIndex:0,className:it.metaValueClickable,onClick:()=>T.startEdit(),onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),T.startEdit())},title:"Click to edit","aria-label":_,"data-testid":k?`${k}-button`:void 0,children:[j!==void 0?j:s?i.jsx("span",{children:s}):i.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function sm(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="textarea",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":_}=t,k=y.useRef(null),S=oh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(S.isEditing){const j=window.setTimeout(()=>{var w;(w=k.current)==null||w.focus()},0);return()=>window.clearTimeout(j)}},[S.isEditing]),c==="create"){const j=C=>{m==null||m(C.target.value)},w=r==null?void 0:r(s);return i.jsxs("div",{className:it.editFieldWrapper,children:[i.jsx("textarea",{className:`${it.editTextarea} ${w?it.editInputInvalid:""}`,value:s,onChange:j,placeholder:v,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),w&&i.jsx("span",{className:it.editError,"data-testid":"edit-error",children:w})]})}if(S.isEditing)return i.jsxs("div",{className:it.editFieldWrapper,children:[i.jsx("textarea",{ref:k,className:`${it.editTextarea} ${S.error?it.editInputInvalid:""}`,value:S.draft,onChange:j=>S.setDraft(j.target.value),onBlur:S.handleBlur,onKeyDown:S.handleKeyDown,title:b,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),S.isDirty&&i.jsx("span",{className:it.unsavedDot,title:"Unsaved changes"}),S.error&&i.jsx("span",{className:it.editError,"data-testid":"edit-error",children:S.error}),i.jsx("span",{className:it.editHint,children:"Tab to save · Esc to cancel"})]});const T=g==null?void 0:g(s);return i.jsxs("span",{role:"button",tabIndex:0,className:it.metaValueClickable,onClick:()=>S.startEdit(),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),S.startEdit())},title:"Click to edit","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[T!==void 0?T:s?i.jsx("span",{children:s}):i.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function pd(t){var D;const{value:s,onSave:o,mode:r="edit",options:c,fieldId:d="select",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":_}=t,k=y.useRef(null),S=oh({value:s,onSave:o,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(S.isEditing){const A=window.setTimeout(()=>{var E;(E=k.current)==null||E.focus()},0);return()=>window.clearTimeout(A)}},[S.isEditing]);const T=y.useCallback(A=>{const E=A.target.value;S.ignoreInitialBlurRef.current=!1,E!==s&&o(E),S.cancelEdit()},[s,o,S]),j=y.useCallback(A=>{if(S.ignoreInitialBlurRef.current){S.ignoreInitialBlurRef.current=!1;return}A.relatedTarget instanceof HTMLElement&&A.relatedTarget.dataset.editAction===d||S.cancelEdit()},[d,S]);if(r==="create")return i.jsx("select",{className:it.editSelect,value:s,onChange:A=>m==null?void 0:m(A.target.value),"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(A=>i.jsx("option",{value:A.value,children:A.label},A.value))});if(S.isEditing)return i.jsx("select",{ref:k,className:it.editSelect,value:S.draft,onChange:T,onBlur:j,title:b,"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(A=>i.jsx("option",{value:A.value,children:A.label},A.value))});const w=g==null?void 0:g(s),C=(D=c.find(A=>A.value===s))==null?void 0:D.label;return i.jsxs("button",{type:"button",className:it.metaValueClickable,onClick:()=>S.startEdit(),title:"Click to change","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[w!==void 0?w:C?i.jsx("span",{children:C}):i.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function M5(t){const{checked:s,onChange:o,label:r,ariaLabel:c,"data-testid":d}=t;return i.jsxs("label",{className:it.worktreeToggle,"data-testid":d,children:[i.jsx("input",{type:"checkbox",checked:s,onChange:u=>o(u.target.checked),"aria-label":c}),i.jsx("span",{children:r})]})}const R5="_nav_1snmp_1",I5="_searchForm_1snmp_8",O5="_searchInput_1snmp_15",B5="_searchButton_1snmp_33",L5="_clearButton_1snmp_68",z5="_workspaceSelect_1snmp_85",$5="_listHeader_1snmp_99",H5="_nodeList_1snmp_108",P5="_nodeItem_1snmp_116",U5="_indicator_1snmp_129",V5="_label_1snmp_136",q5="_badge_1snmp_145",Qn={nav:R5,searchForm:I5,searchInput:O5,searchButton:B5,clearButton:L5,workspaceSelect:z5,listHeader:$5,nodeList:H5,nodeItem:P5,indicator:U5,label:V5,badge:q5};function G5({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]),b=y.useCallback(()=>{g(""),d()},[d]),_=y.useCallback(S=>{u(S)},[u]),k=y.useCallback(S=>{g(""),p(S)},[p]);return i.jsxs("div",{className:Qn.nav,"data-testid":"knowledge-nav",children:[i.jsxs("form",{className:Qn.searchForm,onSubmit:v,children:[i.jsx("input",{className:Qn.searchInput,type:"text",placeholder:"Search...",value:m,onChange:S=>{g(S.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),i.jsx("button",{type:"submit",className:Qn.searchButton,disabled:o,children:"Go"})]}),r&&i.jsx("button",{type:"button",className:Qn.clearButton,onClick:b,children:"Clear search"}),i.jsxs("select",{className:Qn.workspaceSelect,onChange:S=>{k(S.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[i.jsx("option",{value:"",children:"All workspaces"}),s.map(S=>i.jsx("option",{value:S.id,children:S.name},S.id))]}),i.jsxs("div",{className:Qn.listHeader,children:["Nodes (",t.length,")"]}),i.jsx("ul",{className:Qn.nodeList,children:t.map(S=>i.jsxs("li",{className:Qn.nodeItem,onClick:()=>{_(S.id)},onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),_(S.id))},role:"button",tabIndex:0,children:[i.jsx("span",{className:Qn.indicator,style:{backgroundColor:S.kind==="reference"?"#4A9EFF":S.category==="decision"?"#22C55E":S.category==="concept"?"#A855F7":S.category==="snippet"?"#6B7280":"#EAB308"}}),i.jsx("span",{className:Qn.label,children:S.label}),i.jsx("span",{className:Qn.badge,children:S.kind==="reference"?S.sourceType:S.category})]},S.id))})]})}const F5="_container_bwu10_1",K5="_hamburger_bwu10_33",Z5="_brand_bwu10_49",Y5="_brandLogo_bwu10_68",J5="_info_bwu10_75",W5="_connectionLabel_bwu10_90",X5="_connectionDot_bwu10_103",Q5="_connected_bwu10_106",eI="_disconnected_bwu10_110",tI="_connecting_bwu10_113",Es={container:F5,hamburger:K5,brand:Z5,brandLogo:Y5,info:J5,connectionLabel:W5,connectionDot:X5,connected:Q5,disconnected:eI,connecting:tI},nI={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},sI={connected:Es.connected,connecting:Es.connecting,disconnected:Es.disconnected};function aI({connectionStatus:t,environments:s,sessions:o,onToggleSidebar:r,sidebarOpen:c}){const d=vt(),u=s.length,p=s.filter(v=>v.status==="connected").length,m=o.filter(v=>["running","idle"].includes(v.status)).length,g=nI[t];return i.jsxs("div",{className:Es.container,children:[r&&i.jsx("button",{type:"button",className:Es.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:i.jsx(dj,{size:wt,"aria-hidden":"true"})}),i.jsx(wi,{text:"Home",placement:"bottom",children:i.jsxs("button",{type:"button",className:Es.brand,onClick:()=>d(Po),"data-testid":"statusbar-brand",children:[i.jsx("img",{src:Cd("icon-192x192.png"),alt:"",className:Es.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),i.jsxs("div",{className:Es.info,children:[i.jsxs("span",{"aria-label":g,children:[i.jsx("span",{className:`${Es.connectionDot} ${sI[t]}`,"aria-hidden":"true",children:i.jsx(Ti,{size:w_,fill:"currentColor"})})," ",i.jsx("span",{className:Es.connectionLabel,"aria-hidden":"true",children:g})]}),i.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),i.jsxs("span",{children:[m," active"]})]})]})}const iI="_nav_gx5h3_1",oI="_tab_gx5h3_35",rI="_tabIcon_gx5h3_68",lI="_tabLabel_gx5h3_79",cI="_tabActive_gx5h3_84",dI="_tabEnd_gx5h3_90",To={nav:iI,tab:oI,tabIcon:rI,tabLabel:lI,tabActive:cI,tabEnd:dI},Qc=[{view:"dashboard",label:"Dashboard",icon:i.jsx(WT,{size:wt}),route:Po,testId:"sidebar-tab-dashboard",order:0},{view:"tasks",label:"Tasks",icon:i.jsx(AT,{size:wt}),route:FN,testId:"sidebar-tab-tasks",order:1},{view:"environments",label:"Environments",icon:i.jsx(gj,{size:wt}),route:Ro,testId:"sidebar-tab-environments",order:2},{view:"chat",label:"Root",icon:i.jsx(fj,{size:wt}),route:GN,testId:"sidebar-tab-chat",order:3},{view:"knowledge",label:"Knowledge",icon:i.jsx(kT,{size:wt}),route:J_,testId:"sidebar-tab-knowledge",order:5},{view:"coordination",label:"Coordination",icon:i.jsx(yj,{size:wt}),route:Z_,testId:"sidebar-tab-coordination",order:6},{view:"settings",label:"Settings",icon:i.jsx(Dj,{size:wt}),route:HN,testId:"sidebar-tab-settings",align:"end"}];function uI(t){return t===Po||t==="/"?"dashboard":t.startsWith(Z_)?"coordination":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(J_)?"knowledge":t.startsWith(ki)?"settings":"tasks"}function fI({tabs:t=Qc}){var g;const s=Jt(),o=vt(),r=y.useRef(null),c=uI(s.pathname),d=y.useMemo(()=>{const v=(b,_)=>(b.order??Number.MAX_SAFE_INTEGER)-(_.order??Number.MAX_SAFE_INTEGER);return[...t.filter(b=>b.align!=="end").sort(v),...t.filter(b=>b.align==="end")]},[t]),u=(g=d.find(v=>v.align==="end"))==null?void 0:g.view,p=y.useCallback(v=>{o(v.route)},[o]),m=y.useCallback(v=>{var T,j;const b=(T=r.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!b)return;const _=Array.from(b).findIndex(w=>w===document.activeElement),k=_>=0?_:d.findIndex(w=>w.view===c);let S=k;if(v.key==="ArrowRight"||v.key==="j"||v.key==="J")v.preventDefault(),S=(k+1)%d.length;else if(v.key==="ArrowLeft"||v.key==="k"||v.key==="K")v.preventDefault(),S=(k-1+d.length)%d.length;else if(v.key==="Home")v.preventDefault(),S=0;else if(v.key==="End")v.preventDefault(),S=d.length-1;else return;o(d[S].route),(j=b[S])==null||j.focus()},[c,o,d]);return i.jsx("nav",{className:To.nav,ref:r,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:m,"data-testid":"sidebar-nav",children:d.map(v=>{const b=v.view===c,_=v.view===u;return i.jsx(wi,{text:v.label,placement:"bottom",className:_?To.tabEnd:void 0,children:i.jsxs("button",{role:"tab",type:"button","aria-selected":b,tabIndex:b?0:-1,className:`${To.tab} ${b?To.tabActive:""}`,onClick:()=>p(v),"data-testid":v.testId,"aria-label":v.label,children:[i.jsx("span",{className:To.tabIcon,"aria-hidden":"true",children:v.icon}),i.jsx("span",{className:To.tabLabel,children:v.label})]})},v.view)})})}const pI="_container_pi6ii_1",mI="_content_pi6ii_66",Kb={container:pI,content:mI},hI=320,R1=220,I1=600,O1="grackle-sidebar-width";function gI(){try{const t=localStorage.getItem(O1);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=R1&&s<=I1)return s}}catch{}return hI}function vI(t){try{localStorage.setItem(O1,String(t))}catch{}}function yI({content:t}){const[s]=y.useState(gI),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>=R1&&m<=I1&&vI(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return i.jsx("div",{className:Kb.container,ref:o,"data-testid":"sidebar",style:{width:s},children:i.jsx("div",{className:Kb.content,children:t})})}const bI="_bar_tnfsh_1",_I="_btnPrimary_tnfsh_32",xI="_statusText_tnfsh_85",kI="_statusCompleted_tnfsh_90",SI="_statusFailed_tnfsh_94",TI="_statusBlocked_tnfsh_98",jI="_hintText_tnfsh_103",jt={bar:bI,btnPrimary:_I,statusText:xI,statusCompleted:kI,statusFailed:SI,statusBlocked:TI,hintText:jI};function wI({sessions:t,tasks:s,environments:o}){const r=vt(),c=Jt(),d=nn("/sessions/:sessionId"),u=nn("/tasks/:taskId"),p=nn("/tasks/:taskId/stream"),m=nn("/tasks/:taskId/edit"),g=nn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),v=nn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),b=nn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),_=nn("/sessions/new"),k=nn("/environments/:environmentId/workspaces/:workspaceId"),S=nn("/tasks/new"),T=nn("/chat"),j=nn("/"),w=nn("/settings/*"),C=d==null?void 0:d.params.sessionId,D=(u==null?void 0:u.params.taskId)??(p==null?void 0:p.params.taskId)??(g==null?void 0:g.params.taskId)??(v==null?void 0:v.params.taskId)??(b==null?void 0:b.params.taskId),A=g??v??b,E=(A==null?void 0:A.params.environmentId)??(k==null?void 0:k.params.environmentId),R=c.pathname.startsWith("/environments")&&!k&&!A,O=!!T,M=!!_,$=!!k&&!g&&!v&&!b,Y=!!S;if(!!j&&!M&&!$&&!Y||!!w||(!!m||!!b)||Y||R||M)return i.jsx(i.Fragment,{});if(O)return o.find(ae=>ae.adapterType==="local"&&ae.status==="connected")?i.jsx(i.Fragment,{}):i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Add a local environment to start chatting"})});if($)return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Select a task or click + to create one"})});if(D){const Z=s.find(B=>B.id===D);if(!Z)return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Loading..."})});const ae=new Map(s.map(B=>[B.id,B])),H=Z.dependsOn.some(B=>{const F=ae.get(B);return F!==void 0&&F.status!=="complete"});if(Z.status==="not_started"){const B=H?Z.dependsOn.map(F=>ae.get(F)).filter(F=>F&&F.status!=="complete").map(F=>F.title):[];return i.jsx("div",{className:jt.bar,children:H?i.jsxs("span",{className:jt.statusBlocked,children:["Blocked by: ",B.join(", ")]}):i.jsx("span",{className:jt.hintText,children:"Use the buttons above to start or manage this task"})})}if(Z.status==="working"||Z.status==="paused"){const B=Z.latestSessionId||void 0,F=B?t.find(ne=>ne.id===B):void 0;return F&&F.status!=="stopped"?i.jsx(i.Fragment,{}):i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Waiting for agent..."})})}if(Z.status==="complete")return i.jsxs("div",{className:jt.bar,children:[i.jsx("span",{className:`${jt.statusText} ${jt.statusCompleted}`,children:"Task completed"}),i.jsx("button",{onClick:()=>r(Di(Z.workspaceId,void 0,E)),className:jt.btnPrimary,children:"+ New Task"})]});if(Z.status==="failed")return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:`${jt.statusText} ${jt.statusFailed}`,children:"Task failed"})})}if(C){const Z=t.find(B=>B.id===C),ae=(Z==null?void 0:Z.status)==="stopped";if(Z!==void 0&&!ae)return i.jsx(i.Fragment,{});if(ae)return i.jsxs("div",{className:jt.bar,children:[i.jsxs("span",{className:`${jt.statusText} ${jt.hintText}`,children:["Session ",Z.endReason||Z.status]}),i.jsx("button",{onClick:()=>r(G_(Z.environmentId)),className:jt.btnPrimary,children:"+ New Chat"})]})}return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Loading..."})})}const NI="_nav_14i94_1",CI="_tab_14i94_24",EI="_tabActive_14i94_62",AI="_tabLabel_14i94_75",DI="_statusDot_14i94_81",MI="_pulse_14i94_87",RI="_addButton_14i94_99",II="_empty_14i94_132",Ha={nav:NI,tab:CI,tabActive:EI,tabLabel:AI,statusDot:DI,pulse:MI,addButton:RI,empty:II},OI={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function BI({environments:t}){const s=vt(),o=y.useRef(null),r=nn("/environments/:environmentId"),c=nn("/environments/:environmentId/edit"),d=nn("/environments/:environmentId/workspaces/:workspaceId"),u=nn("/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(_=>{s(Io(_))},[s]),v=y.useCallback(_=>{var w;const k=(w=o.current)==null?void 0:w.querySelectorAll('[role="tab"]');if(!k||k.length===0)return;const S=Array.from(k).findIndex(C=>C===document.activeElement),T=S>=0?S:t.findIndex(C=>C.id===m);let j=T;if(_.key==="ArrowDown"||_.key==="j"||_.key==="J")_.preventDefault(),j=(T+1)%k.length;else if(_.key==="ArrowUp"||_.key==="k"||_.key==="K")_.preventDefault(),j=(T-1+k.length)%k.length;else if(_.key==="Home")_.preventDefault(),j=0;else if(_.key==="End")_.preventDefault(),j=k.length-1;else return;j<t.length&&s(Io(t[j].id)),k[j].focus()},[m,t,s]),b=m??(t.length>0?t[0].id:void 0);return i.jsxs("div",{className:Ha.nav,"data-testid":"environment-nav",children:[i.jsx("nav",{ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(_=>{const k=_.id===m,S=_.id===b,T=OI[_.status]||"var(--text-tertiary)",j=_.status==="connected";return i.jsxs("button",{role:"tab",type:"button","aria-selected":k,tabIndex:S?0:-1,className:`${Ha.tab} ${k?Ha.tabActive:""}`,onClick:()=>g(_.id),"data-testid":"env-nav-item",children:[i.jsx("span",{className:`${Ha.statusDot} ${j?Ha.pulse:""}`,style:{color:T},"aria-hidden":"true",children:i.jsx(Ti,{size:w_,fill:"currentColor"})}),i.jsx("span",{className:Ha.tabLabel,title:_.displayName||_.id,children:_.displayName||_.id})]},_.id)})}),i.jsx("button",{type:"button",className:Ha.addButton,onClick:()=>s(zN),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&i.jsx("div",{className:Ha.empty,children:"No environments yet."})]})}function LI(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 B1({text:t,indices:s,highlightClass:o}){if(!s||s.length===0)return i.jsx(i.Fragment,{children:t});const r=LI(s),c=[];let d=0;for(const[u,p]of r)u>d&&c.push(i.jsx("span",{children:t.slice(d,u)},`p${d}`)),c.push(i.jsx("mark",{className:o,children:t.slice(u,p+1)},`m${u}`)),d=p+1;return d<t.length&&c.push(i.jsx("span",{children:t.slice(d)},`p${d}`)),i.jsx(i.Fragment,{children:c})}function zI(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 $I(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 Uj){c.add(d);const u=o.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=Ka(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=Ka(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const HI="_container_z4i38_1",PI="_header_z4i38_5",UI="_headerActions_z4i38_17",VI="_searchInput_z4i38_23",qI="_searchHighlight_z4i38_56",GI="_groupToggle_z4i38_62",FI="_groupToggleActive_z4i38_89",KI="_addButton_z4i38_93",ZI="_taskRow_z4i38_120",YI="_selected_z4i38_140",JI="_expandArrow_z4i38_150",WI="_expanded_z4i38_157",XI="_leafSpacer_z4i38_161",QI="_taskStatusIcon_z4i38_166",eO="_taskTitle_z4i38_170",tO="_workspaceBadge_z4i38_177",nO="_childCountBadge_z4i38_195",sO="_dependencyBadge_z4i38_208",aO="_blockedBadge_z4i38_220",iO="_addChildButton_z4i38_225",oO="_emptyState_z4i38_268",rO="_statusGroupHeader_z4i38_275",lO="_statusGroupIcon_z4i38_294",cO="_statusGroupLabel_z4i38_298",dO="_statusGroupCount_z4i38_303",Je={container:HI,header:PI,headerActions:UI,searchInput:VI,searchHighlight:qI,groupToggle:GI,groupToggleActive:FI,addButton:KI,taskRow:ZI,selected:YI,expandArrow:JI,expanded:WI,leafSpacer:XI,taskStatusIcon:QI,taskTitle:eO,workspaceBadge:tO,childCountBadge:nO,dependencyBadge:sO,blockedBadge:aO,addChildButton:iO,emptyState:oO,statusGroupHeader:rO,statusGroupIcon:lO,statusGroupLabel:cO,statusGroupCount:dO},uO=[{name:"title",weight:2},{name:"description",weight:1}],L1=16,fO=16,z1="grackle-task-group-by-status";function Zb(){try{return localStorage.getItem(z1)==="true"}catch{return!1}}function pO(t){try{localStorage.setItem(z1,String(t))}catch{}}function mO({group:t,isExpanded:s,onToggle:o,selectedTaskId:r,navigate:c,titleHighlights:d,workspaceNames:u}){return i.jsxs("div",{"data-testid":`status-group-${t.status}`,children:[i.jsxs("div",{className:Je.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:o,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),o())},children:[i.jsx("span",{className:`${Je.expandArrow} ${s?Je.expanded:""}`,"aria-hidden":"true",children:i.jsx(da,{size:Ze})}),i.jsx("span",{className:Je.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),i.jsx("span",{className:Je.statusGroupLabel,children:t.label}),i.jsx("span",{className:Je.statusGroupCount,children:t.tasks.length})]}),i.jsx(as,{children:s&&i.jsx($t.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=Ka(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return i.jsxs("div",{onClick:()=>c(os(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:b=>{b.currentTarget===b.target&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c(os(p.id)))},className:`${Je.taskRow} ${g?Je.selected:""}`,style:{"--task-indent":`${L1}px`},"data-task-id":p.id,children:[i.jsx("span",{className:Je.leafSpacer}),i.jsx("span",{className:Je.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${rl(p.status)}`,children:m.icon}),i.jsx("span",{className:Je.taskTitle,title:p.title,children:i.jsx(B1,{text:p.title,indices:d.get(p.id),highlightClass:Je.searchHighlight})}),v&&i.jsx("span",{className:Je.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function $1({node:t,depth:s,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=Ka(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(w=>u.get(w)!=="complete"),b=o.has(t.id),_=t.children.length>0,k=c===t.id,S=L1+s*fO,j=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{onClick:()=>d(os(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:w=>{w.currentTarget===w.target&&(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),d(os(t.id)))},className:`${Je.taskRow} ${k?Je.selected:""}`,style:{"--task-indent":`${S}px`},"data-task-id":t.id,children:[_&&i.jsx("span",{className:`${Je.expandArrow} ${b?Je.expanded:""}`,role:"button",tabIndex:0,"aria-label":b?"Collapse task":"Expand task",onClick:w=>{w.stopPropagation(),r(t.id)},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),w.stopPropagation(),r(t.id))},children:i.jsx(da,{size:Ze,"aria-hidden":"true"})}),!_&&i.jsx("span",{className:Je.leafSpacer}),i.jsx("span",{className:Je.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${rl(t.status)}`,children:g.icon}),i.jsx("span",{className:Je.taskTitle,title:t.title,children:i.jsx(B1,{text:t.title,indices:p.get(t.id),highlightClass:Je.searchHighlight})}),j&&i.jsx("span",{className:Je.workspaceBadge,title:j,children:j}),_&&i.jsxs("span",{className:Je.childCountBadge,children:[t.children.filter(w=>w.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&i.jsx("span",{className:`${Je.dependencyBadge} ${v?Je.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<I2&&i.jsx(wi,{text:"Add child task",children:i.jsx("button",{onClick:w=>{w.stopPropagation(),d(Di(t.workspaceId,t.id))},"aria-label":"Add child task",className:Je.addChildButton,children:"+"})})]}),i.jsx(as,{children:_&&b&&i.jsx($t.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(w=>i.jsx($1,{node:w,depth:s+1,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},w.id))})})]})}function hO({workspaces:t,tasks:s}){const o=vt(),[r,c]=y.useState(new Set),[d,u]=y.useState(new Set),[p,m]=y.useState(Zb),[g,v]=y.useState(Zb),[b,_]=y.useState(new Map),k=nn("/tasks/:taskId/*"),S=(k==null?void 0:k.params.taskId)!=="new"?k==null?void 0:k.params.taskId:void 0,T=y.useMemo(()=>new Map(s.map(Z=>[Z.id,Z.status])),[s]),j=y.useMemo(()=>new Map(t.map(Z=>[Z.id,Z.name])),[t]),w=()=>{const Z=!p;pO(Z),m(Z),Z&&(v(!0),_(new Map))},C=Z=>{_(ae=>{const H=new Map(ae),B=H.has(Z)?H.get(Z):g;return H.set(Z,!B),H})},D=Z=>b.has(Z)?b.get(Z):g,A=Z=>{c(ae=>{const H=new Set(ae);return H.has(Z)?(H.delete(Z),u(B=>new Set(B).add(Z))):(H.add(Z),u(B=>{const F=new Set(B);return F.delete(Z),F})),H})};y.useEffect(()=>{const Z=new Set(s.filter(ae=>ae.parentTaskId).map(ae=>ae.parentTaskId));Z.size>0&&c(ae=>{const H=new Set(ae);for(const B of Z)d.has(B)||H.add(B);return H})},[s,d]);const[E,R]=y.useState(""),{directMatchTaskIds:O,treeMatchTaskIds:M,titleHighlights:$}=y.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const Z=R2(s,E,uO),ae=new Set(Z.map(ge=>ge.item.id)),H=new Map;for(const ge of Z){const ne=ge.matches.find(ce=>ce.key==="title");ne&&H.set(ge.item.id,ne.indices)}const B=new Set(ae),F=new Map(s.map(ge=>[ge.id,ge]));for(const ge of[...ae]){let ne=F.get(ge);for(;ne!=null&&ne.parentTaskId;)B.add(ne.parentTaskId),ne=F.get(ne.parentTaskId)}return{directMatchTaskIds:ae,treeMatchTaskIds:B,titleHighlights:H}},[E,s]),Y=O!==null,V=Y?p?O:M:null,ee=V?s.filter(Z=>V.has(Z.id)):s,le=p?[]:zI(ee);return i.jsxs("div",{className:Je.container,children:[i.jsxs("div",{className:Je.header,children:[i.jsx("span",{children:"Tasks"}),i.jsxs("div",{className:Je.headerActions,children:[i.jsx(wi,{text:p?"Switch to tree view":"Group tasks by status",children:i.jsx("button",{className:`${Je.groupToggle} ${p?Je.groupToggleActive:""}`,onClick:w,"aria-label":p?"Switch to tree view":"Group tasks by status","aria-pressed":p,"data-testid":"task-group-by-status-toggle",children:i.jsx(oj,{size:zt})})}),i.jsx(wi,{text:"New task",children:i.jsx("button",{className:Je.addButton,onClick:()=>o(Di()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&i.jsx("input",{type:"text",value:E,onChange:Z=>R(Z.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:Je.searchInput,"data-testid":"sidebar-search"}),p?$I(ee,T).map(Z=>i.jsx(mO,{group:Z,isExpanded:D(Z.status),onToggle:()=>C(Z.status),selectedTaskId:S,navigate:o,titleHighlights:$,workspaceNames:j},Z.status)):le.map(Z=>i.jsx($1,{node:Z,depth:0,expandedTasks:r,toggleTask:A,selectedTaskId:S,navigate:o,taskStatusById:T,titleHighlights:$,workspaceNames:j},Z.id)),ee.length===0&&!Y&&i.jsx("div",{className:Je.emptyState,children:"No tasks yet. Click + to create one."}),ee.length===0&&Y&&i.jsx("div",{className:Je.emptyState,children:"No matching tasks"})]})}const gO="_toast_ed2dk_1",vO="_success_ed2dk_18",yO="_icon_ed2dk_22",bO="_error_ed2dk_25",_O="_warning_ed2dk_32",xO="_info_ed2dk_38",kO="_message_ed2dk_53",SO="_close_ed2dk_60",$r={toast:gO,success:vO,icon:yO,error:bO,warning:_O,info:xO,message:kO,close:SO},TO={success:i.jsx(Ci,{size:wt}),error:i.jsx(Is,{size:wt}),warning:i.jsx(mm,{size:wt}),info:i.jsx(pm,{size:wt})};function jO({toast:t,onDismiss:s}){return y.useEffect(()=>{const o=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(o)},[t.id,t.duration,s]),i.jsxs($t.div,{className:`${$r.toast} ${$r[t.variant]}`,role:"status",initial:{opacity:0,y:-16,scale:.94},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.94},transition:{duration:.2,ease:"easeOut"},layout:!0,children:[i.jsx("span",{className:$r.icon,"aria-hidden":"true",children:TO[t.variant]}),i.jsx("span",{className:$r.message,children:t.message}),i.jsx("button",{type:"button",className:$r.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:i.jsx(Is,{size:zt,"aria-hidden":"true"})})]})}const wO="_container_qqse2_1",NO={container:wO};function CO({toasts:t,onDismiss:s}){return i.jsx("div",{className:NO.container,"data-testid":"toast-container",children:i.jsx(as,{children:t.map(o=>i.jsx(jO,{toast:o,onDismiss:s},o.id))})})}const EO="_callout_e5awm_1",AO="_success_e5awm_11",DO="_icon_e5awm_15",MO="_error_e5awm_18",RO="_warning_e5awm_25",IO="_info_e5awm_32",OO="_content_e5awm_48",BO="_close_e5awm_53",Hr={callout:EO,success:AO,icon:DO,error:MO,warning:RO,info:IO,content:OO,close:BO},LO={success:i.jsx(Ci,{size:wt}),error:i.jsx(Is,{size:wt}),warning:i.jsx(mm,{size:wt}),info:i.jsx(pm,{size:wt})};function zO({variant:t="info",children:s,dismissible:o=!1,className:r}){const[c,d]=y.useState(!1);return i.jsx(i.Fragment,{children:!c&&i.jsxs("div",{className:[Hr.callout,Hr[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[i.jsx("span",{className:Hr.icon,"aria-hidden":"true",children:LO[t]}),i.jsx("span",{className:Hr.content,children:s}),o&&i.jsx("button",{type:"button",className:Hr.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:i.jsx(Is,{size:zt,"aria-hidden":"true"})})]})})}function $O({currentVersion:t,latestVersion:s,updateAvailable:o,isDocker:r}){if(!o)return i.jsx(i.Fragment,{});const c=r?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return i.jsx("div",{"data-testid":"update-banner",children:i.jsxs(zO,{variant:"info",dismissible:!0,children:[i.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",t,")."," ","Run: ",i.jsx("code",{children:c})]})})}const HO="_container_m1fsr_1",PO="_heading_m1fsr_7",UO="_section_m1fsr_14",VO="_sectionTitle_m1fsr_26",qO="_sectionDescription_m1fsr_35",GO="_emptyState_m1fsr_41",FO="_tokenList_m1fsr_48",KO="_tokenRow_m1fsr_55",ZO="_tokenBadge_m1fsr_68",YO="_tokenName_m1fsr_83",JO="_tokenTarget_m1fsr_90",WO="_deleteButton_m1fsr_99",XO="_addForm_m1fsr_113",QO="_formRow_m1fsr_119",eB="_input_m1fsr_125",tB="_select_m1fsr_155",nB="_addButton_m1fsr_187",sB="_emptyStateInfo_m1fsr_221",aB="_themeOptions_m1fsr_229",iB="_themeOption_m1fsr_229",oB="_themeOptionSelected_m1fsr_254",rB="_themeOptionHeader_m1fsr_259",lB="_themeOptionLabel_m1fsr_266",cB="_themeOptionDesc_m1fsr_273",dB="_variantToggle_m1fsr_279",uB="_variantButton_m1fsr_286",fB="_variantActive_m1fsr_305",pB="_themeSwatches_m1fsr_311",mB="_themeSwatch_m1fsr_311",hB="_systemToggle_m1fsr_325",gB="_systemToggleHint_m1fsr_341",vB="_themeActive_m1fsr_348",yB="_aboutGrid_m1fsr_354",bB="_aboutItem_m1fsr_360",_B="_aboutLabel_m1fsr_373",xB="_aboutValue_m1fsr_379",kB="_aboutDot_m1fsr_387",SB="_aboutDotConnected_m1fsr_394",TB="_aboutDotDisconnected_m1fsr_398",jB="_aboutDotConnecting_m1fsr_402",fe={container:HO,heading:PO,section:UO,sectionTitle:VO,sectionDescription:qO,emptyState:GO,tokenList:FO,tokenRow:KO,tokenBadge:ZO,tokenName:YO,tokenTarget:JO,deleteButton:WO,addForm:XO,formRow:QO,input:eB,select:tB,addButton:nB,emptyStateInfo:sB,themeOptions:aB,themeOption:iB,themeOptionSelected:oB,themeOptionHeader:rB,themeOptionLabel:lB,themeOptionDesc:cB,variantToggle:dB,variantButton:uB,variantActive:fB,themeSwatches:pB,themeSwatch:mB,systemToggle:hB,systemToggleHint:gB,themeActive:vB,aboutGrid:yB,aboutItem:bB,aboutLabel:_B,aboutValue:xB,aboutDot:kB,aboutDotConnected:SB,aboutDotDisconnected:TB,aboutDotConnecting:jB},wB=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function NB({tokens:t,onSetToken:s,onDeleteToken:o,onShowToast:r}){const[c,d]=y.useState(""),[u,p]=y.useState(""),[m,g]=y.useState("env_var"),[v,b]=y.useState(""),[_,k]=y.useState(null),S=w=>{if(w.preventDefault(),!c||!u)return;const C=m==="env_var"?v||c.toUpperCase()+"_TOKEN":"";s(c,u,m,C,m==="file"?v:""),r==null||r("Token saved successfully","success"),d(""),p(""),b("")},T=w=>{k(w)},j=()=>{_&&(o(_),r==null||r("Token deleted","info")),k(null)};return i.jsxs(i.Fragment,{children:[i.jsx(ys,{isOpen:_!==null,title:"Delete Token?",description:_?`"${_}" will be permanently removed.`:void 0,onConfirm:j,onCancel:()=>k(null)}),i.jsxs("section",{className:fe.section,children:[i.jsx("h3",{className:fe.sectionTitle,children:"Tokens"}),i.jsx("p",{className:fe.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?i.jsx("div",{className:fe.emptyStateInfo,children:"Add your first API token to enable service integrations."}):i.jsx("div",{className:fe.tokenList,children:t.map(w=>i.jsxs("div",{className:fe.tokenRow,children:[i.jsx("span",{className:fe.tokenBadge,children:w.tokenType}),i.jsx("span",{className:fe.tokenName,children:w.name}),i.jsx("span",{className:fe.tokenTarget,children:w.tokenType==="env_var"?w.envVar:w.filePath}),i.jsx("button",{className:fe.deleteButton,onClick:()=>T(w.name),title:`Delete ${w.name}`,"aria-label":`Delete ${w.name}`,children:i.jsx(Is,{size:zt,"aria-hidden":"true"})})]},w.name))}),i.jsxs("form",{className:fe.addForm,onSubmit:S,children:[i.jsxs("div",{className:fe.formRow,children:[i.jsx("input",{className:fe.input,type:"text",placeholder:"Token name",value:c,onChange:w=>d(w.target.value)}),i.jsx("input",{className:fe.input,type:"password",placeholder:"Value",value:u,onChange:w=>p(w.target.value)})]}),i.jsxs("div",{className:fe.formRow,children:[i.jsx("select",{className:fe.select,value:m,onChange:w=>g(w.target.value),children:wB.map(w=>i.jsx("option",{value:w.value,children:w.label},w.value))}),i.jsx("input",{className:fe.input,type:"text",placeholder:m==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:v,onChange:w=>b(w.target.value)}),i.jsx("button",{className:fe.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const Ed=[{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"]}],H1=new Set(Ed.map(t=>t.id)),Yb="grackle";function am(t){return Ed.find(s=>s.id===t)}function CB({themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c}){return i.jsxs("section",{className:fe.section,children:[i.jsx("h3",{className:fe.sectionTitle,children:"Appearance"}),i.jsx("p",{className:fe.sectionDescription,children:"Choose how Grackle looks across the app."}),i.jsx("div",{className:fe.themeOptions,children:Ed.filter(d=>!d.hidden).map(d=>{const u=!!(d.variantLightId&&d.variantDarkId),p=u?t===d.id||t===d.variantLightId||t===d.variantDarkId:t===d.id,m=u&&s===d.variantLightId;return i.jsxs("button",{type:"button",className:`${fe.themeOption} ${p?fe.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>o(d.id),children:[i.jsxs("span",{className:fe.themeOptionHeader,children:[i.jsxs("span",{children:[i.jsx("span",{className:fe.themeOptionLabel,children:d.label}),i.jsx("span",{className:fe.themeOptionDesc,children:d.description})]}),u&&i.jsxs("span",{className:fe.variantToggle,children:[i.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${p&&m?fe.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantLightId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantLightId))},"aria-label":"Light variant","aria-pressed":p&&m,children:"☼"}),i.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${p&&!m?fe.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantDarkId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantDarkId))},"aria-label":"Dark variant","aria-pressed":p&&!m,children:"☾"})]})]}),d.swatches&&i.jsx("span",{className:fe.themeSwatches,children:d.swatches.map((g,v)=>i.jsx("span",{className:fe.themeSwatch,style:{background:g}},v))})]},d.id)})}),i.jsxs("label",{className:fe.systemToggle,children:[i.jsx("input",{type:"checkbox",checked:r,onChange:d=>c(d.target.checked)}),i.jsx("span",{children:"Match system light/dark preference"})]}),i.jsx("p",{className:fe.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),i.jsxs("p",{className:fe.themeActive,children:["Active theme: ",i.jsx("strong",{children:s})]})]})}const EB={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},AB={connected:fe.aboutDotConnected,connecting:fe.aboutDotConnecting,disconnected:fe.aboutDotDisconnected};function DB({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 i.jsxs("section",{className:fe.section,"data-testid":"about-panel",children:[i.jsx("h3",{className:fe.sectionTitle,children:"About"}),i.jsx("p",{className:fe.sectionDescription,children:"Connection status and application information."}),i.jsxs("div",{className:fe.aboutGrid,children:[i.jsxs("div",{className:fe.aboutItem,children:[i.jsx("span",{className:fe.aboutLabel,children:"Connection"}),i.jsxs("span",{className:fe.aboutValue,children:[i.jsx("span",{className:`${fe.aboutDot} ${AB[t]}`}),EB[t]]})]}),i.jsxs("div",{className:fe.aboutItem,children:[i.jsx("span",{className:fe.aboutLabel,children:"Environments"}),i.jsxs("span",{className:fe.aboutValue,children:[r,"/",c," connected"]})]}),i.jsxs("div",{className:fe.aboutItem,children:[i.jsx("span",{className:fe.aboutLabel,children:"Active Sessions"}),i.jsx("span",{className:fe.aboutValue,children:d})]}),i.jsxs("div",{className:fe.aboutItem,children:[i.jsx("span",{className:fe.aboutLabel,children:"Version"}),i.jsx("span",{className:fe.aboutValue,children:"0.119.0"})]})]})]})}const MB="_container_cddyd_1",RB="_header_cddyd_8",IB="_headerTitle_cddyd_35",OB="_badge_cddyd_44",BB="_headerActions_cddyd_54",LB="_body_cddyd_61",zB="_formContent_cddyd_73",$B="_section_cddyd_85",HB="_label_cddyd_91",PB="_titleInput_cddyd_98",UB="_descriptionTextarea_cddyd_131",VB="_parentContext_cddyd_167",qB="_parentLabel_cddyd_175",GB="_parentName_cddyd_182",FB="_personaSelect_cddyd_186",KB="_depList_cddyd_220",ZB="_depItem_cddyd_226",YB="_depItemSelected_cddyd_248",JB="_noDeps_cddyd_252",WB="_btnPrimary_cddyd_258",XB="_btnGhost_cddyd_289",at={container:MB,header:RB,headerTitle:IB,badge:OB,headerActions:BB,body:LB,formContent:zB,section:$B,label:HB,titleInput:PB,descriptionTextarea:UB,parentContext:VB,parentLabel:qB,parentName:GB,personaSelect:FB,depList:KB,depItem:ZB,depItemSelected:YB,noDeps:JB,btnPrimary:WB,btnGhost:XB};function P1({mode:t,taskId:s,workspaceId:o,parentTaskId:r,environmentId:c,tasks:d,workspaces:u,personas:p,onCreateTask:m,onUpdateTask:g,onEditDone:v,onShowToast:b}){const _=vt(),k=t==="edit",S=k&&s?d.find(_e=>_e.id===s):void 0,T=k?(S==null?void 0:S.workspaceId)??"":o??"",[j,w]=y.useState(T),C=T||j,D=u.find(_e=>_e.id===C),A=c??(D==null?void 0:D.linkedEnvironmentIds[0]),E=!k&&!o,R=k?(S==null?void 0:S.parentTaskId)??"":r??"",O=R?d.find(_e=>_e.id===R):void 0,[M,$]=y.useState((S==null?void 0:S.title)??""),[Y,V]=y.useState((S==null?void 0:S.description)??""),[ee,le]=y.useState((S==null?void 0:S.dependsOn)??[]),[Z,ae]=y.useState((S==null?void 0:S.defaultPersonaId)??""),[H,B]=y.useState((S==null?void 0:S.canDecompose)??!1),[F,ge]=y.useState(!1),ne=y.useRef(!1);y.useEffect(()=>{k&&S&&!ne.current&&(ne.current=!0,$(S.title),V(S.description),le(S.dependsOn),ae(S.defaultPersonaId),B(S.canDecompose))},[k,S]);const ce=d.filter(_e=>_e.workspaceId===C&&(!k||_e.id!==s)&&_e.id!==R),me=M.trim().length>0&&(!k||S!==void 0)&&C.length>0,ke=_e=>{le(Oe=>Oe.includes(_e)?Oe.filter(Ht=>Ht!==_e):[...Oe,_e])},De=()=>{!me||F||k&&S===void 0||(k&&s?(g(s,M.trim(),Y,ee,Z),b==null||b("Task updated","success"),v?v():_(os(s,void 0,C,A),{replace:!0})):(ge(!0),m(C,M.trim(),Y,ee.length>0?ee:void 0,R||void 0,Z,H,()=>{b==null||b("Task created","success"),_(o?ji(o,A):"/tasks",{replace:!0})},_e=>{b==null||b(_e,"error"),ge(!1)})))},ot=()=>{if(v){v();return}_(k&&s?os(s,void 0,C,A):o?ji(o,A):"/tasks")},yt=k?"edit task":R?"child task":"new task";return i.jsxs("div",{className:at.container,children:[i.jsxs("div",{className:at.header,children:[i.jsxs("div",{className:at.headerTitle,children:[i.jsx("span",{className:at.badge,children:yt}),O&&i.jsxs("span",{className:at.parentContext,children:[i.jsx("span",{className:at.parentLabel,children:"Child of"}),i.jsx("span",{className:at.parentName,children:O.title})]})]}),i.jsxs("div",{className:at.headerActions,children:[i.jsx("button",{onClick:De,disabled:!me||F,className:at.btnPrimary,"data-testid":"task-edit-save",children:F?"Creating…":k?"Save Changes":"Create"}),i.jsx("button",{onClick:ot,className:at.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:at.body,children:i.jsxs("div",{className:at.formContent,children:[E&&i.jsxs("div",{className:at.section,children:[i.jsx("label",{className:at.label,htmlFor:"task-edit-workspace",children:"Workspace"}),i.jsxs("select",{id:"task-edit-workspace",value:j,onChange:_e=>w(_e.target.value),className:at.personaSelect,"data-testid":"task-edit-workspace",children:[i.jsx("option",{value:"",children:"Select a workspace..."}),u.map(_e=>i.jsx("option",{value:_e.id,children:_e.name},_e.id))]})]}),i.jsxs("div",{className:at.section,children:[i.jsx("label",{className:at.label,htmlFor:"task-edit-title",children:"Title"}),i.jsx("input",{id:"task-edit-title",type:"text",value:M,onChange:_e=>$(_e.target.value),placeholder:"Task title...",autoFocus:!0,className:at.titleInput,"data-testid":"task-edit-title",onKeyDown:_e=>{_e.key==="Enter"&&me&&De()}})]}),i.jsxs("div",{className:at.section,children:[i.jsx("label",{className:at.label,htmlFor:"task-edit-description",children:"Description"}),i.jsx("textarea",{id:"task-edit-description",value:Y,onChange:_e=>V(_e.target.value),placeholder:"Describe the task... (markdown supported)",className:at.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),i.jsxs("div",{className:at.section,children:[i.jsx("label",{className:at.label,htmlFor:"task-edit-persona",children:"Default Persona"}),i.jsxs("select",{id:"task-edit-persona",value:Z,onChange:_e=>ae(_e.target.value),className:at.personaSelect,"data-testid":"task-edit-persona",children:[i.jsx("option",{value:"",children:"(Inherit)"}),p.map(_e=>i.jsx("option",{value:_e.id,children:_e.name},_e.id))]})]}),!k&&i.jsx("div",{className:at.section,children:i.jsxs("label",{className:at.depItem,"data-testid":"task-edit-can-decompose",children:[i.jsx("input",{type:"checkbox",checked:H,onChange:_e=>B(_e.target.checked)}),"Can spawn subtasks"]})}),i.jsxs("div",{className:at.section,children:[i.jsx("div",{className:at.label,children:"Dependencies"}),ce.length===0?i.jsx("div",{className:at.noDeps,children:"No other tasks in this workspace"}):i.jsx("div",{className:at.depList,children:ce.map(_e=>{const Oe=ee.includes(_e.id);return i.jsxs("label",{className:`${at.depItem} ${Oe?at.depItemSelected:""}`,"data-testid":`dep-option-${_e.id}`,children:[i.jsx("input",{type:"checkbox",checked:Oe,onChange:()=>ke(_e.id)}),_e.title,i.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",_e.status,")"]})]},_e.id)})})]})]})})]})}const QB="_actionButtons_1rjka_1",eL="_btnPrimary_1rjka_8",tL="_btnDanger_1rjka_39",nL="_btnGhost_1rjka_78",Zt={actionButtons:QB,btnPrimary:eL,btnDanger:tL,btnGhost:nL};function sL({task:t,sessionId:s,isBlocked:o,onStart:r,onResume:c,onStop:d,onPause:u,onDelete:p,onEdit:m}){if(t.status==="not_started")return o?i.jsxs("div",{className:Zt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:m,className:Zt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Zt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):i.jsxs("div",{className:Zt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{"data-testid":"task-header-start",onClick:r,className:Zt.btnPrimary,children:"Start"}),i.jsx("button",{onClick:m,className:Zt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Zt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return i.jsxs("div",{className:Zt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Zt.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:u,disabled:!s,className:Zt.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused")return i.jsxs("div",{className:Zt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Zt.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:c,className:Zt.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),i.jsx("button",{onClick:p,className:Zt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="complete")return i.jsx("div",{className:Zt.actionButtons,"data-testid":"task-action-buttons",children:i.jsx("button",{onClick:p,className:Zt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return i.jsxs("div",{className:Zt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:r,className:Zt.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),i.jsx("button",{onClick:p,className:Zt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const aL="_workpadSection_y8nj9_1",iL="_workpadLabel_y8nj9_9",oL="_workpadStatus_y8nj9_17",rL="_workpadSummary_y8nj9_23",lL="_workpadExtra_y8nj9_29",Pa={workpadSection:aL,workpadLabel:iL,workpadStatus:oL,workpadSummary:rL,workpadExtra:lL};function cL({workpad:t}){if(!t)return;let s;try{const o=JSON.parse(t);if(o==null||typeof o!="object"||Array.isArray(o))return;s=o}catch{return i.jsxs("div",{className:Pa.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:Pa.workpadLabel,children:"Workpad"}),i.jsx("div",{className:Pa.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return i.jsxs("div",{className:Pa.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:Pa.workpadLabel,children:"Workpad"}),s.status&&i.jsx("div",{className:Pa.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&i.jsx("div",{className:Pa.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&i.jsx("div",{className:Pa.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const dL="_overviewDashboard_r05qm_1",uL="_overviewHero_r05qm_7",fL="_statusBadge_r05qm_14",pL="_statusPending_r05qm_26",mL="_statusAssigned_r05qm_31",hL="_statusInProgress_r05qm_36",gL="_statusReview_r05qm_41",vL="_statusDone_r05qm_46",yL="_statusFailed_r05qm_51",bL="_statusWaitingInput_r05qm_56",_L="_overviewBranchPill_r05qm_61",xL="_branchLink_r05qm_76",kL="_overviewSection_r05qm_87",SL="_overviewLabel_r05qm_93",TL="_overviewValue_r05qm_100",jL="_overviewMuted_r05qm_105",wL="_overviewMarkdown_r05qm_111",NL="_envRow_r05qm_180",CL="_envDot_r05qm_186",EL="_envDotGreen_r05qm_193",AL="_envDotYellow_r05qm_197",DL="_envDotRed_r05qm_201",ML="_envDotGray_r05qm_205",RL="_depList_r05qm_209",IL="_depItem_r05qm_215",OL="_depBlocked_r05qm_222",BL="_depDone_r05qm_226",LL="_timeline_r05qm_230",zL="_timelineRow_r05qm_236",$L="_timelineKey_r05qm_243",HL="_timelineValue_r05qm_249",PL="_timelineDelta_r05qm_253",UL="_reviewNotes_r05qm_264",be={overviewDashboard:dL,overviewHero:uL,statusBadge:fL,statusPending:pL,statusAssigned:mL,statusInProgress:hL,statusReview:gL,statusDone:vL,statusFailed:yL,statusWaitingInput:bL,overviewBranchPill:_L,branchLink:xL,overviewSection:kL,overviewLabel:SL,overviewValue:TL,overviewMuted:jL,overviewMarkdown:wL,envRow:NL,envDot:CL,envDotGreen:EL,envDotYellow:AL,envDotRed:DL,envDotGray:ML,depList:RL,depItem:IL,depBlocked:OL,depDone:BL,timeline:LL,timelineRow:zL,timelineKey:$L,timelineValue:HL,timelineDelta:PL,reviewNotes:UL};function Hc(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 kp(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 Jb(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?be.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?be.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?be.envDotRed:be.envDotGray}function VL({status:t}){const s=Ka(t),o=Pj(t);return i.jsx("span",{className:`${be.statusBadge} ${be[o]??be.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function qL({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,b=r.find(S=>S.id===t.workspaceId),_=o.find(S=>S.id===d),k=t.branch&&(b!=null&&b.repoUrl)?`${b.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return i.jsxs("div",{className:be.overviewDashboard,"data-testid":"task-overview-panel",children:[i.jsxs("div",{className:be.overviewHero,children:[i.jsx(VL,{status:t.status}),t.branch&&i.jsx("span",{className:be.overviewBranchPill,"data-testid":"task-overview-branch",children:k?i.jsxs("a",{href:k,target:"_blank",rel:"noreferrer noopener",className:be.branchLink,children:["🔗"," ",t.branch]}):i.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&i.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-description",children:[i.jsx("div",{className:be.overviewLabel,children:"Description"}),i.jsx("div",{className:be.overviewMarkdown,children:i.jsx(um,{remarkPlugins:[fm],children:t.description})})]}),t.workpad&&i.jsx(cL,{workpad:t.workpad}),i.jsxs("div",{className:be.overviewSection,children:[i.jsx("div",{className:be.overviewLabel,children:"Environment"}),g&&v?i.jsxs("div",{className:be.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${be.envDot} ${Jb(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),i.jsx("span",{className:be.overviewValue,children:v.displayName})]}):_?i.jsxs("div",{className:be.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${be.envDot} ${Jb(_.status)}`,title:_.status,"aria-label":`Status: ${_.status}`,role:"img"}),i.jsx("span",{className:be.overviewValue,children:_.displayName}),i.jsx("span",{className:be.overviewMuted,children:"(workspace default)"})]}):i.jsx("div",{className:be.overviewMuted,children:"Set in workspace settings"})]}),i.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-dependencies",children:[i.jsx("div",{className:be.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?i.jsx("div",{className:be.overviewMuted,children:"None"}):i.jsx("div",{className:be.depList,children:t.dependsOn.map(S=>{const T=s.get(S),j=(T==null?void 0:T.status)==="complete";return i.jsxs("div",{className:`${be.depItem} ${j?be.depDone:be.depBlocked}`,children:[i.jsx("span",{children:j?"✓":"○"}),i.jsx("span",{children:(T==null?void 0:T.title)??S})]},S)})})]}),i.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-timeline",children:[i.jsx("div",{className:be.overviewLabel,children:"Timeline"}),i.jsxs("div",{className:be.timeline,children:[t.createdAt&&i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Created"}),i.jsx("span",{className:be.timelineValue,children:Hc(t.createdAt)})]}),t.assignedAt&&(()=>{const S=kp(t.createdAt,t.assignedAt);return i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Assigned"}),i.jsx("span",{className:be.timelineValue,children:Hc(t.assignedAt)}),S!==void 0&&i.jsx("span",{className:be.timelineDelta,children:S})]})})(),t.startedAt&&(()=>{const S=kp(t.assignedAt??t.createdAt,t.startedAt);return i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Started"}),i.jsx("span",{className:be.timelineValue,children:Hc(t.startedAt)}),S!==void 0&&i.jsx("span",{className:be.timelineDelta,children:S})]})})(),t.completedAt&&(()=>{const S=kp(t.startedAt,t.completedAt);return i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Completed"}),i.jsx("span",{className:be.timelineValue,children:Hc(t.completedAt)}),S!==void 0&&i.jsx("span",{className:be.timelineDelta,children:S})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&i.jsx("div",{className:be.overviewMuted,children:"No timing data"})]})]}),u&&u.costMillicents>0&&i.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-usage",children:[i.jsx("div",{className:be.overviewLabel,children:"Usage"}),i.jsxs("div",{className:be.timeline,children:[i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Cost"}),i.jsx("span",{className:be.timelineValue,children:As(u.costMillicents)}),i.jsxs("span",{className:be.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costMillicents>u.costMillicents&&i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Total (incl. subtasks)"}),i.jsx("span",{className:be.timelineValue,children:As(p.costMillicents)}),i.jsxs("span",{className:be.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),(t.tokenBudget>0||t.costBudgetMillicents>0)&&i.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-budget",children:[i.jsx("div",{className:be.overviewLabel,children:"Budget"}),i.jsxs("div",{className:be.timeline,children:[t.tokenBudget>0&&i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Tokens"}),i.jsxs("span",{className:be.timelineValue,children:[Oo(((u==null?void 0:u.inputTokens)??0)+((u==null?void 0:u.outputTokens)??0))," / ",Oo(t.tokenBudget)]})]}),t.costBudgetMillicents>0&&i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Cost"}),i.jsxs("span",{className:be.timelineValue,children:[As((u==null?void 0:u.costMillicents)??0)," / ",As(t.costBudgetMillicents)]})]})]})]}),t.reviewNotes&&i.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-review-notes",children:[i.jsx("div",{className:be.overviewLabel,children:"Review Notes"}),i.jsx("div",{className:be.reviewNotes,children:t.reviewNotes})]})]})}function GL({plugins:t,loading:s,onSetPluginEnabled:o}){return i.jsxs("div",{className:fe.container,"data-testid":"plugins-panel",children:[i.jsx("h2",{className:fe.heading,children:"Plugins"}),i.jsxs("div",{className:fe.section,children:[i.jsx("p",{className:fe.sectionDescription,children:"Enable or disable optional Grackle plugins. A server restart is required for changes to take effect."}),s&&i.jsx("p",{className:fe.emptyState,children:"Loading plugins..."}),!s&&t.length===0&&i.jsx("p",{className:fe.emptyState,children:"No plugins found."}),!s&&t.map(r=>{const c=r.enabled!==r.loaded;return i.jsxs("div",{className:fe.tokenRow,"data-testid":`plugin-row-${r.name}`,children:[i.jsxs("div",{style:{flex:1},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[i.jsx("span",{className:fe.tokenName,children:r.name}),r.required&&i.jsx("span",{className:fe.tokenBadge,title:"Required — cannot be disabled",children:"required"})]}),i.jsx("div",{className:fe.tokenTarget,children:r.description}),c&&i.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"})]}),i.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:i.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 FL({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),[k,S]=y.useState(!1),[T,j]=y.useState(!1),[w,C]=y.useState(null),D=t.find(M=>M.id===w),A=async M=>{if(M.preventDefault(),!(!p.trim()||!g.trim())){S(!0);try{await o(p.trim(),g.trim(),"",b),u==null||u("GitHub account added","success"),m(""),v(""),_(!1)}catch($){const Y=$ instanceof Error?$.message:"Failed to add account";u==null||u(Y,"error")}finally{S(!1)}}},E=async M=>{try{await r(M,{isDefault:!0}),u==null||u("Default account updated","success")}catch($){const Y=$ instanceof Error?$.message:"Failed to update account";u==null||u(Y,"error")}},R=async()=>{if(w)try{await c(w),u==null||u("GitHub account removed","info")}catch(M){const $=M instanceof Error?M.message:"Failed to remove account";u==null||u($,"error")}finally{C(null)}},O=async()=>{j(!0);try{const M=await d();M.imported>0?u==null||u(`Imported ${M.imported} account(s): ${M.usernames.join(", ")}`,"success"):u==null||u("No new accounts to import","info")}catch(M){const $=M instanceof Error?M.message:"Import failed";u==null||u($,"error")}finally{j(!1)}};return i.jsxs(i.Fragment,{children:[i.jsx(ys,{isOpen:w!==null,title:"Remove GitHub Account?",description:D?`"${D.label}"${D.username?` (@${D.username})`:""} will be permanently removed.`:void 0,onConfirm:()=>{R().catch(()=>{})},onCancel:()=>C(null)}),i.jsxs("section",{className:fe.section,"data-testid":"github-accounts-panel",children:[i.jsx("h3",{className:fe.sectionTitle,children:"GitHub Accounts"}),i.jsx("p",{className:fe.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?i.jsx("div",{className:fe.emptyState,children:"Loading..."}):t.length===0?i.jsx("div",{className:fe.emptyStateInfo,children:"No GitHub accounts registered. Add one below or import from the gh CLI."}):i.jsx("div",{className:fe.tokenList,children:t.map(M=>i.jsxs("div",{className:fe.tokenRow,"data-testid":`github-account-row-${M.id}`,children:[M.isDefault&&i.jsx("span",{className:fe.tokenBadge,title:"Default account",children:"default"}),i.jsx("span",{className:fe.tokenName,children:M.label}),M.username&&i.jsxs("span",{className:fe.tokenTarget,children:["@",M.username]}),!M.isDefault&&i.jsx("button",{className:fe.deleteButton,onClick:()=>{E(M.id).catch(()=>{})},title:"Set as default","aria-label":`Set ${M.label} as default`,"data-testid":`github-account-set-default-${M.id}`,children:i.jsx(Oj,{size:zt,"aria-hidden":"true"})}),i.jsx("button",{className:fe.deleteButton,onClick:()=>C(M.id),title:`Remove ${M.label}`,"aria-label":`Remove ${M.label}`,"data-testid":`github-account-remove-${M.id}`,children:i.jsx(Is,{size:zt,"aria-hidden":"true"})})]},M.id))}),i.jsxs("form",{className:fe.addForm,onSubmit:M=>{A(M).catch(()=>{})},children:[i.jsxs("div",{className:fe.formRow,children:[i.jsx("input",{className:fe.input,type:"text",placeholder:"Label (e.g. personal, work)",value:p,onChange:M=>m(M.target.value),"data-testid":"github-account-label-input"}),i.jsx("input",{className:fe.input,type:"password",placeholder:"Personal access token",value:g,onChange:M=>v(M.target.value),"data-testid":"github-account-token-input"})]}),i.jsxs("div",{className:fe.formRow,children:[i.jsxs("label",{className:fe.tokenTarget,style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[i.jsx("input",{type:"checkbox",checked:b,onChange:M=>_(M.target.checked),"data-testid":"github-account-default-checkbox"}),"Set as default"]}),i.jsx("button",{className:fe.addButton,type:"submit",disabled:!p.trim()||!g.trim()||k,"data-testid":"github-account-add-button",children:k?"Adding...":"Add Account"}),i.jsx("button",{className:fe.addButton,type:"button",onClick:()=>{O().catch(()=>{})},disabled:T,"data-testid":"github-account-import-button",children:T?"Importing...":"Import from gh CLI"})]})]})]})]})}const KL="_container_legrg_1",ZL="_header_legrg_8",YL="_headerTitle_legrg_35",JL="_badge_legrg_44",WL="_headerActions_legrg_54",XL="_body_legrg_61",QL="_formContent_legrg_73",e8="_section_legrg_85",t8="_label_legrg_91",n8="_nameInput_legrg_98",s8="_fieldInput_legrg_131",a8="_adapterSelect_legrg_164",i8="_readOnlyValue_legrg_198",o8="_codespaceSection_legrg_204",r8="_codespaceActions_legrg_210",l8="_creatingHint_legrg_216",c8="_errorHint_legrg_222",d8="_btnPrimary_legrg_235",u8="_btnGhost_legrg_266",oe={container:KL,header:ZL,headerTitle:YL,badge:JL,headerActions:WL,body:XL,formContent:QL,section:e8,label:t8,nameInput:n8,fieldInput:s8,adapterSelect:a8,readOnlyValue:i8,codespaceSection:o8,codespaceActions:r8,creatingHint:l8,errorHint:c8,btnPrimary:d8,btnGhost:u8},ed=1,td=65535;function Sp(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=ed&&s<=td}function Tp(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function f8({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(""),[k,S]=y.useState("");return g==="create"?i.jsxs("div",{className:oe.codespaceSection,children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Repository"}),i.jsx("input",{type:"text",value:b,onChange:T=>_(T.target.value),placeholder:"owner/repo",className:oe.fieldInput,"data-testid":"env-codespace-repo"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Machine Type"}),i.jsx("input",{type:"text",value:k,onChange:T=>S(T.target.value),placeholder:"Machine type (optional)...",className:oe.fieldInput,"data-testid":"env-codespace-machine"})]}),i.jsxs("div",{className:oe.codespaceActions,children:[i.jsx("button",{onClick:()=>{b.trim()&&(m(b.trim(),k.trim()||void 0),v("pick"),_(""),S(""))},disabled:!b.trim(),className:oe.btnPrimary,children:"Create"}),i.jsx("button",{onClick:()=>{v("pick"),_(""),S("")},className:oe.btnGhost,children:"Cancel"})]})]}):i.jsx("div",{className:oe.codespaceSection,children:i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Codespace"}),!u&&i.jsxs("select",{value:t,onChange:T=>{T.target.value==="__create__"?(v("create"),s("")):(s(T.target.value),T.target.value&&!o.trim()&&r(T.target.value))},disabled:p,className:oe.adapterSelect,"data-testid":"env-codespace-select",children:[i.jsx("option",{value:"",children:"Select a codespace..."}),c.map(T=>i.jsxs("option",{value:T.name,children:[T.name," (",T.repository,") — ",T.state]},T.name)),i.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&i.jsx("span",{className:oe.creatingHint,children:"Creating codespace..."}),u&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:oe.errorHint,children:u}),i.jsx("input",{type:"text",value:t,onChange:T=>s(T.target.value),placeholder:"Or enter codespace name manually...",className:oe.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&i.jsx("span",{className:oe.errorHint,children:d})]})})}function U1({mode:t,environmentId:s,environments:o,githubAccounts:r,onAddEnvironment:c,onUpdateEnvironment:d,onListCodespaces:u,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:b,onListDockerContainers:_,dockerContainers:k,dockerContainersError:S,onShowToast:T}){const j=vt(),w=t==="edit",C=w&&s?o.find(re=>re.id===s):void 0,[D,A]=y.useState(""),[E,R]=y.useState("local"),[O,M]=y.useState(""),[$,Y]=y.useState(""),[V,ee]=y.useState(""),[le,Z]=y.useState(""),[ae,H]=y.useState(""),[B,F]=y.useState(""),[ge,ne]=y.useState(""),[ce,me]=y.useState(""),[ke,De]=y.useState("create"),[ot,yt]=y.useState(""),[_e,Oe]=y.useState(null),Ht=y.useCallback(()=>{const re={};if(E==="local"){if(O.trim()&&(re.host=O.trim()),$.trim()){const ve=Number($);Number.isInteger(ve)&&(re.port=ve)}}else if(E==="ssh"){if(re.host=O.trim(),V.trim()&&(re.user=V.trim()),$.trim()){const ve=Number($);Number.isInteger(ve)&&(re.sshPort=ve)}le.trim()&&(re.identityFile=le.trim())}else E==="docker"?ke==="attach"?ot.trim()&&(re.attach=ot.trim()):(ae.trim()&&(re.image=ae.trim()),B.trim()&&(re.repo=B.trim())):E==="codespace"&&(re.codespaceName=ge.trim());return re},[E,O,$,V,le,ae,B,ge,ke,ot]),Nt=()=>!(!D.trim()||E==="ssh"&&!O.trim()||E==="codespace"&&!ge.trim()||E==="docker"&&ke==="attach"&&!ot.trim()||(E==="local"||E==="ssh")&&!Sp($)),ue=()=>{Nt()&&(c(D.trim(),E,Ht(),ce||void 0),T==null||T("Environment added successfully","success"),j(Ro,{replace:!0}))},Re=()=>{j(s?Io(s):Ro)},Q=y.useCallback((re,ve)=>{if(!C||!s)return;const Xe=Tp(C.adapterConfig),an=ve.trim();an?Xe[re]=an:delete Xe[re],d(s,{adapterConfig:Xe})},[C,s,d]),et=y.useCallback((re,ve)=>{if(!C||!s)return;const Xe=Tp(C.adapterConfig);if(ve.trim()){const an=Number(ve);Number.isInteger(an)&&an>=ed&&an<=td&&(Xe[re]=an)}else delete Xe[re];d(s,{adapterConfig:Xe})},[C,s,d]);if(w){if(!C)return i.jsxs("div",{className:oe.container,children:[i.jsxs("div",{className:oe.header,children:[i.jsx("div",{className:oe.headerTitle,children:i.jsx("span",{className:oe.badge,children:"edit environment"})}),i.jsx("div",{className:oe.headerActions,children:i.jsx("button",{onClick:Re,className:oe.btnGhost,children:"Back"})})]}),i.jsx("div",{className:oe.body,children:i.jsx("div",{className:oe.formContent,children:i.jsx("span",{className:oe.readOnlyValue,children:"Environment not found"})})})]});const re=Tp(C.adapterConfig);return i.jsxs("div",{className:oe.container,"data-testid":"env-edit-panel",children:[i.jsxs("div",{className:oe.header,children:[i.jsx("div",{className:oe.headerTitle,children:i.jsx("span",{className:oe.badge,children:"edit environment"})}),i.jsx("div",{className:oe.headerActions,children:i.jsx("button",{onClick:Re,className:oe.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),i.jsx("div",{className:oe.body,children:i.jsxs("div",{className:oe.formContent,children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Name"}),i.jsx(Bt,{value:C.displayName,onSave:ve=>{s&&d(s,{displayName:ve})},validate:ve=>ve.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:_e,onActivate:Oe,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Adapter Type"}),i.jsx("span",{className:oe.readOnlyValue,"data-testid":"env-edit-adapter-type",children:C.adapterType})]}),(C.adapterType==="codespace"||C.adapterType==="docker")&&(r.length>0||!!C.githubAccountId)&&i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"GitHub Account"}),i.jsxs("select",{value:C.githubAccountId||"",onChange:ve=>{s&&d(s,{githubAccountId:ve.target.value})},className:oe.adapterSelect,"data-testid":"env-edit-github-account",children:[i.jsx("option",{value:"",children:"(Default)"}),r.map(ve=>i.jsxs("option",{value:ve.id,children:[ve.label,ve.username?` (@${ve.username})`:"",ve.isDefault?" — default":""]},ve.id))]})]}),C.adapterType==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Host"}),i.jsx(Bt,{value:String(re.host??""),onSave:ve=>Q("host",ve),mode:"edit",fieldId:"host",activeFieldId:_e,onActivate:Oe,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Port"}),i.jsx(Bt,{value:String(re.port??""),onSave:ve=>et("port",ve),validate:ve=>Sp(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:_e,onActivate:Oe,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),C.adapterType==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Host"}),i.jsx(Bt,{value:String(re.host??""),onSave:ve=>Q("host",ve),validate:ve=>ve.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:_e,onActivate:Oe,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"User"}),i.jsx(Bt,{value:String(re.user??""),onSave:ve=>Q("user",ve),mode:"edit",fieldId:"user",activeFieldId:_e,onActivate:Oe,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"SSH Port"}),i.jsx(Bt,{value:String(re.sshPort??""),onSave:ve=>et("sshPort",ve),validate:ve=>Sp(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:_e,onActivate:Oe,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Identity File"}),i.jsx(Bt,{value:String(re.identityFile??""),onSave:ve=>Q("identityFile",ve),mode:"edit",fieldId:"identityFile",activeFieldId:_e,onActivate:Oe,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),C.adapterType==="docker"&&re.attach!==void 0&&i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Attach (container)"}),i.jsx(Bt,{value:String(re.attach??""),onSave:ve=>Q("attach",ve),validate:ve=>ve.trim()===""?"Container name is required":void 0,mode:"edit",fieldId:"attach",activeFieldId:_e,onActivate:Oe,placeholder:"container name or ID",ariaLabel:"Attach container","data-testid":"env-edit-attach"})]}),C.adapterType==="docker"&&re.attach===void 0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Image"}),i.jsx(Bt,{value:String(re.image??""),onSave:ve=>Q("image",ve),mode:"edit",fieldId:"image",activeFieldId:_e,onActivate:Oe,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Repo"}),i.jsx(Bt,{value:String(re.repo??""),onSave:ve=>Q("repo",ve),mode:"edit",fieldId:"repo",activeFieldId:_e,onActivate:Oe,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),C.adapterType==="codespace"&&i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Codespace Name"}),i.jsx(Bt,{value:String(re.codespaceName??""),onSave:ve=>Q("codespaceName",ve),validate:ve=>ve.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:_e,onActivate:Oe,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return i.jsxs("div",{className:oe.container,"data-testid":"env-create-panel",children:[i.jsxs("div",{className:oe.header,children:[i.jsx("div",{className:oe.headerTitle,children:i.jsx("span",{className:oe.badge,children:"new environment"})}),i.jsxs("div",{className:oe.headerActions,children:[i.jsx("button",{onClick:ue,disabled:!Nt(),className:oe.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),i.jsx("button",{onClick:Re,className:oe.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:oe.body,children:i.jsxs("div",{className:oe.formContent,children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-name",children:"Name"}),i.jsx("input",{id:"env-create-name",type:"text",value:D,onChange:re=>A(re.target.value),placeholder:"Environment name...",autoFocus:!0,className:oe.nameInput,"data-testid":"env-create-name",onKeyDown:re=>{re.key==="Enter"&&Nt()&&ue()}})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),i.jsxs("select",{id:"env-create-adapter",value:E,onChange:re=>{R(re.target.value),re.target.value==="codespace"&&u(ce||void 0)},className:oe.adapterSelect,"data-testid":"env-create-adapter",children:[i.jsx("option",{value:"local",children:"local"}),i.jsx("option",{value:"ssh",children:"ssh"}),i.jsx("option",{value:"docker",children:"docker"}),i.jsx("option",{value:"codespace",children:"codespace"})]})]}),(E==="codespace"||E==="docker")&&r.length>0&&i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-github-account",children:"GitHub Account"}),i.jsxs("select",{id:"env-create-github-account",value:ce,onChange:re=>{me(re.target.value),E==="codespace"&&u(re.target.value||void 0)},className:oe.adapterSelect,"data-testid":"env-create-github-account",children:[i.jsx("option",{value:"",children:"(Default)"}),r.map(re=>i.jsxs("option",{value:re.id,children:[re.label," (@",re.username,")",re.isDefault?" — default":""]},re.id))]})]}),E==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:O,onChange:re=>M(re.target.value),placeholder:"Host (optional)...",className:oe.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-port",children:"Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:ed,max:td,value:$,onChange:re=>Y(re.target.value),placeholder:"Port (optional)...",className:oe.fieldInput,"data-testid":"env-create-port"})]})]}),E==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:O,onChange:re=>M(re.target.value),placeholder:"Host (required)...",className:oe.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-user",children:"User"}),i.jsx("input",{id:"env-create-user",type:"text",value:V,onChange:re=>ee(re.target.value),placeholder:"User (optional)...",className:oe.fieldInput,"data-testid":"env-create-user"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-port",children:"SSH Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:ed,max:td,value:$,onChange:re=>Y(re.target.value),placeholder:"SSH port (optional)...",className:oe.fieldInput,"data-testid":"env-create-port"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-identity",children:"Identity File"}),i.jsx("input",{id:"env-create-identity",type:"text",value:le,onChange:re=>Z(re.target.value),placeholder:"Identity file (optional)...",className:oe.fieldInput,"data-testid":"env-create-identity"})]})]}),E==="docker"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-docker-mode",children:"Source"}),i.jsxs("select",{id:"env-docker-mode",value:ke,onChange:re=>{const ve=re.target.value;De(ve),ve==="attach"&&_()},className:oe.adapterSelect,"data-testid":"env-docker-mode",children:[i.jsx("option",{value:"create",children:"Create new container"}),i.jsx("option",{value:"attach",children:"Attach to existing container"})]})]}),ke==="create"?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-image",children:"Image"}),i.jsx("input",{id:"env-create-image",type:"text",value:ae,onChange:re=>H(re.target.value),placeholder:"Image (optional)...",className:oe.fieldInput,"data-testid":"env-create-image"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-repo",children:"Repo"}),i.jsx("input",{id:"env-create-repo",type:"text",value:B,onChange:re=>F(re.target.value),placeholder:"Repo (optional)...",className:oe.fieldInput,"data-testid":"env-create-repo"})]})]}):i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Container"}),!S&&k.length>0&&i.jsxs("select",{value:ot,onChange:re=>{yt(re.target.value),re.target.value&&!D.trim()&&A(re.target.value)},className:oe.adapterSelect,"data-testid":"env-docker-container-select",children:[i.jsx("option",{value:"",children:"Select a container..."}),k.map(re=>i.jsxs("option",{value:re.name,children:[re.name," (",re.image,") ",re.status]},re.id))]}),(S||k.length===0)&&i.jsxs(i.Fragment,{children:[S?i.jsx("span",{className:oe.errorHint,children:S}):i.jsx("span",{className:oe.creatingHint,children:"No running containers found."}),i.jsx("input",{type:"text",value:ot,onChange:re=>{yt(re.target.value),re.target.value&&!D.trim()&&A(re.target.value)},placeholder:"Enter container name/ID...",className:oe.fieldInput,"data-testid":"env-docker-container-manual"})]})]})]}),E==="codespace"&&i.jsx(f8,{codespaceName:ge,onCodespaceNameChange:ne,envName:D,onEnvNameChange:A,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:b})]})})]})}const p8="_group_1iprv_1",m8="_groupTitle_1iprv_8",h8="_shortcutList_1iprv_17",g8="_shortcutRow_1iprv_23",v8="_keys_1iprv_36",y8="_kbd_1iprv_43",b8="_description_1iprv_60",yi={group:p8,groupTitle:m8,shortcutList:h8,shortcutRow:g8,keys:v8,kbd:y8,description:b8},_8=[{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"}]},{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:"Root",shortcuts:[{keys:["Ctrl/Cmd","Enter"],description:"Send message (when the composer is focused)"},{keys:["Enter"],description:"Insert a new line in the message composer"}]}];function x8(){return i.jsxs("section",{className:fe.section,"data-testid":"keyboard-shortcuts-panel",children:[i.jsx("h3",{className:fe.sectionTitle,children:"Keyboard Shortcuts"}),i.jsx("p",{className:fe.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),_8.map(t=>i.jsxs("div",{className:yi.group,children:[i.jsx("h4",{className:yi.groupTitle,children:t.title}),i.jsx("div",{className:yi.shortcutList,children:t.shortcuts.map(s=>i.jsxs("div",{className:yi.shortcutRow,children:[i.jsx("span",{className:yi.keys,children:s.keys.map(o=>i.jsx("kbd",{className:yi.kbd,children:o},o))}),i.jsx("span",{className:yi.description,children:s.description})]},s.description))})]},t.title))]})}const k8=[{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 S8({credentialProviders:t,onUpdateCredentialProviders:s}){const o=(r,c)=>{const d={...t};r==="claude"?d.claude=c:d[r]=c,s(d)};return i.jsxs("section",{className:fe.section,children:[i.jsx("h3",{className:fe.sectionTitle,children:"Credential Providers"}),i.jsx("p",{className:fe.sectionDescription,children:"Enable providers to automatically forward credentials to environments at task start. Credentials are read fresh from the host each time."}),i.jsx("div",{className:fe.tokenList,children:k8.map(r=>i.jsxs("div",{className:fe.tokenRow,children:[i.jsx("span",{className:fe.tokenName,children:r.label}),i.jsx("span",{className:fe.tokenTarget,children:r.description}),i.jsx("select",{className:fe.select,value:t[r.key],onChange:c=>o(r.key,c.target.value),children:r.options.map(c=>i.jsx("option",{value:c.value,children:c.label},c.value))})]},r.key))})]})}const T8="_container_10efq_1",j8="_header_10efq_7",w8="_list_10efq_105",N8="_card_10efq_111",C8="_cardHeader_10efq_125",E8="_cardTitle_10efq_135",A8="_defaultBadge_10efq_141",D8="_cardActions_10efq_155",M8="_description_10efq_160",R8="_meta_10efq_166",I8="_empty_10efq_212",O8="_typeBadge_10efq_362",es={container:T8,header:j8,list:w8,card:N8,cardHeader:C8,cardTitle:E8,defaultBadge:A8,cardActions:D8,description:M8,meta:R8,empty:I8,typeBadge:O8};function B8({personas:t,appDefaultPersonaId:s,onDeletePersona:o,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=y.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await o(v),p(null)};return i.jsxs("div",{className:es.container,children:[i.jsxs("div",{className:es.header,children:[i.jsx("h2",{children:"Personas"}),i.jsx(sn,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?i.jsx("p",{className:es.empty,children:"No personas yet. Create one to get started."}):i.jsx("div",{className:es.list,children:t.map(v=>{const b=s===v.id,_=v.type==="script";return i.jsxs("div",{className:es.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:k=>{k.currentTarget===k.target&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(v.id))},children:[i.jsxs("div",{className:es.cardHeader,children:[i.jsxs("span",{className:es.cardTitle,children:[i.jsx("strong",{children:v.name}),i.jsx("span",{className:es.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:_?"Script":"Agent"}),b&&i.jsx("span",{className:es.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),i.jsxs("div",{className:es.cardActions,onClick:k=>k.stopPropagation(),children:[!b&&i.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>{r(v.id).catch(()=>{})},"data-testid":`persona-set-default-${v.id}`,title:"Set as app default persona",children:"Set Default"}),i.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),i.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&i.jsx("p",{className:es.description,children:v.description}),i.jsxs("div",{className:es.meta,children:[v.runtime&&i.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&i.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&i.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),i.jsx(ys,{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 L8="_container_uy08i_1",z8="_header_uy08i_7",$8="_count_uy08i_13",H8="_presets_uy08i_18",P8="_presetButton_uy08i_24",U8="_filterInput_uy08i_41",V8="_groups_uy08i_53",q8="_group_uy08i_53",G8="_groupHeader_uy08i_68",F8="_groupName_uy08i_77",K8="_groupCount_uy08i_81",Z8="_toolList_uy08i_87",Y8="_toolItem_uy08i_95",J8="_toolName_uy08i_103",yn={container:L8,header:z8,count:$8,presets:H8,presetButton:P8,filterInput:U8,groups:V8,group:q8,groupHeader:G8,groupName:F8,groupCount:K8,toolList:Z8,toolItem:Y8,toolName:J8},W8=(()=>{const t=new Map;for(const s of b_){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()}))})(),X8=[{name:"default",label:"Default",tools:y_},{name:"worker",label:"Worker",tools:O2},{name:"orchestrator",label:"Orchestrator",tools:B2},{name:"admin",label:"Admin",tools:L2}];function Wb({selectedTools:t,onChange:s,disabled:o}){const[r,c]=y.useState(""),d=y.useMemo(()=>new Set(t),[t]),u=y.useCallback(v=>{if(o)return;const b=new Set(d);b.has(v)?b.delete(v):b.add(v),s([...b].sort())},[d,s,o]),p=y.useCallback((v,b)=>{if(o)return;const _=new Set(d);for(const k of v)b?_.delete(k):_.add(k);s([..._].sort())},[d,s,o]),m=y.useCallback(v=>{o||s([...v].sort())},[s,o]),g=r.toLowerCase();return i.jsxs("div",{className:yn.container,"data-testid":"mcp-tool-selector",children:[i.jsx("div",{className:yn.header,children:i.jsx("span",{className:yn.count,children:t.length===0?`Using default (${y_.length} tools)`:`${t.length} of ${b_.size} tools selected`})}),i.jsxs("div",{className:yn.presets,"data-testid":"mcp-tool-presets",children:[X8.map(v=>i.jsx("button",{type:"button",className:yn.presetButton,disabled:o,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),i.jsx("button",{type:"button",className:yn.presetButton,disabled:o,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),i.jsx("input",{type:"text",className:yn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:o,"data-testid":"mcp-tool-filter"}),i.jsx("div",{className:yn.groups,children:W8.map(({group:v,tools:b})=>{const _=g?b.filter(S=>S.toLowerCase().includes(g)):b;if(_.length===0)return null;const k=_.every(S=>d.has(S));return i.jsxs("div",{className:yn.group,"data-testid":`tool-group-${v}`,children:[i.jsxs("label",{className:yn.groupHeader,children:[i.jsx("input",{type:"checkbox",checked:k,onChange:()=>p(_,k),disabled:o,"data-testid":`group-toggle-${v}`}),i.jsx("span",{className:yn.groupName,children:v}),i.jsxs("span",{className:yn.groupCount,children:["(",_.filter(S=>d.has(S)).length,"/",_.length,")"]})]}),i.jsx("div",{className:yn.toolList,children:_.map(S=>i.jsxs("label",{className:yn.toolItem,children:[i.jsx("input",{type:"checkbox",checked:d.has(S),onChange:()=>u(S),disabled:o,"data-testid":`tool-${S}`}),i.jsx("span",{className:yn.toolName,children:S})]},S))})]},v)})})]})}function im(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 V1(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 Q8="_container_1gfuq_1",e7="_header_1gfuq_7",t7="_list_1gfuq_19",n7="_card_1gfuq_25",s7="_cardHeader_1gfuq_40",a7="_cardTitle_1gfuq_46",i7="_statusBadge_1gfuq_56",o7="_enabled_1gfuq_68",r7="_disabled_1gfuq_71",l7="_cardActions_1gfuq_75",c7="_cardMeta_1gfuq_80",d7="_empty_1gfuq_98",ts={container:Q8,header:e7,list:t7,card:n7,cardHeader:s7,cardTitle:a7,statusBadge:i7,enabled:o7,disabled:r7,cardActions:l7,cardMeta:c7,empty:d7};function u7({schedules:t,personas:s,onDeleteSchedule:o,onToggleEnabled:r,onNavigateToNew:c,onNavigateToSchedule:d}){const[u,p]=y.useState(null),m=u?t.find(_=>_.id===u):void 0,g=async _=>{await o(_),p(null)},v=y.useMemo(()=>{const _=new Map;for(const k of s)_.set(k.id,k.name);return _},[s]),b=_=>v.get(_)??_;return i.jsxs("div",{className:ts.container,children:[i.jsxs("div",{className:ts.header,children:[i.jsx("h2",{children:"Schedules"}),i.jsx(sn,{variant:"primary",size:"md",onClick:c,"data-testid":"schedule-new-button",children:"+ New Schedule"})]}),t.length===0?i.jsx("p",{className:ts.empty,"data-testid":"schedule-empty-state",children:"No schedules yet. Create one to run tasks on a recurring cadence."}):i.jsx("div",{className:ts.list,children:t.map(_=>i.jsxs("div",{className:ts.card,"data-testid":`schedule-card-${_.id}`,onClick:()=>d(_.id),role:"button",tabIndex:0,onKeyDown:k=>{k.currentTarget===k.target&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(_.id))},children:[i.jsxs("div",{className:ts.cardHeader,children:[i.jsxs("span",{className:ts.cardTitle,children:[i.jsx("strong",{children:_.title}),i.jsx("span",{className:`${ts.statusBadge} ${_.enabled?ts.enabled:ts.disabled}`,"data-testid":`schedule-status-badge-${_.id}`,children:_.enabled?"Enabled":"Disabled"})]}),i.jsxs("div",{className:ts.cardActions,onClick:k=>k.stopPropagation(),children:[i.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>{(async()=>{await r(_.id,{enabled:!_.enabled})})().catch(()=>{})},"data-testid":`schedule-toggle-${_.id}`,title:_.enabled?"Disable schedule":"Enable schedule",children:_.enabled?"Disable":"Enable"}),i.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>d(_.id),"data-testid":`schedule-edit-${_.id}`,children:"Edit"}),i.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>p(_.id),"data-testid":`schedule-delete-${_.id}`,children:"Delete"})]})]}),i.jsxs("div",{className:ts.cardMeta,children:[i.jsx("span",{"data-testid":`schedule-expression-${_.id}`,children:_.scheduleExpression}),_.personaId&&i.jsxs("span",{"data-testid":`schedule-persona-${_.id}`,children:["Persona: ",b(_.personaId)]}),i.jsxs("span",{"data-testid":`schedule-last-run-${_.id}`,children:["Last run: ",_.lastRunAt?im(_.lastRunAt):"Never"]}),_.enabled&&_.nextRunAt?i.jsxs("span",{"data-testid":`schedule-next-run-${_.id}`,children:["Next run: ",V1(_.nextRunAt)]}):null,_.runCount>0&&i.jsxs("span",{"data-testid":`schedule-run-count-${_.id}`,children:["Runs: ",_.runCount]})]})]},_.id))}),i.jsx(ys,{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 f7="_nav_1bhou_1",p7="_tab_1bhou_24",m7="_tabIcon_1bhou_62",h7="_tabActive_1bhou_68",Pc={nav:f7,tab:p7,tabIcon:m7,tabActive:h7},na=[{path:"credentials",label:"Credentials",icon:i.jsx(ej,{size:wt})},{path:"github-accounts",label:"GitHub Accounts",icon:i.jsx(KT,{size:wt})},{path:"personas",label:"Personas",icon:i.jsx(zj,{size:wt})},{path:"schedules",label:"Schedules",icon:i.jsx(TT,{size:wt})},{path:"appearance",label:"Appearance",icon:i.jsx(_j,{size:wt})},{path:"shortcuts",label:"Shortcuts",icon:i.jsx(nj,{size:wt})},{path:"plugins",label:"Plugins",icon:i.jsx(wj,{size:wt})},{path:"about",label:"About",icon:i.jsx(pm,{size:wt})}];function g7(){var u;const t=Jt(),s=vt(),o=y.useRef(null),r=((u=na.find(p=>{const m=`${ki}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??na[0].path,c=y.useCallback(p=>{s(`${ki}/${p}`)},[s]),d=y.useCallback(p=>{var k,S;const m=(k=o.current)==null?void 0:k.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(T=>T===document.activeElement),v=g>=0?g:na.findIndex(T=>T.path===r);let b=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),b=(v+1)%na.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),b=(v-1+na.length)%na.length;else if(p.key==="Home")p.preventDefault(),b=0;else if(p.key==="End")p.preventDefault(),b=na.length-1;else return;const _=na[b].path;s(`${ki}/${_}`),(S=m[b])==null||S.focus()},[r,s]);return i.jsx("nav",{className:Pc.nav,ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:na.map(p=>{const m=p.path===r;return i.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Pc.tab} ${m?Pc.tabActive:""}`,onClick:()=>c(p.path),children:[i.jsx("span",{className:Pc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}const v7=["lifecycle:","pipe:","stdin:"];function q1(t){return t.selfEcho?"chatroom":t.name.startsWith("pipe:")?"pipe":"channel"}function y7(t,s){let o=!1;for(const r of t.subscribers){const c=s.get(r.sessionId);if(c&&(o=!0,c.taskId))return{kind:"task",taskId:c.taskId}}return o?{kind:"unattached"}:{kind:"external"}}function b7(t,s){const o=new Map(s.map(u=>[u.id,u])),r=new Map,c=[];for(const u of t){const p=y7(u,o);if(p.kind==="task"){const m=r.get(p.taskId);m?m.push(u):r.set(p.taskId,[u])}else c.push(u)}const d=Array.from(r,([u,p])=>({taskId:u,streams:p}));return c.length>0&&d.push({taskId:void 0,streams:c}),d}const _7="_container_16qkd_1",x7="_header_16qkd_7",k7="_title_16qkd_15",S7="_headerActions_16qkd_21",T7="_internalsToggle_16qkd_27",j7="_refreshButton_16qkd_37",w7="_state_16qkd_52",N7="_group_16qkd_59",C7="_groupHeader_16qkd_63",E7="_row_16qkd_72",A7="_selected_16qkd_92",D7="_kindBadge_16qkd_96",M7="_kindChatroom_16qkd_108",R7="_kindPipe_16qkd_114",I7="_kindChannel_16qkd_120",O7="_streamName_16qkd_126",B7="_meta_16qkd_135",Yt={container:_7,header:x7,title:k7,headerActions:S7,internalsToggle:T7,refreshButton:j7,state:w7,group:N7,groupHeader:C7,row:E7,selected:A7,kindBadge:D7,kindChatroom:M7,kindPipe:R7,kindChannel:I7,streamName:O7,meta:B7},L7={chatroom:"Chatroom",pipe:"Pipe",channel:"Channel"};function z7({kind:t}){return t==="chatroom"?i.jsx(mj,{size:Ze,"aria-hidden":"true"}):t==="pipe"?i.jsx(GT,{size:Ze,"aria-hidden":"true"}):i.jsx(YT,{size:Ze,"aria-hidden":"true"})}function $7({streams:t,sessions:s,tasks:o,loading:r,loadError:c=!1,loadedOnce:d=!0,showInternals:u,onToggleInternals:p,selectedStreamId:m,onSelectStream:g,onRefresh:v}){const b=b7(t,s),_={chatroom:Yt.kindChatroom,pipe:Yt.kindPipe,channel:Yt.kindChannel},k=S=>{var T;return((T=o.find(j=>j.id===S))==null?void 0:T.title)??S};return i.jsxs("div",{className:Yt.container,"data-testid":"coordination-list",children:[i.jsxs("div",{className:Yt.header,children:[i.jsx("span",{className:Yt.title,children:"Coordination"}),i.jsxs("div",{className:Yt.headerActions,children:[i.jsxs("label",{className:Yt.internalsToggle,children:[i.jsx("input",{type:"checkbox",checked:u,onChange:S=>p(S.target.checked),"data-testid":"coordination-show-internals"}),"Show internals"]}),v&&i.jsx("button",{type:"button",className:Yt.refreshButton,onClick:v,"aria-label":"Refresh streams","data-testid":"coordination-refresh",children:i.jsx(Cj,{size:Ze,"aria-hidden":"true"})})]})]}),r&&t.length===0&&i.jsxs("div",{className:Yt.state,children:["Loading","…"]}),!r&&c&&i.jsx("div",{className:Yt.state,"data-testid":"coordination-error",children:"Unable to load streams"}),!r&&!c&&d&&t.length===0&&i.jsx("div",{className:Yt.state,"data-testid":"coordination-empty",children:"No active streams"}),b.map(S=>i.jsxs("div",{className:Yt.group,children:[i.jsx("div",{className:Yt.groupHeader,children:S.taskId?k(S.taskId):"Unattached / external (CLI · MCP)"}),S.streams.map(T=>{const j=q1(T),w=T.id===m;return i.jsxs("button",{type:"button",className:`${Yt.row}${w?` ${Yt.selected}`:""}`,onClick:()=>g(T.id),"data-testid":`coordination-row-${T.id}`,"aria-current":w?"page":void 0,children:[i.jsxs("span",{className:`${Yt.kindBadge} ${_[j]}`,children:[i.jsx(z7,{kind:j})," ",L7[j]]}),i.jsx("span",{className:Yt.streamName,children:T.name}),i.jsxs("span",{className:Yt.meta,children:[T.subscriberCount," ",T.subscriberCount===1?"sub":"subs"," ","·"," ",T.messageBufferDepth," buffered"]})]},T.id)})]},S.taskId??"__orphans__"))]})}const H7="_transcript_1p4cm_1",P7="_message_1p4cm_10",U7="_meta_1p4cm_16",V7="_sender_1p4cm_24",q7="_time_1p4cm_29",G7="_content_1p4cm_34",F7="_state_1p4cm_42",Ua={transcript:H7,message:P7,meta:U7,sender:V7,time:q7,content:G7,state:F7};function K7(t){const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleTimeString()}function Z7({messages:t,loading:s=!1}){return s?i.jsx("div",{className:Ua.state,"data-testid":"stream-transcript-loading",children:"Loading transcript…"}):t.length===0?i.jsx("div",{className:Ua.state,"data-testid":"stream-transcript-empty",children:"No messages yet."}):i.jsx("div",{className:Ua.transcript,"data-testid":"stream-transcript",children:t.map(o=>i.jsxs("div",{className:Ua.message,"data-testid":"stream-transcript-message",children:[i.jsxs("div",{className:Ua.meta,children:[i.jsx("span",{className:Ua.sender,title:o.senderId,children:o.senderId.slice(0,12)}),i.jsx("span",{className:Ua.time,children:K7(o.timestamp)})]}),i.jsx("div",{className:Ua.content,children:o.content})]},o.seq))})}const Y7="_panel_iibrt_1",J7="_header_iibrt_24",W7="_title_iibrt_33",X7="_closeButton_iibrt_43",Q7="_body_iibrt_57",ez="_section_iibrt_63",tz="_sectionLabel_iibrt_67",nz="_metaRow_iibrt_76",sz="_metaKey_iibrt_84",az="_metaValue_iibrt_90",iz="_subscriberCard_iibrt_99",oz="_subscriberHeader_iibrt_107",rz="_sessionLink_iibrt_114",lz="_badges_iibrt_132",cz="_badgeRw_iibrt_150 _badge_iibrt_132",dz="_badgeR_iibrt_150 _badge_iibrt_132",uz="_badgeW_iibrt_162 _badge_iibrt_132",fz="_badgeAsync_iibrt_168 _badge_iibrt_132",pz="_badgeSync_iibrt_174 _badge_iibrt_132",mz="_badgeDetach_iibrt_178 _badge_iibrt_132",hz="_spawnTag_iibrt_184 _badge_iibrt_132",gz="_fdNumber_iibrt_189",vz="_emptySubscribers_iibrt_195",yz="_metaValueMono_iibrt_201 _metaValue_iibrt_90",bz="_advanced_iibrt_216",_z="_advancedSummary_iibrt_220",Pe={panel:Y7,header:J7,title:W7,closeButton:X7,body:Q7,section:ez,sectionLabel:tz,metaRow:nz,metaKey:sz,metaValue:az,subscriberCard:iz,subscriberHeader:oz,sessionLink:rz,badges:lz,badgeRw:cz,badgeR:dz,badgeW:uz,badgeAsync:fz,badgeSync:pz,badgeDetach:mz,spawnTag:hz,fdNumber:gz,emptySubscribers:vz,metaValueMono:yz,advanced:bz,advancedSummary:_z},xz={chatroom:"Chatroom",pipe:"Pipe",channel:"Channel"};function kz({permission:t}){const s=t==="rw"?Pe.badgeRw:t==="r"?Pe.badgeR:Pe.badgeW;return i.jsx("span",{className:s,children:t})}function Sz({mode:t}){const s=t==="async"?Pe.badgeAsync:t==="detach"?Pe.badgeDetach:Pe.badgeSync;return i.jsx("span",{className:s,children:t})}function Tz({stream:t,messages:s,transcriptLoading:o,onClose:r}){const c=vt();return y.useEffect(()=>{const d=u=>{u.key==="Escape"&&r()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[r]),i.jsxs("div",{className:Pe.panel,"data-testid":"stream-detail-panel",children:[i.jsxs("div",{className:Pe.header,children:[i.jsx("h3",{className:Pe.title,children:t.name}),i.jsx("button",{type:"button",className:Pe.closeButton,onClick:r,"aria-label":"Close stream details",children:"×"})]}),i.jsxs("div",{className:Pe.body,children:[i.jsxs("div",{className:Pe.section,children:[i.jsx("div",{className:Pe.sectionLabel,children:"Overview"}),i.jsxs("div",{className:Pe.metaRow,children:[i.jsx("span",{className:Pe.metaKey,children:"Kind"}),i.jsx("span",{className:Pe.metaValue,children:xz[q1(t)]})]}),i.jsxs("div",{className:Pe.metaRow,children:[i.jsx("span",{className:Pe.metaKey,children:"Participants"}),i.jsx("span",{className:Pe.metaValue,children:t.subscriberCount})]}),i.jsxs("div",{className:Pe.metaRow,children:[i.jsx("span",{className:Pe.metaKey,children:"Buffered"}),i.jsxs("span",{className:Pe.metaValue,children:[t.messageBufferDepth," msgs"]})]})]}),i.jsxs("div",{className:Pe.section,children:[i.jsx("div",{className:Pe.sectionLabel,children:"Participants"}),t.subscribers.length===0?i.jsx("div",{className:Pe.emptySubscribers,children:"No active subscribers"}):t.subscribers.map(d=>i.jsxs("div",{className:Pe.subscriberCard,"data-testid":`subscriber-card-${d.subscriptionId}`,children:[i.jsxs("button",{type:"button",className:Pe.sessionLink,onClick:()=>{c(Sm(d.sessionId))},title:d.sessionId,children:[d.sessionId.slice(0,12),"…"]}),d.createdBySpawn&&i.jsx("span",{className:Pe.spawnTag,children:"spawn"})]},d.subscriptionId))]}),i.jsxs("div",{className:Pe.section,children:[i.jsx("div",{className:Pe.sectionLabel,children:"Conversation"}),i.jsx(Z7,{messages:s??[],loading:o??!1})]}),i.jsxs("details",{className:Pe.advanced,"data-testid":"stream-advanced",children:[i.jsx("summary",{className:Pe.advancedSummary,children:"Advanced"}),i.jsxs("div",{className:Pe.metaRow,children:[i.jsx("span",{className:Pe.metaKey,children:"Stream ID"}),i.jsx("span",{className:Pe.metaValueMono,children:t.id})]}),t.subscribers.map(d=>i.jsxs("div",{className:Pe.subscriberCard,children:[i.jsxs("div",{className:Pe.subscriberHeader,children:[i.jsxs("span",{className:Pe.fdNumber,children:["fd ",d.fd]}),i.jsxs("span",{className:Pe.metaValueMono,title:d.subscriptionId,children:[d.subscriptionId.slice(0,12),"…"]})]}),i.jsxs("div",{className:Pe.badges,children:[i.jsx(kz,{permission:d.permission}),i.jsx(Sz,{mode:d.deliveryMode})]})]},d.subscriptionId))]})]})]})}function jz({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(my.map(d=>[d,[]]));for(const d of t){const u=rl(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 b;if(u==="paused"&&o){const S=o.get(d.id);S==="idle"?b="Needs input":S==="completed"&&(b="Ready to complete")}const _={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:b},k=c.get(u);k?k.push(_):c.get("not_started").push(_)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return my.map(d=>{const u=Ka(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const wz="_boardContainer_1c4y1_1",Nz="_column_1c4y1_17",Cz="_columnHeader_1c4y1_34",Ez="_columnIcon_1c4y1_47",Az="_columnLabel_1c4y1_52",Dz="_columnCount_1c4y1_57",Mz="_cardList_1c4y1_67",Rz="_emptyPlaceholder_1c4y1_76",Iz="_card_1c4y1_67",Oz="_cardHeader_1c4y1_107",Bz="_cardStatusIcon_1c4y1_113",Lz="_cardTitle_1c4y1_119",zz="_cardBadges_1c4y1_127",$z="_badge_1c4y1_134",Hz="_blockedBadge_1c4y1_146",Pz="_childBadge_1c4y1_151",Uz="_depBadge_1c4y1_155",Vz="_parentBadge_1c4y1_159",qz="_pausedSubBadge_1c4y1_166",Gz="_personaBadge_1c4y1_170",Fz="_envBadge_1c4y1_174",Kz="_emptyCta_1c4y1_178",Zz="_ctaButton_1c4y1_188",Yz="_ctaDescription_1c4y1_204",lt={boardContainer:wz,column:Nz,columnHeader:Cz,columnIcon:Ez,columnLabel:Az,columnCount:Dz,cardList:Mz,emptyPlaceholder:Rz,card:Iz,cardHeader:Oz,cardStatusIcon:Bz,cardTitle:Lz,cardBadges:zz,badge:$z,blockedBadge:Hz,childBadge:Pz,depBadge:Uz,parentBadge:Vz,pausedSubBadge:qz,personaBadge:Gz,envBadge:Fz,emptyCta:Kz,ctaButton:Zz,ctaDescription:Yz};function Jz({workspaceId:t,environmentId:s,tasks:o,sessions:r,personas:c,environments:d}){const u=vt(),p=y.useMemo(()=>o.filter(_=>_.workspaceId===t),[o,t]),m=y.useMemo(()=>new Map(o.map(_=>[_.id,_.status])),[o]),g=y.useMemo(()=>new Map(p.map(_=>[_.id,_])),[p]),v=y.useMemo(()=>{const _=new Map(r.map(C=>[C.id,C])),k=new Map(c.map(C=>[C.id,C])),S=new Map(d.map(C=>[C.id,C])),T=new Map,j=new Map,w=new Map;for(const C of p)if(C.latestSessionId){const D=_.get(C.latestSessionId);if(D){if(T.set(C.id,D.endReason||D.status),D.personaId){const A=k.get(D.personaId);A&&j.set(C.id,A.name)}if(D.environmentId){const A=S.get(D.environmentId);A&&w.set(C.id,A.displayName)}}}return{sessionStatusByTaskId:T,personaNameByTaskId:j,environmentNameByTaskId:w}},[p,r,c,d]),b=y.useMemo(()=>jz({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?i.jsxs("div",{className:lt.emptyCta,"data-testid":"board-empty-cta",children:[i.jsx("button",{className:lt.ctaButton,onClick:()=>u(Di(t,void 0,s)),children:"Create Task"}),i.jsx("div",{className:lt.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):i.jsx("div",{className:lt.boardContainer,"data-testid":"board-container",children:b.map(_=>i.jsxs("section",{className:lt.column,"data-testid":`board-column-${_.status}`,"aria-label":`${_.label}, ${_.tasks.length} ${_.tasks.length===1?"task":"tasks"}`,children:[i.jsxs("div",{className:lt.columnHeader,children:[i.jsx("span",{className:lt.columnIcon,style:{color:_.style.color},children:_.style.icon}),i.jsx("span",{className:lt.columnLabel,children:_.label}),i.jsx("span",{className:lt.columnCount,"data-testid":`board-count-${_.status}`,children:_.tasks.length})]}),i.jsx("div",{className:lt.cardList,children:_.tasks.length===0?i.jsx("div",{className:lt.emptyPlaceholder,children:"No tasks"}):i.jsx(as,{mode:"popLayout",children:_.tasks.map(k=>i.jsx($t.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:i.jsx(Wz,{boardTask:k,tasksById:g,personaName:v.personaNameByTaskId.get(k.task.id),envName:v.environmentNameByTaskId.get(k.task.id),onClick:()=>u(os(k.task.id,void 0,t,s))})},k.task.id))})})]},_.status))})}function Wz({boardTask:t,tasksById:s,personaName:o,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=Ka(d.status),b=d.parentTaskId?s.get(d.parentTaskId):void 0;return i.jsxs("div",{className:lt.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),c())},children:[i.jsxs("div",{className:lt.cardHeader,children:[i.jsx("span",{className:lt.cardStatusIcon,style:{color:v.color},children:v.icon}),i.jsx("span",{className:lt.cardTitle,children:d.title})]}),i.jsxs("div",{className:lt.cardBadges,children:[b&&i.jsx("span",{className:`${lt.badge} ${lt.parentBadge}`,title:b.title,children:b.title}),p>0&&i.jsxs("span",{className:`${lt.badge} ${lt.childBadge}`,children:[m,"/",p]}),u&&i.jsx("span",{className:`${lt.badge} ${lt.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&i.jsx("span",{className:`${lt.badge} ${lt.depBadge}`,children:"dep"}),g&&i.jsx("span",{className:`${lt.badge} ${lt.pausedSubBadge}`,children:g}),o&&i.jsx("span",{className:`${lt.badge} ${lt.personaBadge}`,children:o}),r&&i.jsx("span",{className:`${lt.badge} ${lt.envBadge}`,children:r})]})]})}const Xz="_formContent_ymnez_1",Qz="_section_ymnez_13",e$="_label_ymnez_19",t$="_titleInput_ymnez_26",n$="_descriptionTextarea_ymnez_58",s$="_selectField_ymnez_94",a$="_checkboxRow_ymnez_128",i$="_checkboxLabel_ymnez_141",o$="_fieldError_ymnez_146",xt={formContent:Xz,section:Qz,label:e$,titleInput:t$,descriptionTextarea:n$,selectField:s$,checkboxRow:a$,checkboxLabel:i$,fieldError:o$};function r$(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 l$=100;function c$({values:t,onChange:s,environments:o,personas:r,errors:c,disabled:d,autoFocusName:u}){const p=(m,g)=>{s({...t,[m]:g})};return i.jsxs("div",{className:xt.formContent,children:[i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-name",children:"Name"}),i.jsx("input",{id:"ws-name",className:xt.titleInput,type:"text",value:t.name,onChange:m=>p("name",m.target.value),placeholder:"Workspace name",maxLength:l$,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&i.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-description",children:"Description"}),i.jsx("textarea",{id:"ws-description",className:xt.descriptionTextarea,value:t.description,onChange:m=>p("description",m.target.value),placeholder:"Optional description (Markdown supported)",disabled:d,"data-testid":"workspace-form-description"})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-repo",children:"Repository URL"}),i.jsx("input",{id:"ws-repo",className:xt.titleInput,type:"text",value:t.repoUrl,onChange:m=>p("repoUrl",m.target.value),placeholder:"https://github.com/org/repo",disabled:d,"data-testid":"workspace-form-repo"}),(c==null?void 0:c.repoUrl)&&i.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-environment",children:"Environment"}),i.jsxs("select",{id:"ws-environment",className:xt.selectField,value:t.environmentId,onChange:m=>p("environmentId",m.target.value),disabled:d,"data-testid":"workspace-form-environment",children:[i.jsx("option",{value:"",children:"Select environment…"}),o.map(m=>i.jsx("option",{value:m.id,children:m.displayName||m.id},m.id))]}),(c==null?void 0:c.environmentId)&&i.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-persona",children:"Default Persona"}),i.jsxs("select",{id:"ws-persona",className:xt.selectField,value:t.defaultPersonaId,onChange:m=>p("defaultPersonaId",m.target.value),disabled:d,"data-testid":"workspace-form-persona",children:[i.jsx("option",{value:"",children:"(Inherit)"}),r.map(m=>i.jsx("option",{value:m.id,children:m.name},m.id))]})]}),i.jsx("div",{className:xt.section,children:i.jsxs("label",{className:xt.checkboxRow,children:[i.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:m=>p("useWorktrees",m.target.checked),disabled:d,"data-testid":"workspace-form-worktrees"}),i.jsx("span",{className:xt.checkboxLabel,children:"Enable worktree isolation"})]})}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-workdir",children:"Working Directory"}),i.jsx("input",{id:"ws-workdir",className:xt.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 G1=y.createContext(void 0),d$=4e3;function u$({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=d$)=>{const g=`toast-${++r.current}`;o(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return i.jsx(G1.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function pn(){const t=y.useContext(G1);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const om="grackle-theme",F1="grackle-prefer-system",K1="(prefers-color-scheme: dark)";let Gr=[],nd;function jp(){nd=void 0;for(const t of Gr)t()}function rm(){return typeof window>"u"?!1:window.matchMedia(K1).matches}function Wr(){if(typeof localStorage>"u")return Yb;try{const t=localStorage.getItem(om);if(t!==null&&H1.has(t))return t}catch{}return Yb}function md(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(F1)==="true"}catch{return!1}}function lm(t){return Ed.find(s=>s.variantLightId===t||s.variantDarkId===t)}function Z1(t,s){const o=am(t);if(o!=null&&o.variantDarkId)return s&&o.variantLightId?rm()?o.variantDarkId:o.variantLightId:o.variantDarkId;if(o!=null&&o.hidden&&s){const r=lm(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return rm()?r.variantDarkId:r.variantLightId}return t}function No(t,s,o=!1){o&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=Z1(t,s),o&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&No(Wr(),md());function f$(){return nd===void 0&&(nd={themeId:Wr(),systemDark:rm(),preferSystem:md()}),nd}function p$(t){return Gr=[...Gr,t],()=>{Gr=Gr.filter(s=>s!==t)}}function m$(){const t=y.useSyncExternalStore(p$,f$),{themeId:s,preferSystem:o}=t,r=Z1(s,o),c=y.useCallback(u=>{if(H1.has(u)){try{localStorage.setItem(om,u)}catch{}No(u,md(),!0),jp()}},[]),d=y.useCallback(u=>{try{localStorage.setItem(F1,u?"true":"false")}catch{}if(u){const p=Wr(),m=am(p);if(m!=null&&m.hidden){const g=lm(p);if(g)try{localStorage.setItem(om,g.id)}catch{}}}No(Wr(),u,!0),jp()},[]);return y.useEffect(()=>{No(s,o)},[s,o]),y.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(K1),p=()=>{const m=Wr(),g=md();if(g){const v=am(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&No(m,g),v!=null&&v.hidden){const b=lm(m);b!=null&&b.variantDarkId&&b.variantLightId&&No(m,g)}}jp()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:o,setPreferSystem:d}}const Y1=y.createContext(void 0);function h$({children:t}){const s=m$();return i.jsx(Y1.Provider,{value:s,children:t})}function J1(){const t=y.useContext(Y1);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const W1=y.createContext(void 0),X1=y.createContext(void 0);function g$({children:t}){const[s,o]=y.useState(void 0),r=y.useCallback(c=>{o(c)},[]);return i.jsx(X1.Provider,{value:r,children:i.jsx(W1.Provider,{value:s,children:t})})}function v$(){return y.useContext(W1)}function y$(){const t=y.useContext(X1);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const rh=y.createContext(void 0);function ut(){const t=y.useContext(rh);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function Q1(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function ek(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function b$(t){return Q1(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 _$=new Set(["off","subscription","api_key"]),Uc=new Set(["off","on"]);function x$(t){return Q1(t)&&_$.has(t.claude)&&Uc.has(t.github)&&Uc.has(t.copilot)&&Uc.has(t.codex)&&Uc.has(t.goose)}function tk(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 nk(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 jo=5e3;function k$(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 Ni={label:"Home",url:Po};function S$(t){return t?[Ni,{label:"Settings",url:ki},{label:t,url:void 0}]:[Ni,{label:"Settings",url:void 0}]}const sk={label:"Environments",url:Ro};function T$(){return[Ni,{label:"Environments",url:void 0}]}function j$(){return[Ni,{label:"New Chat",url:void 0}]}function w$(t){return[Ni,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function N$(t,s,o,r){const c=o.find(u=>u.id===t),d=r.find(u=>u.id===s);return[Ni,sk,{label:(d==null?void 0:d.displayName)??"Environment",url:Io(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function C$(t,s,o,r,c){const d=k$(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?o.find(k=>k.id===p):void 0,g=s??(m==null?void 0:m.linkedEnvironmentIds[0]),v=g?r.find(k=>k.id===g):void 0,b=[Ni];v&&g&&(b.push(sk),b.push({label:v.displayName,url:Io(g)})),m&&g&&b.push({label:m.name,url:ji(m.id,g)});for(let k=0;k<d.length-1;k++)b.push({label:d[k].title,url:os(d[k].id,void 0,p,g)});const _=d[d.length-1];return b.push({label:(_==null?void 0:_.title)??t,url:void 0}),b}function lh(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 Vc(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 E$(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 ch(t){const s=new Map;for(const v of t)if(v.raw)try{s.set(v,JSON.parse(v.raw))}catch{}const o=new Map;for(const v of t){if(v.eventType!=="tool_use")continue;const b=s.get(v),_=b?Vc(b):void 0;if(_)try{const k=JSON.parse(v.content);o.set(_,{tool:k.tool,args:k.args})}catch{}}const r=new Set,c=new Set,d=t.map((v,b)=>{if(v.eventType!=="tool_result")return v;const _=s.get(v),k=_?E$(_):void 0;if(!k)return v;const S=o.get(k);if(!S)return v;r.add(k),c.add(b);let T;const j=v.content.trim();if(j.startsWith("{"))try{const w=JSON.parse(j);typeof w.detailedContent=="string"&&(T=w.detailedContent)}catch{}return{...v,toolUseCtx:{...S,detailedResult:T}}}),u=[];for(let v=0;v<d.length;v++){if(d[v].eventType!=="tool_use")continue;const b=s.get(d[v]),_=b?Vc(b):void 0;_&&r.has(_)||u.push(v)}const p=[];for(let v=0;v<d.length;v++)d[v].eventType!=="tool_result"||c.has(v)||p.push(v);let m=0;for(const v of u){for(;m<p.length&&p[m]<v;)m++;if(m>=p.length)break;const b=p[m];if(b!==v+1)continue;const _=d[v],k=d[b];let S;try{const T=JSON.parse(_.content);S={tool:T.tool,args:T.args}}catch{}if(S){let T;const j=k.content.trim();if(j.startsWith("{"))try{const D=JSON.parse(j);typeof D.detailedContent=="string"&&(T=D.detailedContent)}catch{}d[b]={...k,toolUseCtx:{...S,detailedResult:T}},c.add(b);const w=s.get(_),C=w?Vc(w):void 0;C?r.add(C):(r.add(`__seq_${v}`),s.set(_,{...w??{},__seqId:`__seq_${v}`})),m++}}const g=d.filter(v=>{if(v.eventType!=="tool_use")return!0;const b=s.get(v);if(!b)return!0;const _=Vc(b);if(_&&r.has(_))return!1;const k=b.__seqId;return!(k&&r.has(k))});for(let v=0;v<g.length;v++){if(g[v].eventType!=="tool_use")continue;let b=!1;for(let _=v+1;_<g.length;_++)if(g[_].eventType!=="tool_use"){b=!0;break}b&&(g[v]={...g[v],settled:!0})}return g}function A$(t,s,o){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=ak(s),d=s.filter(m=>cm(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||cm(m,c)).length,p=o.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function ak(t){const s=new Map;for(const o of t)s.set(o.id,o.status);return s}function cm(t,s){return t.dependsOn.some(o=>s.get(o)!=="complete")}function D$(t,s){var u;const o=new Map;for(const p of s)o.set(p.id,p);const r=ak(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}):cm(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 M$(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 R$(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 Cs=[{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
|
|
326
326
|
export function verifyToken(req: Request, res: Response, next: NextFunction): void {
|
|
327
327
|
const header = req.headers.authorization;
|
|
328
328
|
if (!header?.startsWith("Bearer ")) {
|
|
@@ -752,4 +752,4 @@ const grackle = await host.mcpServer({
|
|
|
752
752
|
url: env.vars.GRACKLE_MCP_URL,
|
|
753
753
|
});
|
|
754
754
|
|
|
755
|
-
$\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),R==="agent"&&i.jsxs("div",{children:[i.jsx("label",{children:"Allowed MCP Tools"}),i.jsx(Wb,{selectedTools:Y,onChange:ue=>{V(ue),_e(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,ue),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!ke&&!me&&i.jsx("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--text-tertiary)",marginTop:"var(--space-xs)"},children:"Only agent personas with a runtime and model can be set as app default."})]}):null,i.jsx(ys,{isOpen:ee,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:yt,onCancel:()=>le(!1)})]})}function YU(){const{schedules:{schedules:t,deleteSchedule:s,updateSchedule:o},personas:{personas:r}}=ut(),{showToast:c}=pn(),d=vt();return i.jsx(u7,{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(UN),onNavigateToSchedule:u=>d(K_(u))})}const JU="_container_1g4qh_1",WU="_form_1g4qh_7",XU="_formActions_1g4qh_66",QU="_editableSection_1g4qh_73",eV="_helperText_1g4qh_84",tV="_metaSection_1g4qh_90",nV="_optional_1g4qh_108",sV="_readonlyValue_1g4qh_113",Bn={container:JU,form:WU,formActions:XU,editableSection:QU,helperText:eV,metaSection:tV,optional:nV,readonlyValue:sV};function h_(){const{scheduleId:t}=ua(),s=vt(),{showToast:o}=pn(),{schedules:{schedules:r,schedulesLoading:c,createSchedule:d,updateSchedule:u,deleteSchedule:p},personas:{personas:m},workspaces:{workspaces:g}}=ut(),v=t===void 0,b=v?void 0:r.find(k=>k.id===t);if(!v&&!c&&r.length>0&&!b)return i.jsx(zn,{to:Jf,replace:!0});const _=[{label:"Settings",url:ki},{label:"Schedules",url:Jf},{label:v?"New Schedule":(b==null?void 0:b.title)??"Schedule",url:void 0}];return i.jsxs("div",{className:Bn.container,children:[i.jsx(fa,{segments:_}),i.jsx(aV,{existing:b,isNew:v,personas:m,workspaces:g,onCreateSchedule:d,onUpdateSchedule:u,onDeleteSchedule:p,onDone:()=>{s(Jf)},showToast:o})]})}function aV({existing:t,isNew:s,personas:o,workspaces:r,onCreateSchedule:c,onUpdateSchedule:d,onDeleteSchedule:u,onDone:p,showToast:m}){var H;const g=vt(),[v,b]=y.useState((t==null?void 0:t.title)??""),[_,k]=y.useState((t==null?void 0:t.description)??""),[S,T]=y.useState((t==null?void 0:t.scheduleExpression)??""),[j,w]=y.useState((t==null?void 0:t.personaId)??""),[C,D]=y.useState((t==null?void 0:t.workspaceId)??""),[A,E]=y.useState(!1),[R,O]=y.useState(null);y.useEffect(()=>{s||t&&R===null&&(b(t.title),k(t.description),T(t.scheduleExpression),w(t.personaId),D(t.workspaceId))},[s,t,R]);const M=!s&&t===void 0,$=s&&v.trim().length>0&&S.trim().length>0&&j.length>0,Y=o.map(B=>({value:B.id,label:B.name})),V=[{value:"",label:"System-level (no workspace)"},...r.map(B=>({value:B.id,label:B.name}))],ee=B=>{B.preventDefault(),$&&c(v,_,S,j,C||void 0).then(F=>{m("Schedule created","success"),g(K_(F.id),{replace:!0})},()=>{m("Failed to create schedule","error")})},le=(B,F)=>{t&&d(t.id,{[B]:F}).then(()=>{m("Schedule updated","success"),B==="title"&&b(String(F)),B==="description"&&k(String(F)),B==="scheduleExpression"&&T(String(F)),B==="personaId"&&w(String(F))},()=>{m("Failed to update schedule","error")})},Z=()=>{if(!t)return;const B=!t.enabled;d(t.id,{enabled:B}).then(()=>{m(B?"Schedule enabled":"Schedule disabled","success")},()=>{m("Failed to update schedule","error")})},ae=()=>{t&&u(t.id).then(()=>{m("Schedule deleted","success"),p()},()=>{m("Failed to delete schedule","error")})};return i.jsxs(i.Fragment,{children:[M?i.jsxs("div",{className:Bn.form,children:[i.jsx("h3",{children:"Edit Schedule"}),i.jsx("p",{children:"Loading schedule..."})]}):s?i.jsxs("form",{onSubmit:ee,className:Bn.form,children:[i.jsx("h3",{children:"Create Schedule"}),i.jsxs("label",{children:["Title",i.jsx("input",{type:"text",value:v,onChange:B=>b(B.target.value),placeholder:"e.g. Nightly Review",required:!0,"data-testid":"schedule-detail-title"})]}),i.jsxs("label",{children:["Description ",i.jsx("span",{className:Bn.optional,children:"(optional)"}),i.jsx("input",{type:"text",value:_,onChange:B=>k(B.target.value),placeholder:"Brief description...","data-testid":"schedule-detail-description"})]}),i.jsxs("label",{children:["Schedule Expression",i.jsx("input",{type:"text",value:S,onChange:B=>T(B.target.value),placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",required:!0,"data-testid":"schedule-detail-expression"}),i.jsxs("p",{className:Bn.helperText,children:["Interval: ",i.jsx("code",{children:"30s"}),", ",i.jsx("code",{children:"5m"}),", ",i.jsx("code",{children:"1h"}),", ",i.jsx("code",{children:"1d"})," (min 10s) | Cron: ",i.jsx("code",{children:"0 9 * * MON"})," (standard 5-field cron syntax)"]})]}),i.jsxs("label",{children:["Persona",i.jsxs("select",{value:j,onChange:B=>w(B.target.value),required:!0,"data-testid":"schedule-detail-persona",children:[i.jsx("option",{value:"",children:"Select a persona..."}),Y.map(B=>i.jsx("option",{value:B.value,children:B.label},B.value))]})]}),i.jsxs("label",{children:["Workspace ",i.jsx("span",{className:Bn.optional,children:"(optional)"}),i.jsx("select",{value:C,onChange:B=>D(B.target.value),"data-testid":"schedule-detail-workspace",children:V.map(B=>i.jsx("option",{value:B.value,children:B.label},B.value))})]}),i.jsxs("div",{className:Bn.formActions,children:[i.jsx(sn,{type:"submit",variant:"primary",size:"md",disabled:!$,"data-testid":"schedule-detail-save",children:"Create"}),i.jsx(sn,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Cancel"})]})]}):t?i.jsxs("div",{className:Bn.form,children:[i.jsx("h3",{children:"Edit Schedule"}),i.jsxs("div",{className:Bn.formActions,children:[i.jsx(sn,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Back to Schedules"}),i.jsx(sn,{type:"button",variant:t.enabled?"ghost":"primary",size:"md",onClick:Z,"data-testid":"schedule-detail-toggle",children:t.enabled?"Disable":"Enable"}),i.jsx(sn,{type:"button",variant:"danger",size:"md",onClick:()=>E(!0),"data-testid":"schedule-detail-delete",children:"Delete"})]}),i.jsxs("div",{className:Bn.editableSection,children:[i.jsxs("label",{children:["Title",i.jsx(Bt,{value:v,onSave:B=>{le("title",B)},validate:B=>B.trim()?void 0:"Title is required",fieldId:"schedule-title",activeFieldId:R,onActivate:O,ariaLabel:"Schedule title","data-testid":"schedule-detail-title"})]}),i.jsxs("label",{children:["Description",i.jsx(Bt,{value:_,onSave:B=>{le("description",B)},fieldId:"schedule-description",activeFieldId:R,onActivate:O,placeholder:"Brief description...",ariaLabel:"Schedule description","data-testid":"schedule-detail-description"})]}),i.jsxs("label",{children:["Schedule Expression",i.jsx(Bt,{value:S,onSave:B=>{le("scheduleExpression",B)},validate:B=>B.trim()?void 0:"Schedule expression is required",fieldId:"schedule-expression",activeFieldId:R,onActivate:O,placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",ariaLabel:"Schedule expression","data-testid":"schedule-detail-expression"})]}),i.jsxs("label",{children:["Persona",i.jsx(pd,{value:j,onSave:B=>{le("personaId",B)},options:Y,fieldId:"schedule-persona",activeFieldId:R,onActivate:O,ariaLabel:"Schedule persona","data-testid":"schedule-detail-persona"})]}),i.jsxs("label",{children:["Workspace ",i.jsx("span",{className:Bn.optional,children:"(optional — set at creation)"}),i.jsx("span",{className:Bn.readonlyValue,"data-testid":"schedule-detail-workspace",children:((H=r.find(B=>B.id===t.workspaceId))==null?void 0:H.name)??"System-level (no workspace)"})]})]}),i.jsxs("div",{className:Bn.metaSection,children:[t.lastRunAt?i.jsxs("span",{children:["Last run: ",im(t.lastRunAt)]}):i.jsx("span",{children:"Last run: Never"}),t.enabled&&t.nextRunAt?i.jsxs("span",{children:["Next run: ",V1(t.nextRunAt)]}):null,t.runCount>0&&i.jsxs("span",{children:["Total runs: ",t.runCount]}),i.jsxs("span",{children:["Created: ",im(t.createdAt)]})]})]}):null,i.jsx(ys,{isOpen:A,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:ae,onCancel:()=>E(!1)})]})}function iV(){const{themeId:t,resolvedThemeId:s,setTheme:o,preferSystem:r,setPreferSystem:c}=J1();return i.jsx(CB,{themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c})}function oV(){const[t,s]=y.useState(void 0);return y.useEffect(()=>{let o=!1;return(async()=>{try{const c=await ze.getVersionStatus({});o||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{o=!0}},[]),t}function rV(){const{connectionStatus:t,environments:{environments:s},sessions:{sessions:o}}=ut(),r=oV();return i.jsxs(i.Fragment,{children:[r&&i.jsx($O,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),i.jsx(DB,{connectionStatus:t,environments:s,sessions:o})]})}function lV(){return i.jsx(x8,{})}function cV(){const{plugins:{plugins:t,pluginsLoading:s,setPluginEnabled:o}}=ut();return i.jsx(GL,{plugins:t,loading:s,onSetPluginEnabled:(r,c)=>{o(r,c).catch(()=>{})}})}const g_=Di();function dV(){const t=vt();return Fa({key:"?"},()=>{t(VN)}),Fa({key:"n"},()=>{t(g_)}),Fa({key:"N"},()=>{t(g_)}),i.jsx(i.Fragment,{})}function Dd(t){const s=y$();y.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function uV(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=ut(),o=y.useMemo(()=>i.jsx(hO,{workspaces:t,tasks:s}),[t,s]);return Dd(o),i.jsx(Ai,{})}function fV(){const{environments:{environments:t}}=ut(),s=y.useMemo(()=>i.jsx(BI,{environments:t}),[t]);return Dd(s),i.jsx(Ai,{})}function pV(){const t=y.useMemo(()=>i.jsx(g7,{}),[]);return Dd(t),i.jsx(Ai,{})}function mV(){const{knowledge:t,workspaces:{workspaces:s}}=ut(),o=y.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=y.useCallback(()=>{t.clearSearch()},[t]),c=y.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=y.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=y.useMemo(()=>i.jsx(G5,{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 Dd(u),i.jsx(Ai,{})}const hV="_wizard_1260s_1",gV="_container_1260s_10",vV="_stepContent_1260s_19",yV="_logoArea_1260s_28",bV="_logoImage_1260s_32",_V="_heading_1260s_41",xV="_tagline_1260s_49",kV="_subtitle_1260s_56",SV="_featureList_1260s_64",TV="_runtimeGrid_1260s_89",jV="_runtimeCard_1260s_101",wV="_runtimeName_1260s_133",NV="_runtimeDescription_1260s_139",CV="_buttonRow_1260s_144",EV="_primaryButton_1260s_151",AV="_ghostButton_1260s_185",DV="_dots_1260s_213",MV="_dot_1260s_213",We={wizard:hV,container:gV,stepContent:vV,logoArea:yV,logoImage:bV,heading:_V,tagline:xV,subtitle:kV,featureList:SV,runtimeGrid:TV,runtimeCard:jV,runtimeName:wV,runtimeDescription:NV,buttonRow:CV,primaryButton:EV,ghostButton:AV,dots:DV,dot:MV};function RV({onNext:t}){return i.jsxs("div",{className:We.stepContent,"data-testid":"setup-welcome",children:[i.jsx("div",{className:We.logoArea,children:i.jsx("img",{src:Cd("grackle-logo.png"),alt:"Grackle",className:We.logoImage})}),i.jsx("h1",{className:We.heading,children:"Welcome to Grackle"}),i.jsx("p",{className:We.tagline,children:"Multi-agent orchestration for software teams"}),i.jsx("button",{type:"button",className:We.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function IV({onNext:t,onBack:s}){return i.jsxs("div",{className:We.stepContent,"data-testid":"setup-about",children:[i.jsx("h2",{className:We.heading,children:"What is Grackle?"}),i.jsxs("ul",{className:We.featureList,children:[i.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),i.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),i.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),i.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),i.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),i.jsxs("div",{className:We.buttonRow,children:[i.jsx("button",{type:"button",className:We.ghostButton,onClick:s,children:"Back"}),i.jsx("button",{type:"button",className:We.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const OV=[{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 BV({currentRuntime:t,onFinish:s,onBack:o,finishDisabled:r}){const[c,d]=y.useState(t||"claude-code");return y.useEffect(()=>{t&&d(t)},[t]),i.jsxs("div",{className:We.stepContent,"data-testid":"setup-runtime",children:[i.jsx("h2",{className:We.heading,children:"Choose Your Runtime"}),i.jsx("p",{className:We.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),i.jsx("div",{className:We.runtimeGrid,children:OV.map(u=>i.jsxs("button",{type:"button",className:We.runtimeCard,"data-selected":c===u.id,"aria-pressed":c===u.id,"data-testid":`runtime-card-${u.id}`,onClick:()=>d(u.id),children:[i.jsx("span",{className:We.runtimeName,children:u.name}),i.jsx("span",{className:We.runtimeDescription,children:u.description})]},u.id))}),i.jsxs("div",{className:We.buttonRow,children:[i.jsx("button",{type:"button",className:We.ghostButton,onClick:o,children:"Back"}),i.jsx("button",{type:"button",className:We.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function LV(){return typeof Notification<"u"}function zV({onFinish:t,onBack:s,finishDisabled:o}){const r=LV(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return i.jsxs("div",{className:We.stepContent,"data-testid":"setup-notifications",children:[i.jsx("h2",{className:We.heading,children:"Stay in the Loop"}),i.jsx("p",{className:We.subtitle,children:"Grackle can send you a browser notification when an agent needs your input, so you never miss an important moment."}),c?i.jsx("p",{className:We.subtitle,children:Notification.permission==="granted"?"Notifications are already enabled.":"Notifications have been blocked. You can change this in your browser settings."}):null,i.jsxs("div",{className:We.buttonRow,children:[i.jsx("button",{type:"button",className:We.ghostButton,onClick:s,disabled:o,children:"Back"}),!c&&r?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:We.ghostButton,onClick:t,disabled:o,"data-testid":"setup-notifications-skip",children:"Skip"}),i.jsx("button",{type:"button",className:We.primaryButton,onClick:d,disabled:o,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):i.jsx("button",{type:"button",className:We.primaryButton,onClick:t,disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const $V=4,v_={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function HV(){const{personas:{personas:t,updatePersona:s},completeOnboarding:o,onboardingCompleted:r}=ut(),{showToast:c}=pn(),d=vt(),[u,p]=y.useState(0),[m,g]=y.useState("claude-code"),[v,b]=y.useState(!1),_=t.find(T=>T.id==="claude-code"),k=y.useCallback(T=>{g(T),p(3)},[]),S=y.useCallback(()=>{const T=m;b(!0);const j=[];if(_&&T!==_.runtime){const C=v_[T]??"sonnet";j.push(s(_.id,void 0,void 0,void 0,T,C))}const w=t.find(C=>C.id===ay);if(w&&T!==w.runtime){const C=v_[T]??"sonnet";j.push(s(ay,void 0,void 0,void 0,T,C))}Promise.all(j).then(()=>o()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),b(!1)})},[m,_,t,s,o,d,c]);return r===!0?i.jsx(zn,{to:"/",replace:!0}):i.jsx("div",{className:We.wizard,"data-testid":"setup-wizard",children:i.jsxs("div",{className:We.container,children:[i.jsx(as,{mode:"wait",children:i.jsxs($t.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&i.jsx(RV,{onNext:()=>p(1)}),u===1&&i.jsx(IV,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&i.jsx(BV,{currentRuntime:m,onFinish:k,onBack:()=>p(1),finishDisabled:!_}),u===3&&i.jsx(zV,{onFinish:S,onBack:()=>p(2),finishDisabled:v})]},u)}),i.jsx("div",{className:We.dots,children:Array.from({length:$V},(T,j)=>i.jsx("span",{className:We.dot,"data-active":j===u},j))})]})})}const PV="_root_zndgp_1",UV="_body_zndgp_7",VV="_main_zndgp_19",qV="_sidebarWrapper_zndgp_26",GV="_overlay_zndgp_51",Fr={root:PV,body:UV,main:VV,sidebarWrapper:qV,overlay:GV},FV=y.lazy(()=>k_(()=>import("./KnowledgePage-t836uaLl.js"),__vite__mapDeps([2,1,3,4,5])).then(t=>({default:t.KnowledgePage}))),lk=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function KV({tabs:t}){const{connectionStatus:s,environments:{environments:o},sessions:{sessions:r},tasks:{tasks:c}}=ut(),{toasts:d,dismissToast:u}=pn(),p=Jt(),m=v$(),g=m!==void 0,[v,b]=y.useState(!1),_=y.useCallback(()=>b(k=>!k),[]);return y.useEffect(()=>{b(!1)},[p.pathname]),y.useEffect(()=>{if(!v)return;const k=S=>{S.key==="Escape"&&b(!1)};return document.addEventListener("keydown",k),()=>{document.removeEventListener("keydown",k)}},[v]),i.jsxs(i.Fragment,{children:[i.jsx(aI,{connectionStatus:s,environments:o,sessions:r,onToggleSidebar:g?_:void 0,sidebarOpen:v}),i.jsx(fI,{tabs:t}),i.jsxs("div",{className:Fr.body,children:[g&&i.jsx("div",{className:Fr.sidebarWrapper,"data-sidebar-open":v,children:i.jsx(yI,{content:m})}),g&&v&&i.jsx("div",{className:Fr.overlay,"data-testid":"drawer-overlay",onClick:()=>b(!1)}),i.jsxs("div",{className:Fr.main,children:[i.jsx(Ai,{}),i.jsx(wI,{sessions:r,tasks:c,environments:o})]})]}),i.jsx(CO,{toasts:d,onDismiss:u}),i.jsx(dV,{})]})}function ZV(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:o,clearOperationError:r},tasks:{tasks:c},connectionStatus:d,onboardingCompleted:u}=ut(),{pluginNames:p}=Ad(),{showToast:m}=pn();N9(s,m),M9(c,m),C9(o,r,m);const g=vt(),v=Jt();if(y.useEffect(()=>{t&&!v.pathname.includes("/tasks/")&&g(Sm(t),{replace:!0})},[t,g,v.pathname]),d==="connected"&&u===!1)return i.jsx(zn,{to:"/setup",replace:!0});const b=W$(p);return i.jsx(g$,{children:i.jsxs("div",{className:Fr.root,children:[lk&&i.jsx(yC,{}),i.jsx(KV,{tabs:b})]})})}function Mp(){const{workspaceId:t}=ua(),{workspaces:{workspaces:s}}=ut(),o=Jt(),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:i.jsx(zn,{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 i.jsx(zn,{to:m,replace:!0})}function YV(){const{pluginNames:t}=Ad(),s=t.includes("orchestration"),o=t.includes("knowledge");return i.jsxs(sN,{children:[i.jsx(Ee,{path:"setup",element:i.jsx(HV,{})}),i.jsxs(Ee,{element:i.jsx(ZV,{}),children:[i.jsx(Ee,{index:!0,element:i.jsx(gP,{})}),i.jsx(Ee,{path:"sessions/new",element:i.jsx(AP,{})}),i.jsx(Ee,{path:"chat",element:i.jsx(wP,{})}),i.jsx(Ee,{path:"chat/:streamId",element:i.jsx(zn,{to:"/coordination",replace:!0})}),i.jsx(Ee,{path:"coordination",element:i.jsx(EP,{})}),i.jsx(Ee,{path:"sessions/:sessionId",element:i.jsx(IP,{})}),o&&i.jsx(Ee,{element:i.jsx(mV,{}),children:i.jsx(Ee,{path:"knowledge",element:i.jsx(y.Suspense,{fallback:i.jsx(E1,{}),children:i.jsx(FV,{})})})}),s&&i.jsxs(Ee,{element:i.jsx(uV,{}),children:[i.jsx(Ee,{path:"tasks",element:i.jsx(mP,{})}),i.jsx(Ee,{path:"tasks/new",element:i.jsx(u_,{})}),i.jsx(Ee,{path:"tasks/:taskId",element:i.jsx(wo,{})}),i.jsx(Ee,{path:"tasks/:taskId/edit",element:i.jsx(wo,{})}),i.jsx(Ee,{path:"tasks/:taskId/stream",element:i.jsx(wo,{})})]}),i.jsxs(Ee,{element:i.jsx(fV,{}),children:[i.jsx(Ee,{path:"workspaces",element:i.jsx(zn,{to:"/environments",replace:!0})}),i.jsx(Ee,{path:"workspaces/new",element:i.jsx(YP,{})}),i.jsx(Ee,{path:"workspaces/:workspaceId",element:i.jsx(Mp,{})}),i.jsx(Ee,{path:"workspaces/:workspaceId/tasks/:taskId",element:i.jsx(Mp,{})}),i.jsx(Ee,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:i.jsx(Mp,{})}),i.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId",element:i.jsx(zP,{})}),i.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:i.jsx(u_,{})}),i.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:i.jsx(wo,{})}),i.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:i.jsx(wo,{})}),i.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:i.jsx(wo,{})}),i.jsxs(Ee,{path:"environments",element:i.jsx(nU,{}),children:[i.jsx(Ee,{index:!0,element:i.jsx(hP,{})}),i.jsx(Ee,{path:"new",element:i.jsx(WP,{})}),i.jsx(Ee,{path:":environmentId",element:i.jsx(MU,{})}),i.jsx(Ee,{path:":environmentId/edit",element:i.jsx(XP,{})})]})]}),i.jsx(Ee,{element:i.jsx(pV,{}),children:i.jsxs(Ee,{path:"settings",element:i.jsx(OU,{}),children:[i.jsx(Ee,{index:!0,element:i.jsx(zn,{to:"credentials",replace:!0})}),i.jsx(Ee,{path:"environments",element:i.jsx(zn,{to:"/environments",replace:!0})}),i.jsx(Ee,{path:"credentials",element:i.jsx(BU,{})}),i.jsx(Ee,{path:"github-accounts",element:i.jsx(LU,{})}),i.jsx(Ee,{path:"tokens",element:i.jsx(zn,{to:"../credentials",replace:!0})}),i.jsx(Ee,{path:"personas",element:i.jsx(zU,{})}),i.jsx(Ee,{path:"personas/new",element:i.jsx(m_,{})}),i.jsx(Ee,{path:"personas/:personaId",element:i.jsx(m_,{})}),i.jsx(Ee,{path:"schedules",element:i.jsx(YU,{})}),i.jsx(Ee,{path:"schedules/new",element:i.jsx(h_,{})}),i.jsx(Ee,{path:"schedules/:scheduleId",element:i.jsx(h_,{})}),i.jsx(Ee,{path:"appearance",element:i.jsx(iV,{})}),i.jsx(Ee,{path:"shortcuts",element:i.jsx(lV,{})}),i.jsx(Ee,{path:"plugins",element:i.jsx(cV,{})}),i.jsx(Ee,{path:"about",element:i.jsx(rV,{})})]})}),i.jsx(Ee,{path:"*",element:i.jsx(zn,{to:"/",replace:!0})})]})]})}const JV=1e4;function WV(){const{onboardingCompleted:t}=ut(),[s,o]=y.useState(!1);y.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>o(!0),JV);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return i.jsx(as,{mode:"wait",children:r?i.jsx($t.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:i.jsx(E1,{})},"splash"):i.jsx($t.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:i.jsx(CN,{basename:"/".replace(/\/$/,""),children:i.jsx(YV,{})})},"app")})}function XV(){const t=lk?q$:w9;return i.jsx(K$,{children:i.jsx(h$,{children:i.jsx(u$,{children:i.jsx(t,{children:i.jsx(WV,{})})})})})}Y2.createRoot(document.getElementById("root")).render(i.jsx(y.StrictMode,{children:i.jsx(XV,{})}));export{fa as B,J_ as K,ut as a,Sm as s,os as t,vt as u};
|
|
755
|
+
$\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),R==="agent"&&i.jsxs("div",{children:[i.jsx("label",{children:"Allowed MCP Tools"}),i.jsx(Wb,{selectedTools:Y,onChange:ue=>{V(ue),_e(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,ue),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!ke&&!me&&i.jsx("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--text-tertiary)",marginTop:"var(--space-xs)"},children:"Only agent personas with a runtime and model can be set as app default."})]}):null,i.jsx(ys,{isOpen:ee,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:yt,onCancel:()=>le(!1)})]})}function YU(){const{schedules:{schedules:t,deleteSchedule:s,updateSchedule:o},personas:{personas:r}}=ut(),{showToast:c}=pn(),d=vt();return i.jsx(u7,{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(UN),onNavigateToSchedule:u=>d(K_(u))})}const JU="_container_1g4qh_1",WU="_form_1g4qh_7",XU="_formActions_1g4qh_66",QU="_editableSection_1g4qh_73",eV="_helperText_1g4qh_84",tV="_metaSection_1g4qh_90",nV="_optional_1g4qh_108",sV="_readonlyValue_1g4qh_113",Bn={container:JU,form:WU,formActions:XU,editableSection:QU,helperText:eV,metaSection:tV,optional:nV,readonlyValue:sV};function h_(){const{scheduleId:t}=ua(),s=vt(),{showToast:o}=pn(),{schedules:{schedules:r,schedulesLoading:c,createSchedule:d,updateSchedule:u,deleteSchedule:p},personas:{personas:m},workspaces:{workspaces:g}}=ut(),v=t===void 0,b=v?void 0:r.find(k=>k.id===t);if(!v&&!c&&r.length>0&&!b)return i.jsx(zn,{to:Jf,replace:!0});const _=[{label:"Settings",url:ki},{label:"Schedules",url:Jf},{label:v?"New Schedule":(b==null?void 0:b.title)??"Schedule",url:void 0}];return i.jsxs("div",{className:Bn.container,children:[i.jsx(fa,{segments:_}),i.jsx(aV,{existing:b,isNew:v,personas:m,workspaces:g,onCreateSchedule:d,onUpdateSchedule:u,onDeleteSchedule:p,onDone:()=>{s(Jf)},showToast:o})]})}function aV({existing:t,isNew:s,personas:o,workspaces:r,onCreateSchedule:c,onUpdateSchedule:d,onDeleteSchedule:u,onDone:p,showToast:m}){var H;const g=vt(),[v,b]=y.useState((t==null?void 0:t.title)??""),[_,k]=y.useState((t==null?void 0:t.description)??""),[S,T]=y.useState((t==null?void 0:t.scheduleExpression)??""),[j,w]=y.useState((t==null?void 0:t.personaId)??""),[C,D]=y.useState((t==null?void 0:t.workspaceId)??""),[A,E]=y.useState(!1),[R,O]=y.useState(null);y.useEffect(()=>{s||t&&R===null&&(b(t.title),k(t.description),T(t.scheduleExpression),w(t.personaId),D(t.workspaceId))},[s,t,R]);const M=!s&&t===void 0,$=s&&v.trim().length>0&&S.trim().length>0&&j.length>0,Y=o.map(B=>({value:B.id,label:B.name})),V=[{value:"",label:"System-level (no workspace)"},...r.map(B=>({value:B.id,label:B.name}))],ee=B=>{B.preventDefault(),$&&c(v,_,S,j,C||void 0).then(F=>{m("Schedule created","success"),g(K_(F.id),{replace:!0})},()=>{m("Failed to create schedule","error")})},le=(B,F)=>{t&&d(t.id,{[B]:F}).then(()=>{m("Schedule updated","success"),B==="title"&&b(String(F)),B==="description"&&k(String(F)),B==="scheduleExpression"&&T(String(F)),B==="personaId"&&w(String(F))},()=>{m("Failed to update schedule","error")})},Z=()=>{if(!t)return;const B=!t.enabled;d(t.id,{enabled:B}).then(()=>{m(B?"Schedule enabled":"Schedule disabled","success")},()=>{m("Failed to update schedule","error")})},ae=()=>{t&&u(t.id).then(()=>{m("Schedule deleted","success"),p()},()=>{m("Failed to delete schedule","error")})};return i.jsxs(i.Fragment,{children:[M?i.jsxs("div",{className:Bn.form,children:[i.jsx("h3",{children:"Edit Schedule"}),i.jsx("p",{children:"Loading schedule..."})]}):s?i.jsxs("form",{onSubmit:ee,className:Bn.form,children:[i.jsx("h3",{children:"Create Schedule"}),i.jsxs("label",{children:["Title",i.jsx("input",{type:"text",value:v,onChange:B=>b(B.target.value),placeholder:"e.g. Nightly Review",required:!0,"data-testid":"schedule-detail-title"})]}),i.jsxs("label",{children:["Description ",i.jsx("span",{className:Bn.optional,children:"(optional)"}),i.jsx("input",{type:"text",value:_,onChange:B=>k(B.target.value),placeholder:"Brief description...","data-testid":"schedule-detail-description"})]}),i.jsxs("label",{children:["Schedule Expression",i.jsx("input",{type:"text",value:S,onChange:B=>T(B.target.value),placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",required:!0,"data-testid":"schedule-detail-expression"}),i.jsxs("p",{className:Bn.helperText,children:["Interval: ",i.jsx("code",{children:"30s"}),", ",i.jsx("code",{children:"5m"}),", ",i.jsx("code",{children:"1h"}),", ",i.jsx("code",{children:"1d"})," (min 10s) | Cron: ",i.jsx("code",{children:"0 9 * * MON"})," (standard 5-field cron syntax)"]})]}),i.jsxs("label",{children:["Persona",i.jsxs("select",{value:j,onChange:B=>w(B.target.value),required:!0,"data-testid":"schedule-detail-persona",children:[i.jsx("option",{value:"",children:"Select a persona..."}),Y.map(B=>i.jsx("option",{value:B.value,children:B.label},B.value))]})]}),i.jsxs("label",{children:["Workspace ",i.jsx("span",{className:Bn.optional,children:"(optional)"}),i.jsx("select",{value:C,onChange:B=>D(B.target.value),"data-testid":"schedule-detail-workspace",children:V.map(B=>i.jsx("option",{value:B.value,children:B.label},B.value))})]}),i.jsxs("div",{className:Bn.formActions,children:[i.jsx(sn,{type:"submit",variant:"primary",size:"md",disabled:!$,"data-testid":"schedule-detail-save",children:"Create"}),i.jsx(sn,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Cancel"})]})]}):t?i.jsxs("div",{className:Bn.form,children:[i.jsx("h3",{children:"Edit Schedule"}),i.jsxs("div",{className:Bn.formActions,children:[i.jsx(sn,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Back to Schedules"}),i.jsx(sn,{type:"button",variant:t.enabled?"ghost":"primary",size:"md",onClick:Z,"data-testid":"schedule-detail-toggle",children:t.enabled?"Disable":"Enable"}),i.jsx(sn,{type:"button",variant:"danger",size:"md",onClick:()=>E(!0),"data-testid":"schedule-detail-delete",children:"Delete"})]}),i.jsxs("div",{className:Bn.editableSection,children:[i.jsxs("label",{children:["Title",i.jsx(Bt,{value:v,onSave:B=>{le("title",B)},validate:B=>B.trim()?void 0:"Title is required",fieldId:"schedule-title",activeFieldId:R,onActivate:O,ariaLabel:"Schedule title","data-testid":"schedule-detail-title"})]}),i.jsxs("label",{children:["Description",i.jsx(Bt,{value:_,onSave:B=>{le("description",B)},fieldId:"schedule-description",activeFieldId:R,onActivate:O,placeholder:"Brief description...",ariaLabel:"Schedule description","data-testid":"schedule-detail-description"})]}),i.jsxs("label",{children:["Schedule Expression",i.jsx(Bt,{value:S,onSave:B=>{le("scheduleExpression",B)},validate:B=>B.trim()?void 0:"Schedule expression is required",fieldId:"schedule-expression",activeFieldId:R,onActivate:O,placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",ariaLabel:"Schedule expression","data-testid":"schedule-detail-expression"})]}),i.jsxs("label",{children:["Persona",i.jsx(pd,{value:j,onSave:B=>{le("personaId",B)},options:Y,fieldId:"schedule-persona",activeFieldId:R,onActivate:O,ariaLabel:"Schedule persona","data-testid":"schedule-detail-persona"})]}),i.jsxs("label",{children:["Workspace ",i.jsx("span",{className:Bn.optional,children:"(optional — set at creation)"}),i.jsx("span",{className:Bn.readonlyValue,"data-testid":"schedule-detail-workspace",children:((H=r.find(B=>B.id===t.workspaceId))==null?void 0:H.name)??"System-level (no workspace)"})]})]}),i.jsxs("div",{className:Bn.metaSection,children:[t.lastRunAt?i.jsxs("span",{children:["Last run: ",im(t.lastRunAt)]}):i.jsx("span",{children:"Last run: Never"}),t.enabled&&t.nextRunAt?i.jsxs("span",{children:["Next run: ",V1(t.nextRunAt)]}):null,t.runCount>0&&i.jsxs("span",{children:["Total runs: ",t.runCount]}),i.jsxs("span",{children:["Created: ",im(t.createdAt)]})]})]}):null,i.jsx(ys,{isOpen:A,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:ae,onCancel:()=>E(!1)})]})}function iV(){const{themeId:t,resolvedThemeId:s,setTheme:o,preferSystem:r,setPreferSystem:c}=J1();return i.jsx(CB,{themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c})}function oV(){const[t,s]=y.useState(void 0);return y.useEffect(()=>{let o=!1;return(async()=>{try{const c=await ze.getVersionStatus({});o||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{o=!0}},[]),t}function rV(){const{connectionStatus:t,environments:{environments:s},sessions:{sessions:o}}=ut(),r=oV();return i.jsxs(i.Fragment,{children:[r&&i.jsx($O,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),i.jsx(DB,{connectionStatus:t,environments:s,sessions:o})]})}function lV(){return i.jsx(x8,{})}function cV(){const{plugins:{plugins:t,pluginsLoading:s,setPluginEnabled:o}}=ut();return i.jsx(GL,{plugins:t,loading:s,onSetPluginEnabled:(r,c)=>{o(r,c).catch(()=>{})}})}const g_=Di();function dV(){const t=vt();return Fa({key:"?"},()=>{t(VN)}),Fa({key:"n"},()=>{t(g_)}),Fa({key:"N"},()=>{t(g_)}),i.jsx(i.Fragment,{})}function Dd(t){const s=y$();y.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function uV(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=ut(),o=y.useMemo(()=>i.jsx(hO,{workspaces:t,tasks:s}),[t,s]);return Dd(o),i.jsx(Ai,{})}function fV(){const{environments:{environments:t}}=ut(),s=y.useMemo(()=>i.jsx(BI,{environments:t}),[t]);return Dd(s),i.jsx(Ai,{})}function pV(){const t=y.useMemo(()=>i.jsx(g7,{}),[]);return Dd(t),i.jsx(Ai,{})}function mV(){const{knowledge:t,workspaces:{workspaces:s}}=ut(),o=y.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=y.useCallback(()=>{t.clearSearch()},[t]),c=y.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=y.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=y.useMemo(()=>i.jsx(G5,{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 Dd(u),i.jsx(Ai,{})}const hV="_wizard_1260s_1",gV="_container_1260s_10",vV="_stepContent_1260s_19",yV="_logoArea_1260s_28",bV="_logoImage_1260s_32",_V="_heading_1260s_41",xV="_tagline_1260s_49",kV="_subtitle_1260s_56",SV="_featureList_1260s_64",TV="_runtimeGrid_1260s_89",jV="_runtimeCard_1260s_101",wV="_runtimeName_1260s_133",NV="_runtimeDescription_1260s_139",CV="_buttonRow_1260s_144",EV="_primaryButton_1260s_151",AV="_ghostButton_1260s_185",DV="_dots_1260s_213",MV="_dot_1260s_213",We={wizard:hV,container:gV,stepContent:vV,logoArea:yV,logoImage:bV,heading:_V,tagline:xV,subtitle:kV,featureList:SV,runtimeGrid:TV,runtimeCard:jV,runtimeName:wV,runtimeDescription:NV,buttonRow:CV,primaryButton:EV,ghostButton:AV,dots:DV,dot:MV};function RV({onNext:t}){return i.jsxs("div",{className:We.stepContent,"data-testid":"setup-welcome",children:[i.jsx("div",{className:We.logoArea,children:i.jsx("img",{src:Cd("grackle-logo.png"),alt:"Grackle",className:We.logoImage})}),i.jsx("h1",{className:We.heading,children:"Welcome to Grackle"}),i.jsx("p",{className:We.tagline,children:"Multi-agent orchestration for software teams"}),i.jsx("button",{type:"button",className:We.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function IV({onNext:t,onBack:s}){return i.jsxs("div",{className:We.stepContent,"data-testid":"setup-about",children:[i.jsx("h2",{className:We.heading,children:"What is Grackle?"}),i.jsxs("ul",{className:We.featureList,children:[i.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),i.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),i.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),i.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),i.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),i.jsxs("div",{className:We.buttonRow,children:[i.jsx("button",{type:"button",className:We.ghostButton,onClick:s,children:"Back"}),i.jsx("button",{type:"button",className:We.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const OV=[{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 BV({currentRuntime:t,onFinish:s,onBack:o,finishDisabled:r}){const[c,d]=y.useState(t||"claude-code");return y.useEffect(()=>{t&&d(t)},[t]),i.jsxs("div",{className:We.stepContent,"data-testid":"setup-runtime",children:[i.jsx("h2",{className:We.heading,children:"Choose Your Runtime"}),i.jsx("p",{className:We.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),i.jsx("div",{className:We.runtimeGrid,children:OV.map(u=>i.jsxs("button",{type:"button",className:We.runtimeCard,"data-selected":c===u.id,"aria-pressed":c===u.id,"data-testid":`runtime-card-${u.id}`,onClick:()=>d(u.id),children:[i.jsx("span",{className:We.runtimeName,children:u.name}),i.jsx("span",{className:We.runtimeDescription,children:u.description})]},u.id))}),i.jsxs("div",{className:We.buttonRow,children:[i.jsx("button",{type:"button",className:We.ghostButton,onClick:o,children:"Back"}),i.jsx("button",{type:"button",className:We.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function LV(){return typeof Notification<"u"}function zV({onFinish:t,onBack:s,finishDisabled:o}){const r=LV(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return i.jsxs("div",{className:We.stepContent,"data-testid":"setup-notifications",children:[i.jsx("h2",{className:We.heading,children:"Stay in the Loop"}),i.jsx("p",{className:We.subtitle,children:"Grackle can send you a browser notification when an agent needs your input, so you never miss an important moment."}),c?i.jsx("p",{className:We.subtitle,children:Notification.permission==="granted"?"Notifications are already enabled.":"Notifications have been blocked. You can change this in your browser settings."}):null,i.jsxs("div",{className:We.buttonRow,children:[i.jsx("button",{type:"button",className:We.ghostButton,onClick:s,disabled:o,children:"Back"}),!c&&r?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:We.ghostButton,onClick:t,disabled:o,"data-testid":"setup-notifications-skip",children:"Skip"}),i.jsx("button",{type:"button",className:We.primaryButton,onClick:d,disabled:o,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):i.jsx("button",{type:"button",className:We.primaryButton,onClick:t,disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const $V=4,v_={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function HV(){const{personas:{personas:t,updatePersona:s},completeOnboarding:o,onboardingCompleted:r}=ut(),{showToast:c}=pn(),d=vt(),[u,p]=y.useState(0),[m,g]=y.useState("claude-code"),[v,b]=y.useState(!1),_=t.find(T=>T.id==="claude-code"),k=y.useCallback(T=>{g(T),p(3)},[]),S=y.useCallback(()=>{const T=m;b(!0);const j=[];if(_&&T!==_.runtime){const C=v_[T]??"sonnet";j.push(s(_.id,void 0,void 0,void 0,T,C))}const w=t.find(C=>C.id===ay);if(w&&T!==w.runtime){const C=v_[T]??"sonnet";j.push(s(ay,void 0,void 0,void 0,T,C))}Promise.all(j).then(()=>o()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),b(!1)})},[m,_,t,s,o,d,c]);return r===!0?i.jsx(zn,{to:"/",replace:!0}):i.jsx("div",{className:We.wizard,"data-testid":"setup-wizard",children:i.jsxs("div",{className:We.container,children:[i.jsx(as,{mode:"wait",children:i.jsxs($t.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&i.jsx(RV,{onNext:()=>p(1)}),u===1&&i.jsx(IV,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&i.jsx(BV,{currentRuntime:m,onFinish:k,onBack:()=>p(1),finishDisabled:!_}),u===3&&i.jsx(zV,{onFinish:S,onBack:()=>p(2),finishDisabled:v})]},u)}),i.jsx("div",{className:We.dots,children:Array.from({length:$V},(T,j)=>i.jsx("span",{className:We.dot,"data-active":j===u},j))})]})})}const PV="_root_zndgp_1",UV="_body_zndgp_7",VV="_main_zndgp_19",qV="_sidebarWrapper_zndgp_26",GV="_overlay_zndgp_51",Fr={root:PV,body:UV,main:VV,sidebarWrapper:qV,overlay:GV},FV=y.lazy(()=>k_(()=>import("./KnowledgePage-C3ucJMNK.js"),__vite__mapDeps([3,1,2,4,5])).then(t=>({default:t.KnowledgePage}))),lk=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function KV({tabs:t}){const{connectionStatus:s,environments:{environments:o},sessions:{sessions:r},tasks:{tasks:c}}=ut(),{toasts:d,dismissToast:u}=pn(),p=Jt(),m=v$(),g=m!==void 0,[v,b]=y.useState(!1),_=y.useCallback(()=>b(k=>!k),[]);return y.useEffect(()=>{b(!1)},[p.pathname]),y.useEffect(()=>{if(!v)return;const k=S=>{S.key==="Escape"&&b(!1)};return document.addEventListener("keydown",k),()=>{document.removeEventListener("keydown",k)}},[v]),i.jsxs(i.Fragment,{children:[i.jsx(aI,{connectionStatus:s,environments:o,sessions:r,onToggleSidebar:g?_:void 0,sidebarOpen:v}),i.jsx(fI,{tabs:t}),i.jsxs("div",{className:Fr.body,children:[g&&i.jsx("div",{className:Fr.sidebarWrapper,"data-sidebar-open":v,children:i.jsx(yI,{content:m})}),g&&v&&i.jsx("div",{className:Fr.overlay,"data-testid":"drawer-overlay",onClick:()=>b(!1)}),i.jsxs("div",{className:Fr.main,children:[i.jsx(Ai,{}),i.jsx(wI,{sessions:r,tasks:c,environments:o})]})]}),i.jsx(CO,{toasts:d,onDismiss:u}),i.jsx(dV,{})]})}function ZV(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:o,clearOperationError:r},tasks:{tasks:c},connectionStatus:d,onboardingCompleted:u}=ut(),{pluginNames:p}=Ad(),{showToast:m}=pn();N9(s,m),M9(c,m),C9(o,r,m);const g=vt(),v=Jt();if(y.useEffect(()=>{t&&!v.pathname.includes("/tasks/")&&g(Sm(t),{replace:!0})},[t,g,v.pathname]),d==="connected"&&u===!1)return i.jsx(zn,{to:"/setup",replace:!0});const b=W$(p);return i.jsx(g$,{children:i.jsxs("div",{className:Fr.root,children:[lk&&i.jsx(yC,{}),i.jsx(KV,{tabs:b})]})})}function Mp(){const{workspaceId:t}=ua(),{workspaces:{workspaces:s}}=ut(),o=Jt(),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:i.jsx(zn,{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 i.jsx(zn,{to:m,replace:!0})}function YV(){const{pluginNames:t}=Ad(),s=t.includes("orchestration"),o=t.includes("knowledge");return i.jsxs(sN,{children:[i.jsx(Ee,{path:"setup",element:i.jsx(HV,{})}),i.jsxs(Ee,{element:i.jsx(ZV,{}),children:[i.jsx(Ee,{index:!0,element:i.jsx(gP,{})}),i.jsx(Ee,{path:"sessions/new",element:i.jsx(AP,{})}),i.jsx(Ee,{path:"chat",element:i.jsx(wP,{})}),i.jsx(Ee,{path:"chat/:streamId",element:i.jsx(zn,{to:"/coordination",replace:!0})}),i.jsx(Ee,{path:"coordination",element:i.jsx(EP,{})}),i.jsx(Ee,{path:"sessions/:sessionId",element:i.jsx(IP,{})}),o&&i.jsx(Ee,{element:i.jsx(mV,{}),children:i.jsx(Ee,{path:"knowledge",element:i.jsx(y.Suspense,{fallback:i.jsx(E1,{}),children:i.jsx(FV,{})})})}),s&&i.jsxs(Ee,{element:i.jsx(uV,{}),children:[i.jsx(Ee,{path:"tasks",element:i.jsx(mP,{})}),i.jsx(Ee,{path:"tasks/new",element:i.jsx(u_,{})}),i.jsx(Ee,{path:"tasks/:taskId",element:i.jsx(wo,{})}),i.jsx(Ee,{path:"tasks/:taskId/edit",element:i.jsx(wo,{})}),i.jsx(Ee,{path:"tasks/:taskId/stream",element:i.jsx(wo,{})})]}),i.jsxs(Ee,{element:i.jsx(fV,{}),children:[i.jsx(Ee,{path:"workspaces",element:i.jsx(zn,{to:"/environments",replace:!0})}),i.jsx(Ee,{path:"workspaces/new",element:i.jsx(YP,{})}),i.jsx(Ee,{path:"workspaces/:workspaceId",element:i.jsx(Mp,{})}),i.jsx(Ee,{path:"workspaces/:workspaceId/tasks/:taskId",element:i.jsx(Mp,{})}),i.jsx(Ee,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:i.jsx(Mp,{})}),i.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId",element:i.jsx(zP,{})}),i.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:i.jsx(u_,{})}),i.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:i.jsx(wo,{})}),i.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:i.jsx(wo,{})}),i.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:i.jsx(wo,{})}),i.jsxs(Ee,{path:"environments",element:i.jsx(nU,{}),children:[i.jsx(Ee,{index:!0,element:i.jsx(hP,{})}),i.jsx(Ee,{path:"new",element:i.jsx(WP,{})}),i.jsx(Ee,{path:":environmentId",element:i.jsx(MU,{})}),i.jsx(Ee,{path:":environmentId/edit",element:i.jsx(XP,{})})]})]}),i.jsx(Ee,{element:i.jsx(pV,{}),children:i.jsxs(Ee,{path:"settings",element:i.jsx(OU,{}),children:[i.jsx(Ee,{index:!0,element:i.jsx(zn,{to:"credentials",replace:!0})}),i.jsx(Ee,{path:"environments",element:i.jsx(zn,{to:"/environments",replace:!0})}),i.jsx(Ee,{path:"credentials",element:i.jsx(BU,{})}),i.jsx(Ee,{path:"github-accounts",element:i.jsx(LU,{})}),i.jsx(Ee,{path:"tokens",element:i.jsx(zn,{to:"../credentials",replace:!0})}),i.jsx(Ee,{path:"personas",element:i.jsx(zU,{})}),i.jsx(Ee,{path:"personas/new",element:i.jsx(m_,{})}),i.jsx(Ee,{path:"personas/:personaId",element:i.jsx(m_,{})}),i.jsx(Ee,{path:"schedules",element:i.jsx(YU,{})}),i.jsx(Ee,{path:"schedules/new",element:i.jsx(h_,{})}),i.jsx(Ee,{path:"schedules/:scheduleId",element:i.jsx(h_,{})}),i.jsx(Ee,{path:"appearance",element:i.jsx(iV,{})}),i.jsx(Ee,{path:"shortcuts",element:i.jsx(lV,{})}),i.jsx(Ee,{path:"plugins",element:i.jsx(cV,{})}),i.jsx(Ee,{path:"about",element:i.jsx(rV,{})})]})}),i.jsx(Ee,{path:"*",element:i.jsx(zn,{to:"/",replace:!0})})]})]})}const JV=1e4;function WV(){const{onboardingCompleted:t}=ut(),[s,o]=y.useState(!1);y.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>o(!0),JV);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return i.jsx(as,{mode:"wait",children:r?i.jsx($t.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:i.jsx(E1,{})},"splash"):i.jsx($t.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:i.jsx(CN,{basename:"/".replace(/\/$/,""),children:i.jsx(YV,{})})},"app")})}function XV(){const t=lk?q$:w9;return i.jsx(K$,{children:i.jsx(h$,{children:i.jsx(u$,{children:i.jsx(t,{children:i.jsx(WV,{})})})})})}Y2.createRoot(document.getElementById("root")).render(i.jsx(y.StrictMode,{children:i.jsx(XV,{})}));export{fa as B,J_ as K,ut as a,Sm as s,os as t,vt as u};
|