morpheus-cli 0.9.13 → 0.9.22

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.
Files changed (102) hide show
  1. package/README.md +48 -17
  2. package/dist/channels/discord.js +93 -6
  3. package/dist/channels/telegram.js +109 -9
  4. package/dist/cli/commands/start.js +15 -0
  5. package/dist/config/manager.js +20 -1
  6. package/dist/config/paths.js +4 -0
  7. package/dist/config/schemas.js +15 -0
  8. package/dist/http/api.js +5 -1
  9. package/dist/http/middleware/auth.js +2 -1
  10. package/dist/http/routers/danger.js +4 -5
  11. package/dist/http/routers/display.js +33 -0
  12. package/dist/http/routers/link.js +2 -2
  13. package/dist/runtime/__tests__/telephonist-tts.test.js +84 -0
  14. package/dist/runtime/adapters/AuditRepositoryAdapter.js +6 -0
  15. package/dist/runtime/adapters/ChannelNotifierAdapter.js +9 -0
  16. package/dist/runtime/adapters/LangChainProviderAdapter.js +9 -0
  17. package/dist/runtime/adapters/SQLiteChatHistoryAdapter.js +15 -0
  18. package/dist/runtime/adapters/SQLiteTaskEnqueuerAdapter.js +6 -0
  19. package/dist/runtime/adapters/index.js +5 -0
  20. package/dist/runtime/audit/repository.js +6 -2
  21. package/dist/runtime/chronos/repository.js +2 -2
  22. package/dist/runtime/container.js +50 -0
  23. package/dist/runtime/display.js +17 -2
  24. package/dist/runtime/hot-reload.js +6 -9
  25. package/dist/runtime/memory/backfill-embeddings.js +2 -3
  26. package/dist/runtime/memory/sati/repository.js +3 -3
  27. package/dist/runtime/memory/sqlite.js +3 -3
  28. package/dist/runtime/memory/trinity-db.js +2 -2
  29. package/dist/runtime/ports/IAuditEmitter.js +1 -0
  30. package/dist/runtime/ports/IChatHistory.js +1 -0
  31. package/dist/runtime/ports/ILLMProviderFactory.js +1 -0
  32. package/dist/runtime/ports/INotifier.js +1 -0
  33. package/dist/runtime/ports/ITaskEnqueuer.js +1 -0
  34. package/dist/runtime/ports/index.js +1 -0
  35. package/dist/runtime/providers/factory.js +8 -52
  36. package/dist/runtime/providers/strategies.js +66 -0
  37. package/dist/runtime/setup/repository.js +2 -2
  38. package/dist/runtime/subagents/apoc.js +2 -2
  39. package/dist/runtime/subagents/link/link.js +2 -2
  40. package/dist/runtime/subagents/link/repository.js +2 -2
  41. package/dist/runtime/subagents/link/worker.js +3 -3
  42. package/dist/runtime/subagents/neo.js +2 -2
  43. package/dist/runtime/subagents/trinity/trinity.js +2 -2
  44. package/dist/runtime/tasks/repository.js +2 -2
  45. package/dist/runtime/telephonist.js +160 -0
  46. package/dist/runtime/tools/delegation-utils.js +5 -7
  47. package/dist/runtime/tools/morpheus-tools.js +6 -7
  48. package/dist/runtime/tools/smith-tool.js +5 -7
  49. package/dist/runtime/webhooks/repository.js +2 -2
  50. package/dist/types/config.js +6 -0
  51. package/dist/ui/assets/AuditDashboard-z3OBbJ8I.js +1 -0
  52. package/dist/ui/assets/{Chat-UVoDlqqM.js → Chat-aFz9FjrD.js} +7 -7
  53. package/dist/ui/assets/{Chronos-Dfs_pOsc.js → Chronos-MP_NCj2A.js} +1 -1
  54. package/dist/ui/assets/{ConfirmationModal-BBIjVef7.js → ConfirmationModal-B3gHIVKY.js} +1 -1
  55. package/dist/ui/assets/Dashboard-OyZXnj44.js +4120 -0
  56. package/dist/ui/assets/{DeleteConfirmationModal-Du85q5u2.js → DeleteConfirmationModal-D8QsQzwP.js} +1 -1
  57. package/dist/ui/assets/{Documents-DguILrI8.js → Documents-B8g_yv4f.js} +1 -1
  58. package/dist/ui/assets/{Logs-BDup2FET.js → Logs-BWufAtHa.js} +1 -1
  59. package/dist/ui/assets/{MCPManager-WBdh1rum.js → MCPManager-lLoGEyBy.js} +1 -1
  60. package/dist/ui/assets/ModelPricing-CuYIUwXt.js +1 -0
  61. package/dist/ui/assets/Notifications-nI--fmYx.js +1 -0
  62. package/dist/ui/assets/{Pagination-BHZKk42X.js → Pagination-D4ShqUKO.js} +1 -1
  63. package/dist/ui/assets/SatiMemories-DO3JDQBi.js +1 -0
  64. package/dist/ui/assets/{SelectInput-KVLsnfra.js → SelectInput-BPDcd3y7.js} +1 -1
  65. package/dist/ui/assets/SessionAudit-BWtJRkj1.js +9 -0
  66. package/dist/ui/assets/Settings-CblauAVd.js +49 -0
  67. package/dist/ui/assets/Skills-Dw6G5c8W.js +7 -0
  68. package/dist/ui/assets/Smiths-B6-CnRMv.js +1 -0
  69. package/dist/ui/assets/Switch-C7TxLq0E.js +1 -0
  70. package/dist/ui/assets/Tasks-DzUyw5z3.js +1 -0
  71. package/dist/ui/assets/{TrinityDatabases-DYHJunk7.js → TrinityDatabases-DCjdwnLH.js} +1 -1
  72. package/dist/ui/assets/{UsageStats-BpGXaHgW.js → UsageStats-VajzjndO.js} +1 -1
  73. package/dist/ui/assets/{WebhookManager-D2muhYy9.js → WebhookManager-BbfMCiy-.js} +2 -2
  74. package/dist/ui/assets/{agents-CgqJea9n.js → agents-CN_AKX_I.js} +1 -1
  75. package/dist/ui/assets/{audit-Dc3YW0-4.js → audit-M-5UGwoK.js} +1 -1
  76. package/dist/ui/assets/{chronos-CZvGhZQB.js → chronos-mZ0RIvh4.js} +1 -1
  77. package/dist/ui/assets/config-7LGRnJ26.js +1 -0
  78. package/dist/ui/assets/index-Bko2TlZY.css +1 -0
  79. package/dist/ui/assets/{index-Bta9YXEm.js → index-Db1XEN8v.js} +3 -3
  80. package/dist/ui/assets/{mcp-vIffcwd6.js → mcp-YiYC-9IH.js} +1 -1
  81. package/dist/ui/assets/{skills-wANsorUj.js → skills-dc6Xqqhb.js} +1 -1
  82. package/dist/ui/assets/{stats-xnlA4NwX.js → stats-BzqxCDuj.js} +1 -1
  83. package/dist/ui/assets/useCurrency-CEc5edm2.js +1 -0
  84. package/dist/ui/assets/vendor-icons-DE7PWdkN.js +1 -0
  85. package/dist/ui/assets/vendor-utils-BIYveU_1.js +39 -0
  86. package/dist/ui/index.html +4 -4
  87. package/dist/ui/sw.js +1 -1
  88. package/package.json +1 -1
  89. package/dist/ui/assets/AuditDashboard-BVyKnpVm.js +0 -1
  90. package/dist/ui/assets/Dashboard-BdSQDB14.js +0 -1
  91. package/dist/ui/assets/ModelPricing-BQPw0r6z.js +0 -1
  92. package/dist/ui/assets/Notifications-BslO2Ect.js +0 -1
  93. package/dist/ui/assets/SatiMemories-DzaLaZ6M.js +0 -1
  94. package/dist/ui/assets/SessionAudit-CBDThjBi.js +0 -9
  95. package/dist/ui/assets/Settings-JPTCA7C7.js +0 -49
  96. package/dist/ui/assets/Skills-BnDg1HCb.js +0 -7
  97. package/dist/ui/assets/Smiths-DR6g_o3D.js +0 -1
  98. package/dist/ui/assets/Tasks-BuoNCvI-.js +0 -1
  99. package/dist/ui/assets/config-pKL8Y4V9.js +0 -1
  100. package/dist/ui/assets/index-Cjli-AD7.css +0 -1
  101. package/dist/ui/assets/vendor-icons-NHF9HNeN.js +0 -1
  102. package/dist/ui/assets/vendor-utils-D4NnWbOU.js +0 -39
