morpheus-cli 0.9.13 → 0.9.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -17
- package/dist/channels/discord.js +93 -6
- package/dist/channels/telegram.js +109 -9
- package/dist/cli/commands/start.js +15 -0
- package/dist/config/manager.js +20 -1
- package/dist/config/paths.js +4 -0
- package/dist/config/schemas.js +15 -0
- package/dist/http/api.js +2 -1
- package/dist/http/routers/danger.js +4 -5
- package/dist/http/routers/link.js +2 -2
- package/dist/runtime/__tests__/telephonist-tts.test.js +84 -0
- package/dist/runtime/adapters/AuditRepositoryAdapter.js +6 -0
- package/dist/runtime/adapters/ChannelNotifierAdapter.js +9 -0
- package/dist/runtime/adapters/LangChainProviderAdapter.js +9 -0
- package/dist/runtime/adapters/SQLiteChatHistoryAdapter.js +15 -0
- package/dist/runtime/adapters/SQLiteTaskEnqueuerAdapter.js +6 -0
- package/dist/runtime/adapters/index.js +5 -0
- package/dist/runtime/audit/repository.js +6 -2
- package/dist/runtime/chronos/repository.js +2 -2
- package/dist/runtime/container.js +50 -0
- package/dist/runtime/hot-reload.js +6 -9
- package/dist/runtime/memory/backfill-embeddings.js +2 -3
- package/dist/runtime/memory/sati/repository.js +3 -3
- package/dist/runtime/memory/sqlite.js +3 -3
- package/dist/runtime/memory/trinity-db.js +2 -2
- package/dist/runtime/ports/IAuditEmitter.js +1 -0
- package/dist/runtime/ports/IChatHistory.js +1 -0
- package/dist/runtime/ports/ILLMProviderFactory.js +1 -0
- package/dist/runtime/ports/INotifier.js +1 -0
- package/dist/runtime/ports/ITaskEnqueuer.js +1 -0
- package/dist/runtime/ports/index.js +1 -0
- package/dist/runtime/providers/factory.js +8 -52
- package/dist/runtime/providers/strategies.js +66 -0
- package/dist/runtime/setup/repository.js +2 -2
- package/dist/runtime/subagents/apoc.js +2 -2
- package/dist/runtime/subagents/link/link.js +2 -2
- package/dist/runtime/subagents/link/repository.js +2 -2
- package/dist/runtime/subagents/link/worker.js +3 -3
- package/dist/runtime/subagents/neo.js +2 -2
- package/dist/runtime/subagents/trinity/trinity.js +2 -2
- package/dist/runtime/tasks/repository.js +2 -2
- package/dist/runtime/telephonist.js +160 -0
- package/dist/runtime/tools/delegation-utils.js +5 -7
- package/dist/runtime/tools/morpheus-tools.js +6 -7
- package/dist/runtime/tools/smith-tool.js +5 -7
- package/dist/runtime/webhooks/repository.js +2 -2
- package/dist/types/config.js +6 -0
- package/dist/ui/assets/AuditDashboard-Cu33zb_7.js +1 -0
- package/dist/ui/assets/{Chat-UVoDlqqM.js → Chat-mt1j5V55.js} +1 -1
- package/dist/ui/assets/{Chronos-Dfs_pOsc.js → Chronos-Bq_h41cw.js} +1 -1
- package/dist/ui/assets/{ConfirmationModal-BBIjVef7.js → ConfirmationModal-CxLP8iC6.js} +1 -1
- package/dist/ui/assets/{Dashboard-BdSQDB14.js → Dashboard-D0LAlHtG.js} +1 -1
- package/dist/ui/assets/{DeleteConfirmationModal-Du85q5u2.js → DeleteConfirmationModal-kZ_c3sFk.js} +1 -1
- package/dist/ui/assets/{Documents-DguILrI8.js → Documents-nlQNoUcq.js} +1 -1
- package/dist/ui/assets/{Logs-BDup2FET.js → Logs-C1tlg574.js} +1 -1
- package/dist/ui/assets/{MCPManager-WBdh1rum.js → MCPManager-Do7isizG.js} +1 -1
- package/dist/ui/assets/ModelPricing-BeJ7oXBA.js +1 -0
- package/dist/ui/assets/{Notifications-BslO2Ect.js → Notifications-Cg5CMlY0.js} +1 -1
- package/dist/ui/assets/{SatiMemories-DzaLaZ6M.js → SatiMemories-D9l6s8Pc.js} +1 -1
- package/dist/ui/assets/SessionAudit-Da1ySlYg.js +9 -0
- package/dist/ui/assets/Settings-DpXwpEhO.js +49 -0
- package/dist/ui/assets/{Skills-BnDg1HCb.js → Skills-DaqCY8QH.js} +1 -1
- package/dist/ui/assets/Smiths-DA-x4KFT.js +1 -0
- package/dist/ui/assets/Switch-CJTE4ZQm.js +1 -0
- package/dist/ui/assets/{Tasks-BuoNCvI-.js → Tasks-DU49M9U-.js} +1 -1
- package/dist/ui/assets/{TrinityDatabases-DYHJunk7.js → TrinityDatabases-CoKzKTL-.js} +1 -1
- package/dist/ui/assets/{UsageStats-BpGXaHgW.js → UsageStats-cds352Pj.js} +1 -1
- package/dist/ui/assets/{WebhookManager-D2muhYy9.js → WebhookManager-DdAdHQUk.js} +1 -1
- package/dist/ui/assets/{agents-CgqJea9n.js → agents-B1z_dlQC.js} +1 -1
- package/dist/ui/assets/{audit-Dc3YW0-4.js → audit-BAhaGrKY.js} +1 -1
- package/dist/ui/assets/{chronos-CZvGhZQB.js → chronos-DGD_Md9M.js} +1 -1
- package/dist/ui/assets/config-BwTXe5M2.js +1 -0
- package/dist/ui/assets/{index-Bta9YXEm.js → index-BcX5O7kY.js} +2 -2
- package/dist/ui/assets/{mcp-vIffcwd6.js → mcp-BlkruPaA.js} +1 -1
- package/dist/ui/assets/{skills-wANsorUj.js → skills-CtCb-52u.js} +1 -1
- package/dist/ui/assets/{stats-xnlA4NwX.js → stats-BiPI2kaw.js} +1 -1
- package/dist/ui/assets/useCurrency-BCdG-pHx.js +1 -0
- package/dist/ui/index.html +1 -1
- package/dist/ui/sw.js +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/AuditDashboard-BVyKnpVm.js +0 -1
- package/dist/ui/assets/ModelPricing-BQPw0r6z.js +0 -1
- package/dist/ui/assets/SessionAudit-CBDThjBi.js +0 -9
- package/dist/ui/assets/Settings-JPTCA7C7.js +0 -49
- package/dist/ui/assets/Smiths-DR6g_o3D.js +0 -1
- package/dist/ui/assets/config-pKL8Y4V9.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{H as c}from"./index-
|
|
1
|
+
import{H as c}from"./index-BcX5O7kY.js";const e=c.getInstance(),n={fetchServers:async()=>e.get("/mcp/servers"),addServer:async(t,s)=>e.post("/mcp/servers",{name:t,config:s}),updateServer:async(t,s)=>e.put(`/mcp/servers/${encodeURIComponent(t)}`,{config:s}),deleteServer:async t=>e.delete(`/mcp/servers/${encodeURIComponent(t)}`),toggleServer:async(t,s)=>e.patch(`/mcp/servers/${encodeURIComponent(t)}/toggle`,{enabled:s}),reloadTools:async()=>e.post("/mcp/reload",{}),fetchStatus:async()=>e.get("/mcp/status"),fetchStats:async()=>e.get("/mcp/stats")};export{n as m};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{H as e}from"./index-
|
|
1
|
+
import{H as e}from"./index-BcX5O7kY.js";const s=e.getInstance(),o={fetchSkills:async()=>s.get("/skills"),fetchSkill:async l=>s.get(`/skills/${encodeURIComponent(l)}`),reloadSkills:async()=>s.post("/skills/reload",{}),enableSkill:async l=>s.post(`/skills/${encodeURIComponent(l)}/enable`,{}),disableSkill:async l=>s.post(`/skills/${encodeURIComponent(l)}/disable`,{}),uploadSkill:async l=>s.uploadFile("/skills/upload",l)};export{o as s};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as t}from"./index-
|
|
1
|
+
import{h as t}from"./index-BcX5O7kY.js";const e={fetchUsageStats:async()=>t.get("/stats/usage"),fetchGroupedUsageStats:async()=>t.get("/stats/usage/grouped")};export{e as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as f}from"./vendor-utils-D4NnWbOU.js";import{c as $}from"./config-BwTXe5M2.js";const y={code:"USD",symbol:"$",rate:1};function m(){const{data:c}=f("config/currency",()=>$.fetchConfig(),{revalidateOnFocus:!1,dedupingInterval:6e4}),r=c?.currency?{code:c.currency.code,symbol:c.currency.symbol,rate:c.currency.rate}:y,n=r.code==="USD"||r.rate===1;function s(t){if(t==null||t===0)return"—";const e=t<1e-4?"<$0.0001":`$${t.toFixed(4)}`;if(n)return e;const o=t*r.rate,u=o<1e-4?`<${r.symbol}0.0001`:`${r.symbol}${o.toFixed(4)}`;return`${e} / ${u}`}function i(t){const e=`$${t.toFixed(4)}`;if(n)return e;const o=t*r.rate;return`${e} / ${r.symbol}${o.toFixed(4)}`}return{currency:r,isUSD:n,fmtCost:s,fmtPrice:i}}export{m as u};
|
package/dist/ui/index.html
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
<title>Morpheus Agent UI</title>
|
|
20
20
|
<!-- vite-plugin-pwa injeta <link rel="manifest"> automaticamente no build -->
|
|
21
|
-
<script type="module" crossorigin src="./assets/index-
|
|
21
|
+
<script type="module" crossorigin src="./assets/index-BcX5O7kY.js"></script>
|
|
22
22
|
<link rel="modulepreload" crossorigin href="./assets/vendor-react-DikRIOlj.js">
|
|
23
23
|
<link rel="modulepreload" crossorigin href="./assets/vendor-motion-C3CZ8ZlO.js">
|
|
24
24
|
<link rel="modulepreload" crossorigin href="./assets/vendor-utils-D4NnWbOU.js">
|
package/dist/ui/sw.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
if(!self.define){let s,e={};const
|
|
1
|
+
if(!self.define){let s,e={};const i=(i,l)=>(i=new URL(i+".js",l).href,e[i]||new Promise(e=>{if("document"in self){const s=document.createElement("script");s.src=i,s.onload=e,document.head.appendChild(s)}else s=i,importScripts(i),e()}).then(()=>{let s=e[i];if(!s)throw new Error(`Module ${i} didn’t register its module`);return s}));self.define=(l,n)=>{const r=s||("document"in self?document.currentScript.src:"")||location.href;if(e[r])return;let a={};const u=s=>i(s,r),o={module:{uri:r},exports:a,require:u};e[r]=Promise.all(l.map(s=>o[s]||u(s))).then(s=>(n(...s),a))}}define(["./workbox-26f462e7"],function(s){"use strict";self.skipWaiting(),s.clientsClaim(),s.precacheAndRoute([{url:"vite.svg",revision:"5e386a6b1608494961c0a0de283e0df8"},{url:"registerSW.js",revision:"402b66900e731ca748771b6fc5e7a068"},{url:"pwa-maskable-512x512.png",revision:"e9dc04fc1b43cd6093e286bf765726d8"},{url:"pwa-maskable-192x192.png",revision:"8eb12fd764e6cb6f56247b2e1b21a31f"},{url:"pwa-512x512.png",revision:"f9619ef45b67856ce91010c1eb1d3c0c"},{url:"pwa-192x192.png",revision:"6174f6c5724689f6c15526be28983ca8"},{url:"index.html",revision:"ee91d81dc9c48285de276bbe9ad71b98"},{url:"assets/vendor-utils-D4NnWbOU.js",revision:null},{url:"assets/vendor-react-DikRIOlj.js",revision:null},{url:"assets/vendor-motion-C3CZ8ZlO.js",revision:null},{url:"assets/vendor-markdown-BN_Np5Ta.js",revision:null},{url:"assets/vendor-icons-NHF9HNeN.js",revision:null},{url:"assets/useCurrency-BCdG-pHx.js",revision:null},{url:"assets/stats-BiPI2kaw.js",revision:null},{url:"assets/skills-CtCb-52u.js",revision:null},{url:"assets/mcp-BlkruPaA.js",revision:null},{url:"assets/index-Cjli-AD7.css",revision:null},{url:"assets/index-BcX5O7kY.js",revision:null},{url:"assets/config-BwTXe5M2.js",revision:null},{url:"assets/chronos-DGD_Md9M.js",revision:null},{url:"assets/audit-BAhaGrKY.js",revision:null},{url:"assets/agents-B1z_dlQC.js",revision:null},{url:"assets/WebhookManager-DdAdHQUk.js",revision:null},{url:"assets/UsageStats-cds352Pj.js",revision:null},{url:"assets/TrinityDatabases-CoKzKTL-.js",revision:null},{url:"assets/Tasks-DU49M9U-.js",revision:null},{url:"assets/Switch-CJTE4ZQm.js",revision:null},{url:"assets/Smiths-DA-x4KFT.js",revision:null},{url:"assets/Skills-DaqCY8QH.js",revision:null},{url:"assets/Settings-DpXwpEhO.js",revision:null},{url:"assets/SessionAudit-Da1ySlYg.js",revision:null},{url:"assets/SelectInput-KVLsnfra.js",revision:null},{url:"assets/SatiMemories-D9l6s8Pc.js",revision:null},{url:"assets/Pagination-BHZKk42X.js",revision:null},{url:"assets/Notifications-Cg5CMlY0.js",revision:null},{url:"assets/ModelPricing-BeJ7oXBA.js",revision:null},{url:"assets/MCPManager-Do7isizG.js",revision:null},{url:"assets/Logs-C1tlg574.js",revision:null},{url:"assets/Documents-nlQNoUcq.js",revision:null},{url:"assets/DeleteConfirmationModal-kZ_c3sFk.js",revision:null},{url:"assets/Dashboard-D0LAlHtG.js",revision:null},{url:"assets/ConfirmationModal-CxLP8iC6.js",revision:null},{url:"assets/Chronos-Bq_h41cw.js",revision:null},{url:"assets/Chat-mt1j5V55.js",revision:null},{url:"assets/AuditDashboard-Cu33zb_7.js",revision:null},{url:"pwa-192x192.png",revision:"6174f6c5724689f6c15526be28983ca8"},{url:"pwa-512x512.png",revision:"f9619ef45b67856ce91010c1eb1d3c0c"},{url:"pwa-maskable-192x192.png",revision:"8eb12fd764e6cb6f56247b2e1b21a31f"},{url:"pwa-maskable-512x512.png",revision:"e9dc04fc1b43cd6093e286bf765726d8"},{url:"manifest.webmanifest",revision:"da8b9a11743009a7e50876a50de29362"}],{}),s.cleanupOutdatedCaches(),s.registerRoute(new s.NavigationRoute(s.createHandlerBoundToURL("/index.html"),{denylist:[/^\/api\//]})),s.registerRoute(/^\/api\//,new s.NetworkOnly,"GET"),s.registerRoute(/\.(?:js|css|woff2)$/,new s.CacheFirst({cacheName:"static-assets",plugins:[new s.ExpirationPlugin({maxAgeSeconds:31536e3})]}),"GET"),s.registerRoute(/\.(?:png|svg|ico)$/,new s.StaleWhileRevalidate({cacheName:"images",plugins:[new s.ExpirationPlugin({maxEntries:50,maxAgeSeconds:2592e3})]}),"GET")});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "morpheus-cli",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.20",
|
|
4
4
|
"description": "Morpheus is a local AI agent for developers, running as a CLI daemon that connects to LLMs, local tools, and MCPs, enabling interaction via Terminal, Telegram, and Discord. Inspired by the character Morpheus from *The Matrix*, the project acts as an intelligent orchestrator, bridging the gap between the developer and complex systems.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"morpheus": "./bin/morpheus.js"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,m as n}from"./vendor-motion-C3CZ8ZlO.js";import{L as E,r as B}from"./vendor-react-DikRIOlj.js";import{a as D}from"./audit-Dc3YW0-4.js";import{u as F}from"./agents-CgqJea9n.js";import{Q as _,O as R,h as L,i as O,as as v,E as j,m as N,A as z,g as w,aw as U,k as W,J as S,ax as I,K as A,p as P,ai as V}from"./vendor-icons-NHF9HNeN.js";import"./vendor-utils-D4NnWbOU.js";import"./index-Bta9YXEm.js";function u(a){return a===0?"$0.00":a<1e-4?"<$0.0001":a<.01?`$${a.toFixed(4)}`:`$${a.toFixed(2)}`}function m(a){return a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${(a/1e3).toFixed(1)}k`:String(a)}function k(a){if(a<1e3)return`${a}ms`;if(a<6e4)return`${(a/1e3).toFixed(1)}s`;const i=Math.floor(a/6e4),l=Math.floor(a%6e4/1e3);return`${i}m ${l}s`}function H(a){return a?new Date(a).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function T(a,i){return i?`${Math.round(a/i*100)}%`:"0%"}function G({data:a}){const[i,l]=B.useState(null);if(!a.length)return e.jsx("p",{className:"text-xs text-gray-400 dark:text-matrix-secondary/50 py-4",children:"No activity in the last 30 days."});const s=Math.max(...a.map(r=>r.eventCount),1);return e.jsx("div",{className:"flex items-end gap-0.5 h-24 w-full relative",children:a.map((r,c)=>{const y=Math.max(4,Math.round(r.eventCount/s*88)),g=i===c;return e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-end group",onMouseEnter:()=>l(c),onMouseLeave:()=>l(null),children:[g&&e.jsxs("div",{className:"absolute -top-10 left-1/2 -translate-x-1/2 z-10 bg-gray-900 dark:bg-zinc-800 text-white text-[10px] rounded px-2 py-1 whitespace-nowrap pointer-events-none shadow-lg",children:[r.date,": ",r.eventCount," events · ",u(r.estimatedCostUsd)]}),e.jsx("div",{style:{height:y},className:`w-full rounded-t transition-colors ${g?"bg-blue-500 dark:bg-matrix-highlight":"bg-blue-300/70 dark:bg-matrix-highlight/40 group-hover:bg-blue-400 dark:group-hover:bg-matrix-highlight/60"}`})]},r.date)})})}function h({icon:a,label:i,value:l,sub:s,color:r="blue"}){const c={blue:"bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 border-blue-200 dark:border-blue-800/40",green:"bg-green-50 dark:bg-green-900/20 text-green-600 dark:text-matrix-highlight border-green-200 dark:border-green-800/40",amber:"bg-amber-50 dark:bg-amber-900/20 text-amber-600 dark:text-amber-400 border-amber-200 dark:border-amber-800/40",purple:"bg-purple-50 dark:bg-purple-900/20 text-purple-600 dark:text-purple-400 border-purple-200 dark:border-purple-800/40",rose:"bg-rose-50 dark:bg-rose-900/20 text-rose-600 dark:text-rose-400 border-rose-200 dark:border-rose-800/40",teal:"bg-teal-50 dark:bg-teal-900/20 text-teal-600 dark:text-teal-400 border-teal-200 dark:border-teal-800/40"};return e.jsxs("div",{className:`rounded-lg border p-4 flex gap-3 items-start ${c[r]}`,children:[e.jsx("div",{className:"mt-0.5 flex-shrink-0",children:a}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-medium opacity-70 uppercase tracking-wider mb-0.5",children:i}),e.jsx("p",{className:"text-xl font-bold font-mono leading-tight",children:l}),s&&e.jsx("div",{className:"text-[11px] opacity-60 mt-0.5 leading-snug",children:s})]})]})}function o({title:a,icon:i,children:l}){return e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-matrix-primary overflow-hidden bg-white dark:bg-zinc-900 shadow-sm",children:[e.jsxs("div",{className:"px-4 py-3 bg-gray-50 dark:bg-zinc-900 border-b border-gray-200 dark:border-matrix-primary flex items-center gap-2",children:[e.jsx("span",{className:"text-gray-500 dark:text-matrix-secondary/70",children:i}),e.jsx("h2",{className:"text-sm font-semibold text-gray-700 dark:text-matrix-secondary uppercase tracking-wider",children:a})]}),e.jsx("div",{className:"p-4",children:l})]})}function M({agent:a}){const{getByKey:i}=F(),l=i(a);return e.jsxs("span",{className:`inline-flex items-center gap-1 text-[11px] font-semibold px-1.5 py-0.5 rounded ${l.badgeClass}`,children:[l.emoji," ",a.toUpperCase()]})}function J({status:a}){const i={active:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-matrix-highlight",paused:"bg-gray-100 text-gray-600 dark:bg-zinc-800 dark:text-matrix-secondary",archived:"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-300",deleted:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400",unknown:"bg-gray-100 text-gray-500 dark:bg-zinc-800 dark:text-matrix-secondary/60"};return e.jsx("span",{className:`text-[10px] font-semibold uppercase px-1.5 py-0.5 rounded ${i[a]??i.unknown}`,children:a})}const K={llm_call:e.jsx(v,{size:13}),tool_call:e.jsx(j,{size:13}),mcp_tool:e.jsxs("svg",{width:"13",height:"13",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"})]}),memory_recovery:e.jsx(N,{size:13}),memory_persist:e.jsx(N,{size:13}),telephonist:e.jsx(A,{size:13}),skill_loaded:e.jsx(S,{size:13}),chronos_job:e.jsx(w,{size:13}),task_created:e.jsx(V,{size:13}),task_completed:e.jsx(P,{size:13})},Q={llm_call:"text-blue-500 dark:text-blue-400",tool_call:"text-amber-500 dark:text-amber-400",mcp_tool:"text-purple-500 dark:text-purple-400",memory_recovery:"text-emerald-500 dark:text-emerald-400",memory_persist:"text-violet-500 dark:text-violet-400",telephonist:"text-rose-500 dark:text-rose-400",skill_loaded:"text-teal-500 dark:text-teal-400",chronos_job:"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"};function Z({eventType:a}){return a==="mcp_tool"?e.jsx("span",{className:"flex-shrink-0 text-purple-500 dark:text-purple-400",children:e.jsxs("svg",{width:"13",height:"13",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"})]})}):e.jsx(j,{size:13,className:"flex-shrink-0 text-amber-500 dark:text-amber-400"})}const q={llm_call:"bg-blue-400 dark:bg-blue-500",tool_call:"bg-amber-400 dark:bg-amber-500",mcp_tool:"bg-purple-400 dark:bg-purple-500",memory_recovery:"bg-emerald-400 dark:bg-emerald-500",memory_persist:"bg-violet-400 dark:bg-violet-500",telephonist:"bg-rose-400 dark:bg-rose-500",skill_loaded:"bg-teal-400 dark:bg-teal-500",chronos_job:"bg-orange-400 dark:bg-orange-500",task_created:"bg-gray-300 dark:bg-matrix-secondary/50",task_completed:"bg-green-400 dark:bg-matrix-highlight/70"},X={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.04}}},x={hidden:{opacity:0,y:12},show:{opacity:1,y:0}},le=()=>{const{data:a,isLoading:i,mutate:l}=D();if(i)return e.jsxs("div",{className:"flex items-center justify-center h-64 gap-3 text-gray-400 dark:text-matrix-secondary",children:[e.jsx(_,{size:20,className:"animate-spin"}),e.jsx("span",{className:"text-sm font-mono",children:"Loading audit data…"})]});if(!a)return e.jsxs("div",{className:"flex flex-col items-center justify-center h-64 gap-2 text-gray-400 dark:text-matrix-secondary",children:[e.jsx(R,{size:24}),e.jsx("span",{className:"text-sm",children:"Failed to load audit data."})]});const{sessions:s,totals:r,byAgent:c,byModel:y,topTools:g,recentSessions:f,dailyActivity:p}=a,C=[["llm_call",r.llmCallCount],["tool_call",r.toolCallCount],["mcp_tool",r.mcpToolCount],["memory_recovery",r.memoryRecoveryCount],["memory_persist",r.memoryPersistCount],["telephonist",r.telephonistCount],["skill_loaded",r.skillCount],["chronos_job",r.chronosJobCount],["task_created",r.taskCreatedCount],["task_completed",r.taskCompletedCount]].filter(([,t])=>t>0).sort((t,d)=>d[1]-t[1]),$=Math.max(...C.map(([,t])=>t),1);return e.jsxs(n.div,{variants:X,initial:"hidden",animate:"show",className:"space-y-6",children:[e.jsxs(n.div,{variants:x,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-blue-500/10 dark:bg-blue-500/20 border border-blue-200 dark:border-blue-800/40 flex items-center justify-center",children:e.jsx(L,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-matrix-highlight",children:"Global Audit"}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-matrix-secondary/60 mt-0.5",children:[s.withAudit," sessions with audit data · ",r.totalEventCount.toLocaleString()," events total"]})]})]}),e.jsxs("button",{onClick:()=>l(),className:"flex items-center gap-2 px-3 py-2 rounded-lg border border-gray-200 dark:border-matrix-primary text-sm text-gray-500 dark:text-matrix-secondary hover:bg-gray-50 dark:hover:bg-zinc-900 transition-colors",children:[e.jsx(_,{size:14})," Refresh"]})]}),e.jsxs(n.div,{variants:x,className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:[e.jsx(h,{icon:e.jsx(O,{size:16}),label:"Total Cost",value:u(r.estimatedCostUsd),color:"green"}),e.jsx(h,{icon:e.jsx(v,{size:16}),label:"LLM Calls",value:r.llmCallCount.toLocaleString(),color:"blue"}),e.jsx(h,{icon:e.jsx(j,{size:16}),label:"Tool Calls",value:(r.toolCallCount+r.mcpToolCount).toLocaleString(),sub:e.jsxs(e.Fragment,{children:[e.jsxs("span",{children:[r.toolCallCount," native"]}),e.jsx("br",{}),e.jsxs("span",{children:[r.mcpToolCount," MCP"]})]}),color:"amber"}),e.jsx(h,{icon:e.jsx(N,{size:16}),label:"Memory Hits",value:r.memoryRecoveryCount.toLocaleString(),color:"teal"}),e.jsx(h,{icon:e.jsx(z,{size:16}),label:"Total Tokens",value:m(r.totalInputTokens+r.totalOutputTokens),sub:e.jsxs(e.Fragment,{children:[e.jsxs("span",{children:["↑",m(r.totalInputTokens)," in"]}),e.jsx("br",{}),e.jsxs("span",{children:["↓",m(r.totalOutputTokens)," out"]})]}),color:"purple"}),e.jsx(h,{icon:e.jsx(w,{size:16}),label:"Total Time",value:k(r.totalDurationMs),color:"rose"})]}),e.jsxs(n.div,{variants:x,className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs(o,{title:"Sessions",icon:e.jsx(U,{size:14}),children:[e.jsx("div",{className:"grid grid-cols-2 gap-3 mb-4",children:[{label:"Total",value:s.total,cls:"text-gray-700 dark:text-matrix-secondary"},{label:"With Audit",value:s.withAudit,cls:"text-blue-600 dark:text-blue-400"},{label:"Active",value:s.active,cls:"text-green-600 dark:text-matrix-highlight"},{label:"Paused",value:s.paused,cls:"text-gray-500 dark:text-matrix-secondary"},{label:"Archived",value:s.archived,cls:"text-amber-600 dark:text-amber-400"},{label:"Deleted",value:s.deleted,cls:"text-red-500 dark:text-red-400"}].map(({label:t,value:d,cls:b})=>e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-widest text-gray-400 dark:text-matrix-secondary/50",children:t}),e.jsx("span",{className:`text-2xl font-bold font-mono ${b}`,children:d})]},t))}),s.total>0&&e.jsxs("div",{className:"h-2 rounded-full overflow-hidden flex gap-px",children:[s.active>0&&e.jsx("div",{className:"bg-green-400 dark:bg-matrix-highlight/70",style:{flex:s.active}}),s.paused>0&&e.jsx("div",{className:"bg-gray-300 dark:bg-matrix-primary/50",style:{flex:s.paused}}),s.archived>0&&e.jsx("div",{className:"bg-amber-400 dark:bg-amber-500/70",style:{flex:s.archived}}),s.deleted>0&&e.jsx("div",{className:"bg-red-400 dark:bg-red-500/70",style:{flex:s.deleted}})]})]}),e.jsxs(o,{title:"Activity — Last 30 Days",icon:e.jsx(W,{size:14}),children:[e.jsx(G,{data:p}),p.length>0&&e.jsxs("div",{className:"flex gap-4 mt-2 text-[11px] text-gray-400 dark:text-matrix-secondary/50 font-mono",children:[e.jsx("span",{children:p[0]?.date}),e.jsx("span",{className:"flex-1 text-right",children:p[p.length-1]?.date})]})]})]}),e.jsx(n.div,{variants:x,children:e.jsx(o,{title:"Events by Type",icon:e.jsx(z,{size:14}),children:e.jsx("div",{className:"space-y-2",children:C.map(([t,d])=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`flex-shrink-0 w-5 flex justify-center ${Q[t]??"text-gray-400"}`,children:K[t]}),e.jsx("span",{className:"text-xs font-mono text-gray-600 dark:text-matrix-secondary w-32 flex-shrink-0",children:t}),e.jsx("div",{className:"flex-1 h-2 bg-gray-100 dark:bg-zinc-800 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all ${q[t]??"bg-gray-400"}`,style:{width:T(d,$)}})}),e.jsx("span",{className:"text-xs font-mono text-gray-500 dark:text-matrix-secondary w-16 text-right",children:d.toLocaleString()}),e.jsx("span",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/50 w-10 text-right",children:T(d,r.totalEventCount)})]},t))})})}),e.jsxs(n.div,{variants:x,className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsx(o,{title:"By Agent",icon:e.jsx(S,{size:14}),children:c.length===0?e.jsx("p",{className:"text-sm text-gray-400 dark:text-matrix-secondary/50",children:"No agent data."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs font-mono",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-[10px] uppercase tracking-wider text-gray-400 dark:text-matrix-secondary/50 border-b border-gray-100 dark:border-matrix-primary/30",children:[e.jsx("th",{className:"pb-2 text-left",children:"Agent"}),e.jsx("th",{className:"pb-2 text-right",children:"LLM"}),e.jsx("th",{className:"pb-2 text-right",children:"Tools"}),e.jsx("th",{className:"pb-2 text-right",children:"Tokens"}),e.jsx("th",{className:"pb-2 text-right",children:"Time"}),e.jsx("th",{className:"pb-2 text-right",children:"Cost"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50 dark:divide-matrix-primary/20",children:c.map(t=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-zinc-900/50",children:[e.jsx("td",{className:"py-1.5",children:e.jsx(M,{agent:t.agent})}),e.jsx("td",{className:"py-1.5 text-right text-gray-600 dark:text-matrix-secondary",children:t.llmCalls.toLocaleString()}),e.jsx("td",{className:"py-1.5 text-right text-gray-600 dark:text-matrix-secondary",children:t.toolCalls.toLocaleString()}),e.jsxs("td",{className:"py-1.5 text-right text-gray-500 dark:text-matrix-secondary/70",children:["↑",m(t.inputTokens)," ↓",m(t.outputTokens)]}),e.jsx("td",{className:"py-1.5 text-right text-gray-500 dark:text-matrix-secondary/70",children:k(t.totalDurationMs)}),e.jsx("td",{className:"py-1.5 text-right font-semibold text-gray-700 dark:text-matrix-secondary",children:u(t.estimatedCostUsd)})]},t.agent))})]})})}),e.jsx(o,{title:"By Model",icon:e.jsx(v,{size:14}),children:y.length===0?e.jsx("p",{className:"text-sm text-gray-400 dark:text-matrix-secondary/50",children:"No model data."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs font-mono",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-[10px] uppercase tracking-wider text-gray-400 dark:text-matrix-secondary/50 border-b border-gray-100 dark:border-matrix-primary/30",children:[e.jsx("th",{className:"pb-2 text-left",children:"Model"}),e.jsx("th",{className:"pb-2 text-right",children:"Calls"}),e.jsx("th",{className:"pb-2 text-right",children:"In"}),e.jsx("th",{className:"pb-2 text-right",children:"Out"}),e.jsx("th",{className:"pb-2 text-right",children:"Cost"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50 dark:divide-matrix-primary/20",children:y.map(t=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-zinc-900/50",children:[e.jsxs("td",{className:"py-1.5",children:[e.jsx("div",{className:"text-gray-700 dark:text-matrix-secondary break-all leading-tight",children:t.model}),e.jsx("div",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/40",children:t.provider})]}),e.jsx("td",{className:"py-1.5 text-right text-gray-600 dark:text-matrix-secondary",children:t.calls.toLocaleString()}),e.jsx("td",{className:"py-1.5 text-right text-gray-500 dark:text-matrix-secondary/70",children:m(t.inputTokens)}),e.jsx("td",{className:"py-1.5 text-right text-gray-500 dark:text-matrix-secondary/70",children:m(t.outputTokens)}),e.jsx("td",{className:"py-1.5 text-right font-semibold text-gray-700 dark:text-matrix-secondary",children:u(t.estimatedCostUsd)})]},`${t.provider}/${t.model}`))})]})})})]}),g.length>0&&e.jsx(n.div,{variants:x,children:e.jsx(o,{title:"Top Tools",icon:e.jsx(j,{size:14}),children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs font-mono",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-[10px] uppercase tracking-wider text-gray-400 dark:text-matrix-secondary/50 border-b border-gray-100 dark:border-matrix-primary/30",children:[e.jsx("th",{className:"pb-2 text-left",children:"Tool"}),e.jsx("th",{className:"pb-2 text-left",children:"Agent"}),e.jsx("th",{className:"pb-2 text-right",children:"Calls"}),e.jsx("th",{className:"pb-2 text-right",children:"Errors"}),e.jsx("th",{className:"pb-2 text-right",children:"Error rate"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50 dark:divide-matrix-primary/20",children:g.map((t,d)=>{const b=t.count?t.errorCount/t.count:0;return e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-zinc-900/50",children:[e.jsx("td",{className:"py-1.5",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Z,{eventType:t.event_type}),e.jsx("span",{className:"text-gray-700 dark:text-matrix-secondary break-all",children:t.tool_name})]})}),e.jsx("td",{className:"py-1.5",children:t.agent?e.jsx(M,{agent:t.agent}):e.jsx("span",{className:"text-gray-400",children:"—"})}),e.jsx("td",{className:"py-1.5 text-right text-gray-600 dark:text-matrix-secondary",children:t.count.toLocaleString()}),e.jsx("td",{className:"py-1.5 text-right",children:e.jsx("span",{className:t.errorCount>0?"text-red-500 dark:text-red-400":"text-gray-400 dark:text-matrix-secondary/50",children:t.errorCount})}),e.jsx("td",{className:"py-1.5 text-right",children:e.jsx("span",{className:b>.1?"text-red-500 dark:text-red-400":b>0?"text-amber-500 dark:text-amber-400":"text-gray-400 dark:text-matrix-secondary/50",children:t.count>0?`${Math.round(b*100)}%`:"—"})})]},d)})})]})})})}),e.jsx(n.div,{variants:x,children:e.jsx(o,{title:"Recent Sessions with Audit",icon:e.jsx(L,{size:14}),children:f.length===0?e.jsx("p",{className:"text-sm text-gray-400 dark:text-matrix-secondary/50",children:"No sessions with audit data yet."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs font-mono",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-[10px] uppercase tracking-wider text-gray-400 dark:text-matrix-secondary/50 border-b border-gray-100 dark:border-matrix-primary/30",children:[e.jsx("th",{className:"pb-2 text-left",children:"Session"}),e.jsx("th",{className:"pb-2 text-left",children:"Status"}),e.jsx("th",{className:"pb-2 text-right",children:"Events"}),e.jsx("th",{className:"pb-2 text-right",children:"LLM"}),e.jsx("th",{className:"pb-2 text-right",children:"Duration"}),e.jsx("th",{className:"pb-2 text-right",children:"Cost"}),e.jsx("th",{className:"pb-2"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50 dark:divide-matrix-primary/20",children:f.map(t=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-zinc-900/50",children:[e.jsxs("td",{className:"py-2",children:[e.jsx("div",{className:"text-gray-700 dark:text-matrix-secondary truncate max-w-[160px]",title:t.title??t.session_id,children:t.title??e.jsxs("span",{className:"text-gray-400 dark:text-matrix-secondary/40 font-mono text-[10px]",children:[t.session_id.slice(0,12),"…"]})}),t.started_at&&e.jsx("div",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/40",children:H(t.started_at)})]}),e.jsx("td",{className:"py-2",children:e.jsx(J,{status:t.status})}),e.jsx("td",{className:"py-2 text-right text-gray-600 dark:text-matrix-secondary",children:t.event_count.toLocaleString()}),e.jsx("td",{className:"py-2 text-right text-gray-500 dark:text-matrix-secondary/70",children:t.llmCallCount.toLocaleString()}),e.jsx("td",{className:"py-2 text-right text-gray-500 dark:text-matrix-secondary/70",children:k(t.totalDurationMs)}),e.jsx("td",{className:"py-2 text-right font-semibold text-gray-700 dark:text-matrix-secondary",children:u(t.estimatedCostUsd)}),e.jsx("td",{className:"py-2 text-right",children:e.jsx(E,{to:`/sessions/${t.session_id}/audit`,className:"inline-flex items-center gap-1 px-2 py-1 rounded border border-gray-200 dark:border-matrix-primary text-gray-400 dark:text-matrix-secondary hover:text-blue-600 dark:hover:text-matrix-highlight hover:border-blue-300 dark:hover:border-matrix-highlight/50 transition-colors",title:"View session audit",children:e.jsx(I,{size:11})})})]},t.session_id))})]})})})}),r.telephonistCount>0&&e.jsx(n.div,{variants:x,children:e.jsx(o,{title:"Audio / Telephonist",icon:e.jsx(A,{size:14}),children:e.jsxs("div",{className:"flex flex-wrap gap-8",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-widest text-gray-400 dark:text-matrix-secondary/50 mb-0.5",children:"Calls"}),e.jsx("p",{className:"text-2xl font-bold font-mono text-rose-500 dark:text-rose-400",children:r.telephonistCount.toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-widest text-gray-400 dark:text-matrix-secondary/50 mb-0.5",children:"Total Audio"}),e.jsx("p",{className:"text-2xl font-bold font-mono text-rose-500 dark:text-rose-400",children:r.totalAudioSeconds<60?`${r.totalAudioSeconds.toFixed(1)}s`:`${(r.totalAudioSeconds/60).toFixed(1)}m`})]})]})})})]})};export{le as AuditDashboard};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,m}from"./vendor-motion-C3CZ8ZlO.js";import{r as o}from"./vendor-react-DikRIOlj.js";import{u as M}from"./vendor-utils-D4NnWbOU.js";import{h as u,D as j,d as z,e as v,j as N}from"./index-Bta9YXEm.js";import{i as F,a6 as E,w as I,z as R}from"./vendor-icons-NHF9HNeN.js";const g={list:()=>u.get("/model-pricing"),upsert:a=>u.post("/model-pricing",a),update:(a,s,p)=>u.put(`/model-pricing/${encodeURIComponent(a)}/${encodeURIComponent(s)}`,p),delete:(a,s)=>u.delete(`/model-pricing/${encodeURIComponent(a)}/${encodeURIComponent(s)}`)},T={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.05}}},_={hidden:{opacity:0,y:10},show:{opacity:1,y:0}},A=["anthropic","openai","google","openrouter","ollama","other"],w=()=>({provider:"",model:"",input_price_per_1m:0,output_price_per_1m:0,audio_cost_per_second:null}),V=()=>{const{data:a=[],mutate:s}=M("/api/model-pricing",()=>g.list()),[p,n]=o.useState(!1),[l,b]=o.useState(null),[t,i]=o.useState(w()),[d,c]=o.useState(null),[h,y]=o.useState(null),[k,f]=o.useState(!1),x=(r,D)=>{y({type:r,message:D}),setTimeout(()=>y(null),3e3)},C=()=>{b(null),i(w()),n(!0)},$=r=>{b(r),i({...r}),n(!0)},S=async()=>{if(!(!t.provider.trim()||!t.model.trim())){f(!0);try{await g.upsert(t),await s(),n(!1),x("success",l?"Pricing updated.":"Pricing created.")}catch{x("error","Failed to save pricing entry.")}finally{f(!1)}}},P=async()=>{if(d)try{await g.delete(d.provider,d.model),await s(),c(null),x("success","Pricing entry deleted.")}catch{x("error","Failed to delete pricing entry.")}};return e.jsxs(m.div,{variants:T,initial:"hidden",animate:"show",className:"space-y-6",children:[e.jsxs(m.div,{variants:_,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(F,{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:C,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(E,{className:"w-4 h-4"})," Add Pricing"]})]}),h&&e.jsx(m.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(m.div,{variants:_,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","Input ($/1M tokens)","Output ($/1M tokens)","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.jsxs("td",{className:"px-4 py-3 text-azure-text-primary dark:text-matrix-text",children:["$",r.input_price_per_1m.toFixed(4)]}),e.jsxs("td",{className:"px-4 py-3 text-azure-text-primary dark:text-matrix-text",children:["$",r.output_price_per_1m.toFixed(4)]}),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:()=>$(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(I,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>c(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(R,{className:"w-4 h-4"})})]})})]},`${r.provider}/${r.model}`))})]})}),e.jsx(j,{open:p,onOpenChange:n,children:e.jsxs(z,{children:[e.jsx(v,{children:e.jsx(N,{children:l?"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"}),l?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..."}),A.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"}),l?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:S,disabled:k||!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:k?"Saving...":"Save"})]})]})]})}),e.jsx(j,{open:!!d,onOpenChange:r=>!r&&c(null),children:e.jsxs(z,{children:[e.jsx(v,{children:e.jsx(N,{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:[d?.provider,"/",d?.model]}),"? This cannot be undone."]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>c(null),className:"px-4 py-2 rounded-lg border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary text-sm hover:bg-azure-surface dark:hover:bg-zinc-800 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:P,className:"px-4 py-2 rounded-lg bg-red-600 text-white text-sm font-medium hover:bg-red-700 transition-colors",children:"Delete"})]})]})]})})]})};export{V as ModelPricing};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as u,f as F,c as I}from"./vendor-react-DikRIOlj.js";import{u as P}from"./audit-Dc3YW0-4.js";import{u as J}from"./agents-CgqJea9n.js";import{E as N,q as D,G as E,K as A,m as $,g as R,J as V,ai as W,as as T,I as B,o as M,a6 as G,w as K,y as Z,aj as q,i as H,at as X,au as Q,F as Y,a8 as ee,av as te,r as re,a2 as se}from"./vendor-icons-NHF9HNeN.js";import"./vendor-utils-D4NnWbOU.js";import"./index-Bta9YXEm.js";const ae={llm_call:e.jsx(T,{size:16}),tool_call:e.jsx(N,{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(W,{size:16}),task_completed:e.jsx(E,{size:16}),skill_loaded:e.jsx(V,{size:16}),chronos_job:e.jsx(R,{size:16}),memory_recovery:e.jsx($,{size:16}),memory_persist:e.jsx($,{size:16}),telephonist:e.jsx(A,{size:16})},ne={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"},oe={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 ie(t){return t==null?"—":t<1e3?`${t}ms`:`${(t/1e3).toFixed(1)}s`}function le(t){return t==null||t===0?"—":t<1e-4?"<$0.0001":`$${t.toFixed(4)}`}function de(t,r){if(t==null&&r==null)return"";const d=t??0,i=r??0;return`↑${d.toLocaleString()} ↓${i.toLocaleString()}`}function L(t){return typeof t=="string"?t:JSON.stringify(t,null,2)}function xe({parsedMeta:t,eventType:r}){const d=r==="tool_call"||r==="mcp_tool",{args:i,result:n,...c}=t;if(r==="memory_persist"){const m=Array.isArray(t.inclusions)?t.inclusions:[],x=Array.isArray(t.edits)?t.edits:[],s=Array.isArray(t.deletions)?t.deletions:[];return m.length===0&&x.length===0&&s.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:[m.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-green-500 dark:text-green-400"})," new memories (",m.length,")"]}),e.jsx("div",{className:"space-y-1",children:m.map((a,l)=>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]})]},l))})]}),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(K,{size:10,className:"text-amber-500 dark:text-amber-400"})," edited memories (",x.length,")"]}),e.jsx("div",{className:"space-y-1",children:x.map((a,l)=>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]})]},l))})]}),s.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-red-500 dark:text-red-400"})," archived memories (",s.length,")"]}),e.jsx("div",{className:"space-y-1",children:s.map((a,l)=>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})]},l))})]})]})}return d&&(i!==void 0||n!==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:L(i)})]}),n!==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:L(n)})]}),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 S=({event:t})=>{const[r,d]=u.useState(!1),{getByKey:i}=J(),n=ae[t.event_type]??e.jsx(N,{size:14}),c=ne[t.event_type]??"text-gray-500",m=oe[t.event_type]??"border-gray-300 dark:border-matrix-primary/40",x=t.agent?i(t.agent):null,s=x?.badgeClass??null,a=x?`${t.agent?.toUpperCase()} ${x.emoji}`:t.agent?.toUpperCase()||null,l=(()=>{try{return t.metadata?typeof t.metadata=="object"?t.metadata:JSON.parse(t.metadata):null}catch{return null}})(),o=l!==null&&Object.keys(l).length>0,h=t.event_type==="memory_recovery"?`${l?.memories_count??0} memories retrieved`:t.event_type==="memory_persist"?(()=>{const g=l?.inclusions_count??0,p=l?.edits_count??0,k=l?.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=l?.audio_duration_seconds,p=l?.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,U=t.event_type==="telephonist",v=l?.audio_duration_seconds,b=U?v!=null?`🎵 ${v}s audio`:"":de(t.input_tokens,t.output_tokens),f=le(t.estimated_cost_usd),_=ie(t.duration_ms),w=t.status==="error"?e.jsx(D,{size:14,className:"text-red-500 flex-shrink-0"}):t.status==="success"?e.jsx(E,{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 ${o?"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:r?e.jsx(B,{size:12}):e.jsx(M,{size:12})}),z=()=>{o&&d(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 ${o?"cursor-pointer":""}`,onClick:z,children:[C,e.jsx("span",{className:`flex-shrink-0 ${c}`,children:n}),s&&e.jsx("span",{className:`flex-shrink-0 text-xs font-semibold px-1.5 py-0.5 rounded ${s}`,children:a}),e.jsx("span",{className:"flex-1 text-sm text-gray-700 dark:text-matrix-secondary font-mono break-all leading-snug",children:h}),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:[b&&e.jsx("span",{children:b}),e.jsx("span",{children:_}),f!=="—"&&e.jsx("span",{className:"text-gray-600 dark:text-matrix-secondary",children:f})]})]}),e.jsxs("div",{className:`hidden md:flex items-center gap-3 ${o?"cursor-pointer":""}`,onClick:z,children:[C,e.jsx("span",{className:`flex-shrink-0 ${c}`,children:n}),s&&e.jsx("span",{className:`flex-shrink-0 text-xs font-semibold px-1.5 py-0.5 rounded ${s}`,children:a}),e.jsx("span",{className:"flex-1 text-sm truncate text-gray-700 dark:text-matrix-secondary font-mono",children:h}),b&&e.jsx("span",{className:"text-xs text-gray-400 dark:text-matrix-secondary/60 font-mono whitespace-nowrap",children:b}),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:f})]}),r&&o&&l&&e.jsx("div",{className:`mt-1.5 ml-5 pl-3 border-l-2 ${m}`,children:e.jsx(xe,{parsedMeta:l,eventType:t.event_type})})]})},ce=({events:t,page:r,pageSize:d,totalCount:i,onPageChange:n})=>{const c=Math.ceil(i/d),m=r*d+1,x=Math.min(r*d+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 s=[],a=new Map;for(const o of t)if(o.task_id){const h=a.get(o.task_id)??[];h.push(o),a.set(o.task_id,h)}const l=new Set;for(const o of t)o.task_id?l.has(o.task_id)||(l.add(o.task_id),s.push({taskId:o.task_id,events:a.get(o.task_id)})):s.push({taskId:null,events:[o]});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:s.map(o=>o.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: ",o.taskId.slice(0,8),"…"]}),e.jsx("div",{className:"pl-4",children:o.events.map(h=>e.jsx(S,{event:h},h.id))})]},o.taskId):e.jsx(S,{event:o.events[0]},o.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:[m,"–",x," of ",i," events"]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>n(r-1),disabled:r===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(q,{size:16})}),e.jsxs("span",{className:"text-xs self-center text-gray-500 dark:text-matrix-secondary font-mono px-2",children:[r+1," / ",c]}),e.jsx("button",{onClick:()=>n(r+1),disabled:r>=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(M,{size:16})})]})]})]})};function j(t){return t===0?"$0.00":t<1e-4?"<$0.0001":`$${t.toFixed(4)}`}function me(t){return t<1e3?`${t}ms`:t<6e4?`${(t/1e3).toFixed(1)}s`:`${(t/6e4).toFixed(1)}m`}const he=({summary:t})=>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(H,{size:14})," Total Cost"]}),e.jsx("div",{className:"text-2xl font-bold text-gray-900 dark:text-matrix-highlight font-mono",children:j(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(T,{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(N,{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(R,{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(A,{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:j(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:j(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,r){const d=new Blob([JSON.stringify(r,null,2)],{type:"application/json"}),i=URL.createObjectURL(d),n=document.createElement("a");n.href=i,n.download=`audit-${t.slice(0,8)}.json`,n.click(),URL.revokeObjectURL(i)}function ge(t,r){const d=["id","created_at","event_type","agent","tool_name","provider","model","input_tokens","output_tokens","duration_ms","status","estimated_cost_usd"],i=r.events.map(s=>[s.id,new Date(s.created_at).toISOString(),s.event_type,s.agent??"",s.tool_name??"",s.provider??"",s.model??"",s.input_tokens??"",s.output_tokens??"",s.duration_ms??"",s.status??"",s.estimated_cost_usd??""].map(a=>`"${String(a).replace(/"/g,'""')}"`).join(",")),n=[d.join(","),...i].join(`
|
|
2
|
-
`),c=new Blob([n],{type:"text/csv"}),m=URL.createObjectURL(c),x=document.createElement("a");x.href=m,x.download=`audit-${t.slice(0,8)}.csv`,x.click(),URL.revokeObjectURL(m)}const ye=({sessionId:t,data:r})=>{const[d,i]=u.useState(!1);return r?e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>i(!d),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(X,{size:14}),"Export",e.jsx(B,{size:12})]}),d&&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,r),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(Q,{size:14,className:"text-blue-500"}),"Export JSON"]}),e.jsxs("button",{onClick:()=>{ge(t,r),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-green-500"}),"Export CSV"]})]})]})]}):null},O=100,_e=()=>{const{id:t}=F(),r=I(),[d,i]=u.useState(0),{data:n,error:c,isLoading:m}=P(t??null,d,O),x=u.useRef(null),[s,a]=u.useState(()=>typeof window<"u"?window.innerWidth>=768:!0);return u.useEffect(()=>{x.current&&(x.current.scrollTop=x.current.scrollHeight)},[n]),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:()=>r(-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(ee,{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(l=>!l),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(te,{size:18})}),e.jsx(ye,{sessionId:t??"",data:n})]})]}),e.jsxs("div",{className:"flex-1 flex overflow-hidden relative",children:[s&&e.jsx("div",{className:"fixed inset-0 bg-black/40 z-20 md:hidden",onClick:()=>a(!1)}),e.jsxs("div",{ref:x,className:"flex-[6] overflow-y-auto p-6 custom-scrollbar",children:[m&&e.jsxs("div",{className:"flex items-center justify-center h-40 gap-2 text-gray-400 dark:text-matrix-secondary",children:[e.jsx(re,{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(se,{size:16}),"Failed to load audit events: ",c.message]}),n&&e.jsx(ce,{events:n.events,page:d,pageSize:O,totalCount:n.summary.llmCallCount+n.summary.toolCallCount,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
|
-
${s?"translate-x-0":"translate-x-full"}
|
|
9
|
-
`,children:n?e.jsx(he,{summary:n.summary}):!m&&e.jsx("div",{className:"text-sm text-gray-400 dark:text-matrix-secondary/50 text-center mt-10",children:"No summary available."})})]})]})};export{_e as SessionAudit};
|