tide-commander 1.199.2 → 1.199.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/assets/{AudioPlayer-XaWiU7f4.js → AudioPlayer-Cc-u3eyV.js} +1 -1
- package/dist/assets/{BossLogsModal-1tI-leZQ.js → BossLogsModal-UEx0fTra.js} +1 -1
- package/dist/assets/{BossSpawnModal-CRoChH0J.js → BossSpawnModal-BWhBAaGa.js} +1 -1
- package/dist/assets/{ControlsModal-Cu7kwhct.js → ControlsModal-Byk5wjfl.js} +1 -1
- package/dist/assets/{DockerLogsModal-DFAiOsWH.js → DockerLogsModal-BGuSToCi.js} +1 -1
- package/dist/assets/{EmbeddedEditor-hnSknX5L.js → EmbeddedEditor-CSc1gyI9.js} +1 -1
- package/dist/assets/{FcStdViewer-B_cbRz1w.js → FcStdViewer-CZ0STF0L.js} +1 -1
- package/dist/assets/{GcodeViewer-CFgwEZ6g.js → GcodeViewer-Dbh-Meoe.js} +1 -1
- package/dist/assets/{GlbViewer-14WSSXX7.js → GlbViewer-7nNJMJS-.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-waw2142C.js → GmailOAuthSetup-C97odd1c.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-Bo59grtp.js → GoogleOAuthSetup-g2LTSCFc.js} +1 -1
- package/dist/assets/{IframeModal-B3M77grB.js → IframeModal-XViOSPXb.js} +1 -1
- package/dist/assets/{IntegrationsPanel-BLHrC0GX.js → IntegrationsPanel-D08PCuel.js} +2 -2
- package/dist/assets/{LogViewerModal-CitlmDgQ.js → LogViewerModal-D5gC69in.js} +1 -1
- package/dist/assets/{MonitoringModal-BcKOCSRM.js → MonitoringModal-BIrdFwjx.js} +1 -1
- package/dist/assets/{PM2LogsModal-DrHpuMNf.js → PM2LogsModal-DKmeAtkQ.js} +1 -1
- package/dist/assets/{RestoreArchivedAreaModal-DcD3vdUJ.js → RestoreArchivedAreaModal-B1PIKYYj.js} +1 -1
- package/dist/assets/{Scene2DCanvas-DKUcFYZW.js → Scene2DCanvas-BXn0oqeE.js} +1 -1
- package/dist/assets/{SceneManager-DPojKMM-.js → SceneManager-Dtw0_zlT.js} +1 -1
- package/dist/assets/{SkillsPanel-CUW0prbh.js → SkillsPanel-BxI09wuY.js} +1 -1
- package/dist/assets/{SlackMultiInstanceSetup-YFYeZ94t.js → SlackMultiInstanceSetup-DG9m0YWC.js} +1 -1
- package/dist/assets/{SpawnModal-DPvq-R5b.js → SpawnModal-kAJ8vugr.js} +1 -1
- package/dist/assets/{StatisticsModal-Dt-Hof51.js → StatisticsModal-CeydmTqR.js} +1 -1
- package/dist/assets/{StlViewer-GyyomEax.js → StlViewer-TV7hesvt.js} +1 -1
- package/dist/assets/{SubordinateAssignmentModal-ahzGBjr4.js → SubordinateAssignmentModal-BdSlca0C.js} +1 -1
- package/dist/assets/{ThreeAreaSelector-Bj_mL6NG.js → ThreeAreaSelector-DSeyJIE9.js} +1 -1
- package/dist/assets/{ThreeViewShortcuts-CKtE3yZV.js → ThreeViewShortcuts-B8niKYtb.js} +1 -1
- package/dist/assets/{TriggerManagerPanel-DtdbOk9B.js → TriggerManagerPanel-DD8gHCn9.js} +1 -1
- package/dist/assets/{VideoPlayer-Crq-MwPS.js → VideoPlayer-Ba5ZHdPo.js} +1 -1
- package/dist/assets/{WorkflowEditorPanel-CitR9Em3.js → WorkflowEditorPanel-BagsxRw7.js} +1 -1
- package/dist/assets/{abnfDiagram-VRR7QNED-QFcuJYPe.js → abnfDiagram-VRR7QNED-CROt6ByM.js} +1 -1
- package/dist/assets/{arc-CLuSzQ4E.js → arc-D9e3N6Jp.js} +1 -1
- package/dist/assets/{architectureDiagram-ZJ3FMSHR-DlhVck93.js → architectureDiagram-ZJ3FMSHR-COTDsgDe.js} +1 -1
- package/dist/assets/{area-logos-DYARiYqI.js → area-logos-11FyfgIm.js} +1 -1
- package/dist/assets/{blockDiagram-677ZJIJ3-CJwOmsfj.js → blockDiagram-677ZJIJ3-dSFbtfjs.js} +1 -1
- package/dist/assets/{c4Diagram-LMCZKHZV-OsgCNPWJ.js → c4Diagram-LMCZKHZV-DYDo7euY.js} +1 -1
- package/dist/assets/channel-DjG11_DZ.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-KG-L7vvm.js → chunk-2Q5K7J3B-BHmTxu7p.js} +1 -1
- package/dist/assets/{chunk-32BRIVSS-BXGbqO9v.js → chunk-32BRIVSS-BUnnt_Ip.js} +1 -1
- package/dist/assets/{chunk-5VM5RSS4-BWXkm8f0.js → chunk-5VM5RSS4-BQiFqh1-.js} +1 -1
- package/dist/assets/{chunk-EX3LRPZG-7-8ulJ19.js → chunk-EX3LRPZG-Bf347Bc1.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-mkwFN5xu.js → chunk-JWPE2WC7-E1cvFM5U.js} +1 -1
- package/dist/assets/{chunk-MOJQB5TN-WEfWznKE.js → chunk-MOJQB5TN-lXncAEzU.js} +1 -1
- package/dist/assets/{chunk-RYQCIY6F-ByP5odu4.js → chunk-RYQCIY6F-PbgD4U9i.js} +1 -1
- package/dist/assets/{chunk-V7JOEXUC-yWHmp1L1.js → chunk-V7JOEXUC-BaxLrntE.js} +1 -1
- package/dist/assets/{chunk-VR4S4FIN-DHbZaHzt.js → chunk-VR4S4FIN-CtA1Pg8N.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-SNa-Wh3U.js → chunk-XXDRQBXY-CHA3dDHm.js} +1 -1
- package/dist/assets/classDiagram-OUVF2IWQ-J0l72d33.js +1 -0
- package/dist/assets/classDiagram-v2-EOCWNBFH-J0l72d33.js +1 -0
- package/dist/assets/{cose-bilkent-JH36ORCC-CyxHYUhP.js → cose-bilkent-JH36ORCC-D1nCEdoB.js} +1 -1
- package/dist/assets/{cynefin-VYW2F7L2-BvwjSDiQ.js → cynefin-VYW2F7L2-ebaABOLt.js} +1 -1
- package/dist/assets/{cynefinDiagram-TSTJHNR4-C8doInhn.js → cynefinDiagram-TSTJHNR4-3Tl079fU.js} +1 -1
- package/dist/assets/{dagre-VKFMJZFB-BNDcupek.js → dagre-VKFMJZFB-BRTJGzE5.js} +1 -1
- package/dist/assets/{diagram-FQU43EPY-Bst0bBnQ.js → diagram-FQU43EPY-DfCfHsbK.js} +1 -1
- package/dist/assets/{diagram-G47NLZAW-CfEv0aTY.js → diagram-G47NLZAW-CAwc9cT_.js} +1 -1
- package/dist/assets/{diagram-NH7WQ7WH-B7MYvWXL.js → diagram-NH7WQ7WH-TvVEUeYk.js} +1 -1
- package/dist/assets/{diagram-OA4YK3LP-BIzII0d2.js → diagram-OA4YK3LP--zG7OL2f.js} +1 -1
- package/dist/assets/{diagram-WEI45ONY-D5yd1HWr.js → diagram-WEI45ONY-BIQMWmaa.js} +1 -1
- package/dist/assets/{ebnfDiagram-CCIWWBDH-gyhVYUos.js → ebnfDiagram-CCIWWBDH-rLx0RZev.js} +1 -1
- package/dist/assets/{erDiagram-Q63AITRT-Duz-DwfE.js → erDiagram-Q63AITRT-TXRWuEkV.js} +1 -1
- package/dist/assets/{flowDiagram-23GEKE2U-CrnARkmw.js → flowDiagram-23GEKE2U-D6EIzoiy.js} +1 -1
- package/dist/assets/{ganttDiagram-NO4QXBWP-D6cBteIN.js → ganttDiagram-NO4QXBWP-mFuR-lGL.js} +1 -1
- package/dist/assets/{gitGraphDiagram-IHSO6WYX-CMHfr_lR.js → gitGraphDiagram-IHSO6WYX-CN2pc0PX.js} +1 -1
- package/dist/assets/{index-DJKuwqJG.js → index-BIqCk3dy.js} +2 -2
- package/dist/assets/{index-DeqoOoo6.js → index-BIr8T2rA.js} +1 -1
- package/dist/assets/{index-CbMtvQTH.js → index-BMUuC9nl.js} +1 -1
- package/dist/assets/{index-D5O_0aq9.js → index-Bdg8anAc.js} +1 -1
- package/dist/assets/{index-2427ATYD.js → index-BoKhs4hC.js} +3 -3
- package/dist/assets/{index-B5wHDczA.js → index-BprMc5QY.js} +1 -1
- package/dist/assets/{index-B1vOCcI-.js → index-Cds2jftW.js} +1 -1
- package/dist/assets/{index-fiC5OXgR.js → index-CzY226TA.js} +1 -1
- package/dist/assets/{index-D5pIRxFm.js → index-D6703TzG.js} +1 -1
- package/dist/assets/{infoDiagram-FWYZ7A6U-Mvk2Mpp3.js → infoDiagram-FWYZ7A6U-Dslv7o7P.js} +1 -1
- package/dist/assets/{ishikawaDiagram-FXEZZL3T-DXsaNDYg.js → ishikawaDiagram-FXEZZL3T-CqfNFX7v.js} +1 -1
- package/dist/assets/{journeyDiagram-5HDEW3XC-6QlK8xHN.js → journeyDiagram-5HDEW3XC-DfRqgnKT.js} +1 -1
- package/dist/assets/{kanban-definition-HUTT4EX6-D5EeRs07.js → kanban-definition-HUTT4EX6-DsLEjOKL.js} +1 -1
- package/dist/assets/{linear-D_aP9MD5.js → linear-BuJKasyP.js} +1 -1
- package/dist/assets/{main-Dk3qq80S.js → main-CICvC5Bz.js} +158 -158
- package/dist/assets/main-Dzc0Sg9A.css +1 -0
- package/dist/assets/{mermaid.core-CEculPxD.js → mermaid.core-DfJsBqur.js} +4 -4
- package/dist/assets/{mindmap-definition-LN4V7U3C-Vjj9vgEN.js → mindmap-definition-LN4V7U3C-Bz3QYsFb.js} +1 -1
- package/dist/assets/{pegDiagram-2B236MQR-B-AwbaoO.js → pegDiagram-2B236MQR-Lmd49Wyn.js} +1 -1
- package/dist/assets/{pieDiagram-ENE6RG2P-D5o1UYPK.js → pieDiagram-ENE6RG2P-BumyYR7Y.js} +1 -1
- package/dist/assets/{quadrantDiagram-ABIIQ3AL-Bl_Rbmz-.js → quadrantDiagram-ABIIQ3AL-PaHoiQa5.js} +1 -1
- package/dist/assets/{railroadDiagram-RFXS5EU6-CW-qy1dp.js → railroadDiagram-RFXS5EU6-C4a6X7uQ.js} +1 -1
- package/dist/assets/{requirementDiagram-TGXJPOKE-DGUQpy3K.js → requirementDiagram-TGXJPOKE-ClZWU4ZI.js} +1 -1
- package/dist/assets/{sankeyDiagram-HTMAVEWB-CUlWZH9G.js → sankeyDiagram-HTMAVEWB-CWpqNtW9.js} +1 -1
- package/dist/assets/{sequenceDiagram-DBY2YBRQ-CeDVJrbJ.js → sequenceDiagram-DBY2YBRQ-UQx3N2fu.js} +1 -1
- package/dist/assets/{sizeCapture-X5ZJPWSS-BGSL3ofq.js → sizeCapture-X5ZJPWSS-5rkdwFAp.js} +1 -1
- package/dist/assets/{stateDiagram-2N3HPSRC-9A8tAPIu.js → stateDiagram-2N3HPSRC-CBHPNiNT.js} +1 -1
- package/dist/assets/stateDiagram-v2-6OUMAXLB-CSOxSxBR.js +1 -0
- package/dist/assets/{swimlanes-5IMT3BWC-CipRR1uk.js → swimlanes-5IMT3BWC-vIQeo3xN.js} +2 -2
- package/dist/assets/swimlanesDiagram-G3AALYLV-B_DV4epp.js +8 -0
- package/dist/assets/{timeline-definition-FHXFAJF6-IgrCsFe-.js → timeline-definition-FHXFAJF6-CL9O0jtE.js} +1 -1
- package/dist/assets/{vennDiagram-L72KCM5P-okSGsDy3.js → vennDiagram-L72KCM5P-CMK1QWzt.js} +1 -1
- package/dist/assets/{wardleyDiagram-EHGQE667-G0RLggUt.js → wardleyDiagram-EHGQE667-Dohoga92.js} +1 -1
- package/dist/assets/{web-B5BfOO5C.js → web-BNTP1enS.js} +1 -1
- package/dist/assets/{web-BPOqvnJL.js → web-DVVqKstc.js} +1 -1
- package/dist/assets/{web-Q8DwQW0W.js → web-_8i7sQiH.js} +1 -1
- package/dist/assets/{xychartDiagram-FW5EYKEG-DtVJEFyI.js → xychartDiagram-FW5EYKEG-E_KRPyA8.js} +1 -1
- package/dist/build-info.json +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/dist/assets/channel-cpl_NpAy.js +0 -1
- package/dist/assets/classDiagram-OUVF2IWQ-D_lsO4mm.js +0 -1
- package/dist/assets/classDiagram-v2-EOCWNBFH-D_lsO4mm.js +0 -1
- package/dist/assets/main-B2ZLroL1.css +0 -1
- package/dist/assets/stateDiagram-v2-6OUMAXLB-DzVFFq0g.js +0 -1
- package/dist/assets/swimlanesDiagram-G3AALYLV-XDQw-C4e.js +0 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{u as Ie,au as oo,av as so,r as i,g as Ee,j as e,Z as we,s as x,a7 as ro,aw as to,ax as ao,N as Le,d as K,L as ze,i as io,z as lo,k as co,ay as I,n as no,M as Pe,I as yo,c as Me}from"./main-
|
|
1
|
+
import{u as Ie,au as oo,av as so,r as i,g as Ee,j as e,Z as we,s as x,a7 as ro,aw as to,ax as ao,N as Le,d as K,L as ze,i as io,z as lo,k as co,ay as I,n as no,M as Pe,I as yo,c as Me}from"./main-CICvC5Bz.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-DYBBrXTx.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-YFYeZ94t.js → SlackMultiInstanceSetup-DG9m0YWC.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as h,j as e,c as b,d as m}from"./main-Dk3qq80S.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-DYBBrXTx.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,c as b,d as m}from"./main-CICvC5Bz.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-DYBBrXTx.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 as,i as ts,k as ls,l as is,B as os,r as t,m as Ie,S as oe,D as cs,C as ce,A as _e,d as re,c as rs,s as S,g as ds,j as e,M as ps,n as Le,H as x,F as ms,P as de,I as pe,o as T,p as X,O as us,G as Y,q as hs,t as me,v as ws,w as ue,x as xs,y as fs}from"./main-Dk3qq80S.js";import{D as js}from"./common-types-CZVd6J8k.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-DYBBrXTx.js";function $e(d,g){const b=g.filter(C=>!d.has(C));return b.length===0?`${g[Math.floor(Math.random()*g.length)]}-${Date.now()%1e3}`:b[Math.floor(Math.random()*b.length)]}function bs({isOpen:d,onClose:g,onSpawnStart:b,onSpawnEnd:C,spawnPosition:Pe,spawnAreaId:v}){const{t:n}=as(["terminal","common"]),F=ts(),p=ls(),he=is(),Q=he.length>0?he:os,[m,N]=t.useState(""),[k,O]=t.useState(()=>Ie(oe.LAST_CWD)),[o,M]=t.useState("scout"),[we,I]=t.useState(!1),[Te,R]=t.useState(!1),[xe,V]=t.useState(!1),[fe,je]=t.useState(""),[y,Z]=t.useState([]),[E,U]=t.useState(null),[Fe,ge]=t.useState(!1),[_,ve]=t.useState(""),[h,Oe]=t.useState(""),[z,Re]=t.useState(!1),[G,Ue]=t.useState("bypass"),[i,L]=t.useState("claude"),[f,A]=t.useState({fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),[ee,se]=t.useState(new Set),[ne,Ne]=t.useState("claude-opus-4-8[1m]"),[q,Se]=t.useState("xHigh"),[ae,ze]=t.useState("gpt-5.6-luna"),[te,Ge]=t.useState("minimax/MiniMax-M1-80k"),[W,qe]=t.useState(cs),[le,We]=t.useState(""),[be,Be]=t.useState(""),[D,Ke]=t.useState(""),B=t.useRef(null),Ce=t.useRef(!1),$=t.useCallback(()=>{window.__spawnModalAreaContext=null},[]),w=t.useMemo(()=>F.filter(s=>s.enabled),[F]);t.useEffect(()=>{if(d&&!Ce.current){if(w.length>0){const l=w.filter(r=>js.includes(r.slug)).map(r=>r.id);l.length>0&&se(new Set(l))}const a=Ie(oe.DEFAULT_AGENT_CLASS);if(a==="random"){const r=[...Object.keys(xs),...p.map(u=>u.id)];M(r[Math.floor(Math.random()*r.length)])}else M(a||"scout")}Ce.current=d},[d,w,p]);const ke=t.useMemo(()=>{if(!D.trim())return w;const s=D.toLowerCase();return w.filter(a=>a.name.toLowerCase().includes(s)||a.description.toLowerCase().includes(s)||a.slug.toLowerCase().includes(s))},[w,D]),He=t.useCallback(s=>{se(a=>{const l=new Set(a);return l.has(s)?l.delete(s):l.add(s),l})},[]);t.useMemo(()=>w.filter(s=>s.assignedAgentClasses.includes(o)),[w,o]);const Je=t.useMemo(()=>{var a;const s=p.find(l=>l.id===o);return(a=s==null?void 0:s.defaultSkillIds)!=null&&a.length?F.filter(l=>s.defaultSkillIds.includes(l.id)):[]},[p,o,F]),Me=t.useMemo(()=>{if(!_.trim())return y;const s=_.toLowerCase();return y.filter(a=>a.sessionId.toLowerCase().includes(s)||a.projectPath.toLowerCase().includes(s)||a.firstMessage&&a.firstMessage.toLowerCase().includes(s))},[y,_]),K=t.useMemo(()=>{if(!h.trim())return p;const s=h.toLowerCase();return p.filter(a=>a.name.toLowerCase().includes(s)||a.description.toLowerCase().includes(s)||a.id.toLowerCase().includes(s))},[p,h]),H=t.useMemo(()=>{if(!h.trim())return ce;const s=h.toLowerCase();return ce.filter(a=>{const l=_e[a.id];return a.name.toLowerCase().includes(s)||a.id.toLowerCase().includes(s)||l.description.toLowerCase().includes(s)})},[h]);t.useEffect(()=>{if(!d||!h.trim())return;const s=[...K.map(a=>a.id),...H.map(a=>a.id)];s.length===1&&s[0]!==o&&M(s[0])},[d,h,K,H,o]);const c=t.useMemo(()=>p.find(s=>s.id===o),[p,o]),Xe=t.useMemo(()=>{if(c!=null&&c.model)return c.model},[c]),Ye=t.useMemo(()=>{if(c!=null&&c.customModelPath)return re(`/api/custom-models/${c.id}`)},[c]),Qe=c==null?void 0:c.modelScale,Ve=t.useMemo(()=>c?"scout":o,[o,c]),J=t.useCallback(async s=>{ge(!0);try{const a=s?re(`/api/agents/claude-sessions?cwd=${encodeURIComponent(s)}`):re("/api/agents/claude-sessions"),r=await(await rs(a)).json();Z(r.sessions||[])}catch(a){console.error("Failed to fetch sessions:",a),Z([])}finally{ge(!1)}},[]);t.useEffect(()=>{d?J(k||void 0):(Z([]),U(null),ve(""))},[d,J]),t.useEffect(()=>{if(!d)return;const s=setTimeout(()=>{J(k||void 0),U(null)},300);return()=>clearTimeout(s)},[k,d,J]),t.useEffect(()=>{if(!d||!v)return;const s=S.getState().areas.get(v);if(s!=null&&s.directories&&s.directories.length>0){O(s.directories[0]);return}const a=Array.from(S.getState().agents.values()).filter(j=>{var P;return((P=S.getAreaForAgent(j.id))==null?void 0:P.id)===v&&j.cwd});if(a.length===0)return;const l=new Map;for(const j of a)l.set(j.cwd,(l.get(j.cwd)||0)+1);let r="",u=0;for(const[j,P]of l)P>u&&(r=j,u=P);r&&O(r)},[d,v]),t.useEffect(()=>{if(d){const s=new Set(Array.from(S.getState().agents.values()).map(u=>u.name)),a=$e(s,Q),l=p.find(u=>u.id===o),r=l?`${l.name} ${a}`:a;N(r),B.current&&(B.current.focus(),B.current.select())}},[d,Q]),t.useEffect(()=>{if(!d)return;const s=p.find(a=>a.id===o);if(s){const a=p.find(l=>m.startsWith(l.name+" "));if(a){const l=m.substring(a.name.length+1);N(`${s.name} ${l}`)}else N(`${s.name} ${m}`)}else{const a=p.find(l=>m.startsWith(l.name+" "));if(a){const l=m.substring(a.name.length+1);N(l)}}},[o]),t.useEffect(()=>{o==="boss"&&Ne("claude-opus-4-8[1m]")},[o]);const Ze=()=>{var r;console.log("[SpawnModal] handleSpawn called"),R(!1);const s=E&&((r=y.find(u=>u.sessionId===E))==null?void 0:r.projectPath)||k;if(console.log("[SpawnModal] Effective CWD:",s),console.log("[SpawnModal] Agent name:",m),console.log("[SpawnModal] Agent class:",o),console.log("[SpawnModal] Permission mode:",G),console.log("[SpawnModal] Provider:",i),console.log("[SpawnModal] Use Chrome:",z),console.log("[SpawnModal] Session ID:",E||"none"),!s.trim()){console.error("[SpawnModal] Empty CWD, showing error"),R(!0);return}if(!m.trim()){console.log("[SpawnModal] Empty name, regenerating");const u=new Set(Array.from(S.getState().agents.values()).map(j=>j.name));N($e(u,Q));return}fs(oe.LAST_CWD,s),I(!0),b();const a=Array.from(ee),l=be.trim()||void 0;console.log("[SpawnModal] Calling store.spawnAgent with:",{name:m.trim(),class:o,cwd:s.trim(),sessionId:E||void 0,useChrome:i==="claude"?z:!1,permissionMode:G,provider:i,codexConfig:i==="codex"?f:void 0,codexModel:i==="codex"?ae:void 0,opencodeModel:i==="opencode"?te:void 0,grokModel:i==="grok"?W:void 0,piModel:i==="pi"&&le||void 0,initialSkillIds:a,model:i==="claude"?ne:void 0,customInstructions:l?`${l.length} chars`:void 0,spawnAreaId:v||void 0}),window.__spawnModalAreaContext=v?{areaId:v}:null,S.spawnAgent(m.trim(),o,s.trim(),Pe||void 0,E||void 0,i==="claude"?z:!1,G,a,i,i==="codex"?f:void 0,i==="codex"?ae:void 0,i==="claude"?ne:void 0,l,i==="claude"||i==="grok"||i==="pi"?q:void 0,i==="opencode"?te:void 0,i==="grok"?W:void 0,i==="pi"&&le||void 0)},ye=()=>{console.log("[SpawnModal] Agent creation successful"),I(!1),N(""),se(new Set),$(),C(),g()},Ee=()=>{console.error("[SpawnModal] Agent creation failed"),I(!1),R(!0),$(),C()},Ae=s=>{console.log("[SpawnModal] Directory not found:",s),I(!1),je(s),V(!0),C()},De=()=>{V(!1),I(!0),b(),S.createDirectoryAndSpawn(fe,m.trim(),o)},ie=()=>{V(!1),je(""),$()};t.useEffect(()=>(window.__spawnModalSuccess=ye,window.__spawnModalError=Ee,window.__spawnModalDirNotFound=Ae,()=>{$(),delete window.__spawnModalSuccess,delete window.__spawnModalError,delete window.__spawnModalDirNotFound}),[m,o,ye,Ee,Ae,$]);const{handleMouseDown:es,handleClick:ss}=ds(g),ns=s=>{s.key==="Escape"&&g()};return!d&&!xe?null:xe?e.jsx("div",{className:"modal-overlay visible",onClick:ie,onKeyDown:s=>{s.key==="Escape"&&ie(),s.key==="Enter"&&De()},children:e.jsxs("div",{className:"modal confirm-modal",onClick:s=>s.stopPropagation(),children:[e.jsx("div",{className:"modal-header",children:n("terminal:spawn.directoryNotFound")}),e.jsxs("div",{className:"modal-body confirm-modal-body",children:[e.jsx("p",{children:n("terminal:spawn.directoryNotExist")}),e.jsx("code",{className:"confirm-modal-path",children:fe}),e.jsx("p",{children:n("terminal:spawn.wouldYouCreate")})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:ie,children:n("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-primary",onClick:De,autoFocus:!0,children:n("terminal:spawn.createDirectory")})]})]})}):e.jsx("div",{className:`modal-overlay ${d?"visible":""}`,onMouseDown:es,onClick:ss,onKeyDown:ns,children:e.jsxs("div",{className:"modal spawn-modal",children:[e.jsx("div",{className:"modal-header",children:n("terminal:spawn.deployTitle")}),e.jsxs("div",{className:"modal-body spawn-modal-body",children:[e.jsxs("div",{className:"spawn-section",children:[e.jsxs("div",{className:"spawn-section-header",children:[e.jsx("h4",{className:"spawn-section-title",children:n("terminal:spawn.agentClass")}),e.jsx("span",{className:"spawn-section-hint",children:(c==null?void 0:c.name)||o})]}),e.jsxs("div",{className:"spawn-top-section",children:[e.jsxs("div",{className:"spawn-preview-compact",children:[e.jsx(ps,{agentClass:Ve,modelFile:Xe,customModelUrl:Ye,modelScale:Qe,width:110,height:130}),e.jsx("div",{className:"spawn-preview-label",children:(c==null?void 0:c.name)||o})]}),e.jsxs("div",{className:"spawn-class-section",children:[p.length+ce.length>6&&e.jsx("input",{type:"text",className:"spawn-input class-search-input",placeholder:n("terminal:spawn.filterClasses"),value:h,onChange:s=>Oe(s.target.value)}),e.jsxs("div",{className:"class-selector-inline",children:[K.map(s=>e.jsxs("button",{className:`class-chip ${o===s.id?"selected":""}`,onClick:()=>M(s.id),title:s.description,children:[e.jsx(Le,{classId:s.id,size:18,className:"class-chip-icon"}),e.jsx("span",{className:"class-chip-name",children:s.name})]},s.id)),H.map(s=>{const a=_e[s.id];return e.jsxs("button",{className:`class-chip ${o===s.id?"selected":""}`,onClick:()=>M(s.id),title:a.description,children:[e.jsx(Le,{classId:s.id,size:18,className:"class-chip-icon"}),e.jsx("span",{className:"class-chip-name",children:s.name})]},s.id)}),h&&K.length===0&&H.length===0&&e.jsx("div",{className:"class-search-empty",children:n("terminal:spawn.noClassesMatch",{query:h})})]})]})]}),e.jsxs("div",{className:"spawn-form-row",children:[e.jsxs("div",{className:"spawn-field",children:[e.jsx("label",{className:"spawn-label",children:n("common:labels.name")}),e.jsx("input",{ref:B,type:"text",className:"spawn-input",placeholder:n("terminal:spawn.agentNamePlaceholder"),value:m,onChange:s=>N(s.target.value)})]}),e.jsxs("div",{className:"spawn-field spawn-field-wide",children:[e.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.workingDir"),e.jsx(x,{text:n("terminal:spawn.helpWorkingDir"),title:n("terminal:spawn.workingDir"),position:"top",size:"sm"})]}),e.jsx(ms,{value:k,onChange:s=>{O(s),R(!1)},placeholder:n("terminal:spawn.workingDirPlaceholder"),className:`spawn-input ${Te?"error":""}`,directoriesOnly:!0})]})]})]}),e.jsxs("div",{className:"spawn-section",children:[e.jsx("div",{className:"spawn-section-header",children:e.jsx("h4",{className:"spawn-section-title",children:n("terminal:spawn.selectRuntime")})}),e.jsxs("div",{className:"spawn-form-row",children:[e.jsxs("div",{className:"spawn-field",children:[e.jsxs("label",{className:"spawn-label",children:[n("common:labels.runtime"),e.jsx(x,{text:n("terminal:spawn.helpRuntime"),title:n("terminal:spawn.runtimeTitle"),position:"top",size:"sm"})]}),e.jsxs("div",{className:"spawn-select-row",children:[e.jsxs("button",{className:`spawn-select-btn ${i==="claude"?"selected":""}`,onClick:()=>L("claude"),title:n("terminal:spawn.useClaudeCli"),children:[e.jsx("img",{src:"/assets/claude.ico",alt:"Claude",className:"spawn-provider-icon"}),e.jsx("span",{children:"Claude"})]}),e.jsxs("button",{className:`spawn-select-btn ${i==="codex"?"selected":""}`,onClick:()=>L("codex"),title:n("terminal:spawn.useCodexCli"),children:[e.jsx("img",{src:"/assets/codex.ico",alt:"Codex",className:"spawn-provider-icon"}),e.jsx("span",{children:"Codex"})]}),e.jsxs("button",{className:`spawn-select-btn spawn-select-btn--opencode ${i==="opencode"?"selected":""}`,onClick:()=>L("opencode"),title:"Use OpenCode CLI (multi-provider)",children:[e.jsx("img",{src:"/assets/opencode.svg",alt:"OpenCode",className:"spawn-provider-icon"}),e.jsx("span",{children:"OpenCode"})]}),e.jsxs("button",{className:`spawn-select-btn spawn-select-btn--grok ${i==="grok"?"selected":""}`,onClick:()=>L("grok"),title:"Use Grok CLI (headless)",children:[e.jsx("img",{src:"/assets/grok.png",alt:"Grok",className:"spawn-provider-icon"}),e.jsx("span",{children:"Grok"})]}),e.jsxs("button",{className:`spawn-select-btn spawn-select-btn--pi ${i==="pi"?"selected":""}`,onClick:()=>L("pi"),title:"Use Pi coding agent CLI (multi-provider)",children:[e.jsx("img",{src:"/assets/pi.svg",alt:"Pi",className:"spawn-provider-icon"}),e.jsx("span",{children:"Pi"})]})]})]}),e.jsxs("div",{className:"spawn-field",children:[e.jsxs("label",{className:"spawn-label",children:[n("common:labels.permissions"),e.jsx(x,{text:n("terminal:spawn.helpPermission"),title:n("terminal:spawn.permissionMode"),position:"top",size:"sm"})]}),e.jsx("div",{className:"spawn-select-row",children:Object.keys(de).map(s=>e.jsxs("button",{className:`spawn-select-btn ${G===s?"selected":""}`,onClick:()=>Ue(s),title:de[s].description,children:[e.jsx("span",{children:e.jsx(pe,{name:s==="bypass"?"bolt":"lock",size:12})}),e.jsx("span",{children:de[s].label})]},s))})]})]}),e.jsx("div",{className:"spawn-form-row",children:e.jsxs("div",{className:"spawn-field",children:[e.jsxs("label",{className:"spawn-label",children:[n("common:labels.model"),e.jsx(x,{text:n("terminal:spawn.helpModel"),title:n("terminal:spawn.modelTitle"),position:"top",size:"sm"})]}),i==="claude"?e.jsx("div",{className:"spawn-select-row spawn-select-row--wrap",children:Object.keys(T).filter(s=>!T[s].deprecated).map(s=>e.jsxs("button",{className:`spawn-select-btn ${ne===s?"selected":""}`,onClick:()=>Ne(s),title:T[s].description,children:[e.jsx("span",{children:T[s].icon}),e.jsx("span",{children:T[s].label})]},s))}):i==="codex"?e.jsx("div",{className:"spawn-select-row spawn-select-row--codex-models",children:Object.keys(X).map(s=>e.jsxs("button",{className:`spawn-select-btn ${ae===s?"selected":""}`,onClick:()=>ze(s),title:X[s].description,children:[e.jsx("span",{children:X[s].icon}),e.jsx("span",{children:X[s].label})]},s))}):i==="opencode"?e.jsx(us,{value:te,onChange:Ge,inputId:"spawn-opencode-model"}):i==="grok"?e.jsx("div",{className:"spawn-select-row spawn-select-row--wrap",children:Object.keys(Y).map(s=>e.jsxs("button",{className:`spawn-select-btn ${W===s?"selected":""}`,onClick:()=>qe(s),title:Y[s].description,children:[e.jsx("span",{children:Y[s].icon}),e.jsx("span",{children:Y[s].label})]},s))}):i==="pi"?e.jsx(hs,{value:le,onChange:We,inputId:"spawn-pi-model"}):e.jsx("div",{className:"spawn-inline-hint",children:n("terminal:spawn.chooseCodexModel")})]})}),e.jsxs("div",{className:"spawn-form-row",children:[(i==="claude"||i==="grok"||i==="pi")&&e.jsxs("div",{className:"spawn-field",children:[e.jsx("label",{className:"spawn-label",children:"Effort"}),e.jsxs("div",{className:"spawn-select-row spawn-select-row--effort",children:[e.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${q===void 0?"selected":""}`,onClick:()=>Se(void 0),title:"Use default effort level",children:e.jsx("span",{children:"Default"})}),Object.keys(me).filter(s=>i!=="grok"||ws(W,s)||q===s).map(s=>e.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${q===s?"selected":""}`,onClick:()=>Se(s),title:me[s].description,children:e.jsx("span",{children:me[s].label})},s))]})]}),e.jsxs("div",{className:"spawn-field",children:[e.jsx("label",{className:"spawn-label",children:n("terminal:spawn.browser")}),e.jsxs("label",{className:"spawn-checkbox",children:[e.jsx("input",{type:"checkbox",checked:z,onChange:s=>Re(s.target.checked),disabled:i!=="claude"}),e.jsxs("span",{children:[e.jsx(pe,{name:"globe",size:12})," ",n("terminal:spawn.chromeBrowser")]}),e.jsx(x,{text:n(i==="claude"?"terminal:spawn.helpChrome":"terminal:spawn.helpChromeDisabled"),title:n("terminal:spawn.chromeBrowser"),position:"top",size:"sm"})]})]})]}),i==="codex"&&e.jsxs("div",{className:"codex-config-section",children:[e.jsx("div",{className:"codex-config-title",children:n("terminal:spawn.codex.configuration")}),e.jsxs("div",{className:"codex-config-options",children:[e.jsxs("div",{className:"codex-option-group",children:[e.jsxs("label",{className:"spawn-checkbox",children:[e.jsx("input",{type:"checkbox",checked:f.fullAuto!==!1,onChange:s=>A(a=>({...a,fullAuto:s.target.checked}))}),e.jsx("span",{children:n("terminal:spawn.codex.fullAuto")}),e.jsx(x,{text:n("terminal:spawn.helpFullAuto"),title:n("terminal:spawn.fullAutoTitle"),position:"top",size:"sm"})]}),e.jsxs("label",{className:"spawn-checkbox",children:[e.jsx("input",{type:"checkbox",checked:!!f.search,onChange:s=>A(a=>({...a,search:s.target.checked}))}),e.jsx("span",{children:n("terminal:spawn.codex.search")}),e.jsx(x,{text:n("terminal:spawn.helpSearch"),title:n("terminal:spawn.searchTitle"),position:"top",size:"sm"})]})]}),f.fullAuto===!1&&e.jsxs("div",{className:"codex-option-group",children:[e.jsx("div",{className:"codex-option-header",children:n("terminal:spawn.codex.restrictions")}),e.jsxs("select",{className:"spawn-input codex-select",value:f.sandbox||"workspace-write",onChange:s=>A(a=>({...a,sandbox:s.target.value})),children:[e.jsxs("option",{value:"read-only",children:["📖 ",n("terminal:spawn.codex.sandboxReadOnly")]}),e.jsxs("option",{value:"workspace-write",children:["✏️ ",n("terminal:spawn.codex.sandboxWorkspaceWrite")]}),e.jsxs("option",{value:"danger-full-access",children:["⚡ ",n("terminal:spawn.codex.sandboxDangerFullAccess")]})]}),e.jsxs("select",{className:"spawn-input codex-select",value:f.approvalMode||"on-request",onChange:s=>A(a=>({...a,approvalMode:s.target.value})),children:[e.jsxs("option",{value:"untrusted",children:["🔒 ",n("terminal:spawn.codex.approvalsUntrusted")]}),e.jsxs("option",{value:"on-failure",children:["⚠️ ",n("terminal:spawn.codex.approvalsOnFailure")]}),e.jsxs("option",{value:"on-request",children:["🤔 ",n("terminal:spawn.codex.approvalsOnRequest")]}),e.jsxs("option",{value:"never",children:["✅ ",n("terminal:spawn.codex.approvalsNever")]})]})]}),e.jsxs("div",{className:"codex-option-group",children:[e.jsx("div",{className:"codex-option-header",children:n("terminal:spawn.codex.profile")}),e.jsx("input",{type:"text",className:"spawn-input codex-profile-input",placeholder:n("terminal:spawn.codex.profilePlaceholder"),value:f.profile||"",onChange:s=>A(a=>({...a,profile:s.target.value||void 0}))})]}),e.jsxs("div",{className:"codex-option-group",children:[e.jsx("div",{className:"codex-option-header",children:n("terminal:spawn.codex.reasoningEffort")}),e.jsxs("select",{className:"spawn-input codex-select",value:f.reasoningEffort||"",onChange:s=>A(a=>({...a,reasoningEffort:s.target.value||void 0})),children:[e.jsx("option",{value:"",children:n("terminal:spawn.codex.reasoningEffortDefault")}),Object.keys(ue).map(s=>e.jsxs("option",{value:s,children:[ue[s].icon," ",ue[s].label]},s))]})]})]})]})]}),w.length>0&&e.jsxs("div",{className:"spawn-section spawn-skills-section",children:[e.jsxs("div",{className:"spawn-section-header",children:[e.jsxs("h4",{className:"spawn-section-title",children:[n("terminal:spawn.skills"),e.jsx(x,{text:n("terminal:spawn.helpSkills"),title:n("terminal:spawn.skillsTitle"),position:"top",size:"sm"})]}),e.jsxs("span",{className:"spawn-section-hint",children:[ee.size," selected · ",n("common:labels.optional")]})]}),w.length>6&&e.jsx("input",{type:"text",className:"spawn-input skill-search-input",placeholder:n("terminal:spawn.filterSkills"),value:D,onChange:s=>Ke(s.target.value)}),e.jsxs("div",{className:"spawn-skills-inline",children:[ke.map(s=>{const a=ee.has(s.id);return Je.some(r=>r.id===s.id)?null:e.jsxs("button",{className:`spawn-skill-chip ${a?"selected":""}`,onClick:()=>He(s.id),title:s.description,children:[a&&e.jsx("span",{className:"spawn-skill-check",children:e.jsx(pe,{name:"check",size:10})}),e.jsx("span",{children:s.name}),s.builtin&&e.jsx("span",{className:"spawn-skill-builtin",children:"TC"})]},s.id)}),D&&ke.length===0&&e.jsx("div",{className:"skill-search-empty",children:n("terminal:spawn.noSkillsMatch",{query:D})})]})]}),e.jsxs("details",{className:"spawn-advanced",children:[e.jsxs("summary",{children:[n("terminal:spawn.customInstructions")," & ",n("terminal:spawn.linkSession")]}),e.jsxs("div",{className:"spawn-advanced-body",children:[e.jsxs("div",{className:"spawn-custom-instructions-section",children:[e.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.customInstructions")," ",e.jsxs("span",{className:"spawn-label-hint",children:["(",n("common:labels.optional"),")"]}),e.jsx(x,{text:n("terminal:spawn.helpCustomInstructions"),title:n("terminal:spawn.customInstructions"),position:"top",size:"sm"})]}),e.jsx("textarea",{className:"spawn-input spawn-textarea",placeholder:n("terminal:spawn.customInstructionsPlaceholder"),value:be,onChange:s=>Be(s.target.value),rows:3})]}),e.jsxs("div",{className:"spawn-sessions-section",children:[e.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.linkSession")," ",e.jsxs("span",{className:"spawn-label-hint",children:["(",n("common:labels.optional"),")"]}),e.jsx(x,{text:n("terminal:spawn.helpLinkSession"),title:n("terminal:spawn.linkSessionTitle"),position:"top",size:"sm"})]}),y.length>0&&e.jsx("input",{type:"text",className:"spawn-input session-search-input",placeholder:n("terminal:spawn.searchSessions"),value:_,onChange:s=>ve(s.target.value)}),e.jsx("div",{className:"sessions-list",children:Fe?e.jsx("div",{className:"sessions-loading",children:n("terminal:spawn.loadingSessions")}):y.length===0?e.jsx("div",{className:"sessions-empty",children:n("terminal:spawn.noSessions")}):Me.length===0?e.jsx("div",{className:"sessions-empty",children:n("terminal:spawn.noSessionsMatch",{query:_})}):Me.map(s=>{const a=E===s.sessionId,l=Date.now()-new Date(s.lastModified).getTime(),r=l<6e4?n("common:time.justNow"):l<36e5?n("common:time.minutesAgo",{count:Math.floor(l/6e4)}):l<864e5?n("common:time.hoursAgo",{count:Math.floor(l/36e5)}):n("common:time.daysAgo",{count:Math.floor(l/864e5)});return e.jsxs("div",{className:`session-item ${a?"selected":""}`,onClick:()=>{a?U(null):(U(s.sessionId),O(s.projectPath))},children:[e.jsxs("div",{className:"session-item-header",children:[e.jsx("span",{className:"session-item-path",children:s.projectPath}),e.jsx("span",{className:"session-item-age",children:r})]}),e.jsx("div",{className:"session-item-preview",children:s.firstMessage||n("terminal:spawn.messagesCount",{count:s.messageCount})})]},s.sessionId)})})]})]})]})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:g,children:n("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-primary",onClick:Ze,disabled:we,children:n(we?"common:buttons.deploying":"common:buttons2.deploy")})]})]})})}export{bs as SpawnModal};
|
|
1
|
+
import{u as as,i as ts,k as ls,l as is,B as os,r as t,m as Ie,S as oe,D as cs,C as ce,A as _e,d as re,c as rs,s as S,g as ds,j as e,M as ps,n as Le,H as x,F as ms,P as de,I as pe,o as T,p as X,O as us,G as Y,q as hs,t as me,v as ws,w as ue,x as xs,y as fs}from"./main-CICvC5Bz.js";import{D as js}from"./common-types-CZVd6J8k.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-DYBBrXTx.js";function $e(d,g){const b=g.filter(C=>!d.has(C));return b.length===0?`${g[Math.floor(Math.random()*g.length)]}-${Date.now()%1e3}`:b[Math.floor(Math.random()*b.length)]}function bs({isOpen:d,onClose:g,onSpawnStart:b,onSpawnEnd:C,spawnPosition:Pe,spawnAreaId:v}){const{t:n}=as(["terminal","common"]),F=ts(),p=ls(),he=is(),Q=he.length>0?he:os,[m,N]=t.useState(""),[k,O]=t.useState(()=>Ie(oe.LAST_CWD)),[o,M]=t.useState("scout"),[we,I]=t.useState(!1),[Te,R]=t.useState(!1),[xe,V]=t.useState(!1),[fe,je]=t.useState(""),[y,Z]=t.useState([]),[E,U]=t.useState(null),[Fe,ge]=t.useState(!1),[_,ve]=t.useState(""),[h,Oe]=t.useState(""),[z,Re]=t.useState(!1),[G,Ue]=t.useState("bypass"),[i,L]=t.useState("claude"),[f,A]=t.useState({fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),[ee,se]=t.useState(new Set),[ne,Ne]=t.useState("claude-opus-4-8[1m]"),[q,Se]=t.useState("xHigh"),[ae,ze]=t.useState("gpt-5.6-luna"),[te,Ge]=t.useState("minimax/MiniMax-M1-80k"),[W,qe]=t.useState(cs),[le,We]=t.useState(""),[be,Be]=t.useState(""),[D,Ke]=t.useState(""),B=t.useRef(null),Ce=t.useRef(!1),$=t.useCallback(()=>{window.__spawnModalAreaContext=null},[]),w=t.useMemo(()=>F.filter(s=>s.enabled),[F]);t.useEffect(()=>{if(d&&!Ce.current){if(w.length>0){const l=w.filter(r=>js.includes(r.slug)).map(r=>r.id);l.length>0&&se(new Set(l))}const a=Ie(oe.DEFAULT_AGENT_CLASS);if(a==="random"){const r=[...Object.keys(xs),...p.map(u=>u.id)];M(r[Math.floor(Math.random()*r.length)])}else M(a||"scout")}Ce.current=d},[d,w,p]);const ke=t.useMemo(()=>{if(!D.trim())return w;const s=D.toLowerCase();return w.filter(a=>a.name.toLowerCase().includes(s)||a.description.toLowerCase().includes(s)||a.slug.toLowerCase().includes(s))},[w,D]),He=t.useCallback(s=>{se(a=>{const l=new Set(a);return l.has(s)?l.delete(s):l.add(s),l})},[]);t.useMemo(()=>w.filter(s=>s.assignedAgentClasses.includes(o)),[w,o]);const Je=t.useMemo(()=>{var a;const s=p.find(l=>l.id===o);return(a=s==null?void 0:s.defaultSkillIds)!=null&&a.length?F.filter(l=>s.defaultSkillIds.includes(l.id)):[]},[p,o,F]),Me=t.useMemo(()=>{if(!_.trim())return y;const s=_.toLowerCase();return y.filter(a=>a.sessionId.toLowerCase().includes(s)||a.projectPath.toLowerCase().includes(s)||a.firstMessage&&a.firstMessage.toLowerCase().includes(s))},[y,_]),K=t.useMemo(()=>{if(!h.trim())return p;const s=h.toLowerCase();return p.filter(a=>a.name.toLowerCase().includes(s)||a.description.toLowerCase().includes(s)||a.id.toLowerCase().includes(s))},[p,h]),H=t.useMemo(()=>{if(!h.trim())return ce;const s=h.toLowerCase();return ce.filter(a=>{const l=_e[a.id];return a.name.toLowerCase().includes(s)||a.id.toLowerCase().includes(s)||l.description.toLowerCase().includes(s)})},[h]);t.useEffect(()=>{if(!d||!h.trim())return;const s=[...K.map(a=>a.id),...H.map(a=>a.id)];s.length===1&&s[0]!==o&&M(s[0])},[d,h,K,H,o]);const c=t.useMemo(()=>p.find(s=>s.id===o),[p,o]),Xe=t.useMemo(()=>{if(c!=null&&c.model)return c.model},[c]),Ye=t.useMemo(()=>{if(c!=null&&c.customModelPath)return re(`/api/custom-models/${c.id}`)},[c]),Qe=c==null?void 0:c.modelScale,Ve=t.useMemo(()=>c?"scout":o,[o,c]),J=t.useCallback(async s=>{ge(!0);try{const a=s?re(`/api/agents/claude-sessions?cwd=${encodeURIComponent(s)}`):re("/api/agents/claude-sessions"),r=await(await rs(a)).json();Z(r.sessions||[])}catch(a){console.error("Failed to fetch sessions:",a),Z([])}finally{ge(!1)}},[]);t.useEffect(()=>{d?J(k||void 0):(Z([]),U(null),ve(""))},[d,J]),t.useEffect(()=>{if(!d)return;const s=setTimeout(()=>{J(k||void 0),U(null)},300);return()=>clearTimeout(s)},[k,d,J]),t.useEffect(()=>{if(!d||!v)return;const s=S.getState().areas.get(v);if(s!=null&&s.directories&&s.directories.length>0){O(s.directories[0]);return}const a=Array.from(S.getState().agents.values()).filter(j=>{var P;return((P=S.getAreaForAgent(j.id))==null?void 0:P.id)===v&&j.cwd});if(a.length===0)return;const l=new Map;for(const j of a)l.set(j.cwd,(l.get(j.cwd)||0)+1);let r="",u=0;for(const[j,P]of l)P>u&&(r=j,u=P);r&&O(r)},[d,v]),t.useEffect(()=>{if(d){const s=new Set(Array.from(S.getState().agents.values()).map(u=>u.name)),a=$e(s,Q),l=p.find(u=>u.id===o),r=l?`${l.name} ${a}`:a;N(r),B.current&&(B.current.focus(),B.current.select())}},[d,Q]),t.useEffect(()=>{if(!d)return;const s=p.find(a=>a.id===o);if(s){const a=p.find(l=>m.startsWith(l.name+" "));if(a){const l=m.substring(a.name.length+1);N(`${s.name} ${l}`)}else N(`${s.name} ${m}`)}else{const a=p.find(l=>m.startsWith(l.name+" "));if(a){const l=m.substring(a.name.length+1);N(l)}}},[o]),t.useEffect(()=>{o==="boss"&&Ne("claude-opus-4-8[1m]")},[o]);const Ze=()=>{var r;console.log("[SpawnModal] handleSpawn called"),R(!1);const s=E&&((r=y.find(u=>u.sessionId===E))==null?void 0:r.projectPath)||k;if(console.log("[SpawnModal] Effective CWD:",s),console.log("[SpawnModal] Agent name:",m),console.log("[SpawnModal] Agent class:",o),console.log("[SpawnModal] Permission mode:",G),console.log("[SpawnModal] Provider:",i),console.log("[SpawnModal] Use Chrome:",z),console.log("[SpawnModal] Session ID:",E||"none"),!s.trim()){console.error("[SpawnModal] Empty CWD, showing error"),R(!0);return}if(!m.trim()){console.log("[SpawnModal] Empty name, regenerating");const u=new Set(Array.from(S.getState().agents.values()).map(j=>j.name));N($e(u,Q));return}fs(oe.LAST_CWD,s),I(!0),b();const a=Array.from(ee),l=be.trim()||void 0;console.log("[SpawnModal] Calling store.spawnAgent with:",{name:m.trim(),class:o,cwd:s.trim(),sessionId:E||void 0,useChrome:i==="claude"?z:!1,permissionMode:G,provider:i,codexConfig:i==="codex"?f:void 0,codexModel:i==="codex"?ae:void 0,opencodeModel:i==="opencode"?te:void 0,grokModel:i==="grok"?W:void 0,piModel:i==="pi"&&le||void 0,initialSkillIds:a,model:i==="claude"?ne:void 0,customInstructions:l?`${l.length} chars`:void 0,spawnAreaId:v||void 0}),window.__spawnModalAreaContext=v?{areaId:v}:null,S.spawnAgent(m.trim(),o,s.trim(),Pe||void 0,E||void 0,i==="claude"?z:!1,G,a,i,i==="codex"?f:void 0,i==="codex"?ae:void 0,i==="claude"?ne:void 0,l,i==="claude"||i==="grok"||i==="pi"?q:void 0,i==="opencode"?te:void 0,i==="grok"?W:void 0,i==="pi"&&le||void 0)},ye=()=>{console.log("[SpawnModal] Agent creation successful"),I(!1),N(""),se(new Set),$(),C(),g()},Ee=()=>{console.error("[SpawnModal] Agent creation failed"),I(!1),R(!0),$(),C()},Ae=s=>{console.log("[SpawnModal] Directory not found:",s),I(!1),je(s),V(!0),C()},De=()=>{V(!1),I(!0),b(),S.createDirectoryAndSpawn(fe,m.trim(),o)},ie=()=>{V(!1),je(""),$()};t.useEffect(()=>(window.__spawnModalSuccess=ye,window.__spawnModalError=Ee,window.__spawnModalDirNotFound=Ae,()=>{$(),delete window.__spawnModalSuccess,delete window.__spawnModalError,delete window.__spawnModalDirNotFound}),[m,o,ye,Ee,Ae,$]);const{handleMouseDown:es,handleClick:ss}=ds(g),ns=s=>{s.key==="Escape"&&g()};return!d&&!xe?null:xe?e.jsx("div",{className:"modal-overlay visible",onClick:ie,onKeyDown:s=>{s.key==="Escape"&&ie(),s.key==="Enter"&&De()},children:e.jsxs("div",{className:"modal confirm-modal",onClick:s=>s.stopPropagation(),children:[e.jsx("div",{className:"modal-header",children:n("terminal:spawn.directoryNotFound")}),e.jsxs("div",{className:"modal-body confirm-modal-body",children:[e.jsx("p",{children:n("terminal:spawn.directoryNotExist")}),e.jsx("code",{className:"confirm-modal-path",children:fe}),e.jsx("p",{children:n("terminal:spawn.wouldYouCreate")})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:ie,children:n("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-primary",onClick:De,autoFocus:!0,children:n("terminal:spawn.createDirectory")})]})]})}):e.jsx("div",{className:`modal-overlay ${d?"visible":""}`,onMouseDown:es,onClick:ss,onKeyDown:ns,children:e.jsxs("div",{className:"modal spawn-modal",children:[e.jsx("div",{className:"modal-header",children:n("terminal:spawn.deployTitle")}),e.jsxs("div",{className:"modal-body spawn-modal-body",children:[e.jsxs("div",{className:"spawn-section",children:[e.jsxs("div",{className:"spawn-section-header",children:[e.jsx("h4",{className:"spawn-section-title",children:n("terminal:spawn.agentClass")}),e.jsx("span",{className:"spawn-section-hint",children:(c==null?void 0:c.name)||o})]}),e.jsxs("div",{className:"spawn-top-section",children:[e.jsxs("div",{className:"spawn-preview-compact",children:[e.jsx(ps,{agentClass:Ve,modelFile:Xe,customModelUrl:Ye,modelScale:Qe,width:110,height:130}),e.jsx("div",{className:"spawn-preview-label",children:(c==null?void 0:c.name)||o})]}),e.jsxs("div",{className:"spawn-class-section",children:[p.length+ce.length>6&&e.jsx("input",{type:"text",className:"spawn-input class-search-input",placeholder:n("terminal:spawn.filterClasses"),value:h,onChange:s=>Oe(s.target.value)}),e.jsxs("div",{className:"class-selector-inline",children:[K.map(s=>e.jsxs("button",{className:`class-chip ${o===s.id?"selected":""}`,onClick:()=>M(s.id),title:s.description,children:[e.jsx(Le,{classId:s.id,size:18,className:"class-chip-icon"}),e.jsx("span",{className:"class-chip-name",children:s.name})]},s.id)),H.map(s=>{const a=_e[s.id];return e.jsxs("button",{className:`class-chip ${o===s.id?"selected":""}`,onClick:()=>M(s.id),title:a.description,children:[e.jsx(Le,{classId:s.id,size:18,className:"class-chip-icon"}),e.jsx("span",{className:"class-chip-name",children:s.name})]},s.id)}),h&&K.length===0&&H.length===0&&e.jsx("div",{className:"class-search-empty",children:n("terminal:spawn.noClassesMatch",{query:h})})]})]})]}),e.jsxs("div",{className:"spawn-form-row",children:[e.jsxs("div",{className:"spawn-field",children:[e.jsx("label",{className:"spawn-label",children:n("common:labels.name")}),e.jsx("input",{ref:B,type:"text",className:"spawn-input",placeholder:n("terminal:spawn.agentNamePlaceholder"),value:m,onChange:s=>N(s.target.value)})]}),e.jsxs("div",{className:"spawn-field spawn-field-wide",children:[e.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.workingDir"),e.jsx(x,{text:n("terminal:spawn.helpWorkingDir"),title:n("terminal:spawn.workingDir"),position:"top",size:"sm"})]}),e.jsx(ms,{value:k,onChange:s=>{O(s),R(!1)},placeholder:n("terminal:spawn.workingDirPlaceholder"),className:`spawn-input ${Te?"error":""}`,directoriesOnly:!0})]})]})]}),e.jsxs("div",{className:"spawn-section",children:[e.jsx("div",{className:"spawn-section-header",children:e.jsx("h4",{className:"spawn-section-title",children:n("terminal:spawn.selectRuntime")})}),e.jsxs("div",{className:"spawn-form-row",children:[e.jsxs("div",{className:"spawn-field",children:[e.jsxs("label",{className:"spawn-label",children:[n("common:labels.runtime"),e.jsx(x,{text:n("terminal:spawn.helpRuntime"),title:n("terminal:spawn.runtimeTitle"),position:"top",size:"sm"})]}),e.jsxs("div",{className:"spawn-select-row",children:[e.jsxs("button",{className:`spawn-select-btn ${i==="claude"?"selected":""}`,onClick:()=>L("claude"),title:n("terminal:spawn.useClaudeCli"),children:[e.jsx("img",{src:"/assets/claude.ico",alt:"Claude",className:"spawn-provider-icon"}),e.jsx("span",{children:"Claude"})]}),e.jsxs("button",{className:`spawn-select-btn ${i==="codex"?"selected":""}`,onClick:()=>L("codex"),title:n("terminal:spawn.useCodexCli"),children:[e.jsx("img",{src:"/assets/codex.ico",alt:"Codex",className:"spawn-provider-icon"}),e.jsx("span",{children:"Codex"})]}),e.jsxs("button",{className:`spawn-select-btn spawn-select-btn--opencode ${i==="opencode"?"selected":""}`,onClick:()=>L("opencode"),title:"Use OpenCode CLI (multi-provider)",children:[e.jsx("img",{src:"/assets/opencode.svg",alt:"OpenCode",className:"spawn-provider-icon"}),e.jsx("span",{children:"OpenCode"})]}),e.jsxs("button",{className:`spawn-select-btn spawn-select-btn--grok ${i==="grok"?"selected":""}`,onClick:()=>L("grok"),title:"Use Grok CLI (headless)",children:[e.jsx("img",{src:"/assets/grok.png",alt:"Grok",className:"spawn-provider-icon"}),e.jsx("span",{children:"Grok"})]}),e.jsxs("button",{className:`spawn-select-btn spawn-select-btn--pi ${i==="pi"?"selected":""}`,onClick:()=>L("pi"),title:"Use Pi coding agent CLI (multi-provider)",children:[e.jsx("img",{src:"/assets/pi.svg",alt:"Pi",className:"spawn-provider-icon"}),e.jsx("span",{children:"Pi"})]})]})]}),e.jsxs("div",{className:"spawn-field",children:[e.jsxs("label",{className:"spawn-label",children:[n("common:labels.permissions"),e.jsx(x,{text:n("terminal:spawn.helpPermission"),title:n("terminal:spawn.permissionMode"),position:"top",size:"sm"})]}),e.jsx("div",{className:"spawn-select-row",children:Object.keys(de).map(s=>e.jsxs("button",{className:`spawn-select-btn ${G===s?"selected":""}`,onClick:()=>Ue(s),title:de[s].description,children:[e.jsx("span",{children:e.jsx(pe,{name:s==="bypass"?"bolt":"lock",size:12})}),e.jsx("span",{children:de[s].label})]},s))})]})]}),e.jsx("div",{className:"spawn-form-row",children:e.jsxs("div",{className:"spawn-field",children:[e.jsxs("label",{className:"spawn-label",children:[n("common:labels.model"),e.jsx(x,{text:n("terminal:spawn.helpModel"),title:n("terminal:spawn.modelTitle"),position:"top",size:"sm"})]}),i==="claude"?e.jsx("div",{className:"spawn-select-row spawn-select-row--wrap",children:Object.keys(T).filter(s=>!T[s].deprecated).map(s=>e.jsxs("button",{className:`spawn-select-btn ${ne===s?"selected":""}`,onClick:()=>Ne(s),title:T[s].description,children:[e.jsx("span",{children:T[s].icon}),e.jsx("span",{children:T[s].label})]},s))}):i==="codex"?e.jsx("div",{className:"spawn-select-row spawn-select-row--codex-models",children:Object.keys(X).map(s=>e.jsxs("button",{className:`spawn-select-btn ${ae===s?"selected":""}`,onClick:()=>ze(s),title:X[s].description,children:[e.jsx("span",{children:X[s].icon}),e.jsx("span",{children:X[s].label})]},s))}):i==="opencode"?e.jsx(us,{value:te,onChange:Ge,inputId:"spawn-opencode-model"}):i==="grok"?e.jsx("div",{className:"spawn-select-row spawn-select-row--wrap",children:Object.keys(Y).map(s=>e.jsxs("button",{className:`spawn-select-btn ${W===s?"selected":""}`,onClick:()=>qe(s),title:Y[s].description,children:[e.jsx("span",{children:Y[s].icon}),e.jsx("span",{children:Y[s].label})]},s))}):i==="pi"?e.jsx(hs,{value:le,onChange:We,inputId:"spawn-pi-model"}):e.jsx("div",{className:"spawn-inline-hint",children:n("terminal:spawn.chooseCodexModel")})]})}),e.jsxs("div",{className:"spawn-form-row",children:[(i==="claude"||i==="grok"||i==="pi")&&e.jsxs("div",{className:"spawn-field",children:[e.jsx("label",{className:"spawn-label",children:"Effort"}),e.jsxs("div",{className:"spawn-select-row spawn-select-row--effort",children:[e.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${q===void 0?"selected":""}`,onClick:()=>Se(void 0),title:"Use default effort level",children:e.jsx("span",{children:"Default"})}),Object.keys(me).filter(s=>i!=="grok"||ws(W,s)||q===s).map(s=>e.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${q===s?"selected":""}`,onClick:()=>Se(s),title:me[s].description,children:e.jsx("span",{children:me[s].label})},s))]})]}),e.jsxs("div",{className:"spawn-field",children:[e.jsx("label",{className:"spawn-label",children:n("terminal:spawn.browser")}),e.jsxs("label",{className:"spawn-checkbox",children:[e.jsx("input",{type:"checkbox",checked:z,onChange:s=>Re(s.target.checked),disabled:i!=="claude"}),e.jsxs("span",{children:[e.jsx(pe,{name:"globe",size:12})," ",n("terminal:spawn.chromeBrowser")]}),e.jsx(x,{text:n(i==="claude"?"terminal:spawn.helpChrome":"terminal:spawn.helpChromeDisabled"),title:n("terminal:spawn.chromeBrowser"),position:"top",size:"sm"})]})]})]}),i==="codex"&&e.jsxs("div",{className:"codex-config-section",children:[e.jsx("div",{className:"codex-config-title",children:n("terminal:spawn.codex.configuration")}),e.jsxs("div",{className:"codex-config-options",children:[e.jsxs("div",{className:"codex-option-group",children:[e.jsxs("label",{className:"spawn-checkbox",children:[e.jsx("input",{type:"checkbox",checked:f.fullAuto!==!1,onChange:s=>A(a=>({...a,fullAuto:s.target.checked}))}),e.jsx("span",{children:n("terminal:spawn.codex.fullAuto")}),e.jsx(x,{text:n("terminal:spawn.helpFullAuto"),title:n("terminal:spawn.fullAutoTitle"),position:"top",size:"sm"})]}),e.jsxs("label",{className:"spawn-checkbox",children:[e.jsx("input",{type:"checkbox",checked:!!f.search,onChange:s=>A(a=>({...a,search:s.target.checked}))}),e.jsx("span",{children:n("terminal:spawn.codex.search")}),e.jsx(x,{text:n("terminal:spawn.helpSearch"),title:n("terminal:spawn.searchTitle"),position:"top",size:"sm"})]})]}),f.fullAuto===!1&&e.jsxs("div",{className:"codex-option-group",children:[e.jsx("div",{className:"codex-option-header",children:n("terminal:spawn.codex.restrictions")}),e.jsxs("select",{className:"spawn-input codex-select",value:f.sandbox||"workspace-write",onChange:s=>A(a=>({...a,sandbox:s.target.value})),children:[e.jsxs("option",{value:"read-only",children:["📖 ",n("terminal:spawn.codex.sandboxReadOnly")]}),e.jsxs("option",{value:"workspace-write",children:["✏️ ",n("terminal:spawn.codex.sandboxWorkspaceWrite")]}),e.jsxs("option",{value:"danger-full-access",children:["⚡ ",n("terminal:spawn.codex.sandboxDangerFullAccess")]})]}),e.jsxs("select",{className:"spawn-input codex-select",value:f.approvalMode||"on-request",onChange:s=>A(a=>({...a,approvalMode:s.target.value})),children:[e.jsxs("option",{value:"untrusted",children:["🔒 ",n("terminal:spawn.codex.approvalsUntrusted")]}),e.jsxs("option",{value:"on-failure",children:["⚠️ ",n("terminal:spawn.codex.approvalsOnFailure")]}),e.jsxs("option",{value:"on-request",children:["🤔 ",n("terminal:spawn.codex.approvalsOnRequest")]}),e.jsxs("option",{value:"never",children:["✅ ",n("terminal:spawn.codex.approvalsNever")]})]})]}),e.jsxs("div",{className:"codex-option-group",children:[e.jsx("div",{className:"codex-option-header",children:n("terminal:spawn.codex.profile")}),e.jsx("input",{type:"text",className:"spawn-input codex-profile-input",placeholder:n("terminal:spawn.codex.profilePlaceholder"),value:f.profile||"",onChange:s=>A(a=>({...a,profile:s.target.value||void 0}))})]}),e.jsxs("div",{className:"codex-option-group",children:[e.jsx("div",{className:"codex-option-header",children:n("terminal:spawn.codex.reasoningEffort")}),e.jsxs("select",{className:"spawn-input codex-select",value:f.reasoningEffort||"",onChange:s=>A(a=>({...a,reasoningEffort:s.target.value||void 0})),children:[e.jsx("option",{value:"",children:n("terminal:spawn.codex.reasoningEffortDefault")}),Object.keys(ue).map(s=>e.jsxs("option",{value:s,children:[ue[s].icon," ",ue[s].label]},s))]})]})]})]})]}),w.length>0&&e.jsxs("div",{className:"spawn-section spawn-skills-section",children:[e.jsxs("div",{className:"spawn-section-header",children:[e.jsxs("h4",{className:"spawn-section-title",children:[n("terminal:spawn.skills"),e.jsx(x,{text:n("terminal:spawn.helpSkills"),title:n("terminal:spawn.skillsTitle"),position:"top",size:"sm"})]}),e.jsxs("span",{className:"spawn-section-hint",children:[ee.size," selected · ",n("common:labels.optional")]})]}),w.length>6&&e.jsx("input",{type:"text",className:"spawn-input skill-search-input",placeholder:n("terminal:spawn.filterSkills"),value:D,onChange:s=>Ke(s.target.value)}),e.jsxs("div",{className:"spawn-skills-inline",children:[ke.map(s=>{const a=ee.has(s.id);return Je.some(r=>r.id===s.id)?null:e.jsxs("button",{className:`spawn-skill-chip ${a?"selected":""}`,onClick:()=>He(s.id),title:s.description,children:[a&&e.jsx("span",{className:"spawn-skill-check",children:e.jsx(pe,{name:"check",size:10})}),e.jsx("span",{children:s.name}),s.builtin&&e.jsx("span",{className:"spawn-skill-builtin",children:"TC"})]},s.id)}),D&&ke.length===0&&e.jsx("div",{className:"skill-search-empty",children:n("terminal:spawn.noSkillsMatch",{query:D})})]})]}),e.jsxs("details",{className:"spawn-advanced",children:[e.jsxs("summary",{children:[n("terminal:spawn.customInstructions")," & ",n("terminal:spawn.linkSession")]}),e.jsxs("div",{className:"spawn-advanced-body",children:[e.jsxs("div",{className:"spawn-custom-instructions-section",children:[e.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.customInstructions")," ",e.jsxs("span",{className:"spawn-label-hint",children:["(",n("common:labels.optional"),")"]}),e.jsx(x,{text:n("terminal:spawn.helpCustomInstructions"),title:n("terminal:spawn.customInstructions"),position:"top",size:"sm"})]}),e.jsx("textarea",{className:"spawn-input spawn-textarea",placeholder:n("terminal:spawn.customInstructionsPlaceholder"),value:be,onChange:s=>Be(s.target.value),rows:3})]}),e.jsxs("div",{className:"spawn-sessions-section",children:[e.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.linkSession")," ",e.jsxs("span",{className:"spawn-label-hint",children:["(",n("common:labels.optional"),")"]}),e.jsx(x,{text:n("terminal:spawn.helpLinkSession"),title:n("terminal:spawn.linkSessionTitle"),position:"top",size:"sm"})]}),y.length>0&&e.jsx("input",{type:"text",className:"spawn-input session-search-input",placeholder:n("terminal:spawn.searchSessions"),value:_,onChange:s=>ve(s.target.value)}),e.jsx("div",{className:"sessions-list",children:Fe?e.jsx("div",{className:"sessions-loading",children:n("terminal:spawn.loadingSessions")}):y.length===0?e.jsx("div",{className:"sessions-empty",children:n("terminal:spawn.noSessions")}):Me.length===0?e.jsx("div",{className:"sessions-empty",children:n("terminal:spawn.noSessionsMatch",{query:_})}):Me.map(s=>{const a=E===s.sessionId,l=Date.now()-new Date(s.lastModified).getTime(),r=l<6e4?n("common:time.justNow"):l<36e5?n("common:time.minutesAgo",{count:Math.floor(l/6e4)}):l<864e5?n("common:time.hoursAgo",{count:Math.floor(l/36e5)}):n("common:time.daysAgo",{count:Math.floor(l/864e5)});return e.jsxs("div",{className:`session-item ${a?"selected":""}`,onClick:()=>{a?U(null):(U(s.sessionId),O(s.projectPath))},children:[e.jsxs("div",{className:"session-item-header",children:[e.jsx("span",{className:"session-item-path",children:s.projectPath}),e.jsx("span",{className:"session-item-age",children:r})]}),e.jsx("div",{className:"session-item-preview",children:s.firstMessage||n("terminal:spawn.messagesCount",{count:s.messageCount})})]},s.sessionId)})})]})]})]})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:g,children:n("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-primary",onClick:Ze,disabled:we,children:n(we?"common:buttons.deploying":"common:buttons2.deploy")})]})]})})}export{bs as SpawnModal};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as U,g as R,U as j,a2 as F,a3 as B,j as t,a4 as G,I,a5 as k}from"./main-Dk3qq80S.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-DYBBrXTx.js";const b=["#6ab8c8","#c89a5a","#9a80c0","#5cb88a","#c85a5a","#c87a9a","#c8c87a","#5a8fd4","#d45a5a","#8a6fbf"],P=14,w=720,C=260,p={top:16,right:20,bottom:42,left:64};function W(){const i=new Date;return i.setHours(0,0,0,0),i.getTime()}function $(i){if(!i)return"N/A";try{return new Date(i).toLocaleString()}catch{return"N/A"}}function z(i,s){if(i.length===0||s<=0)return"conic-gradient(rgba(50, 50, 62, 0.95) 0deg 360deg)";let a=0;return`conic-gradient(${i.map((h,l)=>{const c=a,n=h.tokens.total/s*360;return a+=n,`${b[l%b.length]} ${c.toFixed(2)}deg ${a.toFixed(2)}deg`}).join(", ")})`}function E(i){const[,s,a]=i.split("-");return!s||!a?i:`${s}/${a}`}function q(i){const s=(i==null?void 0:i.days)??[];if(s.length===0)return[];const a=new Map;for(const l of s)for(const c of l.agents){const n=a.get(c.agentId)??{agentName:c.agentName,total:0};n.total+=c.tokens.total,a.set(c.agentId,n)}const r={id:"general",name:"General",color:"#f1fa8c",values:s.map(l=>l.totalTokens),total:s.reduce((l,c)=>l+c.totalTokens,0),peak:Math.max(0,...s.map(l=>l.totalTokens)),isTotal:!0},h=[...a.entries()].sort((l,c)=>c[1].total-l[1].total).map(([l,c],n)=>({id:l,name:c.agentName,color:b[n%b.length],values:s.map(u=>{var d;return((d=u.agents.find(x=>x.agentId===l))==null?void 0:d.tokens.total)??0}),total:c.total,peak:Math.max(0,...s.map(u=>{var d;return((d=u.agents.find(x=>x.agentId===l))==null?void 0:d.tokens.total)??0}))}));return[r,...h].filter(l=>l.total>0)}function Y(i){if(i<=0)return 1;const s=10**Math.floor(Math.log10(i)),a=i/s;return(a<=1?1:a<=2?2:a<=5?5:10)*s}function H(i,s,a,r){const h=p.left,l=p.top,c=w-p.left-p.right,n=C-p.top-p.bottom,u=i<=1?h+c/2:h+s/(i-1)*c,d=l+n-a/r*n;return{x:u,y:d}}function X(i,s){return i.map((a,r)=>{const{x:h,y:l}=H(i.length,r,a,s);return`${h.toFixed(2)},${l.toFixed(2)}`}).join(" ")}function J(i,s=28){return i.length<=s?i:`${i.slice(0,s-1)}...`}function K({summary:i}){const[s,a]=j.useState(null),r=i.days,h=q(i),l=Math.max(1,...h.flatMap(e=>e.values)),c=Y(l),n=p.left,u=p.top,d=w-p.left-p.right,x=C-p.top-p.bottom,f=[0,.5,1],M=Math.max(1,Math.ceil(r.length/5)),v=190,y=86,g=s?Math.min(Math.max(s.x+12,8),w-v-8):0,_=s?Math.min(Math.max(s.y-y-10,8),C-y-8):0;return t.jsxs("div",{className:"statistics-line-chart",children:[t.jsxs("svg",{className:"statistics-line-chart__svg",viewBox:`0 0 ${w} ${C}`,role:"img","aria-label":"Daily Claude token usage by agent",preserveAspectRatio:"xMidYMid meet",onMouseLeave:()=>a(null),children:[f.map(e=>{const m=u+x-e*x;return t.jsxs("g",{children:[t.jsx("line",{className:"statistics-line-chart__grid",x1:n,y1:m,x2:n+d,y2:m}),t.jsx("text",{className:"statistics-line-chart__axis-label",x:n-10,y:m+4,textAnchor:"end",children:k(Math.round(c*e))})]},e)}),t.jsx("line",{className:"statistics-line-chart__axis",x1:n,y1:u,x2:n,y2:u+x}),t.jsx("line",{className:"statistics-line-chart__axis",x1:n,y1:u+x,x2:n+d,y2:u+x}),r.map((e,m)=>{if(m!==0&&m!==r.length-1&&m%M!==0)return null;const o=r.length<=1?n+d/2:n+m/(r.length-1)*d;return t.jsx("text",{className:"statistics-line-chart__axis-label",x:o,y:C-14,textAnchor:"middle",children:E(e.date)},e.date)}),h.map(e=>t.jsx("polyline",{className:e.isTotal?"statistics-line-chart__line statistics-line-chart__line--total":"statistics-line-chart__line",points:X(e.values,c),fill:"none",stroke:e.color,strokeWidth:e.isTotal?3:2,strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("title",{children:`${e.name}: ${e.peak.toLocaleString()} peak daily tokens`})},e.id)),h.map(e=>e.values.map((m,o)=>{var L,D,V,A;const{x:N,y:S}=H(r.length,o,m,c),T={id:`${e.id}-${(L=r[o])==null?void 0:L.date}`,date:((D=r[o])==null?void 0:D.date)??"",name:e.name,color:e.color,value:m,total:e.total,peak:e.peak,x:N,y:S};return t.jsxs("g",{children:[t.jsx("circle",{className:"statistics-line-chart__point",cx:N,cy:S,r:e.isTotal?3.4:2.6,fill:e.color}),t.jsx("circle",{className:"statistics-line-chart__point-hit",cx:N,cy:S,r:10,tabIndex:0,role:"button","aria-label":`${e.name} ${(V=r[o])==null?void 0:V.date}: ${m.toLocaleString()} tokens`,onMouseEnter:()=>a(T),onFocus:()=>a(T),onBlur:()=>a(null)})]},`${e.id}-${(A=r[o])==null?void 0:A.date}`)})),s&&t.jsxs("g",{className:"statistics-line-chart__tooltip",children:[t.jsx("line",{className:"statistics-line-chart__hover-line",x1:s.x,y1:u,x2:s.x,y2:u+x}),t.jsx("circle",{className:"statistics-line-chart__hover-point",cx:s.x,cy:s.y,r:5,fill:s.color}),t.jsx("rect",{className:"statistics-line-chart__tooltip-box",x:g,y:_,width:v,height:y,rx:6}),t.jsx("text",{className:"statistics-line-chart__tooltip-title",x:g+10,y:_+18,children:E(s.date)}),t.jsx("text",{className:"statistics-line-chart__tooltip-name",x:g+10,y:_+34,children:J(s.name)}),t.jsxs("text",{className:"statistics-line-chart__tooltip-value",x:g+10,y:_+52,children:["Daily: ",k(s.value)]}),t.jsxs("text",{className:"statistics-line-chart__tooltip-meta",x:g+10,y:_+68,children:["Peak: ",k(s.peak)]}),t.jsxs("text",{className:"statistics-line-chart__tooltip-meta",x:g+100,y:_+68,children:["Total: ",k(s.total)]})]})]}),t.jsx("div",{className:"statistics-line-chart__legend",children:h.map(e=>t.jsxs("div",{className:"statistics-line-chart__legend-item",title:`${e.name}: peak ${e.peak.toLocaleString()} daily tokens, ${e.total.toLocaleString()} period tokens`,children:[t.jsx("span",{className:"statistics-line-chart__legend-swatch",style:{backgroundColor:e.color}}),t.jsx("span",{children:e.name}),t.jsx("strong",{children:k(e.peak)})]},e.id))})]})}function tt({isOpen:i,onClose:s}){const{t:a}=U(["terminal","common"]),{handleMouseDown:r,handleClick:h}=R(s),[l,c]=j.useState(null),[n,u]=j.useState(null),[d,x]=j.useState(!1),[f,M]=j.useState(null),v=j.useMemo(()=>W(),[]),y=j.useCallback(async()=>{x(!0),M(null);try{const o=Date.now(),[N,S]=await Promise.all([F({since:v,until:o}),B({days:P,until:o})]);c(N),u(S)}catch(o){M((o==null?void 0:o.message)||"Error")}finally{x(!1)}},[v]);if(j.useEffect(()=>{i&&y()},[i,y]),!i)return null;const g=(l==null?void 0:l.entries)??[],_=(l==null?void 0:l.totalTokens)??0,e=z(g,_),m=((n==null?void 0:n.days)??[]).some(o=>o.totalTokens>0);return t.jsx(G,{children:t.jsx("div",{className:"modal-overlay visible",onMouseDown:r,onClick:h,children:t.jsxs("div",{className:"modal statistics-modal",children:[t.jsxs("div",{className:"modal-header statistics-modal__header",children:[t.jsxs("div",{className:"statistics-modal__title",children:[t.jsx("span",{className:"statistics-modal__icon",children:t.jsx(I,{name:"dashboard",size:15})}),t.jsx("span",{children:a("terminal:statistics.title",{defaultValue:"Statistics"})})]}),t.jsx("button",{className:"modal-close statistics-modal__close",onClick:s,title:a("common:buttons.close"),children:"×"})]}),t.jsxs("div",{className:"modal-body statistics-modal__body",children:[t.jsxs("section",{className:"statistics-panel",children:[t.jsxs("div",{className:"statistics-panel__header",children:[t.jsxs("div",{children:[t.jsx("h3",{children:a("terminal:statistics.usageByAgent",{defaultValue:"Claude usage today"})}),t.jsx("span",{className:"statistics-panel__subtitle",children:a("terminal:statistics.usageByAgentSubtitle",{defaultValue:"Input + cache creation + cache read + output tokens, deduped by Claude request id"})})]}),t.jsx("button",{type:"button",className:"statistics-panel__refresh",onClick:y,disabled:d,title:a("terminal:statistics.refresh",{defaultValue:"Refresh usage"}),children:t.jsx(I,{name:"refresh",size:14})})]}),d&&!l&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.loading",{defaultValue:"Loading usage..."})}),!d&&f&&t.jsx("div",{className:"statistics-panel__empty statistics-panel__empty--error",children:a("terminal:statistics.error",{defaultValue:"Failed to load usage: {{error}}",error:f})}),!f&&l&&g.length===0&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.empty",{defaultValue:"No Claude token usage found for today."})}),!f&&l&&g.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"statistics-panel__layout",children:[t.jsx("div",{className:"statistics-panel__chart-wrap",children:t.jsx("div",{className:"statistics-panel__pie",style:{background:e},role:"img","aria-label":a("terminal:statistics.pieLabel",{defaultValue:"Claude token usage by agent"}),children:t.jsxs("div",{className:"statistics-panel__pie-hole",children:[t.jsx("strong",{children:k(_)}),t.jsx("span",{children:a("terminal:statistics.total",{defaultValue:"total"})})]})})}),t.jsx("div",{className:"statistics-panel__list",children:g.map((o,N)=>t.jsxs("div",{className:"statistics-panel__row",title:`${o.agentName}: ${o.tokens.total.toLocaleString()} tokens`,children:[t.jsx("span",{className:"statistics-panel__swatch",style:{backgroundColor:b[N%b.length]}}),t.jsxs("div",{className:"statistics-panel__row-main",children:[t.jsx("div",{className:"statistics-panel__row-name",children:o.agentName}),t.jsxs("div",{className:"statistics-panel__row-meta",children:[o.requestCount.toLocaleString()," ",a("terminal:statistics.requests",{defaultValue:"requests"})," / ",o.percent,"%"]})]}),t.jsx("strong",{children:k(o.tokens.total)})]},o.agentId))})]}),t.jsx("div",{className:"statistics-panel__footnote",children:a("terminal:statistics.window",{defaultValue:"Window: {{since}} to {{until}}",since:$(l.since),until:$(l.until)})})]})]}),t.jsxs("section",{className:"statistics-panel",children:[t.jsx("div",{className:"statistics-panel__header",children:t.jsxs("div",{children:[t.jsx("h3",{children:a("terminal:statistics.dailyUsage",{defaultValue:"Daily usage by agent"})}),t.jsx("span",{className:"statistics-panel__subtitle",children:a("terminal:statistics.dailyUsageSubtitle",{defaultValue:"General token usage by day plus one line for each Claude agent."})})]})}),d&&!n&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.loading",{defaultValue:"Loading usage..."})}),!d&&!f&&n&&!m&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.dailyEmpty",{defaultValue:"No Claude token usage found for recent days."})}),!f&&n&&m&&t.jsxs(t.Fragment,{children:[t.jsx(K,{summary:n}),t.jsx("div",{className:"statistics-panel__footnote",children:a("terminal:statistics.window",{defaultValue:"Window: {{since}} to {{until}}",since:$(n.since),until:$(n.until)})})]})]})]})]})})})}export{tt as StatisticsModal};
|
|
1
|
+
import{u as U,g as R,U as j,a2 as F,a3 as B,j as t,a4 as G,I,a5 as k}from"./main-CICvC5Bz.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-DYBBrXTx.js";const b=["#6ab8c8","#c89a5a","#9a80c0","#5cb88a","#c85a5a","#c87a9a","#c8c87a","#5a8fd4","#d45a5a","#8a6fbf"],P=14,w=720,C=260,p={top:16,right:20,bottom:42,left:64};function W(){const i=new Date;return i.setHours(0,0,0,0),i.getTime()}function $(i){if(!i)return"N/A";try{return new Date(i).toLocaleString()}catch{return"N/A"}}function z(i,s){if(i.length===0||s<=0)return"conic-gradient(rgba(50, 50, 62, 0.95) 0deg 360deg)";let a=0;return`conic-gradient(${i.map((h,l)=>{const c=a,n=h.tokens.total/s*360;return a+=n,`${b[l%b.length]} ${c.toFixed(2)}deg ${a.toFixed(2)}deg`}).join(", ")})`}function E(i){const[,s,a]=i.split("-");return!s||!a?i:`${s}/${a}`}function q(i){const s=(i==null?void 0:i.days)??[];if(s.length===0)return[];const a=new Map;for(const l of s)for(const c of l.agents){const n=a.get(c.agentId)??{agentName:c.agentName,total:0};n.total+=c.tokens.total,a.set(c.agentId,n)}const r={id:"general",name:"General",color:"#f1fa8c",values:s.map(l=>l.totalTokens),total:s.reduce((l,c)=>l+c.totalTokens,0),peak:Math.max(0,...s.map(l=>l.totalTokens)),isTotal:!0},h=[...a.entries()].sort((l,c)=>c[1].total-l[1].total).map(([l,c],n)=>({id:l,name:c.agentName,color:b[n%b.length],values:s.map(u=>{var d;return((d=u.agents.find(x=>x.agentId===l))==null?void 0:d.tokens.total)??0}),total:c.total,peak:Math.max(0,...s.map(u=>{var d;return((d=u.agents.find(x=>x.agentId===l))==null?void 0:d.tokens.total)??0}))}));return[r,...h].filter(l=>l.total>0)}function Y(i){if(i<=0)return 1;const s=10**Math.floor(Math.log10(i)),a=i/s;return(a<=1?1:a<=2?2:a<=5?5:10)*s}function H(i,s,a,r){const h=p.left,l=p.top,c=w-p.left-p.right,n=C-p.top-p.bottom,u=i<=1?h+c/2:h+s/(i-1)*c,d=l+n-a/r*n;return{x:u,y:d}}function X(i,s){return i.map((a,r)=>{const{x:h,y:l}=H(i.length,r,a,s);return`${h.toFixed(2)},${l.toFixed(2)}`}).join(" ")}function J(i,s=28){return i.length<=s?i:`${i.slice(0,s-1)}...`}function K({summary:i}){const[s,a]=j.useState(null),r=i.days,h=q(i),l=Math.max(1,...h.flatMap(e=>e.values)),c=Y(l),n=p.left,u=p.top,d=w-p.left-p.right,x=C-p.top-p.bottom,f=[0,.5,1],M=Math.max(1,Math.ceil(r.length/5)),v=190,y=86,g=s?Math.min(Math.max(s.x+12,8),w-v-8):0,_=s?Math.min(Math.max(s.y-y-10,8),C-y-8):0;return t.jsxs("div",{className:"statistics-line-chart",children:[t.jsxs("svg",{className:"statistics-line-chart__svg",viewBox:`0 0 ${w} ${C}`,role:"img","aria-label":"Daily Claude token usage by agent",preserveAspectRatio:"xMidYMid meet",onMouseLeave:()=>a(null),children:[f.map(e=>{const m=u+x-e*x;return t.jsxs("g",{children:[t.jsx("line",{className:"statistics-line-chart__grid",x1:n,y1:m,x2:n+d,y2:m}),t.jsx("text",{className:"statistics-line-chart__axis-label",x:n-10,y:m+4,textAnchor:"end",children:k(Math.round(c*e))})]},e)}),t.jsx("line",{className:"statistics-line-chart__axis",x1:n,y1:u,x2:n,y2:u+x}),t.jsx("line",{className:"statistics-line-chart__axis",x1:n,y1:u+x,x2:n+d,y2:u+x}),r.map((e,m)=>{if(m!==0&&m!==r.length-1&&m%M!==0)return null;const o=r.length<=1?n+d/2:n+m/(r.length-1)*d;return t.jsx("text",{className:"statistics-line-chart__axis-label",x:o,y:C-14,textAnchor:"middle",children:E(e.date)},e.date)}),h.map(e=>t.jsx("polyline",{className:e.isTotal?"statistics-line-chart__line statistics-line-chart__line--total":"statistics-line-chart__line",points:X(e.values,c),fill:"none",stroke:e.color,strokeWidth:e.isTotal?3:2,strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("title",{children:`${e.name}: ${e.peak.toLocaleString()} peak daily tokens`})},e.id)),h.map(e=>e.values.map((m,o)=>{var L,D,V,A;const{x:N,y:S}=H(r.length,o,m,c),T={id:`${e.id}-${(L=r[o])==null?void 0:L.date}`,date:((D=r[o])==null?void 0:D.date)??"",name:e.name,color:e.color,value:m,total:e.total,peak:e.peak,x:N,y:S};return t.jsxs("g",{children:[t.jsx("circle",{className:"statistics-line-chart__point",cx:N,cy:S,r:e.isTotal?3.4:2.6,fill:e.color}),t.jsx("circle",{className:"statistics-line-chart__point-hit",cx:N,cy:S,r:10,tabIndex:0,role:"button","aria-label":`${e.name} ${(V=r[o])==null?void 0:V.date}: ${m.toLocaleString()} tokens`,onMouseEnter:()=>a(T),onFocus:()=>a(T),onBlur:()=>a(null)})]},`${e.id}-${(A=r[o])==null?void 0:A.date}`)})),s&&t.jsxs("g",{className:"statistics-line-chart__tooltip",children:[t.jsx("line",{className:"statistics-line-chart__hover-line",x1:s.x,y1:u,x2:s.x,y2:u+x}),t.jsx("circle",{className:"statistics-line-chart__hover-point",cx:s.x,cy:s.y,r:5,fill:s.color}),t.jsx("rect",{className:"statistics-line-chart__tooltip-box",x:g,y:_,width:v,height:y,rx:6}),t.jsx("text",{className:"statistics-line-chart__tooltip-title",x:g+10,y:_+18,children:E(s.date)}),t.jsx("text",{className:"statistics-line-chart__tooltip-name",x:g+10,y:_+34,children:J(s.name)}),t.jsxs("text",{className:"statistics-line-chart__tooltip-value",x:g+10,y:_+52,children:["Daily: ",k(s.value)]}),t.jsxs("text",{className:"statistics-line-chart__tooltip-meta",x:g+10,y:_+68,children:["Peak: ",k(s.peak)]}),t.jsxs("text",{className:"statistics-line-chart__tooltip-meta",x:g+100,y:_+68,children:["Total: ",k(s.total)]})]})]}),t.jsx("div",{className:"statistics-line-chart__legend",children:h.map(e=>t.jsxs("div",{className:"statistics-line-chart__legend-item",title:`${e.name}: peak ${e.peak.toLocaleString()} daily tokens, ${e.total.toLocaleString()} period tokens`,children:[t.jsx("span",{className:"statistics-line-chart__legend-swatch",style:{backgroundColor:e.color}}),t.jsx("span",{children:e.name}),t.jsx("strong",{children:k(e.peak)})]},e.id))})]})}function tt({isOpen:i,onClose:s}){const{t:a}=U(["terminal","common"]),{handleMouseDown:r,handleClick:h}=R(s),[l,c]=j.useState(null),[n,u]=j.useState(null),[d,x]=j.useState(!1),[f,M]=j.useState(null),v=j.useMemo(()=>W(),[]),y=j.useCallback(async()=>{x(!0),M(null);try{const o=Date.now(),[N,S]=await Promise.all([F({since:v,until:o}),B({days:P,until:o})]);c(N),u(S)}catch(o){M((o==null?void 0:o.message)||"Error")}finally{x(!1)}},[v]);if(j.useEffect(()=>{i&&y()},[i,y]),!i)return null;const g=(l==null?void 0:l.entries)??[],_=(l==null?void 0:l.totalTokens)??0,e=z(g,_),m=((n==null?void 0:n.days)??[]).some(o=>o.totalTokens>0);return t.jsx(G,{children:t.jsx("div",{className:"modal-overlay visible",onMouseDown:r,onClick:h,children:t.jsxs("div",{className:"modal statistics-modal",children:[t.jsxs("div",{className:"modal-header statistics-modal__header",children:[t.jsxs("div",{className:"statistics-modal__title",children:[t.jsx("span",{className:"statistics-modal__icon",children:t.jsx(I,{name:"dashboard",size:15})}),t.jsx("span",{children:a("terminal:statistics.title",{defaultValue:"Statistics"})})]}),t.jsx("button",{className:"modal-close statistics-modal__close",onClick:s,title:a("common:buttons.close"),children:"×"})]}),t.jsxs("div",{className:"modal-body statistics-modal__body",children:[t.jsxs("section",{className:"statistics-panel",children:[t.jsxs("div",{className:"statistics-panel__header",children:[t.jsxs("div",{children:[t.jsx("h3",{children:a("terminal:statistics.usageByAgent",{defaultValue:"Claude usage today"})}),t.jsx("span",{className:"statistics-panel__subtitle",children:a("terminal:statistics.usageByAgentSubtitle",{defaultValue:"Input + cache creation + cache read + output tokens, deduped by Claude request id"})})]}),t.jsx("button",{type:"button",className:"statistics-panel__refresh",onClick:y,disabled:d,title:a("terminal:statistics.refresh",{defaultValue:"Refresh usage"}),children:t.jsx(I,{name:"refresh",size:14})})]}),d&&!l&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.loading",{defaultValue:"Loading usage..."})}),!d&&f&&t.jsx("div",{className:"statistics-panel__empty statistics-panel__empty--error",children:a("terminal:statistics.error",{defaultValue:"Failed to load usage: {{error}}",error:f})}),!f&&l&&g.length===0&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.empty",{defaultValue:"No Claude token usage found for today."})}),!f&&l&&g.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"statistics-panel__layout",children:[t.jsx("div",{className:"statistics-panel__chart-wrap",children:t.jsx("div",{className:"statistics-panel__pie",style:{background:e},role:"img","aria-label":a("terminal:statistics.pieLabel",{defaultValue:"Claude token usage by agent"}),children:t.jsxs("div",{className:"statistics-panel__pie-hole",children:[t.jsx("strong",{children:k(_)}),t.jsx("span",{children:a("terminal:statistics.total",{defaultValue:"total"})})]})})}),t.jsx("div",{className:"statistics-panel__list",children:g.map((o,N)=>t.jsxs("div",{className:"statistics-panel__row",title:`${o.agentName}: ${o.tokens.total.toLocaleString()} tokens`,children:[t.jsx("span",{className:"statistics-panel__swatch",style:{backgroundColor:b[N%b.length]}}),t.jsxs("div",{className:"statistics-panel__row-main",children:[t.jsx("div",{className:"statistics-panel__row-name",children:o.agentName}),t.jsxs("div",{className:"statistics-panel__row-meta",children:[o.requestCount.toLocaleString()," ",a("terminal:statistics.requests",{defaultValue:"requests"})," / ",o.percent,"%"]})]}),t.jsx("strong",{children:k(o.tokens.total)})]},o.agentId))})]}),t.jsx("div",{className:"statistics-panel__footnote",children:a("terminal:statistics.window",{defaultValue:"Window: {{since}} to {{until}}",since:$(l.since),until:$(l.until)})})]})]}),t.jsxs("section",{className:"statistics-panel",children:[t.jsx("div",{className:"statistics-panel__header",children:t.jsxs("div",{children:[t.jsx("h3",{children:a("terminal:statistics.dailyUsage",{defaultValue:"Daily usage by agent"})}),t.jsx("span",{className:"statistics-panel__subtitle",children:a("terminal:statistics.dailyUsageSubtitle",{defaultValue:"General token usage by day plus one line for each Claude agent."})})]})}),d&&!n&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.loading",{defaultValue:"Loading usage..."})}),!d&&!f&&n&&!m&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.dailyEmpty",{defaultValue:"No Claude token usage found for recent days."})}),!f&&n&&m&&t.jsxs(t.Fragment,{children:[t.jsx(K,{summary:n}),t.jsx("div",{className:"statistics-panel__footnote",children:a("terminal:statistics.window",{defaultValue:"Window: {{since}} to {{until}}",since:$(n.since),until:$(n.until)})})]})]})]})]})})})}export{tt as StatisticsModal};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as Qe,r as e,j as s,c as et}from"./main-Dk3qq80S.js";import{r as tt,F as nt,B as ke,d as Re,f as Ue,g as ve,V as T,s as Te,c as rt,e as st,W as at,H as ot,D as Be,P as ze,h as lt,i as it,j as ct,E as ut,L as dt,k as ft,A as pt,b as ht,a as mt,m as gt}from"./vendor-three-DYBBrXTx.js";import{O as wt}from"./OrbitControls-ANLmgNeR.js";import{g as xt,v as yt,u as bt,a as St,d as De,s as Ct,c as Mt,T as vt,b as Et}from"./ThreeAreaSelector-Bj_mL6NG.js";import{T as Rt,a as Ft}from"./ThreeViewShortcuts-CKtE3yZV.js";import"./vendor-react--Eh9ivFN.js";class jt extends tt{constructor(V){super(V)}load(V,le,ie,a){const _=this,F=new nt(this.manager);F.setPath(this.path),F.setResponseType("arraybuffer"),F.setRequestHeader(this.requestHeader),F.setWithCredentials(this.withCredentials),F.load(V,function(X){try{le(_.parse(X))}catch(d){a?a(d):console.error(d),_.manager.itemError(V)}},ie,a)}parse(V){function le(l){const t=new DataView(l),u=32/8*3+32/8*3*3+16/8,y=t.getUint32(80,!0);if(80+32/8+y*u===t.byteLength)return!0;const j=[115,111,108,105,100];for(let p=0;p<5;p++)if(ie(j,t,p))return!1;return!0}function ie(l,t,u){for(let y=0,A=l.length;y<A;y++)if(l[y]!==t.getUint8(u+y))return!1;return!0}function a(l){const t=new DataView(l),u=t.getUint32(80,!0);let y,A,j,p=!1,P,O,I,G,K;for(let g=0;g<70;g++)t.getUint32(g,!1)==1129270351&&t.getUint8(g+4)==82&&t.getUint8(g+5)==61&&(p=!0,P=new Float32Array(u*3*3),O=t.getUint8(g+6)/255,I=t.getUint8(g+7)/255,G=t.getUint8(g+8)/255,K=t.getUint8(g+9)/255);const C=84,i=50,v=new ke,b=new Float32Array(u*3*3),N=new Float32Array(u*3*3),c=new Re;for(let g=0;g<u;g++){const B=C+g*i,ce=t.getFloat32(B,!0),H=t.getFloat32(B+4,!0),$=t.getFloat32(B+8,!0);if(p){const E=t.getUint16(B+48,!0);(E&32768)===0?(y=(E&31)/31,A=(E>>5&31)/31,j=(E>>10&31)/31):(y=O,A=I,j=G)}for(let E=1;E<=3;E++){const Y=B+E*12,z=g*3*3+(E-1)*3;b[z]=t.getFloat32(Y,!0),b[z+1]=t.getFloat32(Y+4,!0),b[z+2]=t.getFloat32(Y+8,!0),N[z]=ce,N[z+1]=H,N[z+2]=$,p&&(c.setRGB(y,A,j,Ue),P[z]=c.r,P[z+1]=c.g,P[z+2]=c.b)}}return v.setAttribute("position",new ve(b,3)),v.setAttribute("normal",new ve(N,3)),p&&(v.setAttribute("color",new ve(P,3)),v.hasColors=!0,v.alpha=K),v}function _(l){const t=new ke,u=/solid([\s\S]*?)endsolid/g,y=/facet([\s\S]*?)endfacet/g,A=/solid\s(.+)/;let j=0;const p=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,P=new RegExp("vertex"+p+p+p,"g"),O=new RegExp("normal"+p+p+p,"g"),I=[],G=[],K=[],C=new T;let i,v=0,b=0,N=0;for(;(i=u.exec(l))!==null;){b=N;const c=i[0],g=(i=A.exec(c))!==null?i[1]:"";for(K.push(g);(i=y.exec(c))!==null;){let H=0,$=0;const E=i[0];for(;(i=O.exec(E))!==null;)C.x=parseFloat(i[1]),C.y=parseFloat(i[2]),C.z=parseFloat(i[3]),$++;for(;(i=P.exec(E))!==null;)I.push(parseFloat(i[1]),parseFloat(i[2]),parseFloat(i[3])),G.push(C.x,C.y,C.z),H++,N++;$!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+j),H!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+j),j++}const B=b,ce=N-b;t.userData.groupNames=K,t.addGroup(B,ce,v),v++}return t.setAttribute("position",new Te(I,3)),t.setAttribute("normal",new Te(G,3)),t}function F(l){return typeof l!="string"?new TextDecoder().decode(l):l}function X(l){if(typeof l=="string"){const t=new Uint8Array(l.length);for(let u=0;u<l.length;u++)t[u]=l.charCodeAt(u)&255;return t.buffer||t}else return l}const d=X(V);return le(d)?a(d):_(F(V))}}function Ee(L){return Number.isFinite(L)?L>=100?L.toFixed(0):L>=10?L.toFixed(1):L.toFixed(2):"0"}function Bt({url:L,filename:V,filePath:le,onFileSelect:ie}){const{t:a}=Qe("terminal"),_=e.useRef(null),F=e.useRef(null),X=e.useRef(null),d=e.useRef(null),l=e.useRef(null),t=e.useRef(null),u=e.useRef(null),y=e.useRef(null),A=e.useRef(null),j=e.useRef(null),p=e.useRef(null),P=e.useRef(null),O=e.useRef(null),I=e.useRef([]),G=e.useRef(new T),K=e.useRef(1),C=e.useRef(null),[i,v]=e.useState(!0),[b,N]=e.useState(null),[c,g]=e.useState(null),[B,ce]=e.useState(!1),[H]=e.useState(xt),[$,E]=e.useState(H.modelColor),[Y,z]=e.useState(H.backgroundColor),[ue,Oe]=e.useState(H.lightIntensity),[q,Ie]=e.useState(H.modelOpacity),[de,Ge]=e.useState(H.showEdges),[re,He]=e.useState(!1),[Z,$e]=e.useState(0),[J,We]=e.useState(100),[ye,be]=e.useState(!1),[Q,pe]=e.useState(null),[se,he]=e.useState([]),[Se,me]=e.useState(null),Ce=le||yt(L),Xe=bt(Ce,V,"stl");St({enabled:!!c&&Q===null,rendererRef:P,cameraRef:p,controlsRef:O,modelObjectsRef:I,modelCenterRef:G,markerGroupRef:C,renderRef:d,setAreas:he,setSelectedId:me}),e.useEffect(()=>{const n=_.current;if(!n)return;const h=new AbortController;let m=!1,r=null,D=null,W=null,w=null,x=null;v(!0),N(null),g(null);const S=new rt;S.background=new Re(1119258),l.current=S;const f=new st(40,1,.01,1e4);p.current=f,f.up.set(0,0,1);let o;try{o=new at({antialias:!0})}catch{v(!1),N(a("fileViewerModal.webglUnavailable"));return}o.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),P.current=o,o.outputColorSpace=Ue,o.localClippingEnabled=!0,o.domElement.className="stl-viewer-canvas",o.domElement.setAttribute("aria-label",a("fileViewerModal.previewLabel",{filename:V})),n.appendChild(o.domElement);const U=new wt(f,o.domElement);O.current=U,U.enableDamping=!1,U.screenSpacePanning=!0,U.addEventListener("change",()=>o.render(S,f));const ge=new ot(16777215,2502724,2.2);S.add(ge);const ee=new Be(16777215,2.4);ee.position.set(3,4,5),S.add(ee);const ae=new Be(8040191,1.1);ae.position.set(-4,1,-3),S.add(ae),A.current={hemisphere:ge,key:ee,fill:ae},d.current=()=>o.render(S,f),j.current={lower:new ze(new T(0,0,1),1e9),upper:new ze(new T(0,0,-1),1e9)};const fe=()=>{const oe=Math.max(n.clientWidth,1),te=Math.max(n.clientHeight,1);f.aspect=oe/te,f.updateProjectionMatrix(),o.setSize(oe,te,!1),o.render(S,f)},we=new ResizeObserver(fe);return we.observe(n),fe(),(async()=>{var oe,te,Fe,je;try{const ne=await et(L,{signal:h.signal});if(!ne.ok){let R=`Could not load STL (${ne.status})`;try{const M=await ne.json();typeof(M==null?void 0:M.error)=="string"&&(R=M.error)}catch{}throw new Error(R)}const _e=await ne.arrayBuffer();if(m)return;if(r=new jt().parse(_e),!((oe=r.getAttribute("position"))!=null&&oe.count))throw new Error(a("fileViewerModal.emptyStl"));r.computeVertexNormals(),r.computeBoundingBox();const k=((te=r.boundingBox)==null?void 0:te.getSize(new T))??new T(1,1,1);G.current.copy(((Fe=r.boundingBox)==null?void 0:Fe.getCenter(new T))??new T),K.current=Math.max(k.x,k.y,k.z,.001)*.12,r.center(),r.computeBoundingSphere(),D=new lt({color:5818329,vertexColors:!1,metalness:.08,roughness:.62,side:it}),t.current=D;const Le=new ct(r,D);I.current=[Le],S.add(Le),W=new ut(r,28),w=new dt({color:1582123,transparent:!0,opacity:.52});const Ve=new ft(W,w);u.current=w,y.current=Ve,S.add(Ve);const qe=Math.max(k.x,k.y,k.z,.001)*.3;x=new pt(qe),x.position.set(-k.x/2,-k.y/2,-k.z/2),x.renderOrder=5,S.add(x);const Ae=Math.max(((je=r.boundingSphere)==null?void 0:je.radius)??1,.001),Ze=ht.degToRad(f.fov/2),xe=Math.max(Ae/Math.sin(Ze)*1.15,.01),Me=R=>{f.near=Math.max(xe/1e3,1e-4),f.far=Math.max(xe*100,10);const M=R==="x"?new T(1,0,0):R==="y"?new T(0,1,0):R==="z"?new T(0,0,1):new T(1,-1,.82).normalize();f.up.set(0,R==="z"?1:0,R==="z"?0:1),f.position.copy(M.multiplyScalar(xe)),f.updateProjectionMatrix(),U.target.set(0,0,0),U.minDistance=Ae*.05,U.maxDistance=xe*20,U.update(),o.render(S,f)},Pe=()=>Me("iso");X.current=Me,F.current=Pe,Pe();const Je=R=>{if(R.ctrlKey||R.metaKey||R.altKey)return;const M=R.key.toLowerCase(),Ne=M==="x"||M==="1"?"x":M==="y"||M==="2"?"y":M==="z"||M==="3"?"z":M==="i"||M==="4"?"iso":null;Ne&&(R.preventDefault(),Me(Ne))};o.domElement.tabIndex=0,o.domElement.addEventListener("pointerdown",()=>o.domElement.focus()),o.domElement.addEventListener("keydown",Je),g({triangles:Math.floor(r.getAttribute("position").count/3),dimensions:[k.x,k.y,k.z]}),v(!1)}catch(ne){if(h.signal.aborted||m)return;N(ne instanceof Error?ne.message:a("fileViewerModal.renderError")),v(!1)}})(),()=>{m=!0,h.abort(),F.current=null,X.current=null,d.current=null,l.current=null,t.current=null,u.current=null,y.current=null,A.current=null,j.current=null,p.current=null,P.current=null,O.current=null,I.current=[],De(C.current),C.current=null,we.disconnect(),U.dispose(),r==null||r.dispose(),D==null||D.dispose(),W==null||W.dispose(),w==null||w.dispose(),x==null||x.geometry.dispose(),x&&(Array.isArray(x.material)?x.material:[x.material]).forEach(te=>te.dispose()),o.dispose(),o.domElement.remove()}},[L,V,a]),e.useEffect(()=>{var h;l.current&&(l.current.background=new Re(Y)),t.current&&(t.current.color.set($),t.current.transparent=q<100,t.current.opacity=q/100,t.current.depthWrite=q>=100,t.current.needsUpdate=!0);const n=A.current;if(n){const m=ue/100;n.hemisphere.intensity=2.2*m,n.key.intensity=2.4*m,n.fill.intensity=1.1*m}y.current&&(y.current.visible=de),(h=d.current)==null||h.call(d)},[$,Y,ue,q,de,c]),e.useEffect(()=>{Ct({modelColor:$,backgroundColor:Y,lightIntensity:ue,modelOpacity:q,showEdges:de})},[$,Y,ue,q,de]),e.useEffect(()=>{var x,S,f;const n=j.current,h=t.current;if(!n||!h||!c)return;const m=c.dimensions[2],r=-m/2,D=r+m*(Z/100),W=r+m*(J/100);n.lower.constant=-D,n.upper.constant=W;const w=re?[n.lower,n.upper]:[];(((x=h.clippingPlanes)==null?void 0:x.length)??0)!==w.length&&(h.needsUpdate=!0),h.clippingPlanes=w,u.current&&((((S=u.current.clippingPlanes)==null?void 0:S.length)??0)!==w.length&&(u.current.needsUpdate=!0),u.current.clippingPlanes=w),(f=d.current)==null||f.call(d)},[re,Z,J,c]),e.useEffect(()=>{he([]),me(null),pe(null),be(!1)},[L]),e.useEffect(()=>{O.current&&(O.current.enabled=Q===null);const n=P.current,h=p.current;if(!n||!h||!c||!Q)return;const m=n.domElement;let r=null;const D=w=>{r=[w.clientX,w.clientY]},W=w=>{var fe;if(!r||Math.hypot(w.clientX-r[0],w.clientY-r[1])>5)return;const x=m.getBoundingClientRect(),S=new mt((w.clientX-x.left)/x.width*2-1,-((w.clientY-x.top)/x.height)*2+1),f=new gt;f.setFromCamera(S,h);const o=f.intersectObjects(I.current,!1)[0];if(!o)return;const U=o.point.clone().add(G.current),ge=(fe=o.face)==null?void 0:fe.normal.clone().transformDirection(o.object.matrixWorld).toArray(),ee=K.current,ae=`area-${Date.now()}-${Math.random().toString(36).slice(2,7)}`;he(we=>[...we,{id:ae,shape:Q,center:U.toArray(),size:[ee,ee,ee],surfaceNormal:ge}]),me(ae)};return m.addEventListener("pointerdown",D),m.addEventListener("pointerup",W),()=>{m.removeEventListener("pointerdown",D),m.removeEventListener("pointerup",W)}},[Q,c]),e.useEffect(()=>{var m,r;De(C.current),C.current=null;const n=l.current;if(!n||se.length===0){(m=d.current)==null||m.call(d);return}const h=Mt(se,G.current,Se);C.current=h,n.add(h),(r=d.current)==null||r.call(d)},[se,Se,c]);const Ye=e.useCallback(()=>{var n;return(n=F.current)==null?void 0:n.call(F)},[]),Ke=e.useCallback(n=>{var h;return(h=X.current)==null?void 0:h.call(X,n)},[]);return s.jsxs("div",{className:`stl-viewer${Q?" area-placement-active":""}`,ref:_,children:[i&&s.jsx("div",{className:"stl-viewer-status",children:a("fileViewerModal.loading3d")}),b&&s.jsx("div",{className:"stl-viewer-status stl-viewer-error",children:b}),!i&&!b&&s.jsxs("div",{className:"stl-viewer-toolbar",children:[c&&s.jsxs("span",{className:"stl-viewer-info",children:[a("fileViewerModal.triangleCount",{count:c.triangles.toLocaleString()})," ·"," ",c.dimensions.map(Ee).join(" × ")]}),s.jsx(Rt,{onView:Ke}),s.jsx("button",{type:"button",onClick:Ye,title:a("fileViewerModal.resetCamera"),"aria-label":a("fileViewerModal.resetCamera"),children:a("fileViewerModal.resetView")}),s.jsx("button",{type:"button",className:re?"active":void 0,onClick:()=>He(n=>!n),"aria-pressed":re,children:a("fileViewerModal.layers")}),s.jsxs("button",{type:"button",className:ye?"active":void 0,onClick:()=>{be(n=>!n),pe(null)},"aria-expanded":ye,children:[a("fileViewerModal.areas"),se.length>0?` (${se.length})`:""]}),s.jsx("button",{type:"button",className:B?"active":void 0,onClick:()=>ce(n=>!n),"aria-expanded":B,children:a("fileViewerModal.viewerSettings")})]}),!i&&!b&&B&&s.jsx(vt,{modelColor:$,onModelColorChange:E,backgroundColor:Y,onBackgroundColorChange:z,lightIntensity:ue,onLightIntensityChange:Oe,modelOpacity:q,onModelOpacityChange:Ie,showEdges:de,onShowEdgesChange:Ge,recentFiles:Xe,currentFilePath:Ce,onRecentFileSelect:ie}),!i&&!b&&ye&&s.jsx(Et,{areas:se,selectedId:Se,placementShape:Q,filename:V,filePath:Ce,modelExtent:Math.max(...c.dimensions),className:re?"with-layer-control":void 0,onPlacementShapeChange:pe,onSelectedIdChange:me,onAreasChange:he,onClose:()=>{be(!1),pe(null)}}),!i&&!b&&re&&c&&s.jsxs("div",{className:"stl-layer-control",children:[s.jsxs("div",{className:"stl-layer-values",children:[s.jsxs("output",{children:[Math.round(Z),"%"]}),s.jsx("span",{children:"–"}),s.jsxs("output",{children:[Math.round(J),"%"]})]}),s.jsxs("span",{className:"stl-layer-height",children:[Ee(c.dimensions[2]*(J-Z)/100)," / ",Ee(c.dimensions[2])]}),s.jsxs("div",{className:"stl-layer-slider",style:{"--layer-bottom":`${Z}%`,"--layer-top-offset":`${100-J}%`},children:[s.jsx("span",{className:"stl-layer-slider-track","aria-hidden":"true"}),s.jsx("span",{className:"stl-layer-slider-selection","aria-hidden":"true"}),s.jsx("input",{className:"stl-layer-range stl-layer-range-bottom",type:"range",min:"0",max:"100",step:"1",value:Z,onChange:n=>$e(Math.min(Number(n.target.value),J)),"aria-label":a("fileViewerModal.layerBottom"),"aria-orientation":"vertical",title:a("fileViewerModal.layerBottom")}),s.jsx("input",{className:"stl-layer-range stl-layer-range-top",type:"range",min:"0",max:"100",step:"1",value:J,onChange:n=>We(Math.max(Number(n.target.value),Z)),"aria-label":a("fileViewerModal.layerTop"),"aria-orientation":"vertical",title:a("fileViewerModal.layerTop")})]}),s.jsx("span",{children:a("fileViewerModal.layerAxis")})]}),!i&&!b&&s.jsx("div",{className:"stl-viewer-hint",children:a("fileViewerModal.controlsHint")}),!i&&!b&&s.jsx(Ft,{})]})}export{Bt as StlViewer};
|
|
1
|
+
import{u as Qe,r as e,j as s,c as et}from"./main-CICvC5Bz.js";import{r as tt,F as nt,B as ke,d as Re,f as Ue,g as ve,V as T,s as Te,c as rt,e as st,W as at,H as ot,D as Be,P as ze,h as lt,i as it,j as ct,E as ut,L as dt,k as ft,A as pt,b as ht,a as mt,m as gt}from"./vendor-three-DYBBrXTx.js";import{O as wt}from"./OrbitControls-ANLmgNeR.js";import{g as xt,v as yt,u as bt,a as St,d as De,s as Ct,c as Mt,T as vt,b as Et}from"./ThreeAreaSelector-DSeyJIE9.js";import{T as Rt,a as Ft}from"./ThreeViewShortcuts-B8niKYtb.js";import"./vendor-react--Eh9ivFN.js";class jt extends tt{constructor(V){super(V)}load(V,le,ie,a){const _=this,F=new nt(this.manager);F.setPath(this.path),F.setResponseType("arraybuffer"),F.setRequestHeader(this.requestHeader),F.setWithCredentials(this.withCredentials),F.load(V,function(X){try{le(_.parse(X))}catch(d){a?a(d):console.error(d),_.manager.itemError(V)}},ie,a)}parse(V){function le(l){const t=new DataView(l),u=32/8*3+32/8*3*3+16/8,y=t.getUint32(80,!0);if(80+32/8+y*u===t.byteLength)return!0;const j=[115,111,108,105,100];for(let p=0;p<5;p++)if(ie(j,t,p))return!1;return!0}function ie(l,t,u){for(let y=0,A=l.length;y<A;y++)if(l[y]!==t.getUint8(u+y))return!1;return!0}function a(l){const t=new DataView(l),u=t.getUint32(80,!0);let y,A,j,p=!1,P,O,I,G,K;for(let g=0;g<70;g++)t.getUint32(g,!1)==1129270351&&t.getUint8(g+4)==82&&t.getUint8(g+5)==61&&(p=!0,P=new Float32Array(u*3*3),O=t.getUint8(g+6)/255,I=t.getUint8(g+7)/255,G=t.getUint8(g+8)/255,K=t.getUint8(g+9)/255);const C=84,i=50,v=new ke,b=new Float32Array(u*3*3),N=new Float32Array(u*3*3),c=new Re;for(let g=0;g<u;g++){const B=C+g*i,ce=t.getFloat32(B,!0),H=t.getFloat32(B+4,!0),$=t.getFloat32(B+8,!0);if(p){const E=t.getUint16(B+48,!0);(E&32768)===0?(y=(E&31)/31,A=(E>>5&31)/31,j=(E>>10&31)/31):(y=O,A=I,j=G)}for(let E=1;E<=3;E++){const Y=B+E*12,z=g*3*3+(E-1)*3;b[z]=t.getFloat32(Y,!0),b[z+1]=t.getFloat32(Y+4,!0),b[z+2]=t.getFloat32(Y+8,!0),N[z]=ce,N[z+1]=H,N[z+2]=$,p&&(c.setRGB(y,A,j,Ue),P[z]=c.r,P[z+1]=c.g,P[z+2]=c.b)}}return v.setAttribute("position",new ve(b,3)),v.setAttribute("normal",new ve(N,3)),p&&(v.setAttribute("color",new ve(P,3)),v.hasColors=!0,v.alpha=K),v}function _(l){const t=new ke,u=/solid([\s\S]*?)endsolid/g,y=/facet([\s\S]*?)endfacet/g,A=/solid\s(.+)/;let j=0;const p=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,P=new RegExp("vertex"+p+p+p,"g"),O=new RegExp("normal"+p+p+p,"g"),I=[],G=[],K=[],C=new T;let i,v=0,b=0,N=0;for(;(i=u.exec(l))!==null;){b=N;const c=i[0],g=(i=A.exec(c))!==null?i[1]:"";for(K.push(g);(i=y.exec(c))!==null;){let H=0,$=0;const E=i[0];for(;(i=O.exec(E))!==null;)C.x=parseFloat(i[1]),C.y=parseFloat(i[2]),C.z=parseFloat(i[3]),$++;for(;(i=P.exec(E))!==null;)I.push(parseFloat(i[1]),parseFloat(i[2]),parseFloat(i[3])),G.push(C.x,C.y,C.z),H++,N++;$!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+j),H!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+j),j++}const B=b,ce=N-b;t.userData.groupNames=K,t.addGroup(B,ce,v),v++}return t.setAttribute("position",new Te(I,3)),t.setAttribute("normal",new Te(G,3)),t}function F(l){return typeof l!="string"?new TextDecoder().decode(l):l}function X(l){if(typeof l=="string"){const t=new Uint8Array(l.length);for(let u=0;u<l.length;u++)t[u]=l.charCodeAt(u)&255;return t.buffer||t}else return l}const d=X(V);return le(d)?a(d):_(F(V))}}function Ee(L){return Number.isFinite(L)?L>=100?L.toFixed(0):L>=10?L.toFixed(1):L.toFixed(2):"0"}function Bt({url:L,filename:V,filePath:le,onFileSelect:ie}){const{t:a}=Qe("terminal"),_=e.useRef(null),F=e.useRef(null),X=e.useRef(null),d=e.useRef(null),l=e.useRef(null),t=e.useRef(null),u=e.useRef(null),y=e.useRef(null),A=e.useRef(null),j=e.useRef(null),p=e.useRef(null),P=e.useRef(null),O=e.useRef(null),I=e.useRef([]),G=e.useRef(new T),K=e.useRef(1),C=e.useRef(null),[i,v]=e.useState(!0),[b,N]=e.useState(null),[c,g]=e.useState(null),[B,ce]=e.useState(!1),[H]=e.useState(xt),[$,E]=e.useState(H.modelColor),[Y,z]=e.useState(H.backgroundColor),[ue,Oe]=e.useState(H.lightIntensity),[q,Ie]=e.useState(H.modelOpacity),[de,Ge]=e.useState(H.showEdges),[re,He]=e.useState(!1),[Z,$e]=e.useState(0),[J,We]=e.useState(100),[ye,be]=e.useState(!1),[Q,pe]=e.useState(null),[se,he]=e.useState([]),[Se,me]=e.useState(null),Ce=le||yt(L),Xe=bt(Ce,V,"stl");St({enabled:!!c&&Q===null,rendererRef:P,cameraRef:p,controlsRef:O,modelObjectsRef:I,modelCenterRef:G,markerGroupRef:C,renderRef:d,setAreas:he,setSelectedId:me}),e.useEffect(()=>{const n=_.current;if(!n)return;const h=new AbortController;let m=!1,r=null,D=null,W=null,w=null,x=null;v(!0),N(null),g(null);const S=new rt;S.background=new Re(1119258),l.current=S;const f=new st(40,1,.01,1e4);p.current=f,f.up.set(0,0,1);let o;try{o=new at({antialias:!0})}catch{v(!1),N(a("fileViewerModal.webglUnavailable"));return}o.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),P.current=o,o.outputColorSpace=Ue,o.localClippingEnabled=!0,o.domElement.className="stl-viewer-canvas",o.domElement.setAttribute("aria-label",a("fileViewerModal.previewLabel",{filename:V})),n.appendChild(o.domElement);const U=new wt(f,o.domElement);O.current=U,U.enableDamping=!1,U.screenSpacePanning=!0,U.addEventListener("change",()=>o.render(S,f));const ge=new ot(16777215,2502724,2.2);S.add(ge);const ee=new Be(16777215,2.4);ee.position.set(3,4,5),S.add(ee);const ae=new Be(8040191,1.1);ae.position.set(-4,1,-3),S.add(ae),A.current={hemisphere:ge,key:ee,fill:ae},d.current=()=>o.render(S,f),j.current={lower:new ze(new T(0,0,1),1e9),upper:new ze(new T(0,0,-1),1e9)};const fe=()=>{const oe=Math.max(n.clientWidth,1),te=Math.max(n.clientHeight,1);f.aspect=oe/te,f.updateProjectionMatrix(),o.setSize(oe,te,!1),o.render(S,f)},we=new ResizeObserver(fe);return we.observe(n),fe(),(async()=>{var oe,te,Fe,je;try{const ne=await et(L,{signal:h.signal});if(!ne.ok){let R=`Could not load STL (${ne.status})`;try{const M=await ne.json();typeof(M==null?void 0:M.error)=="string"&&(R=M.error)}catch{}throw new Error(R)}const _e=await ne.arrayBuffer();if(m)return;if(r=new jt().parse(_e),!((oe=r.getAttribute("position"))!=null&&oe.count))throw new Error(a("fileViewerModal.emptyStl"));r.computeVertexNormals(),r.computeBoundingBox();const k=((te=r.boundingBox)==null?void 0:te.getSize(new T))??new T(1,1,1);G.current.copy(((Fe=r.boundingBox)==null?void 0:Fe.getCenter(new T))??new T),K.current=Math.max(k.x,k.y,k.z,.001)*.12,r.center(),r.computeBoundingSphere(),D=new lt({color:5818329,vertexColors:!1,metalness:.08,roughness:.62,side:it}),t.current=D;const Le=new ct(r,D);I.current=[Le],S.add(Le),W=new ut(r,28),w=new dt({color:1582123,transparent:!0,opacity:.52});const Ve=new ft(W,w);u.current=w,y.current=Ve,S.add(Ve);const qe=Math.max(k.x,k.y,k.z,.001)*.3;x=new pt(qe),x.position.set(-k.x/2,-k.y/2,-k.z/2),x.renderOrder=5,S.add(x);const Ae=Math.max(((je=r.boundingSphere)==null?void 0:je.radius)??1,.001),Ze=ht.degToRad(f.fov/2),xe=Math.max(Ae/Math.sin(Ze)*1.15,.01),Me=R=>{f.near=Math.max(xe/1e3,1e-4),f.far=Math.max(xe*100,10);const M=R==="x"?new T(1,0,0):R==="y"?new T(0,1,0):R==="z"?new T(0,0,1):new T(1,-1,.82).normalize();f.up.set(0,R==="z"?1:0,R==="z"?0:1),f.position.copy(M.multiplyScalar(xe)),f.updateProjectionMatrix(),U.target.set(0,0,0),U.minDistance=Ae*.05,U.maxDistance=xe*20,U.update(),o.render(S,f)},Pe=()=>Me("iso");X.current=Me,F.current=Pe,Pe();const Je=R=>{if(R.ctrlKey||R.metaKey||R.altKey)return;const M=R.key.toLowerCase(),Ne=M==="x"||M==="1"?"x":M==="y"||M==="2"?"y":M==="z"||M==="3"?"z":M==="i"||M==="4"?"iso":null;Ne&&(R.preventDefault(),Me(Ne))};o.domElement.tabIndex=0,o.domElement.addEventListener("pointerdown",()=>o.domElement.focus()),o.domElement.addEventListener("keydown",Je),g({triangles:Math.floor(r.getAttribute("position").count/3),dimensions:[k.x,k.y,k.z]}),v(!1)}catch(ne){if(h.signal.aborted||m)return;N(ne instanceof Error?ne.message:a("fileViewerModal.renderError")),v(!1)}})(),()=>{m=!0,h.abort(),F.current=null,X.current=null,d.current=null,l.current=null,t.current=null,u.current=null,y.current=null,A.current=null,j.current=null,p.current=null,P.current=null,O.current=null,I.current=[],De(C.current),C.current=null,we.disconnect(),U.dispose(),r==null||r.dispose(),D==null||D.dispose(),W==null||W.dispose(),w==null||w.dispose(),x==null||x.geometry.dispose(),x&&(Array.isArray(x.material)?x.material:[x.material]).forEach(te=>te.dispose()),o.dispose(),o.domElement.remove()}},[L,V,a]),e.useEffect(()=>{var h;l.current&&(l.current.background=new Re(Y)),t.current&&(t.current.color.set($),t.current.transparent=q<100,t.current.opacity=q/100,t.current.depthWrite=q>=100,t.current.needsUpdate=!0);const n=A.current;if(n){const m=ue/100;n.hemisphere.intensity=2.2*m,n.key.intensity=2.4*m,n.fill.intensity=1.1*m}y.current&&(y.current.visible=de),(h=d.current)==null||h.call(d)},[$,Y,ue,q,de,c]),e.useEffect(()=>{Ct({modelColor:$,backgroundColor:Y,lightIntensity:ue,modelOpacity:q,showEdges:de})},[$,Y,ue,q,de]),e.useEffect(()=>{var x,S,f;const n=j.current,h=t.current;if(!n||!h||!c)return;const m=c.dimensions[2],r=-m/2,D=r+m*(Z/100),W=r+m*(J/100);n.lower.constant=-D,n.upper.constant=W;const w=re?[n.lower,n.upper]:[];(((x=h.clippingPlanes)==null?void 0:x.length)??0)!==w.length&&(h.needsUpdate=!0),h.clippingPlanes=w,u.current&&((((S=u.current.clippingPlanes)==null?void 0:S.length)??0)!==w.length&&(u.current.needsUpdate=!0),u.current.clippingPlanes=w),(f=d.current)==null||f.call(d)},[re,Z,J,c]),e.useEffect(()=>{he([]),me(null),pe(null),be(!1)},[L]),e.useEffect(()=>{O.current&&(O.current.enabled=Q===null);const n=P.current,h=p.current;if(!n||!h||!c||!Q)return;const m=n.domElement;let r=null;const D=w=>{r=[w.clientX,w.clientY]},W=w=>{var fe;if(!r||Math.hypot(w.clientX-r[0],w.clientY-r[1])>5)return;const x=m.getBoundingClientRect(),S=new mt((w.clientX-x.left)/x.width*2-1,-((w.clientY-x.top)/x.height)*2+1),f=new gt;f.setFromCamera(S,h);const o=f.intersectObjects(I.current,!1)[0];if(!o)return;const U=o.point.clone().add(G.current),ge=(fe=o.face)==null?void 0:fe.normal.clone().transformDirection(o.object.matrixWorld).toArray(),ee=K.current,ae=`area-${Date.now()}-${Math.random().toString(36).slice(2,7)}`;he(we=>[...we,{id:ae,shape:Q,center:U.toArray(),size:[ee,ee,ee],surfaceNormal:ge}]),me(ae)};return m.addEventListener("pointerdown",D),m.addEventListener("pointerup",W),()=>{m.removeEventListener("pointerdown",D),m.removeEventListener("pointerup",W)}},[Q,c]),e.useEffect(()=>{var m,r;De(C.current),C.current=null;const n=l.current;if(!n||se.length===0){(m=d.current)==null||m.call(d);return}const h=Mt(se,G.current,Se);C.current=h,n.add(h),(r=d.current)==null||r.call(d)},[se,Se,c]);const Ye=e.useCallback(()=>{var n;return(n=F.current)==null?void 0:n.call(F)},[]),Ke=e.useCallback(n=>{var h;return(h=X.current)==null?void 0:h.call(X,n)},[]);return s.jsxs("div",{className:`stl-viewer${Q?" area-placement-active":""}`,ref:_,children:[i&&s.jsx("div",{className:"stl-viewer-status",children:a("fileViewerModal.loading3d")}),b&&s.jsx("div",{className:"stl-viewer-status stl-viewer-error",children:b}),!i&&!b&&s.jsxs("div",{className:"stl-viewer-toolbar",children:[c&&s.jsxs("span",{className:"stl-viewer-info",children:[a("fileViewerModal.triangleCount",{count:c.triangles.toLocaleString()})," ·"," ",c.dimensions.map(Ee).join(" × ")]}),s.jsx(Rt,{onView:Ke}),s.jsx("button",{type:"button",onClick:Ye,title:a("fileViewerModal.resetCamera"),"aria-label":a("fileViewerModal.resetCamera"),children:a("fileViewerModal.resetView")}),s.jsx("button",{type:"button",className:re?"active":void 0,onClick:()=>He(n=>!n),"aria-pressed":re,children:a("fileViewerModal.layers")}),s.jsxs("button",{type:"button",className:ye?"active":void 0,onClick:()=>{be(n=>!n),pe(null)},"aria-expanded":ye,children:[a("fileViewerModal.areas"),se.length>0?` (${se.length})`:""]}),s.jsx("button",{type:"button",className:B?"active":void 0,onClick:()=>ce(n=>!n),"aria-expanded":B,children:a("fileViewerModal.viewerSettings")})]}),!i&&!b&&B&&s.jsx(vt,{modelColor:$,onModelColorChange:E,backgroundColor:Y,onBackgroundColorChange:z,lightIntensity:ue,onLightIntensityChange:Oe,modelOpacity:q,onModelOpacityChange:Ie,showEdges:de,onShowEdgesChange:Ge,recentFiles:Xe,currentFilePath:Ce,onRecentFileSelect:ie}),!i&&!b&&ye&&s.jsx(Et,{areas:se,selectedId:Se,placementShape:Q,filename:V,filePath:Ce,modelExtent:Math.max(...c.dimensions),className:re?"with-layer-control":void 0,onPlacementShapeChange:pe,onSelectedIdChange:me,onAreasChange:he,onClose:()=>{be(!1),pe(null)}}),!i&&!b&&re&&c&&s.jsxs("div",{className:"stl-layer-control",children:[s.jsxs("div",{className:"stl-layer-values",children:[s.jsxs("output",{children:[Math.round(Z),"%"]}),s.jsx("span",{children:"–"}),s.jsxs("output",{children:[Math.round(J),"%"]})]}),s.jsxs("span",{className:"stl-layer-height",children:[Ee(c.dimensions[2]*(J-Z)/100)," / ",Ee(c.dimensions[2])]}),s.jsxs("div",{className:"stl-layer-slider",style:{"--layer-bottom":`${Z}%`,"--layer-top-offset":`${100-J}%`},children:[s.jsx("span",{className:"stl-layer-slider-track","aria-hidden":"true"}),s.jsx("span",{className:"stl-layer-slider-selection","aria-hidden":"true"}),s.jsx("input",{className:"stl-layer-range stl-layer-range-bottom",type:"range",min:"0",max:"100",step:"1",value:Z,onChange:n=>$e(Math.min(Number(n.target.value),J)),"aria-label":a("fileViewerModal.layerBottom"),"aria-orientation":"vertical",title:a("fileViewerModal.layerBottom")}),s.jsx("input",{className:"stl-layer-range stl-layer-range-top",type:"range",min:"0",max:"100",step:"1",value:J,onChange:n=>We(Math.max(Number(n.target.value),Z)),"aria-label":a("fileViewerModal.layerTop"),"aria-orientation":"vertical",title:a("fileViewerModal.layerTop")})]}),s.jsx("span",{children:a("fileViewerModal.layerAxis")})]}),!i&&!b&&s.jsx("div",{className:"stl-viewer-hint",children:a("fileViewerModal.controlsHint")}),!i&&!b&&s.jsx(Ft,{})]})}export{Bt as StlViewer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as K,z as L,K as $,r as m,j as s,E as N,n as S,I as g,s as D}from"./main-
|
|
1
|
+
import{u as K,z as L,K as $,r as m,j as s,E as N,n as S,I as g,s as D}from"./main-CICvC5Bz.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-DYBBrXTx.js";function M({isOpen:l,bossId:r,onClose:o}){var j;const{t:a}=K(["terminal","common"]),f=L(),n=$(r),[i,c]=m.useState(new Set),[u,b]=m.useState(!1),d=Array.from(f.values()).filter(e=>e.class!=="boss"&&(!e.bossId||e.bossId===r));m.useEffect(()=>{l&&n&&c(new Set(n.subordinateIds||[]))},[l,n]);const y=()=>{b(!0),D.assignSubordinates(r,Array.from(i)),setTimeout(()=>{b(!1),o()},300)},A=e=>{const t=new Set(i);t.has(e)?t.delete(e):t.add(e),c(t)},C=()=>{c(new Set(d.map(e=>e.id)))},p=()=>{c(new Set)},w=e=>{e.target===e.currentTarget&&o()},k=e=>{e.key==="Escape"&&o()};if(!l||!n)return null;const E=N.boss,h=((j=n.subordinateIds)==null?void 0:j.length)||0,z=i.size,x=JSON.stringify([...n.subordinateIds||[]].sort())!==JSON.stringify([...i].sort());return s.jsx("div",{className:`modal-overlay ${l?"visible":""}`,onClick:w,onKeyDown:k,children:s.jsxs("div",{className:"modal subordinate-assignment-modal",children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("span",{className:"boss-header-icon",style:{color:E.color},children:s.jsx(S,{agent:n,size:22})}),a("terminal:team.manageTeam"),": ",n.name]}),s.jsxs("div",{className:"modal-body subordinate-assignment-body",children:[s.jsxs("div",{className:"subordinate-assignment-info",children:[s.jsx("p",{children:a("terminal:team.selectAgents")}),s.jsxs("div",{className:"subordinate-assignment-actions",children:[s.jsx("button",{className:"btn btn-small",onClick:C,children:a("common:buttons.selectAll")}),s.jsx("button",{className:"btn btn-small",onClick:p,children:a("common:buttons.clearAll")})]})]}),s.jsx("div",{className:"subordinates-list",children:d.length===0?s.jsx("div",{className:"subordinates-empty",children:a("terminal:team.noAgentsAvailable")}):d.map(e=>{var v;const t=i.has(e.id),I=N[e.class],T=(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}),T&&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})," ",z," ",a("terminal:team.subordinates").toLowerCase()]}):s.jsxs("span",{className:"summary-unchanged",children:[h," ",a("terminal:team.subordinates").toLowerCase()]})})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:o,children:a("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-boss",onClick:y,disabled:u||!x,children:a(u?"common:status.saving":"terminal:team.saveTeam")})]})]})})}export{M as SubordinateAssignmentModal};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{u as F,j as e,ar as D,S as k,as as R,r as M,at as Y}from"./main-
|
|
1
|
+
import{u as F,j as e,ar as D,S as k,as as R,r as M,at as Y}from"./main-CICvC5Bz.js";import{m as G,P as H,j as L,G as A,t as Z,u as O,v as $,i as B,V as z,a as U}from"./vendor-three-DYBBrXTx.js";function re({modelColor:t,onModelColorChange:d,backgroundColor:l,onBackgroundColorChange:o,lightIntensity:u,onLightIntensityChange:p,modelOpacity:n,onModelOpacityChange:j,showEdges:E,onShowEdgesChange:f,preserveModelColors:x,onPreserveModelColorsChange:c,recentFiles:h=[],currentFilePath:b,onRecentFileSelect:m}){const{t:w}=F("terminal");return e.jsxs("div",{className:"three-viewer-settings",role:"group","aria-label":w("fileViewerModal.viewerSettings"),children:[c&&e.jsxs("label",{className:"three-viewer-setting three-viewer-setting-toggle",children:[e.jsx("span",{children:w("fileViewerModal.originalColors")}),e.jsx("input",{type:"checkbox",checked:x,onChange:a=>c(a.target.checked)})]}),e.jsxs("label",{className:"three-viewer-setting",children:[e.jsx("span",{children:w("fileViewerModal.modelColor")}),e.jsx("input",{type:"color",value:t,disabled:x,onChange:a=>d(a.target.value)})]}),e.jsxs("label",{className:"three-viewer-setting",children:[e.jsx("span",{children:w("fileViewerModal.backgroundColor")}),e.jsx("input",{type:"color",value:l,onChange:a=>o(a.target.value)})]}),e.jsxs("label",{className:"three-viewer-setting three-viewer-setting-range",children:[e.jsx("span",{children:w("fileViewerModal.lightIntensity")}),e.jsx("input",{type:"range",min:"0",max:"200",step:"5",value:u,onChange:a=>p(Number(a.target.value))}),e.jsxs("output",{children:[u,"%"]})]}),e.jsxs("label",{className:"three-viewer-setting three-viewer-setting-range",children:[e.jsx("span",{children:w("fileViewerModal.modelOpacity")}),e.jsx("input",{type:"range",min:"0",max:"100",step:"5",value:n,onChange:a=>j(Number(a.target.value))}),e.jsxs("output",{children:[n,"%"]})]}),e.jsxs("label",{className:"three-viewer-setting three-viewer-setting-toggle",children:[e.jsx("span",{children:w("fileViewerModal.showEdges")}),e.jsx("input",{type:"checkbox",checked:E,onChange:a=>f(a.target.checked)})]}),h.length>0&&m&&e.jsxs("div",{className:"three-viewer-recents",children:[e.jsx("span",{className:"three-viewer-recents-title",children:w("fileViewerModal.recentFiles")}),e.jsx("div",{className:"three-viewer-recents-list",children:h.map(a=>e.jsxs("button",{type:"button",className:a.path===b?"active":void 0,onClick:()=>m(a.path),title:a.path,disabled:a.path===b,children:[e.jsx("span",{children:a.filename}),e.jsx("small",{children:a.kind==="fcstd"?"FreeCAD":"STL"})]},a.path))})]})]})}const J={modelColor:"#58c7d9",backgroundColor:"#11141a",lightIntensity:100,modelOpacity:100,showEdges:!0,preserveModelColors:!0};function K(){const t=D(k.THREE_VIEWER_SETTINGS,{});return{...J,...t}}function ne(t){R(k.THREE_VIEWER_SETTINGS,{...K(),...t})}const P="tide-three-viewer-recents-changed",W=8;function _(){return D(k.THREE_VIEWER_RECENT_FILES,[]).filter(t=>t&&typeof t.path=="string"&&(t.kind==="stl"||t.kind==="fcstd"||t.kind==="glb")).slice(0,W)}function Q(t){const d=[t,..._().filter(l=>l.path!==t.path)].slice(0,W);return R(k.THREE_VIEWER_RECENT_FILES,d),window.dispatchEvent(new CustomEvent(P)),d}function ie(t){try{return new URL(t,window.location.origin).searchParams.get("path")||""}catch{return""}}function se(t,d,l){const[o,u]=M.useState(_);return M.useEffect(()=>{t&&u(Q({path:t,filename:d,kind:l,viewedAt:Date.now()}))},[t,d,l]),M.useEffect(()=>{const p=()=>u(_());return window.addEventListener(P,p),window.addEventListener("storage",p),()=>{window.removeEventListener(P,p),window.removeEventListener("storage",p)}},[]),o}function y(t){return Number(t.toFixed(3)).toString()}function q(t,d,l){const o=d||t,u=l.map((n,j)=>{const E=n.center.map(y).join(", "),f=n.objectName?` objeto/componente \`${n.objectName}\`,`:"",x=n.surfaceNormal?` normal superficial [${n.surfaceNormal.map(y).join(", ")}]`:"";return n.shape==="sphere"?`${j+1}. Esfera:${f} centro XYZ [${E}] mm, radio ${y(n.size[0]/2)} mm.${x}`:`${j+1}. Cubo/caja:${f} centro XYZ [${E}] mm, tamaño XYZ [${n.size.map(y).join(", ")}] mm.${x}`}),p=JSON.stringify({file:o,coordinateSystem:"original-model-coordinates",units:"mm",areas:l.map(n=>({shape:n.shape,center:{x:n.center[0],y:n.center[1],z:n.center[2]},...n.objectName?{object:n.objectName}:{},...n.surfaceNormal?{surfaceNormal:{x:n.surfaceNormal[0],y:n.surfaceNormal[1],z:n.surfaceNormal[2]}}:{},...n.shape==="sphere"?{radius:n.size[0]/2}:{size:{x:n.size[0],y:n.size[1],z:n.size[2]}}}))},null,2);return[`Quiero modificar estas áreas del modelo \`${o}\`.`,"Las coordenadas están en el sistema original del archivo y las unidades se interpretan como milímetros.","",...u,"","```json",p,"```"].join(`
|
|
2
2
|
`)}function ae(t,d,l){const o=new A;o.name="tide-area-markers";for(const u of t){const p=u.shape==="sphere"?new Z(Math.max(u.size[0]/2,.001),24,16):new O(...u.size.map(h=>Math.max(h,.001))),n=u.id===l,j=new $({color:n?16763464:3725311,transparent:!0,opacity:n?.22:.13,depthWrite:!1,side:B}),E=new $({color:n?16766815:7398655,transparent:!0,opacity:.95,wireframe:!0,depthTest:!1}),f=new A;f.userData.areaId=u.id,f.position.set(...u.center).sub(d);const x=new L(p,j),c=new L(p,E);x.renderOrder=20,c.renderOrder=21,f.add(x,c),o.add(f)}return o}function oe(t){if(!t)return;t.removeFromParent();const d=new Set,l=new Set;t.traverse(o=>{if(!(o instanceof L))return;d.add(o.geometry),(Array.isArray(o.material)?o.material:[o.material]).forEach(p=>l.add(p))}),d.forEach(o=>o.dispose()),l.forEach(o=>o.dispose())}function ce({enabled:t,rendererRef:d,cameraRef:l,controlsRef:o,modelObjectsRef:u,modelCenterRef:p,markerGroupRef:n,renderRef:j,setAreas:E,setSelectedId:f}){M.useEffect(()=>{const x=d.current,c=l.current;if(!t||!x||!c)return;const h=x.domElement,b=new G,m=new U,w=new H;let a=null;const C=r=>{const s=h.getBoundingClientRect();m.set((r.clientX-s.left)/s.width*2-1,-((r.clientY-s.top)/s.height)*2+1),b.setFromCamera(m,c)},V=r=>{let s=r;for(;s&&typeof s.userData.areaId!="string";)s=s.parent;return s},T=r=>{var N;const s=n.current;if(r.button!==0||!s)return;C(r);const g=V(((N=b.intersectObject(s,!0)[0])==null?void 0:N.object)??null);if(!g)return;const v=g.getWorldPosition(new z);w.setFromNormalAndCoplanarPoint(c.getWorldDirection(new z),v),a={pointerId:r.pointerId,areaId:g.userData.areaId,marker:g,center:v.clone().add(p.current).toArray()},o.current&&(o.current.enabled=!1),h.setPointerCapture(r.pointerId),r.preventDefault(),r.stopImmediatePropagation()},S=r=>{var v,N;if(!a||r.pointerId!==a.pointerId)return;C(r);const s=b.intersectObjects(u.current,!1)[0],g=(s==null?void 0:s.point)??b.ray.intersectPlane(w,new z);g&&(a.marker.position.copy(g),a.center=g.clone().add(p.current).toArray(),s&&(a.objectName=s.object.name||void 0,a.surfaceNormal=(v=s.face)==null?void 0:v.normal.clone().transformDirection(s.object.matrixWorld).toArray()),(N=j.current)==null||N.call(j),r.preventDefault(),r.stopImmediatePropagation())},i=r=>{if(!a||r.pointerId!==a.pointerId)return;const{areaId:s,center:g,objectName:v,surfaceNormal:N}=a;a=null,E(X=>X.map(I=>I.id===s?{...I,center:g,...v?{objectName:v}:{},...N?{surfaceNormal:N}:{}}:I)),f(s),o.current&&(o.current.enabled=!0),h.hasPointerCapture(r.pointerId)&&h.releasePointerCapture(r.pointerId),r.preventDefault(),r.stopImmediatePropagation()};return h.addEventListener("pointerdown",T,!0),h.addEventListener("pointermove",S,!0),h.addEventListener("pointerup",i,!0),h.addEventListener("pointercancel",i,!0),()=>{h.removeEventListener("pointerdown",T,!0),h.removeEventListener("pointermove",S,!0),h.removeEventListener("pointerup",i,!0),h.removeEventListener("pointercancel",i,!0),o.current&&(o.current.enabled=!0)}},[t,l,o,n,p,u,j,d,E,f])}function le({areas:t,selectedId:d,placementShape:l,filename:o,filePath:u,modelExtent:p,className:n,onPlacementShapeChange:j,onSelectedIdChange:E,onAreasChange:f,onClose:x}){const{t:c}=F("terminal"),[h,b]=M.useState(!1),m=t.find(i=>i.id===d)??null,w=Math.max(p/200,.01),a=Math.max(p*1.5,w*2);M.useEffect(()=>{b(!1)},[t]);const C=i=>{m&&f(t.map(r=>r.id===m.id?{...r,...i}:r))},V=(i,r,s)=>{if(!m||!Number.isFinite(s))return;const g=[...m[i]];g[r]=i==="size"?Math.max(s,.001):s,m.shape==="sphere"&&i==="size"&&g.fill(g[r]),C({[i]:g})},T=()=>{m&&(f(t.filter(i=>i.id!==m.id)),E(null))},S=async()=>{t.length!==0&&(await Y(q(o,u,t)),b(!0))};return e.jsxs("aside",{className:`three-area-panel${n?` ${n}`:""}`,children:[e.jsxs("header",{children:[e.jsx("strong",{children:c("fileViewerModal.areaSelection")}),e.jsx("button",{type:"button",onClick:x,"aria-label":c("fileViewerModal.closeAreas"),children:"×"})]}),e.jsx("p",{children:c(l?"fileViewerModal.areaClickHint":"fileViewerModal.areaSelectShape")}),e.jsx("div",{className:"three-area-shapes",role:"group","aria-label":c("fileViewerModal.areaShape"),children:["sphere","box"].map(i=>e.jsxs("button",{type:"button",className:l===i?"active":void 0,onClick:()=>j(l===i?null:i),"aria-pressed":l===i,children:[e.jsx("span",{"aria-hidden":"true",children:i==="sphere"?"●":"◆"}),c(`fileViewerModal.areaShapes.${i}`)]},i))}),t.length>0&&e.jsx("div",{className:"three-area-list",children:t.map((i,r)=>e.jsxs("button",{type:"button",className:i.id===d?"active":void 0,onClick:()=>E(i.id),children:[r+1,". ",c(`fileViewerModal.areaShapes.${i.shape}`),e.jsxs("small",{children:[i.objectName?`${i.objectName} · `:"",i.center.map(y).join(", ")]})]},i.id))}),m&&e.jsxs("div",{className:"three-area-editor",children:[e.jsxs("span",{children:[c("fileViewerModal.areaCenter")," XYZ"]}),e.jsx("div",{className:"three-area-vector",children:m.center.map((i,r)=>e.jsxs("label",{children:["XYZ"[r],e.jsx("input",{type:"number",step:"0.1",value:y(i),onChange:s=>V("center",r,Number(s.target.value))})]},r))}),e.jsx("span",{children:m.shape==="sphere"?c("fileViewerModal.areaDiameter"):`${c("fileViewerModal.areaSize")} XYZ`}),e.jsx("div",{className:"three-area-size-sliders",children:(m.shape==="sphere"?m.size.slice(0,1):m.size).map((i,r)=>e.jsxs("label",{children:[e.jsx("span",{children:m.shape==="sphere"?"Ø":"XYZ"[r]}),e.jsx("input",{type:"range",min:w,max:a,step:w,value:i,onChange:s=>V("size",r,Number(s.target.value))}),e.jsx("input",{type:"number",min:"0.001",step:w,value:y(i),onChange:s=>V("size",r,Number(s.target.value))})]},r))}),e.jsx("button",{type:"button",className:"danger",onClick:T,children:c("fileViewerModal.removeArea")})]}),e.jsxs("footer",{children:[e.jsx("button",{type:"button",onClick:()=>{f([]),E(null)},disabled:t.length===0,children:c("fileViewerModal.clearAreas")}),e.jsx("button",{type:"button",className:"primary",onClick:()=>void S(),disabled:t.length===0,children:c(h?"fileViewerModal.areasCopied":"fileViewerModal.copyAreas")})]})]})}export{re as T,ce as a,le as b,ae as c,oe as d,K as g,ne as s,se as u,ie as v};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as t,j as e}from"./main-
|
|
1
|
+
import{u as t,j as e}from"./main-CICvC5Bz.js";function l({onView:i}){const{t:s}=t("terminal");return e.jsxs("span",{className:"three-view-shortcuts",role:"group","aria-label":s("fileViewerModal.standardViews"),children:[["x","y","z"].map(a=>e.jsx("button",{type:"button",onClick:()=>i(a),title:s("fileViewerModal.axisViewShortcut",{axis:a.toUpperCase(),key:a.toUpperCase()}),"aria-label":s("fileViewerModal.axisView",{axis:a.toUpperCase()}),children:a.toUpperCase()},a)),e.jsx("button",{type:"button",onClick:()=>i("iso"),title:s("fileViewerModal.isoViewShortcut"),"aria-label":s("fileViewerModal.isoView"),children:"ISO"})]})}function n(){const{t:i}=t("terminal");return e.jsxs("div",{className:"three-axis-legend","aria-label":i("fileViewerModal.axisLegend"),children:[e.jsx("span",{className:"axis-x",children:"X"}),e.jsx("span",{className:"axis-y",children:"Y"}),e.jsx("span",{className:"axis-z",children:"Z"})]})}export{l as T,n as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{z as Me,r as o,c as v,d as b,j as e}from"./main-
|
|
1
|
+
import{z as Me,r as o,c as v,d as b,j as e}from"./main-CICvC5Bz.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-DYBBrXTx.js";const Ie=[{value:"webhook",label:"Webhook"},{value:"bitbucket",label:"Bitbucket"},{value:"cron",label:"Cron"},{value:"slack",label:"Slack"},{value:"email",label:"Email"},{value:"jira",label:"Jira"},{value:"whatsapp",label:"WhatsApp"}],Ae=[{value:"all",label:"All",icon:"◎"},{value:"webhook",label:"Webhook",icon:"🪝"},{value:"bitbucket",label:"Bitbucket",icon:"🪣"},{value:"cron",label:"Cron",icon:"⏰"},{value:"slack",label:"Slack",icon:"💬"},{value:"email",label:"Email",icon:"✉️"},{value:"jira",label:"Jira",icon:"🎫"},{value:"whatsapp",label:"WhatsApp",icon:"📱"}],Be=[{value:"pullrequest:created",label:"PR created"},{value:"pullrequest:updated",label:"PR updated"},{value:"pullrequest:approved",label:"PR approved"},{value:"pullrequest:unapproved",label:"PR unapproved"},{value:"pullrequest:fulfilled",label:"PR merged"},{value:"pullrequest:rejected",label:"PR declined"},{value:"pullrequest:comment_created",label:"PR comment created"}],Re=[{value:"structural",label:"Structural",desc:"Field-based matching (fast, free)"},{value:"llm",label:"LLM",desc:"Semantic matching via LLM (flexible, costs tokens)"},{value:"hybrid",label:"Hybrid",desc:"Structural pre-filter + LLM (recommended)"}],Fe=[{value:"structural",label:"Structural"},{value:"llm",label:"LLM"}];function Ee(w){if(!w)return"";const g=new Date(w);if(Number.isNaN(g.getTime()))return"";const m=j=>String(j).padStart(2,"0");return`${g.getFullYear()}-${m(g.getMonth()+1)}-${m(g.getDate())}T${m(g.getHours())}:${m(g.getMinutes())}`}const O=()=>({name:"",description:"",type:"webhook",agentId:"",promptTemplate:"",enabled:!0,matchMode:"structural",extractionMode:"structural",config:{method:"POST"}});function Pe({isOpen:w,onClose:g}){var Q,X,Z,ee,le,te,se,ae,ne,ie,re,oe,ce,de,pe,ue;const m=Me(),[j,xe]=o.useState([]),[S,A]=o.useState("list"),[n,k]=o.useState(O()),[h,R]=o.useState(!1),[L,D]=o.useState(!1),[P,y]=o.useState(null),[z,he]=o.useState([]),[T,ye]=o.useState(null),[F,be]=o.useState(`{
|
|
2
2
|
|
|
3
3
|
}`),[u,M]=o.useState(null),[N,U]=o.useState(!1),[H,W]=o.useState([]),[I,ge]=o.useState("all"),[_,je]=o.useState([]),f=o.useCallback(async()=>{try{const t=await v(b("/api/triggers"));if(t.ok){const s=await t.json();xe(s)}}catch(t){console.error("Failed to load triggers:",t)}},[]),B=o.useCallback(async t=>{try{const s=await v(b(`/api/triggers/${t}/events?limit=20`));if(s.ok){const a=await s.json();he(a)}}catch(s){console.error("Failed to load trigger history:",s)}},[]),q=o.useCallback(async()=>{try{const t=await v(b("/api/slack/instances"));if(t.ok){const s=await t.json(),a=Array.isArray(s==null?void 0:s.instances)?s.instances:[];je(a.map(p=>({id:p.id,label:p.label||p.id})))}}catch(t){console.error("Failed to load Slack instances:",t)}},[]);o.useEffect(()=>{w&&(f(),q())},[w,f,q]),o.useEffect(()=>{T&&B(T)},[T,B]);const ve=o.useCallback(async()=>{D(!0),y(null);try{const t=h?b(`/api/triggers/${n.id}`):b("/api/triggers"),p=await v(t,{method:h?"PATCH":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!p.ok){const d=await p.json();throw new Error(d.error||"Failed to save trigger")}await f(),A("list"),k(O()),R(!1)}catch(t){y(t instanceof Error?t.message:"Save failed")}finally{D(!1)}},[n,h,f]),me=o.useCallback(async t=>{try{await v(b(`/api/triggers/${t}`),{method:"DELETE"}),await f()}catch(s){console.error("Failed to delete trigger:",s)}},[f]),fe=o.useCallback(async t=>{try{await v(b(`/api/triggers/${t.id}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!t.enabled})}),await f()}catch(s){console.error("Failed to toggle trigger:",s)}},[f]),ke=o.useCallback(async t=>{try{await v(b(`/api/triggers/${t}/fire`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({variables:{}})}),T===t&&await B(t)}catch(s){console.error("Failed to test fire trigger:",s)}},[T,B]),Ce=o.useCallback(async()=>{if(n.id){U(!0),M(null);try{let t;try{t=JSON.parse(F)}catch{M({structuralMatch:void 0,extractedVariables:{},wouldFire:!1}),y("Invalid JSON payload");return}const s=await v(b(`/api/triggers/${n.id}/test-match`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({payload:t})});if(s.ok){const a=await s.json();M(a),y(null)}else{const a=await s.json();y(a.error||"Test match failed")}}catch(t){y(t instanceof Error?t.message:"Test match failed")}finally{U(!1)}}},[n.id,F]),we=o.useCallback(async t=>{var s;try{const a=await v(b("/api/triggers/validate-cron"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({expression:t,timezone:((s=n.config)==null?void 0:s.timezone)||"UTC"})});if(a.ok){const p=await a.json();W(p.valid?p.nextFires:[])}}catch{W([])}},[n]),$=o.useCallback(t=>{t?(k({...t}),R(!0)):(k(O()),R(!1)),M(null),y(null),A("edit")},[]),x=o.useCallback((t,s)=>{k(a=>({...a,[t]:s}))},[]),r=o.useCallback((t,s)=>{k(a=>({...a,config:{...a.config,[t]:s}}))},[]),E=o.useCallback((t,s)=>{k(a=>({...a,llmMatch:{...a.llmMatch||{prompt:""},[t]:s}}))},[]),J=o.useCallback((t,s)=>{k(a=>({...a,llmExtract:{...a.llmExtract||{prompt:"",variables:[]},[t]:s}}))},[]),Se=o.useMemo(()=>Array.from(m.values()).map(t=>({id:t.id,name:t.name,class:t.class})),[m]),Te=o.useMemo(()=>{const t={all:j.length,webhook:0,bitbucket:0,cron:0,slack:0,email:0,jira:0,whatsapp:0};for(const s of j)s.type in t&&(t[s.type]+=1);return t},[j]),G=o.useMemo(()=>I==="all"?j:j.filter(t=>t.type===I),[j,I]),[K,V]=o.useState(null),Y=o.useCallback((t,s)=>{t&&navigator.clipboard.writeText(t).then(()=>{V(s),setTimeout(()=>V(a=>a===s?null:a),1500)},()=>y("Failed to copy to clipboard"))},[]);return w?e.jsx("div",{style:l.overlay,onClick:g,children:e.jsxs("div",{style:l.panel,onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{style:l.header,children:[e.jsx("h2",{style:l.title,children:S==="list"?"Triggers":h?"Edit Trigger":"New Trigger"}),e.jsxs("div",{style:l.headerActions,children:[S==="list"&&e.jsx("button",{style:l.addBtn,onClick:()=>$(),children:"+ New Trigger"}),S==="edit"&&e.jsx("button",{style:l.backBtn,onClick:()=>{A("list"),M(null),y(null)},children:"Back"}),e.jsx("button",{style:l.closeBtn,onClick:g,children:"X"})]})]}),P&&e.jsx("div",{style:l.error,children:P}),S==="list"&&e.jsxs("div",{style:l.content,children:[e.jsx("div",{style:l.tabBar,role:"tablist","aria-label":"Filter triggers by type",children:Ae.map(t=>{const s=Te[t.value],a=I===t.value;return e.jsxs("button",{role:"tab","aria-selected":a,onClick:()=>ge(t.value),style:{...l.tab,...a?l.tabActive:{}},title:`${t.label} (${s})`,children:[e.jsx("span",{style:l.tabIcon,children:t.icon}),e.jsx("span",{style:l.tabLabel,children:t.label}),e.jsx("span",{style:{...l.tabBadge,...a?l.tabBadgeActive:{}},children:s})]},t.value)})}),j.length===0?e.jsx("div",{style:l.empty,children:"No triggers configured. Create one to get started."}):G.length===0?e.jsxs("div",{style:l.empty,children:["No ",I," triggers configured yet."]}):G.map(t=>{var s;return e.jsxs("div",{style:{...l.triggerCard,borderLeftColor:t.status==="error"?"#e74c3c":t.enabled?"#2ecc71":"#95a5a6"},onClick:()=>{ye(t.id),$(t)},children:[e.jsxs("div",{style:l.cardHeader,children:[e.jsxs("div",{style:l.cardTitle,children:[e.jsx("span",{style:l.typeTag,children:t.type}),e.jsx("span",{children:t.name}),t.type==="cron"&&(()=>{const a=t.config||{};return a.runOnce?a.completedAt?e.jsx("span",{style:{...l.matchTag,color:"#a6e3a1"},children:"Once · completed"}):a.missedAt?e.jsx("span",{style:{...l.matchTag,color:"#f38ba8"},children:"Once · missed"}):e.jsx("span",{style:{...l.matchTag,color:"#f9e2af"},children:"Once · pending"}):e.jsx("span",{style:l.matchTag,children:"Recurring"})})(),t.matchMode!=="structural"&&e.jsx("span",{style:l.matchTag,children:t.matchMode})]}),e.jsxs("div",{style:l.cardActions,children:[e.jsx("button",{style:l.smallBtn,onClick:a=>{a.stopPropagation(),fe(t)},children:t.enabled?"Disable":"Enable"}),e.jsx("button",{style:l.smallBtn,onClick:a=>{a.stopPropagation(),ke(t.id)},children:"Test Fire"}),e.jsx("button",{style:{...l.smallBtn,color:"#e74c3c"},onClick:a=>{a.stopPropagation(),me(t.id)},children:"Delete"})]})]}),e.jsxs("div",{style:l.cardMeta,children:[e.jsxs("span",{children:["Agent: ",((s=m.get(t.agentId))==null?void 0:s.name)||t.agentId]}),e.jsxs("span",{children:["Fires: ",t.fireCount]}),t.lastFiredAt&&e.jsxs("span",{children:["Last: ",new Date(t.lastFiredAt).toLocaleString()]}),t.status==="error"&&t.lastError&&e.jsxs("span",{style:{color:"#e74c3c"},children:["Error: ",t.lastError]})]})]},t.id)})]}),S==="edit"&&e.jsx("div",{style:l.content,children:e.jsxs("div",{style:l.form,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Name"}),e.jsx("input",{style:l.input,value:n.name||"",onChange:t=>x("name",t.target.value),placeholder:"My Trigger"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Description"}),e.jsx("input",{style:l.input,value:n.description||"",onChange:t=>x("description",t.target.value),placeholder:"Optional description"})]}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Type"}),e.jsx("select",{style:l.select,value:n.type||"webhook",onChange:t=>{const s=t.target.value;x("type",s),s==="webhook"?x("config",{method:"POST"}):s==="cron"?x("config",{expression:"0 9 * * MON-FRI",timezone:"UTC"}):s==="bitbucket"?x("config",{workspace:"",repoSlug:"",events:["pullrequest:created","pullrequest:updated"]}):x("config",{}),(n.promptTemplate??"").trim()||(s==="slack"?x("promptTemplate",`Slack message from {{slack.user}} in {{slack.channelName}}:
|
|
4
4
|
{{slack.message}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u,r as a,a8 as h,j as e}from"./main-
|
|
1
|
+
import{u,r as a,a8 as h,j as e}from"./main-CICvC5Bz.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-DYBBrXTx.js";function y({url:r,downloadUrl:o,filename:s}){const{t:i}=u(["terminal","common"]),[t,l]=a.useState(null),[d,c]=a.useState(!1),m=a.useCallback(()=>{h(o,s)},[o,s]);return d?e.jsxs("div",{className:"video-player-error",children:[e.jsx("div",{children:i("terminal:videoPlayer.unsupported",{defaultValue:"This browser cannot play this video format."})}),e.jsx("button",{type:"button",className:"file-viewer-copy-html-btn",onClick:m,children:i("common:buttons.download")})]}):e.jsxs("div",{className:"video-player",children:[e.jsx("video",{className:"video-player-element",src:r,controls:!0,preload:"metadata",playsInline:!0,onError:()=>c(!0),onLoadedMetadata:n=>l({width:n.currentTarget.videoWidth,height:n.currentTarget.videoHeight})},r),t&&t.width>0&&e.jsxs("div",{className:"video-player-meta",children:[t.width,"×",t.height]})]})}export{y as VideoPlayer};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as x,c as M,d as P,j as e,z as J}from"./main-
|
|
1
|
+
import{r as x,c as M,d as P,j as e,z as J}from"./main-CICvC5Bz.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-DYBBrXTx.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{g as p,r as u,d as a}from"./chunk-MOJQB5TN-
|
|
1
|
+
import{g as p,r as u,d as a}from"./chunk-MOJQB5TN-lXncAEzU.js";import{p as f}from"./chunk-JWPE2WC7-E1cvFM5U.js";import{_ as n,l as o}from"./mermaid.core-DfJsBqur.js";import{M as c,b as d}from"./cynefin-VYW2F7L2-ebaABOLt.js";import"./main-CICvC5Bz.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-DYBBrXTx.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},I={parser:R,db:a,renderer:u,styles:p};export{I as diagram};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{G as ln,H as un,I as N,J as I,K as J,L as an,M as y,N as tn,O as j,P as _,Q as rn,R as o,S as on,T as sn,V as fn}from"./mermaid.core-
|
|
1
|
+
import{G as ln,H as un,I as N,J as I,K as J,L as an,M as y,N as tn,O as j,P as _,Q as rn,R as o,S as on,T as sn,V as fn}from"./mermaid.core-DfJsBqur.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,q,O,v,R,K,u){var D=q-l,i=O-h,n=K-v,d=u-R,a=d*D-n*i;if(!(a*a<y))return a=(n*(h-R)-d*(l-v))/a,[l+a*D,h+a*i]}function W(l,h,q,O,v,R,K){var u=l-q,D=h-O,i=(K?R:-R)/j(u*u+D*D),n=i*D,d=-i*u,a=l+n,s=h+d,f=q+n,c=O+d,L=(a+f)/2,t=(s+c)/2,m=f-a,g=c-s,A=m*m+g*g,T=v-R,P=a*c-f*s,E=(g<0?-1:1)*j(on(0,T*T*A-P*P)),G=(P*g-m*E)/A,H=(-P*m-g*E)/A,w=(P*g+m*E)/A,p=(-P*m+g*E)/A,x=G-L,e=H-t,r=w-L,M=p-t;return x*x+e*e>r*r+M*M&&(G=w,H=p),{cx:G,cy:H,x01:-n,y01:-d,x11:G*(v/T-1),y11:H*(v/T-1)}}function hn(){var l=cn,h=yn,q=J(0),O=null,v=gn,R=dn,K=mn,u=null,D=ln(i);function i(){var n,d,a=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-an,c=R.apply(this,arguments)-an,L=rn(c-f),t=c>f;if(u||(u=n=D()),s<a&&(d=s,s=a,a=d),!(s>y))u.moveTo(0,0);else if(L>tn-y)u.moveTo(s*N(f),s*I(f)),u.arc(0,0,s,f,c,!t),a>y&&(u.moveTo(a*N(c),a*I(c)),u.arc(0,0,a,c,f,t));else{var m=f,g=c,A=f,T=c,P=L,E=L,G=K.apply(this,arguments)/2,H=G>y&&(O?+O.apply(this,arguments):j(a*a+s*s)),w=_(rn(s-a)/2,+q.apply(this,arguments)),p=w,x=w,e,r;if(H>y){var M=sn(H/a*I(G)),z=sn(H/s*I(G));(P-=M*2)>y?(M*=t?1:-1,A+=M,T-=M):(P=0,A=T=(f+c)/2),(E-=z*2)>y?(z*=t?1:-1,m+=z,g-=z):(E=0,m=g=(f+c)/2)}var Q=s*N(m),V=s*I(m),B=a*N(T),C=a*I(T);if(w>y){var F=s*N(g),U=s*I(g),X=a*N(A),Y=a*I(A),S;if(L<un)if(S=pn(Q,V,X,Y,F,U,B,C)){var Z=Q-S[0],$=V-S[1],k=F-S[0],b=U-S[1],nn=1/I(fn((Z*k+$*b)/(j(Z*Z+$*$)*j(k*k+b*b)))/2),en=j(S[0]*S[0]+S[1]*S[1]);p=_(w,(a-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}E>y?x>y?(e=W(X,Y,Q,V,s,x,t),r=W(F,U,B,C,s,x,t),u.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),u.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(u.moveTo(Q,V),u.arc(0,0,s,m,g,!t)):u.moveTo(Q,V),!(a>y)||!(P>y)?u.lineTo(B,C):p>y?(e=W(B,C,F,U,a,-p,t),r=W(Q,V,X,Y,a,-p,t),u.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,a,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),u.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):u.arc(0,0,a,T,A,t)}if(u.closePath(),n)return u=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +R.apply(this,arguments))/2-un/2;return[N(d)*n,I(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:J(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:J(+n),i):h},i.cornerRadius=function(n){return arguments.length?(q=typeof n=="function"?n:J(+n),i):q},i.padRadius=function(n){return arguments.length?(O=n==null?null:typeof n=="function"?n:J(+n),i):O},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:J(+n),i):v},i.endAngle=function(n){return arguments.length?(R=typeof n=="function"?n:J(+n),i):R},i.padAngle=function(n){return arguments.length?(K=typeof n=="function"?n:J(+n),i):K},i.context=function(n){return arguments.length?(u=n??null,i):u},i}export{hn as d};
|