morpheus-cli 0.9.8 → 0.9.10
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/config/manager.js +10 -1
- package/dist/config/schemas.js +1 -0
- package/dist/runtime/apoc.js +2 -1
- package/dist/runtime/memory/sati/service.js +1 -1
- package/dist/runtime/memory/sqlite.js +56 -1
- package/dist/runtime/neo.js +1 -1
- package/dist/runtime/oracle.js +1 -1
- package/dist/runtime/skills/schema.js +1 -2
- package/dist/runtime/smiths/delegator.js +1 -1
- package/dist/runtime/trinity.js +1 -1
- package/dist/types/config.js +1 -0
- package/dist/ui/assets/{AuditDashboard-93LCGHG1.js → AuditDashboard-ZPJ5Pfwi.js} +1 -1
- package/dist/ui/assets/{Chat-CK5sNcQ1.js → Chat-BAivCJ5N.js} +1 -1
- package/dist/ui/assets/{Chronos-m2h--GEe.js → Chronos-buCS0uuh.js} +1 -1
- package/dist/ui/assets/{ConfirmationModal-Dd5pUJme.js → ConfirmationModal-Bud3Ur7D.js} +1 -1
- package/dist/ui/assets/{Dashboard-ODwl7d-a.js → Dashboard-CR6pBg6o.js} +1 -1
- package/dist/ui/assets/{DeleteConfirmationModal-CCcojDmr.js → DeleteConfirmationModal-Cz1jfXgq.js} +1 -1
- package/dist/ui/assets/{Documents-dWnSoxFO.js → Documents-CYW79d8T.js} +1 -1
- package/dist/ui/assets/{Logs-Dc9Z2LBj.js → Logs-BgDEdckr.js} +1 -1
- package/dist/ui/assets/{MCPManager-CMkb8vMn.js → MCPManager-yupmREOG.js} +1 -1
- package/dist/ui/assets/{ModelPricing-DtHPPbEQ.js → ModelPricing-CbKHyj9P.js} +1 -1
- package/dist/ui/assets/{Notifications-BPvo-DWP.js → Notifications-DpabYsn5.js} +1 -1
- package/dist/ui/assets/{SatiMemories-BUPu1Lxr.js → SatiMemories-D75MAyPU.js} +1 -1
- package/dist/ui/assets/{SessionAudit-CFKF4DA8.js → SessionAudit-B3N9C1NR.js} +1 -1
- package/dist/ui/assets/Settings-B1qZ-teD.js +49 -0
- package/dist/ui/assets/{Skills-BUlvJgJ4.js → Skills-BmqC0xkq.js} +1 -1
- package/dist/ui/assets/{Smiths-CDtJdY0I.js → Smiths-DdAcvxg6.js} +1 -1
- package/dist/ui/assets/{Tasks-DK_cOsNK.js → Tasks-D7SrOMOn.js} +1 -1
- package/dist/ui/assets/{TrinityDatabases-X07by-19.js → TrinityDatabases-cyhanIXu.js} +1 -1
- package/dist/ui/assets/{UsageStats-dYcgckLq.js → UsageStats-DOgOQ4YN.js} +1 -1
- package/dist/ui/assets/{WebhookManager-DDw5eX2R.js → WebhookManager-D2TdZ5kD.js} +1 -1
- package/dist/ui/assets/{audit-DZ5WLUEm.js → audit-CZVCVFw_.js} +1 -1
- package/dist/ui/assets/{chronos-B_HI4mlq.js → chronos-DWSd5JMm.js} +1 -1
- package/dist/ui/assets/{config-B-YxlVrc.js → config-C2GB18ML.js} +1 -1
- package/dist/ui/assets/{index-DfJwcKqG.js → index-BiMscUrn.js} +2 -2
- package/dist/ui/assets/index-U7hzqcK_.css +1 -0
- package/dist/ui/assets/{mcp-k-_pwbqA.js → mcp-JmpcV6nl.js} +1 -1
- package/dist/ui/assets/{skills-xMXangks.js → skills-D2stQj7i.js} +1 -1
- package/dist/ui/assets/{stats-C4QZIv5O.js → stats-cDmpngPQ.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/dist/ui/sw.js +1 -1
- package/package.json +2 -2
- package/dist/ui/assets/Settings-C4JrXfsR.js +0 -47
- package/dist/ui/assets/index-DVjwJ8jT.css +0 -1
|
@@ -1 +1 @@
|
|
|
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 S}from"./vendor-utils-D4NnWbOU.js";import{t as m}from"./index-DfJwcKqG.js";import{P as L}from"./Pagination-BHZKk42X.js";import{f as D,Q as B,_ as E,ab as O,p as M,q as _,r as W,g as X,X as q,a2 as Q}from"./vendor-icons-NHF9HNeN.js";const U={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.05}}},u={hidden:{opacity:0,y:8},show:{opacity:1,y:0}},V={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(M,{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(W,{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(X,{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 T({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 G({task:r,onClose:t,onCancel:c,onRetry:j}){const d=r.status==="pending"||r.status==="running",h=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(q,{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(T,{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:i,value:k})=>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:i}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary",children:k})]},i))}),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(Q,{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})]})]}),(d||h)&&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:[d&&e.jsx("button",{onClick:c,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"}),h&&e.jsx("button",{onClick:j,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 H={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 o({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 ${H[r]??"text-azure-text dark:text-matrix-secondary"}`,children:t})]})}function ae(){const[r,t]=s.useState(""),[c,j]=s.useState(""),[d,h]=s.useState(""),[i,k]=s.useState(""),[p,b]=s.useState(null),[v,f]=s.useState(1),[N,$]=s.useState(20),z=s.useMemo(()=>({status:r||void 0,agent:c||void 0,origin_channel:d||void 0,session_id:i.trim()||void 0,page:v,per_page:N}),[r,c,d,i,v,N]),g=()=>f(1),{data:l}=S("/tasks/stats",()=>m.stats(),{refreshInterval:5e3}),{data:x,mutate:w}=S(["/tasks",z],()=>m.list(z),{refreshInterval:3e3}),C=x?.data??[],y="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(n.div,{variants:U,initial:"hidden",animate:"show",className:"space-y-6",children:[e.jsxs(n.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(n.div,{variants:u,className:"grid grid-cols-3 md:grid-cols-6 gap-3",children:[e.jsx(o,{label:"Pending",value:l?.pending??0}),e.jsx(o,{label:"Running",value:l?.running??0}),e.jsx(o,{label:"Completed",value:l?.completed??0}),e.jsx(o,{label:"Failed",value:l?.failed??0}),e.jsx(o,{label:"Cancelled",value:l?.cancelled??0}),e.jsx(o,{label:"Total",value:l?.total??0})]}),e.jsxs(n.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:y,value:r,onChange:a=>{t(a.target.value||""),g()},children:[e.jsx("option",{value:"",children:"All status"}),Object.entries(V).map(([a,I])=>e.jsx("option",{value:a,children:I},a))]}),e.jsxs("select",{className:y,value:c,onChange:a=>{j(a.target.value||""),g()},children:[e.jsx("option",{value:"",children:"All agents"}),e.jsx("option",{value:"apoc",children:"Apoc"}),e.jsx("option",{value:"neo",children:"Neo"}),e.jsx("option",{value:"smith",children:"Smith"}),e.jsx("option",{value:"trinit",children:"Trinity"})]}),e.jsxs("select",{className:y,value:d,onChange:a=>{h(a.target.value||""),g()},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:`${y} placeholder:text-azure-text-secondary/50 dark:placeholder:text-matrix-secondary/40`,value:i,onChange:a=>{k(a.target.value),g()},placeholder:"Filter by session ID"})]}),e.jsx(n.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(B,{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(T,{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:()=>b(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(E,{className:"w-3.5 h-3.5"})}),(a.status==="pending"||a.status==="running")&&e.jsx("button",{onClick:async()=>{await m.cancel(a.id),w()},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(O,{className:"w-3.5 h-3.5"})})]})})]},a.id))})]})})}),x&&x.total_pages>1&&e.jsx(n.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(L,{page:v,totalPages:x.total_pages,perPage:N,total:x.total,onPageChange:f,onPerPageChange:a=>{$(a),f(1)}})})}),p&&e.jsx(G,{task:p,onClose:()=>b(null),onCancel:async()=>{await m.cancel(p.id),b(null),w()},onRetry:async()=>{await m.retry(p.id),b(null),w()}})]})}export{ae as TasksPage};
|
|
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 S}from"./vendor-utils-D4NnWbOU.js";import{t as m}from"./index-BiMscUrn.js";import{P as L}from"./Pagination-BHZKk42X.js";import{f as D,Q as B,_ as E,ab as O,p as M,q as _,r as W,g as X,X as q,a2 as Q}from"./vendor-icons-NHF9HNeN.js";const U={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.05}}},u={hidden:{opacity:0,y:8},show:{opacity:1,y:0}},V={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(M,{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(W,{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(X,{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 T({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 G({task:r,onClose:t,onCancel:c,onRetry:j}){const d=r.status==="pending"||r.status==="running",h=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(q,{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(T,{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:i,value:k})=>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:i}),e.jsx("span",{className:"text-azure-text dark:text-matrix-secondary",children:k})]},i))}),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(Q,{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})]})]}),(d||h)&&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:[d&&e.jsx("button",{onClick:c,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"}),h&&e.jsx("button",{onClick:j,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 H={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 o({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 ${H[r]??"text-azure-text dark:text-matrix-secondary"}`,children:t})]})}function ae(){const[r,t]=s.useState(""),[c,j]=s.useState(""),[d,h]=s.useState(""),[i,k]=s.useState(""),[p,b]=s.useState(null),[v,f]=s.useState(1),[N,$]=s.useState(20),z=s.useMemo(()=>({status:r||void 0,agent:c||void 0,origin_channel:d||void 0,session_id:i.trim()||void 0,page:v,per_page:N}),[r,c,d,i,v,N]),g=()=>f(1),{data:l}=S("/tasks/stats",()=>m.stats(),{refreshInterval:5e3}),{data:x,mutate:w}=S(["/tasks",z],()=>m.list(z),{refreshInterval:3e3}),C=x?.data??[],y="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(n.div,{variants:U,initial:"hidden",animate:"show",className:"space-y-6",children:[e.jsxs(n.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(n.div,{variants:u,className:"grid grid-cols-3 md:grid-cols-6 gap-3",children:[e.jsx(o,{label:"Pending",value:l?.pending??0}),e.jsx(o,{label:"Running",value:l?.running??0}),e.jsx(o,{label:"Completed",value:l?.completed??0}),e.jsx(o,{label:"Failed",value:l?.failed??0}),e.jsx(o,{label:"Cancelled",value:l?.cancelled??0}),e.jsx(o,{label:"Total",value:l?.total??0})]}),e.jsxs(n.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:y,value:r,onChange:a=>{t(a.target.value||""),g()},children:[e.jsx("option",{value:"",children:"All status"}),Object.entries(V).map(([a,I])=>e.jsx("option",{value:a,children:I},a))]}),e.jsxs("select",{className:y,value:c,onChange:a=>{j(a.target.value||""),g()},children:[e.jsx("option",{value:"",children:"All agents"}),e.jsx("option",{value:"apoc",children:"Apoc"}),e.jsx("option",{value:"neo",children:"Neo"}),e.jsx("option",{value:"smith",children:"Smith"}),e.jsx("option",{value:"trinit",children:"Trinity"})]}),e.jsxs("select",{className:y,value:d,onChange:a=>{h(a.target.value||""),g()},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:`${y} placeholder:text-azure-text-secondary/50 dark:placeholder:text-matrix-secondary/40`,value:i,onChange:a=>{k(a.target.value),g()},placeholder:"Filter by session ID"})]}),e.jsx(n.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(B,{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(T,{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:()=>b(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(E,{className:"w-3.5 h-3.5"})}),(a.status==="pending"||a.status==="running")&&e.jsx("button",{onClick:async()=>{await m.cancel(a.id),w()},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(O,{className:"w-3.5 h-3.5"})})]})})]},a.id))})]})})}),x&&x.total_pages>1&&e.jsx(n.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(L,{page:v,totalPages:x.total_pages,perPage:N,total:x.total,onPageChange:f,onPerPageChange:a=>{$(a),f(1)}})})}),p&&e.jsx(G,{task:p,onClose:()=>b(null),onCancel:async()=>{await m.cancel(p.id),b(null),w()},onRetry:async()=>{await m.retry(p.id),b(null),w()}})]})}export{ae 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-D4NnWbOU.js";import{h as u}from"./index-DfJwcKqG.js";import{C as oe}from"./ConfirmationModal-Dd5pUJme.js";import{D as S,a6 as de,ac as D,ad as ce,h as B,Q as me,z as xe,I as he,o as pe,X as ue}from"./vendor-icons-NHF9HNeN.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}),[Q,h]=l.useState(!1),[o,P]=l.useState(null),[r,n]=l.useState(H),[L,w]=l.useState(!1),[z,g]=l.useState(null),[W,G]=l.useState({}),[$,q]=l.useState(null),[J,M]=l.useState({}),[I,O]=l.useState(null),[X,A]=l.useState(null),[f,_]=l.useState(null),[b,y]=l.useState(!1),Y=()=>{P(null),n(H),y(!1),g(null),h(!0)},K=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;A(a);try{await u.delete(`/trinity/databases/${a}`),await C("/trinity/databases")}catch(t){alert(`Delete failed: ${t.message}`)}finally{A(null),_(null)}},ae=async a=>{q(a);try{const t=await u.post(`/trinity/databases/${a}/test`,{});M(i=>({...i,[a]:t.success}))}catch{M(t=>({...t,[a]:!1}))}finally{q(null)}},te=async a=>{O(a);try{await u.post(`/trinity/databases/${a}/refresh-schema`,{}),await C("/trinity/databases")}catch(t){alert(`Schema refresh failed: ${t.message}`)}finally{O(null)}},re=a=>{G(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:Y,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=W[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:$===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:$===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:I===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 ${I===a.id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>K(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:X===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"}),Q&&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-D4NnWbOU.js";import{h as u}from"./index-BiMscUrn.js";import{C as oe}from"./ConfirmationModal-Bud3Ur7D.js";import{D as S,a6 as de,ac as D,ad as ce,h as B,Q as me,z as xe,I as he,o as pe,X as ue}from"./vendor-icons-NHF9HNeN.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}),[Q,h]=l.useState(!1),[o,P]=l.useState(null),[r,n]=l.useState(H),[L,w]=l.useState(!1),[z,g]=l.useState(null),[W,G]=l.useState({}),[$,q]=l.useState(null),[J,M]=l.useState({}),[I,O]=l.useState(null),[X,A]=l.useState(null),[f,_]=l.useState(null),[b,y]=l.useState(!1),Y=()=>{P(null),n(H),y(!1),g(null),h(!0)},K=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;A(a);try{await u.delete(`/trinity/databases/${a}`),await C("/trinity/databases")}catch(t){alert(`Delete failed: ${t.message}`)}finally{A(null),_(null)}},ae=async a=>{q(a);try{const t=await u.post(`/trinity/databases/${a}/test`,{});M(i=>({...i,[a]:t.success}))}catch{M(t=>({...t,[a]:!1}))}finally{q(null)}},te=async a=>{O(a);try{await u.post(`/trinity/databases/${a}/refresh-schema`,{}),await C("/trinity/databases")}catch(t){alert(`Schema refresh failed: ${t.message}`)}finally{O(null)}},re=a=>{G(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:Y,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=W[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:$===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:$===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:I===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 ${I===a.id?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>K(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:X===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"}),Q&&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-cDmpngPQ.js";import{k as b,c as k,D as j,i as N}from"./vendor-icons-NHF9HNeN.js";import"./index-BiMscUrn.js";import"./vendor-utils-D4NnWbOU.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};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e,m as h}from"./vendor-motion-C3CZ8ZlO.js";import{r as s,L as U}from"./vendor-react-DikRIOlj.js";import{u as M}from"./vendor-utils-D4NnWbOU.js";import{w as c,D as C,e as T,j as S}from"./index-
|
|
1
|
+
import{j as e,m as h}from"./vendor-motion-C3CZ8ZlO.js";import{r as s,L as U}from"./vendor-react-DikRIOlj.js";import{u as M}from"./vendor-utils-D4NnWbOU.js";import{w as c,D as C,e as T,j as S}from"./index-BiMscUrn.js";import{e as B,B as K,a6 as X,v as _,T as q,a7 as G,a3 as J,a4 as Q,w as V,z as Y}from"./vendor-icons-NHF9HNeN.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"]}),ne=()=>{const{data:g=[],mutate:u}=M("/webhooks",()=>c.list(),{refreshInterval:1e4}),[W,n]=s.useState(!1),[o,b]=s.useState(null),[a,d]=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),d(E()),i(null),n(!0)},$=r=>{b(r),d({name:r.name,prompt:r.prompt,notification_channels:r.notification_channels}),i(null),n(!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{o?(await c.update(o.id,a),l("success","Webhook updated.")):(await c.create(a),l("success","Webhook created.")),await u(),n(!1)}catch(r){const t=r?.message||"Failed to save webhook.";i(t)}finally{f(!1)}}},O=async r=>{try{await c.update(r.id,{enabled:!r.enabled}),await u()}catch{l("error","Failed to toggle webhook.")}},P=async()=>{if(x)try{await c.delete(x.id),await u(),m(null),l("success","Webhook deleted.")}catch{l("error","Failed to delete webhook.")}},A=r=>`${window.location.origin}/api/webhooks/trigger/${r}`,I=r=>`curl -X POST ${A(r.name)} \\
|
|
2
2
|
-H "x-api-key: ${r.api_key}" \\
|
|
3
3
|
-H "Content-Type: application/json" \\
|
|
4
4
|
-d '{"event":"your_payload"}'`,w=async(r,t)=>{await navigator.clipboard.writeText(r),N(t),setTimeout(()=>N(null),2e3)},R=r=>{const t=a.notification_channels.includes(r);d({...a,notification_channels:t?a.notification_channels.filter(H=>H!==r):[...a.notification_channels,r]})};return e.jsxs(h.div,{variants:Z,initial:"hidden",animate:"show",className:"space-y-6",children:[e.jsxs(h.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(U,{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(K,{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(h.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(h.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.jsx("span",{className:"font-mono text-azure-text-primary dark:text-matrix-secondary font-medium",children:r.name})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[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("button",{onClick:()=>w(I(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(_,{className:"w-3.5 h-3.5 text-green-500"}):e.jsx(q,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>w(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(_,{className:"w-3.5 h-3.5 text-green-500"}):e.jsx(G,{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:()=>O(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(J,{className:"w-3.5 h-3.5"})," Enabled"]}):e.jsxs(e.Fragment,{children:[e.jsx(Q,{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:()=>$(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(C,{open:W,onOpenChange:n,children:[e.jsx(T,{children:e.jsx(S,{className:"text-azure-text-primary dark:text-matrix-highlight",children:o?"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=>{d({...a,name:r.target.value.toLowerCase().replace(/\s+/g,"-")}),i(null)},placeholder:"e.g. deploy-done, github-issue-opened",disabled:!!o,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=>d({...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:()=>R(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))})]}),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:()=>n(!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…":o?"Update":"Create"})]})]})]}),e.jsxs(C,{open:!!x,onOpenChange:r=>!r&&m(null),children:[e.jsx(T,{children:e.jsx(S,{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:P,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-D4NnWbOU.js";import{h as i}from"./index-
|
|
1
|
+
import{u as r}from"./vendor-utils-D4NnWbOU.js";import{h as i}from"./index-BiMscUrn.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-D4NnWbOU.js";import{h as n}from"./index-
|
|
1
|
+
import{u as t}from"./vendor-utils-D4NnWbOU.js";import{h as n}from"./index-BiMscUrn.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{j as r}from"./vendor-motion-C3CZ8ZlO.js";import"./vendor-react-DikRIOlj.js";import{t as o}from"./vendor-utils-D4NnWbOU.js";import{h as t}from"./index-
|
|
1
|
+
import{j as r}from"./vendor-motion-C3CZ8ZlO.js";import"./vendor-react-DikRIOlj.js";import{t as o}from"./vendor-utils-D4NnWbOU.js";import{h as t}from"./index-BiMscUrn.js";function d({label:e,error:n,helperText:a,className:s,...i}){return r.jsxs("div",{className:"flex flex-col gap-1.5",children:[r.jsx("label",{className:"text-sm font-medium text-azure-text-primary/80 dark:text-matrix-secondary",children:e}),r.jsx("input",{type:"number",className:o("bg-azure-bg dark:bg-black border border-azure-border dark:border-matrix-primary text-azure-text-primary dark:text-matrix-secondary placeholder-azure-text-secondary/50 dark:placeholder-matrix-secondary/50 rounded-md px-3 py-2 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 transition-colors",n&&"border-red-500 focus:border-red-500 focus:ring-red-500",s),...i}),a&&!n&&r.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:a}),n&&r.jsx("p",{className:"text-xs text-red-500",children:n})]})}function l({label:e,checked:n,onChange:a,helperText:s,disabled:i}){return r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex flex-col",children:[r.jsx("span",{className:o("text-sm font-medium text-azure-text-primary/80 dark:text-matrix-highlight/80",i&&"opacity-50"),children:e}),s&&r.jsx("span",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:s})]}),r.jsx("button",{type:"button",role:"switch","aria-checked":n,onClick:()=>!i&&a(!n),className:o("relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:ring-offset-2 focus:ring-offset-azure-bg dark:focus:ring-offset-black",n?"bg-azure-primary dark:bg-matrix-highlight":"bg-slate-300 dark:bg-matrix-primary",i&&"opacity-50 cursor-not-allowed"),children:r.jsx("span",{className:o("inline-block h-4 w-4 transform rounded-full bg-white dark:bg-black transition-transform",n?"translate-x-6":"translate-x-1")})})]})}const m={fetchConfig:async()=>t.get("/config"),updateConfig:async e=>t.post("/config",e),getSatiConfig:async()=>t.get("/config/sati"),updateSatiConfig:async e=>t.post("/config/sati",e),deleteSatiConfig:async()=>t.delete("/config/sati"),getApocConfig:async()=>t.get("/config/apoc"),updateApocConfig:async e=>t.post("/config/apoc",e),deleteApocConfig:async()=>t.delete("/config/apoc"),getNeoConfig:async()=>t.get("/config/neo"),updateNeoConfig:async e=>t.post("/config/neo",e),deleteNeoConfig:async()=>t.delete("/config/neo"),getTrinityConfig:async()=>t.get("/config/trinity"),updateTrinityConfig:async e=>t.post("/config/trinity",e),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 e=>t.put("/smiths/config",e),getSmithsList:async()=>t.get("/smiths"),pingSmith:async e=>t.post(`/smiths/${e}/ping`,{}),removeSmith:async e=>t.delete(`/smiths/${e}`)};export{d as N,l as S,m as c};
|