@@ -1 +1 @@
1
- import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import"./vendor-react-DikRIOlj.js";import{B as d}from"./index-Bta9YXEm.js";const n=({isOpen:a,onClose:r,title:t,children:s,size:i="md"})=>{if(!a)return null;const l={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl"};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:r}),e.jsxs("div",{className:`relative bg-azure-surface dark:bg-black rounded-lg border border-azure-border dark:border-matrix-primary shadow-xl w-full ${l[i]} max-h-[90vh] overflow-hidden flex flex-col`,children:[t&&e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-azure-border dark:border-matrix-primary",children:[t&&e.jsx("h3",{className:"text-lg font-semibold text-azure-text-primary dark:text-matrix-highlight",children:t}),r&&e.jsx("button",{onClick:r,className:"text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text-primary dark:hover:text-matrix-highlight",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),e.jsx("div",{className:"overflow-y-auto flex-grow p-6",children:s})]})]})},h=({isOpen:a,onClose:r,onConfirm:t,title:s="Confirm Deletion",message:i="Are you sure you want to delete this item? This action cannot be undone.",confirmButtonText:l="Delete",cancelButtonText:x="Cancel"})=>e.jsx(n,{isOpen:a,onClose:r,title:s,size:"md",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-azure-text-primary dark:text-matrix-secondary",children:i}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(d,{variant:"outline",onClick:r,children:x}),e.jsx(d,{variant:"destructive",onClick:()=>{t(),r()},children:l})]})]})});export{h as D,n as M};
1
+ import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import"./vendor-react-DikRIOlj.js";import{B as d}from"./index-Db1XEN8v.js";const n=({isOpen:a,onClose:r,title:t,children:s,size:i="md"})=>{if(!a)return null;const l={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl"};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:r}),e.jsxs("div",{className:`relative bg-azure-surface dark:bg-black rounded-lg border border-azure-border dark:border-matrix-primary shadow-xl w-full ${l[i]} max-h-[90vh] overflow-hidden flex flex-col`,children:[t&&e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-azure-border dark:border-matrix-primary",children:[t&&e.jsx("h3",{className:"text-lg font-semibold text-azure-text-primary dark:text-matrix-highlight",children:t}),r&&e.jsx("button",{onClick:r,className:"text-azure-text-secondary dark:text-matrix-tertiary hover:text-azure-text-primary dark:hover:text-matrix-highlight",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),e.jsx("div",{className:"overflow-y-auto flex-grow p-6",children:s})]})]})},h=({isOpen:a,onClose:r,onConfirm:t,title:s="Confirm Deletion",message:i="Are you sure you want to delete this item? This action cannot be undone.",confirmButtonText:l="Delete",cancelButtonText:x="Cancel"})=>e.jsx(n,{isOpen:a,onClose:r,title:s,size:"md",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-azure-text-primary dark:text-matrix-secondary",children:i}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(d,{variant:"outline",onClick:r,children:x}),e.jsx(d,{variant:"destructive",onClick:()=>{t(),r()},children:l})]})]})});export{h as D,n as M};
@@ -1,4 +1,4 @@
1
- import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as o}from"./vendor-react-DikRIOlj.js";import{u as T}from"./vendor-utils-D4NnWbOU.js";import{h}from"./index-Bta9YXEm.js";import{C as M}from"./ConfirmationModal-BBIjVef7.js";import{F as O,Q as R}from"./vendor-icons-NHF9HNeN.js";const I=t=>h.get(t);function U(t){const a="/link/documents",{data:i,error:r,mutate:s}=T(a,I);return{documents:i?.documents??[],stats:i?.stats,isLoading:!r&&!i,error:r,mutate:s}}async function _(t,a){return a?h.uploadFileWithProgress("/link/documents/upload",t,a):h.uploadFile("/link/documents/upload",t)}async function B(t){await h.delete(`/link/documents/${t}`)}async function A(t){return h.post(`/link/documents/${t}/reindex`,{})}async function E(){const t=await h.post("/link/worker/scan",{});return{indexed:t.indexed??0,removed:t.removed??0,errors:t.errors??0}}function W({status:t}){const i={pending:{bg:"bg-yellow-100 dark:bg-yellow-900/30",text:"text-yellow-800 dark:text-yellow-400",label:"Pending"},indexing:{bg:"bg-blue-100 dark:bg-blue-900/30",text:"text-blue-800 dark:text-blue-400",label:"Indexing"},indexed:{bg:"bg-green-100 dark:bg-green-900/30",text:"text-green-800 dark:text-green-400",label:"Indexed"},error:{bg:"bg-red-100 dark:bg-red-900/30",text:"text-red-800 dark:text-red-400",label:"Error"}}[t],r=t==="pending"||t==="indexing";return e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ${i.bg} ${i.text} ${r?"animate-pulse":""}`,children:i.label})}function P(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function X(t){return new Date(t).toLocaleString()}function q({documents:t,onDelete:a,onReindex:i,isLoading:r}){return r?e.jsx("div",{className:"text-center py-8 text-azure-text-secondary dark:text-matrix-tertiary",children:"Loading documents..."}):t.length===0?e.jsx("div",{className:"text-center py-8 text-azure-text-secondary dark:text-matrix-tertiary",children:"No documents found. Upload a document to get started."}):e.jsx("div",{className:"overflow-x-auto rounded-lg border border-azure-border dark:border-matrix-primary",children:e.jsxs("table",{className:"min-w-full",children:[e.jsx("thead",{className:"bg-azure-primary/5 dark:bg-matrix-highlight/5",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-azure-text-secondary dark:text-matrix-secondary uppercase tracking-wider",children:"Filename"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-azure-text-secondary dark:text-matrix-secondary uppercase tracking-wider",children:"Status"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-azure-text-secondary dark:text-matrix-secondary uppercase tracking-wider",children:"Size"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-azure-text-secondary dark:text-matrix-secondary uppercase tracking-wider",children:"Chunks"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-azure-text-secondary dark:text-matrix-secondary uppercase tracking-wider",children:"Updated"}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-medium text-azure-text-secondary dark:text-matrix-secondary uppercase tracking-wider",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-azure-border dark:divide-matrix-primary bg-azure-surface dark:bg-black",children:t.map(s=>e.jsxs("tr",{className:"hover:bg-azure-primary/5 dark:hover:bg-matrix-highlight/5",children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("div",{className:"text-sm font-medium text-azure-text dark:text-matrix-highlight",children:s.filename}),s.error_message&&e.jsx("div",{className:"text-xs text-red-500 mt-1",children:s.error_message})]}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(W,{status:s.status})}),e.jsx("td",{className:"px-4 py-3 text-sm text-azure-text-secondary dark:text-matrix-secondary",children:P(s.file_size)}),e.jsx("td",{className:"px-4 py-3 text-sm text-azure-text-secondary dark:text-matrix-secondary",children:s.chunk_count}),e.jsx("td",{className:"px-4 py-3 text-sm text-azure-text-secondary dark:text-matrix-secondary",children:X(s.updated_at)}),e.jsxs("td",{className:"px-4 py-3 text-right space-x-3",children:[e.jsx("button",{onClick:()=>i(s.id),className:"text-xs text-azure-primary dark:text-matrix-secondary hover:text-azure-primary/80 dark:hover:text-matrix-highlight transition-colors",title:"Reindex document",children:"Reindex"}),e.jsx("button",{onClick:()=>a(s.id,s.filename),className:"text-xs text-red-500 hover:text-red-400 transition-colors",title:"Delete document",children:"Delete"})]})]},s.id))})]})})}function H({onUpload:t,isUploading:a,uploadProgress:i}){const r=o.useRef(null),[s,u]=o.useState(!1),j=()=>{r.current?.click()},g=async d=>{const c=d.target.files?.[0];c&&(await t(c),r.current&&(r.current.value=""))},p=d=>{d.preventDefault(),u(!0)},y=d=>{d.preventDefault(),u(!1)},b=async d=>{d.preventDefault(),u(!1);const c=d.dataTransfer.files?.[0];if(c){const v=c.name.split(".").pop()?.toLowerCase();["pdf","txt","md","docx"].includes(v||"")&&await t(c)}},l=a&&i!=null,f=l&&i>=100,m=f?"Indexing...":l?`Uploading... ${i}%`:"Uploading...";return e.jsxs("div",{className:"inline-flex flex-col items-end gap-1",children:[e.jsx("input",{ref:r,type:"file",accept:".pdf,.txt,.md,.docx",onChange:g,className:"hidden"}),e.jsx("button",{onClick:j,onDragOver:p,onDragLeave:y,onDrop:b,disabled:a,className:`
1
+ import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as o}from"./vendor-react-DikRIOlj.js";import{u as T}from"./vendor-utils-BIYveU_1.js";import{h}from"./index-Db1XEN8v.js";import{C as M}from"./ConfirmationModal-B3gHIVKY.js";import{F as O,Y as R}from"./vendor-icons-DE7PWdkN.js";const I=t=>h.get(t);function U(t){const a="/link/documents",{data:i,error:r,mutate:s}=T(a,I);return{documents:i?.documents??[],stats:i?.stats,isLoading:!r&&!i,error:r,mutate:s}}async function _(t,a){return a?h.uploadFileWithProgress("/link/documents/upload",t,a):h.uploadFile("/link/documents/upload",t)}async function B(t){await h.delete(`/link/documents/${t}`)}async function A(t){return h.post(`/link/documents/${t}/reindex`,{})}async function E(){const t=await h.post("/link/worker/scan",{});return{indexed:t.indexed??0,removed:t.removed??0,errors:t.errors??0}}function W({status:t}){const i={pending:{bg:"bg-yellow-100 dark:bg-yellow-900/30",text:"text-yellow-800 dark:text-yellow-400",label:"Pending"},indexing:{bg:"bg-blue-100 dark:bg-blue-900/30",text:"text-blue-800 dark:text-blue-400",label:"Indexing"},indexed:{bg:"bg-green-100 dark:bg-green-900/30",text:"text-green-800 dark:text-green-400",label:"Indexed"},error:{bg:"bg-red-100 dark:bg-red-900/30",text:"text-red-800 dark:text-red-400",label:"Error"}}[t],r=t==="pending"||t==="indexing";return e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ${i.bg} ${i.text} ${r?"animate-pulse":""}`,children:i.label})}function P(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function X(t){return new Date(t).toLocaleString()}function q({documents:t,onDelete:a,onReindex:i,isLoading:r}){return r?e.jsx("div",{className:"text-center py-8 text-azure-text-secondary dark:text-matrix-tertiary",children:"Loading documents..."}):t.length===0?e.jsx("div",{className:"text-center py-8 text-azure-text-secondary dark:text-matrix-tertiary",children:"No documents found. Upload a document to get started."}):e.jsx("div",{className:"overflow-x-auto rounded-lg border border-azure-border dark:border-matrix-primary",children:e.jsxs("table",{className:"min-w-full",children:[e.jsx("thead",{className:"bg-azure-primary/5 dark:bg-matrix-highlight/5",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-azure-text-secondary dark:text-matrix-secondary uppercase tracking-wider",children:"Filename"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-azure-text-secondary dark:text-matrix-secondary uppercase tracking-wider",children:"Status"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-azure-text-secondary dark:text-matrix-secondary uppercase tracking-wider",children:"Size"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-azure-text-secondary dark:text-matrix-secondary uppercase tracking-wider",children:"Chunks"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-azure-text-secondary dark:text-matrix-secondary uppercase tracking-wider",children:"Updated"}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-medium text-azure-text-secondary dark:text-matrix-secondary uppercase tracking-wider",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-azure-border dark:divide-matrix-primary bg-azure-surface dark:bg-black",children:t.map(s=>e.jsxs("tr",{className:"hover:bg-azure-primary/5 dark:hover:bg-matrix-highlight/5",children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("div",{className:"text-sm font-medium text-azure-text dark:text-matrix-highlight",children:s.filename}),s.error_message&&e.jsx("div",{className:"text-xs text-red-500 mt-1",children:s.error_message})]}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(W,{status:s.status})}),e.jsx("td",{className:"px-4 py-3 text-sm text-azure-text-secondary dark:text-matrix-secondary",children:P(s.file_size)}),e.jsx("td",{className:"px-4 py-3 text-sm text-azure-text-secondary dark:text-matrix-secondary",children:s.chunk_count}),e.jsx("td",{className:"px-4 py-3 text-sm text-azure-text-secondary dark:text-matrix-secondary",children:X(s.updated_at)}),e.jsxs("td",{className:"px-4 py-3 text-right space-x-3",children:[e.jsx("button",{onClick:()=>i(s.id),className:"text-xs text-azure-primary dark:text-matrix-secondary hover:text-azure-primary/80 dark:hover:text-matrix-highlight transition-colors",title:"Reindex document",children:"Reindex"}),e.jsx("button",{onClick:()=>a(s.id,s.filename),className:"text-xs text-red-500 hover:text-red-400 transition-colors",title:"Delete document",children:"Delete"})]})]},s.id))})]})})}function H({onUpload:t,isUploading:a,uploadProgress:i}){const r=o.useRef(null),[s,u]=o.useState(!1),j=()=>{r.current?.click()},g=async d=>{const c=d.target.files?.[0];c&&(await t(c),r.current&&(r.current.value=""))},p=d=>{d.preventDefault(),u(!0)},y=d=>{d.preventDefault(),u(!1)},b=async d=>{d.preventDefault(),u(!1);const c=d.dataTransfer.files?.[0];if(c){const v=c.name.split(".").pop()?.toLowerCase();["pdf","txt","md","docx"].includes(v||"")&&await t(c)}},l=a&&i!=null,f=l&&i>=100,m=f?"Indexing...":l?`Uploading... ${i}%`:"Uploading...";return e.jsxs("div",{className:"inline-flex flex-col items-end gap-1",children:[e.jsx("input",{ref:r,type:"file",accept:".pdf,.txt,.md,.docx",onChange:g,className:"hidden"}),e.jsx("button",{onClick:j,onDragOver:p,onDragLeave:y,onDrop:b,disabled:a,className:`
2
2
  inline-flex items-center px-4 py-2 border border-matrix-primary dark:border-gray-600
3
3
  rounded-md text-sm font-medium
4
4
  ${s?"bg-matrix-primary/20 dark:bg-gray-600 text-matrix-highlight dark:text-white":"bg-transparent text-matrix-secondary dark:text-gray-300 hover:bg-matrix-primary/10 dark:hover:bg-gray-700"}
@@ -1 +1 @@
1
- import{j as e,m}from"./vendor-motion-C3CZ8ZlO.js";import{r as i}from"./vendor-react-DikRIOlj.js";import{a as h,b as u}from"./index-Bta9YXEm.js";import{F as c,Q as p}from"./vendor-icons-NHF9HNeN.js";import"./vendor-utils-D4NnWbOU.js";function j(){const{data:t}=h(),[a,n]=i.useState(null),{data:o,mutate:x}=u(a),s=i.useRef(null);return i.useEffect(()=>{!a&&t&&t.length>0&&n(t[0].name)},[t,a]),i.useEffect(()=>{s.current&&(s.current.scrollTop=s.current.scrollHeight)},[o]),e.jsxs(m.div,{className:"flex flex-col space-y-4 md:pt-0",style:{height:"calc(100vh - 2rem)"},initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},transition:{duration:.3},children:[e.jsxs("div",{className:"flex items-center gap-3 shrink-0",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(c,{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:"Logs"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"View runtime logs."})]})]}),e.jsxs("div",{className:"flex-1 flex gap-4 min-h-0 border border-azure-border dark:border-matrix-primary rounded bg-azure-surface dark:bg-zinc-950 p-4",children:[e.jsxs("div",{className:"hidden md:flex w-64 flex-col gap-2 border-r border-azure-border dark:border-matrix-primary pr-4 overflow-y-auto shrink-0",children:[e.jsx("h3",{className:"font-bold text-azure-text-secondary dark:text-matrix-secondary mb-2 sticky top-0 bg-azure-surface dark:bg-zinc-950",children:"LOG FILES"}),t?.map(r=>e.jsxs("button",{onClick:()=>n(r.name),className:`text-left px-3 py-2 rounded text-sm truncate flex items-center gap-2 group transition-colors ${a===r.name?"bg-azure-active text-azure-primary dark:bg-matrix-primary dark:text-matrix-highlight":"text-azure-text-secondary dark:text-matrix-secondary hover:bg-azure-hover dark:hover:bg-zinc-900 group-hover:text-azure-primary dark:group-hover:text-matrix-highlight"}`,children:[e.jsx(c,{className:"w-4 h-4 shrink-0"}),e.jsxs("div",{className:"flex flex-col overflow-hidden",children:[e.jsx("span",{className:"truncate font-bold",children:r.name}),e.jsxs("span",{className:"text-xs opacity-70",children:[(r.size/1024).toFixed(1)," KB"]})]})]},r.name))]}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 bg-azure-bg dark:bg-black border border-azure-border dark:border-matrix-primary/50 rounded",children:[e.jsxs("div",{className:"shrink-0 flex justify-between items-center gap-2 p-2 bg-azure-hover dark:bg-zinc-900 border-b border-azure-border dark:border-matrix-primary/50",children:[e.jsx("select",{value:a??"",onChange:r=>n(r.target.value),className:"md:hidden flex-1 bg-transparent text-azure-text-primary dark:text-matrix-highlight font-bold font-mono text-sm border-none outline-none cursor-pointer",children:t?.map(r=>e.jsx("option",{value:r.name,children:r.name},r.name))}),e.jsx("span",{className:"hidden md:block text-azure-text-primary dark:text-matrix-highlight font-bold font-mono text-sm truncate",children:a}),e.jsx("button",{onClick:()=>x(),className:"shrink-0 text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight transition-colors",children:e.jsx(p,{className:"w-4 h-4"})})]}),e.jsx("div",{ref:s,className:"flex-1 overflow-x-hidden overflow-y-auto p-4 font-mono text-xs break-all text-azure-text-primary dark:text-white",children:o?o.lines.map((r,l)=>{const d=r.match(/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+Z)\s?(.*)/s);return d?e.jsxs("div",{children:[e.jsxs("span",{className:"hidden md:inline opacity-50",children:[d[1]," "]}),e.jsx("span",{children:d[2]})]},l):e.jsx("div",{children:r},l)}):e.jsx("span",{className:"opacity-50",children:"Select a log file to view content..."})})]})]})]})}export{j as Logs};
1
+ import{j as e,m}from"./vendor-motion-C3CZ8ZlO.js";import{r as i}from"./vendor-react-DikRIOlj.js";import{b as h,d as u}from"./index-Db1XEN8v.js";import{F as c,Y as p}from"./vendor-icons-DE7PWdkN.js";import"./vendor-utils-BIYveU_1.js";function j(){const{data:t}=h(),[a,n]=i.useState(null),{data:o,mutate:x}=u(a),s=i.useRef(null);return i.useEffect(()=>{!a&&t&&t.length>0&&n(t[0].name)},[t,a]),i.useEffect(()=>{s.current&&(s.current.scrollTop=s.current.scrollHeight)},[o]),e.jsxs(m.div,{className:"flex flex-col space-y-4 md:pt-0",style:{height:"calc(100vh - 2rem)"},initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},transition:{duration:.3},children:[e.jsxs("div",{className:"flex items-center gap-3 shrink-0",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(c,{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:"Logs"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"View runtime logs."})]})]}),e.jsxs("div",{className:"flex-1 flex gap-4 min-h-0 border border-azure-border dark:border-matrix-primary rounded bg-azure-surface dark:bg-zinc-950 p-4",children:[e.jsxs("div",{className:"hidden md:flex w-64 flex-col gap-2 border-r border-azure-border dark:border-matrix-primary pr-4 overflow-y-auto shrink-0",children:[e.jsx("h3",{className:"font-bold text-azure-text-secondary dark:text-matrix-secondary mb-2 sticky top-0 bg-azure-surface dark:bg-zinc-950",children:"LOG FILES"}),t?.map(r=>e.jsxs("button",{onClick:()=>n(r.name),className:`text-left px-3 py-2 rounded text-sm truncate flex items-center gap-2 group transition-colors ${a===r.name?"bg-azure-active text-azure-primary dark:bg-matrix-primary dark:text-matrix-highlight":"text-azure-text-secondary dark:text-matrix-secondary hover:bg-azure-hover dark:hover:bg-zinc-900 group-hover:text-azure-primary dark:group-hover:text-matrix-highlight"}`,children:[e.jsx(c,{className:"w-4 h-4 shrink-0"}),e.jsxs("div",{className:"flex flex-col overflow-hidden",children:[e.jsx("span",{className:"truncate font-bold",children:r.name}),e.jsxs("span",{className:"text-xs opacity-70",children:[(r.size/1024).toFixed(1)," KB"]})]})]},r.name))]}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 bg-azure-bg dark:bg-black border border-azure-border dark:border-matrix-primary/50 rounded",children:[e.jsxs("div",{className:"shrink-0 flex justify-between items-center gap-2 p-2 bg-azure-hover dark:bg-zinc-900 border-b border-azure-border dark:border-matrix-primary/50",children:[e.jsx("select",{value:a??"",onChange:r=>n(r.target.value),className:"md:hidden flex-1 bg-transparent text-azure-text-primary dark:text-matrix-highlight font-bold font-mono text-sm border-none outline-none cursor-pointer",children:t?.map(r=>e.jsx("option",{value:r.name,children:r.name},r.name))}),e.jsx("span",{className:"hidden md:block text-azure-text-primary dark:text-matrix-highlight font-bold font-mono text-sm truncate",children:a}),e.jsx("button",{onClick:()=>x(),className:"shrink-0 text-azure-text-secondary dark:text-matrix-secondary hover:text-azure-primary dark:hover:text-matrix-highlight transition-colors",children:e.jsx(p,{className:"w-4 h-4"})})]}),e.jsx("div",{ref:s,className:"flex-1 overflow-x-hidden overflow-y-auto p-4 font-mono text-xs break-all text-azure-text-primary dark:text-white",children:o?o.lines.map((r,l)=>{const d=r.match(/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+Z)\s?(.*)/s);return d?e.jsxs("div",{children:[e.jsxs("span",{className:"hidden md:inline opacity-50",children:[d[1]," "]}),e.jsx("span",{children:d[2]})]},l):e.jsx("div",{children:r},l)}):e.jsx("span",{className:"opacity-50",children:"Select a log file to view content..."})})]})]})]})}export{j as Logs};
@@ -1 +1 @@
1
- import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as i}from"./vendor-react-DikRIOlj.js";import{o as J,s as L,a as Z,l as R,u as ee}from"./vendor-utils-D4NnWbOU.js";import{m as k}from"./mcp-vIffcwd6.js";import{D as q,d as H,e as U,j as _}from"./index-Bta9YXEm.js";import{E as re,a2 as te,w as ae,a3 as se,a4 as oe,z as de,T as ne,a5 as ie,G as le,q as ce,P as me}from"./vendor-icons-NHF9HNeN.js";const xe=({label:r,values:s,onChange:t,placeholder:b})=>{const h=s.length>0?s:[""],m=(u,o)=>{const n=[...h];n[u]=o,t(n.filter(d=>d.trim().length>0))},c=()=>t([...h,""]),x=u=>{const o=h.filter((n,d)=>d!==u);t(o.filter(n=>n.trim().length>0))};return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-semibold text-azure-text-primary dark:text-matrix-secondary",children:r}),h.map((u,o)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:"flex-1 rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-black dark:text-matrix-secondary",value:u,placeholder:b,onChange:n=>m(o,n.target.value)}),e.jsx("button",{type:"button",className:"rounded-md border border-red-300 px-3 py-2 text-sm text-red-600 hover:border-red-400 hover:text-red-500 dark:border-red-900 dark:text-red-400",onClick:()=>x(o),children:"Remove"})]},`${r}-${o}`)),e.jsx("button",{type:"button",className:"text-sm font-semibold text-azure-primary hover:text-azure-secondary dark:text-matrix-highlight hover:dark:text-matrix-secondary",onClick:c,children:"Add argument"})]})},O=({label:r,values:s,onChange:t,keyPlaceholder:b,valuePlaceholder:h})=>{const m=i.useMemo(()=>s.length>0?s:[{key:"",value:""}],[s]),c=(o,n,d)=>{const v=[...m];v[o]={...v[o],[n]:d},t(v.filter(f=>f.key.trim().length>0||f.value.trim().length>0))},x=()=>t([...m,{key:"",value:""}]),u=o=>{const n=m.filter((d,v)=>v!==o);t(n.filter(d=>d.key.trim().length>0||d.value.trim().length>0))};return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-semibold text-azure-text-primary dark:text-matrix-secondary",children:r}),m.map((o,n)=>e.jsxs("div",{className:"grid gap-2 md:grid-cols-5",children:[e.jsx("input",{className:"col-span-2 rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-black dark:text-matrix-secondary",value:o.key,placeholder:b,onChange:d=>c(n,"key",d.target.value)}),e.jsx("input",{className:"col-span-2 rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-black dark:text-matrix-secondary",value:o.value,placeholder:h,onChange:d=>c(n,"value",d.target.value)}),e.jsx("button",{type:"button",className:"rounded-md border border-red-300 px-3 py-2 text-sm text-red-600 hover:border-red-400 hover:text-red-500 dark:border-red-900 dark:text-red-400",onClick:()=>u(n),children:"Remove"})]},`${r}-${n}`)),e.jsx("button",{type:"button",className:"text-sm font-semibold text-azure-primary hover:text-azure-secondary dark:text-matrix-highlight hover:dark:text-matrix-secondary",onClick:x,children:"Add entry"})]})},ue=({transport:r,command:s,url:t,args:b,env:h,headers:m,onCommandChange:c,onUrlChange:x,onArgsChange:u,onEnvChange:o,onHeadersChange:n})=>e.jsxs("div",{className:"space-y-4",children:[r==="stdio"&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"block space-y-2 text-sm text-azure-text-primary dark:text-matrix-secondary",children:["Command",e.jsx("input",{className:"w-full rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-black dark:text-matrix-secondary",value:s,onChange:d=>c(d.target.value),placeholder:"npx"})]}),e.jsx(xe,{label:"Arguments",values:b,onChange:u,placeholder:"--flag"})]}),r==="http"&&e.jsxs("label",{className:"block space-y-2 text-sm text-azure-text-primary dark:text-matrix-secondary",children:["URL",e.jsx("input",{className:"w-full rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-black dark:text-matrix-secondary",value:t,onChange:d=>x(d.target.value),placeholder:"https://example.com/mcp"})]}),e.jsx(O,{label:"Environment Variables",values:h,onChange:o,keyPlaceholder:"KEY",valuePlaceholder:"value"}),r==="http"&&e.jsx(O,{label:"Headers",values:m,onChange:n,keyPlaceholder:"Header",valuePlaceholder:"value"})]}),he=J({name:L().min(1,"Name is required"),transport:Z([R("stdio"),R("http")]),command:L().optional(),url:L().optional()}),D=r=>r?Object.entries(r).map(([s,t])=>({key:s,value:t})):[],A=r=>r.reduce((s,t)=>(t.key.trim().length===0||(s[t.key]=t.value),s),{}),pe=({open:r,mode:s,initial:t,onClose:b,onSubmit:h})=>{const[m,c]=i.useState(t?.name??""),[x,u]=i.useState(t?.config.transport??"stdio"),[o,n]=i.useState(t?.config.transport==="stdio"?t.config.command:""),[d,v]=i.useState(t?.config.transport==="http"?t.config.url:""),[f,N]=i.useState(t?.config.args??[]),[j,C]=i.useState(D(t?.config.env)),[p,T]=i.useState(t?.config.transport==="http"?D(t.config.headers):[]),[w,z]=i.useState(null);i.useEffect(()=>{r&&(c(t?.name??""),u(t?.config.transport??"stdio"),n(t?.config.transport==="stdio"?t.config.command:""),v(t?.config.transport==="http"?t.config.url:""),N(t?.config.args??[]),C(D(t?.config.env)),T(t?.config.transport==="http"?D(t.config.headers):[]),z(null))},[r,t]);const P=s==="create",M=async()=>{const y=he.safeParse({name:m,transport:x,command:o,url:d});if(!y.success){z(y.error.issues[0]?.message??"Invalid form");return}if(x==="stdio"&&(!o||o.trim().length===0)){z("Command is required for stdio transport.");return}if(x==="http"&&(!d||d.trim().length===0)){z("URL is required for http transport.");return}const E=x==="stdio"?{transport:"stdio",command:o.trim(),args:f.length>0?f:void 0,env:j.length>0?A(j):void 0}:{transport:"http",url:d.trim(),headers:p.length>0?A(p):void 0,env:j.length>0?A(j):void 0};z(null),await h(m.trim(),E)},$=i.useMemo(()=>s==="create"?"Add MCP Server":"Edit MCP Server",[s]);return e.jsx(q,{open:r,onOpenChange:b,children:e.jsxs(H,{children:[e.jsx(U,{children:e.jsx(_,{children:$})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("label",{className:"block space-y-2 text-sm text-azure-text-primary dark:text-matrix-secondary",children:["Name",e.jsx("input",{className:"w-full rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none disabled:bg-azure-border dark:border-matrix-primary dark:bg-black dark:text-matrix-secondary dark:disabled:bg-matrix-primary/50",value:m,onChange:y=>c(y.target.value),placeholder:"coolify",disabled:!P})]}),e.jsxs("label",{className:"block space-y-2 text-sm text-azure-text-primary dark:text-matrix-secondary",children:["Transport",e.jsxs("select",{className:"w-full rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-black dark:text-matrix-secondary",value:x,onChange:y=>u(y.target.value),children:[e.jsx("option",{value:"stdio",children:"stdio"}),e.jsx("option",{value:"http",children:"http"})]})]}),e.jsx(ue,{transport:x,command:o,url:d,args:f,env:j,headers:p,onCommandChange:n,onUrlChange:v,onArgsChange:N,onEnvChange:C,onHeadersChange:T}),w&&e.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900 dark:bg-red-950/50 dark:text-red-400",children:w}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",className:"rounded-md border border-azure-border px-4 py-2 text-sm text-azure-text-primary hover:border-azure-primary hover:text-azure-primary dark:border-matrix-primary dark:text-matrix-secondary hover:dark:border-matrix-highlight hover:dark:text-matrix-highlight",onClick:b,children:"Cancel"}),e.jsx("button",{type:"button",className:"rounded-md bg-azure-primary px-4 py-2 text-sm font-semibold text-white shadow hover:bg-azure-secondary dark:bg-matrix-highlight dark:text-matrix-bg hover:dark:bg-matrix-secondary",onClick:M,children:"Save"})]})]})]})})};function be({transport:r}){return r==="stdio"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium border rounded px-1.5 py-0.5 text-amber-500 bg-amber-500/10 border-amber-500/30",children:[e.jsx(ne,{className:"w-2.5 h-2.5"}),"stdio"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium border rounded px-1.5 py-0.5 text-cyan-500 bg-cyan-500/10 border-cyan-500/30",children:[e.jsx(ie,{className:"w-2.5 h-2.5"}),"http"]})}function ge({result:r}){return r?r.ok?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium text-emerald-500",children:[e.jsx(le,{className:"w-3 h-3"}),r.toolCount," tool",r.toolCount!==1?"s":""]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium text-red-500",children:[e.jsx(ce,{className:"w-3 h-3"}),"failed"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-zinc-400 dark:text-zinc-600",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-zinc-400 dark:bg-zinc-600"}),"unchecked"]})}const ye=({server:r,probeResult:s,onEdit:t,onDelete:b,onToggle:h})=>{const m=s?.ok,c=s&&!s.ok,x=r.config.env?Object.entries(r.config.env):[];return e.jsxs("div",{className:`rounded-lg border flex flex-col bg-white dark:bg-zinc-900 shadow-sm transition-all ${r.enabled?c?"border-red-400/40 dark:border-red-500/30":m?"border-emerald-400/50 dark:border-emerald-500/30":"border-azure-primary/40 dark:border-matrix-primary":"border-azure-border dark:border-matrix-primary/30"}`,children:[e.jsxs("div",{className:"p-4 flex items-start gap-3",children:[e.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center shrink-0 ${r.enabled?m?"bg-emerald-500/10":c?"bg-red-500/10":"bg-azure-primary/10 dark:bg-matrix-highlight/10":"bg-azure-surface dark:bg-zinc-900"}`,children:e.jsx(re,{className:`w-4 h-4 ${r.enabled?m?"text-emerald-500":c?"text-red-500":"text-azure-primary dark:text-matrix-highlight":"text-azure-text-secondary dark:text-matrix-tertiary"}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:`font-semibold truncate ${r.enabled?"text-azure-text dark:text-matrix-highlight":"text-azure-text-secondary dark:text-matrix-secondary"}`,children:r.name}),e.jsx(be,{transport:r.config.transport}),!r.enabled&&e.jsx("span",{className:"text-[10px] font-medium text-zinc-400 dark:text-zinc-500 bg-zinc-100 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-700 rounded px-1.5 py-0.5 shrink-0",children:"disabled"})]}),e.jsx("div",{className:"mt-1",children:e.jsx(ge,{result:s})})]})]}),e.jsxs("div",{className:"px-4 pb-4 space-y-2",children:[r.config.transport==="stdio"&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-1",children:"Command"}),e.jsxs("code",{className:"block text-xs font-mono text-azure-text dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 rounded px-2.5 py-1.5 break-all",children:[r.config.command,r.config.args&&r.config.args.length>0&&e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:[" ",r.config.args.join(" ")]})]})]}),r.config.transport==="http"&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-1",children:"URL"}),e.jsx("code",{className:"block text-xs font-mono text-azure-text dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 rounded px-2.5 py-1.5 break-all",children:r.config.url})]}),x.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-1",children:["Env vars (",x.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:x.map(([u])=>e.jsx("span",{className:"text-[10px] font-mono text-azure-text-secondary dark:text-matrix-tertiary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/30 rounded px-1.5 py-0.5",children:u},u))})]}),c&&s.error&&e.jsxs("div",{className:"flex items-start gap-2 text-xs text-red-500 bg-red-500/10 border border-red-500/20 rounded p-2",children:[e.jsx(te,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),e.jsx("span",{className:"break-all line-clamp-2",title:s.error,children:s.error})]})]}),e.jsxs("div",{className:"mt-auto px-4 py-3 border-t border-azure-border dark:border-matrix-primary/30 flex items-center justify-between gap-2",children:[r.config._comment?e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-tertiary truncate min-w-0",children:r.config._comment}):e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>t(r),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:"Edit",children:e.jsx(ae,{className:"w-3.5 h-3.5"})}),e.jsx("button",{type:"button",onClick:()=>h(r,!r.enabled),className:`p-1.5 rounded border transition-colors ${r.enabled?"border-emerald-300 dark:border-emerald-700/60 text-emerald-500 dark:text-emerald-400 hover:bg-emerald-50 dark:hover:bg-emerald-900/20":"border-azure-border dark:border-matrix-primary/40 text-zinc-400 dark:text-zinc-600 hover:text-azure-text dark:hover:text-matrix-secondary hover:border-azure-border dark:hover:border-matrix-primary"}`,title:r.enabled?"Disable":"Enable",children:r.enabled?e.jsx(se,{className:"w-4 h-4"}):e.jsx(oe,{className:"w-4 h-4"})}),e.jsx("button",{type:"button",onClick:()=>b(r),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:"Delete",children:e.jsx(de,{className:"w-3.5 h-3.5"})})]})]})]})},Ce=()=>{const{data:r,error:s,mutate:t,isLoading:b}=ee("/api/mcp/servers",()=>k.fetchServers()),[h,m]=i.useState(""),[c,x]=i.useState("all"),[u,o]=i.useState(!1),[n,d]=i.useState(null),[v,f]=i.useState(!1),[N,j]=i.useState(null),[C,p]=i.useState(null),[T,w]=i.useState({}),[z,P]=i.useState(!1),[M,$]=i.useState(!1),[y,E]=i.useState(null),I=r?.servers??[];i.useEffect(()=>{k.fetchStats().then(a=>{E(a);const g={};for(const l of a.servers)g[l.name]={name:l.name,ok:l.ok,toolCount:l.toolCount,error:l.error};w(g)}).catch(()=>{})},[]);const F=i.useMemo(()=>I.filter(a=>{const g=a.name.toLowerCase().includes(h.toLowerCase()),l=c==="all"||a.config.transport===c;return g&&l}),[I,h,c]),K=()=>{d(null),o(!0)},V=a=>{d(a),o(!0)},S=async()=>{const a=await k.fetchStats();E(a);const g={};for(const l of a.servers)g[l.name]={name:l.name,ok:l.ok,toolCount:l.toolCount,error:l.error};return w(g),a},B=async(a,g)=>{try{n?await k.updateServer(n.name,g):await k.addServer(a,g),o(!1),d(null),await t(),await k.reloadTools();const l=await S();p({type:"success",message:`MCP server saved. Tools reloaded: ${l.totalTools} total.`})}catch(l){p({type:"error",message:l.message||"Failed to save MCP server."})}},G=async a=>{j(a),f(!0)},Q=async()=>{if(N)try{await k.deleteServer(N.name),await t(),f(!1),j(null),await k.reloadTools();const a=await S();p({type:"success",message:`MCP server deleted. Tools reloaded: ${a.totalTools} total.`})}catch(a){p({type:"error",message:a.message||"Failed to delete MCP server."})}},W=async()=>{P(!0);try{const a=await S();p({type:"success",message:`Status checked: ${a.totalTools} tools from ${a.servers.length} servers.`})}catch(a){p({type:"error",message:a.message||"Failed to check MCP status."})}finally{P(!1)}},X=async()=>{$(!0);try{await k.reloadTools();const a=await S();p({type:"success",message:`MCP tools reloaded: ${a.totalTools} tools from ${a.servers.length} servers.`})}catch(a){p({type:"error",message:a.message||"Failed to reload MCP tools."})}finally{$(!1)}},Y=async(a,g)=>{try{await k.toggleServer(a.name,g),await t(),await k.reloadTools();const l=await S();p({type:"success",message:`MCP server ${g?"enabled":"disabled"}. Tools reloaded: ${l.totalTools} total.`})}catch(l){p({type:"error",message:l.message||"Failed to toggle MCP server."})}};return e.jsxs("div",{className:"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(me,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"MCP Servers"}),y&&y.totalTools>0&&e.jsxs("span",{className:"rounded-full bg-azure-primary/10 px-2.5 py-0.5 text-xs font-semibold text-azure-primary dark:bg-matrix-highlight/20 dark:text-matrix-highlight",children:[y.totalTools," tools cached"]})]}),e.jsxs("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:["Manage MCP servers stored in mcps.json."," ",y?.lastLoadedAt&&e.jsxs("span",{className:"dark:text-matrix-tertiary",children:["Last loaded: ",new Date(y.lastLoadedAt).toLocaleTimeString()]})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",disabled:z,className:"rounded-md border border-azure-border px-4 py-2 text-sm font-semibold text-azure-text-primary shadow hover:border-azure-primary hover:text-azure-primary disabled:opacity-50 dark:border-matrix-primary dark:text-matrix-secondary hover:dark:border-matrix-highlight hover:dark:text-matrix-highlight",onClick:W,children:z?"Checking…":"Check Status"}),e.jsx("button",{type:"button",disabled:M,className:"rounded-md border border-azure-border px-4 py-2 text-sm font-semibold text-azure-text-primary shadow hover:border-azure-primary hover:text-azure-primary disabled:opacity-50 dark:border-matrix-primary dark:text-matrix-secondary hover:dark:border-matrix-highlight hover:dark:text-matrix-highlight",onClick:X,children:M?"Reloading…":"Reload MCPs"}),e.jsx("button",{type:"button",className:"rounded-md bg-azure-primary px-4 py-2 text-sm font-semibold text-white shadow hover:bg-azure-secondary dark:bg-matrix-highlight dark:text-matrix-bg hover:dark:bg-matrix-secondary",onClick:K,children:"Add Server"})]})]}),C&&e.jsx("div",{className:`p-4 rounded border ${C.type==="success"?"border-azure-primary text-azure-primary bg-azure-primary/10 dark:border-matrix-highlight dark:text-matrix-highlight dark:bg-matrix-highlight/10":"border-red-500 text-red-500 bg-red-900/10"}`,children:C.message}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-center",children:[e.jsx("input",{className:"w-full rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-black dark:text-matrix-secondary",value:h,onChange:a=>m(a.target.value),placeholder:"Search by name"}),e.jsxs("select",{className:"rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-black dark:text-matrix-secondary",value:c,onChange:a=>x(a.target.value),children:[e.jsx("option",{value:"all",children:"All"}),e.jsx("option",{value:"stdio",children:"stdio"}),e.jsx("option",{value:"http",children:"http"})]})]}),b&&e.jsx("div",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary",children:"Loading MCP servers..."}),s&&e.jsx("div",{className:"text-sm text-red-600 dark:text-red-400",children:"Failed to load MCP servers."}),!b&&F.length===0&&e.jsx("div",{className:"rounded-2xl border border-dashed border-azure-border bg-azure-surface/60 p-6 text-center text-sm text-azure-text-secondary dark:border-matrix-primary dark:bg-zinc-950/60 dark:text-matrix-secondary",children:"No MCP servers found. Add a server to get started."}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:F.map(a=>e.jsx(ye,{server:a,probeResult:T[a.name],onEdit:V,onDelete:G,onToggle:Y},`${a.name}-${a.enabled?"on":"off"}`))}),e.jsx(pe,{open:u,mode:n?"edit":"create",initial:n??void 0,onClose:()=>o(!1),onSubmit:B}),e.jsx(q,{open:v,onOpenChange:f,children:e.jsxs(H,{children:[e.jsx(U,{children:e.jsx(_,{children:"Confirm Deletion"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary",children:["Are you sure you want to delete the MCP server ",e.jsxs("span",{className:"font-semibold text-azure-text-primary dark:text-matrix-highlight",children:['"',N?.name,'"']}),"? This action cannot be undone."]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",className:"rounded-md border border-azure-border px-4 py-2 text-sm text-azure-text-primary hover:border-azure-primary hover:text-azure-primary dark:border-matrix-primary dark:text-matrix-secondary hover:dark:border-matrix-highlight hover:dark:text-matrix-highlight",onClick:()=>f(!1),children:"Cancel"}),e.jsx("button",{type:"button",className:"rounded-md bg-red-500 px-4 py-2 text-sm font-semibold text-white shadow hover:bg-red-400 dark:bg-red-600 hover:dark:bg-red-500",onClick:Q,children:"Delete"})]})]})]})})]})};export{Ce as MCPManager};
1
+ import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as i}from"./vendor-react-DikRIOlj.js";import{o as Y,s as I,a as Z,l as R,u as ee}from"./vendor-utils-BIYveU_1.js";import{m as k}from"./mcp-YiYC-9IH.js";import{D as H,e as U,j as q,k as _}from"./index-Db1XEN8v.js";import{I as re,a4 as te,y as ae,a5 as se,a6 as oe,G as de,T as ne,a7 as ie,J as le,s as ce,P as me}from"./vendor-icons-DE7PWdkN.js";const xe=({label:r,values:s,onChange:t,placeholder:b})=>{const h=s.length>0?s:[""],m=(u,o)=>{const n=[...h];n[u]=o,t(n.filter(d=>d.trim().length>0))},c=()=>t([...h,""]),x=u=>{const o=h.filter((n,d)=>d!==u);t(o.filter(n=>n.trim().length>0))};return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-semibold text-azure-text-primary dark:text-matrix-secondary",children:r}),h.map((u,o)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:"flex-1 rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-black dark:text-matrix-secondary",value:u,placeholder:b,onChange:n=>m(o,n.target.value)}),e.jsx("button",{type:"button",className:"rounded-md border border-red-300 px-3 py-2 text-sm text-red-600 hover:border-red-400 hover:text-red-500 dark:border-red-900 dark:text-red-400",onClick:()=>x(o),children:"Remove"})]},`${r}-${o}`)),e.jsx("button",{type:"button",className:"text-sm font-semibold text-azure-primary hover:text-azure-secondary dark:text-matrix-highlight hover:dark:text-matrix-secondary",onClick:c,children:"Add argument"})]})},O=({label:r,values:s,onChange:t,keyPlaceholder:b,valuePlaceholder:h})=>{const m=i.useMemo(()=>s.length>0?s:[{key:"",value:""}],[s]),c=(o,n,d)=>{const v=[...m];v[o]={...v[o],[n]:d},t(v.filter(f=>f.key.trim().length>0||f.value.trim().length>0))},x=()=>t([...m,{key:"",value:""}]),u=o=>{const n=m.filter((d,v)=>v!==o);t(n.filter(d=>d.key.trim().length>0||d.value.trim().length>0))};return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-semibold text-azure-text-primary dark:text-matrix-secondary",children:r}),m.map((o,n)=>e.jsxs("div",{className:"grid gap-2 md:grid-cols-5",children:[e.jsx("input",{className:"col-span-2 rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-black dark:text-matrix-secondary",value:o.key,placeholder:b,onChange:d=>c(n,"key",d.target.value)}),e.jsx("input",{className:"col-span-2 rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-black dark:text-matrix-secondary",value:o.value,placeholder:h,onChange:d=>c(n,"value",d.target.value)}),e.jsx("button",{type:"button",className:"rounded-md border border-red-300 px-3 py-2 text-sm text-red-600 hover:border-red-400 hover:text-red-500 dark:border-red-900 dark:text-red-400",onClick:()=>u(n),children:"Remove"})]},`${r}-${n}`)),e.jsx("button",{type:"button",className:"text-sm font-semibold text-azure-primary hover:text-azure-secondary dark:text-matrix-highlight hover:dark:text-matrix-secondary",onClick:x,children:"Add entry"})]})},ue=({transport:r,command:s,url:t,args:b,env:h,headers:m,onCommandChange:c,onUrlChange:x,onArgsChange:u,onEnvChange:o,onHeadersChange:n})=>e.jsxs("div",{className:"space-y-4",children:[r==="stdio"&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"block space-y-2 text-sm text-azure-text-primary dark:text-matrix-secondary",children:["Command",e.jsx("input",{className:"w-full rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-black dark:text-matrix-secondary",value:s,onChange:d=>c(d.target.value),placeholder:"npx"})]}),e.jsx(xe,{label:"Arguments",values:b,onChange:u,placeholder:"--flag"})]}),r==="http"&&e.jsxs("label",{className:"block space-y-2 text-sm text-azure-text-primary dark:text-matrix-secondary",children:["URL",e.jsx("input",{className:"w-full rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-black dark:text-matrix-secondary",value:t,onChange:d=>x(d.target.value),placeholder:"https://example.com/mcp"})]}),e.jsx(O,{label:"Environment Variables",values:h,onChange:o,keyPlaceholder:"KEY",valuePlaceholder:"value"}),r==="http"&&e.jsx(O,{label:"Headers",values:m,onChange:n,keyPlaceholder:"Header",valuePlaceholder:"value"})]}),he=Y({name:I().min(1,"Name is required"),transport:Z([R("stdio"),R("http")]),command:I().optional(),url:I().optional()}),D=r=>r?Object.entries(r).map(([s,t])=>({key:s,value:t})):[],L=r=>r.reduce((s,t)=>(t.key.trim().length===0||(s[t.key]=t.value),s),{}),pe=({open:r,mode:s,initial:t,onClose:b,onSubmit:h})=>{const[m,c]=i.useState(t?.name??""),[x,u]=i.useState(t?.config.transport??"stdio"),[o,n]=i.useState(t?.config.transport==="stdio"?t.config.command:""),[d,v]=i.useState(t?.config.transport==="http"?t.config.url:""),[f,N]=i.useState(t?.config.args??[]),[j,C]=i.useState(D(t?.config.env)),[p,T]=i.useState(t?.config.transport==="http"?D(t.config.headers):[]),[w,z]=i.useState(null);i.useEffect(()=>{r&&(c(t?.name??""),u(t?.config.transport??"stdio"),n(t?.config.transport==="stdio"?t.config.command:""),v(t?.config.transport==="http"?t.config.url:""),N(t?.config.args??[]),C(D(t?.config.env)),T(t?.config.transport==="http"?D(t.config.headers):[]),z(null))},[r,t]);const P=s==="create",M=async()=>{const y=he.safeParse({name:m,transport:x,command:o,url:d});if(!y.success){z(y.error.issues[0]?.message??"Invalid form");return}if(x==="stdio"&&(!o||o.trim().length===0)){z("Command is required for stdio transport.");return}if(x==="http"&&(!d||d.trim().length===0)){z("URL is required for http transport.");return}const E=x==="stdio"?{transport:"stdio",command:o.trim(),args:f.length>0?f:void 0,env:j.length>0?L(j):void 0}:{transport:"http",url:d.trim(),headers:p.length>0?L(p):void 0,env:j.length>0?L(j):void 0};z(null),await h(m.trim(),E)},$=i.useMemo(()=>s==="create"?"Add MCP Server":"Edit MCP Server",[s]);return e.jsx(H,{open:r,onOpenChange:b,children:e.jsxs(U,{children:[e.jsx(q,{children:e.jsx(_,{children:$})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("label",{className:"block space-y-2 text-sm text-azure-text-primary dark:text-matrix-secondary",children:["Name",e.jsx("input",{className:"w-full rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none disabled:bg-azure-border dark:border-matrix-primary dark:bg-black dark:text-matrix-secondary dark:disabled:bg-matrix-primary/50",value:m,onChange:y=>c(y.target.value),placeholder:"coolify",disabled:!P})]}),e.jsxs("label",{className:"block space-y-2 text-sm text-azure-text-primary dark:text-matrix-secondary",children:["Transport",e.jsxs("select",{className:"w-full rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-black dark:text-matrix-secondary",value:x,onChange:y=>u(y.target.value),children:[e.jsx("option",{value:"stdio",children:"stdio"}),e.jsx("option",{value:"http",children:"http"})]})]}),e.jsx(ue,{transport:x,command:o,url:d,args:f,env:j,headers:p,onCommandChange:n,onUrlChange:v,onArgsChange:N,onEnvChange:C,onHeadersChange:T}),w&&e.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900 dark:bg-red-950/50 dark:text-red-400",children:w}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",className:"rounded-md border border-azure-border px-4 py-2 text-sm text-azure-text-primary hover:border-azure-primary hover:text-azure-primary dark:border-matrix-primary dark:text-matrix-secondary hover:dark:border-matrix-highlight hover:dark:text-matrix-highlight",onClick:b,children:"Cancel"}),e.jsx("button",{type:"button",className:"rounded-md bg-azure-primary px-4 py-2 text-sm font-semibold text-white shadow hover:bg-azure-secondary dark:bg-matrix-highlight dark:text-matrix-bg hover:dark:bg-matrix-secondary",onClick:M,children:"Save"})]})]})]})})};function be({transport:r}){return r==="stdio"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium border rounded px-1.5 py-0.5 text-amber-500 bg-amber-500/10 border-amber-500/30",children:[e.jsx(ne,{className:"w-2.5 h-2.5"}),"stdio"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium border rounded px-1.5 py-0.5 text-cyan-500 bg-cyan-500/10 border-cyan-500/30",children:[e.jsx(ie,{className:"w-2.5 h-2.5"}),"http"]})}function ge({result:r}){return r?r.ok?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium text-emerald-500",children:[e.jsx(le,{className:"w-3 h-3"}),r.toolCount," tool",r.toolCount!==1?"s":""]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium text-red-500",children:[e.jsx(ce,{className:"w-3 h-3"}),"failed"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-zinc-400 dark:text-zinc-600",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-zinc-400 dark:bg-zinc-600"}),"unchecked"]})}const ye=({server:r,probeResult:s,onEdit:t,onDelete:b,onToggle:h})=>{const m=s?.ok,c=s&&!s.ok,x=r.config.env?Object.entries(r.config.env):[];return e.jsxs("div",{className:`rounded-lg border flex flex-col bg-white dark:bg-zinc-900 shadow-sm transition-all ${r.enabled?c?"border-red-400/40 dark:border-red-500/30":m?"border-emerald-400/50 dark:border-emerald-500/30":"border-azure-primary/40 dark:border-matrix-primary":"border-azure-border dark:border-matrix-primary/30"}`,children:[e.jsxs("div",{className:"p-4 flex items-start gap-3",children:[e.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center shrink-0 ${r.enabled?m?"bg-emerald-500/10":c?"bg-red-500/10":"bg-azure-primary/10 dark:bg-matrix-highlight/10":"bg-azure-surface dark:bg-zinc-900"}`,children:e.jsx(re,{className:`w-4 h-4 ${r.enabled?m?"text-emerald-500":c?"text-red-500":"text-azure-primary dark:text-matrix-highlight":"text-azure-text-secondary dark:text-matrix-tertiary"}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:`font-semibold truncate ${r.enabled?"text-azure-text dark:text-matrix-highlight":"text-azure-text-secondary dark:text-matrix-secondary"}`,children:r.name}),e.jsx(be,{transport:r.config.transport}),!r.enabled&&e.jsx("span",{className:"text-[10px] font-medium text-zinc-400 dark:text-zinc-500 bg-zinc-100 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-700 rounded px-1.5 py-0.5 shrink-0",children:"disabled"})]}),e.jsx("div",{className:"mt-1",children:e.jsx(ge,{result:s})})]})]}),e.jsxs("div",{className:"px-4 pb-4 space-y-2",children:[r.config.transport==="stdio"&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-1",children:"Command"}),e.jsxs("code",{className:"block text-xs font-mono text-azure-text dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 rounded px-2.5 py-1.5 break-all",children:[r.config.command,r.config.args&&r.config.args.length>0&&e.jsxs("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:[" ",r.config.args.join(" ")]})]})]}),r.config.transport==="http"&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-1",children:"URL"}),e.jsx("code",{className:"block text-xs font-mono text-azure-text dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/40 rounded px-2.5 py-1.5 break-all",children:r.config.url})]}),x.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-1",children:["Env vars (",x.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:x.map(([u])=>e.jsx("span",{className:"text-[10px] font-mono text-azure-text-secondary dark:text-matrix-tertiary bg-azure-surface dark:bg-zinc-900 border border-azure-border dark:border-matrix-primary/30 rounded px-1.5 py-0.5",children:u},u))})]}),c&&s.error&&e.jsxs("div",{className:"flex items-start gap-2 text-xs text-red-500 bg-red-500/10 border border-red-500/20 rounded p-2",children:[e.jsx(te,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),e.jsx("span",{className:"break-all line-clamp-2",title:s.error,children:s.error})]})]}),e.jsxs("div",{className:"mt-auto px-4 py-3 border-t border-azure-border dark:border-matrix-primary/30 flex items-center justify-between gap-2",children:[r.config._comment?e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-tertiary truncate min-w-0",children:r.config._comment}):e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>t(r),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:"Edit",children:e.jsx(ae,{className:"w-3.5 h-3.5"})}),e.jsx("button",{type:"button",onClick:()=>h(r,!r.enabled),className:`p-1.5 rounded border transition-colors ${r.enabled?"border-emerald-300 dark:border-emerald-700/60 text-emerald-500 dark:text-emerald-400 hover:bg-emerald-50 dark:hover:bg-emerald-900/20":"border-azure-border dark:border-matrix-primary/40 text-zinc-400 dark:text-zinc-600 hover:text-azure-text dark:hover:text-matrix-secondary hover:border-azure-border dark:hover:border-matrix-primary"}`,title:r.enabled?"Disable":"Enable",children:r.enabled?e.jsx(se,{className:"w-4 h-4"}):e.jsx(oe,{className:"w-4 h-4"})}),e.jsx("button",{type:"button",onClick:()=>b(r),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:"Delete",children:e.jsx(de,{className:"w-3.5 h-3.5"})})]})]})]})},Ce=()=>{const{data:r,error:s,mutate:t,isLoading:b}=ee("/api/mcp/servers",()=>k.fetchServers()),[h,m]=i.useState(""),[c,x]=i.useState("all"),[u,o]=i.useState(!1),[n,d]=i.useState(null),[v,f]=i.useState(!1),[N,j]=i.useState(null),[C,p]=i.useState(null),[T,w]=i.useState({}),[z,P]=i.useState(!1),[M,$]=i.useState(!1),[y,E]=i.useState(null),A=r?.servers??[];i.useEffect(()=>{k.fetchStats().then(a=>{E(a);const g={};for(const l of a.servers)g[l.name]={name:l.name,ok:l.ok,toolCount:l.toolCount,error:l.error};w(g)}).catch(()=>{})},[]);const F=i.useMemo(()=>A.filter(a=>{const g=a.name.toLowerCase().includes(h.toLowerCase()),l=c==="all"||a.config.transport===c;return g&&l}),[A,h,c]),K=()=>{d(null),o(!0)},V=a=>{d(a),o(!0)},S=async()=>{const a=await k.fetchStats();E(a);const g={};for(const l of a.servers)g[l.name]={name:l.name,ok:l.ok,toolCount:l.toolCount,error:l.error};return w(g),a},B=async(a,g)=>{try{n?await k.updateServer(n.name,g):await k.addServer(a,g),o(!1),d(null),await t(),await k.reloadTools();const l=await S();p({type:"success",message:`MCP server saved. Tools reloaded: ${l.totalTools} total.`})}catch(l){p({type:"error",message:l.message||"Failed to save MCP server."})}},G=async a=>{j(a),f(!0)},Q=async()=>{if(N)try{await k.deleteServer(N.name),await t(),f(!1),j(null),await k.reloadTools();const a=await S();p({type:"success",message:`MCP server deleted. Tools reloaded: ${a.totalTools} total.`})}catch(a){p({type:"error",message:a.message||"Failed to delete MCP server."})}},W=async()=>{P(!0);try{const a=await S();p({type:"success",message:`Status checked: ${a.totalTools} tools from ${a.servers.length} servers.`})}catch(a){p({type:"error",message:a.message||"Failed to check MCP status."})}finally{P(!1)}},J=async()=>{$(!0);try{await k.reloadTools();const a=await S();p({type:"success",message:`MCP tools reloaded: ${a.totalTools} tools from ${a.servers.length} servers.`})}catch(a){p({type:"error",message:a.message||"Failed to reload MCP tools."})}finally{$(!1)}},X=async(a,g)=>{try{await k.toggleServer(a.name,g),await t(),await k.reloadTools();const l=await S();p({type:"success",message:`MCP server ${g?"enabled":"disabled"}. Tools reloaded: ${l.totalTools} total.`})}catch(l){p({type:"error",message:l.message||"Failed to toggle MCP server."})}};return e.jsxs("div",{className:"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(me,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"MCP Servers"}),y&&y.totalTools>0&&e.jsxs("span",{className:"rounded-full bg-azure-primary/10 px-2.5 py-0.5 text-xs font-semibold text-azure-primary dark:bg-matrix-highlight/20 dark:text-matrix-highlight",children:[y.totalTools," tools cached"]})]}),e.jsxs("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:["Manage MCP servers stored in mcps.json."," ",y?.lastLoadedAt&&e.jsxs("span",{className:"dark:text-matrix-tertiary",children:["Last loaded: ",new Date(y.lastLoadedAt).toLocaleTimeString()]})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",disabled:z,className:"rounded-md border border-azure-border px-4 py-2 text-sm font-semibold text-azure-text-primary shadow hover:border-azure-primary hover:text-azure-primary disabled:opacity-50 dark:border-matrix-primary dark:text-matrix-secondary hover:dark:border-matrix-highlight hover:dark:text-matrix-highlight",onClick:W,children:z?"Checking…":"Check Status"}),e.jsx("button",{type:"button",disabled:M,className:"rounded-md border border-azure-border px-4 py-2 text-sm font-semibold text-azure-text-primary shadow hover:border-azure-primary hover:text-azure-primary disabled:opacity-50 dark:border-matrix-primary dark:text-matrix-secondary hover:dark:border-matrix-highlight hover:dark:text-matrix-highlight",onClick:J,children:M?"Reloading…":"Reload MCPs"}),e.jsx("button",{type:"button",className:"rounded-md bg-azure-primary px-4 py-2 text-sm font-semibold text-white shadow hover:bg-azure-secondary dark:bg-matrix-highlight dark:text-matrix-bg hover:dark:bg-matrix-secondary",onClick:K,children:"Add Server"})]})]}),C&&e.jsx("div",{className:`p-4 rounded border ${C.type==="success"?"border-azure-primary text-azure-primary bg-azure-primary/10 dark:border-matrix-highlight dark:text-matrix-highlight dark:bg-matrix-highlight/10":"border-red-500 text-red-500 bg-red-900/10"}`,children:C.message}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-center",children:[e.jsx("input",{className:"w-full rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-black dark:text-matrix-secondary",value:h,onChange:a=>m(a.target.value),placeholder:"Search by name"}),e.jsxs("select",{className:"rounded-md border border-azure-border bg-azure-surface px-3 py-2 text-sm text-azure-text-primary shadow-sm focus:border-azure-primary focus:outline-none dark:border-matrix-primary dark:bg-black dark:text-matrix-secondary",value:c,onChange:a=>x(a.target.value),children:[e.jsx("option",{value:"all",children:"All"}),e.jsx("option",{value:"stdio",children:"stdio"}),e.jsx("option",{value:"http",children:"http"})]})]}),b&&e.jsx("div",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary",children:"Loading MCP servers..."}),s&&e.jsx("div",{className:"text-sm text-red-600 dark:text-red-400",children:"Failed to load MCP servers."}),!b&&F.length===0&&e.jsx("div",{className:"rounded-2xl border border-dashed border-azure-border bg-azure-surface/60 p-6 text-center text-sm text-azure-text-secondary dark:border-matrix-primary dark:bg-zinc-950/60 dark:text-matrix-secondary",children:"No MCP servers found. Add a server to get started."}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:F.map(a=>e.jsx(ye,{server:a,probeResult:T[a.name],onEdit:V,onDelete:G,onToggle:X},`${a.name}-${a.enabled?"on":"off"}`))}),e.jsx(pe,{open:u,mode:n?"edit":"create",initial:n??void 0,onClose:()=>o(!1),onSubmit:B}),e.jsx(H,{open:v,onOpenChange:f,children:e.jsxs(U,{children:[e.jsx(q,{children:e.jsx(_,{children:"Confirm Deletion"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary",children:["Are you sure you want to delete the MCP server ",e.jsxs("span",{className:"font-semibold text-azure-text-primary dark:text-matrix-highlight",children:['"',N?.name,'"']}),"? This action cannot be undone."]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",className:"rounded-md border border-azure-border px-4 py-2 text-sm text-azure-text-primary hover:border-azure-primary hover:text-azure-primary dark:border-matrix-primary dark:text-matrix-secondary hover:dark:border-matrix-highlight hover:dark:text-matrix-highlight",onClick:()=>f(!1),children:"Cancel"}),e.jsx("button",{type:"button",className:"rounded-md bg-red-500 px-4 py-2 text-sm font-semibold text-white shadow hover:bg-red-400 dark:bg-red-600 hover:dark:bg-red-500",onClick:Q,children:"Delete"})]})]})]})})]})};export{Ce as MCPManager};
@@ -0,0 +1 @@
1
+ import{j as e,m as u}from"./vendor-motion-C3CZ8ZlO.js";import{r as d}from"./vendor-react-DikRIOlj.js";import{u as F}from"./vendor-utils-BIYveU_1.js";import{h as p,D as v,e as N,j as _,k as w}from"./index-Db1XEN8v.js";import{u as O}from"./useCurrency-CEc5edm2.js";import{i as R,a8 as T,y as A,G as U}from"./vendor-icons-DE7PWdkN.js";import"./config-7LGRnJ26.js";const g={list:()=>p.get("/model-pricing"),upsert:a=>p.post("/model-pricing",a),update:(a,s,l)=>p.put(`/model-pricing/${encodeURIComponent(a)}/${encodeURIComponent(s)}`,l),delete:(a,s)=>p.delete(`/model-pricing/${encodeURIComponent(a)}/${encodeURIComponent(s)}`)},W={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.05}}},C={hidden:{opacity:0,y:10},show:{opacity:1,y:0}},L=["anthropic","openai","google","openrouter","ollama","other"],$=()=>({provider:"",model:"",input_price_per_1m:0,output_price_per_1m:0,audio_cost_per_second:null}),Q=()=>{const{data:a=[],mutate:s}=F("/api/model-pricing",()=>g.list()),{fmtPrice:l,isUSD:b,currency:y}=O(),[S,n]=d.useState(!1),[c,k]=d.useState(null),[t,i]=d.useState($()),[o,x]=d.useState(null),[h,f]=d.useState(null),[j,z]=d.useState(!1),m=(r,E)=>{f({type:r,message:E}),setTimeout(()=>f(null),3e3)},P=()=>{k(null),i($()),n(!0)},M=r=>{k(r),i({...r}),n(!0)},D=async()=>{if(!(!t.provider.trim()||!t.model.trim())){z(!0);try{await g.upsert(t),await s(),n(!1),m("success",c?"Pricing updated.":"Pricing created.")}catch{m("error","Failed to save pricing entry.")}finally{z(!1)}}},I=async()=>{if(o)try{await g.delete(o.provider,o.model),await s(),x(null),m("success","Pricing entry deleted.")}catch{m("error","Failed to delete pricing entry.")}};return e.jsxs(u.div,{variants:W,initial:"hidden",animate:"show",className:"space-y-6",children:[e.jsxs(u.div,{variants:C,className:"flex items-center justify-between",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(R,{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:"Model Pricing"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary mt-0.5",children:"Manage per-model pricing to estimate LLM costs in Usage Stats."})]})]}),e.jsxs("button",{onClick:P,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(T,{className:"w-4 h-4"})," Add Pricing"]})]}),h&&e.jsx(u.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},className:`px-4 py-3 rounded-lg text-sm font-medium border ${h.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:h.message}),e.jsx(u.div,{variants:C,className:"rounded-lg border border-azure-border dark:border-matrix-primary overflow-hidden",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:["Provider","Model",b?"Input ($/1M tokens)":`Input ($/1M → ${y.symbol})`,b?"Output ($/1M tokens)":`Output ($/1M → ${y.symbol})`,"Audio ($/s)","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:a.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-4 py-8 text-center text-azure-text-secondary dark:text-matrix-secondary",children:'No pricing entries. Click "Add Pricing" to get started.'})}):a.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 text-azure-text-primary dark:text-matrix-text capitalize",children:r.provider}),e.jsx("td",{className:"px-4 py-3 font-mono text-azure-text-primary dark:text-matrix-highlight text-xs",children:r.model}),e.jsx("td",{className:"px-4 py-3 text-azure-text-primary dark:text-matrix-text font-mono text-xs",children:l(r.input_price_per_1m)}),e.jsx("td",{className:"px-4 py-3 text-azure-text-primary dark:text-matrix-text font-mono text-xs",children:l(r.output_price_per_1m)}),e.jsx("td",{className:"px-4 py-3 text-azure-text-primary dark:text-matrix-text",children:r.audio_cost_per_second!=null?`$${r.audio_cost_per_second.toFixed(6)}`:e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-secondary/40",children:"—"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>M(r),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",title:"Edit",children:e.jsx(A,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>x(r),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",title:"Delete",children:e.jsx(U,{className:"w-4 h-4"})})]})})]},`${r.provider}/${r.model}`))})]})}),e.jsx(v,{open:S,onOpenChange:n,children:e.jsxs(N,{children:[e.jsx(_,{children:e.jsx(w,{children:c?"Edit Pricing":"Add Pricing"})}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-azure-text-secondary dark:text-matrix-secondary mb-1",children:"Provider"}),c?e.jsx("p",{className:"px-3 py-2 rounded-lg bg-azure-bg dark:bg-zinc-900 text-azure-text-primary dark:text-matrix-secondary text-sm capitalize",children:t.provider}):e.jsxs("select",{value:t.provider,onChange:r=>i({...t,provider:r.target.value}),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",children:[e.jsx("option",{value:"",children:"Select provider..."}),L.map(r=>e.jsx("option",{value:r,children:r},r))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-azure-text-secondary dark:text-matrix-secondary mb-1",children:"Model"}),c?e.jsx("p",{className:"px-3 py-2 rounded-lg bg-azure-bg dark:bg-zinc-900 text-azure-text-primary dark:text-matrix-secondary text-sm font-mono",children:t.model}):e.jsx("input",{type:"text",value:t.model,onChange:r=>i({...t,model:r.target.value}),placeholder:"e.g. gpt-4o",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"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-azure-text-secondary dark:text-matrix-secondary mb-1",children:"Input price / 1M tokens ($)"}),e.jsx("input",{type:"number",min:0,step:.001,value:t.input_price_per_1m,onChange:r=>i({...t,input_price_per_1m:parseFloat(r.target.value)||0}),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"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-azure-text-secondary dark:text-matrix-secondary mb-1",children:"Output price / 1M tokens ($)"}),e.jsx("input",{type:"number",min:0,step:.001,value:t.output_price_per_1m,onChange:r=>i({...t,output_price_per_1m:parseFloat(r.target.value)||0}),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"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-azure-text-secondary dark:text-matrix-secondary mb-1",children:["Audio price / second ($)",e.jsx("span",{className:"ml-2 text-[11px] font-normal text-azure-text-secondary/60 dark:text-matrix-secondary/40",children:"for Whisper/audio-only models · leave blank for token-based"})]}),e.jsx("input",{type:"number",min:0,step:1e-6,placeholder:"e.g. 0.0001 (Whisper = $0.006/min)",value:t.audio_cost_per_second??"",onChange:r=>i({...t,audio_cost_per_second:r.target.value===""?null:parseFloat(r.target.value)}),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 placeholder-azure-text-secondary/40 dark:placeholder-matrix-secondary/30"})]}),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:D,disabled:j||!t.provider.trim()||!t.model.trim(),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:j?"Saving...":"Save"})]})]})]})}),e.jsx(v,{open:!!o,onOpenChange:r=>!r&&x(null),children:e.jsxs(N,{children:[e.jsx(_,{children:e.jsx(w,{children:"Delete Pricing Entry"})}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("p",{className:"text-sm text-azure-text-primary dark:text-matrix-text",children:["Are you sure you want to delete the pricing for"," ",e.jsxs("span",{className:"font-mono font-semibold text-azure-primary dark:text-matrix-highlight",children:[o?.provider,"/",o?.model]}),"? This cannot be undone."]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>x(null),className:"px-4 py-2 rounded-lg border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary text-sm hover:bg-azure-surface dark:hover:bg-zinc-800 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:I,className:"px-4 py-2 rounded-lg bg-red-600 text-white text-sm font-medium hover:bg-red-700 transition-colors",children:"Delete"})]})]})]})})]})};export{Q as ModelPricing};
@@ -0,0 +1 @@
1
+ import{j as e,m as n}from"./vendor-motion-C3CZ8ZlO.js";import{r as i,L as P}from"./vendor-react-DikRIOlj.js";import{u as S}from"./vendor-utils-BIYveU_1.js";import{w as y,D as _,j as D,k as R}from"./index-Db1XEN8v.js";import{P as O}from"./Pagination-D4ShqUKO.js";import{B as k,aa as A,ab as F,ac as B,a0 as L,r as W,s as E,g as J}from"./vendor-icons-DE7PWdkN.js";const M={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.05}}},g={hidden:{opacity:0,y:10},show:{opacity:1,y:0}},j=({status:r})=>r==="completed"?e.jsxs("div",{className:"flex items-center gap-1.5 text-green-600 dark:text-green-400",children:[e.jsx(W,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xs",children:"Completed"})]}):r==="failed"?e.jsxs("div",{className:"flex items-center gap-1.5 text-red-600 dark:text-red-400",children:[e.jsx(E,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xs",children:"Failed"})]}):e.jsxs("div",{className:"flex items-center gap-1.5 text-yellow-600 dark:text-yellow-400",children:[e.jsx(J,{className:"w-4 h-4 animate-pulse"}),e.jsx("span",{className:"text-xs",children:"Pending"})]}),x=r=>new Date(r).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),U=r=>{try{return JSON.stringify(JSON.parse(r),null,2)}catch{return r}},q=()=>{const[r,f]=i.useState(!1),[c,N]=i.useState("all"),[m,d]=i.useState(1),[h,v]=i.useState(20),[a,u]=i.useState(null),{data:s,mutate:z}=S(["/webhooks/notifications",r,c,m,h],()=>y.listNotifications({unreadOnly:r,status:c,page:m,per_page:h}),{refreshInterval:5e3}),o=s?.data??[],l=o.filter(t=>!t.read).length,b=async t=>{t.length!==0&&(await y.markRead(t),await z())},w=()=>{const t=o.filter(p=>!p.read).map(p=>p.id);b(t)},C=async t=>{u(t),t.read||await b([t.id])};return e.jsxs(n.div,{variants:M,initial:"hidden",animate:"show",className:"space-y-6",children:[e.jsxs(n.div,{variants:g,className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative 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(k,{className:"w-5 h-5 text-azure-primary dark:text-matrix-highlight"}),l>0&&e.jsx("span",{className:"absolute -top-1.5 -right-1.5 bg-red-500 text-white text-[10px] font-bold rounded-full w-4 h-4 flex items-center justify-center leading-none",children:l>9?"9+":l})]}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:"Notifications"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary mt-0.5",children:"Webhook execution results from the Oracle agent."})]})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs(P,{to:"/webhooks",className:"flex items-center gap-2 text-sm text-azure-text-secondary dark:text-matrix-dim hover:text-azure-primary dark:hover:text-matrix-highlight transition-colors",children:[e.jsx(A,{className:"w-4 h-4"}),"Back to Webhooks"]}),e.jsxs("select",{value:c,onChange:t=>{N(t.target.value),d(1)},className:"px-3 py-2 rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black text-azure-text-secondary dark:text-matrix-dim text-sm focus:outline-none focus:border-azure-primary dark:focus:border-matrix-highlight",children:[e.jsx("option",{value:"all",children:"All statuses"}),e.jsx("option",{value:"completed",children:"Completed"}),e.jsx("option",{value:"failed",children:"Failed"}),e.jsx("option",{value:"pending",children:"Pending"})]}),e.jsxs("button",{onClick:()=>{f(!r),d(1)},className:`flex items-center gap-2 px-3 py-2 rounded-lg border text-sm transition-colors ${r?"border-azure-primary dark:border-matrix-highlight bg-azure-active dark:bg-matrix-primary/20 text-azure-primary dark:text-matrix-highlight":"border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-dim hover:bg-azure-surface dark:hover:bg-zinc-800"}`,children:[e.jsx(F,{className:"w-4 h-4"}),"Unread only"]}),l>0&&e.jsxs("button",{onClick:w,className:"flex items-center gap-2 px-3 py-2 rounded-lg border border-azure-border dark:border-matrix-primary text-sm text-azure-text-secondary dark:text-matrix-dim hover:bg-azure-surface dark:hover:bg-zinc-800 transition-colors",children:[e.jsx(B,{className:"w-4 h-4"}),"Mark all read"]})]})]}),e.jsx(n.div,{variants:g,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:["","Webhook","Status","Created","Completed","Actions"].map(t=>e.jsx("th",{className:"px-4 py-3 text-left font-semibold text-azure-text-secondary dark:text-matrix-dim",children:t},t))})}),e.jsx("tbody",{children:o.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-4 py-10 text-center text-azure-text-secondary dark:text-matrix-dim",children:r?"No unread notifications.":"No notifications yet."})}):o.map(t=>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 ${t.read?"":"bg-blue-50/40 dark:bg-blue-900/10"}`,children:[e.jsx("td",{className:"px-4 py-3 w-6",children:!t.read&&e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-blue-500 dark:bg-matrix-highlight"})}),e.jsx("td",{className:"px-4 py-3 font-mono font-medium text-azure-text-primary dark:text-matrix-text",children:t.webhook_name}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(j,{status:t.status})}),e.jsx("td",{className:"px-4 py-3 text-xs text-azure-text-secondary dark:text-matrix-dim whitespace-nowrap",children:x(t.created_at)}),e.jsx("td",{className:"px-4 py-3 text-xs text-azure-text-secondary dark:text-matrix-dim whitespace-nowrap",children:t.completed_at?x(t.completed_at):"—"}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("button",{onClick:()=>C(t),title:"View details",className:"p-1.5 rounded hover:bg-azure-border dark:hover:bg-matrix-primary/30 text-azure-text-secondary dark:text-matrix-dim hover:text-azure-primary dark:hover:text-matrix-highlight transition-colors",children:e.jsx(L,{className:"w-4 h-4"})})})]},t.id))})]})})}),s&&s.total_pages>1&&e.jsx(n.div,{variants:g,children:e.jsx("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black",children:e.jsx(O,{page:m,totalPages:s.total_pages,perPage:h,total:s.total,onPageChange:d,onPerPageChange:t=>{v(t),d(1)}})})}),e.jsxs(_,{open:!!a,onOpenChange:t=>!t&&u(null),children:[e.jsx(D,{children:e.jsxs(R,{className:"text-azure-text-primary dark:text-matrix-highlight flex items-center gap-2",children:[e.jsx(k,{className:"w-4 h-4"}),a?.webhook_name]})}),a&&e.jsxs("div",{className:"p-6 space-y-4 overflow-y-auto max-h-[65vh]",children:[e.jsxs("div",{className:"flex items-center gap-4 text-xs text-azure-text-secondary dark:text-matrix-dim",children:[e.jsx(j,{status:a.status}),e.jsx("span",{children:x(a.created_at)}),a.completed_at&&e.jsxs("span",{children:["→ ",x(a.completed_at)]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-azure-text-secondary dark:text-matrix-dim mb-1.5",children:"Received Payload"}),e.jsx("pre",{className:"bg-azure-bg dark:bg-zinc-950 rounded-lg p-3 text-xs font-mono overflow-auto max-h-44 text-azure-text-primary dark:text-matrix-text border border-azure-border dark:border-matrix-primary/30 whitespace-pre-wrap",children:U(a.payload)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-azure-text-secondary dark:text-matrix-dim mb-1.5",children:"Agent Result"}),e.jsx("div",{className:"bg-azure-bg dark:bg-zinc-950 rounded-lg p-3 text-xs font-mono overflow-auto max-h-64 text-azure-text-primary dark:text-matrix-text border border-azure-border dark:border-matrix-primary/30 whitespace-pre-wrap",children:a.result??e.jsx("span",{className:"text-yellow-600 dark:text-yellow-400 animate-pulse",children:"Processing…"})})]}),e.jsx("div",{className:"flex justify-end pt-2",children:e.jsx("button",{onClick:()=>u(null),className:"px-4 py-2 rounded-lg border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-dim text-sm hover:bg-azure-surface dark:hover:bg-zinc-800 transition-colors",children:"Close"})})]})]})]})};export{q as Notifications};
@@ -1 +1 @@
1
- import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{aj as c,o as m}from"./vendor-icons-NHF9HNeN.js";function b({page:r,totalPages:i,perPage:a,total:s,onPageChange:d,onPerPageChange:o,perPageOptions:l=[10,20,50,100]}){const x="flex items-center gap-1 px-3 py-1.5 rounded border text-sm transition-colors disabled:opacity-40 disabled:cursor-not-allowed",n="border-azure-border dark:border-matrix-primary text-azure-text dark:text-matrix-secondary hover:border-azure-primary dark:hover:border-matrix-highlight hover:text-azure-primary dark:hover:text-matrix-highlight";return e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-3 px-4 py-3 border-t border-azure-border dark:border-matrix-primary",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:[e.jsx("span",{children:"Rows per page:"}),e.jsx("select",{value:a,onChange:t=>o(Number(t.target.value)),className:"px-2 py-1 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",children:l.map(t=>e.jsx("option",{value:t,children:t},t))})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary whitespace-nowrap",children:s===0?"0 records":`${(r-1)*a+1}–${Math.min(r*a,s)} of ${s}`}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("button",{onClick:()=>d(r-1),disabled:r<=1,className:`${x} ${n}`,title:"Previous page",children:[e.jsx(c,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Prev"})]}),e.jsxs("span",{className:"px-3 py-1.5 text-sm text-azure-text dark:text-matrix-secondary tabular-nums",children:[r," / ",i||1]}),e.jsxs("button",{onClick:()=>d(r+1),disabled:r>=i,className:`${x} ${n}`,title:"Next page",children:[e.jsx("span",{className:"hidden sm:inline",children:"Next"}),e.jsx(m,{className:"w-4 h-4"})]})]})]})]})}export{b as P};
1
+ import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{al as c,q as m}from"./vendor-icons-DE7PWdkN.js";function b({page:r,totalPages:i,perPage:a,total:s,onPageChange:d,onPerPageChange:o,perPageOptions:l=[10,20,50,100]}){const x="flex items-center gap-1 px-3 py-1.5 rounded border text-sm transition-colors disabled:opacity-40 disabled:cursor-not-allowed",n="border-azure-border dark:border-matrix-primary text-azure-text dark:text-matrix-secondary hover:border-azure-primary dark:hover:border-matrix-highlight hover:text-azure-primary dark:hover:text-matrix-highlight";return e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-3 px-4 py-3 border-t border-azure-border dark:border-matrix-primary",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:[e.jsx("span",{children:"Rows per page:"}),e.jsx("select",{value:a,onChange:t=>o(Number(t.target.value)),className:"px-2 py-1 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",children:l.map(t=>e.jsx("option",{value:t,children:t},t))})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary whitespace-nowrap",children:s===0?"0 records":`${(r-1)*a+1}–${Math.min(r*a,s)} of ${s}`}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("button",{onClick:()=>d(r-1),disabled:r<=1,className:`${x} ${n}`,title:"Previous page",children:[e.jsx(c,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Prev"})]}),e.jsxs("span",{className:"px-3 py-1.5 text-sm text-azure-text dark:text-matrix-secondary tabular-nums",children:[r," / ",i||1]}),e.jsxs("button",{onClick:()=>d(r+1),disabled:r>=i,className:`${x} ${n}`,title:"Next page",children:[e.jsx("span",{className:"hidden sm:inline",children:"Next"}),e.jsx(m,{className:"w-4 h-4"})]})]})]})]})}export{b as P};
@@ -0,0 +1 @@
1
+ import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as i}from"./vendor-react-DikRIOlj.js";import{B as j,h as N}from"./index-Db1XEN8v.js";import{M as de,D as oe}from"./DeleteConfirmationModal-D8QsQzwP.js";import{Z as xe,_ as me,$ as H,g as ue,a0 as O,a1 as he,a2 as ge,A as pe,G as B,a3 as fe}from"./vendor-icons-DE7PWdkN.js";import{P as je}from"./Pagination-D4ShqUKO.js";import"./vendor-utils-BIYveU_1.js";const ye=({className:r,...a})=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{className:`w-full caption-bottom text-sm ${r}`,...a})}),be=({...r})=>e.jsx("thead",{...r}),ke=({...r})=>e.jsx("tbody",{...r}),M=({...r})=>e.jsx("tr",{className:"border-b border-azure-border dark:border-matrix-primary/30 transition-colors hover:bg-azure-hover/50 dark:hover:bg-matrix-primary/10",...r}),f=({className:r,...a})=>e.jsx("th",{className:`h-12 px-4 text-left align-middle font-medium text-azure-text-secondary dark:text-matrix-secondary/70 [&:has([role=checkbox])]:pr-0 ${r}`,...a}),g=({className:r,...a})=>e.jsx("td",{className:`p-4 align-middle [&:has([role=checkbox])]:pr-0 ${r}`,...a}),F=({checked:r,onCheckedChange:a,className:s,...n})=>{const l=x=>{a&&a(x.target.checked),n.onChange&&n.onChange(x)};return e.jsx("input",{type:"checkbox",checked:r,onChange:l,className:`h-4 w-4 rounded border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-black text-azure-primary dark:text-matrix-highlight focus:ring-azure-primary dark:focus:ring-matrix-highlight ${s||""}`,...n})},v=({className:r,variant:a="default",...s})=>{const l=`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-zinc-950 focus:ring-offset-2 dark:focus:ring-zinc-300 ${a==="destructive"?"border-transparent bg-red-500 text-zinc-50 dark:bg-red-900 dark:text-zinc-50":a==="secondary"?"border-transparent bg-azure-surface dark:bg-zinc-800 text-azure-text-secondary dark:text-matrix-secondary":a==="outline"?"text-azure-text-primary dark:text-matrix-secondary border-azure-border dark:border-matrix-primary":"border-transparent bg-azure-primary dark:bg-matrix-highlight text-azure-text-inverse dark:text-black"} ${r||""}`;return e.jsx("div",{className:l,...s})},T=({className:r,...a})=>e.jsx("div",{className:`rounded-lg border border-azure-border dark:border-matrix-primary/30 bg-azure-surface dark:bg-zinc-900 text-azure-text-primary dark:text-matrix-secondary shadow-sm ${r||""}`,...a}),I=({className:r,...a})=>e.jsx("div",{className:`flex flex-col space-y-1.5 p-6 ${r||""}`,...a}),Ne=({className:r,...a})=>e.jsx("h3",{className:`text-2xl font-semibold leading-none tracking-tight ${r||""}`,...a}),A=({className:r,...a})=>e.jsx("div",{className:`p-6 pt-0 ${r||""}`,...a}),ve=({className:r,variant:a="default",...s})=>{const l=`relative w-full rounded-lg border p-4 ${a==="destructive"?"border-red-500/50 text-red-700 dark:border-red-900/50 dark:text-red-300":"border-azure-border dark:border-matrix-primary"} ${r||""}`;return e.jsx("div",{className:l,...s})},ze=({className:r,...a})=>e.jsx("div",{className:`text-sm [&_p]:leading-relaxed ${r||""}`,...a}),we=({isOpen:r,onClose:a,memory:s})=>s?e.jsx(de,{isOpen:r,onClose:a,title:"Memory Details",size:"lg",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Category"})]}),e.jsx("div",{children:e.jsx(v,{variant:"outline",children:s.category})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Importance"})]}),e.jsx("div",{children:e.jsx(v,{variant:s.importance==="critical"?"destructive":s.importance==="high"?"default":s.importance==="medium"?"secondary":"outline",children:s.importance})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Created"})]}),e.jsx("div",{className:"text-azure-text-primary dark:text-matrix-secondary",children:new Date(s.created_at).toLocaleString()}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ue,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Updated"})]}),e.jsx("div",{className:"text-azure-text-primary dark:text-matrix-secondary",children:new Date(s.updated_at).toLocaleString()}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Access Count"})]}),e.jsx("div",{className:"text-azure-text-primary dark:text-matrix-secondary",children:s.access_count}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Hash"})]}),e.jsx("div",{className:"text-azure-text-primary dark:text-matrix-secondary break-all text-sm",children:s.hash}),s.source&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ge,{className:"w-4 h-4 text-azure-text-secondary dark:text-matrix-tertiary"}),e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm",children:"Source"})]}),e.jsx("div",{className:"text-azure-text-primary dark:text-matrix-secondary",children:s.source})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm mb-2",children:"Summary"}),e.jsx("p",{className:"text-azure-text-primary dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-900 p-3 rounded-md",children:s.summary})]}),s.details&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-azure-text-secondary dark:text-matrix-tertiary text-sm mb-2",children:"Details"}),e.jsx("div",{className:"text-azure-text-primary dark:text-matrix-secondary bg-azure-surface dark:bg-zinc-900 p-3 rounded-md whitespace-pre-wrap",children:s.details})]}),e.jsx("div",{className:"flex justify-end pt-4",children:e.jsx(j,{onClick:a,children:"Close"})})]})}):null,Ce=()=>{const[r,a]=i.useState(!1),[s,n]=i.useState(null),l=i.useCallback(o=>(a(!0),n(null),N.get(o).then(c=>c).catch(c=>{throw n(c.message||"An error occurred"),c}).finally(()=>{a(!1)})),[]),x=i.useCallback((o,c)=>(a(!0),n(null),N.post(o,c).then(d=>d).catch(d=>{throw n(d.message||"An error occurred"),d}).finally(()=>{a(!1)})),[]),m=i.useCallback((o,c)=>(a(!0),n(null),N.post(o,c).then(d=>d).catch(d=>{throw n(d.message||"An error occurred"),d}).finally(()=>{a(!1)})),[]),z=i.useCallback(o=>(a(!0),n(null),N.delete(o).then(c=>c).catch(c=>{throw n(c.message||"An error occurred"),c}).finally(()=>{a(!1)})),[]);return{get:l,post:x,put:m,del:z,loading:r,error:s}},_e=()=>{const[r,a]=i.useState([]),[s,n]=i.useState(!0),[l,x]=i.useState([]),[m,z]=i.useState(""),[o,c]=i.useState("all"),[d,R]=i.useState("all"),[u,y]=i.useState(1),[h,U]=i.useState(20),[V,q]=i.useState(0),[$,G]=i.useState(1),[P,b]=i.useState(null),[Z,w]=i.useState(!1),[J,K]=i.useState(null),[Q,_]=i.useState(!1),[E,L]=i.useState(null),[W,C]=i.useState(!1),{get:X,del:Y,post:ee}=Ce(),S=i.useCallback(async(t=u,D=h)=>{try{n(!0);const p=new URLSearchParams({page:String(t),per_page:String(D)});o!=="all"&&p.set("category",o),d!=="all"&&p.set("importance",d),m.trim()&&p.set("search",m.trim());const k=await X(`/sati/memories?${p}`);a(k.data??k),q(k.total??0),G(k.total_pages??1),b(null)}catch(p){b("Failed to load memories. Please try again."),console.error("Error fetching memories:",p)}finally{n(!1)}},[u,h,o,d,m]);i.useEffect(()=>{S(u,h)},[u,h,o,d,m]);const te=()=>{l.length===r.length?x([]):x(r.map(t=>t.id))},re=t=>{l.includes(t)?x(l.filter(D=>D!==t)):x([...l,t])},ae=async()=>{if(l.length!==0)try{await ee("/sati/memories/bulk-delete",{ids:l}),await S(u,h),x([]),w(!1)}catch(t){b("Failed to delete memories. Please try again."),console.error("Error deleting memories:",t)}},se=t=>{L(t),C(!0)},ie=async()=>{if(E)try{await Y(`/sati/memories/${E}`),await S(u,h)}catch(t){b("Failed to delete memory. Please try again."),console.error("Error deleting memory:",t)}finally{L(null),C(!1)}},le=t=>{K(t),_(!0)},ne=["preference","project","identity","constraint","context","personal_data","languages","favorite_things","relationships","pets","naming","professional_profile"],ce=["low","medium","high"];return s&&r.length===0?e.jsx(T,{className:"w-full",children:e.jsx(A,{className:"flex justify-center items-center h-64",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-azure-primary dark:border-matrix-highlight"})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-azure-primary/10 dark:bg-matrix-highlight/10 border border-azure-primary/20 dark:border-matrix-highlight/30 flex items-center justify-center",children:e.jsx(pe,{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:"Sati Memories"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"View and manage long-term memories stored by Sati."})]})]}),l.length>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm text-azure-text-muted dark:text-matrix-secondary",children:[l.length," selected"]}),e.jsxs(j,{variant:"destructive",size:"sm",onClick:()=>w(!0),disabled:l.length===0,children:[e.jsx(B,{className:"w-4 h-4 mr-1"}),"Delete Selected"]})]})]}),P&&e.jsx(ve,{variant:"destructive",children:e.jsx(ze,{children:P})}),e.jsxs(T,{children:[e.jsx(I,{className:"border-b border-azure-border dark:border-matrix-primary",children:e.jsxs("div",{className:"flex flex-col lg:flex-row gap-4",children:[e.jsxs("div",{className:"flex flex-col relative w-full",children:[e.jsx(fe,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-azure-text-secondary dark:text-matrix-secondary w-4 h-4"}),e.jsx("input",{type:"text",placeholder:"Search memories...",value:m,onChange:t=>{z(t.target.value),y(1)},className:"w-full pl-10 pr-4 py-2 bg-azure-surface dark:bg-black border border-azure-border dark:border-matrix-primary rounded-md text-azure-text-primary dark:text-matrix-secondary focus:outline-none focus:ring-2 focus:ring-azure-primary dark:focus:ring-matrix-highlight"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 w-full",children:[e.jsxs("select",{value:o,onChange:t=>{c(t.target.value),y(1)},className:"px-3 py-2 bg-azure-surface dark:bg-black border border-azure-border dark:border-matrix-primary rounded-md text-azure-text-primary dark:text-matrix-secondary focus:outline-none focus:ring-2 focus:ring-azure-primary dark:focus:ring-matrix-highlight flex-grow",children:[e.jsx("option",{value:"all",children:"All Categories"}),ne.map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsxs("select",{value:d,onChange:t=>{R(t.target.value),y(1)},className:"px-3 py-2 bg-azure-surface dark:bg-black border border-azure-border dark:border-matrix-primary rounded-md text-azure-text-primary dark:text-matrix-secondary focus:outline-none focus:ring-2 focus:ring-azure-primary dark:focus:ring-matrix-highlight flex-grow",children:[e.jsx("option",{value:"all",children:"All Importance"}),ce.map(t=>e.jsx("option",{value:t,children:t},t))]})]})]})}),e.jsx(A,{className:"p-0",children:e.jsxs(ye,{children:[e.jsx(be,{children:e.jsxs(M,{className:"hover:bg-transparent",children:[e.jsx(f,{className:"w-12",children:e.jsx(F,{checked:r.length>0&&l.length===r.length,onCheckedChange:te})}),e.jsx(f,{children:"Summary"}),e.jsx(f,{children:"Category"}),e.jsx(f,{children:"Importance"}),e.jsx(f,{children:"Created"}),e.jsx(f,{className:"w-32",children:"Actions"})]})}),e.jsx(ke,{children:r.length===0?e.jsx(M,{children:e.jsx(g,{colSpan:6,className:"text-center py-8 text-azure-text-secondary dark:text-matrix-secondary",children:s?"Loading memories...":"No memories found"})}):r.map(t=>e.jsxs(M,{children:[e.jsx(g,{children:e.jsx(F,{checked:l.includes(t.id),onCheckedChange:()=>re(t.id)})}),e.jsx(g,{className:"font-medium max-w-xs truncate",children:t.summary}),e.jsx(g,{children:e.jsx(v,{variant:"outline",children:t.category})}),e.jsx(g,{children:e.jsx(v,{variant:t.importance==="critical"?"destructive":t.importance==="high"?"default":t.importance==="medium"?"secondary":"outline",children:t.importance})}),e.jsx(g,{children:e.jsxs("div",{className:"flex items-center gap-1 text-azure-text-secondary dark:text-matrix-secondary",children:[e.jsx(H,{className:"w-4 h-4"}),new Date(t.created_at).toLocaleDateString()]})}),e.jsx(g,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(j,{variant:"ghost",size:"sm",onClick:()=>le(t),className:"text-blue-500 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:e.jsx(O,{className:"w-4 h-4"})}),e.jsx(j,{variant:"ghost",size:"sm",onClick:()=>se(t.id),className:"text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",children:e.jsx(B,{className:"w-4 h-4"})})]})})]},t.id))})]})}),$>1&&e.jsx(je,{page:u,totalPages:$,perPage:h,total:V,onPageChange:y,onPerPageChange:t=>{U(t),y(1)}})]}),Z&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs(T,{className:"w-full max-w-md mx-4",children:[e.jsx(I,{children:e.jsx(Ne,{children:"Delete Memories"})}),e.jsxs(A,{children:[e.jsxs("p",{className:"mb-4",children:["Are you sure you want to delete ",l.length," ","memory(ies)? This action cannot be undone."]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(j,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),e.jsx(j,{variant:"destructive",onClick:ae,children:"Delete"})]})]})]})}),e.jsx(we,{isOpen:Q,onClose:()=>_(!1),memory:J}),e.jsx(oe,{isOpen:W,onClose:()=>C(!1),onConfirm:ie,title:"Confirm Memory Deletion",message:"Are you sure you want to delete this memory? This action cannot be undone.",confirmButtonText:"Delete Memory",cancelButtonText:"Cancel"})]})};export{_e as SatiMemories};
@@ -1 +1 @@
1
- import{j as r}from"./vendor-motion-C3CZ8ZlO.js";import"./vendor-react-DikRIOlj.js";import{t as x}from"./vendor-utils-D4NnWbOU.js";function m({label:s,error:a,helperText:e,className:t,...d}){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:s}),r.jsx("input",{className:x("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",a&&"border-red-500 focus:border-red-500 focus:ring-red-500",t),...d}),e&&!a&&r.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:e}),a&&r.jsx("p",{className:"text-xs text-red-500",children:a})]})}function u({label:s,options:a,error:e,helperText:t,className:d,...o}){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:s}),r.jsx("select",{className:x("bg-azure-bg dark:bg-black border border-azure-border dark:border-matrix-primary text-azure-text-primary dark:text-matrix-secondary 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 appearance-none",e&&"border-red-500 focus:border-red-500 focus:ring-red-500",d),...o,children:a.map(i=>r.jsx("option",{value:i.value,className:"bg-azure-bg dark:bg-black",children:i.label},i.value))}),t&&!e&&r.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:t}),e&&r.jsx("p",{className:"text-xs text-red-500",children:e})]})}export{u as S,m as T};
1
+ import{j as r}from"./vendor-motion-C3CZ8ZlO.js";import"./vendor-react-DikRIOlj.js";import{t as x}from"./vendor-utils-BIYveU_1.js";function m({label:s,error:a,helperText:e,className:t,...d}){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:s}),r.jsx("input",{className:x("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",a&&"border-red-500 focus:border-red-500 focus:ring-red-500",t),...d}),e&&!a&&r.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:e}),a&&r.jsx("p",{className:"text-xs text-red-500",children:a})]})}function u({label:s,options:a,error:e,helperText:t,className:d,...o}){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:s}),r.jsx("select",{className:x("bg-azure-bg dark:bg-black border border-azure-border dark:border-matrix-primary text-azure-text-primary dark:text-matrix-secondary 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 appearance-none",e&&"border-red-500 focus:border-red-500 focus:ring-red-500",d),...o,children:a.map(i=>r.jsx("option",{value:i.value,className:"bg-azure-bg dark:bg-black",children:i.label},i.value))}),t&&!e&&r.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary",children:t}),e&&r.jsx("p",{className:"text-xs text-red-500",children:e})]})}export{u as S,m as T};
@@ -0,0 +1,9 @@
1
+ import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as b,f as P,c as F}from"./vendor-react-DikRIOlj.js";import{u as J}from"./audit-M-5UGwoK.js";import{u as D}from"./agents-CN_AKX_I.js";import{u as E}from"./useCurrency-CEc5edm2.js";import{I as f,s as V,J as A,O as R,o as L,g as T,N as W,ak as K,au as B,K as M,q as U,a8 as Z,y as q,E as G,al as H,i as X,av as Q,aw as Y,F as ee,aa as te,ax as re,t as se,a4 as ae}from"./vendor-icons-DE7PWdkN.js";import"./vendor-utils-BIYveU_1.js";import"./index-Db1XEN8v.js";import"./config-7LGRnJ26.js";const ne={llm_call:e.jsx(B,{size:16}),tool_call:e.jsx(f,{size:16}),mcp_tool:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M3.49994 11.7501L11.6717 3.57855C12.7762 2.47398 14.5672 2.47398 15.6717 3.57855C16.7762 4.68312 16.7762 6.47398 15.6717 7.57855M15.6717 7.57855L9.49994 13.7501M15.6717 7.57855C16.7762 6.47398 18.5672 6.47398 19.6717 7.57855C20.7762 8.68312 20.7762 10.474 19.6717 11.5785L12.7072 18.543C12.3167 18.9335 12.3167 19.5667 12.7072 19.9572L13.9999 21.2499",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M17.4999 9.74921L11.3282 15.921C10.2237 17.0255 8.43272 17.0255 7.32823 15.921C6.22373 14.8164 6.22373 13.0255 7.32823 11.921L13.4999 5.74939",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),task_created:e.jsx(K,{size:16}),task_completed:e.jsx(A,{size:16}),skill_loaded:e.jsx(W,{size:16}),chronos_job:e.jsx(T,{size:16}),memory_recovery:e.jsx(L,{size:16}),memory_persist:e.jsx(L,{size:16}),telephonist:e.jsx(R,{size:16})},oe={llm_call:"text-blue-400 dark:text-blue-400",tool_call:"text-amber-500 dark:text-amber-400",mcp_tool:"text-orange-500 dark:text-orange-400",task_created:"text-gray-500 dark:text-matrix-secondary",task_completed:"text-green-600 dark:text-matrix-highlight",skill_loaded:"text-teal-600 dark:text-teal-400",chronos_job:"text-orange-500 dark:text-orange-400",memory_recovery:"text-emerald-600 dark:text-emerald-400",memory_persist:"text-violet-600 dark:text-violet-400",telephonist:"text-rose-500 dark:text-rose-400"},ie={llm_call:"border-blue-300 dark:border-blue-500/40",tool_call:"border-amber-300 dark:border-amber-500/40",mcp_tool:"border-purple-300 dark:border-purple-500/40",task_created:"border-gray-300 dark:border-matrix-primary/40",task_completed:"border-green-300 dark:border-matrix-highlight/40",skill_loaded:"border-teal-300 dark:border-teal-500/40",chronos_job:"border-orange-300 dark:border-orange-500/40",memory_recovery:"border-emerald-300 dark:border-emerald-500/40",memory_persist:"border-violet-300 dark:border-violet-500/40",telephonist:"border-rose-300 dark:border-rose-500/40"};function le(t){return t==null?"—":t<1e3?`${t}ms`:`${(t/1e3).toFixed(1)}s`}function de(t,s){if(t==null&&s==null)return"";const r=t??0,i=s??0;return`↑${r.toLocaleString()} ↓${i.toLocaleString()}`}function S(t){return typeof t=="string"?t:JSON.stringify(t,null,2)}function xe({parsedMeta:t,eventType:s}){const r=s==="tool_call"||s==="mcp_tool",{args:i,result:l,...c}=t;if(s==="memory_persist"){const x=Array.isArray(t.inclusions)?t.inclusions:[],d=Array.isArray(t.edits)?t.edits:[],o=Array.isArray(t.deletions)?t.deletions:[];return x.length===0&&d.length===0&&o.length===0?e.jsx("p",{className:"text-[11px] text-gray-400 dark:text-matrix-secondary/50 italic",children:"No memory changes recorded."}):e.jsxs("div",{className:"space-y-2.5",children:[x.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-gray-400 dark:text-matrix-secondary/50 mb-1 flex items-center gap-1",children:[e.jsx(Z,{size:10,className:"text-green-500 dark:text-green-400"})," new memories (",x.length,")"]}),e.jsx("div",{className:"space-y-1",children:x.map((a,m)=>e.jsxs("div",{className:"text-[11px] font-mono text-gray-600 dark:text-matrix-secondary bg-gray-50 dark:bg-zinc-900 rounded px-2 py-1.5 flex items-start gap-2",children:[e.jsx("span",{className:"flex-shrink-0 text-[10px] uppercase font-bold text-violet-500 dark:text-violet-400 bg-violet-50 dark:bg-violet-900/30 px-1 rounded",children:a.category??"?"}),e.jsx("span",{className:"flex-1 break-words",children:a.summary??"—"}),a.importance!=null&&e.jsxs("span",{className:"flex-shrink-0 text-[10px] text-gray-400 dark:text-matrix-secondary/50",children:["imp:",a.importance]})]},m))})]}),d.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-gray-400 dark:text-matrix-secondary/50 mb-1 flex items-center gap-1",children:[e.jsx(q,{size:10,className:"text-amber-500 dark:text-amber-400"})," edited memories (",d.length,")"]}),e.jsx("div",{className:"space-y-1",children:d.map((a,m)=>e.jsxs("div",{className:"text-[11px] font-mono text-gray-600 dark:text-matrix-secondary bg-gray-50 dark:bg-zinc-900 rounded px-2 py-1.5",children:[a.id&&e.jsxs("span",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/50 mr-2",children:["#",a.id]}),a.summary&&e.jsx("span",{className:"break-words",children:a.summary}),a.reason&&e.jsxs("span",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/50 ml-2",children:["— ",a.reason]})]},m))})]}),o.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-gray-400 dark:text-matrix-secondary/50 mb-1 flex items-center gap-1",children:[e.jsx(G,{size:10,className:"text-red-500 dark:text-red-400"})," archived memories (",o.length,")"]}),e.jsx("div",{className:"space-y-1",children:o.map((a,m)=>e.jsxs("div",{className:"text-[11px] font-mono text-gray-600 dark:text-matrix-secondary bg-gray-50 dark:bg-zinc-900 rounded px-2 py-1.5",children:[a.id&&e.jsxs("span",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/50 mr-2",children:["#",a.id]}),a.reason&&e.jsx("span",{className:"break-words",children:a.reason})]},m))})]})]})}return r&&(i!==void 0||l!==void 0)?e.jsxs("div",{className:"space-y-2",children:[i!==void 0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-gray-400 dark:text-matrix-secondary/50 mb-1",children:"args"}),e.jsx("pre",{className:"text-[11px] font-mono text-gray-600 dark:text-matrix-secondary bg-gray-50 dark:bg-zinc-900 rounded p-2 overflow-x-auto whitespace-pre-wrap break-words max-h-40 overflow-y-auto",children:S(i)})]}),l!==void 0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-gray-400 dark:text-matrix-secondary/50 mb-1",children:"result"}),e.jsx("pre",{className:"text-[11px] font-mono text-gray-600 dark:text-matrix-secondary bg-gray-50 dark:bg-zinc-900 rounded p-2 overflow-x-auto whitespace-pre-wrap break-words max-h-48 overflow-y-auto",children:S(l)})]}),Object.keys(c).length>0&&e.jsx("pre",{className:"text-[11px] font-mono text-gray-600 dark:text-matrix-secondary bg-gray-50 dark:bg-zinc-900 rounded p-2 overflow-x-auto whitespace-pre-wrap break-words",children:JSON.stringify(c,null,2)})]}):e.jsx("pre",{className:"text-[11px] font-mono text-gray-600 dark:text-matrix-secondary bg-gray-50 dark:bg-zinc-900 rounded p-2 overflow-x-auto whitespace-pre-wrap break-words max-h-48 overflow-y-auto",children:JSON.stringify(t,null,2)})}const $=({event:t})=>{const[s,r]=b.useState(!1),{getByKey:i}=D(),{fmtCost:l}=E(),c=ne[t.event_type]??e.jsx(f,{size:14}),x=oe[t.event_type]??"text-gray-500",d=ie[t.event_type]??"border-gray-300 dark:border-matrix-primary/40",o=t.agent?i(t.agent):null,a=o?.badgeClass??null,m=o?`${t.agent?.toUpperCase()} ${o.emoji}`:t.agent?.toUpperCase()||null,n=(()=>{try{return t.metadata?typeof t.metadata=="object"?t.metadata:JSON.parse(t.metadata):null}catch{return null}})(),h=n!==null&&Object.keys(n).length>0,N=t.event_type==="memory_recovery"?`${n?.memories_count??0} memories retrieved`:t.event_type==="memory_persist"?(()=>{const g=n?.inclusions_count??0,p=n?.edits_count??0,k=n?.deletions_count??0,y=[];return g&&y.push(`+${g} new`),p&&y.push(`~${p} edited`),k&&y.push(`-${k} archived`),y.length>0?y.join(", "):"memory persisted"})():t.event_type==="telephonist"?(()=>{const g=n?.audio_duration_seconds,p=n?.text_preview,k=g!=null?`${g}s`:"",y=typeof p=="string"&&p?`"${p.length>60?p.slice(0,60)+"…":p}"`:"";return[k,y].filter(Boolean).join(" · ")||"audio transcription"})():t.tool_name??t.model??t.event_type,I=t.event_type==="telephonist",v=n?.audio_duration_seconds,u=I?v!=null?`🎵 ${v}s audio`:"":de(t.input_tokens,t.output_tokens),j=l(t.estimated_cost_usd),_=le(t.duration_ms),w=t.status==="error"?e.jsx(V,{size:14,className:"text-red-500 flex-shrink-0"}):t.status==="success"?e.jsx(A,{size:14,className:"text-green-500 dark:text-matrix-highlight flex-shrink-0"}):null,C=e.jsx("span",{className:`flex-shrink-0 w-3.5 flex items-center justify-center transition-colors ${h?"text-gray-300 dark:text-matrix-secondary/30 hover:text-gray-500 dark:hover:text-matrix-secondary cursor-pointer":"text-transparent pointer-events-none"}`,children:s?e.jsx(M,{size:12}):e.jsx(U,{size:12})}),z=()=>{h&&r(g=>!g)};return e.jsxs("div",{className:"py-2 px-3 rounded-lg hover:bg-gray-50 dark:hover:bg-zinc-900/60 transition-colors border-b border-gray-100 dark:border-matrix-primary/20 last:border-0",children:[e.jsxs("div",{className:"flex flex-col gap-0.5 md:hidden",children:[e.jsxs("div",{className:`flex items-center gap-2 min-w-0 ${h?"cursor-pointer":""}`,onClick:z,children:[C,e.jsx("span",{className:`flex-shrink-0 ${x}`,children:c}),a&&e.jsx("span",{className:`flex-shrink-0 text-xs font-semibold px-1.5 py-0.5 rounded ${a}`,children:m}),e.jsx("span",{className:"flex-1 text-sm text-gray-700 dark:text-matrix-secondary font-mono break-all leading-snug",children:N}),w]}),e.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-0 pl-5 text-[11px] text-gray-400 dark:text-matrix-secondary/60 font-mono",children:[u&&e.jsx("span",{children:u}),e.jsx("span",{children:_}),j!=="—"&&e.jsx("span",{className:"text-gray-600 dark:text-matrix-secondary",children:j})]})]}),e.jsxs("div",{className:`hidden md:flex items-center gap-3 ${h?"cursor-pointer":""}`,onClick:z,children:[C,e.jsx("span",{className:`flex-shrink-0 ${x}`,children:c}),a&&e.jsx("span",{className:`flex-shrink-0 text-xs font-semibold px-1.5 py-0.5 rounded ${a}`,children:m}),e.jsx("span",{className:"flex-1 text-sm truncate text-gray-700 dark:text-matrix-secondary font-mono",children:N}),u&&e.jsx("span",{className:"text-xs text-gray-400 dark:text-matrix-secondary/60 font-mono whitespace-nowrap",children:u}),e.jsx("span",{className:"text-xs text-gray-400 dark:text-matrix-secondary/60 font-mono w-16 text-right whitespace-nowrap",children:_}),w,e.jsx("span",{className:"text-xs text-gray-400 dark:text-matrix-secondary/60 font-mono w-20 text-right whitespace-nowrap",children:j})]}),s&&h&&n&&e.jsx("div",{className:`mt-1.5 ml-5 pl-3 border-l-2 ${d}`,children:e.jsx(xe,{parsedMeta:n,eventType:t.event_type})})]})},ce=({events:t,page:s,pageSize:r,totalCount:i,onPageChange:l})=>{const c=Math.ceil(i/r),x=s*r+1,d=Math.min(s*r+t.length,i);if(t.length===0)return e.jsx("div",{className:"flex items-center justify-center h-40 text-gray-400 dark:text-matrix-secondary/50 text-sm",children:"No audit events for this session."});const o=[],a=new Map;for(const n of t)if(n.task_id){const h=a.get(n.task_id)??[];h.push(n),a.set(n.task_id,h)}const m=new Set;for(const n of t)n.task_id?m.has(n.task_id)||(m.add(n.task_id),o.push({taskId:n.task_id,events:a.get(n.task_id)})):o.push({taskId:null,events:[n]});return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"hidden md:flex items-center gap-3 px-3 py-1 text-xs text-gray-400 dark:text-matrix-secondary/60 border-b border-gray-200 dark:border-matrix-primary/30 font-mono",children:[e.jsx("span",{className:"w-4"}),e.jsx("span",{className:"w-14 flex-shrink-0",children:"agent"}),e.jsx("span",{className:"flex-1",children:"event / tool / model"}),e.jsx("span",{className:"w-28 text-right",children:"tokens ↑↓"}),e.jsx("span",{className:"w-16 text-right",children:"duration"}),e.jsx("span",{className:"w-4"}),e.jsx("span",{className:"w-20 text-right",children:"cost"})]}),e.jsx("div",{className:"flex flex-col",children:o.map(n=>n.taskId?e.jsxs("div",{className:"mb-1",children:[e.jsxs("div",{className:"px-3 py-1 text-xs text-gray-400 dark:text-matrix-secondary/50 font-mono border-l-2 border-blue-300 dark:border-matrix-primary/60 ml-1 mb-0.5",children:["task: ",n.taskId.slice(0,8),"…"]}),e.jsx("div",{className:"pl-4",children:n.events.map(h=>e.jsx($,{event:h},h.id))})]},n.taskId):e.jsx($,{event:n.events[0]},n.events[0].id))}),c>1&&e.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-gray-200 dark:border-matrix-primary/30 mt-2",children:[e.jsxs("span",{className:"text-xs text-gray-400 dark:text-matrix-secondary/60",children:[x,"–",d," of ",i," events"]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>l(s-1),disabled:s===0,className:"p-1 rounded text-gray-400 dark:text-matrix-secondary hover:text-gray-700 dark:hover:text-matrix-highlight disabled:opacity-30 transition-colors",children:e.jsx(H,{size:16})}),e.jsxs("span",{className:"text-xs self-center text-gray-500 dark:text-matrix-secondary font-mono px-2",children:[s+1," / ",c]}),e.jsx("button",{onClick:()=>l(s+1),disabled:s>=c-1,className:"p-1 rounded text-gray-400 dark:text-matrix-secondary hover:text-gray-700 dark:hover:text-matrix-highlight disabled:opacity-30 transition-colors",children:e.jsx(U,{size:16})})]})]})]})};function me(t){return t<1e3?`${t}ms`:t<6e4?`${(t/1e3).toFixed(1)}s`:`${(t/6e4).toFixed(1)}m`}const he=({summary:t})=>{const{fmtCost:s}=E();return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-matrix-primary p-4 bg-white dark:bg-black",children:[e.jsxs("h3",{className:"text-sm font-semibold text-gray-700 dark:text-matrix-highlight mb-3 flex items-center gap-2",children:[e.jsx(X,{size:14})," Total Cost"]}),e.jsx("div",{className:"text-2xl font-bold text-gray-900 dark:text-matrix-highlight font-mono",children:s(t.totalCostUsd)}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs text-gray-500 dark:text-matrix-secondary",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(B,{size:12,className:"text-blue-400"}),e.jsxs("span",{children:[t.llmCallCount," LLM calls"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(f,{size:12,className:"text-amber-400"}),e.jsxs("span",{children:[t.toolCallCount," tool calls"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[e.jsx(T,{size:12,className:"text-gray-400"}),e.jsxs("span",{children:[me(t.totalDurationMs)," total duration"]})]}),t.totalAudioSeconds>0&&e.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[e.jsx(R,{size:12,className:"text-rose-400"}),e.jsxs("span",{children:[t.totalAudioSeconds.toFixed(1),"s audio"]})]})]})]}),t.byAgent.length>0&&e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-matrix-primary p-4 bg-white dark:bg-black",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-700 dark:text-matrix-highlight mb-3",children:"By Agent"}),e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-gray-400 dark:text-matrix-secondary/60 border-b border-gray-100 dark:border-matrix-primary/30",children:[e.jsx("th",{className:"text-left pb-1.5",children:"Agent"}),e.jsx("th",{className:"text-right pb-1.5",children:"Calls"}),e.jsx("th",{className:"text-right pb-1.5",children:"Tokens"}),e.jsx("th",{className:"text-right pb-1.5",children:"Cost"})]})}),e.jsx("tbody",{children:t.byAgent.map(r=>e.jsxs("tr",{className:"border-b border-gray-50 dark:border-matrix-primary/10 last:border-0",children:[e.jsx("td",{className:"py-1.5 text-gray-700 dark:text-matrix-secondary font-semibold",children:r.agent}),e.jsx("td",{className:"py-1.5 text-right text-gray-500 dark:text-matrix-secondary/70 font-mono",children:r.llmCalls}),e.jsx("td",{className:"py-1.5 text-right text-gray-500 dark:text-matrix-secondary/70 font-mono",children:(r.inputTokens+r.outputTokens).toLocaleString()}),e.jsx("td",{className:"py-1.5 text-right text-gray-700 dark:text-matrix-highlight font-mono",children:s(r.estimatedCostUsd)})]},r.agent))})]})]}),t.byModel.length>0&&e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-matrix-primary p-4 bg-white dark:bg-black",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-700 dark:text-matrix-highlight mb-3",children:"By Model"}),e.jsx("div",{className:"flex flex-col gap-2",children:t.byModel.map(r=>e.jsxs("div",{className:"border-b border-gray-50 dark:border-matrix-primary/10 last:border-0 pb-2 last:pb-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-0.5",children:[e.jsx("span",{className:"text-xs font-mono text-gray-700 dark:text-matrix-secondary break-all leading-snug",children:r.model}),e.jsx("span",{className:"text-xs font-mono text-gray-700 dark:text-matrix-highlight whitespace-nowrap shrink-0",children:s(r.estimatedCostUsd)})]}),e.jsxs("div",{className:"text-[11px] text-gray-400 dark:text-matrix-secondary/60 font-mono flex flex-wrap gap-x-3",children:[e.jsxs("span",{children:[r.calls," calls"]}),e.jsxs("span",{children:["in ",r.inputTokens.toLocaleString()]}),e.jsxs("span",{children:["out ",r.outputTokens.toLocaleString()]})]})]},`${r.provider}/${r.model}`))})]})]})};function pe(t,s){const r=new Blob([JSON.stringify(s,null,2)],{type:"application/json"}),i=URL.createObjectURL(r),l=document.createElement("a");l.href=i,l.download=`audit-${t.slice(0,8)}.json`,l.click(),URL.revokeObjectURL(i)}function ge(t,s){const r=["id","created_at","event_type","agent","tool_name","provider","model","input_tokens","output_tokens","duration_ms","status","estimated_cost_usd"],i=s.events.map(o=>[o.id,new Date(o.created_at).toISOString(),o.event_type,o.agent??"",o.tool_name??"",o.provider??"",o.model??"",o.input_tokens??"",o.output_tokens??"",o.duration_ms??"",o.status??"",o.estimated_cost_usd??""].map(a=>`"${String(a).replace(/"/g,'""')}"`).join(",")),l=[r.join(","),...i].join(`
2
+ `),c=new Blob([l],{type:"text/csv"}),x=URL.createObjectURL(c),d=document.createElement("a");d.href=x,d.download=`audit-${t.slice(0,8)}.csv`,d.click(),URL.revokeObjectURL(x)}const ye=({sessionId:t,data:s})=>{const[r,i]=b.useState(!1);return s?e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>i(!r),className:"flex items-center gap-1.5 text-sm px-3 py-1.5 rounded-lg border border-gray-200 dark:border-matrix-primary text-gray-600 dark:text-matrix-secondary hover:text-gray-900 dark:hover:text-matrix-highlight hover:border-gray-300 dark:hover:border-matrix-highlight transition-colors",children:[e.jsx(Q,{size:14}),"Export",e.jsx(M,{size:12})]}),r&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>i(!1)}),e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-20 bg-white dark:bg-black border border-gray-200 dark:border-matrix-primary rounded-lg shadow-xl min-w-[140px] py-1",children:[e.jsxs("button",{onClick:()=>{pe(t,s),i(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-matrix-secondary hover:bg-gray-50 dark:hover:bg-zinc-900 transition-colors",children:[e.jsx(Y,{size:14,className:"text-blue-500"}),"Export JSON"]}),e.jsxs("button",{onClick:()=>{ge(t,s),i(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-matrix-secondary hover:bg-gray-50 dark:hover:bg-zinc-900 transition-colors",children:[e.jsx(ee,{size:14,className:"text-green-500"}),"Export CSV"]})]})]})]}):null},O=100,Ce=()=>{const{id:t}=P(),s=F(),[r,i]=b.useState(0),{data:l,error:c,isLoading:x}=J(t??null,r,O),d=b.useRef(null),[o,a]=b.useState(()=>typeof window<"u"?window.innerWidth>=768:!0);return b.useEffect(()=>{d.current&&(d.current.scrollTop=d.current.scrollHeight)},[l]),e.jsxs("div",{className:"flex flex-col h-full bg-gray-50 dark:bg-black",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-matrix-primary bg-white dark:bg-black flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>s(-1),className:"p-1.5 rounded-lg text-gray-400 dark:text-matrix-secondary hover:text-gray-700 dark:hover:text-matrix-highlight hover:bg-gray-100 dark:hover:bg-zinc-900 transition-colors",children:e.jsx(te,{size:18})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 dark:text-matrix-highlight",children:"Session Audit"}),e.jsx("p",{className:"text-xs text-gray-400 dark:text-matrix-secondary/60 font-mono",children:t})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>a(m=>!m),className:"p-1.5 rounded-lg text-gray-400 dark:text-matrix-secondary hover:text-gray-700 dark:hover:text-matrix-highlight hover:bg-gray-100 dark:hover:bg-zinc-900 transition-colors md:hidden",title:"Toggle summary panel",children:e.jsx(re,{size:18})}),e.jsx(ye,{sessionId:t??"",data:l})]})]}),e.jsxs("div",{className:"flex-1 flex overflow-hidden relative",children:[o&&e.jsx("div",{className:"fixed inset-0 bg-black/40 z-20 md:hidden",onClick:()=>a(!1)}),e.jsxs("div",{ref:d,className:"flex-[6] overflow-y-auto p-6 custom-scrollbar",children:[x&&e.jsxs("div",{className:"flex items-center justify-center h-40 gap-2 text-gray-400 dark:text-matrix-secondary",children:[e.jsx(se,{size:18,className:"animate-spin"}),"Loading audit events…"]}),c&&e.jsxs("div",{className:"flex items-center gap-2 text-red-500 dark:text-red-400 p-4 rounded-lg border border-red-200 dark:border-red-800 bg-red-50 dark:bg-red-900/20",children:[e.jsx(ae,{size:16}),"Failed to load audit events: ",c.message]}),l&&e.jsx(ce,{events:l.events,page:r,pageSize:O,totalCount:l.total_count,onPageChange:i})]}),e.jsx("div",{className:`
3
+ fixed top-16 bottom-0 right-0 z-40 w-72
4
+ md:relative md:inset-auto md:z-auto md:w-auto md:flex-[4] md:translate-x-0
5
+ transition-transform duration-300 ease-out
6
+ overflow-y-auto p-6 border-l border-gray-200 dark:border-matrix-primary
7
+ bg-white dark:bg-black custom-scrollbar
8
+ ${o?"translate-x-0":"translate-x-full"}
9
+ `,children:l?e.jsx(he,{summary:l.summary}):!x&&e.jsx("div",{className:"text-sm text-gray-400 dark:text-matrix-secondary/50 text-center mt-10",children:"No summary available."})})]})]})};export{Ce as SessionAudit};