tide-commander 1.148.0 → 1.150.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/README.md +6 -3
- package/dist/assets/{BossLogsModal-CZMHgMBE.js → BossLogsModal-DvczRUvP.js} +1 -1
- package/dist/assets/BossSpawnModal-B2autFKk.js +1 -0
- package/dist/assets/{ControlsModal-DJ8Scm16.js → ControlsModal-BaREMQxc.js} +1 -1
- package/dist/assets/{DockerLogsModal-Vb4gqdFz.js → DockerLogsModal-DZ0udMCo.js} +1 -1
- package/dist/assets/{EmbeddedEditor-D4sHERAj.js → EmbeddedEditor-CEjr0ZSZ.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-COIYIbJS.js → GmailOAuthSetup-76BP8J8C.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-DJS59Soi.js → GoogleOAuthSetup-D45GImPI.js} +1 -1
- package/dist/assets/{IframeModal-CFysTkn9.js → IframeModal-De63RfJZ.js} +1 -1
- package/dist/assets/{IntegrationsPanel-BK8g9ceY.js → IntegrationsPanel-DYrw1Sqk.js} +2 -2
- package/dist/assets/{LogViewerModal-DRxR0HYq.js → LogViewerModal-DW-2lpln.js} +1 -1
- package/dist/assets/{MonitoringModal-CL7UMOdX.js → MonitoringModal-B0-XXyd3.js} +1 -1
- package/dist/assets/{PM2LogsModal-I3aouUlw.js → PM2LogsModal-DOfOhkCY.js} +1 -1
- package/dist/assets/{RestoreArchivedAreaModal-PWAg6w6b.js → RestoreArchivedAreaModal-DNGmIJmM.js} +1 -1
- package/dist/assets/Scene2DCanvas-BW1E76CQ.js +1 -0
- package/dist/assets/SceneManager-DAvc9-Wp.js +104 -0
- package/dist/assets/{SkillsPanel-EQ74sIa6.js → SkillsPanel-Br-gLCLA.js} +3 -3
- package/dist/assets/{SlackMultiInstanceSetup-CLMUteI0.js → SlackMultiInstanceSetup-DG_bIfDu.js} +1 -1
- package/dist/assets/SpawnModal-lWM8OuZW.js +1 -0
- package/dist/assets/{StatisticsModal-D6MgA_o0.js → StatisticsModal-LvA0Fcvn.js} +1 -1
- package/dist/assets/{SubordinateAssignmentModal-C6n0pMn3.js → SubordinateAssignmentModal-8YxNXcR3.js} +1 -1
- package/dist/assets/{TriggerManagerPanel-Umd8iUg1.js → TriggerManagerPanel-DftIuKUG.js} +1 -1
- package/dist/assets/{WorkflowEditorPanel-CxjBxs9O.js → WorkflowEditorPanel-oLwyO_C6.js} +1 -1
- package/dist/assets/{area-logos-CThPeqIM.js → area-logos-mcpQqUMZ.js} +1 -1
- package/dist/assets/grok.ico +0 -0
- package/dist/assets/grok.png +0 -0
- package/dist/assets/index-Ay7dKyeR.js +1 -0
- package/dist/assets/index-BMw7AAAK.js +5 -0
- package/dist/assets/{index-Cz-ypmob.js → index-BQpd34Mc.js} +1 -1
- package/dist/assets/{index-BUN7MVf5.js → index-C6-68CXL.js} +3 -3
- package/dist/assets/index-CIon0DLf.js +2 -0
- package/dist/assets/{index-maZSt2YW.js → index-Cwt-E2td.js} +5 -5
- package/dist/assets/{index-DelocTaH.js → index-DFVroqA5.js} +1 -1
- package/dist/assets/index-DR6_WeF_.js +1 -0
- package/dist/assets/{index-h3Cuh2Zn.js → index-O0t07OB_.js} +2 -2
- package/dist/assets/main-D5sqeuwB.js +286 -0
- package/dist/assets/main-JBkwGXfE.css +1 -0
- package/dist/assets/{web-CfvEypdU.js → web-BkrshujV.js} +1 -1
- package/dist/assets/{web-CNjTPilF.js → web-DPETNqOf.js} +1 -1
- package/dist/assets/{web-bcYaAwP6.js → web-vG1Smf_N.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/locales/de/config.json +3 -1
- package/dist/locales/en/config.json +2 -0
- package/dist/locales/en/terminal.json +6 -0
- package/dist/locales/en/tools.json +4 -2
- package/dist/locales/es/config.json +2 -0
- package/dist/locales/fr/config.json +3 -1
- package/dist/locales/hi/config.json +3 -1
- package/dist/locales/it/config.json +3 -1
- package/dist/locales/ja/config.json +3 -1
- package/dist/locales/pt/config.json +3 -1
- package/dist/locales/ru/config.json +3 -1
- package/dist/locales/zh-CN/config.json +3 -1
- package/dist/src/packages/server/claude/backend.js +114 -10
- package/dist/src/packages/server/claude/runner/process-lifecycle.js +62 -0
- package/dist/src/packages/server/claude/runner/stdout-pipeline.js +148 -7
- package/dist/src/packages/server/claude/runner/watchdog.js +12 -0
- package/dist/src/packages/server/claude/session-loader.js +295 -0
- package/dist/src/packages/server/codex/json-event-parser.js +149 -4
- package/dist/src/packages/server/data/index.js +1 -0
- package/dist/src/packages/server/grok/backend.js +235 -0
- package/dist/src/packages/server/grok/index.js +4 -0
- package/dist/src/packages/server/grok/json-event-parser.js +153 -0
- package/dist/src/packages/server/grok/session-watcher.js +493 -0
- package/dist/src/packages/server/opencode/json-event-parser.js +184 -15
- package/dist/src/packages/server/routes/agents.js +19 -11
- package/dist/src/packages/server/runtime/grok-runtime-provider.js +11 -0
- package/dist/src/packages/server/runtime/index.js +1 -0
- package/dist/src/packages/server/services/agent-service.js +26 -5
- package/dist/src/packages/server/services/grok-usage-service.js +374 -0
- package/dist/src/packages/server/services/runtime-command-execution.js +4 -2
- package/dist/src/packages/server/services/runtime-events.js +46 -7
- package/dist/src/packages/server/services/runtime-service.js +19 -3
- package/dist/src/packages/server/utils/tool-formatting.js +40 -12
- package/dist/src/packages/server/websocket/handlers/agent-handler.js +70 -17
- package/dist/src/packages/server/websocket/listeners/runtime-listeners.js +73 -14
- package/dist/src/packages/shared/agent-types.js +10 -0
- package/package.json +1 -1
- package/dist/assets/BossSpawnModal-C6DxqtKP.js +0 -1
- package/dist/assets/Scene2DCanvas-DYPHkU3i.js +0 -1
- package/dist/assets/SceneManager-QqKygyaw.js +0 -104
- package/dist/assets/SpawnModal-BOeStihN.js +0 -1
- package/dist/assets/index-DOzFBkSH.js +0 -1
- package/dist/assets/index-DP7kd91h.js +0 -1
- package/dist/assets/index-DRyMARFk.js +0 -5
- package/dist/assets/index-DuWmOZdY.js +0 -2
- package/dist/assets/main-C2zgPci-.js +0 -256
- package/dist/assets/main-C3JO2TRI.css +0 -1
package/dist/assets/{SlackMultiInstanceSetup-CLMUteI0.js → SlackMultiInstanceSetup-DG_bIfDu.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as h,j as e,i as b,k as m}from"./main-C2zgPci-.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const C=["public_channel","private_channel","im","mpim"],z={public_channel:"Public channels",private_channel:"Private channels",im:"1:1 DMs",mpim:"Group DMs"};function M(t){const i=new Set;for(const a of(t||"").split(",")){const f=a.trim();C.includes(f)&&i.add(f)}return i}function $(t){return C.filter(i=>t.has(i)).join(",")}const s={container:{display:"flex",gap:16,minHeight:420},list:{width:200,flexShrink:0,background:"var(--surface-1, #181825)",borderRadius:8,border:"1px solid var(--border, #313244)",padding:8,display:"flex",flexDirection:"column",gap:4},listItem:t=>({padding:"8px 10px",borderRadius:6,cursor:"pointer",background:t?"rgba(137,180,250,0.15)":"transparent",border:t?"1px solid rgba(137,180,250,0.3)":"1px solid transparent",color:t?"#cdd6f4":"#a6adc8",fontSize:13}),label:{fontWeight:500},sub:{fontSize:11,color:"#6c7086",marginTop:2},addBtn:{marginTop:8,padding:"8px 10px",borderRadius:6,background:"transparent",color:"#89b4fa",border:"1px dashed rgba(137,180,250,0.4)",cursor:"pointer",fontSize:13},editor:{flex:1,display:"flex",flexDirection:"column",gap:12},field:{display:"flex",flexDirection:"column",gap:4},fieldLabel:{fontSize:12,fontWeight:500,color:"#a6adc8"},fieldDesc:{fontSize:11,color:"#6c7086"},input:{padding:"8px 10px",background:"var(--surface-0, #1e1e2e)",border:"1px solid var(--border, #313244)",borderRadius:6,color:"#cdd6f4",fontSize:13,fontFamily:"inherit"},badge:t=>{const a={socket:"#a6e3a1",polling:"#89b4fa",none:"#6c7086"}[t]??"#6c7086";return{display:"inline-block",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:500,background:`${a}26`,color:a,border:`1px solid ${a}55`}},rowGap:{display:"flex",gap:12},buttons:{display:"flex",gap:8,marginTop:12},btnPrimary:{padding:"8px 16px",background:"#89b4fa",color:"#1e1e2e",border:"none",borderRadius:6,cursor:"pointer",fontWeight:500,fontSize:13},btnSecondary:{padding:"8px 16px",background:"transparent",color:"#cdd6f4",border:"1px solid var(--border, #313244)",borderRadius:6,cursor:"pointer",fontSize:13},btnDanger:{padding:"8px 16px",background:"transparent",color:"#f38ba8",border:"1px solid rgba(243,139,168,0.4)",borderRadius:6,cursor:"pointer",fontSize:13},alert:t=>({padding:"8px 12px",borderRadius:6,fontSize:12,background:t==="error"?"rgba(243,139,168,0.15)":"rgba(166,227,161,0.15)",color:t==="error"?"#f38ba8":"#a6e3a1",border:`1px solid ${t==="error"?"rgba(243,139,168,0.3)":"rgba(166,227,161,0.3)"}`})},j="/api/slack/instances";async function N(){const t=await b(m(j));if(!t.ok)throw new Error(`HTTP ${t.status}`);return(await t.json()).instances}async function B(t){const i=await b(m(`${j}/${encodeURIComponent(t)}/values`));if(!i.ok)throw new Error(`HTTP ${i.status}`);return(await i.json()).values}async function K(t,i){const a=await b(m(j),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t,label:i})});if(!a.ok){const f=await a.json().catch(()=>({}));throw new Error(f.error||`HTTP ${a.status}`)}}async function H(t,i){const a=await b(m(`${j}/${encodeURIComponent(t)}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!a.ok){const f=await a.json().catch(()=>({}));throw new Error(f.error||`HTTP ${a.status}`)}}async function W(t){const i=await b(m(`${j}/${encodeURIComponent(t)}`),{method:"DELETE"});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.error||`HTTP ${i.status}`)}}const V=({integration:t,onCancel:i})=>{const[a,f]=h.useState([]),[o,v]=h.useState("default"),[l,S]=h.useState(null),[T,_]=h.useState(null),[g,I]=h.useState(""),[D,A]=h.useState(!1),[L,E]=h.useState(!1),[w,x]=h.useState(null),y=h.useCallback(async()=>{try{const n=await N();f(n),!n.some(d=>d.id===o)&&n.length>0&&v(n[0].id)}catch(n){x({kind:"error",message:`Failed to load instances: ${n.message}`})}},[o]),k=h.useCallback(async()=>{if(o){A(!0);try{const n=await B(o);S(n),_(n);const r=a.find(d=>d.id===o);I((r==null?void 0:r.label)??o)}catch(n){x({kind:"error",message:`Failed to load instance: ${n.message}`})}finally{A(!1)}}},[o,a]);h.useEffect(()=>{y()},[y]),h.useEffect(()=>{k()},[k]);const P=async()=>{const n=window.prompt('Instance id (kebab-case, e.g. "personal", "team-bot"):');if(!n)return;const r=window.prompt("Display label:",n)||n;try{await K(n.trim(),r.trim()),await y(),v(n.trim()),x({kind:"success",message:`Created "${n}"`})}catch(d){x({kind:"error",message:d.message})}},O=async()=>{if(o!=="default"&&window.confirm(`Delete Slack instance "${o}"? This disconnects it and removes its config.`))try{await W(o),v("default"),await y(),x({kind:"success",message:"Instance deleted"})}catch(n){x({kind:"error",message:n.message})}},R=async()=>{if(!(!l||!T)){E(!0);try{const n={};Object.keys(l).forEach(p=>{const u=l[p];if(u!==T[p]){if((p==="SLACK_BOT_TOKEN"||p==="SLACK_APP_TOKEN")&&u==="********")return;n[p]=u}});const r=a.find(p=>p.id===o),d=r&&g.trim()&&g.trim()!==r.label;await H(o,{label:d?g.trim():void 0,values:Object.keys(n).length>0?n:void 0}),x({kind:"success",message:"Saved. Slack will reconnect with the new settings."}),await y(),await k()}catch(n){x({kind:"error",message:n.message})}finally{E(!1)}}},c=(n,r)=>{l&&S({...l,[n]:r})};return e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:12,fontSize:12,color:"#a6adc8"},children:"Add multiple Slack connections side-by-side. The default instance maps to your existing bot / token; add more for personal (xoxp-) tokens or additional workspaces."}),w&&e.jsx("div",{style:{...s.alert(w.kind),marginBottom:12},children:w.message}),e.jsxs("div",{style:s.container,children:[e.jsxs("div",{style:s.list,children:[a.map(n=>{var d,p,u;const r=((d=n.config)==null?void 0:d.currentMode)??"none";return e.jsxs("div",{style:s.listItem(n.id===o),onClick:()=>v(n.id),children:[e.jsx("div",{style:s.label,children:n.label}),e.jsxs("div",{style:s.sub,children:[e.jsx("span",{style:s.badge(r),children:r==="none"?"—":r}),(p=n.status)!=null&&p.connected?" • connected":(u=n.status)!=null&&u.error?" • error":" • idle"]})]},n.id)}),e.jsx("button",{type:"button",style:s.addBtn,onClick:P,children:"+ Add Instance"})]}),e.jsxs("div",{style:s.editor,children:[D&&e.jsx("div",{style:{color:"#6c7086",fontSize:13},children:"Loading…"}),!D&&l&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:s.field,children:[e.jsx("span",{style:s.fieldLabel,children:"Display label"}),e.jsx("input",{type:"text",style:s.input,value:g,onChange:n=>I(n.target.value),disabled:!1}),e.jsxs("span",{style:s.fieldDesc,children:["Shown in the instance list. Id is fixed: ",e.jsx("code",{children:o})]})]}),e.jsxs("div",{style:s.field,children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:l.enabled,onChange:n=>c("enabled",n.target.checked)}),e.jsx("span",{style:s.fieldLabel,children:"Enabled"})]}),e.jsx("span",{style:s.fieldDesc,children:"Toggle off to disconnect this instance without deleting its config."})]}),e.jsxs("div",{style:s.field,children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:l.mirrorOwnMessages,onChange:n=>c("mirrorOwnMessages",n.target.checked)}),e.jsx("span",{style:s.fieldLabel,children:"Mirror messages I send too"})]}),e.jsxs("span",{style:s.fieldDesc,children:["Capture your outgoing messages alongside incoming ones (logged as ",e.jsx("code",{children:"direction:outbound"}),"). Recommended for personal (xoxp-) tokens. Triggers do not fire on your own messages — that would loop."]})]}),e.jsxs("div",{style:s.field,children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:l.reactOnTrigger,onChange:n=>c("reactOnTrigger",n.target.checked)}),e.jsx("span",{style:s.fieldLabel,children:"Auto-react with 👀 on trigger"})]}),e.jsxs("span",{style:s.fieldDesc,children:["When a Slack trigger fires on an incoming message, react with ",e.jsx("code",{children:":eyes:"}),' as an "I saw it, working on it" ack. Turn off for accounts where the reaction is noisy. The server env ',e.jsx("code",{children:"SLACK_REACT_ON_TRIGGER=false"})," still disables it across all instances."]})]}),e.jsxs("div",{style:s.field,children:[e.jsx("span",{style:s.fieldLabel,children:"Slack Token"}),e.jsx("input",{type:"password",style:s.input,placeholder:"xoxb-... or xoxp-...",value:l.SLACK_BOT_TOKEN,onChange:n=>c("SLACK_BOT_TOKEN",n.target.value)}),e.jsxs("span",{style:s.fieldDesc,children:["Bot token (xoxb-) → Socket Mode. User token (xoxp-) → Web API polling (~30-60s lag). Stored encrypted under a per-instance key; leave as ",e.jsx("code",{children:"********"})," to keep the existing token."]})]}),e.jsxs("div",{style:s.field,children:[e.jsx("span",{style:s.fieldLabel,children:"App Token (Socket Mode only)"}),e.jsx("input",{type:"password",style:s.input,placeholder:"xapp-...",value:l.SLACK_APP_TOKEN,onChange:n=>c("SLACK_APP_TOKEN",n.target.value)}),e.jsx("span",{style:s.fieldDesc,children:"Required for xoxb- only. Leave blank for xoxp- (polling mode)."})]}),e.jsxs("div",{style:s.rowGap,children:[e.jsxs("div",{style:{...s.field,flex:1},children:[e.jsx("span",{style:s.fieldLabel,children:"Inbound Mode"}),e.jsxs("select",{style:s.input,value:l.authMode,onChange:n=>c("authMode",n.target.value),children:[e.jsx("option",{value:"auto",children:"Auto (from token prefix)"}),e.jsx("option",{value:"socket",children:"Socket Mode (xoxb-)"}),e.jsx("option",{value:"polling",children:"Polling (xoxp-)"})]})]}),e.jsxs("div",{style:{...s.field,flex:1},children:[e.jsx("span",{style:s.fieldLabel,children:"Default Channel"}),e.jsx("input",{type:"text",style:s.input,placeholder:"C0123456789",value:l.defaultChannelId,onChange:n=>c("defaultChannelId",n.target.value)})]})]}),e.jsxs("div",{style:s.rowGap,children:[e.jsxs("div",{style:{...s.field,flex:1},children:[e.jsx("span",{style:s.fieldLabel,children:"Polling Interval (s)"}),e.jsx("input",{type:"number",style:s.input,min:10,max:600,value:l.pollingIntervalSec,onChange:n=>c("pollingIntervalSec",Number(n.target.value))})]}),e.jsxs("div",{style:{...s.field,flex:1},children:[e.jsx("span",{style:s.fieldLabel,children:"Concurrency"}),e.jsx("input",{type:"number",style:s.input,min:1,max:8,value:l.pollingConcurrency,onChange:n=>c("pollingConcurrency",Number(n.target.value))})]}),e.jsxs("div",{style:{...s.field,flex:1},children:[e.jsx("span",{style:s.fieldLabel,children:"Backfill Cap (msgs)"}),e.jsx("input",{type:"number",style:s.input,min:1,max:1e3,value:l.pollingBackfillMessageCap,onChange:n=>c("pollingBackfillMessageCap",Number(n.target.value))})]}),e.jsxs("div",{style:{...s.field,flex:1},children:[e.jsx("span",{style:s.fieldLabel,children:"Min ms between calls"}),e.jsx("input",{type:"number",style:s.input,min:0,max:1e4,value:l.pollingMinMsBetweenCalls,onChange:n=>c("pollingMinMsBetweenCalls",Number(n.target.value))}),e.jsx("span",{style:{...s.fieldDesc,fontSize:11},children:"Throttle. 1500 ≈ 40 req/min. Set 0 to disable."})]})]}),e.jsxs("div",{style:s.field,children:[e.jsx("span",{style:s.fieldLabel,children:"Channel Types (poll all of these)"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:12,marginTop:4},children:C.map(n=>{const d=M(l.pollingChannelTypes).has(n);return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer",fontSize:13},children:[e.jsx("input",{type:"checkbox",checked:d,onChange:p=>{const u=new Set(M(l.pollingChannelTypes));p.target.checked?u.add(n):u.delete(n),c("pollingChannelTypes",$(u))}}),e.jsx("span",{children:z[n]})]},n)})}),e.jsx("span",{style:s.fieldDesc,children:"Determines which channel types are polled when the allowlist below is empty. Tick all four for full coverage. Heads-up: hundreds of channels at once can hit Slack's rate limit (~50 req/min) — use the allowlist to narrow down."})]}),e.jsxs("div",{style:s.field,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:s.fieldLabel,children:"Channel Allowlist (optional)"}),l.pollingChannelAllowlist&&e.jsx("button",{type:"button",style:{...s.btnSecondary,padding:"4px 10px",fontSize:12},onClick:()=>c("pollingChannelAllowlist",""),title:"Clear the allowlist — fall back to polling all channels per the type checkboxes above.",children:"Include all (clear list)"})]}),e.jsx("textarea",{style:{...s.input,minHeight:60,fontFamily:"monospace",fontSize:12},placeholder:`C0123456789, G0987654321
|
|
1
|
+
import{r as h,j as e,i as b,k as m}from"./main-D5sqeuwB.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const C=["public_channel","private_channel","im","mpim"],z={public_channel:"Public channels",private_channel:"Private channels",im:"1:1 DMs",mpim:"Group DMs"};function M(t){const i=new Set;for(const a of(t||"").split(",")){const f=a.trim();C.includes(f)&&i.add(f)}return i}function $(t){return C.filter(i=>t.has(i)).join(",")}const s={container:{display:"flex",gap:16,minHeight:420},list:{width:200,flexShrink:0,background:"var(--surface-1, #181825)",borderRadius:8,border:"1px solid var(--border, #313244)",padding:8,display:"flex",flexDirection:"column",gap:4},listItem:t=>({padding:"8px 10px",borderRadius:6,cursor:"pointer",background:t?"rgba(137,180,250,0.15)":"transparent",border:t?"1px solid rgba(137,180,250,0.3)":"1px solid transparent",color:t?"#cdd6f4":"#a6adc8",fontSize:13}),label:{fontWeight:500},sub:{fontSize:11,color:"#6c7086",marginTop:2},addBtn:{marginTop:8,padding:"8px 10px",borderRadius:6,background:"transparent",color:"#89b4fa",border:"1px dashed rgba(137,180,250,0.4)",cursor:"pointer",fontSize:13},editor:{flex:1,display:"flex",flexDirection:"column",gap:12},field:{display:"flex",flexDirection:"column",gap:4},fieldLabel:{fontSize:12,fontWeight:500,color:"#a6adc8"},fieldDesc:{fontSize:11,color:"#6c7086"},input:{padding:"8px 10px",background:"var(--surface-0, #1e1e2e)",border:"1px solid var(--border, #313244)",borderRadius:6,color:"#cdd6f4",fontSize:13,fontFamily:"inherit"},badge:t=>{const a={socket:"#a6e3a1",polling:"#89b4fa",none:"#6c7086"}[t]??"#6c7086";return{display:"inline-block",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:500,background:`${a}26`,color:a,border:`1px solid ${a}55`}},rowGap:{display:"flex",gap:12},buttons:{display:"flex",gap:8,marginTop:12},btnPrimary:{padding:"8px 16px",background:"#89b4fa",color:"#1e1e2e",border:"none",borderRadius:6,cursor:"pointer",fontWeight:500,fontSize:13},btnSecondary:{padding:"8px 16px",background:"transparent",color:"#cdd6f4",border:"1px solid var(--border, #313244)",borderRadius:6,cursor:"pointer",fontSize:13},btnDanger:{padding:"8px 16px",background:"transparent",color:"#f38ba8",border:"1px solid rgba(243,139,168,0.4)",borderRadius:6,cursor:"pointer",fontSize:13},alert:t=>({padding:"8px 12px",borderRadius:6,fontSize:12,background:t==="error"?"rgba(243,139,168,0.15)":"rgba(166,227,161,0.15)",color:t==="error"?"#f38ba8":"#a6e3a1",border:`1px solid ${t==="error"?"rgba(243,139,168,0.3)":"rgba(166,227,161,0.3)"}`})},j="/api/slack/instances";async function N(){const t=await b(m(j));if(!t.ok)throw new Error(`HTTP ${t.status}`);return(await t.json()).instances}async function B(t){const i=await b(m(`${j}/${encodeURIComponent(t)}/values`));if(!i.ok)throw new Error(`HTTP ${i.status}`);return(await i.json()).values}async function K(t,i){const a=await b(m(j),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t,label:i})});if(!a.ok){const f=await a.json().catch(()=>({}));throw new Error(f.error||`HTTP ${a.status}`)}}async function H(t,i){const a=await b(m(`${j}/${encodeURIComponent(t)}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!a.ok){const f=await a.json().catch(()=>({}));throw new Error(f.error||`HTTP ${a.status}`)}}async function W(t){const i=await b(m(`${j}/${encodeURIComponent(t)}`),{method:"DELETE"});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.error||`HTTP ${i.status}`)}}const V=({integration:t,onCancel:i})=>{const[a,f]=h.useState([]),[o,v]=h.useState("default"),[l,S]=h.useState(null),[T,_]=h.useState(null),[g,I]=h.useState(""),[D,A]=h.useState(!1),[L,E]=h.useState(!1),[w,x]=h.useState(null),y=h.useCallback(async()=>{try{const n=await N();f(n),!n.some(d=>d.id===o)&&n.length>0&&v(n[0].id)}catch(n){x({kind:"error",message:`Failed to load instances: ${n.message}`})}},[o]),k=h.useCallback(async()=>{if(o){A(!0);try{const n=await B(o);S(n),_(n);const r=a.find(d=>d.id===o);I((r==null?void 0:r.label)??o)}catch(n){x({kind:"error",message:`Failed to load instance: ${n.message}`})}finally{A(!1)}}},[o,a]);h.useEffect(()=>{y()},[y]),h.useEffect(()=>{k()},[k]);const P=async()=>{const n=window.prompt('Instance id (kebab-case, e.g. "personal", "team-bot"):');if(!n)return;const r=window.prompt("Display label:",n)||n;try{await K(n.trim(),r.trim()),await y(),v(n.trim()),x({kind:"success",message:`Created "${n}"`})}catch(d){x({kind:"error",message:d.message})}},O=async()=>{if(o!=="default"&&window.confirm(`Delete Slack instance "${o}"? This disconnects it and removes its config.`))try{await W(o),v("default"),await y(),x({kind:"success",message:"Instance deleted"})}catch(n){x({kind:"error",message:n.message})}},R=async()=>{if(!(!l||!T)){E(!0);try{const n={};Object.keys(l).forEach(p=>{const u=l[p];if(u!==T[p]){if((p==="SLACK_BOT_TOKEN"||p==="SLACK_APP_TOKEN")&&u==="********")return;n[p]=u}});const r=a.find(p=>p.id===o),d=r&&g.trim()&&g.trim()!==r.label;await H(o,{label:d?g.trim():void 0,values:Object.keys(n).length>0?n:void 0}),x({kind:"success",message:"Saved. Slack will reconnect with the new settings."}),await y(),await k()}catch(n){x({kind:"error",message:n.message})}finally{E(!1)}}},c=(n,r)=>{l&&S({...l,[n]:r})};return e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:12,fontSize:12,color:"#a6adc8"},children:"Add multiple Slack connections side-by-side. The default instance maps to your existing bot / token; add more for personal (xoxp-) tokens or additional workspaces."}),w&&e.jsx("div",{style:{...s.alert(w.kind),marginBottom:12},children:w.message}),e.jsxs("div",{style:s.container,children:[e.jsxs("div",{style:s.list,children:[a.map(n=>{var d,p,u;const r=((d=n.config)==null?void 0:d.currentMode)??"none";return e.jsxs("div",{style:s.listItem(n.id===o),onClick:()=>v(n.id),children:[e.jsx("div",{style:s.label,children:n.label}),e.jsxs("div",{style:s.sub,children:[e.jsx("span",{style:s.badge(r),children:r==="none"?"—":r}),(p=n.status)!=null&&p.connected?" • connected":(u=n.status)!=null&&u.error?" • error":" • idle"]})]},n.id)}),e.jsx("button",{type:"button",style:s.addBtn,onClick:P,children:"+ Add Instance"})]}),e.jsxs("div",{style:s.editor,children:[D&&e.jsx("div",{style:{color:"#6c7086",fontSize:13},children:"Loading…"}),!D&&l&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:s.field,children:[e.jsx("span",{style:s.fieldLabel,children:"Display label"}),e.jsx("input",{type:"text",style:s.input,value:g,onChange:n=>I(n.target.value),disabled:!1}),e.jsxs("span",{style:s.fieldDesc,children:["Shown in the instance list. Id is fixed: ",e.jsx("code",{children:o})]})]}),e.jsxs("div",{style:s.field,children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:l.enabled,onChange:n=>c("enabled",n.target.checked)}),e.jsx("span",{style:s.fieldLabel,children:"Enabled"})]}),e.jsx("span",{style:s.fieldDesc,children:"Toggle off to disconnect this instance without deleting its config."})]}),e.jsxs("div",{style:s.field,children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:l.mirrorOwnMessages,onChange:n=>c("mirrorOwnMessages",n.target.checked)}),e.jsx("span",{style:s.fieldLabel,children:"Mirror messages I send too"})]}),e.jsxs("span",{style:s.fieldDesc,children:["Capture your outgoing messages alongside incoming ones (logged as ",e.jsx("code",{children:"direction:outbound"}),"). Recommended for personal (xoxp-) tokens. Triggers do not fire on your own messages — that would loop."]})]}),e.jsxs("div",{style:s.field,children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:l.reactOnTrigger,onChange:n=>c("reactOnTrigger",n.target.checked)}),e.jsx("span",{style:s.fieldLabel,children:"Auto-react with 👀 on trigger"})]}),e.jsxs("span",{style:s.fieldDesc,children:["When a Slack trigger fires on an incoming message, react with ",e.jsx("code",{children:":eyes:"}),' as an "I saw it, working on it" ack. Turn off for accounts where the reaction is noisy. The server env ',e.jsx("code",{children:"SLACK_REACT_ON_TRIGGER=false"})," still disables it across all instances."]})]}),e.jsxs("div",{style:s.field,children:[e.jsx("span",{style:s.fieldLabel,children:"Slack Token"}),e.jsx("input",{type:"password",style:s.input,placeholder:"xoxb-... or xoxp-...",value:l.SLACK_BOT_TOKEN,onChange:n=>c("SLACK_BOT_TOKEN",n.target.value)}),e.jsxs("span",{style:s.fieldDesc,children:["Bot token (xoxb-) → Socket Mode. User token (xoxp-) → Web API polling (~30-60s lag). Stored encrypted under a per-instance key; leave as ",e.jsx("code",{children:"********"})," to keep the existing token."]})]}),e.jsxs("div",{style:s.field,children:[e.jsx("span",{style:s.fieldLabel,children:"App Token (Socket Mode only)"}),e.jsx("input",{type:"password",style:s.input,placeholder:"xapp-...",value:l.SLACK_APP_TOKEN,onChange:n=>c("SLACK_APP_TOKEN",n.target.value)}),e.jsx("span",{style:s.fieldDesc,children:"Required for xoxb- only. Leave blank for xoxp- (polling mode)."})]}),e.jsxs("div",{style:s.rowGap,children:[e.jsxs("div",{style:{...s.field,flex:1},children:[e.jsx("span",{style:s.fieldLabel,children:"Inbound Mode"}),e.jsxs("select",{style:s.input,value:l.authMode,onChange:n=>c("authMode",n.target.value),children:[e.jsx("option",{value:"auto",children:"Auto (from token prefix)"}),e.jsx("option",{value:"socket",children:"Socket Mode (xoxb-)"}),e.jsx("option",{value:"polling",children:"Polling (xoxp-)"})]})]}),e.jsxs("div",{style:{...s.field,flex:1},children:[e.jsx("span",{style:s.fieldLabel,children:"Default Channel"}),e.jsx("input",{type:"text",style:s.input,placeholder:"C0123456789",value:l.defaultChannelId,onChange:n=>c("defaultChannelId",n.target.value)})]})]}),e.jsxs("div",{style:s.rowGap,children:[e.jsxs("div",{style:{...s.field,flex:1},children:[e.jsx("span",{style:s.fieldLabel,children:"Polling Interval (s)"}),e.jsx("input",{type:"number",style:s.input,min:10,max:600,value:l.pollingIntervalSec,onChange:n=>c("pollingIntervalSec",Number(n.target.value))})]}),e.jsxs("div",{style:{...s.field,flex:1},children:[e.jsx("span",{style:s.fieldLabel,children:"Concurrency"}),e.jsx("input",{type:"number",style:s.input,min:1,max:8,value:l.pollingConcurrency,onChange:n=>c("pollingConcurrency",Number(n.target.value))})]}),e.jsxs("div",{style:{...s.field,flex:1},children:[e.jsx("span",{style:s.fieldLabel,children:"Backfill Cap (msgs)"}),e.jsx("input",{type:"number",style:s.input,min:1,max:1e3,value:l.pollingBackfillMessageCap,onChange:n=>c("pollingBackfillMessageCap",Number(n.target.value))})]}),e.jsxs("div",{style:{...s.field,flex:1},children:[e.jsx("span",{style:s.fieldLabel,children:"Min ms between calls"}),e.jsx("input",{type:"number",style:s.input,min:0,max:1e4,value:l.pollingMinMsBetweenCalls,onChange:n=>c("pollingMinMsBetweenCalls",Number(n.target.value))}),e.jsx("span",{style:{...s.fieldDesc,fontSize:11},children:"Throttle. 1500 ≈ 40 req/min. Set 0 to disable."})]})]}),e.jsxs("div",{style:s.field,children:[e.jsx("span",{style:s.fieldLabel,children:"Channel Types (poll all of these)"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:12,marginTop:4},children:C.map(n=>{const d=M(l.pollingChannelTypes).has(n);return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer",fontSize:13},children:[e.jsx("input",{type:"checkbox",checked:d,onChange:p=>{const u=new Set(M(l.pollingChannelTypes));p.target.checked?u.add(n):u.delete(n),c("pollingChannelTypes",$(u))}}),e.jsx("span",{children:z[n]})]},n)})}),e.jsx("span",{style:s.fieldDesc,children:"Determines which channel types are polled when the allowlist below is empty. Tick all four for full coverage. Heads-up: hundreds of channels at once can hit Slack's rate limit (~50 req/min) — use the allowlist to narrow down."})]}),e.jsxs("div",{style:s.field,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:s.fieldLabel,children:"Channel Allowlist (optional)"}),l.pollingChannelAllowlist&&e.jsx("button",{type:"button",style:{...s.btnSecondary,padding:"4px 10px",fontSize:12},onClick:()=>c("pollingChannelAllowlist",""),title:"Clear the allowlist — fall back to polling all channels per the type checkboxes above.",children:"Include all (clear list)"})]}),e.jsx("textarea",{style:{...s.input,minHeight:60,fontFamily:"monospace",fontSize:12},placeholder:`C0123456789, G0987654321
|
|
2
2
|
C9999999999`,value:l.pollingChannelAllowlist,onChange:n=>c("pollingChannelAllowlist",n.target.value)}),e.jsx("span",{style:s.fieldDesc,children:'Comma- or newline-separated channel IDs. When set, polling restricts to these channels (plus DMs if "Always include DMs" is on). The Channel Types checkboxes above are ignored while an allowlist is active. Leave blank to fall back to polling all channels per the type checkboxes.'})]}),e.jsxs("div",{style:s.field,children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:l.pollingDmsAlways,onChange:n=>c("pollingDmsAlways",n.target.checked)}),e.jsx("span",{style:s.fieldLabel,children:"Always include DMs"})]}),e.jsx("span",{style:s.fieldDesc,children:"When the allowlist is set, still poll all 1:1 DMs (D-prefix). Default on. Turn off for strict allowlist-only mode."})]}),e.jsxs("div",{style:s.buttons,children:[e.jsx("button",{type:"button",style:s.btnPrimary,onClick:R,disabled:L,children:L?"Saving…":"Save & Reconnect"}),e.jsx("button",{type:"button",style:s.btnSecondary,onClick:i,children:"Close"}),o!=="default"&&e.jsx("button",{type:"button",style:{...s.btnDanger,marginLeft:"auto"},onClick:O,children:"Delete Instance"})]})]})]})]})]})};export{V as SlackMultiInstanceSetup,V as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as ns,b5 as as,b6 as ts,b7 as ls,b8 as os,r as t,_ as De,S as oe,b9 as is,ba as ie,A as Ie,k as ce,i as cs,s as v,n as rs,j as e,bb as ds,a9 as _e,bc as x,bd as ps,be as re,I as de,aT as T,aR as H,bf as ms,bg as J,aS as pe,bh as me,bi as us,$ as hs}from"./main-D5sqeuwB.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function Le(d,j){const S=j.filter(C=>!d.has(C));return S.length===0?`${j[Math.floor(Math.random()*j.length)]}-${Date.now()%1e3}`:S[Math.floor(Math.random()*S.length)]}function gs({isOpen:d,onClose:j,onSpawnStart:S,onSpawnEnd:C,spawnPosition:$e,spawnAreaId:N}){const{t:n}=ns(["terminal","common"]),P=as(),p=ts(),ue=ls(),X=ue.length>0?ue:os,[m,b]=t.useState(""),[k,F]=t.useState(()=>De(oe.LAST_CWD)),[i,M]=t.useState("scout"),[he,I]=t.useState(!1),[Te,R]=t.useState(!1),[we,Y]=t.useState(!1),[xe,fe]=t.useState(""),[y,Q]=t.useState([]),[E,O]=t.useState(null),[Pe,ge]=t.useState(!1),[_,je]=t.useState(""),[h,Fe]=t.useState(""),[U,Re]=t.useState(!1),[z,Oe]=t.useState("bypass"),[o,G]=t.useState("claude"),[f,A]=t.useState({fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),[V,Z]=t.useState(new Set),[ee,Ne]=t.useState("claude-opus-4-8[1m]"),[se,be]=t.useState("xHigh"),[ne,Ue]=t.useState("gpt-5.6-luna"),[ae,ze]=t.useState("minimax/MiniMax-M1-80k"),[te,Ge]=t.useState(is),[ve,qe]=t.useState(""),[D,We]=t.useState(""),q=t.useRef(null),Se=t.useRef(!1),L=t.useCallback(()=>{window.__spawnModalAreaContext=null},[]),w=t.useMemo(()=>P.filter(s=>s.enabled),[P]),Be=["full-notifications","streaming-exec","task-label","report-task-to-boss","agent-tracking","agent-memory","send-message-to-agent"];t.useEffect(()=>{if(d&&!Se.current){if(w.length>0){const l=w.filter(r=>Be.includes(r.slug)).map(r=>r.id);l.length>0&&Z(new Set(l))}const a=De(oe.DEFAULT_AGENT_CLASS);if(a==="random"){const r=[...Object.keys(us),...p.map(u=>u.id)];M(r[Math.floor(Math.random()*r.length)])}else M(a||"scout")}Se.current=d},[d,w,p]);const Ce=t.useMemo(()=>{if(!D.trim())return w;const s=D.toLowerCase();return w.filter(a=>a.name.toLowerCase().includes(s)||a.description.toLowerCase().includes(s)||a.slug.toLowerCase().includes(s))},[w,D]),Ke=t.useCallback(s=>{Z(a=>{const l=new Set(a);return l.has(s)?l.delete(s):l.add(s),l})},[]);t.useMemo(()=>w.filter(s=>s.assignedAgentClasses.includes(i)),[w,i]);const He=t.useMemo(()=>{var a;const s=p.find(l=>l.id===i);return(a=s==null?void 0:s.defaultSkillIds)!=null&&a.length?P.filter(l=>s.defaultSkillIds.includes(l.id)):[]},[p,i,P]),ke=t.useMemo(()=>{if(!_.trim())return y;const s=_.toLowerCase();return y.filter(a=>a.sessionId.toLowerCase().includes(s)||a.projectPath.toLowerCase().includes(s)||a.firstMessage&&a.firstMessage.toLowerCase().includes(s))},[y,_]),W=t.useMemo(()=>{if(!h.trim())return p;const s=h.toLowerCase();return p.filter(a=>a.name.toLowerCase().includes(s)||a.description.toLowerCase().includes(s)||a.id.toLowerCase().includes(s))},[p,h]),B=t.useMemo(()=>{if(!h.trim())return ie;const s=h.toLowerCase();return ie.filter(a=>{const l=Ie[a.id];return a.name.toLowerCase().includes(s)||a.id.toLowerCase().includes(s)||l.description.toLowerCase().includes(s)})},[h]);t.useEffect(()=>{if(!d||!h.trim())return;const s=[...W.map(a=>a.id),...B.map(a=>a.id)];s.length===1&&s[0]!==i&&M(s[0])},[d,h,W,B,i]);const c=t.useMemo(()=>p.find(s=>s.id===i),[p,i]),Je=t.useMemo(()=>{if(c!=null&&c.model)return c.model},[c]),Xe=t.useMemo(()=>{if(c!=null&&c.customModelPath)return ce(`/api/custom-models/${c.id}`)},[c]),Ye=c==null?void 0:c.modelScale,Qe=t.useMemo(()=>c?"scout":i,[i,c]),K=t.useCallback(async s=>{ge(!0);try{const a=s?ce(`/api/agents/claude-sessions?cwd=${encodeURIComponent(s)}`):ce("/api/agents/claude-sessions"),r=await(await cs(a)).json();Q(r.sessions||[])}catch(a){console.error("Failed to fetch sessions:",a),Q([])}finally{ge(!1)}},[]);t.useEffect(()=>{d?K(k||void 0):(Q([]),O(null),je(""))},[d,K]),t.useEffect(()=>{if(!d)return;const s=setTimeout(()=>{K(k||void 0),O(null)},300);return()=>clearTimeout(s)},[k,d,K]),t.useEffect(()=>{if(!d||!N)return;const s=v.getState().areas.get(N);if(s!=null&&s.directories&&s.directories.length>0){F(s.directories[0]);return}const a=Array.from(v.getState().agents.values()).filter(g=>{var $;return(($=v.getAreaForAgent(g.id))==null?void 0:$.id)===N&&g.cwd});if(a.length===0)return;const l=new Map;for(const g of a)l.set(g.cwd,(l.get(g.cwd)||0)+1);let r="",u=0;for(const[g,$]of l)$>u&&(r=g,u=$);r&&F(r)},[d,N]),t.useEffect(()=>{if(d){const s=new Set(Array.from(v.getState().agents.values()).map(u=>u.name)),a=Le(s,X),l=p.find(u=>u.id===i),r=l?`${l.name} ${a}`:a;b(r),q.current&&(q.current.focus(),q.current.select())}},[d,X]),t.useEffect(()=>{if(!d)return;const s=p.find(a=>a.id===i);if(s){const a=p.find(l=>m.startsWith(l.name+" "));if(a){const l=m.substring(a.name.length+1);b(`${s.name} ${l}`)}else b(`${s.name} ${m}`)}else{const a=p.find(l=>m.startsWith(l.name+" "));if(a){const l=m.substring(a.name.length+1);b(l)}}},[i]),t.useEffect(()=>{i==="boss"&&Ne("claude-opus-4-8[1m]")},[i]);const Ve=()=>{var r;console.log("[SpawnModal] handleSpawn called"),R(!1);const s=E&&((r=y.find(u=>u.sessionId===E))==null?void 0:r.projectPath)||k;if(console.log("[SpawnModal] Effective CWD:",s),console.log("[SpawnModal] Agent name:",m),console.log("[SpawnModal] Agent class:",i),console.log("[SpawnModal] Permission mode:",z),console.log("[SpawnModal] Provider:",o),console.log("[SpawnModal] Use Chrome:",U),console.log("[SpawnModal] Session ID:",E||"none"),!s.trim()){console.error("[SpawnModal] Empty CWD, showing error"),R(!0);return}if(!m.trim()){console.log("[SpawnModal] Empty name, regenerating");const u=new Set(Array.from(v.getState().agents.values()).map(g=>g.name));b(Le(u,X));return}hs(oe.LAST_CWD,s),I(!0),S();const a=Array.from(V),l=ve.trim()||void 0;console.log("[SpawnModal] Calling store.spawnAgent with:",{name:m.trim(),class:i,cwd:s.trim(),sessionId:E||void 0,useChrome:o==="claude"?U:!1,permissionMode:z,provider:o,codexConfig:o==="codex"?f:void 0,codexModel:o==="codex"?ne:void 0,opencodeModel:o==="opencode"?ae:void 0,grokModel:o==="grok"?te:void 0,initialSkillIds:a,model:o==="claude"?ee:void 0,customInstructions:l?`${l.length} chars`:void 0,spawnAreaId:N||void 0}),window.__spawnModalAreaContext=N?{areaId:N}:null,v.spawnAgent(m.trim(),i,s.trim(),$e||void 0,E||void 0,o==="claude"?U:!1,z,a,o,o==="codex"?f:void 0,o==="codex"?ne:void 0,o==="claude"?ee:void 0,l,o==="claude"||o==="grok"?se:void 0,o==="opencode"?ae:void 0,o==="grok"?te:void 0)},Me=()=>{console.log("[SpawnModal] Agent creation successful"),I(!1),b(""),Z(new Set),L(),C(),j()},ye=()=>{console.error("[SpawnModal] Agent creation failed"),I(!1),R(!0),L(),C()},Ee=s=>{console.log("[SpawnModal] Directory not found:",s),I(!1),fe(s),Y(!0),C()},Ae=()=>{Y(!1),I(!0),S(),v.createDirectoryAndSpawn(xe,m.trim(),i)},le=()=>{Y(!1),fe(""),L()};t.useEffect(()=>(window.__spawnModalSuccess=Me,window.__spawnModalError=ye,window.__spawnModalDirNotFound=Ee,()=>{L(),delete window.__spawnModalSuccess,delete window.__spawnModalError,delete window.__spawnModalDirNotFound}),[m,i,Me,ye,Ee,L]);const{handleMouseDown:Ze,handleClick:es}=rs(j),ss=s=>{s.key==="Escape"&&j()};return!d&&!we?null:we?e.jsx("div",{className:"modal-overlay visible",onClick:le,onKeyDown:s=>{s.key==="Escape"&&le(),s.key==="Enter"&&Ae()},children:e.jsxs("div",{className:"modal confirm-modal",onClick:s=>s.stopPropagation(),children:[e.jsx("div",{className:"modal-header",children:n("terminal:spawn.directoryNotFound")}),e.jsxs("div",{className:"modal-body confirm-modal-body",children:[e.jsx("p",{children:n("terminal:spawn.directoryNotExist")}),e.jsx("code",{className:"confirm-modal-path",children:xe}),e.jsx("p",{children:n("terminal:spawn.wouldYouCreate")})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:le,children:n("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-primary",onClick:Ae,autoFocus:!0,children:n("terminal:spawn.createDirectory")})]})]})}):e.jsx("div",{className:`modal-overlay ${d?"visible":""}`,onMouseDown:Ze,onClick:es,onKeyDown:ss,children:e.jsxs("div",{className:"modal spawn-modal",children:[e.jsx("div",{className:"modal-header",children:n("terminal:spawn.deployTitle")}),e.jsxs("div",{className:"modal-body spawn-modal-body",children:[e.jsxs("div",{className:"spawn-section",children:[e.jsxs("div",{className:"spawn-section-header",children:[e.jsx("h4",{className:"spawn-section-title",children:n("terminal:spawn.agentClass")}),e.jsx("span",{className:"spawn-section-hint",children:(c==null?void 0:c.name)||i})]}),e.jsxs("div",{className:"spawn-top-section",children:[e.jsxs("div",{className:"spawn-preview-compact",children:[e.jsx(ds,{agentClass:Qe,modelFile:Je,customModelUrl:Xe,modelScale:Ye,width:110,height:130}),e.jsx("div",{className:"spawn-preview-label",children:(c==null?void 0:c.name)||i})]}),e.jsxs("div",{className:"spawn-class-section",children:[p.length+ie.length>6&&e.jsx("input",{type:"text",className:"spawn-input class-search-input",placeholder:n("terminal:spawn.filterClasses"),value:h,onChange:s=>Fe(s.target.value)}),e.jsxs("div",{className:"class-selector-inline",children:[W.map(s=>e.jsxs("button",{className:`class-chip ${i===s.id?"selected":""}`,onClick:()=>M(s.id),title:s.description,children:[e.jsx(_e,{classId:s.id,size:18,className:"class-chip-icon"}),e.jsx("span",{className:"class-chip-name",children:s.name})]},s.id)),B.map(s=>{const a=Ie[s.id];return e.jsxs("button",{className:`class-chip ${i===s.id?"selected":""}`,onClick:()=>M(s.id),title:a.description,children:[e.jsx(_e,{classId:s.id,size:18,className:"class-chip-icon"}),e.jsx("span",{className:"class-chip-name",children:s.name})]},s.id)}),h&&W.length===0&&B.length===0&&e.jsx("div",{className:"class-search-empty",children:n("terminal:spawn.noClassesMatch",{query:h})})]})]})]}),e.jsxs("div",{className:"spawn-form-row",children:[e.jsxs("div",{className:"spawn-field",children:[e.jsx("label",{className:"spawn-label",children:n("common:labels.name")}),e.jsx("input",{ref:q,type:"text",className:"spawn-input",placeholder:n("terminal:spawn.agentNamePlaceholder"),value:m,onChange:s=>b(s.target.value)})]}),e.jsxs("div",{className:"spawn-field spawn-field-wide",children:[e.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.workingDir"),e.jsx(x,{text:n("terminal:spawn.helpWorkingDir"),title:n("terminal:spawn.workingDir"),position:"top",size:"sm"})]}),e.jsx(ps,{value:k,onChange:s=>{F(s),R(!1)},placeholder:n("terminal:spawn.workingDirPlaceholder"),className:`spawn-input ${Te?"error":""}`,directoriesOnly:!0})]})]})]}),e.jsxs("div",{className:"spawn-section",children:[e.jsx("div",{className:"spawn-section-header",children:e.jsx("h4",{className:"spawn-section-title",children:n("terminal:spawn.selectRuntime")})}),e.jsxs("div",{className:"spawn-form-row",children:[e.jsxs("div",{className:"spawn-field",children:[e.jsxs("label",{className:"spawn-label",children:[n("common:labels.runtime"),e.jsx(x,{text:n("terminal:spawn.helpRuntime"),title:n("terminal:spawn.runtimeTitle"),position:"top",size:"sm"})]}),e.jsxs("div",{className:"spawn-select-row",children:[e.jsxs("button",{className:`spawn-select-btn ${o==="claude"?"selected":""}`,onClick:()=>G("claude"),title:n("terminal:spawn.useClaudeCli"),children:[e.jsx("img",{src:"/assets/claude.ico",alt:"Claude",className:"spawn-provider-icon"}),e.jsx("span",{children:"Claude"})]}),e.jsxs("button",{className:`spawn-select-btn ${o==="codex"?"selected":""}`,onClick:()=>G("codex"),title:n("terminal:spawn.useCodexCli"),children:[e.jsx("img",{src:"/assets/codex.ico",alt:"Codex",className:"spawn-provider-icon"}),e.jsx("span",{children:"Codex"})]}),e.jsxs("button",{className:`spawn-select-btn spawn-select-btn--opencode ${o==="opencode"?"selected":""}`,onClick:()=>G("opencode"),title:"Use OpenCode CLI (multi-provider)",children:[e.jsx("img",{src:"/assets/opencode.svg",alt:"OpenCode",className:"spawn-provider-icon"}),e.jsx("span",{children:"OpenCode"})]}),e.jsxs("button",{className:`spawn-select-btn spawn-select-btn--grok ${o==="grok"?"selected":""}`,onClick:()=>G("grok"),title:"Use Grok CLI (headless)",children:[e.jsx("img",{src:"/assets/grok.png",alt:"Grok",className:"spawn-provider-icon"}),e.jsx("span",{children:"Grok"})]})]})]}),e.jsxs("div",{className:"spawn-field",children:[e.jsxs("label",{className:"spawn-label",children:[n("common:labels.permissions"),e.jsx(x,{text:n("terminal:spawn.helpPermission"),title:n("terminal:spawn.permissionMode"),position:"top",size:"sm"})]}),e.jsx("div",{className:"spawn-select-row",children:Object.keys(re).map(s=>e.jsxs("button",{className:`spawn-select-btn ${z===s?"selected":""}`,onClick:()=>Oe(s),title:re[s].description,children:[e.jsx("span",{children:e.jsx(de,{name:s==="bypass"?"bolt":"lock",size:12})}),e.jsx("span",{children:re[s].label})]},s))})]})]}),e.jsx("div",{className:"spawn-form-row",children:e.jsxs("div",{className:"spawn-field",children:[e.jsxs("label",{className:"spawn-label",children:[n("common:labels.model"),e.jsx(x,{text:n("terminal:spawn.helpModel"),title:n("terminal:spawn.modelTitle"),position:"top",size:"sm"})]}),o==="claude"?e.jsx("div",{className:"spawn-select-row spawn-select-row--wrap",children:Object.keys(T).filter(s=>!T[s].deprecated).map(s=>e.jsxs("button",{className:`spawn-select-btn ${ee===s?"selected":""}`,onClick:()=>Ne(s),title:T[s].description,children:[e.jsx("span",{children:T[s].icon}),e.jsx("span",{children:T[s].label})]},s))}):o==="codex"?e.jsx("div",{className:"spawn-select-row spawn-select-row--codex-models",children:Object.keys(H).map(s=>e.jsxs("button",{className:`spawn-select-btn ${ne===s?"selected":""}`,onClick:()=>Ue(s),title:H[s].description,children:[e.jsx("span",{children:H[s].icon}),e.jsx("span",{children:H[s].label})]},s))}):o==="opencode"?e.jsx(ms,{value:ae,onChange:ze,inputId:"spawn-opencode-model"}):o==="grok"?e.jsx("div",{className:"spawn-select-row spawn-select-row--wrap",children:Object.keys(J).map(s=>e.jsxs("button",{className:`spawn-select-btn ${te===s?"selected":""}`,onClick:()=>Ge(s),title:J[s].description,children:[e.jsx("span",{children:J[s].icon}),e.jsx("span",{children:J[s].label})]},s))}):e.jsx("div",{className:"spawn-inline-hint",children:n("terminal:spawn.chooseCodexModel")})]})}),e.jsxs("div",{className:"spawn-form-row",children:[(o==="claude"||o==="grok")&&e.jsxs("div",{className:"spawn-field",children:[e.jsx("label",{className:"spawn-label",children:"Effort"}),e.jsxs("div",{className:"spawn-select-row spawn-select-row--effort",children:[e.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${se===void 0?"selected":""}`,onClick:()=>be(void 0),title:"Use default effort level",children:e.jsx("span",{children:"Default"})}),Object.keys(pe).map(s=>e.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${se===s?"selected":""}`,onClick:()=>be(s),title:pe[s].description,children:e.jsx("span",{children:pe[s].label})},s))]})]}),e.jsxs("div",{className:"spawn-field",children:[e.jsx("label",{className:"spawn-label",children:n("terminal:spawn.browser")}),e.jsxs("label",{className:"spawn-checkbox",children:[e.jsx("input",{type:"checkbox",checked:U,onChange:s=>Re(s.target.checked),disabled:o!=="claude"}),e.jsxs("span",{children:[e.jsx(de,{name:"globe",size:12})," ",n("terminal:spawn.chromeBrowser")]}),e.jsx(x,{text:n(o==="claude"?"terminal:spawn.helpChrome":"terminal:spawn.helpChromeDisabled"),title:n("terminal:spawn.chromeBrowser"),position:"top",size:"sm"})]})]})]}),o==="codex"&&e.jsxs("div",{className:"codex-config-section",children:[e.jsx("div",{className:"codex-config-title",children:n("terminal:spawn.codex.configuration")}),e.jsxs("div",{className:"codex-config-options",children:[e.jsxs("div",{className:"codex-option-group",children:[e.jsxs("label",{className:"spawn-checkbox",children:[e.jsx("input",{type:"checkbox",checked:f.fullAuto!==!1,onChange:s=>A(a=>({...a,fullAuto:s.target.checked}))}),e.jsx("span",{children:n("terminal:spawn.codex.fullAuto")}),e.jsx(x,{text:n("terminal:spawn.helpFullAuto"),title:n("terminal:spawn.fullAutoTitle"),position:"top",size:"sm"})]}),e.jsxs("label",{className:"spawn-checkbox",children:[e.jsx("input",{type:"checkbox",checked:!!f.search,onChange:s=>A(a=>({...a,search:s.target.checked}))}),e.jsx("span",{children:n("terminal:spawn.codex.search")}),e.jsx(x,{text:n("terminal:spawn.helpSearch"),title:n("terminal:spawn.searchTitle"),position:"top",size:"sm"})]})]}),f.fullAuto===!1&&e.jsxs("div",{className:"codex-option-group",children:[e.jsx("div",{className:"codex-option-header",children:n("terminal:spawn.codex.restrictions")}),e.jsxs("select",{className:"spawn-input codex-select",value:f.sandbox||"workspace-write",onChange:s=>A(a=>({...a,sandbox:s.target.value})),children:[e.jsxs("option",{value:"read-only",children:["📖 ",n("terminal:spawn.codex.sandboxReadOnly")]}),e.jsxs("option",{value:"workspace-write",children:["✏️ ",n("terminal:spawn.codex.sandboxWorkspaceWrite")]}),e.jsxs("option",{value:"danger-full-access",children:["⚡ ",n("terminal:spawn.codex.sandboxDangerFullAccess")]})]}),e.jsxs("select",{className:"spawn-input codex-select",value:f.approvalMode||"on-request",onChange:s=>A(a=>({...a,approvalMode:s.target.value})),children:[e.jsxs("option",{value:"untrusted",children:["🔒 ",n("terminal:spawn.codex.approvalsUntrusted")]}),e.jsxs("option",{value:"on-failure",children:["⚠️ ",n("terminal:spawn.codex.approvalsOnFailure")]}),e.jsxs("option",{value:"on-request",children:["🤔 ",n("terminal:spawn.codex.approvalsOnRequest")]}),e.jsxs("option",{value:"never",children:["✅ ",n("terminal:spawn.codex.approvalsNever")]})]})]}),e.jsxs("div",{className:"codex-option-group",children:[e.jsx("div",{className:"codex-option-header",children:n("terminal:spawn.codex.profile")}),e.jsx("input",{type:"text",className:"spawn-input codex-profile-input",placeholder:n("terminal:spawn.codex.profilePlaceholder"),value:f.profile||"",onChange:s=>A(a=>({...a,profile:s.target.value||void 0}))})]}),e.jsxs("div",{className:"codex-option-group",children:[e.jsx("div",{className:"codex-option-header",children:n("terminal:spawn.codex.reasoningEffort")}),e.jsxs("select",{className:"spawn-input codex-select",value:f.reasoningEffort||"",onChange:s=>A(a=>({...a,reasoningEffort:s.target.value||void 0})),children:[e.jsx("option",{value:"",children:n("terminal:spawn.codex.reasoningEffortDefault")}),Object.keys(me).map(s=>e.jsxs("option",{value:s,children:[me[s].icon," ",me[s].label]},s))]})]})]})]})]}),w.length>0&&e.jsxs("div",{className:"spawn-section spawn-skills-section",children:[e.jsxs("div",{className:"spawn-section-header",children:[e.jsxs("h4",{className:"spawn-section-title",children:[n("terminal:spawn.skills"),e.jsx(x,{text:n("terminal:spawn.helpSkills"),title:n("terminal:spawn.skillsTitle"),position:"top",size:"sm"})]}),e.jsxs("span",{className:"spawn-section-hint",children:[V.size," selected · ",n("common:labels.optional")]})]}),w.length>6&&e.jsx("input",{type:"text",className:"spawn-input skill-search-input",placeholder:n("terminal:spawn.filterSkills"),value:D,onChange:s=>We(s.target.value)}),e.jsxs("div",{className:"spawn-skills-inline",children:[Ce.map(s=>{const a=V.has(s.id);return He.some(r=>r.id===s.id)?null:e.jsxs("button",{className:`spawn-skill-chip ${a?"selected":""}`,onClick:()=>Ke(s.id),title:s.description,children:[a&&e.jsx("span",{className:"spawn-skill-check",children:e.jsx(de,{name:"check",size:10})}),e.jsx("span",{children:s.name}),s.builtin&&e.jsx("span",{className:"spawn-skill-builtin",children:"TC"})]},s.id)}),D&&Ce.length===0&&e.jsx("div",{className:"skill-search-empty",children:n("terminal:spawn.noSkillsMatch",{query:D})})]})]}),e.jsxs("details",{className:"spawn-advanced",children:[e.jsxs("summary",{children:[n("terminal:spawn.customInstructions")," & ",n("terminal:spawn.linkSession")]}),e.jsxs("div",{className:"spawn-advanced-body",children:[e.jsxs("div",{className:"spawn-custom-instructions-section",children:[e.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.customInstructions")," ",e.jsxs("span",{className:"spawn-label-hint",children:["(",n("common:labels.optional"),")"]}),e.jsx(x,{text:n("terminal:spawn.helpCustomInstructions"),title:n("terminal:spawn.customInstructions"),position:"top",size:"sm"})]}),e.jsx("textarea",{className:"spawn-input spawn-textarea",placeholder:n("terminal:spawn.customInstructionsPlaceholder"),value:ve,onChange:s=>qe(s.target.value),rows:3})]}),e.jsxs("div",{className:"spawn-sessions-section",children:[e.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.linkSession")," ",e.jsxs("span",{className:"spawn-label-hint",children:["(",n("common:labels.optional"),")"]}),e.jsx(x,{text:n("terminal:spawn.helpLinkSession"),title:n("terminal:spawn.linkSessionTitle"),position:"top",size:"sm"})]}),y.length>0&&e.jsx("input",{type:"text",className:"spawn-input session-search-input",placeholder:n("terminal:spawn.searchSessions"),value:_,onChange:s=>je(s.target.value)}),e.jsx("div",{className:"sessions-list",children:Pe?e.jsx("div",{className:"sessions-loading",children:n("terminal:spawn.loadingSessions")}):y.length===0?e.jsx("div",{className:"sessions-empty",children:n("terminal:spawn.noSessions")}):ke.length===0?e.jsx("div",{className:"sessions-empty",children:n("terminal:spawn.noSessionsMatch",{query:_})}):ke.map(s=>{const a=E===s.sessionId,l=Date.now()-new Date(s.lastModified).getTime(),r=l<6e4?n("common:time.justNow"):l<36e5?n("common:time.minutesAgo",{count:Math.floor(l/6e4)}):l<864e5?n("common:time.hoursAgo",{count:Math.floor(l/36e5)}):n("common:time.daysAgo",{count:Math.floor(l/864e5)});return e.jsxs("div",{className:`session-item ${a?"selected":""}`,onClick:()=>{a?O(null):(O(s.sessionId),F(s.projectPath))},children:[e.jsxs("div",{className:"session-item-header",children:[e.jsx("span",{className:"session-item-path",children:s.projectPath}),e.jsx("span",{className:"session-item-age",children:r})]}),e.jsx("div",{className:"session-item-preview",children:s.firstMessage||n("terminal:spawn.messagesCount",{count:s.messageCount})})]},s.sessionId)})})]})]})]})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:j,children:n("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-primary",onClick:Ve,disabled:he,children:n(he?"common:buttons.deploying":"common:buttons2.deploy")})]})]})})}export{gs as SpawnModal};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as R,n as U,ao as j,cX as F,cY as B,j as t,bv as G,I,bY as k}from"./main-C2zgPci-.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const b=["#6ab8c8","#c89a5a","#9a80c0","#5cb88a","#c85a5a","#c87a9a","#c8c87a","#5a8fd4","#d45a5a","#8a6fbf"],P=14,w=720,C=260,p={top:16,right:20,bottom:42,left:64};function W(){const i=new Date;return i.setHours(0,0,0,0),i.getTime()}function $(i){if(!i)return"N/A";try{return new Date(i).toLocaleString()}catch{return"N/A"}}function Y(i,s){if(i.length===0||s<=0)return"conic-gradient(rgba(50, 50, 62, 0.95) 0deg 360deg)";let a=0;return`conic-gradient(${i.map((h,l)=>{const c=a,n=h.tokens.total/s*360;return a+=n,`${b[l%b.length]} ${c.toFixed(2)}deg ${a.toFixed(2)}deg`}).join(", ")})`}function E(i){const[,s,a]=i.split("-");return!s||!a?i:`${s}/${a}`}function z(i){const s=(i==null?void 0:i.days)??[];if(s.length===0)return[];const a=new Map;for(const l of s)for(const c of l.agents){const n=a.get(c.agentId)??{agentName:c.agentName,total:0};n.total+=c.tokens.total,a.set(c.agentId,n)}const r={id:"general",name:"General",color:"#f1fa8c",values:s.map(l=>l.totalTokens),total:s.reduce((l,c)=>l+c.totalTokens,0),peak:Math.max(0,...s.map(l=>l.totalTokens)),isTotal:!0},h=[...a.entries()].sort((l,c)=>c[1].total-l[1].total).map(([l,c],n)=>({id:l,name:c.agentName,color:b[n%b.length],values:s.map(u=>{var d;return((d=u.agents.find(x=>x.agentId===l))==null?void 0:d.tokens.total)??0}),total:c.total,peak:Math.max(0,...s.map(u=>{var d;return((d=u.agents.find(x=>x.agentId===l))==null?void 0:d.tokens.total)??0}))}));return[r,...h].filter(l=>l.total>0)}function q(i){if(i<=0)return 1;const s=10**Math.floor(Math.log10(i)),a=i/s;return(a<=1?1:a<=2?2:a<=5?5:10)*s}function H(i,s,a,r){const h=p.left,l=p.top,c=w-p.left-p.right,n=C-p.top-p.bottom,u=i<=1?h+c/2:h+s/(i-1)*c,d=l+n-a/r*n;return{x:u,y:d}}function X(i,s){return i.map((a,r)=>{const{x:h,y:l}=H(i.length,r,a,s);return`${h.toFixed(2)},${l.toFixed(2)}`}).join(" ")}function J(i,s=28){return i.length<=s?i:`${i.slice(0,s-1)}...`}function K({summary:i}){const[s,a]=j.useState(null),r=i.days,h=z(i),l=Math.max(1,...h.flatMap(e=>e.values)),c=q(l),n=p.left,u=p.top,d=w-p.left-p.right,x=C-p.top-p.bottom,f=[0,.5,1],M=Math.max(1,Math.ceil(r.length/5)),v=190,y=86,g=s?Math.min(Math.max(s.x+12,8),w-v-8):0,_=s?Math.min(Math.max(s.y-y-10,8),C-y-8):0;return t.jsxs("div",{className:"statistics-line-chart",children:[t.jsxs("svg",{className:"statistics-line-chart__svg",viewBox:`0 0 ${w} ${C}`,role:"img","aria-label":"Daily Claude token usage by agent",preserveAspectRatio:"xMidYMid meet",onMouseLeave:()=>a(null),children:[f.map(e=>{const m=u+x-e*x;return t.jsxs("g",{children:[t.jsx("line",{className:"statistics-line-chart__grid",x1:n,y1:m,x2:n+d,y2:m}),t.jsx("text",{className:"statistics-line-chart__axis-label",x:n-10,y:m+4,textAnchor:"end",children:k(Math.round(c*e))})]},e)}),t.jsx("line",{className:"statistics-line-chart__axis",x1:n,y1:u,x2:n,y2:u+x}),t.jsx("line",{className:"statistics-line-chart__axis",x1:n,y1:u+x,x2:n+d,y2:u+x}),r.map((e,m)=>{if(m!==0&&m!==r.length-1&&m%M!==0)return null;const o=r.length<=1?n+d/2:n+m/(r.length-1)*d;return t.jsx("text",{className:"statistics-line-chart__axis-label",x:o,y:C-14,textAnchor:"middle",children:E(e.date)},e.date)}),h.map(e=>t.jsx("polyline",{className:e.isTotal?"statistics-line-chart__line statistics-line-chart__line--total":"statistics-line-chart__line",points:X(e.values,c),fill:"none",stroke:e.color,strokeWidth:e.isTotal?3:2,strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("title",{children:`${e.name}: ${e.peak.toLocaleString()} peak daily tokens`})},e.id)),h.map(e=>e.values.map((m,o)=>{var L,D,V,A;const{x:N,y:S}=H(r.length,o,m,c),T={id:`${e.id}-${(L=r[o])==null?void 0:L.date}`,date:((D=r[o])==null?void 0:D.date)??"",name:e.name,color:e.color,value:m,total:e.total,peak:e.peak,x:N,y:S};return t.jsxs("g",{children:[t.jsx("circle",{className:"statistics-line-chart__point",cx:N,cy:S,r:e.isTotal?3.4:2.6,fill:e.color}),t.jsx("circle",{className:"statistics-line-chart__point-hit",cx:N,cy:S,r:10,tabIndex:0,role:"button","aria-label":`${e.name} ${(V=r[o])==null?void 0:V.date}: ${m.toLocaleString()} tokens`,onMouseEnter:()=>a(T),onFocus:()=>a(T),onBlur:()=>a(null)})]},`${e.id}-${(A=r[o])==null?void 0:A.date}`)})),s&&t.jsxs("g",{className:"statistics-line-chart__tooltip",children:[t.jsx("line",{className:"statistics-line-chart__hover-line",x1:s.x,y1:u,x2:s.x,y2:u+x}),t.jsx("circle",{className:"statistics-line-chart__hover-point",cx:s.x,cy:s.y,r:5,fill:s.color}),t.jsx("rect",{className:"statistics-line-chart__tooltip-box",x:g,y:_,width:v,height:y,rx:6}),t.jsx("text",{className:"statistics-line-chart__tooltip-title",x:g+10,y:_+18,children:E(s.date)}),t.jsx("text",{className:"statistics-line-chart__tooltip-name",x:g+10,y:_+34,children:J(s.name)}),t.jsxs("text",{className:"statistics-line-chart__tooltip-value",x:g+10,y:_+52,children:["Daily: ",k(s.value)]}),t.jsxs("text",{className:"statistics-line-chart__tooltip-meta",x:g+10,y:_+68,children:["Peak: ",k(s.peak)]}),t.jsxs("text",{className:"statistics-line-chart__tooltip-meta",x:g+100,y:_+68,children:["Total: ",k(s.total)]})]})]}),t.jsx("div",{className:"statistics-line-chart__legend",children:h.map(e=>t.jsxs("div",{className:"statistics-line-chart__legend-item",title:`${e.name}: peak ${e.peak.toLocaleString()} daily tokens, ${e.total.toLocaleString()} period tokens`,children:[t.jsx("span",{className:"statistics-line-chart__legend-swatch",style:{backgroundColor:e.color}}),t.jsx("span",{children:e.name}),t.jsx("strong",{children:k(e.peak)})]},e.id))})]})}function tt({isOpen:i,onClose:s}){const{t:a}=R(["terminal","common"]),{handleMouseDown:r,handleClick:h}=U(s),[l,c]=j.useState(null),[n,u]=j.useState(null),[d,x]=j.useState(!1),[f,M]=j.useState(null),v=j.useMemo(()=>W(),[]),y=j.useCallback(async()=>{x(!0),M(null);try{const o=Date.now(),[N,S]=await Promise.all([F({since:v,until:o}),B({days:P,until:o})]);c(N),u(S)}catch(o){M((o==null?void 0:o.message)||"Error")}finally{x(!1)}},[v]);if(j.useEffect(()=>{i&&y()},[i,y]),!i)return null;const g=(l==null?void 0:l.entries)??[],_=(l==null?void 0:l.totalTokens)??0,e=Y(g,_),m=((n==null?void 0:n.days)??[]).some(o=>o.totalTokens>0);return t.jsx(G,{children:t.jsx("div",{className:"modal-overlay visible",onMouseDown:r,onClick:h,children:t.jsxs("div",{className:"modal statistics-modal",children:[t.jsxs("div",{className:"modal-header statistics-modal__header",children:[t.jsxs("div",{className:"statistics-modal__title",children:[t.jsx("span",{className:"statistics-modal__icon",children:t.jsx(I,{name:"dashboard",size:15})}),t.jsx("span",{children:a("terminal:statistics.title",{defaultValue:"Statistics"})})]}),t.jsx("button",{className:"modal-close statistics-modal__close",onClick:s,title:a("common:buttons.close"),children:"×"})]}),t.jsxs("div",{className:"modal-body statistics-modal__body",children:[t.jsxs("section",{className:"statistics-panel",children:[t.jsxs("div",{className:"statistics-panel__header",children:[t.jsxs("div",{children:[t.jsx("h3",{children:a("terminal:statistics.usageByAgent",{defaultValue:"Claude usage today"})}),t.jsx("span",{className:"statistics-panel__subtitle",children:a("terminal:statistics.usageByAgentSubtitle",{defaultValue:"Input + cache creation + cache read + output tokens, deduped by Claude request id"})})]}),t.jsx("button",{type:"button",className:"statistics-panel__refresh",onClick:y,disabled:d,title:a("terminal:statistics.refresh",{defaultValue:"Refresh usage"}),children:t.jsx(I,{name:"refresh",size:14})})]}),d&&!l&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.loading",{defaultValue:"Loading usage..."})}),!d&&f&&t.jsx("div",{className:"statistics-panel__empty statistics-panel__empty--error",children:a("terminal:statistics.error",{defaultValue:"Failed to load usage: {{error}}",error:f})}),!f&&l&&g.length===0&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.empty",{defaultValue:"No Claude token usage found for today."})}),!f&&l&&g.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"statistics-panel__layout",children:[t.jsx("div",{className:"statistics-panel__chart-wrap",children:t.jsx("div",{className:"statistics-panel__pie",style:{background:e},role:"img","aria-label":a("terminal:statistics.pieLabel",{defaultValue:"Claude token usage by agent"}),children:t.jsxs("div",{className:"statistics-panel__pie-hole",children:[t.jsx("strong",{children:k(_)}),t.jsx("span",{children:a("terminal:statistics.total",{defaultValue:"total"})})]})})}),t.jsx("div",{className:"statistics-panel__list",children:g.map((o,N)=>t.jsxs("div",{className:"statistics-panel__row",title:`${o.agentName}: ${o.tokens.total.toLocaleString()} tokens`,children:[t.jsx("span",{className:"statistics-panel__swatch",style:{backgroundColor:b[N%b.length]}}),t.jsxs("div",{className:"statistics-panel__row-main",children:[t.jsx("div",{className:"statistics-panel__row-name",children:o.agentName}),t.jsxs("div",{className:"statistics-panel__row-meta",children:[o.requestCount.toLocaleString()," ",a("terminal:statistics.requests",{defaultValue:"requests"})," / ",o.percent,"%"]})]}),t.jsx("strong",{children:k(o.tokens.total)})]},o.agentId))})]}),t.jsx("div",{className:"statistics-panel__footnote",children:a("terminal:statistics.window",{defaultValue:"Window: {{since}} to {{until}}",since:$(l.since),until:$(l.until)})})]})]}),t.jsxs("section",{className:"statistics-panel",children:[t.jsx("div",{className:"statistics-panel__header",children:t.jsxs("div",{children:[t.jsx("h3",{children:a("terminal:statistics.dailyUsage",{defaultValue:"Daily usage by agent"})}),t.jsx("span",{className:"statistics-panel__subtitle",children:a("terminal:statistics.dailyUsageSubtitle",{defaultValue:"General token usage by day plus one line for each Claude agent."})})]})}),d&&!n&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.loading",{defaultValue:"Loading usage..."})}),!d&&!f&&n&&!m&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.dailyEmpty",{defaultValue:"No Claude token usage found for recent days."})}),!f&&n&&m&&t.jsxs(t.Fragment,{children:[t.jsx(K,{summary:n}),t.jsx("div",{className:"statistics-panel__footnote",children:a("terminal:statistics.window",{defaultValue:"Window: {{since}} to {{until}}",since:$(n.since),until:$(n.until)})})]})]})]})]})})})}export{tt as StatisticsModal};
|
|
1
|
+
import{u as R,n as U,aq as j,d0 as F,d1 as B,j as t,bA as G,I,c1 as k}from"./main-D5sqeuwB.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const b=["#6ab8c8","#c89a5a","#9a80c0","#5cb88a","#c85a5a","#c87a9a","#c8c87a","#5a8fd4","#d45a5a","#8a6fbf"],P=14,w=720,C=260,p={top:16,right:20,bottom:42,left:64};function W(){const i=new Date;return i.setHours(0,0,0,0),i.getTime()}function $(i){if(!i)return"N/A";try{return new Date(i).toLocaleString()}catch{return"N/A"}}function q(i,s){if(i.length===0||s<=0)return"conic-gradient(rgba(50, 50, 62, 0.95) 0deg 360deg)";let a=0;return`conic-gradient(${i.map((h,l)=>{const c=a,n=h.tokens.total/s*360;return a+=n,`${b[l%b.length]} ${c.toFixed(2)}deg ${a.toFixed(2)}deg`}).join(", ")})`}function E(i){const[,s,a]=i.split("-");return!s||!a?i:`${s}/${a}`}function z(i){const s=(i==null?void 0:i.days)??[];if(s.length===0)return[];const a=new Map;for(const l of s)for(const c of l.agents){const n=a.get(c.agentId)??{agentName:c.agentName,total:0};n.total+=c.tokens.total,a.set(c.agentId,n)}const r={id:"general",name:"General",color:"#f1fa8c",values:s.map(l=>l.totalTokens),total:s.reduce((l,c)=>l+c.totalTokens,0),peak:Math.max(0,...s.map(l=>l.totalTokens)),isTotal:!0},h=[...a.entries()].sort((l,c)=>c[1].total-l[1].total).map(([l,c],n)=>({id:l,name:c.agentName,color:b[n%b.length],values:s.map(u=>{var d;return((d=u.agents.find(x=>x.agentId===l))==null?void 0:d.tokens.total)??0}),total:c.total,peak:Math.max(0,...s.map(u=>{var d;return((d=u.agents.find(x=>x.agentId===l))==null?void 0:d.tokens.total)??0}))}));return[r,...h].filter(l=>l.total>0)}function Y(i){if(i<=0)return 1;const s=10**Math.floor(Math.log10(i)),a=i/s;return(a<=1?1:a<=2?2:a<=5?5:10)*s}function H(i,s,a,r){const h=p.left,l=p.top,c=w-p.left-p.right,n=C-p.top-p.bottom,u=i<=1?h+c/2:h+s/(i-1)*c,d=l+n-a/r*n;return{x:u,y:d}}function X(i,s){return i.map((a,r)=>{const{x:h,y:l}=H(i.length,r,a,s);return`${h.toFixed(2)},${l.toFixed(2)}`}).join(" ")}function J(i,s=28){return i.length<=s?i:`${i.slice(0,s-1)}...`}function K({summary:i}){const[s,a]=j.useState(null),r=i.days,h=z(i),l=Math.max(1,...h.flatMap(e=>e.values)),c=Y(l),n=p.left,u=p.top,d=w-p.left-p.right,x=C-p.top-p.bottom,f=[0,.5,1],M=Math.max(1,Math.ceil(r.length/5)),v=190,y=86,g=s?Math.min(Math.max(s.x+12,8),w-v-8):0,_=s?Math.min(Math.max(s.y-y-10,8),C-y-8):0;return t.jsxs("div",{className:"statistics-line-chart",children:[t.jsxs("svg",{className:"statistics-line-chart__svg",viewBox:`0 0 ${w} ${C}`,role:"img","aria-label":"Daily Claude token usage by agent",preserveAspectRatio:"xMidYMid meet",onMouseLeave:()=>a(null),children:[f.map(e=>{const m=u+x-e*x;return t.jsxs("g",{children:[t.jsx("line",{className:"statistics-line-chart__grid",x1:n,y1:m,x2:n+d,y2:m}),t.jsx("text",{className:"statistics-line-chart__axis-label",x:n-10,y:m+4,textAnchor:"end",children:k(Math.round(c*e))})]},e)}),t.jsx("line",{className:"statistics-line-chart__axis",x1:n,y1:u,x2:n,y2:u+x}),t.jsx("line",{className:"statistics-line-chart__axis",x1:n,y1:u+x,x2:n+d,y2:u+x}),r.map((e,m)=>{if(m!==0&&m!==r.length-1&&m%M!==0)return null;const o=r.length<=1?n+d/2:n+m/(r.length-1)*d;return t.jsx("text",{className:"statistics-line-chart__axis-label",x:o,y:C-14,textAnchor:"middle",children:E(e.date)},e.date)}),h.map(e=>t.jsx("polyline",{className:e.isTotal?"statistics-line-chart__line statistics-line-chart__line--total":"statistics-line-chart__line",points:X(e.values,c),fill:"none",stroke:e.color,strokeWidth:e.isTotal?3:2,strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("title",{children:`${e.name}: ${e.peak.toLocaleString()} peak daily tokens`})},e.id)),h.map(e=>e.values.map((m,o)=>{var L,D,V,A;const{x:N,y:S}=H(r.length,o,m,c),T={id:`${e.id}-${(L=r[o])==null?void 0:L.date}`,date:((D=r[o])==null?void 0:D.date)??"",name:e.name,color:e.color,value:m,total:e.total,peak:e.peak,x:N,y:S};return t.jsxs("g",{children:[t.jsx("circle",{className:"statistics-line-chart__point",cx:N,cy:S,r:e.isTotal?3.4:2.6,fill:e.color}),t.jsx("circle",{className:"statistics-line-chart__point-hit",cx:N,cy:S,r:10,tabIndex:0,role:"button","aria-label":`${e.name} ${(V=r[o])==null?void 0:V.date}: ${m.toLocaleString()} tokens`,onMouseEnter:()=>a(T),onFocus:()=>a(T),onBlur:()=>a(null)})]},`${e.id}-${(A=r[o])==null?void 0:A.date}`)})),s&&t.jsxs("g",{className:"statistics-line-chart__tooltip",children:[t.jsx("line",{className:"statistics-line-chart__hover-line",x1:s.x,y1:u,x2:s.x,y2:u+x}),t.jsx("circle",{className:"statistics-line-chart__hover-point",cx:s.x,cy:s.y,r:5,fill:s.color}),t.jsx("rect",{className:"statistics-line-chart__tooltip-box",x:g,y:_,width:v,height:y,rx:6}),t.jsx("text",{className:"statistics-line-chart__tooltip-title",x:g+10,y:_+18,children:E(s.date)}),t.jsx("text",{className:"statistics-line-chart__tooltip-name",x:g+10,y:_+34,children:J(s.name)}),t.jsxs("text",{className:"statistics-line-chart__tooltip-value",x:g+10,y:_+52,children:["Daily: ",k(s.value)]}),t.jsxs("text",{className:"statistics-line-chart__tooltip-meta",x:g+10,y:_+68,children:["Peak: ",k(s.peak)]}),t.jsxs("text",{className:"statistics-line-chart__tooltip-meta",x:g+100,y:_+68,children:["Total: ",k(s.total)]})]})]}),t.jsx("div",{className:"statistics-line-chart__legend",children:h.map(e=>t.jsxs("div",{className:"statistics-line-chart__legend-item",title:`${e.name}: peak ${e.peak.toLocaleString()} daily tokens, ${e.total.toLocaleString()} period tokens`,children:[t.jsx("span",{className:"statistics-line-chart__legend-swatch",style:{backgroundColor:e.color}}),t.jsx("span",{children:e.name}),t.jsx("strong",{children:k(e.peak)})]},e.id))})]})}function tt({isOpen:i,onClose:s}){const{t:a}=R(["terminal","common"]),{handleMouseDown:r,handleClick:h}=U(s),[l,c]=j.useState(null),[n,u]=j.useState(null),[d,x]=j.useState(!1),[f,M]=j.useState(null),v=j.useMemo(()=>W(),[]),y=j.useCallback(async()=>{x(!0),M(null);try{const o=Date.now(),[N,S]=await Promise.all([F({since:v,until:o}),B({days:P,until:o})]);c(N),u(S)}catch(o){M((o==null?void 0:o.message)||"Error")}finally{x(!1)}},[v]);if(j.useEffect(()=>{i&&y()},[i,y]),!i)return null;const g=(l==null?void 0:l.entries)??[],_=(l==null?void 0:l.totalTokens)??0,e=q(g,_),m=((n==null?void 0:n.days)??[]).some(o=>o.totalTokens>0);return t.jsx(G,{children:t.jsx("div",{className:"modal-overlay visible",onMouseDown:r,onClick:h,children:t.jsxs("div",{className:"modal statistics-modal",children:[t.jsxs("div",{className:"modal-header statistics-modal__header",children:[t.jsxs("div",{className:"statistics-modal__title",children:[t.jsx("span",{className:"statistics-modal__icon",children:t.jsx(I,{name:"dashboard",size:15})}),t.jsx("span",{children:a("terminal:statistics.title",{defaultValue:"Statistics"})})]}),t.jsx("button",{className:"modal-close statistics-modal__close",onClick:s,title:a("common:buttons.close"),children:"×"})]}),t.jsxs("div",{className:"modal-body statistics-modal__body",children:[t.jsxs("section",{className:"statistics-panel",children:[t.jsxs("div",{className:"statistics-panel__header",children:[t.jsxs("div",{children:[t.jsx("h3",{children:a("terminal:statistics.usageByAgent",{defaultValue:"Claude usage today"})}),t.jsx("span",{className:"statistics-panel__subtitle",children:a("terminal:statistics.usageByAgentSubtitle",{defaultValue:"Input + cache creation + cache read + output tokens, deduped by Claude request id"})})]}),t.jsx("button",{type:"button",className:"statistics-panel__refresh",onClick:y,disabled:d,title:a("terminal:statistics.refresh",{defaultValue:"Refresh usage"}),children:t.jsx(I,{name:"refresh",size:14})})]}),d&&!l&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.loading",{defaultValue:"Loading usage..."})}),!d&&f&&t.jsx("div",{className:"statistics-panel__empty statistics-panel__empty--error",children:a("terminal:statistics.error",{defaultValue:"Failed to load usage: {{error}}",error:f})}),!f&&l&&g.length===0&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.empty",{defaultValue:"No Claude token usage found for today."})}),!f&&l&&g.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"statistics-panel__layout",children:[t.jsx("div",{className:"statistics-panel__chart-wrap",children:t.jsx("div",{className:"statistics-panel__pie",style:{background:e},role:"img","aria-label":a("terminal:statistics.pieLabel",{defaultValue:"Claude token usage by agent"}),children:t.jsxs("div",{className:"statistics-panel__pie-hole",children:[t.jsx("strong",{children:k(_)}),t.jsx("span",{children:a("terminal:statistics.total",{defaultValue:"total"})})]})})}),t.jsx("div",{className:"statistics-panel__list",children:g.map((o,N)=>t.jsxs("div",{className:"statistics-panel__row",title:`${o.agentName}: ${o.tokens.total.toLocaleString()} tokens`,children:[t.jsx("span",{className:"statistics-panel__swatch",style:{backgroundColor:b[N%b.length]}}),t.jsxs("div",{className:"statistics-panel__row-main",children:[t.jsx("div",{className:"statistics-panel__row-name",children:o.agentName}),t.jsxs("div",{className:"statistics-panel__row-meta",children:[o.requestCount.toLocaleString()," ",a("terminal:statistics.requests",{defaultValue:"requests"})," / ",o.percent,"%"]})]}),t.jsx("strong",{children:k(o.tokens.total)})]},o.agentId))})]}),t.jsx("div",{className:"statistics-panel__footnote",children:a("terminal:statistics.window",{defaultValue:"Window: {{since}} to {{until}}",since:$(l.since),until:$(l.until)})})]})]}),t.jsxs("section",{className:"statistics-panel",children:[t.jsx("div",{className:"statistics-panel__header",children:t.jsxs("div",{children:[t.jsx("h3",{children:a("terminal:statistics.dailyUsage",{defaultValue:"Daily usage by agent"})}),t.jsx("span",{className:"statistics-panel__subtitle",children:a("terminal:statistics.dailyUsageSubtitle",{defaultValue:"General token usage by day plus one line for each Claude agent."})})]})}),d&&!n&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.loading",{defaultValue:"Loading usage..."})}),!d&&!f&&n&&!m&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.dailyEmpty",{defaultValue:"No Claude token usage found for recent days."})}),!f&&n&&m&&t.jsxs(t.Fragment,{children:[t.jsx(K,{summary:n}),t.jsx("div",{className:"statistics-panel__footnote",children:a("terminal:statistics.window",{defaultValue:"Window: {{since}} to {{until}}",since:$(n.since),until:$(n.until)})})]})]})]})]})})})}export{tt as StatisticsModal};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as L,
|
|
1
|
+
import{u as L,aC as $,ar as D,r as m,j as s,bj as N,a9 as S,I as g,s as J}from"./main-D5sqeuwB.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function M({isOpen:l,bossId:r,onClose:o}){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(()=>{l&&n&&c(new Set(n.subordinateIds||[]))},[l,n]);const y=()=>{b(!0),J.assignSubordinates(r,Array.from(i)),setTimeout(()=>{b(!1),o()},300)},A=e=>{const t=new Set(i);t.has(e)?t.delete(e):t.add(e),c(t)},C=()=>{c(new Set(d.map(e=>e.id)))},p=()=>{c(new Set)},w=e=>{e.target===e.currentTarget&&o()},k=e=>{e.key==="Escape"&&o()};if(!l||!n)return null;const E=N.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 ${l?"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:C,children:a("common:buttons.selectAll")}),s.jsx("button",{className:"btn btn-small",onClick:p,children:a("common:buttons.clearAll")})]})]}),s.jsx("div",{className:"subordinates-list",children:d.length===0?s.jsx("div",{className:"subordinates-empty",children:a("terminal:team.noAgentsAvailable")}):d.map(e=>{var v;const t=i.has(e.id),T=N[e.class],z=(v=n.subordinateIds)==null?void 0:v.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:o,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{M as SubordinateAssignmentModal};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{aC as Me,r as o,i as v,k as b,j as e}from"./main-D5sqeuwB.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Ie=[{value:"webhook",label:"Webhook"},{value:"bitbucket",label:"Bitbucket"},{value:"cron",label:"Cron"},{value:"slack",label:"Slack"},{value:"email",label:"Email"},{value:"jira",label:"Jira"},{value:"whatsapp",label:"WhatsApp"}],Ae=[{value:"all",label:"All",icon:"◎"},{value:"webhook",label:"Webhook",icon:"🪝"},{value:"bitbucket",label:"Bitbucket",icon:"🪣"},{value:"cron",label:"Cron",icon:"⏰"},{value:"slack",label:"Slack",icon:"💬"},{value:"email",label:"Email",icon:"✉️"},{value:"jira",label:"Jira",icon:"🎫"},{value:"whatsapp",label:"WhatsApp",icon:"📱"}],Be=[{value:"pullrequest:created",label:"PR created"},{value:"pullrequest:updated",label:"PR updated"},{value:"pullrequest:approved",label:"PR approved"},{value:"pullrequest:unapproved",label:"PR unapproved"},{value:"pullrequest:fulfilled",label:"PR merged"},{value:"pullrequest:rejected",label:"PR declined"},{value:"pullrequest:comment_created",label:"PR comment created"}],Re=[{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)"}],Fe=[{value:"structural",label:"Structural"},{value:"llm",label:"LLM"}];function Ee(w){if(!w)return"";const g=new Date(w);if(Number.isNaN(g.getTime()))return"";const m=j=>String(j).padStart(2,"0");return`${g.getFullYear()}-${m(g.getMonth()+1)}-${m(g.getDate())}T${m(g.getHours())}:${m(g.getMinutes())}`}const O=()=>({name:"",description:"",type:"webhook",agentId:"",promptTemplate:"",enabled:!0,matchMode:"structural",extractionMode:"structural",config:{method:"POST"}});function Pe({isOpen:w,onClose:g}){var Q,X,Z,ee,le,te,se,ae,ne,ie,re,oe,ce,de,pe,ue;const m=Me(),[j,xe]=o.useState([]),[S,A]=o.useState("list"),[n,k]=o.useState(O()),[h,R]=o.useState(!1),[L,D]=o.useState(!1),[P,y]=o.useState(null),[z,he]=o.useState([]),[T,ye]=o.useState(null),[F,be]=o.useState(`{
|
|
2
2
|
|
|
3
3
|
}`),[u,M]=o.useState(null),[N,U]=o.useState(!1),[H,W]=o.useState([]),[I,ge]=o.useState("all"),[_,je]=o.useState([]),f=o.useCallback(async()=>{try{const t=await v(b("/api/triggers"));if(t.ok){const s=await t.json();xe(s)}}catch(t){console.error("Failed to load triggers:",t)}},[]),B=o.useCallback(async t=>{try{const s=await v(b(`/api/triggers/${t}/events?limit=20`));if(s.ok){const a=await s.json();he(a)}}catch(s){console.error("Failed to load trigger history:",s)}},[]),q=o.useCallback(async()=>{try{const t=await v(b("/api/slack/instances"));if(t.ok){const s=await t.json(),a=Array.isArray(s==null?void 0:s.instances)?s.instances:[];je(a.map(p=>({id:p.id,label:p.label||p.id})))}}catch(t){console.error("Failed to load Slack instances:",t)}},[]);o.useEffect(()=>{w&&(f(),q())},[w,f,q]),o.useEffect(()=>{T&&B(T)},[T,B]);const ve=o.useCallback(async()=>{D(!0),y(null);try{const t=h?b(`/api/triggers/${n.id}`):b("/api/triggers"),p=await v(t,{method:h?"PATCH":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!p.ok){const d=await p.json();throw new Error(d.error||"Failed to save trigger")}await f(),A("list"),k(O()),R(!1)}catch(t){y(t instanceof Error?t.message:"Save failed")}finally{D(!1)}},[n,h,f]),me=o.useCallback(async t=>{try{await v(b(`/api/triggers/${t}`),{method:"DELETE"}),await f()}catch(s){console.error("Failed to delete trigger:",s)}},[f]),fe=o.useCallback(async t=>{try{await v(b(`/api/triggers/${t.id}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!t.enabled})}),await f()}catch(s){console.error("Failed to toggle trigger:",s)}},[f]),ke=o.useCallback(async t=>{try{await v(b(`/api/triggers/${t}/fire`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({variables:{}})}),T===t&&await B(t)}catch(s){console.error("Failed to test fire trigger:",s)}},[T,B]),Ce=o.useCallback(async()=>{if(n.id){U(!0),M(null);try{let t;try{t=JSON.parse(F)}catch{M({structuralMatch:void 0,extractedVariables:{},wouldFire:!1}),y("Invalid JSON payload");return}const s=await v(b(`/api/triggers/${n.id}/test-match`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({payload:t})});if(s.ok){const a=await s.json();M(a),y(null)}else{const a=await s.json();y(a.error||"Test match failed")}}catch(t){y(t instanceof Error?t.message:"Test match failed")}finally{U(!1)}}},[n.id,F]),we=o.useCallback(async t=>{var s;try{const a=await v(b("/api/triggers/validate-cron"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({expression:t,timezone:((s=n.config)==null?void 0:s.timezone)||"UTC"})});if(a.ok){const p=await a.json();W(p.valid?p.nextFires:[])}}catch{W([])}},[n]),$=o.useCallback(t=>{t?(k({...t}),R(!0)):(k(O()),R(!1)),M(null),y(null),A("edit")},[]),x=o.useCallback((t,s)=>{k(a=>({...a,[t]:s}))},[]),r=o.useCallback((t,s)=>{k(a=>({...a,config:{...a.config,[t]:s}}))},[]),E=o.useCallback((t,s)=>{k(a=>({...a,llmMatch:{...a.llmMatch||{prompt:""},[t]:s}}))},[]),J=o.useCallback((t,s)=>{k(a=>({...a,llmExtract:{...a.llmExtract||{prompt:"",variables:[]},[t]:s}}))},[]),Se=o.useMemo(()=>Array.from(m.values()).map(t=>({id:t.id,name:t.name,class:t.class})),[m]),Te=o.useMemo(()=>{const t={all:j.length,webhook:0,bitbucket:0,cron:0,slack:0,email:0,jira:0,whatsapp:0};for(const s of j)s.type in t&&(t[s.type]+=1);return t},[j]),G=o.useMemo(()=>I==="all"?j:j.filter(t=>t.type===I),[j,I]),[K,V]=o.useState(null),Y=o.useCallback((t,s)=>{t&&navigator.clipboard.writeText(t).then(()=>{V(s),setTimeout(()=>V(a=>a===s?null:a),1500)},()=>y("Failed to copy to clipboard"))},[]);return w?e.jsx("div",{style:l.overlay,onClick:g,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:S==="list"?"Triggers":h?"Edit Trigger":"New Trigger"}),e.jsxs("div",{style:l.headerActions,children:[S==="list"&&e.jsx("button",{style:l.addBtn,onClick:()=>$(),children:"+ New Trigger"}),S==="edit"&&e.jsx("button",{style:l.backBtn,onClick:()=>{A("list"),M(null),y(null)},children:"Back"}),e.jsx("button",{style:l.closeBtn,onClick:g,children:"X"})]})]}),P&&e.jsx("div",{style:l.error,children:P}),S==="list"&&e.jsxs("div",{style:l.content,children:[e.jsx("div",{style:l.tabBar,role:"tablist","aria-label":"Filter triggers by type",children:Ae.map(t=>{const s=Te[t.value],a=I===t.value;return e.jsxs("button",{role:"tab","aria-selected":a,onClick:()=>ge(t.value),style:{...l.tab,...a?l.tabActive:{}},title:`${t.label} (${s})`,children:[e.jsx("span",{style:l.tabIcon,children:t.icon}),e.jsx("span",{style:l.tabLabel,children:t.label}),e.jsx("span",{style:{...l.tabBadge,...a?l.tabBadgeActive:{}},children:s})]},t.value)})}),j.length===0?e.jsx("div",{style:l.empty,children:"No triggers configured. Create one to get started."}):G.length===0?e.jsxs("div",{style:l.empty,children:["No ",I," triggers configured yet."]}):G.map(t=>{var s;return e.jsxs("div",{style:{...l.triggerCard,borderLeftColor:t.status==="error"?"#e74c3c":t.enabled?"#2ecc71":"#95a5a6"},onClick:()=>{ye(t.id),$(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.type==="cron"&&(()=>{const a=t.config||{};return a.runOnce?a.completedAt?e.jsx("span",{style:{...l.matchTag,color:"#a6e3a1"},children:"Once · completed"}):a.missedAt?e.jsx("span",{style:{...l.matchTag,color:"#f38ba8"},children:"Once · missed"}):e.jsx("span",{style:{...l.matchTag,color:"#f9e2af"},children:"Once · pending"}):e.jsx("span",{style:l.matchTag,children:"Recurring"})})(),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:a=>{a.stopPropagation(),fe(t)},children:t.enabled?"Disable":"Enable"}),e.jsx("button",{style:l.smallBtn,onClick:a=>{a.stopPropagation(),ke(t.id)},children:"Test Fire"}),e.jsx("button",{style:{...l.smallBtn,color:"#e74c3c"},onClick:a=>{a.stopPropagation(),me(t.id)},children:"Delete"})]})]}),e.jsxs("div",{style:l.cardMeta,children:[e.jsxs("span",{children:["Agent: ",((s=m.get(t.agentId))==null?void 0:s.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)})]}),S==="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:n.name||"",onChange:t=>x("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:n.description||"",onChange:t=>x("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:n.type||"webhook",onChange:t=>{const s=t.target.value;x("type",s),s==="webhook"?x("config",{method:"POST"}):s==="cron"?x("config",{expression:"0 9 * * MON-FRI",timezone:"UTC"}):s==="bitbucket"?x("config",{workspace:"",repoSlug:"",events:["pullrequest:created","pullrequest:updated"]}):x("config",{}),(n.promptTemplate??"").trim()||(s==="slack"?x("promptTemplate",`Slack message from {{slack.user}} in {{slack.channelName}}:
|
|
4
4
|
{{slack.message}}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as x,i as M,k as P,j as e,
|
|
1
|
+
import{r as x,i as M,k as P,j as e,aC as J}from"./main-D5sqeuwB.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{p as i,k as r,K as n}from"./main-
|
|
1
|
+
import{p as i,k as r,K as n}from"./main-D5sqeuwB.js";async function c(e,o){const t=n(),a=await fetch(r(`/api/areas/${e}/logo`),{method:"POST",headers:{"Content-Type":o.type||"image/png","X-Filename":encodeURIComponent(o.name),...t?{Authorization:`Bearer ${t}`}:{}},body:o});if(!a.ok){const s=await a.json().catch(()=>({error:a.statusText}));throw new Error(s.error||`Upload failed: ${a.statusText}`)}return a.json()}async function d(e){const o=n(),t=await fetch(r(`/api/areas/${e}/logo`),{method:"DELETE",headers:{...o?{Authorization:`Bearer ${o}`}:{}}});if(!t.ok)throw new Error(`Failed to delete logo: ${t.statusText}`)}function u(e){return i(r(`/api/areas/logos/${e}`))}export{d,u as g,c as u};
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{aq as ts,u as rs,aU as _s,aV as vs,aW as Is,j as s,I as U,a9 as $s,aX as Es,aY as Ds,aZ as Ms,a_ as Ls,r as o,ag as Xs,aC as Ss,m as Ps,a5 as Ys,Y as Rs,a$ as Gs,b0 as Us,b1 as Fs,b2 as Zs,b3 as Hs,s as M,b4 as Ws,t as G}from"./main-D5sqeuwB.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const bs=ts.memo(({agent:a,isSelected:z,isKeyboardFocused:F=!1,onSelect:L,onDoubleClick:r,onChat:g,onFocus:h,onKill:w,onDragStart:X})=>{const{t:x}=rs(["dashboard","common"]),S=_s().has(a.id),N=vs(a.status),Z=Is(a),j=Ls(Z),I=a.taskLabel?s.jsxs(s.Fragment,{children:[s.jsx(U,{name:"task",size:12})," ",a.taskLabel]}):a.currentTask||a.lastAssignedTask,m=a.status==="idle"&&a.lastActivity>0,[,H]=ts.useState(0);return ts.useEffect(()=>{if(!m)return;const b=window.setInterval(()=>H(q=>q+1),15e3);return()=>window.clearInterval(b)},[m]),s.jsxs("div",{className:`dash-card dash-card--${N} ${z?"dash-card--selected":""} ${F?"dash-card--keyboard-focused":""}`,"data-agent-id":a.id,onClick:()=>L(a.id),onDoubleClick:b=>{b.stopPropagation(),r(a.id)},onDragStart:b=>{X==null||X(a),b.dataTransfer.effectAllowed="move"},draggable:!0,title:x("cards.doubleClickHint"),children:[s.jsxs("div",{className:"dash-card__row1",children:[s.jsx("span",{className:`dash-card__status-dot dash-card__status-dot--${N}`}),s.jsx("span",{className:"dash-card__name",children:a.name}),s.jsxs("span",{className:"dash-card__class",children:[s.jsx($s,{agent:a,size:14})," ",a.class]}),s.jsxs("span",{className:`dash-card__provider dash-card__provider--${a.provider}`,children:[s.jsx(U,{name:a.provider==="codex"||a.provider==="opencode"||a.provider==="grok"?"status-pending":"robot",size:11,weight:a.provider==="codex"||a.provider==="opencode"||a.provider==="grok"?"fill":"regular",color:a.provider==="codex"?"#a16207":a.provider==="opencode"?"#4ade80":a.provider==="grok"?"#6366f1":void 0})," ",a.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":a.status}),s.jsxs("div",{className:"dash-card__context",children:[s.jsx("div",{className:"dash-card__context-bar",children:s.jsx("div",{className:`dash-card__context-fill dash-card__context-fill--${j}`,style:{width:`${Z}%`}})}),s.jsxs("span",{className:`dash-card__context-pct dash-card__context-pct--${j}`,children:[Z,"%"]})]})]}),s.jsxs("div",{className:"dash-card__row3",children:[s.jsxs("span",{className:"dash-card__workdir",title:a.cwd,children:[s.jsx(U,{name:"folder",size:11})," ",a.cwd.split("/").pop()||a.cwd]}),m&&s.jsxs("span",{className:"dash-card__idle-time",style:{color:Ms(a.lastActivity)},title:Ds(a.lastActivity),children:[s.jsx(U,{name:"status-waiting-input",size:10})," ",Es(a.lastActivity)]})]}),I&&s.jsx("div",{className:"dash-card__row4",children:s.jsx("span",{className:"dash-card__task",children:I})}),s.jsxs("div",{className:"dash-card__actions",children:[g&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--chat",onClick:b=>{b.stopPropagation(),g(a.id)},title:x("cards.openTerminal"),children:x("cards.chat")}),w&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--danger",onClick:b=>{b.stopPropagation(),w(a.id)},title:x("cards.killAgent"),children:x("cards.stop")})]})]})});bs.displayName="AgentCard";const fs=({buildings:a,onSelectBuilding:z})=>{const{t:F}=rs(["dashboard"]),L=o.useMemo(()=>Array.from(a.values()).sort((r,g)=>r.name.localeCompare(g.name)),[a]);return s.jsxs("div",{className:"dashboard-view__buildings",children:[s.jsxs("div",{className:"dashboard-view__buildings-header",children:[s.jsx("span",{className:"dashboard-view__buildings-title",children:F("buildings.title")}),s.jsx("span",{className:"dashboard-view__buildings-count",children:L.length})]}),s.jsx("div",{className:"dashboard-view__buildings-row",children:L.map(r=>{const g=vs(r.status),h=Xs(r.type);return s.jsxs("button",{className:`dash-pill dash-pill--${g}`,onClick:()=>z==null?void 0:z(r.id),title:`${r.name} (${r.type}) - ${r.status}`,children:[s.jsx("span",{className:"dash-pill__icon",children:s.jsx(U,{name:h,size:14})}),s.jsx("span",{className:"dash-pill__name",children:r.name}),s.jsx("span",{className:`dash-pill__dot dash-pill__dot--${g}`})]},r.id)})})]})};fs.displayName="BuildingPills";function qs({onSelectAgent:a,onFocusAgent:z,onKillAgent:F,onSelectBuilding:L,onOpenTerminal:r,onFocusZone:g}){const{t:h}=rs(["dashboard","common"]),w=Ss(),X=Ps(),x=Ys(),ns=Rs(),S=_s(),[N,Z]=o.useState(""),[j,I]=o.useState("all"),[m,H]=o.useState("zone"),[b,q]=o.useState(new Set),[k,J]=o.useState(null),[ws,B]=o.useState(null),[P,Q]=o.useState(!1),[p,W]=o.useState(null),K=o.useMemo(()=>{const e=Array.from(w.values());return{total:e.length,working:e.filter(d=>d.status==="working"||d.status==="waiting"||d.status==="waiting_permission").length,idle:e.filter(d=>d.status==="idle").length,error:e.filter(d=>d.status==="error"||d.status==="offline"||d.status==="orphaned").length}},[w]),is=o.useMemo(()=>m==="zone"?Gs(w,x):m==="status"?Us(w,S):Fs(w),[w,x,m,S]),T=o.useMemo(()=>{const e=N.toLowerCase().trim(),d=is.map(l=>({...l,agents:l.agents.filter(_=>{if(j==="working"){if(_.status!=="working"&&_.status!=="waiting"&&_.status!=="waiting_permission")return!1}else if(j==="error"&&_.status!=="error"&&_.status!=="offline"&&_.status!=="orphaned")return!1;return!(e&&!_.name.toLowerCase().includes(e)&&!_.class.toLowerCase().includes(e))})}));return m==="zone"?d:d.filter(l=>l.agents.length>0)},[is,j,N,m]),O=o.useCallback(e=>e.area?`area:${e.area.id}`:`${m}:${e.label}`,[m]),ss=o.useMemo(()=>T.map(e=>({...e,sortedAgents:m==="status"?Zs(e.agents,{prioritizeRecentlyIdle:!0}):Hs(e.agents)})),[T,m]),C=o.useMemo(()=>{const e=[];return ss.forEach(d=>{const l=O(d);b.has(l)||e.push(...d.sortedAgents)}),e},[ss,b,O]),ps=o.useCallback(e=>{q(d=>{const l=new Set(d);return l.has(e)?l.delete(e):l.add(e),l})},[]),gs=o.useCallback(e=>{r==null||r(e)},[r]),xs=o.useCallback(e=>{a==null||a(e),Q(!0),W(e)},[a]),js=o.useCallback(e=>{r==null||r(e)},[r]),Ns=o.useCallback(e=>{J(e)},[]),ks=o.useCallback((e,d)=>{e.preventDefault(),e.dataTransfer.dropEffect="move",B(d)},[]),Cs=o.useCallback(()=>{B(null)},[]),ys=o.useCallback(e=>{if(!k)return;if(e===null){const $=M.getState(),t=Array.from($.areas.values()).find(n=>n.assignedAgentIds.includes(k.id));t&&M.unassignAgentFromArea(k.id,t.id),J(null),B(null);return}const d=x.get(e);if(!d)return;const l=Array.from(w.values()),_=Ws(d,l,k.position);M.updateAgent({...k,position:{...k.position,x:_.x,z:_.z}}),M.assignAgentToArea(k.id,e),J(null),B(null)},[k,x,w]);return o.useEffect(()=>{if(C.length===0){Q(!1),W(null);return}P&&(!p||!C.some(e=>e.id===p))&&(W(C[0].id),a==null||a(C[0].id))},[C,P,p,a]),o.useEffect(()=>{const e=t=>t instanceof HTMLElement?t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"||t.isContentEditable:!1,d=t=>t instanceof HTMLElement?!!t.closest(".guake-terminal")||t.classList.contains("guake-input")||t.classList.contains("agent-panel-input"):!1,l=t=>{const n=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).find(A=>A.dataset.agentId===t);n==null||n.scrollIntoView({block:"nearest",inline:"nearest"})},_=(t,n)=>{var os,cs,ls,us,hs,ms;const A=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).map(i=>{const u=i.dataset.agentId;if(!u)return null;const y=i.getBoundingClientRect();return{id:u,centerX:y.left+y.width/2,centerY:y.top+y.height/2,height:y.height}}).filter(i=>i!==null).sort((i,u)=>i.centerY-u.centerY||i.centerX-u.centerX);if(A.length===0)return t;const es=A.reduce((i,u)=>i+u.height,0)/A.length,as=Math.max(18,es*.6),f=[];for(const i of A){const u=f[f.length-1];if(!u){f.push([{id:i.id,centerX:i.centerX,centerY:i.centerY}]);continue}const y=u.reduce((As,zs)=>As+zs.centerY,0)/u.length;Math.abs(i.centerY-y)<=as?u.push({id:i.id,centerX:i.centerX,centerY:i.centerY}):f.push([{id:i.id,centerX:i.centerX,centerY:i.centerY}])}f.forEach(i=>i.sort((u,y)=>u.centerX-y.centerX));const Y=f.findIndex(i=>i.some(u=>u.id===t));if(Y===-1)return((cs=(os=f[0])==null?void 0:os[0])==null?void 0:cs.id)??t;const E=f[Y],v=E.findIndex(i=>i.id===t);if(v===-1)return((us=(ls=f[0])==null?void 0:ls[0])==null?void 0:us.id)??t;if(n==="left")return((hs=E[Math.max(0,v-1)])==null?void 0:hs.id)??t;if(n==="right")return((ms=E[Math.min(E.length-1,v+1)])==null?void 0:ms.id)??t;const V=n==="up"?Math.max(0,Y-1):Math.min(f.length-1,Y+1),c=f[V],R=E[v].centerX;let D=c[0],ds=Math.abs(D.centerX-R);for(const i of c){const u=Math.abs(i.centerX-R);u<ds&&(D=i,ds=u)}return(D==null?void 0:D.id)??t},$=t=>{const n=M.getShortcuts(),A=n.find(c=>c.id==="dashboard-selector-toggle"),es=n.find(c=>c.id==="dashboard-vim-left"),as=n.find(c=>c.id==="dashboard-vim-down"),f=n.find(c=>c.id==="dashboard-vim-up"),Y=n.find(c=>c.id==="dashboard-vim-right"),E=n.find(c=>c.id==="open-terminal"),v=M.getState();if(e(t.target))if(!v.terminalOpen&&d(t.target)&&document.activeElement instanceof HTMLElement)document.activeElement.blur();else return;if(G(t,A)){if(C.length===0)return;t.preventDefault(),t.stopPropagation(),Q(!0),W(c=>{const R=c&&C.some(D=>D.id===c)?c:C[0].id;return a==null||a(R),window.setTimeout(()=>l(R),0),R});return}const V=G(t,es)||t.key==="ArrowLeft"?"left":G(t,as)||t.key==="ArrowDown"?"down":G(t,f)||t.key==="ArrowUp"?"up":G(t,Y)||t.key==="ArrowRight"?"right":null;if(V&&P&&p){t.preventDefault(),t.stopPropagation();const c=_(p,V);c!==p&&(W(c),a==null||a(c),window.setTimeout(()=>l(c),0));return}if(G(t,E)){if(v.terminalOpen)return;if(P&&p&&v.agents.has(p)){t.preventDefault(),r==null||r(p);return}if(v.selectedAgentIds.size===1){t.preventDefault();const c=Array.from(v.selectedAgentIds)[0];r==null||r(c);return}if(v.lastSelectedAgentId&&v.agents.has(v.lastSelectedAgentId)){t.preventDefault(),r==null||r(v.lastSelectedAgentId);return}}};return document.addEventListener("keydown",$,!0),()=>document.removeEventListener("keydown",$,!0)},[C,P,p,r,a]),o.useEffect(()=>{const e=document.activeElement;e instanceof HTMLElement&&e.closest(".guake-terminal")&&!M.getState().terminalOpen&&e.blur()},[]),s.jsxs("div",{className:"dashboard-view",children:[s.jsxs("div",{className:"dashboard-view__topbar",children:[s.jsxs("div",{className:"dashboard-view__metrics",children:[s.jsxs("button",{className:`dashboard-view__metric-btn ${j==="all"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.total}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:labels.agents")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--working ${j==="working"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("working"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.working}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.working")})]}),s.jsxs("button",{className:"dashboard-view__metric-btn dashboard-view__metric-btn--idle ",onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.idle}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.idle")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--error ${j==="error"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("error"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.error}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.error")})]})]}),s.jsx("input",{className:"dashboard-view__search",type:"text",placeholder:h("searchPlaceholder"),value:N,onChange:e=>Z(e.target.value)})]}),s.jsxs("div",{className:"dashboard-view__grouping",children:[s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="zone"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>H("zone"),children:h("grouping.byZone")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="status"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>H("status"),children:h("grouping.byStatus")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="activity"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>H("activity"),children:h("grouping.byActivity")})]}),s.jsxs("div",{className:"dashboard-view__content",children:[ss.map(e=>{const d=O(e),l=b.has(d),_=e.sortedAgents,$=e.agents.filter(n=>n.status==="working"||n.status==="waiting"||n.status==="waiting_permission").length,t=e.agents.filter(n=>S.has(n.id)).length;return s.jsxs("div",{className:`dashboard-view__zone ${ws===(e.area?e.area.id:null)&&k?"dashboard-view__zone--drag-over":""}`,onDragOver:n=>ks(n,e.area?e.area.id:null),onDragLeave:Cs,onDrop:()=>ys(e.area?e.area.id:null),children:[s.jsxs("div",{className:"dashboard-view__zone-header",onClick:()=>ps(d),children:[s.jsxs("div",{className:"dashboard-view__zone-left",children:[s.jsx("span",{className:`dashboard-view__zone-chevron ${l?"dashboard-view__zone-chevron--collapsed":""}`,children:s.jsx(U,{name:"caret-down",size:12})}),s.jsx("span",{className:"dashboard-view__zone-dot",style:{backgroundColor:e.color}}),s.jsx("span",{className:"dashboard-view__zone-name",children:e.label}),s.jsxs("span",{className:"dashboard-view__zone-count",children:[h("agentCount",{count:e.agents.length}),$>0&&s.jsxs("span",{className:"dashboard-view__zone-working",children:[" · ",$," ",h("working")]}),t>0&&s.jsxs("span",{className:"dashboard-view__zone-unseen",children:[" · ",t," Unseen"]})]})]}),e.area&&g&&s.jsx("button",{className:"dashboard-view__zone-focus",onClick:n=>{n.stopPropagation(),g(e.area.id)},title:h("focusZone"),children:h("focusZone")})]}),!l&&s.jsx("div",{className:"dashboard-view__zone-grid",children:_.map(n=>s.jsx(bs,{agent:n,isSelected:ns.has(n.id),isKeyboardFocused:P&&p===n.id,onSelect:xs,onDoubleClick:gs,onChat:js,onFocus:z,onKill:F,onDragStart:Ns},n.id))})]},d)}),T.length===0&&s.jsx("div",{className:"dashboard-view__empty",children:N?h("noAgentsMatching",{search:N}):h("noAgentsSpawned")}),X.size>0&&s.jsx(fs,{buildings:X,onSelectBuilding:L})]})]})}export{qs as DashboardView};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{bX as He,r as t,s as I,k as ye,bY as Ee,i as Oe,j as e,I as O,u as fe,bZ as ze,Z as Te,b_ as Be,b$ as Ue,q as Ke,c0 as We,c1 as De,c2 as Ve,ak as Ge,al as qe,am as Ye,bk as Je,_ as Me,S as le,bd as Xe,ba as Ze,a9 as Qe,$ as Ie,aC as et,a5 as tt,c3 as st,t as X,c4 as nt}from"./main-D5sqeuwB.js";import{FileExplorerPanel as at}from"./index-C6-68CXL.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Se={status:"all",activity:"all",sort:"activity"},ct={"1h":3600*1e3,"6h":360*60*1e3,"24h":1440*60*1e3},Ae=20,me=3,lt={idle:"#4aff9e",working:"#4a9eff",waiting:"#ff9e4a",waiting_permission:"#ffcc00",error:"#ff4a4a",offline:"#888888",orphaned:"#ff9e4a"},ot=12e4;function rt(s){return s.trim().replace(/\r\n/g,`
|
|
2
|
+
`)}function $e(s,a){return`${s}:${rt(a)}`}function it(s,a,c,f){if(s.uuid&&a.has(s.uuid))return!1;if(s.uuid)return!0;const p=s.isUserPrompt?"user":"assistant",d=$e(p,s.text),M=s.timestamp||0,A=c.get(d);return A!==void 0&&Math.abs(M-A)<=ot?!1:M>f}function dt({isOpen:s,agents:a}){const c=He(),[f,p]=t.useState(new Map),d=t.useRef(new Set);t.useRef(a);const M=t.useMemo(()=>Array.from(a.keys()).sort().join(","),[a]),A=t.useMemo(()=>Array.from(a.values()).map(j=>`${j.id}:${j.sessionId||""}`).sort().join(","),[a]);t.useEffect(()=>{s||(d.current.clear(),p(new Map))},[s]),t.useEffect(()=>{if(!s)return;const j=new Set(Array.from(a.keys()));for(const i of d.current)j.has(i)||d.current.delete(i);let h=null;c>0&&(h=I.preserveOutputs(),d.current.clear());const v=async(i,k,F=0)=>{if(d.current.add(i.id),F>0&&await new Promise(x=>setTimeout(x,F)),p(x=>{const N=new Map(x);return N.set(i.id,{agentId:i.id,messages:[],loading:!0,hasMore:!1,totalCount:0}),N}),!i.sessionId){k&&k.length>0&&I.mergeOutputsWithHistory(i.id,[],k),p(x=>{const N=new Map(x);return N.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),N});return}try{const N=await(await Oe(ye(`/api/agents/${i.id}/history?limit=${Ee}&offset=0`))).json(),P=N.messages||[],W=P.length>0?Math.max(...P.map(w=>w.timestamp?new Date(w.timestamp).getTime():0)):0,Y=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 o=$e(w.type,w.content),L=w.timestamp?new Date(w.timestamp).getTime():0,K=V.get(o)??0;L>K&&V.set(o,L)}const G=I.getOutputs(i.id),U=(k&&k.length>0?[...k,...G]:G).filter(w=>it(w,Y,V,W));I.clearOutputs(i.id);for(const w of U)I.addOutput(i.id,w);p(w=>{const o=new Map(w);return o.set(i.id,{agentId:i.id,messages:P,loading:!1,hasMore:N.hasMore||!1,totalCount:N.totalCount||0}),o})}catch(x){if(console.error(`Failed to load history for ${i.name}:`,x),k&&k.length>0){I.clearOutputs(i.id);for(const N of k)I.addOutput(i.id,N)}p(N=>{const P=new Map(N);return P.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),P})}},u=c>0?500:0,D=Array.from(a.values());for(const i of D)if(!d.current.has(i.id)){const k=h==null?void 0:h.get(i.id);v(i,k,u)}},[s,M,A,c]);const R=t.useRef(a),b=t.useRef(f);R.current=a,b.current=f;const C=t.useCallback(async j=>{const h=R.current.get(j),v=b.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(k=>{const F=new Map(k),x=k.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:C,clearAgentHistory:E}}function ut({command:s,onCommandChange:a,useTextarea:c,forceTextarea:f,onForceTextarea:p,onSend:d,canSend:M,attachedFiles:A,onAddFile:R,onRemoveFile:b,uploadFile:C,onAddPastedText:E,placeholder:j="Message...",className:h="",compact:v=!1,inputRef:u}){const D=t.useRef(null),i=t.useRef(null),k=t.useRef(c);t.useEffect(()=>{if(c&&!k.current&&i.current){const o=i.current;o.focus(),o.selectionStart=o.selectionEnd=o.value.length}k.current=c},[c]),t.useEffect(()=>{const o=i.current;if(!o||!c)return;o.style.height="auto";const L=v?120:180,K=Math.min(o.scrollHeight,L);o.style.height=`${K}px`},[s,c,v]);const F=t.useCallback(async o=>{const L=o.clipboardData.items;for(const z of L)if(z.type.startsWith("image/")){o.preventDefault();const $=z.getAsFile();if($){const _=await C($);_&&R(_)}return}const K=o.clipboardData.files;if(K.length>0){o.preventDefault();for(const z of K){const $=await C(z);$&&R($)}return}const B=o.clipboardData.getData("text"),te=(B.match(/\n/g)||[]).length+1;if(te>5){o.preventDefault();const $=`[Pasted text #${E(B)} +${te} lines]`,_=o.target,se=_.selectionStart||0,ae=_.selectionEnd||0,ne=s.slice(0,se)+$+s.slice(ae);a(ne),c||p(!0)}},[s,a,c,p,C,R,E]),x=t.useCallback(async o=>{const L=o.target.files;if(L){for(const K of L){const B=await C(K);B&&R(B)}D.current&&(D.current.value="")}},[C,R]),N=t.useCallback(o=>{if(o.key==="Enter"&&o.shiftKey){c||(o.preventDefault(),p(!0));return}o.key==="Enter"&&(o.preventDefault(),d())},[c,p,d]),P=t.useCallback(o=>{},[]),W=t.useCallback(o=>{o.button===1&&(o.preventDefault(),o.stopPropagation())},[]),Y=t.useCallback(o=>{i.current=o,u==null||u(o)},[u]),V=v?"agent-panel-input":"guake-input",G=v?"agent-panel-input-container":"guake-input-container",Z=v?"agent-panel-attach-btn":"guake-attach-btn",U=v?"agent-panel-send-btn":"",w=c?v?"agent-panel-input-expanded":"guake-input-expanded":"";return e.jsxs(e.Fragment,{children:[A.length>0&&e.jsx("div",{className:v?"agent-panel-attachments":"guake-attachments",children:A.map(o=>e.jsxs("div",{className:`${v?"agent-panel-attachment":"guake-attachment"} ${o.isImage?"is-image":""}`,children:[e.jsx("span",{className:v?"agent-panel-attachment-icon":"guake-attachment-icon",children:e.jsx(O,{name:o.isImage?"file":"paperclip",size:12})}),e.jsx("span",{className:v?"agent-panel-attachment-name":"guake-attachment-name",title:o.path,children:o.name}),!v&&e.jsxs("span",{className:"guake-attachment-size",children:["(",Math.round(o.size/1024),"KB)"]}),e.jsx("button",{className:v?"agent-panel-attachment-remove":"guake-attachment-remove",onClick:()=>b(o.id),title:"Remove",children:"×"})]},o.id))}),e.jsxs("div",{className:`${V} ${w} ${h}`,children:[e.jsx("input",{ref:D,type:"file",multiple:!0,onChange:x,style:{display:"none"},accept:"*"}),e.jsxs("div",{className:G,onAuxClick:W,children:[e.jsx("button",{className:Z,onClick:()=>{var o;return(o=D.current)==null?void 0:o.click()},title:"Attach file (or paste image)",children:e.jsx(O,{name:"paperclip",size:14})}),c?e.jsx("textarea",{ref:Y,placeholder:j,value:s,onChange:o=>a(o.target.value),onKeyDown:N,onPaste:F,onMouseDown:P}):e.jsx("input",{ref:u,type:"text",placeholder:j,value:s,onChange:o=>a(o.target.value),onKeyDown:N,onPaste:F,onMouseDown:P}),e.jsx("button",{className:U,onClick:d,disabled:!M,title:"Send",children:e.jsx(O,{name:"send",size:14})})]})]})]})}function mt(s){const a=Math.floor(s/1e3),c=Math.floor(a/60),f=a%60;return`${c}:${f.toString().padStart(2,"0")}`}const ft=t.memo(function({agentId:a,isWorking:c,timestamp:f}){const{t:p}=fe(["terminal"]),[d,M]=t.useState(0);return t.useEffect(()=>{if(!c||!f){M(0);return}M(Date.now()-f);const A=setInterval(()=>{M(Date.now()-f)},1e3);return()=>clearInterval(A)},[c,f]),c?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(O,{name:"stop",size:12,weight:"fill"})}),e.jsx("span",{className:"stop-label",children:p("terminal:input.stop")})]})]}):null});function pt({agent:s,history:a,outputs:c,isExpanded:f,isFocused:p,advancedView:d,onExpand:M,onFocus:A,inputRef:R,onLoadMore:b,onClearHistory:C}){const{t:E}=fe(["terminal","common"]),j=ze(s.id),h=t.useRef(null),[v,u]=t.useState(!1),D=t.useRef(0),i=t.useRef(!1),[k,F]=t.useState(!0),[x,N]=t.useState(!1),[P,W]=t.useState(null),[Y,V]=t.useState(null),[G,Z]=t.useState(null);Te(`commander-image-modal-${s.id}`,P!==null,()=>W(null));const{command:U,setCommand:w,forceTextarea:o,setForceTextarea:L,useTextarea:K,setPastedTexts:B,incrementPastedCount:te,resetPastedCount:z,attachedFiles:$,setAttachedFiles:_,removeAttachedFile:se,uploadFile:ae,expandPastedTexts:ne}=Be({selectedAgentId:s.id}),ce=U.trim().length>0||$.length>0,n=Ue({outputs:c,viewMode:d?"advanced":"simple"}),l=t.useMemo(()=>{const S=Ke(s);return{usedPercent:S.usedPercent,freePercent:S.freePercent,hasData:!!s.contextStats,totalTokens:S.totalTokens,contextWindow:S.contextWindow}},[s.contextStats,s.contextUsed,s.contextLimit]),g=t.useCallback(()=>{!v&&(a!=null&&a.hasMore)&&b&&(u(!0),D.current=h.current?h.current.scrollHeight-h.current.scrollTop:0,b())},[v,a==null?void 0:a.hasMore,b]);t.useEffect(()=>{v&&a&&!a.loading&&u(!1)},[a,v]);const m=t.useCallback(()=>{i.current=!0,F(!1)},[]),T=t.useRef(f),Q=t.useRef(p);t.useEffect(()=>{(f&&!T.current||p&&!Q.current)&&(i.current=!1,F(!0),N(!0)),T.current=f,Q.current=p},[f,p]);const ee=t.useRef(a==null?void 0:a.loading);t.useEffect(()=>{ee.current&&!(a!=null&&a.loading)&&(i.current=!1,F(!0),N(!0)),ee.current=a==null?void 0:a.loading},[a==null?void 0:a.loading]),t.useEffect(()=>{if(!x)return;const S=h.current;if(!S)return;const y=performance.now();let H=0,ue=-1,be;const Re=()=>{const{scrollTop:Fe,scrollHeight:Ne,clientHeight:Le}=S,_e=Ne-Fe-Le<=2;if(Math.abs(Ne-ue)<=1&&_e?H+=1:H=0,ue=Ne,H>=3){N(!1);return}if(performance.now()-y>5e3){N(!1);return}be=requestAnimationFrame(Re)};return be=requestAnimationFrame(Re),()=>cancelAnimationFrame(be)},[x]),t.useEffect(()=>{i.current||F(!0)},[n.length]);const q=t.useCallback(()=>!1,[]),ie=t.useCallback(S=>{const y=te();return B(H=>new Map(H).set(y,S)),y},[te,B]),he=t.useCallback(S=>{_(y=>[...y,S])},[_]),xe=t.useCallback(()=>{if(!ce)return;if(U.trim()==="/clear"&&$.length===0){I.clearContext(s.id),C(),w(""),L(!1),B(new Map),_([]),z();return}let S=ne(U.trim());if($.length>0){const y=$.map(H=>H.isImage?`[Image: ${H.path}]`:`[File: ${H.path}]`).join(`
|
|
3
|
+
`);S=S?`${S}
|
|
4
|
+
|
|
5
|
+
${y}`:y}I.sendCommand(s.id,S),w(""),L(!1),B(new Map),_([]),z()},[s.id,U,ce,$,ne,C,z,w,L,B,_]),ge=t.useCallback((S,y)=>{W({url:S,name:y})},[]),ve=t.useCallback((S,y)=>{const H=We(S,s.cwd),ue=H.line?{...y||{},targetLine:H.line}:y;I.setFileViewerPath(H.path,ue,s.cwd)},[s.cwd]),je=t.useCallback((S,y)=>{V({command:S,output:y,isLive:y==="Running..."})},[]),we=t.useCallback(S=>{Z(S)},[]),Ce=t.useCallback(()=>{N(!1),i.current=!0,F(!1)},[]),ke=t.useCallback(()=>W(null),[]),r=t.useCallback(()=>V(null),[]),J=t.useCallback(()=>Z(null),[]),de=t.useCallback(S=>{S.stopPropagation(),M()},[M]),oe=lt[s.status]||"#888888",re=(a==null?void 0:a.messages)||[];return e.jsxs("div",{className:`agent-panel ${s.status==="working"?"working":""} ${f?"expanded":""} ${p?"focused":""}`,onClick:p?void 0:A,children:[e.jsxs("div",{className:"agent-panel-header",onClick:p?A:void 0,children:[e.jsxs("div",{className:"agent-panel-info",children:[e.jsx("span",{className:"agent-panel-status",style:{background:oe},title:s.status}),e.jsxs("span",{className:"agent-panel-name",children:[(s.isBoss||s.class==="boss")&&e.jsx("span",{className:"agent-panel-boss-crown",children:e.jsx(O,{name:"crown",size:14})}),s.name]}),e.jsx("span",{className:`agent-panel-status-label ${s.status}`,children:s.status}),e.jsx("span",{className:"agent-panel-class",children:s.class}),e.jsx("span",{className:`agent-panel-provider ${s.provider==="codex"?"codex":s.provider==="opencode"?"opencode":s.provider==="grok"?"grok":"claude"}`,children:s.provider||"claude"}),e.jsxs("span",{className:"agent-panel-id",title:`ID: ${s.id}`,children:["[",s.id.substring(0,4),"]"]}),s.taskLabel?e.jsxs("div",{className:"agent-panel-task agent-panel-task-label",title:s.taskLabel,children:[e.jsx(O,{name:"task",size:12})," ",s.taskLabel]}):s.currentTask?e.jsxs("div",{className:"agent-panel-task",title:s.currentTask,children:[s.currentTask.substring(0,40),"..."]}):null]}),e.jsxs("div",{className:"agent-panel-context",title:`Context: ${Math.round(l.usedPercent)}% used (${De(l.totalTokens)} / ${De(l.contextWindow)})`,children:[e.jsx("div",{className:"agent-panel-context-bar",style:{background:l.freePercent<20?"#ff4a4a":l.freePercent<50?"#ff9e4a":"#4aff9e",width:`${l.freePercent}%`}}),e.jsxs("span",{className:"agent-panel-context-text",children:[Math.round(l.freePercent),"%"]})]}),e.jsx("div",{className:"agent-panel-actions",children:e.jsx("button",{className:"agent-panel-expand",onClick:de,title:E(f?"commander.collapsePanel":"commander.expandPanel"),children:f?e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"4 14 10 14 10 20"}),e.jsx("polyline",{points:"20 10 14 10 14 4"}),e.jsx("line",{x1:"14",y1:"10",x2:"21",y2:"3"}),e.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]}):e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("polyline",{points:"9 21 3 21 3 15"}),e.jsx("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),e.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})})})]}),e.jsx("div",{className:"agent-panel-content",ref:h,children:a!=null&&a.loading?e.jsx("div",{className:"agent-panel-loading",children:E("common:status.loading")}):e.jsx(e.Fragment,{children:!re.length&&!n.length?e.jsxs("div",{className:"agent-panel-empty",children:[E("commander.noMessages"),!s.sessionId&&e.jsx("div",{style:{fontSize:"10px",color:"#666"},children:E("commander.noSessionId")})]}):e.jsx(Ve,{historyMessages:re,liveOutputs:n,agentId:s.id,viewMode:d?"advanced":"simple",selectedMessageIndex:null,isMessageSelected:q,onImageClick:ge,onFileClick:ve,onBashClick:je,onViewMarkdown:we,scrollContainerRef:h,onScrollTopReached:g,isLoadingMore:v,hasMore:a==null?void 0:a.hasMore,shouldAutoScroll:k,onUserScroll:m,pinToBottom:x,onPinCancel:Ce,isLoadingHistory:a==null?void 0:a.loading})})}),e.jsxs("div",{className:`guake-input-wrapper ${s.status==="working"?"has-stop-btn is-working":""}`,children:[e.jsx(ft,{agentId:s.id,isWorking:s.status==="working",timestamp:j==null?void 0:j.timestamp}),e.jsx(ut,{command:U,onCommandChange:w,useTextarea:K,forceTextarea:o,onForceTextarea:L,onSend:xe,canSend:ce,attachedFiles:$,onAddFile:he,onRemoveFile:se,uploadFile:ae,onAddPastedText:ie,placeholder:E("commander.command",{name:s.name}),compact:!1,inputRef:R})]}),P&&e.jsx(Ge,{url:P.url,name:P.name,onClose:ke}),Y&&e.jsx(qe,{state:Y,onClose:r}),e.jsx(Ye,{agent:s,content:G,onClose:J})]})}function ht({currentArea:s,onClose:a}){const{t:c}=fe(["terminal","common"]),[f,p]=t.useState(()=>{const u=new Set(Array.from(I.getState().agents.values()).map(D=>D.name));return Je.find(D=>!u.has(D))||`Agent-${Date.now().toString(36)}`}),[d,M]=t.useState(()=>Me(le.LAST_CWD)),[A,R]=t.useState("scout"),[b,C]=t.useState("claude"),[E,j]=t.useState(!1),h=()=>{if(!f.trim()||!d.trim())return;j(!0),Ie(le.LAST_CWD,d);let u;s&&(u={x:s.center.x,z:s.center.z}),I.spawnAgent(f.trim(),A,d.trim(),u,void 0,void 0,void 0,void 0,b),setTimeout(()=>{a()},500)},v=u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),h()),u.key==="Escape"&&a()};return e.jsx("div",{className:"commander-spawn-overlay",onClick:a,children:e.jsxs("div",{className:"commander-spawn-form",onClick:u=>u.stopPropagation(),children:[e.jsxs("div",{className:"commander-spawn-header",children:[e.jsx("h3",{children:c("spawn.addNewAgent")}),s&&e.jsxs("span",{className:"commander-spawn-area",children:[e.jsx("span",{className:"commander-spawn-area-dot",style:{background:s.color}}),s.name]})]}),e.jsxs("div",{className:"commander-spawn-body",children:[e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:c("common:labels.name")}),e.jsx("input",{type:"text",value:f,onChange:u=>p(u.target.value),onKeyDown:v,autoFocus:!0})]}),e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:c("common:labels.workingDirectory")}),e.jsx(Xe,{value:d,onChange:M,onSubmit:h,placeholder:c("spawn.workingDirPlaceholder"),directoriesOnly:!0})]}),e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:c("common:labels.class")}),e.jsx("div",{className:"commander-spawn-classes",children:Ze.map(u=>e.jsxs("button",{className:`commander-spawn-class ${A===u.id?"selected":""}`,onClick:()=>R(u.id),children:[e.jsx(Qe,{classId:u.id,size:18,className:"commander-spawn-class-icon"}),e.jsx("span",{children:u.name})]},u.id))})]}),e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:c("common:labels.runtime")}),e.jsxs("div",{className:"commander-spawn-classes",children:[e.jsxs("button",{className:`commander-spawn-class ${b==="claude"?"selected":""}`,onClick:()=>C("claude"),children:[e.jsx("span",{className:"commander-spawn-class-icon",children:e.jsx(O,{name:"brain",size:14})}),e.jsx("span",{children:"Claude"})]}),e.jsxs("button",{className:`commander-spawn-class ${b==="codex"?"selected":""}`,onClick:()=>C("codex"),children:[e.jsx("span",{className:"commander-spawn-class-icon",children:e.jsx(O,{name:"gear",size:14})}),e.jsx("span",{children:"Codex"})]}),e.jsxs("button",{className:`commander-spawn-class ${b==="opencode"?"selected":""}`,onClick:()=>C("opencode"),children:[e.jsx("span",{className:"commander-spawn-class-icon",children:e.jsx(O,{name:"status-pending",size:12,weight:"fill",color:"#4ade80"})}),e.jsx("span",{children:"OpenCode"})]}),e.jsxs("button",{className:`commander-spawn-class ${b==="grok"?"selected":""}`,onClick:()=>C("grok"),children:[e.jsx("span",{className:"commander-spawn-class-icon",children:e.jsx(O,{name:"status-pending",size:12,weight:"fill",color:"#6366f1"})}),e.jsx("span",{children:"Grok"})]})]})]})]}),e.jsxs("div",{className:"commander-spawn-footer",children:[e.jsx("button",{className:"commander-spawn-cancel",onClick:a,children:c("common:buttons.cancel")}),e.jsx("button",{className:"commander-spawn-submit",onClick:h,disabled:!f.trim()||!d.trim()||E,children:c(E?"common:buttons.deploying":"common:buttons.deploy")})]})]})})}const Pe=t.memo(function({agent:a,history:c,isExpanded:f,isFocused:p,advancedView:d,index:M,onExpand:A,onCollapse:R,onFocus:b,onInputRef:C,onLoadMore:E,onClearHistory:j}){const h=nt(a.id),v=t.useCallback(()=>{f?R():A(a.id)},[a.id,f,A,R]),u=t.useCallback(()=>{b(p?-1:M)},[M,p,b]),D=t.useCallback(F=>{C(a.id,F)},[a.id,C]),i=t.useCallback(()=>{E(a.id)},[a.id,E]),k=t.useCallback(()=>{j(a.id)},[a.id,j]);return e.jsx(pt,{agent:a,history:c,outputs:h,isExpanded:f,isFocused:p,advancedView:d,onExpand:v,onFocus:u,inputRef:D,onLoadMore:i,onClearHistory:k})});function Ct({isOpen:s,onClose:a}){const{t:c}=fe(["terminal","common"]),f=et(),p=tt(),[d,M]=t.useState(()=>Me(le.COMMANDER_TAB,"all")),[A,R]=t.useState(0),[b,C]=t.useState(null),E=t.useRef(null),[j,h]=t.useState(0),[v,u]=t.useState(!1),[D,i]=t.useState(null),[k,F]=t.useState(!1),[x,N]=t.useState(()=>{try{const n=Me(le.COMMANDER_FILTERS,"");if(n)return{...Se,...JSON.parse(n)}}catch{}return Se}),P=t.useRef(new Map),W=t.useRef([]),Y=t.useRef(0),V=t.useRef([]),G=t.useRef(d),{histories:Z,loadMoreHistory:U,clearAgentHistory:w}=dt({isOpen:s,agents:f});t.useEffect(()=>{s||(C(null),h(0),u(!1))},[s]);const o=t.useMemo(()=>{const n=Array.from(p.values()).sort((g,m)=>g.name.localeCompare(m.name)),l=[{id:"all",name:c("common:labels.all")}];for(const g of n)l.push({id:g.id,name:g.name,color:g.color});return l.push({id:"unassigned",name:c("commander.unassigned")}),l},[p]),L=t.useMemo(()=>d==="all"||d==="unassigned"?null:p.get(d)||null,[d,p]),K=t.useMemo(()=>{const n=new Map;n.set("all",f.size);let l=0;for(const g of f.values()){const m=I.getAreaForAgent(g.id);m?n.set(m.id,(n.get(m.id)||0)+1):l++}return n.set("unassigned",l),n},[f]),B=x.status!=="all"||x.activity!=="all"||x.sort!=="activity",te=(x.status!=="all"?1:0)+(x.activity!=="all"?1:0)+(x.sort!=="activity"?1:0),z=t.useMemo(()=>{const n=m=>m.isBoss===!0||m.class==="boss",l=Date.now();let g=Array.from(f.values());if(d==="unassigned"?g=g.filter(m=>!I.getAreaForAgent(m.id)):d!=="all"&&(g=g.filter(m=>{const T=I.getAreaForAgent(m.id);return(T==null?void 0:T.id)===d})),x.status!=="all"&&(g=g.filter(m=>{switch(x.status){case"working":return m.status==="working";case"idle":return m.status==="idle";case"error":return m.status==="error"||m.status==="waiting"||m.status==="waiting_permission";case"offline":return m.status==="offline"||m.status==="orphaned";default:return!0}})),x.activity!=="all"){const m=ct[x.activity];g=g.filter(T=>l-(T.lastActivity||0)<m)}return g.sort((m,T)=>{var Q,ee;if(n(m)&&!n(T))return-1;if(!n(m)&&n(T))return 1;switch(x.sort){case"activity":return(T.lastActivity||0)-(m.lastActivity||0);case"name":return m.name.localeCompare(T.name);case"created":return(m.createdAt||0)-(T.createdAt||0);case"context":{const q=((Q=m.contextStats)==null?void 0:Q.usedPercent)??(m.contextUsed||0)/(m.contextLimit||2e5)*100;return(((ee=T.contextStats)==null?void 0:ee.usedPercent)??(T.contextUsed||0)/(T.contextLimit||2e5)*100)-q}default:return(T.lastActivity||0)-(m.lastActivity||0)}}),g},[f,d,x]),$=Math.ceil(z.length/Ae),_=t.useMemo(()=>z.slice(A*Ae,(A+1)*Ae),[z,A]);W.current=_,E.current=b,Y.current=j,V.current=o,G.current=d,Te("commander-expanded",b!==null,()=>C(null));const se=st();t.useEffect(()=>{s&&se&&(C(se),I.clearCommanderExpandRequest())},[s,se]);const ae=t.useCallback(()=>C(null),[]),ne=t.useCallback(n=>C(n),[]),ce=t.useCallback(n=>h(n),[]),pe=t.useCallback((n,l)=>{l?P.current.set(n,l):P.current.delete(n)},[]);return t.useEffect(()=>{R(0),Ie(le.COMMANDER_TAB,d)},[d]),t.useEffect(()=>{Ie(le.COMMANDER_FILTERS,JSON.stringify(x)),R(0)},[x]),t.useEffect(()=>{var l;if(!s||window.matchMedia("(pointer: coarse)").matches)return;const n=b||((l=W.current[j])==null?void 0:l.id);if(n){const g=P.current.get(n);g&&document.activeElement!==g&&setTimeout(()=>g.focus(),50)}},[s,j,b]),t.useEffect(()=>{if(!s)return;const n=l=>{const g=I.getShortcuts(),m=l.target,T=m.tagName==="INPUT"||m.tagName==="TEXTAREA",Q=W.current,ee=Q.length-1,q=E.current,ie=g.find(r=>r.id==="commander-close");if(X(l,ie)){const{fileViewerPath:r,contextModalAgentId:J}=I.getState();if(r||J)return;l.preventDefault(),l.stopImmediatePropagation(),q?C(null):a();return}const he=g.find(r=>r.id==="commander-vim-left");if(X(l,he)&&!q){l.preventDefault(),h(r=>r>0?r-1:r);return}const xe=g.find(r=>r.id==="commander-vim-right");if(X(l,xe)&&!q){l.preventDefault(),h(r=>r<ee?r+1:r);return}const ge=g.find(r=>r.id==="commander-vim-up");if(X(l,ge)&&!q){l.preventDefault(),h(r=>r>=me?r-me:r);return}const ve=g.find(r=>r.id==="commander-vim-down");if(X(l,ve)&&!q){l.preventDefault(),h(r=>r+me<=ee?r+me:r);return}const je=g.find(r=>r.id==="commander-expand");if(X(l,je)){if(l.preventDefault(),q)C(null);else{const r=Q[Y.current];r&&C(r.id)}return}const we=g.find(r=>r.id==="commander-new-agent");if(X(l,we)){l.preventDefault(),u(!0);return}const Ce=g.find(r=>r.id==="commander-next-tab"),ke=g.find(r=>r.id==="commander-prev-tab");if(!T){const r=V.current;if(X(l,Ce)){const J=I.getState().latestNotificationAgentId;if(J){if(l.preventDefault(),l.stopPropagation(),!I.getState().agents.get(J)){I.setLatestNotificationAgentId(null);return}const y=I.getAreaForAgent(J);y&&r.some(H=>H.id===y.id)?M(y.id):M("unassigned"),C(J),h(0),R(0),I.setLatestNotificationAgentId(null);return}l.preventDefault(),l.stopPropagation();const oe=(r.findIndex(re=>re.id===G.current)+1)%r.length;M(r[oe].id),h(0);return}if(X(l,ke)){l.preventDefault(),l.stopPropagation();const de=(r.findIndex(oe=>oe.id===G.current)-1+r.length)%r.length;M(r[de].id),h(0);return}}};return document.addEventListener("keydown",n,!0),()=>document.removeEventListener("keydown",n,!0)},[s,a]),s?e.jsx("div",{className:"commander-overlay",onClick:a,children:e.jsxs("div",{className:"commander-view",onClick:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"commander-header",children:[e.jsxs("div",{className:"commander-title-section",children:[e.jsx("h2",{className:"commander-title",children:c("commander.title")}),e.jsx("span",{className:"commander-shortcuts",children:c("commander.shortcuts")})]}),e.jsxs("div",{className:"commander-controls",children:[e.jsx("button",{className:`commander-view-toggle ${k?"active":""}`,onClick:()=>F(!k),title:c(k?"commander.simple":"commander.advanced"),children:k?e.jsxs(e.Fragment,{children:[e.jsx(O,{name:"target",size:12})," ",c("commander.advanced")]}):e.jsxs(e.Fragment,{children:[e.jsx(O,{name:"status-pending",size:12})," ",c("commander.simple")]})}),e.jsx("button",{className:"commander-add-btn",onClick:()=>u(!0),title:c("commander.addAgent"),children:c("commander.addAgent")}),e.jsx("button",{className:"commander-close",onClick:a,children:c("commander.close")})]})]}),e.jsx("div",{className:"commander-tabs",children:o.map(n=>{const l=n.id!=="all"&&n.id!=="unassigned"?p.get(n.id):null,g=l&&l.directories&&l.directories.length>0;return e.jsxs("button",{className:`commander-tab ${d===n.id?"active":""}`,onClick:()=>{M(n.id),h(0)},style:n.color?{borderBottomColor:d===n.id?n.color:"transparent"}:void 0,children:[n.color&&e.jsx("span",{className:"commander-tab-dot",style:{background:n.color}}),e.jsx("span",{children:n.name}),e.jsx("span",{className:"commander-tab-count",children:K.get(n.id)||0}),g&&e.jsx("span",{className:"commander-tab-folder",onClick:m=>{m.stopPropagation(),i(n.id)},title:c("commander.openFileExplorer"),children:e.jsx(O,{name:"folder",size:12})})]},n.id)})}),e.jsxs("div",{className:"commander-filters",children:[e.jsxs("div",{className:"commander-filter-group",children:[e.jsx("span",{className:"commander-filter-label",children:c("commander.filters.status")}),["all","working","idle","error","offline"].map(n=>e.jsx("button",{className:`commander-filter-btn ${x.status===n?"active":""}`,onClick:()=>N(l=>({...l,status:n})),children:n==="all"?c("commander.filters.all"):n==="error"?c("commander.filters.needsAttn"):n.charAt(0).toUpperCase()+n.slice(1)},n))]}),e.jsxs("div",{className:"commander-filter-group",children:[e.jsx("span",{className:"commander-filter-label",children:c("commander.filters.active")}),["all","1h","6h","24h"].map(n=>e.jsx("button",{className:`commander-filter-btn ${x.activity===n?"active":""}`,onClick:()=>N(l=>({...l,activity:n})),children:n==="all"?c("commander.filters.any"):`< ${n}`},n))]}),e.jsxs("div",{className:"commander-filter-group",children:[e.jsx("span",{className:"commander-filter-label",children:c("commander.filters.sort")}),["activity","name","created","context"].map(n=>e.jsx("button",{className:`commander-filter-btn ${x.sort===n?"active":""}`,onClick:()=>N(l=>({...l,sort:n})),children:n==="activity"?c("commander.filters.recent"):n==="context"?c("commander.filters.context"):n.charAt(0).toUpperCase()+n.slice(1)},n))]}),B&&e.jsx("button",{className:"commander-filter-clear",onClick:()=>N(Se),title:c("commander.clearFilters"),children:c("commander.filters.clearFilters",{count:te})})]}),$>1&&e.jsxs("div",{className:"commander-pagination",children:[e.jsxs("button",{className:"commander-page-btn",onClick:()=>R(n=>Math.max(0,n-1)),disabled:A===0,children:[e.jsx(O,{name:"caret-left",size:12})," ",c("commander.prev")]}),e.jsx("span",{className:"commander-page-info",children:c("commander.page",{current:A+1,total:$,count:z.length})}),e.jsxs("button",{className:"commander-page-btn",onClick:()=>R(n=>Math.min($-1,n+1)),disabled:A===$-1,children:[c("commander.next")," ",e.jsx(O,{name:"caret-right",size:12})]})]}),e.jsx("div",{className:`commander-grid ${b?"has-expanded":""}`,"data-agent-count":b?1:_.length,children:_.length===0?e.jsx("div",{className:"commander-empty",children:c(d==="all"?"commander.noAgentsAll":d==="unassigned"?"commander.noAgentsUnassigned":"commander.noAgentsArea")}):b?(()=>{const n=f.get(b);return n?e.jsx(Pe,{agent:n,history:Z.get(n.id),isExpanded:!0,isFocused:!0,advancedView:k,index:0,onExpand:ne,onCollapse:ae,onFocus:ce,onInputRef:pe,onLoadMore:U,onClearHistory:w},n.id):null})():_.map((n,l)=>e.jsx(Pe,{agent:n,history:Z.get(n.id),isExpanded:!1,isFocused:l===j,advancedView:k,index:l,onExpand:ne,onCollapse:ae,onFocus:ce,onInputRef:pe,onLoadMore:U,onClearHistory:w},n.id))}),v&&e.jsx(ht,{currentArea:L,onClose:()=>u(!1)}),D&&e.jsx(at,{isOpen:!0,areaId:D,onClose:()=>i(null),onChangeArea:n=>i(n)})]})}):null}export{Ct as CommanderView};
|