tide-commander 1.44.0 → 1.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{BossLogsModal-CTo4Bbm7.js → BossLogsModal-BIFXXaaq.js} +1 -1
- package/dist/assets/BossSpawnModal-CL4eQrBS.js +1 -0
- package/dist/assets/ControlsModal-DX_FqPx7.js +1 -0
- package/dist/assets/{DockerLogsModal-CrHd6OZ3.js → DockerLogsModal-SoHgFfH1.js} +1 -1
- package/dist/assets/{EmbeddedEditor-h8IrAy4E.js → EmbeddedEditor-Dx6Y7JM3.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-io57q0N8.js → GmailOAuthSetup-K-SZcqrr.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-YyNFVd9Y.js → GoogleOAuthSetup-BfpfXmbM.js} +1 -1
- package/dist/assets/{IframeModal-DqmSDXCT.js → IframeModal-BAgB3UQ3.js} +1 -1
- package/dist/assets/IntegrationsPanel-B1nXTZW8.js +2 -0
- package/dist/assets/{LogViewerModal-CGW8yajP.js → LogViewerModal-4do7lATm.js} +1 -1
- package/dist/assets/{MonitoringModal-BfsYrF1j.js → MonitoringModal-OAExiDTA.js} +1 -1
- package/dist/assets/{PM2LogsModal-BJytXxKY.js → PM2LogsModal-DnA2AsIM.js} +1 -1
- package/dist/assets/{RestoreArchivedAreaModal-CtRiwwzT.js → RestoreArchivedAreaModal-C0ADFzsM.js} +1 -1
- package/dist/assets/{SaveSnapshotModal-BHBdh1dK.js → SaveSnapshotModal-Ct4aW93y.js} +1 -1
- package/dist/assets/Scene2DCanvas-C5mj6yGY.js +1 -0
- package/dist/assets/{SceneManager-u4hiSYdk.js → SceneManager-CPtKPGZP.js} +1 -1
- package/dist/assets/SkillsPanel-B0XFw3Ae.js +28 -0
- package/dist/assets/SnapshotManager-0NaWlDXc.js +1 -0
- package/dist/assets/SpawnModal-BOJQ1pln.js +1 -0
- package/dist/assets/SubordinateAssignmentModal-BuzBY1CB.js +1 -0
- package/dist/assets/{SupervisorPanel-D0c7Kkzt.js → SupervisorPanel-B2_2QYL0.js} +1 -1
- package/dist/assets/{TriggerManagerPanel-RsbYDmIC.js → TriggerManagerPanel-CUD10Dg9.js} +2 -2
- package/dist/assets/{WorkflowEditorPanel-lpYmT8iN.js → WorkflowEditorPanel-qfjb7ozq.js} +2 -2
- package/dist/assets/{index-C6GdsxBK.js → index-BfXYjLRr.js} +4 -4
- package/dist/assets/{index-CpwhIgf8.js → index-BzvQBrQn.js} +3 -3
- package/dist/assets/{index-BOY5J4U4.js → index-CKitMIQJ.js} +1 -1
- package/dist/assets/{index-X9qZZBXG.js → index-CTdXoSNs.js} +2 -2
- package/dist/assets/{index-BexCA27h.js → index-D0e5Zn8j.js} +3 -3
- package/dist/assets/{index-BQdQ0iv_.js → index-DFTYc8O3.js} +1 -1
- package/dist/assets/index-K6Ld2Man.js +1 -0
- package/dist/assets/{index-BqPgrat9.js → index-RddWDRes.js} +1 -1
- package/dist/assets/{main-DjGrMNoB.css → main-Ch2CJGT4.css} +1 -1
- package/dist/assets/main-D3GShQ8B.js +153 -0
- package/dist/assets/{web-D94DaG2N.js → web-D0MII38C.js} +1 -1
- package/dist/assets/{web-XswRIovf.js → web-bLUMZcn-.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/src/packages/server/data/index.js +28 -0
- package/dist/src/packages/server/routes/config.js +7 -0
- package/dist/src/packages/server/routes/custom-class-icons.js +138 -0
- package/dist/src/packages/server/routes/index.js +2 -0
- package/dist/src/packages/server/services/custom-class-service.js +7 -2
- package/dist/src/packages/server/websocket/handlers/agent-handler.js +3 -0
- package/package.json +1 -1
- package/dist/assets/BossSpawnModal-DOk9u7EW.js +0 -1
- package/dist/assets/ControlsModal-BzBzF0Cw.js +0 -1
- package/dist/assets/IntegrationsPanel-DiW8UeG5.js +0 -2
- package/dist/assets/Scene2DCanvas-BYUuUYur.js +0 -1
- package/dist/assets/SkillsPanel-D4IHFehE.js +0 -28
- package/dist/assets/SnapshotManager-Cys1dllC.js +0 -1
- package/dist/assets/SpawnModal-DUK7X8ql.js +0 -1
- package/dist/assets/SubordinateAssignmentModal-DeH34tA3.js +0 -1
- package/dist/assets/index-t5WzFf-W.js +0 -1
- package/dist/assets/main-CrRMpn-n.js +0 -153
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as M,f as N,r as m,s as u,j as r}from"./main-
|
|
1
|
+
import{u as M,f as N,r as m,s as u,j as r}from"./main-D3GShQ8B.js";import{L as v}from"./LogViewerModal-4do7lATm.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function C(o){const n=["#3498db","#2ecc71","#9b59b6","#e67e22","#1abc9c","#e74c3c","#f1c40f","#00bcd4"];let a=0;for(let t=0;t<o.length;t++)a=o.charCodeAt(t)+((a<<5)-a);return n[Math.abs(a)%n.length]}function w({building:o,isOpen:n,onClose:a}){const{t}=M(["terminal","common"]),{bossStreamingLogs:b,buildings:f}=N(),l=b.get(o.id)||[],[i,d]=m.useState(null),c=o.subordinateBuildingIds||[],g=c.map(e=>f.get(e)).filter(e=>e!==void 0);m.useEffect(()=>(n&&c.length>0&&u.startBossLogStreaming(o.id),()=>{o.id&&u.stopBossLogStreaming(o.id)}),[n,o.id,c.length]);const h=m.useMemo(()=>{const e=new Set;return l.forEach(s=>e.add(s.subordinateName)),Array.from(e)},[l]),p=m.useMemo(()=>(i?l.filter(s=>s.subordinateName===i):l).map((s,j)=>({text:s.chunk,lineNumber:j+1,sourceLabel:s.subordinateName,sourceColor:C(s.subordinateName),isError:s.isError})),[l,i]),x=g.some(e=>{var s;return(s=e.pm2)==null?void 0:s.enabled}),S=h.length>1?r.jsxs("select",{className:"toolbar-btn source-filter",value:i||"",onChange:e=>d(e.target.value||null),children:[r.jsx("option",{value:"",children:t("terminal:logs.allSources")}),h.map(e=>r.jsx("option",{value:e,children:e},e))]}):void 0,L=i?r.jsxs("div",{className:"shortcut",style:{marginLeft:"auto"},children:[r.jsxs("span",{children:[t("terminal:logs.filtered"),": ",i]}),r.jsx("button",{style:{background:"transparent",border:"none",color:"inherit",cursor:"pointer",marginLeft:"0.5rem"},onClick:()=>d(null),children:"x"})]}):void 0;return r.jsx(v,{isOpen:n,onClose:a,title:`${o.name} - ${t("terminal:logs.bossLogs")}`,icon:"👑",lines:p,isStreaming:c.length>0,streamingIndicatorLabel:`${g.length} ${t("terminal:logs.units")}`,onClear:()=>u.clearBossStreamingLogs(o.id),emptyMessage:x?l.length===0?t("terminal:logs.waitingForLogs"):t("terminal:logs.noMatchingLogs"):t("terminal:logs.noPM2Subordinates"),extraToolbar:S,extraFooter:L,modalClassName:"boss-logs-modal"})}export{w as BossLogsModal};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as Ae,f as Le,N as Ee,M as Ie,r as t,U as _e,S as ee,l as De,V as O,A as se,a3 as T,a4 as j,j as s,C as S,X as Be,Z as Re,_ as P,$ as L,a0 as E,a2 as Oe,s as Te}from"./main-D3GShQ8B.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function ae(m){const h=j.filter(g=>!m.has(`Boss ${g}`));return h.length===0?`Boss ${j[Math.floor(Math.random()*j.length)]}-${Date.now()%1e3}`:`Boss ${h[Math.floor(Math.random()*h.length)]}`}function ze({isOpen:m,onClose:h,onSpawnStart:g,onSpawnEnd:I,spawnPosition:ne}){const{t:n}=Ae(["terminal","common"]),{agents:C}=Le(),o=Ee(),k=Ie(),[r,p]=t.useState(""),[M,le]=t.useState(()=>_e(ee.LAST_CWD)),[c,_]=t.useState("boss"),[U,q]=t.useState(!1),[te,y]=t.useState(!1),[F,ie]=t.useState(!0),[z,ce]=t.useState("bypass"),[d,D]=t.useState("claude"),[b,N]=t.useState({fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),[W,oe]=t.useState("opus"),[G,re]=t.useState("gpt-5.3-codex"),[v,$]=t.useState(new Set),[K,B]=t.useState(new Set),[u,de]=t.useState(""),[f,pe]=t.useState(""),[H,ue]=t.useState(""),A=t.useRef(null),R=t.useRef(!1),J=t.useRef(!1),x=t.useMemo(()=>k.filter(e=>e.enabled),[k]),V=t.useMemo(()=>{if(!f.trim())return x;const e=f.toLowerCase();return x.filter(a=>a.name.toLowerCase().includes(e)||a.description.toLowerCase().includes(e)||a.slug.toLowerCase().includes(e))},[x,f]),me=t.useMemo(()=>{var a;const e=o.find(l=>l.id===c);return(a=e==null?void 0:e.defaultSkillIds)!=null&&a.length?k.filter(l=>e.defaultSkillIds.includes(l.id)):[]},[o,c,k]),he=["full-notifications","streaming-exec","task-label","report-task-to-boss"];t.useEffect(()=>{if(m&&!J.current&&x.length>0){const a=x.filter(l=>he.includes(l.slug)).map(l=>l.id);a.length>0&&B(new Set(a))}J.current=m},[m,x]);const we=t.useCallback(e=>{B(a=>{const l=new Set(a);return l.has(e)?l.delete(e):l.add(e),l})},[]),i=t.useMemo(()=>o.find(e=>e.id===c),[o,c]),xe=t.useMemo(()=>{if(i!=null&&i.model)return i.model},[i]),be=t.useMemo(()=>{if(i!=null&&i.customModelPath)return De(`/api/custom-models/${i.id}`)},[i]),fe=i==null?void 0:i.modelScale,je=t.useMemo(()=>i?"scout":c==="boss"?"architect":c,[c,i]),X=Array.from(C.values()).filter(e=>!e.isBoss&&e.class!=="boss"&&!e.bossId),Y=t.useMemo(()=>{if(!u.trim())return o;const e=u.toLowerCase();return o.filter(a=>a.name.toLowerCase().includes(e)||a.description.toLowerCase().includes(e)||a.id.toLowerCase().includes(e))},[o,u]),Z=t.useMemo(()=>{if(!u.trim())return O;const e=u.toLowerCase();return O.filter(a=>{const l=se[a.id];return l?a.name.toLowerCase().includes(e)||a.id.toLowerCase().includes(e)||l.description.toLowerCase().includes(e):!1})},[u]),Q=t.useMemo(()=>{if(!u.trim())return!0;const e=u.toLowerCase(),a=T.boss;return"boss".includes(e)||a.description.toLowerCase().includes(e)},[u]);t.useEffect(()=>{if(m&&!R.current){R.current=!0;const e=new Set(Array.from(C.values()).map(l=>l.name)),a=o.find(l=>l.id===c);if(a){const l=j.filter(w=>!e.has(`${a.name} ${w}`));if(l.length===0){const w=j[Math.floor(Math.random()*j.length)];p(`${a.name} ${w}-${Date.now()%1e3}`)}else p(`${a.name} ${l[Math.floor(Math.random()*l.length)]}`)}else p(ae(e));$(new Set),A.current&&(A.current.focus(),A.current.select())}else m||(R.current=!1)},[m,C]),t.useEffect(()=>{if(!m)return;const e=o.find(a=>a.id===c);if(e)if(r.startsWith("Boss ")){const a=r.substring(5);p(`${e.name} ${a}`)}else{const a=o.find(l=>r.startsWith(l.name+" "));if(a){const l=r.substring(a.name.length+1);p(`${e.name} ${l}`)}else p(`${e.name} ${r}`)}else{const a=o.find(l=>r.startsWith(l.name+" "));if(a){const l=r.substring(a.name.length+1);p(`Boss ${l}`)}else r.startsWith("Boss ")||p(`Boss ${r}`)}},[c]);const Ne=()=>{if(y(!1),!M.trim()){y(!0);return}if(!r.trim()){const l=new Set(Array.from(C.values()).map(w=>w.name));p(ae(l));return}Oe(ee.LAST_CWD,M),g();const e=H.trim()||void 0,a=Array.from(K);Te.spawnBossAgent(r.trim(),c,M.trim(),ne||void 0,Array.from(v),d==="claude"?F:!1,z,d,d==="codex"?b:void 0,d==="codex"?G:void 0,d==="claude"?W:void 0,e,a),p(""),$(new Set),B(new Set),I(),h()},ve=()=>{q(!1),p(""),$(new Set),I(),h()},Se=()=>{q(!1),y(!0),I()};t.useEffect(()=>(window.__bossSpawnModalSuccess=ve,window.__bossSpawnModalError=Se,()=>{delete window.__bossSpawnModalSuccess,delete window.__bossSpawnModalError}),[r]);const ge=e=>{e.target===e.currentTarget&&h()},Ce=e=>{e.key==="Escape"&&h()},ke=e=>{const a=new Set(v);a.has(e)?a.delete(e):a.add(e),$(a)};if(!m)return null;const Me=T.boss;return s.jsx("div",{className:`modal-overlay ${m?"visible":""}`,onClick:ge,onKeyDown:Ce,children:s.jsxs("div",{className:"modal boss-spawn-modal",children:[s.jsxs("div",{className:"modal-header",children:[s.jsx(S,{classId:"boss",size:22,className:"boss-header-icon"}),n("terminal:spawn.deployBossTitle")]}),s.jsxs("div",{className:"modal-body spawn-modal-body",children:[s.jsxs("div",{className:"spawn-top-section",children:[s.jsx("div",{className:"spawn-preview-compact",children:s.jsx(Be,{agentClass:je,modelFile:xe,customModelUrl:be,modelScale:fe,width:100,height:120})}),s.jsxs("div",{className:"spawn-class-section",children:[s.jsx("div",{className:"spawn-class-label",children:n("terminal:spawn.bossClass")}),o.length+O.length+1>6&&s.jsx("input",{type:"text",className:"spawn-input class-search-input",placeholder:n("terminal:spawn.filterClasses"),value:u,onChange:e=>de(e.target.value)}),s.jsxs("div",{className:"class-selector-inline",children:[Y.map(e=>s.jsxs("button",{className:`class-chip ${c===e.id?"selected":""}`,onClick:()=>_(e.id),title:e.description,children:[s.jsx(S,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id)),Q&&s.jsxs("button",{className:`class-chip ${c==="boss"?"selected":""}`,onClick:()=>_("boss"),title:Me.description,children:[s.jsx(S,{classId:"boss",size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:n("terminal:spawn.bossClassName")})]}),Z.map(e=>{const a=se[e.id];return a?s.jsxs("button",{className:`class-chip ${c===e.id?"selected":""}`,onClick:()=>_(e.id),title:a.description,children:[s.jsx(S,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id):null}),u&&Y.length===0&&!Q&&Z.length===0&&s.jsx("div",{className:"class-search-empty",children:n("terminal:spawn.noClassesMatch",{query:u})})]})]})]}),s.jsxs("div",{className:"spawn-form-section",children:[s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("common:labels.name")}),s.jsx("input",{ref:A,type:"text",className:"spawn-input",placeholder:n("terminal:spawn.bossNamePlaceholder"),value:r,onChange:e=>p(e.target.value)})]}),s.jsxs("div",{className:"spawn-field spawn-field-wide",children:[s.jsx("label",{className:"spawn-label",children:n("terminal:spawn.workingDir")}),s.jsx(Re,{value:M,onChange:e=>{le(e),y(!1)},placeholder:n("terminal:spawn.workingDirPlaceholder"),className:"spawn-input",hasError:te,directoriesOnly:!0})]})]}),s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("common:labels.runtime")}),s.jsxs("div",{className:"spawn-select-row",children:[s.jsxs("button",{className:`spawn-select-btn ${d==="claude"?"selected":""}`,onClick:()=>D("claude"),title:n("terminal:spawn.useClaudeCli"),children:[s.jsx("img",{src:"/assets/claude.ico",alt:"Claude",className:"spawn-provider-icon"}),s.jsx("span",{children:"Claude"})]}),s.jsxs("button",{className:`spawn-select-btn ${d==="codex"?"selected":""}`,onClick:()=>D("codex"),title:n("terminal:spawn.useCodexCli"),children:[s.jsx("img",{src:"/assets/codex.ico",alt:"Codex",className:"spawn-provider-icon"}),s.jsx("span",{children:"Codex"})]}),s.jsxs("button",{className:`spawn-select-btn spawn-select-btn--opencode ${d==="opencode"?"selected":""}`,onClick:()=>D("opencode"),title:"Use OpenCode CLI (multi-provider)",children:[s.jsx("span",{children:"🟢"}),s.jsx("span",{children:"OpenCode"})]})]})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("common:labels.permissions")}),s.jsx("div",{className:"spawn-select-row",children:Object.keys(P).map(e=>s.jsxs("button",{className:`spawn-select-btn ${z===e?"selected":""}`,onClick:()=>ce(e),title:P[e].description,children:[s.jsx("span",{children:e==="bypass"?"⚡":"🔐"}),s.jsx("span",{children:P[e].label})]},e))})]})]}),s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("common:labels.model")}),d==="claude"?s.jsx("div",{className:"spawn-select-row",children:Object.keys(L).map(e=>s.jsxs("button",{className:`spawn-select-btn ${W===e?"selected":""}`,onClick:()=>oe(e),title:L[e].description,children:[s.jsx("span",{children:L[e].icon}),s.jsx("span",{children:L[e].label})]},e))}):d==="codex"?s.jsx("div",{className:"spawn-select-row spawn-select-row--codex-models",children:Object.keys(E).map(e=>s.jsxs("button",{className:`spawn-select-btn ${G===e?"selected":""}`,onClick:()=>re(e),title:E[e].description,children:[s.jsx("span",{children:E[e].icon}),s.jsx("span",{children:E[e].label})]},e))}):d==="opencode"?s.jsx("input",{type:"text",className:"spawn-input",defaultValue:"minimax/MiniMax-M1-80k",placeholder:"provider/model (e.g., minimax/MiniMax-M1-80k)"}):s.jsx("div",{className:"spawn-inline-hint",children:n("terminal:spawn.codex.configuration")})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("common:labels.browser")}),s.jsx("div",{className:"spawn-form-row spawn-options-row",children:s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:F,onChange:e=>ie(e.target.checked),disabled:d!=="claude"}),s.jsx("span",{children:n("terminal:spawn.chromeBrowser")})]})})]})]}),d==="codex"&&s.jsx("div",{className:"spawn-form-row",children:s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:n("terminal:spawn.codex.config")}),s.jsxs("div",{className:"spawn-options-row",style:{display:"flex",flexDirection:"column",gap:8},children:[s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:b.fullAuto!==!1,onChange:e=>N(a=>({...a,fullAuto:e.target.checked}))}),s.jsx("span",{children:n("terminal:spawn.codex.useFullAuto")})]}),s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:!!b.search,onChange:e=>N(a=>({...a,search:e.target.checked}))}),s.jsx("span",{children:n("terminal:spawn.codex.enableSearch")})]}),b.fullAuto===!1&&s.jsxs(s.Fragment,{children:[s.jsxs("select",{className:"spawn-input",value:b.sandbox||"workspace-write",onChange:e=>N(a=>({...a,sandbox:e.target.value})),children:[s.jsx("option",{value:"read-only",children:n("terminal:spawn.codex.sandboxReadOnly")}),s.jsx("option",{value:"workspace-write",children:n("terminal:spawn.codex.sandboxWorkspaceWrite")}),s.jsx("option",{value:"danger-full-access",children:n("terminal:spawn.codex.sandboxDangerFullAccess")})]}),s.jsxs("select",{className:"spawn-input",value:b.approvalMode||"on-request",onChange:e=>N(a=>({...a,approvalMode:e.target.value})),children:[s.jsx("option",{value:"untrusted",children:n("terminal:spawn.codex.approvalsUntrusted")}),s.jsx("option",{value:"on-failure",children:n("terminal:spawn.codex.approvalsOnFailure")}),s.jsx("option",{value:"on-request",children:n("terminal:spawn.codex.approvalsOnRequest")}),s.jsx("option",{value:"never",children:n("terminal:spawn.codex.approvalsNever")})]})]}),s.jsx("input",{type:"text",className:"spawn-input",placeholder:n("terminal:spawn.codex.profileOptional"),value:b.profile||"",onChange:e=>N(a=>({...a,profile:e.target.value||void 0}))})]})]})}),x.length>0&&s.jsxs("div",{className:"spawn-skills-section",children:[s.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.skills")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",n("common:labels.optional"),")"]})]}),x.length>6&&s.jsx("input",{type:"text",className:"spawn-input skill-search-input",placeholder:n("terminal:spawn.filterSkills"),value:f,onChange:e=>pe(e.target.value)}),s.jsxs("div",{className:"spawn-skills-inline",children:[V.map(e=>{const a=K.has(e.id);return me.some(w=>w.id===e.id)?null:s.jsxs("button",{className:`spawn-skill-chip ${a?"selected":""}`,onClick:()=>we(e.id),title:e.description,children:[a&&s.jsx("span",{className:"spawn-skill-check",children:"✓"}),s.jsx("span",{children:e.name}),e.builtin&&s.jsx("span",{className:"spawn-skill-builtin",children:"TC"})]},e.id)}),f&&V.length===0&&s.jsx("div",{className:"skill-search-empty",children:n("terminal:spawn.noSkillsMatch",{query:f})})]})]}),s.jsxs("div",{className:"spawn-custom-instructions-section",children:[s.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.customInstructions")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",n("common:labels.optional"),")"]})]}),s.jsx("textarea",{className:"spawn-input spawn-textarea",placeholder:n("terminal:spawn.customInstructionsBossPlaceholder"),value:H,onChange:e=>ue(e.target.value),rows:3})]}),s.jsxs("div",{className:"spawn-subordinates-section",children:[s.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.initialSubordinates")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",n("common:labels.optional"),")"]})]}),s.jsx("div",{className:"subordinates-selector-compact",children:X.length===0?s.jsx("div",{className:"subordinates-empty",children:n("terminal:spawn.noAvailableAgents")}):X.map(e=>{const a=v.has(e.id),l=T[e.class],w=o.find($e=>$e.id===e.class),ye=l||w||{color:"#888888"};return s.jsxs("button",{className:`subordinate-chip ${a?"selected":""}`,onClick:()=>ke(e.id),children:[a&&s.jsx("span",{className:"subordinate-check",children:"✓"}),s.jsx("span",{className:"subordinate-chip-icon",style:{color:ye.color},children:s.jsx(S,{classId:e.class,size:16})}),s.jsx("span",{className:"subordinate-chip-name",children:e.name})]},e.id)})}),v.size>0&&s.jsxs("div",{className:"subordinates-count",children:[v.size," ",n("common:labels.selected").toLowerCase()]})]})]})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:h,children:n("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-boss",onClick:Ne,disabled:U,children:n(U?"common:buttons.deploying":"common:buttons2.deployBoss")})]})]})})}export{ze as BossSpawnModal};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as T,f as X,ba as W,bb as Z,r as x,z as _,h as q,b9 as L,bc as A,bd as H,j as e,be as Q,s as b,bf as V,bg as R}from"./main-D3GShQ8B.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const G={global:"terminal:controls.contextGlobal",commander:"terminal:controls.contextCommander",toolbox:"terminal:controls.contextToolbox"},J={global:"terminal:controls.contextGlobalDesc",commander:"terminal:controls.contextCommanderDesc",toolbox:"terminal:controls.contextToolboxDesc"},U={camera:["camera-pan","camera-orbit","camera-rotate","camera-zoom","camera-tilt"],interaction:["primary-action","selection-box","context-menu","move-command"]},ee={camera:"terminal:controls.cameraControls",interaction:"terminal:controls.interaction"};function ie({isOpen:s,onClose:r}){const{t:a}=T(["terminal","common"]),l=X(),c=W(),h=Z(),[m,v]=x.useState("keyboard"),[j,g]=x.useState(""),[p,N]=x.useState("all"),[d,f]=x.useState(!1),[o,k]=x.useState(null),u=_.useRef(null),{handleMouseDown:D,handleClick:w}=q(r);if(x.useEffect(()=>{if(!s||d)return;const t=n=>{n.key==="Escape"&&(n.preventDefault(),n.stopPropagation(),r())};return document.addEventListener("keydown",t,!0),()=>document.removeEventListener("keydown",t,!0)},[s,r,d]),x.useEffect(()=>{s||(g(""),f(!1),k(null))},[s]),x.useEffect(()=>{if(!s||!d)return;const t=n=>{if(n.key==="Escape"){n.preventDefault(),n.stopPropagation(),f(!1),k(null);return}if(["Control","Alt","Shift","Meta"].includes(n.key))return;n.preventDefault(),n.stopPropagation();let i=n.key;n.code.startsWith("Key")&&n.code.length===4?i=n.code.charAt(3).toLowerCase():n.code.startsWith("Digit")&&n.code.length===6?i=n.code.charAt(5):n.code==="Space"&&(i="Space"),k({key:i,modifiers:{ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey,meta:n.metaKey}})};return document.addEventListener("keydown",t,!0),()=>document.removeEventListener("keydown",t,!0)},[s,d]),!s)return null;const F=l.shortcuts.filter(t=>{const n=a(`terminal:controls.shortcuts.${t.id}.name`,{defaultValue:t.name}),i=a(`terminal:controls.shortcuts.${t.id}.description`,{defaultValue:t.description});if(d&&o){const O=C=>C===" "||C==="Space"?"Space":C.length===1?C.toLowerCase():C,$=O(t.key),B=O(o.key);if(!(B.length===1&&/^[a-zA-Z]$/.test($)?`Key${$.toUpperCase()}`==`Key${B.toUpperCase()}`:$===B))return!1;const S=t.modifiers,M=o.modifiers;return(S.ctrl||!1)===(M.ctrl||!1)&&(S.alt||!1)===(M.alt||!1)&&(S.shift||!1)===(M.shift||!1)&&(S.meta||!1)===(M.meta||!1)}if(!j)return!0;const y=j.toLowerCase();return n.toLowerCase().includes(y)||i.toLowerCase().includes(y)||L(t).toLowerCase().includes(y)}),K=Array.from(l.agents.values()).map(t=>t).filter(t=>t.shortcut&&t.shortcut.trim().length>0).filter(t=>{const n=A(t.shortcut).toLowerCase();if(d&&o){const y={key:o.key,code:o.key.length===1&&/^[a-zA-Z]$/.test(o.key)?`Key${o.key.toUpperCase()}`:o.key.length===1&&/^[0-9]$/.test(o.key)?`Digit${o.key}`:o.key==="Space"?"Space":o.key,ctrlKey:!!o.modifiers.ctrl,altKey:!!o.modifiers.alt,shiftKey:!!o.modifiers.shift,metaKey:!!o.modifiers.meta};return H(y,t.shortcut)}if(!j)return!0;const i=j.toLowerCase();return t.name.toLowerCase().includes(i)||n.toLowerCase().includes(i)}),P=F.reduce((t,n)=>(t[n.context]||(t[n.context]=[]),t[n.context].push(n),t),{}),Y=(t,n)=>{b.updateShortcut(t,n)},E=()=>{m==="keyboard"?confirm(a("terminal:controls.confirmResetKeyboard"))&&b.resetShortcuts():m==="mouse"?confirm(a("terminal:controls.confirmResetMouse"))&&b.resetMouseControls():m==="trackpad"&&confirm(a("terminal:controls.confirmResetTrackpad"))&&b.resetMouseControls()},z=["global","commander","toolbox"],I=c.bindings.reduce((t,n)=>(U.camera.includes(n.action)?t.camera.push(n):U.interaction.includes(n.action)&&t.interaction.push(n),t),{camera:[],interaction:[]});return e.jsx("div",{className:"shortcuts-modal-overlay",onMouseDown:D,onClick:w,children:e.jsxs("div",{className:"shortcuts-modal controls-modal",children:[e.jsxs("div",{className:"shortcuts-modal-header",children:[e.jsxs("div",{className:"shortcuts-modal-title",children:[e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),e.jsx("span",{children:a("terminal:controls.title")})]}),e.jsx("button",{className:"shortcuts-modal-close",onClick:r,children:"×"})]}),e.jsxs("div",{className:"controls-main-tabs",children:[e.jsxs("button",{className:`controls-main-tab ${m==="keyboard"?"active":""}`,onClick:()=>v("keyboard"),children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("path",{d:"M6 8h.01M10 8h.01M14 8h.01M18 8h.01M6 12h.01M18 12h.01M8 16h8"})]}),a("terminal:controls.keyboard")]}),e.jsxs("button",{className:`controls-main-tab ${m==="mouse"?"active":""}`,onClick:()=>v("mouse"),children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"6",y:"3",width:"12",height:"18",rx:"6"}),e.jsx("line",{x1:"12",y1:"7",x2:"12",y2:"11"})]}),a("terminal:controls.mouse")]}),e.jsxs("button",{className:`controls-main-tab ${m==="trackpad"?"active":""}`,onClick:()=>v("trackpad"),children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),a("terminal:controls.trackpad")]})]}),m==="keyboard"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shortcuts-modal-toolbar",children:[d?e.jsxs("div",{className:"shortcuts-search find-by-shortcut-active",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("path",{d:"M6 8h.01M10 8h.01M14 8h.01M18 8h.01M6 12h.01M18 12h.01M8 16h8"})]}),o?e.jsxs("span",{className:"find-by-shortcut-display",children:[L({key:o.key,modifiers:o.modifiers}),e.jsx("button",{className:"shortcuts-search-clear",onClick:()=>k(null),children:"×"})]}):e.jsx("span",{className:"find-by-shortcut-prompt",children:a("terminal:controls.pressKeyCombination")})]}):e.jsxs("div",{className:"shortcuts-search",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"M21 21l-4.35-4.35"})]}),e.jsx("input",{ref:u,type:"text",placeholder:a("terminal:controls.searchShortcuts"),value:j,onChange:t=>g(t.target.value),autoFocus:!0}),j&&e.jsx("button",{className:"shortcuts-search-clear",onClick:()=>g(""),children:"×"})]}),e.jsx("button",{className:`shortcuts-find-by-key-btn ${d?"active":""}`,onClick:()=>{f(!d),k(null),g("")},title:a(d?"terminal:controls.switchToTextSearch":"terminal:controls.findByPressingKeys"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),e.jsx("path",{d:"M6 8h.01M10 8h.01M14 8h.01M18 8h.01M6 12h.01M18 12h.01M8 16h8"})]})}),e.jsx("button",{className:"shortcuts-reset-all-btn",onClick:E,children:a("common:buttons.reset")})]}),e.jsxs("div",{className:"shortcuts-context-tabs",children:[e.jsxs("button",{className:`shortcuts-context-tab ${p==="all"?"active":""}`,onClick:()=>N("all"),children:[a("common:labels.all"),e.jsx("span",{className:"shortcuts-context-tab-count",children:F.length})]}),z.map(t=>{var i;const n=((i=P[t])==null?void 0:i.length)||0;return e.jsxs("button",{className:`shortcuts-context-tab ${p===t?"active":""}`,onClick:()=>N(t),children:[a(G[t]),e.jsx("span",{className:"shortcuts-context-tab-count",children:n})]},t)})]}),e.jsxs("div",{className:"shortcuts-modal-content",children:[z.map(t=>{const n=P[t]||[];return n.length===0||p!=="all"&&p!==t?null:e.jsxs("div",{className:"shortcuts-context-group",children:[p==="all"&&e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:a(G[t])}),e.jsx("span",{className:"shortcuts-context-description",children:a(J[t])})]}),e.jsx("div",{className:"shortcuts-grid",children:n.map(i=>e.jsxs("div",{className:"shortcut-item",children:[e.jsxs("div",{className:"shortcut-item-info",children:[e.jsx("span",{className:"shortcut-item-name",children:a(`terminal:controls.shortcuts.${i.id}.name`,{defaultValue:i.name})}),e.jsx("span",{className:"shortcut-item-description",children:a(`terminal:controls.shortcuts.${i.id}.description`,{defaultValue:i.description})})]}),e.jsx(Q,{shortcut:i,onUpdate:y=>Y(i.id,y)})]},i.id))})]},t)}),F.length===0&&K.length===0&&e.jsx("div",{className:"shortcuts-empty",children:d?o?e.jsx("p",{children:a("terminal:controls.noShortcutBoundTo",{keys:L({key:o.key,modifiers:o.modifiers})})}):e.jsx("p",{children:a("terminal:controls.pressKeyCombinationToFind")}):e.jsx("p",{children:a("terminal:controls.noShortcutsFound",{query:j})})}),K.length>0&&(p==="all"||p==="global")&&e.jsxs("div",{className:"shortcuts-context-group",children:[p==="all"&&e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:"Agent Terminal Shortcuts"}),e.jsx("span",{className:"shortcuts-context-description",children:"Per-agent global shortcuts that open the guake terminal"})]}),e.jsx("div",{className:"shortcuts-grid",children:K.map(t=>e.jsxs("div",{className:"shortcut-item",children:[e.jsxs("div",{className:"shortcut-item-info",children:[e.jsx("span",{className:"shortcut-item-name",children:t.name}),e.jsx("span",{className:"shortcut-item-description",children:"Open terminal for this agent"})]}),e.jsx("div",{className:"key-capture-container",children:e.jsx("button",{className:"key-capture-input disabled",disabled:!0,children:e.jsx("span",{className:"key-capture-value",children:A(t.shortcut)})})})]},t.id))})]})]})]}),m==="mouse"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shortcuts-modal-toolbar",children:[e.jsx("span",{className:"mouse-controls-subtitle",children:a("terminal:controls.cameraAndInteraction")}),e.jsx("button",{className:"shortcuts-reset-all-btn",onClick:E,children:a("common:buttons.reset")})]}),e.jsxs("div",{className:"shortcuts-modal-content mouse-controls-content",children:[e.jsx("div",{className:"mouse-controls-bindings",children:Object.entries(I).map(([t,n])=>e.jsxs("div",{className:"shortcuts-context-group",children:[e.jsx("div",{className:"shortcuts-context-header",children:e.jsx("span",{className:"shortcuts-context-label",children:a(ee[t])})}),e.jsx("div",{className:"shortcuts-grid",children:n.map(i=>e.jsx(se,{binding:i},i.id))})]},t))}),e.jsxs("div",{className:"shortcuts-context-group",children:[e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:a("terminal:controls.sensitivity")}),e.jsx("span",{className:"shortcuts-context-description",children:a("terminal:controls.adjustCameraSpeed")})]}),e.jsx(te,{sensitivity:c.sensitivity})]})]})]}),m==="trackpad"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shortcuts-modal-toolbar",children:[e.jsx("span",{className:"mouse-controls-subtitle",children:a("terminal:controls.trackpadGestureSettings")}),e.jsx("button",{className:"shortcuts-reset-all-btn",onClick:E,children:a("common:buttons.reset")})]}),e.jsx("div",{className:"shortcuts-modal-content trackpad-controls-content",children:e.jsx(ae,{config:h})})]}),e.jsx("div",{className:"shortcuts-modal-footer",children:e.jsx("span",{className:"shortcuts-modal-hint",children:a(m==="keyboard"?d?"terminal:controls.hintFindByShortcut":"terminal:controls.hintKeyboard":m==="mouse"?"terminal:controls.hintMouse":"terminal:controls.hintTrackpad")})})]})})}function se({binding:s}){const{t:r}=T(["terminal"]),a=W(),[l,c]=x.useState(!1),[h,m]=x.useState(null);x.useEffect(()=>{if(!l)return;const d=u=>{u.preventDefault(),u.stopPropagation();const w={0:"left",1:"middle",2:"right",3:"back",4:"forward"}[u.button];w&&m({button:w,modifiers:{ctrl:u.ctrlKey,alt:u.altKey,shift:u.shiftKey,meta:u.metaKey}})},f=u=>{u.key==="Escape"&&(u.preventDefault(),u.stopPropagation(),c(!1),m(null))},o=()=>{h&&V(a.bindings,h,s.id).length===0&&b.updateMouseBinding(s.id,{button:h.button,modifiers:h.modifiers}),c(!1),m(null)},k=setTimeout(()=>{document.addEventListener("mousedown",d,!0),document.addEventListener("keydown",f,!0),document.addEventListener("click",o,!0)},100);return()=>{clearTimeout(k),document.removeEventListener("mousedown",d,!0),document.removeEventListener("keydown",f,!0),document.removeEventListener("click",o,!0)}},[l,h,s.id,a.bindings]);const v=h?V(a.bindings,h,s.id):[],j=r(`terminal:controls.mouseBindings.${s.id}.name`,{defaultValue:s.name}),g=r(`terminal:controls.mouseBindings.${s.id}.description`,{defaultValue:s.description}),p=d=>r(`terminal:controls.mouseButtons.${d}`,{defaultValue:d}),N=h?R({...s,...h},p):R(s,p);return e.jsxs("div",{className:`shortcut-item ${s.enabled?"":"disabled"}`,children:[e.jsxs("div",{className:"shortcut-item-info",children:[e.jsx("span",{className:"shortcut-item-name",children:j}),e.jsx("span",{className:"shortcut-item-description",children:g})]}),e.jsxs("div",{className:"key-capture-container",children:[e.jsx("button",{className:`key-capture-input ${l?"capturing":""} ${v.length>0?"conflict":""}`,onClick:()=>c(!0),children:l?h?e.jsx("span",{className:"key-capture-value",style:{color:"#f1fa8c"},children:N}):e.jsx("span",{style:{color:"#6272a4",fontStyle:"italic"},children:r("terminal:controls.clickToCapture")}):e.jsx("span",{className:"key-capture-value",children:N})}),v.length>0&&e.jsxs("span",{className:"key-capture-conflict",children:[r("terminal:controls.conflicts"),": ",v.map(d=>r(`terminal:controls.mouseBindings.${d.id}.name`,{defaultValue:d.name})).join(", ")]})]})]})}function te({sensitivity:s}){const{t:r}=T(["terminal"]),a=x.useCallback((l,c)=>{b.updateCameraSensitivity({[l]:c})},[]);return e.jsxs("div",{className:"sensitivity-inline-settings",children:[e.jsxs("div",{className:"sensitivity-sliders",children:[e.jsxs("div",{className:"sensitivity-slider-row",children:[e.jsx("label",{children:r("terminal:controls.panSpeed")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.panSpeed,onChange:l=>a("panSpeed",parseFloat(l.target.value))}),e.jsxs("span",{className:"sensitivity-slider-value",children:[s.panSpeed.toFixed(1),"x"]})]}),e.jsxs("div",{className:"sensitivity-slider-row",children:[e.jsx("label",{children:r("terminal:controls.orbitSpeed")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.orbitSpeed,onChange:l=>a("orbitSpeed",parseFloat(l.target.value))}),e.jsxs("span",{className:"sensitivity-slider-value",children:[s.orbitSpeed.toFixed(1),"x"]})]}),e.jsxs("div",{className:"sensitivity-slider-row",children:[e.jsx("label",{children:r("terminal:controls.zoomSpeed")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.zoomSpeed,onChange:l=>a("zoomSpeed",parseFloat(l.target.value))}),e.jsxs("span",{className:"sensitivity-slider-value",children:[s.zoomSpeed.toFixed(1),"x"]})]}),e.jsxs("div",{className:"sensitivity-slider-row",children:[e.jsx("label",{children:r("terminal:controls.smoothing")}),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.1",value:s.smoothing,onChange:l=>a("smoothing",parseFloat(l.target.value))}),e.jsx("span",{className:"sensitivity-slider-value",children:s.smoothing.toFixed(1)})]})]}),e.jsxs("div",{className:"sensitivity-checkboxes-inline",children:[e.jsxs("label",{className:"sensitivity-checkbox-inline",children:[e.jsx("input",{type:"checkbox",checked:s.invertPanX,onChange:l=>a("invertPanX",l.target.checked)}),e.jsx("span",{children:r("terminal:controls.invertPanX")})]}),e.jsxs("label",{className:"sensitivity-checkbox-inline",children:[e.jsx("input",{type:"checkbox",checked:s.invertPanY,onChange:l=>a("invertPanY",l.target.checked)}),e.jsx("span",{children:r("terminal:controls.invertPanY")})]}),e.jsxs("label",{className:"sensitivity-checkbox-inline",children:[e.jsx("input",{type:"checkbox",checked:s.invertOrbitX,onChange:l=>a("invertOrbitX",l.target.checked)}),e.jsx("span",{children:r("terminal:controls.invertOrbitX")})]}),e.jsxs("label",{className:"sensitivity-checkbox-inline",children:[e.jsx("input",{type:"checkbox",checked:s.invertOrbitY,onChange:l=>a("invertOrbitY",l.target.checked)}),e.jsx("span",{children:r("terminal:controls.invertOrbitY")})]})]})]})}function ae({config:s}){const{t:r}=T(["terminal"]),a=x.useCallback((c,h)=>{b.updateTrackpadConfig({[c]:h})},[]),l=x.useCallback((c,h)=>{b.updateTrackpadConfig({sensitivity:{[c]:h}})},[]);return e.jsxs("div",{className:"trackpad-settings",children:[e.jsxs("div",{className:"shortcuts-context-group",children:[e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:r("terminal:controls.trackpadGestures")}),e.jsx("span",{className:"shortcuts-context-description",children:r("terminal:controls.enableTrackpadSupport")})]}),e.jsx("div",{className:"trackpad-toggle-row",children:e.jsxs("label",{className:"trackpad-toggle",children:[e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:c=>a("enabled",c.target.checked)}),e.jsx("span",{className:"trackpad-toggle-label",children:r("terminal:controls.enableTrackpadGestures")})]})})]}),e.jsxs("div",{className:"shortcuts-context-group",children:[e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:r("terminal:controls.gestureControls")}),e.jsx("span",{className:"shortcuts-context-description",children:r("terminal:controls.enableDisableGestures")})]}),e.jsxs("div",{className:"trackpad-gestures-grid",children:[e.jsxs("label",{className:`trackpad-gesture-item ${s.enabled?"":"disabled"}`,children:[e.jsx("input",{type:"checkbox",checked:s.pinchToZoom,onChange:c=>a("pinchToZoom",c.target.checked),disabled:!s.enabled}),e.jsxs("div",{className:"trackpad-gesture-info",children:[e.jsx("span",{className:"trackpad-gesture-name",children:r("terminal:controls.pinchToZoom")}),e.jsx("span",{className:"trackpad-gesture-desc",children:r("terminal:controls.pinchToZoomDesc")})]})]}),e.jsxs("label",{className:`trackpad-gesture-item ${s.enabled?"":"disabled"}`,children:[e.jsx("input",{type:"checkbox",checked:s.twoFingerPan,onChange:c=>a("twoFingerPan",c.target.checked),disabled:!s.enabled}),e.jsxs("div",{className:"trackpad-gesture-info",children:[e.jsx("span",{className:"trackpad-gesture-name",children:r("terminal:controls.twoFingerPan")}),e.jsx("span",{className:"trackpad-gesture-desc",children:r("terminal:controls.twoFingerPanDesc")})]})]}),e.jsxs("label",{className:`trackpad-gesture-item ${s.enabled?"":"disabled"}`,children:[e.jsx("input",{type:"checkbox",checked:s.shiftTwoFingerOrbit,onChange:c=>a("shiftTwoFingerOrbit",c.target.checked),disabled:!s.enabled}),e.jsxs("div",{className:"trackpad-gesture-info",children:[e.jsx("span",{className:"trackpad-gesture-name",children:r("terminal:controls.shiftTwoFingerOrbit")}),e.jsx("span",{className:"trackpad-gesture-desc",children:r("terminal:controls.shiftTwoFingerOrbitDesc")})]})]})]})]}),e.jsxs("div",{className:"shortcuts-context-group",children:[e.jsxs("div",{className:"shortcuts-context-header",children:[e.jsx("span",{className:"shortcuts-context-label",children:r("terminal:controls.sensitivity")}),e.jsx("span",{className:"shortcuts-context-description",children:r("terminal:controls.adjustGestureSensitivity")})]}),e.jsxs("div",{className:"trackpad-sensitivity-sliders",children:[e.jsxs("div",{className:`trackpad-slider-row ${!s.enabled||!s.pinchToZoom?"disabled":""}`,children:[e.jsx("label",{children:r("terminal:controls.zoom")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.sensitivity.zoom,onChange:c=>l("zoom",parseFloat(c.target.value)),disabled:!s.enabled||!s.pinchToZoom}),e.jsxs("span",{className:"trackpad-slider-value",children:[s.sensitivity.zoom.toFixed(1),"x"]})]}),e.jsxs("div",{className:`trackpad-slider-row ${!s.enabled||!s.twoFingerPan?"disabled":""}`,children:[e.jsx("label",{children:r("terminal:controls.pan")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.sensitivity.pan,onChange:c=>l("pan",parseFloat(c.target.value)),disabled:!s.enabled||!s.twoFingerPan}),e.jsxs("span",{className:"trackpad-slider-value",children:[s.sensitivity.pan.toFixed(1),"x"]})]}),e.jsxs("div",{className:`trackpad-slider-row ${!s.enabled||!s.shiftTwoFingerOrbit?"disabled":""}`,children:[e.jsx("label",{children:r("terminal:controls.orbit")}),e.jsx("input",{type:"range",min:"0.1",max:"3",step:"0.1",value:s.sensitivity.orbit,onChange:c=>l("orbit",parseFloat(c.target.value)),disabled:!s.enabled||!s.shiftTwoFingerOrbit}),e.jsxs("span",{className:"trackpad-slider-value",children:[s.sensitivity.orbit.toFixed(1),"x"]})]})]})]})]})}export{ie as ControlsModal};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{u as l,f as L,r as m,s as r,j as x}from"./main-
|
|
1
|
+
import{u as l,f as L,r as m,s as r,j as x}from"./main-D3GShQ8B.js";import{L as S}from"./LogViewerModal-4do7lATm.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function B({building:t,isOpen:o,onClose:n}){var a;const{t:i}=l(["terminal"]),{streamingBuildingLogs:c,streamingBuildingIds:g}=L(),s=c.get(t.id)||"",p=g.has(t.id);m.useEffect(()=>{var e;return o&&((e=t.docker)!=null&&e.enabled)&&r.startLogStreaming(t.id,200),()=>{t.id&&r.stopLogStreaming(t.id)}},[o,t.id,(a=t.docker)==null?void 0:a.enabled]);const d=m.useMemo(()=>s.split(`
|
|
2
2
|
`).map((e,f)=>({text:e,lineNumber:f+1})),[s]);return x.jsx(S,{isOpen:o,onClose:n,title:`${t.name} - ${i("terminal:logs.dockerLogs")}`,icon:"🐳",lines:d,isStreaming:p,onClear:()=>r.clearStreamingLogs(t.id)})}export{B as DockerLogsModal};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,j as s}from"./main-
|
|
1
|
+
import{r as e,j as s}from"./main-D3GShQ8B.js";import{g as j,o as k,E as f,l as N,h as R,a as T,f as A,d as w,r as C,i as K,b as L,c as M,e as q,j as B,s as D,k as G,m as H,n as O,p as V,q as W,t as F,u as I,v as U,w as Y,x as z}from"./index-D0e5Zn8j.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const J=1e3,ee=({content:_,extension:p,onSave:h,onCancel:b})=>{const c=e.useRef(null),i=e.useRef(null),t=e.useRef(null),o=e.useRef(!1),v=e.useRef(h);v.current=h;const[u,d]=e.useState("idle"),[S,l]=e.useState(null),a=e.useCallback(async()=>{if(!(!i.current||o.current)){o.current=!0,d("saving"),l(null);try{const r=i.current.state.doc.toString();await v.current(r),d("saved"),setTimeout(()=>d(n=>n==="saved"?"idle":n),1500)}catch(r){d("error"),l(r.message||"Save failed")}finally{o.current=!1}}},[]),x=e.useCallback(()=>{t.current&&clearTimeout(t.current),t.current=setTimeout(()=>{a()},J)},[a]),g=e.useCallback(()=>{t.current&&(clearTimeout(t.current),t.current=null,a()),b()},[b,a]);return e.useEffect(()=>()=>{t.current&&clearTimeout(t.current)},[]),e.useEffect(()=>{if(!c.current)return;const r=j(p),n=[N(),R(),T(),A(),w(),C(),K(),L(),M(),q(),B(),D({top:!0}),G(z,{fallback:!0}),k,f.lineWrapping,H.of([...O,...V,...W,...F,...I,U,{key:"Mod-s",run:()=>(t.current&&(clearTimeout(t.current),t.current=null),a(),!0)},{key:"Escape",run:()=>(g(),!0)}]),f.updateListener.of(y=>{y.docChanged&&(l(null),x())})];r&&n.push(r);const E=Y.create({doc:_,extensions:n}),m=new f({state:E,parent:c.current});return i.current=m,requestAnimationFrame(()=>m.focus()),()=>{m.destroy(),i.current=null}},[]),s.jsxs("div",{className:"embedded-editor",children:[s.jsxs("div",{className:"embedded-editor__toolbar",children:[s.jsxs("div",{className:"embedded-editor__toolbar-left",children:[u==="saving"&&s.jsx("span",{className:"embedded-editor__status embedded-editor__status--saving",children:"Saving..."}),u==="saved"&&s.jsx("span",{className:"embedded-editor__status embedded-editor__status--saved",children:"Saved"}),u==="error"&&s.jsx("span",{className:"embedded-editor__status embedded-editor__status--error",children:S||"Save failed"})]}),s.jsxs("div",{className:"embedded-editor__toolbar-right",children:[s.jsx("span",{className:"embedded-editor__shortcut-hint",children:"Auto-saves · Esc to close"}),s.jsx("button",{className:"embedded-editor__btn embedded-editor__btn--close",onClick:g,children:"Close"})]})]}),s.jsx("div",{className:"embedded-editor__container",ref:c})]})};export{ee as EmbeddedEditor};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as t,V as J,w as N,j as e}from"./main-CrRMpn-n.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function H({integration:o,onSave:f,onCancel:w}){const[s,y]=t.useState(o.values.authMethod||"oauth2"),[b,P]=t.useState(o.values.clientId||""),[j,T]=t.useState(""),[g,F]=t.useState(""),[v,q]=t.useState(o.values.impersonateEmail||""),[p,k]=t.useState(String(o.values.pollingIntervalMs??3e4)),[h,S]=t.useState(o.values.defaultApprovalKeywords||"approved,aprobado,autorizado,yes,ok"),[A,C]=t.useState(null),[r,z]=t.useState(null),[c,d]=t.useState(!1),[I,i]=t.useState(null),[E,O]=t.useState(!1),[m,u]=t.useState(o.status.connected?"connected":"credentials"),l=t.useRef(null),M=t.useRef(o.status.connected),x=t.useCallback(async()=>{try{const a=await J(N("/api/email/status"));if(a.ok){const n=await a.json();z(n),n.authenticated&&(u("connected"),l.current&&(clearInterval(l.current),l.current=null))}}catch(a){console.error("Failed to fetch Gmail status:",a)}},[]);t.useEffect(()=>{const a=o.status.connected,n=M.current;a&&!n&&m!=="connected"?u("connected"):!a&&n&&m==="connected"&&u("credentials"),M.current=a},[o.status.connected]),t.useEffect(()=>(x(),()=>{l.current&&clearInterval(l.current)}),[x]);const D=async()=>{if(!b.trim()){i("Client ID is required");return}d(!0),i(null);try{const a={authMethod:"oauth2",clientId:b.trim(),pollingIntervalMs:parseInt(p)||3e4,defaultApprovalKeywords:h};j.trim()&&(a.clientSecret=j.trim()),await f(a);const n=await J(N("/api/email/auth/url"));if(!n.ok){const L=await n.json().catch(()=>({}));throw new Error(L.error||`HTTP ${n.status}`)}const _=await n.json();if(!_.url)throw new Error("OAuth URL is empty");C(_.url),i(null),u("authorize"),l.current&&clearInterval(l.current),l.current=setInterval(x,3e3)}catch(a){const n=a instanceof Error?a.message:"Failed to get OAuth URL";i(n)}finally{d(!1)}},K=async()=>{if(!g.trim()){i("Service Account JSON is required");return}if(!v.trim()){i("Impersonate Email is required");return}try{const a=JSON.parse(g.trim());if(!a.client_email||!a.private_key){i("Service Account JSON must contain client_email and private_key");return}}catch{i("Invalid JSON in Service Account field");return}d(!0),i(null);try{await f({authMethod:"service_account",serviceAccountJson:g.trim(),impersonateEmail:v.trim(),pollingIntervalMs:parseInt(p)||3e4,defaultApprovalKeywords:h}),await new Promise(a=>setTimeout(a,1e3)),await x()}catch(a){const n=a instanceof Error?a.message:"Failed to save service account";i(n)}finally{d(!1)}},R=async()=>{O(!0),i(null);try{await f({pollingIntervalMs:parseInt(p)||3e4,defaultApprovalKeywords:h})}catch(a){i(a instanceof Error?a.message:"Failed to save settings")}finally{O(!1)}},U=async()=>{d(!0),i(null);try{await f({refreshToken:"",serviceAccountJson:"",impersonateEmail:""}),z(null),C(null),u("credentials"),await x()}catch(a){i(a instanceof Error?a.message:"Failed to disconnect")}finally{d(!1)}},G=!!o.values.serviceAccountJson;return e.jsxs("div",{className:"gmail-oauth-setup",children:[I&&e.jsx("div",{className:"gmail-oauth-error",children:I}),m==="credentials"&&e.jsxs("div",{className:"gmail-oauth-section",children:[e.jsxs("div",{className:"gmail-oauth-field",style:{marginBottom:24},children:[e.jsx("label",{className:"integration-field-label",children:"Authentication Method"}),e.jsxs("div",{className:"gmail-auth-method-selector",children:[e.jsxs("button",{type:"button",className:`gmail-auth-method-btn ${s==="oauth2"?"active":""}`,onClick:()=>{y("oauth2"),i(null)},children:[e.jsx("span",{className:"gmail-auth-method-icon",children:"🔑"}),e.jsx("span",{className:"gmail-auth-method-label",children:"OAuth 2.0"}),e.jsx("span",{className:"gmail-auth-method-desc",children:"Browser login flow"})]}),e.jsxs("button",{type:"button",className:`gmail-auth-method-btn ${s==="service_account"?"active":""}`,onClick:()=>{y("service_account"),i(null)},children:[e.jsx("span",{className:"gmail-auth-method-icon",children:"🤖"}),e.jsx("span",{className:"gmail-auth-method-label",children:"Service Account"}),e.jsx("span",{className:"gmail-auth-method-desc",children:"Domain-wide delegation"})]})]})]}),s==="oauth2"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Google OAuth Credentials"}),e.jsxs("p",{className:"gmail-oauth-help",children:["Create OAuth2 credentials in the"," ",e.jsx("a",{href:"https://console.cloud.google.com/apis/credentials",target:"_blank",rel:"noopener noreferrer",className:"gmail-oauth-link",children:"Google Cloud Console"}),". Enable the Gmail API and (optionally) the Calendar API. Set the redirect URI to:"," ",e.jsx("code",{className:"gmail-oauth-code",children:N("/api/email/auth/callback")})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client ID ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"text",className:"integration-field-input",value:b,placeholder:"xxxx.apps.googleusercontent.com",onChange:a=>P(a.target.value)})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client Secret ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"password",className:"integration-field-input",value:j,placeholder:o.values.clientSecret?"(saved)":"Enter client secret",onChange:a=>T(a.target.value),autoComplete:"off"})]})]}),s==="service_account"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Service Account Credentials"}),e.jsxs("p",{className:"gmail-oauth-help",children:["Use a Google service account with"," ",e.jsx("a",{href:"https://admin.google.com/ac/owl/domainwidedelegation",target:"_blank",rel:"noopener noreferrer",className:"gmail-oauth-link",children:"domain-wide delegation"})," ","enabled. The service account must be authorized for Gmail scopes in Google Workspace Admin."]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["Service Account JSON ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("textarea",{className:"integration-field-input integration-field-textarea",value:g,placeholder:G?"(saved — paste new JSON to replace)":"Paste the full service account JSON key file contents",onChange:a=>F(a.target.value),rows:6,spellCheck:!1}),e.jsx("span",{className:"integration-field-description",children:"The JSON key file downloaded from Google Cloud Console containing client_email and private_key."})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["Impersonate Email ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"email",className:"integration-field-input",value:v,placeholder:"user@yourdomain.com",onChange:a=>q(a.target.value)}),e.jsx("span",{className:"integration-field-description",children:"The email address to impersonate via domain-wide delegation. Must be a user in your Google Workspace domain."})]})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Polling Interval (ms)"}),e.jsx("input",{type:"number",className:"integration-field-input",value:p,onChange:a=>k(a.target.value)}),e.jsx("span",{className:"integration-field-description",children:"How often to check for new emails. Default: 30000 (30s)."})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Approval Keywords"}),e.jsx("textarea",{className:"integration-field-input integration-field-textarea",value:h,onChange:a=>S(a.target.value),rows:2}),e.jsx("span",{className:"integration-field-description",children:"Comma-separated keywords that indicate email approval."})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:w,children:"Cancel"}),s==="oauth2"?e.jsx("button",{type:"button",className:"integration-btn save",onClick:D,disabled:c||!b.trim(),children:c?"Saving...":"Save & Authorize"}):e.jsx("button",{type:"button",className:"integration-btn save",onClick:K,disabled:c||!v.trim()||!g.trim()&&!G,children:c?"Connecting...":"Save & Connect"})]})]}),m==="authorize"&&e.jsxs("div",{className:"gmail-oauth-section",children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Authorize Gmail Access"}),e.jsx("p",{className:"gmail-oauth-help",children:"Click the link below to authorize Tide Commander to access your Gmail account. After granting access, you will be redirected back and the connection will be established automatically."}),A&&e.jsx("a",{href:A,target:"_blank",rel:"noopener noreferrer",className:"gmail-oauth-authorize-btn",children:"Authorize with Google"}),e.jsxs("div",{className:"gmail-oauth-waiting",children:[e.jsx("span",{className:"gmail-oauth-spinner"}),e.jsx("span",{children:"Waiting for authorization to complete..."})]}),e.jsx("div",{className:"integration-form-actions",children:e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:()=>{l.current&&(clearInterval(l.current),l.current=null),u("credentials")},children:"Back"})})]}),m==="connected"&&e.jsxs("div",{className:"gmail-oauth-section",children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Gmail Connected"}),e.jsxs("div",{className:"gmail-oauth-connected-info",children:[e.jsx("span",{className:"gmail-oauth-connected-badge",children:"Connected"}),(r==null?void 0:r.emailAddress)&&e.jsx("span",{className:"gmail-oauth-email",children:r.emailAddress}),e.jsx("span",{className:"gmail-oauth-auth-type",children:s==="service_account"?"Service Account":"OAuth 2.0"})]}),(r==null?void 0:r.pollingActive)&&e.jsxs("p",{className:"gmail-oauth-help",children:["Email polling is active.",r.lastPollAt&&e.jsxs(e.Fragment,{children:[" Last checked: ",new Date(r.lastPollAt).toLocaleTimeString()]})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Polling Interval (ms)"}),e.jsx("input",{type:"number",className:"integration-field-input",value:p,onChange:a=>k(a.target.value)})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Approval Keywords"}),e.jsx("textarea",{className:"integration-field-input integration-field-textarea",value:h,onChange:a=>S(a.target.value),rows:2})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:w,children:"Close"}),e.jsx("button",{type:"button",className:"integration-btn",style:{backgroundColor:"#f38ba8",color:"#1e1e2e"},onClick:U,disabled:c,children:c?"Disconnecting...":"Disconnect"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:R,disabled:E,children:E?"Saving...":"Save Settings"})]})]}),e.jsx("style",{children:`
|
|
1
|
+
import{r as t,W as J,l as N,j as e}from"./main-D3GShQ8B.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function H({integration:o,onSave:f,onCancel:w}){const[s,y]=t.useState(o.values.authMethod||"oauth2"),[b,P]=t.useState(o.values.clientId||""),[j,T]=t.useState(""),[g,F]=t.useState(""),[v,q]=t.useState(o.values.impersonateEmail||""),[p,k]=t.useState(String(o.values.pollingIntervalMs??3e4)),[h,S]=t.useState(o.values.defaultApprovalKeywords||"approved,aprobado,autorizado,yes,ok"),[A,C]=t.useState(null),[r,z]=t.useState(null),[c,d]=t.useState(!1),[I,i]=t.useState(null),[E,O]=t.useState(!1),[m,u]=t.useState(o.status.connected?"connected":"credentials"),l=t.useRef(null),M=t.useRef(o.status.connected),x=t.useCallback(async()=>{try{const a=await J(N("/api/email/status"));if(a.ok){const n=await a.json();z(n),n.authenticated&&(u("connected"),l.current&&(clearInterval(l.current),l.current=null))}}catch(a){console.error("Failed to fetch Gmail status:",a)}},[]);t.useEffect(()=>{const a=o.status.connected,n=M.current;a&&!n&&m!=="connected"?u("connected"):!a&&n&&m==="connected"&&u("credentials"),M.current=a},[o.status.connected]),t.useEffect(()=>(x(),()=>{l.current&&clearInterval(l.current)}),[x]);const D=async()=>{if(!b.trim()){i("Client ID is required");return}d(!0),i(null);try{const a={authMethod:"oauth2",clientId:b.trim(),pollingIntervalMs:parseInt(p)||3e4,defaultApprovalKeywords:h};j.trim()&&(a.clientSecret=j.trim()),await f(a);const n=await J(N("/api/email/auth/url"));if(!n.ok){const L=await n.json().catch(()=>({}));throw new Error(L.error||`HTTP ${n.status}`)}const _=await n.json();if(!_.url)throw new Error("OAuth URL is empty");C(_.url),i(null),u("authorize"),l.current&&clearInterval(l.current),l.current=setInterval(x,3e3)}catch(a){const n=a instanceof Error?a.message:"Failed to get OAuth URL";i(n)}finally{d(!1)}},K=async()=>{if(!g.trim()){i("Service Account JSON is required");return}if(!v.trim()){i("Impersonate Email is required");return}try{const a=JSON.parse(g.trim());if(!a.client_email||!a.private_key){i("Service Account JSON must contain client_email and private_key");return}}catch{i("Invalid JSON in Service Account field");return}d(!0),i(null);try{await f({authMethod:"service_account",serviceAccountJson:g.trim(),impersonateEmail:v.trim(),pollingIntervalMs:parseInt(p)||3e4,defaultApprovalKeywords:h}),await new Promise(a=>setTimeout(a,1e3)),await x()}catch(a){const n=a instanceof Error?a.message:"Failed to save service account";i(n)}finally{d(!1)}},R=async()=>{O(!0),i(null);try{await f({pollingIntervalMs:parseInt(p)||3e4,defaultApprovalKeywords:h})}catch(a){i(a instanceof Error?a.message:"Failed to save settings")}finally{O(!1)}},U=async()=>{d(!0),i(null);try{await f({refreshToken:"",serviceAccountJson:"",impersonateEmail:""}),z(null),C(null),u("credentials"),await x()}catch(a){i(a instanceof Error?a.message:"Failed to disconnect")}finally{d(!1)}},G=!!o.values.serviceAccountJson;return e.jsxs("div",{className:"gmail-oauth-setup",children:[I&&e.jsx("div",{className:"gmail-oauth-error",children:I}),m==="credentials"&&e.jsxs("div",{className:"gmail-oauth-section",children:[e.jsxs("div",{className:"gmail-oauth-field",style:{marginBottom:24},children:[e.jsx("label",{className:"integration-field-label",children:"Authentication Method"}),e.jsxs("div",{className:"gmail-auth-method-selector",children:[e.jsxs("button",{type:"button",className:`gmail-auth-method-btn ${s==="oauth2"?"active":""}`,onClick:()=>{y("oauth2"),i(null)},children:[e.jsx("span",{className:"gmail-auth-method-icon",children:"🔑"}),e.jsx("span",{className:"gmail-auth-method-label",children:"OAuth 2.0"}),e.jsx("span",{className:"gmail-auth-method-desc",children:"Browser login flow"})]}),e.jsxs("button",{type:"button",className:`gmail-auth-method-btn ${s==="service_account"?"active":""}`,onClick:()=>{y("service_account"),i(null)},children:[e.jsx("span",{className:"gmail-auth-method-icon",children:"🤖"}),e.jsx("span",{className:"gmail-auth-method-label",children:"Service Account"}),e.jsx("span",{className:"gmail-auth-method-desc",children:"Domain-wide delegation"})]})]})]}),s==="oauth2"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Google OAuth Credentials"}),e.jsxs("p",{className:"gmail-oauth-help",children:["Create OAuth2 credentials in the"," ",e.jsx("a",{href:"https://console.cloud.google.com/apis/credentials",target:"_blank",rel:"noopener noreferrer",className:"gmail-oauth-link",children:"Google Cloud Console"}),". Enable the Gmail API and (optionally) the Calendar API. Set the redirect URI to:"," ",e.jsx("code",{className:"gmail-oauth-code",children:N("/api/email/auth/callback")})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client ID ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"text",className:"integration-field-input",value:b,placeholder:"xxxx.apps.googleusercontent.com",onChange:a=>P(a.target.value)})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client Secret ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"password",className:"integration-field-input",value:j,placeholder:o.values.clientSecret?"(saved)":"Enter client secret",onChange:a=>T(a.target.value),autoComplete:"off"})]})]}),s==="service_account"&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Service Account Credentials"}),e.jsxs("p",{className:"gmail-oauth-help",children:["Use a Google service account with"," ",e.jsx("a",{href:"https://admin.google.com/ac/owl/domainwidedelegation",target:"_blank",rel:"noopener noreferrer",className:"gmail-oauth-link",children:"domain-wide delegation"})," ","enabled. The service account must be authorized for Gmail scopes in Google Workspace Admin."]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["Service Account JSON ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("textarea",{className:"integration-field-input integration-field-textarea",value:g,placeholder:G?"(saved — paste new JSON to replace)":"Paste the full service account JSON key file contents",onChange:a=>F(a.target.value),rows:6,spellCheck:!1}),e.jsx("span",{className:"integration-field-description",children:"The JSON key file downloaded from Google Cloud Console containing client_email and private_key."})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["Impersonate Email ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"email",className:"integration-field-input",value:v,placeholder:"user@yourdomain.com",onChange:a=>q(a.target.value)}),e.jsx("span",{className:"integration-field-description",children:"The email address to impersonate via domain-wide delegation. Must be a user in your Google Workspace domain."})]})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Polling Interval (ms)"}),e.jsx("input",{type:"number",className:"integration-field-input",value:p,onChange:a=>k(a.target.value)}),e.jsx("span",{className:"integration-field-description",children:"How often to check for new emails. Default: 30000 (30s)."})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Approval Keywords"}),e.jsx("textarea",{className:"integration-field-input integration-field-textarea",value:h,onChange:a=>S(a.target.value),rows:2}),e.jsx("span",{className:"integration-field-description",children:"Comma-separated keywords that indicate email approval."})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:w,children:"Cancel"}),s==="oauth2"?e.jsx("button",{type:"button",className:"integration-btn save",onClick:D,disabled:c||!b.trim(),children:c?"Saving...":"Save & Authorize"}):e.jsx("button",{type:"button",className:"integration-btn save",onClick:K,disabled:c||!v.trim()||!g.trim()&&!G,children:c?"Connecting...":"Save & Connect"})]})]}),m==="authorize"&&e.jsxs("div",{className:"gmail-oauth-section",children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Authorize Gmail Access"}),e.jsx("p",{className:"gmail-oauth-help",children:"Click the link below to authorize Tide Commander to access your Gmail account. After granting access, you will be redirected back and the connection will be established automatically."}),A&&e.jsx("a",{href:A,target:"_blank",rel:"noopener noreferrer",className:"gmail-oauth-authorize-btn",children:"Authorize with Google"}),e.jsxs("div",{className:"gmail-oauth-waiting",children:[e.jsx("span",{className:"gmail-oauth-spinner"}),e.jsx("span",{children:"Waiting for authorization to complete..."})]}),e.jsx("div",{className:"integration-form-actions",children:e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:()=>{l.current&&(clearInterval(l.current),l.current=null),u("credentials")},children:"Back"})})]}),m==="connected"&&e.jsxs("div",{className:"gmail-oauth-section",children:[e.jsx("h4",{className:"gmail-oauth-section-title",children:"Gmail Connected"}),e.jsxs("div",{className:"gmail-oauth-connected-info",children:[e.jsx("span",{className:"gmail-oauth-connected-badge",children:"Connected"}),(r==null?void 0:r.emailAddress)&&e.jsx("span",{className:"gmail-oauth-email",children:r.emailAddress}),e.jsx("span",{className:"gmail-oauth-auth-type",children:s==="service_account"?"Service Account":"OAuth 2.0"})]}),(r==null?void 0:r.pollingActive)&&e.jsxs("p",{className:"gmail-oauth-help",children:["Email polling is active.",r.lastPollAt&&e.jsxs(e.Fragment,{children:[" Last checked: ",new Date(r.lastPollAt).toLocaleTimeString()]})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Polling Interval (ms)"}),e.jsx("input",{type:"number",className:"integration-field-input",value:p,onChange:a=>k(a.target.value)})]}),e.jsxs("div",{className:"gmail-oauth-field",children:[e.jsx("label",{className:"integration-field-label",children:"Approval Keywords"}),e.jsx("textarea",{className:"integration-field-input integration-field-textarea",value:h,onChange:a=>S(a.target.value),rows:2})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:w,children:"Close"}),e.jsx("button",{type:"button",className:"integration-btn",style:{backgroundColor:"#f38ba8",color:"#1e1e2e"},onClick:U,disabled:c,children:c?"Disconnecting...":"Disconnect"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:R,disabled:E,children:E?"Saving...":"Save Settings"})]})]}),e.jsx("style",{children:`
|
|
2
2
|
.gmail-oauth-setup {
|
|
3
3
|
padding: 0;
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as a,
|
|
1
|
+
import{r as a,W as N,l as b,j as e}from"./main-D3GShQ8B.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function L({integration:r,onSave:x,onCancel:f}){const[i,v]=a.useState(r.values.GOOGLE_CLIENT_ID||""),[d,C]=a.useState(""),[m,y]=a.useState(null),[s,z]=a.useState(null),[j,k]=a.useState(!1),[w,c]=a.useState(null),[g,u]=a.useState(r.status.connected?"connected":"credentials"),t=a.useRef(null),p=a.useCallback(async()=>{try{const o=r.id==="gmail"?"/api/email/status":"/api/calendar/status",l=await N(b(o));if(l.ok){const n=await l.json();z(n),n.authenticated&&(u("connected"),t.current&&(clearInterval(t.current),t.current=null))}}catch(o){console.error("Failed to fetch Google auth status:",o)}},[r.id]);a.useEffect(()=>(p(),()=>{t.current&&clearInterval(t.current)}),[p]);const A=async()=>{if(!i.trim()){c("Client ID is required");return}k(!0),c(null);try{const o={GOOGLE_CLIENT_ID:i.trim()};d.trim()&&(o.GOOGLE_CLIENT_SECRET=d.trim()),console.log("Saving Google OAuth config...",o),await x(o),console.log("Config saved successfully"),console.log("Fetching OAuth URL...");const l=r.id==="gmail"?"/api/email/auth/url":"/api/calendar/auth/url",n=await N(b(l));if(console.log("OAuth URL response:",n.status),!n.ok){const E=await n.json().catch(()=>({}));throw new Error(E.error||`HTTP ${n.status}`)}const h=await n.json();if(console.log("Received OAuth URL:",h),!h.url)throw new Error("OAuth URL is empty");y(h.url),console.log("AuthUrl state updated"),c(null),u("authorize"),console.log("Step updated to authorize"),t.current&&clearInterval(t.current),t.current=setInterval(p,3e3),console.log("Started polling for auth completion")}catch(o){const l=o instanceof Error?o.message:"Failed to get OAuth URL";console.error("Error in handleSaveCredentials:",l,o),c(l)}finally{k(!1)}};return e.jsxs("div",{className:"google-oauth-setup",children:[w&&e.jsx("div",{className:"google-oauth-error",children:w}),g==="credentials"&&e.jsxs("div",{className:"google-oauth-section",children:[e.jsx("h4",{className:"google-oauth-section-title",children:"Google OAuth Credentials"}),e.jsxs("p",{className:"google-oauth-help",children:["Create OAuth2 credentials in the"," ",e.jsx("a",{href:"https://console.cloud.google.com/apis/credentials",target:"_blank",rel:"noopener noreferrer",className:"google-oauth-link",children:"Google Cloud Console"}),". Enable the Gmail and Calendar APIs. Set the redirect URI to:"," ",e.jsx("code",{className:"google-oauth-code",children:b(r.id==="gmail"?"/api/email/auth/callback":"/api/calendar/auth/callback")})]}),e.jsxs("div",{className:"google-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client ID ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"text",className:"integration-field-input",value:i,placeholder:"xxxx.apps.googleusercontent.com",onChange:o=>v(o.target.value)})]}),e.jsxs("div",{className:"google-oauth-field",children:[e.jsxs("label",{className:"integration-field-label",children:["OAuth Client Secret ",e.jsx("span",{className:"integration-field-required",children:"*"})]}),e.jsx("input",{type:"password",className:"integration-field-input",value:d,placeholder:r.values.GOOGLE_CLIENT_SECRET?"(saved)":"Enter client secret",onChange:o=>C(o.target.value),autoComplete:"off"})]}),e.jsxs("div",{className:"integration-form-actions",children:[e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:f,children:"Cancel"}),e.jsx("button",{type:"button",className:"integration-btn save",onClick:A,disabled:j||!i.trim(),children:j?"Saving...":"Save & Authorize"})]})]}),g==="authorize"&&e.jsxs("div",{className:"google-oauth-section",children:[e.jsx("h4",{className:"google-oauth-section-title",children:"Authorize Google Access"}),e.jsx("p",{className:"google-oauth-help",children:"Click the link below to authorize Tide Commander to access your Google account. After granting access, you will be redirected back and the connection will be established automatically."}),m&&e.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"google-oauth-authorize-btn",children:"Authorize with Google"}),e.jsxs("div",{className:"google-oauth-waiting",children:[e.jsx("span",{className:"google-oauth-spinner"}),e.jsx("span",{children:"Waiting for authorization to complete..."})]}),e.jsx("div",{className:"integration-form-actions",children:e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:()=>{t.current&&(clearInterval(t.current),t.current=null),u("credentials")},children:"Back"})})]}),g==="connected"&&e.jsxs("div",{className:"google-oauth-section",children:[e.jsx("h4",{className:"google-oauth-section-title",children:"Google Connected"}),e.jsxs("div",{className:"google-oauth-connected-info",children:[e.jsx("span",{className:"google-oauth-connected-badge",children:"Connected"}),(s==null?void 0:s.emailAddress)&&e.jsx("span",{className:"google-oauth-email",children:s.emailAddress})]}),e.jsx("p",{className:"google-oauth-help",children:"Your Google account has been successfully connected."}),e.jsx("div",{className:"integration-form-actions",children:e.jsx("button",{type:"button",className:"integration-btn cancel",onClick:async()=>{await x({}),f()},children:"Close"})})]}),e.jsx("style",{children:`
|
|
2
2
|
.google-oauth-setup {
|
|
3
3
|
padding: 0;
|
|
4
4
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as K,r as a,j as e}from"./main-
|
|
1
|
+
import{u as K,r as a,j as e}from"./main-D3GShQ8B.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function ae({url:l,title:W,isOpen:g,onClose:I,initialWidth:H=480,initialHeight:B=360,minWidth:M=320,minHeight:b=240}){const{t:n}=K(["terminal","common"]),[Z,h]=a.useState(!0),[L,k]=a.useState(!1),[o,$]=a.useState({width:H,height:B}),[s,y]=a.useState(null),[f,z]=a.useState(1),[O,R]=a.useState(!1),[T,X]=a.useState(!1),N=a.useRef(null),U=a.useRef(null),d=a.useRef(null),r=a.useRef(null);a.useEffect(()=>{if(g&&!s){const t=Math.max(50,(window.innerWidth-o.width)/2),c=Math.max(50,(window.innerHeight-o.height)/2);y({x:t,y:c})}},[g,s,o.width,o.height]),a.useEffect(()=>{h(!0),k(!1)},[l]);const A=a.useCallback(()=>{h(!1)},[]),V=a.useCallback(()=>{h(!1),k(!0)},[]),Y=a.useCallback(()=>{N.current&&(h(!0),k(!1),N.current.src=l)},[l]),_=a.useCallback(()=>{window.open(l,"_blank")},[l]),q=a.useCallback(()=>{z(t=>Math.min(2,t+.25))},[]),F=a.useCallback(()=>{z(t=>Math.max(.25,t-.25))},[]),G=a.useCallback(()=>{z(1)},[]),J=a.useCallback(t=>{if(t.target.closest(".iframe-modal-btn"))return;t.preventDefault(),R(!0),d.current={startX:t.clientX,startY:t.clientY,startPosX:(s==null?void 0:s.x)??0,startPosY:(s==null?void 0:s.y)??0};const c=m=>{if(!d.current)return;const w=m.clientX-d.current.startX,j=m.clientY-d.current.startY;y({x:Math.max(0,Math.min(window.innerWidth-100,d.current.startPosX+w)),y:Math.max(0,Math.min(window.innerHeight-50,d.current.startPosY+j))})},x=()=>{d.current=null,R(!1),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",x)};document.addEventListener("mousemove",c),document.addEventListener("mouseup",x)},[s]),i=a.useCallback((t,c)=>{t.preventDefault(),t.stopPropagation(),X(!0);const x={startX:t.clientX,startY:t.clientY,startW:o.width,startH:o.height,startPosX:(s==null?void 0:s.x)??0,startPosY:(s==null?void 0:s.y)??0,direction:c};r.current=x;const m=j=>{if(!r.current)return;const p=j.clientX-r.current.startX,C=j.clientY-r.current.startY,v=r.current.direction;let E=r.current.startW,D=r.current.startH,P=r.current.startPosX,S=r.current.startPosY;if(v.includes("e")&&(E=Math.max(M,r.current.startW+p)),v.includes("w")){const u=r.current.startW-p;u>=M&&(E=u,P=r.current.startPosX+p)}if(v.includes("s")&&(D=Math.max(b,r.current.startH+C)),v.includes("n")){const u=r.current.startH-C;u>=b&&(D=u,S=r.current.startPosY+C)}$({width:E,height:D}),y({x:P,y:S})},w=()=>{r.current=null,X(!1),document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",w)};document.addEventListener("mousemove",m),document.addEventListener("mouseup",w)},[o,s,M,b]);return g?e.jsxs("div",{ref:U,className:`iframe-modal ${O?"dragging":""} ${T?"resizing":""}`,style:{left:(s==null?void 0:s.x)??0,top:(s==null?void 0:s.y)??0,width:o.width,height:o.height},children:[e.jsxs("div",{className:"iframe-modal-toolbar",onMouseDown:J,children:[e.jsx("div",{className:"iframe-modal-title",title:l,children:W||l}),e.jsxs("div",{className:"iframe-modal-actions",children:[e.jsx("button",{className:"iframe-modal-btn",onClick:F,title:n("terminal:iframeModal.zoomOut"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),e.jsxs("button",{className:"iframe-modal-btn iframe-modal-zoom-label",onClick:G,title:n("terminal:iframeModal.resetZoom"),children:[Math.round(f*100),"%"]}),e.jsx("button",{className:"iframe-modal-btn",onClick:q,title:n("terminal:iframeModal.zoomIn"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),e.jsx("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),e.jsx("div",{className:"iframe-modal-separator"}),e.jsx("button",{className:"iframe-modal-btn",onClick:Y,title:n("terminal:iframeModal.refresh"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M23 4v6h-6M1 20v-6h6"}),e.jsx("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]})}),e.jsx("button",{className:"iframe-modal-btn",onClick:_,title:n("terminal:iframeModal.openInBrowser"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})}),e.jsx("button",{className:"iframe-modal-btn iframe-modal-close",onClick:I,title:n("common:buttons.close"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),e.jsxs("div",{className:"iframe-modal-content",children:[Z&&e.jsxs("div",{className:"iframe-modal-loading",children:[e.jsx("div",{className:"iframe-modal-spinner"}),e.jsx("span",{children:n("common:status.loading")})]}),L&&e.jsxs("div",{className:"iframe-modal-error",children:[e.jsx("span",{children:n("terminal:iframeModal.failedToLoad")}),e.jsx("button",{onClick:Y,children:n("terminal:iframeModal.retry")})]}),e.jsx("iframe",{ref:N,src:l,className:"iframe-modal-frame",onLoad:A,onError:V,style:{display:L?"none":"block",transform:`scale(${f})`,transformOrigin:"top left",width:`${100/f}%`,height:`${100/f}%`}})]}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-n",onMouseDown:t=>i(t,"n")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-s",onMouseDown:t=>i(t,"s")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-e",onMouseDown:t=>i(t,"e")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-w",onMouseDown:t=>i(t,"w")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-ne",onMouseDown:t=>i(t,"ne")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-nw",onMouseDown:t=>i(t,"nw")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-se",onMouseDown:t=>i(t,"se")}),e.jsx("div",{className:"iframe-modal-resize-handle iframe-modal-resize-sw",onMouseDown:t=>i(t,"sw")})]}):null}export{ae as IframeModal,ae as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GmailOAuthSetup-K-SZcqrr.js","assets/main-D3GShQ8B.js","assets/modulepreload-polyfill-B5Qt9EMX.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-Chj50gSY.js","assets/main-Ch2CJGT4.css","assets/GoogleOAuthSetup-BfpfXmbM.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as c,W as I,l as w,j as e,z as B,aO as R}from"./main-D3GShQ8B.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const z={"gmail-oauth":c.lazy(()=>R(()=>import("./GmailOAuthSetup-K-SZcqrr.js"),__vite__mapDeps([0,1,2,3,4,5])).then(s=>({default:s.GmailOAuthSetup}))),"google-oauth":c.lazy(()=>R(()=>import("./GoogleOAuthSetup-BfpfXmbM.js"),__vite__mapDeps([6,1,2,3,4,5])).then(s=>({default:s.GoogleOAuthSetup})))},E={gmail:"✉️",slack:"💬",jira:"📋","google-calendar":"📅",docx:"📄"},N={gmail:"Send and receive emails through Gmail. Supports OAuth 2.0 authentication for secure access to your inbox.",slack:"Connect to Slack workspaces. Send messages, receive notifications, and integrate with channels.",jira:"Manage Jira issues and projects. Create tickets, track progress, and handle service desk requests.","google-calendar":"Access Google Calendar events. Create, update, and monitor calendar entries.",docx:"Generate and manipulate DOCX documents. Create reports, templates, and formatted documents."},A={gmail:["Google Cloud Console project","OAuth 2.0 credentials (Client ID & Secret)","Gmail API enabled"],slack:["Slack App with Bot Token and App-Level Token (Socket Mode)",'Enable Socket Mode in your app settings under "Socket Mode"','Enable Events in the "Event Subscriptions" section of your app config',"Subscribe to bot events: message.channels, message.groups, message.im","Required Bot Token scopes: channels:history, channels:read, chat:write, groups:history, groups:read, im:history, im:read, users:read"],jira:["Jira Cloud instance URL","API Token (from Atlassian account)","Account email address"],"google-calendar":["Google Cloud Console project","OAuth 2.0 credentials","Calendar API enabled"],docx:["No external credentials required","Templates directory (optional)"]},o={overlay:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4,backdropFilter:"blur(4px)",animation:"fadeIn 0.15s ease-out"},modal:{background:"var(--surface-0, #1e1e2e)",borderRadius:12,border:"1px solid var(--border, #313244)",width:"90vw",maxWidth:720,maxHeight:"85vh",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.5)",animation:"slideUp 0.2s ease-out"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--border, #313244)",background:"var(--surface-1, #181825)"},headerTitle:{fontSize:16,fontWeight:600,color:"var(--text-primary, #cdd6f4)",display:"flex",alignItems:"center",gap:8},closeBtn:{background:"none",border:"none",color:"var(--text-secondary, #a6adc8)",fontSize:20,cursor:"pointer",padding:"4px 8px",borderRadius:6,lineHeight:1},tabs:{display:"flex",borderBottom:"1px solid var(--border, #313244)",background:"var(--surface-1, #181825)",overflowX:"auto",scrollbarWidth:"none"},tab:s=>({padding:"10px 16px",background:"none",border:"none",borderBottom:s?"2px solid var(--accent, #89b4fa)":"2px solid transparent",color:s?"var(--accent, #89b4fa)":"var(--text-secondary, #a6adc8)",fontSize:13,fontWeight:s?600:400,cursor:"pointer",display:"flex",alignItems:"center",gap:6,whiteSpace:"nowrap",transition:"color 0.15s, border-color 0.15s",flexShrink:0}),tabStatus:(s,u)=>({width:6,height:6,borderRadius:"50%",background:u?"#f38ba8":s?"#a6e3a1":"#fab387",flexShrink:0}),body:{flex:1,overflow:"auto",padding:20},integrationHeader:{display:"flex",alignItems:"flex-start",gap:12,marginBottom:16},iconCircle:{width:44,height:44,borderRadius:10,background:"var(--surface-1, #181825)",border:"1px solid var(--border, #313244)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:22,flexShrink:0},integrationMeta:{flex:1},integrationName:{fontSize:15,fontWeight:600,color:"var(--text-primary, #cdd6f4)",marginBottom:4,display:"flex",alignItems:"center",gap:8},description:{fontSize:13,color:"var(--text-secondary, #a6adc8)",lineHeight:1.5},statusBadge:(s,u)=>({display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",borderRadius:10,fontSize:11,fontWeight:600,background:u?"rgba(243, 139, 168, 0.15)":s?"rgba(166, 227, 161, 0.15)":"rgba(250, 179, 135, 0.15)",color:u?"#f38ba8":s?"#a6e3a1":"#fab387"}),section:{marginTop:16,padding:12,borderRadius:8,background:"var(--surface-1, #181825)",border:"1px solid var(--border, #313244)"},sectionTitle:{fontSize:12,fontWeight:600,color:"var(--text-secondary, #a6adc8)",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:8},requirementList:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:4},requirementItem:{fontSize:12,color:"var(--text-secondary, #a6adc8)",display:"flex",alignItems:"center",gap:6},formSection:{marginTop:16},formSectionTitle:{fontSize:12,fontWeight:600,color:"var(--text-secondary, #a6adc8)",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:12}};function O({integration:s,onSave:u,onCancel:g}){const[p,T]=c.useState({...s.values}),[m,x]=c.useState({}),[h,C]=c.useState(!1),[y,b]=c.useState(!1);c.useEffect(()=>{T({...s.values}),x({}),b(!1)},[s.id]);const f=(t,l)=>{T(r=>({...r,[t]:l})),x(r=>{const i={...r};return delete i[t],i}),b(!1)},k=async t=>{t.preventDefault();const l={};for(const r of s.schema)if(r.required&&!p[r.key]&&p[r.key]!==0&&p[r.key]!==!1&&(l[r.key]=`${r.label} is required`),r.validate){const i=r.validate(p[r.key]);i&&(l[r.key]=i)}if(Object.keys(l).length>0){x(l);return}C(!0);try{await u(p),b(!0),setTimeout(()=>b(!1),3e3)}catch(r){x({_form:String(r)})}finally{C(!1)}},v=new Map;for(const t of s.schema){const l=t.group||"";v.has(l)||v.set(l,[]),v.get(l).push(t)}const n={display:"flex",flexDirection:"column",gap:4,marginBottom:12},a={fontSize:13,fontWeight:500,color:"var(--text-primary, #cdd6f4)"},d={padding:"8px 10px",borderRadius:6,border:"1px solid var(--border, #313244)",background:"var(--surface-0, #1e1e2e)",color:"var(--text-primary, #cdd6f4)",fontSize:13,outline:"none",width:"100%",boxSizing:"border-box"},S={fontSize:11,color:"var(--text-secondary, #a6adc8)"},j={fontSize:11,color:"#f38ba8"},_=t=>{var r;const l=p[t.key]??t.defaultValue??"";switch(t.type){case"boolean":return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:"var(--text-primary, #cdd6f4)",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:!!l,onChange:i=>f(t.key,i.target.checked)}),t.label]});case"select":return e.jsxs("select",{style:d,value:String(l),onChange:i=>f(t.key,i.target.value),children:[e.jsx("option",{value:"",children:t.placeholder||"Select..."}),(r=t.options)==null?void 0:r.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))]});case"textarea":return e.jsx("textarea",{style:{...d,resize:"vertical",minHeight:80},value:String(l),placeholder:t.placeholder,onChange:i=>f(t.key,i.target.value),rows:4});case"number":return e.jsx("input",{type:"number",style:d,value:l===""?"":Number(l),placeholder:t.placeholder,onChange:i=>f(t.key,i.target.value===""?"":Number(i.target.value))});case"password":return e.jsx("input",{type:"password",style:d,value:String(l),placeholder:t.placeholder,onChange:i=>f(t.key,i.target.value),autoComplete:"off"});default:return e.jsx("input",{type:t.type,style:d,value:String(l),placeholder:t.placeholder,onChange:i=>f(t.key,i.target.value)})}};return e.jsxs("form",{onSubmit:k,children:[m._form&&e.jsx("div",{style:{...j,marginBottom:12,padding:"8px 10px",borderRadius:6,background:"rgba(243, 139, 168, 0.1)"},children:m._form}),Array.from(v.entries()).map(([t,l])=>e.jsxs("div",{children:[t&&e.jsx("div",{style:{...o.sectionTitle,marginTop:16,marginBottom:8},children:t}),l.map(r=>e.jsxs("div",{style:n,children:[r.type!=="boolean"&&e.jsxs("label",{style:a,children:[r.label,r.required&&e.jsx("span",{style:{color:"#f38ba8",marginLeft:2},children:"*"})]}),_(r),r.description&&e.jsx("span",{style:S,children:r.description}),m[r.key]&&e.jsx("span",{style:j,children:m[r.key]})]},r.key))]},t||"_default")),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:16,paddingTop:12,borderTop:"1px solid var(--border, #313244)"},children:[e.jsx("button",{type:"button",onClick:g,style:{padding:"8px 16px",borderRadius:6,border:"1px solid var(--border, #313244)",background:"none",color:"var(--text-secondary, #a6adc8)",fontSize:13,cursor:"pointer"},children:"Cancel"}),e.jsx("button",{type:"submit",disabled:h,style:{padding:"8px 16px",borderRadius:6,border:"none",background:y?"#a6e3a1":"var(--accent, #89b4fa)",color:"#1e1e2e",fontSize:13,fontWeight:600,cursor:h?"wait":"pointer",opacity:h?.7:1},children:h?"Saving...":y?"Saved":"Save Configuration"})]})]})}function L({isOpen:s,onClose:u,initialTab:g}){const[p,T]=c.useState([]),[m,x]=c.useState(g||null),[h,C]=c.useState(!0),[y,b]=c.useState(null),f=c.useRef(g||null),k=c.useCallback(async()=>{try{const a=await I(w("/api/integrations"));if(!a.ok)throw new Error(`HTTP ${a.status}`);const d=await a.json();T(d),b(null),x(S=>{const j=S||g||(d.length>0?d[0].id:null);return f.current=j,j})}catch(a){b(`Failed to load integrations: ${a}`)}finally{C(!1)}},[g]);c.useEffect(()=>{s&&(C(!0),k(),g&&x(g))},[s,g]);const v=c.useCallback(async(a,d)=>{const S=await I(w(`/api/integrations/${a}/config`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)});if(!S.ok){const j=await S.json().catch(()=>({}));throw new Error(j.error||`HTTP ${S.status}`)}await k()},[k]);if(!s)return null;const n=p.find(a=>a.id===m);return e.jsx("div",{style:o.overlay,onClick:u,children:e.jsxs("div",{style:o.modal,onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{style:o.header,children:[e.jsxs("div",{style:o.headerTitle,children:[e.jsx("span",{children:"🔌"}),e.jsx("span",{children:"Integrations"})]}),e.jsx("button",{style:o.closeBtn,onClick:u,title:"Close",children:"×"})]}),h&&e.jsx("div",{style:{padding:40,textAlign:"center",color:"var(--text-secondary, #a6adc8)"},children:"Loading integrations..."}),y&&e.jsxs("div",{style:{padding:20,textAlign:"center"},children:[e.jsx("div",{style:{color:"#f38ba8",marginBottom:8},children:y}),e.jsx("button",{onClick:k,style:{padding:"6px 12px",borderRadius:6,border:"1px solid var(--border, #313244)",background:"none",color:"var(--text-primary, #cdd6f4)",cursor:"pointer",fontSize:13},children:"Retry"})]}),!h&&!y&&p.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:o.tabs,children:p.map(a=>e.jsxs("button",{style:o.tab(m===a.id),onClick:()=>x(a.id),children:[e.jsx("span",{children:E[a.id]||"🔌"}),e.jsx("span",{children:a.name}),e.jsx("span",{style:o.tabStatus(a.status.connected,!!a.status.error)})]},a.id))}),e.jsx("div",{style:o.body,children:n&&e.jsxs("div",{children:[e.jsxs("div",{style:o.integrationHeader,children:[e.jsx("div",{style:o.iconCircle,children:E[n.id]||"🔌"}),e.jsxs("div",{style:o.integrationMeta,children:[e.jsxs("div",{style:o.integrationName,children:[n.name,e.jsx("span",{style:o.statusBadge(n.status.connected,!!n.status.error),children:n.status.error?"✗ Error":n.status.connected?"✓ Connected":"⚠ Not Configured"})]}),e.jsx("div",{style:o.description,children:N[n.id]||n.description})]})]}),n.status.error&&e.jsxs("div",{style:{...o.section,borderColor:"rgba(243, 139, 168, 0.3)",background:"rgba(243, 139, 168, 0.05)"},children:[e.jsx("div",{style:{...o.sectionTitle,color:"#f38ba8"},children:"Error"}),e.jsx("div",{style:{fontSize:12,color:"#f38ba8"},children:n.status.error})]}),A[n.id]&&e.jsxs("div",{style:o.section,children:[e.jsx("div",{style:o.sectionTitle,children:"Requirements"}),e.jsx("ul",{style:o.requirementList,children:A[n.id].map((a,d)=>e.jsxs("li",{style:o.requirementItem,children:[e.jsx("span",{style:{color:"var(--accent, #89b4fa)"},children:"•"}),a]},d))})]}),e.jsxs("div",{style:o.formSection,children:[e.jsx("div",{style:o.formSectionTitle,children:"Configuration"}),n.customComponent&&z[n.customComponent]?e.jsx(c.Suspense,{fallback:e.jsx("div",{style:{color:"var(--text-secondary)",fontSize:13},children:"Loading..."}),children:B.createElement(z[n.customComponent],{key:n.id,integration:n,onSave:a=>v(n.id,a),onCancel:u})}):e.jsx(O,{integration:n,onSave:a=>v(n.id,a),onCancel:u})]})]})})]}),!h&&!y&&p.length===0&&e.jsx("div",{style:{padding:40,textAlign:"center",color:"var(--text-secondary, #a6adc8)"},children:"No integrations available."})]})})}export{L as IntegrationsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as ue,r as l,h as he,j as e,i as de}from"./main-
|
|
1
|
+
import{u as ue,r as l,h as he,j as e,i as de}from"./main-D3GShQ8B.js";function ge({isOpen:E,onClose:w,title:Q,icon:_,lines:c,isStreaming:P,onClear:q,emptyMessage:U,streamingIndicatorLabel:z,extraToolbar:J,extraFooter:X,modalClassName:Y}){const{t:a}=ue(["terminal","common"]),[u,$]=l.useState(""),[h,L]=l.useState(!1),[x,S]=l.useState(!1),[M,R]=l.useState(""),[k,p]=l.useState(!0),[D,Z]=l.useState(!0),[O,B]=l.useState(null),[r,ee]=l.useState([]),[m,j]=l.useState(0),[v,te]=l.useState(!1),[T,se]=l.useState(5),[F,C]=l.useState(null),[y,le]=l.useState(!0),o=l.useRef(null),I=l.useRef(null),A=l.useRef(null),H=l.useRef(!1),V=l.useRef(0),K=l.useMemo(()=>c.map(t=>t.text),[c]),b=l.useMemo(()=>{if(!u)return C(null),null;try{const t=v?u:u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=new RegExp(t,"gi");return C(null),s}catch(t){return C(t.message),null}},[u,v]),N=l.useMemo(()=>{if(!b)return[];const t=[];for(let s=0;s<K.length;s++)b.test(K[s])&&t.push(s),b.lastIndex=0;return t},[K,b]);l.useEffect(()=>{ee(N),m>=N.length&&j(Math.max(0,N.length-1))},[N]);const ne=l.useMemo(()=>{const t=c.map((i,f)=>({entry:i,originalIndex:f}));if(!u||!b||y)return t;if(N.length===0)return[];const s=new Set;for(const i of N){const f=Math.max(0,i-T),ie=Math.min(c.length-1,i+T);for(let G=f;G<=ie;G++)s.add(G)}const n=Array.from(s).sort((i,f)=>i-f),d=[];for(let i=0;i<n.length;i++){const f=n[i];i>0&&f-n[i-1]>1&&d.push({entry:{text:"",lineNumber:-1},originalIndex:-1,isSeparator:!0}),d.push({entry:c[f],originalIndex:f})}return d},[c,u,b,N,T,y]);l.useEffect(()=>{k&&o.current&&c.length>V.current&&(H.current=!0,requestAnimationFrame(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight),setTimeout(()=>{H.current=!1},50)})),V.current=c.length},[c.length,k]),l.useEffect(()=>{h&&I.current&&I.current.focus()},[h]),l.useEffect(()=>{x&&A.current&&A.current.focus()},[x]);const g=l.useCallback(t=>{if(!o.current)return;const n=t*18;o.current.scrollTop=n-100,B(t),setTimeout(()=>B(null),2e3)},[]);l.useEffect(()=>{if(!E)return;const t=s=>{if(s.key==="Escape"){s.preventDefault(),s.stopPropagation(),s.stopImmediatePropagation(),h?L(!1):x?S(!1):w();return}if(s.key==="/"&&!h&&!x&&(s.preventDefault(),L(!0)),s.key==="g"&&s.ctrlKey&&(s.preventDefault(),S(!0)),s.key==="End"&&s.ctrlKey&&o.current&&(o.current.scrollTop=o.current.scrollHeight),s.key==="Home"&&s.ctrlKey&&o.current&&(o.current.scrollTop=0),(s.key==="F3"||s.key==="Enter"&&h)&&r.length>0)if(s.preventDefault(),s.shiftKey){const n=(m-1+r.length)%r.length;j(n),g(r[n])}else{const n=(m+1)%r.length;j(n),g(r[n])}if(!h&&!x&&r.length>0){if(s.key==="n"&&!s.ctrlKey){s.preventDefault();const n=(m+1)%r.length;j(n),g(r[n])}else if(s.key==="N"){s.preventDefault();const n=(m-1+r.length)%r.length;j(n),g(r[n])}}!h&&!x&&o.current&&(s.key==="j"?(s.preventDefault(),o.current.scrollTop+=60,p(!1)):s.key==="k"?(s.preventDefault(),o.current.scrollTop-=60,p(!1)):s.key==="G"&&!s.ctrlKey?(s.preventDefault(),o.current.scrollTop=o.current.scrollHeight,p(!0)):s.key==="g"&&!s.ctrlKey&&(s.preventDefault(),o.current.scrollTop=0,p(!1)))};return window.addEventListener("keydown",t,{capture:!0}),()=>window.removeEventListener("keydown",t,{capture:!0})},[E,h,x,r,m,w,g]);const W=l.useCallback(()=>{const t=parseInt(M,10);!isNaN(t)&&t>0&&t<=c.length&&(g(t-1),p(!1)),S(!1),R("")},[M,c.length,g]),re=l.useCallback(()=>{if(H.current||!o.current)return;const{scrollTop:t,scrollHeight:s,clientHeight:n}=o.current,d=s-t-n<50;!d&&k&&p(!1),d&&!k&&p(!0)},[k]),ae=l.useCallback(t=>{if(!u||!b)return t;const s=v?u:u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");try{const n=new RegExp(`(${s})`,"gi");return t.replace(n,'<mark class="search-highlight">$1</mark>')}catch{return t}},[u,b,v]),{handleMouseDown:oe,handleClick:ce}=he(w);return E?e.jsx("div",{className:"pm2-logs-modal-overlay",onMouseDown:oe,onClick:ce,children:e.jsxs("div",{className:`pm2-logs-modal ${Y||""}`,children:[e.jsxs("div",{className:"pm2-logs-modal-header",children:[e.jsxs("div",{className:"header-left",children:[e.jsx("span",{className:"modal-icon",children:_}),e.jsx("span",{className:"modal-title",children:Q}),P&&e.jsxs("span",{className:"streaming-indicator",title:"Live streaming",children:[e.jsx("span",{className:"pulse"}),z||a("terminal:logs.live")]})]}),e.jsxs("div",{className:"header-right",children:[e.jsx("span",{className:"line-count",children:a("terminal:logs.lines",{count:c.length})}),e.jsx("button",{className:"modal-close",onClick:w,title:a("terminal:logs.closeEsc"),children:"×"})]})]}),e.jsxs("div",{className:"pm2-logs-modal-toolbar",children:[e.jsxs("div",{className:"toolbar-left",children:[e.jsxs("button",{className:`toolbar-btn ${h?"active":""}`,onClick:()=>L(!h),title:a("terminal:logs.searchShortcut"),children:["🔍 ",a("terminal:logs.search")]}),e.jsxs("button",{className:"toolbar-btn",onClick:()=>S(!0),title:a("terminal:logs.goToLineShortcut"),children:["⏬ ",a("terminal:logs.goToLine")]}),J,e.jsxs("button",{className:`toolbar-btn ${D?"active":""}`,onClick:()=>Z(!D),title:a("terminal:logs.toggleWrap"),children:["↩ ",a("terminal:logs.wrap")]}),e.jsxs("button",{className:`toolbar-btn ${k?"active":""}`,onClick:()=>p(!k),title:a("terminal:logs.autoScrollToBottom"),children:["↓ ",a("terminal:logs.auto")]})]}),e.jsx("div",{className:"toolbar-right",children:e.jsxs("button",{className:"toolbar-btn danger",onClick:q,title:a("terminal:logs.clear"),children:["🗑 ",a("terminal:logs.clear")]})})]}),h&&e.jsxs("div",{className:"pm2-logs-search-bar",children:[e.jsx("input",{ref:I,type:"text",placeholder:a(v?"terminal:logs.regexPlaceholder":"terminal:logs.searchPlaceholder"),value:u,onChange:t=>{$(t.target.value),j(0)},onKeyDown:t=>{t.key==="Escape"&&(L(!1),$(""),C(null))}}),e.jsx("button",{className:`toolbar-btn small ${v?"active":""}`,onClick:()=>te(!v),title:"Toggle regex mode",children:".*"}),e.jsx("button",{className:`toolbar-btn small ${y?"active":""}`,onClick:()=>le(!y),title:y?"Show all lines (highlight matches)":"Show only context around matches",children:y?"All":"Ctx"}),e.jsxs("div",{className:`context-control ${y?"hidden":""}`,title:"Lines of context around matches",children:[e.jsx("label",{children:"±"}),e.jsx("input",{type:"number",min:"0",max:"100",value:T,onChange:t=>se(Math.max(0,parseInt(t.target.value)||0)),className:"context-input"})]}),e.jsx("button",{className:"toolbar-btn small",onClick:()=>{if(r.length===0)return;const t=(m-1+r.length)%r.length;j(t),g(r[t])},disabled:r.length===0,title:"Previous match (Shift+F3)",children:"▲"}),e.jsx("button",{className:"toolbar-btn small",onClick:()=>{if(r.length===0)return;const t=(m+1)%r.length;j(t),g(r[t])},disabled:r.length===0,title:"Next match (F3)",children:"▼"}),u&&e.jsx("span",{className:"match-count",children:F?e.jsx("span",{className:"regex-error",title:F,children:a("terminal:logs.invalidRegex")}):r.length>0?`${m+1}/${r.length}`:a("terminal:logs.noMatches")}),e.jsx("button",{className:"search-close",onClick:()=>{L(!1),$(""),C(null)},children:"×"})]}),x&&e.jsxs("div",{className:"pm2-logs-goto-line",children:[e.jsxs("label",{children:[a("terminal:logs.goToLineLabel"),":"]}),e.jsx("input",{ref:A,type:"number",min:"1",max:c.length,placeholder:`1-${c.length}`,value:M,onChange:t=>R(t.target.value),onKeyDown:t=>{t.key==="Enter"?W():t.key==="Escape"&&(S(!1),R(""))}}),e.jsx("button",{onClick:W,children:a("terminal:logs.go")}),e.jsx("button",{onClick:()=>S(!1),children:a("common:buttons.cancel")})]}),e.jsx("div",{ref:o,className:`pm2-logs-content ${D?"wrap":"nowrap"}`,onScroll:re,children:c.length===0?e.jsx("div",{className:"logs-empty",children:U||a(P?"terminal:logs.waitingForLogs":"terminal:logs.noLogs")}):e.jsx("div",{className:"logs-lines",children:ne.map((t,s)=>{if("isSeparator"in t&&t.isSeparator)return e.jsxs("div",{className:"log-separator",children:[e.jsx("span",{className:"separator-line"}),e.jsx("span",{className:"separator-label",children:"…"}),e.jsx("span",{className:"separator-line"})]},`sep-${s}`);const{entry:n,originalIndex:d}=t,i=u&&N.includes(d);return e.jsxs("div",{className:`log-line ${O===d?"highlighted":""} ${r[m]===d?"current-match":""} ${i?"match-line":""} ${n.isError?"error-line":""}`,children:[e.jsx("span",{className:"line-number",children:n.lineNumber}),n.sourceLabel&&e.jsxs("span",{className:"boss-log-source",style:{color:n.sourceColor},children:["[",n.sourceLabel,"]"]}),e.jsx("span",{className:"line-content",dangerouslySetInnerHTML:{__html:ae(de(n.text))}})]},d)})})}),e.jsxs("div",{className:"pm2-logs-modal-footer",children:[e.jsxs("span",{className:"shortcut",children:[e.jsx("kbd",{children:"j"}),"/",e.jsx("kbd",{children:"k"})," Scroll"]}),e.jsxs("span",{className:"shortcut",children:[e.jsx("kbd",{children:"g"}),"/",e.jsx("kbd",{children:"G"})," Top/Bottom"]}),e.jsxs("span",{className:"shortcut",children:[e.jsx("kbd",{children:"/"})," Search"]}),e.jsxs("span",{className:"shortcut",children:[e.jsx("kbd",{children:"n"}),"/",e.jsx("kbd",{children:"N"})," Next/Prev match"]}),e.jsxs("span",{className:"shortcut",children:[e.jsx("kbd",{children:"Ctrl+G"})," Go to line"]}),e.jsxs("span",{className:"shortcut",children:[e.jsx("kbd",{children:"Esc"})," Close"]}),X]})]})}):null}export{ge as L};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as g,V as D,w as O,j as e,s as te}from"./main-CrRMpn-n.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const se=[{id:"triggers",label:"Triggers",icon:"⚡"},{id:"workflows",label:"Workflows",icon:"⚙️"},{id:"instances",label:"Instances",icon:"🔄"},{id:"messages",label:"Messages",icon:"💬"},{id:"stats",label:"Stats",icon:"📊"}],ae={trigger:"#89b4fa",slack:"#cba6f7",email:"#f9e2af",calendar:"#a6e3a1",document:"#fab387",jira:"#89dceb",workflow:"#f38ba8",system:"#6c7086",step:"#f38ba8",variable_change:"#cba6f7",approval:"#a6e3a1",audit:"#6c7086"},ne={trigger:"Trigger",slack:"Slack",email:"Email",calendar:"Calendar",document:"Document",jira:"Jira",workflow:"Workflow",system:"System",step:"Step",variable_change:"Variable",approval:"Approval",audit:"Audit"};function he({isOpen:r,onClose:s}){const[n,B]=g.useState("triggers"),[T,M]=g.useState([]),[y,x]=g.useState(!0),[_,j]=g.useState(null),[C,N]=g.useState("24h"),[R,$]=g.useState(""),[W,E]=g.useState(null),[m,p]=g.useState({}),[i,z]=g.useState(!1),[t,c]=g.useState(null),[d,b]=g.useState([]),l=g.useCallback(async()=>{if(!(n==="stats"||n==="instances")){x(!0);try{const o=Date.now(),h={"1h":36e5,"6h":216e5,"24h":864e5,"7d":6048e5,all:0},w=h[C]>0?String(o-h[C]):void 0;let k=[];if(n==="triggers"){const v=new URLSearchParams({limit:"200"});w&&v.set("since",w);const S=await D(O(`/api/events/triggers?${v}`));if(!S.ok){j(`HTTP ${S.status}`);return}k=((await S.json()).events||[]).map(F=>({type:"trigger",timestamp:F.firedAt,data:F}))}else if(n==="workflows"){const v=new URLSearchParams({limit:"200",category:"workflow"});w&&v.set("since",w);const S=await D(O(`/api/events/audit?${v}`));if(!S.ok){j(`HTTP ${S.status}`);return}k=((await S.json()).entries||[]).map(F=>({type:"workflow",timestamp:F.createdAt,data:F}))}else if(n==="messages"){const v=new URLSearchParams({limit:"200"}),S=new URLSearchParams({limit:"200"}),H=new URLSearchParams({limit:"200"});w&&(v.set("since",w),S.set("since",w));const[F,K,X]=await Promise.all([D(O(`/api/events/slack?${v}`)),D(O(`/api/events/email?${S}`)),D(O(`/api/events/approvals?${H}`))]);if(F.ok){const P=await F.json();for(const I of P.messages||[])k.push({type:"slack",timestamp:I.receivedAt,data:I})}if(K.ok){const P=await K.json();for(const I of P.messages||[])k.push({type:"email",timestamp:I.receivedAt,data:I})}if(X.ok){const P=await X.json();for(const I of P.events||[])k.push({type:"approval",timestamp:I.recordedAt,data:I})}k.sort((P,I)=>I.timestamp-P.timestamp)}M(k),j(null)}catch(o){j(`Failed to load events: ${o}`)}finally{x(!1)}}},[n,C]),f=g.useCallback(async()=>{x(!0);try{const[o,h]=await Promise.all([D(O("/api/events/stats")),D(O("/api/integrations"))]);if(o.ok&&c(await o.json()),h.ok){const w=await h.json();b(Array.isArray(w)?w:[])}j(null)}catch(o){j(`Failed to load stats: ${o}`)}finally{x(!1)}},[]);g.useEffect(()=>{r&&(n==="stats"?f():l())},[r,n,l,f]);const u=T.filter(o=>{if(!R)return!0;const h=R.toLowerCase();return JSON.stringify(o.data).toLowerCase().includes(h)});if(!r)return null;const A=d.filter(o=>o.status.connected).length;return e.jsx("div",{style:a.overlay,onClick:s,children:e.jsxs("div",{style:a.modal,onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{style:a.header,children:[e.jsxs("div",{style:a.headerTitle,children:[e.jsx("span",{children:"📊"}),e.jsx("span",{children:"Monitoring & Logs"})]}),e.jsx("button",{style:a.closeBtn,onClick:s,title:"Close",children:"×"})]}),e.jsx("div",{style:a.tabs,children:se.map(o=>e.jsxs("button",{style:a.tab(n===o.id),onClick:()=>{B(o.id),$(""),E(null)},children:[e.jsx("span",{children:o.icon}),e.jsx("span",{children:o.label})]},o.id))}),n!=="stats"&&n!=="instances"&&e.jsxs("div",{style:a.filters,children:[e.jsx("div",{style:{display:"flex",gap:4},children:["1h","6h","24h","7d","all"].map(o=>e.jsx("button",{style:{...a.timeBtn,background:C===o?"#89b4fa":"transparent",color:C===o?"#1e1e2e":"#a6adc8"},onClick:()=>N(o),children:o},o))}),e.jsx("input",{style:a.searchInput,placeholder:"Search events...",value:R,onChange:o=>$(o.target.value)}),e.jsx("button",{style:a.refreshBtn,onClick:l,children:"Refresh"})]}),e.jsx("div",{style:a.content,children:n==="stats"?e.jsx(oe,{loading:y,error:_,stats:t,integrations:d,connectedCount:A,onRefresh:f}):n==="instances"?e.jsx(ce,{}):e.jsx(re,{loading:y,error:_,entries:u,expandedId:W,matcherResults:m,loadingMatchers:i,onToggleExpand:async(o,h)=>{var w;if(W===o){E(null);return}if(E(o),!m[o]){z(!0);try{let k="";if((h==null?void 0:h.type)==="trigger"&&((w=h==null?void 0:h.data)!=null&&w.id))k=`/api/triggers/events/${h.data.id}/matchers`;else if(h&&["slack","email","approval"].includes(h.type)){const v=h.data,S=v.ts||v.messageId||v.email_id;S&&h.type&&(k=`/api/triggers/matchers/by-source/${h.type}/${encodeURIComponent(S)}`)}if(k){const v=await D(O(k));if(v.ok){const S=await v.json();p(H=>({...H,[o]:S.matchers||[]}))}}}catch(k){console.error("Failed to fetch matchers:",k)}finally{z(!1)}}}})}),n!=="stats"&&n!=="instances"&&e.jsx("div",{style:a.footer,children:e.jsxs("span",{style:{color:"#6c7086",fontSize:11},children:[u.length," event",u.length!==1?"s":""," shown",R&&` (filtered from ${T.length})`]})})]})})}function re({loading:r,error:s,entries:n,expandedId:B,matcherResults:T,loadingMatchers:M,onToggleExpand:y}){return r?e.jsx("div",{style:{color:"#a6adc8",padding:20},children:"Loading events..."}):s?e.jsx("div",{style:{color:"#f38ba8",padding:20},children:s}):n.length===0?e.jsx("div",{style:{color:"#6c7086",textAlign:"center",padding:40},children:"No events found for the selected filters."}):e.jsx(e.Fragment,{children:n.map((x,_)=>{var W;const j=`${x.type}-${x.timestamp}-${_}`,C=B===j,N=ae[x.type]||"#6c7086",R=ie(x),$=new Date(x.timestamp);return e.jsxs("div",{style:{...a.eventRow,borderLeft:`3px solid ${N}`,background:C?"rgba(137,180,250,0.05)":"transparent"},onClick:()=>y(j,x),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{...a.tag,background:`${N}22`,color:N},children:ne[x.type]||x.type}),e.jsx("span",{style:{color:"#cdd6f4",fontSize:12,flex:1},children:R}),e.jsxs("span",{style:{color:"#6c7086",fontSize:10,whiteSpace:"nowrap"},children:[$.toLocaleTimeString()," ",$.toLocaleDateString()]})]}),C&&e.jsxs(e.Fragment,{children:[e.jsx("pre",{style:a.detail,children:JSON.stringify(x.data,null,2)}),T[j]&&e.jsxs("div",{style:{marginTop:12,borderTop:"1px solid #313244",paddingTop:12},children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:.5,marginBottom:8},children:x.type==="trigger"?"Matcher Results":"Trigger Evaluations"}),M?e.jsx("div",{style:{color:"#6c7086",fontSize:12},children:"Loading matchers..."}):((W=T[j])==null?void 0:W.length)===0?e.jsx("div",{style:{color:"#6c7086",fontSize:12},children:"No matchers evaluated"}):(()=>{const E=T[j];if(x.type!=="trigger"){const m=new Map;for(const p of E){const i=String(p.trigger_id||"unknown");m.has(i)||m.set(i,[]),m.get(i).push(p)}return Array.from(m.entries()).map(([p,i])=>{var z;return e.jsxs("div",{style:{marginBottom:12},children:[e.jsxs("div",{style:{color:"#cdd6f4",fontSize:11,fontWeight:500,marginBottom:6,paddingBottom:4,borderBottom:"1px solid #45475a"},children:["Trigger: ",String(((z=i[0])==null?void 0:z.trigger_name)||p)]}),i.map((t,c)=>{const d=t.matched===1||t.matched===!0,b=d?"#a6e3a1":"#f38ba8",l=t.confidence??null,f=String(t.matcher_name||"unknown"),u=t.reason?String(t.reason):"";return e.jsxs("div",{style:{display:"flex",gap:8,padding:"6px 10px",background:"#313244",borderRadius:4,marginBottom:4,fontSize:11},children:[e.jsx("span",{style:{color:b,fontWeight:600,minWidth:50},children:d?"✓":"✗"}),e.jsx("span",{style:{color:"#cdd6f4",flex:1},children:f}),l!==null&&e.jsxs("span",{style:{color:"#a6adc8"},children:["(",(l*100).toFixed(0),"%)"]}),u&&e.jsx("span",{style:{color:"#6c7086",fontSize:10},children:u})]},c)})]},p)})}else return E.map((m,p)=>{const i=m.matched===1||m.matched===!0,z=i?"#a6e3a1":"#f38ba8",t=m.confidence??null,c=String(m.matcher_name||"unknown"),d=m.reason?String(m.reason):"";return e.jsxs("div",{style:{display:"flex",gap:8,padding:"6px 10px",background:"#313244",borderRadius:4,marginBottom:4,fontSize:11},children:[e.jsx("span",{style:{color:z,fontWeight:600,minWidth:50},children:i?"✓ MATCH":"✗ FAIL"}),e.jsx("span",{style:{color:"#cdd6f4",flex:1},children:c}),t!==null&&e.jsxs("span",{style:{color:"#a6adc8"},children:["(",(t*100).toFixed(0),"%)"]}),d&&e.jsx("span",{style:{color:"#6c7086",fontSize:10},children:d})]},p)})})()]})]})]},j)})})}function oe({loading:r,error:s,stats:n,integrations:B,connectedCount:T,onRefresh:M}){return r?e.jsx("div",{style:{color:"#a6adc8",padding:20},children:"Loading stats..."}):s?e.jsx("div",{style:{color:"#f38ba8",padding:20},children:s}):e.jsxs("div",{style:{padding:20},children:[e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:16},children:e.jsx("button",{style:a.refreshBtn,onClick:M,children:"Refresh"})}),n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:a.section,children:[e.jsx("h3",{style:a.sectionTitle,children:"Workflows"}),e.jsxs("div",{style:a.grid,children:[e.jsx(U,{label:"Active",value:n.activeWorkflows,color:"#89b4fa"}),e.jsx(U,{label:"Completed",value:n.completedWorkflows,color:"#a6e3a1"}),e.jsx(U,{label:"Failed",value:n.failedWorkflows,color:"#f38ba8"})]})]}),e.jsxs("div",{style:a.section,children:[e.jsx("h3",{style:a.sectionTitle,children:"Events (Today)"}),e.jsxs("div",{style:a.grid,children:[e.jsx(U,{label:"Triggers Fired",value:n.triggersFiredToday,color:"#f9e2af"}),e.jsx(U,{label:"Slack Messages",value:n.slackMessageCount,color:"#cba6f7"}),e.jsx(U,{label:"Emails",value:n.emailCount,color:"#fab387"})]})]}),e.jsxs("div",{style:a.section,children:[e.jsxs("h3",{style:a.sectionTitle,children:["Integrations (",T,"/",B.length," connected)"]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[B.map(y=>e.jsxs("div",{style:a.integrationRow,children:[e.jsx("span",{style:{color:"#cdd6f4",fontSize:13},children:y.name}),e.jsx("span",{style:{...a.statusBadge,background:y.status.connected?"rgba(166,227,161,0.15)":"rgba(108,112,134,0.15)",color:y.status.connected?"#a6e3a1":"#6c7086"},children:y.status.error?"Error":y.status.connected?"Connected":"Disconnected"})]},y.id)),B.length===0&&e.jsx("div",{style:{color:"#6c7086",fontSize:12},children:"No integrations configured"})]})]})]}),!n&&e.jsx("div",{style:{color:"#6c7086",textAlign:"center",padding:40},children:"No stats available. The event store may not have any data yet."})]})}function U({label:r,value:s,color:n}){return e.jsxs("div",{style:a.card,children:[e.jsx("div",{style:{color:n,fontSize:28,fontWeight:700,lineHeight:1},children:s}),e.jsx("div",{style:{color:"#a6adc8",fontSize:11,marginTop:4},children:r})]})}function ie(r){const s=r.data;switch(r.type){case"trigger":return`Trigger "${s.triggerName||s.triggerId}" ${s.status||"fired"}`;case"slack":return`${s.direction==="outbound"?"Sent":"Received"} in #${s.channelName||s.channelId}: ${Y(s.text,60)}`;case"email":return`${s.direction==="outbound"?"Sent to":"From"} ${s.direction==="outbound"?s.toAddresses:s.fromAddress}: ${Y(s.subject,50)}`;case"approval":return`${s.approved?"Approved":"Rejected"} by ${s.approverEmail}`;case"document":return`Generated "${s.outputFilename}" from template "${s.templateName}"`;case"calendar":return`Calendar event ${s.action}: "${s.summary}"`;case"jira":return`${s.ticketKey} ${s.action}: ${Y(s.summary,50)}`;case"step":return`Workflow step: ${s.toStateName} (${s.status})`;case"variable_change":return`Variable "${s.variableName}" changed by ${s.changedBy}`;case"audit":return`[${(s.level||"info").toUpperCase()}] ${s.category}: ${s.action}`;default:return JSON.stringify(s).slice(0,80)}}function Y(r,s){return r?r.length>s?r.slice(0,s)+"...":r:""}const V={running:"#a6e3a1",paused:"#f9e2af",completed:"#89b4fa",failed:"#f38ba8",cancelled:"#6c7086"},q={action:"#89b4fa",wait:"#f9e2af",decision:"#cba6f7",end:"#6c7086"};let G=null,Q,Z;function ee(){const r=te.getState(),s=r.workflowDefinitions??new Map,n=r.workflowInstances??new Map;return G&&Q===s&&Z===n||(Q=s,Z=n,G={definitions:s,instances:n}),G}function le(){return g.useSyncExternalStore(r=>te.subscribe(r),ee,ee)}function ce(){var z;const{definitions:r,instances:s}=le(),[n,B]=g.useState("all"),[T,M]=g.useState("all"),[y,x]=g.useState(""),[_,j]=g.useState(null),[C,N]=g.useState(null),[R,$]=g.useState(null),W=g.useMemo(()=>Array.from(s.values()),[s]),E=g.useMemo(()=>Array.from(r.values()),[r]),m=g.useMemo(()=>W.filter(t=>{if(n!=="all"&&t.status!==n||T!=="all"&&t.workflowDefId!==T)return!1;if(y){const c=y.toLowerCase();return t.workflowName.toLowerCase().includes(c)||t.id.toLowerCase().includes(c)||JSON.stringify(t.variables).toLowerCase().includes(c)}return!0}).sort((t,c)=>c.updatedAt-t.updatedAt),[W,n,T,y]),p=_?s.get(_):null,i=R?s.get(R):null;if(i){const t=r.get(i.workflowDefId),c=t==null?void 0:t.states.find(f=>f.id===i.currentStateId),d=V[i.status]||"#6c7086",b={},l={};for(const[f,u]of Object.entries(i.variables))f.startsWith("wi_")?b[f]=u:l[f]=u;return e.jsxs("div",{style:{padding:"12px 0"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[e.jsx("button",{style:{...a.refreshBtn,fontSize:12},onClick:()=>$(null),children:"Back"}),e.jsxs("span",{style:{color:"#cdd6f4",fontSize:13,fontWeight:500},children:["Debug: ",i.workflowName]}),e.jsx("span",{style:{...a.tag,background:`${d}22`,color:d},children:i.status})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:8,marginBottom:16},children:[e.jsx(L,{label:"ID",value:i.id}),e.jsx(L,{label:"Def ID",value:i.workflowDefId}),e.jsx(L,{label:"Current State",value:(c==null?void 0:c.name)||i.currentStateId}),e.jsx(L,{label:"State Type",value:(c==null?void 0:c.type)||"unknown"}),e.jsx(L,{label:"Created",value:J(i.createdAt)}),e.jsx(L,{label:"Updated",value:J(i.updatedAt)}),i.completedAt&&e.jsx(L,{label:"Completed",value:J(i.completedAt)}),i.error&&e.jsx(L,{label:"Error",value:i.error,color:"#f38ba8"}),e.jsx(L,{label:"Steps",value:String(((z=i.history)==null?void 0:z.length)??0)})]}),Object.keys(l).length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:1,marginBottom:6},children:"User Variables"}),e.jsx("pre",{style:a.detail,children:JSON.stringify(l,null,2)})]}),Object.keys(b).length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:1,marginBottom:6},children:"Internal Variables (wi_*)"}),e.jsx("pre",{style:a.detail,children:JSON.stringify(b,null,2)})]}),c&&c.transitions.length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:1,marginBottom:6},children:"Available Transitions"}),c.transitions.map(f=>{var u;return e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"4px 10px",background:"#313244",borderRadius:4,marginBottom:4},children:[e.jsx("span",{style:{color:"#cdd6f4",fontSize:12},children:f.name}),e.jsxs("span",{style:{color:"#6c7086",fontSize:10},children:[f.condition.type," → ",((u=t==null?void 0:t.states.find(A=>A.id===f.targetStateId))==null?void 0:u.name)||f.targetStateId]})]},f.id)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:1,marginBottom:6},children:"Raw JSON"}),e.jsx("pre",{style:{...a.detail,maxHeight:400},children:JSON.stringify(i,null,2)})]})]})}if(p){const t=r.get(p.workflowDefId),c=V[p.status]||"#6c7086";return e.jsxs("div",{style:{padding:"12px 0"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx("button",{style:{...a.refreshBtn,fontSize:12},onClick:()=>{j(null),N(null)},children:"Back"}),e.jsx("span",{style:{color:"#cdd6f4",fontSize:13,fontWeight:500},children:p.workflowName}),e.jsxs("span",{style:{color:"#6c7086",fontSize:10,fontFamily:"monospace"},children:["(",p.id.slice(0,8),")"]}),e.jsx("span",{style:{...a.tag,background:`${c}22`,color:c},children:p.status}),e.jsx("div",{style:{flex:1}}),e.jsx("button",{style:{...a.refreshBtn,fontFamily:"monospace",fontSize:10},onClick:()=>$(p.id),children:"{..}"})]}),e.jsxs("div",{style:{display:"flex",gap:16,color:"#6c7086",fontSize:11,marginBottom:12},children:[e.jsxs("span",{children:["Created: ",J(p.createdAt)]}),e.jsxs("span",{children:["Updated: ",J(p.updatedAt)]}),p.error&&e.jsxs("span",{style:{color:"#f38ba8"},children:["Error: ",p.error]})]}),e.jsxs("div",{style:{color:"#a6adc8",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:1,marginBottom:8},children:["Timeline (",p.history.length," step",p.history.length!==1?"s":"",")"]}),p.history.length===0&&e.jsx("div",{style:{color:"#6c7086",fontSize:12,padding:16},children:"No steps recorded yet."}),p.history.map((d,b)=>{const l=t==null?void 0:t.states.find(A=>A.id===d.toStateId),f=C===b,u=l&&q[l.type]||"#6c7086";return e.jsxs("div",{style:{padding:"10px 12px",borderLeft:`3px solid ${u}`,borderBottom:"1px solid #313244",cursor:"pointer",background:f?"rgba(137,180,250,0.05)":"transparent",marginLeft:8},onClick:()=>N(f?null:b),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:u,flexShrink:0}}),e.jsx("span",{style:{color:"#cdd6f4",fontSize:12,fontWeight:500},children:(l==null?void 0:l.name)||d.toStateId}),l&&e.jsx("span",{style:{...a.tag,background:`${u}22`,color:u},children:l.type}),d.transitionName&&e.jsxs("span",{style:{color:"#6c7086",fontSize:10},children:['via "',d.transitionName,'"']}),e.jsx("div",{style:{flex:1}}),e.jsx("span",{style:{color:"#6c7086",fontSize:10,whiteSpace:"nowrap"},children:J(d.timestamp)})]}),f&&e.jsxs("div",{style:{marginTop:8,paddingLeft:20},children:[d.fromStateId&&e.jsxs("div",{style:{color:"#6c7086",fontSize:11,marginBottom:2},children:[e.jsx("span",{style:{fontWeight:600,fontSize:10,textTransform:"uppercase"},children:"From: "}),e.jsx("span",{style:{fontFamily:"monospace"},children:d.fromStateId})]}),d.details&&e.jsxs("div",{style:{marginTop:6},children:[e.jsx("div",{style:{color:"#6c7086",fontSize:10,fontWeight:600,textTransform:"uppercase",marginBottom:4},children:"Agent Reasoning / Summary"}),e.jsx("div",{style:{padding:10,background:"#181825",borderRadius:6,border:"1px solid #313244",fontSize:12,color:"#cdd6f4",lineHeight:1.5,whiteSpace:"pre-wrap"},children:d.details})]}),(l==null?void 0:l.description)&&e.jsxs("div",{style:{marginTop:6,color:"#a6adc8",fontSize:11},children:[e.jsx("span",{style:{color:"#6c7086",fontWeight:600,fontSize:10,textTransform:"uppercase"},children:"Description: "}),l.description]}),d.variables&&Object.keys(d.variables).length>0&&e.jsxs("div",{style:{marginTop:6},children:[e.jsx("div",{style:{color:"#6c7086",fontSize:10,fontWeight:600,textTransform:"uppercase",marginBottom:4},children:"Variables at this step"}),e.jsx("pre",{style:a.detail,children:JSON.stringify(d.variables,null,2)})]}),(l==null?void 0:l.action)&&e.jsxs("div",{style:{marginTop:6},children:[e.jsxs("div",{style:{color:"#6c7086",fontSize:10,fontWeight:600,textTransform:"uppercase",marginBottom:4},children:["Action (",l.action.type,")"]}),e.jsx("pre",{style:a.detail,children:JSON.stringify(l.action,null,2)})]})]})]},b)})]})}return e.jsxs("div",{style:{padding:"12px 0"},children:[e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",marginBottom:12,flexWrap:"wrap"},children:[e.jsxs("select",{style:{background:"#313244",border:"1px solid #45475a",borderRadius:6,padding:"5px 10px",color:"#cdd6f4",fontSize:12,outline:"none"},value:T,onChange:t=>M(t.target.value),children:[e.jsx("option",{value:"all",children:"All Workflows"}),E.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsx("div",{style:{display:"flex",gap:4},children:["all","running","paused","completed","failed","cancelled"].map(t=>e.jsx("button",{style:{...a.timeBtn,background:n===t?t==="all"?"#89b4fa":V[t]||"#89b4fa":"transparent",color:n===t?"#1e1e2e":"#a6adc8",borderColor:n===t?"transparent":"#45475a",textTransform:"capitalize"},onClick:()=>B(t),children:t},t))}),e.jsx("input",{style:a.searchInput,placeholder:"Search instances...",value:y,onChange:t=>x(t.target.value)}),e.jsxs("span",{style:{color:"#6c7086",fontSize:11},children:[m.length,"/",W.length]})]}),m.length===0?e.jsx("div",{style:{color:"#6c7086",textAlign:"center",padding:40},children:"No workflow instances found."}):m.map(t=>{var f,u;const c=r.get(t.workflowDefId),d=V[t.status]||"#6c7086",b=c==null?void 0:c.states.find(A=>A.id===t.currentStateId),l=b&&q[b.type]||"#6c7086";return e.jsxs("div",{style:{...a.eventRow,display:"flex",alignItems:"center",gap:12,borderLeft:`3px solid ${d}`},onClick:()=>j(t.id),children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{color:"#cdd6f4",fontSize:13,fontWeight:500},children:t.workflowName}),e.jsx("span",{style:{...a.tag,background:`${d}22`,color:d},children:t.status})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:2},children:[e.jsx("span",{style:{color:"#6c7086",fontSize:10,fontFamily:"monospace"},children:t.id.slice(0,8)}),b&&e.jsxs("span",{style:{color:l,fontSize:10},children:["@ ",b.name]}),e.jsxs("span",{style:{color:"#45475a",fontSize:10},children:[((f=t.history)==null?void 0:f.length)??0," step",(((u=t.history)==null?void 0:u.length)??0)!==1?"s":""]})]})]}),e.jsx("span",{style:{color:"#6c7086",fontSize:10,whiteSpace:"nowrap"},children:de(t.updatedAt)}),e.jsx("button",{style:{background:"transparent",border:"1px solid #45475a",borderRadius:4,padding:"3px 6px",color:"#6c7086",fontSize:10,fontFamily:"monospace",cursor:"pointer"},onClick:A=>{A.stopPropagation(),$(t.id)},title:"Debug view",children:"{..}"})]},t.id)})]})}function L({label:r,value:s,color:n}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2,padding:"8px 10px",background:"#313244",borderRadius:6},children:[e.jsx("span",{style:{color:"#6c7086",fontSize:10,textTransform:"uppercase",letterSpacing:.5},children:r}),e.jsx("span",{style:{color:n||"#cdd6f4",fontSize:12,fontFamily:"monospace",wordBreak:"break-all"},children:s})]})}function de(r){return new Date(r).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function J(r){const s=new Date(r);return`${s.toLocaleDateString()} ${s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}`}const a={overlay:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4,backdropFilter:"blur(4px)"},modal:{background:"var(--surface-0, #1e1e2e)",borderRadius:12,border:"1px solid var(--border, #313244)",width:"90vw",maxWidth:1e3,height:"85vh",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.5)"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--border, #313244)",background:"var(--surface-1, #181825)"},headerTitle:{fontSize:16,fontWeight:600,color:"var(--text-primary, #cdd6f4)",display:"flex",alignItems:"center",gap:8},closeBtn:{background:"none",border:"none",color:"var(--text-secondary, #a6adc8)",fontSize:20,cursor:"pointer",padding:"4px 8px",borderRadius:6,lineHeight:1},tabs:{display:"flex",borderBottom:"1px solid var(--border, #313244)",background:"var(--surface-1, #181825)",overflowX:"auto",scrollbarWidth:"none"},tab:r=>({padding:"10px 16px",background:"none",border:"none",borderBottom:r?"2px solid var(--accent, #89b4fa)":"2px solid transparent",color:r?"var(--accent, #89b4fa)":"var(--text-secondary, #a6adc8)",fontSize:13,fontWeight:r?600:400,cursor:"pointer",display:"flex",alignItems:"center",gap:6,whiteSpace:"nowrap",transition:"color 0.15s, border-color 0.15s",flexShrink:0}),filters:{display:"flex",gap:8,alignItems:"center",padding:"10px 20px",borderBottom:"1px solid var(--border, #313244)",flexWrap:"wrap"},timeBtn:{border:"1px solid #45475a",borderRadius:4,padding:"4px 8px",fontSize:10,fontWeight:600,cursor:"pointer"},searchInput:{background:"#313244",border:"1px solid #45475a",borderRadius:6,padding:"5px 10px",color:"#cdd6f4",fontSize:12,flex:1,minWidth:120,outline:"none"},refreshBtn:{background:"transparent",border:"1px solid #45475a",borderRadius:6,padding:"5px 12px",color:"#a6adc8",fontSize:11,cursor:"pointer"},content:{flex:1,overflow:"auto",padding:"0 20px"},eventRow:{padding:"8px 12px",borderBottom:"1px solid #313244",cursor:"pointer",transition:"background 0.1s"},tag:{fontSize:10,fontWeight:600,padding:"2px 6px",borderRadius:4,whiteSpace:"nowrap"},detail:{marginTop:8,padding:10,background:"#181825",borderRadius:6,fontSize:11,fontFamily:"monospace",color:"#a6adc8",overflow:"auto",maxHeight:300,whiteSpace:"pre-wrap",wordBreak:"break-all"},footer:{padding:"8px 20px",borderTop:"1px solid #313244"},section:{marginBottom:24},sectionTitle:{color:"#a6adc8",fontSize:12,fontWeight:600,textTransform:"uppercase",letterSpacing:1,marginBottom:12,margin:0},grid:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:12},card:{background:"#313244",borderRadius:8,padding:"16px 14px",textAlign:"center"},integrationRow:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 12px",background:"#313244",borderRadius:6},statusBadge:{fontSize:10,fontWeight:600,padding:"3px 8px",borderRadius:4}};export{he as MonitoringModal};
|
|
1
|
+
import{r as g,W as D,l as O,j as e,s as te}from"./main-D3GShQ8B.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const se=[{id:"triggers",label:"Triggers",icon:"⚡"},{id:"workflows",label:"Workflows",icon:"⚙️"},{id:"instances",label:"Instances",icon:"🔄"},{id:"messages",label:"Messages",icon:"💬"},{id:"stats",label:"Stats",icon:"📊"}],ae={trigger:"#89b4fa",slack:"#cba6f7",email:"#f9e2af",calendar:"#a6e3a1",document:"#fab387",jira:"#89dceb",workflow:"#f38ba8",system:"#6c7086",step:"#f38ba8",variable_change:"#cba6f7",approval:"#a6e3a1",audit:"#6c7086"},ne={trigger:"Trigger",slack:"Slack",email:"Email",calendar:"Calendar",document:"Document",jira:"Jira",workflow:"Workflow",system:"System",step:"Step",variable_change:"Variable",approval:"Approval",audit:"Audit"};function he({isOpen:r,onClose:s}){const[n,B]=g.useState("triggers"),[T,M]=g.useState([]),[y,x]=g.useState(!0),[_,j]=g.useState(null),[C,N]=g.useState("24h"),[R,$]=g.useState(""),[W,E]=g.useState(null),[m,p]=g.useState({}),[i,z]=g.useState(!1),[t,c]=g.useState(null),[d,b]=g.useState([]),l=g.useCallback(async()=>{if(!(n==="stats"||n==="instances")){x(!0);try{const o=Date.now(),h={"1h":36e5,"6h":216e5,"24h":864e5,"7d":6048e5,all:0},w=h[C]>0?String(o-h[C]):void 0;let k=[];if(n==="triggers"){const v=new URLSearchParams({limit:"200"});w&&v.set("since",w);const S=await D(O(`/api/events/triggers?${v}`));if(!S.ok){j(`HTTP ${S.status}`);return}k=((await S.json()).events||[]).map(F=>({type:"trigger",timestamp:F.firedAt,data:F}))}else if(n==="workflows"){const v=new URLSearchParams({limit:"200",category:"workflow"});w&&v.set("since",w);const S=await D(O(`/api/events/audit?${v}`));if(!S.ok){j(`HTTP ${S.status}`);return}k=((await S.json()).entries||[]).map(F=>({type:"workflow",timestamp:F.createdAt,data:F}))}else if(n==="messages"){const v=new URLSearchParams({limit:"200"}),S=new URLSearchParams({limit:"200"}),H=new URLSearchParams({limit:"200"});w&&(v.set("since",w),S.set("since",w));const[F,K,X]=await Promise.all([D(O(`/api/events/slack?${v}`)),D(O(`/api/events/email?${S}`)),D(O(`/api/events/approvals?${H}`))]);if(F.ok){const P=await F.json();for(const I of P.messages||[])k.push({type:"slack",timestamp:I.receivedAt,data:I})}if(K.ok){const P=await K.json();for(const I of P.messages||[])k.push({type:"email",timestamp:I.receivedAt,data:I})}if(X.ok){const P=await X.json();for(const I of P.events||[])k.push({type:"approval",timestamp:I.recordedAt,data:I})}k.sort((P,I)=>I.timestamp-P.timestamp)}M(k),j(null)}catch(o){j(`Failed to load events: ${o}`)}finally{x(!1)}}},[n,C]),f=g.useCallback(async()=>{x(!0);try{const[o,h]=await Promise.all([D(O("/api/events/stats")),D(O("/api/integrations"))]);if(o.ok&&c(await o.json()),h.ok){const w=await h.json();b(Array.isArray(w)?w:[])}j(null)}catch(o){j(`Failed to load stats: ${o}`)}finally{x(!1)}},[]);g.useEffect(()=>{r&&(n==="stats"?f():l())},[r,n,l,f]);const u=T.filter(o=>{if(!R)return!0;const h=R.toLowerCase();return JSON.stringify(o.data).toLowerCase().includes(h)});if(!r)return null;const A=d.filter(o=>o.status.connected).length;return e.jsx("div",{style:a.overlay,onClick:s,children:e.jsxs("div",{style:a.modal,onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{style:a.header,children:[e.jsxs("div",{style:a.headerTitle,children:[e.jsx("span",{children:"📊"}),e.jsx("span",{children:"Monitoring & Logs"})]}),e.jsx("button",{style:a.closeBtn,onClick:s,title:"Close",children:"×"})]}),e.jsx("div",{style:a.tabs,children:se.map(o=>e.jsxs("button",{style:a.tab(n===o.id),onClick:()=>{B(o.id),$(""),E(null)},children:[e.jsx("span",{children:o.icon}),e.jsx("span",{children:o.label})]},o.id))}),n!=="stats"&&n!=="instances"&&e.jsxs("div",{style:a.filters,children:[e.jsx("div",{style:{display:"flex",gap:4},children:["1h","6h","24h","7d","all"].map(o=>e.jsx("button",{style:{...a.timeBtn,background:C===o?"#89b4fa":"transparent",color:C===o?"#1e1e2e":"#a6adc8"},onClick:()=>N(o),children:o},o))}),e.jsx("input",{style:a.searchInput,placeholder:"Search events...",value:R,onChange:o=>$(o.target.value)}),e.jsx("button",{style:a.refreshBtn,onClick:l,children:"Refresh"})]}),e.jsx("div",{style:a.content,children:n==="stats"?e.jsx(oe,{loading:y,error:_,stats:t,integrations:d,connectedCount:A,onRefresh:f}):n==="instances"?e.jsx(ce,{}):e.jsx(re,{loading:y,error:_,entries:u,expandedId:W,matcherResults:m,loadingMatchers:i,onToggleExpand:async(o,h)=>{var w;if(W===o){E(null);return}if(E(o),!m[o]){z(!0);try{let k="";if((h==null?void 0:h.type)==="trigger"&&((w=h==null?void 0:h.data)!=null&&w.id))k=`/api/triggers/events/${h.data.id}/matchers`;else if(h&&["slack","email","approval"].includes(h.type)){const v=h.data,S=v.ts||v.messageId||v.email_id;S&&h.type&&(k=`/api/triggers/matchers/by-source/${h.type}/${encodeURIComponent(S)}`)}if(k){const v=await D(O(k));if(v.ok){const S=await v.json();p(H=>({...H,[o]:S.matchers||[]}))}}}catch(k){console.error("Failed to fetch matchers:",k)}finally{z(!1)}}}})}),n!=="stats"&&n!=="instances"&&e.jsx("div",{style:a.footer,children:e.jsxs("span",{style:{color:"#6c7086",fontSize:11},children:[u.length," event",u.length!==1?"s":""," shown",R&&` (filtered from ${T.length})`]})})]})})}function re({loading:r,error:s,entries:n,expandedId:B,matcherResults:T,loadingMatchers:M,onToggleExpand:y}){return r?e.jsx("div",{style:{color:"#a6adc8",padding:20},children:"Loading events..."}):s?e.jsx("div",{style:{color:"#f38ba8",padding:20},children:s}):n.length===0?e.jsx("div",{style:{color:"#6c7086",textAlign:"center",padding:40},children:"No events found for the selected filters."}):e.jsx(e.Fragment,{children:n.map((x,_)=>{var W;const j=`${x.type}-${x.timestamp}-${_}`,C=B===j,N=ae[x.type]||"#6c7086",R=ie(x),$=new Date(x.timestamp);return e.jsxs("div",{style:{...a.eventRow,borderLeft:`3px solid ${N}`,background:C?"rgba(137,180,250,0.05)":"transparent"},onClick:()=>y(j,x),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{...a.tag,background:`${N}22`,color:N},children:ne[x.type]||x.type}),e.jsx("span",{style:{color:"#cdd6f4",fontSize:12,flex:1},children:R}),e.jsxs("span",{style:{color:"#6c7086",fontSize:10,whiteSpace:"nowrap"},children:[$.toLocaleTimeString()," ",$.toLocaleDateString()]})]}),C&&e.jsxs(e.Fragment,{children:[e.jsx("pre",{style:a.detail,children:JSON.stringify(x.data,null,2)}),T[j]&&e.jsxs("div",{style:{marginTop:12,borderTop:"1px solid #313244",paddingTop:12},children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:.5,marginBottom:8},children:x.type==="trigger"?"Matcher Results":"Trigger Evaluations"}),M?e.jsx("div",{style:{color:"#6c7086",fontSize:12},children:"Loading matchers..."}):((W=T[j])==null?void 0:W.length)===0?e.jsx("div",{style:{color:"#6c7086",fontSize:12},children:"No matchers evaluated"}):(()=>{const E=T[j];if(x.type!=="trigger"){const m=new Map;for(const p of E){const i=String(p.trigger_id||"unknown");m.has(i)||m.set(i,[]),m.get(i).push(p)}return Array.from(m.entries()).map(([p,i])=>{var z;return e.jsxs("div",{style:{marginBottom:12},children:[e.jsxs("div",{style:{color:"#cdd6f4",fontSize:11,fontWeight:500,marginBottom:6,paddingBottom:4,borderBottom:"1px solid #45475a"},children:["Trigger: ",String(((z=i[0])==null?void 0:z.trigger_name)||p)]}),i.map((t,c)=>{const d=t.matched===1||t.matched===!0,b=d?"#a6e3a1":"#f38ba8",l=t.confidence??null,f=String(t.matcher_name||"unknown"),u=t.reason?String(t.reason):"";return e.jsxs("div",{style:{display:"flex",gap:8,padding:"6px 10px",background:"#313244",borderRadius:4,marginBottom:4,fontSize:11},children:[e.jsx("span",{style:{color:b,fontWeight:600,minWidth:50},children:d?"✓":"✗"}),e.jsx("span",{style:{color:"#cdd6f4",flex:1},children:f}),l!==null&&e.jsxs("span",{style:{color:"#a6adc8"},children:["(",(l*100).toFixed(0),"%)"]}),u&&e.jsx("span",{style:{color:"#6c7086",fontSize:10},children:u})]},c)})]},p)})}else return E.map((m,p)=>{const i=m.matched===1||m.matched===!0,z=i?"#a6e3a1":"#f38ba8",t=m.confidence??null,c=String(m.matcher_name||"unknown"),d=m.reason?String(m.reason):"";return e.jsxs("div",{style:{display:"flex",gap:8,padding:"6px 10px",background:"#313244",borderRadius:4,marginBottom:4,fontSize:11},children:[e.jsx("span",{style:{color:z,fontWeight:600,minWidth:50},children:i?"✓ MATCH":"✗ FAIL"}),e.jsx("span",{style:{color:"#cdd6f4",flex:1},children:c}),t!==null&&e.jsxs("span",{style:{color:"#a6adc8"},children:["(",(t*100).toFixed(0),"%)"]}),d&&e.jsx("span",{style:{color:"#6c7086",fontSize:10},children:d})]},p)})})()]})]})]},j)})})}function oe({loading:r,error:s,stats:n,integrations:B,connectedCount:T,onRefresh:M}){return r?e.jsx("div",{style:{color:"#a6adc8",padding:20},children:"Loading stats..."}):s?e.jsx("div",{style:{color:"#f38ba8",padding:20},children:s}):e.jsxs("div",{style:{padding:20},children:[e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:16},children:e.jsx("button",{style:a.refreshBtn,onClick:M,children:"Refresh"})}),n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:a.section,children:[e.jsx("h3",{style:a.sectionTitle,children:"Workflows"}),e.jsxs("div",{style:a.grid,children:[e.jsx(U,{label:"Active",value:n.activeWorkflows,color:"#89b4fa"}),e.jsx(U,{label:"Completed",value:n.completedWorkflows,color:"#a6e3a1"}),e.jsx(U,{label:"Failed",value:n.failedWorkflows,color:"#f38ba8"})]})]}),e.jsxs("div",{style:a.section,children:[e.jsx("h3",{style:a.sectionTitle,children:"Events (Today)"}),e.jsxs("div",{style:a.grid,children:[e.jsx(U,{label:"Triggers Fired",value:n.triggersFiredToday,color:"#f9e2af"}),e.jsx(U,{label:"Slack Messages",value:n.slackMessageCount,color:"#cba6f7"}),e.jsx(U,{label:"Emails",value:n.emailCount,color:"#fab387"})]})]}),e.jsxs("div",{style:a.section,children:[e.jsxs("h3",{style:a.sectionTitle,children:["Integrations (",T,"/",B.length," connected)"]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[B.map(y=>e.jsxs("div",{style:a.integrationRow,children:[e.jsx("span",{style:{color:"#cdd6f4",fontSize:13},children:y.name}),e.jsx("span",{style:{...a.statusBadge,background:y.status.connected?"rgba(166,227,161,0.15)":"rgba(108,112,134,0.15)",color:y.status.connected?"#a6e3a1":"#6c7086"},children:y.status.error?"Error":y.status.connected?"Connected":"Disconnected"})]},y.id)),B.length===0&&e.jsx("div",{style:{color:"#6c7086",fontSize:12},children:"No integrations configured"})]})]})]}),!n&&e.jsx("div",{style:{color:"#6c7086",textAlign:"center",padding:40},children:"No stats available. The event store may not have any data yet."})]})}function U({label:r,value:s,color:n}){return e.jsxs("div",{style:a.card,children:[e.jsx("div",{style:{color:n,fontSize:28,fontWeight:700,lineHeight:1},children:s}),e.jsx("div",{style:{color:"#a6adc8",fontSize:11,marginTop:4},children:r})]})}function ie(r){const s=r.data;switch(r.type){case"trigger":return`Trigger "${s.triggerName||s.triggerId}" ${s.status||"fired"}`;case"slack":return`${s.direction==="outbound"?"Sent":"Received"} in #${s.channelName||s.channelId}: ${Y(s.text,60)}`;case"email":return`${s.direction==="outbound"?"Sent to":"From"} ${s.direction==="outbound"?s.toAddresses:s.fromAddress}: ${Y(s.subject,50)}`;case"approval":return`${s.approved?"Approved":"Rejected"} by ${s.approverEmail}`;case"document":return`Generated "${s.outputFilename}" from template "${s.templateName}"`;case"calendar":return`Calendar event ${s.action}: "${s.summary}"`;case"jira":return`${s.ticketKey} ${s.action}: ${Y(s.summary,50)}`;case"step":return`Workflow step: ${s.toStateName} (${s.status})`;case"variable_change":return`Variable "${s.variableName}" changed by ${s.changedBy}`;case"audit":return`[${(s.level||"info").toUpperCase()}] ${s.category}: ${s.action}`;default:return JSON.stringify(s).slice(0,80)}}function Y(r,s){return r?r.length>s?r.slice(0,s)+"...":r:""}const V={running:"#a6e3a1",paused:"#f9e2af",completed:"#89b4fa",failed:"#f38ba8",cancelled:"#6c7086"},q={action:"#89b4fa",wait:"#f9e2af",decision:"#cba6f7",end:"#6c7086"};let G=null,Q,Z;function ee(){const r=te.getState(),s=r.workflowDefinitions??new Map,n=r.workflowInstances??new Map;return G&&Q===s&&Z===n||(Q=s,Z=n,G={definitions:s,instances:n}),G}function le(){return g.useSyncExternalStore(r=>te.subscribe(r),ee,ee)}function ce(){var z;const{definitions:r,instances:s}=le(),[n,B]=g.useState("all"),[T,M]=g.useState("all"),[y,x]=g.useState(""),[_,j]=g.useState(null),[C,N]=g.useState(null),[R,$]=g.useState(null),W=g.useMemo(()=>Array.from(s.values()),[s]),E=g.useMemo(()=>Array.from(r.values()),[r]),m=g.useMemo(()=>W.filter(t=>{if(n!=="all"&&t.status!==n||T!=="all"&&t.workflowDefId!==T)return!1;if(y){const c=y.toLowerCase();return t.workflowName.toLowerCase().includes(c)||t.id.toLowerCase().includes(c)||JSON.stringify(t.variables).toLowerCase().includes(c)}return!0}).sort((t,c)=>c.updatedAt-t.updatedAt),[W,n,T,y]),p=_?s.get(_):null,i=R?s.get(R):null;if(i){const t=r.get(i.workflowDefId),c=t==null?void 0:t.states.find(f=>f.id===i.currentStateId),d=V[i.status]||"#6c7086",b={},l={};for(const[f,u]of Object.entries(i.variables))f.startsWith("wi_")?b[f]=u:l[f]=u;return e.jsxs("div",{style:{padding:"12px 0"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[e.jsx("button",{style:{...a.refreshBtn,fontSize:12},onClick:()=>$(null),children:"Back"}),e.jsxs("span",{style:{color:"#cdd6f4",fontSize:13,fontWeight:500},children:["Debug: ",i.workflowName]}),e.jsx("span",{style:{...a.tag,background:`${d}22`,color:d},children:i.status})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:8,marginBottom:16},children:[e.jsx(L,{label:"ID",value:i.id}),e.jsx(L,{label:"Def ID",value:i.workflowDefId}),e.jsx(L,{label:"Current State",value:(c==null?void 0:c.name)||i.currentStateId}),e.jsx(L,{label:"State Type",value:(c==null?void 0:c.type)||"unknown"}),e.jsx(L,{label:"Created",value:J(i.createdAt)}),e.jsx(L,{label:"Updated",value:J(i.updatedAt)}),i.completedAt&&e.jsx(L,{label:"Completed",value:J(i.completedAt)}),i.error&&e.jsx(L,{label:"Error",value:i.error,color:"#f38ba8"}),e.jsx(L,{label:"Steps",value:String(((z=i.history)==null?void 0:z.length)??0)})]}),Object.keys(l).length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:1,marginBottom:6},children:"User Variables"}),e.jsx("pre",{style:a.detail,children:JSON.stringify(l,null,2)})]}),Object.keys(b).length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:1,marginBottom:6},children:"Internal Variables (wi_*)"}),e.jsx("pre",{style:a.detail,children:JSON.stringify(b,null,2)})]}),c&&c.transitions.length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:1,marginBottom:6},children:"Available Transitions"}),c.transitions.map(f=>{var u;return e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"4px 10px",background:"#313244",borderRadius:4,marginBottom:4},children:[e.jsx("span",{style:{color:"#cdd6f4",fontSize:12},children:f.name}),e.jsxs("span",{style:{color:"#6c7086",fontSize:10},children:[f.condition.type," → ",((u=t==null?void 0:t.states.find(A=>A.id===f.targetStateId))==null?void 0:u.name)||f.targetStateId]})]},f.id)})]}),e.jsxs("div",{children:[e.jsx("div",{style:{color:"#a6adc8",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:1,marginBottom:6},children:"Raw JSON"}),e.jsx("pre",{style:{...a.detail,maxHeight:400},children:JSON.stringify(i,null,2)})]})]})}if(p){const t=r.get(p.workflowDefId),c=V[p.status]||"#6c7086";return e.jsxs("div",{style:{padding:"12px 0"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx("button",{style:{...a.refreshBtn,fontSize:12},onClick:()=>{j(null),N(null)},children:"Back"}),e.jsx("span",{style:{color:"#cdd6f4",fontSize:13,fontWeight:500},children:p.workflowName}),e.jsxs("span",{style:{color:"#6c7086",fontSize:10,fontFamily:"monospace"},children:["(",p.id.slice(0,8),")"]}),e.jsx("span",{style:{...a.tag,background:`${c}22`,color:c},children:p.status}),e.jsx("div",{style:{flex:1}}),e.jsx("button",{style:{...a.refreshBtn,fontFamily:"monospace",fontSize:10},onClick:()=>$(p.id),children:"{..}"})]}),e.jsxs("div",{style:{display:"flex",gap:16,color:"#6c7086",fontSize:11,marginBottom:12},children:[e.jsxs("span",{children:["Created: ",J(p.createdAt)]}),e.jsxs("span",{children:["Updated: ",J(p.updatedAt)]}),p.error&&e.jsxs("span",{style:{color:"#f38ba8"},children:["Error: ",p.error]})]}),e.jsxs("div",{style:{color:"#a6adc8",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:1,marginBottom:8},children:["Timeline (",p.history.length," step",p.history.length!==1?"s":"",")"]}),p.history.length===0&&e.jsx("div",{style:{color:"#6c7086",fontSize:12,padding:16},children:"No steps recorded yet."}),p.history.map((d,b)=>{const l=t==null?void 0:t.states.find(A=>A.id===d.toStateId),f=C===b,u=l&&q[l.type]||"#6c7086";return e.jsxs("div",{style:{padding:"10px 12px",borderLeft:`3px solid ${u}`,borderBottom:"1px solid #313244",cursor:"pointer",background:f?"rgba(137,180,250,0.05)":"transparent",marginLeft:8},onClick:()=>N(f?null:b),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:u,flexShrink:0}}),e.jsx("span",{style:{color:"#cdd6f4",fontSize:12,fontWeight:500},children:(l==null?void 0:l.name)||d.toStateId}),l&&e.jsx("span",{style:{...a.tag,background:`${u}22`,color:u},children:l.type}),d.transitionName&&e.jsxs("span",{style:{color:"#6c7086",fontSize:10},children:['via "',d.transitionName,'"']}),e.jsx("div",{style:{flex:1}}),e.jsx("span",{style:{color:"#6c7086",fontSize:10,whiteSpace:"nowrap"},children:J(d.timestamp)})]}),f&&e.jsxs("div",{style:{marginTop:8,paddingLeft:20},children:[d.fromStateId&&e.jsxs("div",{style:{color:"#6c7086",fontSize:11,marginBottom:2},children:[e.jsx("span",{style:{fontWeight:600,fontSize:10,textTransform:"uppercase"},children:"From: "}),e.jsx("span",{style:{fontFamily:"monospace"},children:d.fromStateId})]}),d.details&&e.jsxs("div",{style:{marginTop:6},children:[e.jsx("div",{style:{color:"#6c7086",fontSize:10,fontWeight:600,textTransform:"uppercase",marginBottom:4},children:"Agent Reasoning / Summary"}),e.jsx("div",{style:{padding:10,background:"#181825",borderRadius:6,border:"1px solid #313244",fontSize:12,color:"#cdd6f4",lineHeight:1.5,whiteSpace:"pre-wrap"},children:d.details})]}),(l==null?void 0:l.description)&&e.jsxs("div",{style:{marginTop:6,color:"#a6adc8",fontSize:11},children:[e.jsx("span",{style:{color:"#6c7086",fontWeight:600,fontSize:10,textTransform:"uppercase"},children:"Description: "}),l.description]}),d.variables&&Object.keys(d.variables).length>0&&e.jsxs("div",{style:{marginTop:6},children:[e.jsx("div",{style:{color:"#6c7086",fontSize:10,fontWeight:600,textTransform:"uppercase",marginBottom:4},children:"Variables at this step"}),e.jsx("pre",{style:a.detail,children:JSON.stringify(d.variables,null,2)})]}),(l==null?void 0:l.action)&&e.jsxs("div",{style:{marginTop:6},children:[e.jsxs("div",{style:{color:"#6c7086",fontSize:10,fontWeight:600,textTransform:"uppercase",marginBottom:4},children:["Action (",l.action.type,")"]}),e.jsx("pre",{style:a.detail,children:JSON.stringify(l.action,null,2)})]})]})]},b)})]})}return e.jsxs("div",{style:{padding:"12px 0"},children:[e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",marginBottom:12,flexWrap:"wrap"},children:[e.jsxs("select",{style:{background:"#313244",border:"1px solid #45475a",borderRadius:6,padding:"5px 10px",color:"#cdd6f4",fontSize:12,outline:"none"},value:T,onChange:t=>M(t.target.value),children:[e.jsx("option",{value:"all",children:"All Workflows"}),E.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsx("div",{style:{display:"flex",gap:4},children:["all","running","paused","completed","failed","cancelled"].map(t=>e.jsx("button",{style:{...a.timeBtn,background:n===t?t==="all"?"#89b4fa":V[t]||"#89b4fa":"transparent",color:n===t?"#1e1e2e":"#a6adc8",borderColor:n===t?"transparent":"#45475a",textTransform:"capitalize"},onClick:()=>B(t),children:t},t))}),e.jsx("input",{style:a.searchInput,placeholder:"Search instances...",value:y,onChange:t=>x(t.target.value)}),e.jsxs("span",{style:{color:"#6c7086",fontSize:11},children:[m.length,"/",W.length]})]}),m.length===0?e.jsx("div",{style:{color:"#6c7086",textAlign:"center",padding:40},children:"No workflow instances found."}):m.map(t=>{var f,u;const c=r.get(t.workflowDefId),d=V[t.status]||"#6c7086",b=c==null?void 0:c.states.find(A=>A.id===t.currentStateId),l=b&&q[b.type]||"#6c7086";return e.jsxs("div",{style:{...a.eventRow,display:"flex",alignItems:"center",gap:12,borderLeft:`3px solid ${d}`},onClick:()=>j(t.id),children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{color:"#cdd6f4",fontSize:13,fontWeight:500},children:t.workflowName}),e.jsx("span",{style:{...a.tag,background:`${d}22`,color:d},children:t.status})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:2},children:[e.jsx("span",{style:{color:"#6c7086",fontSize:10,fontFamily:"monospace"},children:t.id.slice(0,8)}),b&&e.jsxs("span",{style:{color:l,fontSize:10},children:["@ ",b.name]}),e.jsxs("span",{style:{color:"#45475a",fontSize:10},children:[((f=t.history)==null?void 0:f.length)??0," step",(((u=t.history)==null?void 0:u.length)??0)!==1?"s":""]})]})]}),e.jsx("span",{style:{color:"#6c7086",fontSize:10,whiteSpace:"nowrap"},children:de(t.updatedAt)}),e.jsx("button",{style:{background:"transparent",border:"1px solid #45475a",borderRadius:4,padding:"3px 6px",color:"#6c7086",fontSize:10,fontFamily:"monospace",cursor:"pointer"},onClick:A=>{A.stopPropagation(),$(t.id)},title:"Debug view",children:"{..}"})]},t.id)})]})}function L({label:r,value:s,color:n}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2,padding:"8px 10px",background:"#313244",borderRadius:6},children:[e.jsx("span",{style:{color:"#6c7086",fontSize:10,textTransform:"uppercase",letterSpacing:.5},children:r}),e.jsx("span",{style:{color:n||"#cdd6f4",fontSize:12,fontFamily:"monospace",wordBreak:"break-all"},children:s})]})}function de(r){return new Date(r).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function J(r){const s=new Date(r);return`${s.toLocaleDateString()} ${s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}`}const a={overlay:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4,backdropFilter:"blur(4px)"},modal:{background:"var(--surface-0, #1e1e2e)",borderRadius:12,border:"1px solid var(--border, #313244)",width:"90vw",maxWidth:1e3,height:"85vh",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 20px 60px rgba(0, 0, 0, 0.5)"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid var(--border, #313244)",background:"var(--surface-1, #181825)"},headerTitle:{fontSize:16,fontWeight:600,color:"var(--text-primary, #cdd6f4)",display:"flex",alignItems:"center",gap:8},closeBtn:{background:"none",border:"none",color:"var(--text-secondary, #a6adc8)",fontSize:20,cursor:"pointer",padding:"4px 8px",borderRadius:6,lineHeight:1},tabs:{display:"flex",borderBottom:"1px solid var(--border, #313244)",background:"var(--surface-1, #181825)",overflowX:"auto",scrollbarWidth:"none"},tab:r=>({padding:"10px 16px",background:"none",border:"none",borderBottom:r?"2px solid var(--accent, #89b4fa)":"2px solid transparent",color:r?"var(--accent, #89b4fa)":"var(--text-secondary, #a6adc8)",fontSize:13,fontWeight:r?600:400,cursor:"pointer",display:"flex",alignItems:"center",gap:6,whiteSpace:"nowrap",transition:"color 0.15s, border-color 0.15s",flexShrink:0}),filters:{display:"flex",gap:8,alignItems:"center",padding:"10px 20px",borderBottom:"1px solid var(--border, #313244)",flexWrap:"wrap"},timeBtn:{border:"1px solid #45475a",borderRadius:4,padding:"4px 8px",fontSize:10,fontWeight:600,cursor:"pointer"},searchInput:{background:"#313244",border:"1px solid #45475a",borderRadius:6,padding:"5px 10px",color:"#cdd6f4",fontSize:12,flex:1,minWidth:120,outline:"none"},refreshBtn:{background:"transparent",border:"1px solid #45475a",borderRadius:6,padding:"5px 12px",color:"#a6adc8",fontSize:11,cursor:"pointer"},content:{flex:1,overflow:"auto",padding:"0 20px"},eventRow:{padding:"8px 12px",borderBottom:"1px solid #313244",cursor:"pointer",transition:"background 0.1s"},tag:{fontSize:10,fontWeight:600,padding:"2px 6px",borderRadius:4,whiteSpace:"nowrap"},detail:{marginTop:8,padding:10,background:"#181825",borderRadius:6,fontSize:11,fontFamily:"monospace",color:"#a6adc8",overflow:"auto",maxHeight:300,whiteSpace:"pre-wrap",wordBreak:"break-all"},footer:{padding:"8px 20px",borderTop:"1px solid #313244"},section:{marginBottom:24},sectionTitle:{color:"#a6adc8",fontSize:12,fontWeight:600,textTransform:"uppercase",letterSpacing:1,marginBottom:12,margin:0},grid:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:12},card:{background:"#313244",borderRadius:8,padding:"16px 14px",textAlign:"center"},integrationRow:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 12px",background:"#313244",borderRadius:6},statusBadge:{fontSize:10,fontWeight:600,padding:"3px 8px",borderRadius:4}};export{he as MonitoringModal};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{u as L,f as d,r as m,s as o,j as x}from"./main-
|
|
1
|
+
import{u as L,f as d,r as m,s as o,j as x}from"./main-D3GShQ8B.js";import{L as S}from"./LogViewerModal-4do7lATm.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function $({building:t,isOpen:e,onClose:n}){var a;const{t:i}=L(["terminal"]),{streamingBuildingLogs:p,streamingBuildingIds:c}=d(),r=p.get(t.id)||"",g=c.has(t.id);m.useEffect(()=>{var s;return e&&((s=t.pm2)!=null&&s.enabled)&&o.startLogStreaming(t.id,200),()=>{t.id&&o.stopLogStreaming(t.id)}},[e,t.id,(a=t.pm2)==null?void 0:a.enabled]);const f=m.useMemo(()=>r.split(`
|
|
2
2
|
`).map((s,l)=>({text:s,lineNumber:l+1})),[r]);return x.jsx(S,{isOpen:e,onClose:n,title:`${t.name} - ${i("terminal:logs.pm2Logs")}`,icon:"📄",lines:f,isStreaming:g,onClear:()=>o.clearStreamingLogs(t.id)})}export{$ as PM2LogsModal};
|