tide-commander 1.52.0 → 1.53.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.
Files changed (36) hide show
  1. package/dist/assets/{BossLogsModal-Ymc3oi56.js → BossLogsModal-B9STSmb6.js} +1 -1
  2. package/dist/assets/{BossSpawnModal-DnGG9qzz.js → BossSpawnModal-BYeEp5OI.js} +1 -1
  3. package/dist/assets/{ControlsModal-DRP1_rbW.js → ControlsModal-COpfbGtj.js} +1 -1
  4. package/dist/assets/{DockerLogsModal-ko1qlvFd.js → DockerLogsModal-CwQx-3bW.js} +1 -1
  5. package/dist/assets/{EmbeddedEditor-B2ca-rLR.js → EmbeddedEditor-ehRGRrRs.js} +1 -1
  6. package/dist/assets/{GmailOAuthSetup-BRoIudc6.js → GmailOAuthSetup-B_uaH1bN.js} +1 -1
  7. package/dist/assets/{GoogleOAuthSetup-CFu5df99.js → GoogleOAuthSetup-CNbkfN9l.js} +1 -1
  8. package/dist/assets/{IframeModal-CUUf2I-4.js → IframeModal-Cx0TmGPl.js} +1 -1
  9. package/dist/assets/{IntegrationsPanel-BUFdQGGO.js → IntegrationsPanel-sQyZpWqW.js} +2 -2
  10. package/dist/assets/{LogViewerModal-CXnvkEuC.js → LogViewerModal-pA33JkFl.js} +1 -1
  11. package/dist/assets/{MonitoringModal-myaLpP0P.js → MonitoringModal-Dw90UKnf.js} +1 -1
  12. package/dist/assets/{PM2LogsModal-xYkfYrSr.js → PM2LogsModal-Bya_5RuS.js} +1 -1
  13. package/dist/assets/{RestoreArchivedAreaModal-DFk4VoA6.js → RestoreArchivedAreaModal-Dbc4G6uO.js} +1 -1
  14. package/dist/assets/{Scene2DCanvas-Gw6nYE44.js → Scene2DCanvas-VknyyTen.js} +1 -1
  15. package/dist/assets/{SceneManager-CeqztySP.js → SceneManager-BXqFLaeT.js} +1 -1
  16. package/dist/assets/{SkillsPanel-CocWkSNx.js → SkillsPanel-BrCcIF3N.js} +1 -1
  17. package/dist/assets/{SpawnModal-Bn3ZqlXN.js → SpawnModal-IkjbZFhe.js} +1 -1
  18. package/dist/assets/{SubordinateAssignmentModal-DhejKnmh.js → SubordinateAssignmentModal-fzxC42PS.js} +1 -1
  19. package/dist/assets/{TriggerManagerPanel-2TubwcF4.js → TriggerManagerPanel-D9zIVYkR.js} +1 -1
  20. package/dist/assets/{WorkflowEditorPanel-DvIqQCf4.js → WorkflowEditorPanel-CxAWtPcO.js} +1 -1
  21. package/dist/assets/{index-D-GeyVri.js → index-8bWbGeBs.js} +1 -1
  22. package/dist/assets/{index-iyddtr0v.js → index-BC1k8mon.js} +2 -2
  23. package/dist/assets/{index-D3rq1hsg.js → index-CDC9XyS8.js} +1 -1
  24. package/dist/assets/{index-C7D5bylg.js → index-CJXUPevi.js} +1 -1
  25. package/dist/assets/{index-D8ooZD2k.js → index-CMwlYuij.js} +3 -3
  26. package/dist/assets/{index-B4lXmEKE.js → index-Crfe-OV4.js} +1 -1
  27. package/dist/assets/{index-BafIwYn2.js → index-FrQm2j1t.js} +1 -1
  28. package/dist/assets/{index-W4C-3jYM.js → index-IvXUXoCa.js} +1 -1
  29. package/dist/assets/{main-5tHJV1Fa.js → main-9Cs_hNs-.js} +4 -4
  30. package/dist/assets/{main-CeP2eT5V.css → main-BhrN5Ajl.css} +1 -1
  31. package/dist/assets/{web-DYkyfUtH.js → web-BaEueqP3.js} +1 -1
  32. package/dist/assets/{web-Wkb7M9bi.js → web-C0QtHZck.js} +1 -1
  33. package/dist/index.html +2 -2
  34. package/dist/src/packages/server/routes/notifications.js +5 -1
  35. package/dist/src/packages/server/websocket/handlers/notification-handler.js +3 -1
  36. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import{u as Pe,be as Qe,bf as Ze,r as i,h as Me,j as e,s as v,bg as eo,bh as oo,bi as so,ab as Re,l as D,k as Ae,M as ro,I as to,N as ao,bj as P,C as io,X as Ne,W as Oe}from"./main-5tHJV1Fa.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const lo=[{value:"scout",labelKey:"tools:skills.classScout",descriptionKey:"tools:skills.classScoutDesc"},{value:"builder",labelKey:"tools:skills.classBuilder",descriptionKey:"tools:skills.classBuilderDesc"},{value:"debugger",labelKey:"tools:skills.classDebugger",descriptionKey:"tools:skills.classDebuggerDesc"},{value:"architect",labelKey:"tools:skills.classArchitect",descriptionKey:"tools:skills.classArchitectDesc"},{value:"warrior",labelKey:"tools:skills.classWarrior",descriptionKey:"tools:skills.classWarriorDesc"},{value:"support",labelKey:"tools:skills.classSupport",descriptionKey:"tools:skills.classSupportDesc"},{value:"boss",labelKey:"tools:skills.classBoss",descriptionKey:"tools:skills.classBossDesc"}],co=[{labelKey:"tools:skills.toolReadFiles",value:"Read"},{labelKey:"tools:skills.toolWriteFiles",value:"Write"},{labelKey:"tools:skills.toolEditFiles",value:"Edit"},{labelKey:"tools:skills.toolRunBash",value:"Bash"},{labelKey:"tools:skills.toolGitCommands",value:"Bash(git:*)"},{labelKey:"tools:skills.toolNpmCommands",value:"Bash(npm:*)"},{labelKey:"tools:skills.toolDockerCommands",value:"Bash(docker:*)"},{labelKey:"tools:skills.toolKubectlCommands",value:"Bash(kubectl:*)"},{labelKey:"tools:skills.toolSearchFiles",value:"Grep"},{labelKey:"tools:skills.toolGlobFiles",value:"Glob"},{labelKey:"tools:skills.toolWebFetch",value:"WebFetch"},{labelKey:"tools:skills.toolWebSearch",value:"WebSearch"}],no=`## Instructions
1
+ import{u as Pe,be as Qe,bf as Ze,r as i,h as Me,j as e,s as v,bg as eo,bh as oo,bi as so,ab as Re,l as D,k as Ae,M as ro,I as to,N as ao,bj as P,C as io,X as Ne,W as Oe}from"./main-9Cs_hNs-.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const lo=[{value:"scout",labelKey:"tools:skills.classScout",descriptionKey:"tools:skills.classScoutDesc"},{value:"builder",labelKey:"tools:skills.classBuilder",descriptionKey:"tools:skills.classBuilderDesc"},{value:"debugger",labelKey:"tools:skills.classDebugger",descriptionKey:"tools:skills.classDebuggerDesc"},{value:"architect",labelKey:"tools:skills.classArchitect",descriptionKey:"tools:skills.classArchitectDesc"},{value:"warrior",labelKey:"tools:skills.classWarrior",descriptionKey:"tools:skills.classWarriorDesc"},{value:"support",labelKey:"tools:skills.classSupport",descriptionKey:"tools:skills.classSupportDesc"},{value:"boss",labelKey:"tools:skills.classBoss",descriptionKey:"tools:skills.classBossDesc"}],co=[{labelKey:"tools:skills.toolReadFiles",value:"Read"},{labelKey:"tools:skills.toolWriteFiles",value:"Write"},{labelKey:"tools:skills.toolEditFiles",value:"Edit"},{labelKey:"tools:skills.toolRunBash",value:"Bash"},{labelKey:"tools:skills.toolGitCommands",value:"Bash(git:*)"},{labelKey:"tools:skills.toolNpmCommands",value:"Bash(npm:*)"},{labelKey:"tools:skills.toolDockerCommands",value:"Bash(docker:*)"},{labelKey:"tools:skills.toolKubectlCommands",value:"Bash(kubectl:*)"},{labelKey:"tools:skills.toolSearchFiles",value:"Grep"},{labelKey:"tools:skills.toolGlobFiles",value:"Glob"},{labelKey:"tools:skills.toolWebFetch",value:"WebFetch"},{labelKey:"tools:skills.toolWebSearch",value:"WebSearch"}],no=`## Instructions
2
2
 
3
3
  Describe step-by-step instructions for this skill here.
4
4
 
