morpheus-cli 0.9.20 → 0.9.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/channels/discord.js +5 -0
  2. package/dist/channels/telegram.js +5 -0
  3. package/dist/http/api.js +3 -0
  4. package/dist/http/middleware/auth.js +2 -1
  5. package/dist/http/routers/display.js +38 -0
  6. package/dist/runtime/audit/repository.js +69 -1
  7. package/dist/runtime/chronos/worker.js +2 -0
  8. package/dist/runtime/display.js +49 -2
  9. package/dist/runtime/memory/sati/service.js +5 -0
  10. package/dist/runtime/oracle.js +5 -0
  11. package/dist/runtime/providers/factory.js +14 -2
  12. package/dist/runtime/smiths/delegator.js +3 -0
  13. package/dist/runtime/subagents/devkit-instrument.js +5 -0
  14. package/dist/runtime/subagents/link/link.js +120 -77
  15. package/dist/runtime/subagents/trinity/trinity.js +64 -34
  16. package/dist/runtime/tools/factory.js +6 -2
  17. package/dist/ui/assets/{AuditDashboard-Cu33zb_7.js → AuditDashboard-ClqEr7jg.js} +1 -1
  18. package/dist/ui/assets/{Chat-mt1j5V55.js → Chat-BwxZJphx.js} +7 -7
  19. package/dist/ui/assets/{Chronos-Bq_h41cw.js → Chronos-BafOMteb.js} +1 -1
  20. package/dist/ui/assets/{ConfirmationModal-CxLP8iC6.js → ConfirmationModal-DU0AwhXD.js} +1 -1
  21. package/dist/ui/assets/Dashboard-DvJb72Xe.js +4120 -0
  22. package/dist/ui/assets/{DeleteConfirmationModal-kZ_c3sFk.js → DeleteConfirmationModal-FSWLK6-I.js} +1 -1
  23. package/dist/ui/assets/{Documents-nlQNoUcq.js → Documents-D73CeGkW.js} +1 -1
  24. package/dist/ui/assets/{Logs-C1tlg574.js → Logs-BrFWnLIL.js} +1 -1
  25. package/dist/ui/assets/{MCPManager-Do7isizG.js → MCPManager-_L2Yo-uY.js} +1 -1
  26. package/dist/ui/assets/{ModelPricing-BeJ7oXBA.js → ModelPricing-CyXMdxJD.js} +1 -1
  27. package/dist/ui/assets/Notifications-BpHokTLS.js +1 -0
  28. package/dist/ui/assets/{Pagination-BHZKk42X.js → Pagination-D4ShqUKO.js} +1 -1
  29. package/dist/ui/assets/SatiMemories-CfSTgr9V.js +1 -0
  30. package/dist/ui/assets/{SelectInput-KVLsnfra.js → SelectInput-BPDcd3y7.js} +1 -1
  31. package/dist/ui/assets/{SessionAudit-Da1ySlYg.js → SessionAudit-pOWRgJtc.js} +1 -1
  32. package/dist/ui/assets/{Settings-DpXwpEhO.js → Settings-CPDXAk18.js} +1 -1
  33. package/dist/ui/assets/Skills-GIkCxMS3.js +7 -0
  34. package/dist/ui/assets/{Smiths-DA-x4KFT.js → Smiths-ZcHXcrMt.js} +1 -1
  35. package/dist/ui/assets/{Switch-CJTE4ZQm.js → Switch-C7TxLq0E.js} +1 -1
  36. package/dist/ui/assets/Tasks-DJ6R3d4f.js +1 -0
  37. package/dist/ui/assets/{TrinityDatabases-CoKzKTL-.js → TrinityDatabases-CnRAkDuu.js} +1 -1
  38. package/dist/ui/assets/{UsageStats-cds352Pj.js → UsageStats-Bl7bs4ay.js} +1 -1
  39. package/dist/ui/assets/{WebhookManager-DdAdHQUk.js → WebhookManager-CEjjk4tx.js} +2 -2
  40. package/dist/ui/assets/{agents-B1z_dlQC.js → agents-DO69pNM1.js} +1 -1
  41. package/dist/ui/assets/{audit-BAhaGrKY.js → audit-CP5fC4m8.js} +1 -1
  42. package/dist/ui/assets/{chronos-DGD_Md9M.js → chronos-DPhK718h.js} +1 -1
  43. package/dist/ui/assets/{config-BwTXe5M2.js → config-OLGQFNJL.js} +1 -1
  44. package/dist/ui/assets/{index-BcX5O7kY.js → index-B9ePr-vB.js} +3 -3
  45. package/dist/ui/assets/index-D_0tPLCk.css +1 -0
  46. package/dist/ui/assets/{mcp-BlkruPaA.js → mcp-BeBznKtK.js} +1 -1
  47. package/dist/ui/assets/{skills-CtCb-52u.js → skills-wEUxSGB3.js} +1 -1
  48. package/dist/ui/assets/{stats-BiPI2kaw.js → stats-KMbKDMJ-.js} +1 -1
  49. package/dist/ui/assets/{useCurrency-BCdG-pHx.js → useCurrency-Bgg-7MTE.js} +1 -1
  50. package/dist/ui/assets/vendor-icons-DE7PWdkN.js +1 -0
  51. package/dist/ui/assets/vendor-utils-BIYveU_1.js +39 -0
  52. package/dist/ui/index.html +4 -4
  53. package/dist/ui/sw.js +1 -1
  54. package/package.json +1 -1
  55. package/dist/ui/assets/Dashboard-D0LAlHtG.js +0 -1
  56. package/dist/ui/assets/Notifications-Cg5CMlY0.js +0 -1
  57. package/dist/ui/assets/SatiMemories-D9l6s8Pc.js +0 -1
  58. package/dist/ui/assets/Skills-DaqCY8QH.js +0 -7
  59. package/dist/ui/assets/Tasks-DU49M9U-.js +0 -1
  60. package/dist/ui/assets/index-Cjli-AD7.css +0 -1
  61. package/dist/ui/assets/vendor-icons-NHF9HNeN.js +0 -1
  62. package/dist/ui/assets/vendor-utils-D4NnWbOU.js +0 -39
