tide-commander 1.110.2 → 1.110.3
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-Dub95BCo.js} +1 -1
- package/dist/assets/{BossSpawnModal-DDl6qgnq.js → BossSpawnModal-BXIZWAzn.js} +1 -1
- package/dist/assets/{ControlsModal-BBUukX-p.js → ControlsModal-MclobOaO.js} +1 -1
- package/dist/assets/{DockerLogsModal-BWf3XDEI.js → DockerLogsModal-DRQ6YsEB.js} +1 -1
- package/dist/assets/{EmbeddedEditor-CIOdhnaW.js → EmbeddedEditor-B9iQHzhz.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-qG-_WeOb.js → GmailOAuthSetup-wEezv-Vt.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-BK3lzU4n.js → GoogleOAuthSetup-P_teBMn2.js} +1 -1
- package/dist/assets/{IframeModal-D_NEs_Ld.js → IframeModal-DEXm0UTA.js} +1 -1
- package/dist/assets/{IntegrationsPanel-yphWX1ZD.js → IntegrationsPanel-CgFuLL4S.js} +2 -2
- package/dist/assets/{LogViewerModal-B0h9NNRk.js → LogViewerModal-CSpbNMTp.js} +1 -1
- package/dist/assets/{MonitoringModal-Ciw7KnXH.js → MonitoringModal-Dv1lWqtZ.js} +1 -1
- package/dist/assets/{PM2LogsModal-C1dYQaff.js → PM2LogsModal-qpjByXs_.js} +1 -1
- package/dist/assets/{RestoreArchivedAreaModal-DOwzfu-D.js → RestoreArchivedAreaModal-2O5SPxwQ.js} +1 -1
- package/dist/assets/{Scene2DCanvas-MHfv4Rzg.js → Scene2DCanvas-BJiXSOxB.js} +1 -1
- package/dist/assets/{SceneManager-cm1Kj0YD.js → SceneManager-D9NtdKQ1.js} +1 -1
- package/dist/assets/{SkillsPanel-DLwMkORc.js → SkillsPanel-B8_RPJzS.js} +1 -1
- package/dist/assets/{SlackMultiInstanceSetup-Dql_wPMX.js → SlackMultiInstanceSetup-VcCJhIhV.js} +1 -1
- package/dist/assets/{SpawnModal-DzPTSOKV.js → SpawnModal-gn1VV_xv.js} +1 -1
- package/dist/assets/StatisticsModal-DRvS2yB_.js +1 -0
- package/dist/assets/{SubordinateAssignmentModal-CoLzD3z2.js → SubordinateAssignmentModal-D9gpXqIB.js} +1 -1
- package/dist/assets/{TriggerManagerPanel-BOi2zr7N.js → TriggerManagerPanel-bBguUZCE.js} +1 -1
- package/dist/assets/{WorkflowEditorPanel-DB1ygPDS.js → WorkflowEditorPanel-BGcpM6uO.js} +1 -1
- package/dist/assets/{index-BZsQOteM.js → index-2NGIIydL.js} +1 -1
- package/dist/assets/{index-DKASWGtq.js → index-BLw57j0y.js} +1 -1
- package/dist/assets/index-Bg0YBtj9.js +11 -0
- package/dist/assets/{index-DKdZI-Ar.js → index-Bgcnlnvz.js} +1 -1
- package/dist/assets/{index-6Wak7CPm.js → index-BrdAbMM1.js} +1 -1
- package/dist/assets/{index-BXJSMT4a.js → index-CTfxfQqV.js} +3 -3
- package/dist/assets/{index-ThbMNdRp.js → index-Cy72l2Qo.js} +1 -1
- package/dist/assets/{index-D4XW6MSF.js → index-GpT5NHsq.js} +2 -2
- package/dist/assets/{index-C6EHHgC0.js → index-VYch6p3A.js} +1 -1
- package/dist/assets/{main-BxA3Bhkv.js → main-Brpf2Evy.js} +94 -94
- package/dist/assets/{main-BLrGoeQ_.css → main-VciFPjA1.css} +1 -1
- package/dist/assets/{web-BskC98UQ.js → web-DUdLOxoB.js} +1 -1
- package/dist/assets/{web-CSRmX8Ge.js → web-DjzK5qYd.js} +1 -1
- package/dist/assets/{web-zdygXcYu.js → web-IMi3bHab.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/src/packages/server/data/builtin-skills/send-message-to-agent.js +31 -1
- package/dist/src/packages/server/routes/agents.js +30 -0
- package/dist/src/packages/server/services/runtime-service.js +24 -0
- package/dist/src/packages/server/websocket/handlers/agent-handler.js +18 -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-Brpf2Evy.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-VcCJhIhV.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-Brpf2Evy.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-Brpf2Evy.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-Brpf2Evy.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-Brpf2Evy.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-Brpf2Evy.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-Brpf2Evy.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const H=[{id:"intake",name:"Intake",type:"action",description:"Gather CC details from the developer via Slack",action:{type:"agent_task",agentId:"",promptTemplate:`A developer has requested a new CC (Control de Cambios). Here is their message:
|
|
2
2
|
{{trigger.slack.message}}
|
|
3
3
|
From: {{trigger.slack.user}} (Slack ID: {{trigger.slack.userId}})
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as J,a as Z,r,s as h,j as e,D as de,I as H,C as oe,b as me,c as be,d as ue,g as he,e as _e,Q as pe,R as xe}from"./main-BxA3Bhkv.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const fe=({building:a,connections:x,activeConnectionId:l,activeDatabase:c,collapsed:y,onToggleCollapse:f,onConnectionChange:Q,onDatabaseChange:S,onInsertTable:L,onSelectTableQuery:P})=>{const{t:m}=J(["terminal"]),q=Z(a.id),[I,R]=r.useState(new Set),[k,n]=r.useState(""),[d,g]=r.useState(""),[$,w]=r.useState(!1),[U,F]=r.useState(null),K=r.useRef(null),C=r.useRef(null),O=r.useRef(null),N=l?q.databases.get(l)??[]:[],G=l&&c?`${l}:${c}`:"",j=G?q.tables.get(G)??[]:[],p=l?q.connectionStatus.get(l):void 0,D=r.useMemo(()=>{if(!k.trim())return N;const t=k.toLowerCase();return N.filter(o=>o.toLowerCase().includes(t))},[N,k]),b=r.useMemo(()=>{if(!d.trim())return j;const t=d.toLowerCase();return j.filter(o=>o.name.toLowerCase().includes(t))},[j,d]);r.useEffect(()=>{const t=o=>{C.current&&!C.current.contains(o.target)&&w(!1)};return $&&document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[$]),r.useEffect(()=>{l&&!p&&h.testDatabaseConnection(a.id,l)},[a.id,l,p]),r.useEffect(()=>{l&&(p!=null&&p.connected)&&N.length===0&&h.listDatabases(a.id,l)},[a.id,l,p==null?void 0:p.connected,N.length]),r.useEffect(()=>{l&&c&&j.length===0&&h.listTables(a.id,l,c)},[a.id,l,c,j.length]),r.useEffect(()=>{F(null),g("")},[l,c]);const _=r.useCallback(t=>{R(o=>{const T=new Set(o);if(T.has(t))T.delete(t);else if(T.add(t),l&&c){const v=`${l}:${c}:${t}`;q.tableSchemas.has(v)||h.getTableSchema(a.id,l,c,t)}return T})},[a.id,l,c,q.tableSchemas]),z=t=>{if(!l||!c)return null;const o=`${l}:${c}:${t}`;return q.tableSchemas.get(o)};return y?e.jsx("div",{className:"database-sidebar database-sidebar--collapsed",children:e.jsx("button",{className:"database-sidebar__toggle",onClick:f,title:m("terminal:database.expandSidebar"),children:"»"})}):e.jsxs("div",{className:"database-sidebar",children:[e.jsxs("div",{className:"database-sidebar__header",children:[e.jsx("span",{children:m("terminal:database.explorer")}),e.jsx("button",{className:"database-sidebar__toggle",onClick:f,title:m("terminal:database.collapseSidebar"),children:"«"})]}),e.jsxs("div",{className:"database-sidebar__section",children:[e.jsx("div",{className:"database-sidebar__section-title",children:m("terminal:database.connection")}),e.jsx("select",{className:"database-sidebar__select",value:l||"",onChange:t=>Q(t.target.value),children:x.length===0?e.jsx("option",{value:"",children:m("terminal:database.noConnections")}):x.map(t=>{var o;return e.jsxs("option",{value:t.id,children:[((o=de[t.engine])==null?void 0:o.icon)??"🗄️"," ",t.name]},t.id)})}),p&&e.jsx("div",{className:`database-sidebar__status ${p.connected?"database-sidebar__status--connected":"database-sidebar__status--error"}`,children:p.connected?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"database-sidebar__status-icon",children:"✓"}),m("terminal:database.connected"),p.serverVersion&&e.jsxs("span",{className:"database-sidebar__version",children:["(",p.serverVersion,")"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"database-sidebar__status-icon",children:"✗"}),p.error||m("terminal:database.disconnected")]})})]}),N.length>0&&e.jsxs("div",{className:"database-sidebar__section",children:[e.jsx("div",{className:"database-sidebar__section-title",children:m("terminal:database.databaseTitle")}),e.jsxs("div",{className:"database-sidebar__searchable-select",ref:C,children:[e.jsx("input",{ref:K,className:"database-sidebar__search-input",type:"text",value:$?k:c||"",placeholder:m("terminal:database.selectDatabase"),onChange:t=>{n(t.target.value),$||w(!0)},onFocus:()=>{w(!0),n("")},onKeyDown:t=>{var o,T;t.key==="Escape"?(w(!1),n(""),(o=K.current)==null||o.blur()):t.key==="Enter"&&D.length===1&&(S(D[0]),w(!1),n(""),(T=K.current)==null||T.blur())}}),$&&e.jsx("div",{className:"database-sidebar__dropdown",children:D.length===0?e.jsx("div",{className:"database-sidebar__dropdown-empty",children:"No matches"}):D.map(t=>e.jsx("div",{className:`database-sidebar__dropdown-item ${t===c?"database-sidebar__dropdown-item--active":""}`,onMouseDown:o=>{o.preventDefault(),S(t),w(!1),n("")},children:t},t))})]})]}),j.length>0&&e.jsxs("div",{className:"database-sidebar__section database-sidebar__section--tables",children:[e.jsx("div",{className:"database-sidebar__section-title",children:d.trim()?m("terminal:database.tablesCount",{count:b.length})+` / ${j.length}`:m("terminal:database.tablesCount",{count:j.length})}),e.jsxs("div",{className:"database-sidebar__table-filter",children:[e.jsx("input",{ref:O,className:"database-sidebar__table-filter-input",type:"text",value:d,placeholder:m("terminal:database.filterTables"),onChange:t=>g(t.target.value),onKeyDown:t=>{var o;t.key==="Escape"&&(d?g(""):(o=O.current)==null||o.blur(),t.stopPropagation())}}),d&&e.jsx("button",{className:"database-sidebar__table-filter-clear",onClick:()=>{var t;g(""),(t=O.current)==null||t.focus()},title:"Clear filter",children:"×"})]}),e.jsxs("div",{className:"database-sidebar__tables",children:[d.trim()&&b.length===0&&e.jsx("div",{className:"database-sidebar__tables-empty",children:m("terminal:database.noTablesMatch")}),b.map(t=>{const o=I.has(t.name),T=o?z(t.name):null;return e.jsxs("div",{className:"database-sidebar__table",children:[e.jsxs("div",{className:"database-sidebar__table-header",children:[e.jsx("button",{className:"database-sidebar__table-expand",onClick:()=>_(t.name),title:o?"Collapse table schema":"Expand table schema",children:e.jsx(H,{name:o?"caret-down":"caret-right",size:10})}),e.jsx("span",{className:"database-sidebar__table-icon",children:e.jsx(H,{name:t.type==="view"?"eye":"clipboard",size:12})}),e.jsx("span",{className:`database-sidebar__table-name ${U===t.name?"database-sidebar__table-name--selected":""}`,onClick:()=>F(t.name),onDoubleClick:()=>{F(t.name),P(t.name)},children:t.name}),e.jsx("button",{className:"database-sidebar__table-insert",onClick:v=>{v.stopPropagation(),L(t.name)},title:m("terminal:database.insertTableName"),children:"+"})]}),o&&T&&e.jsx("div",{className:"database-sidebar__table-columns",children:T.columns.map(v=>e.jsxs("div",{className:"database-sidebar__column",onClick:()=>L(v.name),title:`${v.type}${v.nullable?" NULL":" NOT NULL"}${v.primaryKey?" PK":""}`,children:[e.jsx("span",{className:"database-sidebar__column-icon",children:v.primaryKey?e.jsx(H,{name:"key",size:11}):null}),e.jsx("span",{className:"database-sidebar__column-name",children:v.name}),e.jsx("span",{className:"database-sidebar__column-type",children:v.type})]},v.name))})]},t.name)})]})]})]})},je=({buildingId:a,history:x,onLoadQuery:l})=>{const{t:c}=J(["terminal","common"]),[y,f]=r.useState(""),[Q,S]=r.useState(!1),[L,P]=r.useState(!1),m=r.useMemo(()=>{let n=x;if(Q&&(n=n.filter(d=>d.favorite)),y.trim()){const d=y.toLowerCase();n=n.filter(g=>g.query.toLowerCase().includes(d)||g.database.toLowerCase().includes(d))}return n},[x,Q,y]),q=n=>{const d=new Date(n),$=new Date().getTime()-d.getTime();return $<1440*60*1e3?d.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):$<10080*60*1e3?d.toLocaleDateString([],{weekday:"short"})+" "+d.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):d.toLocaleDateString([],{month:"short",day:"numeric"})},I=r.useCallback((n,d)=>{d.stopPropagation(),h.toggleQueryFavorite(a,n)},[a]),R=r.useCallback((n,d)=>{d.stopPropagation(),h.deleteQueryFromHistory(a,n)},[a]),k=r.useCallback(()=>{P(!0)},[]);return x.length===0?e.jsxs("div",{className:"query-history query-history--empty",children:[e.jsx("p",{children:c("terminal:database.noHistory")}),e.jsx("p",{children:c("terminal:database.queriesAppearHere")})]}):e.jsxs("div",{className:"query-history",children:[e.jsxs("div",{className:"query-history__toolbar",children:[e.jsx("input",{type:"text",className:"query-history__search",placeholder:c("terminal:database.searchQueries"),value:y,onChange:n=>f(n.target.value)}),e.jsxs("label",{className:"query-history__filter",children:[e.jsx("input",{type:"checkbox",checked:Q,onChange:n=>S(n.target.checked)}),c("terminal:database.favoritesOnly")]}),e.jsx("button",{className:"query-history__clear",onClick:k,title:c("terminal:database.clearAll"),children:c("terminal:database.clearAll")})]}),e.jsxs("div",{className:"query-history__list",children:[m.map(n=>e.jsxs("div",{className:`query-history__item ${n.status==="error"?"query-history__item--error":""}`,onClick:()=>l(n.query),children:[e.jsxs("div",{className:"query-history__item-header",children:[e.jsx("span",{className:`query-history__status ${n.status==="success"?"query-history__status--success":"query-history__status--error"}`,children:e.jsx(H,{name:n.status==="success"?"check":"cross",size:12})}),e.jsx("span",{className:"query-history__database",children:n.database}),e.jsx("span",{className:"query-history__date",children:q(n.executedAt)}),e.jsxs("span",{className:"query-history__duration",children:[n.duration,"ms"]}),n.rowCount!==void 0&&e.jsx("span",{className:"query-history__row-count",children:c("terminal:database.rowCount",{count:n.rowCount})})]}),e.jsx("div",{className:"query-history__query",children:e.jsx("code",{children:n.query.length>200?n.query.substring(0,200)+"...":n.query})}),n.error&&e.jsx("div",{className:"query-history__error",children:n.error}),e.jsxs("div",{className:"query-history__actions",children:[e.jsx("button",{className:`query-history__favorite ${n.favorite?"query-history__favorite--active":""}`,onClick:d=>I(n.id,d),title:n.favorite?c("terminal:database.removeFromFavorites"):c("terminal:database.addToFavorites"),children:e.jsx(H,{name:"star",size:12,weight:n.favorite?"fill":"regular",color:n.favorite?"#facc15":void 0})}),e.jsx("button",{className:"query-history__delete",onClick:d=>R(n.id,d),title:c("terminal:database.deleteFromHistory"),children:e.jsx(H,{name:"trash",size:12})})]})]},n.id)),m.length===0&&e.jsx("div",{className:"query-history__no-results",children:c("terminal:database.noQueriesMatch")})]}),e.jsx(oe,{isOpen:L,title:c("terminal:database.clearAll"),message:c("terminal:database.confirmClearHistory"),confirmLabel:c("terminal:database.clearAll"),cancelLabel:c("common:buttons.cancel"),variant:"danger",onConfirm:()=>h.clearQueryHistory(a),onClose:()=>P(!1)})]})},ye=({tabs:a,activeTabId:x,onTabClick:l,onTabClose:c})=>{const{t:y}=J(["terminal"]);return e.jsx("div",{className:"database-tabs",children:a.map(f=>e.jsxs("div",{className:`database-tabs__tab ${x===f.id?"database-tabs__tab--active":""}`,children:[e.jsxs("button",{className:"database-tabs__tab-label",onClick:()=>l(f),title:`${f.connectionName} / ${f.database}`,children:[f.database,e.jsx("span",{className:"database-tabs__tab-connection",children:f.connectionName})]}),e.jsx("button",{className:"database-tabs__tab-close",onClick:()=>c(f.id),title:y("terminal:database.closeTab"),"aria-label":`Close ${f.database} tab`,children:"×"})]},f.id))})},ee=a=>`db-panel-${a}`;function Ne(a){try{const x=localStorage.getItem(ee(a));return x?JSON.parse(x):{}}catch{return{}}}function ve(a,x){try{localStorage.setItem(ee(a),JSON.stringify(x))}catch{}}const ge=({building:a,onClose:x})=>{var B,W,Y,X;const{t:l}=J(["terminal","common"]),c=Z(a.id),y=me(a.id),f=be(a.id),Q=ue(a.id),S=r.useRef(Ne(a.id)),L=r.useRef(null),P=r.useRef(0),m=((B=a.database)==null?void 0:B.connections)??[],q=(s,i)=>`${s}:${i}`,I=s=>s?(S.current.queries??{})[s]??"":S.current.generalQuery??"",[R,k]=r.useState("results"),[n,d]=r.useState(0),[g,$]=r.useState(!1),[w,U]=r.useState(!1),[F,K]=r.useState(()=>(S.current.openTabs??[]).map(i=>{var u;return{id:`${i.connectionId}:${i.database}`,connectionId:i.connectionId,connectionName:((u=m.find(A=>A.id===i.connectionId))==null?void 0:u.name)??i.connectionId,database:i.database}})),[C,O]=r.useState(S.current.activeTabId??null),[N,G]=r.useState(()=>{const s=S.current.queries??{};return S.current.generalQuery,s}),[j,p]=r.useState(I(C)),D=r.useCallback(s=>{p(i=>{const u=typeof s=="function"?s(i):s;return G(A=>{const E={...A};return C&&(E[C]=u),E}),u})},[C]),b=c.activeConnectionId??S.current.connectionId??((W=a.database)==null?void 0:W.activeConnectionId)??((Y=m[0])==null?void 0:Y.id),_=c.activeDatabase??S.current.database??((X=a.database)==null?void 0:X.activeDatabase),z=m.find(s=>s.id===b),t=b&&_?`${b}:${_}`:"",o=t?c.tables.get(t)??[]:[],T=r.useMemo(()=>{const s=new Map;return!b||!_||o.forEach(i=>{const u=c.tableSchemas.get(`${b}:${_}:${i.name}`);u&&s.set(i.name,{columns:u.columns})}),s},[b,_,o,c.tableSchemas]),v=r.useCallback((s,i)=>{var E;const u=q(s,i),A=((E=m.find(M=>M.id===s))==null?void 0:E.name)??s;K(M=>{if(M.some(ie=>ie.id===u))return M;const ce={id:u,connectionId:s,connectionName:A,database:i};return[...M,ce]}),O(u),p(N[u]??""),h.setActiveConnection(a.id,s),h.setActiveDatabase(a.id,i)},[a.id,m,N]),ae=r.useCallback(s=>{K(i=>i.filter(u=>u.id!==s)),C===s&&K(i=>{if(i.length>0){const u=i[0];O(u.id),p(N[u.id]??""),h.setActiveConnection(a.id,u.connectionId),h.setActiveDatabase(a.id,u.database)}else O(null),p("");return i})},[C,a.id,N]),se=r.useCallback(s=>{O(s.id),p(N[s.id]??""),h.setActiveConnection(a.id,s.connectionId),h.setActiveDatabase(a.id,s.database)},[a.id,N]);r.useEffect(()=>{if(!w&&m.length>0){const s=S.current;s.connectionId&&m.some(i=>i.id===s.connectionId)&&(h.setActiveConnection(a.id,s.connectionId),h.listDatabases(a.id,s.connectionId),s.database&&(h.setActiveDatabase(a.id,s.database),h.listTables(a.id,s.connectionId,s.database))),U(!0)}},[a.id,m,w]),r.useEffect(()=>{h.requestQueryHistory(a.id)},[a.id]),r.useEffect(()=>{const s=i=>{i.key==="Escape"&&(i.preventDefault(),i.stopPropagation(),x())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[x]),r.useEffect(()=>{w&&b&&ve(a.id,{connectionId:b,database:_,lastQuery:j,queries:N,generalQuery:"",openTabs:F.map(s=>({connectionId:s.connectionId,database:s.database})),activeTabId:C??void 0})},[a.id,b,_,j,w,F,C,N]);const te=r.useCallback(s=>{var i;if(!(!b||!_||!j.trim()||Q))if(s==="cursor"){const u=(i=L.current)==null?void 0:i.querySelector(".query-editor__textarea"),A=(u==null?void 0:u.selectionStart)??P.current,E=he(j,A);E&&h.executeQuery(a.id,b,_,E)}else{const u=_e(j);if(u.length<=1)h.executeQuery(a.id,b,_,j.trim());else{const A=b,E=_;(async()=>{for(const M of u)await h.executeQueryAndWait(a.id,A,E,M.sql)})()}}},[a.id,b,_,j,Q]),ne=r.useCallback(s=>{D(s),k("results")},[]),re=r.useCallback(s=>{h.setActiveConnection(a.id,s),h.listDatabases(a.id,s)},[a.id]),le=r.useCallback(s=>{b&&(v(b,s),h.listTables(a.id,b,s))},[a.id,b,v]),V=y[n];return m.length===0?e.jsxs("div",{className:"database-panel",ref:L,children:[e.jsxs("div",{className:"database-panel__header",children:[e.jsxs("div",{className:"database-panel__title",children:[e.jsx("span",{className:"database-panel__icon",children:e.jsx(H,{name:"database",size:16})}),e.jsx("span",{className:"database-panel__name",children:a.name})]}),e.jsx("button",{className:"database-panel__close",onClick:x,children:"×"})]}),e.jsx("div",{className:"database-panel__body",children:e.jsxs("div",{className:"database-panel__no-connections",children:[e.jsx("div",{className:"database-panel__no-connections-icon",children:e.jsx(H,{name:"plug",size:32})}),e.jsx("h3",{children:l("terminal:database.noConnections")}),e.jsx("p",{children:l("terminal:database.noConnectionsDesc")}),e.jsx("p",{children:l("terminal:database.toGetStarted")}),e.jsxs("ol",{children:[e.jsx("li",{children:l("terminal:database.step1Close")}),e.jsx("li",{children:l("terminal:database.step2Settings")}),e.jsx("li",{children:l("terminal:database.step3AddConnection")}),e.jsx("li",{children:l("terminal:database.step4Reopen")})]})]})})]}):e.jsxs("div",{className:"database-panel",ref:L,children:[e.jsxs("div",{className:"database-panel__header",children:[e.jsxs("div",{className:"database-panel__title",children:[e.jsx("span",{className:"database-panel__icon",children:(z==null?void 0:z.engine)==="mysql"?"🐬":"🐘"}),e.jsx("span",{className:"database-panel__name",children:a.name}),z&&e.jsxs("span",{className:"database-panel__connection-info",children:[z.name," / ",_||l("terminal:database.noDatabaseSelected")]})]}),e.jsx("button",{className:"database-panel__close",onClick:x,children:"×"})]}),e.jsxs("div",{className:"database-panel__body",children:[e.jsx(fe,{building:a,connections:m,activeConnectionId:b,activeDatabase:_,collapsed:g,onToggleCollapse:()=>$(!g),onConnectionChange:re,onDatabaseChange:le,onInsertTable:s=>D(i=>i+` ${s}`),onSelectTableQuery:s=>{const i=`SELECT * FROM ${s}`;D(i),b&&_&&h.executeQuery(a.id,b,_,i)}}),e.jsxs("div",{className:"database-panel__main",children:[F.length>0&&e.jsx(ye,{tabs:F,activeTabId:C,onTabClick:se,onTabClose:ae}),e.jsx(pe,{query:j,onChange:D,onExecute:te,isExecuting:Q,disabled:!b||!_,tables:o,tableSchemas:T,onRequestTableSchema:s=>{b&&_&&h.getTableSchema(a.id,b,_,s)}}),e.jsxs("div",{className:"database-panel__tabs",children:[e.jsxs("button",{className:`database-panel__tab ${R==="results"?"database-panel__tab--active":""}`,onClick:()=>k("results"),children:[l("terminal:database.results"),y.length>0&&e.jsx("span",{className:"database-panel__tab-badge",children:y.length})]}),e.jsxs("button",{className:`database-panel__tab ${R==="history"?"database-panel__tab--active":""}`,onClick:()=>k("history"),children:[l("terminal:database.history"),f.length>0&&e.jsx("span",{className:"database-panel__tab-badge",children:f.length})]}),R==="results"&&y.length>1&&e.jsxs("div",{className:"database-panel__result-nav",children:[e.jsxs("button",{disabled:n>=y.length-1,onClick:()=>d(s=>s+1),children:["← ",l("terminal:database.older")]}),e.jsxs("span",{children:[n+1," / ",y.length]}),e.jsxs("button",{disabled:n<=0,onClick:()=>d(s=>s-1),children:[l("terminal:database.newer")," →"]})]})]}),e.jsx("div",{className:"database-panel__tab-content",children:R==="results"?V?e.jsx(xe,{result:V,buildingId:a.id,building:a}):e.jsxs("div",{className:"database-panel__empty",children:[e.jsx("p",{children:l("terminal:database.noResultsYet")}),e.jsx("p",{children:l("terminal:database.selectDbAndRun")})]}):e.jsx(je,{buildingId:a.id,history:f,onLoadQuery:ne})})]})]})]})};export{ge as DatabasePanel,fe as DatabaseSidebar,ye as DatabaseTabs,pe as QueryEditor,je as QueryHistoryPanel,xe as ResultsTable};
|
|
1
|
+
import{u as J,a as Z,r,s as h,j as e,D as de,I as H,C as oe,b as me,c as be,d as ue,g as he,e as _e,Q as pe,R as xe}from"./main-Brpf2Evy.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const fe=({building:a,connections:x,activeConnectionId:l,activeDatabase:c,collapsed:y,onToggleCollapse:f,onConnectionChange:Q,onDatabaseChange:S,onInsertTable:L,onSelectTableQuery:P})=>{const{t:m}=J(["terminal"]),q=Z(a.id),[I,R]=r.useState(new Set),[k,n]=r.useState(""),[d,g]=r.useState(""),[$,w]=r.useState(!1),[U,F]=r.useState(null),K=r.useRef(null),C=r.useRef(null),O=r.useRef(null),N=l?q.databases.get(l)??[]:[],G=l&&c?`${l}:${c}`:"",j=G?q.tables.get(G)??[]:[],p=l?q.connectionStatus.get(l):void 0,D=r.useMemo(()=>{if(!k.trim())return N;const t=k.toLowerCase();return N.filter(o=>o.toLowerCase().includes(t))},[N,k]),b=r.useMemo(()=>{if(!d.trim())return j;const t=d.toLowerCase();return j.filter(o=>o.name.toLowerCase().includes(t))},[j,d]);r.useEffect(()=>{const t=o=>{C.current&&!C.current.contains(o.target)&&w(!1)};return $&&document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[$]),r.useEffect(()=>{l&&!p&&h.testDatabaseConnection(a.id,l)},[a.id,l,p]),r.useEffect(()=>{l&&(p!=null&&p.connected)&&N.length===0&&h.listDatabases(a.id,l)},[a.id,l,p==null?void 0:p.connected,N.length]),r.useEffect(()=>{l&&c&&j.length===0&&h.listTables(a.id,l,c)},[a.id,l,c,j.length]),r.useEffect(()=>{F(null),g("")},[l,c]);const _=r.useCallback(t=>{R(o=>{const T=new Set(o);if(T.has(t))T.delete(t);else if(T.add(t),l&&c){const v=`${l}:${c}:${t}`;q.tableSchemas.has(v)||h.getTableSchema(a.id,l,c,t)}return T})},[a.id,l,c,q.tableSchemas]),z=t=>{if(!l||!c)return null;const o=`${l}:${c}:${t}`;return q.tableSchemas.get(o)};return y?e.jsx("div",{className:"database-sidebar database-sidebar--collapsed",children:e.jsx("button",{className:"database-sidebar__toggle",onClick:f,title:m("terminal:database.expandSidebar"),children:"»"})}):e.jsxs("div",{className:"database-sidebar",children:[e.jsxs("div",{className:"database-sidebar__header",children:[e.jsx("span",{children:m("terminal:database.explorer")}),e.jsx("button",{className:"database-sidebar__toggle",onClick:f,title:m("terminal:database.collapseSidebar"),children:"«"})]}),e.jsxs("div",{className:"database-sidebar__section",children:[e.jsx("div",{className:"database-sidebar__section-title",children:m("terminal:database.connection")}),e.jsx("select",{className:"database-sidebar__select",value:l||"",onChange:t=>Q(t.target.value),children:x.length===0?e.jsx("option",{value:"",children:m("terminal:database.noConnections")}):x.map(t=>{var o;return e.jsxs("option",{value:t.id,children:[((o=de[t.engine])==null?void 0:o.icon)??"🗄️"," ",t.name]},t.id)})}),p&&e.jsx("div",{className:`database-sidebar__status ${p.connected?"database-sidebar__status--connected":"database-sidebar__status--error"}`,children:p.connected?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"database-sidebar__status-icon",children:"✓"}),m("terminal:database.connected"),p.serverVersion&&e.jsxs("span",{className:"database-sidebar__version",children:["(",p.serverVersion,")"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"database-sidebar__status-icon",children:"✗"}),p.error||m("terminal:database.disconnected")]})})]}),N.length>0&&e.jsxs("div",{className:"database-sidebar__section",children:[e.jsx("div",{className:"database-sidebar__section-title",children:m("terminal:database.databaseTitle")}),e.jsxs("div",{className:"database-sidebar__searchable-select",ref:C,children:[e.jsx("input",{ref:K,className:"database-sidebar__search-input",type:"text",value:$?k:c||"",placeholder:m("terminal:database.selectDatabase"),onChange:t=>{n(t.target.value),$||w(!0)},onFocus:()=>{w(!0),n("")},onKeyDown:t=>{var o,T;t.key==="Escape"?(w(!1),n(""),(o=K.current)==null||o.blur()):t.key==="Enter"&&D.length===1&&(S(D[0]),w(!1),n(""),(T=K.current)==null||T.blur())}}),$&&e.jsx("div",{className:"database-sidebar__dropdown",children:D.length===0?e.jsx("div",{className:"database-sidebar__dropdown-empty",children:"No matches"}):D.map(t=>e.jsx("div",{className:`database-sidebar__dropdown-item ${t===c?"database-sidebar__dropdown-item--active":""}`,onMouseDown:o=>{o.preventDefault(),S(t),w(!1),n("")},children:t},t))})]})]}),j.length>0&&e.jsxs("div",{className:"database-sidebar__section database-sidebar__section--tables",children:[e.jsx("div",{className:"database-sidebar__section-title",children:d.trim()?m("terminal:database.tablesCount",{count:b.length})+` / ${j.length}`:m("terminal:database.tablesCount",{count:j.length})}),e.jsxs("div",{className:"database-sidebar__table-filter",children:[e.jsx("input",{ref:O,className:"database-sidebar__table-filter-input",type:"text",value:d,placeholder:m("terminal:database.filterTables"),onChange:t=>g(t.target.value),onKeyDown:t=>{var o;t.key==="Escape"&&(d?g(""):(o=O.current)==null||o.blur(),t.stopPropagation())}}),d&&e.jsx("button",{className:"database-sidebar__table-filter-clear",onClick:()=>{var t;g(""),(t=O.current)==null||t.focus()},title:"Clear filter",children:"×"})]}),e.jsxs("div",{className:"database-sidebar__tables",children:[d.trim()&&b.length===0&&e.jsx("div",{className:"database-sidebar__tables-empty",children:m("terminal:database.noTablesMatch")}),b.map(t=>{const o=I.has(t.name),T=o?z(t.name):null;return e.jsxs("div",{className:"database-sidebar__table",children:[e.jsxs("div",{className:"database-sidebar__table-header",children:[e.jsx("button",{className:"database-sidebar__table-expand",onClick:()=>_(t.name),title:o?"Collapse table schema":"Expand table schema",children:e.jsx(H,{name:o?"caret-down":"caret-right",size:10})}),e.jsx("span",{className:"database-sidebar__table-icon",children:e.jsx(H,{name:t.type==="view"?"eye":"clipboard",size:12})}),e.jsx("span",{className:`database-sidebar__table-name ${U===t.name?"database-sidebar__table-name--selected":""}`,onClick:()=>F(t.name),onDoubleClick:()=>{F(t.name),P(t.name)},children:t.name}),e.jsx("button",{className:"database-sidebar__table-insert",onClick:v=>{v.stopPropagation(),L(t.name)},title:m("terminal:database.insertTableName"),children:"+"})]}),o&&T&&e.jsx("div",{className:"database-sidebar__table-columns",children:T.columns.map(v=>e.jsxs("div",{className:"database-sidebar__column",onClick:()=>L(v.name),title:`${v.type}${v.nullable?" NULL":" NOT NULL"}${v.primaryKey?" PK":""}`,children:[e.jsx("span",{className:"database-sidebar__column-icon",children:v.primaryKey?e.jsx(H,{name:"key",size:11}):null}),e.jsx("span",{className:"database-sidebar__column-name",children:v.name}),e.jsx("span",{className:"database-sidebar__column-type",children:v.type})]},v.name))})]},t.name)})]})]})]})},je=({buildingId:a,history:x,onLoadQuery:l})=>{const{t:c}=J(["terminal","common"]),[y,f]=r.useState(""),[Q,S]=r.useState(!1),[L,P]=r.useState(!1),m=r.useMemo(()=>{let n=x;if(Q&&(n=n.filter(d=>d.favorite)),y.trim()){const d=y.toLowerCase();n=n.filter(g=>g.query.toLowerCase().includes(d)||g.database.toLowerCase().includes(d))}return n},[x,Q,y]),q=n=>{const d=new Date(n),$=new Date().getTime()-d.getTime();return $<1440*60*1e3?d.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):$<10080*60*1e3?d.toLocaleDateString([],{weekday:"short"})+" "+d.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):d.toLocaleDateString([],{month:"short",day:"numeric"})},I=r.useCallback((n,d)=>{d.stopPropagation(),h.toggleQueryFavorite(a,n)},[a]),R=r.useCallback((n,d)=>{d.stopPropagation(),h.deleteQueryFromHistory(a,n)},[a]),k=r.useCallback(()=>{P(!0)},[]);return x.length===0?e.jsxs("div",{className:"query-history query-history--empty",children:[e.jsx("p",{children:c("terminal:database.noHistory")}),e.jsx("p",{children:c("terminal:database.queriesAppearHere")})]}):e.jsxs("div",{className:"query-history",children:[e.jsxs("div",{className:"query-history__toolbar",children:[e.jsx("input",{type:"text",className:"query-history__search",placeholder:c("terminal:database.searchQueries"),value:y,onChange:n=>f(n.target.value)}),e.jsxs("label",{className:"query-history__filter",children:[e.jsx("input",{type:"checkbox",checked:Q,onChange:n=>S(n.target.checked)}),c("terminal:database.favoritesOnly")]}),e.jsx("button",{className:"query-history__clear",onClick:k,title:c("terminal:database.clearAll"),children:c("terminal:database.clearAll")})]}),e.jsxs("div",{className:"query-history__list",children:[m.map(n=>e.jsxs("div",{className:`query-history__item ${n.status==="error"?"query-history__item--error":""}`,onClick:()=>l(n.query),children:[e.jsxs("div",{className:"query-history__item-header",children:[e.jsx("span",{className:`query-history__status ${n.status==="success"?"query-history__status--success":"query-history__status--error"}`,children:e.jsx(H,{name:n.status==="success"?"check":"cross",size:12})}),e.jsx("span",{className:"query-history__database",children:n.database}),e.jsx("span",{className:"query-history__date",children:q(n.executedAt)}),e.jsxs("span",{className:"query-history__duration",children:[n.duration,"ms"]}),n.rowCount!==void 0&&e.jsx("span",{className:"query-history__row-count",children:c("terminal:database.rowCount",{count:n.rowCount})})]}),e.jsx("div",{className:"query-history__query",children:e.jsx("code",{children:n.query.length>200?n.query.substring(0,200)+"...":n.query})}),n.error&&e.jsx("div",{className:"query-history__error",children:n.error}),e.jsxs("div",{className:"query-history__actions",children:[e.jsx("button",{className:`query-history__favorite ${n.favorite?"query-history__favorite--active":""}`,onClick:d=>I(n.id,d),title:n.favorite?c("terminal:database.removeFromFavorites"):c("terminal:database.addToFavorites"),children:e.jsx(H,{name:"star",size:12,weight:n.favorite?"fill":"regular",color:n.favorite?"#facc15":void 0})}),e.jsx("button",{className:"query-history__delete",onClick:d=>R(n.id,d),title:c("terminal:database.deleteFromHistory"),children:e.jsx(H,{name:"trash",size:12})})]})]},n.id)),m.length===0&&e.jsx("div",{className:"query-history__no-results",children:c("terminal:database.noQueriesMatch")})]}),e.jsx(oe,{isOpen:L,title:c("terminal:database.clearAll"),message:c("terminal:database.confirmClearHistory"),confirmLabel:c("terminal:database.clearAll"),cancelLabel:c("common:buttons.cancel"),variant:"danger",onConfirm:()=>h.clearQueryHistory(a),onClose:()=>P(!1)})]})},ye=({tabs:a,activeTabId:x,onTabClick:l,onTabClose:c})=>{const{t:y}=J(["terminal"]);return e.jsx("div",{className:"database-tabs",children:a.map(f=>e.jsxs("div",{className:`database-tabs__tab ${x===f.id?"database-tabs__tab--active":""}`,children:[e.jsxs("button",{className:"database-tabs__tab-label",onClick:()=>l(f),title:`${f.connectionName} / ${f.database}`,children:[f.database,e.jsx("span",{className:"database-tabs__tab-connection",children:f.connectionName})]}),e.jsx("button",{className:"database-tabs__tab-close",onClick:()=>c(f.id),title:y("terminal:database.closeTab"),"aria-label":`Close ${f.database} tab`,children:"×"})]},f.id))})},ee=a=>`db-panel-${a}`;function Ne(a){try{const x=localStorage.getItem(ee(a));return x?JSON.parse(x):{}}catch{return{}}}function ve(a,x){try{localStorage.setItem(ee(a),JSON.stringify(x))}catch{}}const ge=({building:a,onClose:x})=>{var B,W,Y,X;const{t:l}=J(["terminal","common"]),c=Z(a.id),y=me(a.id),f=be(a.id),Q=ue(a.id),S=r.useRef(Ne(a.id)),L=r.useRef(null),P=r.useRef(0),m=((B=a.database)==null?void 0:B.connections)??[],q=(s,i)=>`${s}:${i}`,I=s=>s?(S.current.queries??{})[s]??"":S.current.generalQuery??"",[R,k]=r.useState("results"),[n,d]=r.useState(0),[g,$]=r.useState(!1),[w,U]=r.useState(!1),[F,K]=r.useState(()=>(S.current.openTabs??[]).map(i=>{var u;return{id:`${i.connectionId}:${i.database}`,connectionId:i.connectionId,connectionName:((u=m.find(A=>A.id===i.connectionId))==null?void 0:u.name)??i.connectionId,database:i.database}})),[C,O]=r.useState(S.current.activeTabId??null),[N,G]=r.useState(()=>{const s=S.current.queries??{};return S.current.generalQuery,s}),[j,p]=r.useState(I(C)),D=r.useCallback(s=>{p(i=>{const u=typeof s=="function"?s(i):s;return G(A=>{const E={...A};return C&&(E[C]=u),E}),u})},[C]),b=c.activeConnectionId??S.current.connectionId??((W=a.database)==null?void 0:W.activeConnectionId)??((Y=m[0])==null?void 0:Y.id),_=c.activeDatabase??S.current.database??((X=a.database)==null?void 0:X.activeDatabase),z=m.find(s=>s.id===b),t=b&&_?`${b}:${_}`:"",o=t?c.tables.get(t)??[]:[],T=r.useMemo(()=>{const s=new Map;return!b||!_||o.forEach(i=>{const u=c.tableSchemas.get(`${b}:${_}:${i.name}`);u&&s.set(i.name,{columns:u.columns})}),s},[b,_,o,c.tableSchemas]),v=r.useCallback((s,i)=>{var E;const u=q(s,i),A=((E=m.find(M=>M.id===s))==null?void 0:E.name)??s;K(M=>{if(M.some(ie=>ie.id===u))return M;const ce={id:u,connectionId:s,connectionName:A,database:i};return[...M,ce]}),O(u),p(N[u]??""),h.setActiveConnection(a.id,s),h.setActiveDatabase(a.id,i)},[a.id,m,N]),ae=r.useCallback(s=>{K(i=>i.filter(u=>u.id!==s)),C===s&&K(i=>{if(i.length>0){const u=i[0];O(u.id),p(N[u.id]??""),h.setActiveConnection(a.id,u.connectionId),h.setActiveDatabase(a.id,u.database)}else O(null),p("");return i})},[C,a.id,N]),se=r.useCallback(s=>{O(s.id),p(N[s.id]??""),h.setActiveConnection(a.id,s.connectionId),h.setActiveDatabase(a.id,s.database)},[a.id,N]);r.useEffect(()=>{if(!w&&m.length>0){const s=S.current;s.connectionId&&m.some(i=>i.id===s.connectionId)&&(h.setActiveConnection(a.id,s.connectionId),h.listDatabases(a.id,s.connectionId),s.database&&(h.setActiveDatabase(a.id,s.database),h.listTables(a.id,s.connectionId,s.database))),U(!0)}},[a.id,m,w]),r.useEffect(()=>{h.requestQueryHistory(a.id)},[a.id]),r.useEffect(()=>{const s=i=>{i.key==="Escape"&&(i.preventDefault(),i.stopPropagation(),x())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[x]),r.useEffect(()=>{w&&b&&ve(a.id,{connectionId:b,database:_,lastQuery:j,queries:N,generalQuery:"",openTabs:F.map(s=>({connectionId:s.connectionId,database:s.database})),activeTabId:C??void 0})},[a.id,b,_,j,w,F,C,N]);const te=r.useCallback(s=>{var i;if(!(!b||!_||!j.trim()||Q))if(s==="cursor"){const u=(i=L.current)==null?void 0:i.querySelector(".query-editor__textarea"),A=(u==null?void 0:u.selectionStart)??P.current,E=he(j,A);E&&h.executeQuery(a.id,b,_,E)}else{const u=_e(j);if(u.length<=1)h.executeQuery(a.id,b,_,j.trim());else{const A=b,E=_;(async()=>{for(const M of u)await h.executeQueryAndWait(a.id,A,E,M.sql)})()}}},[a.id,b,_,j,Q]),ne=r.useCallback(s=>{D(s),k("results")},[]),re=r.useCallback(s=>{h.setActiveConnection(a.id,s),h.listDatabases(a.id,s)},[a.id]),le=r.useCallback(s=>{b&&(v(b,s),h.listTables(a.id,b,s))},[a.id,b,v]),V=y[n];return m.length===0?e.jsxs("div",{className:"database-panel",ref:L,children:[e.jsxs("div",{className:"database-panel__header",children:[e.jsxs("div",{className:"database-panel__title",children:[e.jsx("span",{className:"database-panel__icon",children:e.jsx(H,{name:"database",size:16})}),e.jsx("span",{className:"database-panel__name",children:a.name})]}),e.jsx("button",{className:"database-panel__close",onClick:x,children:"×"})]}),e.jsx("div",{className:"database-panel__body",children:e.jsxs("div",{className:"database-panel__no-connections",children:[e.jsx("div",{className:"database-panel__no-connections-icon",children:e.jsx(H,{name:"plug",size:32})}),e.jsx("h3",{children:l("terminal:database.noConnections")}),e.jsx("p",{children:l("terminal:database.noConnectionsDesc")}),e.jsx("p",{children:l("terminal:database.toGetStarted")}),e.jsxs("ol",{children:[e.jsx("li",{children:l("terminal:database.step1Close")}),e.jsx("li",{children:l("terminal:database.step2Settings")}),e.jsx("li",{children:l("terminal:database.step3AddConnection")}),e.jsx("li",{children:l("terminal:database.step4Reopen")})]})]})})]}):e.jsxs("div",{className:"database-panel",ref:L,children:[e.jsxs("div",{className:"database-panel__header",children:[e.jsxs("div",{className:"database-panel__title",children:[e.jsx("span",{className:"database-panel__icon",children:(z==null?void 0:z.engine)==="mysql"?"🐬":"🐘"}),e.jsx("span",{className:"database-panel__name",children:a.name}),z&&e.jsxs("span",{className:"database-panel__connection-info",children:[z.name," / ",_||l("terminal:database.noDatabaseSelected")]})]}),e.jsx("button",{className:"database-panel__close",onClick:x,children:"×"})]}),e.jsxs("div",{className:"database-panel__body",children:[e.jsx(fe,{building:a,connections:m,activeConnectionId:b,activeDatabase:_,collapsed:g,onToggleCollapse:()=>$(!g),onConnectionChange:re,onDatabaseChange:le,onInsertTable:s=>D(i=>i+` ${s}`),onSelectTableQuery:s=>{const i=`SELECT * FROM ${s}`;D(i),b&&_&&h.executeQuery(a.id,b,_,i)}}),e.jsxs("div",{className:"database-panel__main",children:[F.length>0&&e.jsx(ye,{tabs:F,activeTabId:C,onTabClick:se,onTabClose:ae}),e.jsx(pe,{query:j,onChange:D,onExecute:te,isExecuting:Q,disabled:!b||!_,tables:o,tableSchemas:T,onRequestTableSchema:s=>{b&&_&&h.getTableSchema(a.id,b,_,s)}}),e.jsxs("div",{className:"database-panel__tabs",children:[e.jsxs("button",{className:`database-panel__tab ${R==="results"?"database-panel__tab--active":""}`,onClick:()=>k("results"),children:[l("terminal:database.results"),y.length>0&&e.jsx("span",{className:"database-panel__tab-badge",children:y.length})]}),e.jsxs("button",{className:`database-panel__tab ${R==="history"?"database-panel__tab--active":""}`,onClick:()=>k("history"),children:[l("terminal:database.history"),f.length>0&&e.jsx("span",{className:"database-panel__tab-badge",children:f.length})]}),R==="results"&&y.length>1&&e.jsxs("div",{className:"database-panel__result-nav",children:[e.jsxs("button",{disabled:n>=y.length-1,onClick:()=>d(s=>s+1),children:["← ",l("terminal:database.older")]}),e.jsxs("span",{children:[n+1," / ",y.length]}),e.jsxs("button",{disabled:n<=0,onClick:()=>d(s=>s-1),children:[l("terminal:database.newer")," →"]})]})]}),e.jsx("div",{className:"database-panel__tab-content",children:R==="results"?V?e.jsx(xe,{result:V,buildingId:a.id,building:a}):e.jsxs("div",{className:"database-panel__empty",children:[e.jsx("p",{children:l("terminal:database.noResultsYet")}),e.jsx("p",{children:l("terminal:database.selectDbAndRun")})]}):e.jsx(je,{buildingId:a.id,history:f,onLoadQuery:ne})})]})]})]})};export{ge as DatabasePanel,fe as DatabaseSidebar,ye as DatabaseTabs,pe as QueryEditor,je as QueryHistoryPanel,xe as ResultsTable};
|
|
@@ -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-Brpf2Evy.js";import{FileExplorerPanel as at}from"./index-CTfxfQqV.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
|
|