morpheus-cli 0.9.24 → 0.9.30

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 (50) hide show
  1. package/dist/channels/telegram.js +165 -120
  2. package/dist/cli/commands/restart.js +12 -0
  3. package/dist/config/manager.js +34 -2
  4. package/dist/config/paths.js +2 -0
  5. package/dist/config/schemas.js +6 -0
  6. package/dist/runtime/__tests__/gws-sync.test.js +69 -0
  7. package/dist/runtime/gws-sync.js +102 -0
  8. package/dist/runtime/hash-utils.js +15 -0
  9. package/dist/runtime/hot-reload.js +5 -1
  10. package/dist/runtime/oracle.js +1 -0
  11. package/dist/runtime/scaffold.js +4 -0
  12. package/dist/runtime/skills/loader.js +7 -52
  13. package/dist/runtime/skills/registry.js +5 -1
  14. package/dist/runtime/skills/schema.js +1 -1
  15. package/dist/runtime/skills/tool.js +8 -1
  16. package/dist/runtime/subagents/apoc.js +154 -1
  17. package/dist/runtime/subagents/devkit-instrument.js +13 -0
  18. package/dist/types/config.js +3 -0
  19. package/dist/ui/assets/{AuditDashboard-CfYKdOEt.js → AuditDashboard-tH9QZTl4.js} +1 -1
  20. package/dist/ui/assets/{Chat-CYev7-CJ.js → Chat-Cd0uYF8g.js} +1 -1
  21. package/dist/ui/assets/{Chronos-5KR8aZud.js → Chronos-CWwHYdBl.js} +1 -1
  22. package/dist/ui/assets/{ConfirmationModal-NFwIYI7B.js → ConfirmationModal-CxvFe-We.js} +1 -1
  23. package/dist/ui/assets/{Dashboard-hsjB56la.js → Dashboard-CNNMxl53.js} +1 -1
  24. package/dist/ui/assets/{DeleteConfirmationModal-BfV370Vv.js → DeleteConfirmationModal-AqGQSh1X.js} +1 -1
  25. package/dist/ui/assets/{Documents-BNo2tMfG.js → Documents-BfRYOK88.js} +1 -1
  26. package/dist/ui/assets/{Logs-1hBpMPZE.js → Logs-DhFo4cio.js} +1 -1
  27. package/dist/ui/assets/{MCPManager-CvPRHn4C.js → MCPManager-BMhxbhni.js} +1 -1
  28. package/dist/ui/assets/{ModelPricing-BbwJFdz4.js → ModelPricing-Dvl0R_HR.js} +1 -1
  29. package/dist/ui/assets/{Notifications-C_MA51Gf.js → Notifications-CawvBid4.js} +1 -1
  30. package/dist/ui/assets/{SatiMemories-Cd9xn98_.js → SatiMemories-yyVrJGdc.js} +1 -1
  31. package/dist/ui/assets/{SessionAudit-BTABenGk.js → SessionAudit-joq0ntdJ.js} +1 -1
  32. package/dist/ui/assets/{Settings-DRVx4ICA.js → Settings-B6SMPn41.js} +7 -7
  33. package/dist/ui/assets/{Skills-DS9p1-S8.js → Skills-B5yhTHyn.js} +1 -1
  34. package/dist/ui/assets/{Smiths-CMCZaAF_.js → Smiths-Dug63YED.js} +1 -1
  35. package/dist/ui/assets/{Tasks-Cvt4sTcs.js → Tasks-D8HPLkg0.js} +1 -1
  36. package/dist/ui/assets/{TrinityDatabases-qhSUMeCw.js → TrinityDatabases-D0qEKmwJ.js} +1 -1
  37. package/dist/ui/assets/{UsageStats-Cy9HKYOp.js → UsageStats-CHWALN70.js} +1 -1
  38. package/dist/ui/assets/{WebhookManager-ByqkTyqs.js → WebhookManager-T2ef90p8.js} +1 -1
  39. package/dist/ui/assets/{agents-svEaAPka.js → agents-BVnfnJ1X.js} +1 -1
  40. package/dist/ui/assets/{audit-gxRPR5Jb.js → audit-BErc_ye8.js} +1 -1
  41. package/dist/ui/assets/{chronos-ZrBE4yA4.js → chronos-CAv__H3B.js} +1 -1
  42. package/dist/ui/assets/{config-B1i6Xxwk.js → config-CPFW7PTY.js} +1 -1
  43. package/dist/ui/assets/{index-DyKlGDg1.js → index-BvsF1a9j.js} +2 -2
  44. package/dist/ui/assets/{mcp-DSddQR1h.js → mcp-BaHwY4DW.js} +1 -1
  45. package/dist/ui/assets/{skills-DIuMjpPF.js → skills-lbjIRO8d.js} +1 -1
  46. package/dist/ui/assets/{stats-CxlRAO2g.js → stats-C8KAfpHO.js} +1 -1
  47. package/dist/ui/assets/{useCurrency-BkHiWfcT.js → useCurrency-Ch0lsvGj.js} +1 -1
  48. package/dist/ui/index.html +1 -1
  49. package/dist/ui/sw.js +1 -1
  50. package/package.json +1 -1
@@ -1 +1 @@
1
- import{j as e}from"./vendor-motion-C3CZ8ZlO.js";import{r as n}from"./vendor-react-DikRIOlj.js";import{a as L,b as I,c as y,u as O}from"./chronos-ZrBE4yA4.js";import{D as R}from"./DeleteConfirmationModal-BfV370Vv.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-DyKlGDg1.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
+ 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-CAv__H3B.js";import{D as R}from"./DeleteConfirmationModal-AqGQSh1X.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-BvsF1a9j.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,e as x,j as n,k as c,l as g,B as t}from"./index-DyKlGDg1.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-BvsF1a9j.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};