@@ -1,10 +1,10 @@
1
- import{j as e,A as U,m as q}from"./vendor-motion-C3CZ8ZlO.js";import{c as Y,r as o}from"./vendor-react-DikRIOlj.js";import{s as Z,t as B,u as ee,v as re,X as G,w as te,x as ae,y as se,z as ne,E as ie,q as H,G as X,r as V,I as J,m as oe,M as le,J as F,e as de,g as ce,K as xe,U as me,N as he}from"./vendor-icons-NHF9HNeN.js";import{h as pe,g as ge,i as ue,c as D}from"./index-BcX5O7kY.js";import{u as Q}from"./agents-B1z_dlQC.js";import{M as be,r as ye}from"./vendor-markdown-BN_Np5Ta.js";import{C as fe}from"./ConfirmationModal-CxLP8iC6.js";import"./vendor-utils-D4NnWbOU.js";function ke(r){const i=Date.now()-r;return i<6e4?"just now":i<36e5?`${Math.floor(i/6e4)}m ago`:i<864e5?`${Math.floor(i/36e5)}h ago`:i<6048e5?`${Math.floor(i/864e5)}d ago`:new Date(r).toLocaleDateString()}const je=({sessions:r,activeSessionId:i,onSelectSession:n,onCreateSession:c,onArchiveSession:p,onDeleteSession:x,onRenameSession:m,isOpen:u,toggleSidebar:g})=>{const k=Y(),[h,w]=o.useState(null),[C,f]=o.useState(""),M=o.useRef(null);o.useEffect(()=>{h&&M.current&&M.current.focus()},[h]);const z=(l,E)=>{l.stopPropagation(),w(E.id),f(E.title||"Untitled Session")},I=l=>{l?.stopPropagation(),h&&C.trim()&&(m(h,C.trim()),w(null))},_=l=>{l?.stopPropagation(),w(null)},A=l=>{l.key==="Enter"?I():l.key==="Escape"&&_()};return u?e.jsxs("div",{className:"w-72 bg-white dark:bg-black border-r border-gray-300 dark:border-matrix-primary flex flex-col h-full shrink-0 transition-colors duration-300",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-300 dark:border-matrix-primary shrink-0",children:[e.jsx("span",{className:"text-sm font-semibold text-gray-800 dark:text-matrix-highlight",children:"Sessions"}),e.jsx("button",{onClick:g,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-matrix-primary/20 text-gray-400 dark:text-matrix-secondary/60 transition-colors",title:"Collapse sidebar",children:e.jsx(ee,{size:16})})]}),e.jsx("div",{className:"px-3 py-2.5 shrink-0",children:e.jsxs("button",{onClick:c,className:"w-full flex items-center justify-center gap-2 bg-azure-primary text-white dark:bg-matrix-highlight dark:text-black py-2 px-4 rounded-xl hover:bg-azure-secondary dark:hover:bg-matrix-secondary transition-colors text-sm font-medium shadow-sm",children:[e.jsx(B,{size:16}),"New Chat"]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-2 pb-3 space-y-0.5",children:[r.length===0&&e.jsx("div",{className:"text-center text-gray-400 dark:text-matrix-secondary/40 mt-12 text-sm px-4",children:"No sessions yet. Start a new chat!"}),r.map(l=>{const E=i===l.id,j=h===l.id;return e.jsxs("div",{onClick:()=>!j&&n(l.id),className:`
1
+ import{j as e,A as U,m as G}from"./vendor-motion-C3CZ8ZlO.js";import{c as Y,r as o}from"./vendor-react-DikRIOlj.js";import{u as Z,v as B,w as ee,x as re,X as q,y as te,z as ae,E as se,G as ne,I as ie,s as H,J as X,t as Q,K as J,o as oe,M as le,N as F,e as de,g as ce,O as xe,U as me,Q as he}from"./vendor-icons-DE7PWdkN.js";import{h as pe,g as ge,i as ue,a as D}from"./index-B9ePr-vB.js";import{u as V}from"./agents-DO69pNM1.js";import{M as be,r as ye}from"./vendor-markdown-BN_Np5Ta.js";import{C as fe}from"./ConfirmationModal-DU0AwhXD.js";import"./vendor-utils-BIYveU_1.js";function ke(r){const i=Date.now()-r;return i<6e4?"just now":i<36e5?`${Math.floor(i/6e4)}m ago`:i<864e5?`${Math.floor(i/36e5)}h ago`:i<6048e5?`${Math.floor(i/864e5)}d ago`:new Date(r).toLocaleDateString()}const je=({sessions:r,activeSessionId:i,onSelectSession:n,onCreateSession:c,onArchiveSession:p,onDeleteSession:x,onRenameSession:m,isOpen:u,toggleSidebar:g})=>{const k=Y(),[h,w]=o.useState(null),[C,f]=o.useState(""),M=o.useRef(null);o.useEffect(()=>{h&&M.current&&M.current.focus()},[h]);const z=(l,E)=>{l.stopPropagation(),w(E.id),f(E.title||"Untitled Session")},I=l=>{l?.stopPropagation(),h&&C.trim()&&(m(h,C.trim()),w(null))},O=l=>{l?.stopPropagation(),w(null)},A=l=>{l.key==="Enter"?I():l.key==="Escape"&&O()};return u?e.jsxs("div",{className:"w-72 bg-white dark:bg-black border-r border-gray-300 dark:border-matrix-primary flex flex-col h-full shrink-0 transition-colors duration-300",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-300 dark:border-matrix-primary shrink-0",children:[e.jsx("span",{className:"text-sm font-semibold text-gray-800 dark:text-matrix-highlight",children:"Sessions"}),e.jsx("button",{onClick:g,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-matrix-primary/20 text-gray-400 dark:text-matrix-secondary/60 transition-colors",title:"Collapse sidebar",children:e.jsx(ee,{size:16})})]}),e.jsx("div",{className:"px-3 py-2.5 shrink-0",children:e.jsxs("button",{onClick:c,className:"w-full flex items-center justify-center gap-2 bg-azure-primary text-white dark:bg-matrix-highlight dark:text-black py-2 px-4 rounded-xl hover:bg-azure-secondary dark:hover:bg-matrix-secondary transition-colors text-sm font-medium shadow-sm",children:[e.jsx(B,{size:16}),"New Chat"]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-2 pb-3 space-y-0.5",children:[r.length===0&&e.jsx("div",{className:"text-center text-gray-400 dark:text-matrix-secondary/40 mt-12 text-sm px-4",children:"No sessions yet. Start a new chat!"}),r.map(l=>{const E=i===l.id,j=h===l.id;return e.jsxs("div",{onClick:()=>!j&&n(l.id),className:`
2
2
  group relative flex items-center gap-2 px-3 py-2.5 rounded-xl cursor-pointer transition-all
3
3
  ${E?"bg-azure-primary/10 dark:bg-matrix-primary/15 text-azure-primary dark:text-matrix-highlight":"hover:bg-gray-100 dark:hover:bg-matrix-primary/10 text-gray-700 dark:text-matrix-secondary"}
4
- `,children:[e.jsx("div",{className:"flex-1 min-w-0",children:j?e.jsx("div",{onClick:N=>N.stopPropagation(),children:e.jsx("input",{ref:M,type:"text",value:C,onChange:N=>f(N.target.value),onKeyDown:A,className:"w-full text-sm px-1.5 py-0.5 bg-white dark:bg-black border border-azure-primary dark:border-matrix-highlight rounded-lg focus:outline-none dark:text-matrix-highlight"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-sm font-medium truncate leading-snug",children:l.title||"Untitled Session"}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-matrix-secondary/50 mt-0.5",children:ke(l.last_message_at??l.started_at)})]})}),e.jsx("div",{className:`flex items-center gap-0.5 shrink-0 transition-opacity ${E||j?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:N=>N.stopPropagation(),children:j?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:I,className:"p-1.5 rounded-lg text-emerald-600 hover:bg-emerald-50 dark:text-emerald-400 dark:hover:bg-emerald-900/20 transition-colors",title:"Save",children:e.jsx(re,{size:13})}),e.jsx("button",{onClick:_,className:"p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20 transition-colors",title:"Cancel",children:e.jsx(G,{size:13})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:N=>z(N,l),className:"p-1.5 rounded-lg text-gray-400 hover:text-blue-500 hover:bg-blue-50 dark:text-matrix-secondary/50 dark:hover:text-blue-400 dark:hover:bg-blue-900/20 transition-colors",title:"Rename",children:e.jsx(te,{size:13})}),e.jsx("button",{onClick:()=>k(`/sessions/${l.id}/audit`),className:"p-1.5 rounded-lg text-gray-400 hover:text-violet-500 hover:bg-violet-50 dark:text-matrix-secondary/50 dark:hover:text-violet-400 dark:hover:bg-violet-900/20 transition-colors",title:"Audit",children:e.jsx(ae,{size:13})}),e.jsx("button",{onClick:()=>p(l.id),className:"p-1.5 rounded-lg text-gray-400 hover:text-amber-500 hover:bg-amber-50 dark:text-matrix-secondary/50 dark:hover:text-amber-400 dark:hover:bg-amber-900/20 transition-colors",title:"Archive",children:e.jsx(se,{size:13})}),e.jsx("button",{onClick:()=>x(l.id),className:"p-1.5 rounded-lg text-gray-400 hover:text-red-500 hover:bg-red-50 dark:text-matrix-secondary/50 dark:hover:text-red-400 dark:hover:bg-red-900/20 transition-colors",title:"Delete",children:e.jsx(ne,{size:13})})]})})]},l.id)})]})]}):e.jsxs("div",{className:"w-14 bg-white dark:bg-black border-r border-gray-300 dark:border-matrix-primary flex flex-col items-center py-3 gap-3 shrink-0 transition-colors duration-300",children:[e.jsx("button",{onClick:g,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-matrix-primary/20 text-gray-400 dark:text-matrix-secondary/60 transition-colors",title:"Expand sidebar",children:e.jsx(Z,{size:18})}),e.jsx("div",{className:"w-8 h-px bg-gray-200 dark:bg-matrix-primary/20"}),e.jsx("button",{onClick:c,className:"p-2.5 bg-azure-primary text-white dark:bg-matrix-highlight dark:text-black rounded-xl hover:bg-azure-secondary dark:hover:bg-matrix-secondary shadow-sm transition-colors",title:"New chat",children:e.jsx(B,{size:18})})]})};function W(r){if(r==null)return"";if(typeof r=="string")try{return JSON.stringify(JSON.parse(r),null,2)}catch{return r}try{return JSON.stringify(r,null,2)}catch{return String(r)}}const ve=({group:r})=>{const[i,n]=o.useState(!1),c=r.result!==null,p=r.result?.content??"",x=p.startsWith("Error")||p.startsWith("❌");return e.jsxs("div",{className:"rounded-lg border border-gray-300 dark:border-matrix-primary/70 bg-white dark:bg-black overflow-hidden text-sm mb-1",children:[e.jsxs("button",{onClick:()=>n(!i),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left hover:bg-gray-50 dark:hover:bg-zinc-900/60 transition-colors",children:[e.jsx(ie,{size:12,className:"text-amber-500 dark:text-amber-400/80 flex-shrink-0"}),e.jsx("span",{className:"flex-1 font-mono text-xs text-gray-600 dark:text-matrix-secondary/80 truncate",children:r.call.name}),c?x?e.jsx(H,{size:12,className:"text-red-500 dark:text-red-400 flex-shrink-0"}):e.jsx(X,{size:12,className:"text-emerald-500 dark:text-emerald-400 flex-shrink-0"}):e.jsx(V,{size:12,className:"text-gray-400 animate-spin flex-shrink-0"}),e.jsx(J,{size:12,className:`text-gray-400 dark:text-matrix-secondary/40 flex-shrink-0 transition-transform duration-200 ${i?"rotate-180":""}`})]}),e.jsx(U,{initial:!1,children:i&&e.jsx(q.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15,ease:"easeInOut"},className:"overflow-hidden",children:e.jsxs("div",{className:"px-3 pb-2.5 pt-1 border-t border-gray-100 dark:border-matrix-primary/20 space-y-2",children:[Object.keys(r.call.args??{}).length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/40 uppercase tracking-wider mb-1",children:"args"}),e.jsx("pre",{className:"text-xs font-mono text-gray-600 dark:text-matrix-secondary/80 whitespace-pre-wrap break-all bg-gray-50 dark:bg-zinc-900 rounded-md p-2 border border-gray-100 dark:border-matrix-primary/20 max-h-36 overflow-y-auto",children:W(r.call.args)})]}),c&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/40 uppercase tracking-wider mb-1",children:"result"}),e.jsx("pre",{className:"text-xs font-mono text-gray-600 dark:text-matrix-secondary/80 whitespace-pre-wrap break-all bg-gray-50 dark:bg-zinc-900 rounded-md p-2 border border-gray-100 dark:border-matrix-primary/20 max-h-44 overflow-y-auto",children:W(p)})]})]})})})]})};function P(r){return r?.task??r?.prompt??""}function we(r){if(typeof r!="string")return String(r);try{return JSON.stringify(JSON.parse(r),null,2)}catch{return r}}const Ne=({group:r})=>{const[i,n]=o.useState(!1),{getByToolName:c}=Q(),p=c(r.call.name),x={label:p.label,emoji:p.emoji,colorClass:p.colorClass,bgClass:p.bgClass},m=r.result!==null,u=r.result?.content??"",g=u.startsWith("❌")||u.toLowerCase().startsWith("error"),k=P(r.call.args).slice(0,100),h=r.call.args?.smith??null;return e.jsxs("div",{className:`rounded-lg border border-gray-300 dark:border-matrix-primary/70 overflow-hidden text-sm mb-1 ${x.bgClass}`,children:[e.jsxs("button",{onClick:()=>n(!i),className:"w-full flex items-center gap-2.5 px-3 py-2 text-left hover:brightness-95 dark:hover:brightness-110 transition-all",children:[e.jsx("span",{className:"text-base flex-shrink-0 leading-none",children:x.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:`text-xs font-semibold ${x.colorClass}`,children:[x.label,h?` · ${h}`:""]}),k&&e.jsx("div",{className:"text-xs text-gray-500 dark:text-matrix-secondary/60 truncate mt-0.5",children:k})]}),m?g?e.jsx(H,{size:14,className:"text-red-500 dark:text-red-400 flex-shrink-0"}):e.jsx(X,{size:14,className:"text-emerald-500 dark:text-emerald-400 flex-shrink-0"}):e.jsx(V,{size:14,className:"text-gray-400 animate-spin flex-shrink-0"}),e.jsx(J,{size:13,className:`text-gray-400 dark:text-matrix-secondary/40 flex-shrink-0 transition-transform duration-200 ${i?"rotate-180":""}`})]}),e.jsx(U,{initial:!1,children:i&&e.jsx(q.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.18,ease:"easeInOut"},className:"overflow-hidden",children:e.jsxs("div",{className:"px-3 pb-2.5 pt-1 border-t border-gray-200 dark:border-matrix-primary/20 space-y-2",children:[P(r.call.args)&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/40 uppercase tracking-wider mb-1",children:"task"}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-matrix-secondary/80 bg-white dark:bg-black rounded-md p-2 border border-gray-100 dark:border-matrix-primary/20 whitespace-pre-wrap",children:P(r.call.args)})]}),m&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/40 uppercase tracking-wider mb-1",children:"result"}),e.jsx("pre",{className:"text-xs font-mono text-gray-600 dark:text-matrix-secondary/80 whitespace-pre-wrap break-all bg-white dark:bg-black rounded-md p-2 border border-gray-100 dark:border-matrix-primary/20 max-h-56 overflow-y-auto",children:we(u)})]})]})})})]})};function Se(r){return r==null||r===0?null:r<1e3?`${r}ms`:`${(r/1e3).toFixed(1)}s`}function L(r){return r>=1e3?`${(r/1e3).toFixed(1)}k`:String(r)}const ze=({message:r})=>{const i=r.usage_metadata,n=i?.input_tokens??i?.prompt_tokens??0,c=i?.output_tokens??i?.completion_tokens??0,p=n>0||c>0,x=Se(r.duration_ms),m=r.model,u=r.sati_memories_count??null;if(!p&&!x&&!m&&u==null)return null;const g=m?(m.includes(":")?m.split(":").pop():m)?.split("-").slice(0,4).join("-")??m:null;return e.jsxs("div",{className:"mt-2 pt-1.5 border-t border-gray-100 dark:border-matrix-primary/20 flex flex-wrap items-center gap-x-3 gap-y-0.5",children:[g&&e.jsx("span",{className:"text-[11px] font-mono text-gray-400 dark:text-matrix-secondary/40 truncate max-w-[180px]",title:m??"",children:g}),p&&e.jsxs("span",{className:"text-[11px] font-mono text-gray-400 dark:text-matrix-secondary/40",children:["↑",L(n)," ↓",L(c)]}),x&&e.jsx("span",{className:"text-[11px] font-mono text-gray-400 dark:text-matrix-secondary/40",children:x}),u!=null&&u>0&&e.jsxs("span",{className:"flex items-center gap-1 text-[11px] font-mono text-purple-400 dark:text-purple-400/70",children:[e.jsx(oe,{size:10}),u]})]})},K={amber:"bg-amber-100 text-amber-800 border-amber-300 dark:bg-amber-900/30 dark:text-amber-300 dark:border-amber-700/60",purple:"bg-purple-100 text-purple-800 border-purple-300 dark:bg-purple-900/30 dark:text-purple-300 dark:border-purple-700/60",violet:"bg-violet-100 text-violet-800 border-violet-300 dark:bg-violet-900/30 dark:text-violet-300 dark:border-violet-700/60",teal:"bg-teal-100 text-teal-800 border-teal-300 dark:bg-teal-900/30 dark:text-teal-300 dark:border-teal-700/60",gray:"bg-zinc-100 text-zinc-700 border-zinc-300 dark:bg-zinc-800 dark:text-zinc-300 dark:border-zinc-600",indigo:"bg-indigo-100 text-indigo-800 border-indigo-300 dark:bg-indigo-900/30 dark:text-indigo-300 dark:border-indigo-700/60"};function Ce(r){const i=r.replace(/^```json\s*/i,"").replace(/\s*```$/,"");try{return JSON.stringify(JSON.parse(i),null,2)}catch{return i}}function Ee(r){return r.session_id?.startsWith("sati-evaluation-")===!0||r.tool_name?.toLowerCase().includes("sati")===!0}const Me=({message:r})=>{const[i,n]=o.useState(!1),c=Ee(r),p=c?r.tool_name==="sati_evaluation_output"?"Sati · memory update":"Sati · analysis":r.tool_name??"tool result";return e.jsxs("details",{open:i,onToggle:x=>n(x.target.open),className:"w-full",children:[e.jsxs("summary",{className:"list-none cursor-pointer select-none flex items-center gap-2 text-xs text-gray-400 dark:text-matrix-secondary/40 hover:text-gray-500 dark:hover:text-matrix-secondary/60 transition-colors py-0.5",children:[e.jsx("div",{className:"flex-1 h-px bg-gray-200 dark:bg-matrix-primary/20"}),e.jsxs("span",{className:"flex items-center gap-1.5 whitespace-nowrap px-2",children:[e.jsx("span",{children:c?"🧠":"🔧"}),e.jsx("span",{children:p}),e.jsx(J,{size:11,className:`transition-transform duration-200 ${i?"rotate-180":""}`})]}),e.jsx("div",{className:"flex-1 h-px bg-gray-200 dark:bg-matrix-primary/20"})]}),i&&e.jsx("pre",{className:"mt-2 px-3 py-2.5 whitespace-pre-wrap break-all text-xs font-mono text-gray-600 dark:text-matrix-secondary/80 border border-gray-300 dark:border-matrix-primary/60 rounded-lg bg-gray-50 dark:bg-zinc-900 max-h-48 overflow-y-auto",children:Ce(r.content)})]})},Ae={table:({children:r})=>e.jsx("div",{className:"my-2 overflow-x-auto rounded-lg border border-gray-200 dark:border-matrix-primary/60",children:e.jsx("table",{className:"min-w-full text-xs border-collapse",children:r})}),thead:({children:r})=>e.jsx("thead",{className:"bg-gray-100 dark:bg-zinc-900 text-gray-600 dark:text-matrix-secondary/70",children:r}),tbody:({children:r})=>e.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-matrix-primary/20",children:r}),tr:({children:r})=>e.jsx("tr",{className:"hover:bg-gray-50 dark:hover:bg-zinc-900/60 transition-colors",children:r}),th:({children:r})=>e.jsx("th",{className:"px-3 py-2 text-left font-semibold whitespace-nowrap border-b border-gray-200 dark:border-matrix-primary/40",children:r}),td:({children:r})=>e.jsx("td",{className:"px-3 py-2 text-gray-700 dark:text-matrix-secondary align-top",children:r})},De=({messages:r,onSendMessage:i,isLoading:n,activeSessionId:c,activeSession:p,onToggleSidebar:x})=>{const[m,u]=o.useState(""),[g,k]=o.useState([]),[h,w]=o.useState(null),[C,f]=o.useState(0),[M,z]=o.useState([]),{getSubagents:I}=Q(),_=o.useRef(null),A=o.useRef(null);o.useEffect(()=>{_.current?.scrollIntoView({behavior:"smooth"})},[r,n]),o.useEffect(()=>{const t=A.current;t&&(t.style.height="auto",t.style.height=t.scrollHeight+"px")},[m]),o.useEffect(()=>{pe.get("/smiths").then(t=>z(t.smiths.map(a=>({name:a.name,emoji:"🕶️",description:"Remote Smith agent",color:"gray"})))).catch(()=>{})},[]);const l=I().map(t=>({name:t.auditAgent,emoji:t.emoji,description:t.description,color:t.color})),E=[...l,...M.filter(t=>!l.some(a=>a.name===t.name))],j=h?E.filter(t=>t.name.toLowerCase().startsWith(h.query.toLowerCase())):[],N=t=>{if(!h)return;const a=m.slice(0,h.startIdx),y=m.slice(h.startIdx+1+h.query.length),O=(a+y).replace(/ +/g," ").trim();u(O),k(S=>S.includes(t)?S:[...S,t]),w(null),f(0),setTimeout(()=>A.current?.focus(),0)},R=t=>{k(a=>a.filter(y=>y!==t))},s=t=>{const a=t.target.value;u(a);const y=t.target.selectionStart??a.length,S=a.slice(0,y).match(/@(\w*)$/);S?(w({query:S[1],startIdx:y-S[0].length}),f(0)):w(null)},d=()=>{if(!(m.trim()||g.length>0)||n)return;const a=[...g.map(y=>`@${y}`),m.trim()].filter(Boolean);i(a.join(" ")),u(""),k([]),w(null),A.current&&(A.current.style.height="auto")},v=t=>{if(h&&j.length>0){if(t.key==="ArrowDown"){t.preventDefault(),f(a=>(a+1)%j.length);return}if(t.key==="ArrowUp"){t.preventDefault(),f(a=>(a-1+j.length)%j.length);return}if(t.key==="Tab"||t.key==="Enter"){t.preventDefault(),N(j[C].name);return}if(t.key==="Escape"){t.preventDefault(),w(null);return}}t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),d())},b=t=>E.find(a=>a.name===t)??{name:t,emoji:"🤖",description:"",color:"gray"};return e.jsxs("div",{className:"flex-1 flex flex-col h-full bg-white dark:bg-black overflow-hidden transition-colors duration-300",children:[x&&e.jsxs("div",{className:"md:hidden flex items-center gap-3 px-4 py-3 shrink-0 bg-white dark:bg-black border-b border-gray-300 dark:border-matrix-primary",children:[e.jsx("button",{onClick:x,className:"p-2 -ml-1 rounded-lg hover:bg-gray-100 dark:hover:bg-matrix-primary/20 text-gray-500 dark:text-matrix-secondary transition-colors","aria-label":"Open sessions",children:e.jsx(le,{size:20})}),e.jsx("span",{className:"text-sm font-semibold text-gray-800 dark:text-matrix-highlight truncate flex-1",children:p?.title??(c?"Chat":"Morpheus")})]}),c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 px-4 py-5 space-y-4",children:[ge(r).map(t=>{const{message:a,toolGroups:y}=t;if(a.type==="tool")return e.jsx("div",{className:"px-2 py-0.5",children:e.jsx(Me,{message:a})},t.index);const O=a.type==="human",S=a.source==="webhook"||a.source==="chronos",T=O&&!S;return e.jsxs("div",{className:`flex items-end gap-2.5 ${T?"justify-end":"justify-start"}`,children:[!T&&e.jsx("div",{className:"w-7 h-7 rounded-full flex-shrink-0 flex items-center justify-center bg-azure-primary/10 text-azure-primary dark:bg-matrix-primary/20 dark:text-matrix-highlight mb-0.5",children:S&&a.source==="webhook"?e.jsx(de,{size:14}):S&&a.source==="chronos"?e.jsx(ce,{size:14}):e.jsx(F,{size:14})}),e.jsxs("div",{className:`
4
+ `,children:[e.jsx("div",{className:"flex-1 min-w-0",children:j?e.jsx("div",{onClick:N=>N.stopPropagation(),children:e.jsx("input",{ref:M,type:"text",value:C,onChange:N=>f(N.target.value),onKeyDown:A,className:"w-full text-sm px-1.5 py-0.5 bg-white dark:bg-black border border-azure-primary dark:border-matrix-highlight rounded-lg focus:outline-none dark:text-matrix-highlight"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-sm font-medium truncate leading-snug",children:l.title||"Untitled Session"}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-matrix-secondary/50 mt-0.5",children:ke(l.last_message_at??l.started_at)})]})}),e.jsx("div",{className:`flex items-center gap-0.5 shrink-0 transition-opacity ${E||j?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:N=>N.stopPropagation(),children:j?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:I,className:"p-1.5 rounded-lg text-emerald-600 hover:bg-emerald-50 dark:text-emerald-400 dark:hover:bg-emerald-900/20 transition-colors",title:"Save",children:e.jsx(re,{size:13})}),e.jsx("button",{onClick:O,className:"p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20 transition-colors",title:"Cancel",children:e.jsx(q,{size:13})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:N=>z(N,l),className:"p-1.5 rounded-lg text-gray-400 hover:text-blue-500 hover:bg-blue-50 dark:text-matrix-secondary/50 dark:hover:text-blue-400 dark:hover:bg-blue-900/20 transition-colors",title:"Rename",children:e.jsx(te,{size:13})}),e.jsx("button",{onClick:()=>k(`/sessions/${l.id}/audit`),className:"p-1.5 rounded-lg text-gray-400 hover:text-violet-500 hover:bg-violet-50 dark:text-matrix-secondary/50 dark:hover:text-violet-400 dark:hover:bg-violet-900/20 transition-colors",title:"Audit",children:e.jsx(ae,{size:13})}),e.jsx("button",{onClick:()=>p(l.id),className:"p-1.5 rounded-lg text-gray-400 hover:text-amber-500 hover:bg-amber-50 dark:text-matrix-secondary/50 dark:hover:text-amber-400 dark:hover:bg-amber-900/20 transition-colors",title:"Archive",children:e.jsx(se,{size:13})}),e.jsx("button",{onClick:()=>x(l.id),className:"p-1.5 rounded-lg text-gray-400 hover:text-red-500 hover:bg-red-50 dark:text-matrix-secondary/50 dark:hover:text-red-400 dark:hover:bg-red-900/20 transition-colors",title:"Delete",children:e.jsx(ne,{size:13})})]})})]},l.id)})]})]}):e.jsxs("div",{className:"w-14 bg-white dark:bg-black border-r border-gray-300 dark:border-matrix-primary flex flex-col items-center py-3 gap-3 shrink-0 transition-colors duration-300",children:[e.jsx("button",{onClick:g,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-matrix-primary/20 text-gray-400 dark:text-matrix-secondary/60 transition-colors",title:"Expand sidebar",children:e.jsx(Z,{size:18})}),e.jsx("div",{className:"w-8 h-px bg-gray-200 dark:bg-matrix-primary/20"}),e.jsx("button",{onClick:c,className:"p-2.5 bg-azure-primary text-white dark:bg-matrix-highlight dark:text-black rounded-xl hover:bg-azure-secondary dark:hover:bg-matrix-secondary shadow-sm transition-colors",title:"New chat",children:e.jsx(B,{size:18})})]})};function W(r){if(r==null)return"";if(typeof r=="string")try{return JSON.stringify(JSON.parse(r),null,2)}catch{return r}try{return JSON.stringify(r,null,2)}catch{return String(r)}}const ve=({group:r})=>{const[i,n]=o.useState(!1),c=r.result!==null,p=r.result?.content??"",x=p.startsWith("Error")||p.startsWith("❌");return e.jsxs("div",{className:"rounded-lg border border-gray-300 dark:border-matrix-primary/70 bg-white dark:bg-black overflow-hidden text-sm mb-1",children:[e.jsxs("button",{onClick:()=>n(!i),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left hover:bg-gray-50 dark:hover:bg-zinc-900/60 transition-colors",children:[e.jsx(ie,{size:12,className:"text-amber-500 dark:text-amber-400/80 flex-shrink-0"}),e.jsx("span",{className:"flex-1 font-mono text-xs text-gray-600 dark:text-matrix-secondary/80 truncate",children:r.call.name}),c?x?e.jsx(H,{size:12,className:"text-red-500 dark:text-red-400 flex-shrink-0"}):e.jsx(X,{size:12,className:"text-emerald-500 dark:text-emerald-400 flex-shrink-0"}):e.jsx(Q,{size:12,className:"text-gray-400 animate-spin flex-shrink-0"}),e.jsx(J,{size:12,className:`text-gray-400 dark:text-matrix-secondary/40 flex-shrink-0 transition-transform duration-200 ${i?"rotate-180":""}`})]}),e.jsx(U,{initial:!1,children:i&&e.jsx(G.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15,ease:"easeInOut"},className:"overflow-hidden",children:e.jsxs("div",{className:"px-3 pb-2.5 pt-1 border-t border-gray-100 dark:border-matrix-primary/20 space-y-2",children:[Object.keys(r.call.args??{}).length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/40 uppercase tracking-wider mb-1",children:"args"}),e.jsx("pre",{className:"text-xs font-mono text-gray-600 dark:text-matrix-secondary/80 whitespace-pre-wrap break-all bg-gray-50 dark:bg-zinc-900 rounded-md p-2 border border-gray-100 dark:border-matrix-primary/20 max-h-36 overflow-y-auto",children:W(r.call.args)})]}),c&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/40 uppercase tracking-wider mb-1",children:"result"}),e.jsx("pre",{className:"text-xs font-mono text-gray-600 dark:text-matrix-secondary/80 whitespace-pre-wrap break-all bg-gray-50 dark:bg-zinc-900 rounded-md p-2 border border-gray-100 dark:border-matrix-primary/20 max-h-44 overflow-y-auto",children:W(p)})]})]})})})]})};function P(r){return r?.task??r?.prompt??""}function we(r){if(typeof r!="string")return String(r);try{return JSON.stringify(JSON.parse(r),null,2)}catch{return r}}const Ne=({group:r})=>{const[i,n]=o.useState(!1),{getByToolName:c}=V(),p=c(r.call.name),x={label:p.label,emoji:p.emoji,colorClass:p.colorClass,bgClass:p.bgClass},m=r.result!==null,u=r.result?.content??"",g=u.startsWith("❌")||u.toLowerCase().startsWith("error"),k=P(r.call.args).slice(0,100),h=r.call.args?.smith??null;return e.jsxs("div",{className:`rounded-lg border border-gray-300 dark:border-matrix-primary/70 overflow-hidden text-sm mb-1 ${x.bgClass}`,children:[e.jsxs("button",{onClick:()=>n(!i),className:"w-full flex items-center gap-2.5 px-3 py-2 text-left hover:brightness-95 dark:hover:brightness-110 transition-all",children:[e.jsx("span",{className:"text-base flex-shrink-0 leading-none",children:x.emoji}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:`text-xs font-semibold ${x.colorClass}`,children:[x.label,h?` · ${h}`:""]}),k&&e.jsx("div",{className:"text-xs text-gray-500 dark:text-matrix-secondary/60 truncate mt-0.5",children:k})]}),m?g?e.jsx(H,{size:14,className:"text-red-500 dark:text-red-400 flex-shrink-0"}):e.jsx(X,{size:14,className:"text-emerald-500 dark:text-emerald-400 flex-shrink-0"}):e.jsx(Q,{size:14,className:"text-gray-400 animate-spin flex-shrink-0"}),e.jsx(J,{size:13,className:`text-gray-400 dark:text-matrix-secondary/40 flex-shrink-0 transition-transform duration-200 ${i?"rotate-180":""}`})]}),e.jsx(U,{initial:!1,children:i&&e.jsx(G.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.18,ease:"easeInOut"},className:"overflow-hidden",children:e.jsxs("div",{className:"px-3 pb-2.5 pt-1 border-t border-gray-200 dark:border-matrix-primary/20 space-y-2",children:[P(r.call.args)&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/40 uppercase tracking-wider mb-1",children:"task"}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-matrix-secondary/80 bg-white dark:bg-black rounded-md p-2 border border-gray-100 dark:border-matrix-primary/20 whitespace-pre-wrap",children:P(r.call.args)})]}),m&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-gray-400 dark:text-matrix-secondary/40 uppercase tracking-wider mb-1",children:"result"}),e.jsx("pre",{className:"text-xs font-mono text-gray-600 dark:text-matrix-secondary/80 whitespace-pre-wrap break-all bg-white dark:bg-black rounded-md p-2 border border-gray-100 dark:border-matrix-primary/20 max-h-56 overflow-y-auto",children:we(u)})]})]})})})]})};function Se(r){return r==null||r===0?null:r<1e3?`${r}ms`:`${(r/1e3).toFixed(1)}s`}function L(r){return r>=1e3?`${(r/1e3).toFixed(1)}k`:String(r)}const ze=({message:r})=>{const i=r.usage_metadata,n=i?.input_tokens??i?.prompt_tokens??0,c=i?.output_tokens??i?.completion_tokens??0,p=n>0||c>0,x=Se(r.duration_ms),m=r.model,u=r.sati_memories_count??null;if(!p&&!x&&!m&&u==null)return null;const g=m?(m.includes(":")?m.split(":").pop():m)?.split("-").slice(0,4).join("-")??m:null;return e.jsxs("div",{className:"mt-2 pt-1.5 border-t border-gray-100 dark:border-matrix-primary/20 flex flex-wrap items-center gap-x-3 gap-y-0.5",children:[g&&e.jsx("span",{className:"text-[11px] font-mono text-gray-400 dark:text-matrix-secondary/40 truncate max-w-[180px]",title:m??"",children:g}),p&&e.jsxs("span",{className:"text-[11px] font-mono text-gray-400 dark:text-matrix-secondary/40",children:["↑",L(n)," ↓",L(c)]}),x&&e.jsx("span",{className:"text-[11px] font-mono text-gray-400 dark:text-matrix-secondary/40",children:x}),u!=null&&u>0&&e.jsxs("span",{className:"flex items-center gap-1 text-[11px] font-mono text-purple-400 dark:text-purple-400/70",children:[e.jsx(oe,{size:10}),u]})]})},K={amber:"bg-amber-100 text-amber-800 border-amber-300 dark:bg-amber-900/30 dark:text-amber-300 dark:border-amber-700/60",purple:"bg-purple-100 text-purple-800 border-purple-300 dark:bg-purple-900/30 dark:text-purple-300 dark:border-purple-700/60",violet:"bg-violet-100 text-violet-800 border-violet-300 dark:bg-violet-900/30 dark:text-violet-300 dark:border-violet-700/60",teal:"bg-teal-100 text-teal-800 border-teal-300 dark:bg-teal-900/30 dark:text-teal-300 dark:border-teal-700/60",gray:"bg-zinc-100 text-zinc-700 border-zinc-300 dark:bg-zinc-800 dark:text-zinc-300 dark:border-zinc-600",indigo:"bg-indigo-100 text-indigo-800 border-indigo-300 dark:bg-indigo-900/30 dark:text-indigo-300 dark:border-indigo-700/60"};function Ce(r){const i=r.replace(/^```json\s*/i,"").replace(/\s*```$/,"");try{return JSON.stringify(JSON.parse(i),null,2)}catch{return i}}function Ee(r){return r.session_id?.startsWith("sati-evaluation-")===!0||r.tool_name?.toLowerCase().includes("sati")===!0}const Me=({message:r})=>{const[i,n]=o.useState(!1),c=Ee(r),p=c?r.tool_name==="sati_evaluation_output"?"Sati · memory update":"Sati · analysis":r.tool_name??"tool result";return e.jsxs("details",{open:i,onToggle:x=>n(x.target.open),className:"w-full",children:[e.jsxs("summary",{className:"list-none cursor-pointer select-none flex items-center gap-2 text-xs text-gray-400 dark:text-matrix-secondary/40 hover:text-gray-500 dark:hover:text-matrix-secondary/60 transition-colors py-0.5",children:[e.jsx("div",{className:"flex-1 h-px bg-gray-200 dark:bg-matrix-primary/20"}),e.jsxs("span",{className:"flex items-center gap-1.5 whitespace-nowrap px-2",children:[e.jsx("span",{children:c?"🧠":"🔧"}),e.jsx("span",{children:p}),e.jsx(J,{size:11,className:`transition-transform duration-200 ${i?"rotate-180":""}`})]}),e.jsx("div",{className:"flex-1 h-px bg-gray-200 dark:bg-matrix-primary/20"})]}),i&&e.jsx("pre",{className:"mt-2 px-3 py-2.5 whitespace-pre-wrap break-all text-xs font-mono text-gray-600 dark:text-matrix-secondary/80 border border-gray-300 dark:border-matrix-primary/60 rounded-lg bg-gray-50 dark:bg-zinc-900 max-h-48 overflow-y-auto",children:Ce(r.content)})]})},Ae={table:({children:r})=>e.jsx("div",{className:"my-2 overflow-x-auto rounded-lg border border-gray-200 dark:border-matrix-primary/60",children:e.jsx("table",{className:"min-w-full text-xs border-collapse",children:r})}),thead:({children:r})=>e.jsx("thead",{className:"bg-gray-100 dark:bg-zinc-900 text-gray-600 dark:text-matrix-secondary/70",children:r}),tbody:({children:r})=>e.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-matrix-primary/20",children:r}),tr:({children:r})=>e.jsx("tr",{className:"hover:bg-gray-50 dark:hover:bg-zinc-900/60 transition-colors",children:r}),th:({children:r})=>e.jsx("th",{className:"px-3 py-2 text-left font-semibold whitespace-nowrap border-b border-gray-200 dark:border-matrix-primary/40",children:r}),td:({children:r})=>e.jsx("td",{className:"px-3 py-2 text-gray-700 dark:text-matrix-secondary align-top",children:r})},De=({messages:r,onSendMessage:i,isLoading:n,activeSessionId:c,activeSession:p,onToggleSidebar:x})=>{const[m,u]=o.useState(""),[g,k]=o.useState([]),[h,w]=o.useState(null),[C,f]=o.useState(0),[M,z]=o.useState([]),{getSubagents:I}=V(),O=o.useRef(null),A=o.useRef(null);o.useEffect(()=>{O.current?.scrollIntoView({behavior:"smooth"})},[r,n]),o.useEffect(()=>{const t=A.current;t&&(t.style.height="auto",t.style.height=t.scrollHeight+"px")},[m]),o.useEffect(()=>{pe.get("/smiths").then(t=>z(t.smiths.map(a=>({name:a.name,emoji:"🕶️",description:"Remote Smith agent",color:"gray"})))).catch(()=>{})},[]);const l=I().map(t=>({name:t.auditAgent,emoji:t.emoji,description:t.description,color:t.color})),E=[...l,...M.filter(t=>!l.some(a=>a.name===t.name))],j=h?E.filter(t=>t.name.toLowerCase().startsWith(h.query.toLowerCase())):[],N=t=>{if(!h)return;const a=m.slice(0,h.startIdx),y=m.slice(h.startIdx+1+h.query.length),_=(a+y).replace(/ +/g," ").trim();u(_),k(S=>S.includes(t)?S:[...S,t]),w(null),f(0),setTimeout(()=>A.current?.focus(),0)},R=t=>{k(a=>a.filter(y=>y!==t))},s=t=>{const a=t.target.value;u(a);const y=t.target.selectionStart??a.length,S=a.slice(0,y).match(/@(\w*)$/);S?(w({query:S[1],startIdx:y-S[0].length}),f(0)):w(null)},d=()=>{if(!(m.trim()||g.length>0)||n)return;const a=[...g.map(y=>`@${y}`),m.trim()].filter(Boolean);i(a.join(" ")),u(""),k([]),w(null),A.current&&(A.current.style.height="auto")},v=t=>{if(h&&j.length>0){if(t.key==="ArrowDown"){t.preventDefault(),f(a=>(a+1)%j.length);return}if(t.key==="ArrowUp"){t.preventDefault(),f(a=>(a-1+j.length)%j.length);return}if(t.key==="Tab"||t.key==="Enter"){t.preventDefault(),N(j[C].name);return}if(t.key==="Escape"){t.preventDefault(),w(null);return}}t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),d())},b=t=>E.find(a=>a.name===t)??{name:t,emoji:"🤖",description:"",color:"gray"};return e.jsxs("div",{className:"flex-1 flex flex-col h-full bg-white dark:bg-black overflow-hidden transition-colors duration-300",children:[x&&e.jsxs("div",{className:"md:hidden flex items-center gap-3 px-4 py-3 shrink-0 bg-white dark:bg-black border-b border-gray-300 dark:border-matrix-primary",children:[e.jsx("button",{onClick:x,className:"p-2 -ml-1 rounded-lg hover:bg-gray-100 dark:hover:bg-matrix-primary/20 text-gray-500 dark:text-matrix-secondary transition-colors","aria-label":"Open sessions",children:e.jsx(le,{size:20})}),e.jsx("span",{className:"text-sm font-semibold text-gray-800 dark:text-matrix-highlight truncate flex-1",children:p?.title??(c?"Chat":"Morpheus")})]}),c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 px-4 py-5 space-y-4",children:[ge(r).map(t=>{const{message:a,toolGroups:y}=t;if(a.type==="tool")return e.jsx("div",{className:"px-2 py-0.5",children:e.jsx(Me,{message:a})},t.index);const _=a.type==="human",S=a.source==="webhook"||a.source==="chronos",T=_&&!S;return e.jsxs("div",{className:`flex items-end gap-2.5 ${T?"justify-end":"justify-start"}`,children:[!T&&e.jsx("div",{className:"w-7 h-7 rounded-full flex-shrink-0 flex items-center justify-center bg-azure-primary/10 text-azure-primary dark:bg-matrix-primary/20 dark:text-matrix-highlight mb-0.5",children:S&&a.source==="webhook"?e.jsx(de,{size:14}):S&&a.source==="chronos"?e.jsx(ce,{size:14}):e.jsx(F,{size:14})}),e.jsxs("div",{className:`
5
5
  max-w-[85%] md:max-w-[72%] min-w-0
6
6
  ${T?"bg-azure-primary text-white dark:text-white/80 dark:bg-matrix-primary rounded-2xl rounded-br-sm px-4 py-2.5":"bg-gray-50 dark:bg-zinc-900 border border-gray-300 dark:border-matrix-primary/60 text-gray-800 dark:text-matrix-secondary rounded-2xl rounded-bl-sm px-4 py-3"}
7
- `,children:[S&&e.jsx("div",{className:"flex items-center gap-1.5 mb-1.5",children:e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-semibold uppercase tracking-wider border bg-amber-50 text-amber-700 border-amber-300 dark:bg-amber-900/30 dark:text-amber-300 dark:border-amber-700/60",children:a.source==="webhook"?"Webhook":"Chronos"})}),O&&e.jsxs(e.Fragment,{children:[a.audio_duration_seconds!=null&&e.jsxs("div",{className:"flex items-center gap-1 mb-1.5 text-white/70 dark:text-white/50",children:[e.jsx(xe,{size:11}),e.jsxs("span",{className:"text-[10px] font-mono tracking-wide",children:["voice · ",a.audio_duration_seconds,"s"]})]}),e.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap break-words",children:a.content})]}),a.type==="ai"&&e.jsxs(e.Fragment,{children:[y&&y.length>0&&e.jsx("div",{className:"mb-2.5 space-y-1",children:y.map($=>ue($.call.name)?e.jsx(Ne,{group:$},$.call.id):e.jsx(ve,{group:$},$.call.id))}),a.content&&e.jsx("div",{className:`
7
+ `,children:[S&&e.jsx("div",{className:"flex items-center gap-1.5 mb-1.5",children:e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-semibold uppercase tracking-wider border bg-amber-50 text-amber-700 border-amber-300 dark:bg-amber-900/30 dark:text-amber-300 dark:border-amber-700/60",children:a.source==="webhook"?"Webhook":"Chronos"})}),_&&e.jsxs(e.Fragment,{children:[a.audio_duration_seconds!=null&&e.jsxs("div",{className:"flex items-center gap-1 mb-1.5 text-white/70 dark:text-white/50",children:[e.jsx(xe,{size:11}),e.jsxs("span",{className:"text-[10px] font-mono tracking-wide",children:["voice · ",a.audio_duration_seconds,"s"]})]}),e.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap break-words",children:a.content})]}),a.type==="ai"&&e.jsxs(e.Fragment,{children:[y&&y.length>0&&e.jsx("div",{className:"mb-2.5 space-y-1",children:y.map($=>ue($.call.name)?e.jsx(Ne,{group:$},$.call.id):e.jsx(ve,{group:$},$.call.id))}),a.content&&e.jsx("div",{className:`
8
8
  prose prose-sm dark:prose-invert max-w-none
9
9
  prose-p:my-1.5 prose-p:leading-relaxed
10
10
  prose-headings:my-2 prose-headings:font-semibold
@@ -19,10 +19,10 @@ import{j as e,A as U,m as q}from"./vendor-motion-C3CZ8ZlO.js";import{c as Y,r as
19
19
  dark:prose-li:text-matrix-secondary
20
20
  dark:prose-code:text-matrix-highlight dark:prose-code:bg-black/60
21
21
  dark:prose-pre:bg-black dark:prose-pre:border dark:prose-pre:border-matrix-primary/30
22
- `,children:e.jsx(be,{remarkPlugins:[ye],components:Ae,children:a.content})}),e.jsx(ze,{message:a})]})]}),T&&e.jsx("div",{className:"w-7 h-7 rounded-full flex-shrink-0 flex items-center justify-center bg-gray-200 dark:bg-matrix-primary/30 text-gray-500 dark:text-matrix-secondary mb-0.5",children:e.jsx(me,{size:14})})]},t.index)}),n&&e.jsxs("div",{className:"flex items-end gap-2.5 justify-start",children:[e.jsx("div",{className:"w-7 h-7 rounded-full flex-shrink-0 flex items-center justify-center bg-azure-primary/10 text-azure-primary dark:bg-matrix-primary/20 dark:text-matrix-highlight mb-0.5",children:e.jsx(F,{size:14})}),e.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 border border-gray-300 dark:border-matrix-primary/60 rounded-2xl rounded-bl-sm px-4 py-3 flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-azure-primary dark:bg-matrix-highlight animate-bounce",style:{animationDelay:"0ms"}}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-azure-primary dark:bg-matrix-highlight animate-bounce",style:{animationDelay:"160ms"}}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-azure-primary dark:bg-matrix-highlight animate-bounce",style:{animationDelay:"320ms"}})]})]}),e.jsx("div",{ref:_})]}),e.jsx("div",{className:"shrink-0 px-4 pt-3 pb-4 bg-white dark:bg-black border-t border-gray-300 dark:border-matrix-primary",children:e.jsxs("div",{className:"max-w-3xl mx-auto relative",children:[h&&j.length>0&&e.jsxs("div",{className:"absolute bottom-full left-0 right-0 mb-2 z-50 bg-white dark:bg-zinc-900 border border-gray-300 dark:border-matrix-primary rounded-xl shadow-xl overflow-hidden",children:[e.jsx("div",{className:"px-3 py-1.5 border-b border-gray-100 dark:border-matrix-primary/40 flex items-center gap-1.5",children:e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-gray-400 dark:text-matrix-secondary/50",children:"Agents"})}),e.jsx("ul",{className:"max-h-52 overflow-y-auto py-1",children:j.map((t,a)=>e.jsx("li",{children:e.jsxs("button",{type:"button",onMouseDown:y=>{y.preventDefault(),N(t.name)},onMouseEnter:()=>f(a),className:`
22
+ `,children:e.jsx(be,{remarkPlugins:[ye],components:Ae,children:a.content})}),e.jsx(ze,{message:a})]})]}),T&&e.jsx("div",{className:"w-7 h-7 rounded-full flex-shrink-0 flex items-center justify-center bg-gray-200 dark:bg-matrix-primary/30 text-gray-500 dark:text-matrix-secondary mb-0.5",children:e.jsx(me,{size:14})})]},t.index)}),n&&e.jsxs("div",{className:"flex items-end gap-2.5 justify-start",children:[e.jsx("div",{className:"w-7 h-7 rounded-full flex-shrink-0 flex items-center justify-center bg-azure-primary/10 text-azure-primary dark:bg-matrix-primary/20 dark:text-matrix-highlight mb-0.5",children:e.jsx(F,{size:14})}),e.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 border border-gray-300 dark:border-matrix-primary/60 rounded-2xl rounded-bl-sm px-4 py-3 flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-azure-primary dark:bg-matrix-highlight animate-bounce",style:{animationDelay:"0ms"}}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-azure-primary dark:bg-matrix-highlight animate-bounce",style:{animationDelay:"160ms"}}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-azure-primary dark:bg-matrix-highlight animate-bounce",style:{animationDelay:"320ms"}})]})]}),e.jsx("div",{ref:O})]}),e.jsx("div",{className:"shrink-0 px-4 pt-3 pb-4 bg-white dark:bg-black border-t border-gray-300 dark:border-matrix-primary",children:e.jsxs("div",{className:"max-w-3xl mx-auto relative",children:[h&&j.length>0&&e.jsxs("div",{className:"absolute bottom-full left-0 right-0 mb-2 z-50 bg-white dark:bg-zinc-900 border border-gray-300 dark:border-matrix-primary rounded-xl shadow-xl overflow-hidden",children:[e.jsx("div",{className:"px-3 py-1.5 border-b border-gray-100 dark:border-matrix-primary/40 flex items-center gap-1.5",children:e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-gray-400 dark:text-matrix-secondary/50",children:"Agents"})}),e.jsx("ul",{className:"max-h-52 overflow-y-auto py-1",children:j.map((t,a)=>e.jsx("li",{children:e.jsxs("button",{type:"button",onMouseDown:y=>{y.preventDefault(),N(t.name)},onMouseEnter:()=>f(a),className:`
23
23
  w-full flex items-center gap-3 px-3 py-2 text-left transition-colors
24
24
  ${a===C?"bg-azure-primary/10 dark:bg-matrix-primary/20":"hover:bg-gray-50 dark:hover:bg-matrix-primary/10"}
25
- `,children:[e.jsx("span",{className:"text-base leading-none",children:t.emoji}),e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsxs("span",{className:"block text-sm font-medium text-gray-800 dark:text-matrix-highlight",children:["@",t.name]}),e.jsx("span",{className:"block text-xs text-gray-400 dark:text-matrix-secondary/50 truncate",children:t.description})]}),a===C&&e.jsx("kbd",{className:"flex-shrink-0 text-[10px] px-1.5 py-0.5 rounded bg-gray-100 dark:bg-black text-gray-500 dark:text-matrix-secondary/60 font-mono border border-gray-200 dark:border-matrix-primary/40",children:"Tab"})]})},t.name))})]}),g.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:g.map(t=>{const a=b(t),y=K[a.color]??K.gray;return e.jsxs("span",{className:`inline-flex items-center gap-1 pl-2 pr-1 py-0.5 rounded-full text-xs font-medium border ${y}`,children:[e.jsx("span",{className:"leading-none",children:a.emoji}),e.jsxs("span",{children:["@",t]}),e.jsx("button",{type:"button",onClick:()=>R(t),className:"ml-0.5 rounded-full p-0.5 hover:bg-black/10 dark:hover:bg-white/10 transition-colors","aria-label":`Remove @${t}`,children:e.jsx(G,{size:10})})]},t)})}),e.jsxs("form",{onSubmit:t=>{t.preventDefault(),d()},className:"flex items-end gap-2",children:[e.jsx("textarea",{ref:A,value:m,onChange:s,onKeyDown:v,placeholder:"Message Morpheus… (type @ to mention an agent)",rows:1,disabled:n,className:`
25
+ `,children:[e.jsx("span",{className:"text-base leading-none",children:t.emoji}),e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsxs("span",{className:"block text-sm font-medium text-gray-800 dark:text-matrix-highlight",children:["@",t.name]}),e.jsx("span",{className:"block text-xs text-gray-400 dark:text-matrix-secondary/50 truncate",children:t.description})]}),a===C&&e.jsx("kbd",{className:"flex-shrink-0 text-[10px] px-1.5 py-0.5 rounded bg-gray-100 dark:bg-black text-gray-500 dark:text-matrix-secondary/60 font-mono border border-gray-200 dark:border-matrix-primary/40",children:"Tab"})]})},t.name))})]}),g.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:g.map(t=>{const a=b(t),y=K[a.color]??K.gray;return e.jsxs("span",{className:`inline-flex items-center gap-1 pl-2 pr-1 py-0.5 rounded-full text-xs font-medium border ${y}`,children:[e.jsx("span",{className:"leading-none",children:a.emoji}),e.jsxs("span",{children:["@",t]}),e.jsx("button",{type:"button",onClick:()=>R(t),className:"ml-0.5 rounded-full p-0.5 hover:bg-black/10 dark:hover:bg-white/10 transition-colors","aria-label":`Remove @${t}`,children:e.jsx(q,{size:10})})]},t)})}),e.jsxs("form",{onSubmit:t=>{t.preventDefault(),d()},className:"flex items-end gap-2",children:[e.jsx("textarea",{ref:A,value:m,onChange:s,onKeyDown:v,placeholder:"Message Morpheus… (type @ to mention an agent)",rows:1,disabled:n,className:`
26
26
  flex-1 resize-none max-h-40 overflow-y-auto
27
27
  bg-gray-100 dark:bg-zinc-900
28
28
  border border-gray-300 dark:border-matrix-primary/60
@@ -33,9 +33,9 @@ import{j as e,A as U,m as q}from"./vendor-motion-C3CZ8ZlO.js";import{c as Y,r as
33
33
  focus:outline-none focus:ring-2 focus:ring-azure-primary dark:focus:ring-matrix-highlight focus:border-transparent
34
34
  disabled:opacity-50
35
35
  transition-all duration-200
36
- `}),e.jsx("button",{type:"submit",disabled:!m.trim()&&g.length===0||n,className:"flex-shrink-0 p-3 rounded-xl bg-azure-primary text-white dark:bg-matrix-secondary dark:text-black hover:bg-azure-secondary dark:hover:bg-matrix-highlight disabled:opacity-40 disabled:cursor-not-allowed transition-colors shadow-sm",children:e.jsx(he,{size:18})})]}),e.jsx("p",{className:"mt-1.5 text-center text-[11px] text-gray-300 dark:text-matrix-secondary/25 select-none",children:"Enter to send · Shift+Enter for newline · @ to mention an agent"})]})})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-5 p-8 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-azure-primary/10 dark:bg-matrix-primary/10 flex items-center justify-center",children:e.jsx(F,{size:30,className:"text-azure-primary/60 dark:text-matrix-highlight/50"})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-700 dark:text-matrix-highlight",children:"Morpheus is ready"}),e.jsx("p",{className:"text-sm text-gray-400 dark:text-matrix-secondary/60 max-w-[240px] leading-relaxed",children:"Select a session from the sidebar or start a new chat."})]})]})]})},Je=()=>{const[r,i]=o.useState([]),[n,c]=o.useState(null),[p,x]=o.useState([]),[m,u]=o.useState({}),[g,k]=o.useState(()=>typeof window<"u"?window.innerWidth>=768:!0),h=n?m[n]??!1:!1,w=o.useRef(!1);o.useEffect(()=>{w.current=h},[h]);const C=o.useRef(n);o.useEffect(()=>{C.current=n},[n]),o.useEffect(()=>{if(!n)return;const s=setInterval(async()=>{if(!w.current)try{const v=(await D.getMessages(n)).filter(b=>b.type!=="system");x(b=>{if(v.length!==b.length)return v;const t=v.at(-1)?.created_at??0,a=b.at(-1)?.created_at??0;return t>a?v:b})}catch{}},3e3);return()=>clearInterval(s)},[n]),o.useEffect(()=>{const s=setInterval(()=>{z()},1e4);return()=>clearInterval(s)},[]);const[f,M]=o.useState({isOpen:!1,title:"",description:"",onConfirm:()=>{}}),z=async()=>{try{const s=await D.getSessions();return i(s),s}catch(s){return console.error("Failed to load sessions:",s),[]}};o.useEffect(()=>{z().then(s=>{if(!s.length)return;const d=sessionStorage.getItem("morpheus.chat.uiSessionId"),v=d&&s.find(b=>b.id===d)?d:s[0].id;c(v)})},[]),o.useEffect(()=>{n?(I(n),sessionStorage.setItem("morpheus.chat.uiSessionId",n)):x([])},[n]);const I=async s=>{try{const d=await D.getMessages(s);x(d.filter(v=>v.type!=="system"))}catch(d){console.error("Failed to load messages:",d)}},_=async()=>{try{const s=await D.createSession();await z(),c(s.id),window.innerWidth<768&&k(!1)}catch(s){console.error("Failed to create session:",s)}},A=s=>{c(s),window.innerWidth<768&&k(!1)},l=async s=>{if(!n)return;const d=n,v={type:"human",content:s};x(b=>[...b,v]),u(b=>({...b,[d]:!0}));try{await D.sendMessage(d,s),d===C.current&&await I(d),await z()}catch(b){console.error("Failed to send message:",b)}finally{u(b=>{const t={...b};return delete t[d],t})}},E=s=>{M({isOpen:!0,title:"Archive Session",description:"Are you sure you want to archive this session? It will be moved to the archives.",confirmJson:"Archive",onConfirm:async()=>{try{await D.archiveSession(s),n===s&&c(null),await z()}catch(d){console.error("Failed to archive session:",d)}}})},j=s=>{M({isOpen:!0,title:"Delete Session",description:"Are you sure you want to DELETE this session? This action cannot be undone.",confirmJson:"Delete",variant:"destructive",onConfirm:async()=>{try{await D.deleteSession(s),n===s&&c(null),await z()}catch(d){console.error("Failed to delete session:",d)}}})},N=async(s,d)=>{try{await D.renameSession(s,d),await z()}catch(v){console.error("Failed to rename session:",v)}},R=r.find(s=>s.id===n)??null;return e.jsxs("div",{className:"flex h-full w-full overflow-hidden bg-white dark:bg-black relative",children:[g&&e.jsx("div",{className:"fixed inset-0 bg-black/40 z-20 md:hidden",onClick:()=>k(!1)}),e.jsx("div",{className:`
36
+ `}),e.jsx("button",{type:"submit",disabled:!m.trim()&&g.length===0||n,className:"flex-shrink-0 p-3 rounded-xl bg-azure-primary text-white dark:bg-matrix-secondary dark:text-black hover:bg-azure-secondary dark:hover:bg-matrix-highlight disabled:opacity-40 disabled:cursor-not-allowed transition-colors shadow-sm",children:e.jsx(he,{size:18})})]}),e.jsx("p",{className:"mt-1.5 text-center text-[11px] text-gray-300 dark:text-matrix-secondary/25 select-none",children:"Enter to send · Shift+Enter for newline · @ to mention an agent"})]})})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-5 p-8 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-azure-primary/10 dark:bg-matrix-primary/10 flex items-center justify-center",children:e.jsx(F,{size:30,className:"text-azure-primary/60 dark:text-matrix-highlight/50"})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-700 dark:text-matrix-highlight",children:"Morpheus is ready"}),e.jsx("p",{className:"text-sm text-gray-400 dark:text-matrix-secondary/60 max-w-[240px] leading-relaxed",children:"Select a session from the sidebar or start a new chat."})]})]})]})},Je=()=>{const[r,i]=o.useState([]),[n,c]=o.useState(null),[p,x]=o.useState([]),[m,u]=o.useState({}),[g,k]=o.useState(()=>typeof window<"u"?window.innerWidth>=768:!0),h=n?m[n]??!1:!1,w=o.useRef(!1);o.useEffect(()=>{w.current=h},[h]);const C=o.useRef(n);o.useEffect(()=>{C.current=n},[n]),o.useEffect(()=>{if(!n)return;const s=setInterval(async()=>{if(!w.current)try{const v=(await D.getMessages(n)).filter(b=>b.type!=="system");x(b=>{if(v.length!==b.length)return v;const t=v.at(-1)?.created_at??0,a=b.at(-1)?.created_at??0;return t>a?v:b})}catch{}},3e3);return()=>clearInterval(s)},[n]),o.useEffect(()=>{const s=setInterval(()=>{z()},1e4);return()=>clearInterval(s)},[]);const[f,M]=o.useState({isOpen:!1,title:"",description:"",onConfirm:()=>{}}),z=async()=>{try{const s=await D.getSessions();return i(s),s}catch(s){return console.error("Failed to load sessions:",s),[]}};o.useEffect(()=>{z().then(s=>{if(!s.length)return;const d=sessionStorage.getItem("morpheus.chat.uiSessionId"),v=d&&s.find(b=>b.id===d)?d:s[0].id;c(v)})},[]),o.useEffect(()=>{n?(I(n),sessionStorage.setItem("morpheus.chat.uiSessionId",n)):x([])},[n]);const I=async s=>{try{const d=await D.getMessages(s);x(d.filter(v=>v.type!=="system"))}catch(d){console.error("Failed to load messages:",d)}},O=async()=>{try{const s=await D.createSession();await z(),c(s.id),window.innerWidth<768&&k(!1)}catch(s){console.error("Failed to create session:",s)}},A=s=>{c(s),window.innerWidth<768&&k(!1)},l=async s=>{if(!n)return;const d=n,v={type:"human",content:s};x(b=>[...b,v]),u(b=>({...b,[d]:!0}));try{await D.sendMessage(d,s),d===C.current&&await I(d),await z()}catch(b){console.error("Failed to send message:",b)}finally{u(b=>{const t={...b};return delete t[d],t})}},E=s=>{M({isOpen:!0,title:"Archive Session",description:"Are you sure you want to archive this session? It will be moved to the archives.",confirmJson:"Archive",onConfirm:async()=>{try{await D.archiveSession(s),n===s&&c(null),await z()}catch(d){console.error("Failed to archive session:",d)}}})},j=s=>{M({isOpen:!0,title:"Delete Session",description:"Are you sure you want to DELETE this session? This action cannot be undone.",confirmJson:"Delete",variant:"destructive",onConfirm:async()=>{try{await D.deleteSession(s),n===s&&c(null),await z()}catch(d){console.error("Failed to delete session:",d)}}})},N=async(s,d)=>{try{await D.renameSession(s,d),await z()}catch(v){console.error("Failed to rename session:",v)}},R=r.find(s=>s.id===n)??null;return e.jsxs("div",{className:"flex h-full w-full overflow-hidden bg-white dark:bg-black relative",children:[g&&e.jsx("div",{className:"fixed inset-0 bg-black/40 z-20 md:hidden",onClick:()=>k(!1)}),e.jsx("div",{className:`
37
37
  fixed top-16 bottom-0 left-0 z-40 flex
38
38
  md:relative md:inset-auto md:z-auto md:translate-x-0
39
39
  transition-transform duration-300 ease-out
40
40
  ${g?"translate-x-0":"-translate-x-full"}
41
- `,children:e.jsx(je,{sessions:r,activeSessionId:n,onSelectSession:A,onCreateSession:_,onArchiveSession:E,onDeleteSession:j,onRenameSession:N,isOpen:g,toggleSidebar:()=>k(!g)})}),e.jsx("div",{className:"flex-1 flex flex-col h-full overflow-hidden min-w-0",children:e.jsx(De,{messages:p,onSendMessage:l,isLoading:h,activeSessionId:n,activeSession:R,onToggleSidebar:()=>k(!g)})}),e.jsx(fe,{isOpen:f.isOpen,onClose:()=>M(s=>({...s,isOpen:!1})),onConfirm:f.onConfirm,title:f.title,description:f.description,confirmJson:f.confirmJson,variant:f.variant})]})};export{Je as ChatPage};
41
+ `,children:e.jsx(je,{sessions:r,activeSessionId:n,onSelectSession:A,onCreateSession:O,onArchiveSession:E,onDeleteSession:j,onRenameSession:N,isOpen:g,toggleSidebar:()=>k(!g)})}),e.jsx("div",{className:"flex-1 flex flex-col h-full overflow-hidden min-w-0",children:e.jsx(De,{messages:p,onSendMessage:l,isLoading:h,activeSessionId:n,activeSession:R,onToggleSidebar:()=>k(!g)})}),e.jsx(fe,{isOpen:f.isOpen,onClose:()=>M(s=>({...s,isOpen:!1})),onConfirm:f.onConfirm,title:f.title,description:f.description,confirmJson:f.confirmJson,variant:f.variant})]})};export{Je as ChatPage};
@@ -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-DGD_Md9M.js";import{D as R}from"./DeleteConfirmationModal-kZ_c3sFk.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-BcX5O7kY.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-DPhK718h.js";import{D as R}from"./DeleteConfirmationModal-FSWLK6-I.js";import{P as J}from"./Pagination-D4ShqUKO.js";import{ag as M,ah as U,ai as B,aj as H,ak as W,G as $,g as T,X as q,a8 as F}from"./vendor-icons-DE7PWdkN.js";import{m as z}from"./vendor-utils-BIYveU_1.js";import{T as C,S}from"./SelectInput-BPDcd3y7.js";import"./index-B9ePr-vB.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 G({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 K({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 V=["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(K,{scheduleExpression:x,scheduleType:h,timezone:p})]}),e.jsx(S,{label:"Timezone",value:p,onChange:a=>b(a.target.value),options:V.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(G,{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-BcX5O7kY.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
+ import{j as r}from"./vendor-motion-C3CZ8ZlO.js";import{D as o,e as x,j as n,k as c,l as g,B as t}from"./index-B9ePr-vB.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};