tide-commander 1.148.0 → 1.149.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/CHANGELOG.md +17 -0
- package/README.md +6 -3
- package/dist/assets/{BossLogsModal-CZMHgMBE.js → BossLogsModal-Cs4kWugD.js} +1 -1
- package/dist/assets/BossSpawnModal-BudMgJqj.js +1 -0
- package/dist/assets/{ControlsModal-DJ8Scm16.js → ControlsModal-Bh6_3qtH.js} +1 -1
- package/dist/assets/{DockerLogsModal-Vb4gqdFz.js → DockerLogsModal-Nf4wQFfz.js} +1 -1
- package/dist/assets/{EmbeddedEditor-D4sHERAj.js → EmbeddedEditor-BfRXRX50.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-COIYIbJS.js → GmailOAuthSetup-CXUtjA0r.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-DJS59Soi.js → GoogleOAuthSetup-D-_rwicD.js} +1 -1
- package/dist/assets/{IframeModal-CFysTkn9.js → IframeModal-CdaXsQK0.js} +1 -1
- package/dist/assets/{IntegrationsPanel-BK8g9ceY.js → IntegrationsPanel-ZsSVxcWr.js} +2 -2
- package/dist/assets/{LogViewerModal-DRxR0HYq.js → LogViewerModal-BAf-klB2.js} +1 -1
- package/dist/assets/{MonitoringModal-CL7UMOdX.js → MonitoringModal-BjRbh5z4.js} +1 -1
- package/dist/assets/{PM2LogsModal-I3aouUlw.js → PM2LogsModal-SaywDZVL.js} +1 -1
- package/dist/assets/{RestoreArchivedAreaModal-PWAg6w6b.js → RestoreArchivedAreaModal-jru2Ez9a.js} +1 -1
- package/dist/assets/Scene2DCanvas-NJHoe2Qg.js +1 -0
- package/dist/assets/SceneManager-i9wVMa_V.js +104 -0
- package/dist/assets/{SkillsPanel-EQ74sIa6.js → SkillsPanel-BHfKLzWe.js} +3 -3
- package/dist/assets/{SlackMultiInstanceSetup-CLMUteI0.js → SlackMultiInstanceSetup-BfVevCSo.js} +1 -1
- package/dist/assets/SpawnModal-29x5z53B.js +1 -0
- package/dist/assets/{StatisticsModal-D6MgA_o0.js → StatisticsModal-MbIByjWD.js} +1 -1
- package/dist/assets/{SubordinateAssignmentModal-C6n0pMn3.js → SubordinateAssignmentModal-DF0vYaM6.js} +1 -1
- package/dist/assets/{TriggerManagerPanel-Umd8iUg1.js → TriggerManagerPanel-EGcKS1Pt.js} +1 -1
- package/dist/assets/{WorkflowEditorPanel-CxjBxs9O.js → WorkflowEditorPanel-BLmejfqe.js} +1 -1
- package/dist/assets/{area-logos-CThPeqIM.js → area-logos-C4fgpLgO.js} +1 -1
- package/dist/assets/grok.ico +0 -0
- package/dist/assets/grok.png +0 -0
- package/dist/assets/{index-h3Cuh2Zn.js → index-B-2H7O_Y.js} +2 -2
- package/dist/assets/{index-DelocTaH.js → index-B9xpLAcH.js} +1 -1
- package/dist/assets/{index-BUN7MVf5.js → index-BZ4wZwRu.js} +3 -3
- package/dist/assets/index-BiiLWTXJ.js +1 -0
- package/dist/assets/{index-maZSt2YW.js → index-C6Kf4ewu.js} +5 -5
- package/dist/assets/{index-Cz-ypmob.js → index-C8CGfmXP.js} +1 -1
- package/dist/assets/index-DThK5_yS.js +5 -0
- package/dist/assets/index-DYgVP0G3.js +2 -0
- package/dist/assets/{index-DOzFBkSH.js → index-DhD3m2Qx.js} +1 -1
- package/dist/assets/main-B0UlZnfk.js +260 -0
- package/dist/assets/main-DeiAIdzy.css +1 -0
- package/dist/assets/{web-CfvEypdU.js → web-CXC8P25z.js} +1 -1
- package/dist/assets/{web-CNjTPilF.js → web-LGEDa25c.js} +1 -1
- package/dist/assets/{web-bcYaAwP6.js → web-NM4dUqWg.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/locales/en/tools.json +4 -2
- package/dist/src/packages/server/claude/runner/process-lifecycle.js +53 -0
- package/dist/src/packages/server/claude/runner/stdout-pipeline.js +125 -4
- package/dist/src/packages/server/claude/runner/watchdog.js +12 -0
- package/dist/src/packages/server/claude/session-loader.js +280 -0
- package/dist/src/packages/server/data/index.js +1 -0
- package/dist/src/packages/server/grok/backend.js +231 -0
- package/dist/src/packages/server/grok/index.js +4 -0
- package/dist/src/packages/server/grok/json-event-parser.js +138 -0
- package/dist/src/packages/server/grok/session-watcher.js +460 -0
- package/dist/src/packages/server/routes/agents.js +7 -2
- package/dist/src/packages/server/runtime/grok-runtime-provider.js +11 -0
- package/dist/src/packages/server/runtime/index.js +1 -0
- package/dist/src/packages/server/services/agent-service.js +26 -5
- package/dist/src/packages/server/services/runtime-command-execution.js +4 -2
- package/dist/src/packages/server/services/runtime-events.js +46 -7
- package/dist/src/packages/server/services/runtime-service.js +19 -3
- package/dist/src/packages/server/utils/tool-formatting.js +40 -12
- package/dist/src/packages/server/websocket/handlers/agent-handler.js +70 -17
- package/dist/src/packages/server/websocket/listeners/runtime-listeners.js +63 -7
- package/dist/src/packages/shared/agent-types.js +10 -0
- package/package.json +1 -1
- package/dist/assets/BossSpawnModal-C6DxqtKP.js +0 -1
- package/dist/assets/Scene2DCanvas-DYPHkU3i.js +0 -1
- package/dist/assets/SceneManager-QqKygyaw.js +0 -104
- package/dist/assets/SpawnModal-BOeStihN.js +0 -1
- package/dist/assets/index-DP7kd91h.js +0 -1
- package/dist/assets/index-DRyMARFk.js +0 -5
- package/dist/assets/index-DuWmOZdY.js +0 -2
- package/dist/assets/main-C2zgPci-.js +0 -256
- package/dist/assets/main-C3JO2TRI.css +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as Ze,b2 as es,b3 as ss,b4 as as,b5 as ns,r as t,_ as Ae,S as ne,b6 as te,A as Ee,k as le,i as ts,s as v,n as ls,j as s,b7 as os,a9 as De,b8 as x,b9 as is,ba as oe,I as ie,aQ as T,aO as K,bb as cs,aP as ce,bc as re,bd as rs,$ as ds}from"./main-C2zgPci-.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function Ie(r,j){const S=j.filter(C=>!r.has(C));return S.length===0?`${j[Math.floor(Math.random()*j.length)]}-${Date.now()%1e3}`:S[Math.floor(Math.random()*S.length)]}function hs({isOpen:r,onClose:j,onSpawnStart:S,onSpawnEnd:C,spawnPosition:_e,spawnAreaId:b}){const{t:a}=Ze(["terminal","common"]),P=es(),p=ss(),de=as(),H=de.length>0?de:ns,[m,N]=t.useState(""),[M,F]=t.useState(()=>Ae(ne.LAST_CWD)),[i,k]=t.useState("scout"),[pe,I]=t.useState(!1),[Le,R]=t.useState(!1),[me,J]=t.useState(!1),[ue,he]=t.useState(""),[y,X]=t.useState([]),[A,O]=t.useState(null),[$e,we]=t.useState(!1),[_,xe]=t.useState(""),[h,Te]=t.useState(""),[U,Pe]=t.useState(!1),[z,Fe]=t.useState("bypass"),[o,Y]=t.useState("claude"),[f,E]=t.useState({fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),[fe,Q]=t.useState(new Set),[V,ge]=t.useState("claude-opus-4-8[1m]"),[Z,je]=t.useState("xHigh"),[ee,Re]=t.useState("gpt-5.6-luna"),[se,Oe]=t.useState("minimax/MiniMax-M1-80k"),[be,Ue]=t.useState(""),[D,ze]=t.useState(""),q=t.useRef(null),Ne=t.useRef(!1),L=t.useCallback(()=>{window.__spawnModalAreaContext=null},[]),w=t.useMemo(()=>P.filter(e=>e.enabled),[P]),qe=["full-notifications","streaming-exec","task-label","report-task-to-boss","agent-tracking","agent-memory","send-message-to-agent"];t.useEffect(()=>{if(r&&!Ne.current){if(w.length>0){const l=w.filter(c=>qe.includes(c.slug)).map(c=>c.id);l.length>0&&Q(new Set(l))}const n=Ae(ne.DEFAULT_AGENT_CLASS);if(n==="random"){const c=[...Object.keys(rs),...p.map(u=>u.id)];k(c[Math.floor(Math.random()*c.length)])}else k(n||"scout")}Ne.current=r},[r,w,p]);const ve=t.useMemo(()=>{if(!D.trim())return w;const e=D.toLowerCase();return w.filter(n=>n.name.toLowerCase().includes(e)||n.description.toLowerCase().includes(e)||n.slug.toLowerCase().includes(e))},[w,D]),We=t.useCallback(e=>{Q(n=>{const l=new Set(n);return l.has(e)?l.delete(e):l.add(e),l})},[]);t.useMemo(()=>w.filter(e=>e.assignedAgentClasses.includes(i)),[w,i]);const Ge=t.useMemo(()=>{var n;const e=p.find(l=>l.id===i);return(n=e==null?void 0:e.defaultSkillIds)!=null&&n.length?P.filter(l=>e.defaultSkillIds.includes(l.id)):[]},[p,i,P]),Se=t.useMemo(()=>{if(!_.trim())return y;const e=_.toLowerCase();return y.filter(n=>n.sessionId.toLowerCase().includes(e)||n.projectPath.toLowerCase().includes(e)||n.firstMessage&&n.firstMessage.toLowerCase().includes(e))},[y,_]),W=t.useMemo(()=>{if(!h.trim())return p;const e=h.toLowerCase();return p.filter(n=>n.name.toLowerCase().includes(e)||n.description.toLowerCase().includes(e)||n.id.toLowerCase().includes(e))},[p,h]),G=t.useMemo(()=>{if(!h.trim())return te;const e=h.toLowerCase();return te.filter(n=>{const l=Ee[n.id];return n.name.toLowerCase().includes(e)||n.id.toLowerCase().includes(e)||l.description.toLowerCase().includes(e)})},[h]);t.useEffect(()=>{if(!r||!h.trim())return;const e=[...W.map(n=>n.id),...G.map(n=>n.id)];e.length===1&&e[0]!==i&&k(e[0])},[r,h,W,G,i]);const d=t.useMemo(()=>p.find(e=>e.id===i),[p,i]),Be=t.useMemo(()=>{if(d!=null&&d.model)return d.model},[d]),Ke=t.useMemo(()=>{if(d!=null&&d.customModelPath)return le(`/api/custom-models/${d.id}`)},[d]),He=d==null?void 0:d.modelScale,Je=t.useMemo(()=>d?"scout":i,[i,d]),B=t.useCallback(async e=>{we(!0);try{const n=e?le(`/api/agents/claude-sessions?cwd=${encodeURIComponent(e)}`):le("/api/agents/claude-sessions"),c=await(await ts(n)).json();X(c.sessions||[])}catch(n){console.error("Failed to fetch sessions:",n),X([])}finally{we(!1)}},[]);t.useEffect(()=>{r?B(M||void 0):(X([]),O(null),xe(""))},[r,B]),t.useEffect(()=>{if(!r)return;const e=setTimeout(()=>{B(M||void 0),O(null)},300);return()=>clearTimeout(e)},[M,r,B]),t.useEffect(()=>{if(!r||!b)return;const e=v.getState().areas.get(b);if(e!=null&&e.directories&&e.directories.length>0){F(e.directories[0]);return}const n=Array.from(v.getState().agents.values()).filter(g=>{var $;return(($=v.getAreaForAgent(g.id))==null?void 0:$.id)===b&&g.cwd});if(n.length===0)return;const l=new Map;for(const g of n)l.set(g.cwd,(l.get(g.cwd)||0)+1);let c="",u=0;for(const[g,$]of l)$>u&&(c=g,u=$);c&&F(c)},[r,b]),t.useEffect(()=>{if(r){const e=new Set(Array.from(v.getState().agents.values()).map(u=>u.name)),n=Ie(e,H),l=p.find(u=>u.id===i),c=l?`${l.name} ${n}`:n;N(c),q.current&&(q.current.focus(),q.current.select())}},[r,H]),t.useEffect(()=>{if(!r)return;const e=p.find(n=>n.id===i);if(e){const n=p.find(l=>m.startsWith(l.name+" "));if(n){const l=m.substring(n.name.length+1);N(`${e.name} ${l}`)}else N(`${e.name} ${m}`)}else{const n=p.find(l=>m.startsWith(l.name+" "));if(n){const l=m.substring(n.name.length+1);N(l)}}},[i]),t.useEffect(()=>{i==="boss"&&ge("claude-opus-4-8[1m]")},[i]);const Xe=()=>{var c;console.log("[SpawnModal] handleSpawn called"),R(!1);const e=A&&((c=y.find(u=>u.sessionId===A))==null?void 0:c.projectPath)||M;if(console.log("[SpawnModal] Effective CWD:",e),console.log("[SpawnModal] Agent name:",m),console.log("[SpawnModal] Agent class:",i),console.log("[SpawnModal] Permission mode:",z),console.log("[SpawnModal] Provider:",o),console.log("[SpawnModal] Use Chrome:",U),console.log("[SpawnModal] Session ID:",A||"none"),!e.trim()){console.error("[SpawnModal] Empty CWD, showing error"),R(!0);return}if(!m.trim()){console.log("[SpawnModal] Empty name, regenerating");const u=new Set(Array.from(v.getState().agents.values()).map(g=>g.name));N(Ie(u,H));return}ds(ne.LAST_CWD,e),I(!0),S();const n=Array.from(fe),l=be.trim()||void 0;console.log("[SpawnModal] Calling store.spawnAgent with:",{name:m.trim(),class:i,cwd:e.trim(),sessionId:A||void 0,useChrome:o==="claude"?U:!1,permissionMode:z,provider:o,codexConfig:o==="codex"?f:void 0,codexModel:o==="codex"?ee:void 0,opencodeModel:o==="opencode"?se:void 0,initialSkillIds:n,model:o==="claude"?V:void 0,customInstructions:l?`${l.length} chars`:void 0,spawnAreaId:b||void 0}),window.__spawnModalAreaContext=b?{areaId:b}:null,v.spawnAgent(m.trim(),i,e.trim(),_e||void 0,A||void 0,o==="claude"?U:!1,z,n,o,o==="codex"?f:void 0,o==="codex"?ee:void 0,o==="claude"?V:void 0,l,o==="claude"?Z:void 0,o==="opencode"?se:void 0)},Ce=()=>{console.log("[SpawnModal] Agent creation successful"),I(!1),N(""),Q(new Set),L(),C(),j()},Me=()=>{console.error("[SpawnModal] Agent creation failed"),I(!1),R(!0),L(),C()},ke=e=>{console.log("[SpawnModal] Directory not found:",e),I(!1),he(e),J(!0),C()},ye=()=>{J(!1),I(!0),S(),v.createDirectoryAndSpawn(ue,m.trim(),i)},ae=()=>{J(!1),he(""),L()};t.useEffect(()=>(window.__spawnModalSuccess=Ce,window.__spawnModalError=Me,window.__spawnModalDirNotFound=ke,()=>{L(),delete window.__spawnModalSuccess,delete window.__spawnModalError,delete window.__spawnModalDirNotFound}),[m,i,Ce,Me,ke,L]);const{handleMouseDown:Ye,handleClick:Qe}=ls(j),Ve=e=>{e.key==="Escape"&&j()};return!r&&!me?null:me?s.jsx("div",{className:"modal-overlay visible",onClick:ae,onKeyDown:e=>{e.key==="Escape"&&ae(),e.key==="Enter"&&ye()},children:s.jsxs("div",{className:"modal confirm-modal",onClick:e=>e.stopPropagation(),children:[s.jsx("div",{className:"modal-header",children:a("terminal:spawn.directoryNotFound")}),s.jsxs("div",{className:"modal-body confirm-modal-body",children:[s.jsx("p",{children:a("terminal:spawn.directoryNotExist")}),s.jsx("code",{className:"confirm-modal-path",children:ue}),s.jsx("p",{children:a("terminal:spawn.wouldYouCreate")})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:ae,children:a("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-primary",onClick:ye,autoFocus:!0,children:a("terminal:spawn.createDirectory")})]})]})}):s.jsx("div",{className:`modal-overlay ${r?"visible":""}`,onMouseDown:Ye,onClick:Qe,onKeyDown:Ve,children:s.jsxs("div",{className:"modal spawn-modal",children:[s.jsx("div",{className:"modal-header",children:a("terminal:spawn.deployTitle")}),s.jsxs("div",{className:"modal-body spawn-modal-body",children:[s.jsxs("div",{className:"spawn-top-section",children:[s.jsx("div",{className:"spawn-preview-compact",children:s.jsx(os,{agentClass:Je,modelFile:Be,customModelUrl:Ke,modelScale:He,width:100,height:120})}),s.jsxs("div",{className:"spawn-class-section",children:[s.jsx("div",{className:"spawn-class-label",children:a("terminal:spawn.agentClass")}),p.length+te.length>6&&s.jsx("input",{type:"text",className:"spawn-input class-search-input",placeholder:a("terminal:spawn.filterClasses"),value:h,onChange:e=>Te(e.target.value)}),s.jsxs("div",{className:"class-selector-inline",children:[W.map(e=>s.jsxs("button",{className:`class-chip ${i===e.id?"selected":""}`,onClick:()=>k(e.id),title:e.description,children:[s.jsx(De,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id)),G.map(e=>{const n=Ee[e.id];return s.jsxs("button",{className:`class-chip ${i===e.id?"selected":""}`,onClick:()=>k(e.id),title:n.description,children:[s.jsx(De,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id)}),h&&W.length===0&&G.length===0&&s.jsx("div",{className:"class-search-empty",children:a("terminal:spawn.noClassesMatch",{query:h})})]})]})]}),s.jsxs("div",{className:"spawn-form-section",children:[s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:a("common:labels.name")}),s.jsx("input",{ref:q,type:"text",className:"spawn-input",placeholder:a("terminal:spawn.agentNamePlaceholder"),value:m,onChange:e=>N(e.target.value)})]}),s.jsxs("div",{className:"spawn-field spawn-field-wide",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.workingDir"),s.jsx(x,{text:a("terminal:spawn.helpWorkingDir"),title:a("terminal:spawn.workingDir"),position:"top",size:"sm"})]}),s.jsx(is,{value:M,onChange:e=>{F(e),R(!1)},placeholder:a("terminal:spawn.workingDirPlaceholder"),className:`spawn-input ${Le?"error":""}`,directoriesOnly:!0})]})]}),s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.selectRuntime"),s.jsx(x,{text:a("terminal:spawn.helpRuntime"),title:a("terminal:spawn.runtimeTitle"),position:"top",size:"sm"})]}),s.jsxs("div",{className:"spawn-select-row",children:[s.jsxs("button",{className:`spawn-select-btn ${o==="claude"?"selected":""}`,onClick:()=>Y("claude"),title:a("terminal:spawn.useClaudeCli"),children:[s.jsx("img",{src:"/assets/claude.ico",alt:"Claude",className:"spawn-provider-icon"}),s.jsx("span",{children:"Claude"})]}),s.jsxs("button",{className:`spawn-select-btn ${o==="codex"?"selected":""}`,onClick:()=>Y("codex"),title:a("terminal:spawn.useCodexCli"),children:[s.jsx("img",{src:"/assets/codex.ico",alt:"Codex",className:"spawn-provider-icon"}),s.jsx("span",{children:"Codex"})]}),s.jsxs("button",{className:`spawn-select-btn spawn-select-btn--opencode ${o==="opencode"?"selected":""}`,onClick:()=>Y("opencode"),title:"Use OpenCode CLI (multi-provider)",children:[s.jsx("img",{src:"/assets/opencode.svg",alt:"OpenCode",className:"spawn-provider-icon"}),s.jsx("span",{children:"OpenCode"})]})]})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsxs("label",{className:"spawn-label",children:[a("common:labels.permissions"),s.jsx(x,{text:a("terminal:spawn.helpPermission"),title:a("terminal:spawn.permissionMode"),position:"top",size:"sm"})]}),s.jsx("div",{className:"spawn-select-row",children:Object.keys(oe).map(e=>s.jsxs("button",{className:`spawn-select-btn ${z===e?"selected":""}`,onClick:()=>Fe(e),title:oe[e].description,children:[s.jsx("span",{children:s.jsx(ie,{name:e==="bypass"?"bolt":"lock",size:12})}),s.jsx("span",{children:oe[e].label})]},e))})]})]}),s.jsx("div",{className:"spawn-form-row",children:s.jsxs("div",{className:"spawn-field",children:[s.jsxs("label",{className:"spawn-label",children:[a("common:labels.model"),s.jsx(x,{text:a("terminal:spawn.helpModel"),title:a("terminal:spawn.modelTitle"),position:"top",size:"sm"})]}),o==="claude"?s.jsx("div",{className:"spawn-select-row spawn-select-row--wrap",children:Object.keys(T).filter(e=>!T[e].deprecated).map(e=>s.jsxs("button",{className:`spawn-select-btn ${V===e?"selected":""}`,onClick:()=>ge(e),title:T[e].description,children:[s.jsx("span",{children:T[e].icon}),s.jsx("span",{children:T[e].label})]},e))}):o==="codex"?s.jsx("div",{className:"spawn-select-row spawn-select-row--codex-models",children:Object.keys(K).map(e=>s.jsxs("button",{className:`spawn-select-btn ${ee===e?"selected":""}`,onClick:()=>Re(e),title:K[e].description,children:[s.jsx("span",{children:K[e].icon}),s.jsx("span",{children:K[e].label})]},e))}):o==="opencode"?s.jsx(cs,{value:se,onChange:Oe,inputId:"spawn-opencode-model"}):s.jsx("div",{className:"spawn-inline-hint",children:a("terminal:spawn.chooseCodexModel")})]})}),s.jsxs("div",{className:"spawn-form-row",children:[o==="claude"&&s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:"Effort"}),s.jsxs("div",{className:"spawn-select-row spawn-select-row--effort",children:[s.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${Z===void 0?"selected":""}`,onClick:()=>je(void 0),title:"Use default effort level",children:s.jsx("span",{children:"Default"})}),Object.keys(ce).map(e=>s.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${Z===e?"selected":""}`,onClick:()=>je(e),title:ce[e].description,children:s.jsx("span",{children:ce[e].label})},e))]})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:a("terminal:spawn.browser")}),s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:U,onChange:e=>Pe(e.target.checked),disabled:o!=="claude"}),s.jsxs("span",{children:[s.jsx(ie,{name:"globe",size:12})," ",a("terminal:spawn.chromeBrowser")]}),s.jsx(x,{text:a(o==="claude"?"terminal:spawn.helpChrome":"terminal:spawn.helpChromeDisabled"),title:a("terminal:spawn.chromeBrowser"),position:"top",size:"sm"})]})]})]}),o==="codex"&&s.jsxs("div",{className:"codex-config-section",children:[s.jsx("div",{className:"codex-config-title",children:a("terminal:spawn.codex.configuration")}),s.jsxs("div",{className:"codex-config-options",children:[s.jsxs("div",{className:"codex-option-group",children:[s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:f.fullAuto!==!1,onChange:e=>E(n=>({...n,fullAuto:e.target.checked}))}),s.jsx("span",{children:a("terminal:spawn.codex.fullAuto")}),s.jsx(x,{text:a("terminal:spawn.helpFullAuto"),title:a("terminal:spawn.fullAutoTitle"),position:"top",size:"sm"})]}),s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:!!f.search,onChange:e=>E(n=>({...n,search:e.target.checked}))}),s.jsx("span",{children:a("terminal:spawn.codex.search")}),s.jsx(x,{text:a("terminal:spawn.helpSearch"),title:a("terminal:spawn.searchTitle"),position:"top",size:"sm"})]})]}),f.fullAuto===!1&&s.jsxs("div",{className:"codex-option-group",children:[s.jsx("div",{className:"codex-option-header",children:a("terminal:spawn.codex.restrictions")}),s.jsxs("select",{className:"spawn-input codex-select",value:f.sandbox||"workspace-write",onChange:e=>E(n=>({...n,sandbox:e.target.value})),children:[s.jsxs("option",{value:"read-only",children:["📖 ",a("terminal:spawn.codex.sandboxReadOnly")]}),s.jsxs("option",{value:"workspace-write",children:["✏️ ",a("terminal:spawn.codex.sandboxWorkspaceWrite")]}),s.jsxs("option",{value:"danger-full-access",children:["⚡ ",a("terminal:spawn.codex.sandboxDangerFullAccess")]})]}),s.jsxs("select",{className:"spawn-input codex-select",value:f.approvalMode||"on-request",onChange:e=>E(n=>({...n,approvalMode:e.target.value})),children:[s.jsxs("option",{value:"untrusted",children:["🔒 ",a("terminal:spawn.codex.approvalsUntrusted")]}),s.jsxs("option",{value:"on-failure",children:["⚠️ ",a("terminal:spawn.codex.approvalsOnFailure")]}),s.jsxs("option",{value:"on-request",children:["🤔 ",a("terminal:spawn.codex.approvalsOnRequest")]}),s.jsxs("option",{value:"never",children:["✅ ",a("terminal:spawn.codex.approvalsNever")]})]})]}),s.jsxs("div",{className:"codex-option-group",children:[s.jsx("div",{className:"codex-option-header",children:a("terminal:spawn.codex.profile")}),s.jsx("input",{type:"text",className:"spawn-input codex-profile-input",placeholder:a("terminal:spawn.codex.profilePlaceholder"),value:f.profile||"",onChange:e=>E(n=>({...n,profile:e.target.value||void 0}))})]}),s.jsxs("div",{className:"codex-option-group",children:[s.jsx("div",{className:"codex-option-header",children:a("terminal:spawn.codex.reasoningEffort")}),s.jsxs("select",{className:"spawn-input codex-select",value:f.reasoningEffort||"",onChange:e=>E(n=>({...n,reasoningEffort:e.target.value||void 0})),children:[s.jsx("option",{value:"",children:a("terminal:spawn.codex.reasoningEffortDefault")}),Object.keys(re).map(e=>s.jsxs("option",{value:e,children:[re[e].icon," ",re[e].label]},e))]})]})]})]}),w.length>0&&s.jsxs("div",{className:"spawn-skills-section",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.skills")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",a("common:labels.optional"),")"]}),s.jsx(x,{text:a("terminal:spawn.helpSkills"),title:a("terminal:spawn.skillsTitle"),position:"top",size:"sm"})]}),w.length>6&&s.jsx("input",{type:"text",className:"spawn-input skill-search-input",placeholder:a("terminal:spawn.filterSkills"),value:D,onChange:e=>ze(e.target.value)}),s.jsxs("div",{className:"spawn-skills-inline",children:[ve.map(e=>{const n=fe.has(e.id);return Ge.some(c=>c.id===e.id)?null:s.jsxs("button",{className:`spawn-skill-chip ${n?"selected":""}`,onClick:()=>We(e.id),title:e.description,children:[n&&s.jsx("span",{className:"spawn-skill-check",children:s.jsx(ie,{name:"check",size:10})}),s.jsx("span",{children:e.name}),e.builtin&&s.jsx("span",{className:"spawn-skill-builtin",children:"TC"})]},e.id)}),D&&ve.length===0&&s.jsx("div",{className:"skill-search-empty",children:a("terminal:spawn.noSkillsMatch",{query:D})})]})]}),s.jsxs("div",{className:"spawn-custom-instructions-section",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.customInstructions")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",a("common:labels.optional"),")"]}),s.jsx(x,{text:a("terminal:spawn.helpCustomInstructions"),title:a("terminal:spawn.customInstructions"),position:"top",size:"sm"})]}),s.jsx("textarea",{className:"spawn-input spawn-textarea",placeholder:a("terminal:spawn.customInstructionsPlaceholder"),value:be,onChange:e=>Ue(e.target.value),rows:3})]}),s.jsxs("div",{className:"spawn-sessions-section",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.linkSession")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",a("common:labels.optional"),")"]}),s.jsx(x,{text:a("terminal:spawn.helpLinkSession"),title:a("terminal:spawn.linkSessionTitle"),position:"top",size:"sm"})]}),y.length>0&&s.jsx("input",{type:"text",className:"spawn-input session-search-input",placeholder:a("terminal:spawn.searchSessions"),value:_,onChange:e=>xe(e.target.value)}),s.jsx("div",{className:"sessions-list",children:$e?s.jsx("div",{className:"sessions-loading",children:a("terminal:spawn.loadingSessions")}):y.length===0?s.jsx("div",{className:"sessions-empty",children:a("terminal:spawn.noSessions")}):Se.length===0?s.jsx("div",{className:"sessions-empty",children:a("terminal:spawn.noSessionsMatch",{query:_})}):Se.map(e=>{const n=A===e.sessionId,l=Date.now()-new Date(e.lastModified).getTime(),c=l<6e4?a("common:time.justNow"):l<36e5?a("common:time.minutesAgo",{count:Math.floor(l/6e4)}):l<864e5?a("common:time.hoursAgo",{count:Math.floor(l/36e5)}):a("common:time.daysAgo",{count:Math.floor(l/864e5)});return s.jsxs("div",{className:`session-item ${n?"selected":""}`,onClick:()=>{n?O(null):(O(e.sessionId),F(e.projectPath))},children:[s.jsxs("div",{className:"session-item-header",children:[s.jsx("span",{className:"session-item-path",children:e.projectPath}),s.jsx("span",{className:"session-item-age",children:c})]}),s.jsx("div",{className:"session-item-preview",children:e.firstMessage||a("terminal:spawn.messagesCount",{count:e.messageCount})})]},e.sessionId)})})]})]})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:j,children:a("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-primary",onClick:Xe,disabled:pe,children:a(pe?"common:buttons.deploying":"common:buttons2.deploy")})]})]})})}export{hs as SpawnModal};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ao as ts,u as rs,aR as _s,aS as vs,aT as Is,j as s,I as U,a9 as $s,aU as Es,aV as Ds,aW as Ms,aX as Ls,r as o,ae as Ss,aA as Xs,m as Ps,a5 as Ys,Y as Rs,aY as Gs,aZ as Us,a_ as Fs,a$ as Zs,b0 as Hs,s as M,b1 as Ws,t as G}from"./main-C2zgPci-.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const bs=ts.memo(({agent:a,isSelected:z,isKeyboardFocused:F=!1,onSelect:L,onDoubleClick:r,onChat:g,onFocus:h,onKill:w,onDragStart:S})=>{const{t:x}=rs(["dashboard","common"]),X=_s().has(a.id),N=vs(a.status),Z=Is(a),j=Ls(Z),I=a.taskLabel?s.jsxs(s.Fragment,{children:[s.jsx(U,{name:"task",size:12})," ",a.taskLabel]}):a.currentTask||a.lastAssignedTask,m=a.status==="idle"&&a.lastActivity>0,[,H]=ts.useState(0);return ts.useEffect(()=>{if(!m)return;const b=window.setInterval(()=>H(q=>q+1),15e3);return()=>window.clearInterval(b)},[m]),s.jsxs("div",{className:`dash-card dash-card--${N} ${z?"dash-card--selected":""} ${F?"dash-card--keyboard-focused":""}`,"data-agent-id":a.id,onClick:()=>L(a.id),onDoubleClick:b=>{b.stopPropagation(),r(a.id)},onDragStart:b=>{S==null||S(a),b.dataTransfer.effectAllowed="move"},draggable:!0,title:x("cards.doubleClickHint"),children:[s.jsxs("div",{className:"dash-card__row1",children:[s.jsx("span",{className:`dash-card__status-dot dash-card__status-dot--${N}`}),s.jsx("span",{className:"dash-card__name",children:a.name}),s.jsxs("span",{className:"dash-card__class",children:[s.jsx($s,{agent:a,size:14})," ",a.class]}),s.jsxs("span",{className:`dash-card__provider dash-card__provider--${a.provider}`,children:[s.jsx(U,{name:a.provider==="codex"||a.provider==="opencode"?"status-pending":"robot",size:11,weight:a.provider==="codex"||a.provider==="opencode"?"fill":"regular",color:a.provider==="codex"?"#a16207":a.provider==="opencode"?"#4ade80":void 0})," ",a.provider]}),X&&s.jsx("span",{className:"dash-card__unseen-badge",title:"New output available - click to view",children:"!"})]}),s.jsxs("div",{className:"dash-card__row2",children:[s.jsx("span",{className:`dash-card__status dash-card__status--${N}`,children:X?"Unseen":a.status}),s.jsxs("div",{className:"dash-card__context",children:[s.jsx("div",{className:"dash-card__context-bar",children:s.jsx("div",{className:`dash-card__context-fill dash-card__context-fill--${j}`,style:{width:`${Z}%`}})}),s.jsxs("span",{className:`dash-card__context-pct dash-card__context-pct--${j}`,children:[Z,"%"]})]})]}),s.jsxs("div",{className:"dash-card__row3",children:[s.jsxs("span",{className:"dash-card__workdir",title:a.cwd,children:[s.jsx(U,{name:"folder",size:11})," ",a.cwd.split("/").pop()||a.cwd]}),m&&s.jsxs("span",{className:"dash-card__idle-time",style:{color:Ms(a.lastActivity)},title:Ds(a.lastActivity),children:[s.jsx(U,{name:"status-waiting-input",size:10})," ",Es(a.lastActivity)]})]}),I&&s.jsx("div",{className:"dash-card__row4",children:s.jsx("span",{className:"dash-card__task",children:I})}),s.jsxs("div",{className:"dash-card__actions",children:[g&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--chat",onClick:b=>{b.stopPropagation(),g(a.id)},title:x("cards.openTerminal"),children:x("cards.chat")}),w&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--danger",onClick:b=>{b.stopPropagation(),w(a.id)},title:x("cards.killAgent"),children:x("cards.stop")})]})]})});bs.displayName="AgentCard";const fs=({buildings:a,onSelectBuilding:z})=>{const{t:F}=rs(["dashboard"]),L=o.useMemo(()=>Array.from(a.values()).sort((r,g)=>r.name.localeCompare(g.name)),[a]);return s.jsxs("div",{className:"dashboard-view__buildings",children:[s.jsxs("div",{className:"dashboard-view__buildings-header",children:[s.jsx("span",{className:"dashboard-view__buildings-title",children:F("buildings.title")}),s.jsx("span",{className:"dashboard-view__buildings-count",children:L.length})]}),s.jsx("div",{className:"dashboard-view__buildings-row",children:L.map(r=>{const g=vs(r.status),h=Ss(r.type);return s.jsxs("button",{className:`dash-pill dash-pill--${g}`,onClick:()=>z==null?void 0:z(r.id),title:`${r.name} (${r.type}) - ${r.status}`,children:[s.jsx("span",{className:"dash-pill__icon",children:s.jsx(U,{name:h,size:14})}),s.jsx("span",{className:"dash-pill__name",children:r.name}),s.jsx("span",{className:`dash-pill__dot dash-pill__dot--${g}`})]},r.id)})})]})};fs.displayName="BuildingPills";function qs({onSelectAgent:a,onFocusAgent:z,onKillAgent:F,onSelectBuilding:L,onOpenTerminal:r,onFocusZone:g}){const{t:h}=rs(["dashboard","common"]),w=Xs(),S=Ps(),x=Ys(),ns=Rs(),X=_s(),[N,Z]=o.useState(""),[j,I]=o.useState("all"),[m,H]=o.useState("zone"),[b,q]=o.useState(new Set),[k,T]=o.useState(null),[ws,B]=o.useState(null),[P,J]=o.useState(!1),[p,W]=o.useState(null),K=o.useMemo(()=>{const e=Array.from(w.values());return{total:e.length,working:e.filter(d=>d.status==="working"||d.status==="waiting"||d.status==="waiting_permission").length,idle:e.filter(d=>d.status==="idle").length,error:e.filter(d=>d.status==="error"||d.status==="offline"||d.status==="orphaned").length}},[w]),is=o.useMemo(()=>m==="zone"?Gs(w,x):m==="status"?Us(w,X):Fs(w),[w,x,m,X]),Q=o.useMemo(()=>{const e=N.toLowerCase().trim(),d=is.map(l=>({...l,agents:l.agents.filter(_=>{if(j==="working"){if(_.status!=="working"&&_.status!=="waiting"&&_.status!=="waiting_permission")return!1}else if(j==="error"&&_.status!=="error"&&_.status!=="offline"&&_.status!=="orphaned")return!1;return!(e&&!_.name.toLowerCase().includes(e)&&!_.class.toLowerCase().includes(e))})}));return m==="zone"?d:d.filter(l=>l.agents.length>0)},[is,j,N,m]),O=o.useCallback(e=>e.area?`area:${e.area.id}`:`${m}:${e.label}`,[m]),ss=o.useMemo(()=>Q.map(e=>({...e,sortedAgents:m==="status"?Zs(e.agents,{prioritizeRecentlyIdle:!0}):Hs(e.agents)})),[Q,m]),C=o.useMemo(()=>{const e=[];return ss.forEach(d=>{const l=O(d);b.has(l)||e.push(...d.sortedAgents)}),e},[ss,b,O]),ps=o.useCallback(e=>{q(d=>{const l=new Set(d);return l.has(e)?l.delete(e):l.add(e),l})},[]),gs=o.useCallback(e=>{r==null||r(e)},[r]),xs=o.useCallback(e=>{a==null||a(e),J(!0),W(e)},[a]),js=o.useCallback(e=>{r==null||r(e)},[r]),Ns=o.useCallback(e=>{T(e)},[]),ks=o.useCallback((e,d)=>{e.preventDefault(),e.dataTransfer.dropEffect="move",B(d)},[]),Cs=o.useCallback(()=>{B(null)},[]),ys=o.useCallback(e=>{if(!k)return;if(e===null){const $=M.getState(),t=Array.from($.areas.values()).find(n=>n.assignedAgentIds.includes(k.id));t&&M.unassignAgentFromArea(k.id,t.id),T(null),B(null);return}const d=x.get(e);if(!d)return;const l=Array.from(w.values()),_=Ws(d,l,k.position);M.updateAgent({...k,position:{...k.position,x:_.x,z:_.z}}),M.assignAgentToArea(k.id,e),T(null),B(null)},[k,x,w]);return o.useEffect(()=>{if(C.length===0){J(!1),W(null);return}P&&(!p||!C.some(e=>e.id===p))&&(W(C[0].id),a==null||a(C[0].id))},[C,P,p,a]),o.useEffect(()=>{const e=t=>t instanceof HTMLElement?t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"||t.isContentEditable:!1,d=t=>t instanceof HTMLElement?!!t.closest(".guake-terminal")||t.classList.contains("guake-input")||t.classList.contains("agent-panel-input"):!1,l=t=>{const n=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).find(A=>A.dataset.agentId===t);n==null||n.scrollIntoView({block:"nearest",inline:"nearest"})},_=(t,n)=>{var os,cs,ls,us,hs,ms;const A=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).map(i=>{const u=i.dataset.agentId;if(!u)return null;const y=i.getBoundingClientRect();return{id:u,centerX:y.left+y.width/2,centerY:y.top+y.height/2,height:y.height}}).filter(i=>i!==null).sort((i,u)=>i.centerY-u.centerY||i.centerX-u.centerX);if(A.length===0)return t;const es=A.reduce((i,u)=>i+u.height,0)/A.length,as=Math.max(18,es*.6),f=[];for(const i of A){const u=f[f.length-1];if(!u){f.push([{id:i.id,centerX:i.centerX,centerY:i.centerY}]);continue}const y=u.reduce((As,zs)=>As+zs.centerY,0)/u.length;Math.abs(i.centerY-y)<=as?u.push({id:i.id,centerX:i.centerX,centerY:i.centerY}):f.push([{id:i.id,centerX:i.centerX,centerY:i.centerY}])}f.forEach(i=>i.sort((u,y)=>u.centerX-y.centerX));const Y=f.findIndex(i=>i.some(u=>u.id===t));if(Y===-1)return((cs=(os=f[0])==null?void 0:os[0])==null?void 0:cs.id)??t;const E=f[Y],v=E.findIndex(i=>i.id===t);if(v===-1)return((us=(ls=f[0])==null?void 0:ls[0])==null?void 0:us.id)??t;if(n==="left")return((hs=E[Math.max(0,v-1)])==null?void 0:hs.id)??t;if(n==="right")return((ms=E[Math.min(E.length-1,v+1)])==null?void 0:ms.id)??t;const V=n==="up"?Math.max(0,Y-1):Math.min(f.length-1,Y+1),c=f[V],R=E[v].centerX;let D=c[0],ds=Math.abs(D.centerX-R);for(const i of c){const u=Math.abs(i.centerX-R);u<ds&&(D=i,ds=u)}return(D==null?void 0:D.id)??t},$=t=>{const n=M.getShortcuts(),A=n.find(c=>c.id==="dashboard-selector-toggle"),es=n.find(c=>c.id==="dashboard-vim-left"),as=n.find(c=>c.id==="dashboard-vim-down"),f=n.find(c=>c.id==="dashboard-vim-up"),Y=n.find(c=>c.id==="dashboard-vim-right"),E=n.find(c=>c.id==="open-terminal"),v=M.getState();if(e(t.target))if(!v.terminalOpen&&d(t.target)&&document.activeElement instanceof HTMLElement)document.activeElement.blur();else return;if(G(t,A)){if(C.length===0)return;t.preventDefault(),t.stopPropagation(),J(!0),W(c=>{const R=c&&C.some(D=>D.id===c)?c:C[0].id;return a==null||a(R),window.setTimeout(()=>l(R),0),R});return}const V=G(t,es)||t.key==="ArrowLeft"?"left":G(t,as)||t.key==="ArrowDown"?"down":G(t,f)||t.key==="ArrowUp"?"up":G(t,Y)||t.key==="ArrowRight"?"right":null;if(V&&P&&p){t.preventDefault(),t.stopPropagation();const c=_(p,V);c!==p&&(W(c),a==null||a(c),window.setTimeout(()=>l(c),0));return}if(G(t,E)){if(v.terminalOpen)return;if(P&&p&&v.agents.has(p)){t.preventDefault(),r==null||r(p);return}if(v.selectedAgentIds.size===1){t.preventDefault();const c=Array.from(v.selectedAgentIds)[0];r==null||r(c);return}if(v.lastSelectedAgentId&&v.agents.has(v.lastSelectedAgentId)){t.preventDefault(),r==null||r(v.lastSelectedAgentId);return}}};return document.addEventListener("keydown",$,!0),()=>document.removeEventListener("keydown",$,!0)},[C,P,p,r,a]),o.useEffect(()=>{const e=document.activeElement;e instanceof HTMLElement&&e.closest(".guake-terminal")&&!M.getState().terminalOpen&&e.blur()},[]),s.jsxs("div",{className:"dashboard-view",children:[s.jsxs("div",{className:"dashboard-view__topbar",children:[s.jsxs("div",{className:"dashboard-view__metrics",children:[s.jsxs("button",{className:`dashboard-view__metric-btn ${j==="all"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.total}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:labels.agents")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--working ${j==="working"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("working"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.working}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.working")})]}),s.jsxs("button",{className:"dashboard-view__metric-btn dashboard-view__metric-btn--idle ",onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.idle}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.idle")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--error ${j==="error"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("error"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.error}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.error")})]})]}),s.jsx("input",{className:"dashboard-view__search",type:"text",placeholder:h("searchPlaceholder"),value:N,onChange:e=>Z(e.target.value)})]}),s.jsxs("div",{className:"dashboard-view__grouping",children:[s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="zone"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>H("zone"),children:h("grouping.byZone")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="status"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>H("status"),children:h("grouping.byStatus")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="activity"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>H("activity"),children:h("grouping.byActivity")})]}),s.jsxs("div",{className:"dashboard-view__content",children:[ss.map(e=>{const d=O(e),l=b.has(d),_=e.sortedAgents,$=e.agents.filter(n=>n.status==="working"||n.status==="waiting"||n.status==="waiting_permission").length,t=e.agents.filter(n=>X.has(n.id)).length;return s.jsxs("div",{className:`dashboard-view__zone ${ws===(e.area?e.area.id:null)&&k?"dashboard-view__zone--drag-over":""}`,onDragOver:n=>ks(n,e.area?e.area.id:null),onDragLeave:Cs,onDrop:()=>ys(e.area?e.area.id:null),children:[s.jsxs("div",{className:"dashboard-view__zone-header",onClick:()=>ps(d),children:[s.jsxs("div",{className:"dashboard-view__zone-left",children:[s.jsx("span",{className:`dashboard-view__zone-chevron ${l?"dashboard-view__zone-chevron--collapsed":""}`,children:s.jsx(U,{name:"caret-down",size:12})}),s.jsx("span",{className:"dashboard-view__zone-dot",style:{backgroundColor:e.color}}),s.jsx("span",{className:"dashboard-view__zone-name",children:e.label}),s.jsxs("span",{className:"dashboard-view__zone-count",children:[h("agentCount",{count:e.agents.length}),$>0&&s.jsxs("span",{className:"dashboard-view__zone-working",children:[" · ",$," ",h("working")]}),t>0&&s.jsxs("span",{className:"dashboard-view__zone-unseen",children:[" · ",t," Unseen"]})]})]}),e.area&&g&&s.jsx("button",{className:"dashboard-view__zone-focus",onClick:n=>{n.stopPropagation(),g(e.area.id)},title:h("focusZone"),children:h("focusZone")})]}),!l&&s.jsx("div",{className:"dashboard-view__zone-grid",children:_.map(n=>s.jsx(bs,{agent:n,isSelected:ns.has(n.id),isKeyboardFocused:P&&p===n.id,onSelect:xs,onDoubleClick:gs,onChat:js,onFocus:z,onKill:F,onDragStart:Ns},n.id))})]},d)}),Q.length===0&&s.jsx("div",{className:"dashboard-view__empty",children:N?h("noAgentsMatching",{search:N}):h("noAgentsSpawned")}),S.size>0&&s.jsx(fs,{buildings:S,onSelectBuilding:L})]})]})}export{qs as DashboardView};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{bS as He,r as t,s as I,k as ye,bT as Ee,i as Oe,j as e,I as z,u as fe,bU as ze,Z as Pe,bV as Ue,bW as Be,q as We,bX as Ke,bY as De,bZ as Ve,ai as qe,aj as Ge,ak as Ye,bf as Je,_ as Me,S as ce,b9 as Xe,b6 as Ze,a9 as Qe,$ as Ie,aA as et,a5 as tt,b_ as st,t as X,b$ as nt}from"./main-C2zgPci-.js";import{FileExplorerPanel as at}from"./index-BUN7MVf5.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Ne={status:"all",activity:"all",sort:"activity"},lt={"1h":3600*1e3,"6h":360*60*1e3,"24h":1440*60*1e3},Ae=20,me=3,ct={idle:"#4aff9e",working:"#4a9eff",waiting:"#ff9e4a",waiting_permission:"#ffcc00",error:"#ff4a4a",offline:"#888888",orphaned:"#ff9e4a"},ot=12e4;function rt(s){return s.trim().replace(/\r\n/g,`
|
|
2
|
-
`)}function $e(s,a){return`${s}:${rt(a)}`}function it(s,a,l,f){if(s.uuid&&a.has(s.uuid))return!1;if(s.uuid)return!0;const p=s.isUserPrompt?"user":"assistant",d=$e(p,s.text),M=s.timestamp||0,A=l.get(d);return A!==void 0&&Math.abs(M-A)<=ot?!1:M>f}function dt({isOpen:s,agents:a}){const l=He(),[f,p]=t.useState(new Map),d=t.useRef(new Set);t.useRef(a);const M=t.useMemo(()=>Array.from(a.keys()).sort().join(","),[a]),A=t.useMemo(()=>Array.from(a.values()).map(j=>`${j.id}:${j.sessionId||""}`).sort().join(","),[a]);t.useEffect(()=>{s||(d.current.clear(),p(new Map))},[s]),t.useEffect(()=>{if(!s)return;const j=new Set(Array.from(a.keys()));for(const i of d.current)j.has(i)||d.current.delete(i);let h=null;l>0&&(h=I.preserveOutputs(),d.current.clear());const v=async(i,C,F=0)=>{if(d.current.add(i.id),F>0&&await new Promise(x=>setTimeout(x,F)),p(x=>{const k=new Map(x);return k.set(i.id,{agentId:i.id,messages:[],loading:!0,hasMore:!1,totalCount:0}),k}),!i.sessionId){C&&C.length>0&&I.mergeOutputsWithHistory(i.id,[],C),p(x=>{const k=new Map(x);return k.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),k});return}try{const k=await(await Oe(ye(`/api/agents/${i.id}/history?limit=${Ee}&offset=0`))).json(),T=k.messages||[],K=T.length>0?Math.max(...T.map(w=>w.timestamp?new Date(w.timestamp).getTime():0)):0,Y=new Set(T.map(w=>w.uuid).filter(w=>!!w)),V=new Map;for(const w of T){if(w.type!=="user"&&w.type!=="assistant")continue;const o=$e(w.type,w.content),L=w.timestamp?new Date(w.timestamp).getTime():0,W=V.get(o)??0;L>W&&V.set(o,L)}const q=I.getOutputs(i.id),B=(C&&C.length>0?[...C,...q]:q).filter(w=>it(w,Y,V,K));I.clearOutputs(i.id);for(const w of B)I.addOutput(i.id,w);p(w=>{const o=new Map(w);return o.set(i.id,{agentId:i.id,messages:T,loading:!1,hasMore:k.hasMore||!1,totalCount:k.totalCount||0}),o})}catch(x){if(console.error(`Failed to load history for ${i.name}:`,x),C&&C.length>0){I.clearOutputs(i.id);for(const k of C)I.addOutput(i.id,k)}p(k=>{const T=new Map(k);return T.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),T})}},u=l>0?500:0,D=Array.from(a.values());for(const i of D)if(!d.current.has(i.id)){const C=h==null?void 0:h.get(i.id);v(i,C,u)}},[s,M,A,l]);const R=t.useRef(a),N=t.useRef(f);R.current=a,N.current=f;const b=t.useCallback(async j=>{const h=R.current.get(j),v=N.current.get(j);if(!(h!=null&&h.sessionId)||!v||!v.hasMore)return;const u=v.messages.length;try{const i=await(await fetch(ye(`/api/agents/${j}/history?limit=${Ee}&offset=${u}`))).json();i.messages&&i.messages.length>0&&p(C=>{const F=new Map(C),x=C.get(j);return x&&F.set(j,{...x,messages:[...i.messages,...x.messages],hasMore:i.hasMore||!1}),F})}catch(D){console.error(`Failed to load more history for agent ${j}:`,D)}},[]),E=t.useCallback(j=>{d.current.delete(j),p(h=>{const v=new Map(h),u=h.get(j);return u&&v.set(j,{...u,messages:[],hasMore:!1,totalCount:0,loading:!1}),v})},[]);return{histories:f,loadMoreHistory:b,clearAgentHistory:E}}function ut({command:s,onCommandChange:a,useTextarea:l,forceTextarea:f,onForceTextarea:p,onSend:d,canSend:M,attachedFiles:A,onAddFile:R,onRemoveFile:N,uploadFile:b,onAddPastedText:E,placeholder:j="Message...",className:h="",compact:v=!1,inputRef:u}){const D=t.useRef(null),i=t.useRef(null),C=t.useRef(l);t.useEffect(()=>{if(l&&!C.current&&i.current){const o=i.current;o.focus(),o.selectionStart=o.selectionEnd=o.value.length}C.current=l},[l]),t.useEffect(()=>{const o=i.current;if(!o||!l)return;o.style.height="auto";const L=v?120:180,W=Math.min(o.scrollHeight,L);o.style.height=`${W}px`},[s,l,v]);const F=t.useCallback(async o=>{const L=o.clipboardData.items;for(const O of L)if(O.type.startsWith("image/")){o.preventDefault();const $=O.getAsFile();if($){const _=await b($);_&&R(_)}return}const W=o.clipboardData.files;if(W.length>0){o.preventDefault();for(const O of W){const $=await b(O);$&&R($)}return}const U=o.clipboardData.getData("text"),te=(U.match(/\n/g)||[]).length+1;if(te>5){o.preventDefault();const $=`[Pasted text #${E(U)} +${te} lines]`,_=o.target,se=_.selectionStart||0,ae=_.selectionEnd||0,ne=s.slice(0,se)+$+s.slice(ae);a(ne),l||p(!0)}},[s,a,l,p,b,R,E]),x=t.useCallback(async o=>{const L=o.target.files;if(L){for(const W of L){const U=await b(W);U&&R(U)}D.current&&(D.current.value="")}},[b,R]),k=t.useCallback(o=>{if(o.key==="Enter"&&o.shiftKey){l||(o.preventDefault(),p(!0));return}o.key==="Enter"&&(o.preventDefault(),d())},[l,p,d]),T=t.useCallback(o=>{},[]),K=t.useCallback(o=>{o.button===1&&(o.preventDefault(),o.stopPropagation())},[]),Y=t.useCallback(o=>{i.current=o,u==null||u(o)},[u]),V=v?"agent-panel-input":"guake-input",q=v?"agent-panel-input-container":"guake-input-container",Z=v?"agent-panel-attach-btn":"guake-attach-btn",B=v?"agent-panel-send-btn":"",w=l?v?"agent-panel-input-expanded":"guake-input-expanded":"";return e.jsxs(e.Fragment,{children:[A.length>0&&e.jsx("div",{className:v?"agent-panel-attachments":"guake-attachments",children:A.map(o=>e.jsxs("div",{className:`${v?"agent-panel-attachment":"guake-attachment"} ${o.isImage?"is-image":""}`,children:[e.jsx("span",{className:v?"agent-panel-attachment-icon":"guake-attachment-icon",children:e.jsx(z,{name:o.isImage?"file":"paperclip",size:12})}),e.jsx("span",{className:v?"agent-panel-attachment-name":"guake-attachment-name",title:o.path,children:o.name}),!v&&e.jsxs("span",{className:"guake-attachment-size",children:["(",Math.round(o.size/1024),"KB)"]}),e.jsx("button",{className:v?"agent-panel-attachment-remove":"guake-attachment-remove",onClick:()=>N(o.id),title:"Remove",children:"×"})]},o.id))}),e.jsxs("div",{className:`${V} ${w} ${h}`,children:[e.jsx("input",{ref:D,type:"file",multiple:!0,onChange:x,style:{display:"none"},accept:"*"}),e.jsxs("div",{className:q,onAuxClick:K,children:[e.jsx("button",{className:Z,onClick:()=>{var o;return(o=D.current)==null?void 0:o.click()},title:"Attach file (or paste image)",children:e.jsx(z,{name:"paperclip",size:14})}),l?e.jsx("textarea",{ref:Y,placeholder:j,value:s,onChange:o=>a(o.target.value),onKeyDown:k,onPaste:F,onMouseDown:T}):e.jsx("input",{ref:u,type:"text",placeholder:j,value:s,onChange:o=>a(o.target.value),onKeyDown:k,onPaste:F,onMouseDown:T}),e.jsx("button",{className:B,onClick:d,disabled:!M,title:"Send",children:e.jsx(z,{name:"send",size:14})})]})]})]})}function mt(s){const a=Math.floor(s/1e3),l=Math.floor(a/60),f=a%60;return`${l}:${f.toString().padStart(2,"0")}`}const ft=t.memo(function({agentId:a,isWorking:l,timestamp:f}){const{t:p}=fe(["terminal"]),[d,M]=t.useState(0);return t.useEffect(()=>{if(!l||!f){M(0);return}M(Date.now()-f);const A=setInterval(()=>{M(Date.now()-f)},1e3);return()=>clearInterval(A)},[l,f]),l?e.jsxs("div",{className:"guake-stop-bar",children:[e.jsx("span",{className:"guake-elapsed-timer",children:mt(d)}),e.jsxs("button",{className:"guake-stop-btn",onClick:()=>I.stopAgent(a),title:p("terminal:input.stopOperation"),children:[e.jsx("span",{className:"stop-icon",children:e.jsx(z,{name:"stop",size:12,weight:"fill"})}),e.jsx("span",{className:"stop-label",children:p("terminal:input.stop")})]})]}):null});function pt({agent:s,history:a,outputs:l,isExpanded:f,isFocused:p,advancedView:d,onExpand:M,onFocus:A,inputRef:R,onLoadMore:N,onClearHistory:b}){const{t:E}=fe(["terminal","common"]),j=ze(s.id),h=t.useRef(null),[v,u]=t.useState(!1),D=t.useRef(0),i=t.useRef(!1),[C,F]=t.useState(!0),[x,k]=t.useState(!1),[T,K]=t.useState(null),[Y,V]=t.useState(null),[q,Z]=t.useState(null);Pe(`commander-image-modal-${s.id}`,T!==null,()=>K(null));const{command:B,setCommand:w,forceTextarea:o,setForceTextarea:L,useTextarea:W,setPastedTexts:U,incrementPastedCount:te,resetPastedCount:O,attachedFiles:$,setAttachedFiles:_,removeAttachedFile:se,uploadFile:ae,expandPastedTexts:ne}=Ue({selectedAgentId:s.id}),le=B.trim().length>0||$.length>0,n=Be({outputs:l,viewMode:d?"advanced":"simple"}),c=t.useMemo(()=>{const S=We(s);return{usedPercent:S.usedPercent,freePercent:S.freePercent,hasData:!!s.contextStats,totalTokens:S.totalTokens,contextWindow:S.contextWindow}},[s.contextStats,s.contextUsed,s.contextLimit]),g=t.useCallback(()=>{!v&&(a!=null&&a.hasMore)&&N&&(u(!0),D.current=h.current?h.current.scrollHeight-h.current.scrollTop:0,N())},[v,a==null?void 0:a.hasMore,N]);t.useEffect(()=>{v&&a&&!a.loading&&u(!1)},[a,v]);const m=t.useCallback(()=>{i.current=!0,F(!1)},[]),P=t.useRef(f),Q=t.useRef(p);t.useEffect(()=>{(f&&!P.current||p&&!Q.current)&&(i.current=!1,F(!0),k(!0)),P.current=f,Q.current=p},[f,p]);const ee=t.useRef(a==null?void 0:a.loading);t.useEffect(()=>{ee.current&&!(a!=null&&a.loading)&&(i.current=!1,F(!0),k(!0)),ee.current=a==null?void 0:a.loading},[a==null?void 0:a.loading]),t.useEffect(()=>{if(!x)return;const S=h.current;if(!S)return;const y=performance.now();let H=0,ue=-1,ke;const Re=()=>{const{scrollTop:Fe,scrollHeight:Se,clientHeight:Le}=S,_e=Se-Fe-Le<=2;if(Math.abs(Se-ue)<=1&&_e?H+=1:H=0,ue=Se,H>=3){k(!1);return}if(performance.now()-y>5e3){k(!1);return}ke=requestAnimationFrame(Re)};return ke=requestAnimationFrame(Re),()=>cancelAnimationFrame(ke)},[x]),t.useEffect(()=>{i.current||F(!0)},[n.length]);const G=t.useCallback(()=>!1,[]),ie=t.useCallback(S=>{const y=te();return U(H=>new Map(H).set(y,S)),y},[te,U]),he=t.useCallback(S=>{_(y=>[...y,S])},[_]),xe=t.useCallback(()=>{if(!le)return;if(B.trim()==="/clear"&&$.length===0){I.clearContext(s.id),b(),w(""),L(!1),U(new Map),_([]),O();return}let S=ne(B.trim());if($.length>0){const y=$.map(H=>H.isImage?`[Image: ${H.path}]`:`[File: ${H.path}]`).join(`
|
|
3
|
-
`);S=S?`${S}
|
|
4
|
-
|
|
5
|
-
${y}`:y}I.sendCommand(s.id,S),w(""),L(!1),U(new Map),_([]),O()},[s.id,B,le,$,ne,b,O,w,L,U,_]),ge=t.useCallback((S,y)=>{K({url:S,name:y})},[]),ve=t.useCallback((S,y)=>{const H=Ke(S,s.cwd),ue=H.line?{...y||{},targetLine:H.line}:y;I.setFileViewerPath(H.path,ue,s.cwd)},[s.cwd]),je=t.useCallback((S,y)=>{V({command:S,output:y,isLive:y==="Running..."})},[]),we=t.useCallback(S=>{Z(S)},[]),Ce=t.useCallback(()=>{k(!1),i.current=!0,F(!1)},[]),be=t.useCallback(()=>K(null),[]),r=t.useCallback(()=>V(null),[]),J=t.useCallback(()=>Z(null),[]),de=t.useCallback(S=>{S.stopPropagation(),M()},[M]),oe=ct[s.status]||"#888888",re=(a==null?void 0:a.messages)||[];return e.jsxs("div",{className:`agent-panel ${s.status==="working"?"working":""} ${f?"expanded":""} ${p?"focused":""}`,onClick:p?void 0:A,children:[e.jsxs("div",{className:"agent-panel-header",onClick:p?A:void 0,children:[e.jsxs("div",{className:"agent-panel-info",children:[e.jsx("span",{className:"agent-panel-status",style:{background:oe},title:s.status}),e.jsxs("span",{className:"agent-panel-name",children:[(s.isBoss||s.class==="boss")&&e.jsx("span",{className:"agent-panel-boss-crown",children:e.jsx(z,{name:"crown",size:14})}),s.name]}),e.jsx("span",{className:`agent-panel-status-label ${s.status}`,children:s.status}),e.jsx("span",{className:"agent-panel-class",children:s.class}),e.jsx("span",{className:`agent-panel-provider ${s.provider==="codex"?"codex":s.provider==="opencode"?"opencode":"claude"}`,children:s.provider||"claude"}),e.jsxs("span",{className:"agent-panel-id",title:`ID: ${s.id}`,children:["[",s.id.substring(0,4),"]"]}),s.taskLabel?e.jsxs("div",{className:"agent-panel-task agent-panel-task-label",title:s.taskLabel,children:[e.jsx(z,{name:"task",size:12})," ",s.taskLabel]}):s.currentTask?e.jsxs("div",{className:"agent-panel-task",title:s.currentTask,children:[s.currentTask.substring(0,40),"..."]}):null]}),e.jsxs("div",{className:"agent-panel-context",title:`Context: ${Math.round(c.usedPercent)}% used (${De(c.totalTokens)} / ${De(c.contextWindow)})`,children:[e.jsx("div",{className:"agent-panel-context-bar",style:{background:c.freePercent<20?"#ff4a4a":c.freePercent<50?"#ff9e4a":"#4aff9e",width:`${c.freePercent}%`}}),e.jsxs("span",{className:"agent-panel-context-text",children:[Math.round(c.freePercent),"%"]})]}),e.jsx("div",{className:"agent-panel-actions",children:e.jsx("button",{className:"agent-panel-expand",onClick:de,title:E(f?"commander.collapsePanel":"commander.expandPanel"),children:f?e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"4 14 10 14 10 20"}),e.jsx("polyline",{points:"20 10 14 10 14 4"}),e.jsx("line",{x1:"14",y1:"10",x2:"21",y2:"3"}),e.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]}):e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("polyline",{points:"9 21 3 21 3 15"}),e.jsx("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),e.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})})})]}),e.jsx("div",{className:"agent-panel-content",ref:h,children:a!=null&&a.loading?e.jsx("div",{className:"agent-panel-loading",children:E("common:status.loading")}):e.jsx(e.Fragment,{children:!re.length&&!n.length?e.jsxs("div",{className:"agent-panel-empty",children:[E("commander.noMessages"),!s.sessionId&&e.jsx("div",{style:{fontSize:"10px",color:"#666"},children:E("commander.noSessionId")})]}):e.jsx(Ve,{historyMessages:re,liveOutputs:n,agentId:s.id,viewMode:d?"advanced":"simple",selectedMessageIndex:null,isMessageSelected:G,onImageClick:ge,onFileClick:ve,onBashClick:je,onViewMarkdown:we,scrollContainerRef:h,onScrollTopReached:g,isLoadingMore:v,hasMore:a==null?void 0:a.hasMore,shouldAutoScroll:C,onUserScroll:m,pinToBottom:x,onPinCancel:Ce,isLoadingHistory:a==null?void 0:a.loading})})}),e.jsxs("div",{className:`guake-input-wrapper ${s.status==="working"?"has-stop-btn is-working":""}`,children:[e.jsx(ft,{agentId:s.id,isWorking:s.status==="working",timestamp:j==null?void 0:j.timestamp}),e.jsx(ut,{command:B,onCommandChange:w,useTextarea:W,forceTextarea:o,onForceTextarea:L,onSend:xe,canSend:le,attachedFiles:$,onAddFile:he,onRemoveFile:se,uploadFile:ae,onAddPastedText:ie,placeholder:E("commander.command",{name:s.name}),compact:!1,inputRef:R})]}),T&&e.jsx(qe,{url:T.url,name:T.name,onClose:be}),Y&&e.jsx(Ge,{state:Y,onClose:r}),e.jsx(Ye,{agent:s,content:q,onClose:J})]})}function ht({currentArea:s,onClose:a}){const{t:l}=fe(["terminal","common"]),[f,p]=t.useState(()=>{const u=new Set(Array.from(I.getState().agents.values()).map(D=>D.name));return Je.find(D=>!u.has(D))||`Agent-${Date.now().toString(36)}`}),[d,M]=t.useState(()=>Me(ce.LAST_CWD)),[A,R]=t.useState("scout"),[N,b]=t.useState("claude"),[E,j]=t.useState(!1),h=()=>{if(!f.trim()||!d.trim())return;j(!0),Ie(ce.LAST_CWD,d);let u;s&&(u={x:s.center.x,z:s.center.z}),I.spawnAgent(f.trim(),A,d.trim(),u,void 0,void 0,void 0,void 0,N),setTimeout(()=>{a()},500)},v=u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),h()),u.key==="Escape"&&a()};return e.jsx("div",{className:"commander-spawn-overlay",onClick:a,children:e.jsxs("div",{className:"commander-spawn-form",onClick:u=>u.stopPropagation(),children:[e.jsxs("div",{className:"commander-spawn-header",children:[e.jsx("h3",{children:l("spawn.addNewAgent")}),s&&e.jsxs("span",{className:"commander-spawn-area",children:[e.jsx("span",{className:"commander-spawn-area-dot",style:{background:s.color}}),s.name]})]}),e.jsxs("div",{className:"commander-spawn-body",children:[e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:l("common:labels.name")}),e.jsx("input",{type:"text",value:f,onChange:u=>p(u.target.value),onKeyDown:v,autoFocus:!0})]}),e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:l("common:labels.workingDirectory")}),e.jsx(Xe,{value:d,onChange:M,onSubmit:h,placeholder:l("spawn.workingDirPlaceholder"),directoriesOnly:!0})]}),e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:l("common:labels.class")}),e.jsx("div",{className:"commander-spawn-classes",children:Ze.map(u=>e.jsxs("button",{className:`commander-spawn-class ${A===u.id?"selected":""}`,onClick:()=>R(u.id),children:[e.jsx(Qe,{classId:u.id,size:18,className:"commander-spawn-class-icon"}),e.jsx("span",{children:u.name})]},u.id))})]}),e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:l("common:labels.runtime")}),e.jsxs("div",{className:"commander-spawn-classes",children:[e.jsxs("button",{className:`commander-spawn-class ${N==="claude"?"selected":""}`,onClick:()=>b("claude"),children:[e.jsx("span",{className:"commander-spawn-class-icon",children:e.jsx(z,{name:"brain",size:14})}),e.jsx("span",{children:"Claude"})]}),e.jsxs("button",{className:`commander-spawn-class ${N==="codex"?"selected":""}`,onClick:()=>b("codex"),children:[e.jsx("span",{className:"commander-spawn-class-icon",children:e.jsx(z,{name:"gear",size:14})}),e.jsx("span",{children:"Codex"})]}),e.jsxs("button",{className:`commander-spawn-class ${N==="opencode"?"selected":""}`,onClick:()=>b("opencode"),children:[e.jsx("span",{className:"commander-spawn-class-icon",children:e.jsx(z,{name:"status-pending",size:12,weight:"fill",color:"#4ade80"})}),e.jsx("span",{children:"OpenCode"})]})]})]})]}),e.jsxs("div",{className:"commander-spawn-footer",children:[e.jsx("button",{className:"commander-spawn-cancel",onClick:a,children:l("common:buttons.cancel")}),e.jsx("button",{className:"commander-spawn-submit",onClick:h,disabled:!f.trim()||!d.trim()||E,children:l(E?"common:buttons.deploying":"common:buttons.deploy")})]})]})})}const Te=t.memo(function({agent:a,history:l,isExpanded:f,isFocused:p,advancedView:d,index:M,onExpand:A,onCollapse:R,onFocus:N,onInputRef:b,onLoadMore:E,onClearHistory:j}){const h=nt(a.id),v=t.useCallback(()=>{f?R():A(a.id)},[a.id,f,A,R]),u=t.useCallback(()=>{N(p?-1:M)},[M,p,N]),D=t.useCallback(F=>{b(a.id,F)},[a.id,b]),i=t.useCallback(()=>{E(a.id)},[a.id,E]),C=t.useCallback(()=>{j(a.id)},[a.id,j]);return e.jsx(pt,{agent:a,history:l,outputs:h,isExpanded:f,isFocused:p,advancedView:d,onExpand:v,onFocus:u,inputRef:D,onLoadMore:i,onClearHistory:C})});function Ct({isOpen:s,onClose:a}){const{t:l}=fe(["terminal","common"]),f=et(),p=tt(),[d,M]=t.useState(()=>Me(ce.COMMANDER_TAB,"all")),[A,R]=t.useState(0),[N,b]=t.useState(null),E=t.useRef(null),[j,h]=t.useState(0),[v,u]=t.useState(!1),[D,i]=t.useState(null),[C,F]=t.useState(!1),[x,k]=t.useState(()=>{try{const n=Me(ce.COMMANDER_FILTERS,"");if(n)return{...Ne,...JSON.parse(n)}}catch{}return Ne}),T=t.useRef(new Map),K=t.useRef([]),Y=t.useRef(0),V=t.useRef([]),q=t.useRef(d),{histories:Z,loadMoreHistory:B,clearAgentHistory:w}=dt({isOpen:s,agents:f});t.useEffect(()=>{s||(b(null),h(0),u(!1))},[s]);const o=t.useMemo(()=>{const n=Array.from(p.values()).sort((g,m)=>g.name.localeCompare(m.name)),c=[{id:"all",name:l("common:labels.all")}];for(const g of n)c.push({id:g.id,name:g.name,color:g.color});return c.push({id:"unassigned",name:l("commander.unassigned")}),c},[p]),L=t.useMemo(()=>d==="all"||d==="unassigned"?null:p.get(d)||null,[d,p]),W=t.useMemo(()=>{const n=new Map;n.set("all",f.size);let c=0;for(const g of f.values()){const m=I.getAreaForAgent(g.id);m?n.set(m.id,(n.get(m.id)||0)+1):c++}return n.set("unassigned",c),n},[f]),U=x.status!=="all"||x.activity!=="all"||x.sort!=="activity",te=(x.status!=="all"?1:0)+(x.activity!=="all"?1:0)+(x.sort!=="activity"?1:0),O=t.useMemo(()=>{const n=m=>m.isBoss===!0||m.class==="boss",c=Date.now();let g=Array.from(f.values());if(d==="unassigned"?g=g.filter(m=>!I.getAreaForAgent(m.id)):d!=="all"&&(g=g.filter(m=>{const P=I.getAreaForAgent(m.id);return(P==null?void 0:P.id)===d})),x.status!=="all"&&(g=g.filter(m=>{switch(x.status){case"working":return m.status==="working";case"idle":return m.status==="idle";case"error":return m.status==="error"||m.status==="waiting"||m.status==="waiting_permission";case"offline":return m.status==="offline"||m.status==="orphaned";default:return!0}})),x.activity!=="all"){const m=lt[x.activity];g=g.filter(P=>c-(P.lastActivity||0)<m)}return g.sort((m,P)=>{var Q,ee;if(n(m)&&!n(P))return-1;if(!n(m)&&n(P))return 1;switch(x.sort){case"activity":return(P.lastActivity||0)-(m.lastActivity||0);case"name":return m.name.localeCompare(P.name);case"created":return(m.createdAt||0)-(P.createdAt||0);case"context":{const G=((Q=m.contextStats)==null?void 0:Q.usedPercent)??(m.contextUsed||0)/(m.contextLimit||2e5)*100;return(((ee=P.contextStats)==null?void 0:ee.usedPercent)??(P.contextUsed||0)/(P.contextLimit||2e5)*100)-G}default:return(P.lastActivity||0)-(m.lastActivity||0)}}),g},[f,d,x]),$=Math.ceil(O.length/Ae),_=t.useMemo(()=>O.slice(A*Ae,(A+1)*Ae),[O,A]);K.current=_,E.current=N,Y.current=j,V.current=o,q.current=d,Pe("commander-expanded",N!==null,()=>b(null));const se=st();t.useEffect(()=>{s&&se&&(b(se),I.clearCommanderExpandRequest())},[s,se]);const ae=t.useCallback(()=>b(null),[]),ne=t.useCallback(n=>b(n),[]),le=t.useCallback(n=>h(n),[]),pe=t.useCallback((n,c)=>{c?T.current.set(n,c):T.current.delete(n)},[]);return t.useEffect(()=>{R(0),Ie(ce.COMMANDER_TAB,d)},[d]),t.useEffect(()=>{Ie(ce.COMMANDER_FILTERS,JSON.stringify(x)),R(0)},[x]),t.useEffect(()=>{var c;if(!s||window.matchMedia("(pointer: coarse)").matches)return;const n=N||((c=K.current[j])==null?void 0:c.id);if(n){const g=T.current.get(n);g&&document.activeElement!==g&&setTimeout(()=>g.focus(),50)}},[s,j,N]),t.useEffect(()=>{if(!s)return;const n=c=>{const g=I.getShortcuts(),m=c.target,P=m.tagName==="INPUT"||m.tagName==="TEXTAREA",Q=K.current,ee=Q.length-1,G=E.current,ie=g.find(r=>r.id==="commander-close");if(X(c,ie)){const{fileViewerPath:r,contextModalAgentId:J}=I.getState();if(r||J)return;c.preventDefault(),c.stopImmediatePropagation(),G?b(null):a();return}const he=g.find(r=>r.id==="commander-vim-left");if(X(c,he)&&!G){c.preventDefault(),h(r=>r>0?r-1:r);return}const xe=g.find(r=>r.id==="commander-vim-right");if(X(c,xe)&&!G){c.preventDefault(),h(r=>r<ee?r+1:r);return}const ge=g.find(r=>r.id==="commander-vim-up");if(X(c,ge)&&!G){c.preventDefault(),h(r=>r>=me?r-me:r);return}const ve=g.find(r=>r.id==="commander-vim-down");if(X(c,ve)&&!G){c.preventDefault(),h(r=>r+me<=ee?r+me:r);return}const je=g.find(r=>r.id==="commander-expand");if(X(c,je)){if(c.preventDefault(),G)b(null);else{const r=Q[Y.current];r&&b(r.id)}return}const we=g.find(r=>r.id==="commander-new-agent");if(X(c,we)){c.preventDefault(),u(!0);return}const Ce=g.find(r=>r.id==="commander-next-tab"),be=g.find(r=>r.id==="commander-prev-tab");if(!P){const r=V.current;if(X(c,Ce)){const J=I.getState().latestNotificationAgentId;if(J){if(c.preventDefault(),c.stopPropagation(),!I.getState().agents.get(J)){I.setLatestNotificationAgentId(null);return}const y=I.getAreaForAgent(J);y&&r.some(H=>H.id===y.id)?M(y.id):M("unassigned"),b(J),h(0),R(0),I.setLatestNotificationAgentId(null);return}c.preventDefault(),c.stopPropagation();const oe=(r.findIndex(re=>re.id===q.current)+1)%r.length;M(r[oe].id),h(0);return}if(X(c,be)){c.preventDefault(),c.stopPropagation();const de=(r.findIndex(oe=>oe.id===q.current)-1+r.length)%r.length;M(r[de].id),h(0);return}}};return document.addEventListener("keydown",n,!0),()=>document.removeEventListener("keydown",n,!0)},[s,a]),s?e.jsx("div",{className:"commander-overlay",onClick:a,children:e.jsxs("div",{className:"commander-view",onClick:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"commander-header",children:[e.jsxs("div",{className:"commander-title-section",children:[e.jsx("h2",{className:"commander-title",children:l("commander.title")}),e.jsx("span",{className:"commander-shortcuts",children:l("commander.shortcuts")})]}),e.jsxs("div",{className:"commander-controls",children:[e.jsx("button",{className:`commander-view-toggle ${C?"active":""}`,onClick:()=>F(!C),title:l(C?"commander.simple":"commander.advanced"),children:C?e.jsxs(e.Fragment,{children:[e.jsx(z,{name:"target",size:12})," ",l("commander.advanced")]}):e.jsxs(e.Fragment,{children:[e.jsx(z,{name:"status-pending",size:12})," ",l("commander.simple")]})}),e.jsx("button",{className:"commander-add-btn",onClick:()=>u(!0),title:l("commander.addAgent"),children:l("commander.addAgent")}),e.jsx("button",{className:"commander-close",onClick:a,children:l("commander.close")})]})]}),e.jsx("div",{className:"commander-tabs",children:o.map(n=>{const c=n.id!=="all"&&n.id!=="unassigned"?p.get(n.id):null,g=c&&c.directories&&c.directories.length>0;return e.jsxs("button",{className:`commander-tab ${d===n.id?"active":""}`,onClick:()=>{M(n.id),h(0)},style:n.color?{borderBottomColor:d===n.id?n.color:"transparent"}:void 0,children:[n.color&&e.jsx("span",{className:"commander-tab-dot",style:{background:n.color}}),e.jsx("span",{children:n.name}),e.jsx("span",{className:"commander-tab-count",children:W.get(n.id)||0}),g&&e.jsx("span",{className:"commander-tab-folder",onClick:m=>{m.stopPropagation(),i(n.id)},title:l("commander.openFileExplorer"),children:e.jsx(z,{name:"folder",size:12})})]},n.id)})}),e.jsxs("div",{className:"commander-filters",children:[e.jsxs("div",{className:"commander-filter-group",children:[e.jsx("span",{className:"commander-filter-label",children:l("commander.filters.status")}),["all","working","idle","error","offline"].map(n=>e.jsx("button",{className:`commander-filter-btn ${x.status===n?"active":""}`,onClick:()=>k(c=>({...c,status:n})),children:n==="all"?l("commander.filters.all"):n==="error"?l("commander.filters.needsAttn"):n.charAt(0).toUpperCase()+n.slice(1)},n))]}),e.jsxs("div",{className:"commander-filter-group",children:[e.jsx("span",{className:"commander-filter-label",children:l("commander.filters.active")}),["all","1h","6h","24h"].map(n=>e.jsx("button",{className:`commander-filter-btn ${x.activity===n?"active":""}`,onClick:()=>k(c=>({...c,activity:n})),children:n==="all"?l("commander.filters.any"):`< ${n}`},n))]}),e.jsxs("div",{className:"commander-filter-group",children:[e.jsx("span",{className:"commander-filter-label",children:l("commander.filters.sort")}),["activity","name","created","context"].map(n=>e.jsx("button",{className:`commander-filter-btn ${x.sort===n?"active":""}`,onClick:()=>k(c=>({...c,sort:n})),children:n==="activity"?l("commander.filters.recent"):n==="context"?l("commander.filters.context"):n.charAt(0).toUpperCase()+n.slice(1)},n))]}),U&&e.jsx("button",{className:"commander-filter-clear",onClick:()=>k(Ne),title:l("commander.clearFilters"),children:l("commander.filters.clearFilters",{count:te})})]}),$>1&&e.jsxs("div",{className:"commander-pagination",children:[e.jsxs("button",{className:"commander-page-btn",onClick:()=>R(n=>Math.max(0,n-1)),disabled:A===0,children:[e.jsx(z,{name:"caret-left",size:12})," ",l("commander.prev")]}),e.jsx("span",{className:"commander-page-info",children:l("commander.page",{current:A+1,total:$,count:O.length})}),e.jsxs("button",{className:"commander-page-btn",onClick:()=>R(n=>Math.min($-1,n+1)),disabled:A===$-1,children:[l("commander.next")," ",e.jsx(z,{name:"caret-right",size:12})]})]}),e.jsx("div",{className:`commander-grid ${N?"has-expanded":""}`,"data-agent-count":N?1:_.length,children:_.length===0?e.jsx("div",{className:"commander-empty",children:l(d==="all"?"commander.noAgentsAll":d==="unassigned"?"commander.noAgentsUnassigned":"commander.noAgentsArea")}):N?(()=>{const n=f.get(N);return n?e.jsx(Te,{agent:n,history:Z.get(n.id),isExpanded:!0,isFocused:!0,advancedView:C,index:0,onExpand:ne,onCollapse:ae,onFocus:le,onInputRef:pe,onLoadMore:B,onClearHistory:w},n.id):null})():_.map((n,c)=>e.jsx(Te,{agent:n,history:Z.get(n.id),isExpanded:!1,isFocused:c===j,advancedView:C,index:c,onExpand:ne,onCollapse:ae,onFocus:le,onInputRef:pe,onLoadMore:B,onClearHistory:w},n.id))}),v&&e.jsx(ht,{currentArea:L,onClose:()=>u(!1)}),D&&e.jsx(at,{isOpen:!0,areaId:D,onClose:()=>i(null),onChangeArea:n=>i(n)})]})}):null}export{Ct as CommanderView};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as a,H as wn,J as qt,K as ln,L as rn,j as e,M as on,N as vn,u as Ut,O as Cn,P as jn,U as Nn,V as yn,W as kn,X as An,Y as Sn,Z as En,_ as Yt,S as E,$ as Kt,a0 as Ht,a1 as Zt,a2 as Nt,a3 as Ae,a4 as Mn,s as f,a5 as cn,m as dn,a6 as In,z as Jt,B as Qt,I as p,a7 as Tn,q as Pn,a8 as Ln,a9 as un,aa as pn,ab as Rn,ac as $n,ad as Dn,ae as zn,af as On,ag as Bn,ah as Fn,ai as Wn,aj as Hn,ak as Un,al as Vn,am as Xn,an as en,C as Gn,ao as qn,ap as tn,aq as Yn,ar as Kn,as as Zn,at as Jn,au as Qn,av as ea,aw as ta,ax as na,ay as aa,az as sa,aA as ia,aB as la,aC as ra,aD as oa,aE as Ke,aF as ca,aG as da,aH as ua,aI as pa,aJ as rt,aK as ma,aL as fa,aM as ha,aN as ga,aO as xa,aP as ba,aQ as _a}from"./main-C2zgPci-.js";import{g as wa}from"./area-logos-CThPeqIM.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function va(u){const o=a.useRef(u);o.current=u,a.useEffect(()=>{if(!wn())return;let m=null,h=!1;return qt.addListener("backButton",()=>{o.current()==="exit"&&qt.exitApp()}).then(y=>{h?y.remove():m=y}),()=>{h=!0,m&&(m.remove(),m=null)}},[])}async function Ca(u){const o=ln(),m=await fetch(`${rn()}/api/agents/${u}/terminal`,{method:"POST",headers:{Authorization:`Bearer ${o}`}});if(!m.ok){const h=await m.json().catch(()=>({}));throw new Error((h==null?void 0:h.error)||`Failed to start terminal (${m.status})`)}return m.json()}async function ja(u){const o=ln();await fetch(`${rn()}/api/agents/${u}/terminal`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}})}const ot=new Map;function Na({agentId:u}){const[o,m]=a.useState(null),[h,y]=a.useState(null);return a.useEffect(()=>{let $=!1;const T=ot.get(u);return T&&(clearTimeout(T),ot.delete(u)),m(null),y(null),Ca(u).then(B=>{$||m(B.url)}).catch(B=>{$||y(B instanceof Error?B.message:"Failed to start terminal")}),()=>{$=!0;const B=ot.get(u);B&&clearTimeout(B),ot.set(u,setTimeout(()=>{ot.delete(u),ja(u)},2500))}},[u]),h?e.jsx("div",{className:"flat-classic-terminal flat-classic-terminal--message",children:e.jsx("span",{children:h})}):o?e.jsx("div",{className:"flat-classic-terminal",children:e.jsx(on,{terminalUrl:o,visible:!0})}):e.jsx("div",{className:"flat-classic-terminal flat-classic-terminal--message",children:e.jsx("span",{children:"Attaching to interactive session…"})})}const Bt=new Map,ya=6e4;function ka({agentId:u,contextSummary:o}){const{t:m}=Ut(["terminal","common"]),[h,y]=a.useState(()=>{var D;return((D=Bt.get(u))==null?void 0:D.snapshot)??null}),[$,T]=a.useState(!1),[B,te]=a.useState(null),w=a.useRef(0);a.useEffect(()=>{const D=Bt.get(u);if(D&&Date.now()-D.fetchedAt<ya){y(D.snapshot);return}const X=++w.current;T(!0),te(null),Cn(u).then(J=>{X===w.current&&(Bt.set(u,{snapshot:J,fetchedAt:Date.now()}),y(J),T(!1))}).catch(J=>{X===w.current&&(te(J.message||"Failed to load plan limits"),T(!1))})},[u]);const F=[];if(h!=null&&h.rateLimits){const D=[{key:"fiveHour",label:m("terminal:usage.currentSession"),window:h.rateLimits.fiveHour},{key:"sevenDay",label:m("terminal:usage.currentWeekAll"),window:h.rateLimits.sevenDay},{key:"sevenDayOpus",label:m("terminal:usage.currentWeekOpus"),window:h.rateLimits.sevenDayOpus},{key:"sevenDaySonnet",label:m("terminal:usage.currentWeekSonnet"),window:h.rateLimits.sevenDaySonnet}];for(const X of D)X.window&&F.push({...X,window:X.window})}return e.jsxs("div",{className:"plan-limits-tooltip",children:[o&&e.jsx("div",{className:"plan-limits-tooltip__context",children:o}),e.jsx("div",{className:"plan-limits-tooltip__title",children:m("terminal:usage.limits")}),$&&!h&&e.jsxs("div",{className:"plan-limits-tooltip__muted",children:[m("common:status.loading"),"…"]}),!$&&B&&!h&&e.jsx("div",{className:"plan-limits-tooltip__muted",children:m("terminal:usage.limitsError",{message:B})}),F.length>0?e.jsx("div",{className:"plan-limits-tooltip__gauges",children:F.map(({key:D,label:X,window:J})=>{const Q=Math.max(0,Math.min(100,J.utilization)),oe=Nn(Q);return e.jsxs("div",{className:"plan-limits-tooltip__gauge",children:[e.jsxs("div",{className:"plan-limits-tooltip__gauge-head",children:[e.jsx("span",{className:"plan-limits-tooltip__gauge-label",children:X}),e.jsx("span",{className:"plan-limits-tooltip__gauge-percent",style:{color:oe},children:m("terminal:usage.percentUsed",{percent:Math.round(Q)})})]}),e.jsx("div",{className:"plan-limits-tooltip__bar",children:e.jsx("div",{className:"plan-limits-tooltip__bar-fill",style:{width:`${Q}%`,background:oe}})}),e.jsx("div",{className:"plan-limits-tooltip__reset",children:m("terminal:usage.resets",{time:jn(J.resetsAt)})})]},D)})}):h&&!$&&e.jsx("div",{className:"plan-limits-tooltip__muted",children:h.rateLimitsError?m("terminal:usage.limitsError",{message:h.rateLimitsError}):h.cliHint})]})}function Aa({agentId:u,disabled:o,contextSummary:m,children:h}){return e.jsx(vn,{position:"top",maxWidth:320,disabled:o,className:"plan-limits-tooltip-wrapper",triggerStyle:{display:"inline-flex",alignItems:"center"},content:e.jsx(ka,{agentId:u,contextSummary:m}),children:h})}const Sa=a.memo(function({className:o=""}){const{t:m}=Ut(["common"]),[h,y]=yn(),$=a.useRef(null),[T,B]=a.useState(null);a.useLayoutEffect(()=>{const w=$.current;if(!w)return;const F=w.querySelector(".view-mode-toggle__btn--active");F&&B({left:F.offsetLeft,width:F.offsetWidth})},[h]);const te=a.useCallback(w=>{if(w!==h){if(typeof window<"u"&&window.dispatchEvent(new CustomEvent("tide:viewmode-switch-pressed",{detail:{mode:w}})),w==="3d"){requestAnimationFrame(()=>y(w));return}y(w)}},[h,y]);return e.jsxs("div",{className:`view-mode-toggle ${o}`,ref:$,children:[T&&e.jsx("div",{className:"view-mode-toggle__indicator",style:{left:T.left,width:T.width}}),kn.map(w=>e.jsxs("button",{className:`view-mode-toggle__btn ${h===w?"view-mode-toggle__btn--active":""}`,onClick:()=>te(w),title:m(`common:viewMode.descriptions.${w}`),children:[e.jsxs("span",{className:"view-mode-toggle__icon",children:[w==="2d"&&e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),e.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"21"})]}),w==="3d"&&e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),e.jsx("path",{d:"M2 17l10 5 10-5"}),e.jsx("path",{d:"M2 12l10 5 10-5"})]}),w==="flat"&&e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1"})]}),w==="dashboard"&&e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"9",rx:"1"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"5",rx:"1"}),e.jsx("rect",{x:"14",y:"12",width:"7",height:"9",rx:"1"}),e.jsx("rect",{x:"3",y:"16",width:"7",height:"5",rx:"1"})]})]}),e.jsx("span",{className:"view-mode-toggle__label",children:m(`common:viewMode.labels.${w}`)})]},w))]})}),yt=3,kt=280,nn=320,Ft=240,an=64,Ea=["simple","chat","advanced"],Ma={simple:"Simple",chat:"Chat",advanced:"Advanced"},Ia={simple:"○",chat:"◐",advanced:"◉"},Ta={simple:"Simple view — clean messages only",chat:"Chat view — assistant replies (no tool calls)",advanced:"Advanced view — everything including tools"},sn="flat-clear-context",mn="tide:flat-embedded-panels";function fn(){try{const u=localStorage.getItem(mn),o=u?JSON.parse(u):{};return o&&typeof o=="object"?o:{}}catch{return{}}}function Wt(u,o){try{const m=fn();o?m[u]=o:delete m[u],localStorage.setItem(mn,JSON.stringify(m))}catch{}}function Pa(u){const o=u.split("/").filter(Boolean);return o.length===0?u:o.slice(-2).join("/")}function La(u){if(u.provider==="codex"){const $=u.codexModel||"gpt-5.6-luna",T=xa[$];return{model:(T==null?void 0:T.label)||$}}if(u.provider==="opencode")return{model:u.opencodeModel||"opencode"};const o=u.model||"sonnet",m=_a[o],h=u.effort,y=h?ba[h]:void 0;return{model:(m==null?void 0:m.label)||o,effort:y==null?void 0:y.label}}function Ra(u,o){if(o.type==="rectangle"&&o.width&&o.height){const m=o.width/2,h=o.height/2;return u.x>=o.center.x-m&&u.x<=o.center.x+m&&u.z>=o.center.z-h&&u.z<=o.center.z+h}if(o.type==="circle"&&o.radius){const m=u.x-o.center.x,h=u.z-o.center.z;return m*m+h*h<=o.radius*o.radius}return!1}const $a=qn.memo(function({agentId:o,terminalViewMode:m,onTerminalViewModeChange:h,inspectorOpen:y,onToggleInspector:$,onImageClick:T,onFileClick:B,onBashClick:te,onViewMarkdown:w,onRequestClearSubordinates:F,keyboard:D,canNavigateBack:X,canNavigateForward:J,onNavigateBack:Q,onNavigateForward:oe,agentInfoOpen:Fe,onToggleAgentInfo:Ze,onHeaderContextMenu:ct,onBuildingContextMenu:K}){var it,bt;const b=tn(o),I=dn(),Je=Yn(),ne=a.useRef(null),We=a.useRef(null),{displayedAgentId:Re,fadingOut:Qe}=Kn(o),dt=tn(Re),He=!!Je.interactiveMode&&((b==null?void 0:b.provider)??"claude")==="claude"&&!!(b!=null&&b.sessionId),[fe,$e]=a.useState(!1);a.useEffect(()=>{$e(!1)},[o]),a.useEffect(()=>{!He&&fe&&$e(!1)},[He,fe]),a.useEffect(()=>{const n=We.current;if(!n)return;const r=d=>{d.button===3?(d.preventDefault(),d.stopPropagation(),Q()):d.button===4&&(d.preventDefault(),d.stopPropagation(),oe())},i=d=>{(d.button===3||d.button===4)&&d.preventDefault()};return n.addEventListener("mouseup",r),n.addEventListener("mousedown",i),()=>{n.removeEventListener("mouseup",r),n.removeEventListener("mousedown",i)}},[Q,oe]),a.useEffect(()=>{const n=We.current;if(!n)return;let r=0,i=0,d=0;const O=250,re=600,P=80,Le=1.5,Ye=L=>{let U=L instanceof HTMLElement?L:null;for(;U&&U!==n;){const wt=window.getComputedStyle(U).overflowX;if((wt==="auto"||wt==="scroll")&&U.scrollWidth>U.clientWidth)return!0;U=U.parentElement}return!1},_t=L=>{const U=Date.now();if(U<d){L.preventDefault();return}if(Math.abs(L.deltaX)<=Math.abs(L.deltaY)*Le){r=0;return}if(Ye(L.target)){r=0;return}U-i>O&&(r=0),i=U,r+=L.deltaX,r<=-P?(r=0,d=U+re,L.preventDefault(),Q()):r>=P&&(r=0,d=U+re,L.preventDefault(),oe())};return n.addEventListener("wheel",_t,{passive:!1}),()=>n.removeEventListener("wheel",_t)},[Q,oe]);const et=cn(),Se=a.useMemo(()=>{if(!b)return null;const n=new Set,r=[];for(const i of et.values())i.archived||i.directories.length===0||i.assignedAgentIds.includes(o)&&(n.add(i.id),r.push(i));for(const i of et.values())i.archived||i.directories.length===0||n.has(i.id)||Ra({x:b.position.x,z:b.position.z},i)&&(n.add(i.id),r.push(i));return r.length===0?null:r.flatMap(i=>i.directories.filter(d=>d&&d.trim().length>0).map(d=>({areaId:i.id,areaName:i.name,dir:d})))},[b,o,et]),{branches:Ee,fetchRemote:he,fetchingDirs:ge}=Zn(Se),Ue=a.useMemo(()=>{var i;const n=f.getAreaForAgent(o);if(!n)return[];const r=[];for(const d of I.values())d.type==="terminal"&&f.isPositionInArea(d.position,n)&&r.push({id:d.id,name:d.name,hasUrl:!!((i=d.terminalStatus)!=null&&i.url)});return r},[o,I]),Ve=a.useMemo(()=>{var i;const n=f.getAreaForAgent(o);if(!n)return[];const r=[];for(const d of I.values())d.type==="server"&&((i=d.pm2)!=null&&i.enabled)&&f.isPositionInArea(d.position,n)&&r.push({id:d.id,name:d.name});return r},[o,I]),xe=a.useMemo(()=>{const n=f.getAreaForAgent(o);if(!n)return[];const r=[];for(const i of I.values())i.type==="database"&&i.database&&f.isPositionInArea(i.position,n)&&r.push({id:i.id,name:i.name});return r},[o,I]),Me=Jn(),ce=a.useMemo(()=>{const n=f.getAreaForAgent(o);if(!n)return[];const r=[];for(const i of I.values())if(i.type==="tests"&&f.isPositionInArea(i.position,n)){const d=!!i.folderPath&&Me.some(O=>Qn(O,i.folderPath));r.push({id:i.id,name:i.name,working:d})}return r},[o,I,Me]),be=a.useMemo(()=>{const n=f.getAreaForAgent(o);if(!n)return[];const r=[];for(const i of I.values())i.type==="http"&&f.isPositionInArea(i.position,n)&&r.push({id:i.id,name:i.name});return r},[o,I]),[,de]=a.useReducer(n=>n+1,0),_e=((it=ne.current)==null?void 0:it.search.searchMode)??!1,Ie=a.useCallback(()=>{var n;(n=ne.current)==null||n.search.toggleSearch(),de()},[]),we=ea(),tt=we.isPending(sn),[C,ve]=a.useState(null),W=C?I.get(C.buildingId):null,[ut,Te]=a.useState(""),[Ce,At]=a.useState(()=>ta()),z=a.useMemo(()=>{var n;return((n=f.getAreaForAgent(o))==null?void 0:n.id)??null},[o,I]),De=a.useCallback((n,r)=>{Te(""),ve(i=>{const d=(i==null?void 0:i.buildingId)===r?null:{type:n,buildingId:r};return z&&Wt(z,d),d})},[z]),ae=a.useCallback(()=>{Te(""),ve(null),z&&Wt(z,null)},[z]);a.useEffect(()=>{if((C==null?void 0:C.type)!=="pm2-logs")return;const n=C.buildingId;return f.startLogStreaming(n,200),()=>f.stopLogStreaming(n)},[C]);const{height:St,onResizeStart:Et}=na(),{sidePanelWidth:Mt,handleSidePanelResizeStart:It}=aa(),[ze,pt]=a.useState(()=>Ht(E.GIT_PANEL_OPEN,!1)),[je,_]=a.useState(()=>Ht(E.BUILDINGS_PANEL_OPEN,!1)),[Oe,mt]=a.useState(!1),Ne=a.useCallback(()=>{mt(n=>{const r=!n;return r&&sa.setEnabled(!0),r})},[]),se=a.useCallback(()=>mt(!1),[]),Xe=a.useCallback(()=>{pt(n=>{const r=!n;return Ae(E.GIT_PANEL_OPEN,r),r})},[]),ft=a.useCallback(()=>{_(n=>{const r=!n;return Ae(E.BUILDINGS_PANEL_OPEN,r),r})},[]),Tt=a.useCallback(()=>{pt(!1),Ae(E.GIT_PANEL_OPEN,!1)},[]),Pt=a.useCallback(()=>{_(!1),Ae(E.BUILDINGS_PANEL_OPEN,!1)},[]),Lt=ia(),Pe=a.useMemo(()=>({terminal:Ue,"pm2-logs":Ve,database:xe,tests:ce,http:be}),[Ue,Ve,xe,ce,be]);a.useEffect(()=>{if(!C)return;Pe[C.type].some(r=>r.id===C.buildingId)||(Te(""),ve(null))},[C,Pe]);const Ge=a.useRef(void 0);a.useEffect(()=>{var r;if(Ge.current===z)return;Ge.current=z;const n=z?fn()[z]:void 0;Te(""),n&&((r=Pe[n.type])!=null&&r.some(i=>i.id===n.buildingId))?ve(n):ve(null)},[z,Pe]),a.useEffect(()=>{const n=r=>{var O;const i=r.detail;if(!(i!=null&&i.buildingId)||!(i!=null&&i.type)||!((O=Pe[i.type])!=null&&O.some(re=>re.id===i.buildingId)))return;i.handled=!0,Te("");const d={type:i.type,buildingId:i.buildingId};ve(d),z&&Wt(z,d)};return window.addEventListener("tide:dock-building-flat",n),()=>window.removeEventListener("tide:dock-building-flat",n)},[Pe,z]);const[ie,ue]=a.useState(!1),pe=a.useRef(null);if(a.useEffect(()=>{if(!ie)return;const n=r=>{pe.current&&!pe.current.contains(r.target)&&ue(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[ie]),!b)return e.jsx("div",{className:"flat-chat flat-chat--empty",children:e.jsxs("div",{className:"flat-chat__placeholder",children:[e.jsx("span",{className:"flat-chat__placeholder-icon",children:"💬"}),e.jsx("span",{className:"flat-chat__placeholder-text",children:"Select an agent to start chatting"})]})});const ye=b.contextStats,Z=!!ye,ke=ye?ye.totalTokens:b.contextUsed||0,ht=ye?ye.contextWindow:b.contextLimit||2e5,Rt=ye?ye.usedPercent:Math.round(ke/ht*100),me=Math.max(0,Math.min(100,Rt)),nt=Math.round(me*10)/10,$t=Math.round((100-me)*10)/10,gt=me>=80?"#ff4a4a":me>=60?"#ff9e4a":me>=40?"#ffd700":"#4aff9e",at=(ke/1e3).toFixed(1),ee=(ht/1e3).toFixed(1),le=b.cwd,st=le?Pa(le):null,qe=((bt=b.subordinateIds)==null?void 0:bt.length)||0,xt=qe>0;return e.jsxs("div",{ref:We,className:`flat-terminal-wrapper ${ze||je||Oe?"flat-terminal-wrapper--with-side-panel":""} ${Qe?"pane-fading-out":""}`,style:{"--guake-side-panel-width":`min(${Mt}px, 70%)`},children:[e.jsxs("div",{className:"flat-terminal-wrapper__header",children:[e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__header-main ${Fe?"flat-terminal-wrapper__header-main--active":""}`,onClick:Ze,onContextMenu:n=>{n.preventDefault(),n.stopPropagation(),ct({x:n.clientX,y:n.clientY})},title:Fe?"Hide agent info":"Show agent info","aria-pressed":Fe,children:[e.jsx(un,{agent:b,size:28}),e.jsxs("span",{className:"flat-terminal-wrapper__header-info",children:[e.jsx("span",{className:"flat-terminal-wrapper__header-name",children:b.name}),e.jsx("span",{className:"flat-terminal-wrapper__header-status",style:{color:pn(b.status)},children:b.status})]}),b.taskLabel&&e.jsxs("span",{className:"flat-terminal-wrapper__header-task",title:b.taskLabel,children:["📋 ",b.taskLabel]}),e.jsxs("span",{className:"flat-terminal-wrapper__header-model",children:[e.jsx("img",{src:b.provider==="codex"?"/assets/codex.png":b.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:b.provider,className:"flat-terminal-wrapper__header-provider-icon",title:b.provider==="codex"?"Codex Agent":b.provider==="opencode"?"OpenCode Agent":"Claude Agent"}),(()=>{const{model:n,effort:r}=La(b);return e.jsxs("span",{className:"flat-terminal-wrapper__header-model-chip",title:r?`Model: ${n} · Effort: ${r}`:`Model: ${n}`,children:[e.jsx("span",{className:"flat-terminal-wrapper__header-model-name",children:n}),r&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flat-terminal-wrapper__header-model-sep","aria-hidden":"true",children:"·"}),e.jsx("span",{className:"flat-terminal-wrapper__header-model-effort",children:r})]})]})})()]})]}),e.jsxs("div",{className:"flat-terminal-wrapper__header-meta",children:[e.jsxs("div",{className:"flat-terminal-wrapper__view-mode",role:"group","aria-label":"Message view mode",children:[Ea.map(n=>e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__view-mode-btn ${!fe&&m===n?"flat-terminal-wrapper__view-mode-btn--active":""}`,onClick:()=>{$e(!1),h(n)},title:Ta[n],"aria-pressed":!fe&&m===n,children:[e.jsx("span",{className:"flat-terminal-wrapper__view-mode-icon","aria-hidden":"true",children:Ia[n]}),e.jsx("span",{className:"flat-terminal-wrapper__view-mode-label",children:Ma[n]})]},n)),He&&e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__view-mode-btn ${fe?"flat-terminal-wrapper__view-mode-btn--active":""}`,onClick:()=>$e(n=>!n),title:"Classic TUI — attach to the live interactive claude session in a terminal","aria-pressed":fe,children:[e.jsx("span",{className:"flat-terminal-wrapper__view-mode-icon","aria-hidden":"true",children:e.jsx(p,{name:"terminal",size:13})}),e.jsx("span",{className:"flat-terminal-wrapper__view-mode-label",children:"Classic TUI"})]})]}),e.jsxs("div",{className:"flat-terminal-wrapper__actions",role:"group","aria-label":"Terminal actions",children:[e.jsx("button",{type:"button",className:"flat-terminal-wrapper__action-btn",onClick:Q,disabled:!X,title:"Back to previous agent","aria-label":"Back to previous agent",children:e.jsx(p,{name:"arrow-left",size:14})}),e.jsx("button",{type:"button",className:"flat-terminal-wrapper__action-btn",onClick:oe,disabled:!J,title:"Forward to next agent","aria-label":"Forward to next agent",children:e.jsx(p,{name:"arrow-right",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${_e?"flat-terminal-wrapper__action-btn--active":""}`,onClick:Ie,title:_e?"Close search":"Search messages","aria-pressed":_e,children:e.jsx(p,{name:_e?"cross":"search",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn flat-terminal-wrapper__action-btn--danger ${tt?"flat-terminal-wrapper__action-btn--confirm":""}`,onClick:()=>we.handleClick(sn,()=>{var n;f.clearContext(o),(n=ne.current)==null||n.historyLoader.clearHistory()}),title:tt?"Click again to confirm clear context":"Clear context",children:e.jsx(p,{name:tt?"question":"clear",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${ze?"flat-terminal-wrapper__action-btn--active":""}`,onClick:Xe,title:ze?"Hide git panel":"Show git changes","aria-pressed":ze,children:e.jsx(p,{name:"git-branch",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${je?"flat-terminal-wrapper__action-btn--active":""}`,onClick:ft,title:je?"Hide buildings panel":"Show area buildings","aria-pressed":je,children:e.jsx(p,{name:"buildings",size:14})}),e.jsxs("div",{className:"flat-terminal-wrapper__more",ref:pe,children:[e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${ie?"flat-terminal-wrapper__action-btn--active":""}`,onClick:()=>ue(n=>!n),title:"More actions","aria-expanded":ie,children:"⋮"}),ie&&e.jsxs("div",{className:"flat-terminal-wrapper__more-menu",role:"menu",children:[e.jsxs("button",{type:"button",role:"menuitem",className:`flat-terminal-wrapper__more-item ${Oe?"flat-terminal-wrapper__more-item--active":""}`,onClick:()=>{Ne(),ue(!1)},title:Oe?"Hide Debug Panel":"Show Debug Panel",children:[e.jsx(p,{name:"bug",size:14}),e.jsx("span",{children:Oe?"Hide Debug Panel":"Show Debug Panel"})]}),e.jsx("div",{className:"flat-terminal-wrapper__more-divider"}),e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item",onClick:()=>{f.collapseContext(o),ue(!1)},disabled:b.status!=="idle",title:b.status!=="idle"?"Agent must be idle to collapse context":"Collapse context",children:[e.jsx(p,{name:"package",size:14}),e.jsx("span",{children:"Collapse context"})]}),xt&&e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item flat-terminal-wrapper__more-item--danger",onClick:()=>{F(o,qe),ue(!1)},children:[e.jsx(p,{name:"crown",size:14}),e.jsxs("span",{children:["Clear ",qe," subordinate",qe===1?"":"s"]})]}),e.jsx("div",{className:"flat-terminal-wrapper__more-divider"}),e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item flat-terminal-wrapper__more-item--danger",onClick:()=>{f.killAgent(o),ue(!1)},children:[e.jsx(p,{name:"cross",size:14}),e.jsx("span",{children:"Remove agent"})]})]})]})]}),e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__inspector-toggle ${y?"flat-terminal-wrapper__inspector-toggle--active":""}`,onClick:$,title:y?"Hide inspector panel":"Show inspector panel","aria-label":y?"Hide inspector panel":"Show inspector panel","aria-pressed":y,children:[e.jsx("span",{className:"flat-terminal-wrapper__inspector-icon","aria-hidden":"true",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"}),e.jsx("line",{x1:"10",y1:"2.5",x2:"10",y2:"13.5"})]})}),e.jsx("span",{className:"flat-terminal-wrapper__inspector-label",children:"Inspector"})]}),e.jsx("button",{type:"button",className:"flat-terminal-wrapper__close",onClick:()=>f.deselectAll(),title:"Close chat","aria-label":"Close chat",children:e.jsx(p,{name:"cross",size:14})})]})]}),fe&&He?e.jsx(Na,{agentId:o}):Re&&dt?e.jsx(la,{ref:ne,agentId:Re,agent:dt,viewMode:m,isOpen:!0,onImageClick:T,onFileClick:B,onBashClick:te,onViewMarkdown:w,keyboard:D,hasModalOpen:!1},Re):null,C&&W&&(()=>{var O,re;const n=C.type,r={terminal:"terminal","pm2-logs":"scroll",database:"hard-drives",tests:"flask",http:"globe"},i=n==="terminal"&&!((O=W.terminalStatus)!=null&&O.url),d=!i;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"guake-bottom-terminal-resize",onMouseDown:Et,role:"separator","aria-orientation":"horizontal","aria-label":"Resize embedded panel"}),e.jsxs("div",{className:"flat-bottom-panel",role:"region","aria-label":`${W.name} panel`,style:{height:St},children:[e.jsxs("div",{className:"flat-bottom-panel__header",children:[e.jsxs("span",{className:"flat-bottom-panel__title",children:[e.jsx(p,{name:r[n],size:12}),e.jsx("span",{children:W.name}),i&&e.jsx("span",{className:"flat-bottom-panel__muted",children:"(starting...)"})]}),e.jsxs("span",{className:"flat-bottom-panel__header-actions",children:[n==="pm2-logs"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",className:"guake-bottom-terminal-filter",value:ut,onChange:P=>Te(P.target.value),placeholder:"Filter logs","aria-label":`Filter logs for ${W.name}`,spellCheck:!1}),e.jsx("select",{className:"guake-bottom-terminal-retention",value:Ce===null?"unlimited":String(Ce),onChange:P=>{const Le=P.target.value==="unlimited"?null:Number(P.target.value);At(Le),oa(Le)},"aria-label":`Max log retention for ${W.name}`,children:ra.map(P=>e.jsx("option",{value:P===null?"unlimited":String(P),children:P===null?"Unlimited":`${P.toLocaleString()} lines`},P===null?"unlimited":P))}),e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:()=>f.clearStreamingLogs(C.buildingId),title:"Clear logs",children:e.jsx(p,{name:"trash",size:12})}),e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:()=>f.sendBuildingCommand(C.buildingId,"restart"),title:"Restart",children:e.jsx(p,{name:"restart",size:12})})]}),d&&e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:()=>{ae(),Ke(C.buildingId)},title:"Maximize — open as modal","aria-label":"Open as modal",children:e.jsx(p,{name:"fullscreen",size:12})}),e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:ae,title:"Close panel","aria-label":"Close panel",children:e.jsx(p,{name:"cross",size:12})})]})]}),e.jsx("div",{className:"flat-bottom-panel__body",children:n==="terminal"?(re=W.terminalStatus)!=null&&re.url?e.jsx(on,{terminalUrl:W.terminalStatus.url,visible:!0}):e.jsx("div",{className:"flat-bottom-panel__placeholder",children:"Starting terminal..."}):n==="pm2-logs"?e.jsx(ca,{buildingId:C.buildingId,filterText:ut,maxRetention:Ce}):n==="database"?e.jsx(da,{building:W}):n==="tests"?e.jsx("div",{className:"tests-panel-host",children:e.jsx(ua,{building:W,autoFocusSearch:!1})}):e.jsx("div",{className:"http-requests-panel-host",children:e.jsx(pa,{building:W,autoFocusSearch:!1})})})]})]})})(),e.jsxs("div",{className:"flat-terminal-wrapper__statusbar",role:"contentinfo",children:[b.isDetached&&e.jsxs("span",{className:"flat-terminal-wrapper__detached",title:"Reattaching session...",children:[e.jsx(p,{name:"refresh",size:12}),e.jsx("span",{children:"Reattaching"})]}),le&&st&&e.jsxs("span",{className:"flat-terminal-wrapper__cwd",title:`Open in file explorer: ${le}`,"aria-label":`Open ${le} in file explorer`,role:"button",tabIndex:0,onClick:()=>f.openFileExplorer(le),onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),f.openFileExplorer(le))},children:[e.jsx("span",{className:"flat-terminal-wrapper__cwd-icon",children:e.jsx(p,{name:"folder",size:12})}),e.jsx("span",{className:"flat-terminal-wrapper__cwd-text",children:st})]}),Se&&Se.map(({areaId:n,areaName:r,dir:i})=>{const d=Ee.get(i),O=ge.has(i),re=i.split("/").filter(Boolean).pop()||i;return e.jsxs("span",{className:"flat-terminal-wrapper__area-dir",title:`${r}: ${i}${d?` (${d.branch}${d.ahead?` ↑${d.ahead}`:""}${d.behind?` ↓${d.behind}`:""})`:""}`,onClick:()=>f.openFileExplorerForAreaFolder(n,i),children:[e.jsx(p,{name:"folder-open",size:12}),e.jsx("span",{className:"flat-terminal-wrapper__area-dir-name",children:re}),d&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flat-terminal-wrapper__area-dir-branch",children:[e.jsx(p,{name:"git-branch",size:10})," ",d.branch]}),d.ahead>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-ahead",title:`${d.ahead} ahead`,children:[e.jsx(p,{name:"arrow-up",size:9}),d.ahead]}),d.behind>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-behind",title:`${d.behind} behind`,children:[e.jsx(p,{name:"arrow-down",size:9}),d.behind]}),e.jsx("span",{className:`flat-terminal-wrapper__area-fetch ${O?"flat-terminal-wrapper__area-fetch--fetching":""}`,title:"Git fetch",onClick:P=>{P.stopPropagation(),he(i)},children:e.jsx(p,{name:O?"hourglass":"download",size:12})})]})]},`${n}:${i}`)}),e.jsx(Aa,{agentId:o,disabled:((b==null?void 0:b.provider)??"claude")!=="claude",contextSummary:Z?`Context: ${at}k / ${ee}k tokens (${nt}% used)`:void 0,children:e.jsxs("span",{className:"flat-terminal-wrapper__context",tabIndex:0,role:"button",onClick:()=>f.setContextModalAgentId(o),onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),f.setContextModalAgentId(o))},title:((b==null?void 0:b.provider)??"claude")!=="claude"?Z?`Context usage: ${at}k / ${ee}k tokens (${nt}% used). Click to view stats.`:"Click to fetch context stats":void 0,children:[e.jsx("span",{className:"flat-terminal-wrapper__context-icon",children:e.jsx(p,{name:"dashboard",size:12})}),e.jsx("span",{className:"flat-terminal-wrapper__context-label",children:"Ctx:"}),e.jsx("span",{className:"flat-terminal-wrapper__context-bar",children:e.jsx("span",{className:"flat-terminal-wrapper__context-bar-fill",style:{width:`${me}%`,backgroundColor:gt}})}),e.jsxs("span",{className:"flat-terminal-wrapper__context-tokens",style:{color:gt},children:[at,"k/",ee,"k"]}),e.jsxs("span",{className:"flat-terminal-wrapper__context-free",children:["(",$t,"% free)"]}),!Z&&e.jsx("span",{className:"flat-terminal-wrapper__context-warning",title:"No context stats yet",children:e.jsx(p,{name:"warn",size:12})})]})}),e.jsx("div",{className:"flat-terminal-wrapper__statusbar-spacer","aria-hidden":"true"}),Ue.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area terminals",children:Ue.map(n=>{const r=(C==null?void 0:C.buildingId)===n.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${r?"flat-terminal-wrapper__building-btn--active":""} ${n.hasUrl?"":"flat-terminal-wrapper__building-btn--offline"}`,title:`${r?"Hide":"Show"} terminal: ${n.name}${n.hasUrl?"":" (starting...)"}`,onClick:()=>{if(r){ae();return}if(n.hasUrl&&rt(n.id)==="modal"){Ke(n.id);return}n.hasUrl||f.sendBuildingCommand(n.id,"start"),De("terminal",n.id)},onContextMenu:i=>{i.preventDefault(),i.stopPropagation(),K(n.id,{x:i.clientX,y:i.clientY})},children:e.jsx(p,{name:"terminal",size:14})},n.id)})}),Ve.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area PM2 logs",children:Ve.map(n=>{const r=(C==null?void 0:C.buildingId)===n.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${r?"flat-terminal-wrapper__building-btn--active":""}`,title:`${r?"Hide":"Show"} logs: ${n.name}`,onClick:()=>{r?ae():rt(n.id)==="modal"?Ke(n.id):De("pm2-logs",n.id)},onContextMenu:i=>{i.preventDefault(),i.stopPropagation(),K(n.id,{x:i.clientX,y:i.clientY})},children:e.jsx(p,{name:"scroll",size:14})},n.id)})}),xe.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area databases",children:xe.map(n=>{const r=(C==null?void 0:C.buildingId)===n.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${r?"flat-terminal-wrapper__building-btn--active":""}`,title:`${r?"Hide":"Show"} database: ${n.name}`,onClick:()=>{r?ae():rt(n.id)==="modal"?Ke(n.id):De("database",n.id)},onContextMenu:i=>{i.preventDefault(),i.stopPropagation(),K(n.id,{x:i.clientX,y:i.clientY})},children:e.jsx(p,{name:"hard-drives",size:14})},n.id)})}),ce.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area tests",children:ce.map(n=>{const r=(C==null?void 0:C.buildingId)===n.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${r?"flat-terminal-wrapper__building-btn--active":""} ${n.working?"flat-terminal-wrapper__building-btn--tests-working":""}`,title:n.working?`Running tests: ${n.name}`:`${r?"Hide":"Show"} tests: ${n.name}`,onClick:()=>{r?ae():rt(n.id)==="modal"?Ke(n.id):De("tests",n.id)},onContextMenu:i=>{i.preventDefault(),i.stopPropagation(),K(n.id,{x:i.clientX,y:i.clientY})},children:e.jsx(p,{name:"flask",size:14})},n.id)})}),be.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area HTTP requests",children:be.map(n=>{const r=(C==null?void 0:C.buildingId)===n.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${r?"flat-terminal-wrapper__building-btn--active":""}`,title:`${r?"Hide":"Show"} HTTP requests: ${n.name}`,onClick:()=>{r?ae():rt(n.id)==="modal"?Ke(n.id):De("http",n.id)},onContextMenu:i=>{i.preventDefault(),i.stopPropagation(),K(n.id,{x:i.clientX,y:i.clientY})},children:e.jsx(p,{name:"globe",size:14})},n.id)})}),e.jsx("div",{className:"flat-terminal-wrapper__theme",children:e.jsx(ma,{})})]}),ze&&e.jsx(fa,{agentId:o,agents:Lt,onClose:Tt,branchInfoMap:Ee,fetchRemote:he,fetchingDirs:ge,onResizeStart:n=>It(n,"right")}),je&&e.jsx(ha,{agentId:o,onClose:Pt}),Oe&&e.jsx(ga,{agentId:o,onClose:se})]})}),Da={groups:[],gridCols:1,gridRows:1,positions:new Map};function Wa({onAgentClick:u,onBuildingClick:o,onBuildingDoubleClick:m,onBuildingPopup:h,onAreaContextMenu:y,onOpenSpawnModal:$,onOpenBossSpawnModal:T,onOpenAreaModal:B}){const{t:te}=Ut(["common"]),w=An(),F=Sn(),[D,X]=a.useState(null),[J,Q]=a.useState(null),[oe,Fe]=a.useState(null);En("flatview-image-modal",D!==null,()=>X(null));const[Ze,ct]=a.useState(null),[K,b]=a.useState(null),[I,Je]=a.useState(null),[ne,We]=a.useState(null),[Re,Qe]=a.useState(!1),dt=a.useCallback(()=>{Qe(t=>!t)},[]),He=a.useCallback(()=>{Qe(!1)},[]),[fe,$e]=a.useState(()=>{const t=Yt(E.VIEW_MODE);return t==="simple"||t==="chat"||t==="advanced"?t:"simple"}),et=a.useCallback(t=>{$e(t),Kt(E.VIEW_MODE,t)},[]);a.useEffect(()=>{const t=s=>{if(s.key!==E.VIEW_MODE)return;const l=s.newValue;(l==="simple"||l==="chat"||l==="advanced")&&$e(l)};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)},[]);const[Se,Ee]=a.useState(()=>Ht(E.FLAT_INSPECTOR_OPEN,!1)),[he,ge]=a.useState(!1),Ue=a.useCallback(()=>ge(t=>!t),[]),Ve=a.useCallback(()=>ge(!1),[]);a.useEffect(()=>{window.dispatchEvent(new CustomEvent("tide-flat-agents-drawer-state",{detail:{open:he}}))},[he]),a.useEffect(()=>{window.dispatchEvent(new CustomEvent("tide-flat-inspector-state",{detail:{open:Se}}))},[Se]),a.useEffect(()=>{const t=()=>ge(j=>!j),s=()=>{Ee(j=>{const k=!j;return Ae(E.FLAT_INSPECTOR_OPEN,k),k})},l=()=>{ge(!1),Ee(!1),Ae(E.FLAT_INSPECTOR_OPEN,!1)},g=()=>ge(!1),x=()=>{Ee(!1),Ae(E.FLAT_INSPECTOR_OPEN,!1)};return window.addEventListener("tide-toggle-flat-agents-drawer",t),window.addEventListener("tide-toggle-flat-inspector",s),window.addEventListener("tide-close-flat-side-views",l),window.addEventListener("tide-close-flat-agents-drawer-only",g),window.addEventListener("tide-close-flat-inspector-only",x),()=>{window.removeEventListener("tide-toggle-flat-agents-drawer",t),window.removeEventListener("tide-toggle-flat-inspector",s),window.removeEventListener("tide-close-flat-side-views",l),window.removeEventListener("tide-close-flat-agents-drawer-only",g),window.removeEventListener("tide-close-flat-inspector-only",x)}},[]);const xe=a.useRef(null),Me=a.useRef(null),[ce,be]=a.useState(()=>{const t=Zt(E.FLAT_MIDDLE_WIDTH,0);return t>=kt?t:null}),[de,_e]=a.useState(()=>{const t=Zt(E.FLAT_INSPECTOR_WIDTH,0);return t>=Ft?t:null}),Ie=a.useCallback(t=>{if(typeof window>"u")return t;const s=de!==null?yt+de:0,l=window.innerWidth-an-yt-nn-s;return Math.max(kt,Math.min(Math.max(l,kt),t))},[de]),we=a.useCallback(t=>{var x;if(typeof window>"u")return t;const s=(x=xe.current)==null?void 0:x.querySelector(".flat-middle"),l=(s==null?void 0:s.getBoundingClientRect().width)??kt,g=window.innerWidth-an-l-yt-nn-yt;return Math.max(Ft,Math.min(Math.max(g,Ft),t))},[]);a.useEffect(()=>{if(ce===null&&de===null)return;const t=()=>{be(s=>{if(s===null)return s;const l=Ie(s);return l===s?s:l}),_e(s=>{if(s===null)return s;const l=we(s);return l===s?s:l})};return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[ce,de,Ie,we]);const tt=a.useCallback(t=>{var l;if(t.button!==0)return;const s=(l=xe.current)==null?void 0:l.querySelector(".flat-middle");s&&(t.currentTarget.setPointerCapture(t.pointerId),Me.current={kind:"middle",startX:t.clientX,startWidth:s.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),C=a.useCallback(t=>{var l;if(t.button!==0)return;const s=(l=xe.current)==null?void 0:l.querySelector(".flat-inspector");s&&(t.currentTarget.setPointerCapture(t.pointerId),Me.current={kind:"inspector",startX:t.clientX,startWidth:s.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),ve=a.useCallback(t=>{const s=Me.current;if(!s||t.pointerId!==s.pointerId)return;const l=t.clientX-s.startX;s.kind==="middle"?be(Ie(s.startWidth+l)):_e(we(s.startWidth-l))},[Ie,we]),W=a.useCallback(t=>{const s=Me.current;if(!s||t.pointerId!==s.pointerId)return;try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}if(Me.current=null,document.body.classList.remove("flat-splitter-dragging"),!(Math.abs(t.clientX-s.startX)>2))return;const g=t.clientX-s.startX;if(s.kind==="middle"){const x=Ie(s.startWidth+g);be(x),Nt(E.FLAT_MIDDLE_WIDTH,x)}else{const x=we(s.startWidth-g);_e(x),Nt(E.FLAT_INSPECTOR_WIDTH,x)}},[Ie,we]),ut=a.useCallback(()=>{be(null),Nt(E.FLAT_MIDDLE_WIDTH,0)},[]),Te=a.useCallback(()=>{_e(null),Nt(E.FLAT_INSPECTOR_WIDTH,0)},[]),[Ce,At]=a.useState(()=>Yt(E.FLAT_INSPECTOR_VIEW)==="tracking"?"tracking":"agent"),z=a.useCallback(t=>{At(t),Kt(E.FLAT_INSPECTOR_VIEW,t)},[]),De=a.useCallback(()=>{Ee(t=>{const s=!t;return Ae(E.FLAT_INSPECTOR_OPEN,s),s})},[]),ae=a.useCallback(()=>{Ee(!1),Ae(E.FLAT_INSPECTOR_OPEN,!1)},[]),St=Mn(),Et=a.useCallback((t,s)=>{X({url:t,name:s})},[]),Mt=a.useCallback((t,s)=>{Q({command:t,output:s,isLive:!1})},[]),It=a.useCallback((t,s)=>{var x;const l=F.size>0?Array.from(F)[0]:null,g=l?(x=f.getState().agents.get(l))==null?void 0:x.cwd:void 0;f.setFileViewerPath(t,s,g)},[F]),ze=a.useCallback(t=>{Fe(t)},[]),pt=a.useCallback((t,s)=>{ct({agentId:t,count:s})},[]),je=a.useCallback(t=>{m?m(t):o(t)},[o,m]),_=a.useMemo(()=>F.size>0?Array.from(F)[0]:null,[F]),Oe=a.useCallback(t=>{_&&b({agentId:_,position:t})},[_]),mt=a.useCallback((t,s)=>{Je({buildingId:t,position:s})},[]);a.useEffect(()=>{Qe(!1)},[_]);const Ne=a.useRef([]),se=a.useRef(-1),Xe=a.useRef(!1),ft=a.useRef(null),[Tt,Pt]=a.useState(!1),[Lt,Pe]=a.useState(!1),Ge=a.useRef(!1),ie=a.useRef(null),ue=a.useRef(!1),pe=a.useMemo(()=>new Set(w.map(t=>t.id)),[w]),ye=a.useMemo(()=>{const t=new Map(w.map(l=>[l.id,l])),s=new Map;for(const l of w)if((l.isBoss||l.class==="boss")&&l.subordinateIds&&l.subordinateIds.length>0){const g=l.subordinateIds.map(x=>t.get(x)).filter(x=>x!==void 0);g.length>0&&s.set(l.id,g)}return s},[w]),Z=a.useCallback(()=>{const t=Ne.current,s=se.current;Pt(s>0),Pe(s>=0&&s<t.length-1)},[]),ke=a.useCallback(t=>{const s=Ne.current;if(s.length===0)return;let l=se.current+t;for(;l>=0&&l<s.length;){const g=s[l];if(pe.has(g)){Xe.current=!0,se.current=l,Z(),f.selectAgent(g);return}l+=t}},[pe,Z]),ht=a.useCallback(()=>ke(-1),[ke]),Rt=a.useCallback(()=>ke(1),[ke]);va(a.useCallback(()=>{const t=Ne.current,s=se.current;return t.length>0&&s>0?(ke(-1),"handled"):"exit"},[ke]));const me=a.useCallback((t,s)=>{if(typeof window>"u")return;const l=window.history.state,x={...typeof l=="object"&&l!==null?l:{},__flatAgentNav:{agentId:t}};s==="replace"?window.history.replaceState(x,"",window.location.href):window.history.pushState(x,"",window.location.href)},[]);a.useEffect(()=>{if(!_){Ge.current=!1,ie.current=null;return}if(!Ge.current){me(_,"replace"),Ge.current=!0,ie.current=_;return}if(ue.current){ue.current=!1,ie.current=_;return}ie.current!==_&&(me(_,"push"),ie.current=_)},[_,me]),a.useEffect(()=>{const t=s=>{var j,k;const l=(k=(j=s.state)==null?void 0:j.__flatAgentNav)==null?void 0:k.agentId;if(!l||typeof l!="string"||!pe.has(l)||l===_)return;ue.current=!0,Xe.current=!0;const g=Ne.current,x=g.lastIndexOf(l);x>=0?se.current=x:(g.push(l),se.current=g.length-1),Z(),f.selectAgent(l)};return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)},[pe,_,Z]),a.useEffect(()=>{if(!_){Ne.current=[],se.current=-1,Z();return}if(ft.current=_,Xe.current){Xe.current=!1,Z();return}const t=Ne.current,s=se.current;if(s>=0&&t[s]===_){Z();return}const l=s<t.length-1?t.slice(0,s+1):t.slice();l.push(_),l.length>100&&l.shift(),Ne.current=l,se.current=l.length-1,Z()},[_,Z]);const nt=a.useCallback(t=>{u(t),ge(!1)},[u]),$t=_??"",gt=a.useCallback(()=>{},[]),at=a.useCallback(t=>{nt(t)},[nt]),ee=Se,[le,st]=a.useState(ee),[qe,xt]=a.useState(ee);a.useEffect(()=>{if(ee){st(!0);return}xt(!1);const t=setTimeout(()=>st(!1),240);return()=>clearTimeout(t)},[ee]),a.useEffect(()=>{if(!le||!ee)return;let t=0;const s=requestAnimationFrame(()=>{t=requestAnimationFrame(()=>xt(!0))});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(t)}},[le,ee]);const it=a.useRef(null);a.useEffect(()=>{if(_)return;const t=s=>{if(s.key!==" "&&s.key!=="Backspace")return;const l=s.target;if(l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.isContentEditable)return;const g=ft.current;!g||!pe.has(g)||(s.preventDefault(),f.selectAgent(g))};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[_,pe]);const[bt,n]=a.useState(new Set),r=a.useCallback(t=>{n(s=>{const l=new Set(s);return l.has(t)?l.delete(t):l.add(t),l})},[]),[i,d]=a.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 768px)").matches);a.useEffect(()=>{if(typeof window>"u")return;const t=window.matchMedia("(max-width: 768px)"),s=l=>d(l.matches);return t.addEventListener("change",s),()=>t.removeEventListener("change",s)},[]);const[O,re]=a.useState(null),P=a.useCallback(t=>{re(s=>s===t?null:t)},[]),Le=cn(),Ye=dn(),[_t]=In(),L=a.useMemo(()=>{if(_)return Da;const t=new Map,s=[];for(const v of w){const S=f.getAreaForAgent(v.id);if(!Jt((S==null?void 0:S.id)??null))continue;if(!S||S.archived){s.push(v);continue}const M=t.get(S.id);M?M.push(v):t.set(S.id,[v])}const l=new Map,g=[];for(const v of Ye.values()){let S=!1;for(const M of Le.values())if(!M.archived&&Qt(M.id)&&f.isPositionInArea(v.position,M)){const G=l.get(M.id);G?G.push(v):l.set(M.id,[v]),S=!0;break}!S&&Jt(null)&&g.push(v)}const x=[];for(const[,v]of Le){if(v.archived||!Qt(v.id))continue;const S=t.get(v.id),M=l.get(v.id)??[];(S&&S.length>0||M.length>0)&&x.push({area:v,agents:S??[],buildings:M})}(s.length>0||g.length>0)&&x.push({area:{id:"__unassigned__",name:"Unassigned",color:"#6272a4",center:{x:0,z:0},type:"circle",radius:0,directories:[],archived:!1,assignedAgentIds:[],zIndex:0},agents:s,buildings:g});const j=x.filter(v=>v.area.id!=="__unassigned__"),k=x.filter(v=>v.area.id==="__unassigned__");let c=1,A=1;const V=new Map;if(j.length>1){let v=1/0,S=-1/0,M=1/0,G=-1/0;for(const q of j)v=Math.min(v,q.area.center.x),S=Math.max(S,q.area.center.x),M=Math.min(M,q.area.center.z),G=Math.max(G,q.area.center.z);const vt=S-v||1,Ct=G-M||1;if(j.length<=4){c=j.length,A=1;const q=[...j].sort((Y,Dt)=>Y.area.center.x-Dt.area.center.x);for(let Y=0;Y<q.length;Y++)V.set(q[Y].area.id,{row:1,col:Y+1})}else{const q=[...j].sort((N,H)=>N.area.center.x-H.area.center.x),Y=[];for(let N=1;N<q.length;N++)Y.push(q[N].area.center.x-q[N-1].area.center.x);const Dt=Y.reduce((N,H)=>N+H,0)/Y.length||1;let Vt=1;for(const N of Y)N>Dt*1.3&&Vt++;c=Math.max(2,Math.min(Vt,j.length));const zt=[...j].sort((N,H)=>N.area.center.z-H.area.center.z),jt=[];for(let N=1;N<zt.length;N++)jt.push(zt[N].area.center.z-zt[N-1].area.center.z);const gn=jt.reduce((N,H)=>N+H,0)/jt.length||1;let Xt=1;for(const N of jt)N>gn*1.3&&Xt++;A=Math.max(2,Math.min(Xt,j.length)),c=Math.max(c,Math.ceil(j.length/A)),A=Math.max(A,Math.ceil(j.length/c));const xn=vt/c,bn=Ct/A,Ot=new Set;for(const N of j){let H=Math.min(c-1,Math.max(0,Math.floor((N.area.center.x-v)/xn))),Be=Math.min(A-1,Math.max(0,Math.floor((N.area.center.z-M)/bn))),lt=`${Be},${H}`,Gt=0;const _n=A*c;for(;Ot.has(lt)&&Gt<_n;)H++,H>=c&&(H=0,Be=(Be+1)%A),lt=`${Be},${H}`,Gt++;Ot.has(lt)&&(Be=A,H=0,lt=`${Be},${H}`,A++),Ot.add(lt),V.set(N.area.id,{row:Be+1,col:H+1})}}}const R=v=>{v.sort((S,M)=>{var vt,Ct,q,Y;const G=(((vt=S.position)==null?void 0:vt.z)??0)-(((Ct=M.position)==null?void 0:Ct.z)??0);return G!==0?G:(((q=S.position)==null?void 0:q.x)??0)-(((Y=M.position)==null?void 0:Y.x)??0)})};for(const v of j)R(v.agents);for(const v of k)R(v.agents);return{groups:[...j,...k],gridCols:c,gridRows:A,positions:V}},[w,Le,Ye,_t,_]),U=a.useMemo(()=>{if(!K)return[];const t=w.find(s=>s.id===K.agentId);return t?[{id:"edit-agent",label:"Edit Agent",icon:e.jsx(p,{name:"edit",size:14}),onClick:()=>{window.dispatchEvent(new CustomEvent("tide:open-agent-edit",{detail:{agentId:t.id}}))}},{id:"open-chat",label:"Open Chat",icon:e.jsx(p,{name:"chat",size:14}),onClick:()=>u(t.id)},{id:"clone-agent",label:"Clone Agent",icon:e.jsx(p,{name:"clipboard",size:14}),onClick:()=>f.cloneAgent(t.id)},{id:"fork-agent",label:"Fork Agent (with history)",icon:e.jsx(p,{name:"git-branch",size:14}),onClick:()=>f.forkAgent(t.id)},{id:"delete-agent",label:"Delete Agent",icon:e.jsx(p,{name:"trash",size:14}),danger:!0,onClick:()=>{We({agentId:t.id,name:t.name})}}]:[]},[K,w,u]),wt=a.useMemo(()=>{var j;if(!I)return[];const t=Ye.get(I.buildingId);if(!t)return[];const s=[],l=t.type==="server"||t.type==="docker"||t.type==="terminal",g=t.status==="running",x=t.type==="boss";if(s.push({id:"open",label:t.type==="database"?"Open Database":t.type==="folder"?"Open Folder":t.type==="tests"?"Open Tests":t.type==="http"?"Open Requests":t.type==="boss"?"View Boss Logs":t.type==="terminal"?"Open Terminal":t.type==="server"&&((j=t.pm2)!=null&&j.enabled)?"View PM2 Logs":"Open",icon:e.jsx(p,{name:t.type==="database"?"database":t.type==="folder"?"folder":t.type==="tests"?"flask":t.type==="http"?"globe":t.type==="terminal"?"terminal":"eye",size:14}),onClick:()=>je(t.id)}),l&&(g||s.push({id:"start",label:"Start",icon:e.jsx(p,{name:"play",size:14}),onClick:()=>f.sendBuildingCommand(t.id,"start")}),g&&(s.push({id:"restart",label:"Restart",icon:e.jsx(p,{name:"refresh",size:14}),onClick:()=>f.sendBuildingCommand(t.id,"restart")}),s.push({id:"stop",label:"Stop",icon:e.jsx(p,{name:"stop",size:14}),onClick:()=>f.sendBuildingCommand(t.id,"stop")}))),x&&t.subordinateBuildingIds&&t.subordinateBuildingIds.length>0&&(s.push({id:"start-all",label:"Start All Subordinates",icon:e.jsx(p,{name:"launch",size:14}),onClick:()=>{for(const k of t.subordinateBuildingIds)f.sendBuildingCommand(k,"start")}}),s.push({id:"stop-all",label:"Stop All Subordinates",icon:e.jsx(p,{name:"pause",size:14}),onClick:()=>{for(const k of t.subordinateBuildingIds)f.sendBuildingCommand(k,"stop")}}),s.push({id:"restart-all",label:"Restart All Subordinates",icon:e.jsx(p,{name:"restart",size:14}),onClick:()=>{for(const k of t.subordinateBuildingIds)f.sendBuildingCommand(k,"restart")}})),l&&s.push({id:"health-check",label:"Health Check",icon:e.jsx(p,{name:"health",size:14}),onClick:()=>f.sendBuildingCommand(t.id,"healthCheck")}),s.push({id:"divider-edit",label:"",divider:!0,onClick:()=>{}}),s.push({id:"edit",label:"Edit Building",icon:e.jsx(p,{name:"edit",size:14}),onClick:()=>{window.dispatchEvent(new CustomEvent("tide:building-edit",{detail:{buildingId:t.id}}))}}),s.push({id:"clone",label:"Clone Building",icon:e.jsx(p,{name:"copy",size:14}),onClick:()=>{f.createBuilding({name:`${t.name} (Copy)`,type:t.type,style:t.style,color:t.color,scale:t.scale,position:{x:t.position.x+2,z:t.position.z+2},cwd:t.cwd,folderPath:t.folderPath,commands:t.commands,pm2:t.pm2,docker:t.docker,database:t.database,terminal:t.terminal,urls:t.urls,subordinateBuildingIds:t.subordinateBuildingIds})}}),t.urls&&t.urls.length>0)for(const k of t.urls)s.push({id:`url-${k.label}`,label:k.label,icon:e.jsx(p,{name:"link",size:14}),onClick:()=>window.open(k.url,"_blank","noopener,noreferrer")});return s.push({id:"divider-danger",label:"",divider:!0,onClick:()=>{}}),s.push({id:"delete",label:"Delete Building",icon:e.jsx(p,{name:"trash",size:14}),danger:!0,onClick:()=>f.deleteBuilding(t.id)}),s},[I,Ye,je]),hn=a.useCallback(t=>{const s=new Set(L.groups.map(l=>l.area.id));s.delete(t),n(s),requestAnimationFrame(()=>{const l=it.current;if(!l)return;const g=l.querySelector(`[data-area-id="${t}"]`);if(!g)return;const x=l.getBoundingClientRect(),k=g.getBoundingClientRect().top-x.top+l.scrollTop-8;l.scrollTo({top:Math.max(0,k),behavior:"smooth"})})},[L]);return e.jsxs("div",{ref:xe,className:`flat-view ${ee?"flat-view--with-inspector":""} ${_?"flat-view--has-chat":""} ${he?"flat-view--mobile-sidebar-open":""}`,style:(()=>{if(ce===null&&de===null)return;const t={};return ce!==null&&(t["--flat-middle-width"]=`${ce}px`),de!==null&&(t["--flat-inspector-width"]=`${de}px`),t})(),children:[he&&e.jsx("div",{className:"flat-mobile-sidebar-backdrop",onClick:Ve,"aria-hidden":"true"}),e.jsxs("div",{className:"flat-middle",children:[e.jsx("div",{className:"flat-middle__header",children:e.jsxs("div",{className:"flat-middle__actions",children:[e.jsx("button",{className:"flat-cta-btn flat-cta-btn--agent",onClick:$,title:"Create new agent",children:"+ Agent"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--boss",onClick:T,title:"Create new boss agent",children:"+ Boss"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--area",onClick:B,title:"Create new area",children:"+ Area"})]})}),e.jsx("div",{className:"flat-middle__content",children:e.jsx(Tn,{activeAgentId:$t,onClose:gt,onSelectAgent:at,collapsedAreas:bt,onToggleArea:r,agentListRef:it})})]}),e.jsx("div",{className:"flat-splitter flat-splitter--middle",role:"separator","aria-orientation":"vertical","aria-label":"Resize agents panel",title:"Drag to resize · Double-click to reset",onPointerDown:tt,onPointerMove:ve,onPointerUp:W,onPointerCancel:W,onDoubleClick:ut}),e.jsxs("div",{className:"flat-right",children:[e.jsxs("button",{type:"button",className:"flat-mobile-sidebar-toggle","aria-label":he?"Close agents sidebar":"Open agents sidebar","aria-expanded":he,onClick:Ue,children:[e.jsx(p,{name:"list",size:18}),e.jsx("span",{className:"flat-mobile-sidebar-toggle__label",children:"Agents"})]}),_?e.jsx($a,{agentId:_,terminalViewMode:fe,onTerminalViewModeChange:et,inspectorOpen:Se,onToggleInspector:De,onImageClick:Et,onFileClick:It,onBashClick:Mt,onViewMarkdown:ze,onRequestClearSubordinates:pt,keyboard:St,canNavigateBack:Tt,canNavigateForward:Lt,onNavigateBack:ht,onNavigateForward:Rt,agentInfoOpen:Re,onToggleAgentInfo:dt,onHeaderContextMenu:Oe,onBuildingContextMenu:mt}):e.jsx("div",{className:"flat-chat flat-chat--empty",children:e.jsxs("div",{className:"flat-map",children:[e.jsxs("div",{className:"flat-map__header",children:[e.jsx("span",{className:"flat-map__title",children:"🗺️ Areas"}),e.jsx("span",{className:"flat-map__hint",children:"Click an area to focus it, or an agent to chat"}),e.jsx(Sa,{className:"flat-map__view-mode"})]}),e.jsx("div",{className:"flat-map__grid",style:{gridTemplateColumns:`repeat(${L.gridCols}, 1fr)`},children:L.groups.length===0?e.jsx("div",{className:"flat-map__empty",children:e.jsx("span",{children:"No areas or agents yet"})}):(()=>{var s;const t=i&&O?((s=L.positions.get(O))==null?void 0:s.row)??null:null;return L.groups.map(l=>{var k;const g=l.area.id,x=L.positions.get(g),j=i&&O!==g;return i&&t!=null&&(x==null?void 0:x.row)===t&&g!==O?null:e.jsxs("div",{className:`flat-map-area-card${j?" flat-map-area-card--collapsed":""}`,style:{"--area-color":l.area.color,gridRow:x==null?void 0:x.row,gridColumn:x==null?void 0:x.col},onContextMenu:c=>{y&&(c.preventDefault(),c.stopPropagation(),y(g,{x:c.clientX,y:c.clientY}))},children:[((k=l.area.logo)==null?void 0:k.filename)&&e.jsx("img",{className:"flat-map-area-card__logo",src:wa(l.area.logo.filename),alt:"","aria-hidden":"true",onError:c=>{c.currentTarget.style.display="none"}}),e.jsxs("button",{type:"button",className:"flat-map-area-card__header",onClick:()=>i?P(g):hn(g),title:i?j?`Expand ${l.area.name}`:`Collapse ${l.area.name}`:`Focus ${l.area.name} in left panel`,"aria-expanded":i?!j:void 0,children:[e.jsx("span",{className:"flat-map-area-card__color",style:{background:l.area.color}}),e.jsx("span",{className:"flat-map-area-card__name",children:l.area.name}),e.jsx("span",{className:"flat-map-area-card__count",children:l.agents.length}),i&&e.jsx(p,{name:j?"caret-down":"caret-up",size:11,className:"flat-map-area-card__caret"})]}),e.jsx("div",{className:"flat-map-area-card__agents",children:l.agents.map(c=>{const A=c.isBoss||c.class==="boss",V=A?ye.get(c.id):void 0,R=Pn(c),v=R.usedPercent>=80?"#ff4a4a":R.usedPercent>=60?"#ff9e4a":R.usedPercent>=40?"#ffd700":"#4aff9e",S=`Context: ${(R.totalTokens/1e3).toFixed(1)}k / ${(R.contextWindow/1e3).toFixed(1)}k (${R.usedPercent}% used, ${R.freePercent}% free)`,M=c.latestTodos&&c.latestTodos.length>0||V&&V.length>0;return e.jsx(Ln,{todos:c.latestTodos,subordinates:V,position:"top",children:e.jsxs("button",{type:"button",className:`flat-map-agent-chip ${c.status}`,onClick:()=>u(c.id),onContextMenu:G=>{G.preventDefault(),G.stopPropagation(),b({agentId:c.id,position:{x:G.clientX,y:G.clientY}})},title:M?void 0:`${A?"Boss · ":""}Open chat with ${c.name}
|
|
2
|
-
${S}`,children:[e.jsx(un,{agent:c,size:16}),A&&e.jsx("span",{className:"flat-map-agent-chip__crown","aria-hidden":"true",children:e.jsx(p,{name:"crown",size:11,color:"#ffd700",weight:"fill"})}),e.jsx("span",{className:"flat-map-agent-chip__name",children:c.name}),e.jsx("img",{src:c.provider==="codex"?"/assets/codex.png":c.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:c.provider,className:"flat-map-agent-chip__provider-icon",title:c.provider==="codex"?"Codex Agent":c.provider==="opencode"?"OpenCode Agent":"Claude Agent"}),e.jsx("span",{className:"flat-map-agent-chip__dot",style:{backgroundColor:pn(c.status)}}),c.latestTodos&&c.latestTodos.length>0&&e.jsx(Rn,{todos:c.latestTodos,maxDots:6}),A&&V&&V.length>0&&e.jsx($n,{subordinates:V,maxDots:6}),e.jsx("span",{className:"flat-map-agent-chip__context-bar","aria-hidden":"true",children:e.jsx("span",{className:"flat-map-agent-chip__context-bar-fill",style:{width:`${R.usedPercent}%`,backgroundColor:v}})})]})},c.id)})}),l.area.directories.length>0&&e.jsx("div",{className:"flat-map-area-card__folders",role:"group","aria-label":`${l.area.name} folders`,children:l.area.directories.map(c=>{const A=c.split("/").filter(Boolean).pop()||c;return e.jsxs("button",{type:"button",className:"flat-map-folder-chip",onClick:V=>{V.stopPropagation(),f.openFileExplorerForAreaFolder(g,c)},title:`Open in file explorer: ${c}`,children:[e.jsx(p,{name:"folder-open",size:12}),e.jsx("span",{className:"flat-map-folder-chip__name",children:A})]},c)})}),l.buildings.length>0&&e.jsx("div",{className:"flat-map-area-card__buildings",children:l.buildings.map(c=>{var V;const A=(V=Dn[c.type])==null?void 0:V.color;return e.jsxs("button",{type:"button",className:`flat-map-building-chip flat-map-building-chip--${c.status}`,style:A?{"--building-type-color":A}:void 0,onClick:R=>{if(h){const v=R.currentTarget.getBoundingClientRect();h(c.id,{x:v.right,y:v.top+v.height/2})}else je(c.id)},onContextMenu:R=>{R.preventDefault(),R.stopPropagation(),Je({buildingId:c.id,position:{x:R.clientX,y:R.clientY}})},title:`${c.name} · ${c.type} · ${c.status}`,children:[e.jsx(p,{name:zn(c.type),size:12,color:A}),e.jsx("span",{className:"flat-map-building-chip__name",children:c.name}),e.jsx("span",{className:"flat-map-building-chip__dot",style:{backgroundColor:On(c.status)}})]},c.id)})})]},g)})})()})]})})]}),ee&&e.jsx("div",{className:"flat-splitter flat-splitter--inspector",role:"separator","aria-orientation":"vertical","aria-label":"Resize inspector panel",title:"Drag to resize · Double-click to reset",onPointerDown:C,onPointerMove:ve,onPointerUp:W,onPointerCancel:W,onDoubleClick:Te}),le&&e.jsxs("aside",{className:`flat-inspector ${qe?"flat-inspector--open":"flat-inspector--closing"}`,"aria-label":"Inspector panel",children:[e.jsxs("div",{className:"flat-inspector__header",children:[e.jsxs("div",{className:"flat-inspector__tabs",role:"tablist","aria-label":"Inspector view",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":Ce==="agent",className:`flat-inspector__tab ${Ce==="agent"?"flat-inspector__tab--active":""}`,onClick:()=>z("agent"),children:"Agent"}),e.jsx("button",{type:"button",role:"tab","aria-selected":Ce==="tracking",className:`flat-inspector__tab ${Ce==="tracking"?"flat-inspector__tab--active":""}`,onClick:()=>z("tracking"),children:"Tracking"})]}),e.jsx("button",{type:"button",className:"flat-inspector__close",onClick:ae,title:"Close inspector","aria-label":"Close inspector",children:"✕"})]}),e.jsx("div",{className:"flat-inspector__body",children:Ce==="tracking"?e.jsx(Bn,{activeAgentId:_??"",onSelectAgent:t=>{u(t),window.innerWidth<=768&&ae()}}):(()=>{if(!_)return e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Select an agent to inspect"})});const t=w.find(s=>s.id===_);return t?e.jsx(Fn,{agent:t,onFocusAgent:s=>{u(s),window.innerWidth<=768&&ae()},onKillAgent:s=>f.killAgent(s)}):e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Agent not found"})})})()})]}),D&&e.jsx(Wn,{url:D.url,name:D.name,onClose:()=>X(null)}),J&&e.jsx(Hn,{state:J,onClose:()=>Q(null)}),e.jsx(Un,{agent:_?w.find(t=>t.id===_)??null:null,content:oe,onClose:()=>Fe(null)}),Ze&&e.jsx(Vn,{action:"clear-subordinates",selectedAgentId:Ze.agentId,subordinateCount:Ze.count,onClose:()=>ct(null),onClearHistory:()=>{}}),e.jsx(Xn,{agent:_?w.find(t=>t.id===_)??null:null,isOpen:Re&&!!_,onClose:He}),e.jsx(en,{isOpen:K!==null,position:(K==null?void 0:K.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:U,onClose:()=>b(null)}),e.jsx(en,{isOpen:I!==null,position:(I==null?void 0:I.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:wt,onClose:()=>Je(null)}),e.jsx(Gn,{isOpen:ne!==null,title:te("common:confirm.removeAgentTitle"),message:te("common:confirm.removeAgentMessage",{name:(ne==null?void 0:ne.name)??""}),confirmLabel:te("common:buttons.remove"),cancelLabel:te("common:buttons.cancel"),variant:"danger",onConfirm:()=>{ne&&f.removeAgentFromServer(ne.agentId)},onClose:()=>We(null)})]})}export{Wa as FlatView};
|