@@ -1 +1 @@
1
- import{u as Xe,M as Ve,N as Ze,O as Qe,P as es,r as t,U as ss,S as Me,V as ne,A as ke,l as te,W as as,s as S,h as ns,j as s,X as ts,C as ye,Y as x,Z as ls,_ as le,$,a0 as G,a1 as oe,a2 as os}from"./main-5tHJV1Fa.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function Ae(c,g){const b=g.filter(C=>!c.has(C));return b.length===0?`${g[Math.floor(Math.random()*g.length)]}-${Date.now()%1e3}`:b[Math.floor(Math.random()*b.length)]}function ps({isOpen:c,onClose:g,onSpawnStart:b,onSpawnEnd:C,spawnPosition:De,spawnAreaId:v}){const{t:a}=Xe(["terminal","common"]),P=Ve(),p=Ze(),ie=Qe(),K=ie.length>0?ie:es,[m,N]=t.useState(""),[M,T]=t.useState(()=>ss(Me.LAST_CWD)),[i,H]=t.useState("scout"),[ce,D]=t.useState(!1),[Ee,F]=t.useState(!1),[re,Y]=t.useState(!1),[de,pe]=t.useState(""),[k,J]=t.useState([]),[y,R]=t.useState(null),[Ie,me]=t.useState(!1),[E,ue]=t.useState(""),[u,Le]=t.useState(""),[U,_e]=t.useState(!0),[z,$e]=t.useState("bypass"),[o,X]=t.useState("claude"),[j,I]=t.useState({fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),[he,V]=t.useState(new Set),[Z,we]=t.useState("claude-opus-4-7"),[Q,xe]=t.useState("high"),[ee,Pe]=t.useState("gpt-5.3-codex"),[se,Te]=t.useState("minimax/MiniMax-M1-80k"),[fe,Fe]=t.useState(""),[A,Re]=t.useState(""),q=t.useRef(null),ge=t.useRef(!1),L=t.useCallback(()=>{window.__spawnModalAreaContext=null},[]),h=t.useMemo(()=>P.filter(e=>e.enabled),[P]),Ue=["full-notifications","streaming-exec","task-label","report-task-to-boss","agent-tracking","send-message-to-agent"];t.useEffect(()=>{if(c&&!ge.current&&h.length>0){const n=h.filter(l=>Ue.includes(l.slug)).map(l=>l.id);n.length>0&&V(new Set(n))}ge.current=c},[c,h]);const je=t.useMemo(()=>{if(!A.trim())return h;const e=A.toLowerCase();return h.filter(n=>n.name.toLowerCase().includes(e)||n.description.toLowerCase().includes(e)||n.slug.toLowerCase().includes(e))},[h,A]),ze=t.useCallback(e=>{V(n=>{const l=new Set(n);return l.has(e)?l.delete(e):l.add(e),l})},[]);t.useMemo(()=>h.filter(e=>e.assignedAgentClasses.includes(i)),[h,i]);const qe=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]),ve=t.useMemo(()=>{if(!E.trim())return k;const e=E.toLowerCase();return k.filter(n=>n.sessionId.toLowerCase().includes(e)||n.projectPath.toLowerCase().includes(e)||n.firstMessage&&n.firstMessage.toLowerCase().includes(e))},[k,E]),W=t.useMemo(()=>{if(!u.trim())return p;const e=u.toLowerCase();return p.filter(n=>n.name.toLowerCase().includes(e)||n.description.toLowerCase().includes(e)||n.id.toLowerCase().includes(e))},[p,u]),O=t.useMemo(()=>{if(!u.trim())return ne;const e=u.toLowerCase();return ne.filter(n=>{const l=ke[n.id];return n.name.toLowerCase().includes(e)||n.id.toLowerCase().includes(e)||l.description.toLowerCase().includes(e)})},[u]);t.useEffect(()=>{if(!c||!u.trim())return;const e=[...W.map(n=>n.id),...O.map(n=>n.id)];e.length===1&&e[0]!==i&&H(e[0])},[c,u,W,O,i]);const r=t.useMemo(()=>p.find(e=>e.id===i),[p,i]),We=t.useMemo(()=>{if(r!=null&&r.model)return r.model},[r]),Oe=t.useMemo(()=>{if(r!=null&&r.customModelPath)return te(`/api/custom-models/${r.id}`)},[r]),Be=r==null?void 0:r.modelScale,Ge=t.useMemo(()=>r?"scout":i,[i,r]),B=t.useCallback(async e=>{me(!0);try{const n=e?te(`/api/agents/claude-sessions?cwd=${encodeURIComponent(e)}`):te("/api/agents/claude-sessions"),d=await(await as(n)).json();J(d.sessions||[])}catch(n){console.error("Failed to fetch sessions:",n),J([])}finally{me(!1)}},[]);t.useEffect(()=>{c?B(M||void 0):(J([]),R(null),ue(""))},[c,B]),t.useEffect(()=>{if(!c)return;const e=setTimeout(()=>{B(M||void 0),R(null)},300);return()=>clearTimeout(e)},[M,c,B]),t.useEffect(()=>{if(!c||!v)return;const e=S.getState().areas.get(v);if(e!=null&&e.directories&&e.directories.length>0){T(e.directories[0]);return}const n=Array.from(S.getState().agents.values()).filter(f=>{var _;return((_=S.getAreaForAgent(f.id))==null?void 0:_.id)===v&&f.cwd});if(n.length===0)return;const l=new Map;for(const f of n)l.set(f.cwd,(l.get(f.cwd)||0)+1);let d="",w=0;for(const[f,_]of l)_>w&&(d=f,w=_);d&&T(d)},[c,v]),t.useEffect(()=>{if(c){const e=new Set(Array.from(S.getState().agents.values()).map(w=>w.name)),n=Ae(e,K),l=p.find(w=>w.id===i),d=l?`${l.name} ${n}`:n;N(d),q.current&&(q.current.focus(),q.current.select())}},[c,K]),t.useEffect(()=>{if(!c)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"&&we("claude-opus-4-7")},[i]);const Ke=()=>{var d;console.log("[SpawnModal] handleSpawn called"),F(!1);const e=y&&((d=k.find(w=>w.sessionId===y))==null?void 0:d.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:",y||"none"),!e.trim()){console.error("[SpawnModal] Empty CWD, showing error"),F(!0);return}if(!m.trim()){console.log("[SpawnModal] Empty name, regenerating");const w=new Set(Array.from(S.getState().agents.values()).map(f=>f.name));N(Ae(w,K));return}os(Me.LAST_CWD,e),D(!0),b();const n=Array.from(he),l=fe.trim()||void 0;console.log("[SpawnModal] Calling store.spawnAgent with:",{name:m.trim(),class:i,cwd:e.trim(),sessionId:y||void 0,useChrome:o==="claude"?U:!1,permissionMode:z,provider:o,codexConfig:o==="codex"?j:void 0,codexModel:o==="codex"?ee:void 0,opencodeModel:o==="opencode"?se:void 0,initialSkillIds:n,model:o==="claude"?Z:void 0,customInstructions:l?`${l.length} chars`:void 0,spawnAreaId:v||void 0}),window.__spawnModalAreaContext=v?{areaId:v}:null,S.spawnAgent(m.trim(),i,e.trim(),De||void 0,y||void 0,o==="claude"?U:!1,z,n,o,o==="codex"?j:void 0,o==="codex"?ee:void 0,o==="claude"?Z:void 0,l,o==="claude"?Q:void 0,o==="opencode"?se:void 0)},Ne=()=>{console.log("[SpawnModal] Agent creation successful"),D(!1),N(""),V(new Set),L(),C(),g()},Se=()=>{console.error("[SpawnModal] Agent creation failed"),D(!1),F(!0),L(),C()},be=e=>{console.log("[SpawnModal] Directory not found:",e),D(!1),pe(e),Y(!0),C()},Ce=()=>{Y(!1),D(!0),b(),S.createDirectoryAndSpawn(de,m.trim(),i)},ae=()=>{Y(!1),pe(""),L()};t.useEffect(()=>(window.__spawnModalSuccess=Ne,window.__spawnModalError=Se,window.__spawnModalDirNotFound=be,()=>{L(),delete window.__spawnModalSuccess,delete window.__spawnModalError,delete window.__spawnModalDirNotFound}),[m,i,Ne,Se,be,L]);const{handleMouseDown:He,handleClick:Ye}=ns(g),Je=e=>{e.key==="Escape"&&g()};return!c&&!re?null:re?s.jsx("div",{className:"modal-overlay visible",onClick:ae,onKeyDown:e=>{e.key==="Escape"&&ae(),e.key==="Enter"&&Ce()},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:de}),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:Ce,autoFocus:!0,children:a("terminal:spawn.createDirectory")})]})]})}):s.jsx("div",{className:`modal-overlay ${c?"visible":""}`,onMouseDown:He,onClick:Ye,onKeyDown:Je,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(ts,{agentClass:Ge,modelFile:We,customModelUrl:Oe,modelScale:Be,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+ne.length>6&&s.jsx("input",{type:"text",className:"spawn-input class-search-input",placeholder:a("terminal:spawn.filterClasses"),value:u,onChange:e=>Le(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:()=>H(e.id),title:e.description,children:[s.jsx(ye,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id)),O.map(e=>{const n=ke[e.id];return s.jsxs("button",{className:`class-chip ${i===e.id?"selected":""}`,onClick:()=>H(e.id),title:n.description,children:[s.jsx(ye,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id)}),u&&W.length===0&&O.length===0&&s.jsx("div",{className:"class-search-empty",children:a("terminal:spawn.noClassesMatch",{query:u})})]})]})]}),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(ls,{value:M,onChange:e=>{T(e),F(!1)},placeholder:a("terminal:spawn.workingDirPlaceholder"),className:`spawn-input ${Ee?"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:()=>X("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:()=>X("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:()=>X("opencode"),title:"Use OpenCode CLI (multi-provider)",children:[s.jsx("span",{children:"🟢"}),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(le).map(e=>s.jsxs("button",{className:`spawn-select-btn ${z===e?"selected":""}`,onClick:()=>$e(e),title:le[e].description,children:[s.jsx("span",{children:e==="bypass"?"⚡":"🔐"}),s.jsx("span",{children:le[e].label})]},e))})]})]}),s.jsxs("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",children:Object.keys($).filter(e=>!$[e].deprecated).map(e=>s.jsxs("button",{className:`spawn-select-btn ${Z===e?"selected":""}`,onClick:()=>we(e),title:$[e].description,children:[s.jsx("span",{children:$[e].icon}),s.jsx("span",{children:$[e].label})]},e))}):o==="codex"?s.jsx("div",{className:"spawn-select-row spawn-select-row--codex-models",children:Object.keys(G).map(e=>s.jsxs("button",{className:`spawn-select-btn ${ee===e?"selected":""}`,onClick:()=>Pe(e),title:G[e].description,children:[s.jsx("span",{children:G[e].icon}),s.jsx("span",{children:G[e].label})]},e))}):o==="opencode"?s.jsx("input",{type:"text",className:"spawn-input",value:se,onChange:e=>Te(e.target.value),placeholder:"provider/model (e.g., minimax/MiniMax-M1-80k)"}):s.jsx("div",{className:"spawn-inline-hint",children:a("terminal:spawn.chooseCodexModel")})]}),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 ${Q===void 0?"selected":""}`,onClick:()=>xe(void 0),title:"Use default effort level",children:s.jsx("span",{children:"Default"})}),Object.keys(oe).map(e=>s.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${Q===e?"selected":""}`,onClick:()=>xe(e),title:oe[e].description,children:s.jsx("span",{children:oe[e].label})},e))]})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:a("terminal:spawn.browser")}),s.jsx("div",{className:"spawn-form-row spawn-options-row",children:s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:U,onChange:e=>_e(e.target.checked),disabled:o!=="claude"}),s.jsxs("span",{children:["🌐 ",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:j.fullAuto!==!1,onChange:e=>I(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:!!j.search,onChange:e=>I(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"})]})]}),j.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:j.sandbox||"workspace-write",onChange:e=>I(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:j.approvalMode||"on-request",onChange:e=>I(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:j.profile||"",onChange:e=>I(n=>({...n,profile:e.target.value||void 0}))})]})]})]}),h.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"})]}),h.length>6&&s.jsx("input",{type:"text",className:"spawn-input skill-search-input",placeholder:a("terminal:spawn.filterSkills"),value:A,onChange:e=>Re(e.target.value)}),s.jsxs("div",{className:"spawn-skills-inline",children:[je.map(e=>{const n=he.has(e.id);return qe.some(d=>d.id===e.id)?null:s.jsxs("button",{className:`spawn-skill-chip ${n?"selected":""}`,onClick:()=>ze(e.id),title:e.description,children:[n&&s.jsx("span",{className:"spawn-skill-check",children:"✓"}),s.jsx("span",{children:e.name}),e.builtin&&s.jsx("span",{className:"spawn-skill-builtin",children:"TC"})]},e.id)}),A&&je.length===0&&s.jsx("div",{className:"skill-search-empty",children:a("terminal:spawn.noSkillsMatch",{query:A})})]})]}),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:fe,onChange:e=>Fe(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"})]}),k.length>0&&s.jsx("input",{type:"text",className:"spawn-input session-search-input",placeholder:a("terminal:spawn.searchSessions"),value:E,onChange:e=>ue(e.target.value)}),s.jsx("div",{className:"sessions-list",children:Ie?s.jsx("div",{className:"sessions-loading",children:a("terminal:spawn.loadingSessions")}):k.length===0?s.jsx("div",{className:"sessions-empty",children:a("terminal:spawn.noSessions")}):ve.length===0?s.jsx("div",{className:"sessions-empty",children:a("terminal:spawn.noSessionsMatch",{query:E})}):ve.map(e=>{const n=y===e.sessionId,l=Date.now()-new Date(e.lastModified).getTime(),d=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?R(null):(R(e.sessionId),T(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:d})]}),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:g,children:a("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-primary",onClick:Ke,disabled:ce,children:a(ce?"common:buttons.deploying":"common:buttons2.deploy")})]})]})})}export{ps as SpawnModal};
1
+ import{u as Xe,M as Ve,N as Ze,O as Qe,P as es,r as t,U as ss,S as Me,V as ne,A as ke,l as te,W as as,s as S,h as ns,j as s,X as ts,C as ye,Y as x,Z as ls,_ as le,$,a0 as G,a1 as oe,a2 as os}from"./main-9Cs_hNs-.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function Ae(c,g){const b=g.filter(C=>!c.has(C));return b.length===0?`${g[Math.floor(Math.random()*g.length)]}-${Date.now()%1e3}`:b[Math.floor(Math.random()*b.length)]}function ps({isOpen:c,onClose:g,onSpawnStart:b,onSpawnEnd:C,spawnPosition:De,spawnAreaId:v}){const{t:a}=Xe(["terminal","common"]),P=Ve(),p=Ze(),ie=Qe(),K=ie.length>0?ie:es,[m,N]=t.useState(""),[M,T]=t.useState(()=>ss(Me.LAST_CWD)),[i,H]=t.useState("scout"),[ce,D]=t.useState(!1),[Ee,F]=t.useState(!1),[re,Y]=t.useState(!1),[de,pe]=t.useState(""),[k,J]=t.useState([]),[y,R]=t.useState(null),[Ie,me]=t.useState(!1),[E,ue]=t.useState(""),[u,Le]=t.useState(""),[U,_e]=t.useState(!0),[z,$e]=t.useState("bypass"),[o,X]=t.useState("claude"),[j,I]=t.useState({fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),[he,V]=t.useState(new Set),[Z,we]=t.useState("claude-opus-4-7"),[Q,xe]=t.useState("high"),[ee,Pe]=t.useState("gpt-5.3-codex"),[se,Te]=t.useState("minimax/MiniMax-M1-80k"),[fe,Fe]=t.useState(""),[A,Re]=t.useState(""),q=t.useRef(null),ge=t.useRef(!1),L=t.useCallback(()=>{window.__spawnModalAreaContext=null},[]),h=t.useMemo(()=>P.filter(e=>e.enabled),[P]),Ue=["full-notifications","streaming-exec","task-label","report-task-to-boss","agent-tracking","send-message-to-agent"];t.useEffect(()=>{if(c&&!ge.current&&h.length>0){const n=h.filter(l=>Ue.includes(l.slug)).map(l=>l.id);n.length>0&&V(new Set(n))}ge.current=c},[c,h]);const je=t.useMemo(()=>{if(!A.trim())return h;const e=A.toLowerCase();return h.filter(n=>n.name.toLowerCase().includes(e)||n.description.toLowerCase().includes(e)||n.slug.toLowerCase().includes(e))},[h,A]),ze=t.useCallback(e=>{V(n=>{const l=new Set(n);return l.has(e)?l.delete(e):l.add(e),l})},[]);t.useMemo(()=>h.filter(e=>e.assignedAgentClasses.includes(i)),[h,i]);const qe=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]),ve=t.useMemo(()=>{if(!E.trim())return k;const e=E.toLowerCase();return k.filter(n=>n.sessionId.toLowerCase().includes(e)||n.projectPath.toLowerCase().includes(e)||n.firstMessage&&n.firstMessage.toLowerCase().includes(e))},[k,E]),W=t.useMemo(()=>{if(!u.trim())return p;const e=u.toLowerCase();return p.filter(n=>n.name.toLowerCase().includes(e)||n.description.toLowerCase().includes(e)||n.id.toLowerCase().includes(e))},[p,u]),O=t.useMemo(()=>{if(!u.trim())return ne;const e=u.toLowerCase();return ne.filter(n=>{const l=ke[n.id];return n.name.toLowerCase().includes(e)||n.id.toLowerCase().includes(e)||l.description.toLowerCase().includes(e)})},[u]);t.useEffect(()=>{if(!c||!u.trim())return;const e=[...W.map(n=>n.id),...O.map(n=>n.id)];e.length===1&&e[0]!==i&&H(e[0])},[c,u,W,O,i]);const r=t.useMemo(()=>p.find(e=>e.id===i),[p,i]),We=t.useMemo(()=>{if(r!=null&&r.model)return r.model},[r]),Oe=t.useMemo(()=>{if(r!=null&&r.customModelPath)return te(`/api/custom-models/${r.id}`)},[r]),Be=r==null?void 0:r.modelScale,Ge=t.useMemo(()=>r?"scout":i,[i,r]),B=t.useCallback(async e=>{me(!0);try{const n=e?te(`/api/agents/claude-sessions?cwd=${encodeURIComponent(e)}`):te("/api/agents/claude-sessions"),d=await(await as(n)).json();J(d.sessions||[])}catch(n){console.error("Failed to fetch sessions:",n),J([])}finally{me(!1)}},[]);t.useEffect(()=>{c?B(M||void 0):(J([]),R(null),ue(""))},[c,B]),t.useEffect(()=>{if(!c)return;const e=setTimeout(()=>{B(M||void 0),R(null)},300);return()=>clearTimeout(e)},[M,c,B]),t.useEffect(()=>{if(!c||!v)return;const e=S.getState().areas.get(v);if(e!=null&&e.directories&&e.directories.length>0){T(e.directories[0]);return}const n=Array.from(S.getState().agents.values()).filter(f=>{var _;return((_=S.getAreaForAgent(f.id))==null?void 0:_.id)===v&&f.cwd});if(n.length===0)return;const l=new Map;for(const f of n)l.set(f.cwd,(l.get(f.cwd)||0)+1);let d="",w=0;for(const[f,_]of l)_>w&&(d=f,w=_);d&&T(d)},[c,v]),t.useEffect(()=>{if(c){const e=new Set(Array.from(S.getState().agents.values()).map(w=>w.name)),n=Ae(e,K),l=p.find(w=>w.id===i),d=l?`${l.name} ${n}`:n;N(d),q.current&&(q.current.focus(),q.current.select())}},[c,K]),t.useEffect(()=>{if(!c)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"&&we("claude-opus-4-7")},[i]);const Ke=()=>{var d;console.log("[SpawnModal] handleSpawn called"),F(!1);const e=y&&((d=k.find(w=>w.sessionId===y))==null?void 0:d.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:",y||"none"),!e.trim()){console.error("[SpawnModal] Empty CWD, showing error"),F(!0);return}if(!m.trim()){console.log("[SpawnModal] Empty name, regenerating");const w=new Set(Array.from(S.getState().agents.values()).map(f=>f.name));N(Ae(w,K));return}os(Me.LAST_CWD,e),D(!0),b();const n=Array.from(he),l=fe.trim()||void 0;console.log("[SpawnModal] Calling store.spawnAgent with:",{name:m.trim(),class:i,cwd:e.trim(),sessionId:y||void 0,useChrome:o==="claude"?U:!1,permissionMode:z,provider:o,codexConfig:o==="codex"?j:void 0,codexModel:o==="codex"?ee:void 0,opencodeModel:o==="opencode"?se:void 0,initialSkillIds:n,model:o==="claude"?Z:void 0,customInstructions:l?`${l.length} chars`:void 0,spawnAreaId:v||void 0}),window.__spawnModalAreaContext=v?{areaId:v}:null,S.spawnAgent(m.trim(),i,e.trim(),De||void 0,y||void 0,o==="claude"?U:!1,z,n,o,o==="codex"?j:void 0,o==="codex"?ee:void 0,o==="claude"?Z:void 0,l,o==="claude"?Q:void 0,o==="opencode"?se:void 0)},Ne=()=>{console.log("[SpawnModal] Agent creation successful"),D(!1),N(""),V(new Set),L(),C(),g()},Se=()=>{console.error("[SpawnModal] Agent creation failed"),D(!1),F(!0),L(),C()},be=e=>{console.log("[SpawnModal] Directory not found:",e),D(!1),pe(e),Y(!0),C()},Ce=()=>{Y(!1),D(!0),b(),S.createDirectoryAndSpawn(de,m.trim(),i)},ae=()=>{Y(!1),pe(""),L()};t.useEffect(()=>(window.__spawnModalSuccess=Ne,window.__spawnModalError=Se,window.__spawnModalDirNotFound=be,()=>{L(),delete window.__spawnModalSuccess,delete window.__spawnModalError,delete window.__spawnModalDirNotFound}),[m,i,Ne,Se,be,L]);const{handleMouseDown:He,handleClick:Ye}=ns(g),Je=e=>{e.key==="Escape"&&g()};return!c&&!re?null:re?s.jsx("div",{className:"modal-overlay visible",onClick:ae,onKeyDown:e=>{e.key==="Escape"&&ae(),e.key==="Enter"&&Ce()},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:de}),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:Ce,autoFocus:!0,children:a("terminal:spawn.createDirectory")})]})]})}):s.jsx("div",{className:`modal-overlay ${c?"visible":""}`,onMouseDown:He,onClick:Ye,onKeyDown:Je,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(ts,{agentClass:Ge,modelFile:We,customModelUrl:Oe,modelScale:Be,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+ne.length>6&&s.jsx("input",{type:"text",className:"spawn-input class-search-input",placeholder:a("terminal:spawn.filterClasses"),value:u,onChange:e=>Le(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:()=>H(e.id),title:e.description,children:[s.jsx(ye,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id)),O.map(e=>{const n=ke[e.id];return s.jsxs("button",{className:`class-chip ${i===e.id?"selected":""}`,onClick:()=>H(e.id),title:n.description,children:[s.jsx(ye,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id)}),u&&W.length===0&&O.length===0&&s.jsx("div",{className:"class-search-empty",children:a("terminal:spawn.noClassesMatch",{query:u})})]})]})]}),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(ls,{value:M,onChange:e=>{T(e),F(!1)},placeholder:a("terminal:spawn.workingDirPlaceholder"),className:`spawn-input ${Ee?"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:()=>X("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:()=>X("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:()=>X("opencode"),title:"Use OpenCode CLI (multi-provider)",children:[s.jsx("span",{children:"🟢"}),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(le).map(e=>s.jsxs("button",{className:`spawn-select-btn ${z===e?"selected":""}`,onClick:()=>$e(e),title:le[e].description,children:[s.jsx("span",{children:e==="bypass"?"⚡":"🔐"}),s.jsx("span",{children:le[e].label})]},e))})]})]}),s.jsxs("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",children:Object.keys($).filter(e=>!$[e].deprecated).map(e=>s.jsxs("button",{className:`spawn-select-btn ${Z===e?"selected":""}`,onClick:()=>we(e),title:$[e].description,children:[s.jsx("span",{children:$[e].icon}),s.jsx("span",{children:$[e].label})]},e))}):o==="codex"?s.jsx("div",{className:"spawn-select-row spawn-select-row--codex-models",children:Object.keys(G).map(e=>s.jsxs("button",{className:`spawn-select-btn ${ee===e?"selected":""}`,onClick:()=>Pe(e),title:G[e].description,children:[s.jsx("span",{children:G[e].icon}),s.jsx("span",{children:G[e].label})]},e))}):o==="opencode"?s.jsx("input",{type:"text",className:"spawn-input",value:se,onChange:e=>Te(e.target.value),placeholder:"provider/model (e.g., minimax/MiniMax-M1-80k)"}):s.jsx("div",{className:"spawn-inline-hint",children:a("terminal:spawn.chooseCodexModel")})]}),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 ${Q===void 0?"selected":""}`,onClick:()=>xe(void 0),title:"Use default effort level",children:s.jsx("span",{children:"Default"})}),Object.keys(oe).map(e=>s.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${Q===e?"selected":""}`,onClick:()=>xe(e),title:oe[e].description,children:s.jsx("span",{children:oe[e].label})},e))]})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:a("terminal:spawn.browser")}),s.jsx("div",{className:"spawn-form-row spawn-options-row",children:s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:U,onChange:e=>_e(e.target.checked),disabled:o!=="claude"}),s.jsxs("span",{children:["🌐 ",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:j.fullAuto!==!1,onChange:e=>I(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:!!j.search,onChange:e=>I(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"})]})]}),j.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:j.sandbox||"workspace-write",onChange:e=>I(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:j.approvalMode||"on-request",onChange:e=>I(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:j.profile||"",onChange:e=>I(n=>({...n,profile:e.target.value||void 0}))})]})]})]}),h.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"})]}),h.length>6&&s.jsx("input",{type:"text",className:"spawn-input skill-search-input",placeholder:a("terminal:spawn.filterSkills"),value:A,onChange:e=>Re(e.target.value)}),s.jsxs("div",{className:"spawn-skills-inline",children:[je.map(e=>{const n=he.has(e.id);return qe.some(d=>d.id===e.id)?null:s.jsxs("button",{className:`spawn-skill-chip ${n?"selected":""}`,onClick:()=>ze(e.id),title:e.description,children:[n&&s.jsx("span",{className:"spawn-skill-check",children:"✓"}),s.jsx("span",{children:e.name}),e.builtin&&s.jsx("span",{className:"spawn-skill-builtin",children:"TC"})]},e.id)}),A&&je.length===0&&s.jsx("div",{className:"skill-search-empty",children:a("terminal:spawn.noSkillsMatch",{query:A})})]})]}),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:fe,onChange:e=>Fe(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"})]}),k.length>0&&s.jsx("input",{type:"text",className:"spawn-input session-search-input",placeholder:a("terminal:spawn.searchSessions"),value:E,onChange:e=>ue(e.target.value)}),s.jsx("div",{className:"sessions-list",children:Ie?s.jsx("div",{className:"sessions-loading",children:a("terminal:spawn.loadingSessions")}):k.length===0?s.jsx("div",{className:"sessions-empty",children:a("terminal:spawn.noSessions")}):ve.length===0?s.jsx("div",{className:"sessions-empty",children:a("terminal:spawn.noSessionsMatch",{query:E})}):ve.map(e=>{const n=y===e.sessionId,l=Date.now()-new Date(e.lastModified).getTime(),d=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?R(null):(R(e.sessionId),T(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:d})]}),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:g,children:a("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-primary",onClick:Ke,disabled:ce,children:a(ce?"common:buttons.deploying":"common:buttons2.deploy")})]})]})})}export{ps as SpawnModal};
@@ -1 +1 @@
1
- import{u as z,I as L,a5 as $,r as m,j as s,a3 as N,C as S,s as D}from"./main-5tHJV1Fa.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function M({isOpen:o,bossId:r,onClose:l}){var j;const{t:a}=z(["terminal","common"]),f=L(),n=$(r),[i,c]=m.useState(new Set),[u,b]=m.useState(!1),d=Array.from(f.values()).filter(e=>e.class!=="boss"&&(!e.bossId||e.bossId===r));m.useEffect(()=>{o&&n&&c(new Set(n.subordinateIds||[]))},[o,n]);const g=()=>{b(!0),D.assignSubordinates(r,Array.from(i)),setTimeout(()=>{b(!1),l()},300)},y=e=>{const t=new Set(i);t.has(e)?t.delete(e):t.add(e),c(t)},A=()=>{c(new Set(d.map(e=>e.id)))},C=()=>{c(new Set)},p=e=>{e.target===e.currentTarget&&l()},w=e=>{e.key==="Escape"&&l()};if(!o||!n)return null;const k=N.boss,h=((j=n.subordinateIds)==null?void 0:j.length)||0,E=i.size,x=JSON.stringify([...n.subordinateIds||[]].sort())!==JSON.stringify([...i].sort());return s.jsx("div",{className:`modal-overlay ${o?"visible":""}`,onClick:p,onKeyDown:w,children:s.jsxs("div",{className:"modal subordinate-assignment-modal",children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("span",{className:"boss-header-icon",style:{color:k.color},children:s.jsx(S,{agent:n,size:22})}),a("terminal:team.manageTeam"),": ",n.name]}),s.jsxs("div",{className:"modal-body subordinate-assignment-body",children:[s.jsxs("div",{className:"subordinate-assignment-info",children:[s.jsx("p",{children:a("terminal:team.selectAgents")}),s.jsxs("div",{className:"subordinate-assignment-actions",children:[s.jsx("button",{className:"btn btn-small",onClick:A,children:a("common:buttons.selectAll")}),s.jsx("button",{className:"btn btn-small",onClick:C,children:a("common:buttons.clearAll")})]})]}),s.jsx("div",{className:"subordinates-list",children:d.length===0?s.jsx("div",{className:"subordinates-empty",children:a("terminal:team.noAgentsAvailable")}):d.map(e=>{var v;const t=i.has(e.id),T=N[e.class],I=(v=n.subordinateIds)==null?void 0:v.includes(e.id);return s.jsxs("div",{className:`subordinate-item ${t?"selected":""}`,onClick:()=>y(e.id),children:[s.jsx("div",{className:"subordinate-checkbox",children:t?"✓":""}),s.jsx("div",{className:"subordinate-icon",style:{color:T.color},children:s.jsx(S,{agent:e,size:18})}),s.jsxs("div",{className:"subordinate-info",children:[s.jsx("div",{className:"subordinate-name",children:e.name}),s.jsx("div",{className:"subordinate-class",children:e.class})]}),s.jsx("div",{className:`subordinate-status status-${e.status}`,children:e.status}),I&&s.jsx("div",{className:"subordinate-badge",children:a("common:status.current")})]},e.id)})}),s.jsx("div",{className:"subordinate-assignment-summary",children:x?s.jsxs("span",{className:"summary-changed",children:[h," → ",E," ",a("terminal:team.subordinates").toLowerCase()]}):s.jsxs("span",{className:"summary-unchanged",children:[h," ",a("terminal:team.subordinates").toLowerCase()]})})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:l,children:a("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-boss",onClick:g,disabled:u||!x,children:a(u?"common:status.saving":"terminal:team.saveTeam")})]})]})})}export{M as SubordinateAssignmentModal};
1
+ import{u as z,I as L,a5 as $,r as m,j as s,a3 as N,C as S,s as D}from"./main-9Cs_hNs-.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function M({isOpen:o,bossId:r,onClose:l}){var j;const{t:a}=z(["terminal","common"]),f=L(),n=$(r),[i,c]=m.useState(new Set),[u,b]=m.useState(!1),d=Array.from(f.values()).filter(e=>e.class!=="boss"&&(!e.bossId||e.bossId===r));m.useEffect(()=>{o&&n&&c(new Set(n.subordinateIds||[]))},[o,n]);const g=()=>{b(!0),D.assignSubordinates(r,Array.from(i)),setTimeout(()=>{b(!1),l()},300)},y=e=>{const t=new Set(i);t.has(e)?t.delete(e):t.add(e),c(t)},A=()=>{c(new Set(d.map(e=>e.id)))},C=()=>{c(new Set)},p=e=>{e.target===e.currentTarget&&l()},w=e=>{e.key==="Escape"&&l()};if(!o||!n)return null;const k=N.boss,h=((j=n.subordinateIds)==null?void 0:j.length)||0,E=i.size,x=JSON.stringify([...n.subordinateIds||[]].sort())!==JSON.stringify([...i].sort());return s.jsx("div",{className:`modal-overlay ${o?"visible":""}`,onClick:p,onKeyDown:w,children:s.jsxs("div",{className:"modal subordinate-assignment-modal",children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("span",{className:"boss-header-icon",style:{color:k.color},children:s.jsx(S,{agent:n,size:22})}),a("terminal:team.manageTeam"),": ",n.name]}),s.jsxs("div",{className:"modal-body subordinate-assignment-body",children:[s.jsxs("div",{className:"subordinate-assignment-info",children:[s.jsx("p",{children:a("terminal:team.selectAgents")}),s.jsxs("div",{className:"subordinate-assignment-actions",children:[s.jsx("button",{className:"btn btn-small",onClick:A,children:a("common:buttons.selectAll")}),s.jsx("button",{className:"btn btn-small",onClick:C,children:a("common:buttons.clearAll")})]})]}),s.jsx("div",{className:"subordinates-list",children:d.length===0?s.jsx("div",{className:"subordinates-empty",children:a("terminal:team.noAgentsAvailable")}):d.map(e=>{var v;const t=i.has(e.id),T=N[e.class],I=(v=n.subordinateIds)==null?void 0:v.includes(e.id);return s.jsxs("div",{className:`subordinate-item ${t?"selected":""}`,onClick:()=>y(e.id),children:[s.jsx("div",{className:"subordinate-checkbox",children:t?"✓":""}),s.jsx("div",{className:"subordinate-icon",style:{color:T.color},children:s.jsx(S,{agent:e,size:18})}),s.jsxs("div",{className:"subordinate-info",children:[s.jsx("div",{className:"subordinate-name",children:e.name}),s.jsx("div",{className:"subordinate-class",children:e.class})]}),s.jsx("div",{className:`subordinate-status status-${e.status}`,children:e.status}),I&&s.jsx("div",{className:"subordinate-badge",children:a("common:status.current")})]},e.id)})}),s.jsx("div",{className:"subordinate-assignment-summary",children:x?s.jsxs("span",{className:"summary-changed",children:[h," → ",E," ",a("terminal:team.subordinates").toLowerCase()]}):s.jsxs("span",{className:"summary-unchanged",children:[h," ",a("terminal:team.subordinates").toLowerCase()]})})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:l,children:a("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-boss",onClick:g,disabled:u||!x,children:a(u?"common:status.saving":"terminal:team.saveTeam")})]})]})})}export{M as SubordinateAssignmentModal};
@@ -1,3 +1,3 @@
1
- import{I as ce,r as n,W as h,l as p,j as e}from"./main-5tHJV1Fa.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const pe=[{value:"webhook",label:"Webhook"},{value:"cron",label:"Cron"},{value:"slack",label:"Slack"},{value:"email",label:"Email"},{value:"jira",label:"Jira"}],xe=[{value:"structural",label:"Structural",desc:"Field-based matching (fast, free)"},{value:"llm",label:"LLM",desc:"Semantic matching via LLM (flexible, costs tokens)"},{value:"hybrid",label:"Hybrid",desc:"Structural pre-filter + LLM (recommended)"}],he=[{value:"structural",label:"Structural"},{value:"llm",label:"LLM"}],w=()=>({name:"",description:"",type:"webhook",agentId:"",promptTemplate:"",enabled:!0,matchMode:"structural",extractionMode:"structural",config:{method:"POST"}});function me({isOpen:C,onClose:E}){var H,U,W,_,J,$,V,G,X,q,Y,K;const T=ce(),[R,Q]=n.useState([]),[y,j]=n.useState("list"),[s,u]=n.useState(w()),[d,S]=n.useState(!1),[F,z]=n.useState(!1),[L,c]=n.useState(null),[O,Z]=n.useState([]),[g,ee]=n.useState(null),[k,te]=n.useState(`{
1
+ import{I as ce,r as n,W as h,l as p,j as e}from"./main-9Cs_hNs-.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const pe=[{value:"webhook",label:"Webhook"},{value:"cron",label:"Cron"},{value:"slack",label:"Slack"},{value:"email",label:"Email"},{value:"jira",label:"Jira"}],xe=[{value:"structural",label:"Structural",desc:"Field-based matching (fast, free)"},{value:"llm",label:"LLM",desc:"Semantic matching via LLM (flexible, costs tokens)"},{value:"hybrid",label:"Hybrid",desc:"Structural pre-filter + LLM (recommended)"}],he=[{value:"structural",label:"Structural"},{value:"llm",label:"LLM"}],w=()=>({name:"",description:"",type:"webhook",agentId:"",promptTemplate:"",enabled:!0,matchMode:"structural",extractionMode:"structural",config:{method:"POST"}});function me({isOpen:C,onClose:E}){var H,U,W,_,J,$,V,G,X,q,Y,K;const T=ce(),[R,Q]=n.useState([]),[y,j]=n.useState("list"),[s,u]=n.useState(w()),[d,S]=n.useState(!1),[F,z]=n.useState(!1),[L,c]=n.useState(null),[O,Z]=n.useState([]),[g,ee]=n.useState(null),[k,te]=n.useState(`{
2
2
 
3
3
  }`),[r,f]=n.useState(null),[B,I]=n.useState(!1),[N,P]=n.useState([]),x=n.useCallback(async()=>{try{const t=await h(p("/api/triggers"));if(t.ok){const a=await t.json();Q(a)}}catch(t){console.error("Failed to load triggers:",t)}},[]),v=n.useCallback(async t=>{try{const a=await h(p(`/api/triggers/${t}/events?limit=20`));if(a.ok){const i=await a.json();Z(i)}}catch(a){console.error("Failed to load trigger history:",a)}},[]);n.useEffect(()=>{C&&x()},[C,x]),n.useEffect(()=>{g&&v(g)},[g,v]);const le=n.useCallback(async()=>{z(!0),c(null);try{const t=d?p(`/api/triggers/${s.id}`):p("/api/triggers"),b=await h(t,{method:d?"PATCH":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!b.ok){const de=await b.json();throw new Error(de.error||"Failed to save trigger")}await x(),j("list"),u(w()),S(!1)}catch(t){c(t instanceof Error?t.message:"Save failed")}finally{z(!1)}},[s,d,x]),ae=n.useCallback(async t=>{try{await h(p(`/api/triggers/${t}`),{method:"DELETE"}),await x()}catch(a){console.error("Failed to delete trigger:",a)}},[x]),se=n.useCallback(async t=>{try{await h(p(`/api/triggers/${t.id}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!t.enabled})}),await x()}catch(a){console.error("Failed to toggle trigger:",a)}},[x]),ie=n.useCallback(async t=>{try{await h(p(`/api/triggers/${t}/fire`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({variables:{}})}),g===t&&await v(t)}catch(a){console.error("Failed to test fire trigger:",a)}},[g,v]),ne=n.useCallback(async()=>{if(s.id){I(!0),f(null);try{let t;try{t=JSON.parse(k)}catch{f({structuralMatch:void 0,extractedVariables:{},wouldFire:!1}),c("Invalid JSON payload");return}const a=await h(p(`/api/triggers/${s.id}/test-match`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({payload:t})});if(a.ok){const i=await a.json();f(i),c(null)}else{const i=await a.json();c(i.error||"Test match failed")}}catch(t){c(t instanceof Error?t.message:"Test match failed")}finally{I(!1)}}},[s.id,k]),re=n.useCallback(async t=>{var a;try{const i=await h(p("/api/triggers/validate-cron"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({expression:t,timezone:((a=s.config)==null?void 0:a.timezone)||"UTC"})});if(i.ok){const b=await i.json();P(b.valid?b.nextFires:[])}}catch{P([])}},[s]),D=n.useCallback(t=>{t?(u({...t}),S(!0)):(u(w()),S(!1)),f(null),c(null),j("edit")},[]),o=n.useCallback((t,a)=>{u(i=>({...i,[t]:a}))},[]),m=n.useCallback((t,a)=>{u(i=>({...i,config:{...i.config,[t]:a}}))},[]),M=n.useCallback((t,a)=>{u(i=>({...i,llmMatch:{...i.llmMatch||{prompt:""},[t]:a}}))},[]),A=n.useCallback((t,a)=>{u(i=>({...i,llmExtract:{...i.llmExtract||{prompt:"",variables:[]},[t]:a}}))},[]),oe=n.useMemo(()=>Array.from(T.values()).map(t=>({id:t.id,name:t.name})),[T]);return C?e.jsx("div",{style:l.overlay,onClick:E,children:e.jsxs("div",{style:l.panel,onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{style:l.header,children:[e.jsx("h2",{style:l.title,children:y==="list"?"Triggers":d?"Edit Trigger":"New Trigger"}),e.jsxs("div",{style:l.headerActions,children:[y==="list"&&e.jsx("button",{style:l.addBtn,onClick:()=>D(),children:"+ New Trigger"}),y==="edit"&&e.jsx("button",{style:l.backBtn,onClick:()=>{j("list"),f(null),c(null)},children:"Back"}),e.jsx("button",{style:l.closeBtn,onClick:E,children:"X"})]})]}),L&&e.jsx("div",{style:l.error,children:L}),y==="list"&&e.jsx("div",{style:l.content,children:R.length===0?e.jsx("div",{style:l.empty,children:"No triggers configured. Create one to get started."}):R.map(t=>{var a;return e.jsxs("div",{style:{...l.triggerCard,borderLeftColor:t.status==="error"?"#e74c3c":t.enabled?"#2ecc71":"#95a5a6"},onClick:()=>{ee(t.id),D(t)},children:[e.jsxs("div",{style:l.cardHeader,children:[e.jsxs("div",{style:l.cardTitle,children:[e.jsx("span",{style:l.typeTag,children:t.type}),e.jsx("span",{children:t.name}),t.matchMode!=="structural"&&e.jsx("span",{style:l.matchTag,children:t.matchMode})]}),e.jsxs("div",{style:l.cardActions,children:[e.jsx("button",{style:l.smallBtn,onClick:i=>{i.stopPropagation(),se(t)},children:t.enabled?"Disable":"Enable"}),e.jsx("button",{style:l.smallBtn,onClick:i=>{i.stopPropagation(),ie(t.id)},children:"Test Fire"}),e.jsx("button",{style:{...l.smallBtn,color:"#e74c3c"},onClick:i=>{i.stopPropagation(),ae(t.id)},children:"Delete"})]})]}),e.jsxs("div",{style:l.cardMeta,children:[e.jsxs("span",{children:["Agent: ",((a=T.get(t.agentId))==null?void 0:a.name)||t.agentId]}),e.jsxs("span",{children:["Fires: ",t.fireCount]}),t.lastFiredAt&&e.jsxs("span",{children:["Last: ",new Date(t.lastFiredAt).toLocaleString()]}),t.status==="error"&&t.lastError&&e.jsxs("span",{style:{color:"#e74c3c"},children:["Error: ",t.lastError]})]})]},t.id)})}),y==="edit"&&e.jsx("div",{style:l.content,children:e.jsxs("div",{style:l.form,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Name"}),e.jsx("input",{style:l.input,value:s.name||"",onChange:t=>o("name",t.target.value),placeholder:"My Trigger"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Description"}),e.jsx("input",{style:l.input,value:s.description||"",onChange:t=>o("description",t.target.value),placeholder:"Optional description"})]}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Type"}),e.jsx("select",{style:l.select,value:s.type||"webhook",onChange:t=>{const a=t.target.value;o("type",a),a==="webhook"?o("config",{method:"POST"}):a==="cron"?o("config",{expression:"0 9 * * MON-FRI",timezone:"UTC"}):o("config",{})},children:pe.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Agent"}),e.jsxs("select",{style:l.select,value:s.agentId||"",onChange:t=>o("agentId",t.target.value),children:[e.jsx("option",{value:"",children:"Select agent..."}),oe.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Prompt Template"}),e.jsx("textarea",{style:l.textarea,value:s.promptTemplate||"",onChange:t=>o("promptTemplate",t.target.value),placeholder:"Message sent to agent. Use {{variable}} for interpolation.",rows:4})]}),s.type==="webhook"&&e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Webhook Config"}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Method"}),e.jsxs("select",{style:l.select,value:((H=s.config)==null?void 0:H.method)||"POST",onChange:t=>m("method",t.target.value),children:[e.jsx("option",{value:"POST",children:"POST"}),e.jsx("option",{value:"PUT",children:"PUT"})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Secret (HMAC)"}),e.jsx("input",{style:l.input,type:"password",value:((U=s.config)==null?void 0:U.secret)||"",onChange:t=>m("secret",t.target.value||void 0),placeholder:"Optional HMAC secret"})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Extract Fields (comma-separated JSON paths)"}),e.jsx("input",{style:l.input,value:((_=(W=s.config)==null?void 0:W.extractFields)==null?void 0:_.join(", "))||"",onChange:t=>m("extractFields",t.target.value.split(",").map(a=>a.trim()).filter(Boolean)),placeholder:"body.release_name, body.version"})]}),d&&s.id&&e.jsxs("div",{style:l.webhookUrl,children:[e.jsx("label",{style:l.label,children:"Webhook URL"}),e.jsx("code",{style:l.code,children:`${window.location.origin}/api/triggers/webhook/${s.id}`})]})]}),s.type==="cron"&&e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Cron Config"}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Expression"}),e.jsx("input",{style:l.input,value:((J=s.config)==null?void 0:J.expression)||"",onChange:t=>{m("expression",t.target.value),t.target.value&&re(t.target.value)},placeholder:"0 9 * * MON-FRI"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Timezone"}),e.jsx("input",{style:l.input,value:(($=s.config)==null?void 0:$.timezone)||"UTC",onChange:t=>m("timezone",t.target.value),placeholder:"America/Mexico_City"})]})]}),N.length>0&&e.jsxs("div",{style:l.nextFires,children:[e.jsx("label",{style:l.label,children:"Next fires:"}),N.map((t,a)=>e.jsx("div",{style:l.nextFireItem,children:new Date(t).toLocaleString()},a))]})]}),e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Match Mode"}),e.jsx("div",{style:l.modeSelector,children:xe.map(t=>e.jsxs("button",{style:{...l.modeBtn,...s.matchMode===t.value?l.modeBtnActive:{}},onClick:()=>o("matchMode",t.value),children:[e.jsx("strong",{children:t.label}),e.jsx("span",{style:l.modeDesc,children:t.desc})]},t.value))}),(s.matchMode==="llm"||s.matchMode==="hybrid")&&e.jsxs("div",{style:l.llmConfig,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"LLM Match Prompt"}),e.jsx("textarea",{style:l.textarea,value:((V=s.llmMatch)==null?void 0:V.prompt)||"",onChange:t=>M("prompt",t.target.value),placeholder:"Does this message request a release deployment?",rows:3})]}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Model"}),e.jsxs("select",{style:l.select,value:((G=s.llmMatch)==null?void 0:G.model)||"haiku",onChange:t=>M("model",t.target.value),children:[e.jsx("option",{value:"haiku",children:"Haiku (fast, cheap)"}),e.jsx("option",{value:"sonnet",children:"Sonnet (balanced)"}),e.jsx("option",{value:"opus",children:"Opus (powerful)"})]})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Min Confidence"}),e.jsx("input",{style:l.input,type:"number",min:"0",max:"1",step:"0.1",value:((X=s.llmMatch)==null?void 0:X.minConfidence)??0,onChange:t=>M("minConfidence",parseFloat(t.target.value))})]})]})]})]}),e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Extraction Mode"}),e.jsx("div",{style:l.row,children:he.map(t=>e.jsx("button",{style:{...l.modeBtn,...s.extractionMode===t.value?l.modeBtnActive:{}},onClick:()=>o("extractionMode",t.value),children:t.label},t.value))}),s.extractionMode==="llm"&&e.jsxs("div",{style:l.llmConfig,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Extraction Instructions"}),e.jsx("textarea",{style:l.textarea,value:((q=s.llmExtract)==null?void 0:q.prompt)||"",onChange:t=>A("prompt",t.target.value),placeholder:"Extract: release version, affected systems, urgency",rows:3})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Variable Names (comma-separated)"}),e.jsx("input",{style:l.input,value:((K=(Y=s.llmExtract)==null?void 0:Y.variables)==null?void 0:K.join(", "))||"",onChange:t=>A("variables",t.target.value.split(",").map(a=>a.trim()).filter(Boolean)),placeholder:"release_name, affected_systems, urgency"})]})]})]}),d&&e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Test Match"}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Sample Event Payload (JSON)"}),e.jsx("textarea",{style:l.textarea,value:k,onChange:t=>te(t.target.value),rows:4})]}),e.jsx("button",{style:l.testBtn,onClick:ne,disabled:B,children:B?"Testing...":"Test Match"}),r&&e.jsxs("div",{style:l.testResult,children:[e.jsx("div",{style:{...l.testResultHeader,color:r.wouldFire?"#2ecc71":"#e74c3c"},children:r.wouldFire?"WOULD FIRE":"WOULD NOT FIRE"}),r.structuralMatch!==void 0&&e.jsxs("div",{children:["Structural: ",r.structuralMatch?"Match":"No match"]}),r.llmMatch&&e.jsxs("div",{style:l.llmResult,children:[e.jsxs("div",{children:["LLM: ",r.llmMatch.match?"Match":"No match"]}),e.jsxs("div",{children:["Confidence: ",(r.llmMatch.confidence*100).toFixed(0),"%"]}),e.jsxs("div",{children:["Reason: ",r.llmMatch.reason]}),e.jsxs("div",{style:l.llmMeta,children:["Model: ",r.llmMatch.model," | Tokens: ",r.llmMatch.tokensUsed," | Latency: ",r.llmMatch.durationMs,"ms"]})]}),Object.keys(r.extractedVariables).length>0&&e.jsxs("div",{children:[e.jsx("div",{style:l.label,children:"Extracted Variables:"}),Object.entries(r.extractedVariables).map(([t,a])=>e.jsxs("div",{style:l.varRow,children:[e.jsx("code",{children:t}),": ",a]},t))]})]})]}),d&&O.length>0&&e.jsxs("div",{style:l.section,children:[e.jsx("h4",{style:l.sectionTitle,children:"Recent Fires"}),e.jsx("div",{style:l.historyList,children:O.map((t,a)=>{const i=t.llm_match_result?JSON.parse(t.llm_match_result):null;return e.jsxs("div",{style:l.historyItem,children:[e.jsxs("div",{style:l.historyHeader,children:[e.jsx("span",{style:{color:t.status==="delivered"?"#2ecc71":t.status==="failed"?"#e74c3c":"#f39c12"},children:t.status}),e.jsx("span",{children:new Date(t.fired_at).toLocaleString()}),t.duration_ms&&e.jsxs("span",{children:[t.duration_ms,"ms"]})]}),t.error&&e.jsx("div",{style:{color:"#e74c3c",fontSize:"12px"},children:t.error}),i&&e.jsxs("div",{style:l.llmMeta,children:["LLM: ",i.match?"match":"no match"," (",(i.confidence*100).toFixed(0),"%) - ",i.reason]})]},t.id||a)})})]}),e.jsxs("div",{style:l.actions,children:[e.jsx("button",{style:l.cancelBtn,onClick:()=>{j("list"),c(null)},children:"Cancel"}),e.jsx("button",{style:l.saveBtn,onClick:le,disabled:F||!s.name||!s.agentId,children:F?"Saving...":d?"Update":"Create"})]})]})})]})}):null}const l={overlay:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},panel:{background:"#1e1e2e",borderRadius:"12px",width:"680px",maxHeight:"85vh",display:"flex",flexDirection:"column",color:"#cdd6f4",boxShadow:"0 8px 32px rgba(0,0,0,0.4)"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:"1px solid #313244"},title:{margin:0,fontSize:"18px",fontWeight:600},headerActions:{display:"flex",gap:"8px"},content:{overflow:"auto",padding:"16px 20px",flex:1},empty:{textAlign:"center",padding:"40px",color:"#6c7086"},error:{background:"#45252a",color:"#f38ba8",padding:"8px 20px",fontSize:"13px"},triggerCard:{background:"#181825",borderRadius:"8px",padding:"12px 16px",marginBottom:"8px",borderLeft:"3px solid",cursor:"pointer",transition:"background 0.15s"},cardHeader:{display:"flex",justifyContent:"space-between",alignItems:"center"},cardTitle:{display:"flex",alignItems:"center",gap:"8px",fontWeight:500},typeTag:{background:"#313244",padding:"2px 6px",borderRadius:"4px",fontSize:"11px",textTransform:"uppercase"},matchTag:{background:"#45475a",padding:"2px 6px",borderRadius:"4px",fontSize:"10px",color:"#a6e3a1"},cardActions:{display:"flex",gap:"6px"},cardMeta:{display:"flex",gap:"16px",marginTop:"8px",fontSize:"12px",color:"#6c7086"},form:{display:"flex",flexDirection:"column",gap:"12px"},field:{display:"flex",flexDirection:"column",gap:"4px",flex:1},row:{display:"flex",gap:"12px"},label:{fontSize:"12px",color:"#a6adc8",fontWeight:500},input:{background:"#313244",border:"1px solid #45475a",borderRadius:"6px",padding:"8px 10px",color:"#cdd6f4",fontSize:"13px",outline:"none"},select:{background:"#313244",border:"1px solid #45475a",borderRadius:"6px",padding:"8px 10px",color:"#cdd6f4",fontSize:"13px",outline:"none"},textarea:{background:"#313244",border:"1px solid #45475a",borderRadius:"6px",padding:"8px 10px",color:"#cdd6f4",fontSize:"13px",outline:"none",fontFamily:"monospace",resize:"vertical"},section:{borderTop:"1px solid #313244",paddingTop:"12px"},sectionTitle:{margin:"0 0 8px",fontSize:"14px",fontWeight:600,color:"#a6adc8"},modeSelector:{display:"flex",gap:"8px",marginBottom:"8px"},modeBtn:{flex:1,background:"#313244",border:"1px solid #45475a",borderRadius:"6px",padding:"8px",color:"#cdd6f4",cursor:"pointer",textAlign:"left",display:"flex",flexDirection:"column",gap:"2px",fontSize:"12px"},modeBtnActive:{borderColor:"#89b4fa",background:"#1e3a5f"},modeDesc:{fontSize:"10px",color:"#6c7086"},llmConfig:{background:"#181825",borderRadius:"6px",padding:"12px",display:"flex",flexDirection:"column",gap:"8px"},webhookUrl:{marginTop:"8px"},code:{background:"#313244",padding:"6px 10px",borderRadius:"4px",fontSize:"12px",display:"block",wordBreak:"break-all",color:"#89b4fa"},nextFires:{marginTop:"8px"},nextFireItem:{fontSize:"12px",color:"#a6e3a1",padding:"2px 0"},testBtn:{background:"#89b4fa",border:"none",borderRadius:"6px",padding:"8px 16px",color:"#1e1e2e",fontWeight:600,cursor:"pointer",fontSize:"13px"},testResult:{background:"#181825",borderRadius:"6px",padding:"12px",marginTop:"8px",fontSize:"13px",display:"flex",flexDirection:"column",gap:"6px"},testResultHeader:{fontWeight:700,fontSize:"14px"},llmResult:{display:"flex",flexDirection:"column",gap:"2px"},llmMeta:{fontSize:"11px",color:"#6c7086",marginTop:"2px"},varRow:{fontSize:"12px",padding:"2px 0"},historyList:{display:"flex",flexDirection:"column",gap:"6px",maxHeight:"200px",overflow:"auto"},historyItem:{background:"#181825",borderRadius:"4px",padding:"8px 10px",fontSize:"12px"},historyHeader:{display:"flex",justifyContent:"space-between",alignItems:"center"},actions:{display:"flex",justifyContent:"flex-end",gap:"8px",marginTop:"16px",paddingTop:"12px",borderTop:"1px solid #313244"},addBtn:{background:"#89b4fa",border:"none",borderRadius:"6px",padding:"6px 14px",color:"#1e1e2e",fontWeight:600,cursor:"pointer",fontSize:"13px"},backBtn:{background:"transparent",border:"1px solid #45475a",borderRadius:"6px",padding:"6px 14px",color:"#cdd6f4",cursor:"pointer",fontSize:"13px"},closeBtn:{background:"transparent",border:"none",color:"#6c7086",cursor:"pointer",fontSize:"16px",padding:"4px 8px"},smallBtn:{background:"transparent",border:"1px solid #45475a",borderRadius:"4px",padding:"3px 8px",color:"#cdd6f4",cursor:"pointer",fontSize:"11px"},saveBtn:{background:"#a6e3a1",border:"none",borderRadius:"6px",padding:"8px 20px",color:"#1e1e2e",fontWeight:600,cursor:"pointer",fontSize:"13px"},cancelBtn:{background:"transparent",border:"1px solid #45475a",borderRadius:"6px",padding:"8px 20px",color:"#cdd6f4",cursor:"pointer",fontSize:"13px"}};export{me as TriggerManagerPanel,me as default};
