tide-commander 1.55.2 → 1.56.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-NMLA8Tb-.js → BossLogsModal-BC_jQLh8.js} +1 -1
  2. package/dist/assets/{BossSpawnModal-CHWYUZ5g.js → BossSpawnModal-B72i5voc.js} +1 -1
  3. package/dist/assets/{ControlsModal-B7YvUMVm.js → ControlsModal-DcdQqTH4.js} +1 -1
  4. package/dist/assets/{DockerLogsModal-CaspMYEh.js → DockerLogsModal-B8x_ivqO.js} +1 -1
  5. package/dist/assets/{EmbeddedEditor-kYx4AdLw.js → EmbeddedEditor-D9LcnB5d.js} +1 -1
  6. package/dist/assets/{GmailOAuthSetup-9eQ1r9Ar.js → GmailOAuthSetup-otrOoA9u.js} +1 -1
  7. package/dist/assets/{GoogleOAuthSetup-Pi7a58Mi.js → GoogleOAuthSetup-BPUBFDuT.js} +1 -1
  8. package/dist/assets/{IframeModal-z1T59LJS.js → IframeModal-CU9CJzXv.js} +1 -1
  9. package/dist/assets/{IntegrationsPanel-CB9QtfvD.js → IntegrationsPanel-DOIhvWCo.js} +2 -2
  10. package/dist/assets/{LogViewerModal-BBdr9r3i.js → LogViewerModal-B_Egijt4.js} +1 -1
  11. package/dist/assets/{MonitoringModal-CUZ4Xhuk.js → MonitoringModal-DfiF8Ois.js} +1 -1
  12. package/dist/assets/{PM2LogsModal-Bt16sW5A.js → PM2LogsModal-D_AFUT5u.js} +1 -1
  13. package/dist/assets/{RestoreArchivedAreaModal-BETGHA22.js → RestoreArchivedAreaModal-uTcGOQwr.js} +1 -1
  14. package/dist/assets/{Scene2DCanvas-BelfJXGw.js → Scene2DCanvas-CDSiA6Q-.js} +1 -1
  15. package/dist/assets/{SceneManager-BI_UCXtB.js → SceneManager-TsF_FO-E.js} +1 -1
  16. package/dist/assets/{SkillsPanel-BHjnx8LP.js → SkillsPanel-zhSpW4aZ.js} +1 -1
  17. package/dist/assets/{SpawnModal-Dwfx-NFz.js → SpawnModal-CZbl8gUh.js} +1 -1
  18. package/dist/assets/{SubordinateAssignmentModal-DHRZ-Evy.js → SubordinateAssignmentModal-BRGbwqD6.js} +1 -1
  19. package/dist/assets/{TriggerManagerPanel-cUWM5poU.js → TriggerManagerPanel-Dt177r71.js} +1 -1
  20. package/dist/assets/{WorkflowEditorPanel-Ha9SXdvW.js → WorkflowEditorPanel-BVqNyyfi.js} +1 -1
  21. package/dist/assets/{index-CesYqhoW.js → index-5Ho0_Q1V.js} +1 -1
  22. package/dist/assets/{index-DBgGw8Bd.js → index-BIikPV5c.js} +1 -1
  23. package/dist/assets/{index-Vcs3Odgf.js → index-BLGpGzmM.js} +1 -1
  24. package/dist/assets/{index-BsEoXc0j.js → index-CzIqp9mo.js} +2 -2
  25. package/dist/assets/{index-CD9Q_div.js → index-DqwrYg9u.js} +1 -1
  26. package/dist/assets/{index-xU9wiWEU.js → index-Dw2g5HNf.js} +1 -1
  27. package/dist/assets/{index-BvZsOpS_.js → index-mBUzmvwn.js} +3 -3
  28. package/dist/assets/{index-De9wibqy.js → index-xyE9C6tP.js} +1 -1
  29. package/dist/assets/main-DrWm3QHp.css +1 -0
  30. package/dist/assets/{main-B_0o0aI9.js → main-rXJ69gpC.js} +78 -77
  31. package/dist/assets/{web-DGSbcqAM.js → web-BsAda6Xu.js} +1 -1
  32. package/dist/assets/{web-D2W-1YTG.js → web-Cg2MK9Og.js} +1 -1
  33. package/dist/index.html +2 -2
  34. package/dist/src/packages/server/integrations/jira/jira-client.js +1 -3
  35. package/package.json +1 -1
  36. package/dist/assets/main-DTgTDvIL.css +0 -1
