morpheus-cli 0.9.23 → 0.9.30
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/channels/telegram.js +165 -120
- package/dist/cli/commands/restart.js +27 -0
- package/dist/cli/commands/start.js +9 -9
- package/dist/config/manager.js +34 -2
- package/dist/config/paths.js +2 -0
- package/dist/config/schemas.js +6 -0
- package/dist/http/webhooks-router.js +12 -6
- package/dist/runtime/__tests__/gws-sync.test.js +69 -0
- package/dist/runtime/gws-sync.js +102 -0
- package/dist/runtime/hash-utils.js +15 -0
- package/dist/runtime/hot-reload.js +5 -1
- package/dist/runtime/oracle.js +1 -0
- package/dist/runtime/scaffold.js +4 -0
- package/dist/runtime/skills/loader.js +7 -52
- package/dist/runtime/skills/registry.js +5 -1
- package/dist/runtime/skills/schema.js +1 -1
- package/dist/runtime/skills/tool.js +8 -1
- package/dist/runtime/subagents/apoc.js +154 -1
- package/dist/runtime/subagents/devkit-instrument.js +13 -0
- package/dist/runtime/webhooks/dispatcher.js +12 -4
- package/dist/runtime/webhooks/repository.js +17 -6
- package/dist/types/config.js +3 -0
- package/dist/ui/assets/{AuditDashboard-ClqEr7jg.js → AuditDashboard-tH9QZTl4.js} +1 -1
- package/dist/ui/assets/{Chat-BwxZJphx.js → Chat-Cd0uYF8g.js} +1 -1
- package/dist/ui/assets/{Chronos-BafOMteb.js → Chronos-CWwHYdBl.js} +1 -1
- package/dist/ui/assets/{ConfirmationModal-DU0AwhXD.js → ConfirmationModal-CxvFe-We.js} +1 -1
- package/dist/ui/assets/{Dashboard-DvJb72Xe.js → Dashboard-CNNMxl53.js} +1 -1
- package/dist/ui/assets/{DeleteConfirmationModal-FSWLK6-I.js → DeleteConfirmationModal-AqGQSh1X.js} +1 -1
- package/dist/ui/assets/{Documents-D73CeGkW.js → Documents-BfRYOK88.js} +1 -1
- package/dist/ui/assets/{Logs-BrFWnLIL.js → Logs-DhFo4cio.js} +1 -1
- package/dist/ui/assets/{MCPManager-_L2Yo-uY.js → MCPManager-BMhxbhni.js} +1 -1
- package/dist/ui/assets/{ModelPricing-CyXMdxJD.js → ModelPricing-Dvl0R_HR.js} +1 -1
- package/dist/ui/assets/{Notifications-BpHokTLS.js → Notifications-CawvBid4.js} +1 -1
- package/dist/ui/assets/{SatiMemories-CfSTgr9V.js → SatiMemories-yyVrJGdc.js} +1 -1
- package/dist/ui/assets/{SessionAudit-pOWRgJtc.js → SessionAudit-joq0ntdJ.js} +1 -1
- package/dist/ui/assets/{Settings-CPDXAk18.js → Settings-B6SMPn41.js} +7 -7
- package/dist/ui/assets/{Skills-GIkCxMS3.js → Skills-B5yhTHyn.js} +1 -1
- package/dist/ui/assets/{Smiths-ZcHXcrMt.js → Smiths-Dug63YED.js} +1 -1
- package/dist/ui/assets/{Tasks-DJ6R3d4f.js → Tasks-D8HPLkg0.js} +1 -1
- package/dist/ui/assets/{TrinityDatabases-CnRAkDuu.js → TrinityDatabases-D0qEKmwJ.js} +1 -1
- package/dist/ui/assets/{UsageStats-Bl7bs4ay.js → UsageStats-CHWALN70.js} +1 -1
- package/dist/ui/assets/WebhookManager-T2ef90p8.js +4 -0
- package/dist/ui/assets/{agents-DO69pNM1.js → agents-BVnfnJ1X.js} +1 -1
- package/dist/ui/assets/{audit-CP5fC4m8.js → audit-BErc_ye8.js} +1 -1
- package/dist/ui/assets/{chronos-DPhK718h.js → chronos-CAv__H3B.js} +1 -1
- package/dist/ui/assets/{config-OLGQFNJL.js → config-CPFW7PTY.js} +1 -1
- package/dist/ui/assets/{index-B9ePr-vB.js → index-BvsF1a9j.js} +2 -2
- package/dist/ui/assets/index-gx__iEcl.css +1 -0
- package/dist/ui/assets/{mcp-BeBznKtK.js → mcp-BaHwY4DW.js} +1 -1
- package/dist/ui/assets/{skills-wEUxSGB3.js → skills-lbjIRO8d.js} +1 -1
- package/dist/ui/assets/{stats-KMbKDMJ-.js → stats-C8KAfpHO.js} +1 -1
- package/dist/ui/assets/{useCurrency-Bgg-7MTE.js → useCurrency-Ch0lsvGj.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/dist/ui/sw.js +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/WebhookManager-CEjjk4tx.js +0 -4
- package/dist/ui/assets/index-D_0tPLCk.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e,m as n}from"./vendor-motion-C3CZ8ZlO.js";import{r as s}from"./vendor-react-DikRIOlj.js";import{u as Z}from"./vendor-utils-BIYveU_1.js";import{s as l}from"./skills-wEUxSGB3.js";import{D as K,j as O,k as V}from"./index-B9ePr-vB.js";import{W as y,am as u,Y as b,a4 as W,J as F,Z as L,U as I,a0 as q,a5 as A,a6 as B,X as H,an as J}from"./vendor-icons-DE7PWdkN.js";const U={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.05}}},g={hidden:{opacity:0,y:8},show:{opacity:1,y:0}};function M({skill:r,onToggle:i,onView:d}){return e.jsxs(n.div,{variants:g,className:`rounded-lg border flex flex-col transition-all ${r.enabled?"border-azure-primary/50 dark:border-matrix-primary bg-white dark:bg-zinc-900 shadow-sm":"border-azure-border dark:border-matrix-primary/30 bg-azure-surface/50 dark:bg-zinc-900 shadow-sm"}`,children:[e.jsxs("div",{className:"p-4 flex items-start gap-3 flex-1",children:[e.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center shrink-0 ${r.enabled?"bg-azure-primary/10 dark:bg-matrix-highlight/10":"bg-azure-surface dark:bg-zinc-900"}`,children:e.jsx(y,{className:`w-4 h-4 ${r.enabled?"text-azure-primary dark:text-matrix-highlight":"text-azure-text-secondary dark:text-matrix-tertiary"}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:`font-semibold truncate ${r.enabled?"text-azure-text dark:text-matrix-highlight":"text-azure-text-secondary dark:text-matrix-secondary"}`,children:r.name}),r.version&&e.jsxs("span",{className:"text-[10px] font-mono text-azure-text-secondary dark:text-matrix-tertiary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 rounded px-1.5 py-0.5 shrink-0",children:["v",r.version]}),!r.enabled&&e.jsx("span",{className:"text-[10px] font-medium text-zinc-400 dark:text-zinc-500 bg-zinc-100 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-700 rounded px-1.5 py-0.5 shrink-0",children:"disabled"})]}),e.jsx("p",{className:`text-sm mt-1.5 line-clamp-2 leading-relaxed ${r.enabled?"text-azure-text-secondary dark:text-matrix-secondary":"text-azure-text-secondary/70 dark:text-matrix-tertiary"}`,children:r.description}),r.tags&&r.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:r.tags.map(t=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-[10px] font-medium rounded border border-azure-primary/20 dark:border-matrix-primary/40 bg-azure-primary/5 dark:bg-matrix-primary/10 text-azure-primary dark:text-matrix-secondary",children:[e.jsx(L,{className:"w-2.5 h-2.5"}),t]},t))})]})]}),e.jsxs("div",{className:"px-4 py-3 border-t border-azure-border dark:border-matrix-primary/30 flex items-center justify-between gap-2",children:[r.author?e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-azure-text-secondary dark:text-matrix-tertiary min-w-0",children:[e.jsx(I,{className:"w-3 h-3 shrink-0"}),e.jsx("span",{className:"truncate",children:r.author})]}):e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:d,className:"p-1.5 rounded border border-azure-border dark:border-matrix-primary/50 text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-primary dark:hover:text-matrix-highlight hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",title:"View details",children:e.jsx(q,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:i,className:`p-1.5 rounded border transition-colors ${r.enabled?"border-emerald-300 dark:border-emerald-700/60 text-emerald-500 dark:text-emerald-400 hover:bg-emerald-50 dark:hover:bg-emerald-900/20":"border-azure-border dark:border-matrix-primary/40 text-zinc-400 dark:text-zinc-600 hover:text-azure-text dark:hover:text-matrix-secondary hover:border-azure-border dark:hover:border-matrix-primary"}`,title:r.enabled?"Disable skill":"Enable skill",children:r.enabled?e.jsx(A,{className:"w-4 h-4"}):e.jsx(B,{className:"w-4 h-4"})})]})]})]})}function X({skill:r,open:i,onOpenChange:d}){return!i||!r?null:e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>d(!1)}),e.jsxs("div",{className:"relative bg-white dark:bg-black border border-azure-border dark:border-matrix-primary rounded-lg shadow-xl w-full max-w-2xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 px-5 py-4 border-b border-azure-border dark:border-matrix-primary shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 flex items-center justify-center shrink-0",children:e.jsx(y,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h2",{className:"text-base font-semibold text-azure-text dark:text-matrix-highlight truncate",children:r.name}),r.version&&e.jsxs("span",{className:"text-[10px] font-mono text-azure-text-secondary dark:text-matrix-tertiary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 rounded px-1.5 py-0.5 shrink-0",children:["v",r.version]})]}),r.author&&e.jsxs("div",{className:"flex items-center gap-1 mt-0.5 text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:[e.jsx(I,{className:"w-3 h-3 shrink-0"}),r.author]})]})]}),e.jsx("button",{onClick:()=>d(!1),className:"p-1.5 rounded text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-highlight hover:bg-azure-surface dark:hover:bg-zinc-900 transition-colors shrink-0",children:e.jsx(H,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"overflow-y-auto flex-1 p-5 space-y-5",children:[r.description&&e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary leading-relaxed",children:r.description}),e.jsx("div",{className:"flex flex-col gap-2",children:e.jsxs("div",{className:"flex items-start gap-2 text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:[e.jsx(J,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),e.jsx("span",{className:"break-all font-mono text-azure-text dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 rounded px-2 py-0.5",children:r.path})]})}),r.tags&&r.tags.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.tags.map(t=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-[10px] font-medium rounded border border-azure-primary/20 dark:border-matrix-primary/40 bg-azure-primary/5 dark:bg-matrix-primary/10 text-azure-primary dark:text-matrix-secondary",children:[e.jsx(L,{className:"w-2.5 h-2.5"}),t]},t))})]}),r.examples&&r.examples.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Examples"}),e.jsx("ul",{className:"space-y-1.5",children:r.examples.map((t,x)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-azure-text-secondary dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/30 rounded px-3 py-2",children:[e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary font-mono text-xs mt-0.5 shrink-0",children:[x+1,"."]}),t]},x))})]}),r.content&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"SKILL.md"}),e.jsx("pre",{className:"rounded-lg bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 p-4 text-xs text-azure-text-secondary dark:text-matrix-secondary overflow-auto max-h-72 whitespace-pre-wrap leading-relaxed font-mono",children:r.content})]})]})]})]})}function ae(){const[r,i]=s.useState(null),[d,t]=s.useState(!1),[x,N]=s.useState(!1),[o,v]=s.useState(!1),[c,k]=s.useState(null),[w,f]=s.useState(null),j=s.useRef(null),{data:S,mutate:z,isLoading:D}=Z("/skills",()=>l.fetchSkills(),{refreshInterval:1e4}),m=S?.skills??[],E=S?.enabled??0,R=async()=>{await l.reloadSkills(),z()},T=async a=>{a.enabled?await l.disableSkill(a.name):await l.enableSkill(a.name),z()},$=async a=>{t(!0);try{const p=await l.fetchSkill(a.name);i(p)}finally{t(!1)}},P=async a=>{const p=a.target.files?.[0];if(p){k(null),f(null),v(!0);try{const h=await l.uploadSkill(p);f(`Skill "${h.skill.name}" uploaded successfully!`),z(),j.current&&(j.current.value="")}catch(h){k({error:h.message||"Upload failed",details:h.details})}finally{v(!1)}}},C=()=>{k(null),f(null),N(!0)};return e.jsxs(n.div,{variants:U,initial:"hidden",animate:"show",className:"space-y-6",children:[e.jsxs(n.div,{variants:g,className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(y,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Skills"}),e.jsxs("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:[m.length," skill",m.length!==1?"s":"",", ",E," enabled"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:C,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-azure-primary dark:border-matrix-primary text-azure-primary dark:text-matrix-primary font-medium hover:bg-azure-primary/10 dark:hover:bg-matrix-primary/10 transition-colors",children:[e.jsx(u,{className:"w-4 h-4"}),"Upload"]}),e.jsxs("button",{onClick:R,className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-azure-primary dark:bg-matrix-primary text-white dark:text-black font-medium hover:opacity-90 transition-opacity",children:[e.jsx(b,{className:"w-4 h-4"}),"Reload"]})]})]}),D?e.jsxs(n.div,{variants:g,className:"text-center py-12",children:[e.jsx(b,{className:"w-8 h-8 animate-spin mx-auto text-azure-text-secondary dark:text-matrix-dim"}),e.jsx("p",{className:"mt-2 text-azure-text-secondary dark:text-matrix-dim",children:"Loading skills..."})]}):m.length===0?e.jsxs(n.div,{variants:g,className:"rounded-lg border border-dashed border-azure-border dark:border-matrix-primary p-8 text-center",children:[e.jsx(y,{className:"w-12 h-12 mx-auto text-azure-text-tertiary dark:text-matrix-dim"}),e.jsx("h3",{className:"mt-4 text-lg font-medium text-azure-text-primary dark:text-matrix-highlight",children:"No skills found"}),e.jsxs("p",{className:"mt-2 text-azure-text-secondary dark:text-matrix-secondary max-w-md mx-auto",children:["Upload a skill ZIP or add skills manually to"," ",e.jsx("code",{className:"bg-azure-hover dark:bg-zinc-800 px-1 rounded",children:"~/.morpheus/skills/"}),". Each skill folder must contain a"," ",e.jsx("code",{className:"bg-azure-hover dark:bg-zinc-800 px-1 rounded",children:"SKILL.md"})," file with frontmatter."]}),e.jsxs("button",{onClick:C,className:"mt-4 inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-azure-primary dark:bg-matrix-primary text-white dark:text-black font-medium hover:opacity-90 transition-opacity",children:[e.jsx(u,{className:"w-4 h-4"}),"Upload Skill"]})]}):e.jsx(n.div,{variants:U,initial:"hidden",animate:"show",className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:m.map(a=>e.jsx(M,{skill:a,onToggle:()=>T(a),onView:()=>$(a)},a.name))}),e.jsx(X,{skill:r,open:!!r,onOpenChange:a=>!a&&i(null)}),e.jsxs(K,{open:x,onOpenChange:N,children:[e.jsx(O,{children:e.jsx(V,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(u,{className:"w-5 h-5"}),"Upload Skill"]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-azure-text-secondary dark:text-matrix-secondary text-sm",children:["Upload a ZIP file containing your skill folder. The ZIP must have exactly one folder at root level with a valid ",e.jsx("code",{className:"bg-azure-hover dark:bg-zinc-800 px-1 rounded",children:"SKILL.md"})," file."]}),e.jsxs("div",{className:"border-2 border-dashed border-azure-border dark:border-matrix-primary rounded-lg p-6",children:[e.jsx("input",{ref:j,type:"file",accept:".zip,application/zip,application/x-zip-compressed",onChange:P,disabled:o,className:"hidden",id:"skill-upload-input"}),e.jsxs("label",{htmlFor:"skill-upload-input",className:`flex flex-col items-center gap-2 cursor-pointer ${o?"opacity-50 cursor-not-allowed":""}`,children:[o?e.jsx(b,{className:"w-8 h-8 animate-spin text-azure-primary dark:text-matrix-primary"}):e.jsx(u,{className:"w-8 h-8 text-azure-text-tertiary dark:text-matrix-dim"}),e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-secondary",children:o?"Uploading...":"Click to select ZIP file"})]})]}),c&&e.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800",children:[e.jsx(W,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-red-800 dark:text-red-200",children:c.error}),c.details&&e.jsx("p",{className:"text-xs text-red-600 dark:text-red-300 mt-1",children:c.details})]})]}),w&&e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800",children:[e.jsx(F,{className:"w-5 h-5 text-green-600 dark:text-green-400"}),e.jsx("p",{className:"text-sm text-green-800 dark:text-green-200",children:w})]}),e.jsxs("div",{className:"rounded-lg bg-azure-hover dark:bg-zinc-900 p-3",children:[e.jsx("h4",{className:"text-sm font-medium text-azure-text-primary dark:text-matrix-highlight mb-2",children:"ZIP Structure Example"}),e.jsx("pre",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:`my-skill.zip
|
|
1
|
+
import{j as e,m as n}from"./vendor-motion-C3CZ8ZlO.js";import{r as s}from"./vendor-react-DikRIOlj.js";import{u as Z}from"./vendor-utils-BIYveU_1.js";import{s as l}from"./skills-lbjIRO8d.js";import{D as K,j as O,k as V}from"./index-BvsF1a9j.js";import{W as y,am as u,Y as b,a4 as W,J as F,Z as L,U as I,a0 as q,a5 as A,a6 as B,X as H,an as J}from"./vendor-icons-DE7PWdkN.js";const U={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.05}}},g={hidden:{opacity:0,y:8},show:{opacity:1,y:0}};function M({skill:r,onToggle:i,onView:d}){return e.jsxs(n.div,{variants:g,className:`rounded-lg border flex flex-col transition-all ${r.enabled?"border-azure-primary/50 dark:border-matrix-primary bg-white dark:bg-zinc-900 shadow-sm":"border-azure-border dark:border-matrix-primary/30 bg-azure-surface/50 dark:bg-zinc-900 shadow-sm"}`,children:[e.jsxs("div",{className:"p-4 flex items-start gap-3 flex-1",children:[e.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center shrink-0 ${r.enabled?"bg-azure-primary/10 dark:bg-matrix-highlight/10":"bg-azure-surface dark:bg-zinc-900"}`,children:e.jsx(y,{className:`w-4 h-4 ${r.enabled?"text-azure-primary dark:text-matrix-highlight":"text-azure-text-secondary dark:text-matrix-tertiary"}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:`font-semibold truncate ${r.enabled?"text-azure-text dark:text-matrix-highlight":"text-azure-text-secondary dark:text-matrix-secondary"}`,children:r.name}),r.version&&e.jsxs("span",{className:"text-[10px] font-mono text-azure-text-secondary dark:text-matrix-tertiary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 rounded px-1.5 py-0.5 shrink-0",children:["v",r.version]}),!r.enabled&&e.jsx("span",{className:"text-[10px] font-medium text-zinc-400 dark:text-zinc-500 bg-zinc-100 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-700 rounded px-1.5 py-0.5 shrink-0",children:"disabled"})]}),e.jsx("p",{className:`text-sm mt-1.5 line-clamp-2 leading-relaxed ${r.enabled?"text-azure-text-secondary dark:text-matrix-secondary":"text-azure-text-secondary/70 dark:text-matrix-tertiary"}`,children:r.description}),r.tags&&r.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:r.tags.map(t=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-[10px] font-medium rounded border border-azure-primary/20 dark:border-matrix-primary/40 bg-azure-primary/5 dark:bg-matrix-primary/10 text-azure-primary dark:text-matrix-secondary",children:[e.jsx(L,{className:"w-2.5 h-2.5"}),t]},t))})]})]}),e.jsxs("div",{className:"px-4 py-3 border-t border-azure-border dark:border-matrix-primary/30 flex items-center justify-between gap-2",children:[r.author?e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-azure-text-secondary dark:text-matrix-tertiary min-w-0",children:[e.jsx(I,{className:"w-3 h-3 shrink-0"}),e.jsx("span",{className:"truncate",children:r.author})]}):e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:d,className:"p-1.5 rounded border border-azure-border dark:border-matrix-primary/50 text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-primary dark:hover:text-matrix-highlight hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",title:"View details",children:e.jsx(q,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:i,className:`p-1.5 rounded border transition-colors ${r.enabled?"border-emerald-300 dark:border-emerald-700/60 text-emerald-500 dark:text-emerald-400 hover:bg-emerald-50 dark:hover:bg-emerald-900/20":"border-azure-border dark:border-matrix-primary/40 text-zinc-400 dark:text-zinc-600 hover:text-azure-text dark:hover:text-matrix-secondary hover:border-azure-border dark:hover:border-matrix-primary"}`,title:r.enabled?"Disable skill":"Enable skill",children:r.enabled?e.jsx(A,{className:"w-4 h-4"}):e.jsx(B,{className:"w-4 h-4"})})]})]})]})}function X({skill:r,open:i,onOpenChange:d}){return!i||!r?null:e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>d(!1)}),e.jsxs("div",{className:"relative bg-white dark:bg-black border border-azure-border dark:border-matrix-primary rounded-lg shadow-xl w-full max-w-2xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 px-5 py-4 border-b border-azure-border dark:border-matrix-primary shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 flex items-center justify-center shrink-0",children:e.jsx(y,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h2",{className:"text-base font-semibold text-azure-text dark:text-matrix-highlight truncate",children:r.name}),r.version&&e.jsxs("span",{className:"text-[10px] font-mono text-azure-text-secondary dark:text-matrix-tertiary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 rounded px-1.5 py-0.5 shrink-0",children:["v",r.version]})]}),r.author&&e.jsxs("div",{className:"flex items-center gap-1 mt-0.5 text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:[e.jsx(I,{className:"w-3 h-3 shrink-0"}),r.author]})]})]}),e.jsx("button",{onClick:()=>d(!1),className:"p-1.5 rounded text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-highlight hover:bg-azure-surface dark:hover:bg-zinc-900 transition-colors shrink-0",children:e.jsx(H,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"overflow-y-auto flex-1 p-5 space-y-5",children:[r.description&&e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary leading-relaxed",children:r.description}),e.jsx("div",{className:"flex flex-col gap-2",children:e.jsxs("div",{className:"flex items-start gap-2 text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:[e.jsx(J,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),e.jsx("span",{className:"break-all font-mono text-azure-text dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 rounded px-2 py-0.5",children:r.path})]})}),r.tags&&r.tags.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.tags.map(t=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-[10px] font-medium rounded border border-azure-primary/20 dark:border-matrix-primary/40 bg-azure-primary/5 dark:bg-matrix-primary/10 text-azure-primary dark:text-matrix-secondary",children:[e.jsx(L,{className:"w-2.5 h-2.5"}),t]},t))})]}),r.examples&&r.examples.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Examples"}),e.jsx("ul",{className:"space-y-1.5",children:r.examples.map((t,x)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-azure-text-secondary dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/30 rounded px-3 py-2",children:[e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary font-mono text-xs mt-0.5 shrink-0",children:[x+1,"."]}),t]},x))})]}),r.content&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"SKILL.md"}),e.jsx("pre",{className:"rounded-lg bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 p-4 text-xs text-azure-text-secondary dark:text-matrix-secondary overflow-auto max-h-72 whitespace-pre-wrap leading-relaxed font-mono",children:r.content})]})]})]})]})}function ae(){const[r,i]=s.useState(null),[d,t]=s.useState(!1),[x,N]=s.useState(!1),[o,v]=s.useState(!1),[c,k]=s.useState(null),[w,f]=s.useState(null),j=s.useRef(null),{data:S,mutate:z,isLoading:D}=Z("/skills",()=>l.fetchSkills(),{refreshInterval:1e4}),m=S?.skills??[],E=S?.enabled??0,R=async()=>{await l.reloadSkills(),z()},T=async a=>{a.enabled?await l.disableSkill(a.name):await l.enableSkill(a.name),z()},$=async a=>{t(!0);try{const p=await l.fetchSkill(a.name);i(p)}finally{t(!1)}},P=async a=>{const p=a.target.files?.[0];if(p){k(null),f(null),v(!0);try{const h=await l.uploadSkill(p);f(`Skill "${h.skill.name}" uploaded successfully!`),z(),j.current&&(j.current.value="")}catch(h){k({error:h.message||"Upload failed",details:h.details})}finally{v(!1)}}},C=()=>{k(null),f(null),N(!0)};return e.jsxs(n.div,{variants:U,initial:"hidden",animate:"show",className:"space-y-6",children:[e.jsxs(n.div,{variants:g,className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(y,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Skills"}),e.jsxs("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:[m.length," skill",m.length!==1?"s":"",", ",E," enabled"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:C,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-azure-primary dark:border-matrix-primary text-azure-primary dark:text-matrix-primary font-medium hover:bg-azure-primary/10 dark:hover:bg-matrix-primary/10 transition-colors",children:[e.jsx(u,{className:"w-4 h-4"}),"Upload"]}),e.jsxs("button",{onClick:R,className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-azure-primary dark:bg-matrix-primary text-white dark:text-black font-medium hover:opacity-90 transition-opacity",children:[e.jsx(b,{className:"w-4 h-4"}),"Reload"]})]})]}),D?e.jsxs(n.div,{variants:g,className:"text-center py-12",children:[e.jsx(b,{className:"w-8 h-8 animate-spin mx-auto text-azure-text-secondary dark:text-matrix-dim"}),e.jsx("p",{className:"mt-2 text-azure-text-secondary dark:text-matrix-dim",children:"Loading skills..."})]}):m.length===0?e.jsxs(n.div,{variants:g,className:"rounded-lg border border-dashed border-azure-border dark:border-matrix-primary p-8 text-center",children:[e.jsx(y,{className:"w-12 h-12 mx-auto text-azure-text-tertiary dark:text-matrix-dim"}),e.jsx("h3",{className:"mt-4 text-lg font-medium text-azure-text-primary dark:text-matrix-highlight",children:"No skills found"}),e.jsxs("p",{className:"mt-2 text-azure-text-secondary dark:text-matrix-secondary max-w-md mx-auto",children:["Upload a skill ZIP or add skills manually to"," ",e.jsx("code",{className:"bg-azure-hover dark:bg-zinc-800 px-1 rounded",children:"~/.morpheus/skills/"}),". Each skill folder must contain a"," ",e.jsx("code",{className:"bg-azure-hover dark:bg-zinc-800 px-1 rounded",children:"SKILL.md"})," file with frontmatter."]}),e.jsxs("button",{onClick:C,className:"mt-4 inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-azure-primary dark:bg-matrix-primary text-white dark:text-black font-medium hover:opacity-90 transition-opacity",children:[e.jsx(u,{className:"w-4 h-4"}),"Upload Skill"]})]}):e.jsx(n.div,{variants:U,initial:"hidden",animate:"show",className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:m.map(a=>e.jsx(M,{skill:a,onToggle:()=>T(a),onView:()=>$(a)},a.name))}),e.jsx(X,{skill:r,open:!!r,onOpenChange:a=>!a&&i(null)}),e.jsxs(K,{open:x,onOpenChange:N,children:[e.jsx(O,{children:e.jsx(V,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(u,{className:"w-5 h-5"}),"Upload Skill"]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-azure-text-secondary dark:text-matrix-secondary text-sm",children:["Upload a ZIP file containing your skill folder. The ZIP must have exactly one folder at root level with a valid ",e.jsx("code",{className:"bg-azure-hover dark:bg-zinc-800 px-1 rounded",children:"SKILL.md"})," file."]}),e.jsxs("div",{className:"border-2 border-dashed border-azure-border dark:border-matrix-primary rounded-lg p-6",children:[e.jsx("input",{ref:j,type:"file",accept:".zip,application/zip,application/x-zip-compressed",onChange:P,disabled:o,className:"hidden",id:"skill-upload-input"}),e.jsxs("label",{htmlFor:"skill-upload-input",className:`flex flex-col items-center gap-2 cursor-pointer ${o?"opacity-50 cursor-not-allowed":""}`,children:[o?e.jsx(b,{className:"w-8 h-8 animate-spin text-azure-primary dark:text-matrix-primary"}):e.jsx(u,{className:"w-8 h-8 text-azure-text-tertiary dark:text-matrix-dim"}),e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-secondary",children:o?"Uploading...":"Click to select ZIP file"})]})]}),c&&e.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800",children:[e.jsx(W,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-red-800 dark:text-red-200",children:c.error}),c.details&&e.jsx("p",{className:"text-xs text-red-600 dark:text-red-300 mt-1",children:c.details})]})]}),w&&e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800",children:[e.jsx(F,{className:"w-5 h-5 text-green-600 dark:text-green-400"}),e.jsx("p",{className:"text-sm text-green-800 dark:text-green-200",children:w})]}),e.jsxs("div",{className:"rounded-lg bg-azure-hover dark:bg-zinc-900 p-3",children:[e.jsx("h4",{className:"text-sm font-medium text-azure-text-primary dark:text-matrix-highlight mb-2",children:"ZIP Structure Example"}),e.jsx("pre",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:`my-skill.zip
|
|
2
2
|
└── my-skill/
|
|
3
3
|
├── SKILL.md (required)
|
|
4
4
|
├── scripts/ (optional)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as c}from"./vendor-react-DikRIOlj.js";import{u as O}from"./vendor-utils-BIYveU_1.js";import{c as b}from"./config-OLGQFNJL.js";import{S as Q,T as C}from"./SelectInput-BPDcd3y7.js";import{S as V,N as w}from"./Switch-C7TxLq0E.js";import{C as Z}from"./ConfirmationModal-DU0AwhXD.js";import{h as ee,a4 as $,H as _,Y as te,ao as H,a8 as I,ae as re,ap as q,af as ae,aq as se,ar as ie,as as ne,y as le,G as de,n as oe,at as ce,g as me,ag as xe,K as he,X as ue}from"./vendor-icons-DE7PWdkN.js";import"./index-B9ePr-vB.js";const ge={name:"",host:"",port:7900,auth_token:"",tls:!1};function be(t){const n=Math.floor(t/86400),i=Math.floor(t%86400/3600),o=Math.floor(t%3600/60);return n>0?`${n}d ${i}h`:i>0?`${i}h ${o}m`:`${o}m`}function pe(t,n){const i=t>=1024?`${(t/1024).toFixed(1)}GB`:`${Math.round(t)}MB`,o=n>=1024?`${(n/1024).toFixed(1)}GB`:`${Math.round(n)}MB`;return`${i} / ${o}`}function fe({state:t}){return t==="online"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-emerald-500 bg-emerald-500/10 border border-emerald-500/30 rounded-full px-2 py-0.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),"online"]}):t==="connecting"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-amber-500 bg-amber-500/10 border border-amber-500/30 rounded-full px-2 py-0.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-500 animate-pulse"}),"connecting"]}):t==="error"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-red-500 bg-red-500/10 border border-red-500/30 rounded-full px-2 py-0.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-500"}),"error"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-zinc-500 bg-zinc-500/10 border border-zinc-500/30 rounded-full px-2 py-0.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-zinc-500"}),"offline"]})}function je({cap:t}){const i={filesystem:"text-blue-400 bg-blue-400/10 border-blue-400/30",shell:"text-yellow-400 bg-yellow-400/10 border-yellow-400/30",git:"text-orange-400 bg-orange-400/10 border-orange-400/30",browser:"text-purple-400 bg-purple-400/10 border-purple-400/30",network:"text-cyan-400 bg-cyan-400/10 border-cyan-400/30",packages:"text-green-400 bg-green-400/10 border-green-400/30",processes:"text-pink-400 bg-pink-400/10 border-pink-400/30",system:"text-indigo-400 bg-indigo-400/10 border-indigo-400/30"}[t]??"text-zinc-400 bg-zinc-400/10 border-zinc-400/30";return e.jsx("span",{className:`text-[10px] font-medium border rounded px-1.5 py-0.5 ${i}`,children:t})}function ye({status:t,entry:n,onPing:i,onEdit:o,onDelete:a}){const[l,h]=c.useState(!1),s=t.state==="online";return e.jsxs("div",{className:`rounded-lg border bg-white dark:bg-zinc-900 shadow-sm transition-all ${s?"border-emerald-500/40 dark:border-emerald-500/30":t.state==="error"?"border-red-500/40 dark:border-red-500/30":t.state==="connecting"?"border-amber-500/40 dark:border-amber-500/30":"border-azure-border dark:border-matrix-primary"}`,children:[e.jsxs("div",{className:"p-4 bg-white dark:bg-zinc-900 shadow-sm rounded-tl-lg rounded-tr-lg",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center shrink-0 ${s?"bg-emerald-500/10":"bg-zinc-100 dark:bg-zinc-900"}`,children:e.jsx(ie,{className:`w-4 h-4 ${s?"text-emerald-500":"text-zinc-400 dark:text-matrix-tertiary"}`})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-semibold text-azure-text dark:text-matrix-highlight truncate",children:t.name}),e.jsx(fe,{state:t.state}),n?.tls&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-emerald-500 bg-emerald-500/10 border border-emerald-500/30 rounded px-1.5 py-0.5",children:[e.jsx(ne,{className:"w-2.5 h-2.5"}),"TLS"]})]}),e.jsxs("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-tertiary mt-0.5",children:[t.host,":",t.port]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>i(t.name),className:"p-1.5 rounded border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",title:"Ping",children:e.jsx(q,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>o(n??{name:t.name,host:t.host,port:t.port,auth_token:"",tls:!1}),className:"p-1.5 rounded border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",title:"Edit",children:e.jsx(le,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>a(t.name),className:"p-1.5 rounded border border-red-200 dark:border-red-800/50 text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 hover:text-red-500 transition-colors",title:"Remove",children:e.jsx(de,{className:"w-3.5 h-3.5"})})]})]}),t.error&&e.jsxs("div",{className:"mt-3 flex items-start gap-2 text-xs text-red-500 bg-red-500/10 border border-red-500/20 rounded p-2",children:[e.jsx($,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),e.jsx("span",{children:t.error})]}),s&&t.stats&&e.jsx("div",{className:"mt-3 space-y-2",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:"OS"}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono",children:t.stats.os})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:"Hostname"}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono truncate max-w-[120px]",children:t.stats.hostname})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary flex items-center gap-1",children:[e.jsx(oe,{className:"w-3 h-3"})," CPU"]}),e.jsxs("span",{className:"text-azure-text dark:text-matrix-secondary font-mono",children:[t.stats.cpu_percent.toFixed(1),"%"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary flex items-center gap-1",children:[e.jsx(ce,{className:"w-3 h-3"})," RAM"]}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono",children:pe(t.stats.memory_used_mb,t.stats.memory_total_mb)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary flex items-center gap-1",children:[e.jsx(me,{className:"w-3 h-3"})," Uptime"]}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono",children:be(t.stats.uptime_seconds)})]}),t.config?.sandbox_dir&&e.jsxs("div",{className:"flex justify-between col-span-2",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary shrink-0",children:"Sandbox"}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono truncate text-right ml-2",children:t.config.sandbox_dir})]}),t.config&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:"Read-only"}),e.jsx("span",{className:`font-medium ${t.config.readonly_mode?"text-amber-500":"text-emerald-500"}`,children:t.config.readonly_mode?"yes":"no"})]})]})}),!s&&t.lastSeen&&e.jsxs("div",{className:"mt-2 text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:["Last seen: ",new Date(t.lastSeen).toLocaleString()]})]}),t.capabilities.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>h(!l),className:"w-full flex items-center justify-between px-4 py-2 border-t border-azure-border dark:border-matrix-primary/30 text-xs text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-secondary hover:bg-azure-surface/50 dark:hover:bg-zinc-900/50 transition-colors",children:[e.jsxs("span",{children:["Capabilities (",t.capabilities.length,")"]}),l?e.jsx(xe,{className:"w-3.5 h-3.5"}):e.jsx(he,{className:"w-3.5 h-3.5"})]}),l&&e.jsxs("div",{className:"px-4 pb-4 pt-3 border-t border-azure-border dark:border-matrix-primary/30 bg-azure-surface/30 dark:bg-zinc-900/30",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.capabilities.map(x=>e.jsx(je,{cap:x},x))}),t.lastSeen&&e.jsxs("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-tertiary mt-3",children:["Last seen: ",new Date(t.lastSeen).toLocaleString()]})]})]})]})}function U({title:t,initial:n,isEdit:i,onSave:o,onClose:a,saving:l,error:h}){const[s,x]=c.useState(n),[j,p]=c.useState(null),f=()=>{if(!s.name.trim()){p("Name is required.");return}if(!s.host.trim()){p("Host is required.");return}if(!i&&!s.auth_token.trim()){p("Auth token is required.");return}p(null),o(s)};return e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white dark:bg-black border border-azure-border dark:border-matrix-primary rounded-lg shadow-xl w-full max-w-md",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-azure-border dark:border-matrix-primary",children:[e.jsxs("h2",{className:"text-base font-semibold text-azure-text dark:text-matrix-highlight flex items-center gap-2",children:[e.jsx(_,{className:"w-4 h-4"}),t]}),e.jsx("button",{onClick:a,className:"text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-highlight transition-colors",children:e.jsx(ue,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"p-5 space-y-3",children:[(j||h)&&e.jsxs("div",{className:"flex items-start gap-2 text-sm text-red-500 bg-red-500/10 border border-red-500/20 rounded p-3",children:[e.jsx($,{className:"w-4 h-4 shrink-0 mt-0.5"}),e.jsx("span",{children:j||h})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx("div",{className:"col-span-2",children:e.jsx(C,{label:"Name",value:s.name,onChange:m=>x({...s,name:m.target.value}),disabled:i,helperText:i?"Name cannot be changed after creation.":"Unique identifier (lowercase, hyphens ok)."})}),e.jsx(C,{label:"Host",value:s.host,onChange:m=>x({...s,host:m.target.value}),placeholder:"localhost"}),e.jsx(w,{label:"Port",value:s.port,onChange:m=>x({...s,port:Number(m.target.value)}),min:1,max:65535}),e.jsx("div",{className:"col-span-2",children:e.jsx(C,{label:"Auth Token",value:s.auth_token,onChange:m=>x({...s,auth_token:m.target.value}),placeholder:i?"Leave blank to keep existing token":"Shared secret",helperText:i?"Leave blank to keep the current token.":void 0})})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx("input",{type:"checkbox",id:"smith-tls",checked:s.tls??!1,onChange:m=>x({...s,tls:m.target.checked}),className:"w-4 h-4 accent-azure-primary dark:accent-matrix-highlight"}),e.jsxs("label",{htmlFor:"smith-tls",className:"text-sm text-azure-text-secondary dark:text-matrix-secondary cursor-pointer",children:["Use TLS (",e.jsx("code",{className:"text-xs font-mono",children:"wss://"}),")"]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 px-5 py-4 border-t border-azure-border dark:border-matrix-primary",children:[e.jsx("button",{onClick:a,className:"px-4 py-2 rounded text-sm text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-highlight transition-colors",children:"Cancel"}),e.jsx("button",{onClick:f,disabled:l,className:"px-4 py-2 rounded text-sm font-medium bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:l?"Saving…":i?"Update Smith":"Add Smith"})]})]})})}function Te(){const{data:t,mutate:n}=O("/api/smiths",b.getSmithsList,{refreshInterval:1e4}),{data:i,mutate:o}=O("/api/smiths/config",b.getSmithsConfig),[a,l]=c.useState(null),[h,s]=c.useState(!1),[x,j]=c.useState(!1),[p,f]=c.useState(!1),[m,z]=c.useState(null),[T,v]=c.useState(!1),[M,u]=c.useState(null),[N,A]=c.useState(null),[B,L]=c.useState(!1),[y,S]=c.useState(null);i&&!a&&l(i);const g=(r,d)=>{A({type:r,message:d}),setTimeout(()=>A(null),4e3)},G=async r=>{try{const d=await b.pingSmith(r);g("success",`Ping ${r}: ${d.latency_ms}ms`)}catch(d){g("error",`Ping failed: ${d.message}`)}},W=r=>{S(r)},K=async()=>{if(y)try{await b.removeSmith(y),n(),o(),l(null),g("success",`Smith "${y}" removed.`)}catch(r){g("error",`Failed to remove: ${r.message}`)}finally{S(null)}},Y=async r=>{if(a){if(a.entries.some(d=>d.name===r.name)){u(`Smith "${r.name}" already exists.`);return}v(!0),u(null);try{const d={...a,entries:[...a.entries,r]};await b.updateSmithsConfig(d),f(!1),l(null),n(),o(),g("success",`Smith "${r.name}" added.`)}catch(d){u(d.message)}finally{v(!1)}}},J=async r=>{if(a){v(!0),u(null);try{const d={...a,entries:a.entries.map(F=>F.name===r.name?r:F)};await b.updateSmithsConfig(d),z(null),l(null),n(),o(),g("success",`Smith "${r.name}" updated.`)}catch(d){u(d.message)}finally{v(!1)}}},X=async()=>{if(a){j(!0);try{await b.updateSmithsConfig(a),n(),o(),g("success","Settings saved."),s(!1)}catch(r){g("error",r.message)}finally{j(!1)}}},k=t?.smiths??[],P=k.filter(r=>r.state==="online").length,E=k.filter(r=>r.state==="offline"||r.state==="error").length,R=k.filter(r=>r.state==="connecting").length,D={};return(a??i)?.entries?.forEach(r=>{D[r.name]=r}),e.jsxs("div",{className:"space-y-6",children:[N&&e.jsxs("div",{className:`fixed top-4 right-4 z-50 flex items-center gap-2 px-4 py-3 rounded-lg shadow-xl text-sm border ${N.type==="success"?"bg-emerald-50 dark:bg-emerald-900/30 border-emerald-300 dark:border-emerald-500/50 text-emerald-700 dark:text-emerald-400":"bg-red-50 dark:bg-red-900/30 border-red-300 dark:border-red-500/50 text-red-700 dark:text-red-400"}`,children:[N.type==="success"?e.jsx(ee,{className:"w-4 h-4"}):e.jsx($,{className:"w-4 h-4"}),N.message]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(_,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Smiths"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Remote DevKit agents via WebSocket"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:async()=>{L(!0),await Promise.all([n(),o(),new Promise(r=>setTimeout(r,500))]),L(!1)},className:"p-2 rounded border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight transition-colors",title:"Refresh",children:e.jsx(te,{className:`w-4 h-4 transition-transform ${B?"animate-spin":""}`})}),e.jsxs("button",{onClick:()=>{s(!h),!a&&i&&l(i)},className:`flex items-center gap-1.5 px-3 py-2 rounded border text-sm transition-colors ${h?"bg-azure-primary/10 border-azure-primary dark:bg-matrix-highlight/10 dark:border-matrix-highlight text-azure-primary dark:text-matrix-highlight":"border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight"}`,children:[e.jsx(H,{className:"w-4 h-4"}),"Settings"]}),e.jsxs("button",{onClick:()=>{f(!0),u(null)},className:"flex items-center gap-1.5 px-3 py-2 rounded bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 text-sm font-medium transition-colors",children:[e.jsx(I,{className:"w-4 h-4"}),"Add Smith"]})]})]}),t&&e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:"Total"}),e.jsx("span",{className:"font-semibold text-azure-text dark:text-matrix-secondary",children:t.total})]}),P>0&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(re,{className:"w-3.5 h-3.5 text-emerald-500"}),e.jsxs("span",{className:"font-semibold text-emerald-500",children:[P," online"]})]}),R>0&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(q,{className:"w-3.5 h-3.5 text-amber-500"}),e.jsxs("span",{className:"font-semibold text-amber-500",children:[R," connecting"]})]}),E>0&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(ae,{className:"w-3.5 h-3.5 text-zinc-400 dark:text-matrix-tertiary"}),e.jsxs("span",{className:"font-semibold text-zinc-500 dark:text-matrix-tertiary",children:[E," offline"]})]}),!t.enabled&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-amber-500 bg-amber-500/10 border border-amber-500/30 rounded-full px-2.5 py-0.5",children:[e.jsx(se,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Smiths subsystem disabled"})]})]}),h&&a&&e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black p-5 space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h2",{className:"text-sm font-semibold text-azure-text dark:text-matrix-highlight flex items-center gap-2",children:[e.jsx(H,{className:"w-4 h-4"}),"Global Settings"]})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx("div",{className:"sm:col-span-2",children:e.jsx(V,{label:"Enable Smiths",checked:a.enabled,onChange:r=>l({...a,enabled:r}),helperText:"Master switch — disabling stops all Smith connections."})}),e.jsx(Q,{label:"Execution Mode",value:a.execution_mode,onChange:r=>l({...a,execution_mode:r.target.value}),options:[{label:"Sync — inline result",value:"sync"},{label:"Async — background task",value:"async"}]}),e.jsx(w,{label:"Heartbeat Interval (s)",value:Math.round(a.heartbeat_interval_ms/1e3),onChange:r=>l({...a,heartbeat_interval_ms:Number(r.target.value)*1e3}),min:5}),e.jsx(w,{label:"Connection Timeout (s)",value:Math.round(a.connection_timeout_ms/1e3),onChange:r=>l({...a,connection_timeout_ms:Number(r.target.value)*1e3}),min:1}),e.jsx(w,{label:"Task Timeout (s)",value:Math.round(a.task_timeout_ms/1e3),onChange:r=>l({...a,task_timeout_ms:Number(r.target.value)*1e3}),min:5})]}),e.jsx("div",{className:"flex justify-end pt-1",children:e.jsx("button",{onClick:X,disabled:x,className:"px-4 py-2 rounded text-sm font-medium bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:x?"Saving…":"Save Settings"})})]}),k.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary flex items-center justify-center mb-4",children:e.jsx(_,{className:"w-7 h-7 text-azure-text-secondary dark:text-matrix-tertiary"})}),e.jsx("h3",{className:"text-base font-semibold text-azure-text dark:text-matrix-highlight mb-1",children:"No Smiths configured"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary mb-4",children:"Add a remote agent to delegate DevKit tasks to isolated environments."}),e.jsxs("button",{onClick:()=>{f(!0),u(null)},className:"flex items-center gap-2 px-4 py-2 rounded bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black text-sm font-medium transition-colors",children:[e.jsx(I,{className:"w-4 h-4"}),"Add First Smith"]})]}):e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:k.map(r=>e.jsx(ye,{status:r,entry:D[r.name],onPing:G,onEdit:d=>{z({...d,auth_token:""}),u(null)},onDelete:W},r.name))}),p&&e.jsx(U,{title:"Add Smith",initial:ge,onSave:Y,onClose:()=>f(!1),saving:T,error:M}),m&&e.jsx(U,{title:"Edit Smith",initial:m,isEdit:!0,onSave:J,onClose:()=>z(null),saving:T,error:M}),e.jsx(Z,{isOpen:!!y,onClose:()=>S(null),onConfirm:K,title:"Remove Smith",description:`Are you sure you want to remove "${y}" from the registry? This action cannot be undone.`,confirmJson:"Remove",variant:"destructive"})]})}export{Te as SmithsPage};
|
|
1
|
+
import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as c}from"./vendor-react-DikRIOlj.js";import{u as O}from"./vendor-utils-BIYveU_1.js";import{c as b}from"./config-CPFW7PTY.js";import{S as Q,T as C}from"./SelectInput-BPDcd3y7.js";import{S as V,N as w}from"./Switch-C7TxLq0E.js";import{C as Z}from"./ConfirmationModal-CxvFe-We.js";import{h as ee,a4 as $,H as _,Y as te,ao as H,a8 as I,ae as re,ap as q,af as ae,aq as se,ar as ie,as as ne,y as le,G as de,n as oe,at as ce,g as me,ag as xe,K as he,X as ue}from"./vendor-icons-DE7PWdkN.js";import"./index-BvsF1a9j.js";const ge={name:"",host:"",port:7900,auth_token:"",tls:!1};function be(t){const n=Math.floor(t/86400),i=Math.floor(t%86400/3600),o=Math.floor(t%3600/60);return n>0?`${n}d ${i}h`:i>0?`${i}h ${o}m`:`${o}m`}function pe(t,n){const i=t>=1024?`${(t/1024).toFixed(1)}GB`:`${Math.round(t)}MB`,o=n>=1024?`${(n/1024).toFixed(1)}GB`:`${Math.round(n)}MB`;return`${i} / ${o}`}function fe({state:t}){return t==="online"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-emerald-500 bg-emerald-500/10 border border-emerald-500/30 rounded-full px-2 py-0.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),"online"]}):t==="connecting"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-amber-500 bg-amber-500/10 border border-amber-500/30 rounded-full px-2 py-0.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-500 animate-pulse"}),"connecting"]}):t==="error"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-red-500 bg-red-500/10 border border-red-500/30 rounded-full px-2 py-0.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-500"}),"error"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-zinc-500 bg-zinc-500/10 border border-zinc-500/30 rounded-full px-2 py-0.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-zinc-500"}),"offline"]})}function je({cap:t}){const i={filesystem:"text-blue-400 bg-blue-400/10 border-blue-400/30",shell:"text-yellow-400 bg-yellow-400/10 border-yellow-400/30",git:"text-orange-400 bg-orange-400/10 border-orange-400/30",browser:"text-purple-400 bg-purple-400/10 border-purple-400/30",network:"text-cyan-400 bg-cyan-400/10 border-cyan-400/30",packages:"text-green-400 bg-green-400/10 border-green-400/30",processes:"text-pink-400 bg-pink-400/10 border-pink-400/30",system:"text-indigo-400 bg-indigo-400/10 border-indigo-400/30"}[t]??"text-zinc-400 bg-zinc-400/10 border-zinc-400/30";return e.jsx("span",{className:`text-[10px] font-medium border rounded px-1.5 py-0.5 ${i}`,children:t})}function ye({status:t,entry:n,onPing:i,onEdit:o,onDelete:a}){const[l,h]=c.useState(!1),s=t.state==="online";return e.jsxs("div",{className:`rounded-lg border bg-white dark:bg-zinc-900 shadow-sm transition-all ${s?"border-emerald-500/40 dark:border-emerald-500/30":t.state==="error"?"border-red-500/40 dark:border-red-500/30":t.state==="connecting"?"border-amber-500/40 dark:border-amber-500/30":"border-azure-border dark:border-matrix-primary"}`,children:[e.jsxs("div",{className:"p-4 bg-white dark:bg-zinc-900 shadow-sm rounded-tl-lg rounded-tr-lg",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center shrink-0 ${s?"bg-emerald-500/10":"bg-zinc-100 dark:bg-zinc-900"}`,children:e.jsx(ie,{className:`w-4 h-4 ${s?"text-emerald-500":"text-zinc-400 dark:text-matrix-tertiary"}`})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-semibold text-azure-text dark:text-matrix-highlight truncate",children:t.name}),e.jsx(fe,{state:t.state}),n?.tls&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-emerald-500 bg-emerald-500/10 border border-emerald-500/30 rounded px-1.5 py-0.5",children:[e.jsx(ne,{className:"w-2.5 h-2.5"}),"TLS"]})]}),e.jsxs("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-tertiary mt-0.5",children:[t.host,":",t.port]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>i(t.name),className:"p-1.5 rounded border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",title:"Ping",children:e.jsx(q,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>o(n??{name:t.name,host:t.host,port:t.port,auth_token:"",tls:!1}),className:"p-1.5 rounded border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",title:"Edit",children:e.jsx(le,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>a(t.name),className:"p-1.5 rounded border border-red-200 dark:border-red-800/50 text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 hover:text-red-500 transition-colors",title:"Remove",children:e.jsx(de,{className:"w-3.5 h-3.5"})})]})]}),t.error&&e.jsxs("div",{className:"mt-3 flex items-start gap-2 text-xs text-red-500 bg-red-500/10 border border-red-500/20 rounded p-2",children:[e.jsx($,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),e.jsx("span",{children:t.error})]}),s&&t.stats&&e.jsx("div",{className:"mt-3 space-y-2",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:"OS"}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono",children:t.stats.os})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:"Hostname"}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono truncate max-w-[120px]",children:t.stats.hostname})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary flex items-center gap-1",children:[e.jsx(oe,{className:"w-3 h-3"})," CPU"]}),e.jsxs("span",{className:"text-azure-text dark:text-matrix-secondary font-mono",children:[t.stats.cpu_percent.toFixed(1),"%"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary flex items-center gap-1",children:[e.jsx(ce,{className:"w-3 h-3"})," RAM"]}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono",children:pe(t.stats.memory_used_mb,t.stats.memory_total_mb)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary flex items-center gap-1",children:[e.jsx(me,{className:"w-3 h-3"})," Uptime"]}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono",children:be(t.stats.uptime_seconds)})]}),t.config?.sandbox_dir&&e.jsxs("div",{className:"flex justify-between col-span-2",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary shrink-0",children:"Sandbox"}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary font-mono truncate text-right ml-2",children:t.config.sandbox_dir})]}),t.config&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:"Read-only"}),e.jsx("span",{className:`font-medium ${t.config.readonly_mode?"text-amber-500":"text-emerald-500"}`,children:t.config.readonly_mode?"yes":"no"})]})]})}),!s&&t.lastSeen&&e.jsxs("div",{className:"mt-2 text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:["Last seen: ",new Date(t.lastSeen).toLocaleString()]})]}),t.capabilities.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>h(!l),className:"w-full flex items-center justify-between px-4 py-2 border-t border-azure-border dark:border-matrix-primary/30 text-xs text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-secondary hover:bg-azure-surface/50 dark:hover:bg-zinc-900/50 transition-colors",children:[e.jsxs("span",{children:["Capabilities (",t.capabilities.length,")"]}),l?e.jsx(xe,{className:"w-3.5 h-3.5"}):e.jsx(he,{className:"w-3.5 h-3.5"})]}),l&&e.jsxs("div",{className:"px-4 pb-4 pt-3 border-t border-azure-border dark:border-matrix-primary/30 bg-azure-surface/30 dark:bg-zinc-900/30",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.capabilities.map(x=>e.jsx(je,{cap:x},x))}),t.lastSeen&&e.jsxs("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-tertiary mt-3",children:["Last seen: ",new Date(t.lastSeen).toLocaleString()]})]})]})]})}function U({title:t,initial:n,isEdit:i,onSave:o,onClose:a,saving:l,error:h}){const[s,x]=c.useState(n),[j,p]=c.useState(null),f=()=>{if(!s.name.trim()){p("Name is required.");return}if(!s.host.trim()){p("Host is required.");return}if(!i&&!s.auth_token.trim()){p("Auth token is required.");return}p(null),o(s)};return e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white dark:bg-black border border-azure-border dark:border-matrix-primary rounded-lg shadow-xl w-full max-w-md",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-azure-border dark:border-matrix-primary",children:[e.jsxs("h2",{className:"text-base font-semibold text-azure-text dark:text-matrix-highlight flex items-center gap-2",children:[e.jsx(_,{className:"w-4 h-4"}),t]}),e.jsx("button",{onClick:a,className:"text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-highlight transition-colors",children:e.jsx(ue,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"p-5 space-y-3",children:[(j||h)&&e.jsxs("div",{className:"flex items-start gap-2 text-sm text-red-500 bg-red-500/10 border border-red-500/20 rounded p-3",children:[e.jsx($,{className:"w-4 h-4 shrink-0 mt-0.5"}),e.jsx("span",{children:j||h})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx("div",{className:"col-span-2",children:e.jsx(C,{label:"Name",value:s.name,onChange:m=>x({...s,name:m.target.value}),disabled:i,helperText:i?"Name cannot be changed after creation.":"Unique identifier (lowercase, hyphens ok)."})}),e.jsx(C,{label:"Host",value:s.host,onChange:m=>x({...s,host:m.target.value}),placeholder:"localhost"}),e.jsx(w,{label:"Port",value:s.port,onChange:m=>x({...s,port:Number(m.target.value)}),min:1,max:65535}),e.jsx("div",{className:"col-span-2",children:e.jsx(C,{label:"Auth Token",value:s.auth_token,onChange:m=>x({...s,auth_token:m.target.value}),placeholder:i?"Leave blank to keep existing token":"Shared secret",helperText:i?"Leave blank to keep the current token.":void 0})})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx("input",{type:"checkbox",id:"smith-tls",checked:s.tls??!1,onChange:m=>x({...s,tls:m.target.checked}),className:"w-4 h-4 accent-azure-primary dark:accent-matrix-highlight"}),e.jsxs("label",{htmlFor:"smith-tls",className:"text-sm text-azure-text-secondary dark:text-matrix-secondary cursor-pointer",children:["Use TLS (",e.jsx("code",{className:"text-xs font-mono",children:"wss://"}),")"]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 px-5 py-4 border-t border-azure-border dark:border-matrix-primary",children:[e.jsx("button",{onClick:a,className:"px-4 py-2 rounded text-sm text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-highlight transition-colors",children:"Cancel"}),e.jsx("button",{onClick:f,disabled:l,className:"px-4 py-2 rounded text-sm font-medium bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:l?"Saving…":i?"Update Smith":"Add Smith"})]})]})})}function Te(){const{data:t,mutate:n}=O("/api/smiths",b.getSmithsList,{refreshInterval:1e4}),{data:i,mutate:o}=O("/api/smiths/config",b.getSmithsConfig),[a,l]=c.useState(null),[h,s]=c.useState(!1),[x,j]=c.useState(!1),[p,f]=c.useState(!1),[m,z]=c.useState(null),[T,v]=c.useState(!1),[M,u]=c.useState(null),[N,A]=c.useState(null),[B,L]=c.useState(!1),[y,S]=c.useState(null);i&&!a&&l(i);const g=(r,d)=>{A({type:r,message:d}),setTimeout(()=>A(null),4e3)},G=async r=>{try{const d=await b.pingSmith(r);g("success",`Ping ${r}: ${d.latency_ms}ms`)}catch(d){g("error",`Ping failed: ${d.message}`)}},W=r=>{S(r)},K=async()=>{if(y)try{await b.removeSmith(y),n(),o(),l(null),g("success",`Smith "${y}" removed.`)}catch(r){g("error",`Failed to remove: ${r.message}`)}finally{S(null)}},Y=async r=>{if(a){if(a.entries.some(d=>d.name===r.name)){u(`Smith "${r.name}" already exists.`);return}v(!0),u(null);try{const d={...a,entries:[...a.entries,r]};await b.updateSmithsConfig(d),f(!1),l(null),n(),o(),g("success",`Smith "${r.name}" added.`)}catch(d){u(d.message)}finally{v(!1)}}},J=async r=>{if(a){v(!0),u(null);try{const d={...a,entries:a.entries.map(F=>F.name===r.name?r:F)};await b.updateSmithsConfig(d),z(null),l(null),n(),o(),g("success",`Smith "${r.name}" updated.`)}catch(d){u(d.message)}finally{v(!1)}}},X=async()=>{if(a){j(!0);try{await b.updateSmithsConfig(a),n(),o(),g("success","Settings saved."),s(!1)}catch(r){g("error",r.message)}finally{j(!1)}}},k=t?.smiths??[],P=k.filter(r=>r.state==="online").length,E=k.filter(r=>r.state==="offline"||r.state==="error").length,R=k.filter(r=>r.state==="connecting").length,D={};return(a??i)?.entries?.forEach(r=>{D[r.name]=r}),e.jsxs("div",{className:"space-y-6",children:[N&&e.jsxs("div",{className:`fixed top-4 right-4 z-50 flex items-center gap-2 px-4 py-3 rounded-lg shadow-xl text-sm border ${N.type==="success"?"bg-emerald-50 dark:bg-emerald-900/30 border-emerald-300 dark:border-emerald-500/50 text-emerald-700 dark:text-emerald-400":"bg-red-50 dark:bg-red-900/30 border-red-300 dark:border-red-500/50 text-red-700 dark:text-red-400"}`,children:[N.type==="success"?e.jsx(ee,{className:"w-4 h-4"}):e.jsx($,{className:"w-4 h-4"}),N.message]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(_,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Smiths"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Remote DevKit agents via WebSocket"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:async()=>{L(!0),await Promise.all([n(),o(),new Promise(r=>setTimeout(r,500))]),L(!1)},className:"p-2 rounded border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight transition-colors",title:"Refresh",children:e.jsx(te,{className:`w-4 h-4 transition-transform ${B?"animate-spin":""}`})}),e.jsxs("button",{onClick:()=>{s(!h),!a&&i&&l(i)},className:`flex items-center gap-1.5 px-3 py-2 rounded border text-sm transition-colors ${h?"bg-azure-primary/10 border-azure-primary dark:bg-matrix-highlight/10 dark:border-matrix-highlight text-azure-primary dark:text-matrix-highlight":"border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight"}`,children:[e.jsx(H,{className:"w-4 h-4"}),"Settings"]}),e.jsxs("button",{onClick:()=>{f(!0),u(null)},className:"flex items-center gap-1.5 px-3 py-2 rounded bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 text-sm font-medium transition-colors",children:[e.jsx(I,{className:"w-4 h-4"}),"Add Smith"]})]})]}),t&&e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:"Total"}),e.jsx("span",{className:"font-semibold text-azure-text dark:text-matrix-secondary",children:t.total})]}),P>0&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(re,{className:"w-3.5 h-3.5 text-emerald-500"}),e.jsxs("span",{className:"font-semibold text-emerald-500",children:[P," online"]})]}),R>0&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(q,{className:"w-3.5 h-3.5 text-amber-500"}),e.jsxs("span",{className:"font-semibold text-amber-500",children:[R," connecting"]})]}),E>0&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(ae,{className:"w-3.5 h-3.5 text-zinc-400 dark:text-matrix-tertiary"}),e.jsxs("span",{className:"font-semibold text-zinc-500 dark:text-matrix-tertiary",children:[E," offline"]})]}),!t.enabled&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-amber-500 bg-amber-500/10 border border-amber-500/30 rounded-full px-2.5 py-0.5",children:[e.jsx(se,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Smiths subsystem disabled"})]})]}),h&&a&&e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black p-5 space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h2",{className:"text-sm font-semibold text-azure-text dark:text-matrix-highlight flex items-center gap-2",children:[e.jsx(H,{className:"w-4 h-4"}),"Global Settings"]})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx("div",{className:"sm:col-span-2",children:e.jsx(V,{label:"Enable Smiths",checked:a.enabled,onChange:r=>l({...a,enabled:r}),helperText:"Master switch — disabling stops all Smith connections."})}),e.jsx(Q,{label:"Execution Mode",value:a.execution_mode,onChange:r=>l({...a,execution_mode:r.target.value}),options:[{label:"Sync — inline result",value:"sync"},{label:"Async — background task",value:"async"}]}),e.jsx(w,{label:"Heartbeat Interval (s)",value:Math.round(a.heartbeat_interval_ms/1e3),onChange:r=>l({...a,heartbeat_interval_ms:Number(r.target.value)*1e3}),min:5}),e.jsx(w,{label:"Connection Timeout (s)",value:Math.round(a.connection_timeout_ms/1e3),onChange:r=>l({...a,connection_timeout_ms:Number(r.target.value)*1e3}),min:1}),e.jsx(w,{label:"Task Timeout (s)",value:Math.round(a.task_timeout_ms/1e3),onChange:r=>l({...a,task_timeout_ms:Number(r.target.value)*1e3}),min:5})]}),e.jsx("div",{className:"flex justify-end pt-1",children:e.jsx("button",{onClick:X,disabled:x,className:"px-4 py-2 rounded text-sm font-medium bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:x?"Saving…":"Save Settings"})})]}),k.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary flex items-center justify-center mb-4",children:e.jsx(_,{className:"w-7 h-7 text-azure-text-secondary dark:text-matrix-tertiary"})}),e.jsx("h3",{className:"text-base font-semibold text-azure-text dark:text-matrix-highlight mb-1",children:"No Smiths configured"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary mb-4",children:"Add a remote agent to delegate DevKit tasks to isolated environments."}),e.jsxs("button",{onClick:()=>{f(!0),u(null)},className:"flex items-center gap-2 px-4 py-2 rounded bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black text-sm font-medium transition-colors",children:[e.jsx(I,{className:"w-4 h-4"}),"Add First Smith"]})]}):e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:k.map(r=>e.jsx(ye,{status:r,entry:D[r.name],onPing:G,onEdit:d=>{z({...d,auth_token:""}),u(null)},onDelete:W},r.name))}),p&&e.jsx(U,{title:"Add Smith",initial:ge,onSave:Y,onClose:()=>f(!1),saving:T,error:M}),m&&e.jsx(U,{title:"Edit Smith",initial:m,isEdit:!0,onSave:J,onClose:()=>z(null),saving:T,error:M}),e.jsx(Z,{isOpen:!!y,onClose:()=>S(null),onConfirm:K,title:"Remove Smith",description:`Are you sure you want to remove "${y}" from the registry? This action cannot be undone.`,confirmJson:"Remove",variant:"destructive"})]})}export{Te as SmithsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,m as l}from"./vendor-motion-C3CZ8ZlO.js";import{r as s}from"./vendor-react-DikRIOlj.js";import{u as S}from"./vendor-utils-BIYveU_1.js";import{t as m}from"./index-B9ePr-vB.js";import{P as B}from"./Pagination-D4ShqUKO.js";import{u as E}from"./agents-DO69pNM1.js";import{f as D,Y as O,a0 as M,ad as K,r as W,s as _,t as X,g as U,X as V,a4 as Y}from"./vendor-icons-DE7PWdkN.js";const q={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.05}}},u={hidden:{opacity:0,y:8},show:{opacity:1,y:0}},G={pending:"Pending",running:"Running",completed:"Completed",failed:"Failed",cancelled:"Cancelled"};function F({status:r}){const t="inline-flex items-center gap-1 text-xs font-medium rounded-full px-2 py-0.5 border";return r==="completed"?e.jsxs("span",{className:`${t} text-emerald-600 dark:text-emerald-400 bg-emerald-50 dark:bg-emerald-900/20 border-emerald-200 dark:border-emerald-700/50`,children:[e.jsx(W,{className:"w-3 h-3"}),"Completed"]}):r==="failed"?e.jsxs("span",{className:`${t} text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20 border-red-200 dark:border-red-700/50`,children:[e.jsx(_,{className:"w-3 h-3"}),"Failed"]}):r==="running"?e.jsxs("span",{className:`${t} text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-700/50`,children:[e.jsx(X,{className:"w-3 h-3 animate-spin"}),"Running"]}):r==="cancelled"?e.jsxs("span",{className:`${t} text-zinc-500 dark:text-zinc-400 bg-zinc-100 dark:bg-zinc-900 border-zinc-200 dark:border-zinc-700`,children:[e.jsx(_,{className:"w-3 h-3"}),"Cancelled"]}):e.jsxs("span",{className:`${t} text-yellow-600 dark:text-yellow-400 bg-yellow-50 dark:bg-yellow-900/20 border-yellow-200 dark:border-yellow-700/50`,children:[e.jsx(U,{className:"w-3 h-3"}),"Pending"]})}function R({agent:r}){return e.jsx("span",{className:"inline-flex items-center text-[10px] font-medium font-mono rounded px-1.5 py-0.5 border border-azure-primary/20 dark:border-matrix-primary/40 bg-azure-primary/5 dark:bg-matrix-primary/10 text-azure-primary dark:text-matrix-secondary uppercase",children:r})}function $({channel:r}){return e.jsx("span",{className:"inline-flex items-center text-[10px] font-medium rounded px-1.5 py-0.5 border border-zinc-200 dark:border-zinc-700 bg-zinc-100 dark:bg-zinc-900 text-zinc-500 dark:text-zinc-400 uppercase",children:r})}const P=r=>r?new Date(r).toLocaleString(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"—",A=r=>r?new Date(r).toLocaleString():"—";function H({task:r,onClose:t,onCancel:o,onRetry:k}){const h=r.status==="pending"||r.status==="running",d=r.status==="failed";return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:t}),e.jsxs("div",{className:"relative bg-white dark:bg-black border border-azure-border dark:border-matrix-primary rounded-lg shadow-xl w-full max-w-2xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 px-5 py-4 border-b border-azure-border dark:border-matrix-primary shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 flex items-center justify-center shrink-0",children:e.jsx(D,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h2",{className:"text-base font-semibold text-azure-text dark:text-matrix-highlight",children:"Task Details"}),e.jsx(F,{status:r.status})]}),e.jsx("p",{className:"text-xs font-mono text-azure-text-secondary dark:text-matrix-tertiary mt-0.5 truncate",children:r.id})]})]}),e.jsx("button",{onClick:t,className:"p-1.5 rounded text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-highlight hover:bg-azure-surface dark:hover:bg-zinc-900 transition-colors shrink-0",children:e.jsx(V,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"overflow-y-auto flex-1 p-5 space-y-5",children:[e.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-2 text-sm",children:[{label:"Agent",value:e.jsx(R,{agent:r.agent})},{label:"Channel",value:e.jsx($,{channel:r.origin_channel})},{label:"Attempts",value:`${r.attempt_count} / ${r.max_attempts}`},{label:"Session",value:e.jsx("span",{className:"font-mono text-xs",children:r.session_id})},{label:"Created",value:A(r.created_at)},{label:"Finished",value:A(r.finished_at)}].map(({label:p,value:c})=>e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary",children:p}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary",children:c})]},p))}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Input"}),e.jsx("pre",{className:"rounded-lg bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 p-4 text-xs text-azure-text-secondary dark:text-matrix-secondary overflow-auto max-h-48 whitespace-pre-wrap leading-relaxed font-mono",children:r.input})]}),r.output&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Output"}),e.jsx("pre",{className:"rounded-lg bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 p-4 text-xs text-azure-text-secondary dark:text-matrix-secondary overflow-auto max-h-64 whitespace-pre-wrap leading-relaxed font-mono",children:r.output})]}),r.error&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-red-500 mb-2 flex items-center gap-1",children:[e.jsx(Y,{className:"w-3 h-3"})," Error"]}),e.jsx("pre",{className:"rounded-lg bg-red-50 dark:bg-red-950/30 border border-red-200 dark:border-red-800/50 p-4 text-xs text-red-600 dark:text-red-400 overflow-auto max-h-48 whitespace-pre-wrap leading-relaxed font-mono",children:r.error})]})]}),(h||d)&&e.jsxs("div",{className:"flex justify-end gap-2 px-5 py-4 border-t border-azure-border dark:border-matrix-primary shrink-0",children:[h&&e.jsx("button",{onClick:o,className:"px-4 py-2 rounded text-sm border border-red-300 dark:border-red-700/60 text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:"Cancel Task"}),d&&e.jsx("button",{onClick:k,className:"px-4 py-2 rounded text-sm font-medium bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 transition-colors",children:"Retry Task"})]})]})]})}const J={Pending:"text-yellow-600 dark:text-yellow-400",Running:"text-blue-600 dark:text-blue-400",Completed:"text-emerald-600 dark:text-emerald-400",Failed:"text-red-600 dark:text-red-400",Cancelled:"text-zinc-500 dark:text-zinc-400",Total:"text-azure-text dark:text-matrix-highlight"};function n({label:r,value:t}){return e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black px-4 py-3",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary",children:r}),e.jsx("p",{className:`text-2xl font-bold mt-0.5 ${J[r]??"text-azure-text dark:text-matrix-secondary"}`,children:t})]})}function de(){const[r,t]=s.useState(""),[o,k]=s.useState(""),{getSubagents:h}=E(),[d,p]=s.useState(""),[c,T]=s.useState(""),[b,g]=s.useState(null),[f,v]=s.useState(1),[w,I]=s.useState(20),z=s.useMemo(()=>({status:r||void 0,agent:o||void 0,origin_channel:d||void 0,session_id:c.trim()||void 0,page:f,per_page:w}),[r,o,d,c,f,w]),y=()=>v(1),{data:i}=S("/tasks/stats",()=>m.stats(),{refreshInterval:5e3}),{data:x,mutate:N}=S(["/tasks",z],()=>m.list(z),{refreshInterval:3e3}),C=x?.data??[],j="px-3 py-2 rounded border border-azure-border dark:border-matrix-primary bg-white dark:bg-black text-azure-text dark:text-matrix-secondary text-sm focus:outline-none focus:border-azure-primary dark:focus:border-matrix-highlight";return e.jsxs(l.div,{variants:q,initial:"hidden",animate:"show",className:"space-y-6",children:[e.jsxs(l.div,{variants:u,className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(D,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Tasks"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Async tasks delegated by Oracle and processed by workers."})]})]}),e.jsxs(l.div,{variants:u,className:"grid grid-cols-3 md:grid-cols-6 gap-3",children:[e.jsx(n,{label:"Pending",value:i?.pending??0}),e.jsx(n,{label:"Running",value:i?.running??0}),e.jsx(n,{label:"Completed",value:i?.completed??0}),e.jsx(n,{label:"Failed",value:i?.failed??0}),e.jsx(n,{label:"Cancelled",value:i?.cancelled??0}),e.jsx(n,{label:"Total",value:i?.total??0})]}),e.jsxs(l.div,{variants:u,className:"rounded-lg border border-azure-border dark:border-matrix-primary p-4 bg-white dark:bg-black grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsxs("select",{className:j,value:r,onChange:a=>{t(a.target.value||""),y()},children:[e.jsx("option",{value:"",children:"All status"}),Object.entries(G).map(([a,L])=>e.jsx("option",{value:a,children:L},a))]}),e.jsxs("select",{className:j,value:o,onChange:a=>{k(a.target.value||""),y()},children:[e.jsx("option",{value:"",children:"All agents"}),h().map(a=>e.jsx("option",{value:a.agentKey,children:a.label},a.agentKey))]}),e.jsxs("select",{className:j,value:d,onChange:a=>{p(a.target.value||""),y()},children:[e.jsx("option",{value:"",children:"All channels"}),e.jsx("option",{value:"telegram",children:"Telegram"}),e.jsx("option",{value:"discord",children:"Discord"}),e.jsx("option",{value:"ui",children:"UI"}),e.jsx("option",{value:"api",children:"API"}),e.jsx("option",{value:"webhook",children:"Webhook"}),e.jsx("option",{value:"cli",children:"CLI"})]}),e.jsx("input",{className:`${j} placeholder:text-azure-text-secondary/50 dark:placeholder:text-matrix-secondary/40`,value:c,onChange:a=>{T(a.target.value),y()},placeholder:"Filter by session ID"})]}),e.jsx(l.div,{variants:u,className:"rounded-lg border border-azure-border dark:border-matrix-primary overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm min-w-[820px]",children:[e.jsx("thead",{className:"bg-azure-surface dark:bg-zinc-900 border-b border-azure-border dark:border-matrix-primary",children:e.jsx("tr",{children:[{label:"ID",cls:"w-24"},{label:"Status",cls:"w-32"},{label:"Agent",cls:"w-24"},{label:"Channel",cls:"w-24"},{label:"Session",cls:"w-28"},{label:"Attempts",cls:"w-20"},{label:"Created",cls:"w-36"},{label:"Finished",cls:"w-36"},{label:"",cls:"w-16"}].map(a=>e.jsx("th",{className:`text-left px-4 py-3 text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary ${a.cls}`,children:a.label},a.label))})}),e.jsx("tbody",{children:C.length===0?e.jsx("tr",{children:e.jsxs("td",{colSpan:9,className:"px-4 py-12 text-center text-azure-text-secondary dark:text-matrix-tertiary",children:[e.jsx(O,{className:"w-5 h-5 mx-auto mb-2 opacity-40"}),"No tasks found."]})}):C.map(a=>e.jsxs("tr",{className:"border-b border-azure-border dark:border-matrix-primary/30 hover:bg-azure-surface/60 dark:hover:bg-zinc-900/50 transition-colors",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:a.id.slice(0,8)}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(F,{status:a.status})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(R,{agent:a.agent})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx($,{channel:a.origin_channel})}),e.jsx("td",{className:"px-4 py-3 font-mono text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:a.session_id?a.session_id.slice(0,10):"—"}),e.jsxs("td",{className:"px-4 py-3 text-center text-azure-text-secondary dark:text-matrix-secondary text-xs",children:[a.attempt_count,"/",a.max_attempts]}),e.jsx("td",{className:"px-4 py-3 text-xs text-azure-text-secondary dark:text-matrix-secondary whitespace-nowrap",children:P(a.created_at)}),e.jsx("td",{className:"px-4 py-3 text-xs text-azure-text-secondary dark:text-matrix-secondary whitespace-nowrap",children:P(a.finished_at)}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>g(a),className:"p-1.5 rounded border border-azure-border dark:border-matrix-primary/50 text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-primary dark:hover:text-matrix-highlight hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",title:"View details",children:e.jsx(M,{className:"w-3.5 h-3.5"})}),(a.status==="pending"||a.status==="running")&&e.jsx("button",{onClick:async()=>{await m.cancel(a.id),N()},className:"p-1.5 rounded border border-red-200 dark:border-red-800/50 text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 hover:text-red-500 transition-colors",title:"Cancel task",children:e.jsx(K,{className:"w-3.5 h-3.5"})})]})})]},a.id))})]})})}),x&&x.total_pages>1&&e.jsx(l.div,{variants:u,children:e.jsx("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black",children:e.jsx(B,{page:f,totalPages:x.total_pages,perPage:w,total:x.total,onPageChange:v,onPerPageChange:a=>{I(a),v(1)}})})}),b&&e.jsx(H,{task:b,onClose:()=>g(null),onCancel:async()=>{await m.cancel(b.id),g(null),N()},onRetry:async()=>{await m.retry(b.id),g(null),N()}})]})}export{de as TasksPage};
|
|
1
|
+
import{j as e,m as l}from"./vendor-motion-C3CZ8ZlO.js";import{r as s}from"./vendor-react-DikRIOlj.js";import{u as S}from"./vendor-utils-BIYveU_1.js";import{t as m}from"./index-BvsF1a9j.js";import{P as B}from"./Pagination-D4ShqUKO.js";import{u as E}from"./agents-BVnfnJ1X.js";import{f as D,Y as O,a0 as M,ad as K,r as W,s as _,t as X,g as U,X as V,a4 as Y}from"./vendor-icons-DE7PWdkN.js";const q={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.05}}},u={hidden:{opacity:0,y:8},show:{opacity:1,y:0}},G={pending:"Pending",running:"Running",completed:"Completed",failed:"Failed",cancelled:"Cancelled"};function F({status:r}){const t="inline-flex items-center gap-1 text-xs font-medium rounded-full px-2 py-0.5 border";return r==="completed"?e.jsxs("span",{className:`${t} text-emerald-600 dark:text-emerald-400 bg-emerald-50 dark:bg-emerald-900/20 border-emerald-200 dark:border-emerald-700/50`,children:[e.jsx(W,{className:"w-3 h-3"}),"Completed"]}):r==="failed"?e.jsxs("span",{className:`${t} text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20 border-red-200 dark:border-red-700/50`,children:[e.jsx(_,{className:"w-3 h-3"}),"Failed"]}):r==="running"?e.jsxs("span",{className:`${t} text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-700/50`,children:[e.jsx(X,{className:"w-3 h-3 animate-spin"}),"Running"]}):r==="cancelled"?e.jsxs("span",{className:`${t} text-zinc-500 dark:text-zinc-400 bg-zinc-100 dark:bg-zinc-900 border-zinc-200 dark:border-zinc-700`,children:[e.jsx(_,{className:"w-3 h-3"}),"Cancelled"]}):e.jsxs("span",{className:`${t} text-yellow-600 dark:text-yellow-400 bg-yellow-50 dark:bg-yellow-900/20 border-yellow-200 dark:border-yellow-700/50`,children:[e.jsx(U,{className:"w-3 h-3"}),"Pending"]})}function R({agent:r}){return e.jsx("span",{className:"inline-flex items-center text-[10px] font-medium font-mono rounded px-1.5 py-0.5 border border-azure-primary/20 dark:border-matrix-primary/40 bg-azure-primary/5 dark:bg-matrix-primary/10 text-azure-primary dark:text-matrix-secondary uppercase",children:r})}function $({channel:r}){return e.jsx("span",{className:"inline-flex items-center text-[10px] font-medium rounded px-1.5 py-0.5 border border-zinc-200 dark:border-zinc-700 bg-zinc-100 dark:bg-zinc-900 text-zinc-500 dark:text-zinc-400 uppercase",children:r})}const P=r=>r?new Date(r).toLocaleString(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"—",A=r=>r?new Date(r).toLocaleString():"—";function H({task:r,onClose:t,onCancel:o,onRetry:k}){const h=r.status==="pending"||r.status==="running",d=r.status==="failed";return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:t}),e.jsxs("div",{className:"relative bg-white dark:bg-black border border-azure-border dark:border-matrix-primary rounded-lg shadow-xl w-full max-w-2xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 px-5 py-4 border-b border-azure-border dark:border-matrix-primary shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 flex items-center justify-center shrink-0",children:e.jsx(D,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h2",{className:"text-base font-semibold text-azure-text dark:text-matrix-highlight",children:"Task Details"}),e.jsx(F,{status:r.status})]}),e.jsx("p",{className:"text-xs font-mono text-azure-text-secondary dark:text-matrix-tertiary mt-0.5 truncate",children:r.id})]})]}),e.jsx("button",{onClick:t,className:"p-1.5 rounded text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text dark:hover:text-matrix-highlight hover:bg-azure-surface dark:hover:bg-zinc-900 transition-colors shrink-0",children:e.jsx(V,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"overflow-y-auto flex-1 p-5 space-y-5",children:[e.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-2 text-sm",children:[{label:"Agent",value:e.jsx(R,{agent:r.agent})},{label:"Channel",value:e.jsx($,{channel:r.origin_channel})},{label:"Attempts",value:`${r.attempt_count} / ${r.max_attempts}`},{label:"Session",value:e.jsx("span",{className:"font-mono text-xs",children:r.session_id})},{label:"Created",value:A(r.created_at)},{label:"Finished",value:A(r.finished_at)}].map(({label:p,value:c})=>e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary",children:p}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary",children:c})]},p))}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Input"}),e.jsx("pre",{className:"rounded-lg bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 p-4 text-xs text-azure-text-secondary dark:text-matrix-secondary overflow-auto max-h-48 whitespace-pre-wrap leading-relaxed font-mono",children:r.input})]}),r.output&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Output"}),e.jsx("pre",{className:"rounded-lg bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 p-4 text-xs text-azure-text-secondary dark:text-matrix-secondary overflow-auto max-h-64 whitespace-pre-wrap leading-relaxed font-mono",children:r.output})]}),r.error&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-red-500 mb-2 flex items-center gap-1",children:[e.jsx(Y,{className:"w-3 h-3"})," Error"]}),e.jsx("pre",{className:"rounded-lg bg-red-50 dark:bg-red-950/30 border border-red-200 dark:border-red-800/50 p-4 text-xs text-red-600 dark:text-red-400 overflow-auto max-h-48 whitespace-pre-wrap leading-relaxed font-mono",children:r.error})]})]}),(h||d)&&e.jsxs("div",{className:"flex justify-end gap-2 px-5 py-4 border-t border-azure-border dark:border-matrix-primary shrink-0",children:[h&&e.jsx("button",{onClick:o,className:"px-4 py-2 rounded text-sm border border-red-300 dark:border-red-700/60 text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:"Cancel Task"}),d&&e.jsx("button",{onClick:k,className:"px-4 py-2 rounded text-sm font-medium bg-azure-primary text-white hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 transition-colors",children:"Retry Task"})]})]})]})}const J={Pending:"text-yellow-600 dark:text-yellow-400",Running:"text-blue-600 dark:text-blue-400",Completed:"text-emerald-600 dark:text-emerald-400",Failed:"text-red-600 dark:text-red-400",Cancelled:"text-zinc-500 dark:text-zinc-400",Total:"text-azure-text dark:text-matrix-highlight"};function n({label:r,value:t}){return e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black px-4 py-3",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary",children:r}),e.jsx("p",{className:`text-2xl font-bold mt-0.5 ${J[r]??"text-azure-text dark:text-matrix-secondary"}`,children:t})]})}function de(){const[r,t]=s.useState(""),[o,k]=s.useState(""),{getSubagents:h}=E(),[d,p]=s.useState(""),[c,T]=s.useState(""),[b,g]=s.useState(null),[f,v]=s.useState(1),[w,I]=s.useState(20),z=s.useMemo(()=>({status:r||void 0,agent:o||void 0,origin_channel:d||void 0,session_id:c.trim()||void 0,page:f,per_page:w}),[r,o,d,c,f,w]),y=()=>v(1),{data:i}=S("/tasks/stats",()=>m.stats(),{refreshInterval:5e3}),{data:x,mutate:N}=S(["/tasks",z],()=>m.list(z),{refreshInterval:3e3}),C=x?.data??[],j="px-3 py-2 rounded border border-azure-border dark:border-matrix-primary bg-white dark:bg-black text-azure-text dark:text-matrix-secondary text-sm focus:outline-none focus:border-azure-primary dark:focus:border-matrix-highlight";return e.jsxs(l.div,{variants:q,initial:"hidden",animate:"show",className:"space-y-6",children:[e.jsxs(l.div,{variants:u,className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(D,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Tasks"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Async tasks delegated by Oracle and processed by workers."})]})]}),e.jsxs(l.div,{variants:u,className:"grid grid-cols-3 md:grid-cols-6 gap-3",children:[e.jsx(n,{label:"Pending",value:i?.pending??0}),e.jsx(n,{label:"Running",value:i?.running??0}),e.jsx(n,{label:"Completed",value:i?.completed??0}),e.jsx(n,{label:"Failed",value:i?.failed??0}),e.jsx(n,{label:"Cancelled",value:i?.cancelled??0}),e.jsx(n,{label:"Total",value:i?.total??0})]}),e.jsxs(l.div,{variants:u,className:"rounded-lg border border-azure-border dark:border-matrix-primary p-4 bg-white dark:bg-black grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsxs("select",{className:j,value:r,onChange:a=>{t(a.target.value||""),y()},children:[e.jsx("option",{value:"",children:"All status"}),Object.entries(G).map(([a,L])=>e.jsx("option",{value:a,children:L},a))]}),e.jsxs("select",{className:j,value:o,onChange:a=>{k(a.target.value||""),y()},children:[e.jsx("option",{value:"",children:"All agents"}),h().map(a=>e.jsx("option",{value:a.agentKey,children:a.label},a.agentKey))]}),e.jsxs("select",{className:j,value:d,onChange:a=>{p(a.target.value||""),y()},children:[e.jsx("option",{value:"",children:"All channels"}),e.jsx("option",{value:"telegram",children:"Telegram"}),e.jsx("option",{value:"discord",children:"Discord"}),e.jsx("option",{value:"ui",children:"UI"}),e.jsx("option",{value:"api",children:"API"}),e.jsx("option",{value:"webhook",children:"Webhook"}),e.jsx("option",{value:"cli",children:"CLI"})]}),e.jsx("input",{className:`${j} placeholder:text-azure-text-secondary/50 dark:placeholder:text-matrix-secondary/40`,value:c,onChange:a=>{T(a.target.value),y()},placeholder:"Filter by session ID"})]}),e.jsx(l.div,{variants:u,className:"rounded-lg border border-azure-border dark:border-matrix-primary overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm min-w-[820px]",children:[e.jsx("thead",{className:"bg-azure-surface dark:bg-zinc-900 border-b border-azure-border dark:border-matrix-primary",children:e.jsx("tr",{children:[{label:"ID",cls:"w-24"},{label:"Status",cls:"w-32"},{label:"Agent",cls:"w-24"},{label:"Channel",cls:"w-24"},{label:"Session",cls:"w-28"},{label:"Attempts",cls:"w-20"},{label:"Created",cls:"w-36"},{label:"Finished",cls:"w-36"},{label:"",cls:"w-16"}].map(a=>e.jsx("th",{className:`text-left px-4 py-3 text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary ${a.cls}`,children:a.label},a.label))})}),e.jsx("tbody",{children:C.length===0?e.jsx("tr",{children:e.jsxs("td",{colSpan:9,className:"px-4 py-12 text-center text-azure-text-secondary dark:text-matrix-tertiary",children:[e.jsx(O,{className:"w-5 h-5 mx-auto mb-2 opacity-40"}),"No tasks found."]})}):C.map(a=>e.jsxs("tr",{className:"border-b border-azure-border dark:border-matrix-primary/30 hover:bg-azure-surface/60 dark:hover:bg-zinc-900/50 transition-colors",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:a.id.slice(0,8)}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(F,{status:a.status})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(R,{agent:a.agent})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx($,{channel:a.origin_channel})}),e.jsx("td",{className:"px-4 py-3 font-mono text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:a.session_id?a.session_id.slice(0,10):"—"}),e.jsxs("td",{className:"px-4 py-3 text-center text-azure-text-secondary dark:text-matrix-secondary text-xs",children:[a.attempt_count,"/",a.max_attempts]}),e.jsx("td",{className:"px-4 py-3 text-xs text-azure-text-secondary dark:text-matrix-secondary whitespace-nowrap",children:P(a.created_at)}),e.jsx("td",{className:"px-4 py-3 text-xs text-azure-text-secondary dark:text-matrix-secondary whitespace-nowrap",children:P(a.finished_at)}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>g(a),className:"p-1.5 rounded border border-azure-border dark:border-matrix-primary/50 text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-primary dark:hover:text-matrix-highlight hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",title:"View details",children:e.jsx(M,{className:"w-3.5 h-3.5"})}),(a.status==="pending"||a.status==="running")&&e.jsx("button",{onClick:async()=>{await m.cancel(a.id),N()},className:"p-1.5 rounded border border-red-200 dark:border-red-800/50 text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 hover:text-red-500 transition-colors",title:"Cancel task",children:e.jsx(K,{className:"w-3.5 h-3.5"})})]})})]},a.id))})]})})}),x&&x.total_pages>1&&e.jsx(l.div,{variants:u,children:e.jsx("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black",children:e.jsx(B,{page:f,totalPages:x.total_pages,perPage:w,total:x.total,onPageChange:v,onPerPageChange:a=>{I(a),v(1)}})})}),b&&e.jsx(H,{task:b,onClose:()=>g(null),onCancel:async()=>{await m.cancel(b.id),g(null),N()},onRetry:async()=>{await m.retry(b.id),g(null),N()}})]})}export{de as TasksPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as l}from"./vendor-react-DikRIOlj.js";import{u as ne,m as C}from"./vendor-utils-BIYveU_1.js";import{h as u}from"./index-B9ePr-vB.js";import{C as oe}from"./ConfirmationModal-DU0AwhXD.js";import{D as S,a8 as de,ae as D,af as ce,h as B,Y as me,G as xe,K as he,q as pe,X as ue}from"./vendor-icons-DE7PWdkN.js";const T={postgresql:5432,mysql:3306,mongodb:27017,sqlite:0},H={name:"",type:"postgresql",host:"",port:"",database_name:"",username:"",password:"",connection_string:"",allow_read:!0,allow_insert:!1,allow_update:!1,allow_delete:!1,allow_ddl:!1},ge={postgresql:[{key:"allow_read",label:"SELECT",description:"Permite consultas SELECT"},{key:"allow_insert",label:"INSERT",description:"Permite inserir registros"},{key:"allow_update",label:"UPDATE",description:"Permite atualizar registros"},{key:"allow_delete",label:"DELETE",description:"Permite excluir registros"},{key:"allow_ddl",label:"DDL",description:"CREATE / ALTER / DROP TABLE"}],mysql:[{key:"allow_read",label:"SELECT",description:"Permite consultas SELECT"},{key:"allow_insert",label:"INSERT",description:"Permite inserir registros"},{key:"allow_update",label:"UPDATE",description:"Permite atualizar registros"},{key:"allow_delete",label:"DELETE",description:"Permite excluir registros"},{key:"allow_ddl",label:"DDL",description:"CREATE / ALTER / DROP TABLE"}],sqlite:[{key:"allow_read",label:"SELECT",description:"Permite consultas SELECT"},{key:"allow_insert",label:"INSERT",description:"Permite inserir registros"},{key:"allow_update",label:"UPDATE",description:"Permite atualizar registros"},{key:"allow_delete",label:"DELETE",description:"Permite excluir registros"},{key:"allow_ddl",label:"DDL",description:"CREATE / ALTER / DROP TABLE"}],mongodb:[{key:"allow_read",label:"find / aggregate",description:"Permite consultas e agregações"},{key:"allow_insert",label:"insertOne / insertMany",description:"Permite inserir documentos"},{key:"allow_update",label:"updateOne / updateMany",description:"Permite atualizar documentos"},{key:"allow_delete",label:"deleteOne / deleteMany",description:"Permite excluir documentos"},{key:"allow_ddl",label:"Schema changes",description:"createCollection / dropCollection / createIndex"}]};async function be(){return u.get("/trinity/databases")}function we(){const{data:v,error:R}=ne("/trinity/databases",be,{refreshInterval:3e4}),[W,h]=l.useState(!1),[o,P]=l.useState(null),[r,n]=l.useState(H),[L,w]=l.useState(!1),[z,g]=l.useState(null),[G,Q]=l.useState({}),[q,$]=l.useState(null),[J,M]=l.useState({}),[O,A]=l.useState(null),[Y,I]=l.useState(null),[f,_]=l.useState(null),[b,y]=l.useState(!1),K=()=>{P(null),n(H),y(!1),g(null),h(!0)},X=a=>{P(a),n({name:a.name,type:a.type,host:a.host||"",port:a.port?String(a.port):"",database_name:a.database_name||"",username:a.username||"",password:"",connection_string:"",allow_read:a.allow_read,allow_insert:a.allow_insert,allow_update:a.allow_update,allow_delete:a.allow_delete,allow_ddl:a.allow_ddl}),y(!!a.connection_string),g(null),h(!0)},V=async()=>{if(w(!0),g(null),!b&&!r.database_name.trim()){g(r.type==="sqlite"?"File path is required.":"Database name is required."),w(!1);return}try{const a={name:r.name,type:r.type,allow_read:r.allow_read,allow_insert:r.allow_insert,allow_update:r.allow_update,allow_delete:r.allow_delete,allow_ddl:r.allow_ddl};b?(!o||r.connection_string)&&(a.connection_string=r.connection_string||null):(a.host=r.host||null,a.port=r.port?parseInt(r.port):null,a.database_name=r.database_name||null,a.username=r.username||null,(!o||r.password)&&(a.password=r.password||null)),o?await u.put(`/trinity/databases/${o.id}`,a):await u.post("/trinity/databases",a),await C("/trinity/databases"),h(!1)}catch(a){g(a.message||"Failed to save database")}finally{w(!1)}},Z=a=>{_(a)},ee=async()=>{if(!f)return;const a=f.id;I(a);try{await u.delete(`/trinity/databases/${a}`),await C("/trinity/databases")}catch(t){alert(`Delete failed: ${t.message}`)}finally{I(null),_(null)}},ae=async a=>{$(a);try{const t=await u.post(`/trinity/databases/${a}/test`,{});M(i=>({...i,[a]:t.success}))}catch{M(t=>({...t,[a]:!1}))}finally{$(null)}},te=async a=>{A(a);try{await u.post(`/trinity/databases/${a}/refresh-schema`,{}),await C("/trinity/databases")}catch(t){alert(`Schema refresh failed: ${t.message}`)}finally{A(null)}},re=a=>{Q(t=>({...t,[a]:!t[a]}))},se=a=>{a!=="mongodb"&&y(!1),n(t=>({...t,type:a,port:T[a]?String(T[a]):""}))},ie=a=>{n(t=>({...t,[a]:!t[a]}))};if(R)return e.jsxs("div",{className:"p-8 text-red-500",children:["Failed to load databases: ",R.message]});const x="w-full px-3 py-2 bg-azure-surface dark:bg-black border border-azure-border dark:border-matrix-primary rounded text-azure-text-primary dark:text-matrix-secondary font-mono text-sm focus:outline-none focus:border-azure-primary dark:focus:border-matrix-highlight",m="block text-xs font-medium text-azure-text-secondary dark:text-matrix-secondary mb-1",le=a=>[{key:"allow_read",badge:"R"},{key:"allow_insert",badge:"I"},{key:"allow_update",badge:"U"},{key:"allow_delete",badge:"D"},{key:"allow_ddl",badge:"DDL"}].filter(i=>a[i.key]).map(i=>i.badge);return e.jsxs("div",{className:"max-w-5xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(S,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Trinity Databases"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Register databases for Trinity to access and query."})]})]}),e.jsxs("button",{onClick:K,className:"flex items-center gap-2 px-4 py-2 bg-azure-primary text-white rounded hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 transition-colors text-sm font-medium",children:[e.jsx(de,{className:"w-4 h-4"}),"Register Database"]})]}),v?v.length===0?e.jsxs("div",{className:"border border-azure-border dark:border-matrix-primary rounded p-8 text-center text-azure-text-secondary dark:text-matrix-secondary",children:[e.jsx(S,{className:"w-10 h-10 mx-auto mb-3 opacity-40"}),e.jsx("p",{className:"font-medium",children:"No databases registered"}),e.jsx("p",{className:"text-sm mt-1 opacity-70",children:'Click "Register Database" to add your first database.'})]}):e.jsx("div",{className:"space-y-4",children:v.map(a=>{const t=a.schema_json?JSON.parse(a.schema_json):null,i=!!t?.databases,c=i?t.databases.reduce((s,d)=>s+d.tables.length,0):t?.tables?.length??0,j=i?t.databases.length:0,k=a.type==="mongodb"?"collection":"table",p=a.type==="mongodb"?"collections":"tables",U=J[a.id],E=G[a.id],F=le(a);return e.jsxs("div",{className:"border border-azure-border dark:border-matrix-primary rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"bg-azure-surface dark:bg-black/50 px-4 py-3 flex items-center gap-3",children:[e.jsx(S,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-bold text-azure-text-primary dark:text-matrix-highlight truncate",children:a.name}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary uppercase flex-shrink-0",children:a.type}),U===!0&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-green-500",children:[e.jsx(D,{className:"w-3 h-3"})," Connected"]}),U===!1&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-red-500",children:[e.jsx(ce,{className:"w-3 h-3"})," Failed"]}),F.length>0&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(B,{className:"w-3 h-3 text-azure-text-secondary dark:text-matrix-secondary opacity-60"}),F.map(s=>e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-azure-primary/10 dark:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight font-mono",children:s},s))]})]}),e.jsxs("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary truncate mt-0.5",children:[a.host?`${a.host}:${a.port}${a.database_name?`/${a.database_name}`:""}`:a.database_name||"connection string configured",i&&j>0&&e.jsxs("span",{className:"ml-2 opacity-70",children:["· ",j," database",j!==1?"s":""," · ",c," ",c!==1?p:k]}),!i&&c>0&&e.jsxs("span",{className:"ml-2 opacity-70",children:["· ",c," ",c!==1?p:k]}),a.schema_updated_at&&e.jsxs("span",{className:"ml-2 opacity-50",children:["· schema ",new Date(a.schema_updated_at).toLocaleDateString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx("button",{onClick:()=>ae(a.id),disabled:q===a.id,title:"Test connection",className:"p-1.5 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary transition-colors",children:q===a.id?e.jsx(D,{className:"w-4 h-4 animate-pulse"}):e.jsx(D,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>te(a.id),disabled:O===a.id,title:"Refresh schema",className:"p-1.5 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary transition-colors",children:e.jsx(me,{className:`w-4 h-4 ${O===a.id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>X(a),title:"Edit",className:"p-1.5 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary transition-colors text-xs font-medium px-2",children:"Edit"}),e.jsx("button",{onClick:()=>Z(a),disabled:Y===a.id,title:"Delete",className:"p-1.5 rounded hover:bg-red-50 dark:hover:bg-red-900/20 text-red-500 transition-colors",children:e.jsx(xe,{className:"w-4 h-4"})}),t&&e.jsx("button",{onClick:()=>re(a.id),title:E?"Hide schema":"Show schema",className:"p-1.5 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary transition-colors",children:E?e.jsx(he,{className:"w-4 h-4"}):e.jsx(pe,{className:"w-4 h-4"})})]})]}),E&&t&&e.jsxs("div",{className:"border-t border-azure-border dark:border-matrix-primary px-4 py-3 bg-azure-bg dark:bg-black/20",children:[e.jsx("div",{className:"text-xs font-medium text-azure-text-secondary dark:text-matrix-secondary mb-2",children:i?`${j} database${j!==1?"s":""} — ${c} ${c!==1?p:k} total`:`Schema — ${c} ${c!==1?p:k}`}),e.jsx("div",{className:"space-y-2 max-h-72 overflow-y-auto",children:i?t.databases?.map(s=>e.jsxs("div",{className:"text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx("span",{className:"font-bold text-azure-primary dark:text-matrix-highlight",children:s.name}),e.jsxs("span",{className:"opacity-40 text-azure-text-secondary dark:text-matrix-secondary",children:["(",s.tables.length," ",s.tables.length!==1?p:k,")"]})]}),e.jsxs("div",{className:"pl-3 space-y-1.5 border-l border-azure-border dark:border-matrix-primary/40 ml-1",children:[s.tables.map(d=>e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-azure-text-primary dark:text-matrix-secondary mb-0.5",children:d.name}),e.jsx("div",{className:"pl-3 space-y-0.5",children:d.columns?.map(N=>e.jsxs("div",{className:"text-azure-text-secondary dark:text-matrix-secondary font-mono",children:[e.jsx("span",{children:N.name}),e.jsx("span",{className:"opacity-50 ml-2",children:N.type}),N.nullable===!1&&e.jsx("span",{className:"ml-1 opacity-40",children:"NOT NULL"})]},N.name))})]},d.name)),s.tables.length===0&&e.jsxs("div",{className:"text-azure-text-secondary dark:text-matrix-secondary opacity-50 italic",children:["no ",p]})]})]},s.name)):t.tables?.map(s=>e.jsxs("div",{className:"text-xs",children:[e.jsx("div",{className:"font-bold text-azure-primary dark:text-matrix-highlight mb-1",children:s.name}),e.jsx("div",{className:"pl-3 space-y-0.5",children:s.columns?.map(d=>e.jsxs("div",{className:"text-azure-text-secondary dark:text-matrix-secondary font-mono",children:[e.jsx("span",{className:"text-azure-text-primary dark:text-matrix-secondary",children:d.name}),e.jsx("span",{className:"opacity-50 ml-2",children:d.type}),d.nullable===!1&&e.jsx("span",{className:"ml-1 opacity-40 text-xs",children:"NOT NULL"})]},d.name))})]},s.name))})]})]},a.id)})}):e.jsx("div",{className:"text-azure-text-secondary dark:text-matrix-secondary",children:"Loading..."}),e.jsx(oe,{isOpen:!!f,onClose:()=>_(null),onConfirm:ee,title:"Delete database",description:`Remove "${f?.name}" from Trinity? The database itself won't be affected — only this registration will be deleted.`,confirmJson:"Delete",variant:"destructive"}),W&&e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>h(!1)}),e.jsxs("div",{className:"relative bg-azure-surface dark:bg-black border border-azure-border dark:border-matrix-primary rounded-lg shadow-xl w-full max-w-lg mx-4 max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-azure-border dark:border-matrix-primary",children:[e.jsx("h2",{className:"text-lg font-bold text-azure-text-primary dark:text-matrix-highlight",children:o?"Edit Database":"Register Database"}),e.jsx("button",{onClick:()=>h(!1),className:"text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-text-primary dark:hover:text-matrix-highlight",children:e.jsx(ue,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Name *"}),e.jsx("input",{className:x,value:r.name,onChange:a=>n(t=>({...t,name:a.target.value})),placeholder:"My Production DB"})]}),e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Type *"}),e.jsxs("select",{className:x,value:r.type,onChange:a=>se(a.target.value),children:[e.jsx("option",{value:"postgresql",children:"PostgreSQL"}),e.jsx("option",{value:"mysql",children:"MySQL / MariaDB"}),e.jsx("option",{value:"sqlite",children:"SQLite"}),e.jsx("option",{value:"mongodb",children:"MongoDB"})]})]}),r.type==="mongodb"&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>y(!1),className:`text-xs px-3 py-1.5 rounded border transition-colors ${b?"border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary":"border-azure-primary dark:border-matrix-highlight bg-azure-primary/10 dark:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight"}`,children:"Individual fields"}),e.jsx("button",{type:"button",onClick:()=>y(!0),className:`text-xs px-3 py-1.5 rounded border transition-colors ${b?"border-azure-primary dark:border-matrix-highlight bg-azure-primary/10 dark:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight":"border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary"}`,children:"Connection string"})]}),r.type==="mongodb"&&b?e.jsxs("div",{children:[e.jsxs("label",{className:m,children:["Connection String ",o&&e.jsx("span",{className:"opacity-60",children:"(leave blank to keep existing)"})]}),e.jsx("input",{className:x,type:"password",value:r.connection_string,onChange:a=>n(t=>({...t,connection_string:a.target.value})),placeholder:o?"unchanged":"mongodb://user:pass@host:27017/dbname"}),e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Stored encrypted with AES-256-GCM. Requires MORPHEUS_SECRET env var."})]}):e.jsxs(e.Fragment,{children:[r.type!=="sqlite"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Host"}),e.jsx("input",{className:x,value:r.host,onChange:a=>n(t=>({...t,host:a.target.value})),placeholder:"localhost"})]}),e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Port"}),e.jsx("input",{className:x,type:"number",value:r.port,onChange:a=>n(t=>({...t,port:a.target.value})),placeholder:String(T[r.type]||"")})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:m,children:[r.type==="sqlite"?"File Path":"Database Name"," *"]}),e.jsx("input",{className:`w-full px-3 py-2 bg-azure-surface dark:bg-black border rounded text-azure-text-primary dark:text-matrix-secondary font-mono text-sm focus:outline-none ${z&&!r.database_name.trim()?"border-red-500 dark:border-red-500":"border-azure-border dark:border-matrix-primary focus:border-azure-primary dark:focus:border-matrix-highlight"}`,value:r.database_name,onChange:a=>n(t=>({...t,database_name:a.target.value})),placeholder:r.type==="sqlite"?"/path/to/database.db":"mydb"})]}),r.type!=="sqlite"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Username"}),e.jsx("input",{className:x,value:r.username,onChange:a=>n(t=>({...t,username:a.target.value})),placeholder:"postgres"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:m,children:["Password ",o&&e.jsx("span",{className:"opacity-60",children:"(leave blank to keep existing)"})]}),e.jsx("input",{className:x,type:"password",value:r.password,onChange:a=>n(t=>({...t,password:a.target.value})),placeholder:o?"unchanged":"••••••••"}),e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Stored encrypted with AES-256-GCM. Requires MORPHEUS_SECRET env var."})]})]})]}),e.jsxs("div",{className:"border-t border-azure-border dark:border-matrix-primary pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(B,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight"}),e.jsx("span",{className:"text-sm font-medium text-azure-text-primary dark:text-matrix-highlight",children:"Permissões"})]}),e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mb-3",children:"Defina quais operações Trinity pode executar neste banco. Operações não permitidas retornarão erro de permissão."}),e.jsx("div",{className:"space-y-2",children:ge[r.type]?.map(({key:a,label:t,description:i})=>e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsxs("div",{className:"relative mt-0.5 flex-shrink-0",children:[e.jsx("input",{type:"checkbox",checked:!!r[a],onChange:()=>ie(a),className:"sr-only"}),e.jsx("div",{className:`w-4 h-4 rounded border transition-colors flex items-center justify-center ${r[a]?"bg-azure-primary dark:bg-matrix-highlight border-azure-primary dark:border-matrix-highlight":"border-azure-border dark:border-matrix-primary bg-transparent"}`,children:r[a]&&e.jsx("svg",{className:"w-2.5 h-2.5 text-white dark:text-black",fill:"none",viewBox:"0 0 10 10",children:e.jsx("path",{d:"M1.5 5l2.5 2.5L8.5 2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-azure-text-primary dark:text-matrix-secondary font-mono",children:t}),e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary opacity-70",children:i})]})]},a))})]}),z&&e.jsx("div",{className:"text-sm text-red-500 border border-red-500/30 bg-red-500/10 rounded px-3 py-2",children:z})]}),e.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-azure-border dark:border-matrix-primary",children:[e.jsx("button",{onClick:()=>h(!1),className:"px-4 py-2 text-sm text-azure-text-secondary dark:text-matrix-secondary border border-azure-border dark:border-matrix-primary rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:V,disabled:L||!r.name,className:"px-4 py-2 text-sm font-medium bg-azure-primary text-white rounded hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 transition-colors disabled:opacity-50",children:L?"Saving...":o?"Update":"Register"})]})]})]})]})}export{we as TrinityDatabases};
|
|
1
|
+
import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as l}from"./vendor-react-DikRIOlj.js";import{u as ne,m as C}from"./vendor-utils-BIYveU_1.js";import{h as u}from"./index-BvsF1a9j.js";import{C as oe}from"./ConfirmationModal-CxvFe-We.js";import{D as S,a8 as de,ae as D,af as ce,h as B,Y as me,G as xe,K as he,q as pe,X as ue}from"./vendor-icons-DE7PWdkN.js";const T={postgresql:5432,mysql:3306,mongodb:27017,sqlite:0},H={name:"",type:"postgresql",host:"",port:"",database_name:"",username:"",password:"",connection_string:"",allow_read:!0,allow_insert:!1,allow_update:!1,allow_delete:!1,allow_ddl:!1},ge={postgresql:[{key:"allow_read",label:"SELECT",description:"Permite consultas SELECT"},{key:"allow_insert",label:"INSERT",description:"Permite inserir registros"},{key:"allow_update",label:"UPDATE",description:"Permite atualizar registros"},{key:"allow_delete",label:"DELETE",description:"Permite excluir registros"},{key:"allow_ddl",label:"DDL",description:"CREATE / ALTER / DROP TABLE"}],mysql:[{key:"allow_read",label:"SELECT",description:"Permite consultas SELECT"},{key:"allow_insert",label:"INSERT",description:"Permite inserir registros"},{key:"allow_update",label:"UPDATE",description:"Permite atualizar registros"},{key:"allow_delete",label:"DELETE",description:"Permite excluir registros"},{key:"allow_ddl",label:"DDL",description:"CREATE / ALTER / DROP TABLE"}],sqlite:[{key:"allow_read",label:"SELECT",description:"Permite consultas SELECT"},{key:"allow_insert",label:"INSERT",description:"Permite inserir registros"},{key:"allow_update",label:"UPDATE",description:"Permite atualizar registros"},{key:"allow_delete",label:"DELETE",description:"Permite excluir registros"},{key:"allow_ddl",label:"DDL",description:"CREATE / ALTER / DROP TABLE"}],mongodb:[{key:"allow_read",label:"find / aggregate",description:"Permite consultas e agregações"},{key:"allow_insert",label:"insertOne / insertMany",description:"Permite inserir documentos"},{key:"allow_update",label:"updateOne / updateMany",description:"Permite atualizar documentos"},{key:"allow_delete",label:"deleteOne / deleteMany",description:"Permite excluir documentos"},{key:"allow_ddl",label:"Schema changes",description:"createCollection / dropCollection / createIndex"}]};async function be(){return u.get("/trinity/databases")}function we(){const{data:v,error:R}=ne("/trinity/databases",be,{refreshInterval:3e4}),[W,h]=l.useState(!1),[o,P]=l.useState(null),[r,n]=l.useState(H),[L,w]=l.useState(!1),[z,g]=l.useState(null),[G,Q]=l.useState({}),[q,$]=l.useState(null),[J,M]=l.useState({}),[O,A]=l.useState(null),[Y,I]=l.useState(null),[f,_]=l.useState(null),[b,y]=l.useState(!1),K=()=>{P(null),n(H),y(!1),g(null),h(!0)},X=a=>{P(a),n({name:a.name,type:a.type,host:a.host||"",port:a.port?String(a.port):"",database_name:a.database_name||"",username:a.username||"",password:"",connection_string:"",allow_read:a.allow_read,allow_insert:a.allow_insert,allow_update:a.allow_update,allow_delete:a.allow_delete,allow_ddl:a.allow_ddl}),y(!!a.connection_string),g(null),h(!0)},V=async()=>{if(w(!0),g(null),!b&&!r.database_name.trim()){g(r.type==="sqlite"?"File path is required.":"Database name is required."),w(!1);return}try{const a={name:r.name,type:r.type,allow_read:r.allow_read,allow_insert:r.allow_insert,allow_update:r.allow_update,allow_delete:r.allow_delete,allow_ddl:r.allow_ddl};b?(!o||r.connection_string)&&(a.connection_string=r.connection_string||null):(a.host=r.host||null,a.port=r.port?parseInt(r.port):null,a.database_name=r.database_name||null,a.username=r.username||null,(!o||r.password)&&(a.password=r.password||null)),o?await u.put(`/trinity/databases/${o.id}`,a):await u.post("/trinity/databases",a),await C("/trinity/databases"),h(!1)}catch(a){g(a.message||"Failed to save database")}finally{w(!1)}},Z=a=>{_(a)},ee=async()=>{if(!f)return;const a=f.id;I(a);try{await u.delete(`/trinity/databases/${a}`),await C("/trinity/databases")}catch(t){alert(`Delete failed: ${t.message}`)}finally{I(null),_(null)}},ae=async a=>{$(a);try{const t=await u.post(`/trinity/databases/${a}/test`,{});M(i=>({...i,[a]:t.success}))}catch{M(t=>({...t,[a]:!1}))}finally{$(null)}},te=async a=>{A(a);try{await u.post(`/trinity/databases/${a}/refresh-schema`,{}),await C("/trinity/databases")}catch(t){alert(`Schema refresh failed: ${t.message}`)}finally{A(null)}},re=a=>{Q(t=>({...t,[a]:!t[a]}))},se=a=>{a!=="mongodb"&&y(!1),n(t=>({...t,type:a,port:T[a]?String(T[a]):""}))},ie=a=>{n(t=>({...t,[a]:!t[a]}))};if(R)return e.jsxs("div",{className:"p-8 text-red-500",children:["Failed to load databases: ",R.message]});const x="w-full px-3 py-2 bg-azure-surface dark:bg-black border border-azure-border dark:border-matrix-primary rounded text-azure-text-primary dark:text-matrix-secondary font-mono text-sm focus:outline-none focus:border-azure-primary dark:focus:border-matrix-highlight",m="block text-xs font-medium text-azure-text-secondary dark:text-matrix-secondary mb-1",le=a=>[{key:"allow_read",badge:"R"},{key:"allow_insert",badge:"I"},{key:"allow_update",badge:"U"},{key:"allow_delete",badge:"D"},{key:"allow_ddl",badge:"DDL"}].filter(i=>a[i.key]).map(i=>i.badge);return e.jsxs("div",{className:"max-w-5xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(S,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Trinity Databases"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Register databases for Trinity to access and query."})]})]}),e.jsxs("button",{onClick:K,className:"flex items-center gap-2 px-4 py-2 bg-azure-primary text-white rounded hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 transition-colors text-sm font-medium",children:[e.jsx(de,{className:"w-4 h-4"}),"Register Database"]})]}),v?v.length===0?e.jsxs("div",{className:"border border-azure-border dark:border-matrix-primary rounded p-8 text-center text-azure-text-secondary dark:text-matrix-secondary",children:[e.jsx(S,{className:"w-10 h-10 mx-auto mb-3 opacity-40"}),e.jsx("p",{className:"font-medium",children:"No databases registered"}),e.jsx("p",{className:"text-sm mt-1 opacity-70",children:'Click "Register Database" to add your first database.'})]}):e.jsx("div",{className:"space-y-4",children:v.map(a=>{const t=a.schema_json?JSON.parse(a.schema_json):null,i=!!t?.databases,c=i?t.databases.reduce((s,d)=>s+d.tables.length,0):t?.tables?.length??0,j=i?t.databases.length:0,k=a.type==="mongodb"?"collection":"table",p=a.type==="mongodb"?"collections":"tables",U=J[a.id],E=G[a.id],F=le(a);return e.jsxs("div",{className:"border border-azure-border dark:border-matrix-primary rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"bg-azure-surface dark:bg-black/50 px-4 py-3 flex items-center gap-3",children:[e.jsx(S,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-bold text-azure-text-primary dark:text-matrix-highlight truncate",children:a.name}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary uppercase flex-shrink-0",children:a.type}),U===!0&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-green-500",children:[e.jsx(D,{className:"w-3 h-3"})," Connected"]}),U===!1&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-red-500",children:[e.jsx(ce,{className:"w-3 h-3"})," Failed"]}),F.length>0&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(B,{className:"w-3 h-3 text-azure-text-secondary dark:text-matrix-secondary opacity-60"}),F.map(s=>e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-azure-primary/10 dark:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight font-mono",children:s},s))]})]}),e.jsxs("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary truncate mt-0.5",children:[a.host?`${a.host}:${a.port}${a.database_name?`/${a.database_name}`:""}`:a.database_name||"connection string configured",i&&j>0&&e.jsxs("span",{className:"ml-2 opacity-70",children:["· ",j," database",j!==1?"s":""," · ",c," ",c!==1?p:k]}),!i&&c>0&&e.jsxs("span",{className:"ml-2 opacity-70",children:["· ",c," ",c!==1?p:k]}),a.schema_updated_at&&e.jsxs("span",{className:"ml-2 opacity-50",children:["· schema ",new Date(a.schema_updated_at).toLocaleDateString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx("button",{onClick:()=>ae(a.id),disabled:q===a.id,title:"Test connection",className:"p-1.5 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary transition-colors",children:q===a.id?e.jsx(D,{className:"w-4 h-4 animate-pulse"}):e.jsx(D,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>te(a.id),disabled:O===a.id,title:"Refresh schema",className:"p-1.5 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary transition-colors",children:e.jsx(me,{className:`w-4 h-4 ${O===a.id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>X(a),title:"Edit",className:"p-1.5 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary transition-colors text-xs font-medium px-2",children:"Edit"}),e.jsx("button",{onClick:()=>Z(a),disabled:Y===a.id,title:"Delete",className:"p-1.5 rounded hover:bg-red-50 dark:hover:bg-red-900/20 text-red-500 transition-colors",children:e.jsx(xe,{className:"w-4 h-4"})}),t&&e.jsx("button",{onClick:()=>re(a.id),title:E?"Hide schema":"Show schema",className:"p-1.5 rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary transition-colors",children:E?e.jsx(he,{className:"w-4 h-4"}):e.jsx(pe,{className:"w-4 h-4"})})]})]}),E&&t&&e.jsxs("div",{className:"border-t border-azure-border dark:border-matrix-primary px-4 py-3 bg-azure-bg dark:bg-black/20",children:[e.jsx("div",{className:"text-xs font-medium text-azure-text-secondary dark:text-matrix-secondary mb-2",children:i?`${j} database${j!==1?"s":""} — ${c} ${c!==1?p:k} total`:`Schema — ${c} ${c!==1?p:k}`}),e.jsx("div",{className:"space-y-2 max-h-72 overflow-y-auto",children:i?t.databases?.map(s=>e.jsxs("div",{className:"text-xs",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx("span",{className:"font-bold text-azure-primary dark:text-matrix-highlight",children:s.name}),e.jsxs("span",{className:"opacity-40 text-azure-text-secondary dark:text-matrix-secondary",children:["(",s.tables.length," ",s.tables.length!==1?p:k,")"]})]}),e.jsxs("div",{className:"pl-3 space-y-1.5 border-l border-azure-border dark:border-matrix-primary/40 ml-1",children:[s.tables.map(d=>e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-azure-text-primary dark:text-matrix-secondary mb-0.5",children:d.name}),e.jsx("div",{className:"pl-3 space-y-0.5",children:d.columns?.map(N=>e.jsxs("div",{className:"text-azure-text-secondary dark:text-matrix-secondary font-mono",children:[e.jsx("span",{children:N.name}),e.jsx("span",{className:"opacity-50 ml-2",children:N.type}),N.nullable===!1&&e.jsx("span",{className:"ml-1 opacity-40",children:"NOT NULL"})]},N.name))})]},d.name)),s.tables.length===0&&e.jsxs("div",{className:"text-azure-text-secondary dark:text-matrix-secondary opacity-50 italic",children:["no ",p]})]})]},s.name)):t.tables?.map(s=>e.jsxs("div",{className:"text-xs",children:[e.jsx("div",{className:"font-bold text-azure-primary dark:text-matrix-highlight mb-1",children:s.name}),e.jsx("div",{className:"pl-3 space-y-0.5",children:s.columns?.map(d=>e.jsxs("div",{className:"text-azure-text-secondary dark:text-matrix-secondary font-mono",children:[e.jsx("span",{className:"text-azure-text-primary dark:text-matrix-secondary",children:d.name}),e.jsx("span",{className:"opacity-50 ml-2",children:d.type}),d.nullable===!1&&e.jsx("span",{className:"ml-1 opacity-40 text-xs",children:"NOT NULL"})]},d.name))})]},s.name))})]})]},a.id)})}):e.jsx("div",{className:"text-azure-text-secondary dark:text-matrix-secondary",children:"Loading..."}),e.jsx(oe,{isOpen:!!f,onClose:()=>_(null),onConfirm:ee,title:"Delete database",description:`Remove "${f?.name}" from Trinity? The database itself won't be affected — only this registration will be deleted.`,confirmJson:"Delete",variant:"destructive"}),W&&e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>h(!1)}),e.jsxs("div",{className:"relative bg-azure-surface dark:bg-black border border-azure-border dark:border-matrix-primary rounded-lg shadow-xl w-full max-w-lg mx-4 max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-azure-border dark:border-matrix-primary",children:[e.jsx("h2",{className:"text-lg font-bold text-azure-text-primary dark:text-matrix-highlight",children:o?"Edit Database":"Register Database"}),e.jsx("button",{onClick:()=>h(!1),className:"text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-text-primary dark:hover:text-matrix-highlight",children:e.jsx(ue,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Name *"}),e.jsx("input",{className:x,value:r.name,onChange:a=>n(t=>({...t,name:a.target.value})),placeholder:"My Production DB"})]}),e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Type *"}),e.jsxs("select",{className:x,value:r.type,onChange:a=>se(a.target.value),children:[e.jsx("option",{value:"postgresql",children:"PostgreSQL"}),e.jsx("option",{value:"mysql",children:"MySQL / MariaDB"}),e.jsx("option",{value:"sqlite",children:"SQLite"}),e.jsx("option",{value:"mongodb",children:"MongoDB"})]})]}),r.type==="mongodb"&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>y(!1),className:`text-xs px-3 py-1.5 rounded border transition-colors ${b?"border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary":"border-azure-primary dark:border-matrix-highlight bg-azure-primary/10 dark:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight"}`,children:"Individual fields"}),e.jsx("button",{type:"button",onClick:()=>y(!0),className:`text-xs px-3 py-1.5 rounded border transition-colors ${b?"border-azure-primary dark:border-matrix-highlight bg-azure-primary/10 dark:bg-matrix-highlight/10 text-azure-primary dark:text-matrix-highlight":"border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary"}`,children:"Connection string"})]}),r.type==="mongodb"&&b?e.jsxs("div",{children:[e.jsxs("label",{className:m,children:["Connection String ",o&&e.jsx("span",{className:"opacity-60",children:"(leave blank to keep existing)"})]}),e.jsx("input",{className:x,type:"password",value:r.connection_string,onChange:a=>n(t=>({...t,connection_string:a.target.value})),placeholder:o?"unchanged":"mongodb://user:pass@host:27017/dbname"}),e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Stored encrypted with AES-256-GCM. Requires MORPHEUS_SECRET env var."})]}):e.jsxs(e.Fragment,{children:[r.type!=="sqlite"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Host"}),e.jsx("input",{className:x,value:r.host,onChange:a=>n(t=>({...t,host:a.target.value})),placeholder:"localhost"})]}),e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Port"}),e.jsx("input",{className:x,type:"number",value:r.port,onChange:a=>n(t=>({...t,port:a.target.value})),placeholder:String(T[r.type]||"")})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:m,children:[r.type==="sqlite"?"File Path":"Database Name"," *"]}),e.jsx("input",{className:`w-full px-3 py-2 bg-azure-surface dark:bg-black border rounded text-azure-text-primary dark:text-matrix-secondary font-mono text-sm focus:outline-none ${z&&!r.database_name.trim()?"border-red-500 dark:border-red-500":"border-azure-border dark:border-matrix-primary focus:border-azure-primary dark:focus:border-matrix-highlight"}`,value:r.database_name,onChange:a=>n(t=>({...t,database_name:a.target.value})),placeholder:r.type==="sqlite"?"/path/to/database.db":"mydb"})]}),r.type!=="sqlite"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:m,children:"Username"}),e.jsx("input",{className:x,value:r.username,onChange:a=>n(t=>({...t,username:a.target.value})),placeholder:"postgres"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:m,children:["Password ",o&&e.jsx("span",{className:"opacity-60",children:"(leave blank to keep existing)"})]}),e.jsx("input",{className:x,type:"password",value:r.password,onChange:a=>n(t=>({...t,password:a.target.value})),placeholder:o?"unchanged":"••••••••"}),e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mt-1",children:"Stored encrypted with AES-256-GCM. Requires MORPHEUS_SECRET env var."})]})]})]}),e.jsxs("div",{className:"border-t border-azure-border dark:border-matrix-primary pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(B,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight"}),e.jsx("span",{className:"text-sm font-medium text-azure-text-primary dark:text-matrix-highlight",children:"Permissões"})]}),e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary mb-3",children:"Defina quais operações Trinity pode executar neste banco. Operações não permitidas retornarão erro de permissão."}),e.jsx("div",{className:"space-y-2",children:ge[r.type]?.map(({key:a,label:t,description:i})=>e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsxs("div",{className:"relative mt-0.5 flex-shrink-0",children:[e.jsx("input",{type:"checkbox",checked:!!r[a],onChange:()=>ie(a),className:"sr-only"}),e.jsx("div",{className:`w-4 h-4 rounded border transition-colors flex items-center justify-center ${r[a]?"bg-azure-primary dark:bg-matrix-highlight border-azure-primary dark:border-matrix-highlight":"border-azure-border dark:border-matrix-primary bg-transparent"}`,children:r[a]&&e.jsx("svg",{className:"w-2.5 h-2.5 text-white dark:text-black",fill:"none",viewBox:"0 0 10 10",children:e.jsx("path",{d:"M1.5 5l2.5 2.5L8.5 2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-azure-text-primary dark:text-matrix-secondary font-mono",children:t}),e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary opacity-70",children:i})]})]},a))})]}),z&&e.jsx("div",{className:"text-sm text-red-500 border border-red-500/30 bg-red-500/10 rounded px-3 py-2",children:z})]}),e.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-azure-border dark:border-matrix-primary",children:[e.jsx("button",{onClick:()=>h(!1),className:"px-4 py-2 text-sm text-azure-text-secondary dark:text-matrix-secondary border border-azure-border dark:border-matrix-primary rounded hover:bg-azure-hover dark:hover:bg-matrix-primary/30 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:V,disabled:L||!r.name,className:"px-4 py-2 text-sm font-medium bg-azure-primary text-white rounded hover:bg-azure-active dark:bg-matrix-highlight dark:text-black dark:hover:bg-matrix-highlight/90 transition-colors disabled:opacity-50",children:L?"Saving...":o?"Update":"Register"})]})]})]})]})}export{we as TrinityDatabases};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,m as r}from"./vendor-motion-C3CZ8ZlO.js";import{r as d}from"./vendor-react-DikRIOlj.js";import{s as n}from"./stats-
|
|
1
|
+
import{j as e,m as r}from"./vendor-motion-C3CZ8ZlO.js";import{r as d}from"./vendor-react-DikRIOlj.js";import{s as n}from"./stats-C8KAfpHO.js";import{k as b,c as k,D as j,i as N}from"./vendor-icons-DE7PWdkN.js";import"./index-BvsF1a9j.js";import"./vendor-utils-BIYveU_1.js";function w(){const[o,c]=d.useState(null),[i,x]=d.useState([]),[m,h]=d.useState(!0),[l,u]=d.useState("");if(d.useEffect(()=>{async function t(){try{const[s,p]=await Promise.all([n.fetchUsageStats(),n.fetchGroupedUsageStats()]);c(s),x(p)}catch(s){u("Failed to load usage statistics"),console.error(s)}finally{h(!1)}}t()},[]),m)return e.jsx("div",{className:"flex items-center justify-center h-64 text-azure-accent dark:text-matrix-highlight font-mono animate-pulse",children:"LOADING_DATA_STREAM..."});if(l)return e.jsxs("div",{className:"p-4 bg-red-900/20 border border-red-500/50 text-red-500 font-mono rounded",children:["ERROR_ACCESSING_DATABASE: ",l]});const g={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.1}}},a={hidden:{y:20,opacity:0},show:{y:0,opacity:1}};return e.jsxs(r.div,{variants:g,initial:"hidden",animate:"show",className:"space-y-6",children:[e.jsxs(r.div,{variants:a,className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(b,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Usage Stats"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Resource consumption tracking and cost metrics."})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs(r.div,{variants:a,className:"p-6 bg-azure-surface dark:bg-black/40 border border-azure-border dark:border-matrix-primary rounded-lg shadow-sm backdrop-blur-sm",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2 text-azure-text-muted dark:text-matrix-secondary",children:[e.jsx(k,{className:"w-5 h-5"}),e.jsx("h3",{className:"font-mono text-sm font-bold uppercase",children:"Total Input Tokens"})]}),e.jsx("p",{className:"text-3xl font-bold text-azure-primary dark:text-matrix-highlight font-mono",children:o?.totalInputTokens.toLocaleString()??0})]}),e.jsxs(r.div,{variants:a,className:"p-6 bg-azure-surface dark:bg-black/40 border border-azure-border dark:border-matrix-primary rounded-lg shadow-sm backdrop-blur-sm",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2 text-azure-text-muted dark:text-matrix-secondary",children:[e.jsx(j,{className:"w-5 h-5"}),e.jsx("h3",{className:"font-mono text-sm font-bold uppercase",children:"Total Output Tokens"})]}),e.jsx("p",{className:"text-3xl font-bold text-azure-primary dark:text-matrix-highlight font-mono",children:o?.totalOutputTokens.toLocaleString()??0})]}),e.jsxs(r.div,{variants:a,className:"p-6 bg-azure-surface dark:bg-black/40 border border-azure-border dark:border-matrix-primary rounded-lg shadow-sm backdrop-blur-sm",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2 text-azure-text-muted dark:text-matrix-secondary",children:[e.jsx(N,{className:"w-5 h-5"}),e.jsx("h3",{className:"font-mono text-sm font-bold uppercase",children:"Est. Total Cost"})]}),e.jsx("p",{className:"text-3xl font-bold text-green-600 dark:text-green-400 font-mono",children:o?.totalEstimatedCostUsd!=null?`$${o.totalEstimatedCostUsd.toFixed(4)}`:"—"})]})]}),e.jsxs(r.div,{variants:a,className:"bg-azure-surface dark:bg-black/40 border border-azure-border dark:border-matrix-primary rounded-lg overflow-hidden backdrop-blur-sm",children:[e.jsx("div",{className:"p-4 border-b border-azure-border dark:border-matrix-primary bg-azure-bg dark:bg-zinc-900/50",children:e.jsx("h3",{className:"text-lg font-bold text-azure-text-primary dark:text-matrix-highlight font-mono uppercase",children:"Usage Breakdown by Model"})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left font-mono text-sm",children:[e.jsx("thead",{className:"bg-azure-bg dark:bg-zinc-900/50 text-azure-text-secondary dark:text-matrix-secondary border-b border-azure-border dark:border-matrix-primary",children:e.jsxs("tr",{children:[e.jsx("th",{className:"p-4",children:"Provider"}),e.jsx("th",{className:"p-4",children:"Model"}),e.jsx("th",{className:"p-4 text-right",children:"Messages"}),e.jsx("th",{className:"p-4 text-right",children:"Input Tokens"}),e.jsx("th",{className:"p-4 text-right",children:"Output Tokens"}),e.jsx("th",{className:"p-4 text-right",children:"Total Tokens"}),e.jsx("th",{className:"p-4 text-right",children:"Audio (s)"}),e.jsx("th",{className:"p-4 text-right",children:"Est. Cost (USD)"})]})}),e.jsx("tbody",{className:"divide-y divide-azure-border dark:divide-matrix-primary/30",children:i.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:8,className:"p-8 text-center text-azure-text-muted dark:text-matrix-secondary italic",children:"NO_DATA_AVAILABLE"})}):i.map((t,s)=>e.jsxs("tr",{className:"hover:bg-azure-hover dark:hover:bg-matrix-primary/10 transition-colors",children:[e.jsx("td",{className:"p-4 font-bold text-azure-text-primary dark:text-matrix-highlight",children:t.provider}),e.jsx("td",{className:"p-4 text-azure-text-secondary dark:text-matrix-secondary",children:t.model}),e.jsx("td",{className:"p-4 text-right text-azure-text-primary dark:text-gray-300",children:t.messageCount.toLocaleString()}),e.jsx("td",{className:"p-4 text-right text-azure-text-primary dark:text-gray-300",children:t.totalInputTokens.toLocaleString()}),e.jsx("td",{className:"p-4 text-right text-azure-text-primary dark:text-gray-300",children:t.totalOutputTokens.toLocaleString()}),e.jsx("td",{className:"p-4 text-right font-bold text-azure-text-primary dark:text-matrix-highlight",children:t.totalTokens.toLocaleString()}),e.jsx("td",{className:"p-4 text-right text-azure-text-primary dark:text-gray-300",children:t.totalAudioSeconds>0?t.totalAudioSeconds.toLocaleString():"—"}),e.jsx("td",{className:"p-4 text-right font-bold text-green-600 dark:text-green-400",children:t.estimatedCostUsd!=null?`$${t.estimatedCostUsd.toFixed(4)}`:"—"})]},`${t.provider}-${t.model}-${s}`))})]})})]})]})}export{w as UsageStats};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{j as e,m as u}from"./vendor-motion-C3CZ8ZlO.js";import{r as s,L as K}from"./vendor-react-DikRIOlj.js";import{u as M}from"./vendor-utils-BIYveU_1.js";import{w as c,D as w,j as C,k as T}from"./index-BvsF1a9j.js";import{e as B,B as G,a8 as X,x as S,T as J,a9 as Q,a5 as q,a6 as $,y as V,G as Y}from"./vendor-icons-DE7PWdkN.js";const Z={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.05}}},D={hidden:{opacity:0,y:10},show:{opacity:1,y:0}},ee=["ui","telegram","discord"],E=()=>({name:"",prompt:"",notification_channels:["ui"],requires_api_key:!0}),ne=()=>{const{data:g=[],mutate:h}=M("/webhooks",()=>c.list(),{refreshInterval:1e4}),[W,o]=s.useState(!1),[d,b]=s.useState(null),[a,n]=s.useState(E()),[x,m]=s.useState(null),[p,y]=s.useState(null),[k,f]=s.useState(!1),[j,N]=s.useState(null),[z,i]=s.useState(null),l=(r,t)=>{y({type:r,message:t}),setTimeout(()=>y(null),3500)},v=()=>{b(null),n(E()),i(null),o(!0)},P=r=>{b(r),n({name:r.name,prompt:r.prompt,notification_channels:r.notification_channels,requires_api_key:r.requires_api_key}),i(null),o(!0)},F=r=>/^[a-z0-9-_]+$/.test(r),L=async()=>{if(!(!a.name.trim()||!a.prompt.trim())){if(!F(a.name)){i("Name must only contain lowercase letters, numbers, hyphens (-) and underscores (_).");return}if(a.notification_channels.length===0){i("Select at least one notification channel.");return}i(null),f(!0);try{d?(await c.update(d.id,a),l("success","Webhook updated.")):(await c.create(a),l("success","Webhook created.")),await h(),o(!1)}catch(r){const t=r?.message||"Failed to save webhook.";i(t)}finally{f(!1)}}},A=async r=>{try{await c.update(r.id,{enabled:!r.enabled}),await h()}catch{l("error","Failed to toggle webhook.")}},I=async()=>{if(x)try{await c.delete(x.id),await h(),m(null),l("success","Webhook deleted.")}catch{l("error","Failed to delete webhook.")}},O=r=>`${window.location.origin}/api/webhooks/trigger/${r}`,R=r=>{const t=r.requires_api_key?` -H "x-api-key: ${r.api_key}" \\
|
|
2
|
+
`:"";return`curl -X POST ${O(r.name)} \\
|
|
3
|
+
${t} -H "Content-Type: application/json" \\
|
|
4
|
+
-d '{"event":"your_payload"}'`},_=async(r,t)=>{await navigator.clipboard.writeText(r),N(t),setTimeout(()=>N(null),2e3)},U=r=>{const t=a.notification_channels.includes(r);n({...a,notification_channels:t?a.notification_channels.filter(H=>H!==r):[...a.notification_channels,r]})};return e.jsxs(u.div,{variants:Z,initial:"hidden",animate:"show",className:"space-y-6",children:[e.jsxs(u.div,{variants:D,className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(B,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Webhooks"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary mt-0.5",children:"Trigger Oracle agent tasks from external events."})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(K,{to:"/notifications",className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-azure-border dark:border-matrix-primary text-sm text-azure-text-secondary dark:text-matrix-secondary hover:bg-azure-surface dark:hover:bg-zinc-800 transition-colors",children:[e.jsx(G,{className:"w-4 h-4"}),"Notifications"]}),e.jsxs("button",{onClick:v,className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-azure-primary dark:bg-matrix-primary text-white dark:text-matrix-highlight text-sm font-medium hover:opacity-90 transition-opacity",children:[e.jsx(X,{className:"w-4 h-4"}),"New Webhook"]})]})]}),p&&e.jsx(u.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},className:`px-4 py-3 rounded-lg text-sm font-medium border ${p.type==="success"?"bg-green-50 dark:bg-green-900/20 border-green-300 dark:border-green-700 text-green-800 dark:text-green-400":"bg-red-50 dark:bg-red-900/20 border-red-300 dark:border-red-700 text-red-800 dark:text-red-400"}`,children:p.message}),e.jsx(u.div,{variants:D,className:"rounded-lg border border-azure-border dark:border-matrix-primary overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-azure-surface dark:bg-zinc-900 border-b border-azure-border dark:border-matrix-primary",children:e.jsx("tr",{children:["Name","API Key","Channels","Triggers","Status","Actions"].map(r=>e.jsx("th",{className:"px-4 py-3 text-left font-semibold text-azure-text-secondary dark:text-matrix-secondary",children:r},r))})}),e.jsx("tbody",{children:g.length===0?e.jsx("tr",{children:e.jsxs("td",{colSpan:6,className:"px-4 py-10 text-center text-azure-text-secondary dark:text-matrix-secondary",children:["No webhooks yet."," ",e.jsx("button",{onClick:v,className:"underline text-azure-primary dark:text-matrix-highlight",children:"Create one"})]})}):g.map(r=>e.jsxs("tr",{className:"border-b border-azure-border dark:border-matrix-primary/30 hover:bg-azure-surface/50 dark:hover:bg-zinc-800/50 transition-colors",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"font-mono text-azure-text-primary dark:text-matrix-secondary font-medium",children:r.name}),!r.requires_api_key&&e.jsx("span",{className:"text-[10px] uppercase tracking-wider font-bold text-orange-600 dark:text-orange-400",children:"Public / Unsecured"})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[r.requires_api_key?e.jsxs("code",{className:"text-xs font-mono text-azure-text-secondary dark:text-matrix-secondary truncate max-w-[140px]",children:[r.api_key.slice(0,16),"…"]}):e.jsx("span",{className:"text-xs text-azure-text-muted dark:text-matrix-tertiary",children:"Not required"}),e.jsx("button",{onClick:()=>_(R(r),`curl-${r.id}`),className:"p-1 rounded hover:bg-azure-border dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary",title:"Copy curl example",children:j===`curl-${r.id}`?e.jsx(S,{className:"w-3.5 h-3.5 text-green-500"}):e.jsx(J,{className:"w-3.5 h-3.5"})}),r.requires_api_key&&e.jsx("button",{onClick:()=>_(r.api_key,`key-${r.id}`),className:"p-1 rounded hover:bg-azure-border dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary",title:"Copy API key",children:j===`key-${r.id}`?e.jsx(S,{className:"w-3.5 h-3.5 text-green-500"}):e.jsx(Q,{className:"w-3.5 h-3.5"})})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("div",{className:"flex gap-1 flex-wrap",children:r.notification_channels.map(t=>e.jsx("span",{className:"px-2 py-0.5 text-xs rounded bg-azure-border dark:bg-matrix-primary/20 text-azure-text-secondary dark:text-matrix-secondary capitalize",children:t},t))})}),e.jsx("td",{className:"px-4 py-3 text-azure-text-primary dark:text-matrix-secondary",children:r.trigger_count}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("button",{onClick:()=>A(r),className:`flex items-center gap-1.5 text-xs px-2 py-1 rounded transition-colors ${r.enabled?"bg-green-50 dark:bg-green-900/20 text-green-700 dark:text-green-400 hover:bg-green-100 dark:hover:bg-green-900/30":"bg-zinc-100 dark:bg-zinc-800 text-zinc-500 dark:text-zinc-400 hover:bg-zinc-200 dark:hover:bg-zinc-700"}`,children:r.enabled?e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"w-3.5 h-3.5"})," Enabled"]}):e.jsxs(e.Fragment,{children:[e.jsx($,{className:"w-3.5 h-3.5"})," Disabled"]})})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>P(r),title:"Edit",className:"p-1.5 rounded hover:bg-azure-border dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight transition-colors",children:e.jsx(V,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>m(r),title:"Delete",className:"p-1.5 rounded hover:bg-red-50 dark:hover:bg-red-900/20 text-azure-text-secondary dark:text-matrix-secondary hover:text-red-600 dark:hover:text-red-400 transition-colors",children:e.jsx(Y,{className:"w-4 h-4"})})]})})]},r.id))})]})})}),e.jsxs(w,{open:W,onOpenChange:o,children:[e.jsx(C,{children:e.jsx(T,{className:"text-azure-text-primary dark:text-matrix-highlight",children:d?"Edit Webhook":"New Webhook"})}),e.jsxs("div",{className:"p-6 space-y-4 overflow-y-auto",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-azure-text-secondary dark:text-matrix-secondary mb-1",children:["Name ",e.jsx("span",{className:"text-azure-text-muted dark:text-matrix-secondary/60 font-normal",children:"(slug — used in URL)"})]}),e.jsx("input",{type:"text",value:a.name,onChange:r=>{n({...a,name:r.target.value.toLowerCase().replace(/\s+/g,"-")}),i(null)},placeholder:"e.g. deploy-done, github-issue-opened",disabled:!!d,className:"w-full px-3 py-2 rounded-lg border border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-black text-azure-text-primary dark:text-matrix-secondary text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:border-azure-primary dark:focus:border-matrix-highlight disabled:opacity-50 disabled:cursor-not-allowed"}),a.name&&e.jsxs("p",{className:"mt-1 text-xs text-azure-text-secondary dark:text-matrix-secondary",children:["Trigger URL:"," ",e.jsxs("code",{className:"font-mono text-azure-primary dark:text-matrix-highlight",children:["POST /api/webhooks/trigger/",a.name]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-azure-text-secondary dark:text-matrix-secondary mb-1",children:"Agent Prompt"}),e.jsx("textarea",{rows:5,value:a.prompt,onChange:r=>n({...a,prompt:r.target.value}),placeholder:"Describe what Apoc should do when this webhook fires. The received payload will be appended automatically.",className:"w-full px-3 py-2 rounded-lg border border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-black text-azure-text-primary dark:text-matrix-secondary text-sm focus:outline-none focus:ring-1 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:border-azure-primary dark:focus:border-matrix-highlight resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-azure-text-secondary dark:text-matrix-secondary mb-2",children:"Notification Channels"}),e.jsx("div",{className:"flex gap-4",children:ee.map(r=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:a.notification_channels.includes(r),onChange:()=>U(r),className:"rounded border-azure-border dark:border-matrix-primary accent-azure-primary dark:accent-matrix-highlight"}),e.jsx("span",{className:"text-sm text-azure-text-primary dark:text-matrix-secondary capitalize",children:r})]},r))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-azure-text-secondary dark:text-matrix-secondary mb-2",children:"Security"}),e.jsx("button",{onClick:()=>n({...a,requires_api_key:!a.requires_api_key}),className:`flex items-center gap-2 text-sm px-3 py-2 rounded-lg border transition-colors ${a.requires_api_key?"border-green-200 dark:border-green-900/50 bg-green-50/50 dark:bg-green-900/10 text-green-700 dark:text-green-400":"border-orange-200 dark:border-orange-900/50 bg-orange-50/50 dark:bg-orange-900/10 text-orange-700 dark:text-orange-400"}`,children:a.requires_api_key?e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"w-4 h-4"})," Require API Key (Secure)"]}):e.jsxs(e.Fragment,{children:[e.jsx($,{className:"w-4 h-4"})," No API Key (Public)"]})}),e.jsx("p",{className:"mt-1.5 text-xs text-azure-text-muted dark:text-matrix-tertiary",children:a.requires_api_key?"External requests must provide the x-api-key header.":"Warning: This webhook will be publicly triggerable by its URL."})]}),z&&e.jsx("p",{className:"text-sm text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded px-3 py-2",children:z}),e.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[e.jsx("button",{onClick:()=>o(!1),className:"px-4 py-2 rounded-lg border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary text-sm hover:bg-azure-surface dark:hover:bg-zinc-800 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:L,disabled:k||!a.name.trim()||!a.prompt.trim()||a.notification_channels.length===0,className:"px-4 py-2 rounded-lg bg-azure-primary dark:bg-matrix-primary text-white dark:text-matrix-highlight text-sm font-medium hover:opacity-90 disabled:opacity-50 transition-opacity",children:k?"Saving…":d?"Update":"Create"})]})]})]}),e.jsxs(w,{open:!!x,onOpenChange:r=>!r&&m(null),children:[e.jsx(C,{children:e.jsx(T,{className:"text-azure-text-primary dark:text-matrix-highlight",children:"Delete Webhook"})}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsxs("p",{className:"text-sm text-azure-text-primary dark:text-matrix-secondary",children:["Delete"," ",e.jsx("span",{className:"font-semibold font-mono dark:text-matrix-highlight",children:x?.name}),"? This also removes all associated notifications and cannot be undone."]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>m(null),className:"px-4 py-2 rounded-lg border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary text-sm hover:bg-azure-surface dark:hover:bg-zinc-800 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:I,className:"px-4 py-2 rounded-lg bg-red-600 text-white text-sm font-medium hover:bg-red-700 transition-colors",children:"Delete"})]})]})]})]})};export{ne as WebhookManager};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as r}from"./vendor-utils-BIYveU_1.js";import{h as d}from"./index-
|
|
1
|
+
import{u as r}from"./vendor-utils-BIYveU_1.js";import{h as d}from"./index-BvsF1a9j.js";const n={agentKey:"unknown",auditAgent:"unknown",label:"Unknown",delegateToolName:"",emoji:"🤖",color:"gray",description:"",colorClass:"text-gray-500 dark:text-gray-400",bgClass:"bg-gray-50 dark:bg-zinc-900",badgeClass:"bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-300"};function s(){const{data:g}=r("/api/agents/metadata",e=>d.get(e.replace("/api","")),{revalidateOnFocus:!1,dedupingInterval:6e4}),t=g?.agents??[];return{agents:t,getByKey(e){return t.find(a=>a.agentKey===e||a.auditAgent===e)??{...n,agentKey:e,label:e}},getByToolName(e){return t.find(a=>a.delegateToolName===e)??{...n,delegateToolName:e,label:e}},getEmoji(e){return t.find(a=>a.agentKey===e||a.auditAgent===e)?.emoji??"🤖"},getBadgeClass(e){return t.find(a=>a.agentKey===e||a.auditAgent===e)?.badgeClass??n.badgeClass},getSubagents(){return t.filter(e=>e.delegateToolName!=="")}}}export{s as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as r}from"./vendor-utils-BIYveU_1.js";import{h as i}from"./index-
|
|
1
|
+
import{u as r}from"./vendor-utils-BIYveU_1.js";import{h as i}from"./index-BvsF1a9j.js";function m(){const{data:t,error:s,isLoading:e,mutate:a}=r("/audit/global",o=>i.get(o),{revalidateOnFocus:!1,refreshInterval:3e4});return{data:t,error:s,isLoading:e,mutate:a}}function g(t,s=0,e=100){const a=e,o=s*e,{data:n,error:u,isLoading:l}=r(t?`/sessions/${t}/audit?limit=${a}&offset=${o}`:null,f=>i.get(f),{revalidateOnFocus:!1});return{data:n,error:u,isLoading:l}}export{m as a,g as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as t}from"./vendor-utils-BIYveU_1.js";import{h as n}from"./index-
|
|
1
|
+
import{u as t}from"./vendor-utils-BIYveU_1.js";import{h as n}from"./index-BvsF1a9j.js";function a(o){const e=new URLSearchParams;o?.enabled!==void 0&&e.set("enabled",String(o.enabled)),o?.created_by&&e.set("created_by",o.created_by),o?.page!==void 0&&e.set("page",String(o.page)),o?.per_page!==void 0&&e.set("per_page",String(o.per_page));const s=e.toString()?`?${e}`:"";return t(`/chronos${s}`,()=>n.get(`/chronos${s}`))}function i(o,e=50){return t(o?`/chronos/${o}/executions?limit=${e}`:null,()=>n.get(`/chronos/${o}/executions?limit=${e}`))}function h(){return t("/config/chronos",()=>n.get("/config/chronos"))}const p={createJob:o=>n.post("/chronos",o),updateJob:(o,e)=>n.put(`/chronos/${o}`,e),deleteJob:o=>n.delete(`/chronos/${o}`),enableJob:o=>n.patch(`/chronos/${o}/enable`,{}),disableJob:o=>n.patch(`/chronos/${o}/disable`,{}),getConfig:()=>n.get("/config/chronos"),updateConfig:o=>n.post("/config/chronos",o),preview:(o,e,s)=>n.post("/chronos/preview",{expression:o,schedule_type:e,timezone:s})};export{i as a,a as b,p as c,h as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as t}from"./index-
|
|
1
|
+
import{h as t}from"./index-BvsF1a9j.js";const i={fetchConfig:async()=>t.get("/config"),updateConfig:async n=>t.post("/config",n),getSatiConfig:async()=>t.get("/config/sati"),updateSatiConfig:async n=>t.post("/config/sati",n),deleteSatiConfig:async()=>t.delete("/config/sati"),getApocConfig:async()=>t.get("/config/apoc"),updateApocConfig:async n=>t.post("/config/apoc",n),deleteApocConfig:async()=>t.delete("/config/apoc"),getNeoConfig:async()=>t.get("/config/neo"),updateNeoConfig:async n=>t.post("/config/neo",n),deleteNeoConfig:async()=>t.delete("/config/neo"),getTrinityConfig:async()=>t.get("/config/trinity"),updateTrinityConfig:async n=>t.post("/config/trinity",n),deleteTrinityConfig:async()=>t.delete("/config/trinity"),getEncryptionStatus:async()=>t.get("/config/encryption-status"),getEnvOverrides:async()=>t.get("/config/env-overrides"),getSmithsConfig:async()=>await t.get("/smiths/config"),updateSmithsConfig:async n=>t.put("/smiths/config",n),getSmithsList:async()=>t.get("/smiths"),pingSmith:async n=>t.post(`/smiths/${n}/ping`,{}),removeSmith:async n=>t.delete(`/smiths/${n}`)};export{i as c};
|