@@ -1,4 +1,4 @@
1
- import{r as x,W as M,l as P,j as e,I as J}from"./main-5tHJV1Fa.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const H=[{id:"intake",name:"Intake",type:"action",description:"Gather CC details from the developer via Slack",action:{type:"agent_task",agentId:"",promptTemplate:`A developer has requested a new CC (Control de Cambios). Here is their message:
1
+ import{r as x,W as M,l as P,j as e,I as J}from"./main-9Cs_hNs-.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const H=[{id:"intake",name:"Intake",type:"action",description:"Gather CC details from the developer via Slack",action:{type:"agent_task",agentId:"",promptTemplate:`A developer has requested a new CC (Control de Cambios). Here is their message:
2
2
  {{trigger.slack.message}}
3
3
  From: {{trigger.slack.user}} (Slack ID: {{trigger.slack.userId}})
4
4
 
@@ -1 +1 @@
1
- import{z as ts,u as ns,B as _s,j as e,C as Is,E as Ms,G as Es,H as $s,r as g,I as Ds,J as Ss,K as Ls,L as Xs,s as U,n as Z}from"./main-5tHJV1Fa.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Rs=1,gs=Rs*2.5;function Ps(s,v,d){const l=v.filter(o=>o.position&&!isNaN(o.position.x)&&!isNaN(o.position.z));let t,i,n,u;if(s.type==="rectangle"){const o=(s.width||10)/2,b=(s.height||10)/2;t=s.center.x-o,i=s.center.x+o,n=s.center.z-b,u=s.center.z+b}else{const o=s.radius||5;t=s.center.x-o,i=s.center.x+o,n=s.center.z-o,u=s.center.z+o}const p=2;if(t+=p,i-=p,n+=p,u-=p,d){const o={...d};if(o.x=Math.max(t,Math.min(i,o.x)),o.z=Math.max(n,Math.min(u,o.z)),fs(o,l,s))return o}const N=(t+i)/2,S=(n+u)/2,j=Math.min(i-N,u-S);for(let o=0;o<j;o+=gs*.5)for(let b=0;b<Math.PI*2;b+=Math.PI/8){const z=N+Math.cos(b)*o,M=S+Math.sin(b)*o,_={x:z,z:M};if(_.x=Math.max(t,Math.min(i,_.x)),_.z=Math.max(n,Math.min(u,_.z)),fs(_,l,s))return _}return{x:N,z:S}}function fs(s,v,d){for(const l of v){if(!l.position)continue;if(Math.hypot(s.x-l.position.x,s.z-l.position.z)<gs)return!1}if(d.type==="rectangle"){const l=(d.width||10)/2,t=(d.height||10)/2,i=s.x>=d.center.x-l+1&&s.x<=d.center.x+l-1,n=s.z>=d.center.z-t+1&&s.z<=d.center.z+t-1;return i&&n}else{const l=(d.radius||5)-1;return Math.hypot(s.x-d.center.x,s.z-d.center.z)<=l}}function vs(s){switch(s){case"idle":case"running":return"healthy";case"working":case"waiting":case"waiting_permission":case"starting":case"stopping":return"working";case"error":case"offline":case"orphaned":case"stopped":return"error";default:return"unknown"}}function Us(s){switch(s){case"server":return"🖥️";case"link":return"🔗";case"database":return"🗄️";case"docker":return"🐳";case"monitor":return"📊";case"folder":return"📁";case"boss":return"🏰";default:return"🏢"}}function Ys(s,v){const d=[],l=new Set;for(const i of v.values()){if(i.archived)continue;const n=[];for(const u of i.assignedAgentIds){const p=s.get(u);p&&(n.push(p),l.add(u))}d.push({area:i,agents:n,label:i.name,color:i.color})}d.sort((i,n)=>i.label.localeCompare(n.label));const t=[];for(const i of s.values())l.has(i.id)||t.push(i);return t.length>0&&d.push({area:null,agents:t,label:"Unassigned",color:"#555"}),d}function Gs(s,v){const d=[],l=[],t=[];for(const n of s.values())n.status==="working"||n.status==="waiting"||n.status==="waiting_permission"?d.push(n):n.status==="error"||n.status==="offline"||n.status==="orphaned"?t.push(n):v&&v.has(n.id)?d.push(n):l.push(n);const i=[];return t.length>0&&i.push({area:null,agents:t,label:"Errors",color:"#d64545"}),d.length>0&&i.push({area:null,agents:d,label:"Working & Unseen",color:"#f5d76e"}),l.length>0&&i.push({area:null,agents:l,label:"Idle",color:"#5cb88a"}),i}function Hs(s){const v=Date.now(),l=[...Array.from(s.values())].sort((o,b)=>(b.lastActivity||0)-(o.lastActivity||0)),t=[],i=[],n=[],u=[],p=300*1e3,N=3600*1e3,S=1440*60*1e3;for(const o of l){const b=v-(o.lastActivity||0);b<p?t.push(o):b<N?i.push(o):b<S?n.push(o):u.push(o)}const j=[];return t.length>0&&j.push({area:null,agents:t,label:"Just Now (< 5m)",color:"#4ade80"}),i.length>0&&j.push({area:null,agents:i,label:"Recent (5m - 1h)",color:"#60a5fa"}),n.length>0&&j.push({area:null,agents:n,label:"Stale (1h - 1d)",color:"#facc15"}),u.length>0&&j.push({area:null,agents:u,label:"Very Stale (> 1d)",color:"#f87171"}),j}function Zs(s){return s.contextLimit<=0?0:Math.round(s.contextUsed/s.contextLimit*100)}function Bs(s){return s>=80?"red":s>=50?"yellow":"green"}function ms(s){return as(s)}function as(s,v={}){const{prioritizeRecentlyIdle:d=!1}=v;return[...s].sort((l,t)=>{const i={error:0,offline:0,orphaned:0,working:1,waiting:1,waiting_permission:1,idle:2},n=i[l.status]??3,u=i[t.status]??3;if(n!==u)return n-u;if(d&&l.status==="idle"&&t.status==="idle"){const p=!!l.taskLabel,N=!!t.taskLabel;return p!==N?p?-1:1:(t.lastActivity||0)-(l.lastActivity||0)}return l.name.localeCompare(t.name)})}const ps=ts.memo(({agent:s,isSelected:v,isKeyboardFocused:d=!1,onSelect:l,onDoubleClick:t,onChat:i,onFocus:n,onKill:u,onDragStart:p})=>{const{t:N}=ns(["dashboard","common"]),j=_s().has(s.id),o=vs(s.status),b=Zs(s),z=Bs(b),M=s.taskLabel?`📋 ${s.taskLabel}`:s.currentTask||s.lastAssignedTask,_=s.status==="idle"&&s.lastActivity>0,[,B]=ts.useState(0);return ts.useEffect(()=>{if(!_)return;const A=window.setInterval(()=>B(q=>q+1),15e3);return()=>window.clearInterval(A)},[_]),e.jsxs("div",{className:`dash-card dash-card--${o} ${v?"dash-card--selected":""} ${d?"dash-card--keyboard-focused":""}`,"data-agent-id":s.id,onClick:l,onDoubleClick:A=>{A.stopPropagation(),t()},onDragStart:A=>{p==null||p(s),A.dataTransfer.effectAllowed="move"},draggable:!0,title:N("cards.doubleClickHint"),children:[e.jsxs("div",{className:"dash-card__row1",children:[e.jsx("span",{className:`dash-card__status-dot dash-card__status-dot--${o}`}),e.jsx("span",{className:"dash-card__name",children:s.name}),e.jsxs("span",{className:"dash-card__class",children:[e.jsx(Is,{agent:s,size:14})," ",s.class]}),e.jsxs("span",{className:`dash-card__provider dash-card__provider--${s.provider}`,children:[s.provider==="codex"?"🔸":s.provider==="opencode"?"🟢":"🤖"," ",s.provider]}),j&&e.jsx("span",{className:"dash-card__unseen-badge",title:"New output available - click to view",children:"!"})]}),e.jsxs("div",{className:"dash-card__row2",children:[e.jsx("span",{className:`dash-card__status dash-card__status--${o}`,children:j?"Unseen":s.status}),e.jsxs("div",{className:"dash-card__context",children:[e.jsx("div",{className:"dash-card__context-bar",children:e.jsx("div",{className:`dash-card__context-fill dash-card__context-fill--${z}`,style:{width:`${b}%`}})}),e.jsxs("span",{className:`dash-card__context-pct dash-card__context-pct--${z}`,children:[b,"%"]})]})]}),e.jsxs("div",{className:"dash-card__row3",children:[e.jsxs("span",{className:"dash-card__workdir",title:s.cwd,children:["📁 ",s.cwd.split("/").pop()||s.cwd]}),_&&e.jsxs("span",{className:"dash-card__idle-time",style:{color:$s(s.lastActivity)},title:Es(s.lastActivity),children:["⏱ ",Ms(s.lastActivity)]})]}),M&&e.jsx("div",{className:"dash-card__row4",children:e.jsx("span",{className:"dash-card__task",children:M})}),e.jsxs("div",{className:"dash-card__actions",children:[i&&e.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--chat",onClick:A=>{A.stopPropagation(),i()},title:N("cards.openTerminal"),children:N("cards.chat")}),u&&e.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--danger",onClick:A=>{A.stopPropagation(),u()},title:N("cards.killAgent"),children:N("cards.stop")})]})]})});ps.displayName="AgentCard";const bs=({buildings:s,onSelectBuilding:v})=>{const{t:d}=ns(["dashboard"]),l=g.useMemo(()=>Array.from(s.values()).sort((t,i)=>t.name.localeCompare(i.name)),[s]);return e.jsxs("div",{className:"dashboard-view__buildings",children:[e.jsxs("div",{className:"dashboard-view__buildings-header",children:[e.jsx("span",{className:"dashboard-view__buildings-title",children:d("buildings.title")}),e.jsx("span",{className:"dashboard-view__buildings-count",children:l.length})]}),e.jsx("div",{className:"dashboard-view__buildings-row",children:l.map(t=>{const i=vs(t.status),n=Us(t.type);return e.jsxs("button",{className:`dash-pill dash-pill--${i}`,onClick:()=>v==null?void 0:v(t.id),title:`${t.name} (${t.type}) - ${t.status}`,children:[e.jsx("span",{className:"dash-pill__icon",children:n}),e.jsx("span",{className:"dash-pill__name",children:t.name}),e.jsx("span",{className:`dash-pill__dot dash-pill__dot--${i}`})]},t.id)})})]})};bs.displayName="BuildingPills";function Ks({onSelectAgent:s,onFocusAgent:v,onKillAgent:d,onSelectBuilding:l,onOpenTerminal:t,onFocusZone:i}){const{t:n}=ns(["dashboard","common"]),u=Ds(),p=Ss(),N=Ls(),S=Xs(),j=_s(),[o,b]=g.useState(""),[z,M]=g.useState("all"),[_,B]=g.useState("zone"),[A,q]=g.useState(new Set),[E,J]=g.useState(null),[ws,T]=g.useState(null),[Y,Q]=g.useState(!1),[I,F]=g.useState(null),V=g.useMemo(()=>{const a=Array.from(u.values());return{total:a.length,working:a.filter(h=>h.status==="working"||h.status==="waiting"||h.status==="waiting_permission").length,idle:a.filter(h=>h.status==="idle").length,error:a.filter(h=>h.status==="error"||h.status==="offline"||h.status==="orphaned").length}},[u]),rs=g.useMemo(()=>_==="zone"?Ys(u,N):_==="status"?Gs(u,j):Hs(u),[u,N,_,j]),W=g.useMemo(()=>{const a=o.toLowerCase().trim(),h=rs.map(w=>({...w,agents:w.agents.filter(k=>{if(z==="working"){if(k.status!=="working"&&k.status!=="waiting"&&k.status!=="waiting_permission")return!1}else if(z==="error"&&k.status!=="error"&&k.status!=="offline"&&k.status!=="orphaned")return!1;return!(a&&!k.name.toLowerCase().includes(a)&&!k.class.toLowerCase().includes(a))})}));return _==="zone"?h:h.filter(w=>w.agents.length>0)},[rs,z,o,_]),O=g.useCallback(a=>a.area?`area:${a.area.id}`:`${_}:${a.label}`,[_]),$=g.useMemo(()=>{const a=[];return W.forEach(h=>{const w=O(h);if(A.has(w))return;const k=_==="status"?as(h.agents,{prioritizeRecentlyIdle:!0}):ms(h.agents);a.push(...k)}),a},[W,A,_,O]),xs=g.useCallback(a=>{q(h=>{const w=new Set(h);return w.has(a)?w.delete(a):w.add(a),w})},[]),Ns=g.useCallback(a=>{t==null||t(a)},[t]),ks=g.useCallback(a=>{J(a)},[]),js=g.useCallback((a,h)=>{a.preventDefault(),a.dataTransfer.dropEffect="move",T(h)},[]),ys=g.useCallback(()=>{T(null)},[]),As=g.useCallback(a=>{if(!E)return;if(a===null){const X=U.getState(),r=Array.from(X.areas.values()).find(c=>c.assignedAgentIds.includes(E.id));r&&U.unassignAgentFromArea(E.id,r.id),J(null),T(null);return}const h=N.get(a);if(!h)return;const w=Array.from(u.values()),k=Ps(h,w,E.position);U.updateAgent({...E,position:{...E.position,x:k.x,z:k.z}}),U.assignAgentToArea(E.id,a),J(null),T(null)},[E,N,u]);return g.useEffect(()=>{if($.length===0){Q(!1),F(null);return}Y&&(!I||!$.some(a=>a.id===I))&&(F($[0].id),s==null||s($[0].id))},[$,Y,I,s]),g.useEffect(()=>{const a=r=>r instanceof HTMLElement?r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.tagName==="SELECT"||r.isContentEditable:!1,h=r=>r instanceof HTMLElement?!!r.closest(".guake-terminal")||r.classList.contains("guake-input")||r.classList.contains("agent-panel-input"):!1,w=r=>{const c=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).find(L=>L.dataset.agentId===r);c==null||c.scrollIntoView({block:"nearest",inline:"nearest"})},k=(r,c)=>{var os,cs,ds,ls,us,hs;const L=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).map(f=>{const x=f.dataset.agentId;if(!x)return null;const D=f.getBoundingClientRect();return{id:x,centerX:D.left+D.width/2,centerY:D.top+D.height/2,height:D.height}}).filter(f=>f!==null).sort((f,x)=>f.centerY-x.centerY||f.centerX-x.centerX);if(L.length===0)return r;const ss=L.reduce((f,x)=>f+x.height,0)/L.length,es=Math.max(18,ss*.6),C=[];for(const f of L){const x=C[C.length-1];if(!x){C.push([{id:f.id,centerX:f.centerX,centerY:f.centerY}]);continue}const D=x.reduce((Cs,zs)=>Cs+zs.centerY,0)/x.length;Math.abs(f.centerY-D)<=es?x.push({id:f.id,centerX:f.centerX,centerY:f.centerY}):C.push([{id:f.id,centerX:f.centerX,centerY:f.centerY}])}C.forEach(f=>f.sort((x,D)=>x.centerX-D.centerX));const G=C.findIndex(f=>f.some(x=>x.id===r));if(G===-1)return((cs=(os=C[0])==null?void 0:os[0])==null?void 0:cs.id)??r;const R=C[G],y=R.findIndex(f=>f.id===r);if(y===-1)return((ls=(ds=C[0])==null?void 0:ds[0])==null?void 0:ls.id)??r;if(c==="left")return((us=R[Math.max(0,y-1)])==null?void 0:us.id)??r;if(c==="right")return((hs=R[Math.min(R.length-1,y+1)])==null?void 0:hs.id)??r;const K=c==="up"?Math.max(0,G-1):Math.min(C.length-1,G+1),m=C[K],H=R[y].centerX;let P=m[0],is=Math.abs(P.centerX-H);for(const f of m){const x=Math.abs(f.centerX-H);x<is&&(P=f,is=x)}return(P==null?void 0:P.id)??r},X=r=>{const c=U.getShortcuts(),L=c.find(m=>m.id==="dashboard-selector-toggle"),ss=c.find(m=>m.id==="dashboard-vim-left"),es=c.find(m=>m.id==="dashboard-vim-down"),C=c.find(m=>m.id==="dashboard-vim-up"),G=c.find(m=>m.id==="dashboard-vim-right"),R=c.find(m=>m.id==="open-terminal"),y=U.getState();if(a(r.target))if(!y.terminalOpen&&h(r.target)&&document.activeElement instanceof HTMLElement)document.activeElement.blur();else return;if(Z(r,L)){if($.length===0)return;r.preventDefault(),r.stopPropagation(),Q(!0),F(m=>{const H=m&&$.some(P=>P.id===m)?m:$[0].id;return s==null||s(H),window.setTimeout(()=>w(H),0),H});return}const K=Z(r,ss)||r.key==="ArrowLeft"?"left":Z(r,es)||r.key==="ArrowDown"?"down":Z(r,C)||r.key==="ArrowUp"?"up":Z(r,G)||r.key==="ArrowRight"?"right":null;if(K&&Y&&I){r.preventDefault(),r.stopPropagation();const m=k(I,K);m!==I&&(F(m),s==null||s(m),window.setTimeout(()=>w(m),0));return}if(Z(r,R)){if(y.terminalOpen)return;if(Y&&I&&y.agents.has(I)){r.preventDefault(),t==null||t(I);return}if(y.selectedAgentIds.size===1){r.preventDefault();const m=Array.from(y.selectedAgentIds)[0];t==null||t(m);return}if(y.lastSelectedAgentId&&y.agents.has(y.lastSelectedAgentId)){r.preventDefault(),t==null||t(y.lastSelectedAgentId);return}}};return document.addEventListener("keydown",X,!0),()=>document.removeEventListener("keydown",X,!0)},[$,Y,I,t,s]),g.useEffect(()=>{const a=document.activeElement;a instanceof HTMLElement&&a.closest(".guake-terminal")&&!U.getState().terminalOpen&&a.blur()},[]),e.jsxs("div",{className:"dashboard-view",children:[e.jsxs("div",{className:"dashboard-view__topbar",children:[e.jsxs("div",{className:"dashboard-view__metrics",children:[e.jsxs("button",{className:`dashboard-view__metric-btn ${z==="all"?"dashboard-view__metric-btn--active":""}`,onClick:()=>M("all"),children:[e.jsx("span",{className:"dashboard-view__metric-value",children:V.total}),e.jsx("span",{className:"dashboard-view__metric-label",children:n("common:labels.agents")})]}),e.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--working ${z==="working"?"dashboard-view__metric-btn--active":""}`,onClick:()=>M("working"),children:[e.jsx("span",{className:"dashboard-view__metric-value",children:V.working}),e.jsx("span",{className:"dashboard-view__metric-label",children:n("common:status.working")})]}),e.jsxs("button",{className:"dashboard-view__metric-btn dashboard-view__metric-btn--idle ",onClick:()=>M("all"),children:[e.jsx("span",{className:"dashboard-view__metric-value",children:V.idle}),e.jsx("span",{className:"dashboard-view__metric-label",children:n("common:status.idle")})]}),e.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--error ${z==="error"?"dashboard-view__metric-btn--active":""}`,onClick:()=>M("error"),children:[e.jsx("span",{className:"dashboard-view__metric-value",children:V.error}),e.jsx("span",{className:"dashboard-view__metric-label",children:n("common:status.error")})]})]}),e.jsx("input",{className:"dashboard-view__search",type:"text",placeholder:n("searchPlaceholder"),value:o,onChange:a=>b(a.target.value)})]}),e.jsxs("div",{className:"dashboard-view__grouping",children:[e.jsx("button",{className:`dashboard-view__grouping-btn ${_==="zone"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>B("zone"),children:n("grouping.byZone")}),e.jsx("button",{className:`dashboard-view__grouping-btn ${_==="status"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>B("status"),children:n("grouping.byStatus")}),e.jsx("button",{className:`dashboard-view__grouping-btn ${_==="activity"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>B("activity"),children:n("grouping.byActivity")})]}),e.jsxs("div",{className:"dashboard-view__content",children:[W.map(a=>{const h=O(a),w=A.has(h),k=_==="status"?as(a.agents,{prioritizeRecentlyIdle:!0}):ms(a.agents),X=a.agents.filter(c=>c.status==="working"||c.status==="waiting"||c.status==="waiting_permission").length,r=a.agents.filter(c=>j.has(c.id)).length;return e.jsxs("div",{className:`dashboard-view__zone ${ws===(a.area?a.area.id:null)&&E?"dashboard-view__zone--drag-over":""}`,onDragOver:c=>js(c,a.area?a.area.id:null),onDragLeave:ys,onDrop:()=>As(a.area?a.area.id:null),children:[e.jsxs("div",{className:"dashboard-view__zone-header",onClick:()=>xs(h),children:[e.jsxs("div",{className:"dashboard-view__zone-left",children:[e.jsx("span",{className:`dashboard-view__zone-chevron ${w?"dashboard-view__zone-chevron--collapsed":""}`,children:"▼"}),e.jsx("span",{className:"dashboard-view__zone-dot",style:{backgroundColor:a.color}}),e.jsx("span",{className:"dashboard-view__zone-name",children:a.label}),e.jsxs("span",{className:"dashboard-view__zone-count",children:[n("agentCount",{count:a.agents.length}),X>0&&e.jsxs("span",{className:"dashboard-view__zone-working",children:[" · ",X," ",n("working")]}),r>0&&e.jsxs("span",{className:"dashboard-view__zone-unseen",children:[" · ",r," Unseen"]})]})]}),a.area&&i&&e.jsx("button",{className:"dashboard-view__zone-focus",onClick:c=>{c.stopPropagation(),i(a.area.id)},title:n("focusZone"),children:n("focusZone")})]}),!w&&e.jsx("div",{className:"dashboard-view__zone-grid",children:k.map(c=>e.jsx(ps,{agent:c,isSelected:S.has(c.id),isKeyboardFocused:Y&&I===c.id,onSelect:()=>{s==null||s(c.id),Q(!0),F(c.id)},onDoubleClick:()=>Ns(c.id),onChat:()=>t==null?void 0:t(c.id),onFocus:v?()=>v(c.id):void 0,onKill:d?()=>d(c.id):void 0,onDragStart:ks},c.id))})]},h)}),W.length===0&&e.jsx("div",{className:"dashboard-view__empty",children:o?n("noAgentsMatching",{search:o}):n("noAgentsSpawned")}),p.size>0&&e.jsx(bs,{buildings:p,onSelectBuilding:l})]})]})}export{Ks as DashboardView};
1
+ import{z as ts,u as ns,B as _s,j as e,C as Is,E as Ms,G as Es,H as $s,r as g,I as Ds,J as Ss,K as Ls,L as Xs,s as U,n as Z}from"./main-9Cs_hNs-.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Rs=1,gs=Rs*2.5;function Ps(s,v,d){const l=v.filter(o=>o.position&&!isNaN(o.position.x)&&!isNaN(o.position.z));let t,i,n,u;if(s.type==="rectangle"){const o=(s.width||10)/2,b=(s.height||10)/2;t=s.center.x-o,i=s.center.x+o,n=s.center.z-b,u=s.center.z+b}else{const o=s.radius||5;t=s.center.x-o,i=s.center.x+o,n=s.center.z-o,u=s.center.z+o}const p=2;if(t+=p,i-=p,n+=p,u-=p,d){const o={...d};if(o.x=Math.max(t,Math.min(i,o.x)),o.z=Math.max(n,Math.min(u,o.z)),fs(o,l,s))return o}const N=(t+i)/2,S=(n+u)/2,j=Math.min(i-N,u-S);for(let o=0;o<j;o+=gs*.5)for(let b=0;b<Math.PI*2;b+=Math.PI/8){const z=N+Math.cos(b)*o,M=S+Math.sin(b)*o,_={x:z,z:M};if(_.x=Math.max(t,Math.min(i,_.x)),_.z=Math.max(n,Math.min(u,_.z)),fs(_,l,s))return _}return{x:N,z:S}}function fs(s,v,d){for(const l of v){if(!l.position)continue;if(Math.hypot(s.x-l.position.x,s.z-l.position.z)<gs)return!1}if(d.type==="rectangle"){const l=(d.width||10)/2,t=(d.height||10)/2,i=s.x>=d.center.x-l+1&&s.x<=d.center.x+l-1,n=s.z>=d.center.z-t+1&&s.z<=d.center.z+t-1;return i&&n}else{const l=(d.radius||5)-1;return Math.hypot(s.x-d.center.x,s.z-d.center.z)<=l}}function vs(s){switch(s){case"idle":case"running":return"healthy";case"working":case"waiting":case"waiting_permission":case"starting":case"stopping":return"working";case"error":case"offline":case"orphaned":case"stopped":return"error";default:return"unknown"}}function Us(s){switch(s){case"server":return"🖥️";case"link":return"🔗";case"database":return"🗄️";case"docker":return"🐳";case"monitor":return"📊";case"folder":return"📁";case"boss":return"🏰";default:return"🏢"}}function Ys(s,v){const d=[],l=new Set;for(const i of v.values()){if(i.archived)continue;const n=[];for(const u of i.assignedAgentIds){const p=s.get(u);p&&(n.push(p),l.add(u))}d.push({area:i,agents:n,label:i.name,color:i.color})}d.sort((i,n)=>i.label.localeCompare(n.label));const t=[];for(const i of s.values())l.has(i.id)||t.push(i);return t.length>0&&d.push({area:null,agents:t,label:"Unassigned",color:"#555"}),d}function Gs(s,v){const d=[],l=[],t=[];for(const n of s.values())n.status==="working"||n.status==="waiting"||n.status==="waiting_permission"?d.push(n):n.status==="error"||n.status==="offline"||n.status==="orphaned"?t.push(n):v&&v.has(n.id)?d.push(n):l.push(n);const i=[];return t.length>0&&i.push({area:null,agents:t,label:"Errors",color:"#d64545"}),d.length>0&&i.push({area:null,agents:d,label:"Working & Unseen",color:"#f5d76e"}),l.length>0&&i.push({area:null,agents:l,label:"Idle",color:"#5cb88a"}),i}function Hs(s){const v=Date.now(),l=[...Array.from(s.values())].sort((o,b)=>(b.lastActivity||0)-(o.lastActivity||0)),t=[],i=[],n=[],u=[],p=300*1e3,N=3600*1e3,S=1440*60*1e3;for(const o of l){const b=v-(o.lastActivity||0);b<p?t.push(o):b<N?i.push(o):b<S?n.push(o):u.push(o)}const j=[];return t.length>0&&j.push({area:null,agents:t,label:"Just Now (< 5m)",color:"#4ade80"}),i.length>0&&j.push({area:null,agents:i,label:"Recent (5m - 1h)",color:"#60a5fa"}),n.length>0&&j.push({area:null,agents:n,label:"Stale (1h - 1d)",color:"#facc15"}),u.length>0&&j.push({area:null,agents:u,label:"Very Stale (> 1d)",color:"#f87171"}),j}function Zs(s){return s.contextLimit<=0?0:Math.round(s.contextUsed/s.contextLimit*100)}function Bs(s){return s>=80?"red":s>=50?"yellow":"green"}function ms(s){return as(s)}function as(s,v={}){const{prioritizeRecentlyIdle:d=!1}=v;return[...s].sort((l,t)=>{const i={error:0,offline:0,orphaned:0,working:1,waiting:1,waiting_permission:1,idle:2},n=i[l.status]??3,u=i[t.status]??3;if(n!==u)return n-u;if(d&&l.status==="idle"&&t.status==="idle"){const p=!!l.taskLabel,N=!!t.taskLabel;return p!==N?p?-1:1:(t.lastActivity||0)-(l.lastActivity||0)}return l.name.localeCompare(t.name)})}const ps=ts.memo(({agent:s,isSelected:v,isKeyboardFocused:d=!1,onSelect:l,onDoubleClick:t,onChat:i,onFocus:n,onKill:u,onDragStart:p})=>{const{t:N}=ns(["dashboard","common"]),j=_s().has(s.id),o=vs(s.status),b=Zs(s),z=Bs(b),M=s.taskLabel?`📋 ${s.taskLabel}`:s.currentTask||s.lastAssignedTask,_=s.status==="idle"&&s.lastActivity>0,[,B]=ts.useState(0);return ts.useEffect(()=>{if(!_)return;const A=window.setInterval(()=>B(q=>q+1),15e3);return()=>window.clearInterval(A)},[_]),e.jsxs("div",{className:`dash-card dash-card--${o} ${v?"dash-card--selected":""} ${d?"dash-card--keyboard-focused":""}`,"data-agent-id":s.id,onClick:l,onDoubleClick:A=>{A.stopPropagation(),t()},onDragStart:A=>{p==null||p(s),A.dataTransfer.effectAllowed="move"},draggable:!0,title:N("cards.doubleClickHint"),children:[e.jsxs("div",{className:"dash-card__row1",children:[e.jsx("span",{className:`dash-card__status-dot dash-card__status-dot--${o}`}),e.jsx("span",{className:"dash-card__name",children:s.name}),e.jsxs("span",{className:"dash-card__class",children:[e.jsx(Is,{agent:s,size:14})," ",s.class]}),e.jsxs("span",{className:`dash-card__provider dash-card__provider--${s.provider}`,children:[s.provider==="codex"?"🔸":s.provider==="opencode"?"🟢":"🤖"," ",s.provider]}),j&&e.jsx("span",{className:"dash-card__unseen-badge",title:"New output available - click to view",children:"!"})]}),e.jsxs("div",{className:"dash-card__row2",children:[e.jsx("span",{className:`dash-card__status dash-card__status--${o}`,children:j?"Unseen":s.status}),e.jsxs("div",{className:"dash-card__context",children:[e.jsx("div",{className:"dash-card__context-bar",children:e.jsx("div",{className:`dash-card__context-fill dash-card__context-fill--${z}`,style:{width:`${b}%`}})}),e.jsxs("span",{className:`dash-card__context-pct dash-card__context-pct--${z}`,children:[b,"%"]})]})]}),e.jsxs("div",{className:"dash-card__row3",children:[e.jsxs("span",{className:"dash-card__workdir",title:s.cwd,children:["📁 ",s.cwd.split("/").pop()||s.cwd]}),_&&e.jsxs("span",{className:"dash-card__idle-time",style:{color:$s(s.lastActivity)},title:Es(s.lastActivity),children:["⏱ ",Ms(s.lastActivity)]})]}),M&&e.jsx("div",{className:"dash-card__row4",children:e.jsx("span",{className:"dash-card__task",children:M})}),e.jsxs("div",{className:"dash-card__actions",children:[i&&e.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--chat",onClick:A=>{A.stopPropagation(),i()},title:N("cards.openTerminal"),children:N("cards.chat")}),u&&e.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--danger",onClick:A=>{A.stopPropagation(),u()},title:N("cards.killAgent"),children:N("cards.stop")})]})]})});ps.displayName="AgentCard";const bs=({buildings:s,onSelectBuilding:v})=>{const{t:d}=ns(["dashboard"]),l=g.useMemo(()=>Array.from(s.values()).sort((t,i)=>t.name.localeCompare(i.name)),[s]);return e.jsxs("div",{className:"dashboard-view__buildings",children:[e.jsxs("div",{className:"dashboard-view__buildings-header",children:[e.jsx("span",{className:"dashboard-view__buildings-title",children:d("buildings.title")}),e.jsx("span",{className:"dashboard-view__buildings-count",children:l.length})]}),e.jsx("div",{className:"dashboard-view__buildings-row",children:l.map(t=>{const i=vs(t.status),n=Us(t.type);return e.jsxs("button",{className:`dash-pill dash-pill--${i}`,onClick:()=>v==null?void 0:v(t.id),title:`${t.name} (${t.type}) - ${t.status}`,children:[e.jsx("span",{className:"dash-pill__icon",children:n}),e.jsx("span",{className:"dash-pill__name",children:t.name}),e.jsx("span",{className:`dash-pill__dot dash-pill__dot--${i}`})]},t.id)})})]})};bs.displayName="BuildingPills";function Ks({onSelectAgent:s,onFocusAgent:v,onKillAgent:d,onSelectBuilding:l,onOpenTerminal:t,onFocusZone:i}){const{t:n}=ns(["dashboard","common"]),u=Ds(),p=Ss(),N=Ls(),S=Xs(),j=_s(),[o,b]=g.useState(""),[z,M]=g.useState("all"),[_,B]=g.useState("zone"),[A,q]=g.useState(new Set),[E,J]=g.useState(null),[ws,T]=g.useState(null),[Y,Q]=g.useState(!1),[I,F]=g.useState(null),V=g.useMemo(()=>{const a=Array.from(u.values());return{total:a.length,working:a.filter(h=>h.status==="working"||h.status==="waiting"||h.status==="waiting_permission").length,idle:a.filter(h=>h.status==="idle").length,error:a.filter(h=>h.status==="error"||h.status==="offline"||h.status==="orphaned").length}},[u]),rs=g.useMemo(()=>_==="zone"?Ys(u,N):_==="status"?Gs(u,j):Hs(u),[u,N,_,j]),W=g.useMemo(()=>{const a=o.toLowerCase().trim(),h=rs.map(w=>({...w,agents:w.agents.filter(k=>{if(z==="working"){if(k.status!=="working"&&k.status!=="waiting"&&k.status!=="waiting_permission")return!1}else if(z==="error"&&k.status!=="error"&&k.status!=="offline"&&k.status!=="orphaned")return!1;return!(a&&!k.name.toLowerCase().includes(a)&&!k.class.toLowerCase().includes(a))})}));return _==="zone"?h:h.filter(w=>w.agents.length>0)},[rs,z,o,_]),O=g.useCallback(a=>a.area?`area:${a.area.id}`:`${_}:${a.label}`,[_]),$=g.useMemo(()=>{const a=[];return W.forEach(h=>{const w=O(h);if(A.has(w))return;const k=_==="status"?as(h.agents,{prioritizeRecentlyIdle:!0}):ms(h.agents);a.push(...k)}),a},[W,A,_,O]),xs=g.useCallback(a=>{q(h=>{const w=new Set(h);return w.has(a)?w.delete(a):w.add(a),w})},[]),Ns=g.useCallback(a=>{t==null||t(a)},[t]),ks=g.useCallback(a=>{J(a)},[]),js=g.useCallback((a,h)=>{a.preventDefault(),a.dataTransfer.dropEffect="move",T(h)},[]),ys=g.useCallback(()=>{T(null)},[]),As=g.useCallback(a=>{if(!E)return;if(a===null){const X=U.getState(),r=Array.from(X.areas.values()).find(c=>c.assignedAgentIds.includes(E.id));r&&U.unassignAgentFromArea(E.id,r.id),J(null),T(null);return}const h=N.get(a);if(!h)return;const w=Array.from(u.values()),k=Ps(h,w,E.position);U.updateAgent({...E,position:{...E.position,x:k.x,z:k.z}}),U.assignAgentToArea(E.id,a),J(null),T(null)},[E,N,u]);return g.useEffect(()=>{if($.length===0){Q(!1),F(null);return}Y&&(!I||!$.some(a=>a.id===I))&&(F($[0].id),s==null||s($[0].id))},[$,Y,I,s]),g.useEffect(()=>{const a=r=>r instanceof HTMLElement?r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.tagName==="SELECT"||r.isContentEditable:!1,h=r=>r instanceof HTMLElement?!!r.closest(".guake-terminal")||r.classList.contains("guake-input")||r.classList.contains("agent-panel-input"):!1,w=r=>{const c=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).find(L=>L.dataset.agentId===r);c==null||c.scrollIntoView({block:"nearest",inline:"nearest"})},k=(r,c)=>{var os,cs,ds,ls,us,hs;const L=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).map(f=>{const x=f.dataset.agentId;if(!x)return null;const D=f.getBoundingClientRect();return{id:x,centerX:D.left+D.width/2,centerY:D.top+D.height/2,height:D.height}}).filter(f=>f!==null).sort((f,x)=>f.centerY-x.centerY||f.centerX-x.centerX);if(L.length===0)return r;const ss=L.reduce((f,x)=>f+x.height,0)/L.length,es=Math.max(18,ss*.6),C=[];for(const f of L){const x=C[C.length-1];if(!x){C.push([{id:f.id,centerX:f.centerX,centerY:f.centerY}]);continue}const D=x.reduce((Cs,zs)=>Cs+zs.centerY,0)/x.length;Math.abs(f.centerY-D)<=es?x.push({id:f.id,centerX:f.centerX,centerY:f.centerY}):C.push([{id:f.id,centerX:f.centerX,centerY:f.centerY}])}C.forEach(f=>f.sort((x,D)=>x.centerX-D.centerX));const G=C.findIndex(f=>f.some(x=>x.id===r));if(G===-1)return((cs=(os=C[0])==null?void 0:os[0])==null?void 0:cs.id)??r;const R=C[G],y=R.findIndex(f=>f.id===r);if(y===-1)return((ls=(ds=C[0])==null?void 0:ds[0])==null?void 0:ls.id)??r;if(c==="left")return((us=R[Math.max(0,y-1)])==null?void 0:us.id)??r;if(c==="right")return((hs=R[Math.min(R.length-1,y+1)])==null?void 0:hs.id)??r;const K=c==="up"?Math.max(0,G-1):Math.min(C.length-1,G+1),m=C[K],H=R[y].centerX;let P=m[0],is=Math.abs(P.centerX-H);for(const f of m){const x=Math.abs(f.centerX-H);x<is&&(P=f,is=x)}return(P==null?void 0:P.id)??r},X=r=>{const c=U.getShortcuts(),L=c.find(m=>m.id==="dashboard-selector-toggle"),ss=c.find(m=>m.id==="dashboard-vim-left"),es=c.find(m=>m.id==="dashboard-vim-down"),C=c.find(m=>m.id==="dashboard-vim-up"),G=c.find(m=>m.id==="dashboard-vim-right"),R=c.find(m=>m.id==="open-terminal"),y=U.getState();if(a(r.target))if(!y.terminalOpen&&h(r.target)&&document.activeElement instanceof HTMLElement)document.activeElement.blur();else return;if(Z(r,L)){if($.length===0)return;r.preventDefault(),r.stopPropagation(),Q(!0),F(m=>{const H=m&&$.some(P=>P.id===m)?m:$[0].id;return s==null||s(H),window.setTimeout(()=>w(H),0),H});return}const K=Z(r,ss)||r.key==="ArrowLeft"?"left":Z(r,es)||r.key==="ArrowDown"?"down":Z(r,C)||r.key==="ArrowUp"?"up":Z(r,G)||r.key==="ArrowRight"?"right":null;if(K&&Y&&I){r.preventDefault(),r.stopPropagation();const m=k(I,K);m!==I&&(F(m),s==null||s(m),window.setTimeout(()=>w(m),0));return}if(Z(r,R)){if(y.terminalOpen)return;if(Y&&I&&y.agents.has(I)){r.preventDefault(),t==null||t(I);return}if(y.selectedAgentIds.size===1){r.preventDefault();const m=Array.from(y.selectedAgentIds)[0];t==null||t(m);return}if(y.lastSelectedAgentId&&y.agents.has(y.lastSelectedAgentId)){r.preventDefault(),t==null||t(y.lastSelectedAgentId);return}}};return document.addEventListener("keydown",X,!0),()=>document.removeEventListener("keydown",X,!0)},[$,Y,I,t,s]),g.useEffect(()=>{const a=document.activeElement;a instanceof HTMLElement&&a.closest(".guake-terminal")&&!U.getState().terminalOpen&&a.blur()},[]),e.jsxs("div",{className:"dashboard-view",children:[e.jsxs("div",{className:"dashboard-view__topbar",children:[e.jsxs("div",{className:"dashboard-view__metrics",children:[e.jsxs("button",{className:`dashboard-view__metric-btn ${z==="all"?"dashboard-view__metric-btn--active":""}`,onClick:()=>M("all"),children:[e.jsx("span",{className:"dashboard-view__metric-value",children:V.total}),e.jsx("span",{className:"dashboard-view__metric-label",children:n("common:labels.agents")})]}),e.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--working ${z==="working"?"dashboard-view__metric-btn--active":""}`,onClick:()=>M("working"),children:[e.jsx("span",{className:"dashboard-view__metric-value",children:V.working}),e.jsx("span",{className:"dashboard-view__metric-label",children:n("common:status.working")})]}),e.jsxs("button",{className:"dashboard-view__metric-btn dashboard-view__metric-btn--idle ",onClick:()=>M("all"),children:[e.jsx("span",{className:"dashboard-view__metric-value",children:V.idle}),e.jsx("span",{className:"dashboard-view__metric-label",children:n("common:status.idle")})]}),e.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--error ${z==="error"?"dashboard-view__metric-btn--active":""}`,onClick:()=>M("error"),children:[e.jsx("span",{className:"dashboard-view__metric-value",children:V.error}),e.jsx("span",{className:"dashboard-view__metric-label",children:n("common:status.error")})]})]}),e.jsx("input",{className:"dashboard-view__search",type:"text",placeholder:n("searchPlaceholder"),value:o,onChange:a=>b(a.target.value)})]}),e.jsxs("div",{className:"dashboard-view__grouping",children:[e.jsx("button",{className:`dashboard-view__grouping-btn ${_==="zone"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>B("zone"),children:n("grouping.byZone")}),e.jsx("button",{className:`dashboard-view__grouping-btn ${_==="status"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>B("status"),children:n("grouping.byStatus")}),e.jsx("button",{className:`dashboard-view__grouping-btn ${_==="activity"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>B("activity"),children:n("grouping.byActivity")})]}),e.jsxs("div",{className:"dashboard-view__content",children:[W.map(a=>{const h=O(a),w=A.has(h),k=_==="status"?as(a.agents,{prioritizeRecentlyIdle:!0}):ms(a.agents),X=a.agents.filter(c=>c.status==="working"||c.status==="waiting"||c.status==="waiting_permission").length,r=a.agents.filter(c=>j.has(c.id)).length;return e.jsxs("div",{className:`dashboard-view__zone ${ws===(a.area?a.area.id:null)&&E?"dashboard-view__zone--drag-over":""}`,onDragOver:c=>js(c,a.area?a.area.id:null),onDragLeave:ys,onDrop:()=>As(a.area?a.area.id:null),children:[e.jsxs("div",{className:"dashboard-view__zone-header",onClick:()=>xs(h),children:[e.jsxs("div",{className:"dashboard-view__zone-left",children:[e.jsx("span",{className:`dashboard-view__zone-chevron ${w?"dashboard-view__zone-chevron--collapsed":""}`,children:"▼"}),e.jsx("span",{className:"dashboard-view__zone-dot",style:{backgroundColor:a.color}}),e.jsx("span",{className:"dashboard-view__zone-name",children:a.label}),e.jsxs("span",{className:"dashboard-view__zone-count",children:[n("agentCount",{count:a.agents.length}),X>0&&e.jsxs("span",{className:"dashboard-view__zone-working",children:[" · ",X," ",n("working")]}),r>0&&e.jsxs("span",{className:"dashboard-view__zone-unseen",children:[" · ",r," Unseen"]})]})]}),a.area&&i&&e.jsx("button",{className:"dashboard-view__zone-focus",onClick:c=>{c.stopPropagation(),i(a.area.id)},title:n("focusZone"),children:n("focusZone")})]}),!w&&e.jsx("div",{className:"dashboard-view__zone-grid",children:k.map(c=>e.jsx(ps,{agent:c,isSelected:S.has(c.id),isKeyboardFocused:Y&&I===c.id,onSelect:()=>{s==null||s(c.id),Q(!0),F(c.id)},onDoubleClick:()=>Ns(c.id),onChat:()=>t==null?void 0:t(c.id),onFocus:v?()=>v(c.id):void 0,onKill:d?()=>d(c.id):void 0,onDragStart:ks},c.id))})]},h)}),W.length===0&&e.jsx("div",{className:"dashboard-view__empty",children:o?n("noAgentsMatching",{search:o}):n("noAgentsSpawned")}),p.size>0&&e.jsx(bs,{buildings:p,onSelectBuilding:l})]})]})}export{Ks as DashboardView};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-Wkb7M9bi.js","assets/main-5tHJV1Fa.js","assets/modulepreload-polyfill-B5Qt9EMX.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-Chj50gSY.js","assets/main-CeP2eT5V.css"])))=>i.map(i=>d[i]);
2
- import{bk as e,aL as o}from"./main-5tHJV1Fa.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";var i;(function(r){r.Heavy="HEAVY",r.Medium="MEDIUM",r.Light="LIGHT"})(i||(i={}));var t;(function(r){r.Success="SUCCESS",r.Warning="WARNING",r.Error="ERROR"})(t||(t={}));const E=e("Haptics",{web:()=>o(()=>import("./web-Wkb7M9bi.js"),__vite__mapDeps([0,1,2,3,4,5])).then(r=>new r.HapticsWeb)});export{E as Haptics,i as ImpactStyle,t as NotificationType};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-C0QtHZck.js","assets/main-9Cs_hNs-.js","assets/modulepreload-polyfill-B5Qt9EMX.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-Chj50gSY.js","assets/main-BhrN5Ajl.css"])))=>i.map(i=>d[i]);
2
+ import{bk as e,aL as o}from"./main-9Cs_hNs-.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";var i;(function(r){r.Heavy="HEAVY",r.Medium="MEDIUM",r.Light="LIGHT"})(i||(i={}));var t;(function(r){r.Success="SUCCESS",r.Warning="WARNING",r.Error="ERROR"})(t||(t={}));const E=e("Haptics",{web:()=>o(()=>import("./web-C0QtHZck.js"),__vite__mapDeps([0,1,2,3,4,5])).then(r=>new r.HapticsWeb)});export{E as Haptics,i as ImpactStyle,t as NotificationType};
@@ -1 +1 @@
1
- import{a3 as Ve,I as He,K as Ye,J as Je,b5 as Xe,r as A,s as re,b6 as Be,z as he,u as Ee,j as g}from"./main-5tHJV1Fa.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function J(t){return Array.isArray?Array.isArray(t):je(t)==="[object Array]"}function Ze(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function qe(t){return t==null?"":Ze(t)}function H(t){return typeof t=="string"}function Ne(t){return typeof t=="number"}function et(t){return t===!0||t===!1||tt(t)&&je(t)=="[object Boolean]"}function Le(t){return typeof t=="object"}function tt(t){return Le(t)&&t!==null}function P(t){return t!=null}function de(t){return!t.trim().length}function je(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const st="Incorrect 'index' type",nt=t=>`Invalid value for key ${t}`,rt=t=>`Pattern length exceeds max of ${t}.`,it=t=>`Missing ${t} property in key`,ct=t=>`Property 'weight' in key '${t}' must be a positive integer`,Se=Object.prototype.hasOwnProperty;class ot{constructor(e){this._keys=[],this._keyMap={};let s=0;e.forEach(n=>{let r=Te(n);this._keys.push(r),this._keyMap[r.id]=r,s+=r.weight}),this._keys.forEach(n=>{n.weight/=s})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Te(t){let e=null,s=null,n=null,r=1,i=null;if(H(t)||J(t))n=t,e=Ie(t),s=fe(t);else{if(!Se.call(t,"name"))throw new Error(it("name"));const c=t.name;if(n=c,Se.call(t,"weight")&&(r=t.weight,r<=0))throw new Error(ct(c));e=Ie(c),s=fe(c),i=t.getFn}return{path:e,id:s,weight:r,src:n,getFn:i}}function Ie(t){return J(t)?t:t.split(".")}function fe(t){return J(t)?t.join("."):t}function at(t,e){let s=[],n=!1;const r=(i,c,a)=>{if(P(i))if(!c[a])s.push(i);else{let u=c[a];const l=i[u];if(!P(l))return;if(a===c.length-1&&(H(l)||Ne(l)||et(l)))s.push(qe(l));else if(J(l)){n=!0;for(let h=0,d=l.length;h<d;h+=1)r(l[h],c,a+1)}else c.length&&r(l,c,a+1)}};return r(t,H(e)?e.split("."):e,0),n?s:s[0]}const ut={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},lt={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},ht={location:0,threshold:.6,distance:100},dt={useExtendedSearch:!1,getFn:at,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var m={...lt,...ut,...ht,...dt};const ft=/[^ ]+/g;function mt(t=1,e=3){const s=new Map,n=Math.pow(10,e);return{get(r){const i=r.match(ft).length;if(s.has(i))return s.get(i);const c=1/Math.pow(i,.5*t),a=parseFloat(Math.round(c*n)/n);return s.set(i,a),a},clear(){s.clear()}}}class xe{constructor({getFn:e=m.getFn,fieldNormWeight:s=m.fieldNormWeight}={}){this.norm=mt(s,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((s,n)=>{this._keysMap[s.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,H(this.docs[0])?this.docs.forEach((e,s)=>{this._addString(e,s)}):this.docs.forEach((e,s)=>{this._addObject(e,s)}),this.norm.clear())}add(e){const s=this.size();H(e)?this._addString(e,s):this._addObject(e,s)}removeAt(e){this.records.splice(e,1);for(let s=e,n=this.size();s<n;s+=1)this.records[s].i-=1}getValueForItemAtKeyId(e,s){return e[this._keysMap[s]]}size(){return this.records.length}_addString(e,s){if(!P(e)||de(e))return;let n={v:e,i:s,n:this.norm.get(e)};this.records.push(n)}_addObject(e,s){let n={i:s,$:{}};this.keys.forEach((r,i)=>{let c=r.getFn?r.getFn(e):this.getFn(e,r.path);if(P(c)){if(J(c)){let a=[];const u=[{nestedArrIndex:-1,value:c}];for(;u.length;){const{nestedArrIndex:l,value:h}=u.pop();if(P(h))if(H(h)&&!de(h)){let d={v:h,i:l,n:this.norm.get(h)};a.push(d)}else J(h)&&h.forEach((d,f)=>{u.push({nestedArrIndex:f,value:d})})}n.$[i]=a}else if(H(c)&&!de(c)){let a={v:c,n:this.norm.get(c)};n.$[i]=a}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function Pe(t,e,{getFn:s=m.getFn,fieldNormWeight:n=m.fieldNormWeight}={}){const r=new xe({getFn:s,fieldNormWeight:n});return r.setKeys(t.map(Te)),r.setSources(e),r.create(),r}function pt(t,{getFn:e=m.getFn,fieldNormWeight:s=m.fieldNormWeight}={}){const{keys:n,records:r}=t,i=new xe({getFn:e,fieldNormWeight:s});return i.setKeys(n),i.setIndexRecords(r),i}function ae(t,{errors:e=0,currentLocation:s=0,expectedLocation:n=0,distance:r=m.distance,ignoreLocation:i=m.ignoreLocation}={}){const c=e/t.length;if(i)return c;const a=Math.abs(n-s);return r?c+a/r:a?1:c}function gt(t=[],e=m.minMatchCharLength){let s=[],n=-1,r=-1,i=0;for(let c=t.length;i<c;i+=1){let a=t[i];a&&n===-1?n=i:!a&&n!==-1&&(r=i-1,r-n+1>=e&&s.push([n,r]),n=-1)}return t[i-1]&&i-n>=e&&s.push([n,i-1]),s}const ee=32;function At(t,e,s,{location:n=m.location,distance:r=m.distance,threshold:i=m.threshold,findAllMatches:c=m.findAllMatches,minMatchCharLength:a=m.minMatchCharLength,includeMatches:u=m.includeMatches,ignoreLocation:l=m.ignoreLocation}={}){if(e.length>ee)throw new Error(rt(ee));const h=e.length,d=t.length,f=Math.max(0,Math.min(n,d));let p=i,y=f;const D=a>1||u,B=D?Array(d):[];let N;for(;(N=t.indexOf(e,y))>-1;){let x=ae(e,{currentLocation:N,expectedLocation:f,distance:r,ignoreLocation:l});if(p=Math.min(x,p),y=N+h,D){let T=0;for(;T<h;)B[N+T]=1,T+=1}}y=-1;let L=[],Q=1,K=h+d;const te=1<<h-1;for(let x=0;x<h;x+=1){let T=0,I=K;for(;T<I;)ae(e,{errors:x,currentLocation:f+I,expectedLocation:f,distance:r,ignoreLocation:l})<=p?T=I:K=I,I=Math.floor((K-T)/2+T);K=I;let b=Math.max(1,f-I+1),Z=c?d:Math.min(f+I,d)+h,W=Array(Z+2);W[Z+1]=(1<<x)-1;for(let R=Z;R>=b;R-=1){let Y=R-1,ce=s[t.charAt(Y)];if(D&&(B[Y]=+!!ce),W[R]=(W[R+1]<<1|1)&ce,x&&(W[R]|=(L[R+1]|L[R])<<1|1|L[R+1]),W[R]&te&&(Q=ae(e,{errors:x,currentLocation:Y,expectedLocation:f,distance:r,ignoreLocation:l}),Q<=p)){if(p=Q,y=Y,y<=f)break;b=Math.max(1,2*f-y)}}if(ae(e,{errors:x+1,currentLocation:f,expectedLocation:f,distance:r,ignoreLocation:l})>p)break;L=W}const v={isMatch:y>=0,score:Math.max(.001,Q)};if(D){const x=gt(B,a);x.length?u&&(v.indices=x):v.isMatch=!1}return v}function yt(t){let e={};for(let s=0,n=t.length;s<n;s+=1){const r=t.charAt(s);e[r]=(e[r]||0)|1<<n-s-1}return e}const ue=String.prototype.normalize?(t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(t=>t);class Ke{constructor(e,{location:s=m.location,threshold:n=m.threshold,distance:r=m.distance,includeMatches:i=m.includeMatches,findAllMatches:c=m.findAllMatches,minMatchCharLength:a=m.minMatchCharLength,isCaseSensitive:u=m.isCaseSensitive,ignoreDiacritics:l=m.ignoreDiacritics,ignoreLocation:h=m.ignoreLocation}={}){if(this.options={location:s,threshold:n,distance:r,includeMatches:i,findAllMatches:c,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:h},e=u?e:e.toLowerCase(),e=l?ue(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const d=(p,y)=>{this.chunks.push({pattern:p,alphabet:yt(p),startIndex:y})},f=this.pattern.length;if(f>ee){let p=0;const y=f%ee,D=f-y;for(;p<D;)d(this.pattern.substr(p,ee),p),p+=ee;if(y){const B=f-ee;d(this.pattern.substr(B),B)}}else d(this.pattern,0)}searchIn(e){const{isCaseSensitive:s,ignoreDiacritics:n,includeMatches:r}=this.options;if(e=s?e:e.toLowerCase(),e=n?ue(e):e,this.pattern===e){let D={isMatch:!0,score:0};return r&&(D.indices=[[0,e.length-1]]),D}const{location:i,distance:c,threshold:a,findAllMatches:u,minMatchCharLength:l,ignoreLocation:h}=this.options;let d=[],f=0,p=!1;this.chunks.forEach(({pattern:D,alphabet:B,startIndex:N})=>{const{isMatch:L,score:Q,indices:K}=At(e,D,B,{location:i+N,distance:c,threshold:a,findAllMatches:u,minMatchCharLength:l,includeMatches:r,ignoreLocation:h});L&&(p=!0),f+=Q,L&&K&&(d=[...d,...K])});let y={isMatch:p,score:p?f/this.chunks.length:1};return p&&r&&(y.indices=d),y}}class X{constructor(e){this.pattern=e}static isMultiMatch(e){return ke(e,this.multiRegex)}static isSingleMatch(e){return ke(e,this.singleRegex)}search(){}}function ke(t,e){const s=t.match(e);return s?s[1]:null}class Et extends X{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const s=e===this.pattern;return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class xt extends X{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const n=e.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class Ct extends X{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const s=e.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Ft extends X{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const s=!e.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}}class Mt extends X{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const s=e.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class wt extends X{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const s=!e.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}}class Oe extends X{constructor(e,{location:s=m.location,threshold:n=m.threshold,distance:r=m.distance,includeMatches:i=m.includeMatches,findAllMatches:c=m.findAllMatches,minMatchCharLength:a=m.minMatchCharLength,isCaseSensitive:u=m.isCaseSensitive,ignoreDiacritics:l=m.ignoreDiacritics,ignoreLocation:h=m.ignoreLocation}={}){super(e),this._bitapSearch=new Ke(e,{location:s,threshold:n,distance:r,includeMatches:i,findAllMatches:c,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:h})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class Qe extends X{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let s=0,n;const r=[],i=this.pattern.length;for(;(n=e.indexOf(this.pattern,s))>-1;)s=n+i,r.push([n,s-1]);const c=!!r.length;return{isMatch:c,score:c?0:1,indices:r}}}const me=[Et,Qe,Ct,Ft,wt,Mt,xt,Oe],ve=me.length,Dt=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Bt="|";function St(t,e={}){return t.split(Bt).map(s=>{let n=s.trim().split(Dt).filter(i=>i&&!!i.trim()),r=[];for(let i=0,c=n.length;i<c;i+=1){const a=n[i];let u=!1,l=-1;for(;!u&&++l<ve;){const h=me[l];let d=h.isMultiMatch(a);d&&(r.push(new h(d,e)),u=!0)}if(!u)for(l=-1;++l<ve;){const h=me[l];let d=h.isSingleMatch(a);if(d){r.push(new h(d,e));break}}}return r})}const It=new Set([Oe.type,Qe.type]);class kt{constructor(e,{isCaseSensitive:s=m.isCaseSensitive,ignoreDiacritics:n=m.ignoreDiacritics,includeMatches:r=m.includeMatches,minMatchCharLength:i=m.minMatchCharLength,ignoreLocation:c=m.ignoreLocation,findAllMatches:a=m.findAllMatches,location:u=m.location,threshold:l=m.threshold,distance:h=m.distance}={}){this.query=null,this.options={isCaseSensitive:s,ignoreDiacritics:n,includeMatches:r,minMatchCharLength:i,findAllMatches:a,ignoreLocation:c,location:u,threshold:l,distance:h},e=s?e:e.toLowerCase(),e=n?ue(e):e,this.pattern=e,this.query=St(this.pattern,this.options)}static condition(e,s){return s.useExtendedSearch}searchIn(e){const s=this.query;if(!s)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:r,ignoreDiacritics:i}=this.options;e=r?e:e.toLowerCase(),e=i?ue(e):e;let c=0,a=[],u=0;for(let l=0,h=s.length;l<h;l+=1){const d=s[l];a.length=0,c=0;for(let f=0,p=d.length;f<p;f+=1){const y=d[f],{isMatch:D,indices:B,score:N}=y.search(e);if(D){if(c+=1,u+=N,n){const L=y.constructor.type;It.has(L)?a=[...a,...B]:a.push(B)}}else{u=0,c=0,a.length=0;break}}if(c){let f={isMatch:!0,score:u/c};return n&&(f.indices=a),f}}return{isMatch:!1,score:1}}}const pe=[];function vt(...t){pe.push(...t)}function ge(t,e){for(let s=0,n=pe.length;s<n;s+=1){let r=pe[s];if(r.condition(t,e))return new r(t,e)}return new Ke(t,e)}const le={AND:"$and",OR:"$or"},Ae={PATH:"$path",PATTERN:"$val"},ye=t=>!!(t[le.AND]||t[le.OR]),bt=t=>!!t[Ae.PATH],Rt=t=>!J(t)&&Le(t)&&!ye(t),be=t=>({[le.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function We(t,e,{auto:s=!0}={}){const n=r=>{let i=Object.keys(r);const c=bt(r);if(!c&&i.length>1&&!ye(r))return n(be(r));if(Rt(r)){const u=c?r[Ae.PATH]:i[0],l=c?r[Ae.PATTERN]:r[u];if(!H(l))throw new Error(nt(u));const h={keyId:fe(u),pattern:l};return s&&(h.searcher=ge(l,e)),h}let a={children:[],operator:i[0]};return i.forEach(u=>{const l=r[u];J(l)&&l.forEach(h=>{a.children.push(n(h))})}),a};return ye(t)||(t=be(t)),n(t)}function _t(t,{ignoreFieldNorm:e=m.ignoreFieldNorm}){t.forEach(s=>{let n=1;s.matches.forEach(({key:r,norm:i,score:c})=>{const a=r?r.weight:null;n*=Math.pow(c===0&&a?Number.EPSILON:c,(a||1)*(e?1:i))}),s.score=n})}function $t(t,e){const s=t.matches;e.matches=[],P(s)&&s.forEach(n=>{if(!P(n.indices)||!n.indices.length)return;const{indices:r,value:i}=n;let c={indices:r,value:i};n.key&&(c.key=n.key.src),n.idx>-1&&(c.refIndex=n.idx),e.matches.push(c)})}function Nt(t,e){e.score=t.score}function Lt(t,e,{includeMatches:s=m.includeMatches,includeScore:n=m.includeScore}={}){const r=[];return s&&r.push($t),n&&r.push(Nt),t.map(i=>{const{idx:c}=i,a={item:e[c],refIndex:c};return r.length&&r.forEach(u=>{u(i,a)}),a})}class V{constructor(e,s={},n){this.options={...m,...s},this.options.useExtendedSearch,this._keyStore=new ot(this.options.keys),this.setCollection(e,n)}setCollection(e,s){if(this._docs=e,s&&!(s instanceof xe))throw new Error(st);this._myIndex=s||Pe(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){P(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const s=[];for(let n=0,r=this._docs.length;n<r;n+=1){const i=this._docs[n];e(i,n)&&(this.removeAt(n),n-=1,r-=1,s.push(i))}return s}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:s=-1}={}){const{includeMatches:n,includeScore:r,shouldSort:i,sortFn:c,ignoreFieldNorm:a}=this.options;let u=H(e)?H(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return _t(u,{ignoreFieldNorm:a}),i&&u.sort(c),Ne(s)&&s>-1&&(u=u.slice(0,s)),Lt(u,this._docs,{includeMatches:n,includeScore:r})}_searchStringList(e){const s=ge(e,this.options),{records:n}=this._myIndex,r=[];return n.forEach(({v:i,i:c,n:a})=>{if(!P(i))return;const{isMatch:u,score:l,indices:h}=s.searchIn(i);u&&r.push({item:i,idx:c,matches:[{score:l,value:i,norm:a,indices:h}]})}),r}_searchLogical(e){const s=We(e,this.options),n=(a,u,l)=>{if(!a.children){const{keyId:d,searcher:f}=a,p=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(u,d),searcher:f});return p&&p.length?[{idx:l,item:u,matches:p}]:[]}const h=[];for(let d=0,f=a.children.length;d<f;d+=1){const p=a.children[d],y=n(p,u,l);if(y.length)h.push(...y);else if(a.operator===le.AND)return[]}return h},r=this._myIndex.records,i={},c=[];return r.forEach(({$:a,i:u})=>{if(P(a)){let l=n(s,a,u);l.length&&(i[u]||(i[u]={idx:u,item:a,matches:[]},c.push(i[u])),l.forEach(({matches:h})=>{i[u].matches.push(...h)}))}}),c}_searchObjectList(e){const s=ge(e,this.options),{keys:n,records:r}=this._myIndex,i=[];return r.forEach(({$:c,i:a})=>{if(!P(c))return;let u=[];n.forEach((l,h)=>{u.push(...this._findMatches({key:l,value:c[h],searcher:s}))}),u.length&&i.push({idx:a,item:c,matches:u})}),i}_findMatches({key:e,value:s,searcher:n}){if(!P(s))return[];let r=[];if(J(s))s.forEach(({v:i,i:c,n:a})=>{if(!P(i))return;const{isMatch:u,score:l,indices:h}=n.searchIn(i);u&&r.push({score:l,key:e,value:i,idx:c,norm:a,indices:h})});else{const{v:i,n:c}=s,{isMatch:a,score:u,indices:l}=n.searchIn(i);a&&r.push({score:u,key:e,value:i,norm:c,indices:l})}return r}}V.version="7.1.0";V.createIndex=Pe;V.parseIndex=pt;V.config=m;V.parseQuery=We;vt(kt);const Re={".ts":"📘",".tsx":"⚛️",".js":"📒",".jsx":"⚛️",".py":"🐍",".rs":"🦀",".go":"🔷",".md":"📝",".json":"📋",".yaml":"⚙️",".yml":"⚙️",".css":"🎨",".scss":"🎨",".html":"🌐",".sql":"🗃️",".sh":"💻",".env":"🔐",".toml":"⚙️",".lock":"🔒",default:"📄"};function jt(t){var s;const e="."+((s=t.split(".").pop())==null?void 0:s.toLowerCase());return Re[e]||Re.default}function Tt(t){const e=Ve[t];return(e==null?void 0:e.icon)||"🤖"}function ze(t){const e=Math.floor(t/1e3),s=Math.floor(e/60),n=Math.floor(s/60),r=Math.floor(n/24);return r>0?`${r}d ${n%24}h ago`:n>0?`${n}h ${s%60}m ago`:s>0?`${s}m ago`:"just now"}function Ht(t){const s=Date.now()-t;return ze(s)}function _e(t){switch(t){case"agent":return"Agent";case"command":return"Command";case"area":return"Area";case"modified-file":return"Changed";case"building":return"Server";default:return t}}const $e=["command","agent","building","area","modified-file"];function Pt({isOpen:t,onClose:e,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:r,onOpenFileExplorer:i,onOpenPM2LogsModal:c,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=He(),d=Ye(),f=Je(),p=Xe(),y=A.useRef(e);y.current=e;const D=A.useRef(s);D.current=s;const B=A.useRef(n);B.current=n;const N=A.useRef(r);N.current=r;const L=A.useRef(i);L.current=i;const Q=A.useRef(c);Q.current=c;const K=A.useRef(a);K.current=a;const te=A.useRef(u);te.current=u;const v=A.useRef(l);v.current=l;const[x,T]=A.useState(""),[I,b]=A.useState(0);A.useEffect(()=>{t&&(T(""),b(0))},[t]);const Z=re.getShortcuts(),W=A.useMemo(()=>{if(!t)return[];const o=Z.find(F=>F.id==="spawn-agent"),C=Z.find(F=>F.id==="toggle-commander");return[{id:"cmd-spawn",type:"command",title:"Spawn New Agent",subtitle:o?Be(o):"Alt+N",icon:"➕",action:()=>{y.current(),D.current()}},{id:"cmd-commander",type:"command",title:"Commander View",subtitle:C?Be(C):"Ctrl+K",icon:"📊",action:()=>{y.current(),B.current()}},{id:"cmd-settings",type:"command",title:"Settings & Tools",subtitle:"Configure Tide Commander",icon:"⚙️",action:()=>{y.current(),N.current()}},{id:"cmd-monitoring",type:"command",title:"Monitoring & Logs",subtitle:"Triggers, workflows, events",icon:"📊",action:()=>{var F;y.current(),(F=v.current)==null||F.call(v)}}]},[t,Z]),ie=A.useMemo(()=>t?Array.from(h.values()).map(o=>{const C=(p||[]).filter(j=>j.agentId===o.id).map(j=>j.filePath),F=[...new Set(C)],M=F.map(j=>j.split("/").pop()||j),k=[];o.lastAssignedTask&&k.push(o.lastAssignedTask);const _=`${o.class} • ${o.status} • ${o.cwd}`;let w=`${o.name} ${_}`;M.length>0&&(w+=` ${M.join(" ")} ${F.join(" ")}`),k.length>0&&(w+=` ${k.join(" ")}`);const O=Date.now()-o.lastActivity;let G;return o.lastAssignedTask&&(o.lastAssignedTask.length>150?G=o.lastAssignedTask.slice(0,150)+"...":G=o.lastAssignedTask),{id:`agent-${o.id}`,type:"agent",title:o.name,subtitle:_,lastUserInput:G,timeAway:O,icon:Tt(o.class),_searchText:w,_modifiedFiles:F,_userQueries:k,action:()=>{y.current(),re.selectAgent(o.id)}}}):[],[t,h,p]),R=A.useMemo(()=>t?Array.from(d.values()).map(o=>{var C;return{id:`area-${o.id}`,type:"area",title:o.name,subtitle:`${o.assignedAgentIds.length} agents • ${((C=o.directories)==null?void 0:C.length)||0} folders`,icon:"🗺️",action:()=>{y.current(),re.selectArea(o.id)}}}):[],[t,d]),Y=A.useMemo(()=>t?Array.from(f.values()).filter(o=>o.type==="server"||o.type==="boss"||o.type==="database").map(o=>{var w,O,G,j;const C=o.status==="running"?"🟢":o.status==="stopped"?"🔴":"🟡",F=o.type==="boss"?"👑":o.type==="database"?"🗄️":"🖥️";let k=`${o.type==="boss"?"Boss":o.type==="database"?"Database":"Server"} • ${o.status}`;if(o.type==="database"&&((O=(w=o.database)==null?void 0:w.connections)!=null&&O.length)){const E=o.database.connections[0];k+=` • ${E.engine} @ ${E.host}`}else o.cwd&&(k+=` • ${o.cwd}`);let _=`${o.name} ${o.type} ${o.status} ${o.cwd||""} ${((G=o.pm2)==null?void 0:G.name)||""}`;if(o.type==="database"&&((j=o.database)!=null&&j.connections))for(const E of o.database.connections)_+=` ${E.name} ${E.engine} ${E.host} ${E.database||""} mysql postgresql sql`;return{id:`building-${o.id}`,type:"building",title:o.name,subtitle:k,icon:`${C} ${F}`,_searchText:_,action:()=>{var E;y.current(),o.type==="boss"?K.current(o.id):o.type==="database"?te.current(o.id):(E=o.pm2)!=null&&E.enabled&&Q.current(o.id)}}}):[],[t,f]),ce=A.useMemo(()=>{if(!t)return[];const o=p||[],C=new Set,F=[];for(const M of o){if(C.has(M.filePath))continue;C.add(M.filePath);const k=M.filePath.split("/").pop()||M.filePath,_=M.action==="created"?"Created":M.action==="modified"?"Modified":M.action==="deleted"?"Deleted":"Read";if(F.push({id:`modified-${M.filePath}-${M.timestamp}`,type:"modified-file",title:k,subtitle:`${_} by ${M.agentName} • ${M.filePath}`,matchedText:M.filePath,icon:M.action==="deleted"?"🗑️":jt(M.filePath),action:()=>{y.current();const w=Array.from(re.getState().areas.values());for(const O of w)for(const G of O.directories||[])if(M.filePath.startsWith(G)){re.setFileViewerPath(M.filePath),L.current(O.id);return}re.selectAgent(M.agentId)}}),F.length>=50)break}return F},[t,p]),Ce=A.useMemo(()=>new V(ie,{keys:["title","subtitle","_searchText","lastUserInput"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[ie]),Fe=A.useMemo(()=>new V(W,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[W]),Me=A.useMemo(()=>new V(R,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[R]),we=A.useMemo(()=>new V(ce,{keys:["title","subtitle","matchedText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[ce]),De=A.useMemo(()=>new V(Y,{keys:["title","subtitle","_searchText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[Y]),z=A.useMemo(()=>{if(!x.trim()){const E=[];E.push(...Y);const S=[...ie].sort(($,U)=>{const se=$.timeAway??0,ne=U.timeAway??0;return se-ne});E.push(...S),E.push(...W.slice(0,2)),E.push(...R.slice(0,2));const q={};return $e.forEach(($,U)=>{q[$]=U}),E.sort(($,U)=>(q[$.type]??999)-(q[U.type]??999)),E}const o=x.toLowerCase(),C=Ce.search(x).slice(0,8),F=Fe.search(x).slice(0,3),M=Me.search(x).slice(0,2),k=we.search(x).slice(0,3),_=De.search(x).filter(E=>{const S=E.score??1;return`${E.item.title} ${E.item.subtitle||""} ${E.item._searchText||""}`.toLowerCase().includes(o)||S<=.2}).slice(0,4),w=[],O=[],G=[];for(const E of C){const S={...E.item};if(S._modifiedFiles&&S._modifiedFiles.length>0){const $=S._modifiedFiles.filter(U=>{var oe;const se=((oe=U.split("/").pop())==null?void 0:oe.toLowerCase())||"",ne=U.toLowerCase();return se.includes(o)||ne.includes(o)});$.length>0&&(S.matchedFiles=$)}if(S._userQueries&&S._userQueries.length>0){const $=S._userQueries.find(U=>U.toLowerCase().includes(o));if($)if($.length>200){const se=$.toLowerCase().indexOf(o),ne=Math.max(0,se-60),oe=Math.min($.length,se+o.length+100);S.matchedQuery=(ne>0?"...":"")+$.slice(ne,oe)+(oe<$.length?"...":"")}else S.matchedQuery=$}const q=S.title.toLowerCase();q===o||q.startsWith(o)?O.push(S):G.push(S)}for(const E of O)w.push(E);for(const E of _)w.push(E.item);for(const E of G)w.push(E);for(const E of F)w.push(E.item);for(const E of M)w.push(E.item);for(const E of k)w.push(E.item);const j={};return $e.forEach((E,S)=>{j[E]=S}),w.sort((E,S)=>(j[E.type]??999)-(j[S.type]??999)),w},[x,Ce,Fe,Me,we,De,W,ie,R,Y]);A.useEffect(()=>{I>=z.length&&b(Math.max(0,z.length-1))},[z.length,I]);const Ge=A.useCallback(o=>{if(o.altKey&&!o.ctrlKey&&!o.metaKey&&(o.key==="p"||o.key==="n"||o.key==="P"||o.key==="N")){o.preventDefault(),o.stopPropagation(),o.nativeEvent.stopImmediatePropagation();const C=o.key.toLowerCase();b(C==="p"?F=>F>0?F-1:z.length-1:F=>F<z.length-1?F+1:0);return}switch(o.key){case"Escape":o.preventDefault(),y.current();break;case"ArrowUp":o.preventDefault(),b(C=>C>0?C-1:z.length-1);break;case"ArrowDown":o.preventDefault(),b(C=>C<z.length-1?C+1:0);break;case"Enter":o.preventDefault(),z[I]&&z[I].action();break}},[z,I]),Ue=A.useCallback((o,C)=>{if(!C||!o)return o;const F=o.toLowerCase(),M=C.toLowerCase(),k=[];let _=0,w=F.indexOf(M),O=0;for(;w!==-1;)w>_&&k.push(o.slice(_,w)),k.push(he.createElement("mark",{key:O++,className:"spotlight-highlight"},o.slice(w,w+C.length))),_=w+C.length,w=F.indexOf(M,_);return _<o.length&&k.push(o.slice(_)),k.length>0?he.createElement(he.Fragment,null,...k):o},[]);return{query:x,setQuery:T,selectedIndex:I,setSelectedIndex:b,results:z,handleKeyDown:Ge,highlightMatch:Ue}}const Kt=A.forwardRef(function({query:e,onQueryChange:s,onKeyDown:n,onResetSelection:r},i){const{t:c}=Ee(["common"]);return g.jsxs("div",{className:"spotlight-input-wrapper",children:[g.jsx("span",{className:"spotlight-search-icon",children:"⌘"}),g.jsx("input",{ref:i,type:"text",className:"spotlight-input",placeholder:c("common:search.spotlightPlaceholder"),value:e,onChange:a=>{s(a.target.value),r()},onKeyDown:n,autoFocus:!0,spellCheck:!1}),g.jsxs("div",{className:"spotlight-input-hints",children:[g.jsx("span",{className:"spotlight-shortcut-hint",children:"↑↓"}),g.jsx("span",{className:"spotlight-shortcut-hint",children:"Enter"}),g.jsx("span",{className:"spotlight-shortcut-hint",children:"Esc"})]})]})}),Ot=A.memo(function({result:e,isSelected:s,query:n,highlightMatch:r,onClick:i,onMouseEnter:c}){const a=e.activityText||e.matchedFiles&&e.matchedFiles.length>0||e.matchedQuery;return g.jsxs("div",{className:`spotlight-item ${s?"selected":""} ${e.activityText?"has-activity":""}`,onClick:i,onMouseEnter:c,role:"option","aria-selected":s,children:[g.jsx("span",{className:"spotlight-item-icon","aria-hidden":"true",children:e.icon}),g.jsxs("div",{className:"spotlight-item-content",children:[g.jsxs("div",{className:"spotlight-item-header",children:[g.jsx("span",{className:"spotlight-item-title",children:r(e.title,n)}),g.jsx("span",{className:`spotlight-item-type ${e.type}`,"aria-label":_e(e.type),children:_e(e.type)})]}),e.subtitle&&g.jsx("span",{className:"spotlight-item-subtitle",children:r(e.subtitle,n)}),e.activityText&&g.jsx("span",{className:"spotlight-item-activity",children:r(e.activityText,n)}),a&&g.jsxs("div",{className:"spotlight-item-details",children:[e.matchedFiles&&e.matchedFiles.length>0&&g.jsx("span",{className:"spotlight-item-files",children:e.matchedFiles.map((u,l)=>g.jsxs("span",{className:"file-badge",children:[l>0&&g.jsx("span",{className:"file-separator",children:"•"}),r(u.split("/").pop()||u,n)]},u))}),e.matchedQuery&&g.jsx("span",{className:"spotlight-item-query",children:r(e.matchedQuery,n)})]}),e.timeAway!==void 0&&g.jsx("span",{className:"spotlight-item-time",children:g.jsxs("span",{className:"spotlight-time-away",children:["Idle: ",ze(e.timeAway)]})}),e.lastUserInput&&!e.matchedQuery&&g.jsxs("span",{className:"spotlight-item-last-input",children:['"',r(e.lastUserInput,n),'"']})]})]})}),Qt=A.forwardRef(function({results:e,selectedIndex:s,query:n,highlightMatch:r,onSelectIndex:i},c){const{t:a}=Ee(["terminal"]),u=A.useRef(!1);A.useEffect(()=>{u.current=!1},[e]),A.useEffect(()=>{const d=typeof c=="function"?null:c==null?void 0:c.current;if(!d)return;const f=()=>{u.current=!0};return d.addEventListener("mousemove",f),()=>{d.removeEventListener("mousemove",f)}},[c,e]);const l={command:a("terminal:spotlight.categories.commands"),agent:a("terminal:spotlight.categories.agents"),building:a("terminal:spotlight.categories.infrastructure"),area:a("terminal:spotlight.categories.areas"),"modified-file":a("terminal:spotlight.categories.modifiedFiles")},h=A.useMemo(()=>{const d=[];let f=null,p=[];return e.forEach((y,D)=>{y.type!==f&&(f!==null&&p.length>0&&d.push([f,p]),f=y.type,p=[]),p.push({result:y,index:D})}),f!==null&&p.length>0&&d.push([f,p]),d},[e]);return A.useEffect(()=>{if(!c||typeof c=="function")return;const d=c.current;if(!d)return;const f=d.querySelector(".spotlight-item.selected");f&&f.scrollIntoView({block:"nearest",behavior:"smooth"})},[s,c]),e.length===0?g.jsx("div",{className:"spotlight-results",ref:c,children:g.jsx("div",{className:"spotlight-empty",children:a("terminal:spotlight.noResults")})}):g.jsx("div",{className:"spotlight-results",ref:c,children:h.map(([d,f])=>g.jsxs("div",{children:[h.length>1&&g.jsx("div",{className:"spotlight-category-header",children:l[d]||d}),f.map(({result:p,index:y})=>g.jsx(Ot,{result:p,isSelected:y===s,query:n,highlightMatch:r,onClick:()=>p.action(),onMouseEnter:()=>{u.current&&i(y)}},p.id))]},d))})}),Wt=A.memo(function(){const{t:e}=Ee(["terminal"]);return g.jsxs("div",{className:"spotlight-footer",children:[g.jsxs("div",{className:"spotlight-footer-left",children:[g.jsxs("span",{className:"spotlight-footer-hint",children:[g.jsx("kbd",{children:"↑"}),g.jsx("kbd",{children:"↓"})," ",g.jsx("kbd",{children:"Alt+N"}),g.jsx("kbd",{children:"Alt+P"})," ",e("terminal:spotlight.navigate")]}),g.jsxs("span",{className:"spotlight-footer-hint",children:[g.jsx("kbd",{children:"Enter"})," ",e("terminal:spotlight.select")]})]}),g.jsx("div",{className:"spotlight-footer-right",children:g.jsxs("span",{className:"spotlight-footer-hint",children:[g.jsx("kbd",{children:"Esc"})," ",e("common:buttons.close")]})})]})});function Yt({isOpen:t,onClose:e,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:r,onOpenFileExplorer:i,onOpenPM2LogsModal:c,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=A.useRef(null),d=A.useRef(null),f=A.useRef(0),{query:p,setQuery:y,selectedIndex:D,setSelectedIndex:B,results:N,handleKeyDown:L,highlightMatch:Q}=Pt({isOpen:t,onClose:e,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:r,onOpenFileExplorer:i,onOpenPM2LogsModal:c,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l});f.current=N.length,A.useEffect(()=>{t&&setTimeout(()=>{var v;(v=h.current)==null||v.focus()},50)},[t]),A.useEffect(()=>{if(!t)return;const v=x=>{if(x.key==="Escape"){x.preventDefault(),x.stopPropagation(),x.stopImmediatePropagation(),e();return}if(x.altKey&&!x.ctrlKey&&!x.metaKey&&(x.key==="n"||x.key==="p"||x.key==="N"||x.key==="P")){x.preventDefault(),x.stopPropagation(),x.stopImmediatePropagation();const T=x.key.toLowerCase(),I=f.current;B(T==="p"?b=>b>0?b-1:I-1:b=>b<I-1?b+1:0);return}};return window.addEventListener("keydown",v,{capture:!0}),()=>{window.removeEventListener("keydown",v,{capture:!0})}},[t,e]);const K=A.useCallback(v=>{v.target===v.currentTarget&&e()},[e]),te=A.useCallback(()=>{B(0)},[B]);return t?g.jsx("div",{className:"spotlight-overlay",onClick:K,children:g.jsxs("div",{className:"spotlight-modal",children:[g.jsx(Kt,{ref:h,query:p,onQueryChange:y,onKeyDown:L,onResetSelection:te}),g.jsx(Qt,{ref:d,results:N,selectedIndex:D,query:p,highlightMatch:Q,onSelectIndex:B}),g.jsx(Wt,{})]})}):null}export{Re as FILE_ICONS,Yt as Spotlight,Wt as SpotlightFooter,Kt as SpotlightInput,Ot as SpotlightItem,Qt as SpotlightResults,ze as formatDuration,Ht as formatRelativeTime,Tt as getAgentIcon,jt as getFileIconFromPath,_e as getTypeLabel,Pt as useSpotlightSearch};
1
+ import{a3 as Ve,I as He,K as Ye,J as Je,b5 as Xe,r as A,s as re,b6 as Be,z as he,u as Ee,j as g}from"./main-9Cs_hNs-.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function J(t){return Array.isArray?Array.isArray(t):je(t)==="[object Array]"}function Ze(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function qe(t){return t==null?"":Ze(t)}function H(t){return typeof t=="string"}function Ne(t){return typeof t=="number"}function et(t){return t===!0||t===!1||tt(t)&&je(t)=="[object Boolean]"}function Le(t){return typeof t=="object"}function tt(t){return Le(t)&&t!==null}function P(t){return t!=null}function de(t){return!t.trim().length}function je(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const st="Incorrect 'index' type",nt=t=>`Invalid value for key ${t}`,rt=t=>`Pattern length exceeds max of ${t}.`,it=t=>`Missing ${t} property in key`,ct=t=>`Property 'weight' in key '${t}' must be a positive integer`,Se=Object.prototype.hasOwnProperty;class ot{constructor(e){this._keys=[],this._keyMap={};let s=0;e.forEach(n=>{let r=Te(n);this._keys.push(r),this._keyMap[r.id]=r,s+=r.weight}),this._keys.forEach(n=>{n.weight/=s})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Te(t){let e=null,s=null,n=null,r=1,i=null;if(H(t)||J(t))n=t,e=Ie(t),s=fe(t);else{if(!Se.call(t,"name"))throw new Error(it("name"));const c=t.name;if(n=c,Se.call(t,"weight")&&(r=t.weight,r<=0))throw new Error(ct(c));e=Ie(c),s=fe(c),i=t.getFn}return{path:e,id:s,weight:r,src:n,getFn:i}}function Ie(t){return J(t)?t:t.split(".")}function fe(t){return J(t)?t.join("."):t}function at(t,e){let s=[],n=!1;const r=(i,c,a)=>{if(P(i))if(!c[a])s.push(i);else{let u=c[a];const l=i[u];if(!P(l))return;if(a===c.length-1&&(H(l)||Ne(l)||et(l)))s.push(qe(l));else if(J(l)){n=!0;for(let h=0,d=l.length;h<d;h+=1)r(l[h],c,a+1)}else c.length&&r(l,c,a+1)}};return r(t,H(e)?e.split("."):e,0),n?s:s[0]}const ut={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},lt={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},ht={location:0,threshold:.6,distance:100},dt={useExtendedSearch:!1,getFn:at,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var m={...lt,...ut,...ht,...dt};const ft=/[^ ]+/g;function mt(t=1,e=3){const s=new Map,n=Math.pow(10,e);return{get(r){const i=r.match(ft).length;if(s.has(i))return s.get(i);const c=1/Math.pow(i,.5*t),a=parseFloat(Math.round(c*n)/n);return s.set(i,a),a},clear(){s.clear()}}}class xe{constructor({getFn:e=m.getFn,fieldNormWeight:s=m.fieldNormWeight}={}){this.norm=mt(s,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((s,n)=>{this._keysMap[s.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,H(this.docs[0])?this.docs.forEach((e,s)=>{this._addString(e,s)}):this.docs.forEach((e,s)=>{this._addObject(e,s)}),this.norm.clear())}add(e){const s=this.size();H(e)?this._addString(e,s):this._addObject(e,s)}removeAt(e){this.records.splice(e,1);for(let s=e,n=this.size();s<n;s+=1)this.records[s].i-=1}getValueForItemAtKeyId(e,s){return e[this._keysMap[s]]}size(){return this.records.length}_addString(e,s){if(!P(e)||de(e))return;let n={v:e,i:s,n:this.norm.get(e)};this.records.push(n)}_addObject(e,s){let n={i:s,$:{}};this.keys.forEach((r,i)=>{let c=r.getFn?r.getFn(e):this.getFn(e,r.path);if(P(c)){if(J(c)){let a=[];const u=[{nestedArrIndex:-1,value:c}];for(;u.length;){const{nestedArrIndex:l,value:h}=u.pop();if(P(h))if(H(h)&&!de(h)){let d={v:h,i:l,n:this.norm.get(h)};a.push(d)}else J(h)&&h.forEach((d,f)=>{u.push({nestedArrIndex:f,value:d})})}n.$[i]=a}else if(H(c)&&!de(c)){let a={v:c,n:this.norm.get(c)};n.$[i]=a}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function Pe(t,e,{getFn:s=m.getFn,fieldNormWeight:n=m.fieldNormWeight}={}){const r=new xe({getFn:s,fieldNormWeight:n});return r.setKeys(t.map(Te)),r.setSources(e),r.create(),r}function pt(t,{getFn:e=m.getFn,fieldNormWeight:s=m.fieldNormWeight}={}){const{keys:n,records:r}=t,i=new xe({getFn:e,fieldNormWeight:s});return i.setKeys(n),i.setIndexRecords(r),i}function ae(t,{errors:e=0,currentLocation:s=0,expectedLocation:n=0,distance:r=m.distance,ignoreLocation:i=m.ignoreLocation}={}){const c=e/t.length;if(i)return c;const a=Math.abs(n-s);return r?c+a/r:a?1:c}function gt(t=[],e=m.minMatchCharLength){let s=[],n=-1,r=-1,i=0;for(let c=t.length;i<c;i+=1){let a=t[i];a&&n===-1?n=i:!a&&n!==-1&&(r=i-1,r-n+1>=e&&s.push([n,r]),n=-1)}return t[i-1]&&i-n>=e&&s.push([n,i-1]),s}const ee=32;function At(t,e,s,{location:n=m.location,distance:r=m.distance,threshold:i=m.threshold,findAllMatches:c=m.findAllMatches,minMatchCharLength:a=m.minMatchCharLength,includeMatches:u=m.includeMatches,ignoreLocation:l=m.ignoreLocation}={}){if(e.length>ee)throw new Error(rt(ee));const h=e.length,d=t.length,f=Math.max(0,Math.min(n,d));let p=i,y=f;const D=a>1||u,B=D?Array(d):[];let N;for(;(N=t.indexOf(e,y))>-1;){let x=ae(e,{currentLocation:N,expectedLocation:f,distance:r,ignoreLocation:l});if(p=Math.min(x,p),y=N+h,D){let T=0;for(;T<h;)B[N+T]=1,T+=1}}y=-1;let L=[],Q=1,K=h+d;const te=1<<h-1;for(let x=0;x<h;x+=1){let T=0,I=K;for(;T<I;)ae(e,{errors:x,currentLocation:f+I,expectedLocation:f,distance:r,ignoreLocation:l})<=p?T=I:K=I,I=Math.floor((K-T)/2+T);K=I;let b=Math.max(1,f-I+1),Z=c?d:Math.min(f+I,d)+h,W=Array(Z+2);W[Z+1]=(1<<x)-1;for(let R=Z;R>=b;R-=1){let Y=R-1,ce=s[t.charAt(Y)];if(D&&(B[Y]=+!!ce),W[R]=(W[R+1]<<1|1)&ce,x&&(W[R]|=(L[R+1]|L[R])<<1|1|L[R+1]),W[R]&te&&(Q=ae(e,{errors:x,currentLocation:Y,expectedLocation:f,distance:r,ignoreLocation:l}),Q<=p)){if(p=Q,y=Y,y<=f)break;b=Math.max(1,2*f-y)}}if(ae(e,{errors:x+1,currentLocation:f,expectedLocation:f,distance:r,ignoreLocation:l})>p)break;L=W}const v={isMatch:y>=0,score:Math.max(.001,Q)};if(D){const x=gt(B,a);x.length?u&&(v.indices=x):v.isMatch=!1}return v}function yt(t){let e={};for(let s=0,n=t.length;s<n;s+=1){const r=t.charAt(s);e[r]=(e[r]||0)|1<<n-s-1}return e}const ue=String.prototype.normalize?(t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(t=>t);class Ke{constructor(e,{location:s=m.location,threshold:n=m.threshold,distance:r=m.distance,includeMatches:i=m.includeMatches,findAllMatches:c=m.findAllMatches,minMatchCharLength:a=m.minMatchCharLength,isCaseSensitive:u=m.isCaseSensitive,ignoreDiacritics:l=m.ignoreDiacritics,ignoreLocation:h=m.ignoreLocation}={}){if(this.options={location:s,threshold:n,distance:r,includeMatches:i,findAllMatches:c,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:h},e=u?e:e.toLowerCase(),e=l?ue(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const d=(p,y)=>{this.chunks.push({pattern:p,alphabet:yt(p),startIndex:y})},f=this.pattern.length;if(f>ee){let p=0;const y=f%ee,D=f-y;for(;p<D;)d(this.pattern.substr(p,ee),p),p+=ee;if(y){const B=f-ee;d(this.pattern.substr(B),B)}}else d(this.pattern,0)}searchIn(e){const{isCaseSensitive:s,ignoreDiacritics:n,includeMatches:r}=this.options;if(e=s?e:e.toLowerCase(),e=n?ue(e):e,this.pattern===e){let D={isMatch:!0,score:0};return r&&(D.indices=[[0,e.length-1]]),D}const{location:i,distance:c,threshold:a,findAllMatches:u,minMatchCharLength:l,ignoreLocation:h}=this.options;let d=[],f=0,p=!1;this.chunks.forEach(({pattern:D,alphabet:B,startIndex:N})=>{const{isMatch:L,score:Q,indices:K}=At(e,D,B,{location:i+N,distance:c,threshold:a,findAllMatches:u,minMatchCharLength:l,includeMatches:r,ignoreLocation:h});L&&(p=!0),f+=Q,L&&K&&(d=[...d,...K])});let y={isMatch:p,score:p?f/this.chunks.length:1};return p&&r&&(y.indices=d),y}}class X{constructor(e){this.pattern=e}static isMultiMatch(e){return ke(e,this.multiRegex)}static isSingleMatch(e){return ke(e,this.singleRegex)}search(){}}function ke(t,e){const s=t.match(e);return s?s[1]:null}class Et extends X{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const s=e===this.pattern;return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class xt extends X{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const n=e.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class Ct extends X{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const s=e.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Ft extends X{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const s=!e.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}}class Mt extends X{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const s=e.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class wt extends X{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const s=!e.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}}class Oe extends X{constructor(e,{location:s=m.location,threshold:n=m.threshold,distance:r=m.distance,includeMatches:i=m.includeMatches,findAllMatches:c=m.findAllMatches,minMatchCharLength:a=m.minMatchCharLength,isCaseSensitive:u=m.isCaseSensitive,ignoreDiacritics:l=m.ignoreDiacritics,ignoreLocation:h=m.ignoreLocation}={}){super(e),this._bitapSearch=new Ke(e,{location:s,threshold:n,distance:r,includeMatches:i,findAllMatches:c,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:h})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class Qe extends X{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let s=0,n;const r=[],i=this.pattern.length;for(;(n=e.indexOf(this.pattern,s))>-1;)s=n+i,r.push([n,s-1]);const c=!!r.length;return{isMatch:c,score:c?0:1,indices:r}}}const me=[Et,Qe,Ct,Ft,wt,Mt,xt,Oe],ve=me.length,Dt=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Bt="|";function St(t,e={}){return t.split(Bt).map(s=>{let n=s.trim().split(Dt).filter(i=>i&&!!i.trim()),r=[];for(let i=0,c=n.length;i<c;i+=1){const a=n[i];let u=!1,l=-1;for(;!u&&++l<ve;){const h=me[l];let d=h.isMultiMatch(a);d&&(r.push(new h(d,e)),u=!0)}if(!u)for(l=-1;++l<ve;){const h=me[l];let d=h.isSingleMatch(a);if(d){r.push(new h(d,e));break}}}return r})}const It=new Set([Oe.type,Qe.type]);class kt{constructor(e,{isCaseSensitive:s=m.isCaseSensitive,ignoreDiacritics:n=m.ignoreDiacritics,includeMatches:r=m.includeMatches,minMatchCharLength:i=m.minMatchCharLength,ignoreLocation:c=m.ignoreLocation,findAllMatches:a=m.findAllMatches,location:u=m.location,threshold:l=m.threshold,distance:h=m.distance}={}){this.query=null,this.options={isCaseSensitive:s,ignoreDiacritics:n,includeMatches:r,minMatchCharLength:i,findAllMatches:a,ignoreLocation:c,location:u,threshold:l,distance:h},e=s?e:e.toLowerCase(),e=n?ue(e):e,this.pattern=e,this.query=St(this.pattern,this.options)}static condition(e,s){return s.useExtendedSearch}searchIn(e){const s=this.query;if(!s)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:r,ignoreDiacritics:i}=this.options;e=r?e:e.toLowerCase(),e=i?ue(e):e;let c=0,a=[],u=0;for(let l=0,h=s.length;l<h;l+=1){const d=s[l];a.length=0,c=0;for(let f=0,p=d.length;f<p;f+=1){const y=d[f],{isMatch:D,indices:B,score:N}=y.search(e);if(D){if(c+=1,u+=N,n){const L=y.constructor.type;It.has(L)?a=[...a,...B]:a.push(B)}}else{u=0,c=0,a.length=0;break}}if(c){let f={isMatch:!0,score:u/c};return n&&(f.indices=a),f}}return{isMatch:!1,score:1}}}const pe=[];function vt(...t){pe.push(...t)}function ge(t,e){for(let s=0,n=pe.length;s<n;s+=1){let r=pe[s];if(r.condition(t,e))return new r(t,e)}return new Ke(t,e)}const le={AND:"$and",OR:"$or"},Ae={PATH:"$path",PATTERN:"$val"},ye=t=>!!(t[le.AND]||t[le.OR]),bt=t=>!!t[Ae.PATH],Rt=t=>!J(t)&&Le(t)&&!ye(t),be=t=>({[le.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function We(t,e,{auto:s=!0}={}){const n=r=>{let i=Object.keys(r);const c=bt(r);if(!c&&i.length>1&&!ye(r))return n(be(r));if(Rt(r)){const u=c?r[Ae.PATH]:i[0],l=c?r[Ae.PATTERN]:r[u];if(!H(l))throw new Error(nt(u));const h={keyId:fe(u),pattern:l};return s&&(h.searcher=ge(l,e)),h}let a={children:[],operator:i[0]};return i.forEach(u=>{const l=r[u];J(l)&&l.forEach(h=>{a.children.push(n(h))})}),a};return ye(t)||(t=be(t)),n(t)}function _t(t,{ignoreFieldNorm:e=m.ignoreFieldNorm}){t.forEach(s=>{let n=1;s.matches.forEach(({key:r,norm:i,score:c})=>{const a=r?r.weight:null;n*=Math.pow(c===0&&a?Number.EPSILON:c,(a||1)*(e?1:i))}),s.score=n})}function $t(t,e){const s=t.matches;e.matches=[],P(s)&&s.forEach(n=>{if(!P(n.indices)||!n.indices.length)return;const{indices:r,value:i}=n;let c={indices:r,value:i};n.key&&(c.key=n.key.src),n.idx>-1&&(c.refIndex=n.idx),e.matches.push(c)})}function Nt(t,e){e.score=t.score}function Lt(t,e,{includeMatches:s=m.includeMatches,includeScore:n=m.includeScore}={}){const r=[];return s&&r.push($t),n&&r.push(Nt),t.map(i=>{const{idx:c}=i,a={item:e[c],refIndex:c};return r.length&&r.forEach(u=>{u(i,a)}),a})}class V{constructor(e,s={},n){this.options={...m,...s},this.options.useExtendedSearch,this._keyStore=new ot(this.options.keys),this.setCollection(e,n)}setCollection(e,s){if(this._docs=e,s&&!(s instanceof xe))throw new Error(st);this._myIndex=s||Pe(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){P(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const s=[];for(let n=0,r=this._docs.length;n<r;n+=1){const i=this._docs[n];e(i,n)&&(this.removeAt(n),n-=1,r-=1,s.push(i))}return s}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:s=-1}={}){const{includeMatches:n,includeScore:r,shouldSort:i,sortFn:c,ignoreFieldNorm:a}=this.options;let u=H(e)?H(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return _t(u,{ignoreFieldNorm:a}),i&&u.sort(c),Ne(s)&&s>-1&&(u=u.slice(0,s)),Lt(u,this._docs,{includeMatches:n,includeScore:r})}_searchStringList(e){const s=ge(e,this.options),{records:n}=this._myIndex,r=[];return n.forEach(({v:i,i:c,n:a})=>{if(!P(i))return;const{isMatch:u,score:l,indices:h}=s.searchIn(i);u&&r.push({item:i,idx:c,matches:[{score:l,value:i,norm:a,indices:h}]})}),r}_searchLogical(e){const s=We(e,this.options),n=(a,u,l)=>{if(!a.children){const{keyId:d,searcher:f}=a,p=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(u,d),searcher:f});return p&&p.length?[{idx:l,item:u,matches:p}]:[]}const h=[];for(let d=0,f=a.children.length;d<f;d+=1){const p=a.children[d],y=n(p,u,l);if(y.length)h.push(...y);else if(a.operator===le.AND)return[]}return h},r=this._myIndex.records,i={},c=[];return r.forEach(({$:a,i:u})=>{if(P(a)){let l=n(s,a,u);l.length&&(i[u]||(i[u]={idx:u,item:a,matches:[]},c.push(i[u])),l.forEach(({matches:h})=>{i[u].matches.push(...h)}))}}),c}_searchObjectList(e){const s=ge(e,this.options),{keys:n,records:r}=this._myIndex,i=[];return r.forEach(({$:c,i:a})=>{if(!P(c))return;let u=[];n.forEach((l,h)=>{u.push(...this._findMatches({key:l,value:c[h],searcher:s}))}),u.length&&i.push({idx:a,item:c,matches:u})}),i}_findMatches({key:e,value:s,searcher:n}){if(!P(s))return[];let r=[];if(J(s))s.forEach(({v:i,i:c,n:a})=>{if(!P(i))return;const{isMatch:u,score:l,indices:h}=n.searchIn(i);u&&r.push({score:l,key:e,value:i,idx:c,norm:a,indices:h})});else{const{v:i,n:c}=s,{isMatch:a,score:u,indices:l}=n.searchIn(i);a&&r.push({score:u,key:e,value:i,norm:c,indices:l})}return r}}V.version="7.1.0";V.createIndex=Pe;V.parseIndex=pt;V.config=m;V.parseQuery=We;vt(kt);const Re={".ts":"📘",".tsx":"⚛️",".js":"📒",".jsx":"⚛️",".py":"🐍",".rs":"🦀",".go":"🔷",".md":"📝",".json":"📋",".yaml":"⚙️",".yml":"⚙️",".css":"🎨",".scss":"🎨",".html":"🌐",".sql":"🗃️",".sh":"💻",".env":"🔐",".toml":"⚙️",".lock":"🔒",default:"📄"};function jt(t){var s;const e="."+((s=t.split(".").pop())==null?void 0:s.toLowerCase());return Re[e]||Re.default}function Tt(t){const e=Ve[t];return(e==null?void 0:e.icon)||"🤖"}function ze(t){const e=Math.floor(t/1e3),s=Math.floor(e/60),n=Math.floor(s/60),r=Math.floor(n/24);return r>0?`${r}d ${n%24}h ago`:n>0?`${n}h ${s%60}m ago`:s>0?`${s}m ago`:"just now"}function Ht(t){const s=Date.now()-t;return ze(s)}function _e(t){switch(t){case"agent":return"Agent";case"command":return"Command";case"area":return"Area";case"modified-file":return"Changed";case"building":return"Server";default:return t}}const $e=["command","agent","building","area","modified-file"];function Pt({isOpen:t,onClose:e,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:r,onOpenFileExplorer:i,onOpenPM2LogsModal:c,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=He(),d=Ye(),f=Je(),p=Xe(),y=A.useRef(e);y.current=e;const D=A.useRef(s);D.current=s;const B=A.useRef(n);B.current=n;const N=A.useRef(r);N.current=r;const L=A.useRef(i);L.current=i;const Q=A.useRef(c);Q.current=c;const K=A.useRef(a);K.current=a;const te=A.useRef(u);te.current=u;const v=A.useRef(l);v.current=l;const[x,T]=A.useState(""),[I,b]=A.useState(0);A.useEffect(()=>{t&&(T(""),b(0))},[t]);const Z=re.getShortcuts(),W=A.useMemo(()=>{if(!t)return[];const o=Z.find(F=>F.id==="spawn-agent"),C=Z.find(F=>F.id==="toggle-commander");return[{id:"cmd-spawn",type:"command",title:"Spawn New Agent",subtitle:o?Be(o):"Alt+N",icon:"➕",action:()=>{y.current(),D.current()}},{id:"cmd-commander",type:"command",title:"Commander View",subtitle:C?Be(C):"Ctrl+K",icon:"📊",action:()=>{y.current(),B.current()}},{id:"cmd-settings",type:"command",title:"Settings & Tools",subtitle:"Configure Tide Commander",icon:"⚙️",action:()=>{y.current(),N.current()}},{id:"cmd-monitoring",type:"command",title:"Monitoring & Logs",subtitle:"Triggers, workflows, events",icon:"📊",action:()=>{var F;y.current(),(F=v.current)==null||F.call(v)}}]},[t,Z]),ie=A.useMemo(()=>t?Array.from(h.values()).map(o=>{const C=(p||[]).filter(j=>j.agentId===o.id).map(j=>j.filePath),F=[...new Set(C)],M=F.map(j=>j.split("/").pop()||j),k=[];o.lastAssignedTask&&k.push(o.lastAssignedTask);const _=`${o.class} • ${o.status} • ${o.cwd}`;let w=`${o.name} ${_}`;M.length>0&&(w+=` ${M.join(" ")} ${F.join(" ")}`),k.length>0&&(w+=` ${k.join(" ")}`);const O=Date.now()-o.lastActivity;let G;return o.lastAssignedTask&&(o.lastAssignedTask.length>150?G=o.lastAssignedTask.slice(0,150)+"...":G=o.lastAssignedTask),{id:`agent-${o.id}`,type:"agent",title:o.name,subtitle:_,lastUserInput:G,timeAway:O,icon:Tt(o.class),_searchText:w,_modifiedFiles:F,_userQueries:k,action:()=>{y.current(),re.selectAgent(o.id)}}}):[],[t,h,p]),R=A.useMemo(()=>t?Array.from(d.values()).map(o=>{var C;return{id:`area-${o.id}`,type:"area",title:o.name,subtitle:`${o.assignedAgentIds.length} agents • ${((C=o.directories)==null?void 0:C.length)||0} folders`,icon:"🗺️",action:()=>{y.current(),re.selectArea(o.id)}}}):[],[t,d]),Y=A.useMemo(()=>t?Array.from(f.values()).filter(o=>o.type==="server"||o.type==="boss"||o.type==="database").map(o=>{var w,O,G,j;const C=o.status==="running"?"🟢":o.status==="stopped"?"🔴":"🟡",F=o.type==="boss"?"👑":o.type==="database"?"🗄️":"🖥️";let k=`${o.type==="boss"?"Boss":o.type==="database"?"Database":"Server"} • ${o.status}`;if(o.type==="database"&&((O=(w=o.database)==null?void 0:w.connections)!=null&&O.length)){const E=o.database.connections[0];k+=` • ${E.engine} @ ${E.host}`}else o.cwd&&(k+=` • ${o.cwd}`);let _=`${o.name} ${o.type} ${o.status} ${o.cwd||""} ${((G=o.pm2)==null?void 0:G.name)||""}`;if(o.type==="database"&&((j=o.database)!=null&&j.connections))for(const E of o.database.connections)_+=` ${E.name} ${E.engine} ${E.host} ${E.database||""} mysql postgresql sql`;return{id:`building-${o.id}`,type:"building",title:o.name,subtitle:k,icon:`${C} ${F}`,_searchText:_,action:()=>{var E;y.current(),o.type==="boss"?K.current(o.id):o.type==="database"?te.current(o.id):(E=o.pm2)!=null&&E.enabled&&Q.current(o.id)}}}):[],[t,f]),ce=A.useMemo(()=>{if(!t)return[];const o=p||[],C=new Set,F=[];for(const M of o){if(C.has(M.filePath))continue;C.add(M.filePath);const k=M.filePath.split("/").pop()||M.filePath,_=M.action==="created"?"Created":M.action==="modified"?"Modified":M.action==="deleted"?"Deleted":"Read";if(F.push({id:`modified-${M.filePath}-${M.timestamp}`,type:"modified-file",title:k,subtitle:`${_} by ${M.agentName} • ${M.filePath}`,matchedText:M.filePath,icon:M.action==="deleted"?"🗑️":jt(M.filePath),action:()=>{y.current();const w=Array.from(re.getState().areas.values());for(const O of w)for(const G of O.directories||[])if(M.filePath.startsWith(G)){re.setFileViewerPath(M.filePath),L.current(O.id);return}re.selectAgent(M.agentId)}}),F.length>=50)break}return F},[t,p]),Ce=A.useMemo(()=>new V(ie,{keys:["title","subtitle","_searchText","lastUserInput"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[ie]),Fe=A.useMemo(()=>new V(W,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[W]),Me=A.useMemo(()=>new V(R,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[R]),we=A.useMemo(()=>new V(ce,{keys:["title","subtitle","matchedText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[ce]),De=A.useMemo(()=>new V(Y,{keys:["title","subtitle","_searchText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[Y]),z=A.useMemo(()=>{if(!x.trim()){const E=[];E.push(...Y);const S=[...ie].sort(($,U)=>{const se=$.timeAway??0,ne=U.timeAway??0;return se-ne});E.push(...S),E.push(...W.slice(0,2)),E.push(...R.slice(0,2));const q={};return $e.forEach(($,U)=>{q[$]=U}),E.sort(($,U)=>(q[$.type]??999)-(q[U.type]??999)),E}const o=x.toLowerCase(),C=Ce.search(x).slice(0,8),F=Fe.search(x).slice(0,3),M=Me.search(x).slice(0,2),k=we.search(x).slice(0,3),_=De.search(x).filter(E=>{const S=E.score??1;return`${E.item.title} ${E.item.subtitle||""} ${E.item._searchText||""}`.toLowerCase().includes(o)||S<=.2}).slice(0,4),w=[],O=[],G=[];for(const E of C){const S={...E.item};if(S._modifiedFiles&&S._modifiedFiles.length>0){const $=S._modifiedFiles.filter(U=>{var oe;const se=((oe=U.split("/").pop())==null?void 0:oe.toLowerCase())||"",ne=U.toLowerCase();return se.includes(o)||ne.includes(o)});$.length>0&&(S.matchedFiles=$)}if(S._userQueries&&S._userQueries.length>0){const $=S._userQueries.find(U=>U.toLowerCase().includes(o));if($)if($.length>200){const se=$.toLowerCase().indexOf(o),ne=Math.max(0,se-60),oe=Math.min($.length,se+o.length+100);S.matchedQuery=(ne>0?"...":"")+$.slice(ne,oe)+(oe<$.length?"...":"")}else S.matchedQuery=$}const q=S.title.toLowerCase();q===o||q.startsWith(o)?O.push(S):G.push(S)}for(const E of O)w.push(E);for(const E of _)w.push(E.item);for(const E of G)w.push(E);for(const E of F)w.push(E.item);for(const E of M)w.push(E.item);for(const E of k)w.push(E.item);const j={};return $e.forEach((E,S)=>{j[E]=S}),w.sort((E,S)=>(j[E.type]??999)-(j[S.type]??999)),w},[x,Ce,Fe,Me,we,De,W,ie,R,Y]);A.useEffect(()=>{I>=z.length&&b(Math.max(0,z.length-1))},[z.length,I]);const Ge=A.useCallback(o=>{if(o.altKey&&!o.ctrlKey&&!o.metaKey&&(o.key==="p"||o.key==="n"||o.key==="P"||o.key==="N")){o.preventDefault(),o.stopPropagation(),o.nativeEvent.stopImmediatePropagation();const C=o.key.toLowerCase();b(C==="p"?F=>F>0?F-1:z.length-1:F=>F<z.length-1?F+1:0);return}switch(o.key){case"Escape":o.preventDefault(),y.current();break;case"ArrowUp":o.preventDefault(),b(C=>C>0?C-1:z.length-1);break;case"ArrowDown":o.preventDefault(),b(C=>C<z.length-1?C+1:0);break;case"Enter":o.preventDefault(),z[I]&&z[I].action();break}},[z,I]),Ue=A.useCallback((o,C)=>{if(!C||!o)return o;const F=o.toLowerCase(),M=C.toLowerCase(),k=[];let _=0,w=F.indexOf(M),O=0;for(;w!==-1;)w>_&&k.push(o.slice(_,w)),k.push(he.createElement("mark",{key:O++,className:"spotlight-highlight"},o.slice(w,w+C.length))),_=w+C.length,w=F.indexOf(M,_);return _<o.length&&k.push(o.slice(_)),k.length>0?he.createElement(he.Fragment,null,...k):o},[]);return{query:x,setQuery:T,selectedIndex:I,setSelectedIndex:b,results:z,handleKeyDown:Ge,highlightMatch:Ue}}const Kt=A.forwardRef(function({query:e,onQueryChange:s,onKeyDown:n,onResetSelection:r},i){const{t:c}=Ee(["common"]);return g.jsxs("div",{className:"spotlight-input-wrapper",children:[g.jsx("span",{className:"spotlight-search-icon",children:"⌘"}),g.jsx("input",{ref:i,type:"text",className:"spotlight-input",placeholder:c("common:search.spotlightPlaceholder"),value:e,onChange:a=>{s(a.target.value),r()},onKeyDown:n,autoFocus:!0,spellCheck:!1}),g.jsxs("div",{className:"spotlight-input-hints",children:[g.jsx("span",{className:"spotlight-shortcut-hint",children:"↑↓"}),g.jsx("span",{className:"spotlight-shortcut-hint",children:"Enter"}),g.jsx("span",{className:"spotlight-shortcut-hint",children:"Esc"})]})]})}),Ot=A.memo(function({result:e,isSelected:s,query:n,highlightMatch:r,onClick:i,onMouseEnter:c}){const a=e.activityText||e.matchedFiles&&e.matchedFiles.length>0||e.matchedQuery;return g.jsxs("div",{className:`spotlight-item ${s?"selected":""} ${e.activityText?"has-activity":""}`,onClick:i,onMouseEnter:c,role:"option","aria-selected":s,children:[g.jsx("span",{className:"spotlight-item-icon","aria-hidden":"true",children:e.icon}),g.jsxs("div",{className:"spotlight-item-content",children:[g.jsxs("div",{className:"spotlight-item-header",children:[g.jsx("span",{className:"spotlight-item-title",children:r(e.title,n)}),g.jsx("span",{className:`spotlight-item-type ${e.type}`,"aria-label":_e(e.type),children:_e(e.type)})]}),e.subtitle&&g.jsx("span",{className:"spotlight-item-subtitle",children:r(e.subtitle,n)}),e.activityText&&g.jsx("span",{className:"spotlight-item-activity",children:r(e.activityText,n)}),a&&g.jsxs("div",{className:"spotlight-item-details",children:[e.matchedFiles&&e.matchedFiles.length>0&&g.jsx("span",{className:"spotlight-item-files",children:e.matchedFiles.map((u,l)=>g.jsxs("span",{className:"file-badge",children:[l>0&&g.jsx("span",{className:"file-separator",children:"•"}),r(u.split("/").pop()||u,n)]},u))}),e.matchedQuery&&g.jsx("span",{className:"spotlight-item-query",children:r(e.matchedQuery,n)})]}),e.timeAway!==void 0&&g.jsx("span",{className:"spotlight-item-time",children:g.jsxs("span",{className:"spotlight-time-away",children:["Idle: ",ze(e.timeAway)]})}),e.lastUserInput&&!e.matchedQuery&&g.jsxs("span",{className:"spotlight-item-last-input",children:['"',r(e.lastUserInput,n),'"']})]})]})}),Qt=A.forwardRef(function({results:e,selectedIndex:s,query:n,highlightMatch:r,onSelectIndex:i},c){const{t:a}=Ee(["terminal"]),u=A.useRef(!1);A.useEffect(()=>{u.current=!1},[e]),A.useEffect(()=>{const d=typeof c=="function"?null:c==null?void 0:c.current;if(!d)return;const f=()=>{u.current=!0};return d.addEventListener("mousemove",f),()=>{d.removeEventListener("mousemove",f)}},[c,e]);const l={command:a("terminal:spotlight.categories.commands"),agent:a("terminal:spotlight.categories.agents"),building:a("terminal:spotlight.categories.infrastructure"),area:a("terminal:spotlight.categories.areas"),"modified-file":a("terminal:spotlight.categories.modifiedFiles")},h=A.useMemo(()=>{const d=[];let f=null,p=[];return e.forEach((y,D)=>{y.type!==f&&(f!==null&&p.length>0&&d.push([f,p]),f=y.type,p=[]),p.push({result:y,index:D})}),f!==null&&p.length>0&&d.push([f,p]),d},[e]);return A.useEffect(()=>{if(!c||typeof c=="function")return;const d=c.current;if(!d)return;const f=d.querySelector(".spotlight-item.selected");f&&f.scrollIntoView({block:"nearest",behavior:"smooth"})},[s,c]),e.length===0?g.jsx("div",{className:"spotlight-results",ref:c,children:g.jsx("div",{className:"spotlight-empty",children:a("terminal:spotlight.noResults")})}):g.jsx("div",{className:"spotlight-results",ref:c,children:h.map(([d,f])=>g.jsxs("div",{children:[h.length>1&&g.jsx("div",{className:"spotlight-category-header",children:l[d]||d}),f.map(({result:p,index:y})=>g.jsx(Ot,{result:p,isSelected:y===s,query:n,highlightMatch:r,onClick:()=>p.action(),onMouseEnter:()=>{u.current&&i(y)}},p.id))]},d))})}),Wt=A.memo(function(){const{t:e}=Ee(["terminal"]);return g.jsxs("div",{className:"spotlight-footer",children:[g.jsxs("div",{className:"spotlight-footer-left",children:[g.jsxs("span",{className:"spotlight-footer-hint",children:[g.jsx("kbd",{children:"↑"}),g.jsx("kbd",{children:"↓"})," ",g.jsx("kbd",{children:"Alt+N"}),g.jsx("kbd",{children:"Alt+P"})," ",e("terminal:spotlight.navigate")]}),g.jsxs("span",{className:"spotlight-footer-hint",children:[g.jsx("kbd",{children:"Enter"})," ",e("terminal:spotlight.select")]})]}),g.jsx("div",{className:"spotlight-footer-right",children:g.jsxs("span",{className:"spotlight-footer-hint",children:[g.jsx("kbd",{children:"Esc"})," ",e("common:buttons.close")]})})]})});function Yt({isOpen:t,onClose:e,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:r,onOpenFileExplorer:i,onOpenPM2LogsModal:c,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=A.useRef(null),d=A.useRef(null),f=A.useRef(0),{query:p,setQuery:y,selectedIndex:D,setSelectedIndex:B,results:N,handleKeyDown:L,highlightMatch:Q}=Pt({isOpen:t,onClose:e,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:r,onOpenFileExplorer:i,onOpenPM2LogsModal:c,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l});f.current=N.length,A.useEffect(()=>{t&&setTimeout(()=>{var v;(v=h.current)==null||v.focus()},50)},[t]),A.useEffect(()=>{if(!t)return;const v=x=>{if(x.key==="Escape"){x.preventDefault(),x.stopPropagation(),x.stopImmediatePropagation(),e();return}if(x.altKey&&!x.ctrlKey&&!x.metaKey&&(x.key==="n"||x.key==="p"||x.key==="N"||x.key==="P")){x.preventDefault(),x.stopPropagation(),x.stopImmediatePropagation();const T=x.key.toLowerCase(),I=f.current;B(T==="p"?b=>b>0?b-1:I-1:b=>b<I-1?b+1:0);return}};return window.addEventListener("keydown",v,{capture:!0}),()=>{window.removeEventListener("keydown",v,{capture:!0})}},[t,e]);const K=A.useCallback(v=>{v.target===v.currentTarget&&e()},[e]),te=A.useCallback(()=>{B(0)},[B]);return t?g.jsx("div",{className:"spotlight-overlay",onClick:K,children:g.jsxs("div",{className:"spotlight-modal",children:[g.jsx(Kt,{ref:h,query:p,onQueryChange:y,onKeyDown:L,onResetSelection:te}),g.jsx(Qt,{ref:d,results:N,selectedIndex:D,query:p,highlightMatch:Q,onSelectIndex:B}),g.jsx(Wt,{})]})}):null}export{Re as FILE_ICONS,Yt as Spotlight,Wt as SpotlightFooter,Kt as SpotlightInput,Ot as SpotlightItem,Qt as SpotlightResults,ze as formatDuration,Ht as formatRelativeTime,Tt as getAgentIcon,jt as getFileIconFromPath,_e as getTypeLabel,Pt as useSpotlightSearch};
@@ -1,4 +1,4 @@
1
- import{at as He,r as t,s as I,l as Re,au as ye,W as Oe,j as e,u as me,av as _e,aw as Pe,ax as Be,ay as Ue,m as Ke,az as We,aA as Ee,aB as Ve,aC as ze,aD as Ge,aE as qe,a4 as Ye,U as Ae,S as oe,Z as Je,V as Xe,C as Ze,a2 as Me,I as Qe,K as et,aF as tt,n as J,aG as st}from"./main-5tHJV1Fa.js";import{F as nt}from"./index-D8ooZD2k.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Se={status:"all",activity:"all",sort:"activity"},at={"1h":3600*1e3,"6h":360*60*1e3,"24h":1440*60*1e3},Ne=20,ue=3,ot={idle:"#4aff9e",working:"#4a9eff",waiting:"#ff9e4a",waiting_permission:"#ffcc00",error:"#ff4a4a",offline:"#888888",orphaned:"#ff9e4a"},ct=12e4;function lt(n){return n.trim().replace(/\r\n/g,`
1
+ import{at as He,r as t,s as I,l as Re,au as ye,W as Oe,j as e,u as me,av as _e,aw as Pe,ax as Be,ay as Ue,m as Ke,az as We,aA as Ee,aB as Ve,aC as ze,aD as Ge,aE as qe,a4 as Ye,U as Ae,S as oe,Z as Je,V as Xe,C as Ze,a2 as Me,I as Qe,K as et,aF as tt,n as J,aG as st}from"./main-9Cs_hNs-.js";import{F as nt}from"./index-CMwlYuij.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Se={status:"all",activity:"all",sort:"activity"},at={"1h":3600*1e3,"6h":360*60*1e3,"24h":1440*60*1e3},Ne=20,ue=3,ot={idle:"#4aff9e",working:"#4a9eff",waiting:"#ff9e4a",waiting_permission:"#ffcc00",error:"#ff4a4a",offline:"#888888",orphaned:"#ff9e4a"},ct=12e4;function lt(n){return n.trim().replace(/\r\n/g,`
2
2
  `)}function Te(n,a){return`${n}:${lt(a)}`}function rt(n,a,o,f){if(n.uuid&&a.has(n.uuid))return!1;const p=n.isUserPrompt?"user":"assistant",d=Te(p,n.text),M=n.timestamp||0,A=o.get(d);return A!==void 0&&Math.abs(M-A)<=ct?!1:M>f}function it({isOpen:n,agents:a}){const o=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(w=>`${w.id}:${w.sessionId||""}`).sort().join(","),[a]);t.useEffect(()=>{n||(d.current.clear(),p(new Map))},[n]),t.useEffect(()=>{if(!n)return;const w=new Set(Array.from(a.keys()));for(const i of d.current)w.has(i)||d.current.delete(i);let h=null;o>0&&(h=I.preserveOutputs(),d.current.clear());const v=async(i,j,F=0)=>{if(d.current.add(i.id),F>0&&await new Promise(g=>setTimeout(g,F)),p(g=>{const b=new Map(g);return b.set(i.id,{agentId:i.id,messages:[],loading:!0,hasMore:!1,totalCount:0}),b}),!i.sessionId){j&&j.length>0&&I.mergeOutputsWithHistory(i.id,[],j),p(g=>{const b=new Map(g);return b.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),b});return}try{const b=await(await Oe(Re(`/api/agents/${i.id}/history?limit=${ye}&offset=0`))).json(),P=b.messages||[],W=P.length>0?Math.max(...P.map(C=>C.timestamp?new Date(C.timestamp).getTime():0)):0,q=new Set(P.map(C=>C.uuid).filter(C=>!!C)),V=new Map;for(const C of P){if(C.type!=="user"&&C.type!=="assistant")continue;const l=Te(C.type,C.content),L=C.timestamp?new Date(C.timestamp).getTime():0,K=V.get(l)??0;L>K&&V.set(l,L)}const z=I.getOutputs(i.id),U=(j&&j.length>0?[...j,...z]:z).filter(C=>rt(C,q,V,W));I.clearOutputs(i.id);for(const C of U)I.addOutput(i.id,C);p(C=>{const l=new Map(C);return l.set(i.id,{agentId:i.id,messages:P,loading:!1,hasMore:b.hasMore||!1,totalCount:b.totalCount||0}),l})}catch(g){if(console.error(`Failed to load history for ${i.name}:`,g),j&&j.length>0){I.clearOutputs(i.id);for(const b of j)I.addOutput(i.id,b)}p(b=>{const P=new Map(b);return P.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),P})}},u=o>0?500:0,D=Array.from(a.values());for(const i of D)if(!d.current.has(i.id)){const j=h==null?void 0:h.get(i.id);v(i,j,u)}},[n,M,A,o]);const R=t.useRef(a),N=t.useRef(f);R.current=a,N.current=f;const k=t.useCallback(async w=>{const h=R.current.get(w),v=N.current.get(w);if(!(h!=null&&h.sessionId)||!v||!v.hasMore)return;const u=v.messages.length;try{const i=await(await fetch(Re(`/api/agents/${w}/history?limit=${ye}&offset=${u}`))).json();i.messages&&i.messages.length>0&&p(j=>{const F=new Map(j),g=j.get(w);return g&&F.set(w,{...g,messages:[...i.messages,...g.messages],hasMore:i.hasMore||!1}),F})}catch(D){console.error(`Failed to load more history for agent ${w}:`,D)}},[]),E=t.useCallback(w=>{d.current.delete(w),p(h=>{const v=new Map(h),u=h.get(w);return u&&v.set(w,{...u,messages:[],hasMore:!1,totalCount:0,loading:!1}),v})},[]);return{histories:f,loadMoreHistory:k,clearAgentHistory:E}}function dt({command:n,onCommandChange:a,useTextarea:o,forceTextarea:f,onForceTextarea:p,onSend:d,canSend:M,attachedFiles:A,onAddFile:R,onRemoveFile:N,uploadFile:k,onAddPastedText:E,placeholder:w="Message...",className:h="",compact:v=!1,inputRef:u}){const D=t.useRef(null),i=t.useRef(null),j=t.useRef(o);t.useEffect(()=>{if(o&&!j.current&&i.current){const l=i.current;l.focus(),l.selectionStart=l.selectionEnd=l.value.length}j.current=o},[o]),t.useEffect(()=>{const l=i.current;if(!l||!o)return;l.style.height="auto";const L=v?120:180,K=Math.min(l.scrollHeight,L);l.style.height=`${K}px`},[n,o,v]);const F=t.useCallback(async l=>{const L=l.clipboardData.items;for(const _ of L)if(_.type.startsWith("image/")){l.preventDefault();const $=_.getAsFile();if($){const H=await k($);H&&R(H)}return}const K=l.clipboardData.files;if(K.length>0){l.preventDefault();for(const _ of K){const $=await k(_);$&&R($)}return}const B=l.clipboardData.getData("text"),ee=(B.match(/\n/g)||[]).length+1;if(ee>5){l.preventDefault();const $=`[Pasted text #${E(B)} +${ee} lines]`,H=l.target,te=H.selectionStart||0,ne=H.selectionEnd||0,se=n.slice(0,te)+$+n.slice(ne);a(se),o||p(!0)}},[n,a,o,p,k,R,E]),g=t.useCallback(async l=>{const L=l.target.files;if(L){for(const K of L){const B=await k(K);B&&R(B)}D.current&&(D.current.value="")}},[k,R]),b=t.useCallback(l=>{if(l.key==="Enter"&&l.shiftKey){o||(l.preventDefault(),p(!0));return}l.key==="Enter"&&(l.preventDefault(),d())},[o,p,d]),P=t.useCallback(l=>{},[]),W=t.useCallback(l=>{l.button===1&&(l.preventDefault(),l.stopPropagation())},[]),q=t.useCallback(l=>{i.current=l,u==null||u(l)},[u]),V=v?"agent-panel-input":"guake-input",z=v?"agent-panel-input-container":"guake-input-container",X=v?"agent-panel-attach-btn":"guake-attach-btn",U=v?"agent-panel-send-btn":"",C=o?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(l=>e.jsxs("div",{className:`${v?"agent-panel-attachment":"guake-attachment"} ${l.isImage?"is-image":""}`,children:[e.jsx("span",{className:v?"agent-panel-attachment-icon":"guake-attachment-icon",children:l.isImage?"🖼️":"📎"}),e.jsx("span",{className:v?"agent-panel-attachment-name":"guake-attachment-name",title:l.path,children:l.name}),!v&&e.jsxs("span",{className:"guake-attachment-size",children:["(",Math.round(l.size/1024),"KB)"]}),e.jsx("button",{className:v?"agent-panel-attachment-remove":"guake-attachment-remove",onClick:()=>N(l.id),title:"Remove",children:"×"})]},l.id))}),e.jsxs("div",{className:`${V} ${C} ${h}`,children:[e.jsx("input",{ref:D,type:"file",multiple:!0,onChange:g,style:{display:"none"},accept:"*"}),e.jsxs("div",{className:z,onAuxClick:W,children:[e.jsx("button",{className:X,onClick:()=>{var l;return(l=D.current)==null?void 0:l.click()},title:"Attach file (or paste image)",children:"📎"}),o?e.jsx("textarea",{ref:q,placeholder:w,value:n,onChange:l=>a(l.target.value),onKeyDown:b,onPaste:F,onMouseDown:P}):e.jsx("input",{ref:u,type:"text",placeholder:w,value:n,onChange:l=>a(l.target.value),onKeyDown:b,onPaste:F,onMouseDown:P}),e.jsx("button",{className:U,onClick:d,disabled:!M,title:"Send",children:"➤"})]})]})]})}function ut(n){const a=Math.floor(n/1e3),o=Math.floor(a/60),f=a%60;return`${o}:${f.toString().padStart(2,"0")}`}const mt=t.memo(function({agentId:a,isWorking:o,timestamp:f}){const{t:p}=me(["terminal"]),[d,M]=t.useState(0);return t.useEffect(()=>{if(!o||!f){M(0);return}M(Date.now()-f);const A=setInterval(()=>{M(Date.now()-f)},1e3);return()=>clearInterval(A)},[o,f]),o?e.jsxs("div",{className:"guake-stop-bar",children:[e.jsx("span",{className:"guake-elapsed-timer",children:ut(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("span",{className:"stop-label",children:p("terminal:input.stop")})]})]}):null});function ft({agent:n,history:a,outputs:o,isExpanded:f,isFocused:p,advancedView:d,onExpand:M,onFocus:A,inputRef:R,onLoadMore:N,onClearHistory:k}){const{t:E}=me(["terminal","common"]),w=_e(n.id),h=t.useRef(null),[v,u]=t.useState(!1),D=t.useRef(0),i=t.useRef(!1),[j,F]=t.useState(!0),[g,b]=t.useState(!1),[P,W]=t.useState(null),[q,V]=t.useState(null),[z,X]=t.useState(null);Pe(`commander-image-modal-${n.id}`,P!==null,()=>W(null));const{command:U,setCommand:C,forceTextarea:l,setForceTextarea:L,useTextarea:K,setPastedTexts:B,incrementPastedCount:ee,resetPastedCount:_,attachedFiles:$,setAttachedFiles:H,removeAttachedFile:te,uploadFile:ne,expandPastedTexts:se}=Be({selectedAgentId:n.id}),ae=U.trim().length>0||$.length>0,s=Ue({outputs:o,viewMode:d?"advanced":"simple"}),c=t.useMemo(()=>{const S=Ke(n);return{usedPercent:S.usedPercent,freePercent:S.freePercent,hasData:!!n.contextStats,totalTokens:S.totalTokens,contextWindow:S.contextWindow}},[n.contextStats,n.contextUsed,n.contextLimit]),x=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)},[]),T=t.useRef(f),Z=t.useRef(p);t.useEffect(()=>{(f&&!T.current||p&&!Z.current)&&(i.current=!1,F(!0),b(!0)),T.current=f,Z.current=p},[f,p]);const Q=t.useRef(a==null?void 0:a.loading);t.useEffect(()=>{Q.current&&!(a!=null&&a.loading)&&(i.current=!1,F(!0),b(!0)),Q.current=a==null?void 0:a.loading},[a==null?void 0:a.loading]),t.useEffect(()=>{if(!g)return;const S=h.current;if(!S)return;const y=performance.now();let O=0,de=-1,ke;const Ie=()=>{const{scrollTop:$e,scrollHeight:be,clientHeight:Fe}=S,Le=be-$e-Fe<=2;if(Math.abs(be-de)<=1&&Le?O+=1:O=0,de=be,O>=3){b(!1);return}if(performance.now()-y>5e3){b(!1);return}ke=requestAnimationFrame(Ie)};return ke=requestAnimationFrame(Ie),()=>cancelAnimationFrame(ke)},[g]),t.useEffect(()=>{i.current||F(!0)},[s.length]);const G=t.useCallback(()=>!1,[]),re=t.useCallback(S=>{const y=ee();return B(O=>new Map(O).set(y,S)),y},[ee,B]),pe=t.useCallback(S=>{H(y=>[...y,S])},[H]),he=t.useCallback(()=>{if(!ae)return;if(U.trim()==="/clear"&&$.length===0){I.clearContext(n.id),k(),C(""),L(!1),B(new Map),H([]),_();return}let S=se(U.trim());if($.length>0){const y=$.map(O=>O.isImage?`[Image: ${O.path}]`:`[File: ${O.path}]`).join(`
3
3
  `);S=S?`${S}
4
4