@@ -1,4 +1,4 @@
1
- import{u as Pe,bp as Qe,bq as Ze,r as i,h as Me,j as e,s as v,br as eo,bs as oo,bt as so,al as Re,l as D,k as Ae,$ as ro,N as to,a0 as ao,bu as P,G as io,a6 as Ne,I as lo,a5 as Oe}from"./main-B_0o0aI9.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const co=[{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"}],no=[{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"}],yo=`## Instructions
1
+ import{u as Pe,bp as Qe,bq as Ze,r as i,h as Me,j as e,s as v,br as eo,bs as oo,bt as so,al as Re,l as D,k as Ae,$ as ro,N as to,a0 as ao,bu as P,G as io,a6 as Ne,I as lo,a5 as Oe}from"./main-rXJ69gpC.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const co=[{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"}],no=[{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"}],yo=`## Instructions
2
2
 
3
3
  Describe step-by-step instructions for this skill here.
4
4
 
@@ -1 +1 @@
1
- import{u as Qe,$ as Ve,a0 as Ze,a1 as es,a2 as ss,r as t,a3 as as,S as ke,a4 as te,A as ye,l as le,a5 as ns,s as b,h as ts,j as s,a6 as ls,G as Ae,a7 as x,a8 as os,I as G,a9 as oe,aa as $,ab as K,ac as ie,ad as is}from"./main-B_0o0aI9.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function De(c,g){const S=g.filter(C=>!c.has(C));return S.length===0?`${g[Math.floor(Math.random()*g.length)]}-${Date.now()%1e3}`:S[Math.floor(Math.random()*S.length)]}function ms({isOpen:c,onClose:g,onSpawnStart:S,onSpawnEnd:C,spawnPosition:Ee,spawnAreaId:v}){const{t:a}=Qe(["terminal","common"]),P=Ve(),p=Ze(),ce=es(),H=ce.length>0?ce:ss,[m,N]=t.useState(""),[M,T]=t.useState(()=>as(ke.LAST_CWD)),[i,J]=t.useState("scout"),[re,D]=t.useState(!1),[Ie,F]=t.useState(!1),[de,Y]=t.useState(!1),[pe,me]=t.useState(""),[k,X]=t.useState([]),[y,z]=t.useState(null),[Le,ue]=t.useState(!1),[E,he]=t.useState(""),[u,_e]=t.useState(""),[R,$e]=t.useState(!0),[U,Pe]=t.useState("bypass"),[o,Q]=t.useState("claude"),[j,I]=t.useState({fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),[we,V]=t.useState(new Set),[Z,xe]=t.useState("claude-opus-4-7"),[ee,fe]=t.useState("high"),[se,Te]=t.useState("gpt-5.3-codex"),[ae,Fe]=t.useState("minimax/MiniMax-M1-80k"),[ge,ze]=t.useState(""),[A,Re]=t.useState(""),q=t.useRef(null),je=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&&!je.current&&h.length>0){const n=h.filter(l=>Ue.includes(l.slug)).map(l=>l.id);n.length>0&&V(new Set(n))}je.current=c},[c,h]);const ve=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]),qe=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 We=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]),Ne=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 te;const e=u.toLowerCase();return te.filter(n=>{const l=ye[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&&J(e[0])},[c,u,W,O,i]);const r=t.useMemo(()=>p.find(e=>e.id===i),[p,i]),Oe=t.useMemo(()=>{if(r!=null&&r.model)return r.model},[r]),Be=t.useMemo(()=>{if(r!=null&&r.customModelPath)return le(`/api/custom-models/${r.id}`)},[r]),Ge=r==null?void 0:r.modelScale,Ke=t.useMemo(()=>r?"scout":i,[i,r]),B=t.useCallback(async e=>{ue(!0);try{const n=e?le(`/api/agents/claude-sessions?cwd=${encodeURIComponent(e)}`):le("/api/agents/claude-sessions"),d=await(await ns(n)).json();X(d.sessions||[])}catch(n){console.error("Failed to fetch sessions:",n),X([])}finally{ue(!1)}},[]);t.useEffect(()=>{c?B(M||void 0):(X([]),z(null),he(""))},[c,B]),t.useEffect(()=>{if(!c)return;const e=setTimeout(()=>{B(M||void 0),z(null)},300);return()=>clearTimeout(e)},[M,c,B]),t.useEffect(()=>{if(!c||!v)return;const e=b.getState().areas.get(v);if(e!=null&&e.directories&&e.directories.length>0){T(e.directories[0]);return}const n=Array.from(b.getState().agents.values()).filter(f=>{var _;return((_=b.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(b.getState().agents.values()).map(w=>w.name)),n=De(e,H),l=p.find(w=>w.id===i),d=l?`${l.name} ${n}`:n;N(d),q.current&&(q.current.focus(),q.current.select())}},[c,H]),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"&&xe("claude-opus-4-7")},[i]);const He=()=>{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:",U),console.log("[SpawnModal] Provider:",o),console.log("[SpawnModal] Use Chrome:",R),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(b.getState().agents.values()).map(f=>f.name));N(De(w,H));return}is(ke.LAST_CWD,e),D(!0),S();const n=Array.from(we),l=ge.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"?R:!1,permissionMode:U,provider:o,codexConfig:o==="codex"?j:void 0,codexModel:o==="codex"?se:void 0,opencodeModel:o==="opencode"?ae: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,b.spawnAgent(m.trim(),i,e.trim(),Ee||void 0,y||void 0,o==="claude"?R:!1,U,n,o,o==="codex"?j:void 0,o==="codex"?se:void 0,o==="claude"?Z:void 0,l,o==="claude"?ee:void 0,o==="opencode"?ae:void 0)},be=()=>{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()},Ce=e=>{console.log("[SpawnModal] Directory not found:",e),D(!1),me(e),Y(!0),C()},Me=()=>{Y(!1),D(!0),S(),b.createDirectoryAndSpawn(pe,m.trim(),i)},ne=()=>{Y(!1),me(""),L()};t.useEffect(()=>(window.__spawnModalSuccess=be,window.__spawnModalError=Se,window.__spawnModalDirNotFound=Ce,()=>{L(),delete window.__spawnModalSuccess,delete window.__spawnModalError,delete window.__spawnModalDirNotFound}),[m,i,be,Se,Ce,L]);const{handleMouseDown:Je,handleClick:Ye}=ts(g),Xe=e=>{e.key==="Escape"&&g()};return!c&&!de?null:de?s.jsx("div",{className:"modal-overlay visible",onClick:ne,onKeyDown:e=>{e.key==="Escape"&&ne(),e.key==="Enter"&&Me()},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:pe}),s.jsx("p",{children:a("terminal:spawn.wouldYouCreate")})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:ne,children:a("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-primary",onClick:Me,autoFocus:!0,children:a("terminal:spawn.createDirectory")})]})]})}):s.jsx("div",{className:`modal-overlay ${c?"visible":""}`,onMouseDown:Je,onClick:Ye,onKeyDown:Xe,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(ls,{agentClass:Ke,modelFile:Oe,customModelUrl:Be,modelScale:Ge,width:100,height:120})}),s.jsxs("div",{className:"spawn-class-section",children:[s.jsx("div",{className:"spawn-class-label",children:a("terminal:spawn.agentClass")}),p.length+te.length>6&&s.jsx("input",{type:"text",className:"spawn-input class-search-input",placeholder:a("terminal:spawn.filterClasses"),value:u,onChange:e=>_e(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:()=>J(e.id),title:e.description,children:[s.jsx(Ae,{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=ye[e.id];return s.jsxs("button",{className:`class-chip ${i===e.id?"selected":""}`,onClick:()=>J(e.id),title:n.description,children:[s.jsx(Ae,{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(os,{value:M,onChange:e=>{T(e),F(!1)},placeholder:a("terminal:spawn.workingDirPlaceholder"),className:`spawn-input ${Ie?"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:()=>Q("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:()=>Q("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:()=>Q("opencode"),title:"Use OpenCode CLI (multi-provider)",children:[s.jsx("span",{children:s.jsx(G,{name:"status-pending",size:12,weight:"fill",color:"#4ade80"})}),s.jsx("span",{children:"OpenCode"})]})]})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsxs("label",{className:"spawn-label",children:[a("common:labels.permissions"),s.jsx(x,{text:a("terminal:spawn.helpPermission"),title:a("terminal:spawn.permissionMode"),position:"top",size:"sm"})]}),s.jsx("div",{className:"spawn-select-row",children:Object.keys(oe).map(e=>s.jsxs("button",{className:`spawn-select-btn ${U===e?"selected":""}`,onClick:()=>Pe(e),title:oe[e].description,children:[s.jsx("span",{children:s.jsx(G,{name:e==="bypass"?"bolt":"lock",size:12})}),s.jsx("span",{children:oe[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:()=>xe(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(K).map(e=>s.jsxs("button",{className:`spawn-select-btn ${se===e?"selected":""}`,onClick:()=>Te(e),title:K[e].description,children:[s.jsx("span",{children:K[e].icon}),s.jsx("span",{children:K[e].label})]},e))}):o==="opencode"?s.jsx("input",{type:"text",className:"spawn-input",value:ae,onChange:e=>Fe(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 ${ee===void 0?"selected":""}`,onClick:()=>fe(void 0),title:"Use default effort level",children:s.jsx("span",{children:"Default"})}),Object.keys(ie).map(e=>s.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${ee===e?"selected":""}`,onClick:()=>fe(e),title:ie[e].description,children:s.jsx("span",{children:ie[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:R,onChange:e=>$e(e.target.checked),disabled:o!=="claude"}),s.jsxs("span",{children:[s.jsx(G,{name:"globe",size:12})," ",a("terminal:spawn.chromeBrowser")]}),s.jsx(x,{text:a(o==="claude"?"terminal:spawn.helpChrome":"terminal:spawn.helpChromeDisabled"),title:a("terminal:spawn.chromeBrowser"),position:"top",size:"sm"})]})})]})]}),o==="codex"&&s.jsxs("div",{className:"codex-config-section",children:[s.jsx("div",{className:"codex-config-title",children:a("terminal:spawn.codex.configuration")}),s.jsxs("div",{className:"codex-config-options",children:[s.jsxs("div",{className:"codex-option-group",children:[s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked: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:[ve.map(e=>{const n=we.has(e.id);return We.some(d=>d.id===e.id)?null:s.jsxs("button",{className:`spawn-skill-chip ${n?"selected":""}`,onClick:()=>qe(e.id),title:e.description,children:[n&&s.jsx("span",{className:"spawn-skill-check",children:s.jsx(G,{name:"check",size:10})}),s.jsx("span",{children:e.name}),e.builtin&&s.jsx("span",{className:"spawn-skill-builtin",children:"TC"})]},e.id)}),A&&ve.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:ge,onChange:e=>ze(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=>he(e.target.value)}),s.jsx("div",{className:"sessions-list",children:Le?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")}):Ne.length===0?s.jsx("div",{className:"sessions-empty",children:a("terminal:spawn.noSessionsMatch",{query:E})}):Ne.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?z(null):(z(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:He,disabled:re,children:a(re?"common:buttons.deploying":"common:buttons2.deploy")})]})]})})}export{ms as SpawnModal};
1
+ import{u as Qe,$ as Ve,a0 as Ze,a1 as es,a2 as ss,r as t,a3 as as,S as ke,a4 as te,A as ye,l as le,a5 as ns,s as b,h as ts,j as s,a6 as ls,G as Ae,a7 as x,a8 as os,I as G,a9 as oe,aa as $,ab as K,ac as ie,ad as is}from"./main-rXJ69gpC.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function De(c,g){const S=g.filter(C=>!c.has(C));return S.length===0?`${g[Math.floor(Math.random()*g.length)]}-${Date.now()%1e3}`:S[Math.floor(Math.random()*S.length)]}function ms({isOpen:c,onClose:g,onSpawnStart:S,onSpawnEnd:C,spawnPosition:Ee,spawnAreaId:v}){const{t:a}=Qe(["terminal","common"]),P=Ve(),p=Ze(),ce=es(),H=ce.length>0?ce:ss,[m,N]=t.useState(""),[M,T]=t.useState(()=>as(ke.LAST_CWD)),[i,J]=t.useState("scout"),[re,D]=t.useState(!1),[Ie,F]=t.useState(!1),[de,Y]=t.useState(!1),[pe,me]=t.useState(""),[k,X]=t.useState([]),[y,z]=t.useState(null),[Le,ue]=t.useState(!1),[E,he]=t.useState(""),[u,_e]=t.useState(""),[R,$e]=t.useState(!0),[U,Pe]=t.useState("bypass"),[o,Q]=t.useState("claude"),[j,I]=t.useState({fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),[we,V]=t.useState(new Set),[Z,xe]=t.useState("claude-opus-4-7"),[ee,fe]=t.useState("high"),[se,Te]=t.useState("gpt-5.3-codex"),[ae,Fe]=t.useState("minimax/MiniMax-M1-80k"),[ge,ze]=t.useState(""),[A,Re]=t.useState(""),q=t.useRef(null),je=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&&!je.current&&h.length>0){const n=h.filter(l=>Ue.includes(l.slug)).map(l=>l.id);n.length>0&&V(new Set(n))}je.current=c},[c,h]);const ve=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]),qe=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 We=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]),Ne=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 te;const e=u.toLowerCase();return te.filter(n=>{const l=ye[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&&J(e[0])},[c,u,W,O,i]);const r=t.useMemo(()=>p.find(e=>e.id===i),[p,i]),Oe=t.useMemo(()=>{if(r!=null&&r.model)return r.model},[r]),Be=t.useMemo(()=>{if(r!=null&&r.customModelPath)return le(`/api/custom-models/${r.id}`)},[r]),Ge=r==null?void 0:r.modelScale,Ke=t.useMemo(()=>r?"scout":i,[i,r]),B=t.useCallback(async e=>{ue(!0);try{const n=e?le(`/api/agents/claude-sessions?cwd=${encodeURIComponent(e)}`):le("/api/agents/claude-sessions"),d=await(await ns(n)).json();X(d.sessions||[])}catch(n){console.error("Failed to fetch sessions:",n),X([])}finally{ue(!1)}},[]);t.useEffect(()=>{c?B(M||void 0):(X([]),z(null),he(""))},[c,B]),t.useEffect(()=>{if(!c)return;const e=setTimeout(()=>{B(M||void 0),z(null)},300);return()=>clearTimeout(e)},[M,c,B]),t.useEffect(()=>{if(!c||!v)return;const e=b.getState().areas.get(v);if(e!=null&&e.directories&&e.directories.length>0){T(e.directories[0]);return}const n=Array.from(b.getState().agents.values()).filter(f=>{var _;return((_=b.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(b.getState().agents.values()).map(w=>w.name)),n=De(e,H),l=p.find(w=>w.id===i),d=l?`${l.name} ${n}`:n;N(d),q.current&&(q.current.focus(),q.current.select())}},[c,H]),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"&&xe("claude-opus-4-7")},[i]);const He=()=>{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:",U),console.log("[SpawnModal] Provider:",o),console.log("[SpawnModal] Use Chrome:",R),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(b.getState().agents.values()).map(f=>f.name));N(De(w,H));return}is(ke.LAST_CWD,e),D(!0),S();const n=Array.from(we),l=ge.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"?R:!1,permissionMode:U,provider:o,codexConfig:o==="codex"?j:void 0,codexModel:o==="codex"?se:void 0,opencodeModel:o==="opencode"?ae: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,b.spawnAgent(m.trim(),i,e.trim(),Ee||void 0,y||void 0,o==="claude"?R:!1,U,n,o,o==="codex"?j:void 0,o==="codex"?se:void 0,o==="claude"?Z:void 0,l,o==="claude"?ee:void 0,o==="opencode"?ae:void 0)},be=()=>{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()},Ce=e=>{console.log("[SpawnModal] Directory not found:",e),D(!1),me(e),Y(!0),C()},Me=()=>{Y(!1),D(!0),S(),b.createDirectoryAndSpawn(pe,m.trim(),i)},ne=()=>{Y(!1),me(""),L()};t.useEffect(()=>(window.__spawnModalSuccess=be,window.__spawnModalError=Se,window.__spawnModalDirNotFound=Ce,()=>{L(),delete window.__spawnModalSuccess,delete window.__spawnModalError,delete window.__spawnModalDirNotFound}),[m,i,be,Se,Ce,L]);const{handleMouseDown:Je,handleClick:Ye}=ts(g),Xe=e=>{e.key==="Escape"&&g()};return!c&&!de?null:de?s.jsx("div",{className:"modal-overlay visible",onClick:ne,onKeyDown:e=>{e.key==="Escape"&&ne(),e.key==="Enter"&&Me()},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:pe}),s.jsx("p",{children:a("terminal:spawn.wouldYouCreate")})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:ne,children:a("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-primary",onClick:Me,autoFocus:!0,children:a("terminal:spawn.createDirectory")})]})]})}):s.jsx("div",{className:`modal-overlay ${c?"visible":""}`,onMouseDown:Je,onClick:Ye,onKeyDown:Xe,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(ls,{agentClass:Ke,modelFile:Oe,customModelUrl:Be,modelScale:Ge,width:100,height:120})}),s.jsxs("div",{className:"spawn-class-section",children:[s.jsx("div",{className:"spawn-class-label",children:a("terminal:spawn.agentClass")}),p.length+te.length>6&&s.jsx("input",{type:"text",className:"spawn-input class-search-input",placeholder:a("terminal:spawn.filterClasses"),value:u,onChange:e=>_e(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:()=>J(e.id),title:e.description,children:[s.jsx(Ae,{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=ye[e.id];return s.jsxs("button",{className:`class-chip ${i===e.id?"selected":""}`,onClick:()=>J(e.id),title:n.description,children:[s.jsx(Ae,{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(os,{value:M,onChange:e=>{T(e),F(!1)},placeholder:a("terminal:spawn.workingDirPlaceholder"),className:`spawn-input ${Ie?"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:()=>Q("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:()=>Q("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:()=>Q("opencode"),title:"Use OpenCode CLI (multi-provider)",children:[s.jsx("span",{children:s.jsx(G,{name:"status-pending",size:12,weight:"fill",color:"#4ade80"})}),s.jsx("span",{children:"OpenCode"})]})]})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsxs("label",{className:"spawn-label",children:[a("common:labels.permissions"),s.jsx(x,{text:a("terminal:spawn.helpPermission"),title:a("terminal:spawn.permissionMode"),position:"top",size:"sm"})]}),s.jsx("div",{className:"spawn-select-row",children:Object.keys(oe).map(e=>s.jsxs("button",{className:`spawn-select-btn ${U===e?"selected":""}`,onClick:()=>Pe(e),title:oe[e].description,children:[s.jsx("span",{children:s.jsx(G,{name:e==="bypass"?"bolt":"lock",size:12})}),s.jsx("span",{children:oe[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:()=>xe(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(K).map(e=>s.jsxs("button",{className:`spawn-select-btn ${se===e?"selected":""}`,onClick:()=>Te(e),title:K[e].description,children:[s.jsx("span",{children:K[e].icon}),s.jsx("span",{children:K[e].label})]},e))}):o==="opencode"?s.jsx("input",{type:"text",className:"spawn-input",value:ae,onChange:e=>Fe(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 ${ee===void 0?"selected":""}`,onClick:()=>fe(void 0),title:"Use default effort level",children:s.jsx("span",{children:"Default"})}),Object.keys(ie).map(e=>s.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${ee===e?"selected":""}`,onClick:()=>fe(e),title:ie[e].description,children:s.jsx("span",{children:ie[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:R,onChange:e=>$e(e.target.checked),disabled:o!=="claude"}),s.jsxs("span",{children:[s.jsx(G,{name:"globe",size:12})," ",a("terminal:spawn.chromeBrowser")]}),s.jsx(x,{text:a(o==="claude"?"terminal:spawn.helpChrome":"terminal:spawn.helpChromeDisabled"),title:a("terminal:spawn.chromeBrowser"),position:"top",size:"sm"})]})})]})]}),o==="codex"&&s.jsxs("div",{className:"codex-config-section",children:[s.jsx("div",{className:"codex-config-title",children:a("terminal:spawn.codex.configuration")}),s.jsxs("div",{className:"codex-config-options",children:[s.jsxs("div",{className:"codex-option-group",children:[s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked: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:[ve.map(e=>{const n=we.has(e.id);return We.some(d=>d.id===e.id)?null:s.jsxs("button",{className:`spawn-skill-chip ${n?"selected":""}`,onClick:()=>qe(e.id),title:e.description,children:[n&&s.jsx("span",{className:"spawn-skill-check",children:s.jsx(G,{name:"check",size:10})}),s.jsx("span",{children:e.name}),e.builtin&&s.jsx("span",{className:"spawn-skill-builtin",children:"TC"})]},e.id)}),A&&ve.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:ge,onChange:e=>ze(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=>he(e.target.value)}),s.jsx("div",{className:"sessions-list",children:Le?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")}):Ne.length===0?s.jsx("div",{className:"sessions-empty",children:a("terminal:spawn.noSessionsMatch",{query:E})}):Ne.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?z(null):(z(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:He,disabled:re,children:a(re?"common:buttons.deploying":"common:buttons2.deploy")})]})]})})}export{ms as SpawnModal};
@@ -1 +1 @@
1
- import{u as L,N as $,ag as D,r as m,j as s,ae as v,G as S,I as g,s as G}from"./main-B_0o0aI9.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function R({isOpen:o,bossId:r,onClose:l}){var j;const{t:a}=L(["terminal","common"]),f=$(),n=D(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 y=()=>{b(!0),G.assignSubordinates(r,Array.from(i)),setTimeout(()=>{b(!1),l()},300)},A=e=>{const t=new Set(i);t.has(e)?t.delete(e):t.add(e),c(t)},p=()=>{c(new Set(d.map(e=>e.id)))},C=()=>{c(new Set)},w=e=>{e.target===e.currentTarget&&l()},k=e=>{e.key==="Escape"&&l()};if(!o||!n)return null;const E=v.boss,h=((j=n.subordinateIds)==null?void 0:j.length)||0,I=i.size,x=JSON.stringify([...n.subordinateIds||[]].sort())!==JSON.stringify([...i].sort());return s.jsx("div",{className:`modal-overlay ${o?"visible":""}`,onClick:w,onKeyDown:k,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:E.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:p,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 N;const t=i.has(e.id),T=v[e.class],z=(N=n.subordinateIds)==null?void 0:N.includes(e.id);return s.jsxs("div",{className:`subordinate-item ${t?"selected":""}`,onClick:()=>A(e.id),children:[s.jsx("div",{className:"subordinate-checkbox",children:t?s.jsx(g,{name:"check",size:12}):null}),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}),z&&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," ",s.jsx(g,{name:"arrow-right",size:11})," ",I," ",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:y,disabled:u||!x,children:a(u?"common:status.saving":"terminal:team.saveTeam")})]})]})})}export{R as SubordinateAssignmentModal};
1
+ import{u as L,N as $,ag as D,r as m,j as s,ae as v,G as S,I as g,s as G}from"./main-rXJ69gpC.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function R({isOpen:o,bossId:r,onClose:l}){var j;const{t:a}=L(["terminal","common"]),f=$(),n=D(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 y=()=>{b(!0),G.assignSubordinates(r,Array.from(i)),setTimeout(()=>{b(!1),l()},300)},A=e=>{const t=new Set(i);t.has(e)?t.delete(e):t.add(e),c(t)},p=()=>{c(new Set(d.map(e=>e.id)))},C=()=>{c(new Set)},w=e=>{e.target===e.currentTarget&&l()},k=e=>{e.key==="Escape"&&l()};if(!o||!n)return null;const E=v.boss,h=((j=n.subordinateIds)==null?void 0:j.length)||0,I=i.size,x=JSON.stringify([...n.subordinateIds||[]].sort())!==JSON.stringify([...i].sort());return s.jsx("div",{className:`modal-overlay ${o?"visible":""}`,onClick:w,onKeyDown:k,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:E.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:p,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 N;const t=i.has(e.id),T=v[e.class],z=(N=n.subordinateIds)==null?void 0:N.includes(e.id);return s.jsxs("div",{className:`subordinate-item ${t?"selected":""}`,onClick:()=>A(e.id),children:[s.jsx("div",{className:"subordinate-checkbox",children:t?s.jsx(g,{name:"check",size:12}):null}),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}),z&&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," ",s.jsx(g,{name:"arrow-right",size:11})," ",I," ",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:y,disabled:u||!x,children:a(u?"common:status.saving":"terminal:team.saveTeam")})]})]})})}export{R as SubordinateAssignmentModal};
@@ -1,3 +1,3 @@
1
- import{N as ce,r as n,a5 as h,l as p,j as e}from"./main-B_0o0aI9.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{N as ce,r as n,a5 as h,l as p,j as e}from"./main-rXJ69gpC.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:_.extractFields)==null?void 0:W.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,a5 as M,l as P,j as e,N as J}from"./main-B_0o0aI9.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,a5 as M,l as P,j as e,N as J}from"./main-rXJ69gpC.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{u as U,a as Z,r as n,s as u,j as e,D as le,I as F,b as ce,c as ie,d as de,g as oe,e as me,Q as ue,R as be}from"./main-B_0o0aI9.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const he=({building:a,connections:x,activeConnectionId:l,activeDatabase:i,collapsed:j,onToggleCollapse:p,onConnectionChange:$,onDatabaseChange:N,onInsertTable:Q,onSelectTableQuery:P})=>{const{t:d}=U(["terminal"]),w=Z(a.id),[M,r]=n.useState(new Set),[o,v]=n.useState(""),[S,H]=n.useState(""),[O,q]=n.useState(!1),[V,R]=n.useState(null),z=n.useRef(null),g=n.useRef(null),A=n.useRef(null),y=l?w.databases.get(l)??[]:[],J=l&&i?`${l}:${i}`:"",f=J?w.tables.get(J)??[]:[],_=l?w.connectionStatus.get(l):void 0,D=n.useMemo(()=>{if(!o.trim())return y;const t=o.toLowerCase();return y.filter(m=>m.toLowerCase().includes(t))},[y,o]),h=n.useMemo(()=>{if(!S.trim())return f;const t=S.toLowerCase();return f.filter(m=>m.name.toLowerCase().includes(t))},[f,S]);n.useEffect(()=>{const t=m=>{g.current&&!g.current.contains(m.target)&&q(!1)};return O&&document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[O]),n.useEffect(()=>{l&&!_&&u.testDatabaseConnection(a.id,l)},[a.id,l,_]),n.useEffect(()=>{l&&(_!=null&&_.connected)&&y.length===0&&u.listDatabases(a.id,l)},[a.id,l,_==null?void 0:_.connected,y.length]),n.useEffect(()=>{l&&i&&f.length===0&&u.listTables(a.id,l,i)},[a.id,l,i,f.length]),n.useEffect(()=>{R(null),H("")},[l,i]);const C=n.useCallback(t=>{r(m=>{const k=new Set(m);if(k.has(t))k.delete(t);else if(k.add(t),l&&i){const T=`${l}:${i}:${t}`;w.tableSchemas.has(T)||u.getTableSchema(a.id,l,i,t)}return k})},[a.id,l,i,w.tableSchemas]),K=t=>{if(!l||!i)return null;const m=`${l}:${i}:${t}`;return w.tableSchemas.get(m)};return j?e.jsx("div",{className:"database-sidebar database-sidebar--collapsed",children:e.jsx("button",{className:"database-sidebar__toggle",onClick:p,title:d("terminal:database.expandSidebar"),children:"»"})}):e.jsxs("div",{className:"database-sidebar",children:[e.jsxs("div",{className:"database-sidebar__header",children:[e.jsx("span",{children:d("terminal:database.explorer")}),e.jsx("button",{className:"database-sidebar__toggle",onClick:p,title:d("terminal:database.collapseSidebar"),children:"«"})]}),e.jsxs("div",{className:"database-sidebar__section",children:[e.jsx("div",{className:"database-sidebar__section-title",children:d("terminal:database.connection")}),e.jsx("select",{className:"database-sidebar__select",value:l||"",onChange:t=>$(t.target.value),children:x.length===0?e.jsx("option",{value:"",children:d("terminal:database.noConnections")}):x.map(t=>{var m;return e.jsxs("option",{value:t.id,children:[((m=le[t.engine])==null?void 0:m.icon)??"🗄️"," ",t.name]},t.id)})}),_&&e.jsx("div",{className:`database-sidebar__status ${_.connected?"database-sidebar__status--connected":"database-sidebar__status--error"}`,children:_.connected?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"database-sidebar__status-icon",children:"✓"}),d("terminal:database.connected"),_.serverVersion&&e.jsxs("span",{className:"database-sidebar__version",children:["(",_.serverVersion,")"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"database-sidebar__status-icon",children:"✗"}),_.error||d("terminal:database.disconnected")]})})]}),y.length>0&&e.jsxs("div",{className:"database-sidebar__section",children:[e.jsx("div",{className:"database-sidebar__section-title",children:d("terminal:database.databaseTitle")}),e.jsxs("div",{className:"database-sidebar__searchable-select",ref:g,children:[e.jsx("input",{ref:z,className:"database-sidebar__search-input",type:"text",value:O?o:i||"",placeholder:d("terminal:database.selectDatabase"),onChange:t=>{v(t.target.value),O||q(!0)},onFocus:()=>{q(!0),v("")},onKeyDown:t=>{var m,k;t.key==="Escape"?(q(!1),v(""),(m=z.current)==null||m.blur()):t.key==="Enter"&&D.length===1&&(N(D[0]),q(!1),v(""),(k=z.current)==null||k.blur())}}),O&&e.jsx("div",{className:"database-sidebar__dropdown",children:D.length===0?e.jsx("div",{className:"database-sidebar__dropdown-empty",children:"No matches"}):D.map(t=>e.jsx("div",{className:`database-sidebar__dropdown-item ${t===i?"database-sidebar__dropdown-item--active":""}`,onMouseDown:m=>{m.preventDefault(),N(t),q(!1),v("")},children:t},t))})]})]}),f.length>0&&e.jsxs("div",{className:"database-sidebar__section database-sidebar__section--tables",children:[e.jsx("div",{className:"database-sidebar__section-title",children:S.trim()?d("terminal:database.tablesCount",{count:h.length})+` / ${f.length}`:d("terminal:database.tablesCount",{count:f.length})}),e.jsxs("div",{className:"database-sidebar__table-filter",children:[e.jsx("input",{ref:A,className:"database-sidebar__table-filter-input",type:"text",value:S,placeholder:d("terminal:database.filterTables"),onChange:t=>H(t.target.value),onKeyDown:t=>{var m;t.key==="Escape"&&(S?H(""):(m=A.current)==null||m.blur(),t.stopPropagation())}}),S&&e.jsx("button",{className:"database-sidebar__table-filter-clear",onClick:()=>{var t;H(""),(t=A.current)==null||t.focus()},title:"Clear filter",children:"×"})]}),e.jsxs("div",{className:"database-sidebar__tables",children:[S.trim()&&h.length===0&&e.jsx("div",{className:"database-sidebar__tables-empty",children:d("terminal:database.noTablesMatch")}),h.map(t=>{const m=M.has(t.name),k=m?K(t.name):null;return e.jsxs("div",{className:"database-sidebar__table",children:[e.jsxs("div",{className:"database-sidebar__table-header",children:[e.jsx("button",{className:"database-sidebar__table-expand",onClick:()=>C(t.name),title:m?"Collapse table schema":"Expand table schema",children:e.jsx(F,{name:m?"caret-down":"caret-right",size:10})}),e.jsx("span",{className:"database-sidebar__table-icon",children:e.jsx(F,{name:t.type==="view"?"eye":"clipboard",size:12})}),e.jsx("span",{className:`database-sidebar__table-name ${V===t.name?"database-sidebar__table-name--selected":""}`,onClick:()=>R(t.name),onDoubleClick:()=>{R(t.name),P(t.name)},children:t.name}),e.jsx("button",{className:"database-sidebar__table-insert",onClick:T=>{T.stopPropagation(),Q(t.name)},title:d("terminal:database.insertTableName"),children:"+"})]}),m&&k&&e.jsx("div",{className:"database-sidebar__table-columns",children:k.columns.map(T=>e.jsxs("div",{className:"database-sidebar__column",onClick:()=>Q(T.name),title:`${T.type}${T.nullable?" NULL":" NOT NULL"}${T.primaryKey?" PK":""}`,children:[e.jsx("span",{className:"database-sidebar__column-icon",children:T.primaryKey?e.jsx(F,{name:"key",size:11}):null}),e.jsx("span",{className:"database-sidebar__column-name",children:T.name}),e.jsx("span",{className:"database-sidebar__column-type",children:T.type})]},T.name))})]},t.name)})]})]})]})},_e=({buildingId:a,history:x,onLoadQuery:l})=>{const{t:i}=U(["terminal"]),[j,p]=n.useState(""),[$,N]=n.useState(!1),Q=n.useMemo(()=>{let r=x;if($&&(r=r.filter(o=>o.favorite)),j.trim()){const o=j.toLowerCase();r=r.filter(v=>v.query.toLowerCase().includes(o)||v.database.toLowerCase().includes(o))}return r},[x,$,j]),P=r=>{const o=new Date(r),S=new Date().getTime()-o.getTime();return S<1440*60*1e3?o.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):S<10080*60*1e3?o.toLocaleDateString([],{weekday:"short"})+" "+o.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):o.toLocaleDateString([],{month:"short",day:"numeric"})},d=n.useCallback((r,o)=>{o.stopPropagation(),u.toggleQueryFavorite(a,r)},[a]),w=n.useCallback((r,o)=>{o.stopPropagation(),u.deleteQueryFromHistory(a,r)},[a]),M=n.useCallback(()=>{confirm(i("terminal:database.confirmClearHistory"))&&u.clearQueryHistory(a)},[a,i]);return x.length===0?e.jsxs("div",{className:"query-history query-history--empty",children:[e.jsx("p",{children:i("terminal:database.noHistory")}),e.jsx("p",{children:i("terminal:database.queriesAppearHere")})]}):e.jsxs("div",{className:"query-history",children:[e.jsxs("div",{className:"query-history__toolbar",children:[e.jsx("input",{type:"text",className:"query-history__search",placeholder:i("terminal:database.searchQueries"),value:j,onChange:r=>p(r.target.value)}),e.jsxs("label",{className:"query-history__filter",children:[e.jsx("input",{type:"checkbox",checked:$,onChange:r=>N(r.target.checked)}),i("terminal:database.favoritesOnly")]}),e.jsx("button",{className:"query-history__clear",onClick:M,title:i("terminal:database.clearAll"),children:i("terminal:database.clearAll")})]}),e.jsxs("div",{className:"query-history__list",children:[Q.map(r=>e.jsxs("div",{className:`query-history__item ${r.status==="error"?"query-history__item--error":""}`,onClick:()=>l(r.query),children:[e.jsxs("div",{className:"query-history__item-header",children:[e.jsx("span",{className:`query-history__status ${r.status==="success"?"query-history__status--success":"query-history__status--error"}`,children:e.jsx(F,{name:r.status==="success"?"check":"cross",size:12})}),e.jsx("span",{className:"query-history__database",children:r.database}),e.jsx("span",{className:"query-history__date",children:P(r.executedAt)}),e.jsxs("span",{className:"query-history__duration",children:[r.duration,"ms"]}),r.rowCount!==void 0&&e.jsx("span",{className:"query-history__row-count",children:i("terminal:database.rowCount",{count:r.rowCount})})]}),e.jsx("div",{className:"query-history__query",children:e.jsx("code",{children:r.query.length>200?r.query.substring(0,200)+"...":r.query})}),r.error&&e.jsx("div",{className:"query-history__error",children:r.error}),e.jsxs("div",{className:"query-history__actions",children:[e.jsx("button",{className:`query-history__favorite ${r.favorite?"query-history__favorite--active":""}`,onClick:o=>d(r.id,o),title:r.favorite?i("terminal:database.removeFromFavorites"):i("terminal:database.addToFavorites"),children:e.jsx(F,{name:"star",size:12,weight:r.favorite?"fill":"regular",color:r.favorite?"#facc15":void 0})}),e.jsx("button",{className:"query-history__delete",onClick:o=>w(r.id,o),title:i("terminal:database.deleteFromHistory"),children:e.jsx(F,{name:"trash",size:12})})]})]},r.id)),Q.length===0&&e.jsx("div",{className:"query-history__no-results",children:i("terminal:database.noQueriesMatch")})]})]})},xe=({tabs:a,activeTabId:x,onTabClick:l,onTabClose:i})=>{const{t:j}=U(["terminal"]);return e.jsx("div",{className:"database-tabs",children:a.map(p=>e.jsxs("div",{className:`database-tabs__tab ${x===p.id?"database-tabs__tab--active":""}`,children:[e.jsxs("button",{className:"database-tabs__tab-label",onClick:()=>l(p),title:`${p.connectionName} / ${p.database}`,children:[p.database,e.jsx("span",{className:"database-tabs__tab-connection",children:p.connectionName})]}),e.jsx("button",{className:"database-tabs__tab-close",onClick:()=>i(p.id),title:j("terminal:database.closeTab"),"aria-label":`Close ${p.database} tab`,children:"×"})]},p.id))})},ee=a=>`db-panel-${a}`;function pe(a){try{const x=localStorage.getItem(ee(a));return x?JSON.parse(x):{}}catch{return{}}}function fe(a,x){try{localStorage.setItem(ee(a),JSON.stringify(x))}catch{}}const Se=({building:a,onClose:x})=>{var I,Y,W,X;const{t:l}=U(["terminal","common"]),i=Z(a.id),j=ce(a.id),p=ie(a.id),$=de(a.id),N=n.useRef(pe(a.id)),Q=n.useRef(null),P=n.useRef(0),d=((I=a.database)==null?void 0:I.connections)??[],w=(s,c)=>`${s}:${c}`,M=s=>s?(N.current.queries??{})[s]??"":N.current.generalQuery??"",[r,o]=n.useState("results"),[v,S]=n.useState(0),[H,O]=n.useState(!1),[q,V]=n.useState(!1),[R,z]=n.useState(()=>(N.current.openTabs??[]).map(c=>{var b;return{id:`${c.connectionId}:${c.database}`,connectionId:c.connectionId,connectionName:((b=d.find(L=>L.id===c.connectionId))==null?void 0:b.name)??c.connectionId,database:c.database}})),[g,A]=n.useState(N.current.activeTabId??null),[y,J]=n.useState(()=>{const s=N.current.queries??{};return N.current.generalQuery,s}),[f,_]=n.useState(M(g)),D=n.useCallback(s=>{_(c=>{const b=typeof s=="function"?s(c):s;return J(L=>{const E={...L};return g&&(E[g]=b),E}),b})},[g]),h=i.activeConnectionId??N.current.connectionId??((Y=a.database)==null?void 0:Y.activeConnectionId)??((W=d[0])==null?void 0:W.id),C=i.activeDatabase??N.current.database??((X=a.database)==null?void 0:X.activeDatabase),K=d.find(s=>s.id===h),t=n.useCallback((s,c)=>{var E;const b=w(s,c),L=((E=d.find(G=>G.id===s))==null?void 0:E.name)??s;z(G=>{if(G.some(re=>re.id===b))return G;const ne={id:b,connectionId:s,connectionName:L,database:c};return[...G,ne]}),A(b),_(y[b]??""),u.setActiveConnection(a.id,s),u.setActiveDatabase(a.id,c)},[a.id,d,y]),m=n.useCallback(s=>{z(c=>c.filter(b=>b.id!==s)),g===s&&z(c=>{if(c.length>0){const b=c[0];A(b.id),_(y[b.id]??""),u.setActiveConnection(a.id,b.connectionId),u.setActiveDatabase(a.id,b.database)}else A(null),_("");return c})},[g,a.id,y]),k=n.useCallback(s=>{A(s.id),_(y[s.id]??""),u.setActiveConnection(a.id,s.connectionId),u.setActiveDatabase(a.id,s.database)},[a.id,y]);n.useEffect(()=>{if(!q&&d.length>0){const s=N.current;s.connectionId&&d.some(c=>c.id===s.connectionId)&&(u.setActiveConnection(a.id,s.connectionId),u.listDatabases(a.id,s.connectionId),s.database&&(u.setActiveDatabase(a.id,s.database),u.listTables(a.id,s.connectionId,s.database))),V(!0)}},[a.id,d,q]),n.useEffect(()=>{u.requestQueryHistory(a.id)},[a.id]),n.useEffect(()=>{const s=c=>{c.key==="Escape"&&(c.preventDefault(),c.stopPropagation(),x())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[x]),n.useEffect(()=>{q&&h&&fe(a.id,{connectionId:h,database:C,lastQuery:f,queries:y,generalQuery:"",openTabs:R.map(s=>({connectionId:s.connectionId,database:s.database})),activeTabId:g??void 0})},[a.id,h,C,f,q,R,g,y]);const T=n.useCallback(s=>{var c;if(!(!h||!C||!f.trim()||$))if(s==="cursor"){const b=(c=Q.current)==null?void 0:c.querySelector(".query-editor__textarea"),L=(b==null?void 0:b.selectionStart)??P.current,E=oe(f,L);E&&u.executeQuery(a.id,h,C,E)}else{const b=me(f);b.length<=1?u.executeQuery(a.id,h,C,f.trim()):b.forEach((L,E)=>{setTimeout(()=>{u.executeQuery(a.id,h,C,L.sql)},E*150)})}},[a.id,h,C,f,$]),ae=n.useCallback(s=>{D(s),o("results")},[]),se=n.useCallback(s=>{u.setActiveConnection(a.id,s),u.listDatabases(a.id,s)},[a.id]),te=n.useCallback(s=>{h&&(t(h,s),u.listTables(a.id,h,s))},[a.id,h,t]),B=j[v];return d.length===0?e.jsxs("div",{className:"database-panel",ref:Q,children:[e.jsxs("div",{className:"database-panel__header",children:[e.jsxs("div",{className:"database-panel__title",children:[e.jsx("span",{className:"database-panel__icon",children:e.jsx(F,{name:"database",size:16})}),e.jsx("span",{className:"database-panel__name",children:a.name})]}),e.jsx("button",{className:"database-panel__close",onClick:x,children:"×"})]}),e.jsx("div",{className:"database-panel__body",children:e.jsxs("div",{className:"database-panel__no-connections",children:[e.jsx("div",{className:"database-panel__no-connections-icon",children:e.jsx(F,{name:"plug",size:32})}),e.jsx("h3",{children:l("terminal:database.noConnections")}),e.jsx("p",{children:l("terminal:database.noConnectionsDesc")}),e.jsx("p",{children:l("terminal:database.toGetStarted")}),e.jsxs("ol",{children:[e.jsx("li",{children:l("terminal:database.step1Close")}),e.jsx("li",{children:l("terminal:database.step2Settings")}),e.jsx("li",{children:l("terminal:database.step3AddConnection")}),e.jsx("li",{children:l("terminal:database.step4Reopen")})]})]})})]}):e.jsxs("div",{className:"database-panel",ref:Q,children:[e.jsxs("div",{className:"database-panel__header",children:[e.jsxs("div",{className:"database-panel__title",children:[e.jsx("span",{className:"database-panel__icon",children:(K==null?void 0:K.engine)==="mysql"?"🐬":"🐘"}),e.jsx("span",{className:"database-panel__name",children:a.name}),K&&e.jsxs("span",{className:"database-panel__connection-info",children:[K.name," / ",C||l("terminal:database.noDatabaseSelected")]})]}),e.jsx("button",{className:"database-panel__close",onClick:x,children:"×"})]}),e.jsxs("div",{className:"database-panel__body",children:[e.jsx(he,{building:a,connections:d,activeConnectionId:h,activeDatabase:C,collapsed:H,onToggleCollapse:()=>O(!H),onConnectionChange:se,onDatabaseChange:te,onInsertTable:s=>D(c=>c+` ${s}`),onSelectTableQuery:s=>{const c=`SELECT * FROM ${s}`;D(c),h&&C&&u.executeQuery(a.id,h,C,c)}}),e.jsxs("div",{className:"database-panel__main",children:[R.length>0&&e.jsx(xe,{tabs:R,activeTabId:g,onTabClick:k,onTabClose:m}),e.jsx(ue,{query:f,onChange:D,onExecute:T,isExecuting:$,disabled:!h||!C}),e.jsxs("div",{className:"database-panel__tabs",children:[e.jsxs("button",{className:`database-panel__tab ${r==="results"?"database-panel__tab--active":""}`,onClick:()=>o("results"),children:[l("terminal:database.results"),j.length>0&&e.jsx("span",{className:"database-panel__tab-badge",children:j.length})]}),e.jsxs("button",{className:`database-panel__tab ${r==="history"?"database-panel__tab--active":""}`,onClick:()=>o("history"),children:[l("terminal:database.history"),p.length>0&&e.jsx("span",{className:"database-panel__tab-badge",children:p.length})]}),r==="results"&&j.length>1&&e.jsxs("div",{className:"database-panel__result-nav",children:[e.jsxs("button",{disabled:v>=j.length-1,onClick:()=>S(s=>s+1),children:["← ",l("terminal:database.older")]}),e.jsxs("span",{children:[v+1," / ",j.length]}),e.jsxs("button",{disabled:v<=0,onClick:()=>S(s=>s-1),children:[l("terminal:database.newer")," →"]})]})]}),e.jsx("div",{className:"database-panel__tab-content",children:r==="results"?B?e.jsx(be,{result:B,buildingId:a.id,building:a}):e.jsxs("div",{className:"database-panel__empty",children:[e.jsx("p",{children:l("terminal:database.noResultsYet")}),e.jsx("p",{children:l("terminal:database.selectDbAndRun")})]}):e.jsx(_e,{buildingId:a.id,history:p,onLoadQuery:ae})})]})]})]})};export{Se as DatabasePanel,he as DatabaseSidebar,xe as DatabaseTabs,ue as QueryEditor,_e as QueryHistoryPanel,be as ResultsTable};
1
+ import{u as U,a as Z,r as n,s as u,j as e,D as le,I as F,b as ce,c as ie,d as de,g as oe,e as me,Q as ue,R as be}from"./main-rXJ69gpC.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const he=({building:a,connections:x,activeConnectionId:l,activeDatabase:i,collapsed:j,onToggleCollapse:p,onConnectionChange:$,onDatabaseChange:N,onInsertTable:Q,onSelectTableQuery:P})=>{const{t:d}=U(["terminal"]),w=Z(a.id),[M,r]=n.useState(new Set),[o,v]=n.useState(""),[S,H]=n.useState(""),[O,q]=n.useState(!1),[V,R]=n.useState(null),z=n.useRef(null),g=n.useRef(null),A=n.useRef(null),y=l?w.databases.get(l)??[]:[],J=l&&i?`${l}:${i}`:"",f=J?w.tables.get(J)??[]:[],_=l?w.connectionStatus.get(l):void 0,D=n.useMemo(()=>{if(!o.trim())return y;const t=o.toLowerCase();return y.filter(m=>m.toLowerCase().includes(t))},[y,o]),h=n.useMemo(()=>{if(!S.trim())return f;const t=S.toLowerCase();return f.filter(m=>m.name.toLowerCase().includes(t))},[f,S]);n.useEffect(()=>{const t=m=>{g.current&&!g.current.contains(m.target)&&q(!1)};return O&&document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[O]),n.useEffect(()=>{l&&!_&&u.testDatabaseConnection(a.id,l)},[a.id,l,_]),n.useEffect(()=>{l&&(_!=null&&_.connected)&&y.length===0&&u.listDatabases(a.id,l)},[a.id,l,_==null?void 0:_.connected,y.length]),n.useEffect(()=>{l&&i&&f.length===0&&u.listTables(a.id,l,i)},[a.id,l,i,f.length]),n.useEffect(()=>{R(null),H("")},[l,i]);const C=n.useCallback(t=>{r(m=>{const k=new Set(m);if(k.has(t))k.delete(t);else if(k.add(t),l&&i){const T=`${l}:${i}:${t}`;w.tableSchemas.has(T)||u.getTableSchema(a.id,l,i,t)}return k})},[a.id,l,i,w.tableSchemas]),K=t=>{if(!l||!i)return null;const m=`${l}:${i}:${t}`;return w.tableSchemas.get(m)};return j?e.jsx("div",{className:"database-sidebar database-sidebar--collapsed",children:e.jsx("button",{className:"database-sidebar__toggle",onClick:p,title:d("terminal:database.expandSidebar"),children:"»"})}):e.jsxs("div",{className:"database-sidebar",children:[e.jsxs("div",{className:"database-sidebar__header",children:[e.jsx("span",{children:d("terminal:database.explorer")}),e.jsx("button",{className:"database-sidebar__toggle",onClick:p,title:d("terminal:database.collapseSidebar"),children:"«"})]}),e.jsxs("div",{className:"database-sidebar__section",children:[e.jsx("div",{className:"database-sidebar__section-title",children:d("terminal:database.connection")}),e.jsx("select",{className:"database-sidebar__select",value:l||"",onChange:t=>$(t.target.value),children:x.length===0?e.jsx("option",{value:"",children:d("terminal:database.noConnections")}):x.map(t=>{var m;return e.jsxs("option",{value:t.id,children:[((m=le[t.engine])==null?void 0:m.icon)??"🗄️"," ",t.name]},t.id)})}),_&&e.jsx("div",{className:`database-sidebar__status ${_.connected?"database-sidebar__status--connected":"database-sidebar__status--error"}`,children:_.connected?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"database-sidebar__status-icon",children:"✓"}),d("terminal:database.connected"),_.serverVersion&&e.jsxs("span",{className:"database-sidebar__version",children:["(",_.serverVersion,")"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"database-sidebar__status-icon",children:"✗"}),_.error||d("terminal:database.disconnected")]})})]}),y.length>0&&e.jsxs("div",{className:"database-sidebar__section",children:[e.jsx("div",{className:"database-sidebar__section-title",children:d("terminal:database.databaseTitle")}),e.jsxs("div",{className:"database-sidebar__searchable-select",ref:g,children:[e.jsx("input",{ref:z,className:"database-sidebar__search-input",type:"text",value:O?o:i||"",placeholder:d("terminal:database.selectDatabase"),onChange:t=>{v(t.target.value),O||q(!0)},onFocus:()=>{q(!0),v("")},onKeyDown:t=>{var m,k;t.key==="Escape"?(q(!1),v(""),(m=z.current)==null||m.blur()):t.key==="Enter"&&D.length===1&&(N(D[0]),q(!1),v(""),(k=z.current)==null||k.blur())}}),O&&e.jsx("div",{className:"database-sidebar__dropdown",children:D.length===0?e.jsx("div",{className:"database-sidebar__dropdown-empty",children:"No matches"}):D.map(t=>e.jsx("div",{className:`database-sidebar__dropdown-item ${t===i?"database-sidebar__dropdown-item--active":""}`,onMouseDown:m=>{m.preventDefault(),N(t),q(!1),v("")},children:t},t))})]})]}),f.length>0&&e.jsxs("div",{className:"database-sidebar__section database-sidebar__section--tables",children:[e.jsx("div",{className:"database-sidebar__section-title",children:S.trim()?d("terminal:database.tablesCount",{count:h.length})+` / ${f.length}`:d("terminal:database.tablesCount",{count:f.length})}),e.jsxs("div",{className:"database-sidebar__table-filter",children:[e.jsx("input",{ref:A,className:"database-sidebar__table-filter-input",type:"text",value:S,placeholder:d("terminal:database.filterTables"),onChange:t=>H(t.target.value),onKeyDown:t=>{var m;t.key==="Escape"&&(S?H(""):(m=A.current)==null||m.blur(),t.stopPropagation())}}),S&&e.jsx("button",{className:"database-sidebar__table-filter-clear",onClick:()=>{var t;H(""),(t=A.current)==null||t.focus()},title:"Clear filter",children:"×"})]}),e.jsxs("div",{className:"database-sidebar__tables",children:[S.trim()&&h.length===0&&e.jsx("div",{className:"database-sidebar__tables-empty",children:d("terminal:database.noTablesMatch")}),h.map(t=>{const m=M.has(t.name),k=m?K(t.name):null;return e.jsxs("div",{className:"database-sidebar__table",children:[e.jsxs("div",{className:"database-sidebar__table-header",children:[e.jsx("button",{className:"database-sidebar__table-expand",onClick:()=>C(t.name),title:m?"Collapse table schema":"Expand table schema",children:e.jsx(F,{name:m?"caret-down":"caret-right",size:10})}),e.jsx("span",{className:"database-sidebar__table-icon",children:e.jsx(F,{name:t.type==="view"?"eye":"clipboard",size:12})}),e.jsx("span",{className:`database-sidebar__table-name ${V===t.name?"database-sidebar__table-name--selected":""}`,onClick:()=>R(t.name),onDoubleClick:()=>{R(t.name),P(t.name)},children:t.name}),e.jsx("button",{className:"database-sidebar__table-insert",onClick:T=>{T.stopPropagation(),Q(t.name)},title:d("terminal:database.insertTableName"),children:"+"})]}),m&&k&&e.jsx("div",{className:"database-sidebar__table-columns",children:k.columns.map(T=>e.jsxs("div",{className:"database-sidebar__column",onClick:()=>Q(T.name),title:`${T.type}${T.nullable?" NULL":" NOT NULL"}${T.primaryKey?" PK":""}`,children:[e.jsx("span",{className:"database-sidebar__column-icon",children:T.primaryKey?e.jsx(F,{name:"key",size:11}):null}),e.jsx("span",{className:"database-sidebar__column-name",children:T.name}),e.jsx("span",{className:"database-sidebar__column-type",children:T.type})]},T.name))})]},t.name)})]})]})]})},_e=({buildingId:a,history:x,onLoadQuery:l})=>{const{t:i}=U(["terminal"]),[j,p]=n.useState(""),[$,N]=n.useState(!1),Q=n.useMemo(()=>{let r=x;if($&&(r=r.filter(o=>o.favorite)),j.trim()){const o=j.toLowerCase();r=r.filter(v=>v.query.toLowerCase().includes(o)||v.database.toLowerCase().includes(o))}return r},[x,$,j]),P=r=>{const o=new Date(r),S=new Date().getTime()-o.getTime();return S<1440*60*1e3?o.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):S<10080*60*1e3?o.toLocaleDateString([],{weekday:"short"})+" "+o.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):o.toLocaleDateString([],{month:"short",day:"numeric"})},d=n.useCallback((r,o)=>{o.stopPropagation(),u.toggleQueryFavorite(a,r)},[a]),w=n.useCallback((r,o)=>{o.stopPropagation(),u.deleteQueryFromHistory(a,r)},[a]),M=n.useCallback(()=>{confirm(i("terminal:database.confirmClearHistory"))&&u.clearQueryHistory(a)},[a,i]);return x.length===0?e.jsxs("div",{className:"query-history query-history--empty",children:[e.jsx("p",{children:i("terminal:database.noHistory")}),e.jsx("p",{children:i("terminal:database.queriesAppearHere")})]}):e.jsxs("div",{className:"query-history",children:[e.jsxs("div",{className:"query-history__toolbar",children:[e.jsx("input",{type:"text",className:"query-history__search",placeholder:i("terminal:database.searchQueries"),value:j,onChange:r=>p(r.target.value)}),e.jsxs("label",{className:"query-history__filter",children:[e.jsx("input",{type:"checkbox",checked:$,onChange:r=>N(r.target.checked)}),i("terminal:database.favoritesOnly")]}),e.jsx("button",{className:"query-history__clear",onClick:M,title:i("terminal:database.clearAll"),children:i("terminal:database.clearAll")})]}),e.jsxs("div",{className:"query-history__list",children:[Q.map(r=>e.jsxs("div",{className:`query-history__item ${r.status==="error"?"query-history__item--error":""}`,onClick:()=>l(r.query),children:[e.jsxs("div",{className:"query-history__item-header",children:[e.jsx("span",{className:`query-history__status ${r.status==="success"?"query-history__status--success":"query-history__status--error"}`,children:e.jsx(F,{name:r.status==="success"?"check":"cross",size:12})}),e.jsx("span",{className:"query-history__database",children:r.database}),e.jsx("span",{className:"query-history__date",children:P(r.executedAt)}),e.jsxs("span",{className:"query-history__duration",children:[r.duration,"ms"]}),r.rowCount!==void 0&&e.jsx("span",{className:"query-history__row-count",children:i("terminal:database.rowCount",{count:r.rowCount})})]}),e.jsx("div",{className:"query-history__query",children:e.jsx("code",{children:r.query.length>200?r.query.substring(0,200)+"...":r.query})}),r.error&&e.jsx("div",{className:"query-history__error",children:r.error}),e.jsxs("div",{className:"query-history__actions",children:[e.jsx("button",{className:`query-history__favorite ${r.favorite?"query-history__favorite--active":""}`,onClick:o=>d(r.id,o),title:r.favorite?i("terminal:database.removeFromFavorites"):i("terminal:database.addToFavorites"),children:e.jsx(F,{name:"star",size:12,weight:r.favorite?"fill":"regular",color:r.favorite?"#facc15":void 0})}),e.jsx("button",{className:"query-history__delete",onClick:o=>w(r.id,o),title:i("terminal:database.deleteFromHistory"),children:e.jsx(F,{name:"trash",size:12})})]})]},r.id)),Q.length===0&&e.jsx("div",{className:"query-history__no-results",children:i("terminal:database.noQueriesMatch")})]})]})},xe=({tabs:a,activeTabId:x,onTabClick:l,onTabClose:i})=>{const{t:j}=U(["terminal"]);return e.jsx("div",{className:"database-tabs",children:a.map(p=>e.jsxs("div",{className:`database-tabs__tab ${x===p.id?"database-tabs__tab--active":""}`,children:[e.jsxs("button",{className:"database-tabs__tab-label",onClick:()=>l(p),title:`${p.connectionName} / ${p.database}`,children:[p.database,e.jsx("span",{className:"database-tabs__tab-connection",children:p.connectionName})]}),e.jsx("button",{className:"database-tabs__tab-close",onClick:()=>i(p.id),title:j("terminal:database.closeTab"),"aria-label":`Close ${p.database} tab`,children:"×"})]},p.id))})},ee=a=>`db-panel-${a}`;function pe(a){try{const x=localStorage.getItem(ee(a));return x?JSON.parse(x):{}}catch{return{}}}function fe(a,x){try{localStorage.setItem(ee(a),JSON.stringify(x))}catch{}}const Se=({building:a,onClose:x})=>{var I,Y,W,X;const{t:l}=U(["terminal","common"]),i=Z(a.id),j=ce(a.id),p=ie(a.id),$=de(a.id),N=n.useRef(pe(a.id)),Q=n.useRef(null),P=n.useRef(0),d=((I=a.database)==null?void 0:I.connections)??[],w=(s,c)=>`${s}:${c}`,M=s=>s?(N.current.queries??{})[s]??"":N.current.generalQuery??"",[r,o]=n.useState("results"),[v,S]=n.useState(0),[H,O]=n.useState(!1),[q,V]=n.useState(!1),[R,z]=n.useState(()=>(N.current.openTabs??[]).map(c=>{var b;return{id:`${c.connectionId}:${c.database}`,connectionId:c.connectionId,connectionName:((b=d.find(L=>L.id===c.connectionId))==null?void 0:b.name)??c.connectionId,database:c.database}})),[g,A]=n.useState(N.current.activeTabId??null),[y,J]=n.useState(()=>{const s=N.current.queries??{};return N.current.generalQuery,s}),[f,_]=n.useState(M(g)),D=n.useCallback(s=>{_(c=>{const b=typeof s=="function"?s(c):s;return J(L=>{const E={...L};return g&&(E[g]=b),E}),b})},[g]),h=i.activeConnectionId??N.current.connectionId??((Y=a.database)==null?void 0:Y.activeConnectionId)??((W=d[0])==null?void 0:W.id),C=i.activeDatabase??N.current.database??((X=a.database)==null?void 0:X.activeDatabase),K=d.find(s=>s.id===h),t=n.useCallback((s,c)=>{var E;const b=w(s,c),L=((E=d.find(G=>G.id===s))==null?void 0:E.name)??s;z(G=>{if(G.some(re=>re.id===b))return G;const ne={id:b,connectionId:s,connectionName:L,database:c};return[...G,ne]}),A(b),_(y[b]??""),u.setActiveConnection(a.id,s),u.setActiveDatabase(a.id,c)},[a.id,d,y]),m=n.useCallback(s=>{z(c=>c.filter(b=>b.id!==s)),g===s&&z(c=>{if(c.length>0){const b=c[0];A(b.id),_(y[b.id]??""),u.setActiveConnection(a.id,b.connectionId),u.setActiveDatabase(a.id,b.database)}else A(null),_("");return c})},[g,a.id,y]),k=n.useCallback(s=>{A(s.id),_(y[s.id]??""),u.setActiveConnection(a.id,s.connectionId),u.setActiveDatabase(a.id,s.database)},[a.id,y]);n.useEffect(()=>{if(!q&&d.length>0){const s=N.current;s.connectionId&&d.some(c=>c.id===s.connectionId)&&(u.setActiveConnection(a.id,s.connectionId),u.listDatabases(a.id,s.connectionId),s.database&&(u.setActiveDatabase(a.id,s.database),u.listTables(a.id,s.connectionId,s.database))),V(!0)}},[a.id,d,q]),n.useEffect(()=>{u.requestQueryHistory(a.id)},[a.id]),n.useEffect(()=>{const s=c=>{c.key==="Escape"&&(c.preventDefault(),c.stopPropagation(),x())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[x]),n.useEffect(()=>{q&&h&&fe(a.id,{connectionId:h,database:C,lastQuery:f,queries:y,generalQuery:"",openTabs:R.map(s=>({connectionId:s.connectionId,database:s.database})),activeTabId:g??void 0})},[a.id,h,C,f,q,R,g,y]);const T=n.useCallback(s=>{var c;if(!(!h||!C||!f.trim()||$))if(s==="cursor"){const b=(c=Q.current)==null?void 0:c.querySelector(".query-editor__textarea"),L=(b==null?void 0:b.selectionStart)??P.current,E=oe(f,L);E&&u.executeQuery(a.id,h,C,E)}else{const b=me(f);b.length<=1?u.executeQuery(a.id,h,C,f.trim()):b.forEach((L,E)=>{setTimeout(()=>{u.executeQuery(a.id,h,C,L.sql)},E*150)})}},[a.id,h,C,f,$]),ae=n.useCallback(s=>{D(s),o("results")},[]),se=n.useCallback(s=>{u.setActiveConnection(a.id,s),u.listDatabases(a.id,s)},[a.id]),te=n.useCallback(s=>{h&&(t(h,s),u.listTables(a.id,h,s))},[a.id,h,t]),B=j[v];return d.length===0?e.jsxs("div",{className:"database-panel",ref:Q,children:[e.jsxs("div",{className:"database-panel__header",children:[e.jsxs("div",{className:"database-panel__title",children:[e.jsx("span",{className:"database-panel__icon",children:e.jsx(F,{name:"database",size:16})}),e.jsx("span",{className:"database-panel__name",children:a.name})]}),e.jsx("button",{className:"database-panel__close",onClick:x,children:"×"})]}),e.jsx("div",{className:"database-panel__body",children:e.jsxs("div",{className:"database-panel__no-connections",children:[e.jsx("div",{className:"database-panel__no-connections-icon",children:e.jsx(F,{name:"plug",size:32})}),e.jsx("h3",{children:l("terminal:database.noConnections")}),e.jsx("p",{children:l("terminal:database.noConnectionsDesc")}),e.jsx("p",{children:l("terminal:database.toGetStarted")}),e.jsxs("ol",{children:[e.jsx("li",{children:l("terminal:database.step1Close")}),e.jsx("li",{children:l("terminal:database.step2Settings")}),e.jsx("li",{children:l("terminal:database.step3AddConnection")}),e.jsx("li",{children:l("terminal:database.step4Reopen")})]})]})})]}):e.jsxs("div",{className:"database-panel",ref:Q,children:[e.jsxs("div",{className:"database-panel__header",children:[e.jsxs("div",{className:"database-panel__title",children:[e.jsx("span",{className:"database-panel__icon",children:(K==null?void 0:K.engine)==="mysql"?"🐬":"🐘"}),e.jsx("span",{className:"database-panel__name",children:a.name}),K&&e.jsxs("span",{className:"database-panel__connection-info",children:[K.name," / ",C||l("terminal:database.noDatabaseSelected")]})]}),e.jsx("button",{className:"database-panel__close",onClick:x,children:"×"})]}),e.jsxs("div",{className:"database-panel__body",children:[e.jsx(he,{building:a,connections:d,activeConnectionId:h,activeDatabase:C,collapsed:H,onToggleCollapse:()=>O(!H),onConnectionChange:se,onDatabaseChange:te,onInsertTable:s=>D(c=>c+` ${s}`),onSelectTableQuery:s=>{const c=`SELECT * FROM ${s}`;D(c),h&&C&&u.executeQuery(a.id,h,C,c)}}),e.jsxs("div",{className:"database-panel__main",children:[R.length>0&&e.jsx(xe,{tabs:R,activeTabId:g,onTabClick:k,onTabClose:m}),e.jsx(ue,{query:f,onChange:D,onExecute:T,isExecuting:$,disabled:!h||!C}),e.jsxs("div",{className:"database-panel__tabs",children:[e.jsxs("button",{className:`database-panel__tab ${r==="results"?"database-panel__tab--active":""}`,onClick:()=>o("results"),children:[l("terminal:database.results"),j.length>0&&e.jsx("span",{className:"database-panel__tab-badge",children:j.length})]}),e.jsxs("button",{className:`database-panel__tab ${r==="history"?"database-panel__tab--active":""}`,onClick:()=>o("history"),children:[l("terminal:database.history"),p.length>0&&e.jsx("span",{className:"database-panel__tab-badge",children:p.length})]}),r==="results"&&j.length>1&&e.jsxs("div",{className:"database-panel__result-nav",children:[e.jsxs("button",{disabled:v>=j.length-1,onClick:()=>S(s=>s+1),children:["← ",l("terminal:database.older")]}),e.jsxs("span",{children:[v+1," / ",j.length]}),e.jsxs("button",{disabled:v<=0,onClick:()=>S(s=>s-1),children:[l("terminal:database.newer")," →"]})]})]}),e.jsx("div",{className:"database-panel__tab-content",children:r==="results"?B?e.jsx(be,{result:B,buildingId:a.id,building:a}):e.jsxs("div",{className:"database-panel__empty",children:[e.jsx("p",{children:l("terminal:database.noResultsYet")}),e.jsx("p",{children:l("terminal:database.selectDbAndRun")})]}):e.jsx(_e,{buildingId:a.id,history:p,onLoadQuery:ae})})]})]})]})};export{Se as DatabasePanel,he as DatabaseSidebar,xe as DatabaseTabs,ue as QueryEditor,_e as QueryHistoryPanel,be as ResultsTable};
@@ -1 +1 @@
1
- import{z as ts,u as as,B as vs,C as bs,E as zs,j as s,I as F,G as Is,H as Es,J as $s,K as Ds,L as Ms,r as c,M as Ls,N as Xs,O as Ps,P as Ss,U as Ys,V as Rs,W as Gs,X as Us,Y as ms,Z as _s,s as M,_ as Fs,n as U}from"./main-B_0o0aI9.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const fs=ts.memo(({agent:t,isSelected:A,isKeyboardFocused:L=!1,onSelect:X,onDoubleClick:n,onChat:g,onFocus:h,onKill:w,onDragStart:P})=>{const{t:x}=as(["dashboard","common"]),S=vs().has(t.id),N=bs(t.status),H=zs(t),j=Ms(H),I=t.taskLabel?s.jsxs(s.Fragment,{children:[s.jsx(F,{name:"task",size:12})," ",t.taskLabel]}):t.currentTask||t.lastAssignedTask,m=t.status==="idle"&&t.lastActivity>0,[,Z]=ts.useState(0);return ts.useEffect(()=>{if(!m)return;const b=window.setInterval(()=>Z(J=>J+1),15e3);return()=>window.clearInterval(b)},[m]),s.jsxs("div",{className:`dash-card dash-card--${N} ${A?"dash-card--selected":""} ${L?"dash-card--keyboard-focused":""}`,"data-agent-id":t.id,onClick:X,onDoubleClick:b=>{b.stopPropagation(),n()},onDragStart:b=>{P==null||P(t),b.dataTransfer.effectAllowed="move"},draggable:!0,title:x("cards.doubleClickHint"),children:[s.jsxs("div",{className:"dash-card__row1",children:[s.jsx("span",{className:`dash-card__status-dot dash-card__status-dot--${N}`}),s.jsx("span",{className:"dash-card__name",children:t.name}),s.jsxs("span",{className:"dash-card__class",children:[s.jsx(Is,{agent:t,size:14})," ",t.class]}),s.jsxs("span",{className:`dash-card__provider dash-card__provider--${t.provider}`,children:[s.jsx(F,{name:t.provider==="codex"||t.provider==="opencode"?"status-pending":"robot",size:11,weight:t.provider==="codex"||t.provider==="opencode"?"fill":"regular",color:t.provider==="codex"?"#a16207":t.provider==="opencode"?"#4ade80":void 0})," ",t.provider]}),S&&s.jsx("span",{className:"dash-card__unseen-badge",title:"New output available - click to view",children:"!"})]}),s.jsxs("div",{className:"dash-card__row2",children:[s.jsx("span",{className:`dash-card__status dash-card__status--${N}`,children:S?"Unseen":t.status}),s.jsxs("div",{className:"dash-card__context",children:[s.jsx("div",{className:"dash-card__context-bar",children:s.jsx("div",{className:`dash-card__context-fill dash-card__context-fill--${j}`,style:{width:`${H}%`}})}),s.jsxs("span",{className:`dash-card__context-pct dash-card__context-pct--${j}`,children:[H,"%"]})]})]}),s.jsxs("div",{className:"dash-card__row3",children:[s.jsxs("span",{className:"dash-card__workdir",title:t.cwd,children:[s.jsx(F,{name:"folder",size:11})," ",t.cwd.split("/").pop()||t.cwd]}),m&&s.jsxs("span",{className:"dash-card__idle-time",style:{color:Ds(t.lastActivity)},title:$s(t.lastActivity),children:[s.jsx(F,{name:"status-waiting-input",size:10})," ",Es(t.lastActivity)]})]}),I&&s.jsx("div",{className:"dash-card__row4",children:s.jsx("span",{className:"dash-card__task",children:I})}),s.jsxs("div",{className:"dash-card__actions",children:[g&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--chat",onClick:b=>{b.stopPropagation(),g()},title:x("cards.openTerminal"),children:x("cards.chat")}),w&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--danger",onClick:b=>{b.stopPropagation(),w()},title:x("cards.killAgent"),children:x("cards.stop")})]})]})});fs.displayName="AgentCard";const ws=({buildings:t,onSelectBuilding:A})=>{const{t:L}=as(["dashboard"]),X=c.useMemo(()=>Array.from(t.values()).sort((n,g)=>n.name.localeCompare(g.name)),[t]);return s.jsxs("div",{className:"dashboard-view__buildings",children:[s.jsxs("div",{className:"dashboard-view__buildings-header",children:[s.jsx("span",{className:"dashboard-view__buildings-title",children:L("buildings.title")}),s.jsx("span",{className:"dashboard-view__buildings-count",children:X.length})]}),s.jsx("div",{className:"dashboard-view__buildings-row",children:X.map(n=>{const g=bs(n.status),h=Ls(n.type);return s.jsxs("button",{className:`dash-pill dash-pill--${g}`,onClick:()=>A==null?void 0:A(n.id),title:`${n.name} (${n.type}) - ${n.status}`,children:[s.jsx("span",{className:"dash-pill__icon",children:s.jsx(F,{name:h,size:14})}),s.jsx("span",{className:"dash-pill__name",children:n.name}),s.jsx("span",{className:`dash-pill__dot dash-pill__dot--${g}`})]},n.id)})})]})};ws.displayName="BuildingPills";function Ks({onSelectAgent:t,onFocusAgent:A,onKillAgent:L,onSelectBuilding:X,onOpenTerminal:n,onFocusZone:g}){const{t:h}=as(["dashboard","common"]),w=Xs(),P=Ps(),x=Ss(),rs=Ys(),S=vs(),[N,H]=c.useState(""),[j,I]=c.useState("all"),[m,Z]=c.useState("zone"),[b,J]=c.useState(new Set),[k,T]=c.useState(null),[ps,W]=c.useState(null),[Y,Q]=c.useState(!1),[p,B]=c.useState(null),K=c.useMemo(()=>{const e=Array.from(w.values());return{total:e.length,working:e.filter(i=>i.status==="working"||i.status==="waiting"||i.status==="waiting_permission").length,idle:e.filter(i=>i.status==="idle").length,error:e.filter(i=>i.status==="error"||i.status==="offline"||i.status==="orphaned").length}},[w]),ns=c.useMemo(()=>m==="zone"?Rs(w,x):m==="status"?Gs(w,S):Us(w),[w,x,m,S]),V=c.useMemo(()=>{const e=N.toLowerCase().trim(),i=ns.map(l=>({...l,agents:l.agents.filter(_=>{if(j==="working"){if(_.status!=="working"&&_.status!=="waiting"&&_.status!=="waiting_permission")return!1}else if(j==="error"&&_.status!=="error"&&_.status!=="offline"&&_.status!=="orphaned")return!1;return!(e&&!_.name.toLowerCase().includes(e)&&!_.class.toLowerCase().includes(e))})}));return m==="zone"?i:i.filter(l=>l.agents.length>0)},[ns,j,N,m]),O=c.useCallback(e=>e.area?`area:${e.area.id}`:`${m}:${e.label}`,[m]),C=c.useMemo(()=>{const e=[];return V.forEach(i=>{const l=O(i);if(b.has(l))return;const _=m==="status"?ms(i.agents,{prioritizeRecentlyIdle:!0}):_s(i.agents);e.push(..._)}),e},[V,b,m,O]),gs=c.useCallback(e=>{J(i=>{const l=new Set(i);return l.has(e)?l.delete(e):l.add(e),l})},[]),xs=c.useCallback(e=>{n==null||n(e)},[n]),js=c.useCallback(e=>{T(e)},[]),Ns=c.useCallback((e,i)=>{e.preventDefault(),e.dataTransfer.dropEffect="move",W(i)},[]),ks=c.useCallback(()=>{W(null)},[]),Cs=c.useCallback(e=>{if(!k)return;if(e===null){const E=M.getState(),a=Array.from(E.areas.values()).find(r=>r.assignedAgentIds.includes(k.id));a&&M.unassignAgentFromArea(k.id,a.id),T(null),W(null);return}const i=x.get(e);if(!i)return;const l=Array.from(w.values()),_=Fs(i,l,k.position);M.updateAgent({...k,position:{...k.position,x:_.x,z:_.z}}),M.assignAgentToArea(k.id,e),T(null),W(null)},[k,x,w]);return c.useEffect(()=>{if(C.length===0){Q(!1),B(null);return}Y&&(!p||!C.some(e=>e.id===p))&&(B(C[0].id),t==null||t(C[0].id))},[C,Y,p,t]),c.useEffect(()=>{const e=a=>a instanceof HTMLElement?a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.tagName==="SELECT"||a.isContentEditable:!1,i=a=>a instanceof HTMLElement?!!a.closest(".guake-terminal")||a.classList.contains("guake-input")||a.classList.contains("agent-panel-input"):!1,l=a=>{const r=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).find(z=>z.dataset.agentId===a);r==null||r.scrollIntoView({block:"nearest",inline:"nearest"})},_=(a,r)=>{var ds,os,cs,ls,us,hs;const z=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).map(d=>{const u=d.dataset.agentId;if(!u)return null;const y=d.getBoundingClientRect();return{id:u,centerX:y.left+y.width/2,centerY:y.top+y.height/2,height:y.height}}).filter(d=>d!==null).sort((d,u)=>d.centerY-u.centerY||d.centerX-u.centerX);if(z.length===0)return a;const ss=z.reduce((d,u)=>d+u.height,0)/z.length,es=Math.max(18,ss*.6),f=[];for(const d of z){const u=f[f.length-1];if(!u){f.push([{id:d.id,centerX:d.centerX,centerY:d.centerY}]);continue}const y=u.reduce((ys,As)=>ys+As.centerY,0)/u.length;Math.abs(d.centerY-y)<=es?u.push({id:d.id,centerX:d.centerX,centerY:d.centerY}):f.push([{id:d.id,centerX:d.centerX,centerY:d.centerY}])}f.forEach(d=>d.sort((u,y)=>u.centerX-y.centerX));const R=f.findIndex(d=>d.some(u=>u.id===a));if(R===-1)return((os=(ds=f[0])==null?void 0:ds[0])==null?void 0:os.id)??a;const $=f[R],v=$.findIndex(d=>d.id===a);if(v===-1)return((ls=(cs=f[0])==null?void 0:cs[0])==null?void 0:ls.id)??a;if(r==="left")return((us=$[Math.max(0,v-1)])==null?void 0:us.id)??a;if(r==="right")return((hs=$[Math.min($.length-1,v+1)])==null?void 0:hs.id)??a;const q=r==="up"?Math.max(0,R-1):Math.min(f.length-1,R+1),o=f[q],G=$[v].centerX;let D=o[0],is=Math.abs(D.centerX-G);for(const d of o){const u=Math.abs(d.centerX-G);u<is&&(D=d,is=u)}return(D==null?void 0:D.id)??a},E=a=>{const r=M.getShortcuts(),z=r.find(o=>o.id==="dashboard-selector-toggle"),ss=r.find(o=>o.id==="dashboard-vim-left"),es=r.find(o=>o.id==="dashboard-vim-down"),f=r.find(o=>o.id==="dashboard-vim-up"),R=r.find(o=>o.id==="dashboard-vim-right"),$=r.find(o=>o.id==="open-terminal"),v=M.getState();if(e(a.target))if(!v.terminalOpen&&i(a.target)&&document.activeElement instanceof HTMLElement)document.activeElement.blur();else return;if(U(a,z)){if(C.length===0)return;a.preventDefault(),a.stopPropagation(),Q(!0),B(o=>{const G=o&&C.some(D=>D.id===o)?o:C[0].id;return t==null||t(G),window.setTimeout(()=>l(G),0),G});return}const q=U(a,ss)||a.key==="ArrowLeft"?"left":U(a,es)||a.key==="ArrowDown"?"down":U(a,f)||a.key==="ArrowUp"?"up":U(a,R)||a.key==="ArrowRight"?"right":null;if(q&&Y&&p){a.preventDefault(),a.stopPropagation();const o=_(p,q);o!==p&&(B(o),t==null||t(o),window.setTimeout(()=>l(o),0));return}if(U(a,$)){if(v.terminalOpen)return;if(Y&&p&&v.agents.has(p)){a.preventDefault(),n==null||n(p);return}if(v.selectedAgentIds.size===1){a.preventDefault();const o=Array.from(v.selectedAgentIds)[0];n==null||n(o);return}if(v.lastSelectedAgentId&&v.agents.has(v.lastSelectedAgentId)){a.preventDefault(),n==null||n(v.lastSelectedAgentId);return}}};return document.addEventListener("keydown",E,!0),()=>document.removeEventListener("keydown",E,!0)},[C,Y,p,n,t]),c.useEffect(()=>{const e=document.activeElement;e instanceof HTMLElement&&e.closest(".guake-terminal")&&!M.getState().terminalOpen&&e.blur()},[]),s.jsxs("div",{className:"dashboard-view",children:[s.jsxs("div",{className:"dashboard-view__topbar",children:[s.jsxs("div",{className:"dashboard-view__metrics",children:[s.jsxs("button",{className:`dashboard-view__metric-btn ${j==="all"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.total}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:labels.agents")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--working ${j==="working"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("working"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.working}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.working")})]}),s.jsxs("button",{className:"dashboard-view__metric-btn dashboard-view__metric-btn--idle ",onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.idle}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.idle")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--error ${j==="error"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("error"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.error}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.error")})]})]}),s.jsx("input",{className:"dashboard-view__search",type:"text",placeholder:h("searchPlaceholder"),value:N,onChange:e=>H(e.target.value)})]}),s.jsxs("div",{className:"dashboard-view__grouping",children:[s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="zone"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>Z("zone"),children:h("grouping.byZone")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="status"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>Z("status"),children:h("grouping.byStatus")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="activity"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>Z("activity"),children:h("grouping.byActivity")})]}),s.jsxs("div",{className:"dashboard-view__content",children:[V.map(e=>{const i=O(e),l=b.has(i),_=m==="status"?ms(e.agents,{prioritizeRecentlyIdle:!0}):_s(e.agents),E=e.agents.filter(r=>r.status==="working"||r.status==="waiting"||r.status==="waiting_permission").length,a=e.agents.filter(r=>S.has(r.id)).length;return s.jsxs("div",{className:`dashboard-view__zone ${ps===(e.area?e.area.id:null)&&k?"dashboard-view__zone--drag-over":""}`,onDragOver:r=>Ns(r,e.area?e.area.id:null),onDragLeave:ks,onDrop:()=>Cs(e.area?e.area.id:null),children:[s.jsxs("div",{className:"dashboard-view__zone-header",onClick:()=>gs(i),children:[s.jsxs("div",{className:"dashboard-view__zone-left",children:[s.jsx("span",{className:`dashboard-view__zone-chevron ${l?"dashboard-view__zone-chevron--collapsed":""}`,children:s.jsx(F,{name:"caret-down",size:12})}),s.jsx("span",{className:"dashboard-view__zone-dot",style:{backgroundColor:e.color}}),s.jsx("span",{className:"dashboard-view__zone-name",children:e.label}),s.jsxs("span",{className:"dashboard-view__zone-count",children:[h("agentCount",{count:e.agents.length}),E>0&&s.jsxs("span",{className:"dashboard-view__zone-working",children:[" · ",E," ",h("working")]}),a>0&&s.jsxs("span",{className:"dashboard-view__zone-unseen",children:[" · ",a," Unseen"]})]})]}),e.area&&g&&s.jsx("button",{className:"dashboard-view__zone-focus",onClick:r=>{r.stopPropagation(),g(e.area.id)},title:h("focusZone"),children:h("focusZone")})]}),!l&&s.jsx("div",{className:"dashboard-view__zone-grid",children:_.map(r=>s.jsx(fs,{agent:r,isSelected:rs.has(r.id),isKeyboardFocused:Y&&p===r.id,onSelect:()=>{t==null||t(r.id),Q(!0),B(r.id)},onDoubleClick:()=>xs(r.id),onChat:()=>n==null?void 0:n(r.id),onFocus:A?()=>A(r.id):void 0,onKill:L?()=>L(r.id):void 0,onDragStart:js},r.id))})]},i)}),V.length===0&&s.jsx("div",{className:"dashboard-view__empty",children:N?h("noAgentsMatching",{search:N}):h("noAgentsSpawned")}),P.size>0&&s.jsx(ws,{buildings:P,onSelectBuilding:X})]})]})}export{Ks as DashboardView};
1
+ import{z as ts,u as as,B as vs,C as bs,E as zs,j as s,I as F,G as Is,H as Es,J as $s,K as Ds,L as Ms,r as c,M as Ls,N as Xs,O as Ps,P as Ss,U as Ys,V as Rs,W as Gs,X as Us,Y as ms,Z as _s,s as M,_ as Fs,n as U}from"./main-rXJ69gpC.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const fs=ts.memo(({agent:t,isSelected:A,isKeyboardFocused:L=!1,onSelect:X,onDoubleClick:n,onChat:g,onFocus:h,onKill:w,onDragStart:P})=>{const{t:x}=as(["dashboard","common"]),S=vs().has(t.id),N=bs(t.status),H=zs(t),j=Ms(H),I=t.taskLabel?s.jsxs(s.Fragment,{children:[s.jsx(F,{name:"task",size:12})," ",t.taskLabel]}):t.currentTask||t.lastAssignedTask,m=t.status==="idle"&&t.lastActivity>0,[,Z]=ts.useState(0);return ts.useEffect(()=>{if(!m)return;const b=window.setInterval(()=>Z(J=>J+1),15e3);return()=>window.clearInterval(b)},[m]),s.jsxs("div",{className:`dash-card dash-card--${N} ${A?"dash-card--selected":""} ${L?"dash-card--keyboard-focused":""}`,"data-agent-id":t.id,onClick:X,onDoubleClick:b=>{b.stopPropagation(),n()},onDragStart:b=>{P==null||P(t),b.dataTransfer.effectAllowed="move"},draggable:!0,title:x("cards.doubleClickHint"),children:[s.jsxs("div",{className:"dash-card__row1",children:[s.jsx("span",{className:`dash-card__status-dot dash-card__status-dot--${N}`}),s.jsx("span",{className:"dash-card__name",children:t.name}),s.jsxs("span",{className:"dash-card__class",children:[s.jsx(Is,{agent:t,size:14})," ",t.class]}),s.jsxs("span",{className:`dash-card__provider dash-card__provider--${t.provider}`,children:[s.jsx(F,{name:t.provider==="codex"||t.provider==="opencode"?"status-pending":"robot",size:11,weight:t.provider==="codex"||t.provider==="opencode"?"fill":"regular",color:t.provider==="codex"?"#a16207":t.provider==="opencode"?"#4ade80":void 0})," ",t.provider]}),S&&s.jsx("span",{className:"dash-card__unseen-badge",title:"New output available - click to view",children:"!"})]}),s.jsxs("div",{className:"dash-card__row2",children:[s.jsx("span",{className:`dash-card__status dash-card__status--${N}`,children:S?"Unseen":t.status}),s.jsxs("div",{className:"dash-card__context",children:[s.jsx("div",{className:"dash-card__context-bar",children:s.jsx("div",{className:`dash-card__context-fill dash-card__context-fill--${j}`,style:{width:`${H}%`}})}),s.jsxs("span",{className:`dash-card__context-pct dash-card__context-pct--${j}`,children:[H,"%"]})]})]}),s.jsxs("div",{className:"dash-card__row3",children:[s.jsxs("span",{className:"dash-card__workdir",title:t.cwd,children:[s.jsx(F,{name:"folder",size:11})," ",t.cwd.split("/").pop()||t.cwd]}),m&&s.jsxs("span",{className:"dash-card__idle-time",style:{color:Ds(t.lastActivity)},title:$s(t.lastActivity),children:[s.jsx(F,{name:"status-waiting-input",size:10})," ",Es(t.lastActivity)]})]}),I&&s.jsx("div",{className:"dash-card__row4",children:s.jsx("span",{className:"dash-card__task",children:I})}),s.jsxs("div",{className:"dash-card__actions",children:[g&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--chat",onClick:b=>{b.stopPropagation(),g()},title:x("cards.openTerminal"),children:x("cards.chat")}),w&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--danger",onClick:b=>{b.stopPropagation(),w()},title:x("cards.killAgent"),children:x("cards.stop")})]})]})});fs.displayName="AgentCard";const ws=({buildings:t,onSelectBuilding:A})=>{const{t:L}=as(["dashboard"]),X=c.useMemo(()=>Array.from(t.values()).sort((n,g)=>n.name.localeCompare(g.name)),[t]);return s.jsxs("div",{className:"dashboard-view__buildings",children:[s.jsxs("div",{className:"dashboard-view__buildings-header",children:[s.jsx("span",{className:"dashboard-view__buildings-title",children:L("buildings.title")}),s.jsx("span",{className:"dashboard-view__buildings-count",children:X.length})]}),s.jsx("div",{className:"dashboard-view__buildings-row",children:X.map(n=>{const g=bs(n.status),h=Ls(n.type);return s.jsxs("button",{className:`dash-pill dash-pill--${g}`,onClick:()=>A==null?void 0:A(n.id),title:`${n.name} (${n.type}) - ${n.status}`,children:[s.jsx("span",{className:"dash-pill__icon",children:s.jsx(F,{name:h,size:14})}),s.jsx("span",{className:"dash-pill__name",children:n.name}),s.jsx("span",{className:`dash-pill__dot dash-pill__dot--${g}`})]},n.id)})})]})};ws.displayName="BuildingPills";function Ks({onSelectAgent:t,onFocusAgent:A,onKillAgent:L,onSelectBuilding:X,onOpenTerminal:n,onFocusZone:g}){const{t:h}=as(["dashboard","common"]),w=Xs(),P=Ps(),x=Ss(),rs=Ys(),S=vs(),[N,H]=c.useState(""),[j,I]=c.useState("all"),[m,Z]=c.useState("zone"),[b,J]=c.useState(new Set),[k,T]=c.useState(null),[ps,W]=c.useState(null),[Y,Q]=c.useState(!1),[p,B]=c.useState(null),K=c.useMemo(()=>{const e=Array.from(w.values());return{total:e.length,working:e.filter(i=>i.status==="working"||i.status==="waiting"||i.status==="waiting_permission").length,idle:e.filter(i=>i.status==="idle").length,error:e.filter(i=>i.status==="error"||i.status==="offline"||i.status==="orphaned").length}},[w]),ns=c.useMemo(()=>m==="zone"?Rs(w,x):m==="status"?Gs(w,S):Us(w),[w,x,m,S]),V=c.useMemo(()=>{const e=N.toLowerCase().trim(),i=ns.map(l=>({...l,agents:l.agents.filter(_=>{if(j==="working"){if(_.status!=="working"&&_.status!=="waiting"&&_.status!=="waiting_permission")return!1}else if(j==="error"&&_.status!=="error"&&_.status!=="offline"&&_.status!=="orphaned")return!1;return!(e&&!_.name.toLowerCase().includes(e)&&!_.class.toLowerCase().includes(e))})}));return m==="zone"?i:i.filter(l=>l.agents.length>0)},[ns,j,N,m]),O=c.useCallback(e=>e.area?`area:${e.area.id}`:`${m}:${e.label}`,[m]),C=c.useMemo(()=>{const e=[];return V.forEach(i=>{const l=O(i);if(b.has(l))return;const _=m==="status"?ms(i.agents,{prioritizeRecentlyIdle:!0}):_s(i.agents);e.push(..._)}),e},[V,b,m,O]),gs=c.useCallback(e=>{J(i=>{const l=new Set(i);return l.has(e)?l.delete(e):l.add(e),l})},[]),xs=c.useCallback(e=>{n==null||n(e)},[n]),js=c.useCallback(e=>{T(e)},[]),Ns=c.useCallback((e,i)=>{e.preventDefault(),e.dataTransfer.dropEffect="move",W(i)},[]),ks=c.useCallback(()=>{W(null)},[]),Cs=c.useCallback(e=>{if(!k)return;if(e===null){const E=M.getState(),a=Array.from(E.areas.values()).find(r=>r.assignedAgentIds.includes(k.id));a&&M.unassignAgentFromArea(k.id,a.id),T(null),W(null);return}const i=x.get(e);if(!i)return;const l=Array.from(w.values()),_=Fs(i,l,k.position);M.updateAgent({...k,position:{...k.position,x:_.x,z:_.z}}),M.assignAgentToArea(k.id,e),T(null),W(null)},[k,x,w]);return c.useEffect(()=>{if(C.length===0){Q(!1),B(null);return}Y&&(!p||!C.some(e=>e.id===p))&&(B(C[0].id),t==null||t(C[0].id))},[C,Y,p,t]),c.useEffect(()=>{const e=a=>a instanceof HTMLElement?a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.tagName==="SELECT"||a.isContentEditable:!1,i=a=>a instanceof HTMLElement?!!a.closest(".guake-terminal")||a.classList.contains("guake-input")||a.classList.contains("agent-panel-input"):!1,l=a=>{const r=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).find(z=>z.dataset.agentId===a);r==null||r.scrollIntoView({block:"nearest",inline:"nearest"})},_=(a,r)=>{var ds,os,cs,ls,us,hs;const z=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).map(d=>{const u=d.dataset.agentId;if(!u)return null;const y=d.getBoundingClientRect();return{id:u,centerX:y.left+y.width/2,centerY:y.top+y.height/2,height:y.height}}).filter(d=>d!==null).sort((d,u)=>d.centerY-u.centerY||d.centerX-u.centerX);if(z.length===0)return a;const ss=z.reduce((d,u)=>d+u.height,0)/z.length,es=Math.max(18,ss*.6),f=[];for(const d of z){const u=f[f.length-1];if(!u){f.push([{id:d.id,centerX:d.centerX,centerY:d.centerY}]);continue}const y=u.reduce((ys,As)=>ys+As.centerY,0)/u.length;Math.abs(d.centerY-y)<=es?u.push({id:d.id,centerX:d.centerX,centerY:d.centerY}):f.push([{id:d.id,centerX:d.centerX,centerY:d.centerY}])}f.forEach(d=>d.sort((u,y)=>u.centerX-y.centerX));const R=f.findIndex(d=>d.some(u=>u.id===a));if(R===-1)return((os=(ds=f[0])==null?void 0:ds[0])==null?void 0:os.id)??a;const $=f[R],v=$.findIndex(d=>d.id===a);if(v===-1)return((ls=(cs=f[0])==null?void 0:cs[0])==null?void 0:ls.id)??a;if(r==="left")return((us=$[Math.max(0,v-1)])==null?void 0:us.id)??a;if(r==="right")return((hs=$[Math.min($.length-1,v+1)])==null?void 0:hs.id)??a;const q=r==="up"?Math.max(0,R-1):Math.min(f.length-1,R+1),o=f[q],G=$[v].centerX;let D=o[0],is=Math.abs(D.centerX-G);for(const d of o){const u=Math.abs(d.centerX-G);u<is&&(D=d,is=u)}return(D==null?void 0:D.id)??a},E=a=>{const r=M.getShortcuts(),z=r.find(o=>o.id==="dashboard-selector-toggle"),ss=r.find(o=>o.id==="dashboard-vim-left"),es=r.find(o=>o.id==="dashboard-vim-down"),f=r.find(o=>o.id==="dashboard-vim-up"),R=r.find(o=>o.id==="dashboard-vim-right"),$=r.find(o=>o.id==="open-terminal"),v=M.getState();if(e(a.target))if(!v.terminalOpen&&i(a.target)&&document.activeElement instanceof HTMLElement)document.activeElement.blur();else return;if(U(a,z)){if(C.length===0)return;a.preventDefault(),a.stopPropagation(),Q(!0),B(o=>{const G=o&&C.some(D=>D.id===o)?o:C[0].id;return t==null||t(G),window.setTimeout(()=>l(G),0),G});return}const q=U(a,ss)||a.key==="ArrowLeft"?"left":U(a,es)||a.key==="ArrowDown"?"down":U(a,f)||a.key==="ArrowUp"?"up":U(a,R)||a.key==="ArrowRight"?"right":null;if(q&&Y&&p){a.preventDefault(),a.stopPropagation();const o=_(p,q);o!==p&&(B(o),t==null||t(o),window.setTimeout(()=>l(o),0));return}if(U(a,$)){if(v.terminalOpen)return;if(Y&&p&&v.agents.has(p)){a.preventDefault(),n==null||n(p);return}if(v.selectedAgentIds.size===1){a.preventDefault();const o=Array.from(v.selectedAgentIds)[0];n==null||n(o);return}if(v.lastSelectedAgentId&&v.agents.has(v.lastSelectedAgentId)){a.preventDefault(),n==null||n(v.lastSelectedAgentId);return}}};return document.addEventListener("keydown",E,!0),()=>document.removeEventListener("keydown",E,!0)},[C,Y,p,n,t]),c.useEffect(()=>{const e=document.activeElement;e instanceof HTMLElement&&e.closest(".guake-terminal")&&!M.getState().terminalOpen&&e.blur()},[]),s.jsxs("div",{className:"dashboard-view",children:[s.jsxs("div",{className:"dashboard-view__topbar",children:[s.jsxs("div",{className:"dashboard-view__metrics",children:[s.jsxs("button",{className:`dashboard-view__metric-btn ${j==="all"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.total}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:labels.agents")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--working ${j==="working"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("working"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.working}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.working")})]}),s.jsxs("button",{className:"dashboard-view__metric-btn dashboard-view__metric-btn--idle ",onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.idle}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.idle")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--error ${j==="error"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("error"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.error}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.error")})]})]}),s.jsx("input",{className:"dashboard-view__search",type:"text",placeholder:h("searchPlaceholder"),value:N,onChange:e=>H(e.target.value)})]}),s.jsxs("div",{className:"dashboard-view__grouping",children:[s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="zone"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>Z("zone"),children:h("grouping.byZone")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="status"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>Z("status"),children:h("grouping.byStatus")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="activity"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>Z("activity"),children:h("grouping.byActivity")})]}),s.jsxs("div",{className:"dashboard-view__content",children:[V.map(e=>{const i=O(e),l=b.has(i),_=m==="status"?ms(e.agents,{prioritizeRecentlyIdle:!0}):_s(e.agents),E=e.agents.filter(r=>r.status==="working"||r.status==="waiting"||r.status==="waiting_permission").length,a=e.agents.filter(r=>S.has(r.id)).length;return s.jsxs("div",{className:`dashboard-view__zone ${ps===(e.area?e.area.id:null)&&k?"dashboard-view__zone--drag-over":""}`,onDragOver:r=>Ns(r,e.area?e.area.id:null),onDragLeave:ks,onDrop:()=>Cs(e.area?e.area.id:null),children:[s.jsxs("div",{className:"dashboard-view__zone-header",onClick:()=>gs(i),children:[s.jsxs("div",{className:"dashboard-view__zone-left",children:[s.jsx("span",{className:`dashboard-view__zone-chevron ${l?"dashboard-view__zone-chevron--collapsed":""}`,children:s.jsx(F,{name:"caret-down",size:12})}),s.jsx("span",{className:"dashboard-view__zone-dot",style:{backgroundColor:e.color}}),s.jsx("span",{className:"dashboard-view__zone-name",children:e.label}),s.jsxs("span",{className:"dashboard-view__zone-count",children:[h("agentCount",{count:e.agents.length}),E>0&&s.jsxs("span",{className:"dashboard-view__zone-working",children:[" · ",E," ",h("working")]}),a>0&&s.jsxs("span",{className:"dashboard-view__zone-unseen",children:[" · ",a," Unseen"]})]})]}),e.area&&g&&s.jsx("button",{className:"dashboard-view__zone-focus",onClick:r=>{r.stopPropagation(),g(e.area.id)},title:h("focusZone"),children:h("focusZone")})]}),!l&&s.jsx("div",{className:"dashboard-view__zone-grid",children:_.map(r=>s.jsx(fs,{agent:r,isSelected:rs.has(r.id),isKeyboardFocused:Y&&p===r.id,onSelect:()=>{t==null||t(r.id),Q(!0),B(r.id)},onDoubleClick:()=>xs(r.id),onChat:()=>n==null?void 0:n(r.id),onFocus:A?()=>A(r.id):void 0,onKill:L?()=>L(r.id):void 0,onDragStart:js},r.id))})]},i)}),V.length===0&&s.jsx("div",{className:"dashboard-view__empty",children:N?h("noAgentsMatching",{search:N}):h("noAgentsSpawned")}),P.size>0&&s.jsx(ws,{buildings:P,onSelectBuilding:X})]})]})}export{Ks as DashboardView};
@@ -1,4 +1,4 @@
1
- import{aE as Oe,r as t,s as I,l as ye,aF as Ee,a5 as _e,j as e,I as z,u as fe,aG as ze,aH as Te,aI as Be,aJ as Ue,m as Ke,aK as We,aL as De,aM as Ve,aN as Ge,aO as qe,aP as Je,af as Ye,a3 as Me,S as oe,a8 as Qe,a4 as Xe,G as Ze,ad as Ie,N as et,P as tt,aQ as st,n as Q,aR as nt}from"./main-B_0o0aI9.js";import{F as at}from"./index-BvZsOpS_.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Se={status:"all",activity:"all",sort:"activity"},lt={"1h":3600*1e3,"6h":360*60*1e3,"24h":1440*60*1e3},Ae=20,me=3,ot={idle:"#4aff9e",working:"#4a9eff",waiting:"#ff9e4a",waiting_permission:"#ffcc00",error:"#ff4a4a",offline:"#888888",orphaned:"#ff9e4a"},ct=12e4;function rt(n){return n.trim().replace(/\r\n/g,`
1
+ import{aE as Oe,r as t,s as I,l as ye,aF as Ee,a5 as _e,j as e,I as z,u as fe,aG as ze,aH as Te,aI as Be,aJ as Ue,m as Ke,aK as We,aL as De,aM as Ve,aN as Ge,aO as qe,aP as Je,af as Ye,a3 as Me,S as oe,a8 as Qe,a4 as Xe,G as Ze,ad as Ie,N as et,P as tt,aQ as st,n as Q,aR as nt}from"./main-rXJ69gpC.js";import{F as at}from"./index-mBUzmvwn.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Se={status:"all",activity:"all",sort:"activity"},lt={"1h":3600*1e3,"6h":360*60*1e3,"24h":1440*60*1e3},Ae=20,me=3,ot={idle:"#4aff9e",working:"#4a9eff",waiting:"#ff9e4a",waiting_permission:"#ffcc00",error:"#ff4a4a",offline:"#888888",orphaned:"#ff9e4a"},ct=12e4;function rt(n){return n.trim().replace(/\r\n/g,`
2
2
  `)}function $e(n,a){return`${n}:${rt(a)}`}function it(n,a,l,f){if(n.uuid&&a.has(n.uuid))return!1;const p=n.isUserPrompt?"user":"assistant",d=$e(p,n.text),M=n.timestamp||0,A=l.get(d);return A!==void 0&&Math.abs(M-A)<=ct?!1:M>f}function dt({isOpen:n,agents:a}){const l=Oe(),[f,p]=t.useState(new Map),d=t.useRef(new Set);t.useRef(a);const M=t.useMemo(()=>Array.from(a.keys()).sort().join(","),[a]),A=t.useMemo(()=>Array.from(a.values()).map(j=>`${j.id}:${j.sessionId||""}`).sort().join(","),[a]);t.useEffect(()=>{n||(d.current.clear(),p(new Map))},[n]),t.useEffect(()=>{if(!n)return;const j=new Set(Array.from(a.keys()));for(const i of d.current)j.has(i)||d.current.delete(i);let h=null;l>0&&(h=I.preserveOutputs(),d.current.clear());const v=async(i,C,F=0)=>{if(d.current.add(i.id),F>0&&await new Promise(x=>setTimeout(x,F)),p(x=>{const b=new Map(x);return b.set(i.id,{agentId:i.id,messages:[],loading:!0,hasMore:!1,totalCount:0}),b}),!i.sessionId){C&&C.length>0&&I.mergeOutputsWithHistory(i.id,[],C),p(x=>{const b=new Map(x);return b.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),b});return}try{const b=await(await _e(ye(`/api/agents/${i.id}/history?limit=${Ee}&offset=0`))).json(),P=b.messages||[],W=P.length>0?Math.max(...P.map(w=>w.timestamp?new Date(w.timestamp).getTime():0)):0,J=new Set(P.map(w=>w.uuid).filter(w=>!!w)),V=new Map;for(const w of P){if(w.type!=="user"&&w.type!=="assistant")continue;const c=$e(w.type,w.content),L=w.timestamp?new Date(w.timestamp).getTime():0,K=V.get(c)??0;L>K&&V.set(c,L)}const G=I.getOutputs(i.id),U=(C&&C.length>0?[...C,...G]:G).filter(w=>it(w,J,V,W));I.clearOutputs(i.id);for(const w of U)I.addOutput(i.id,w);p(w=>{const c=new Map(w);return c.set(i.id,{agentId:i.id,messages:P,loading:!1,hasMore:b.hasMore||!1,totalCount:b.totalCount||0}),c})}catch(x){if(console.error(`Failed to load history for ${i.name}:`,x),C&&C.length>0){I.clearOutputs(i.id);for(const b of C)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=l>0?500:0,D=Array.from(a.values());for(const i of D)if(!d.current.has(i.id)){const C=h==null?void 0:h.get(i.id);v(i,C,u)}},[n,M,A,l]);const R=t.useRef(a),S=t.useRef(f);R.current=a,S.current=f;const k=t.useCallback(async j=>{const h=R.current.get(j),v=S.current.get(j);if(!(h!=null&&h.sessionId)||!v||!v.hasMore)return;const u=v.messages.length;try{const i=await(await fetch(ye(`/api/agents/${j}/history?limit=${Ee}&offset=${u}`))).json();i.messages&&i.messages.length>0&&p(C=>{const F=new Map(C),x=C.get(j);return x&&F.set(j,{...x,messages:[...i.messages,...x.messages],hasMore:i.hasMore||!1}),F})}catch(D){console.error(`Failed to load more history for agent ${j}:`,D)}},[]),E=t.useCallback(j=>{d.current.delete(j),p(h=>{const v=new Map(h),u=h.get(j);return u&&v.set(j,{...u,messages:[],hasMore:!1,totalCount:0,loading:!1}),v})},[]);return{histories:f,loadMoreHistory:k,clearAgentHistory:E}}function ut({command:n,onCommandChange:a,useTextarea:l,forceTextarea:f,onForceTextarea:p,onSend:d,canSend:M,attachedFiles:A,onAddFile:R,onRemoveFile:S,uploadFile:k,onAddPastedText:E,placeholder:j="Message...",className:h="",compact:v=!1,inputRef:u}){const D=t.useRef(null),i=t.useRef(null),C=t.useRef(l);t.useEffect(()=>{if(l&&!C.current&&i.current){const c=i.current;c.focus(),c.selectionStart=c.selectionEnd=c.value.length}C.current=l},[l]),t.useEffect(()=>{const c=i.current;if(!c||!l)return;c.style.height="auto";const L=v?120:180,K=Math.min(c.scrollHeight,L);c.style.height=`${K}px`},[n,l,v]);const F=t.useCallback(async c=>{const L=c.clipboardData.items;for(const _ of L)if(_.type.startsWith("image/")){c.preventDefault();const $=_.getAsFile();if($){const H=await k($);H&&R(H)}return}const K=c.clipboardData.files;if(K.length>0){c.preventDefault();for(const _ of K){const $=await k(_);$&&R($)}return}const B=c.clipboardData.getData("text"),te=(B.match(/\n/g)||[]).length+1;if(te>5){c.preventDefault();const $=`[Pasted text #${E(B)} +${te} lines]`,H=c.target,se=H.selectionStart||0,ae=H.selectionEnd||0,ne=n.slice(0,se)+$+n.slice(ae);a(ne),l||p(!0)}},[n,a,l,p,k,R,E]),x=t.useCallback(async c=>{const L=c.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(c=>{if(c.key==="Enter"&&c.shiftKey){l||(c.preventDefault(),p(!0));return}c.key==="Enter"&&(c.preventDefault(),d())},[l,p,d]),P=t.useCallback(c=>{},[]),W=t.useCallback(c=>{c.button===1&&(c.preventDefault(),c.stopPropagation())},[]),J=t.useCallback(c=>{i.current=c,u==null||u(c)},[u]),V=v?"agent-panel-input":"guake-input",G=v?"agent-panel-input-container":"guake-input-container",X=v?"agent-panel-attach-btn":"guake-attach-btn",U=v?"agent-panel-send-btn":"",w=l?v?"agent-panel-input-expanded":"guake-input-expanded":"";return e.jsxs(e.Fragment,{children:[A.length>0&&e.jsx("div",{className:v?"agent-panel-attachments":"guake-attachments",children:A.map(c=>e.jsxs("div",{className:`${v?"agent-panel-attachment":"guake-attachment"} ${c.isImage?"is-image":""}`,children:[e.jsx("span",{className:v?"agent-panel-attachment-icon":"guake-attachment-icon",children:e.jsx(z,{name:c.isImage?"file":"paperclip",size:12})}),e.jsx("span",{className:v?"agent-panel-attachment-name":"guake-attachment-name",title:c.path,children:c.name}),!v&&e.jsxs("span",{className:"guake-attachment-size",children:["(",Math.round(c.size/1024),"KB)"]}),e.jsx("button",{className:v?"agent-panel-attachment-remove":"guake-attachment-remove",onClick:()=>S(c.id),title:"Remove",children:"×"})]},c.id))}),e.jsxs("div",{className:`${V} ${w} ${h}`,children:[e.jsx("input",{ref:D,type:"file",multiple:!0,onChange:x,style:{display:"none"},accept:"*"}),e.jsxs("div",{className:G,onAuxClick:W,children:[e.jsx("button",{className:X,onClick:()=>{var c;return(c=D.current)==null?void 0:c.click()},title:"Attach file (or paste image)",children:e.jsx(z,{name:"paperclip",size:14})}),l?e.jsx("textarea",{ref:J,placeholder:j,value:n,onChange:c=>a(c.target.value),onKeyDown:b,onPaste:F,onMouseDown:P}):e.jsx("input",{ref:u,type:"text",placeholder:j,value:n,onChange:c=>a(c.target.value),onKeyDown:b,onPaste:F,onMouseDown:P}),e.jsx("button",{className:U,onClick:d,disabled:!M,title:"Send",children:e.jsx(z,{name:"send",size:14})})]})]})]})}function mt(n){const a=Math.floor(n/1e3),l=Math.floor(a/60),f=a%60;return`${l}:${f.toString().padStart(2,"0")}`}const ft=t.memo(function({agentId:a,isWorking:l,timestamp:f}){const{t:p}=fe(["terminal"]),[d,M]=t.useState(0);return t.useEffect(()=>{if(!l||!f){M(0);return}M(Date.now()-f);const A=setInterval(()=>{M(Date.now()-f)},1e3);return()=>clearInterval(A)},[l,f]),l?e.jsxs("div",{className:"guake-stop-bar",children:[e.jsx("span",{className:"guake-elapsed-timer",children:mt(d)}),e.jsxs("button",{className:"guake-stop-btn",onClick:()=>I.stopAgent(a),title:p("terminal:input.stopOperation"),children:[e.jsx("span",{className:"stop-icon",children:e.jsx(z,{name:"stop",size:12,weight:"fill"})}),e.jsx("span",{className:"stop-label",children:p("terminal:input.stop")})]})]}):null});function pt({agent:n,history:a,outputs:l,isExpanded:f,isFocused:p,advancedView:d,onExpand:M,onFocus:A,inputRef:R,onLoadMore:S,onClearHistory:k}){const{t:E}=fe(["terminal","common"]),j=ze(n.id),h=t.useRef(null),[v,u]=t.useState(!1),D=t.useRef(0),i=t.useRef(!1),[C,F]=t.useState(!0),[x,b]=t.useState(!1),[P,W]=t.useState(null),[J,V]=t.useState(null),[G,X]=t.useState(null);Te(`commander-image-modal-${n.id}`,P!==null,()=>W(null));const{command:U,setCommand:w,forceTextarea:c,setForceTextarea:L,useTextarea:K,setPastedTexts:B,incrementPastedCount:te,resetPastedCount:_,attachedFiles:$,setAttachedFiles:H,removeAttachedFile:se,uploadFile:ae,expandPastedTexts:ne}=Be({selectedAgentId:n.id}),le=U.trim().length>0||$.length>0,s=Ue({outputs:l,viewMode:d?"advanced":"simple"}),o=t.useMemo(()=>{const N=Ke(n);return{usedPercent:N.usedPercent,freePercent:N.freePercent,hasData:!!n.contextStats,totalTokens:N.totalTokens,contextWindow:N.contextWindow}},[n.contextStats,n.contextUsed,n.contextLimit]),g=t.useCallback(()=>{!v&&(a!=null&&a.hasMore)&&S&&(u(!0),D.current=h.current?h.current.scrollHeight-h.current.scrollTop:0,S())},[v,a==null?void 0:a.hasMore,S]);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 ee=t.useRef(a==null?void 0:a.loading);t.useEffect(()=>{ee.current&&!(a!=null&&a.loading)&&(i.current=!1,F(!0),b(!0)),ee.current=a==null?void 0:a.loading},[a==null?void 0:a.loading]),t.useEffect(()=>{if(!x)return;const N=h.current;if(!N)return;const y=performance.now();let O=0,ue=-1,be;const Re=()=>{const{scrollTop:Fe,scrollHeight:Ne,clientHeight:Le}=N,He=Ne-Fe-Le<=2;if(Math.abs(Ne-ue)<=1&&He?O+=1:O=0,ue=Ne,O>=3){b(!1);return}if(performance.now()-y>5e3){b(!1);return}be=requestAnimationFrame(Re)};return be=requestAnimationFrame(Re),()=>cancelAnimationFrame(be)},[x]),t.useEffect(()=>{i.current||F(!0)},[s.length]);const q=t.useCallback(()=>!1,[]),ie=t.useCallback(N=>{const y=te();return B(O=>new Map(O).set(y,N)),y},[te,B]),he=t.useCallback(N=>{H(y=>[...y,N])},[H]),xe=t.useCallback(()=>{if(!le)return;if(U.trim()==="/clear"&&$.length===0){I.clearContext(n.id),k(),w(""),L(!1),B(new Map),H([]),_();return}let N=ne(U.trim());if($.length>0){const y=$.map(O=>O.isImage?`[Image: ${O.path}]`:`[File: ${O.path}]`).join(`
3
3
  `);N=N?`${N}
4
4
 
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-D2W-1YTG.js","assets/main-B_0o0aI9.js","assets/modulepreload-polyfill-B5Qt9EMX.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-Chj50gSY.js","assets/main-DTgTDvIL.css"])))=>i.map(i=>d[i]);
2
- import{bv as e,aW as o}from"./main-B_0o0aI9.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-D2W-1YTG.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-Cg2MK9Og.js","assets/main-rXJ69gpC.js","assets/modulepreload-polyfill-B5Qt9EMX.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-Chj50gSY.js","assets/main-DrWm3QHp.css"])))=>i.map(i=>d[i]);
2
+ import{bv as e,aW as o}from"./main-rXJ69gpC.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-Cg2MK9Og.js"),__vite__mapDeps([0,1,2,3,4,5])).then(r=>new r.HapticsWeb)});export{E as Haptics,i as ImpactStyle,t as NotificationType};