tide-commander 1.110.2 → 1.110.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{BossLogsModal-DBeMak5-.js → BossLogsModal-BBO4P4qG.js} +1 -1
- package/dist/assets/{BossSpawnModal-DDl6qgnq.js → BossSpawnModal-DJ1DmEWp.js} +1 -1
- package/dist/assets/{ControlsModal-BBUukX-p.js → ControlsModal-DeRColMt.js} +1 -1
- package/dist/assets/{DockerLogsModal-BWf3XDEI.js → DockerLogsModal-DGpatLiw.js} +1 -1
- package/dist/assets/{EmbeddedEditor-CIOdhnaW.js → EmbeddedEditor-Dsgf6hMF.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-qG-_WeOb.js → GmailOAuthSetup-CGis0yjA.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-BK3lzU4n.js → GoogleOAuthSetup-Bnhf_nts.js} +1 -1
- package/dist/assets/{IframeModal-D_NEs_Ld.js → IframeModal-BahnrxAm.js} +1 -1
- package/dist/assets/{IntegrationsPanel-yphWX1ZD.js → IntegrationsPanel-BUs_7XBA.js} +2 -2
- package/dist/assets/{LogViewerModal-B0h9NNRk.js → LogViewerModal-DXxjS8NR.js} +1 -1
- package/dist/assets/{MonitoringModal-Ciw7KnXH.js → MonitoringModal-DPeyASIV.js} +1 -1
- package/dist/assets/{PM2LogsModal-C1dYQaff.js → PM2LogsModal-kNNjOmdB.js} +1 -1
- package/dist/assets/{RestoreArchivedAreaModal-DOwzfu-D.js → RestoreArchivedAreaModal-CVHj28LX.js} +1 -1
- package/dist/assets/{Scene2DCanvas-MHfv4Rzg.js → Scene2DCanvas-BShs3yx7.js} +1 -1
- package/dist/assets/{SceneManager-cm1Kj0YD.js → SceneManager-CF89Ktyf.js} +1 -1
- package/dist/assets/{SkillsPanel-DLwMkORc.js → SkillsPanel-BVRP74vV.js} +1 -1
- package/dist/assets/{SlackMultiInstanceSetup-Dql_wPMX.js → SlackMultiInstanceSetup-f6boDwm1.js} +1 -1
- package/dist/assets/{SpawnModal-DzPTSOKV.js → SpawnModal-Bm8rg45q.js} +1 -1
- package/dist/assets/StatisticsModal-DuNj8UzS.js +1 -0
- package/dist/assets/{SubordinateAssignmentModal-CoLzD3z2.js → SubordinateAssignmentModal-Cn3e2lNE.js} +1 -1
- package/dist/assets/{TriggerManagerPanel-BOi2zr7N.js → TriggerManagerPanel-Deo2dE4T.js} +1 -1
- package/dist/assets/{WorkflowEditorPanel-DB1ygPDS.js → WorkflowEditorPanel-D-_duRlu.js} +1 -1
- package/dist/assets/{index-DKASWGtq.js → index-Bb-7Dvp1.js} +1 -1
- package/dist/assets/{index-C6EHHgC0.js → index-BsykE0PB.js} +1 -1
- package/dist/assets/{index-D4XW6MSF.js → index-C9A7qvBF.js} +2 -2
- package/dist/assets/{index-DKdZI-Ar.js → index-CZGINGY-.js} +1 -1
- package/dist/assets/{index-6Wak7CPm.js → index-DZu9t3BI.js} +1 -1
- package/dist/assets/{index-BZsQOteM.js → index-DeeuvLUM.js} +1 -1
- package/dist/assets/index-v1ImDk7h.js +11 -0
- package/dist/assets/{index-BXJSMT4a.js → index-y3mA_lBK.js} +3 -3
- package/dist/assets/{index-ThbMNdRp.js → index-zphXsHhS.js} +1 -1
- package/dist/assets/{main-BxA3Bhkv.js → main-CyZg1kKu.js} +94 -94
- package/dist/assets/{main-BLrGoeQ_.css → main-VciFPjA1.css} +1 -1
- package/dist/assets/{web-zdygXcYu.js → web-BKgFBlgl.js} +1 -1
- package/dist/assets/{web-BskC98UQ.js → web-BZcyP_IR.js} +1 -1
- package/dist/assets/{web-CSRmX8Ge.js → web-VEWFSkZI.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/src/packages/server/data/builtin-skills/send-message-to-agent.js +54 -1
- package/dist/src/packages/server/routes/agents.js +43 -0
- package/dist/src/packages/server/services/collapse-context.js +72 -0
- package/dist/src/packages/server/services/runtime-service.js +46 -0
- package/dist/src/packages/server/websocket/handlers/agent-handler.js +27 -12
- package/package.json +1 -1
- package/dist/assets/index-BP6ukiYG.js +0 -11
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{u as Ie,c5 as oo,G as so,r as i,h as Ee,j as e,C as we,s as x,c6 as ro,c7 as to,c8 as ao,aZ as Le,l as K,k as ze,aG as io,aj as lo,aH as co,c9 as I,_ as no,aM as Pe,I as yo,aL as Me}from"./main-
|
|
1
|
+
import{u as Ie,c5 as oo,G as so,r as i,h as Ee,j as e,C as we,s as x,c6 as ro,c7 as to,c8 as ao,aZ as Le,l as K,k as ze,aG as io,aj as lo,aH as co,c9 as I,_ as no,aM as Pe,I as yo,aL as Me}from"./main-CyZg1kKu.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const mo=[{value:"scout",labelKey:"tools:skills.classScout",descriptionKey:"tools:skills.classScoutDesc"},{value:"builder",labelKey:"tools:skills.classBuilder",descriptionKey:"tools:skills.classBuilderDesc"},{value:"debugger",labelKey:"tools:skills.classDebugger",descriptionKey:"tools:skills.classDebuggerDesc"},{value:"architect",labelKey:"tools:skills.classArchitect",descriptionKey:"tools:skills.classArchitectDesc"},{value:"warrior",labelKey:"tools:skills.classWarrior",descriptionKey:"tools:skills.classWarriorDesc"},{value:"support",labelKey:"tools:skills.classSupport",descriptionKey:"tools:skills.classSupportDesc"},{value:"boss",labelKey:"tools:skills.classBoss",descriptionKey:"tools:skills.classBossDesc"}],go=[{labelKey:"tools:skills.toolReadFiles",value:"Read"},{labelKey:"tools:skills.toolWriteFiles",value:"Write"},{labelKey:"tools:skills.toolEditFiles",value:"Edit"},{labelKey:"tools:skills.toolRunBash",value:"Bash"},{labelKey:"tools:skills.toolGitCommands",value:"Bash(git:*)"},{labelKey:"tools:skills.toolNpmCommands",value:"Bash(npm:*)"},{labelKey:"tools:skills.toolDockerCommands",value:"Bash(docker:*)"},{labelKey:"tools:skills.toolKubectlCommands",value:"Bash(kubectl:*)"},{labelKey:"tools:skills.toolSearchFiles",value:"Grep"},{labelKey:"tools:skills.toolGlobFiles",value:"Glob"},{labelKey:"tools:skills.toolWebFetch",value:"WebFetch"},{labelKey:"tools:skills.toolWebSearch",value:"WebSearch"}],po=`## Instructions
|
|
2
2
|
|
|
3
3
|
Describe step-by-step instructions for this skill here.
|
|
4
4
|
|
package/dist/assets/{SlackMultiInstanceSetup-Dql_wPMX.js → SlackMultiInstanceSetup-f6boDwm1.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as h,j as e,aL as b,l as m}from"./main-BxA3Bhkv.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,aL as b,l as m}from"./main-CyZg1kKu.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as Ze,aG as es,aH as ss,aI as as,aJ as ns,r as t,J as Ae,S as ne,aK as te,A as Ee,l as le,aL as ts,s as S,h as ls,j as s,aM as os,_ as De,aN as x,aO as is,aP as oe,I as ie,as as T,aq as K,aQ as cs,ar as ce,aR as re,aS as rs,K as ds}from"./main-BxA3Bhkv.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function Ie(r,j){const b=j.filter(C=>!r.has(C));return b.length===0?`${j[Math.floor(Math.random()*j.length)]}-${Date.now()%1e3}`:b[Math.floor(Math.random()*b.length)]}function hs({isOpen:r,onClose:j,onSpawnStart:b,onSpawnEnd:C,spawnPosition:_e,spawnAreaId:N}){const{t:a}=Ze(["terminal","common"]),P=es(),p=ss(),de=as(),H=de.length>0?de:ns,[m,v]=t.useState(""),[M,F]=t.useState(()=>Ae(ne.LAST_CWD)),[i,k]=t.useState("scout"),[pe,I]=t.useState(!1),[Le,R]=t.useState(!1),[me,J]=t.useState(!1),[ue,he]=t.useState(""),[y,X]=t.useState([]),[A,O]=t.useState(null),[$e,we]=t.useState(!1),[_,xe]=t.useState(""),[h,Te]=t.useState(""),[U,Pe]=t.useState(!1),[z,Fe]=t.useState("bypass"),[o,Y]=t.useState("claude"),[f,E]=t.useState({fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),[fe,Q]=t.useState(new Set),[V,ge]=t.useState("claude-opus-4-8[1m]"),[Z,je]=t.useState("xHigh"),[ee,Re]=t.useState("gpt-5.3-codex"),[se,Oe]=t.useState("minimax/MiniMax-M1-80k"),[Ne,Ue]=t.useState(""),[D,ze]=t.useState(""),q=t.useRef(null),ve=t.useRef(!1),L=t.useCallback(()=>{window.__spawnModalAreaContext=null},[]),w=t.useMemo(()=>P.filter(e=>e.enabled),[P]),qe=["full-notifications","streaming-exec","task-label","report-task-to-boss","agent-tracking","agent-memory","send-message-to-agent"];t.useEffect(()=>{if(r&&!ve.current){if(w.length>0){const l=w.filter(c=>qe.includes(c.slug)).map(c=>c.id);l.length>0&&Q(new Set(l))}const n=Ae(ne.DEFAULT_AGENT_CLASS);if(n==="random"){const c=[...Object.keys(rs),...p.map(u=>u.id)];k(c[Math.floor(Math.random()*c.length)])}else k(n||"scout")}ve.current=r},[r,w,p]);const Se=t.useMemo(()=>{if(!D.trim())return w;const e=D.toLowerCase();return w.filter(n=>n.name.toLowerCase().includes(e)||n.description.toLowerCase().includes(e)||n.slug.toLowerCase().includes(e))},[w,D]),Ge=t.useCallback(e=>{Q(n=>{const l=new Set(n);return l.has(e)?l.delete(e):l.add(e),l})},[]);t.useMemo(()=>w.filter(e=>e.assignedAgentClasses.includes(i)),[w,i]);const We=t.useMemo(()=>{var n;const e=p.find(l=>l.id===i);return(n=e==null?void 0:e.defaultSkillIds)!=null&&n.length?P.filter(l=>e.defaultSkillIds.includes(l.id)):[]},[p,i,P]),be=t.useMemo(()=>{if(!_.trim())return y;const e=_.toLowerCase();return y.filter(n=>n.sessionId.toLowerCase().includes(e)||n.projectPath.toLowerCase().includes(e)||n.firstMessage&&n.firstMessage.toLowerCase().includes(e))},[y,_]),G=t.useMemo(()=>{if(!h.trim())return p;const e=h.toLowerCase();return p.filter(n=>n.name.toLowerCase().includes(e)||n.description.toLowerCase().includes(e)||n.id.toLowerCase().includes(e))},[p,h]),W=t.useMemo(()=>{if(!h.trim())return te;const e=h.toLowerCase();return te.filter(n=>{const l=Ee[n.id];return n.name.toLowerCase().includes(e)||n.id.toLowerCase().includes(e)||l.description.toLowerCase().includes(e)})},[h]);t.useEffect(()=>{if(!r||!h.trim())return;const e=[...G.map(n=>n.id),...W.map(n=>n.id)];e.length===1&&e[0]!==i&&k(e[0])},[r,h,G,W,i]);const d=t.useMemo(()=>p.find(e=>e.id===i),[p,i]),Be=t.useMemo(()=>{if(d!=null&&d.model)return d.model},[d]),Ke=t.useMemo(()=>{if(d!=null&&d.customModelPath)return le(`/api/custom-models/${d.id}`)},[d]),He=d==null?void 0:d.modelScale,Je=t.useMemo(()=>d?"scout":i,[i,d]),B=t.useCallback(async e=>{we(!0);try{const n=e?le(`/api/agents/claude-sessions?cwd=${encodeURIComponent(e)}`):le("/api/agents/claude-sessions"),c=await(await ts(n)).json();X(c.sessions||[])}catch(n){console.error("Failed to fetch sessions:",n),X([])}finally{we(!1)}},[]);t.useEffect(()=>{r?B(M||void 0):(X([]),O(null),xe(""))},[r,B]),t.useEffect(()=>{if(!r)return;const e=setTimeout(()=>{B(M||void 0),O(null)},300);return()=>clearTimeout(e)},[M,r,B]),t.useEffect(()=>{if(!r||!N)return;const e=S.getState().areas.get(N);if(e!=null&&e.directories&&e.directories.length>0){F(e.directories[0]);return}const n=Array.from(S.getState().agents.values()).filter(g=>{var $;return(($=S.getAreaForAgent(g.id))==null?void 0:$.id)===N&&g.cwd});if(n.length===0)return;const l=new Map;for(const g of n)l.set(g.cwd,(l.get(g.cwd)||0)+1);let c="",u=0;for(const[g,$]of l)$>u&&(c=g,u=$);c&&F(c)},[r,N]),t.useEffect(()=>{if(r){const e=new Set(Array.from(S.getState().agents.values()).map(u=>u.name)),n=Ie(e,H),l=p.find(u=>u.id===i),c=l?`${l.name} ${n}`:n;v(c),q.current&&(q.current.focus(),q.current.select())}},[r,H]),t.useEffect(()=>{if(!r)return;const e=p.find(n=>n.id===i);if(e){const n=p.find(l=>m.startsWith(l.name+" "));if(n){const l=m.substring(n.name.length+1);v(`${e.name} ${l}`)}else v(`${e.name} ${m}`)}else{const n=p.find(l=>m.startsWith(l.name+" "));if(n){const l=m.substring(n.name.length+1);v(l)}}},[i]),t.useEffect(()=>{i==="boss"&&ge("claude-opus-4-8[1m]")},[i]);const Xe=()=>{var c;console.log("[SpawnModal] handleSpawn called"),R(!1);const e=A&&((c=y.find(u=>u.sessionId===A))==null?void 0:c.projectPath)||M;if(console.log("[SpawnModal] Effective CWD:",e),console.log("[SpawnModal] Agent name:",m),console.log("[SpawnModal] Agent class:",i),console.log("[SpawnModal] Permission mode:",z),console.log("[SpawnModal] Provider:",o),console.log("[SpawnModal] Use Chrome:",U),console.log("[SpawnModal] Session ID:",A||"none"),!e.trim()){console.error("[SpawnModal] Empty CWD, showing error"),R(!0);return}if(!m.trim()){console.log("[SpawnModal] Empty name, regenerating");const u=new Set(Array.from(S.getState().agents.values()).map(g=>g.name));v(Ie(u,H));return}ds(ne.LAST_CWD,e),I(!0),b();const n=Array.from(fe),l=Ne.trim()||void 0;console.log("[SpawnModal] Calling store.spawnAgent with:",{name:m.trim(),class:i,cwd:e.trim(),sessionId:A||void 0,useChrome:o==="claude"?U:!1,permissionMode:z,provider:o,codexConfig:o==="codex"?f:void 0,codexModel:o==="codex"?ee:void 0,opencodeModel:o==="opencode"?se:void 0,initialSkillIds:n,model:o==="claude"?V:void 0,customInstructions:l?`${l.length} chars`:void 0,spawnAreaId:N||void 0}),window.__spawnModalAreaContext=N?{areaId:N}:null,S.spawnAgent(m.trim(),i,e.trim(),_e||void 0,A||void 0,o==="claude"?U:!1,z,n,o,o==="codex"?f:void 0,o==="codex"?ee:void 0,o==="claude"?V:void 0,l,o==="claude"?Z:void 0,o==="opencode"?se:void 0)},Ce=()=>{console.log("[SpawnModal] Agent creation successful"),I(!1),v(""),Q(new Set),L(),C(),j()},Me=()=>{console.error("[SpawnModal] Agent creation failed"),I(!1),R(!0),L(),C()},ke=e=>{console.log("[SpawnModal] Directory not found:",e),I(!1),he(e),J(!0),C()},ye=()=>{J(!1),I(!0),b(),S.createDirectoryAndSpawn(ue,m.trim(),i)},ae=()=>{J(!1),he(""),L()};t.useEffect(()=>(window.__spawnModalSuccess=Ce,window.__spawnModalError=Me,window.__spawnModalDirNotFound=ke,()=>{L(),delete window.__spawnModalSuccess,delete window.__spawnModalError,delete window.__spawnModalDirNotFound}),[m,i,Ce,Me,ke,L]);const{handleMouseDown:Ye,handleClick:Qe}=ls(j),Ve=e=>{e.key==="Escape"&&j()};return!r&&!me?null:me?s.jsx("div",{className:"modal-overlay visible",onClick:ae,onKeyDown:e=>{e.key==="Escape"&&ae(),e.key==="Enter"&&ye()},children:s.jsxs("div",{className:"modal confirm-modal",onClick:e=>e.stopPropagation(),children:[s.jsx("div",{className:"modal-header",children:a("terminal:spawn.directoryNotFound")}),s.jsxs("div",{className:"modal-body confirm-modal-body",children:[s.jsx("p",{children:a("terminal:spawn.directoryNotExist")}),s.jsx("code",{className:"confirm-modal-path",children:ue}),s.jsx("p",{children:a("terminal:spawn.wouldYouCreate")})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:ae,children:a("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-primary",onClick:ye,autoFocus:!0,children:a("terminal:spawn.createDirectory")})]})]})}):s.jsx("div",{className:`modal-overlay ${r?"visible":""}`,onMouseDown:Ye,onClick:Qe,onKeyDown:Ve,children:s.jsxs("div",{className:"modal spawn-modal",children:[s.jsx("div",{className:"modal-header",children:a("terminal:spawn.deployTitle")}),s.jsxs("div",{className:"modal-body spawn-modal-body",children:[s.jsxs("div",{className:"spawn-top-section",children:[s.jsx("div",{className:"spawn-preview-compact",children:s.jsx(os,{agentClass:Je,modelFile:Be,customModelUrl:Ke,modelScale:He,width:100,height:120})}),s.jsxs("div",{className:"spawn-class-section",children:[s.jsx("div",{className:"spawn-class-label",children:a("terminal:spawn.agentClass")}),p.length+te.length>6&&s.jsx("input",{type:"text",className:"spawn-input class-search-input",placeholder:a("terminal:spawn.filterClasses"),value:h,onChange:e=>Te(e.target.value)}),s.jsxs("div",{className:"class-selector-inline",children:[G.map(e=>s.jsxs("button",{className:`class-chip ${i===e.id?"selected":""}`,onClick:()=>k(e.id),title:e.description,children:[s.jsx(De,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id)),W.map(e=>{const n=Ee[e.id];return s.jsxs("button",{className:`class-chip ${i===e.id?"selected":""}`,onClick:()=>k(e.id),title:n.description,children:[s.jsx(De,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id)}),h&&G.length===0&&W.length===0&&s.jsx("div",{className:"class-search-empty",children:a("terminal:spawn.noClassesMatch",{query:h})})]})]})]}),s.jsxs("div",{className:"spawn-form-section",children:[s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:a("common:labels.name")}),s.jsx("input",{ref:q,type:"text",className:"spawn-input",placeholder:a("terminal:spawn.agentNamePlaceholder"),value:m,onChange:e=>v(e.target.value)})]}),s.jsxs("div",{className:"spawn-field spawn-field-wide",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.workingDir"),s.jsx(x,{text:a("terminal:spawn.helpWorkingDir"),title:a("terminal:spawn.workingDir"),position:"top",size:"sm"})]}),s.jsx(is,{value:M,onChange:e=>{F(e),R(!1)},placeholder:a("terminal:spawn.workingDirPlaceholder"),className:`spawn-input ${Le?"error":""}`,directoriesOnly:!0})]})]}),s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.selectRuntime"),s.jsx(x,{text:a("terminal:spawn.helpRuntime"),title:a("terminal:spawn.runtimeTitle"),position:"top",size:"sm"})]}),s.jsxs("div",{className:"spawn-select-row",children:[s.jsxs("button",{className:`spawn-select-btn ${o==="claude"?"selected":""}`,onClick:()=>Y("claude"),title:a("terminal:spawn.useClaudeCli"),children:[s.jsx("img",{src:"/assets/claude.ico",alt:"Claude",className:"spawn-provider-icon"}),s.jsx("span",{children:"Claude"})]}),s.jsxs("button",{className:`spawn-select-btn ${o==="codex"?"selected":""}`,onClick:()=>Y("codex"),title:a("terminal:spawn.useCodexCli"),children:[s.jsx("img",{src:"/assets/codex.ico",alt:"Codex",className:"spawn-provider-icon"}),s.jsx("span",{children:"Codex"})]}),s.jsxs("button",{className:`spawn-select-btn spawn-select-btn--opencode ${o==="opencode"?"selected":""}`,onClick:()=>Y("opencode"),title:"Use OpenCode CLI (multi-provider)",children:[s.jsx("img",{src:"/assets/opencode.svg",alt:"OpenCode",className:"spawn-provider-icon"}),s.jsx("span",{children:"OpenCode"})]})]})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsxs("label",{className:"spawn-label",children:[a("common:labels.permissions"),s.jsx(x,{text:a("terminal:spawn.helpPermission"),title:a("terminal:spawn.permissionMode"),position:"top",size:"sm"})]}),s.jsx("div",{className:"spawn-select-row",children:Object.keys(oe).map(e=>s.jsxs("button",{className:`spawn-select-btn ${z===e?"selected":""}`,onClick:()=>Fe(e),title:oe[e].description,children:[s.jsx("span",{children:s.jsx(ie,{name:e==="bypass"?"bolt":"lock",size:12})}),s.jsx("span",{children:oe[e].label})]},e))})]})]}),s.jsx("div",{className:"spawn-form-row",children:s.jsxs("div",{className:"spawn-field",children:[s.jsxs("label",{className:"spawn-label",children:[a("common:labels.model"),s.jsx(x,{text:a("terminal:spawn.helpModel"),title:a("terminal:spawn.modelTitle"),position:"top",size:"sm"})]}),o==="claude"?s.jsx("div",{className:"spawn-select-row spawn-select-row--wrap",children:Object.keys(T).filter(e=>!T[e].deprecated).map(e=>s.jsxs("button",{className:`spawn-select-btn ${V===e?"selected":""}`,onClick:()=>ge(e),title:T[e].description,children:[s.jsx("span",{children:T[e].icon}),s.jsx("span",{children:T[e].label})]},e))}):o==="codex"?s.jsx("div",{className:"spawn-select-row spawn-select-row--codex-models",children:Object.keys(K).map(e=>s.jsxs("button",{className:`spawn-select-btn ${ee===e?"selected":""}`,onClick:()=>Re(e),title:K[e].description,children:[s.jsx("span",{children:K[e].icon}),s.jsx("span",{children:K[e].label})]},e))}):o==="opencode"?s.jsx(cs,{value:se,onChange:Oe,inputId:"spawn-opencode-model"}):s.jsx("div",{className:"spawn-inline-hint",children:a("terminal:spawn.chooseCodexModel")})]})}),s.jsxs("div",{className:"spawn-form-row",children:[o==="claude"&&s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:"Effort"}),s.jsxs("div",{className:"spawn-select-row spawn-select-row--effort",children:[s.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${Z===void 0?"selected":""}`,onClick:()=>je(void 0),title:"Use default effort level",children:s.jsx("span",{children:"Default"})}),Object.keys(ce).map(e=>s.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${Z===e?"selected":""}`,onClick:()=>je(e),title:ce[e].description,children:s.jsx("span",{children:ce[e].label})},e))]})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:a("terminal:spawn.browser")}),s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:U,onChange:e=>Pe(e.target.checked),disabled:o!=="claude"}),s.jsxs("span",{children:[s.jsx(ie,{name:"globe",size:12})," ",a("terminal:spawn.chromeBrowser")]}),s.jsx(x,{text:a(o==="claude"?"terminal:spawn.helpChrome":"terminal:spawn.helpChromeDisabled"),title:a("terminal:spawn.chromeBrowser"),position:"top",size:"sm"})]})]})]}),o==="codex"&&s.jsxs("div",{className:"codex-config-section",children:[s.jsx("div",{className:"codex-config-title",children:a("terminal:spawn.codex.configuration")}),s.jsxs("div",{className:"codex-config-options",children:[s.jsxs("div",{className:"codex-option-group",children:[s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:f.fullAuto!==!1,onChange:e=>E(n=>({...n,fullAuto:e.target.checked}))}),s.jsx("span",{children:a("terminal:spawn.codex.fullAuto")}),s.jsx(x,{text:a("terminal:spawn.helpFullAuto"),title:a("terminal:spawn.fullAutoTitle"),position:"top",size:"sm"})]}),s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:!!f.search,onChange:e=>E(n=>({...n,search:e.target.checked}))}),s.jsx("span",{children:a("terminal:spawn.codex.search")}),s.jsx(x,{text:a("terminal:spawn.helpSearch"),title:a("terminal:spawn.searchTitle"),position:"top",size:"sm"})]})]}),f.fullAuto===!1&&s.jsxs("div",{className:"codex-option-group",children:[s.jsx("div",{className:"codex-option-header",children:a("terminal:spawn.codex.restrictions")}),s.jsxs("select",{className:"spawn-input codex-select",value:f.sandbox||"workspace-write",onChange:e=>E(n=>({...n,sandbox:e.target.value})),children:[s.jsxs("option",{value:"read-only",children:["📖 ",a("terminal:spawn.codex.sandboxReadOnly")]}),s.jsxs("option",{value:"workspace-write",children:["✏️ ",a("terminal:spawn.codex.sandboxWorkspaceWrite")]}),s.jsxs("option",{value:"danger-full-access",children:["⚡ ",a("terminal:spawn.codex.sandboxDangerFullAccess")]})]}),s.jsxs("select",{className:"spawn-input codex-select",value:f.approvalMode||"on-request",onChange:e=>E(n=>({...n,approvalMode:e.target.value})),children:[s.jsxs("option",{value:"untrusted",children:["🔒 ",a("terminal:spawn.codex.approvalsUntrusted")]}),s.jsxs("option",{value:"on-failure",children:["⚠️ ",a("terminal:spawn.codex.approvalsOnFailure")]}),s.jsxs("option",{value:"on-request",children:["🤔 ",a("terminal:spawn.codex.approvalsOnRequest")]}),s.jsxs("option",{value:"never",children:["✅ ",a("terminal:spawn.codex.approvalsNever")]})]})]}),s.jsxs("div",{className:"codex-option-group",children:[s.jsx("div",{className:"codex-option-header",children:a("terminal:spawn.codex.profile")}),s.jsx("input",{type:"text",className:"spawn-input codex-profile-input",placeholder:a("terminal:spawn.codex.profilePlaceholder"),value:f.profile||"",onChange:e=>E(n=>({...n,profile:e.target.value||void 0}))})]}),s.jsxs("div",{className:"codex-option-group",children:[s.jsx("div",{className:"codex-option-header",children:a("terminal:spawn.codex.reasoningEffort")}),s.jsxs("select",{className:"spawn-input codex-select",value:f.reasoningEffort||"",onChange:e=>E(n=>({...n,reasoningEffort:e.target.value||void 0})),children:[s.jsx("option",{value:"",children:a("terminal:spawn.codex.reasoningEffortDefault")}),Object.keys(re).map(e=>s.jsxs("option",{value:e,children:[re[e].icon," ",re[e].label]},e))]})]})]})]}),w.length>0&&s.jsxs("div",{className:"spawn-skills-section",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.skills")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",a("common:labels.optional"),")"]}),s.jsx(x,{text:a("terminal:spawn.helpSkills"),title:a("terminal:spawn.skillsTitle"),position:"top",size:"sm"})]}),w.length>6&&s.jsx("input",{type:"text",className:"spawn-input skill-search-input",placeholder:a("terminal:spawn.filterSkills"),value:D,onChange:e=>ze(e.target.value)}),s.jsxs("div",{className:"spawn-skills-inline",children:[Se.map(e=>{const n=fe.has(e.id);return We.some(c=>c.id===e.id)?null:s.jsxs("button",{className:`spawn-skill-chip ${n?"selected":""}`,onClick:()=>Ge(e.id),title:e.description,children:[n&&s.jsx("span",{className:"spawn-skill-check",children:s.jsx(ie,{name:"check",size:10})}),s.jsx("span",{children:e.name}),e.builtin&&s.jsx("span",{className:"spawn-skill-builtin",children:"TC"})]},e.id)}),D&&Se.length===0&&s.jsx("div",{className:"skill-search-empty",children:a("terminal:spawn.noSkillsMatch",{query:D})})]})]}),s.jsxs("div",{className:"spawn-custom-instructions-section",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.customInstructions")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",a("common:labels.optional"),")"]}),s.jsx(x,{text:a("terminal:spawn.helpCustomInstructions"),title:a("terminal:spawn.customInstructions"),position:"top",size:"sm"})]}),s.jsx("textarea",{className:"spawn-input spawn-textarea",placeholder:a("terminal:spawn.customInstructionsPlaceholder"),value:Ne,onChange:e=>Ue(e.target.value),rows:3})]}),s.jsxs("div",{className:"spawn-sessions-section",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.linkSession")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",a("common:labels.optional"),")"]}),s.jsx(x,{text:a("terminal:spawn.helpLinkSession"),title:a("terminal:spawn.linkSessionTitle"),position:"top",size:"sm"})]}),y.length>0&&s.jsx("input",{type:"text",className:"spawn-input session-search-input",placeholder:a("terminal:spawn.searchSessions"),value:_,onChange:e=>xe(e.target.value)}),s.jsx("div",{className:"sessions-list",children:$e?s.jsx("div",{className:"sessions-loading",children:a("terminal:spawn.loadingSessions")}):y.length===0?s.jsx("div",{className:"sessions-empty",children:a("terminal:spawn.noSessions")}):be.length===0?s.jsx("div",{className:"sessions-empty",children:a("terminal:spawn.noSessionsMatch",{query:_})}):be.map(e=>{const n=A===e.sessionId,l=Date.now()-new Date(e.lastModified).getTime(),c=l<6e4?a("common:time.justNow"):l<36e5?a("common:time.minutesAgo",{count:Math.floor(l/6e4)}):l<864e5?a("common:time.hoursAgo",{count:Math.floor(l/36e5)}):a("common:time.daysAgo",{count:Math.floor(l/864e5)});return s.jsxs("div",{className:`session-item ${n?"selected":""}`,onClick:()=>{n?O(null):(O(e.sessionId),F(e.projectPath))},children:[s.jsxs("div",{className:"session-item-header",children:[s.jsx("span",{className:"session-item-path",children:e.projectPath}),s.jsx("span",{className:"session-item-age",children:c})]}),s.jsx("div",{className:"session-item-preview",children:e.firstMessage||a("terminal:spawn.messagesCount",{count:e.messageCount})})]},e.sessionId)})})]})]})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:j,children:a("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-primary",onClick:Xe,disabled:pe,children:a(pe?"common:buttons.deploying":"common:buttons2.deploy")})]})]})})}export{hs as SpawnModal};
|
|
1
|
+
import{u as Ze,aG as es,aH as ss,aI as as,aJ as ns,r as t,J as Ae,S as ne,aK as te,A as Ee,l as le,aL as ts,s as S,h as ls,j as s,aM as os,_ as De,aN as x,aO as is,aP as oe,I as ie,as as T,aq as K,aQ as cs,ar as ce,aR as re,aS as rs,K as ds}from"./main-CyZg1kKu.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function Ie(r,j){const b=j.filter(C=>!r.has(C));return b.length===0?`${j[Math.floor(Math.random()*j.length)]}-${Date.now()%1e3}`:b[Math.floor(Math.random()*b.length)]}function hs({isOpen:r,onClose:j,onSpawnStart:b,onSpawnEnd:C,spawnPosition:_e,spawnAreaId:N}){const{t:a}=Ze(["terminal","common"]),P=es(),p=ss(),de=as(),H=de.length>0?de:ns,[m,v]=t.useState(""),[M,F]=t.useState(()=>Ae(ne.LAST_CWD)),[i,k]=t.useState("scout"),[pe,I]=t.useState(!1),[Le,R]=t.useState(!1),[me,J]=t.useState(!1),[ue,he]=t.useState(""),[y,X]=t.useState([]),[A,O]=t.useState(null),[$e,we]=t.useState(!1),[_,xe]=t.useState(""),[h,Te]=t.useState(""),[U,Pe]=t.useState(!1),[z,Fe]=t.useState("bypass"),[o,Y]=t.useState("claude"),[f,E]=t.useState({fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),[fe,Q]=t.useState(new Set),[V,ge]=t.useState("claude-opus-4-8[1m]"),[Z,je]=t.useState("xHigh"),[ee,Re]=t.useState("gpt-5.3-codex"),[se,Oe]=t.useState("minimax/MiniMax-M1-80k"),[Ne,Ue]=t.useState(""),[D,ze]=t.useState(""),q=t.useRef(null),ve=t.useRef(!1),L=t.useCallback(()=>{window.__spawnModalAreaContext=null},[]),w=t.useMemo(()=>P.filter(e=>e.enabled),[P]),qe=["full-notifications","streaming-exec","task-label","report-task-to-boss","agent-tracking","agent-memory","send-message-to-agent"];t.useEffect(()=>{if(r&&!ve.current){if(w.length>0){const l=w.filter(c=>qe.includes(c.slug)).map(c=>c.id);l.length>0&&Q(new Set(l))}const n=Ae(ne.DEFAULT_AGENT_CLASS);if(n==="random"){const c=[...Object.keys(rs),...p.map(u=>u.id)];k(c[Math.floor(Math.random()*c.length)])}else k(n||"scout")}ve.current=r},[r,w,p]);const Se=t.useMemo(()=>{if(!D.trim())return w;const e=D.toLowerCase();return w.filter(n=>n.name.toLowerCase().includes(e)||n.description.toLowerCase().includes(e)||n.slug.toLowerCase().includes(e))},[w,D]),Ge=t.useCallback(e=>{Q(n=>{const l=new Set(n);return l.has(e)?l.delete(e):l.add(e),l})},[]);t.useMemo(()=>w.filter(e=>e.assignedAgentClasses.includes(i)),[w,i]);const We=t.useMemo(()=>{var n;const e=p.find(l=>l.id===i);return(n=e==null?void 0:e.defaultSkillIds)!=null&&n.length?P.filter(l=>e.defaultSkillIds.includes(l.id)):[]},[p,i,P]),be=t.useMemo(()=>{if(!_.trim())return y;const e=_.toLowerCase();return y.filter(n=>n.sessionId.toLowerCase().includes(e)||n.projectPath.toLowerCase().includes(e)||n.firstMessage&&n.firstMessage.toLowerCase().includes(e))},[y,_]),G=t.useMemo(()=>{if(!h.trim())return p;const e=h.toLowerCase();return p.filter(n=>n.name.toLowerCase().includes(e)||n.description.toLowerCase().includes(e)||n.id.toLowerCase().includes(e))},[p,h]),W=t.useMemo(()=>{if(!h.trim())return te;const e=h.toLowerCase();return te.filter(n=>{const l=Ee[n.id];return n.name.toLowerCase().includes(e)||n.id.toLowerCase().includes(e)||l.description.toLowerCase().includes(e)})},[h]);t.useEffect(()=>{if(!r||!h.trim())return;const e=[...G.map(n=>n.id),...W.map(n=>n.id)];e.length===1&&e[0]!==i&&k(e[0])},[r,h,G,W,i]);const d=t.useMemo(()=>p.find(e=>e.id===i),[p,i]),Be=t.useMemo(()=>{if(d!=null&&d.model)return d.model},[d]),Ke=t.useMemo(()=>{if(d!=null&&d.customModelPath)return le(`/api/custom-models/${d.id}`)},[d]),He=d==null?void 0:d.modelScale,Je=t.useMemo(()=>d?"scout":i,[i,d]),B=t.useCallback(async e=>{we(!0);try{const n=e?le(`/api/agents/claude-sessions?cwd=${encodeURIComponent(e)}`):le("/api/agents/claude-sessions"),c=await(await ts(n)).json();X(c.sessions||[])}catch(n){console.error("Failed to fetch sessions:",n),X([])}finally{we(!1)}},[]);t.useEffect(()=>{r?B(M||void 0):(X([]),O(null),xe(""))},[r,B]),t.useEffect(()=>{if(!r)return;const e=setTimeout(()=>{B(M||void 0),O(null)},300);return()=>clearTimeout(e)},[M,r,B]),t.useEffect(()=>{if(!r||!N)return;const e=S.getState().areas.get(N);if(e!=null&&e.directories&&e.directories.length>0){F(e.directories[0]);return}const n=Array.from(S.getState().agents.values()).filter(g=>{var $;return(($=S.getAreaForAgent(g.id))==null?void 0:$.id)===N&&g.cwd});if(n.length===0)return;const l=new Map;for(const g of n)l.set(g.cwd,(l.get(g.cwd)||0)+1);let c="",u=0;for(const[g,$]of l)$>u&&(c=g,u=$);c&&F(c)},[r,N]),t.useEffect(()=>{if(r){const e=new Set(Array.from(S.getState().agents.values()).map(u=>u.name)),n=Ie(e,H),l=p.find(u=>u.id===i),c=l?`${l.name} ${n}`:n;v(c),q.current&&(q.current.focus(),q.current.select())}},[r,H]),t.useEffect(()=>{if(!r)return;const e=p.find(n=>n.id===i);if(e){const n=p.find(l=>m.startsWith(l.name+" "));if(n){const l=m.substring(n.name.length+1);v(`${e.name} ${l}`)}else v(`${e.name} ${m}`)}else{const n=p.find(l=>m.startsWith(l.name+" "));if(n){const l=m.substring(n.name.length+1);v(l)}}},[i]),t.useEffect(()=>{i==="boss"&&ge("claude-opus-4-8[1m]")},[i]);const Xe=()=>{var c;console.log("[SpawnModal] handleSpawn called"),R(!1);const e=A&&((c=y.find(u=>u.sessionId===A))==null?void 0:c.projectPath)||M;if(console.log("[SpawnModal] Effective CWD:",e),console.log("[SpawnModal] Agent name:",m),console.log("[SpawnModal] Agent class:",i),console.log("[SpawnModal] Permission mode:",z),console.log("[SpawnModal] Provider:",o),console.log("[SpawnModal] Use Chrome:",U),console.log("[SpawnModal] Session ID:",A||"none"),!e.trim()){console.error("[SpawnModal] Empty CWD, showing error"),R(!0);return}if(!m.trim()){console.log("[SpawnModal] Empty name, regenerating");const u=new Set(Array.from(S.getState().agents.values()).map(g=>g.name));v(Ie(u,H));return}ds(ne.LAST_CWD,e),I(!0),b();const n=Array.from(fe),l=Ne.trim()||void 0;console.log("[SpawnModal] Calling store.spawnAgent with:",{name:m.trim(),class:i,cwd:e.trim(),sessionId:A||void 0,useChrome:o==="claude"?U:!1,permissionMode:z,provider:o,codexConfig:o==="codex"?f:void 0,codexModel:o==="codex"?ee:void 0,opencodeModel:o==="opencode"?se:void 0,initialSkillIds:n,model:o==="claude"?V:void 0,customInstructions:l?`${l.length} chars`:void 0,spawnAreaId:N||void 0}),window.__spawnModalAreaContext=N?{areaId:N}:null,S.spawnAgent(m.trim(),i,e.trim(),_e||void 0,A||void 0,o==="claude"?U:!1,z,n,o,o==="codex"?f:void 0,o==="codex"?ee:void 0,o==="claude"?V:void 0,l,o==="claude"?Z:void 0,o==="opencode"?se:void 0)},Ce=()=>{console.log("[SpawnModal] Agent creation successful"),I(!1),v(""),Q(new Set),L(),C(),j()},Me=()=>{console.error("[SpawnModal] Agent creation failed"),I(!1),R(!0),L(),C()},ke=e=>{console.log("[SpawnModal] Directory not found:",e),I(!1),he(e),J(!0),C()},ye=()=>{J(!1),I(!0),b(),S.createDirectoryAndSpawn(ue,m.trim(),i)},ae=()=>{J(!1),he(""),L()};t.useEffect(()=>(window.__spawnModalSuccess=Ce,window.__spawnModalError=Me,window.__spawnModalDirNotFound=ke,()=>{L(),delete window.__spawnModalSuccess,delete window.__spawnModalError,delete window.__spawnModalDirNotFound}),[m,i,Ce,Me,ke,L]);const{handleMouseDown:Ye,handleClick:Qe}=ls(j),Ve=e=>{e.key==="Escape"&&j()};return!r&&!me?null:me?s.jsx("div",{className:"modal-overlay visible",onClick:ae,onKeyDown:e=>{e.key==="Escape"&&ae(),e.key==="Enter"&&ye()},children:s.jsxs("div",{className:"modal confirm-modal",onClick:e=>e.stopPropagation(),children:[s.jsx("div",{className:"modal-header",children:a("terminal:spawn.directoryNotFound")}),s.jsxs("div",{className:"modal-body confirm-modal-body",children:[s.jsx("p",{children:a("terminal:spawn.directoryNotExist")}),s.jsx("code",{className:"confirm-modal-path",children:ue}),s.jsx("p",{children:a("terminal:spawn.wouldYouCreate")})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:ae,children:a("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-primary",onClick:ye,autoFocus:!0,children:a("terminal:spawn.createDirectory")})]})]})}):s.jsx("div",{className:`modal-overlay ${r?"visible":""}`,onMouseDown:Ye,onClick:Qe,onKeyDown:Ve,children:s.jsxs("div",{className:"modal spawn-modal",children:[s.jsx("div",{className:"modal-header",children:a("terminal:spawn.deployTitle")}),s.jsxs("div",{className:"modal-body spawn-modal-body",children:[s.jsxs("div",{className:"spawn-top-section",children:[s.jsx("div",{className:"spawn-preview-compact",children:s.jsx(os,{agentClass:Je,modelFile:Be,customModelUrl:Ke,modelScale:He,width:100,height:120})}),s.jsxs("div",{className:"spawn-class-section",children:[s.jsx("div",{className:"spawn-class-label",children:a("terminal:spawn.agentClass")}),p.length+te.length>6&&s.jsx("input",{type:"text",className:"spawn-input class-search-input",placeholder:a("terminal:spawn.filterClasses"),value:h,onChange:e=>Te(e.target.value)}),s.jsxs("div",{className:"class-selector-inline",children:[G.map(e=>s.jsxs("button",{className:`class-chip ${i===e.id?"selected":""}`,onClick:()=>k(e.id),title:e.description,children:[s.jsx(De,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id)),W.map(e=>{const n=Ee[e.id];return s.jsxs("button",{className:`class-chip ${i===e.id?"selected":""}`,onClick:()=>k(e.id),title:n.description,children:[s.jsx(De,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id)}),h&&G.length===0&&W.length===0&&s.jsx("div",{className:"class-search-empty",children:a("terminal:spawn.noClassesMatch",{query:h})})]})]})]}),s.jsxs("div",{className:"spawn-form-section",children:[s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:a("common:labels.name")}),s.jsx("input",{ref:q,type:"text",className:"spawn-input",placeholder:a("terminal:spawn.agentNamePlaceholder"),value:m,onChange:e=>v(e.target.value)})]}),s.jsxs("div",{className:"spawn-field spawn-field-wide",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.workingDir"),s.jsx(x,{text:a("terminal:spawn.helpWorkingDir"),title:a("terminal:spawn.workingDir"),position:"top",size:"sm"})]}),s.jsx(is,{value:M,onChange:e=>{F(e),R(!1)},placeholder:a("terminal:spawn.workingDirPlaceholder"),className:`spawn-input ${Le?"error":""}`,directoriesOnly:!0})]})]}),s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.selectRuntime"),s.jsx(x,{text:a("terminal:spawn.helpRuntime"),title:a("terminal:spawn.runtimeTitle"),position:"top",size:"sm"})]}),s.jsxs("div",{className:"spawn-select-row",children:[s.jsxs("button",{className:`spawn-select-btn ${o==="claude"?"selected":""}`,onClick:()=>Y("claude"),title:a("terminal:spawn.useClaudeCli"),children:[s.jsx("img",{src:"/assets/claude.ico",alt:"Claude",className:"spawn-provider-icon"}),s.jsx("span",{children:"Claude"})]}),s.jsxs("button",{className:`spawn-select-btn ${o==="codex"?"selected":""}`,onClick:()=>Y("codex"),title:a("terminal:spawn.useCodexCli"),children:[s.jsx("img",{src:"/assets/codex.ico",alt:"Codex",className:"spawn-provider-icon"}),s.jsx("span",{children:"Codex"})]}),s.jsxs("button",{className:`spawn-select-btn spawn-select-btn--opencode ${o==="opencode"?"selected":""}`,onClick:()=>Y("opencode"),title:"Use OpenCode CLI (multi-provider)",children:[s.jsx("img",{src:"/assets/opencode.svg",alt:"OpenCode",className:"spawn-provider-icon"}),s.jsx("span",{children:"OpenCode"})]})]})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsxs("label",{className:"spawn-label",children:[a("common:labels.permissions"),s.jsx(x,{text:a("terminal:spawn.helpPermission"),title:a("terminal:spawn.permissionMode"),position:"top",size:"sm"})]}),s.jsx("div",{className:"spawn-select-row",children:Object.keys(oe).map(e=>s.jsxs("button",{className:`spawn-select-btn ${z===e?"selected":""}`,onClick:()=>Fe(e),title:oe[e].description,children:[s.jsx("span",{children:s.jsx(ie,{name:e==="bypass"?"bolt":"lock",size:12})}),s.jsx("span",{children:oe[e].label})]},e))})]})]}),s.jsx("div",{className:"spawn-form-row",children:s.jsxs("div",{className:"spawn-field",children:[s.jsxs("label",{className:"spawn-label",children:[a("common:labels.model"),s.jsx(x,{text:a("terminal:spawn.helpModel"),title:a("terminal:spawn.modelTitle"),position:"top",size:"sm"})]}),o==="claude"?s.jsx("div",{className:"spawn-select-row spawn-select-row--wrap",children:Object.keys(T).filter(e=>!T[e].deprecated).map(e=>s.jsxs("button",{className:`spawn-select-btn ${V===e?"selected":""}`,onClick:()=>ge(e),title:T[e].description,children:[s.jsx("span",{children:T[e].icon}),s.jsx("span",{children:T[e].label})]},e))}):o==="codex"?s.jsx("div",{className:"spawn-select-row spawn-select-row--codex-models",children:Object.keys(K).map(e=>s.jsxs("button",{className:`spawn-select-btn ${ee===e?"selected":""}`,onClick:()=>Re(e),title:K[e].description,children:[s.jsx("span",{children:K[e].icon}),s.jsx("span",{children:K[e].label})]},e))}):o==="opencode"?s.jsx(cs,{value:se,onChange:Oe,inputId:"spawn-opencode-model"}):s.jsx("div",{className:"spawn-inline-hint",children:a("terminal:spawn.chooseCodexModel")})]})}),s.jsxs("div",{className:"spawn-form-row",children:[o==="claude"&&s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:"Effort"}),s.jsxs("div",{className:"spawn-select-row spawn-select-row--effort",children:[s.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${Z===void 0?"selected":""}`,onClick:()=>je(void 0),title:"Use default effort level",children:s.jsx("span",{children:"Default"})}),Object.keys(ce).map(e=>s.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${Z===e?"selected":""}`,onClick:()=>je(e),title:ce[e].description,children:s.jsx("span",{children:ce[e].label})},e))]})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:a("terminal:spawn.browser")}),s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:U,onChange:e=>Pe(e.target.checked),disabled:o!=="claude"}),s.jsxs("span",{children:[s.jsx(ie,{name:"globe",size:12})," ",a("terminal:spawn.chromeBrowser")]}),s.jsx(x,{text:a(o==="claude"?"terminal:spawn.helpChrome":"terminal:spawn.helpChromeDisabled"),title:a("terminal:spawn.chromeBrowser"),position:"top",size:"sm"})]})]})]}),o==="codex"&&s.jsxs("div",{className:"codex-config-section",children:[s.jsx("div",{className:"codex-config-title",children:a("terminal:spawn.codex.configuration")}),s.jsxs("div",{className:"codex-config-options",children:[s.jsxs("div",{className:"codex-option-group",children:[s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:f.fullAuto!==!1,onChange:e=>E(n=>({...n,fullAuto:e.target.checked}))}),s.jsx("span",{children:a("terminal:spawn.codex.fullAuto")}),s.jsx(x,{text:a("terminal:spawn.helpFullAuto"),title:a("terminal:spawn.fullAutoTitle"),position:"top",size:"sm"})]}),s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:!!f.search,onChange:e=>E(n=>({...n,search:e.target.checked}))}),s.jsx("span",{children:a("terminal:spawn.codex.search")}),s.jsx(x,{text:a("terminal:spawn.helpSearch"),title:a("terminal:spawn.searchTitle"),position:"top",size:"sm"})]})]}),f.fullAuto===!1&&s.jsxs("div",{className:"codex-option-group",children:[s.jsx("div",{className:"codex-option-header",children:a("terminal:spawn.codex.restrictions")}),s.jsxs("select",{className:"spawn-input codex-select",value:f.sandbox||"workspace-write",onChange:e=>E(n=>({...n,sandbox:e.target.value})),children:[s.jsxs("option",{value:"read-only",children:["📖 ",a("terminal:spawn.codex.sandboxReadOnly")]}),s.jsxs("option",{value:"workspace-write",children:["✏️ ",a("terminal:spawn.codex.sandboxWorkspaceWrite")]}),s.jsxs("option",{value:"danger-full-access",children:["⚡ ",a("terminal:spawn.codex.sandboxDangerFullAccess")]})]}),s.jsxs("select",{className:"spawn-input codex-select",value:f.approvalMode||"on-request",onChange:e=>E(n=>({...n,approvalMode:e.target.value})),children:[s.jsxs("option",{value:"untrusted",children:["🔒 ",a("terminal:spawn.codex.approvalsUntrusted")]}),s.jsxs("option",{value:"on-failure",children:["⚠️ ",a("terminal:spawn.codex.approvalsOnFailure")]}),s.jsxs("option",{value:"on-request",children:["🤔 ",a("terminal:spawn.codex.approvalsOnRequest")]}),s.jsxs("option",{value:"never",children:["✅ ",a("terminal:spawn.codex.approvalsNever")]})]})]}),s.jsxs("div",{className:"codex-option-group",children:[s.jsx("div",{className:"codex-option-header",children:a("terminal:spawn.codex.profile")}),s.jsx("input",{type:"text",className:"spawn-input codex-profile-input",placeholder:a("terminal:spawn.codex.profilePlaceholder"),value:f.profile||"",onChange:e=>E(n=>({...n,profile:e.target.value||void 0}))})]}),s.jsxs("div",{className:"codex-option-group",children:[s.jsx("div",{className:"codex-option-header",children:a("terminal:spawn.codex.reasoningEffort")}),s.jsxs("select",{className:"spawn-input codex-select",value:f.reasoningEffort||"",onChange:e=>E(n=>({...n,reasoningEffort:e.target.value||void 0})),children:[s.jsx("option",{value:"",children:a("terminal:spawn.codex.reasoningEffortDefault")}),Object.keys(re).map(e=>s.jsxs("option",{value:e,children:[re[e].icon," ",re[e].label]},e))]})]})]})]}),w.length>0&&s.jsxs("div",{className:"spawn-skills-section",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.skills")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",a("common:labels.optional"),")"]}),s.jsx(x,{text:a("terminal:spawn.helpSkills"),title:a("terminal:spawn.skillsTitle"),position:"top",size:"sm"})]}),w.length>6&&s.jsx("input",{type:"text",className:"spawn-input skill-search-input",placeholder:a("terminal:spawn.filterSkills"),value:D,onChange:e=>ze(e.target.value)}),s.jsxs("div",{className:"spawn-skills-inline",children:[Se.map(e=>{const n=fe.has(e.id);return We.some(c=>c.id===e.id)?null:s.jsxs("button",{className:`spawn-skill-chip ${n?"selected":""}`,onClick:()=>Ge(e.id),title:e.description,children:[n&&s.jsx("span",{className:"spawn-skill-check",children:s.jsx(ie,{name:"check",size:10})}),s.jsx("span",{children:e.name}),e.builtin&&s.jsx("span",{className:"spawn-skill-builtin",children:"TC"})]},e.id)}),D&&Se.length===0&&s.jsx("div",{className:"skill-search-empty",children:a("terminal:spawn.noSkillsMatch",{query:D})})]})]}),s.jsxs("div",{className:"spawn-custom-instructions-section",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.customInstructions")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",a("common:labels.optional"),")"]}),s.jsx(x,{text:a("terminal:spawn.helpCustomInstructions"),title:a("terminal:spawn.customInstructions"),position:"top",size:"sm"})]}),s.jsx("textarea",{className:"spawn-input spawn-textarea",placeholder:a("terminal:spawn.customInstructionsPlaceholder"),value:Ne,onChange:e=>Ue(e.target.value),rows:3})]}),s.jsxs("div",{className:"spawn-sessions-section",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.linkSession")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",a("common:labels.optional"),")"]}),s.jsx(x,{text:a("terminal:spawn.helpLinkSession"),title:a("terminal:spawn.linkSessionTitle"),position:"top",size:"sm"})]}),y.length>0&&s.jsx("input",{type:"text",className:"spawn-input session-search-input",placeholder:a("terminal:spawn.searchSessions"),value:_,onChange:e=>xe(e.target.value)}),s.jsx("div",{className:"sessions-list",children:$e?s.jsx("div",{className:"sessions-loading",children:a("terminal:spawn.loadingSessions")}):y.length===0?s.jsx("div",{className:"sessions-empty",children:a("terminal:spawn.noSessions")}):be.length===0?s.jsx("div",{className:"sessions-empty",children:a("terminal:spawn.noSessionsMatch",{query:_})}):be.map(e=>{const n=A===e.sessionId,l=Date.now()-new Date(e.lastModified).getTime(),c=l<6e4?a("common:time.justNow"):l<36e5?a("common:time.minutesAgo",{count:Math.floor(l/6e4)}):l<864e5?a("common:time.hoursAgo",{count:Math.floor(l/36e5)}):a("common:time.daysAgo",{count:Math.floor(l/864e5)});return s.jsxs("div",{className:`session-item ${n?"selected":""}`,onClick:()=>{n?O(null):(O(e.sessionId),F(e.projectPath))},children:[s.jsxs("div",{className:"session-item-header",children:[s.jsx("span",{className:"session-item-path",children:e.projectPath}),s.jsx("span",{className:"session-item-age",children:c})]}),s.jsx("div",{className:"session-item-preview",children:e.firstMessage||a("terminal:spawn.messagesCount",{count:e.messageCount})})]},e.sessionId)})})]})]})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:j,children:a("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-primary",onClick:Xe,disabled:pe,children:a(pe?"common:buttons.deploying":"common:buttons2.deploy")})]})]})})}export{hs as SpawnModal};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as y,h as w,ad as l,ca as C,j as s,b5 as S,I as j,bw as N}from"./main-CyZg1kKu.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const d=["#6ab8c8","#c89a5a","#9a80c0","#5cb88a","#c85a5a","#c87a9a","#c8c87a","#5a8fd4","#d45a5a","#8a6fbf"];function V(){const i=new Date;return i.setHours(0,0,0,0),i.getTime()}function b(i){if(!i)return"N/A";try{return new Date(i).toLocaleString()}catch{return"N/A"}}function D(i,n){if(i.length===0||n<=0)return"conic-gradient(rgba(50, 50, 62, 0.95) 0deg 360deg)";let t=0;return`conic-gradient(${i.map((u,e)=>{const m=t,c=u.tokens.total/n*360;return t+=c,`${d[e%d.length]} ${m.toFixed(2)}deg ${t.toFixed(2)}deg`}).join(", ")})`}function T({isOpen:i,onClose:n}){const{t}=y(["terminal","common"]),{handleMouseDown:_,handleClick:u}=w(n),[e,m]=l.useState(null),[c,h]=l.useState(!1),[o,p]=l.useState(null),x=l.useMemo(()=>V(),[]),g=l.useCallback(async()=>{h(!0),p(null);try{const a=await C({since:x,until:Date.now()});m(a)}catch(a){p((a==null?void 0:a.message)||"Error")}finally{h(!1)}},[x]);if(l.useEffect(()=>{i&&g()},[i,g]),!i)return null;const r=(e==null?void 0:e.entries)??[],f=(e==null?void 0:e.totalTokens)??0,v=D(r,f);return s.jsx(S,{children:s.jsx("div",{className:"modal-overlay visible",onMouseDown:_,onClick:u,children:s.jsxs("div",{className:"modal statistics-modal",children:[s.jsxs("div",{className:"modal-header statistics-modal__header",children:[s.jsxs("div",{className:"statistics-modal__title",children:[s.jsx("span",{className:"statistics-modal__icon",children:s.jsx(j,{name:"dashboard",size:15})}),s.jsx("span",{children:t("terminal:statistics.title",{defaultValue:"Statistics"})})]}),s.jsx("button",{className:"modal-close statistics-modal__close",onClick:n,title:t("common:buttons.close"),children:"×"})]}),s.jsx("div",{className:"modal-body statistics-modal__body",children:s.jsxs("section",{className:"statistics-panel",children:[s.jsxs("div",{className:"statistics-panel__header",children:[s.jsxs("div",{children:[s.jsx("h3",{children:t("terminal:statistics.usageByAgent",{defaultValue:"Claude usage today"})}),s.jsx("span",{className:"statistics-panel__subtitle",children:t("terminal:statistics.usageByAgentSubtitle",{defaultValue:"Input + cache creation + cache read + output tokens, deduped by Claude request id"})})]}),s.jsx("button",{type:"button",className:"statistics-panel__refresh",onClick:g,disabled:c,title:t("terminal:statistics.refresh",{defaultValue:"Refresh usage"}),children:s.jsx(j,{name:"refresh",size:14})})]}),c&&!e&&s.jsx("div",{className:"statistics-panel__empty",children:t("terminal:statistics.loading",{defaultValue:"Loading usage..."})}),!c&&o&&s.jsx("div",{className:"statistics-panel__empty statistics-panel__empty--error",children:t("terminal:statistics.error",{defaultValue:"Failed to load usage: {{error}}",error:o})}),!o&&e&&r.length===0&&s.jsx("div",{className:"statistics-panel__empty",children:t("terminal:statistics.empty",{defaultValue:"No Claude token usage found for today."})}),!o&&e&&r.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"statistics-panel__layout",children:[s.jsx("div",{className:"statistics-panel__chart-wrap",children:s.jsx("div",{className:"statistics-panel__pie",style:{background:v},role:"img","aria-label":t("terminal:statistics.pieLabel",{defaultValue:"Claude token usage by agent"}),children:s.jsxs("div",{className:"statistics-panel__pie-hole",children:[s.jsx("strong",{children:N(f)}),s.jsx("span",{children:t("terminal:statistics.total",{defaultValue:"total"})})]})})}),s.jsx("div",{className:"statistics-panel__list",children:r.map((a,k)=>s.jsxs("div",{className:"statistics-panel__row",title:`${a.agentName}: ${a.tokens.total.toLocaleString()} tokens`,children:[s.jsx("span",{className:"statistics-panel__swatch",style:{backgroundColor:d[k%d.length]}}),s.jsxs("div",{className:"statistics-panel__row-main",children:[s.jsx("div",{className:"statistics-panel__row-name",children:a.agentName}),s.jsxs("div",{className:"statistics-panel__row-meta",children:[a.requestCount.toLocaleString()," ",t("terminal:statistics.requests",{defaultValue:"requests"})," / ",a.percent,"%"]})]}),s.jsx("strong",{children:N(a.tokens.total)})]},a.agentId))})]}),s.jsx("div",{className:"statistics-panel__footnote",children:t("terminal:statistics.window",{defaultValue:"Window: {{since}} to {{until}}",since:b(e.since),until:b(e.until)})})]})]})})]})})})}export{T as StatisticsModal};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as L,aj as $,ae as D,r as m,j as s,aT as N,_ as S,I as g,s as J}from"./main-
|
|
1
|
+
import{u as L,aj as $,ae as D,r as m,j as s,aT as N,_ as S,I as g,s as J}from"./main-CyZg1kKu.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function G({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 T=N.boss,h=((j=n.subordinateIds)==null?void 0:j.length)||0,E=i.size,x=JSON.stringify([...n.subordinateIds||[]].sort())!==JSON.stringify([...i].sort());return s.jsx("div",{className:`modal-overlay ${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:T.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),I=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:I.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})," ",E," ",a("terminal:team.subordinates").toLowerCase()]}):s.jsxs("span",{className:"summary-unchanged",children:[h," ",a("terminal:team.subordinates").toLowerCase()]})})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick: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{G as SubordinateAssignmentModal};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aj as Te,r as i,aL as j,l as y,j as e}from"./main-
|
|
1
|
+
import{aj as Te,r as i,aL as j,l as y,j as e}from"./main-CyZg1kKu.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Se=[{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"}],we=[{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:"📱"}],Me=[{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)"}],Be=[{value:"structural",label:"Structural"},{value:"llm",label:"LLM"}];function Ee(k){if(!k)return"";const b=new Date(k);if(Number.isNaN(b.getTime()))return"";const m=g=>String(g).padStart(2,"0");return`${b.getFullYear()}-${m(b.getMonth()+1)}-${m(b.getDate())}T${m(b.getHours())}:${m(b.getMinutes())}`}const L=()=>({name:"",description:"",type:"webhook",agentId:"",promptTemplate:"",enabled:!0,matchMode:"structural",extractionMode:"structural",config:{method:"POST"}});function Oe({isOpen:k,onClose:b}){var G,Y,X,K,Q,Z,ee,te,le,se,ae,ne,ie,re,oe,ce;const m=Te(),[g,de]=i.useState([]),[T,R]=i.useState("list"),[n,v]=i.useState(L()),[x,E]=i.useState(!1),[O,z]=i.useState(!1),[P,u]=i.useState(null),[I,pe]=i.useState([]),[S,xe]=i.useState(null),[A,ue]=i.useState(`{
|
|
2
2
|
|
|
3
3
|
}`),[o,w]=i.useState(null),[D,N]=i.useState(!1),[W,H]=i.useState([]),[M,he]=i.useState("all"),f=i.useCallback(async()=>{try{const l=await j(y("/api/triggers"));if(l.ok){const s=await l.json();de(s)}}catch(l){console.error("Failed to load triggers:",l)}},[]),B=i.useCallback(async l=>{try{const s=await j(y(`/api/triggers/${l}/events?limit=20`));if(s.ok){const a=await s.json();pe(a)}}catch(s){console.error("Failed to load trigger history:",s)}},[]);i.useEffect(()=>{k&&f()},[k,f]),i.useEffect(()=>{S&&B(S)},[S,B]);const be=i.useCallback(async()=>{z(!0),u(null);try{const l=x?y(`/api/triggers/${n.id}`):y("/api/triggers"),h=await j(l,{method:x?"PATCH":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!h.ok){const r=await h.json();throw new Error(r.error||"Failed to save trigger")}await f(),R("list"),v(L()),E(!1)}catch(l){u(l instanceof Error?l.message:"Save failed")}finally{z(!1)}},[n,x,f]),ge=i.useCallback(async l=>{try{await j(y(`/api/triggers/${l}`),{method:"DELETE"}),await f()}catch(s){console.error("Failed to delete trigger:",s)}},[f]),ye=i.useCallback(async l=>{try{await j(y(`/api/triggers/${l.id}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!l.enabled})}),await f()}catch(s){console.error("Failed to toggle trigger:",s)}},[f]),me=i.useCallback(async l=>{try{await j(y(`/api/triggers/${l}/fire`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({variables:{}})}),S===l&&await B(l)}catch(s){console.error("Failed to test fire trigger:",s)}},[S,B]),fe=i.useCallback(async()=>{if(n.id){N(!0),w(null);try{let l;try{l=JSON.parse(A)}catch{w({structuralMatch:void 0,extractedVariables:{},wouldFire:!1}),u("Invalid JSON payload");return}const s=await j(y(`/api/triggers/${n.id}/test-match`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({payload:l})});if(s.ok){const a=await s.json();w(a),u(null)}else{const a=await s.json();u(a.error||"Test match failed")}}catch(l){u(l instanceof Error?l.message:"Test match failed")}finally{N(!1)}}},[n.id,A]),je=i.useCallback(async l=>{var s;try{const a=await j(y("/api/triggers/validate-cron"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({expression:l,timezone:((s=n.config)==null?void 0:s.timezone)||"UTC"})});if(a.ok){const h=await a.json();H(h.valid?h.nextFires:[])}}catch{H([])}},[n]),U=i.useCallback(l=>{l?(v({...l}),E(!0)):(v(L()),E(!1)),w(null),u(null),R("edit")},[]),c=i.useCallback((l,s)=>{v(a=>({...a,[l]:s}))},[]),d=i.useCallback((l,s)=>{v(a=>({...a,config:{...a.config,[l]:s}}))},[]),F=i.useCallback((l,s)=>{v(a=>({...a,llmMatch:{...a.llmMatch||{prompt:""},[l]:s}}))},[]),_=i.useCallback((l,s)=>{v(a=>({...a,llmExtract:{...a.llmExtract||{prompt:"",variables:[]},[l]:s}}))},[]),ve=i.useMemo(()=>Array.from(m.values()).map(l=>({id:l.id,name:l.name,class:l.class})),[m]),ke=i.useMemo(()=>{const l={all:g.length,webhook:0,bitbucket:0,cron:0,slack:0,email:0,jira:0,whatsapp:0};for(const s of g)s.type in l&&(l[s.type]+=1);return l},[g]),$=i.useMemo(()=>M==="all"?g:g.filter(l=>l.type===M),[g,M]),[J,q]=i.useState(null),V=i.useCallback((l,s)=>{l&&navigator.clipboard.writeText(l).then(()=>{q(s),setTimeout(()=>q(a=>a===s?null:a),1500)},()=>u("Failed to copy to clipboard"))},[]);return k?e.jsx("div",{style:t.overlay,onClick:b,children:e.jsxs("div",{style:t.panel,onClick:l=>l.stopPropagation(),children:[e.jsxs("div",{style:t.header,children:[e.jsx("h2",{style:t.title,children:T==="list"?"Triggers":x?"Edit Trigger":"New Trigger"}),e.jsxs("div",{style:t.headerActions,children:[T==="list"&&e.jsx("button",{style:t.addBtn,onClick:()=>U(),children:"+ New Trigger"}),T==="edit"&&e.jsx("button",{style:t.backBtn,onClick:()=>{R("list"),w(null),u(null)},children:"Back"}),e.jsx("button",{style:t.closeBtn,onClick:b,children:"X"})]})]}),P&&e.jsx("div",{style:t.error,children:P}),T==="list"&&e.jsxs("div",{style:t.content,children:[e.jsx("div",{style:t.tabBar,role:"tablist","aria-label":"Filter triggers by type",children:we.map(l=>{const s=ke[l.value],a=M===l.value;return e.jsxs("button",{role:"tab","aria-selected":a,onClick:()=>he(l.value),style:{...t.tab,...a?t.tabActive:{}},title:`${l.label} (${s})`,children:[e.jsx("span",{style:t.tabIcon,children:l.icon}),e.jsx("span",{style:t.tabLabel,children:l.label}),e.jsx("span",{style:{...t.tabBadge,...a?t.tabBadgeActive:{}},children:s})]},l.value)})}),g.length===0?e.jsx("div",{style:t.empty,children:"No triggers configured. Create one to get started."}):$.length===0?e.jsxs("div",{style:t.empty,children:["No ",M," triggers configured yet."]}):$.map(l=>{var s;return e.jsxs("div",{style:{...t.triggerCard,borderLeftColor:l.status==="error"?"#e74c3c":l.enabled?"#2ecc71":"#95a5a6"},onClick:()=>{xe(l.id),U(l)},children:[e.jsxs("div",{style:t.cardHeader,children:[e.jsxs("div",{style:t.cardTitle,children:[e.jsx("span",{style:t.typeTag,children:l.type}),e.jsx("span",{children:l.name}),l.type==="cron"&&(()=>{const a=l.config||{};return a.runOnce?a.completedAt?e.jsx("span",{style:{...t.matchTag,color:"#a6e3a1"},children:"Once · completed"}):a.missedAt?e.jsx("span",{style:{...t.matchTag,color:"#f38ba8"},children:"Once · missed"}):e.jsx("span",{style:{...t.matchTag,color:"#f9e2af"},children:"Once · pending"}):e.jsx("span",{style:t.matchTag,children:"Recurring"})})(),l.matchMode!=="structural"&&e.jsx("span",{style:t.matchTag,children:l.matchMode})]}),e.jsxs("div",{style:t.cardActions,children:[e.jsx("button",{style:t.smallBtn,onClick:a=>{a.stopPropagation(),ye(l)},children:l.enabled?"Disable":"Enable"}),e.jsx("button",{style:t.smallBtn,onClick:a=>{a.stopPropagation(),me(l.id)},children:"Test Fire"}),e.jsx("button",{style:{...t.smallBtn,color:"#e74c3c"},onClick:a=>{a.stopPropagation(),ge(l.id)},children:"Delete"})]})]}),e.jsxs("div",{style:t.cardMeta,children:[e.jsxs("span",{children:["Agent: ",((s=m.get(l.agentId))==null?void 0:s.name)||l.agentId]}),e.jsxs("span",{children:["Fires: ",l.fireCount]}),l.lastFiredAt&&e.jsxs("span",{children:["Last: ",new Date(l.lastFiredAt).toLocaleString()]}),l.status==="error"&&l.lastError&&e.jsxs("span",{style:{color:"#e74c3c"},children:["Error: ",l.lastError]})]})]},l.id)})]}),T==="edit"&&e.jsx("div",{style:t.content,children:e.jsxs("div",{style:t.form,children:[e.jsxs("div",{style:t.field,children:[e.jsx("label",{style:t.label,children:"Name"}),e.jsx("input",{style:t.input,value:n.name||"",onChange:l=>c("name",l.target.value),placeholder:"My Trigger"})]}),e.jsxs("div",{style:t.field,children:[e.jsx("label",{style:t.label,children:"Description"}),e.jsx("input",{style:t.input,value:n.description||"",onChange:l=>c("description",l.target.value),placeholder:"Optional description"})]}),e.jsxs("div",{style:t.row,children:[e.jsxs("div",{style:t.field,children:[e.jsx("label",{style:t.label,children:"Type"}),e.jsx("select",{style:t.select,value:n.type||"webhook",onChange:l=>{const s=l.target.value;c("type",s),s==="webhook"?c("config",{method:"POST"}):s==="cron"?c("config",{expression:"0 9 * * MON-FRI",timezone:"UTC"}):s==="bitbucket"?c("config",{workspace:"",repoSlug:"",events:["pullrequest:created","pullrequest:updated"]}):c("config",{}),(n.promptTemplate??"").trim()||(s==="slack"?c("promptTemplate",`Slack message from {{slack.user}} in {{slack.channelName}}:
|
|
4
4
|
{{slack.message}}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as x,aL as M,l as P,j as e,aj as J}from"./main-
|
|
1
|
+
import{r as x,aL as M,l as P,j as e,aj as J}from"./main-CyZg1kKu.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,4 +1,4 @@
|
|
|
1
|
-
import{bp as He,r as t,s as I,l as ye,bq as Ee,aL as _e,j as e,I as z,u as fe,br as ze,bs as Te,bt as Ue,bu as Be,m as Ke,bv as We,bw as De,bx as Ve,a7 as qe,a8 as Ge,a9 as Je,aU as Ye,J as Me,S as ce,aO as Xe,aK as Qe,_ as Ze,K as Ie,aj as et,U as tt,by as st,n as X,bz as nt}from"./main-
|
|
1
|
+
import{bp as He,r as t,s as I,l as ye,bq as Ee,aL as _e,j as e,I as z,u as fe,br as ze,bs as Te,bt as Ue,bu as Be,m as Ke,bv as We,bw as De,bx as Ve,a7 as qe,a8 as Ge,a9 as Je,aU as Ye,J as Me,S as ce,aO as Xe,aK as Qe,_ as Ze,K as Ie,aj as et,U as tt,by as st,n as X,bz as nt}from"./main-CyZg1kKu.js";import{FileExplorerPanel as at}from"./index-y3mA_lBK.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Ne={status:"all",activity:"all",sort:"activity"},lt={"1h":3600*1e3,"6h":360*60*1e3,"24h":1440*60*1e3},Ae=20,me=3,ct={idle:"#4aff9e",working:"#4a9eff",waiting:"#ff9e4a",waiting_permission:"#ffcc00",error:"#ff4a4a",offline:"#888888",orphaned:"#ff9e4a"},ot=12e4;function rt(s){return s.trim().replace(/\r\n/g,`
|
|
2
2
|
`)}function $e(s,a){return`${s}:${rt(a)}`}function it(s,a,l,f){if(s.uuid&&a.has(s.uuid))return!1;if(s.uuid)return!0;const p=s.isUserPrompt?"user":"assistant",d=$e(p,s.text),M=s.timestamp||0,A=l.get(d);return A!==void 0&&Math.abs(M-A)<=ot?!1:M>f}function dt({isOpen:s,agents:a}){const l=He(),[f,p]=t.useState(new Map),d=t.useRef(new Set);t.useRef(a);const M=t.useMemo(()=>Array.from(a.keys()).sort().join(","),[a]),A=t.useMemo(()=>Array.from(a.values()).map(j=>`${j.id}:${j.sessionId||""}`).sort().join(","),[a]);t.useEffect(()=>{s||(d.current.clear(),p(new Map))},[s]),t.useEffect(()=>{if(!s)return;const j=new Set(Array.from(a.keys()));for(const i of d.current)j.has(i)||d.current.delete(i);let h=null;l>0&&(h=I.preserveOutputs(),d.current.clear());const v=async(i,C,F=0)=>{if(d.current.add(i.id),F>0&&await new Promise(x=>setTimeout(x,F)),p(x=>{const k=new Map(x);return k.set(i.id,{agentId:i.id,messages:[],loading:!0,hasMore:!1,totalCount:0}),k}),!i.sessionId){C&&C.length>0&&I.mergeOutputsWithHistory(i.id,[],C),p(x=>{const k=new Map(x);return k.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),k});return}try{const k=await(await _e(ye(`/api/agents/${i.id}/history?limit=${Ee}&offset=0`))).json(),P=k.messages||[],W=P.length>0?Math.max(...P.map(w=>w.timestamp?new Date(w.timestamp).getTime():0)):0,J=new Set(P.map(w=>w.uuid).filter(w=>!!w)),V=new Map;for(const w of P){if(w.type!=="user"&&w.type!=="assistant")continue;const 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 q=I.getOutputs(i.id),B=(C&&C.length>0?[...C,...q]:q).filter(w=>it(w,J,V,W));I.clearOutputs(i.id);for(const w of B)I.addOutput(i.id,w);p(w=>{const o=new Map(w);return o.set(i.id,{agentId:i.id,messages:P,loading:!1,hasMore:k.hasMore||!1,totalCount:k.totalCount||0}),o})}catch(x){if(console.error(`Failed to load history for ${i.name}:`,x),C&&C.length>0){I.clearOutputs(i.id);for(const k of C)I.addOutput(i.id,k)}p(k=>{const P=new Map(k);return P.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),P})}},u=l>0?500:0,D=Array.from(a.values());for(const i of D)if(!d.current.has(i.id)){const C=h==null?void 0:h.get(i.id);v(i,C,u)}},[s,M,A,l]);const R=t.useRef(a),N=t.useRef(f);R.current=a,N.current=f;const b=t.useCallback(async j=>{const h=R.current.get(j),v=N.current.get(j);if(!(h!=null&&h.sessionId)||!v||!v.hasMore)return;const u=v.messages.length;try{const i=await(await fetch(ye(`/api/agents/${j}/history?limit=${Ee}&offset=${u}`))).json();i.messages&&i.messages.length>0&&p(C=>{const F=new Map(C),x=C.get(j);return x&&F.set(j,{...x,messages:[...i.messages,...x.messages],hasMore:i.hasMore||!1}),F})}catch(D){console.error(`Failed to load more history for agent ${j}:`,D)}},[]),E=t.useCallback(j=>{d.current.delete(j),p(h=>{const v=new Map(h),u=h.get(j);return u&&v.set(j,{...u,messages:[],hasMore:!1,totalCount:0,loading:!1}),v})},[]);return{histories:f,loadMoreHistory:b,clearAgentHistory:E}}function ut({command:s,onCommandChange:a,useTextarea:l,forceTextarea:f,onForceTextarea:p,onSend:d,canSend:M,attachedFiles:A,onAddFile:R,onRemoveFile:N,uploadFile:b,onAddPastedText:E,placeholder:j="Message...",className:h="",compact:v=!1,inputRef:u}){const D=t.useRef(null),i=t.useRef(null),C=t.useRef(l);t.useEffect(()=>{if(l&&!C.current&&i.current){const o=i.current;o.focus(),o.selectionStart=o.selectionEnd=o.value.length}C.current=l},[l]),t.useEffect(()=>{const o=i.current;if(!o||!l)return;o.style.height="auto";const L=v?120:180,K=Math.min(o.scrollHeight,L);o.style.height=`${K}px`},[s,l,v]);const F=t.useCallback(async o=>{const L=o.clipboardData.items;for(const _ of L)if(_.type.startsWith("image/")){o.preventDefault();const $=_.getAsFile();if($){const O=await b($);O&&R(O)}return}const K=o.clipboardData.files;if(K.length>0){o.preventDefault();for(const _ of K){const $=await b(_);$&&R($)}return}const U=o.clipboardData.getData("text"),te=(U.match(/\n/g)||[]).length+1;if(te>5){o.preventDefault();const $=`[Pasted text #${E(U)} +${te} lines]`,O=o.target,se=O.selectionStart||0,ae=O.selectionEnd||0,ne=s.slice(0,se)+$+s.slice(ae);a(ne),l||p(!0)}},[s,a,l,p,b,R,E]),x=t.useCallback(async o=>{const L=o.target.files;if(L){for(const K of L){const U=await b(K);U&&R(U)}D.current&&(D.current.value="")}},[b,R]),k=t.useCallback(o=>{if(o.key==="Enter"&&o.shiftKey){l||(o.preventDefault(),p(!0));return}o.key==="Enter"&&(o.preventDefault(),d())},[l,p,d]),P=t.useCallback(o=>{},[]),W=t.useCallback(o=>{o.button===1&&(o.preventDefault(),o.stopPropagation())},[]),J=t.useCallback(o=>{i.current=o,u==null||u(o)},[u]),V=v?"agent-panel-input":"guake-input",q=v?"agent-panel-input-container":"guake-input-container",Q=v?"agent-panel-attach-btn":"guake-attach-btn",B=v?"agent-panel-send-btn":"",w=l?v?"agent-panel-input-expanded":"guake-input-expanded":"";return e.jsxs(e.Fragment,{children:[A.length>0&&e.jsx("div",{className:v?"agent-panel-attachments":"guake-attachments",children:A.map(o=>e.jsxs("div",{className:`${v?"agent-panel-attachment":"guake-attachment"} ${o.isImage?"is-image":""}`,children:[e.jsx("span",{className:v?"agent-panel-attachment-icon":"guake-attachment-icon",children:e.jsx(z,{name:o.isImage?"file":"paperclip",size:12})}),e.jsx("span",{className:v?"agent-panel-attachment-name":"guake-attachment-name",title:o.path,children:o.name}),!v&&e.jsxs("span",{className:"guake-attachment-size",children:["(",Math.round(o.size/1024),"KB)"]}),e.jsx("button",{className:v?"agent-panel-attachment-remove":"guake-attachment-remove",onClick:()=>N(o.id),title:"Remove",children:"×"})]},o.id))}),e.jsxs("div",{className:`${V} ${w} ${h}`,children:[e.jsx("input",{ref:D,type:"file",multiple:!0,onChange:x,style:{display:"none"},accept:"*"}),e.jsxs("div",{className:q,onAuxClick:W,children:[e.jsx("button",{className:Q,onClick:()=>{var o;return(o=D.current)==null?void 0:o.click()},title:"Attach file (or paste image)",children:e.jsx(z,{name:"paperclip",size:14})}),l?e.jsx("textarea",{ref:J,placeholder:j,value:s,onChange:o=>a(o.target.value),onKeyDown:k,onPaste:F,onMouseDown:P}):e.jsx("input",{ref:u,type:"text",placeholder:j,value:s,onChange:o=>a(o.target.value),onKeyDown:k,onPaste:F,onMouseDown:P}),e.jsx("button",{className:B,onClick:d,disabled:!M,title:"Send",children:e.jsx(z,{name:"send",size:14})})]})]})]})}function mt(s){const a=Math.floor(s/1e3),l=Math.floor(a/60),f=a%60;return`${l}:${f.toString().padStart(2,"0")}`}const ft=t.memo(function({agentId:a,isWorking:l,timestamp:f}){const{t:p}=fe(["terminal"]),[d,M]=t.useState(0);return t.useEffect(()=>{if(!l||!f){M(0);return}M(Date.now()-f);const A=setInterval(()=>{M(Date.now()-f)},1e3);return()=>clearInterval(A)},[l,f]),l?e.jsxs("div",{className:"guake-stop-bar",children:[e.jsx("span",{className:"guake-elapsed-timer",children:mt(d)}),e.jsxs("button",{className:"guake-stop-btn",onClick:()=>I.stopAgent(a),title:p("terminal:input.stopOperation"),children:[e.jsx("span",{className:"stop-icon",children:e.jsx(z,{name:"stop",size:12,weight:"fill"})}),e.jsx("span",{className:"stop-label",children:p("terminal:input.stop")})]})]}):null});function pt({agent:s,history:a,outputs:l,isExpanded:f,isFocused:p,advancedView:d,onExpand:M,onFocus:A,inputRef:R,onLoadMore:N,onClearHistory:b}){const{t:E}=fe(["terminal","common"]),j=ze(s.id),h=t.useRef(null),[v,u]=t.useState(!1),D=t.useRef(0),i=t.useRef(!1),[C,F]=t.useState(!0),[x,k]=t.useState(!1),[P,W]=t.useState(null),[J,V]=t.useState(null),[q,Q]=t.useState(null);Te(`commander-image-modal-${s.id}`,P!==null,()=>W(null));const{command:B,setCommand:w,forceTextarea:o,setForceTextarea:L,useTextarea:K,setPastedTexts:U,incrementPastedCount:te,resetPastedCount:_,attachedFiles:$,setAttachedFiles:O,removeAttachedFile:se,uploadFile:ae,expandPastedTexts:ne}=Ue({selectedAgentId:s.id}),le=B.trim().length>0||$.length>0,n=Be({outputs:l,viewMode:d?"advanced":"simple"}),c=t.useMemo(()=>{const S=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)&&N&&(u(!0),D.current=h.current?h.current.scrollHeight-h.current.scrollTop:0,N())},[v,a==null?void 0:a.hasMore,N]);t.useEffect(()=>{v&&a&&!a.loading&&u(!1)},[a,v]);const m=t.useCallback(()=>{i.current=!0,F(!1)},[]),T=t.useRef(f),Z=t.useRef(p);t.useEffect(()=>{(f&&!T.current||p&&!Z.current)&&(i.current=!1,F(!0),k(!0)),T.current=f,Z.current=p},[f,p]);const ee=t.useRef(a==null?void 0:a.loading);t.useEffect(()=>{ee.current&&!(a!=null&&a.loading)&&(i.current=!1,F(!0),k(!0)),ee.current=a==null?void 0:a.loading},[a==null?void 0:a.loading]),t.useEffect(()=>{if(!x)return;const S=h.current;if(!S)return;const y=performance.now();let H=0,ue=-1,ke;const Re=()=>{const{scrollTop:Fe,scrollHeight:Se,clientHeight:Le}=S,Oe=Se-Fe-Le<=2;if(Math.abs(Se-ue)<=1&&Oe?H+=1:H=0,ue=Se,H>=3){k(!1);return}if(performance.now()-y>5e3){k(!1);return}ke=requestAnimationFrame(Re)};return ke=requestAnimationFrame(Re),()=>cancelAnimationFrame(ke)},[x]),t.useEffect(()=>{i.current||F(!0)},[n.length]);const G=t.useCallback(()=>!1,[]),ie=t.useCallback(S=>{const y=te();return U(H=>new Map(H).set(y,S)),y},[te,U]),he=t.useCallback(S=>{O(y=>[...y,S])},[O]),xe=t.useCallback(()=>{if(!le)return;if(B.trim()==="/clear"&&$.length===0){I.clearContext(s.id),b(),w(""),L(!1),U(new Map),O([]),_();return}let S=ne(B.trim());if($.length>0){const y=$.map(H=>H.isImage?`[Image: ${H.path}]`:`[File: ${H.path}]`).join(`
|
|
3
3
|
`);S=S?`${S}
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ad as as,u as ts,at as vs,au as bs,av as zs,j as s,I as F,_ as Is,aw as Es,ax as $s,ay as Ds,az as Ms,r as c,a3 as Ls,aj as Ss,W as Xs,U as Ps,H as Rs,aA as Ys,aB as Us,aC as Gs,aD as ms,aE as _s,s as M,aF as Fs,n as G}from"./main-BxA3Bhkv.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const fs=as.memo(({agent:a,isSelected:A,isKeyboardFocused:L=!1,onSelect:S,onDoubleClick:n,onChat:g,onFocus:h,onKill:w,onDragStart:X})=>{const{t:x}=ts(["dashboard","common"]),P=vs().has(a.id),N=bs(a.status),H=zs(a),j=Ms(H),I=a.taskLabel?s.jsxs(s.Fragment,{children:[s.jsx(F,{name:"task",size:12})," ",a.taskLabel]}):a.currentTask||a.lastAssignedTask,m=a.status==="idle"&&a.lastActivity>0,[,B]=as.useState(0);return as.useEffect(()=>{if(!m)return;const b=window.setInterval(()=>B(T=>T+1),15e3);return()=>window.clearInterval(b)},[m]),s.jsxs("div",{className:`dash-card dash-card--${N} ${A?"dash-card--selected":""} ${L?"dash-card--keyboard-focused":""}`,"data-agent-id":a.id,onClick:S,onDoubleClick:b=>{b.stopPropagation(),n()},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(Is,{agent:a,size:14})," ",a.class]}),s.jsxs("span",{className:`dash-card__provider dash-card__provider--${a.provider}`,children:[s.jsx(F,{name:a.provider==="codex"||a.provider==="opencode"?"status-pending":"robot",size:11,weight:a.provider==="codex"||a.provider==="opencode"?"fill":"regular",color:a.provider==="codex"?"#a16207":a.provider==="opencode"?"#4ade80":void 0})," ",a.provider]}),P&&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:P?"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:`${H}%`}})}),s.jsxs("span",{className:`dash-card__context-pct dash-card__context-pct--${j}`,children:[H,"%"]})]})]}),s.jsxs("div",{className:"dash-card__row3",children:[s.jsxs("span",{className:"dash-card__workdir",title:a.cwd,children:[s.jsx(F,{name:"folder",size:11})," ",a.cwd.split("/").pop()||a.cwd]}),m&&s.jsxs("span",{className:"dash-card__idle-time",style:{color:Ds(a.lastActivity)},title:$s(a.lastActivity),children:[s.jsx(F,{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()},title:x("cards.openTerminal"),children:x("cards.chat")}),w&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--danger",onClick:b=>{b.stopPropagation(),w()},title:x("cards.killAgent"),children:x("cards.stop")})]})]})});fs.displayName="AgentCard";const ws=({buildings:a,onSelectBuilding:A})=>{const{t:L}=ts(["dashboard"]),S=c.useMemo(()=>Array.from(a.values()).sort((n,g)=>n.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:L("buildings.title")}),s.jsx("span",{className:"dashboard-view__buildings-count",children:S.length})]}),s.jsx("div",{className:"dashboard-view__buildings-row",children:S.map(n=>{const g=bs(n.status),h=Ls(n.type);return s.jsxs("button",{className:`dash-pill dash-pill--${g}`,onClick:()=>A==null?void 0:A(n.id),title:`${n.name} (${n.type}) - ${n.status}`,children:[s.jsx("span",{className:"dash-pill__icon",children:s.jsx(F,{name:h,size:14})}),s.jsx("span",{className:"dash-pill__name",children:n.name}),s.jsx("span",{className:`dash-pill__dot dash-pill__dot--${g}`})]},n.id)})})]})};ws.displayName="BuildingPills";function Zs({onSelectAgent:a,onFocusAgent:A,onKillAgent:L,onSelectBuilding:S,onOpenTerminal:n,onFocusZone:g}){const{t:h}=ts(["dashboard","common"]),w=Ss(),X=Xs(),x=Ps(),rs=Rs(),P=vs(),[N,H]=c.useState(""),[j,I]=c.useState("all"),[m,B]=c.useState("zone"),[b,T]=c.useState(new Set),[k,J]=c.useState(null),[ps,Z]=c.useState(null),[R,Q]=c.useState(!1),[p,W]=c.useState(null),K=c.useMemo(()=>{const e=Array.from(w.values());return{total:e.length,working:e.filter(i=>i.status==="working"||i.status==="waiting"||i.status==="waiting_permission").length,idle:e.filter(i=>i.status==="idle").length,error:e.filter(i=>i.status==="error"||i.status==="offline"||i.status==="orphaned").length}},[w]),ns=c.useMemo(()=>m==="zone"?Ys(w,x):m==="status"?Us(w,P):Gs(w),[w,x,m,P]),V=c.useMemo(()=>{const e=N.toLowerCase().trim(),i=ns.map(l=>({...l,agents:l.agents.filter(_=>{if(j==="working"){if(_.status!=="working"&&_.status!=="waiting"&&_.status!=="waiting_permission")return!1}else if(j==="error"&&_.status!=="error"&&_.status!=="offline"&&_.status!=="orphaned")return!1;return!(e&&!_.name.toLowerCase().includes(e)&&!_.class.toLowerCase().includes(e))})}));return m==="zone"?i:i.filter(l=>l.agents.length>0)},[ns,j,N,m]),O=c.useCallback(e=>e.area?`area:${e.area.id}`:`${m}:${e.label}`,[m]),C=c.useMemo(()=>{const e=[];return V.forEach(i=>{const l=O(i);if(b.has(l))return;const _=m==="status"?ms(i.agents,{prioritizeRecentlyIdle:!0}):_s(i.agents);e.push(..._)}),e},[V,b,m,O]),gs=c.useCallback(e=>{T(i=>{const l=new Set(i);return l.has(e)?l.delete(e):l.add(e),l})},[]),xs=c.useCallback(e=>{n==null||n(e)},[n]),js=c.useCallback(e=>{J(e)},[]),Ns=c.useCallback((e,i)=>{e.preventDefault(),e.dataTransfer.dropEffect="move",Z(i)},[]),ks=c.useCallback(()=>{Z(null)},[]),Cs=c.useCallback(e=>{if(!k)return;if(e===null){const E=M.getState(),t=Array.from(E.areas.values()).find(r=>r.assignedAgentIds.includes(k.id));t&&M.unassignAgentFromArea(k.id,t.id),J(null),Z(null);return}const i=x.get(e);if(!i)return;const l=Array.from(w.values()),_=Fs(i,l,k.position);M.updateAgent({...k,position:{...k.position,x:_.x,z:_.z}}),M.assignAgentToArea(k.id,e),J(null),Z(null)},[k,x,w]);return c.useEffect(()=>{if(C.length===0){Q(!1),W(null);return}R&&(!p||!C.some(e=>e.id===p))&&(W(C[0].id),a==null||a(C[0].id))},[C,R,p,a]),c.useEffect(()=>{const e=t=>t instanceof HTMLElement?t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"||t.isContentEditable:!1,i=t=>t instanceof HTMLElement?!!t.closest(".guake-terminal")||t.classList.contains("guake-input")||t.classList.contains("agent-panel-input"):!1,l=t=>{const r=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).find(z=>z.dataset.agentId===t);r==null||r.scrollIntoView({block:"nearest",inline:"nearest"})},_=(t,r)=>{var ds,os,cs,ls,us,hs;const z=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).map(d=>{const u=d.dataset.agentId;if(!u)return null;const y=d.getBoundingClientRect();return{id:u,centerX:y.left+y.width/2,centerY:y.top+y.height/2,height:y.height}}).filter(d=>d!==null).sort((d,u)=>d.centerY-u.centerY||d.centerX-u.centerX);if(z.length===0)return t;const ss=z.reduce((d,u)=>d+u.height,0)/z.length,es=Math.max(18,ss*.6),f=[];for(const d of z){const u=f[f.length-1];if(!u){f.push([{id:d.id,centerX:d.centerX,centerY:d.centerY}]);continue}const y=u.reduce((ys,As)=>ys+As.centerY,0)/u.length;Math.abs(d.centerY-y)<=es?u.push({id:d.id,centerX:d.centerX,centerY:d.centerY}):f.push([{id:d.id,centerX:d.centerX,centerY:d.centerY}])}f.forEach(d=>d.sort((u,y)=>u.centerX-y.centerX));const Y=f.findIndex(d=>d.some(u=>u.id===t));if(Y===-1)return((os=(ds=f[0])==null?void 0:ds[0])==null?void 0:os.id)??t;const $=f[Y],v=$.findIndex(d=>d.id===t);if(v===-1)return((ls=(cs=f[0])==null?void 0:cs[0])==null?void 0:ls.id)??t;if(r==="left")return((us=$[Math.max(0,v-1)])==null?void 0:us.id)??t;if(r==="right")return((hs=$[Math.min($.length-1,v+1)])==null?void 0:hs.id)??t;const q=r==="up"?Math.max(0,Y-1):Math.min(f.length-1,Y+1),o=f[q],U=$[v].centerX;let D=o[0],is=Math.abs(D.centerX-U);for(const d of o){const u=Math.abs(d.centerX-U);u<is&&(D=d,is=u)}return(D==null?void 0:D.id)??t},E=t=>{const r=M.getShortcuts(),z=r.find(o=>o.id==="dashboard-selector-toggle"),ss=r.find(o=>o.id==="dashboard-vim-left"),es=r.find(o=>o.id==="dashboard-vim-down"),f=r.find(o=>o.id==="dashboard-vim-up"),Y=r.find(o=>o.id==="dashboard-vim-right"),$=r.find(o=>o.id==="open-terminal"),v=M.getState();if(e(t.target))if(!v.terminalOpen&&i(t.target)&&document.activeElement instanceof HTMLElement)document.activeElement.blur();else return;if(G(t,z)){if(C.length===0)return;t.preventDefault(),t.stopPropagation(),Q(!0),W(o=>{const U=o&&C.some(D=>D.id===o)?o:C[0].id;return a==null||a(U),window.setTimeout(()=>l(U),0),U});return}const q=G(t,ss)||t.key==="ArrowLeft"?"left":G(t,es)||t.key==="ArrowDown"?"down":G(t,f)||t.key==="ArrowUp"?"up":G(t,Y)||t.key==="ArrowRight"?"right":null;if(q&&R&&p){t.preventDefault(),t.stopPropagation();const o=_(p,q);o!==p&&(W(o),a==null||a(o),window.setTimeout(()=>l(o),0));return}if(G(t,$)){if(v.terminalOpen)return;if(R&&p&&v.agents.has(p)){t.preventDefault(),n==null||n(p);return}if(v.selectedAgentIds.size===1){t.preventDefault();const o=Array.from(v.selectedAgentIds)[0];n==null||n(o);return}if(v.lastSelectedAgentId&&v.agents.has(v.lastSelectedAgentId)){t.preventDefault(),n==null||n(v.lastSelectedAgentId);return}}};return document.addEventListener("keydown",E,!0),()=>document.removeEventListener("keydown",E,!0)},[C,R,p,n,a]),c.useEffect(()=>{const e=document.activeElement;e instanceof HTMLElement&&e.closest(".guake-terminal")&&!M.getState().terminalOpen&&e.blur()},[]),s.jsxs("div",{className:"dashboard-view",children:[s.jsxs("div",{className:"dashboard-view__topbar",children:[s.jsxs("div",{className:"dashboard-view__metrics",children:[s.jsxs("button",{className:`dashboard-view__metric-btn ${j==="all"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.total}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:labels.agents")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--working ${j==="working"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("working"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.working}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.working")})]}),s.jsxs("button",{className:"dashboard-view__metric-btn dashboard-view__metric-btn--idle ",onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.idle}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.idle")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--error ${j==="error"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("error"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.error}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.error")})]})]}),s.jsx("input",{className:"dashboard-view__search",type:"text",placeholder:h("searchPlaceholder"),value:N,onChange:e=>H(e.target.value)})]}),s.jsxs("div",{className:"dashboard-view__grouping",children:[s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="zone"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>B("zone"),children:h("grouping.byZone")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="status"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>B("status"),children:h("grouping.byStatus")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="activity"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>B("activity"),children:h("grouping.byActivity")})]}),s.jsxs("div",{className:"dashboard-view__content",children:[V.map(e=>{const i=O(e),l=b.has(i),_=m==="status"?ms(e.agents,{prioritizeRecentlyIdle:!0}):_s(e.agents),E=e.agents.filter(r=>r.status==="working"||r.status==="waiting"||r.status==="waiting_permission").length,t=e.agents.filter(r=>P.has(r.id)).length;return s.jsxs("div",{className:`dashboard-view__zone ${ps===(e.area?e.area.id:null)&&k?"dashboard-view__zone--drag-over":""}`,onDragOver:r=>Ns(r,e.area?e.area.id:null),onDragLeave:ks,onDrop:()=>Cs(e.area?e.area.id:null),children:[s.jsxs("div",{className:"dashboard-view__zone-header",onClick:()=>gs(i),children:[s.jsxs("div",{className:"dashboard-view__zone-left",children:[s.jsx("span",{className:`dashboard-view__zone-chevron ${l?"dashboard-view__zone-chevron--collapsed":""}`,children:s.jsx(F,{name:"caret-down",size:12})}),s.jsx("span",{className:"dashboard-view__zone-dot",style:{backgroundColor:e.color}}),s.jsx("span",{className:"dashboard-view__zone-name",children:e.label}),s.jsxs("span",{className:"dashboard-view__zone-count",children:[h("agentCount",{count:e.agents.length}),E>0&&s.jsxs("span",{className:"dashboard-view__zone-working",children:[" · ",E," ",h("working")]}),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:r=>{r.stopPropagation(),g(e.area.id)},title:h("focusZone"),children:h("focusZone")})]}),!l&&s.jsx("div",{className:"dashboard-view__zone-grid",children:_.map(r=>s.jsx(fs,{agent:r,isSelected:rs.has(r.id),isKeyboardFocused:R&&p===r.id,onSelect:()=>{a==null||a(r.id),Q(!0),W(r.id)},onDoubleClick:()=>xs(r.id),onChat:()=>n==null?void 0:n(r.id),onFocus:A?()=>A(r.id):void 0,onKill:L?()=>L(r.id):void 0,onDragStart:js},r.id))})]},i)}),V.length===0&&s.jsx("div",{className:"dashboard-view__empty",children:N?h("noAgentsMatching",{search:N}):h("noAgentsSpawned")}),X.size>0&&s.jsx(ws,{buildings:X,onSelectBuilding:S})]})]})}export{Zs as DashboardView};
|
|
1
|
+
import{ad as as,u as ts,at as vs,au as bs,av as zs,j as s,I as F,_ as Is,aw as Es,ax as $s,ay as Ds,az as Ms,r as c,a3 as Ls,aj as Ss,W as Xs,U as Ps,H as Rs,aA as Ys,aB as Us,aC as Gs,aD as ms,aE as _s,s as M,aF as Fs,n as G}from"./main-CyZg1kKu.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const fs=as.memo(({agent:a,isSelected:A,isKeyboardFocused:L=!1,onSelect:S,onDoubleClick:n,onChat:g,onFocus:h,onKill:w,onDragStart:X})=>{const{t:x}=ts(["dashboard","common"]),P=vs().has(a.id),N=bs(a.status),H=zs(a),j=Ms(H),I=a.taskLabel?s.jsxs(s.Fragment,{children:[s.jsx(F,{name:"task",size:12})," ",a.taskLabel]}):a.currentTask||a.lastAssignedTask,m=a.status==="idle"&&a.lastActivity>0,[,B]=as.useState(0);return as.useEffect(()=>{if(!m)return;const b=window.setInterval(()=>B(T=>T+1),15e3);return()=>window.clearInterval(b)},[m]),s.jsxs("div",{className:`dash-card dash-card--${N} ${A?"dash-card--selected":""} ${L?"dash-card--keyboard-focused":""}`,"data-agent-id":a.id,onClick:S,onDoubleClick:b=>{b.stopPropagation(),n()},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(Is,{agent:a,size:14})," ",a.class]}),s.jsxs("span",{className:`dash-card__provider dash-card__provider--${a.provider}`,children:[s.jsx(F,{name:a.provider==="codex"||a.provider==="opencode"?"status-pending":"robot",size:11,weight:a.provider==="codex"||a.provider==="opencode"?"fill":"regular",color:a.provider==="codex"?"#a16207":a.provider==="opencode"?"#4ade80":void 0})," ",a.provider]}),P&&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:P?"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:`${H}%`}})}),s.jsxs("span",{className:`dash-card__context-pct dash-card__context-pct--${j}`,children:[H,"%"]})]})]}),s.jsxs("div",{className:"dash-card__row3",children:[s.jsxs("span",{className:"dash-card__workdir",title:a.cwd,children:[s.jsx(F,{name:"folder",size:11})," ",a.cwd.split("/").pop()||a.cwd]}),m&&s.jsxs("span",{className:"dash-card__idle-time",style:{color:Ds(a.lastActivity)},title:$s(a.lastActivity),children:[s.jsx(F,{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()},title:x("cards.openTerminal"),children:x("cards.chat")}),w&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--danger",onClick:b=>{b.stopPropagation(),w()},title:x("cards.killAgent"),children:x("cards.stop")})]})]})});fs.displayName="AgentCard";const ws=({buildings:a,onSelectBuilding:A})=>{const{t:L}=ts(["dashboard"]),S=c.useMemo(()=>Array.from(a.values()).sort((n,g)=>n.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:L("buildings.title")}),s.jsx("span",{className:"dashboard-view__buildings-count",children:S.length})]}),s.jsx("div",{className:"dashboard-view__buildings-row",children:S.map(n=>{const g=bs(n.status),h=Ls(n.type);return s.jsxs("button",{className:`dash-pill dash-pill--${g}`,onClick:()=>A==null?void 0:A(n.id),title:`${n.name} (${n.type}) - ${n.status}`,children:[s.jsx("span",{className:"dash-pill__icon",children:s.jsx(F,{name:h,size:14})}),s.jsx("span",{className:"dash-pill__name",children:n.name}),s.jsx("span",{className:`dash-pill__dot dash-pill__dot--${g}`})]},n.id)})})]})};ws.displayName="BuildingPills";function Zs({onSelectAgent:a,onFocusAgent:A,onKillAgent:L,onSelectBuilding:S,onOpenTerminal:n,onFocusZone:g}){const{t:h}=ts(["dashboard","common"]),w=Ss(),X=Xs(),x=Ps(),rs=Rs(),P=vs(),[N,H]=c.useState(""),[j,I]=c.useState("all"),[m,B]=c.useState("zone"),[b,T]=c.useState(new Set),[k,J]=c.useState(null),[ps,Z]=c.useState(null),[R,Q]=c.useState(!1),[p,W]=c.useState(null),K=c.useMemo(()=>{const e=Array.from(w.values());return{total:e.length,working:e.filter(i=>i.status==="working"||i.status==="waiting"||i.status==="waiting_permission").length,idle:e.filter(i=>i.status==="idle").length,error:e.filter(i=>i.status==="error"||i.status==="offline"||i.status==="orphaned").length}},[w]),ns=c.useMemo(()=>m==="zone"?Ys(w,x):m==="status"?Us(w,P):Gs(w),[w,x,m,P]),V=c.useMemo(()=>{const e=N.toLowerCase().trim(),i=ns.map(l=>({...l,agents:l.agents.filter(_=>{if(j==="working"){if(_.status!=="working"&&_.status!=="waiting"&&_.status!=="waiting_permission")return!1}else if(j==="error"&&_.status!=="error"&&_.status!=="offline"&&_.status!=="orphaned")return!1;return!(e&&!_.name.toLowerCase().includes(e)&&!_.class.toLowerCase().includes(e))})}));return m==="zone"?i:i.filter(l=>l.agents.length>0)},[ns,j,N,m]),O=c.useCallback(e=>e.area?`area:${e.area.id}`:`${m}:${e.label}`,[m]),C=c.useMemo(()=>{const e=[];return V.forEach(i=>{const l=O(i);if(b.has(l))return;const _=m==="status"?ms(i.agents,{prioritizeRecentlyIdle:!0}):_s(i.agents);e.push(..._)}),e},[V,b,m,O]),gs=c.useCallback(e=>{T(i=>{const l=new Set(i);return l.has(e)?l.delete(e):l.add(e),l})},[]),xs=c.useCallback(e=>{n==null||n(e)},[n]),js=c.useCallback(e=>{J(e)},[]),Ns=c.useCallback((e,i)=>{e.preventDefault(),e.dataTransfer.dropEffect="move",Z(i)},[]),ks=c.useCallback(()=>{Z(null)},[]),Cs=c.useCallback(e=>{if(!k)return;if(e===null){const E=M.getState(),t=Array.from(E.areas.values()).find(r=>r.assignedAgentIds.includes(k.id));t&&M.unassignAgentFromArea(k.id,t.id),J(null),Z(null);return}const i=x.get(e);if(!i)return;const l=Array.from(w.values()),_=Fs(i,l,k.position);M.updateAgent({...k,position:{...k.position,x:_.x,z:_.z}}),M.assignAgentToArea(k.id,e),J(null),Z(null)},[k,x,w]);return c.useEffect(()=>{if(C.length===0){Q(!1),W(null);return}R&&(!p||!C.some(e=>e.id===p))&&(W(C[0].id),a==null||a(C[0].id))},[C,R,p,a]),c.useEffect(()=>{const e=t=>t instanceof HTMLElement?t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"||t.isContentEditable:!1,i=t=>t instanceof HTMLElement?!!t.closest(".guake-terminal")||t.classList.contains("guake-input")||t.classList.contains("agent-panel-input"):!1,l=t=>{const r=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).find(z=>z.dataset.agentId===t);r==null||r.scrollIntoView({block:"nearest",inline:"nearest"})},_=(t,r)=>{var ds,os,cs,ls,us,hs;const z=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).map(d=>{const u=d.dataset.agentId;if(!u)return null;const y=d.getBoundingClientRect();return{id:u,centerX:y.left+y.width/2,centerY:y.top+y.height/2,height:y.height}}).filter(d=>d!==null).sort((d,u)=>d.centerY-u.centerY||d.centerX-u.centerX);if(z.length===0)return t;const ss=z.reduce((d,u)=>d+u.height,0)/z.length,es=Math.max(18,ss*.6),f=[];for(const d of z){const u=f[f.length-1];if(!u){f.push([{id:d.id,centerX:d.centerX,centerY:d.centerY}]);continue}const y=u.reduce((ys,As)=>ys+As.centerY,0)/u.length;Math.abs(d.centerY-y)<=es?u.push({id:d.id,centerX:d.centerX,centerY:d.centerY}):f.push([{id:d.id,centerX:d.centerX,centerY:d.centerY}])}f.forEach(d=>d.sort((u,y)=>u.centerX-y.centerX));const Y=f.findIndex(d=>d.some(u=>u.id===t));if(Y===-1)return((os=(ds=f[0])==null?void 0:ds[0])==null?void 0:os.id)??t;const $=f[Y],v=$.findIndex(d=>d.id===t);if(v===-1)return((ls=(cs=f[0])==null?void 0:cs[0])==null?void 0:ls.id)??t;if(r==="left")return((us=$[Math.max(0,v-1)])==null?void 0:us.id)??t;if(r==="right")return((hs=$[Math.min($.length-1,v+1)])==null?void 0:hs.id)??t;const q=r==="up"?Math.max(0,Y-1):Math.min(f.length-1,Y+1),o=f[q],U=$[v].centerX;let D=o[0],is=Math.abs(D.centerX-U);for(const d of o){const u=Math.abs(d.centerX-U);u<is&&(D=d,is=u)}return(D==null?void 0:D.id)??t},E=t=>{const r=M.getShortcuts(),z=r.find(o=>o.id==="dashboard-selector-toggle"),ss=r.find(o=>o.id==="dashboard-vim-left"),es=r.find(o=>o.id==="dashboard-vim-down"),f=r.find(o=>o.id==="dashboard-vim-up"),Y=r.find(o=>o.id==="dashboard-vim-right"),$=r.find(o=>o.id==="open-terminal"),v=M.getState();if(e(t.target))if(!v.terminalOpen&&i(t.target)&&document.activeElement instanceof HTMLElement)document.activeElement.blur();else return;if(G(t,z)){if(C.length===0)return;t.preventDefault(),t.stopPropagation(),Q(!0),W(o=>{const U=o&&C.some(D=>D.id===o)?o:C[0].id;return a==null||a(U),window.setTimeout(()=>l(U),0),U});return}const q=G(t,ss)||t.key==="ArrowLeft"?"left":G(t,es)||t.key==="ArrowDown"?"down":G(t,f)||t.key==="ArrowUp"?"up":G(t,Y)||t.key==="ArrowRight"?"right":null;if(q&&R&&p){t.preventDefault(),t.stopPropagation();const o=_(p,q);o!==p&&(W(o),a==null||a(o),window.setTimeout(()=>l(o),0));return}if(G(t,$)){if(v.terminalOpen)return;if(R&&p&&v.agents.has(p)){t.preventDefault(),n==null||n(p);return}if(v.selectedAgentIds.size===1){t.preventDefault();const o=Array.from(v.selectedAgentIds)[0];n==null||n(o);return}if(v.lastSelectedAgentId&&v.agents.has(v.lastSelectedAgentId)){t.preventDefault(),n==null||n(v.lastSelectedAgentId);return}}};return document.addEventListener("keydown",E,!0),()=>document.removeEventListener("keydown",E,!0)},[C,R,p,n,a]),c.useEffect(()=>{const e=document.activeElement;e instanceof HTMLElement&&e.closest(".guake-terminal")&&!M.getState().terminalOpen&&e.blur()},[]),s.jsxs("div",{className:"dashboard-view",children:[s.jsxs("div",{className:"dashboard-view__topbar",children:[s.jsxs("div",{className:"dashboard-view__metrics",children:[s.jsxs("button",{className:`dashboard-view__metric-btn ${j==="all"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.total}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:labels.agents")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--working ${j==="working"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("working"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.working}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.working")})]}),s.jsxs("button",{className:"dashboard-view__metric-btn dashboard-view__metric-btn--idle ",onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.idle}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.idle")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--error ${j==="error"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("error"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.error}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.error")})]})]}),s.jsx("input",{className:"dashboard-view__search",type:"text",placeholder:h("searchPlaceholder"),value:N,onChange:e=>H(e.target.value)})]}),s.jsxs("div",{className:"dashboard-view__grouping",children:[s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="zone"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>B("zone"),children:h("grouping.byZone")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="status"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>B("status"),children:h("grouping.byStatus")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="activity"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>B("activity"),children:h("grouping.byActivity")})]}),s.jsxs("div",{className:"dashboard-view__content",children:[V.map(e=>{const i=O(e),l=b.has(i),_=m==="status"?ms(e.agents,{prioritizeRecentlyIdle:!0}):_s(e.agents),E=e.agents.filter(r=>r.status==="working"||r.status==="waiting"||r.status==="waiting_permission").length,t=e.agents.filter(r=>P.has(r.id)).length;return s.jsxs("div",{className:`dashboard-view__zone ${ps===(e.area?e.area.id:null)&&k?"dashboard-view__zone--drag-over":""}`,onDragOver:r=>Ns(r,e.area?e.area.id:null),onDragLeave:ks,onDrop:()=>Cs(e.area?e.area.id:null),children:[s.jsxs("div",{className:"dashboard-view__zone-header",onClick:()=>gs(i),children:[s.jsxs("div",{className:"dashboard-view__zone-left",children:[s.jsx("span",{className:`dashboard-view__zone-chevron ${l?"dashboard-view__zone-chevron--collapsed":""}`,children:s.jsx(F,{name:"caret-down",size:12})}),s.jsx("span",{className:"dashboard-view__zone-dot",style:{backgroundColor:e.color}}),s.jsx("span",{className:"dashboard-view__zone-name",children:e.label}),s.jsxs("span",{className:"dashboard-view__zone-count",children:[h("agentCount",{count:e.agents.length}),E>0&&s.jsxs("span",{className:"dashboard-view__zone-working",children:[" · ",E," ",h("working")]}),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:r=>{r.stopPropagation(),g(e.area.id)},title:h("focusZone"),children:h("focusZone")})]}),!l&&s.jsx("div",{className:"dashboard-view__zone-grid",children:_.map(r=>s.jsx(fs,{agent:r,isSelected:rs.has(r.id),isKeyboardFocused:R&&p===r.id,onSelect:()=>{a==null||a(r.id),Q(!0),W(r.id)},onDoubleClick:()=>xs(r.id),onChat:()=>n==null?void 0:n(r.id),onFocus:A?()=>A(r.id):void 0,onKill:L?()=>L(r.id):void 0,onDragStart:js},r.id))})]},i)}),V.length===0&&s.jsx("div",{className:"dashboard-view__empty",children:N?h("noAgentsMatching",{search:N}):h("noAgentsSpawned")}),X.size>0&&s.jsx(ws,{buildings:X,onSelectBuilding:S})]})]})}export{Zs as DashboardView};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-
|
|
2
|
-
import{
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-BZcyP_IR.js","assets/main-CyZg1kKu.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-Chj50gSY.js","assets/main-VciFPjA1.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{cb as e,bC as o}from"./main-CyZg1kKu.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";var i;(function(r){r.Heavy="HEAVY",r.Medium="MEDIUM",r.Light="LIGHT"})(i||(i={}));var t;(function(r){r.Success="SUCCESS",r.Warning="WARNING",r.Error="ERROR"})(t||(t={}));const c=e("Haptics",{web:()=>o(()=>import("./web-BZcyP_IR.js"),__vite__mapDeps([0,1,2,3,4])).then(r=>new r.HapticsWeb)});export{c as Haptics,i as ImpactStyle,t as NotificationType};
|