morpheus-cli 0.9.10 → 0.9.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/http/api.js +1 -0
- package/dist/http/routers/link.js +25 -4
- package/dist/runtime/link-worker.js +49 -0
- package/dist/runtime/memory/sqlite.js +33 -5
- package/dist/runtime/oracle.js +7 -0
- package/dist/runtime/webhooks/dispatcher.js +24 -1
- package/dist/ui/assets/{AuditDashboard-ZPJ5Pfwi.js → AuditDashboard-CM1YN1uk.js} +1 -1
- package/dist/ui/assets/Chat-D4y-g6Tw.js +41 -0
- package/dist/ui/assets/{Chronos-buCS0uuh.js → Chronos-D1yAb4M5.js} +1 -1
- package/dist/ui/assets/{ConfirmationModal-Bud3Ur7D.js → ConfirmationModal-DxUHZgTy.js} +1 -1
- package/dist/ui/assets/{Dashboard-CR6pBg6o.js → Dashboard-BzxmcHaS.js} +1 -1
- package/dist/ui/assets/{DeleteConfirmationModal-Cz1jfXgq.js → DeleteConfirmationModal-CqNXT_YQ.js} +1 -1
- package/dist/ui/assets/Documents-DLFZdmim.js +7 -0
- package/dist/ui/assets/{Logs-BgDEdckr.js → Logs-B1Bpy9dB.js} +1 -1
- package/dist/ui/assets/{MCPManager-yupmREOG.js → MCPManager-BbUDMh5Q.js} +1 -1
- package/dist/ui/assets/{ModelPricing-CbKHyj9P.js → ModelPricing-DCl-2_eJ.js} +1 -1
- package/dist/ui/assets/{Notifications-DpabYsn5.js → Notifications-8Cqj-mNp.js} +1 -1
- package/dist/ui/assets/{SatiMemories-D75MAyPU.js → SatiMemories-CdHUe6di.js} +1 -1
- package/dist/ui/assets/{SessionAudit-B3N9C1NR.js → SessionAudit-CtVHK_IH.js} +1 -1
- package/dist/ui/assets/{Settings-B1qZ-teD.js → Settings-Clge45Z0.js} +1 -1
- package/dist/ui/assets/{Skills-BmqC0xkq.js → Skills-0k7A2T5_.js} +1 -1
- package/dist/ui/assets/{Smiths-DdAcvxg6.js → Smiths-gjgBMN1F.js} +1 -1
- package/dist/ui/assets/{Tasks-D7SrOMOn.js → Tasks-AQ3MrrMp.js} +1 -1
- package/dist/ui/assets/{TrinityDatabases-cyhanIXu.js → TrinityDatabases-CGna6IMX.js} +1 -1
- package/dist/ui/assets/{UsageStats-DOgOQ4YN.js → UsageStats-B7EzZlZe.js} +1 -1
- package/dist/ui/assets/{WebhookManager-D2TdZ5kD.js → WebhookManager-Bb7KiucS.js} +1 -1
- package/dist/ui/assets/{audit-CZVCVFw_.js → audit-CJ2Ms81U.js} +1 -1
- package/dist/ui/assets/{chronos-DWSd5JMm.js → chronos-Bm68OSy4.js} +1 -1
- package/dist/ui/assets/{config-C2GB18ML.js → config-C88yQ_CP.js} +1 -1
- package/dist/ui/assets/{index-BiMscUrn.js → index-BxN2w9sY.js} +6 -6
- package/dist/ui/assets/index-C3Ff736M.css +1 -0
- package/dist/ui/assets/{mcp-JmpcV6nl.js → mcp-BE_OVkBe.js} +1 -1
- package/dist/ui/assets/{skills-D2stQj7i.js → skills-Dt0qU4gH.js} +1 -1
- package/dist/ui/assets/{stats-cDmpngPQ.js → stats-Bmdps1LR.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/dist/ui/sw.js +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/Chat-BAivCJ5N.js +0 -41
- package/dist/ui/assets/Documents-CYW79d8T.js +0 -7
- package/dist/ui/assets/index-U7hzqcK_.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as n}from"./vendor-react-DikRIOlj.js";import{a as L,b as I,c as y,u as O}from"./chronos-DWSd5JMm.js";import{D as R}from"./DeleteConfirmationModal-Cz1jfXgq.js";import{P as J}from"./Pagination-BHZKk42X.js";import{ae as M,af as U,ag as B,ah as H,ai as W,z as $,g as T,X as q,a6 as F}from"./vendor-icons-NHF9HNeN.js";import{m as z}from"./vendor-utils-D4NnWbOU.js";import{T as C,S}from"./SelectInput-KVLsnfra.js";import"./index-BiMscUrn.js";const Y={running:"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",success:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",failed:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400",timeout:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"};function X({jobId:s}){const{data:i,isLoading:m}=L(s,50);return m?e.jsx("div",{className:"p-4 dark:bg-zinc-900 rounded text-sm dark:text-matrix-secondary animate-pulse",children:"Loading history…"}):!i||i.length===0?e.jsx("div",{className:"p-4 dark:bg-zinc-900 rounded text-sm dark:text-matrix-secondary italic",children:"No executions yet."}):e.jsx("div",{className:"rounded border border-azure-border dark:border-matrix-primary dark:bg-zinc-900 overflow-hidden",children:e.jsxs("table",{className:"w-full text-xs font-mono",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-azure-border dark:border-matrix-primary",children:[e.jsx("th",{className:"text-left px-3 py-2 text-azure-text-muted dark:text-matrix-tertiary",children:"Triggered At"}),e.jsx("th",{className:"text-left px-3 py-2 text-azure-text-muted dark:text-matrix-tertiary",children:"Completed At"}),e.jsx("th",{className:"text-left px-3 py-2 text-azure-text-muted dark:text-matrix-tertiary",children:"Status"}),e.jsx("th",{className:"text-left px-3 py-2 text-azure-text-muted dark:text-matrix-tertiary",children:"Error"})]})}),e.jsx("tbody",{children:i.map(r=>e.jsxs("tr",{className:"border-b border-azure-border dark:border-matrix-primary/30 last:border-0",children:[e.jsx("td",{className:"px-3 py-2 dark:text-matrix-secondary",children:new Date(r.triggered_at).toLocaleString()}),e.jsx("td",{className:"px-3 py-2 dark:text-matrix-secondary",children:r.completed_at?new Date(r.completed_at).toLocaleString():"—"}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-bold uppercase ${Y[r.status]}`,children:r.status})}),e.jsx("td",{className:"px-3 py-2 dark:text-red-400 max-w-xs truncate",children:r.error??"—"})]},r.id))})]})})}function Z({enabled:s}){return e.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-bold uppercase ${s?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":"bg-gray-100 text-gray-500 dark:bg-zinc-800 dark:text-matrix-tertiary"}`,children:s?"Enabled":"Disabled"})}function _(s,i){return s.length>i?`${s.slice(0,i)}…`:s}function E(s){return s?new Date(s).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function K({onEdit:s}){const[i,m]=n.useState(1),[r,u]=n.useState(20),{data:o,isLoading:c}=I({page:i,per_page:r}),d=o?.data??[],[h,l]=n.useState(null),[x,g]=n.useState(null),[p,b]=n.useState(null),f=t=>{u(t),m(1)},k=async t=>{g(t.id);try{t.enabled?await y.disableJob(t.id):await y.enableJob(t.id),await z(N=>typeof N=="string"&&N.startsWith("/chronos"))}finally{g(null)}},v=async()=>{if(p){g(p.id);try{await y.deleteJob(p.id),await z(t=>typeof t=="string"&&t.startsWith("/chronos"))}finally{g(null),b(null)}}};return c?e.jsx("div",{className:"rounded border border-azure-border dark:border-matrix-primary p-8 text-center dark:text-matrix-secondary animate-pulse",children:"Loading jobs…"}):!c&&d.length===0&&i===1?e.jsxs("div",{className:"rounded border border-azure-border dark:border-matrix-primary p-8 text-center dark:text-matrix-secondary",children:["No Chronos jobs yet. Click ",e.jsx("strong",{className:"dark:text-matrix-highlight",children:"New Job"})," to get started."]}):e.jsxs("div",{className:"rounded border border-azure-border dark:border-matrix-primary overflow-hidden",children:[e.jsxs("table",{className:"w-full text-sm font-mono",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-zinc-900",children:[e.jsx("th",{className:"text-left px-4 py-3 text-azure-text-muted dark:text-matrix-tertiary font-medium",children:"Prompt"}),e.jsx("th",{className:"text-left px-4 py-3 text-azure-text-muted dark:text-matrix-tertiary font-medium hidden md:table-cell",children:"Schedule"}),e.jsx("th",{className:"text-left px-4 py-3 text-azure-text-muted dark:text-matrix-tertiary font-medium hidden lg:table-cell",children:"Next Run"}),e.jsx("th",{className:"text-left px-4 py-3 text-azure-text-muted dark:text-matrix-tertiary font-medium hidden lg:table-cell",children:"Last Run"}),e.jsx("th",{className:"text-left px-4 py-3 text-azure-text-muted dark:text-matrix-tertiary font-medium",children:"Status"}),e.jsx("th",{className:"px-4 py-3 text-azure-text-muted dark:text-matrix-tertiary font-medium text-right",children:"Actions"})]})}),e.jsx("tbody",{children:d.map(t=>e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"border-b border-azure-border dark:border-matrix-primary/30 last:border-0 hover:bg-azure-hover dark:hover:bg-matrix-primary/10 transition-colors",children:[e.jsxs("td",{className:"px-4 py-3 dark:text-matrix-secondary max-w-xs",children:[e.jsx("span",{title:t.prompt,children:_(t.prompt,50)}),e.jsx("div",{className:"text-xs text-azure-text-muted dark:text-matrix-tertiary",children:t.created_by})]}),e.jsxs("td",{className:"px-4 py-3 dark:text-matrix-secondary hidden md:table-cell text-xs",children:[e.jsx("div",{className:"capitalize",children:t.schedule_type}),e.jsx("div",{className:"text-azure-text-muted dark:text-matrix-tertiary truncate max-w-[140px]",title:t.schedule_expression,children:t.schedule_expression})]}),e.jsx("td",{className:"px-4 py-3 dark:text-matrix-secondary hidden lg:table-cell text-xs",children:E(t.next_run_at)}),e.jsx("td",{className:"px-4 py-3 dark:text-matrix-secondary hidden lg:table-cell text-xs",children:E(t.last_run_at)}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(Z,{enabled:t.enabled})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx("button",{title:h===t.id?"Hide history":"View history",onClick:()=>l(h===t.id?null:t.id),className:"p-1.5 rounded dark:text-matrix-tertiary dark:hover:text-matrix-highlight hover:bg-azure-hover dark:hover:bg-matrix-primary/20 transition-colors",children:h===t.id?e.jsx(M,{className:"w-4 h-4"}):e.jsx(U,{className:"w-4 h-4"})}),e.jsx("button",{title:"Edit",onClick:()=>s(t),className:"p-1.5 rounded dark:text-matrix-tertiary dark:hover:text-matrix-highlight hover:bg-azure-hover dark:hover:bg-matrix-primary/20 transition-colors",children:e.jsx(B,{className:"w-4 h-4"})}),e.jsx("button",{title:t.enabled?"Disable":"Enable",onClick:()=>k(t),disabled:x===t.id,className:"p-1.5 rounded dark:text-matrix-tertiary dark:hover:text-matrix-highlight hover:bg-azure-hover dark:hover:bg-matrix-primary/20 transition-colors disabled:opacity-40",children:t.enabled?e.jsx(H,{className:"w-4 h-4"}):e.jsx(W,{className:"w-4 h-4"})}),e.jsx("button",{title:"Delete",onClick:()=>b(t),disabled:x===t.id,className:"p-1.5 rounded text-red-500 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors disabled:opacity-40",children:e.jsx($,{className:"w-4 h-4"})})]})})]},t.id),h===t.id&&e.jsx("tr",{className:"bg-azure-surface dark:bg-zinc-900/50",children:e.jsxs("td",{colSpan:6,className:"px-4 py-3",children:[e.jsx("div",{className:"text-xs font-bold dark:text-matrix-highlight mb-2",children:"Execution History"}),e.jsx(X,{jobId:t.id})]})},`${t.id}-history`)]}))})]}),o&&o.total_pages>1&&e.jsx(J,{page:i,totalPages:o.total_pages,perPage:r,total:o.total,onPageChange:m,onPerPageChange:f}),e.jsx(R,{isOpen:!!p,onClose:()=>b(null),onConfirm:v,title:"Delete Chronos Job",message:p?`Delete job "${_(p.prompt,60)}"? This action cannot be undone.`:""})]})}function V({scheduleExpression:s,scheduleType:i,timezone:m}){const[r,u]=n.useState(null),[o,c]=n.useState(null),d=n.useRef(null);if(n.useEffect(()=>{if(!s.trim()){u(null),c(null);return}return d.current&&clearTimeout(d.current),d.current=setTimeout(async()=>{try{const l=await y.preview(s,i,m);u(l),c(null)}catch(l){c(l.message??"Invalid expression"),u(null)}},500),()=>{d.current&&clearTimeout(d.current)}},[s,i,m]),!s.trim())return null;const h=(l,x)=>{try{return new Date(l).toLocaleString("pt-BR",{timeZone:x,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return new Date(l).toLocaleString()}};return e.jsx("div",{className:"mt-2 rounded border border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-zinc-900 p-3 text-sm",children:o?e.jsxs("p",{className:"text-red-500 dark:text-red-400 flex items-center gap-1.5",children:[e.jsx("span",{children:"⚠"})," ",o]}):r?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-azure-text-secondary dark:text-matrix-secondary",children:[e.jsx(T,{className:"w-3.5 h-3.5 text-azure-primary dark:text-matrix-highlight shrink-0"}),e.jsx("span",{className:"font-medium dark:text-matrix-highlight",children:"Next run:"}),e.jsx("span",{children:h(r.next_run_at,m||"UTC")})]}),r.human_readable&&e.jsx("p",{className:"text-azure-text-muted dark:text-matrix-secondary/70 pl-5",children:r.human_readable}),r.next_occurrences.length>0&&e.jsx("div",{className:"pl-5 space-y-0.5",children:r.next_occurrences.map((l,x)=>e.jsxs("p",{className:"text-azure-text-muted dark:text-matrix-tertiary text-xs",children:["#",x+2,": ",l]},x))})]}):e.jsx("p",{className:"text-azure-text-muted dark:text-matrix-tertiary italic",children:"Parsing…"})})}const G=["UTC","America/Sao_Paulo","America/New_York","America/Chicago","America/Denver","America/Los_Angeles","America/Toronto","America/Mexico_City","America/Buenos_Aires","America/Bogota","America/Lima","America/Santiago","Europe/London","Europe/Paris","Europe/Berlin","Europe/Rome","Europe/Madrid","Europe/Lisbon","Europe/Moscow","Europe/Istanbul","Asia/Dubai","Asia/Kolkata","Asia/Bangkok","Asia/Singapore","Asia/Tokyo","Asia/Shanghai","Asia/Seoul","Asia/Jakarta","Australia/Sydney","Australia/Melbourne","Pacific/Auckland","Africa/Cairo","Africa/Johannesburg","Africa/Lagos"],Q=[{value:"telegram",label:"Telegram"},{value:"discord",label:"Discord"}],ee=[{value:"once",label:"Once"},{value:"cron",label:"Recurring (Cron)"},{value:"interval",label:"Recurring (Interval)"}],te={once:'e.g. "in 30 minutes", "tomorrow at 9am", "2026-03-01T09:00:00"',cron:'e.g. "0 9 * * 1-5" (weekdays at 9am)',interval:'e.g. "every 30 minutes", "every sunday at 9am", "every weekday"'};function re({isOpen:s,onClose:i,onCreated:m,editJob:r}){const u=!!r,{data:o}=O(),[c,d]=n.useState(""),[h,l]=n.useState("once"),[x,g]=n.useState(""),[p,b]=n.useState("UTC"),[f,k]=n.useState([]),[v,t]=n.useState(null),[N,w]=n.useState(!1),A=a=>{k(j=>j.includes(a)?j.filter(D=>D!==a):[...j,a])};n.useEffect(()=>{r?(d(r.prompt),l(r.schedule_type),g(r.schedule_expression),b(r.timezone),k(r.notify_channels??[])):(d(""),l("once"),g(""),b(o?.timezone??"UTC"),k([])),t(null)},[r,s,o?.timezone]);const P=async()=>{if(t(null),!c.trim()){t("Prompt is required");return}if(!x.trim()){t("Schedule expression is required");return}w(!0);try{if(u&&r){const a={prompt:c,schedule_expression:x,timezone:p,notify_channels:f};await y.updateJob(r.id,a)}else{const a={prompt:c,schedule_type:h,schedule_expression:x,timezone:p,notify_channels:f};await y.createJob(a)}await z(a=>typeof a=="string"&&a.startsWith("/chronos")),m(),i()}catch(a){t(a.message??"Failed to save job")}finally{w(!1)}};return s?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:i}),e.jsxs("div",{className:"relative z-10 w-full max-w-lg mx-4 rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black shadow-xl",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-azure-border dark:border-matrix-primary",children:[e.jsx("h2",{className:"text-lg font-bold text-azure-text-primary dark:text-matrix-highlight font-mono",children:u?"Edit Chronos Job":"New Chronos Job"}),e.jsx("button",{onClick:i,className:"p-1 rounded text-azure-text-muted dark:text-matrix-tertiary hover:text-azure-text-primary dark:hover:text-matrix-highlight transition-colors",children:e.jsx(q,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsx(C,{label:"Prompt",value:c,onChange:a=>d(a.target.value),placeholder:"What should the Oracle do when this job triggers?"}),!u&&e.jsx(S,{label:"Schedule Type",value:h,onChange:a=>l(a.target.value),options:ee}),e.jsxs("div",{children:[e.jsx(C,{label:"Schedule Expression",value:x,onChange:a=>g(a.target.value),placeholder:te[h]}),e.jsx(V,{scheduleExpression:x,scheduleType:h,timezone:p})]}),e.jsx(S,{label:"Timezone",value:p,onChange:a=>b(a.target.value),options:G.map(a=>({value:a,label:a}))}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium text-azure-text-secondary dark:text-matrix-secondary mb-2",children:["Notify Channels ",e.jsx("span",{className:"text-xs font-normal opacity-60",children:"(empty = all active channels)"})]}),e.jsx("div",{className:"flex gap-4",children:Q.map(({value:a,label:j})=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:f.includes(a),onChange:()=>A(a),className:"rounded border-azure-border dark:border-matrix-primary accent-azure-primary dark:accent-matrix-highlight"}),e.jsx("span",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary capitalize",children:j})]},a))})]}),v&&e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:v})]}),e.jsxs("div",{className:"flex justify-end gap-3 p-4 border-t border-azure-border dark:border-matrix-primary",children:[e.jsx("button",{onClick:i,className:"px-4 py-2 rounded text-sm border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:bg-azure-hover dark:hover:bg-matrix-primary/20 transition-colors font-mono",children:"Cancel"}),e.jsx("button",{onClick:P,disabled:N,className:"px-4 py-2 rounded text-sm bg-azure-primary dark:bg-matrix-primary text-white dark:text-matrix-highlight font-bold hover:opacity-90 disabled:opacity-50 transition-opacity font-mono",children:N?"Saving…":u?"Update":"Create"})]})]})]}):null}function me(){const[s,i]=n.useState(!1),[m,r]=n.useState(null),u=d=>{r(d),i(!0)},o=()=>{i(!1),r(null)},c=()=>{z(d=>typeof d=="string"&&d.startsWith("/chronos"))};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{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(T,{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:"Chronos"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary mt-0.5",children:"Temporal Intent Engine — schedule prompts for the Oracle."})]})]}),e.jsxs("button",{onClick:()=>{r(null),i(!0)},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(F,{className:"w-4 h-4"}),"New Job"]})]}),e.jsx(K,{onEdit:u}),e.jsx(re,{isOpen:s,onClose:o,onCreated:c,editJob:m})]})}export{me as ChronosPage};
|
|
1
|
+
import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as n}from"./vendor-react-DikRIOlj.js";import{a as L,b as I,c as y,u as O}from"./chronos-Bm68OSy4.js";import{D as R}from"./DeleteConfirmationModal-CqNXT_YQ.js";import{P as J}from"./Pagination-BHZKk42X.js";import{ae as M,af as U,ag as B,ah as H,ai as W,z as $,g as T,X as q,a6 as F}from"./vendor-icons-NHF9HNeN.js";import{m as z}from"./vendor-utils-D4NnWbOU.js";import{T as C,S}from"./SelectInput-KVLsnfra.js";import"./index-BxN2w9sY.js";const Y={running:"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",success:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",failed:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400",timeout:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"};function X({jobId:s}){const{data:i,isLoading:m}=L(s,50);return m?e.jsx("div",{className:"p-4 dark:bg-zinc-900 rounded text-sm dark:text-matrix-secondary animate-pulse",children:"Loading history…"}):!i||i.length===0?e.jsx("div",{className:"p-4 dark:bg-zinc-900 rounded text-sm dark:text-matrix-secondary italic",children:"No executions yet."}):e.jsx("div",{className:"rounded border border-azure-border dark:border-matrix-primary dark:bg-zinc-900 overflow-hidden",children:e.jsxs("table",{className:"w-full text-xs font-mono",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-azure-border dark:border-matrix-primary",children:[e.jsx("th",{className:"text-left px-3 py-2 text-azure-text-muted dark:text-matrix-tertiary",children:"Triggered At"}),e.jsx("th",{className:"text-left px-3 py-2 text-azure-text-muted dark:text-matrix-tertiary",children:"Completed At"}),e.jsx("th",{className:"text-left px-3 py-2 text-azure-text-muted dark:text-matrix-tertiary",children:"Status"}),e.jsx("th",{className:"text-left px-3 py-2 text-azure-text-muted dark:text-matrix-tertiary",children:"Error"})]})}),e.jsx("tbody",{children:i.map(r=>e.jsxs("tr",{className:"border-b border-azure-border dark:border-matrix-primary/30 last:border-0",children:[e.jsx("td",{className:"px-3 py-2 dark:text-matrix-secondary",children:new Date(r.triggered_at).toLocaleString()}),e.jsx("td",{className:"px-3 py-2 dark:text-matrix-secondary",children:r.completed_at?new Date(r.completed_at).toLocaleString():"—"}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-bold uppercase ${Y[r.status]}`,children:r.status})}),e.jsx("td",{className:"px-3 py-2 dark:text-red-400 max-w-xs truncate",children:r.error??"—"})]},r.id))})]})})}function Z({enabled:s}){return e.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-bold uppercase ${s?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":"bg-gray-100 text-gray-500 dark:bg-zinc-800 dark:text-matrix-tertiary"}`,children:s?"Enabled":"Disabled"})}function _(s,i){return s.length>i?`${s.slice(0,i)}…`:s}function E(s){return s?new Date(s).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function K({onEdit:s}){const[i,m]=n.useState(1),[r,u]=n.useState(20),{data:o,isLoading:c}=I({page:i,per_page:r}),d=o?.data??[],[h,l]=n.useState(null),[x,g]=n.useState(null),[p,b]=n.useState(null),f=t=>{u(t),m(1)},k=async t=>{g(t.id);try{t.enabled?await y.disableJob(t.id):await y.enableJob(t.id),await z(N=>typeof N=="string"&&N.startsWith("/chronos"))}finally{g(null)}},v=async()=>{if(p){g(p.id);try{await y.deleteJob(p.id),await z(t=>typeof t=="string"&&t.startsWith("/chronos"))}finally{g(null),b(null)}}};return c?e.jsx("div",{className:"rounded border border-azure-border dark:border-matrix-primary p-8 text-center dark:text-matrix-secondary animate-pulse",children:"Loading jobs…"}):!c&&d.length===0&&i===1?e.jsxs("div",{className:"rounded border border-azure-border dark:border-matrix-primary p-8 text-center dark:text-matrix-secondary",children:["No Chronos jobs yet. Click ",e.jsx("strong",{className:"dark:text-matrix-highlight",children:"New Job"})," to get started."]}):e.jsxs("div",{className:"rounded border border-azure-border dark:border-matrix-primary overflow-hidden",children:[e.jsxs("table",{className:"w-full text-sm font-mono",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-zinc-900",children:[e.jsx("th",{className:"text-left px-4 py-3 text-azure-text-muted dark:text-matrix-tertiary font-medium",children:"Prompt"}),e.jsx("th",{className:"text-left px-4 py-3 text-azure-text-muted dark:text-matrix-tertiary font-medium hidden md:table-cell",children:"Schedule"}),e.jsx("th",{className:"text-left px-4 py-3 text-azure-text-muted dark:text-matrix-tertiary font-medium hidden lg:table-cell",children:"Next Run"}),e.jsx("th",{className:"text-left px-4 py-3 text-azure-text-muted dark:text-matrix-tertiary font-medium hidden lg:table-cell",children:"Last Run"}),e.jsx("th",{className:"text-left px-4 py-3 text-azure-text-muted dark:text-matrix-tertiary font-medium",children:"Status"}),e.jsx("th",{className:"px-4 py-3 text-azure-text-muted dark:text-matrix-tertiary font-medium text-right",children:"Actions"})]})}),e.jsx("tbody",{children:d.map(t=>e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"border-b border-azure-border dark:border-matrix-primary/30 last:border-0 hover:bg-azure-hover dark:hover:bg-matrix-primary/10 transition-colors",children:[e.jsxs("td",{className:"px-4 py-3 dark:text-matrix-secondary max-w-xs",children:[e.jsx("span",{title:t.prompt,children:_(t.prompt,50)}),e.jsx("div",{className:"text-xs text-azure-text-muted dark:text-matrix-tertiary",children:t.created_by})]}),e.jsxs("td",{className:"px-4 py-3 dark:text-matrix-secondary hidden md:table-cell text-xs",children:[e.jsx("div",{className:"capitalize",children:t.schedule_type}),e.jsx("div",{className:"text-azure-text-muted dark:text-matrix-tertiary truncate max-w-[140px]",title:t.schedule_expression,children:t.schedule_expression})]}),e.jsx("td",{className:"px-4 py-3 dark:text-matrix-secondary hidden lg:table-cell text-xs",children:E(t.next_run_at)}),e.jsx("td",{className:"px-4 py-3 dark:text-matrix-secondary hidden lg:table-cell text-xs",children:E(t.last_run_at)}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(Z,{enabled:t.enabled})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx("button",{title:h===t.id?"Hide history":"View history",onClick:()=>l(h===t.id?null:t.id),className:"p-1.5 rounded dark:text-matrix-tertiary dark:hover:text-matrix-highlight hover:bg-azure-hover dark:hover:bg-matrix-primary/20 transition-colors",children:h===t.id?e.jsx(M,{className:"w-4 h-4"}):e.jsx(U,{className:"w-4 h-4"})}),e.jsx("button",{title:"Edit",onClick:()=>s(t),className:"p-1.5 rounded dark:text-matrix-tertiary dark:hover:text-matrix-highlight hover:bg-azure-hover dark:hover:bg-matrix-primary/20 transition-colors",children:e.jsx(B,{className:"w-4 h-4"})}),e.jsx("button",{title:t.enabled?"Disable":"Enable",onClick:()=>k(t),disabled:x===t.id,className:"p-1.5 rounded dark:text-matrix-tertiary dark:hover:text-matrix-highlight hover:bg-azure-hover dark:hover:bg-matrix-primary/20 transition-colors disabled:opacity-40",children:t.enabled?e.jsx(H,{className:"w-4 h-4"}):e.jsx(W,{className:"w-4 h-4"})}),e.jsx("button",{title:"Delete",onClick:()=>b(t),disabled:x===t.id,className:"p-1.5 rounded text-red-500 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors disabled:opacity-40",children:e.jsx($,{className:"w-4 h-4"})})]})})]},t.id),h===t.id&&e.jsx("tr",{className:"bg-azure-surface dark:bg-zinc-900/50",children:e.jsxs("td",{colSpan:6,className:"px-4 py-3",children:[e.jsx("div",{className:"text-xs font-bold dark:text-matrix-highlight mb-2",children:"Execution History"}),e.jsx(X,{jobId:t.id})]})},`${t.id}-history`)]}))})]}),o&&o.total_pages>1&&e.jsx(J,{page:i,totalPages:o.total_pages,perPage:r,total:o.total,onPageChange:m,onPerPageChange:f}),e.jsx(R,{isOpen:!!p,onClose:()=>b(null),onConfirm:v,title:"Delete Chronos Job",message:p?`Delete job "${_(p.prompt,60)}"? This action cannot be undone.`:""})]})}function V({scheduleExpression:s,scheduleType:i,timezone:m}){const[r,u]=n.useState(null),[o,c]=n.useState(null),d=n.useRef(null);if(n.useEffect(()=>{if(!s.trim()){u(null),c(null);return}return d.current&&clearTimeout(d.current),d.current=setTimeout(async()=>{try{const l=await y.preview(s,i,m);u(l),c(null)}catch(l){c(l.message??"Invalid expression"),u(null)}},500),()=>{d.current&&clearTimeout(d.current)}},[s,i,m]),!s.trim())return null;const h=(l,x)=>{try{return new Date(l).toLocaleString("pt-BR",{timeZone:x,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return new Date(l).toLocaleString()}};return e.jsx("div",{className:"mt-2 rounded border border-azure-border dark:border-matrix-primary bg-azure-surface dark:bg-zinc-900 p-3 text-sm",children:o?e.jsxs("p",{className:"text-red-500 dark:text-red-400 flex items-center gap-1.5",children:[e.jsx("span",{children:"⚠"})," ",o]}):r?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-azure-text-secondary dark:text-matrix-secondary",children:[e.jsx(T,{className:"w-3.5 h-3.5 text-azure-primary dark:text-matrix-highlight shrink-0"}),e.jsx("span",{className:"font-medium dark:text-matrix-highlight",children:"Next run:"}),e.jsx("span",{children:h(r.next_run_at,m||"UTC")})]}),r.human_readable&&e.jsx("p",{className:"text-azure-text-muted dark:text-matrix-secondary/70 pl-5",children:r.human_readable}),r.next_occurrences.length>0&&e.jsx("div",{className:"pl-5 space-y-0.5",children:r.next_occurrences.map((l,x)=>e.jsxs("p",{className:"text-azure-text-muted dark:text-matrix-tertiary text-xs",children:["#",x+2,": ",l]},x))})]}):e.jsx("p",{className:"text-azure-text-muted dark:text-matrix-tertiary italic",children:"Parsing…"})})}const G=["UTC","America/Sao_Paulo","America/New_York","America/Chicago","America/Denver","America/Los_Angeles","America/Toronto","America/Mexico_City","America/Buenos_Aires","America/Bogota","America/Lima","America/Santiago","Europe/London","Europe/Paris","Europe/Berlin","Europe/Rome","Europe/Madrid","Europe/Lisbon","Europe/Moscow","Europe/Istanbul","Asia/Dubai","Asia/Kolkata","Asia/Bangkok","Asia/Singapore","Asia/Tokyo","Asia/Shanghai","Asia/Seoul","Asia/Jakarta","Australia/Sydney","Australia/Melbourne","Pacific/Auckland","Africa/Cairo","Africa/Johannesburg","Africa/Lagos"],Q=[{value:"telegram",label:"Telegram"},{value:"discord",label:"Discord"}],ee=[{value:"once",label:"Once"},{value:"cron",label:"Recurring (Cron)"},{value:"interval",label:"Recurring (Interval)"}],te={once:'e.g. "in 30 minutes", "tomorrow at 9am", "2026-03-01T09:00:00"',cron:'e.g. "0 9 * * 1-5" (weekdays at 9am)',interval:'e.g. "every 30 minutes", "every sunday at 9am", "every weekday"'};function re({isOpen:s,onClose:i,onCreated:m,editJob:r}){const u=!!r,{data:o}=O(),[c,d]=n.useState(""),[h,l]=n.useState("once"),[x,g]=n.useState(""),[p,b]=n.useState("UTC"),[f,k]=n.useState([]),[v,t]=n.useState(null),[N,w]=n.useState(!1),A=a=>{k(j=>j.includes(a)?j.filter(D=>D!==a):[...j,a])};n.useEffect(()=>{r?(d(r.prompt),l(r.schedule_type),g(r.schedule_expression),b(r.timezone),k(r.notify_channels??[])):(d(""),l("once"),g(""),b(o?.timezone??"UTC"),k([])),t(null)},[r,s,o?.timezone]);const P=async()=>{if(t(null),!c.trim()){t("Prompt is required");return}if(!x.trim()){t("Schedule expression is required");return}w(!0);try{if(u&&r){const a={prompt:c,schedule_expression:x,timezone:p,notify_channels:f};await y.updateJob(r.id,a)}else{const a={prompt:c,schedule_type:h,schedule_expression:x,timezone:p,notify_channels:f};await y.createJob(a)}await z(a=>typeof a=="string"&&a.startsWith("/chronos")),m(),i()}catch(a){t(a.message??"Failed to save job")}finally{w(!1)}};return s?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:i}),e.jsxs("div",{className:"relative z-10 w-full max-w-lg mx-4 rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black shadow-xl",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-azure-border dark:border-matrix-primary",children:[e.jsx("h2",{className:"text-lg font-bold text-azure-text-primary dark:text-matrix-highlight font-mono",children:u?"Edit Chronos Job":"New Chronos Job"}),e.jsx("button",{onClick:i,className:"p-1 rounded text-azure-text-muted dark:text-matrix-tertiary hover:text-azure-text-primary dark:hover:text-matrix-highlight transition-colors",children:e.jsx(q,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsx(C,{label:"Prompt",value:c,onChange:a=>d(a.target.value),placeholder:"What should the Oracle do when this job triggers?"}),!u&&e.jsx(S,{label:"Schedule Type",value:h,onChange:a=>l(a.target.value),options:ee}),e.jsxs("div",{children:[e.jsx(C,{label:"Schedule Expression",value:x,onChange:a=>g(a.target.value),placeholder:te[h]}),e.jsx(V,{scheduleExpression:x,scheduleType:h,timezone:p})]}),e.jsx(S,{label:"Timezone",value:p,onChange:a=>b(a.target.value),options:G.map(a=>({value:a,label:a}))}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium text-azure-text-secondary dark:text-matrix-secondary mb-2",children:["Notify Channels ",e.jsx("span",{className:"text-xs font-normal opacity-60",children:"(empty = all active channels)"})]}),e.jsx("div",{className:"flex gap-4",children:Q.map(({value:a,label:j})=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:f.includes(a),onChange:()=>A(a),className:"rounded border-azure-border dark:border-matrix-primary accent-azure-primary dark:accent-matrix-highlight"}),e.jsx("span",{className:"text-sm text-azure-text-secondary dark:text-matrix-secondary capitalize",children:j})]},a))})]}),v&&e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:v})]}),e.jsxs("div",{className:"flex justify-end gap-3 p-4 border-t border-azure-border dark:border-matrix-primary",children:[e.jsx("button",{onClick:i,className:"px-4 py-2 rounded text-sm border border-azure-border dark:border-matrix-primary text-azure-text-secondary dark:text-matrix-secondary hover:bg-azure-hover dark:hover:bg-matrix-primary/20 transition-colors font-mono",children:"Cancel"}),e.jsx("button",{onClick:P,disabled:N,className:"px-4 py-2 rounded text-sm bg-azure-primary dark:bg-matrix-primary text-white dark:text-matrix-highlight font-bold hover:opacity-90 disabled:opacity-50 transition-opacity font-mono",children:N?"Saving…":u?"Update":"Create"})]})]})]}):null}function me(){const[s,i]=n.useState(!1),[m,r]=n.useState(null),u=d=>{r(d),i(!0)},o=()=>{i(!1),r(null)},c=()=>{z(d=>typeof d=="string"&&d.startsWith("/chronos"))};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{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(T,{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:"Chronos"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary mt-0.5",children:"Temporal Intent Engine — schedule prompts for the Oracle."})]})]}),e.jsxs("button",{onClick:()=>{r(null),i(!0)},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(F,{className:"w-4 h-4"}),"New Job"]})]}),e.jsx(K,{onEdit:u}),e.jsx(re,{isOpen:s,onClose:o,onCreated:c,editJob:m})]})}export{me as ChronosPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r}from"./vendor-motion-C3CZ8ZlO.js";import{D as o,d as x,e as n,j as c,k as g,B as t}from"./index-
|
|
1
|
+
import{j as r}from"./vendor-motion-C3CZ8ZlO.js";import{D as o,d as x,e as n,j as c,k as g,B as t}from"./index-BxN2w9sY.js";function p({isOpen:i,onClose:a,onConfirm:s,title:d,description:l,confirmJson:m="Confirm",variant:e="default"}){return r.jsx(o,{open:i,onOpenChange:a,children:r.jsxs(x,{className:"sm:max-w-md bg-azure-surface dark:bg-black border-azure-border dark:border-matrix-primary",children:[r.jsx(n,{children:r.jsx(c,{className:"text-azure-primary dark:text-matrix-highlight flex items-center gap-2",children:d})}),r.jsx("div",{className:"py-4",children:r.jsx("p",{className:"text-azure-text-secondary dark:text-matrix-secondary",children:l})}),r.jsxs(g,{className:"flex flex-col sm:flex-row gap-3 sm:justify-end",children:[r.jsx(t,{variant:"outline",onClick:a,className:"dark:border-matrix-primary dark:text-matrix-secondary dark:hover:bg-matrix-primary/20",children:"Cancel"}),r.jsx(t,{variant:e,onClick:()=>{s(),a()},className:e==="destructive"?"dark:bg-red-900/50 dark:text-red-200 dark:hover:bg-red-800/60":"dark:bg-matrix-primary dark:text-black dark:hover:bg-matrix-highlight",children:m})]})]})})}export{p as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,m as d}from"./vendor-motion-C3CZ8ZlO.js";import{u as P,t as z,h as w,f as U}from"./index-BiMscUrn.js";import{u as n}from"./vendor-utils-D4NnWbOU.js";import{s as A}from"./stats-cDmpngPQ.js";import{m as E}from"./mcp-JmpcV6nl.js";import{s as R}from"./skills-D2stQj7i.js";import{L as V,A as F,g as j,l as O,m as J,n as W,i as B,W as G,P as H,H as q,f as X,o as S,p as K,q as Q,r as Y}from"./vendor-icons-NHF9HNeN.js";import{L as C}from"./vendor-react-DikRIOlj.js";const Z={hidden:{opacity:0,y:20},show:{opacity:1,y:0}},k=({title:r,value:a,icon:i,subValue:l})=>e.jsxs(d.div,{variants:Z,className:"border border-azure-border dark:border-matrix-primary bg-azure-surface/50 dark:bg-zinc-950/50 p-6 rounded relative overflow-hidden group hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",children:[e.jsxs("div",{className:"flex justify-between items-start mb-4",children:[e.jsx("h3",{className:"text-azure-text-secondary dark:text-matrix-secondary text-sm font-bold uppercase",children:r}),e.jsx(i,{className:"w-6 h-6 text-azure-primary dark:text-matrix-primary group-hover:text-azure-primary dark:group-hover:text-matrix-highlight transition-colors"})]}),e.jsx("div",{className:"text-3xl font-bold text-azure-primary dark:text-matrix-highlight mb-1 font-mono tracking-tighter truncate",children:a}),l&&e.jsx("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary opacity-70 font-mono",children:l})]}),ee={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.07}}},c={hidden:{opacity:0,y:12},show:{opacity:1,y:0}};function m({icon:r,title:a,to:i,children:l,status:o="neutral"}){const h=o==="ok"?"border-emerald-300/60 dark:border-emerald-700/40":o==="warn"?"border-amber-300/60 dark:border-amber-700/40":o==="error"?"border-red-300/60 dark:border-red-700/40":"border-azure-border dark:border-matrix-primary/50";return e.jsxs(C,{to:i,className:`group flex flex-col gap-3 rounded-lg border bg-white dark:bg-black p-4 hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors ${h}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(r,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight"}),e.jsx("span",{className:"text-sm font-semibold text-azure-text dark:text-matrix-highlight",children:a})]}),e.jsx(S,{className:"w-3.5 h-3.5 text-azure-text-secondary dark:text-matrix-tertiary group-hover:text-azure-primary dark:group-hover:text-matrix-highlight transition-colors"})]}),e.jsx("div",{className:"space-y-1.5",children:l})]})}function s({label:r,value:a,highlight:i}){return e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:r}),e.jsx("span",{className:i?"font-semibold text-azure-text dark:text-matrix-highlight":"text-azure-text-secondary dark:text-matrix-secondary",children:a})]})}function te({status:r}){return r==="completed"?e.jsx(K,{className:"w-3.5 h-3.5 text-emerald-500 shrink-0"}):r==="failed"?e.jsx(Q,{className:"w-3.5 h-3.5 text-red-500 shrink-0"}):r==="running"?e.jsx(Y,{className:"w-3.5 h-3.5 text-blue-500 animate-spin shrink-0"}):e.jsx(j,{className:"w-3.5 h-3.5 text-yellow-500 shrink-0"})}function xe(){const{data:r}=P(),{data:a}=n("/tasks/stats",()=>z.stats(),{refreshInterval:5e3}),{data:i}=n("/api/stats/usage",()=>A.fetchUsageStats(),{refreshInterval:3e4}),{data:l}=n("/api/mcp/stats",()=>E.fetchStats(),{refreshInterval:3e4}),{data:o}=n("/smiths",()=>w.get("/smiths"),{refreshInterval:1e4}),{data:h=[]}=n("/chronos",()=>w.get("/chronos"),{refreshInterval:3e4}),{data:x}=n("/api/skills",()=>R.fetchSkills(),{refreshInterval:6e4}),{data:p=[]}=n(["/tasks",{limit:5}],()=>z.list({limit:5}),{refreshInterval:5e3}),v=(i?.totalInputTokens??0)+(i?.totalOutputTokens??0),f=i?.totalEstimatedCostUsd!=null,T=i?.totalEstimatedCostUsd??0,g=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t),u=h.filter(t=>t.enabled),y=u.filter(t=>t.next_run_at).sort((t,b)=>t.next_run_at-b.next_run_at)[0],N=y?.next_run_at?(()=>{const t=y.next_run_at-Date.now();return t<0?"due now":t<6e4?`${Math.floor(t/1e3)}s`:t<36e5?`${Math.floor(t/6e4)}m`:`${Math.floor(t/36e5)}h`})():null,$=(a?.pending??0)+(a?.running??0),I=a?.failed?"warn":$>0?"ok":"neutral",L=(l?.totalTools??0)>0?"ok":"neutral",_=(o?.online??0)>0?"ok":(o?.total??0)>0?"warn":"neutral",D=u.length>0?"ok":"neutral",M=(x?.enabled??0)>0?"ok":"neutral";return e.jsxs(d.div,{className:"space-y-6",variants:ee,initial:"hidden",animate:"show",children:[e.jsxs(d.div,{variants:c,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(V,{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:"Dashboard"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Overview of the Morpheus agent runtime."})]})]}),e.jsxs(d.div,{variants:c,className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsx(k,{title:"Agent Status",value:r?.status.toUpperCase()??"CONNECTING...",icon:F,subValue:r?`PID: ${r.pid}`:""}),e.jsx(k,{title:"Uptime",value:r?U(r.uptimeSeconds):"-",icon:j,subValue:r?`${r.uptimeSeconds.toFixed(0)}s elapsed`:""}),e.jsx(k,{title:"Version",value:r?.projectVersion??"-",icon:O,subValue:`Node ${r?.nodeVersion??"-"}`})]}),e.jsxs(d.div,{variants:c,className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black p-4",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Provider"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(J,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight shrink-0"}),e.jsx("p",{className:"text-base font-bold text-azure-text dark:text-matrix-highlight truncate",children:r?.llmProvider?.toUpperCase()??"—"})]})]}),e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black p-4",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Model"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight shrink-0"}),e.jsx("p",{className:"text-sm font-bold text-azure-text dark:text-matrix-highlight truncate leading-tight",children:r?.llmModel??"—"})]})]}),e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black p-4",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Total Tokens"}),e.jsx("p",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:v>0?g(v):"—"}),e.jsxs("p",{className:"text-[10px] text-azure-text-secondary dark:text-matrix-tertiary mt-1",children:[g(i?.totalInputTokens??0)," in · ",g(i?.totalOutputTokens??0)," out"]})]}),e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black p-4",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Est. Cost"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(B,{className:"w-4 h-4 text-emerald-500 shrink-0"}),e.jsx("p",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:f?`$${T.toFixed(4)}`:"—"})]}),e.jsx("p",{className:"text-[10px] text-azure-text-secondary dark:text-matrix-tertiary mt-1",children:f?"accumulated total":"configure pricing to track"})]})]}),e.jsxs(d.div,{variants:c,children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-3",children:"Platform"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-4",children:[e.jsxs(m,{icon:G,title:"Skills",to:"/skills",status:M,children:[e.jsx(s,{label:"Enabled",value:x?`${x.enabled} / ${x.total}`:"—",highlight:(x?.enabled??0)>0}),e.jsx(s,{label:"Total",value:x?.total??"—"})]}),e.jsxs(m,{icon:H,title:"MCP Servers",to:"/mcp-servers",status:L,children:[e.jsx(s,{label:"Tools loaded",value:l?.totalTools??"—",highlight:!!l?.totalTools}),e.jsx(s,{label:"Servers",value:l?.servers?.length??"—"}),l?.lastLoadedAt&&e.jsx(s,{label:"Last loaded",value:new Date(l.lastLoadedAt).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})})]}),e.jsxs(m,{icon:q,title:"Smiths",to:"/smiths",status:_,children:[e.jsx(s,{label:"Online",value:o?`${o.online} / ${o.total}`:"—",highlight:(o?.online??0)>0}),e.jsx(s,{label:"System",value:o?.enabled?"enabled":"disabled"})]}),e.jsxs(m,{icon:X,title:"Tasks",to:"/tasks",status:I,children:[e.jsx(s,{label:"Running",value:a?.running??"—",highlight:!!a?.running}),e.jsx(s,{label:"Pending",value:a?.pending??"—"}),e.jsx(s,{label:"Completed",value:a?.completed??"—"}),(a?.failed??0)>0&&e.jsx(s,{label:"Failed",value:a.failed})]}),e.jsxs(m,{icon:j,title:"Chronos",to:"/chronos",status:D,children:[e.jsx(s,{label:"Active jobs",value:u.length,highlight:u.length>0}),e.jsx(s,{label:"Total jobs",value:h.length}),N&&e.jsx(s,{label:"Next run",value:`in ${N}`})]})]})]}),p.length>0&&e.jsxs(d.div,{variants:c,children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary",children:"Recent Tasks"}),e.jsxs(C,{to:"/tasks",className:"flex items-center gap-0.5 text-xs text-azure-primary dark:text-matrix-highlight hover:underline",children:["View all ",e.jsx(S,{className:"w-3 h-3"})]})]}),e.jsx("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary overflow-hidden",children:p.map((t,b)=>e.jsxs("div",{className:`flex items-center gap-3 px-4 py-2.5 ${b<p.length-1?"border-b border-azure-border dark:border-matrix-primary/30":""} hover:bg-azure-surface/60 dark:hover:bg-zinc-900/50 transition-colors`,children:[e.jsx(te,{status:t.status}),e.jsx("span",{className:"font-mono text-[10px] text-azure-text-secondary dark:text-matrix-tertiary w-16 shrink-0",children:t.id.slice(0,8)}),e.jsx("span",{className:"flex-1 text-xs text-azure-text dark:text-matrix-secondary truncate",children:t.input.slice(0,100)}),e.jsx("span",{className:"text-[10px] font-mono uppercase text-azure-text-secondary dark:text-matrix-tertiary shrink-0",children:t.agent}),e.jsx("span",{className:"text-[10px] text-azure-text-secondary dark:text-matrix-tertiary shrink-0",children:new Date(t.created_at).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})})]},t.id))})]})]})}export{xe as Dashboard};
|
|
1
|
+
import{j as e,m as d}from"./vendor-motion-C3CZ8ZlO.js";import{u as P,t as z,h as w,f as U}from"./index-BxN2w9sY.js";import{u as n}from"./vendor-utils-D4NnWbOU.js";import{s as A}from"./stats-Bmdps1LR.js";import{m as E}from"./mcp-BE_OVkBe.js";import{s as R}from"./skills-Dt0qU4gH.js";import{L as V,A as F,g as j,l as O,m as J,n as W,i as B,W as G,P as H,H as q,f as X,o as S,p as K,q as Q,r as Y}from"./vendor-icons-NHF9HNeN.js";import{L as C}from"./vendor-react-DikRIOlj.js";const Z={hidden:{opacity:0,y:20},show:{opacity:1,y:0}},k=({title:r,value:a,icon:i,subValue:l})=>e.jsxs(d.div,{variants:Z,className:"border border-azure-border dark:border-matrix-primary bg-azure-surface/50 dark:bg-zinc-950/50 p-6 rounded relative overflow-hidden group hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors",children:[e.jsxs("div",{className:"flex justify-between items-start mb-4",children:[e.jsx("h3",{className:"text-azure-text-secondary dark:text-matrix-secondary text-sm font-bold uppercase",children:r}),e.jsx(i,{className:"w-6 h-6 text-azure-primary dark:text-matrix-primary group-hover:text-azure-primary dark:group-hover:text-matrix-highlight transition-colors"})]}),e.jsx("div",{className:"text-3xl font-bold text-azure-primary dark:text-matrix-highlight mb-1 font-mono tracking-tighter truncate",children:a}),l&&e.jsx("div",{className:"text-xs text-azure-text-secondary dark:text-matrix-secondary opacity-70 font-mono",children:l})]}),ee={hidden:{opacity:0},show:{opacity:1,transition:{staggerChildren:.07}}},c={hidden:{opacity:0,y:12},show:{opacity:1,y:0}};function m({icon:r,title:a,to:i,children:l,status:o="neutral"}){const h=o==="ok"?"border-emerald-300/60 dark:border-emerald-700/40":o==="warn"?"border-amber-300/60 dark:border-amber-700/40":o==="error"?"border-red-300/60 dark:border-red-700/40":"border-azure-border dark:border-matrix-primary/50";return e.jsxs(C,{to:i,className:`group flex flex-col gap-3 rounded-lg border bg-white dark:bg-black p-4 hover:border-azure-primary dark:hover:border-matrix-highlight transition-colors ${h}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(r,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight"}),e.jsx("span",{className:"text-sm font-semibold text-azure-text dark:text-matrix-highlight",children:a})]}),e.jsx(S,{className:"w-3.5 h-3.5 text-azure-text-secondary dark:text-matrix-tertiary group-hover:text-azure-primary dark:group-hover:text-matrix-highlight transition-colors"})]}),e.jsx("div",{className:"space-y-1.5",children:l})]})}function s({label:r,value:a,highlight:i}){return e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-azure-text-secondary dark:text-matrix-tertiary",children:r}),e.jsx("span",{className:i?"font-semibold text-azure-text dark:text-matrix-highlight":"text-azure-text-secondary dark:text-matrix-secondary",children:a})]})}function te({status:r}){return r==="completed"?e.jsx(K,{className:"w-3.5 h-3.5 text-emerald-500 shrink-0"}):r==="failed"?e.jsx(Q,{className:"w-3.5 h-3.5 text-red-500 shrink-0"}):r==="running"?e.jsx(Y,{className:"w-3.5 h-3.5 text-blue-500 animate-spin shrink-0"}):e.jsx(j,{className:"w-3.5 h-3.5 text-yellow-500 shrink-0"})}function xe(){const{data:r}=P(),{data:a}=n("/tasks/stats",()=>z.stats(),{refreshInterval:5e3}),{data:i}=n("/api/stats/usage",()=>A.fetchUsageStats(),{refreshInterval:3e4}),{data:l}=n("/api/mcp/stats",()=>E.fetchStats(),{refreshInterval:3e4}),{data:o}=n("/smiths",()=>w.get("/smiths"),{refreshInterval:1e4}),{data:h=[]}=n("/chronos",()=>w.get("/chronos"),{refreshInterval:3e4}),{data:x}=n("/api/skills",()=>R.fetchSkills(),{refreshInterval:6e4}),{data:p=[]}=n(["/tasks",{limit:5}],()=>z.list({limit:5}),{refreshInterval:5e3}),v=(i?.totalInputTokens??0)+(i?.totalOutputTokens??0),f=i?.totalEstimatedCostUsd!=null,T=i?.totalEstimatedCostUsd??0,g=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t),u=h.filter(t=>t.enabled),y=u.filter(t=>t.next_run_at).sort((t,b)=>t.next_run_at-b.next_run_at)[0],N=y?.next_run_at?(()=>{const t=y.next_run_at-Date.now();return t<0?"due now":t<6e4?`${Math.floor(t/1e3)}s`:t<36e5?`${Math.floor(t/6e4)}m`:`${Math.floor(t/36e5)}h`})():null,$=(a?.pending??0)+(a?.running??0),I=a?.failed?"warn":$>0?"ok":"neutral",L=(l?.totalTools??0)>0?"ok":"neutral",_=(o?.online??0)>0?"ok":(o?.total??0)>0?"warn":"neutral",D=u.length>0?"ok":"neutral",M=(x?.enabled??0)>0?"ok":"neutral";return e.jsxs(d.div,{className:"space-y-6",variants:ee,initial:"hidden",animate:"show",children:[e.jsxs(d.div,{variants:c,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(V,{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:"Dashboard"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Overview of the Morpheus agent runtime."})]})]}),e.jsxs(d.div,{variants:c,className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsx(k,{title:"Agent Status",value:r?.status.toUpperCase()??"CONNECTING...",icon:F,subValue:r?`PID: ${r.pid}`:""}),e.jsx(k,{title:"Uptime",value:r?U(r.uptimeSeconds):"-",icon:j,subValue:r?`${r.uptimeSeconds.toFixed(0)}s elapsed`:""}),e.jsx(k,{title:"Version",value:r?.projectVersion??"-",icon:O,subValue:`Node ${r?.nodeVersion??"-"}`})]}),e.jsxs(d.div,{variants:c,className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black p-4",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Provider"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(J,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight shrink-0"}),e.jsx("p",{className:"text-base font-bold text-azure-text dark:text-matrix-highlight truncate",children:r?.llmProvider?.toUpperCase()??"—"})]})]}),e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black p-4",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Model"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{className:"w-4 h-4 text-azure-primary dark:text-matrix-highlight shrink-0"}),e.jsx("p",{className:"text-sm font-bold text-azure-text dark:text-matrix-highlight truncate leading-tight",children:r?.llmModel??"—"})]})]}),e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black p-4",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Total Tokens"}),e.jsx("p",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:v>0?g(v):"—"}),e.jsxs("p",{className:"text-[10px] text-azure-text-secondary dark:text-matrix-tertiary mt-1",children:[g(i?.totalInputTokens??0)," in · ",g(i?.totalOutputTokens??0)," out"]})]}),e.jsxs("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary bg-white dark:bg-black p-4",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-2",children:"Est. Cost"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(B,{className:"w-4 h-4 text-emerald-500 shrink-0"}),e.jsx("p",{className:"text-xl font-bold text-azure-text dark:text-matrix-highlight",children:f?`$${T.toFixed(4)}`:"—"})]}),e.jsx("p",{className:"text-[10px] text-azure-text-secondary dark:text-matrix-tertiary mt-1",children:f?"accumulated total":"configure pricing to track"})]})]}),e.jsxs(d.div,{variants:c,children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary mb-3",children:"Platform"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-4",children:[e.jsxs(m,{icon:G,title:"Skills",to:"/skills",status:M,children:[e.jsx(s,{label:"Enabled",value:x?`${x.enabled} / ${x.total}`:"—",highlight:(x?.enabled??0)>0}),e.jsx(s,{label:"Total",value:x?.total??"—"})]}),e.jsxs(m,{icon:H,title:"MCP Servers",to:"/mcp-servers",status:L,children:[e.jsx(s,{label:"Tools loaded",value:l?.totalTools??"—",highlight:!!l?.totalTools}),e.jsx(s,{label:"Servers",value:l?.servers?.length??"—"}),l?.lastLoadedAt&&e.jsx(s,{label:"Last loaded",value:new Date(l.lastLoadedAt).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})})]}),e.jsxs(m,{icon:q,title:"Smiths",to:"/smiths",status:_,children:[e.jsx(s,{label:"Online",value:o?`${o.online} / ${o.total}`:"—",highlight:(o?.online??0)>0}),e.jsx(s,{label:"System",value:o?.enabled?"enabled":"disabled"})]}),e.jsxs(m,{icon:X,title:"Tasks",to:"/tasks",status:I,children:[e.jsx(s,{label:"Running",value:a?.running??"—",highlight:!!a?.running}),e.jsx(s,{label:"Pending",value:a?.pending??"—"}),e.jsx(s,{label:"Completed",value:a?.completed??"—"}),(a?.failed??0)>0&&e.jsx(s,{label:"Failed",value:a.failed})]}),e.jsxs(m,{icon:j,title:"Chronos",to:"/chronos",status:D,children:[e.jsx(s,{label:"Active jobs",value:u.length,highlight:u.length>0}),e.jsx(s,{label:"Total jobs",value:h.length}),N&&e.jsx(s,{label:"Next run",value:`in ${N}`})]})]})]}),p.length>0&&e.jsxs(d.div,{variants:c,children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-azure-text-secondary dark:text-matrix-tertiary",children:"Recent Tasks"}),e.jsxs(C,{to:"/tasks",className:"flex items-center gap-0.5 text-xs text-azure-primary dark:text-matrix-highlight hover:underline",children:["View all ",e.jsx(S,{className:"w-3 h-3"})]})]}),e.jsx("div",{className:"rounded-lg border border-azure-border dark:border-matrix-primary overflow-hidden",children:p.map((t,b)=>e.jsxs("div",{className:`flex items-center gap-3 px-4 py-2.5 ${b<p.length-1?"border-b border-azure-border dark:border-matrix-primary/30":""} hover:bg-azure-surface/60 dark:hover:bg-zinc-900/50 transition-colors`,children:[e.jsx(te,{status:t.status}),e.jsx("span",{className:"font-mono text-[10px] text-azure-text-secondary dark:text-matrix-tertiary w-16 shrink-0",children:t.id.slice(0,8)}),e.jsx("span",{className:"flex-1 text-xs text-azure-text dark:text-matrix-secondary truncate",children:t.input.slice(0,100)}),e.jsx("span",{className:"text-[10px] font-mono uppercase text-azure-text-secondary dark:text-matrix-tertiary shrink-0",children:t.agent}),e.jsx("span",{className:"text-[10px] text-azure-text-secondary dark:text-matrix-tertiary shrink-0",children:new Date(t.created_at).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})})]},t.id))})]})]})}export{xe as Dashboard};
|
package/dist/ui/assets/{DeleteConfirmationModal-Cz1jfXgq.js → DeleteConfirmationModal-CqNXT_YQ.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import"./vendor-react-DikRIOlj.js";import{B as d}from"./index-
|
|
1
|
+
import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import"./vendor-react-DikRIOlj.js";import{B as d}from"./index-BxN2w9sY.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};
|
|
@@ -0,0 +1,7 @@
|
|
|
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-BxN2w9sY.js";import{C as M}from"./ConfirmationModal-DxUHZgTy.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:`
|
|
2
|
+
inline-flex items-center px-4 py-2 border border-matrix-primary dark:border-gray-600
|
|
3
|
+
rounded-md text-sm font-medium
|
|
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"}
|
|
5
|
+
transition-colors
|
|
6
|
+
${a?"opacity-50 cursor-not-allowed":"cursor-pointer"}
|
|
7
|
+
`,children:a?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),m]}):e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"mr-2 h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"})}),"Upload Document"]})}),l&&!f&&e.jsx("div",{className:"w-full h-1.5 bg-gray-200 dark:bg-zinc-700 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-azure-primary dark:bg-matrix-highlight rounded-full transition-all duration-300",style:{width:`${i}%`}})})]})}function Z(){const{documents:t,stats:a,isLoading:i,mutate:r}=U(),[s,u]=o.useState(!1),[j,g]=o.useState(null),[p,y]=o.useState(!1),[b,l]=o.useState(null),[f,m]=o.useState(null),[d,c]=o.useState(!1),[v,z]=o.useState(!1),[N,w]=o.useState(null),k=t.some(n=>n.status==="pending"||n.status==="indexing");o.useEffect(()=>{if(!(!d&&!k)&&(k||d)){const n=setInterval(()=>{r()},2e3);return!k&&d&&c(!1),()=>clearInterval(n)}},[k,d,r]);const D=o.useCallback(async n=>{u(!0),g(0),l(null),m(null);try{const x=await _(n,L=>{g(L)});m(`Uploaded "${x.filename}" - indexed ${x.indexed} document(s)`),c(!0),await r()}catch(x){l(x.message||"Failed to upload document")}finally{u(!1),g(null)}},[r]),C=async()=>{if(N){l(null);try{await B(N.id),m("Document deleted"),await r()}catch(n){l(n.message||"Failed to delete document")}finally{w(null)}}},S=(n,x)=>{w({id:n,filename:x}),z(!0)},$=async n=>{l(null);try{await A(n),m("Document reindexed"),c(!0),await r()}catch(x){l(x.message||"Failed to reindex document")}},F=async()=>{y(!0),l(null);try{const n=await E();m(`Scan complete: ${n.indexed} indexed, ${n.removed} removed`),await r()}catch(n){l(n.message||"Failed to scan")}finally{y(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{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(O,{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:"Documents"}),e.jsx("p",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary mt-0.5",children:"Manage your document library for Link agent"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:F,disabled:p,className:"flex items-center gap-2 px-4 py-2 rounded-lg border border-azure-primary/20 dark:border-matrix-highlight/30 text-azure-text-secondary dark:text-matrix-secondary text-sm font-medium hover:opacity-90 transition-opacity disabled:opacity-50",children:[e.jsx(R,{className:`w-4 h-4 ${p?"animate-spin":""}`}),p?"Scanning...":"Scan Now"]}),e.jsx(H,{onUpload:D,isUploading:s,uploadProgress:j})]})]}),b&&e.jsx("div",{className:"p-3 bg-red-500/10 border border-red-500/30 rounded-md text-red-500 text-sm",children:b}),f&&e.jsx("div",{className:"p-3 bg-green-500/10 border border-green-500/30 rounded-md text-green-500 text-sm",children:f}),a&&e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"p-4 bg-azure-primary/5 dark:bg-matrix-highlight/5 border border-azure-primary/20 dark:border-matrix-highlight/30 rounded-lg",children:[e.jsx("div",{className:"text-2xl font-bold text-azure-text dark:text-matrix-highlight",children:a.documents_total}),e.jsx("div",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Total Documents"})]}),e.jsxs("div",{className:"p-4 bg-azure-primary/5 dark:bg-matrix-highlight/5 border border-azure-primary/20 dark:border-matrix-highlight/30 rounded-lg",children:[e.jsx("div",{className:"text-2xl font-bold text-green-600 dark:text-green-400",children:a.documents_indexed}),e.jsx("div",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Indexed"})]}),e.jsxs("div",{className:"p-4 bg-azure-primary/5 dark:bg-matrix-highlight/5 border border-azure-primary/20 dark:border-matrix-highlight/30 rounded-lg",children:[e.jsx("div",{className:"text-2xl font-bold text-azure-text dark:text-matrix-highlight",children:a.chunks_total}),e.jsx("div",{className:"text-sm text-azure-text-secondary dark:text-matrix-tertiary",children:"Total Chunks"})]})]}),e.jsx(q,{documents:t,onDelete:S,onReindex:$,isLoading:i}),e.jsx(M,{isOpen:v,onClose:()=>{z(!1),w(null)},onConfirm:C,title:"Delete Document",description:`Are you sure you want to delete "${N?.filename}"? This action cannot be undone and the document will be removed from the index.`,confirmJson:"Delete",variant:"destructive"}),e.jsx("p",{className:"text-xs text-azure-text-secondary dark:text-matrix-tertiary",children:"Supported formats: PDF, TXT, Markdown, DOCX. Documents are stored in ~/.morpheus/docs. Ask Oracle questions about your documents using natural language."})]})}export{Z as Documents};
|
|
@@ -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-
|
|
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-BxN2w9sY.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 +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-JmpcV6nl.js";import{D as q,d as H,e as U,j as _}from"./index-BiMscUrn.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 J,s as L,a as Z,l as R,u as ee}from"./vendor-utils-D4NnWbOU.js";import{m as k}from"./mcp-BE_OVkBe.js";import{D as q,d as H,e as U,j as _}from"./index-BxN2w9sY.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 +1 @@
|
|
|
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-BiMscUrn.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
|
+
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-BxN2w9sY.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 +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-D4NnWbOU.js";import{w as y,D as _,e as D,j as R}from"./index-
|
|
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-D4NnWbOU.js";import{w as y,D as _,e as D,j as R}from"./index-BxN2w9sY.js";import{P as O}from"./Pagination-BHZKk42X.js";import{B as k,a8 as A,a9 as F,aa as B,_ as L,p as W,q as E,g as J}from"./vendor-icons-NHF9HNeN.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}},X=()=>{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{X as Notifications};
|
|
@@ -1 +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-BiMscUrn.js";import{M as de,D as oe}from"./DeleteConfirmationModal-Cz1jfXgq.js";import{V as xe,Y as me,Z as H,g as ue,_ as O,$ as he,a0 as ge,A as pe,z as B,a1 as fe}from"./vendor-icons-NHF9HNeN.js";import{P as je}from"./Pagination-BHZKk42X.js";import"./vendor-utils-D4NnWbOU.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),[$,Y]=i.useState(1),[P,b]=i.useState(null),[Z,w]=i.useState(!1),[G,J]=i.useState(null),[K,_]=i.useState(!1),[E,L]=i.useState(null),[Q,C]=i.useState(!1),{get:W,del:X,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 W(`/sati/memories?${p}`);a(k.data??k),q(k.total??0),Y(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 X(`/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=>{J(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:K,onClose:()=>_(!1),memory:G}),e.jsx(oe,{isOpen:Q,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
|
+
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-BxN2w9sY.js";import{M as de,D as oe}from"./DeleteConfirmationModal-CqNXT_YQ.js";import{V as xe,Y as me,Z as H,g as ue,_ as O,$ as he,a0 as ge,A as pe,z as B,a1 as fe}from"./vendor-icons-NHF9HNeN.js";import{P as je}from"./Pagination-BHZKk42X.js";import"./vendor-utils-D4NnWbOU.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),[$,Y]=i.useState(1),[P,b]=i.useState(null),[Z,w]=i.useState(!1),[G,J]=i.useState(null),[K,_]=i.useState(!1),[E,L]=i.useState(null),[Q,C]=i.useState(!1),{get:W,del:X,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 W(`/sati/memories?${p}`);a(k.data??k),q(k.total??0),Y(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 X(`/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=>{J(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:K,onClose:()=>_(!1),memory:G}),e.jsx(oe,{isOpen:Q,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};
|