bunqueue-dashboard 1.0.2 → 1.0.4

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 (123) hide show
  1. package/README.md +8 -7
  2. package/agent/manager/config.ts +2 -1
  3. package/agent/server/handler.ts +2 -1
  4. package/agent/server/router.ts +1 -0
  5. package/agent/server/types.ts +1 -1
  6. package/agent/workflow/runtime.ts +25 -7
  7. package/agent/workflow/runtimeRoutes.ts +4 -1
  8. package/dist/.vite/manifest.json +341 -603
  9. package/dist/assets/AddJob-Dgjlhzn2.js +3 -0
  10. package/dist/assets/Alerts-Lyzbq0qw.js +1 -0
  11. package/dist/assets/{AreaChart-Db2UVnaK.js → AreaChart-CSP0-00u.js} +1 -1
  12. package/dist/assets/Benchmark-B4NfYkAi.js +1 -0
  13. package/dist/assets/{BulkAddJobs-GRMVnf0j.js → BulkAddJobs-BAN5wT8A.js} +3 -3
  14. package/dist/assets/Cron-Bz46oVXB.js +1 -0
  15. package/dist/assets/CronManager-Cl5RW2cB.js +1 -0
  16. package/dist/assets/Database-CeUKS6Nf.js +3 -0
  17. package/dist/assets/Diagnostics-DuzTPfyb.js +1 -0
  18. package/dist/assets/Dlq-D8s-NhV2.js +1 -0
  19. package/dist/assets/DlqControl-DDxRMM8i.js +1 -0
  20. package/dist/assets/DlqPro-xj-MM6u8.js +1 -0
  21. package/dist/assets/Fleet-BAziMWfo.js +1 -0
  22. package/dist/assets/Flows-BFUMTSWv.js +2 -0
  23. package/dist/assets/JobInspector-BXuXxDwR.js +2 -0
  24. package/dist/assets/Jobs-pQBmffni.js +1 -0
  25. package/dist/assets/JobsPro-k20Pas24.js +1 -0
  26. package/dist/assets/Logs-DA4JFvpM.js +1 -0
  27. package/dist/assets/LogsPro-hna5L6sP.js +1 -0
  28. package/dist/assets/McpServer-Cqem-L3z.js +22 -0
  29. package/dist/assets/Metrics-CJ9dW0me.js +1 -0
  30. package/dist/assets/MetricsPro-BslYrx1A.js +1 -0
  31. package/dist/assets/Overview-Cmg_2NAt.js +1 -0
  32. package/dist/assets/Pagination-WVfHLHDS.js +1 -0
  33. package/dist/assets/{QueueActions-BBxRt-t0.js → QueueActions-BQf1-g5m.js} +1 -1
  34. package/dist/assets/QueueControl-BiMM0jLp.js +1 -0
  35. package/dist/assets/QueueDetail-DfRY4jS4.js +1 -0
  36. package/dist/assets/QueueDetailPro-CpSMSo8A.js +1 -0
  37. package/dist/assets/Queues-C5lElTjp.js +1 -0
  38. package/dist/assets/QueuesOverview-DRohFtuC.js +1 -0
  39. package/dist/assets/S3Backup-DUHmp2Xw.js +1 -0
  40. package/dist/assets/S3BackupPro-Cr2ZJZkw.js +3 -0
  41. package/dist/assets/ServerControl-m58ooJT2.js +3 -0
  42. package/dist/assets/Settings-DXsjoOqD.js +1 -0
  43. package/dist/assets/{StatusBadge-DereLzOj.js → StatusBadge-D-mexaga.js} +1 -1
  44. package/dist/assets/Usage-CY2uEJEu.js +1 -0
  45. package/dist/assets/UsagePro-DtlB1dJc.js +1 -0
  46. package/dist/assets/Webhooks-B_GwTCBW.js +1 -0
  47. package/dist/assets/Workers-Bu8aJlZf.js +1 -0
  48. package/dist/assets/WorkersPro-C6gNYGfo.js +1 -0
  49. package/dist/assets/Workflows-ClF4YzhW.js +1 -0
  50. package/dist/assets/{api-D9aT0ND7.js → api-CCgfskjt.js} +1 -1
  51. package/dist/assets/{classicJobsData-Csj4iihY.js → classicJobsData-wdIr-E4y.js} +1 -1
  52. package/dist/assets/connectionStore-B946Fhuv.js +1 -0
  53. package/dist/assets/controlConnectionEpoch-x9VjrWgN.js +1 -0
  54. package/dist/assets/{form-DG3X6cLL.js → form-DBkslwzu.js} +1 -1
  55. package/dist/assets/{icons-DH9SS1DA.js → icons-BIT5aq1c.js} +1 -1
  56. package/dist/assets/index-DR8flo6r.css +1 -0
  57. package/dist/assets/index-X_fHGbXZ.js +8 -0
  58. package/dist/assets/install-hFu5e6YM.js +3 -0
  59. package/dist/assets/package-Bb3FkjoS.js +1 -0
  60. package/dist/assets/react-vendor-08inPAVO.js +11 -0
  61. package/dist/assets/responses-YgpvqWEr.js +1 -0
  62. package/dist/assets/rolldown-runtime-XKyaHtl9.js +1 -0
  63. package/dist/assets/{useControlActionGuard-1i7aFA7E.js → useControlActionGuard-Bx5MkufG.js} +1 -1
  64. package/dist/assets/{useServerActionGuard-CUx8TOAC.js → useServerActionGuard-uiZWD3dS.js} +1 -1
  65. package/dist/assets/useThroughputSeries-BN5QmKPt.js +1 -0
  66. package/dist/index.html +8 -16
  67. package/package.json +46 -56
  68. package/scripts/embedded.gen.ts +140 -154
  69. package/dist/assets/AddJob-CiwWycYG.js +0 -3
  70. package/dist/assets/Alerts-DCKl_C8D.js +0 -1
  71. package/dist/assets/Benchmark-DyHvEM8x.js +0 -1
  72. package/dist/assets/Button-_aSJvRoW.js +0 -1
  73. package/dist/assets/Card-egIDLwVk.js +0 -1
  74. package/dist/assets/Cron-XL0PdUEc.js +0 -1
  75. package/dist/assets/CronManager-Cqtg9Zr8.js +0 -1
  76. package/dist/assets/Database-BBzyi7f0.js +0 -3
  77. package/dist/assets/Diagnostics-E_icHggb.js +0 -1
  78. package/dist/assets/Dlq-DNs32CzV.js +0 -1
  79. package/dist/assets/DlqControl-DawwIsTI.js +0 -1
  80. package/dist/assets/DlqPro-BEdxFiNN.js +0 -1
  81. package/dist/assets/Fleet-Bkbq0dFB.js +0 -1
  82. package/dist/assets/Flows-DKZxI7ta.js +0 -2
  83. package/dist/assets/JobInspector-BARE52q3.js +0 -2
  84. package/dist/assets/Jobs-CKzKpQ7i.js +0 -1
  85. package/dist/assets/JobsPro-DxDw-akG.js +0 -1
  86. package/dist/assets/Logs-Bj60G_FP.js +0 -1
  87. package/dist/assets/LogsPro-Hv8xwXDK.js +0 -1
  88. package/dist/assets/McpServer-zxSMjG8K.js +0 -24
  89. package/dist/assets/Metrics-BBLdWOw1.js +0 -1
  90. package/dist/assets/MetricsPro-D470b1aP.js +0 -1
  91. package/dist/assets/Overview-B_AOa5kW.js +0 -1
  92. package/dist/assets/PageHeader-CQzNsw8r.js +0 -1
  93. package/dist/assets/Pagination-CSkzhNW6.js +0 -1
  94. package/dist/assets/QueueControl-DaZjeZnw.js +0 -1
  95. package/dist/assets/QueueDetail-Dgo9Ukmp.js +0 -1
  96. package/dist/assets/QueueDetailPro-D7U8ahp2.js +0 -1
  97. package/dist/assets/Queues-CS8LeZtJ.js +0 -1
  98. package/dist/assets/QueuesOverview-BySSnCm0.js +0 -1
  99. package/dist/assets/S3Backup-Ci4dJPP_.js +0 -1
  100. package/dist/assets/S3BackupPro-UwWu0yxr.js +0 -3
  101. package/dist/assets/ServerControl-Ch1wZcKB.js +0 -3
  102. package/dist/assets/Settings-FOzwrB25.js +0 -1
  103. package/dist/assets/Usage-DR90dCt0.js +0 -1
  104. package/dist/assets/UsagePro-DAlE3oCE.js +0 -1
  105. package/dist/assets/Webhooks-BonYUgMo.js +0 -1
  106. package/dist/assets/Workers-D1Ead02h.js +0 -1
  107. package/dist/assets/WorkersPro-XuLxtU4A.js +0 -1
  108. package/dist/assets/Workflows-CqZZ96EK.js +0 -1
  109. package/dist/assets/bq-DR2BTISO.js +0 -1
  110. package/dist/assets/connectionStore-CVjQyIZv.js +0 -1
  111. package/dist/assets/controlConnectionEpoch-ChAeMMLk.js +0 -1
  112. package/dist/assets/feedback-CtGN_kqB.js +0 -1
  113. package/dist/assets/format-Cg7VCIZW.js +0 -1
  114. package/dist/assets/index-DZFZr0Mi.js +0 -8
  115. package/dist/assets/index-DaEyLvTR.css +0 -1
  116. package/dist/assets/install-oydLpc1T.js +0 -3
  117. package/dist/assets/react-vendor-CFL9l8LK.js +0 -11
  118. package/dist/assets/responses-BkR2JTH9.js +0 -1
  119. package/dist/assets/rolldown-runtime-QTnfLwEv.js +0 -1
  120. package/dist/assets/toastStore-XmMX7A5W.js +0 -1
  121. package/dist/assets/usePolledData-CEyyLRYa.js +0 -1
  122. package/dist/assets/useThroughputSeries-CeFx-Mwq.js +0 -1
  123. package/patches/ai@7.0.14.patch +0 -25
@@ -1,3 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-CFL9l8LK.js";import{t as r}from"./bq-DR2BTISO.js";import{C as i,T as a,b as o,x as s}from"./icons-DH9SS1DA.js";import{r as c}from"./StatusBadge-DereLzOj.js";import{n as l}from"./usePolledData-CEyyLRYa.js";import{t as u}from"./Button-_aSJvRoW.js";import{n as d,t as f}from"./Card-egIDLwVk.js";import{i as p,n as m,r as h}from"./feedback-CtGN_kqB.js";import{t as g}from"./PageHeader-CQzNsw8r.js";import{f as _,i as v,l as y,n as b,u as x}from"./format-Cg7VCIZW.js";import{a as S}from"./index-DZFZr0Mi.js";import{i as C,n as w,t as T}from"./form-DG3X6cLL.js";import{t as E}from"./useControlActionGuard-1i7aFA7E.js";var D=e(t(),1),O=n();function k({children:e}){return(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs text-fg`,children:e})}function A({agentBase:e}){return(0,O.jsx)(f,{children:(0,O.jsxs)(`details`,{className:`group`,children:[(0,O.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2`,children:[(0,O.jsx)(`span`,{className:`text-base font-semibold text-fg`,children:`How server control works`}),(0,O.jsx)(`span`,{className:`text-xs text-muted transition-transform group-open:rotate-90`,children:`▶`})]}),(0,O.jsxs)(`div`,{className:`mt-4 space-y-4 text-sm leading-relaxed text-muted`,children:[(0,O.jsxs)(`p`,{children:[`A browser can't start or stop an OS process, so the dashboard talks to a small local`,` `,(0,O.jsx)(`span`,{className:`font-medium text-fg`,children:`control agent`}),` (`,(0,O.jsx)(k,{children:e}),`) that supervises the bunqueue server process — start, stop and restart — and streams its logs back here.`]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Launch & environment`}),(0,O.jsxs)(`p`,{children:[`The agent runs your `,(0,O.jsx)(`span`,{className:`text-fg`,children:`Command`}),` and injects`,` `,(0,O.jsx)(k,{children:`HTTP_PORT`}),` and `,(0,O.jsx)(k,{children:`TCP_PORT`}),`, plus `,(0,O.jsx)(k,{children:`BUNQUEUE_DATA_PATH`}),` `,`only for SQLite. Memory and PostgreSQL modes remove every SQLite path alias before launch. Any `,(0,O.jsx)(`span`,{className:`text-fg`,children:`Environment variables`}),` you add are included too. The default `,(0,O.jsx)(k,{children:`bunx bunqueue@2.9.4 start`}),` resolves the verified release; pointing the command at a local entry (e.g.`,` `,(0,O.jsx)(k,{children:`bun run /path/to/bunqueue/src/main.ts`}),`) works without one.`]})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`When changes apply`}),(0,O.jsxs)(`p`,{children:[`Config is editable any time, but `,(0,O.jsx)(`span`,{className:`text-fg`,children:`Command`}),`, ports and data path only take effect on the `,(0,O.jsx)(`span`,{className:`text-fg`,children:`next start/restart`}),` `,`— the running process keeps the config it launched with until then.`]})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Data path`}),(0,O.jsxs)(`p`,{children:[`Relative paths resolve against the `,(0,O.jsx)(`span`,{className:`text-fg`,children:`agent's`}),` working directory. SQLite creates the database `,(0,O.jsx)(`span`,{className:`text-fg`,children:`file`}),` but not its parent `,(0,O.jsx)(`span`,{className:`text-fg`,children:`folder`}),` — if start fails with`,` `,(0,O.jsx)(k,{children:`SQLITE_CANTOPEN`}),`, create the directory first or use a path whose folder already exists.`]})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`mb-1 font-medium text-fg`,children:`Security`}),(0,O.jsxs)(`p`,{children:[`The direct agent listener binds `,(0,O.jsx)(k,{children:`127.0.0.1`}),`, locks CORS to an allowlist (never `,(0,O.jsx)(k,{children:`*`}),`), and rejects a disallowed `,(0,O.jsx)(k,{children:`Origin`}),` or`,` `,(0,O.jsx)(k,{children:`Host`}),` with `,(0,O.jsx)(k,{children:`403`}),`. The all-in-one server's `,(0,O.jsx)(k,{children:`/agent`}),` `,`bridge treats LAN and reverse-proxy access as remote: `,(0,O.jsx)(k,{children:`AGENT_TOKEN`}),` is then mandatory for status, logs, database reads and changes alike. Without it, the bridge stays disabled.`]}),(0,O.jsxs)(`p`,{children:[`If you started the agent with `,(0,O.jsx)(k,{children:`AGENT_TOKEN`}),`, enter that token under`,` `,(0,O.jsx)(`span`,{className:`text-fg`,children:`Settings → Agent token`}),` (or when the lock screen prompts). It stays in memory for this browser session; never bake it into a public`,` `,(0,O.jsx)(k,{children:`VITE_*`}),` value.`]})]})]})]})})}function j(e,t,n,r){return{baseline:F(e),id:r,revision:t,scope:n,value:F(e)}}function ee(e,t,n,r,i){return{accepted:F(e),acceptedRevision:t,before:n?F(n):null,beforeRevision:r,ignoreThroughRequestId:i}}function te(e,t,n,r){return P(t,e.accepted)?!1:r!==void 0&&e.ignoreThroughRequestId!==void 0?r<=e.ignoreThroughRequestId:n===void 0?e.before!==null&&P(t,e.before):n===e.beforeRevision||n===e.acceptedRevision}function M(e){if(!L(e))return R();let{command:t,httpPort:n,tcpPort:r,dataPath:i,extraEnv:a}=e;if(typeof t!=`string`||t.trim()===``||!I(n)||!I(r)||n===r||typeof i!=`string`||!L(a)||Object.values(a).some(e=>typeof e!=`string`))return R();let o=N(e.configRevision);return e.configRevision!==void 0&&o===void 0?R():{config:{command:t,httpPort:n,tcpPort:r,dataPath:i,extraEnv:Object.fromEntries(Object.entries(a))},revision:o}}function N(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0?e:void 0}function ne(e){return I(e.httpPort)?I(e.tcpPort)?e.httpPort===e.tcpPort?`HTTP and TCP ports must differ`:null:`TCP port must be an integer between 1 and 65535`:`HTTP port must be an integer between 1 and 65535`}function re(e,t){if(!e)return[];let n=[];return e.command!==t.command&&n.push(`command`),e.httpPort!==t.httpPort&&n.push(`HTTP port`),e.tcpPort!==t.tcpPort&&n.push(`TCP port`),e.dataPath!==t.dataPath&&n.push(`data path`),z(e.extraEnv)!==z(t.extraEnv)&&n.push(`environment variables`),n}function P(e,t){return JSON.stringify(B(e))===JSON.stringify(B(t))}function F(e){return{...e,extraEnv:{...e.extraEnv}}}function I(e){return typeof e==`number`&&Number.isInteger(e)&&e>=1&&e<=65535}function L(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function R(){throw Error(`Configuration save returned a malformed response`)}function z(e){return JSON.stringify(Object.entries(e).sort(([e],[t])=>e.localeCompare(t)))}function B(e){return{...e,extraEnv:Object.fromEntries(Object.entries(e.extraEnv).sort(([e],[t])=>e.localeCompare(t)))}}var V=0,H=e=>Object.entries(e).map(([e,t])=>({id:V++,key:e,value:t})),U=e=>{let t={};for(let n of e){let e=n.key.trim();e&&(t[e]=n.value)}return t};function W(e){let t=e.map(e=>e.trim());return[...new Set(t.filter((e,t,n)=>e&&n.indexOf(e)!==t))]}var ie=[`AUTH_TOKENS`,`LOG_LEVEL`,`BUNQUEUE_STORAGE_DRIVER`,`BUNQUEUE_POSTGRES_URL`,`BUNQUEUE_POSTGRES_NAMESPACE`,`BUNQUEUE_POSTGRES_POOL_SIZE`,`BUNQUEUE_MAX_COMPLETED_JOBS`,`BUNQUEUE_COMPLETED_RETENTION_MS`,`S3_BACKUP_ENABLED`,`S3_BUCKET`,`METRICS_ENABLED`];function G({value:e,onChange:t,disabled:n}){let[r,i]=(0,D.useState)(()=>H(e)),a=e=>{i(e),t(U(e))},o=(e,t)=>a(r.map(n=>n.id===e?{...n,...t}:n)),s=(e=``)=>a([...r,{id:V++,key:e,value:``}]),c=e=>a(r.filter(t=>t.id!==e)),l=new Set(r.map(e=>e.key.trim()).filter(Boolean)),d=W(r.map(e=>e.key)),f=[...new Set(r.map(e=>e.key.trim()).filter(e=>e&&(/[\s=]/.test(e)||/[a-z]/.test(e))))];return(0,O.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.length===0&&(0,O.jsxs)(`p`,{className:`text-xs leading-relaxed text-faint`,children:[`No custom variables. The agent already injects`,` `,(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1 py-0.5`,children:`HTTP_PORT`}),`,`,` `,(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1 py-0.5`,children:`TCP_PORT`}),`, plus the SQLite data path unless PostgreSQL mode is selected.`]}),r.map(e=>(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`w-2/5 shrink-0`,children:(0,O.jsx)(w,{id:`env-key-${e.id}`,name:`env-key-${e.id}`,"aria-label":`Variable name${e.key?` ${e.key}`:``}`,className:`font-mono`,placeholder:`KEY`,value:e.key,disabled:n,autoComplete:`off`,spellCheck:!1,onChange:t=>o(e.id,{key:t.target.value})})}),(0,O.jsx)(`span`,{className:`text-faint`,children:`=`}),(0,O.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,O.jsx)(w,{id:`env-value-${e.id}`,name:`env-value-${e.id}`,"aria-label":`Value for ${e.key||`variable`}`,className:`font-mono`,placeholder:`value`,value:e.value,disabled:n,autoComplete:`off`,spellCheck:!1,onChange:t=>o(e.id,{value:t.target.value})})}),(0,O.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.key||`variable`}`,disabled:n,onClick:()=>c(e.id),className:`shrink-0 rounded-md px-2 py-1 text-xs text-faint transition-colors hover:text-danger disabled:opacity-40`,children:`✕`})]},e.id)),d.length>0&&(0,O.jsxs)(`p`,{className:`text-xs text-warning`,children:[`Duplicate key`,d.length>1?`s`:``,` — the last value wins: `,d.join(`, `)]}),f.length>0&&(0,O.jsxs)(`p`,{className:`text-xs text-faint`,children:[`Unusual key`,f.length>1?`s`:``,` — env names are usually UPPER_SNAKE_CASE with no spaces or "=": `,f.join(`, `),`. Saved as-is.`]}),(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[(0,O.jsx)(u,{size:`sm`,variant:`ghost`,disabled:n,onClick:()=>s(),children:`+ Add variable`}),ie.filter(e=>!l.has(e)).map(e=>(0,O.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>s(e),className:`rounded-md border border-line bg-surface-2 px-2 py-1 font-mono text-[11px] text-muted transition-colors hover:border-line-strong hover:text-fg disabled:opacity-40`,children:[`+ `,e]},e))]})]})}function K({status:e,onSaved:t,running:n,statusRequestId:a,getStatusRequestSequence:o,transitioning:s}){let c=E(`server-config`),l=(0,D.useRef)(0),p=(0,D.useRef)(null),m=(0,D.useRef)(null),[h,g]=(0,D.useState)(null),[_,v]=(0,D.useState)(!1),[y,b]=(0,D.useState)(!1),[x,S]=(0,D.useState)(null),[C,k]=(0,D.useState)(!1),[A,F]=(0,D.useState)(null);(0,D.useEffect)(()=>{p.current&&clearTimeout(p.current),p.current=null,m.current=null,g(null),v(!1),b(!1),S(null),k(!1),F(null)},[c.scopeKey]),(0,D.useEffect)(()=>{if(!e?.config||_)return;let t=m.current;t&&te(t,e.config,N(e.configRevision),a)||(m.current=null,g(j(e.config,N(e.configRevision),c.scopeKey,++l.current)),k(!1))},[c.scopeKey,_,e?.config,e?.configRevision,a]),(0,D.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]);let I=h?.scope===c.scopeKey?h:null,L=I?.value??e?.config??null;if(!L)return(0,O.jsx)(f,{children:`Loading…`});let R=t=>{let n=I??j(L,N(e?.configRevision),c.scopeKey,++l.current);g({...n,value:{...n.value,...t}}),v(!0),b(!1),k(!1)},z=re(e?.runningConfig??null,L),B=n&&z.length>0,V=s||x!==null,H=()=>{p.current&&clearTimeout(p.current),b(!0),p.current=setTimeout(()=>{p.current=null,b(!1)},2e3)},U=async n=>{let i=c.begin([`config`,`lifecycle`]);if(!i)return;let a=ne(L);if(a)return i.finish(),F(a);let s=I?.baseline??e?.config,u=I?.revision??N(e?.configRevision);if(u===void 0&&s&&e?.config&&!P(s,e.config))return i.finish(),k(!0),F(`Configuration changed elsewhere; reload the latest values before saving.`);F(null),k(!1),S(n?`restart`:`save`);try{let a=await r.control.setConfig(L,u);if(!i.isCurrent())return;let{config:s,revision:d}=M(a);if(m.current=ee(s,d,e?.config??null,N(e?.configRevision),o?.()),g(j(s,d,c.scopeKey,++l.current)),v(!1),n&&await r.control.restart(),!i.isCurrent())return;H(),await t()}catch(e){if(!i.isCurrent())return;let t=e.message;t.startsWith(`Configuration changed since revision`)&&k(!0),F(t)}finally{i.finish()&&S(null)}},W=()=>U(!1);return(0,O.jsxs)(f,{children:[(0,O.jsx)(d,{title:`Configuration`}),(0,O.jsx)(`p`,{className:`mb-3 text-xs text-muted`,children:n?`Ports and data path apply on the next restart — edit freely, then restart.`:`Edit and save; the config is used the next time the server starts.`}),(0,O.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),W()},children:[(0,O.jsx)(T,{label:`Command`,hint:`The exact command the agent runs to launch bunqueue. It receives HTTP_PORT and TCP_PORT; BUNQUEUE_DATA_PATH is injected only for SQLite and removed in non-SQLite modes. The default resolves Bunqueue 2.9.4 with bunx; offline installs can point at a local entry.`,children:(0,O.jsx)(w,{name:`server-command`,autoComplete:`off`,spellCheck:!1,value:L.command,disabled:V,onChange:e=>R({command:e.target.value}),placeholder:`bunx bunqueue@2.9.4 start`})}),(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,O.jsx)(T,{label:`HTTP port`,hint:`Dashboard API + SSE.`,children:(0,O.jsx)(w,{name:`server-http-port`,autoComplete:`off`,type:`number`,min:1,max:65535,value:L.httpPort,disabled:V,onChange:e=>R({httpPort:Number(e.target.value)})})}),(0,O.jsx)(T,{label:`TCP port`,hint:`Binary protocol. Must differ from HTTP.`,children:(0,O.jsx)(w,{name:`server-tcp-port`,autoComplete:`off`,type:`number`,min:1,max:65535,value:L.tcpPort,disabled:V,onChange:e=>R({tcpPort:Number(e.target.value)})})})]}),(0,O.jsx)(T,{label:`Data path`,hint:`Durable SQLite path for the managed broker and Workflow Engine, relative to the agent's working directory. In PostgreSQL mode the agent keeps it for Workflow state but does not pass it to the broker.`,children:(0,O.jsx)(w,{name:`server-data-path`,autoComplete:`off`,spellCheck:!1,value:L.dataPath,disabled:V,onChange:e=>R({dataPath:e.target.value})})}),(0,O.jsx)(T,{label:`Environment variables`,hint:`Injected on start. Includes Bunqueue 2.9.3 completed-history controls: BUNQUEUE_MAX_COMPLETED_JOBS bounds hot memory, while BUNQUEUE_COMPLETED_RETENTION_MS opts into durable age-based expiry. Memory and PostgreSQL modes remove inherited SQLite path aliases. Applies on the next restart.`,children:(0,O.jsx)(G,{value:L.extraEnv??{},onChange:e=>R({extraEnv:e}),disabled:V},I?.id??`initial`)}),(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,O.jsx)(u,{type:`submit`,variant:`accent`,size:`sm`,disabled:V,children:`Save config`}),n&&(0,O.jsxs)(u,{variant:`warning`,size:`sm`,disabled:V,onClick:()=>{let e=z.length>0?` Changed: ${z.join(`, `)}.`:``;if(window.confirm(`Save configuration and restart the server to apply it?${e}`))return U(!0)},children:[(0,O.jsx)(i,{className:`size-3.5`}),` Save & restart`]}),B&&!y&&(0,O.jsx)(`span`,{className:`text-xs text-warning`,children:`Restart to apply changes`}),y&&(0,O.jsx)(`span`,{className:`text-xs text-success`,children:`Saved`}),C&&(0,O.jsx)(u,{type:`button`,variant:`ghost`,size:`sm`,disabled:V,onClick:()=>{e?.config&&(m.current=null,g(j(e.config,N(e.configRevision),c.scopeKey,++l.current)),v(!1),k(!1),F(null))},children:`Reload latest`}),A&&(0,O.jsx)(`span`,{className:`text-xs text-danger`,children:A})]})]})]})}var q=[`all`,`stdout`,`stderr`,`sys`],J=e=>`${new Date(e).toLocaleTimeString([],{hour12:!1})}.${String(e%1e3).padStart(3,`0`)}`,ae=e=>e===`stderr`?`text-danger/90`:e===`sys`?`text-accent/80`:`text-muted`;function oe(e,t=Date.now()){let n=new Blob([e],{type:`text/plain`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`bunqueue-logs-${t}.log`;try{document.body.appendChild(i),i.click()}finally{i.remove(),setTimeout(()=>URL.revokeObjectURL(r),0)}}function se(){let{data:e,error:t,loading:n,refetch:r}=ce(),i=(0,D.useMemo)(()=>e?.lines??[],[e]),[o,s]=(0,D.useState)(`all`),[l,u]=(0,D.useState)(``),[d,g]=(0,D.useState)(!0),[v,y]=(0,D.useState)(!1),b=(0,D.useRef)(null),x=(0,D.useMemo)(()=>{let e=l.trim().toLowerCase();return i.map(e=>e.line.includes(`\x1B`)?{...e,line:_(e.line)}:e).filter(t=>(o===`all`||t.stream===o)&&(!e||t.line.toLowerCase().includes(e)))},[i,o,l]);(0,D.useEffect)(()=>{if(!d)return;let e=b.current;e&&(e.scrollTop=e.scrollHeight)},[x.length,d]);let w=(0,D.useMemo)(()=>x.map(e=>v?`${J(e.ts)} [${e.stream}] ${e.line}`:e.line).join(`
2
- `),[x,v]);return(0,O.jsxs)(f,{padded:!1,className:`overflow-hidden`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-line px-4 py-3`,children:[(0,O.jsx)(`h3`,{className:`mr-1 text-base font-semibold text-fg`,children:`Process logs`}),(0,O.jsx)(C,{options:q,value:o,onChange:s}),(0,O.jsxs)(`div`,{className:`relative min-w-40 flex-1`,children:[(0,O.jsx)(a,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),(0,O.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),"aria-label":`Filter log lines`,name:`process-log-filter`,autoComplete:`off`,placeholder:`Filter…`,className:`h-8 w-full rounded-lg border border-line bg-surface-2 pl-8 pr-2 text-xs text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,O.jsx)(Y,{on:d,onClick:()=>g(e=>!e),label:`Follow`}),(0,O.jsx)(Y,{on:v,onClick:()=>y(e=>!e),label:`Times`}),(0,O.jsx)(S,{value:w}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>{oe(w)},disabled:x.length===0,className:`rounded-md border border-line bg-surface-2 px-2 py-1 text-xs text-muted transition-colors hover:text-fg disabled:opacity-40`,children:`Download`})]}),t&&e&&(0,O.jsx)(`div`,{className:`border-b border-line px-4 pt-3 font-sans`,children:(0,O.jsx)(p,{message:`Process-log refresh failed — showing the last received lines. ${t.message}`,onRetry:r})}),(0,O.jsx)(`div`,{ref:b,className:`max-h-80 min-h-40 overflow-y-auto p-4 font-mono text-xs leading-relaxed`,children:n&&!e&&!t?(0,O.jsx)(`div`,{className:`font-sans`,children:(0,O.jsx)(h,{label:`Loading process logs…`})}):t&&!e?(0,O.jsx)(`div`,{className:`font-sans`,children:(0,O.jsx)(m,{error:t,onRetry:r})}):x.length===0?(0,O.jsx)(`p`,{className:`text-faint`,children:i.length===0?`No output yet.`:`No lines match the current filter.`}):x.map(e=>(0,O.jsxs)(`div`,{className:c(`whitespace-pre-wrap`,ae(e.stream)),children:[v&&(0,O.jsx)(`span`,{className:`mr-2 text-faint`,children:J(e.ts)}),e.line]},e.seq))}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between border-t border-line px-4 py-2 text-[11px] text-faint`,children:[(0,O.jsx)(`span`,{children:t&&!e?`logs unavailable`:x.length===i.length?`${i.length} lines`:`${x.length} of ${i.length} lines`}),(0,O.jsx)(`span`,{children:t?`refresh failed`:d?`following tail`:`paused`})]})]})}function Y({on:e,onClick:t,label:n}){return(0,O.jsx)(`button`,{type:`button`,onClick:t,"aria-pressed":e,className:c(`rounded-md border px-2 py-1 text-xs transition-colors`,e?`border-accent/40 bg-accent/10 text-accent`:`border-line bg-surface-2 text-muted hover:text-fg`),children:n})}function ce(){return l(()=>r.control.logs(),[])}var X={running:{label:`Running`,tone:`text-success`,dot:`bg-emerald-400`},starting:{label:`Starting`,tone:`text-warning`,dot:`bg-amber-400`},stopping:{label:`Stopping`,tone:`text-warning`,dot:`bg-amber-400`},stopped:{label:`Stopped`,tone:`text-danger`,dot:`bg-red-400`}};function Z({startedAt:e}){let[,t]=(0,D.useState)(0);return(0,D.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,O.jsx)(O.Fragment,{children:x((Date.now()-e)/1e3)})}function Q({label:e,children:t,title:n}){return(0,O.jsxs)(`div`,{className:`min-w-0`,title:n,children:[(0,O.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-faint`,children:e}),(0,O.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-sm text-fg`,children:t})]})}function le({status:e,agentBase:t,transitioning:n,stale:r=!1,vitals:a=null,busy:l,onStart:d,onStop:f,onRestart:p}){let m=e?.status??`stopped`,h=e?.managementMode===`external`,g=h?e?.reachable===!0:m===`running`,_=h?e?.healthy?{label:`External`,tone:`text-success`,dot:`bg-emerald-400`}:e?.reachable?{label:`External`,tone:`text-warning`,dot:`bg-amber-400`}:{label:`External`,tone:`text-danger`,dot:`bg-red-400`}:X[m]??X.stopped,y=!!e?.healthy&&!r,b=!h&&!g&&e?.exitCode!=null&&e.exitCode!==0,x=e?.runningConfig??e?.config??null,C=x?.httpPort??6790,w=h?e?.externalUrl??`—`:`http://localhost:${C}`,T=w===`—`?`—`:`${w}/health`;return(0,O.jsxs)(`section`,{className:`mb-6 overflow-hidden rounded-xl border border-line bg-surface`,children:[(0,O.jsx)(`div`,{className:c(`h-0.5 bg-gradient-to-r to-transparent`,g&&y?`from-emerald-400/80 via-emerald-400/25`:g||n?`from-amber-400/80 via-amber-400/25`:`from-red-400/70 via-red-400/20`)}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-5 p-5 lg:flex-row lg:items-center lg:justify-between`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,O.jsxs)(`span`,{className:`relative flex size-3.5 shrink-0`,children:[g&&y&&(0,O.jsx)(`span`,{className:`absolute inline-flex size-full rounded-full bg-emerald-400 opacity-50 motion-safe:animate-ping`}),(0,O.jsx)(`span`,{className:c(`relative inline-flex size-3.5 rounded-full`,_.dot)})]}),(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,O.jsx)(`span`,{className:c(`text-2xl font-bold tracking-tight`,_.tone),children:n&&l?`${l}…`:_.label}),e?.version&&(0,O.jsxs)(`span`,{className:`font-mono text-xs text-muted`,children:[`bunqueue v`,e.version]}),b&&(0,O.jsxs)(`span`,{className:`rounded-full bg-red-500/15 px-2 py-0.5 font-mono text-[11px] font-medium text-danger`,children:[`crashed · exit `,e?.exitCode]})]}),(0,O.jsx)(`div`,{className:`mt-1 font-mono text-xs text-muted`,children:r?(0,O.jsxs)(`span`,{className:`text-warning`,children:[`last known: pid `,e?.pid??`—`,` — agent unreachable, state may have changed`]}):h?(0,O.jsx)(`span`,{title:e?.healthError,children:e?.reachable?y?`healthy via ${T}`:`reachable but unhealthy via ${T}`:`unreachable via ${T}`}):g?(0,O.jsxs)(O.Fragment,{children:[y?`healthy`:`waiting for health…`,` · pid `,e?.pid??`—`,` · up`,` `,e?.startedAt?(0,O.jsx)(Z,{startedAt:e.startedAt}):`—`]}):`process not running — start it below or point the dashboard at an external server`})]})]}),!h&&(0,O.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,O.jsxs)(u,{variant:`success`,disabled:g||n||r,onClick:d,children:[(0,O.jsx)(s,{className:`size-4`}),` Start`]}),(0,O.jsxs)(u,{variant:`warning`,disabled:!g||n||r,onClick:f,children:[(0,O.jsx)(o,{className:`size-4`}),` Stop`]}),(0,O.jsxs)(u,{disabled:n||r,onClick:p,children:[(0,O.jsx)(i,{className:`size-4`}),` Restart`]})]})]}),(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 border-t border-line bg-surface-2/30 px-5 py-4 md:grid-cols-3 xl:grid-cols-7`,children:[(0,O.jsx)(Q,{label:`Memory`,children:a?.memory?.rss==null?(0,O.jsx)(`span`,{className:`text-faint`,children:`—`}):(0,O.jsxs)(`span`,{title:`heap ${a.memory.heapUsed??`?`} / ${a.memory.heapTotal??`?`} MB`,children:[a.memory.rss,` MB rss`]})}),(0,O.jsx)(Q,{label:`Connections`,children:a?.connections?`${a.connections.tcp??0} tcp · ${a.connections.ws??0} ws · ${a.connections.sse??0} sse`:(0,O.jsx)(`span`,{className:`text-faint`,children:`—`})}),(0,O.jsx)(Q,{label:h?`Health target`:`API endpoint`,title:T,children:w===`—`?(0,O.jsx)(`span`,{className:`text-faint`,children:w}):(0,O.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,O.jsx)(`a`,{href:T,target:`_blank`,rel:`noreferrer`,className:`truncate text-accent hover:underline`,children:w}),(0,O.jsx)(S,{value:w})]})}),(0,O.jsx)(Q,{label:h?`Lifecycle`:`Ports`,children:h?`external`:x?`${x.httpPort} http · ${x.tcpPort} tcp`:`—`}),(0,O.jsx)(Q,{label:h?`Health HTTP`:`Started`,children:h?e?.healthStatus??`—`:g&&e?.startedAt?v(e.startedAt):`—`}),(0,O.jsx)(Q,{label:`Control agent`,title:t,children:t.replace(/^https?:\/\//,``)}),(0,O.jsx)(Q,{label:h?`Supervisor`:`Storage`,title:e?.storageMode===`postgres`?`PostgreSQL ${e.postgresTarget??`configured`} · namespace ${e.postgresNamespace??`default`}`:e?.storageMode,children:h?`managed elsewhere`:e?.storageMode===`postgres`?`postgres · ${e.postgresNamespace??`default`}`:e?.storageMode??`—`})]})]})}var $=[{key:`size`,label:`Database`,color:`bg-accent`},{key:`walSize`,label:`WAL`,color:`bg-amber-400`},{key:`shmSize`,label:`SHM`,color:`bg-zinc-500`}];function ue({db:e}){let t=e.totalSize||0;return(0,O.jsxs)(f,{children:[(0,O.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2`,children:[(0,O.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Storage`}),(0,O.jsx)(`span`,{className:`font-mono text-xs text-muted`,children:e.exists?`${b(t)} on disk`:`not created yet`})]}),(0,O.jsxs)(`p`,{className:`mb-4 flex items-center gap-1.5 truncate font-mono text-xs text-faint`,title:e.path,children:[(0,O.jsx)(`span`,{className:`truncate`,children:e.path}),(0,O.jsx)(S,{value:e.path})]}),e.exists&&t>0?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`flex h-2.5 overflow-hidden rounded-full bg-surface-2`,children:$.map(n=>{let r=e[n.key];return r?(0,O.jsx)(`div`,{className:c(`h-full`,n.color),style:{width:`${r/t*100}%`},title:`${n.label}: ${b(r)}`},n.key):null})}),(0,O.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 font-mono text-[11px] text-faint`,children:[$.map(t=>(0,O.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,O.jsx)(`span`,{className:c(`size-2 rounded-full`,t.color)}),t.label,` `,(0,O.jsx)(`span`,{className:`text-fg`,children:b(e[t.key])})]},t.key)),e.mtimeMs?(0,O.jsxs)(`span`,{className:`ml-auto`,children:[`written `,y(e.mtimeMs)]}):null]})]}):(0,O.jsx)(`p`,{className:`rounded-lg border border-dashed border-line px-4 py-6 text-center text-sm text-faint`,children:`The database appears here after the first start — SQLite creates the file at the configured data path.`})]})}function de(){let e=(0,D.useRef)(0),t=(0,D.useRef)(new WeakMap),{data:n,error:i,refetch:a}=l(async()=>{let n=++e.current,i=await r.control.status();return t.current.set(i,n),i},[]),o=E(`server-lifecycle`),[s,c]=(0,D.useState)(null),[u,m]=(0,D.useState)(null);(0,D.useEffect)(()=>{c(null),m(null)},[o.scopeKey]);let h=n?.managementMode===`external`,_=h?n?.reachable===!0:n?.status===`running`,{data:v}=l(()=>_?r.health():Promise.resolve(null),[_]),y=_?v??null:null,b=y?.connections?` This drops ${y.connections.tcp??0} TCP / ${y.connections.ws??0} WS connections; in-flight jobs are interrupted.`:` In-flight jobs are interrupted.`,x=async(e,t,n)=>{let r=o.begin(`lifecycle`);if(r){if(n&&!window.confirm(n)){r.finish();return}if(!r.isCurrent()){r.finish();return}c(e),m(null);try{if(await t(),!r.isCurrent())return;await a()}catch(e){if(!r.isCurrent())return;m(e.message)}finally{r.finish()&&c(null)}}};if(i&&!n)return(0,O.jsxs)(`div`,{children:[(0,O.jsx)(g,{title:`Server`,description:`Start, stop and restart the bunqueue server.`}),(0,O.jsx)(p,{message:`Control agent unreachable — server lifecycle controls are unavailable.`,onRetry:a}),(0,O.jsxs)(f,{children:[(0,O.jsx)(d,{title:`Control agent not running`}),(0,O.jsxs)(`p`,{className:`text-sm text-muted`,children:[`The local control agent is unreachable at`,` `,(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs`,children:r.agentBase}),`. It manages the bunqueue server process (start / stop / restart). Start it with:`]}),(0,O.jsxs)(`pre`,{className:`mt-3 overflow-x-auto rounded-lg border border-line bg-surface-2 px-3 py-2 text-xs`,children:[`bun start`,` `,`# agent + dashboard together (recommended)`,`
3
- `,`bun run agent`,` `,`# agent only, if the dashboard is already running`]}),(0,O.jsx)(`p`,{className:`mt-3 text-xs text-faint`,children:`This page reconnects automatically once the agent is up — no reload needed.`})]})]});let S=n?.status??`stopped`,C=S===`running`,w=S===`starting`||S===`stopping`||s!=null,T=i!=null&&n!=null;return(0,O.jsxs)(`div`,{children:[(0,O.jsx)(g,{title:`Server`,description:h?`Observe the Bunqueue server managed by an external supervisor.`:`Supervise the bunqueue server process — lifecycle, configuration, storage and logs.`}),u&&(0,O.jsx)(`div`,{role:`status`,className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-2 text-sm text-danger`,children:u}),T&&(0,O.jsx)(`div`,{className:`mb-4 rounded-lg border border-amber-500/20 bg-amber-500/5 px-4 py-2 text-sm text-warning`,children:`Control agent unreachable — showing last known state. Lifecycle actions are disabled until it responds again.`}),(0,O.jsx)(le,{status:n,agentBase:r.agentBase,stale:T,vitals:y,transitioning:w,busy:s,onStart:()=>x(`starting`,()=>r.control.start()),onStop:()=>x(`stopping`,()=>r.control.stop(),`Stop the bunqueue server?${b}`),onRestart:()=>x(`restarting`,()=>r.control.restart(),`Restart the bunqueue server?${b}`)}),h?(0,O.jsxs)(f,{children:[(0,O.jsx)(d,{title:`Managed externally`}),(0,O.jsxs)(`p`,{className:`text-sm text-muted`,children:[`This dashboard is attached to`,` `,(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs`,children:n?.externalUrl??`BUNQUEUE_URL`}),`. Start, stop, restart and launch configuration are intentionally unavailable while`,` `,(0,O.jsx)(`code`,{className:`rounded bg-surface-2 px-1.5 py-0.5 text-xs`,children:`BUNQUEUE_MANAGED=0`}),`. Use systemd, Docker, Kubernetes or the broker's external supervisor instead.`]})]}):(0,O.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,O.jsx)(K,{status:n,onSaved:a,running:C,statusRequestId:n?t.current.get(n):void 0,getStatusRequestSequence:()=>e.current,transitioning:w}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[n?.db&&(0,O.jsx)(ue,{db:n.db}),(0,O.jsx)(se,{})]})]}),(0,O.jsx)(`div`,{className:`mt-6`,children:(0,O.jsx)(A,{agentBase:r.agentBase})})]})}export{de as ServerControl};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-CFL9l8LK.js";import{c as r,o as i,s as a}from"./connectionStore-CVjQyIZv.js";import{f as o}from"./icons-DH9SS1DA.js";import{n as s,t as c}from"./Button-_aSJvRoW.js";import{n as l,t as u}from"./Card-egIDLwVk.js";import{t as d}from"./PageHeader-CQzNsw8r.js";import{o as f}from"./index-DZFZr0Mi.js";import{a as p,n as m,t as h}from"./form-DG3X6cLL.js";var g=n(),_=[[`1000`,`1 second`],[`2000`,`2 seconds`],[`3000`,`3 seconds`],[`5000`,`5 seconds`],[`10000`,`10 seconds`]];function v(){let{refreshMs:e,setRefreshMs:t}=i(),{theme:n,setTheme:r}=f();return(0,g.jsxs)(u,{children:[(0,g.jsx)(l,{title:`Appearance & refresh`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,g.jsx)(h,{label:`Theme`,children:(0,g.jsxs)(p,{name:`theme`,autoComplete:`off`,value:n,onChange:e=>r(e.target.value),children:[(0,g.jsx)(`option`,{value:`dark`,children:`Dark`}),(0,g.jsx)(`option`,{value:`light`,children:`Light`})]})}),(0,g.jsx)(h,{label:`Refresh interval`,children:(0,g.jsx)(p,{name:`refresh-interval`,autoComplete:`off`,value:String(e),onChange:e=>t(Number(e.target.value)),children:_.map(([e,t])=>(0,g.jsx)(`option`,{value:e,children:t},e))})})]})]})}var y=e(t(),1),b=1e4,x=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u;async function S(e,t={},n=b){let r=new AbortController,i=t.signal,a=i?AbortSignal.any([i,r.signal]):r.signal,o=Error(`Connection test timed out after ${Math.ceil(n/1e3)} seconds.`),s,c,l=new Promise((e,t)=>{s=setTimeout(()=>{r.abort(o),t(o)},n)}),u=i?new Promise((e,t)=>{let n=()=>{t(i.reason??new DOMException(`Connection test aborted`,`AbortError`))};i.aborted?n():(i.addEventListener(`abort`,n,{once:!0}),c=()=>i.removeEventListener(`abort`,n))}):null;try{let n=(async()=>{let n=await fetch(e,{...t,signal:a});return{response:n,value:await n.json()}})();return await Promise.race(u?[n,l,u]:[n,l])}catch(e){throw r.signal.aborted&&r.signal.reason===o?o:e}finally{s!==void 0&&clearTimeout(s),c?.()}}async function C(e,t={},n=b){let{response:r,value:i}=await S(e,t,n);if(!r.ok&&r.status!==503)throw Error(`HTTP ${r.status}`);if(typeof i!=`object`||!i||Array.isArray(i))throw Error(`Malformed health response`);let a=i;if(typeof a.ok!=`boolean`||a.status!==`healthy`&&a.status!==`degraded`||!Number.isSafeInteger(a.uptime)||a.uptime<0||typeof a.version!=`string`||!x.test(a.version)||a.ok!==(a.status===`healthy`))throw Error(`Malformed health response`);return{response:r,health:a}}function w(){let e=i(),[t,n]=(0,y.useState)(``),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(``),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(``),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(null),[x,w]=(0,y.useState)(null),[T,E]=(0,y.useState)(null),D=(0,y.useRef)(!0),O=(0,y.useRef)(0),k=(0,y.useRef)(null),A=(0,y.useRef)(null),j=(0,y.useCallback)(()=>{A.current!==null&&clearTimeout(A.current),A.current=null,D.current&&E(null)},[]),M=(0,y.useCallback)(()=>{O.current+=1,k.current?.abort(new DOMException(`Connection test superseded`,`AbortError`)),k.current=null,D.current&&(h(null),_(null))},[]),N=(0,y.useCallback)(()=>{M(),j()},[j,M]);(0,y.useEffect)(()=>(D.current=!0,()=>{D.current=!1,O.current+=1,k.current?.abort(new DOMException(`Settings unmounted`,`AbortError`)),A.current!==null&&clearTimeout(A.current)}),[]),(0,y.useEffect)(()=>{let t=e.profiles.find(t=>t.id===e.activeProfileId);n(t?.name??`Bunqueue`),s(e.baseUrl),l(e.agentBaseUrl),d(e.token),p(e.agentToken),b(null),w(null),M()},[e.activeProfileId,e.agentBaseUrl,e.baseUrl,e.profiles,e.token,e.agentToken,M]);let P=()=>{let e=i.getState();return JSON.stringify([e.activeProfileId,e.baseUrl,e.agentBaseUrl,e.token,e.agentToken])},F=async e=>{M();let t=r(e===`server`?o:c);if(!t){e===`server`?b(a):w(a),_({ok:!1,msg:a});return}e===`server`?b(null):w(null);let n=O.current,i=new AbortController,s=P(),l=()=>D.current&&n===O.current&&!i.signal.aborted&&P()===s;k.current=i,h(e),_(null);let d=performance.now();try{if(e===`server`){let{response:e,health:n}=await C(`${t}/health`,{headers:u.trim()?{Authorization:`Bearer ${u.trim()}`}:void 0,signal:i.signal});if(!l())return;let r=e.status===503||n.status===`degraded`;_({ok:!r,msg:`${r?`Server reachable`:`Connected`} in ${Math.round(performance.now()-d)}ms · bunqueue v${n.version}${r?` · degraded`:``}`})}else{let{response:e,value:n}=await S(`${t}/control/status`,{headers:f.trim()?{Authorization:`Bearer ${f.trim()}`}:void 0,signal:i.signal});if(!e.ok)throw Error(`HTTP ${e.status}`);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`Malformed control agent response`);let r=n;if(![`running`,`stopped`,`starting`,`stopping`].includes(String(r.status)))throw Error(`Malformed control agent response`);if(!l())return;_({ok:!0,msg:`Agent connected in ${Math.round(performance.now()-d)}ms · server ${r.status}${r.storageMode?` · ${r.storageMode}`:``}`})}}catch(e){l()&&_({ok:!1,msg:e.message})}finally{D.current&&n===O.current&&(k.current=null,h(null))}},I=()=>{M();let n=r(o),i=r(c);if(b(n?null:a),w(i?null:a),!n||!i)return;let s=e.saveConnection({name:t,baseUrl:n,agentBaseUrl:i,token:u,agentToken:f});j(),E({ok:s.persisted,msg:s.persisted?`Saved ✓`:`Saved for this session only — browser storage unavailable${s.error?`: ${s.error}`:`.`}`}),A.current=setTimeout(()=>D.current&&E(null),4e3)},L=()=>{N(),e.addProfile({name:`Bunqueue ${e.profiles.length+1}`,baseUrl:`http://localhost:6790`,agentBaseUrl:`http://localhost:6800`,token:``,agentToken:``})},R=()=>{let t=e.profiles.find(t=>t.id===e.activeProfileId);!t||!window.confirm(`Remove connection profile "${t.name}"?`)||e.removeProfile(t.id)};return{...e,name:t,setName:n,url:o,setUrl:s,agentUrl:c,setAgentUrl:l,tok:u,setTok:d,agentTok:f,setAgentTok:p,testing:m,result:g,urlError:v,agentUrlError:x,saveNotice:T,edit:N,save:I,add:L,remove:R,testServer:()=>F(`server`),testAgent:()=>F(`agent`)}}function T({id:e,label:t,hint:n,value:r,placeholder:i,onChange:a}){let[c,l]=(0,y.useState)(!1);return(0,g.jsx)(h,{label:t,hint:n,htmlFor:e,children:(0,g.jsxs)(`div`,{className:`relative`,children:[(0,g.jsx)(m,{id:e,name:e,type:c?`text`:`password`,value:r,onChange:e=>a(e.target.value),placeholder:i,className:`pr-10`,autoComplete:`off`,spellCheck:!1}),(0,g.jsx)(s,{"aria-label":c?`Hide ${t.toLowerCase()}`:`Show ${t.toLowerCase()}`,className:`absolute right-0.5 top-1/2 -translate-y-1/2`,onClick:()=>l(e=>!e),children:(0,g.jsx)(o,{className:`size-4`})})]})})}function E(){let e=w(),t=t=>n=>{e.edit(),t(n)};return(0,g.jsxs)(u,{children:[(0,g.jsx)(l,{title:`Bunqueue fleet connections`}),(0,g.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,g.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[1fr_auto_auto]`,children:[(0,g.jsx)(h,{label:`Active node`,children:(0,g.jsx)(p,{"aria-label":`Active Bunqueue node`,value:e.activeProfileId,onChange:t=>e.activateProfile(t.target.value),children:e.profiles.map(e=>(0,g.jsx)(`option`,{value:e.id,children:e.name},e.id))})}),(0,g.jsx)(c,{className:`self-end`,onClick:e.add,children:`Add node`}),(0,g.jsx)(c,{className:`self-end`,variant:`danger`,disabled:e.profiles.length===1,onClick:e.remove,children:`Remove`})]}),(0,g.jsx)(h,{label:`Node name`,children:(0,g.jsx)(m,{name:`profile-name`,value:e.name,onChange:n=>t(e.setName)(n.target.value),maxLength:64,autoComplete:`off`,placeholder:`broker-eu-1`})}),(0,g.jsx)(h,{label:`Server URL`,children:(0,g.jsx)(m,{name:`server-url`,value:e.url,onChange:n=>{t(e.setUrl)(n.target.value)},placeholder:`/api or https://queue.example.com`,autoComplete:`off`,inputMode:`url`,"aria-invalid":e.urlError?!0:void 0,"aria-describedby":e.urlError?`server-url-error`:`server-url-help`})}),e.urlError?(0,g.jsx)(`p`,{id:`server-url-error`,className:`-mt-2 text-xs text-danger`,children:e.urlError}):(0,g.jsx)(`p`,{id:`server-url-help`,className:`-mt-2 text-xs text-faint`,children:`Bunqueue HTTP API for this broker. All queue pages use the selected node.`}),(0,g.jsx)(h,{label:`Control agent URL`,children:(0,g.jsx)(m,{name:`agent-url`,value:e.agentUrl,onChange:n=>t(e.setAgentUrl)(n.target.value),placeholder:`/agent or https://broker.example.com/agent`,autoComplete:`off`,inputMode:`url`,"aria-invalid":e.agentUrlError?!0:void 0,"aria-describedby":e.agentUrlError?`agent-url-error`:`agent-url-help`})}),e.agentUrlError?(0,g.jsx)(`p`,{id:`agent-url-error`,className:`-mt-2 text-xs text-danger`,children:e.agentUrlError}):(0,g.jsx)(`p`,{id:`agent-url-help`,className:`-mt-2 text-xs text-faint`,children:`One paired agent per broker enables lifecycle, configuration, Flow, Workflow and advanced queue controls.`}),(0,g.jsx)(T,{id:`bearer-token`,label:`Bearer token (optional)`,hint:`Server credential, kept in memory only and isolated to this node.`,value:e.tok,onChange:t(e.setTok),placeholder:`only if AUTH_TOKENS is set`}),(0,g.jsx)(T,{id:`agent-token`,label:`Agent token (optional)`,hint:`AGENT_TOKEN for this node, kept in memory only.`,value:e.agentTok,onChange:t(e.setAgentTok),placeholder:`only if AGENT_TOKEN is set`}),(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,g.jsx)(c,{variant:`accent`,onClick:e.save,children:`Save`}),(0,g.jsx)(c,{onClick:e.testServer,children:e.testing===`server`?`Restart test`:`Test connection`}),(0,g.jsx)(c,{onClick:e.testAgent,children:e.testing===`agent`?`Restart agent test`:`Test agent`}),e.saveNotice&&(0,g.jsx)(`span`,{role:`status`,className:e.saveNotice.ok?`text-sm text-success`:`text-sm text-warning`,children:e.saveNotice.msg}),e.result&&(0,g.jsx)(`span`,{role:`status`,className:e.result.ok?`text-sm text-success`:`text-sm text-danger`,children:e.result.msg})]}),(0,g.jsx)(`p`,{className:`-mt-1 text-xs text-faint`,children:`Switching the active node retargets every Dashboard feature atomically. Profile metadata persists; both credentials are erased on reload.`})]})]})}function D(){return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(d,{title:`Settings`,description:`Bunqueue fleet connections, credentials and appearance.`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,g.jsx)(E,{}),(0,g.jsx)(v,{})]})]})}export{D as Settings};
@@ -1 +0,0 @@
1
- import{t as e}from"./react-vendor-CFL9l8LK.js";import{t}from"./api-D9aT0ND7.js";import{n}from"./usePolledData-CEyyLRYa.js";import{n as r,t as i}from"./Card-egIDLwVk.js";import{i as a,n as o,r as s}from"./feedback-CtGN_kqB.js";import{t as c}from"./PageHeader-CQzNsw8r.js";import{l,n as u,s as d,u as f}from"./format-Cg7VCIZW.js";import{r as p}from"./index-DZFZr0Mi.js";var m=e(),h={stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},memory:{heapUsed:0,heapTotal:0,rss:0},workers:{total:0,active:0},crons:{total:0},storage:{}};function g(){let{data:e,error:g,loading:v,refetch:y}=n(()=>t.overview(),[]);if(v&&!e&&!g)return(0,m.jsx)(s,{label:`Loading usage…`});if(g&&!e)return(0,m.jsxs)(`div`,{children:[(0,m.jsx)(c,{title:`Usage`,description:`Cumulative resource usage is unavailable.`}),(0,m.jsx)(o,{error:g,onRetry:y})]});let{stats:b,memory:x,workers:S,crons:C,storage:w}=e??h,T=typeof w.diskFull==`boolean`;return(0,m.jsxs)(`div`,{children:[(0,m.jsx)(c,{title:`Usage`,description:`Cumulative resource usage on the connected server.`,live:!!e&&!g&&T}),g&&(0,m.jsx)(a,{message:`Usage refresh failed — showing the last successful snapshot.`,onRetry:y}),(0,m.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,m.jsx)(p,{label:`Jobs Pushed`,value:d(b.totalPushed)}),(0,m.jsx)(p,{label:`Jobs Completed`,value:d(b.totalCompleted),tone:`green`}),(0,m.jsx)(p,{label:`Jobs Failed`,value:d(b.totalFailed),tone:b.totalFailed?`red`:`default`}),(0,m.jsx)(p,{label:`Jobs Pulled`,value:d(b.totalPulled),tone:`blue`})]}),(0,m.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,m.jsxs)(i,{children:[(0,m.jsx)(r,{title:`Runtime`}),(0,m.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,m.jsx)(_,{label:`Uptime`,value:f(b.uptime/1e3)}),(0,m.jsx)(_,{label:`Heap used`,value:u(x.heapUsed*1024*1024)}),(0,m.jsx)(_,{label:`RSS`,value:u(x.rss*1024*1024)}),(0,m.jsx)(_,{label:`Workers`,value:`${S.active} active / ${S.total}`}),(0,m.jsx)(_,{label:`Cron jobs`,value:String(C.total)})]})]}),(0,m.jsxs)(i,{children:[(0,m.jsx)(r,{title:`Storage`}),(0,m.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,m.jsx)(_,{label:`Status`,value:T?w.diskFull?`Disk full`:`Healthy`:`Unavailable`}),(0,m.jsx)(_,{label:`Disk full since`,value:w.diskFull?l(w.since):`—`}),w.error?(0,m.jsx)(_,{label:`Error`,value:String(w.error)}):null]})]})]})]})}function _({label:e,value:t,mono:n}){return(0,m.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,m.jsx)(`dt`,{className:`text-muted`,children:e}),(0,m.jsx)(`dd`,{className:n?`font-mono text-xs text-fg`:`font-medium text-fg`,children:t})]})}export{g as Usage};
@@ -1 +0,0 @@
1
- import{t as e}from"./react-vendor-CFL9l8LK.js";import{t}from"./bq-DR2BTISO.js";import{n}from"./usePolledData-CEyyLRYa.js";import{n as r,t as i}from"./Card-egIDLwVk.js";import{i as a,n as o,r as s}from"./feedback-CtGN_kqB.js";import{t as c}from"./PageHeader-CQzNsw8r.js";import{c as l,l as u,n as d,s as f,t as p,u as m}from"./format-Cg7VCIZW.js";import{n as h,r as g}from"./index-DZFZr0Mi.js";var _=e(),v={overview:{stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},memory:{heapUsed:0,heapTotal:0,rss:0},crons:{total:0}},storage:{},failedTotal:0};function y(){let{data:e,error:y,loading:x,refetch:S}=n(async()=>{let[e,n,r]=await Promise.all([t.overview(),t.storage(),t.queuesSummary()]);if(!n?.data||typeof n.data.diskFull!=`boolean`)throw Error(`Storage status response is missing disk health data`);if(h(e),!Number.isFinite(e.memory.heapUsed))throw Error(`Malformed /dashboard response: memory.heapUsed is missing or non-numeric.`);let i=r.reduce((e,t)=>e+(t.counts?.failed??0),0);return{overview:e,storage:n.data,failedTotal:i}},[]);if(x&&!e&&!y)return(0,_.jsx)(s,{label:`Loading usage…`});if(y&&!e)return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(c,{title:`Usage`,description:`Cumulative resource usage is unavailable.`}),(0,_.jsx)(o,{error:y,onRetry:S})]});let C=e??v,{stats:w,memory:T,crons:E}=C.overview,{storage:D,failedTotal:O}=C,k=p(w.completed,O),A=w.uptime?m(w.uptime/1e3):`—`;return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(c,{title:`Usage`,description:`Cumulative resource usage on the connected server.`,live:!!e&&!y}),y&&(0,_.jsx)(a,{message:`Usage refresh failed — showing the last successful snapshot.`,onRetry:S}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,_.jsx)(g,{label:`Completed`,value:f(w.completed),tone:`green`}),(0,_.jsx)(g,{label:`Failed`,value:f(O),tone:O?`red`:`default`}),(0,_.jsx)(g,{label:`Waiting`,value:f(w.waiting),tone:`amber`}),(0,_.jsx)(g,{label:`Active`,value:f(w.active),tone:`blue`}),(0,_.jsx)(g,{label:`Error Rate`,value:k==null?`—`:l(k),tone:k==null?`default`:k>.05?`red`:`green`}),(0,_.jsx)(g,{label:`Uptime`,value:A})]}),(0,_.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(i,{children:[(0,_.jsx)(r,{title:`Runtime`}),(0,_.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,_.jsx)(b,{label:`Jobs pushed (since restart)`,value:f(w.totalPushed)}),(0,_.jsx)(b,{label:`Jobs pulled (since restart)`,value:f(w.totalPulled)}),(0,_.jsx)(b,{label:`Heap used`,value:d(T.heapUsed*1024*1024)}),(0,_.jsx)(b,{label:`RSS`,value:d(T.rss*1024*1024)}),(0,_.jsx)(b,{label:`Cron jobs`,value:String(E.total)})]})]}),(0,_.jsxs)(i,{children:[(0,_.jsx)(r,{title:`Storage`}),D.diskFull?(0,_.jsxs)(`div`,{className:`rounded-lg border border-red-500/25 bg-red-500/[0.06] px-4 py-3`,children:[(0,_.jsx)(`div`,{className:`font-semibold text-danger`,children:`Disk full — writes suspended`}),D.error&&(0,_.jsx)(`div`,{className:`mt-1 text-xs text-muted`,children:D.error}),D.since!=null&&(0,_.jsxs)(`div`,{className:`mt-1 text-xs text-faint`,children:[`since `,u(D.since)]})]}):(0,_.jsxs)(`div`,{className:`rounded-lg border border-emerald-500/25 bg-emerald-500/[0.06] px-4 py-3`,children:[(0,_.jsx)(`div`,{className:`font-semibold text-success`,children:`Healthy`}),(0,_.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:`Disk writes are being accepted.`})]})]})]})]})}function b({label:e,value:t}){return(0,_.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,_.jsx)(`dt`,{className:`text-muted`,children:e}),(0,_.jsx)(`dd`,{className:`font-medium text-fg`,children:t})]})}export{y as UsagePro};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-CFL9l8LK.js";import{t as r}from"./bq-DR2BTISO.js";import{t as i}from"./toastStore-XmMX7A5W.js";import{O as a,m as o}from"./icons-DH9SS1DA.js";import{n as s}from"./usePolledData-CEyyLRYa.js";import{n as c,t as l}from"./Button-_aSJvRoW.js";import{n as u,t as d}from"./Card-egIDLwVk.js";import{i as f,n as p,r as m,t as h}from"./feedback-CtGN_kqB.js";import{t as g}from"./PageHeader-CQzNsw8r.js";import{l as _,s as v}from"./format-Cg7VCIZW.js";import{n as y,o as b,t as x}from"./form-DG3X6cLL.js";import{t as S}from"./Pagination-CSkzhNW6.js";import{r as C,t as w}from"./useServerActionGuard-CUx8TOAC.js";var T=[`job.pushed`,`job.started`,`job.completed`,`job.failed`,`job.progress`],E=e(t(),1);function D(e){try{let t=new URL(e);return e.length<=2048&&/^https?:$/.test(t.protocol)&&t.username===``&&t.password===``}catch{return!1}}function O(e){try{let t=new URL(e);return!t.username&&!t.password?e:(t.username=`redacted`,t.password=`redacted`,t.toString())}catch{return e}}function k(e,t,n,r){let i=e.trim();if(!i||t.length===0)return{ok:!1,msg:`URL and at least one event are required`};if(!D(i))return{ok:!1,msg:`URL must be a valid http:// or https:// address without embedded credentials`};let a=n.trim();return a&&(a.length>256||!/^[a-zA-Z0-9_\-.:]+$/.test(a))?{ok:!1,msg:`Queue must be at most 256 characters using letters, numbers, _, -, . or :`}:{ok:!0,body:{url:i,events:t,queue:a||void 0,secret:r.trim()||void 0}}}var A=n();function j({onAdd:e,onAccepted:t,beginAdd:n,scopeKey:r}){let[i,a]=(0,E.useState)(``),[o,s]=(0,E.useState)(``),[c,u]=(0,E.useState)(``),[d,f]=(0,E.useState)([`job.completed`,`job.failed`]),[p,m]=(0,E.useState)(null),[h,g]=(0,E.useState)(!1);(0,E.useEffect)(()=>{g(!1),m(null)},[r]);let _=e=>f(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),v=async()=>{if(h)return;m(null);let r=k(i,d,o,c);if(!r.ok)return m(r.msg);let s=n();if(s){g(!0);try{if(w(await e(r.body),`Add webhook`),!s.isCurrent())return;a(``),u(``),t()}catch(e){s.isCurrent()&&m(e.message)}finally{s.finish()&&g(!1)}}};return(0,A.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),v()},children:[(0,A.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-3`,children:[(0,A.jsx)(`div`,{className:`md:col-span-1`,children:(0,A.jsx)(x,{label:`URL`,children:(0,A.jsx)(y,{value:i,onInput:e=>a(e.currentTarget.value),name:`webhook-url`,type:`url`,maxLength:2048,autoComplete:`url`,placeholder:`https://example.com/hook`})})}),(0,A.jsx)(x,{label:`Queue (optional)`,children:(0,A.jsx)(y,{value:o,onChange:e=>s(e.target.value),name:`webhook-queue`,maxLength:256,autoComplete:`off`,placeholder:`all queues`})}),(0,A.jsx)(x,{label:`Secret (optional)`,children:(0,A.jsx)(y,{type:`password`,autoComplete:`new-password`,name:`webhook-secret`,maxLength:65536,value:c,onChange:e=>u(e.target.value),placeholder:`HMAC signing secret`})})]}),(0,A.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:T.map(e=>(0,A.jsx)(`button`,{type:`button`,"aria-pressed":d.includes(e),onClick:()=>_(e),className:d.includes(e)?`rounded-full bg-accent/15 px-3 py-1 text-xs font-medium text-accent`:`rounded-full border border-line px-3 py-1 text-xs font-medium text-muted hover:text-fg`,children:e},e))}),(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(l,{type:`submit`,variant:`accent`,size:`sm`,disabled:h,children:h?`Adding…`:`Add webhook`}),p&&(0,A.jsx)(`span`,{className:`text-xs text-danger`,children:p})]})]})}function M(e){let[t,n]=(0,E.useState)(0);return(0,E.useEffect)(()=>{t>e-1&&n(e-1)},[t,e]),[Math.min(t,e-1),n]}function N(){let{data:e,error:t,loading:n,refetch:l}=s(()=>r.webhooks(),[]),y=e?.data?.webhooks??[],[x,T]=M(Math.max(1,Math.ceil(y.length/15))),[D,k]=(0,E.useState)(null),[N,P]=(0,E.useState)(new Set),F=C(`webhooks`),[I,L]=(0,E.useState)({}),R=(0,E.useRef)(new Map);(0,E.useEffect)(()=>{k(null),P(new Set),L({}),R.current.clear()},[F.scopeKey]);let z=async e=>{let t=F.begin([`registry-write`,`webhook:${e}`]);if(t){k(null),P(t=>new Set(t).add(e));try{if(w(await r.removeWebhook(e),`Remove webhook`),!t.isCurrent())return;l()}catch(e){if(!t.isCurrent())return;k(e.message)}finally{t.finish()&&P(t=>{let n=new Set(t);return n.delete(e),n})}}},B=(e,t)=>{let n=Symbol(`webhook-toggle`),a=R.current.get(e);if(a){a.desired=t,a.intent=n,L(r=>({...r,[e]:{value:t,intent:n}}));return}let o=F.begin(`webhook:${e}`);if(!o)return;let s={desired:t,intent:n,lease:o};R.current.set(e,s),L(r=>({...r,[e]:{value:t,intent:n}})),(async()=>{try{for(;o.isCurrent()&&R.current.get(e)===s;){let t=s.desired,n=null;try{w(await r.setWebhookEnabled(e,t),`Toggle webhook`)}catch(e){n=e instanceof Error?e:Error(String(e))}if(!o.isCurrent()||R.current.get(e)!==s)return;if(s.desired!==t)continue;if(await l(),!o.isCurrent()||R.current.get(e)!==s)return;if(s.desired!==t)continue;R.current.delete(e);let a=s.intent;L(t=>{if(t[e]?.intent!==a)return t;let{[e]:n,...r}=t;return r}),n&&i.error(`Webhook toggle failed`,n.message);return}}finally{o.finish()}})()};return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(g,{title:`Webhooks`,description:`HTTP callbacks fired on job events.`,live:!!e&&!t}),t&&e&&(0,A.jsx)(f,{message:`Webhook refresh failed — showing the last successful registry.`,onRetry:l}),D&&(0,A.jsx)(`div`,{role:`status`,className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-2 text-sm text-danger`,children:D}),(0,A.jsxs)(d,{className:`mb-6`,children:[(0,A.jsx)(u,{title:`Add webhook`}),(0,A.jsx)(j,{onAdd:e=>r.addWebhook(e),onAccepted:()=>void l(),beginAdd:()=>F.begin([`registry-write`,`add`]),scopeKey:F.scopeKey})]}),t&&!e?(0,A.jsx)(p,{error:t,onRetry:l}):n&&!e?(0,A.jsx)(m,{label:`Loading webhooks…`}):y.length===0?(0,A.jsx)(h,{icon:(0,A.jsx)(o,{}),title:`No webhooks`,hint:`Add one above to receive job-event callbacks.`}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,A.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,A.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`URL`}),(0,A.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Events`}),(0,A.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,A.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Success / Fail`}),(0,A.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Last`}),(0,A.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Enabled`}),(0,A.jsx)(`th`,{className:`w-12 px-5 py-3`})]})}),(0,A.jsx)(`tbody`,{children:y.slice(x*15,x*15+15).map(e=>(0,A.jsxs)(`tr`,{className:`border-b border-line last:border-0 align-top hover:bg-surface-2/40`,children:[(0,A.jsx)(`td`,{className:`max-w-xs truncate px-5 py-3 font-mono text-xs text-fg`,children:O(e.url)}),(0,A.jsx)(`td`,{className:`px-5 py-3 text-xs text-muted`,children:e.events.join(`, `)}),(0,A.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue??`all`}),(0,A.jsxs)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:[(0,A.jsx)(`span`,{className:`text-success`,children:v(e.successCount)}),` / `,(0,A.jsx)(`span`,{className:e.failureCount?`text-danger`:``,children:v(e.failureCount)})]}),(0,A.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:_(e.lastTriggered)}),(0,A.jsx)(`td`,{className:`px-5 py-3`,children:(0,A.jsx)(b,{checked:I[e.id]?.value??e.enabled,label:`${I[e.id]?.value??e.enabled?`Disable`:`Enable`} webhook`,onChange:t=>B(e.id,t)})}),(0,A.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,A.jsx)(c,{"aria-label":`Remove webhook`,disabled:N.has(e.id),onClick:()=>window.confirm(`Remove webhook for ${O(e.url)}?`)&&z(e.id),children:(0,A.jsx)(a,{className:`size-3.5`})})})]},e.id))})]})}),(0,A.jsx)(S,{page:x,pageSize:15,total:y.length,onPageChange:T,label:`webhooks`})]})]})}export{N as Webhooks};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-CFL9l8LK.js";import{A as r}from"./icons-DH9SS1DA.js";import{t as i}from"./api-D9aT0ND7.js";import{n as a}from"./usePolledData-CEyyLRYa.js";import{i as o,n as s,r as c,t as l}from"./feedback-CtGN_kqB.js";import{t as u}from"./PageHeader-CQzNsw8r.js";import{l as d,s as f}from"./format-Cg7VCIZW.js";import{r as p}from"./index-DZFZr0Mi.js";import{t as m}from"./Pagination-CSkzhNW6.js";var h=e(t(),1),g=n(),_=20,v={workers:{total:0,active:0,list:[],truncated:!1}};function y(){let{data:e,error:t,loading:n,refetch:y}=a(()=>i.overview(),[]),[b,x]=(0,h.useState)(0);if(n&&!e&&!t)return(0,g.jsx)(c,{label:`Loading workers…`});if(t&&!e)return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(u,{title:`Workers`,description:`Worker inventory is unavailable.`}),(0,g.jsx)(s,{error:t,onRetry:y})]});let{workers:S}=e??v,C=Math.max(1,Math.ceil(S.list.length/_)),w=Math.min(b,C-1),T=S.list.slice(w*_,w*_+_);return(0,g.jsxs)(`div`,{children:[t&&(0,g.jsx)(o,{message:`Worker refresh failed — showing the last successful inventory.`,onRetry:y}),(0,g.jsx)(u,{title:`Workers`,description:`Registered workers and their throughput.`,live:!!e&&!t}),(0,g.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,g.jsx)(p,{label:`Total`,value:f(S.total),compact:!0}),(0,g.jsx)(p,{label:`Active`,value:f(S.active),tone:`green`,compact:!0})]}),S.list.length===0?(0,g.jsx)(l,{icon:(0,g.jsx)(r,{}),title:`No workers registered`,hint:`Workers appear here once they connect and register with the server.`}):(0,g.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,g.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,g.jsx)(`thead`,{children:(0,g.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,g.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Worker`}),(0,g.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queues`}),(0,g.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,g.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Processed`}),(0,g.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`}),(0,g.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Last Seen`})]})}),(0,g.jsx)(`tbody`,{children:T.map(e=>(0,g.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,g.jsxs)(`td`,{className:`px-5 py-3`,children:[(0,g.jsx)(`div`,{className:`font-medium text-fg`,children:e.name||`worker`}),(0,g.jsx)(`div`,{className:`font-mono text-[11px] text-faint`,children:e.id})]}),(0,g.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queues.join(`, `)||`—`}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:f(e.activeJobs)}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:f(e.processedJobs)}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:f(e.failedJobs)}),(0,g.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:d(e.lastSeen)})]},e.id))})]})}),S.truncated&&(0,g.jsxs)(`p`,{className:`mt-3 text-xs text-amber-400`,children:[`Showing first `,f(S.list.length),` of `,f(S.total),` `,`workers.`]}),(0,g.jsx)(m,{page:w,pageSize:_,total:S.list.length,onPageChange:x,label:`workers`})]})}export{y as Workers};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-CFL9l8LK.js";import{t as r}from"./bq-DR2BTISO.js";import{A as i,O as a}from"./icons-DH9SS1DA.js";import{r as o}from"./StatusBadge-DereLzOj.js";import{n as s}from"./usePolledData-CEyyLRYa.js";import{n as c}from"./Button-_aSJvRoW.js";import{i as l,n as u,r as d,t as f}from"./feedback-CtGN_kqB.js";import{t as p}from"./PageHeader-CQzNsw8r.js";import{l as m,s as h}from"./format-Cg7VCIZW.js";import{r as g}from"./index-DZFZr0Mi.js";import{r as _,t as v}from"./useServerActionGuard-CUx8TOAC.js";var y=e(t(),1),b=n(),x=100,S=`No heartbeat recently — derived from lastSeen`;function C(){let{data:e,error:t,loading:n,refetch:C}=s(async()=>(await r.workers()).data,[]),[T,E]=(0,y.useState)(new Set),[D,O]=(0,y.useState)(null),[k,A]=(0,y.useState)(null),j=_(`workers-pro`);if((0,y.useEffect)(()=>{E(new Set),O(null)},[j.scopeKey]),n&&!e&&!t)return(0,b.jsx)(d,{label:`Loading workers…`});if(t&&!e)return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(p,{title:`Workers`,description:`Worker inventory is unavailable.`}),(0,b.jsx)(u,{error:t,onRetry:C})]});let M=e?.workers??[],N=e?.quarantinedWorkers??[],P=(k?[...M].sort((e,t)=>{let n=k.key===`failed`?e.failedJobs??0:e.lastSeen??0,r=k.key===`failed`?t.failedJobs??0:t.lastSeen??0;return k.dir===`asc`?n-r:r-n}):M).slice(0,x),F=e=>A(t=>t?.key===e?{key:e,dir:t.dir===`desc`?`asc`:`desc`}:{key:e,dir:`desc`}),I=M.filter(e=>e.status===`active`).length,L=M.length-I,R=M.reduce((e,t)=>e+(t.activeJobs??0),0),z=async e=>{if(!window.confirm(`Remove the stale registry record for worker "${e}"? This does not stop the worker process. Continue only after confirming that process is stopped; Bunqueue v2.9.3 workers do not automatically re-register after their heartbeat record is removed.`))return;let t=j.begin(`worker:${e}`);if(t){E(t=>new Set(t).add(e)),O(null);try{if(v(await r.unregisterWorker(e),`Remove stale worker registry record`),!t.isCurrent())return;O({ok:!0,text:`Removed stale registry record for ${e} ✓`}),C()}catch(e){if(!t.isCurrent())return;O({ok:!1,text:`Removal failed: ${e.message}`})}finally{t.finish()&&E(t=>{let n=new Set(t);return n.delete(e),n})}}};return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(p,{title:`Workers`,description:`Registered workers and their throughput.`,live:!!e&&!t}),t&&(0,b.jsx)(l,{message:`Worker refresh failed — showing the last successful inventory.`,onRetry:C}),(0,b.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-5`,children:[(0,b.jsx)(g,{label:`Total`,value:h(M.length+N.length),compact:!0}),(0,b.jsx)(g,{label:`Active`,value:h(I),tone:`green`,compact:!0}),(0,b.jsx)(`div`,{title:S,children:(0,b.jsx)(g,{label:`Stale`,value:h(L),tone:L?`amber`:`default`,compact:!0})}),(0,b.jsx)(g,{label:`Active Jobs`,value:h(R),tone:`blue`,compact:!0}),(0,b.jsx)(g,{label:`Quarantined`,value:h(N.length),tone:N.length?`red`:`default`,compact:!0})]}),N.length>0&&(0,b.jsxs)(`div`,{role:`alert`,className:`mb-4 rounded-lg border border-danger/30 bg-danger/5 p-4`,children:[(0,b.jsxs)(`p`,{className:`text-sm font-medium text-danger`,children:[N.length,` worker registration(s) contain values accepted by Bunqueue 2.9.3 but unsafe to render. Healthy workers remain available below.`]}),(0,b.jsx)(`p`,{className:`mt-1 text-xs text-muted`,children:`Their status and active-job count are unknown, so this dashboard will not offer the registry-only removal action for them.`}),(0,b.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs text-muted`,children:N.slice(0,20).map(e=>(0,b.jsxs)(`li`,{className:`truncate font-mono`,children:[`#`,e.index+1,` `,e.id??`(unaddressable id)`,` — `,e.reason]},`${e.index}:${e.id??`unknown`}`))})]}),D&&(0,b.jsx)(`div`,{className:o(`mb-3 text-sm`,D.ok?`text-success`:`text-danger`),children:D.text}),M.length===0?(0,b.jsx)(f,{icon:(0,b.jsx)(i,{}),title:N.length?`No renderable workers`:`No workers registered`,hint:N.length?`Malformed registrations are isolated above instead of taking down the inventory.`:`Workers appear here once they connect and register with the server.`}):(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,b.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Worker`}),(0,b.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queues`}),(0,b.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,b.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,b.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Processed`}),(0,b.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:(0,b.jsx)(w,{label:`Failed`,active:k?.key===`failed`?k.dir:null,onClick:()=>F(`failed`)})}),(0,b.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:(0,b.jsx)(w,{label:`Last Seen`,active:k?.key===`lastSeen`?k.dir:null,onClick:()=>F(`lastSeen`)})}),(0,b.jsx)(`th`,{className:`w-16 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,b.jsx)(`tbody`,{children:P.map(e=>(0,b.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,b.jsxs)(`td`,{className:`px-5 py-3`,children:[(0,b.jsx)(`div`,{className:`font-medium text-fg`,children:e.name||`worker`}),(0,b.jsx)(`div`,{className:`font-mono text-[11px] text-faint`,children:e.id})]}),(0,b.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queues.join(`, `)||`—`}),(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(`span`,{title:e.status===`active`?void 0:S,className:o(`rounded-full px-2 py-0.5 text-[11px] font-medium`,e.status===`active`?`bg-emerald-500/10 text-success`:`bg-amber-500/10 text-warning`),children:e.status})}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:h(e.activeJobs)}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:h(e.processedJobs)}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:h(e.failedJobs)}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:m(e.lastSeen)}),(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(`div`,{className:`flex justify-end`,children:e.status===`stale`&&e.activeJobs===0?(0,b.jsx)(c,{"aria-label":`Remove stale registry record for worker ${e.id}`,title:`Registry cleanup only — does not stop the worker process`,disabled:T.has(e.id),onClick:()=>z(e.id),children:(0,b.jsx)(a,{className:`size-3.5`})}):(0,b.jsx)(`span`,{className:`text-xs text-faint`,title:e.status===`stale`?`Registry cleanup is blocked while active jobs are reported`:`Only stale, idle registry records can be removed`,children:`—`})})})]},e.id))})]})}),M.length>x&&(0,b.jsxs)(`p`,{className:`mt-3 text-xs text-warning`,children:[`Showing first `,h(x),` of `,h(M.length),` workers.`]})]})}function w({label:e,active:t,onClick:n}){return(0,b.jsxs)(`button`,{type:`button`,onClick:n,title:`Sort by ${e}`,className:o(`inline-flex items-center gap-1 uppercase tracking-wider transition-colors hover:text-fg`,t?`text-fg`:`text-faint`),children:[e,(0,b.jsx)(`span`,{"aria-hidden":`true`,children:t===`desc`?`↓`:t===`asc`?`↑`:``})]})}export{C as WorkersPro};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t,g as n,l as r,t as i}from"./react-vendor-CFL9l8LK.js";import{a}from"./connectionStore-CVjQyIZv.js";import{t as o}from"./upstreamPaths-DQeKSxGc.js";import{s,t as c}from"./bq-DR2BTISO.js";import{t as l}from"./toastStore-XmMX7A5W.js";import{r as u,t as d}from"./StatusBadge-DereLzOj.js";import{n as f}from"./usePolledData-CEyyLRYa.js";import{t as p}from"./Card-egIDLwVk.js";import{i as m,n as h,r as g,t as _}from"./feedback-CtGN_kqB.js";import{t as v}from"./PageHeader-CQzNsw8r.js";import{a as y,i as b,l as x}from"./format-Cg7VCIZW.js";import{n as S,t as C}from"./controlConnectionEpoch-ChAeMMLk.js";import{t as w}from"./useControlActionGuard-1i7aFA7E.js";var T={"/workflows":{id:`overview`,label:`Overview`,description:`The complete durable command center for Bunqueue Workflow Engine.`,kind:`active`,state:``},"/workflows/executions":{id:`executions`,label:`Executions`,description:`Inspect every active execution, step record, decision, and nested run.`,kind:`active`,state:``},"/workflows/waiting":{id:`waiting`,label:`Waiting & Signals`,description:`Focus on parked executions and their durable signal payloads.`,kind:`active`,state:`waiting`,lockKind:!0,lockState:!0},"/workflows/compensation":{id:`compensation`,label:`Compensation`,description:`See running, completed, skipped, failed, and parked saga compensation outcomes.`,kind:`active`,state:`compensation`,lockKind:!0,lockState:!0},"/workflows/archive":{id:`archive`,label:`Archive`,description:`Audit terminal executions retained by Workflow Engine archival.`,kind:`archive`,state:``,lockKind:!0}};function ee(e){return T[e]??T[`/workflows`]}function te(e,t){return e?.source===`link`||e&&t.some(t=>t.id===e.id)?e:t[0]?{id:t[0].id,source:`page`}:null}var E=e(n(),1),ne=[`waiting`,`failed`,`compensation-stuck`];async function re(e,t){let[n,r]=await Promise.all([e.stats(),e.list(t)]);return{stats:n,page:r}}async function ie(e,t){let[n,...r]=await Promise.all([e.stats(),...ne.map(n=>e.list({kind:`active`,state:n,limit:t,offset:0}))]),i=r.flatMap(e=>e.executions).sort(ae).slice(0,t);return{stats:n,page:{ok:r.every(e=>e.ok),available:r.every(e=>e.available),executions:i,total:r.reduce((e,t)=>e+t.total,0),limit:t,offset:0}}}function ae(e,t){return t.createdAt-e.createdAt||t.id.localeCompare(e.id)}var D=new Set([`summary`,`history`,`payloads`]),oe=new Set([`running`,`waiting`,`completed`,`failed`,`compensating`,`compensation-stuck`,`compensation`]);function O(e,t){let n=e.get(`kind`),r=t.id===`executions`&&(n===`active`||n===`archive`)?n:t.kind,i=t.id===`overview`?``:ce(e.get(`workflow`)),a=ue(e.get(`state`),t),s=t.id===`overview`?0:le(e.get(`offset`)),c=e.get(`execution`),l=c&&o(c,`Workflow execution id`)===null?c:null,u=e.get(`tab`),d=t.id===`overview`||t.id===`executions`;return{kind:r,workflowName:i,state:a,offset:s,executionId:l,tab:l&&d&&D.has(u)?u:`summary`}}function k(e,t){let n=new URLSearchParams;return e.id===`executions`&&t.kind===`archive`&&n.set(`kind`,`archive`),e.id!==`overview`&&t.workflowName&&n.set(`workflow`,t.workflowName),j(e)&&t.state&&n.set(`state`,t.state),e.id!==`overview`&&t.offset>0&&n.set(`offset`,String(t.offset)),t.executionId&&n.set(`execution`,t.executionId),t.executionId&&t.tab!==`summary`&&(e.id===`overview`||e.id===`executions`)&&n.set(`tab`,t.tab),n}function A(e,t,n){return k(t,{...O(e,t),...n})}function se(e){return D.has(e)}function ce(e){return e&&e.length<=256?e:``}function le(e){if(!e||!/^(0|[1-9]\d*)$/.test(e))return 0;let t=Number(e);return Number.isSafeInteger(t)&&t<=1e6?Math.floor(t/25)*25:0}function ue(e,t){return j(t)?e?t.id===`archive`?e===`completed`||e===`failed`?e:``:oe.has(e)?e:``:``:t.state}function j(e){return e.id===`executions`||e.id===`archive`}var de=e=>`${e}?target=${encodeURIComponent(a())}`,M=e=>({method:`POST`,headers:e===void 0?void 0:{"Content-Type":`application/json`},body:e===void 0?void 0:JSON.stringify(e)});async function N(e,t){return(await s(de(e),t)).result}var P={status:()=>N(`/workflows/runtime`),reload:()=>N(`/workflows/runtime/reload`,M()),start:async(e,t)=>(await N(`/workflows/start`,M({workflowName:e,input:t}))).run,signal:async(e,t,n)=>{await N(`/workflows/${encodeURIComponent(e)}/signal`,M({event:t,payload:n}))},recover:async()=>(await N(`/workflows/recover`,M())).recovered,resumeCompensation:async e=>{await N(`/workflows/${encodeURIComponent(e)}/resume-compensation`,M())},abandonCompensation:async e=>{await N(`/workflows/${encodeURIComponent(e)}/abandon-compensation`,M())},archive:async(e,t)=>(await N(`/workflows/archive`,M({maxAgeMs:e,states:t}))).affected,cleanup:async(e,t)=>(await N(`/workflows/cleanup`,M({maxAgeMs:e,states:t}))).affected},fe={stats:()=>c.workflows.stats(),list:e=>c.workflows.list(e),get:(e,t)=>c.workflows.get(e,t)};function pe(e){let[n,r]=t(),i=n.toString(),a=(0,E.useMemo)(()=>O(new URLSearchParams(i),e),[i,e]),o=(0,E.useMemo)(()=>k(e,a).toString(),[e,a]),s=(0,E.useRef)(null);(0,E.useEffect)(()=>{o!==i&&r(o,{replace:!0})},[o,i,r]);let c=(0,E.useCallback)((t,n=!1)=>{r(n=>A(n,e,t),{replace:n})},[e,r]),l=(0,E.useCallback)((e,t=!1)=>{s.current=e,c({executionId:e?.id??null,tab:`summary`},t)},[c]),u=a.executionId?{id:a.executionId,source:s.current?.id===a.executionId?s.current.source:`link`}:null;return{...a,selected:u,update:c,select:l}}function F(e){let t=S(),n=`workflow-command:${e.operationGroup}`,r=w(n),i=(0,E.useMemo)(()=>({local:e.scopeKey,connectionEpoch:t}),[t,e.scopeKey]),a=(0,E.useRef)(e);a.current=e;let o=(0,E.useRef)(null),s=(0,E.useRef)(!0),c=(0,E.useRef)(i),l=(0,E.useRef)(0);if(!Object.is(c.current,i)){let e=c.current.connectionEpoch!==t;c.current=i,l.current+=1,e&&(o.current=null)}let[u,d]=(0,E.useState)(()=>I(i,t));(0,E.useEffect)(()=>(s.current=!0,()=>{s.current=!1,l.current+=1,o.current=null}),[]);let f=(e,t)=>s.current&&e===l.current&&t===C(),p=async(e,c)=>{if(o.current||t!==C())return;let u=r.begin(n);if(!u)return;let p=Symbol(`workflow-command`);o.current=p;let m=l.current,h=t,{onApplied:g,onSucceeded:_}=a.current;try{d({connectionEpoch:t,scope:i,busy:e,error:``,receipt:null});let n=await c();if(!f(m,h))return;d({connectionEpoch:t,scope:i,busy:e,error:``,receipt:{label:e,value:n}});try{_?.(e,n)}catch{}try{await g?.()}catch(e){f(m,h)&&d(t=>({...t,error:`Command succeeded; refresh failed: ${L(e)}`}))}}catch(n){f(m,h)&&d({connectionEpoch:t,scope:i,busy:e,error:L(n),receipt:null})}finally{u.finish(),o.current===p&&(o.current=null,s.current&&h===C()&&d(e=>({...e,busy:``})))}},m=Object.is(u.scope,i)?u:I(i,t);return{busy:u.connectionEpoch===t?u.busy:``,error:m.error,result:m.receipt?.value,succeeded:m.receipt?.label??``,run:p,clearResult:()=>d(e=>({...e,receipt:null}))}}function I(e,t){return{connectionEpoch:t,scope:e,busy:``,error:``,receipt:null}}function L(e){return e instanceof Error?e.message:String(e)}var R=i(),z=e=>JSON.stringify(e,null,2)??`null`;function B({value:e,empty:t=`None`}){return e==null||typeof e==`object`&&Object.keys(e).length===0?(0,R.jsx)(`p`,{className:`text-xs text-faint`,children:t}):(0,R.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words rounded-lg border border-line bg-surface-2 p-3 font-mono text-xs leading-5 text-muted`,children:z(e)})}function V({label:e,value:t}){return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{className:`text-faint`,children:e}),(0,R.jsx)(`dd`,{className:`mt-0.5 break-words text-muted`,children:t})]})}var me=3600*1e3;function he({repository:e=P,onApplied:t}){let[n,r]=(0,E.useState)(`720`),[i,a]=(0,E.useState)(!0),[o,s]=(0,E.useState)(!0),c=F({operationGroup:`maintenance`,scopeKey:(0,E.useMemo)(()=>Symbol(`workflow-maintenance:${n.length}:${i}:${o}`),[i,o,n]),onApplied:t}),l=[...i?[`completed`]:[],...o?[`failed`]:[]],u=n.trim()===``?NaN:Number(n),d=Number.isFinite(u)&&u>=0&&l.length>0,f=t=>{if(!d)return;let n=t===`archive`?`Archive ${l.join(` and `)} workflows at least ${u} hours old?`:`Permanently delete ${l.join(` and `)} workflows at least ${u} hours old from the active execution store? Archive records are not deleted.`;if(!window.confirm(n))return;let r=Math.round(u*me);c.run(t,async()=>({operation:t,affected:t===`archive`?await e.archive(r,l):await e.cleanup(r,l)}))};return(0,R.jsxs)(`section`,{className:`mb-5 rounded-lg border border-line bg-surface p-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Retention operations`}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Archive moves terminal runs into retention. Cleanup permanently deletes eligible terminal runs from the active store only; archive records remain intact.`})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Minimum age (hours)`,(0,R.jsx)(`input`,{"aria-label":`Workflow retention age hours`,type:`number`,min:`0`,step:`1`,value:n,onChange:e=>r(e.target.value),className:`mt-1 block h-9 w-32 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`})]}),(0,R.jsxs)(`label`,{className:`flex h-9 items-center gap-2 text-xs text-muted`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked)}),`Completed`]}),(0,R.jsxs)(`label`,{className:`flex h-9 items-center gap-2 text-xs text-muted`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Failed`]})]})]}),(0,R.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:!d||!!c.busy,onClick:()=>f(`archive`),className:`rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:`Archive eligible`}),(0,R.jsx)(`button`,{type:`button`,disabled:!d||!!c.busy,onClick:()=>f(`cleanup`),className:`rounded-md border border-danger/40 px-3 py-2 text-xs text-danger disabled:opacity-40`,children:`Delete eligible`})]}),c.error&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:c.error}),c.result!==void 0&&(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(B,{value:c.result})})]})}var ge=[[`Active`,`activeTotal`,`text-fg`],[`Running`,`running`,`text-blue-400`],[`Waiting`,`waiting`,`text-warning`],[`Completed`,`completed`,`text-success`],[`Failed`,`failed`,`text-danger`],[`Compensating`,`compensating`,`text-violet-400`],[`Stuck`,`compensation-stuck`,`text-danger`]];function _e({stats:e}){return(0,R.jsx)(`dl`,{className:`mb-4 grid grid-cols-2 divide-x divide-y divide-line overflow-hidden rounded-lg border border-line bg-surface sm:grid-cols-4 xl:grid-cols-7 xl:divide-y-0`,children:ge.map(([t,n,r])=>(0,R.jsxs)(`div`,{className:`px-3 py-2.5 first:border-0`,children:[(0,R.jsx)(`dt`,{className:`text-[10px] font-medium uppercase tracking-wider text-faint`,children:t}),(0,R.jsx)(`dd`,{className:u(`mt-1 tnum font-mono text-lg font-semibold`,r),children:n===`activeTotal`?e.activeTotal:e.states[n]})]},n))})}function ve({repository:e=P,onApplied:t}){let[n,r]=(0,E.useState)(``),[i,a]=(0,E.useState)(`{}`),o=(0,E.useMemo)(()=>Symbol(`workflow-runtime:${n.length}:${i.length}`),[i,n]),s=f(()=>e.status(),[e],{intervalMs:5e3}),c=F({operationGroup:`runtime`,scopeKey:o,onApplied:async()=>{await s.refetch(),await t?.()}}),l=s.data?.ready===!0;return(0,R.jsxs)(`section`,{className:`mb-5 overflow-hidden rounded-lg border border-line bg-surface`,children:[(0,R.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-line px-4 py-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Workflow runtime`}),(0,R.jsx)(`p`,{className:`mt-0.5 text-xs text-faint`,children:`Registered application handlers stay in the agent-side runtime; commands never edit SQLite directly.`})]}),(0,R.jsx)(ye,{ready:l,configured:s.data?.configured===!0,unavailable:!!(s.error&&!s.data)})]}),s.data?.configured&&(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-x-5 gap-y-1 border-b border-line px-4 py-2 text-[11px] text-faint`,children:[(0,R.jsxs)(`span`,{children:[`Module`,` `,(0,R.jsx)(`strong`,{className:`font-mono font-medium text-muted`,children:s.data.moduleName??`—`})]}),(0,R.jsxs)(`span`,{children:[`Queue`,` `,(0,R.jsx)(`strong`,{className:`font-mono font-medium text-muted`,children:s.data.queueName??`—`})]}),(0,R.jsxs)(`span`,{children:[`Concurrency`,` `,(0,R.jsx)(`strong`,{className:`font-mono font-medium text-muted`,children:s.data.concurrency??`—`})]})]}),s.error&&s.data&&(0,R.jsx)(m,{message:`Runtime status refresh failed; showing the last snapshot.`,onRetry:s.refetch}),s.error&&!s.data&&(0,R.jsx)(`div`,{className:`p-4`,children:(0,R.jsx)(h,{error:s.error,onRetry:s.refetch})}),(0,R.jsxs)(`div`,{className:`grid gap-5 p-4 lg:grid-cols-[minmax(0,1fr)_auto]`,children:[(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Registered workflow`,(0,R.jsx)(`input`,{"aria-label":`Registered workflow`,list:`workflow-runtime-names`,value:n,onChange:e=>r(e.target.value),className:`mt-1 h-9 w-full rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`}),(0,R.jsx)(`datalist`,{id:`workflow-runtime-names`,children:s.data?.workflowNames.map(e=>(0,R.jsx)(`option`,{value:e},e))})]}),(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Input JSON`,(0,R.jsx)(`textarea`,{"aria-label":`Workflow input JSON`,value:i,onChange:e=>a(e.target.value),className:`mt-1 min-h-20 w-full resize-y rounded-lg border border-line bg-surface-2 p-2 font-mono text-xs text-fg`})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap content-start gap-2 lg:w-48 lg:flex-col`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:!l||!n.trim()||!!c.busy,onClick:()=>{let t;try{t=JSON.parse(i)}catch{c.run(`start`,async()=>{throw Error(`Workflow input must be valid JSON.`)});return}c.run(`start`,()=>e.start(n.trim(),t))},className:`rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:c.busy===`start`?`Starting…`:`Start execution`}),(0,R.jsx)(`button`,{type:`button`,disabled:!l||!!c.busy,onClick:()=>{window.confirm(`Recover every orphaned workflow using the registered idempotent handlers?`)&&c.run(`recover`,()=>e.recover())},className:`rounded-md border border-line px-3 py-2 text-xs text-muted disabled:opacity-40`,children:`Recover orphaned`}),(0,R.jsx)(`button`,{type:`button`,disabled:!s.data?.configured||!!c.busy,onClick:()=>void c.run(`reload`,()=>e.reload()),className:`rounded-md border border-line px-3 py-2 text-xs text-muted disabled:opacity-40`,children:`Reload definitions`})]})]}),!s.loading&&!s.error&&!s.data?.configured&&(0,R.jsxs)(`p`,{className:`border-t border-line px-4 py-3 text-xs text-warning`,children:[`Set `,(0,R.jsx)(`code`,{children:`BUNQUEUE_WORKFLOW_MODULE`}),` to an absolute module path in Server → Extra environment, then start the managed server.`]}),s.data?.error&&(0,R.jsx)(`p`,{role:`alert`,className:`border-t border-line px-4 py-3 text-xs text-danger`,children:s.data.error}),c.error&&(0,R.jsx)(`p`,{role:`alert`,className:`border-t border-line px-4 py-3 text-xs text-danger`,children:c.error}),c.result!==void 0&&(0,R.jsx)(`div`,{className:`border-t border-line p-4`,children:(0,R.jsx)(B,{value:c.result})})]})}function ye({ready:e,configured:t,unavailable:n}){return(0,R.jsx)(`span`,{className:e?`rounded-full bg-success/10 px-2 py-1 text-[11px] text-success`:`rounded-full bg-warning/10 px-2 py-1 text-[11px] text-warning`,children:e?`Handlers loaded`:n?`Status unavailable`:t?`Unavailable`:`Not configured`})}var be=[``,`running`,`waiting`,`completed`,`failed`,`compensating`,`compensation-stuck`,`compensation`];function xe({section:e,kind:t,workflowName:n,state:r,stats:i,total:a,onKind:o,onWorkflowName:s,onState:c}){return(0,R.jsx)(p,{className:`mb-5`,children:(0,R.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[e.lockKind?(0,R.jsx)(H,{label:`Store`,value:`${e.kind}${e.kind===`archive`&&i?` · ${i.archiveTotal}`:``}`,capitalize:!0}):(0,R.jsx)(Se,{kind:t,archiveTotal:i?.archiveTotal,onChange:o}),(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Workflow`,(0,R.jsxs)(`select`,{value:n,onChange:e=>s(e.target.value),className:`mt-1 block h-9 min-w-48 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:[(0,R.jsx)(`option`,{value:``,children:`All workflows`}),i?.workflowNames.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})]}),e.lockState?(0,R.jsx)(H,{label:`State scope`,value:e.state===`compensation`?`Compensating + stuck`:e.state}):(0,R.jsx)(Ce,{state:r,onChange:c}),a!==void 0&&(0,R.jsxs)(`span`,{className:`ml-auto text-xs text-faint`,children:[a,` execution`,a===1?``:`s`]})]})})}function Se({kind:e,archiveTotal:t,onChange:n}){return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`mb-1 block text-xs text-faint`,children:`Store`}),(0,R.jsx)(`div`,{className:`flex rounded-lg border border-line p-0.5`,children:[`active`,`archive`].map(r=>(0,R.jsxs)(`button`,{type:`button`,"aria-pressed":e===r,onClick:()=>n(r),className:u(`rounded-md px-3 py-1.5 text-xs capitalize`,e===r?`bg-surface-2 text-fg`:`text-muted hover:text-fg`),children:[r,r===`archive`&&t!==void 0?` (${t})`:``]},r))})]})}function Ce({state:e,onChange:t}){return(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`State`,(0,R.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),className:`mt-1 block h-9 min-w-44 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:be.map(e=>(0,R.jsx)(`option`,{value:e,children:e===`compensation`?`All compensation`:e||`All states`},e||`all`))})]})}function H({label:e,value:t,capitalize:n=!1}){return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`mb-1 block text-xs text-faint`,children:e}),(0,R.jsx)(`span`,{className:u(`inline-flex h-9 items-center rounded-lg border border-line bg-surface-2 px-3 text-xs text-fg`,n&&`capitalize`),children:t})]})}function we({label:e=`Workflow`,value:t,stats:n,onChange:r}){return(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[e,(0,R.jsxs)(`select`,{value:t,onChange:e=>r(e.target.value),className:`mt-1 block h-9 min-w-52 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:[(0,R.jsx)(`option`,{value:``,children:`All workflows`}),n?.workflowNames.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})]})}function Te(e){return e.section.id===`overview`?null:e.section.id===`executions`?(0,R.jsx)(xe,{...e}):(0,R.jsxs)(`div`,{className:`mb-5 flex items-end gap-4 rounded-lg border border-line bg-surface px-4 py-3`,children:[(0,R.jsx)(we,{value:e.workflowName,stats:e.stats,onChange:e.onWorkflowName}),e.section.id===`archive`&&(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Outcome`,(0,R.jsxs)(`select`,{value:e.state,onChange:t=>e.onState(t.target.value),className:`mt-1 block h-9 min-w-36 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:[(0,R.jsx)(`option`,{value:``,children:`All outcomes`}),(0,R.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,R.jsx)(`option`,{value:`failed`,children:`Failed`})]})]}),(0,R.jsxs)(`span`,{className:`ml-auto pb-2 text-xs text-faint`,children:[e.total??0,` `,e.section.id===`archive`?`records`:`executions`]})]})}function Ee(e){let t=[{id:`execution-started`,at:e.createdAt,title:`Execution started`,detail:e.workflowName,status:`running`,category:`execution`}];for(let[n,r]of Object.entries(e.steps))t.push(...De(n,r));for(let n of Object.keys(e.signals))t.push({id:`signal:${n}`,title:`Signal persisted: ${n}`,detail:`The store does not expose an exact signal timestamp.`,category:`signal`});return e.state!==`running`&&e.state!==`waiting`&&t.push({id:`execution-settled`,at:e.updatedAt,title:`Execution ${e.state}`,detail:e.failureReason,status:e.state,category:`execution`}),t.sort(Oe)}function De(e,t){let n=[];return t.startedAt!==void 0&&n.push({id:`step:${e}:started`,at:t.startedAt,title:`Step started: ${e}`,detail:t.attempts?`Attempt ${t.attempts}`:void 0,status:`running`,category:`step`}),(t.completedAt!==void 0||t.status===`failed`)&&n.push({id:`step:${e}:settled`,at:t.completedAt,title:`Step ${t.status}: ${e}`,detail:t.error,status:t.status,category:`step`}),t.compensation&&n.push({id:`step:${e}:compensation`,at:t.compensation.at,title:`Compensation ${t.compensation.status}: ${e}`,detail:t.compensation.error,status:t.compensation.status,category:`compensation`}),n}function Oe(e,t){return e.at===void 0&&t.at===void 0?e.id.localeCompare(t.id):e.at===void 0?1:t.at===void 0?-1:e.at-t.at||e.id.localeCompare(t.id)}function U({execution:e}){let t=Ee(e);return(0,R.jsx)(`ol`,{className:`divide-y divide-line/70 border-y border-line/70`,children:t.map((e,n)=>(0,R.jsxs)(`li`,{className:`grid grid-cols-[28px_minmax(0,1fr)] gap-3 py-3`,children:[(0,R.jsxs)(`div`,{className:`relative flex justify-center`,"aria-hidden":`true`,children:[(0,R.jsx)(`span`,{className:`mt-1.5 size-2 rounded-full border-2 border-surface bg-accent ring-1 ring-line`}),n<t.length-1&&(0,R.jsx)(`span`,{className:`absolute top-5 bottom-[-13px] w-px bg-line`})]}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`break-words text-sm font-medium text-fg`,children:e.title}),e.status&&(0,R.jsx)(d,{status:e.status})]}),(0,R.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-x-3 text-xs text-faint`,children:[(0,R.jsx)(`span`,{className:`capitalize`,children:e.category}),(0,R.jsx)(`span`,{children:e.at===void 0?`Timestamp unavailable`:b(e.at)})]}),e.detail&&(0,R.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-xs text-muted`,children:e.detail})]})]},e.id))})}var W={now:Date.now,subscribe:e=>{let t=window.setInterval(e,1e3);return()=>window.clearInterval(t)}};function ke({since:e,clock:t=W}){let n=G(t);return(0,R.jsx)(R.Fragment,{children:y(Math.max(0,n-e))})}function G(e=W,t=!0){let[n,r]=(0,E.useState)(()=>e.now());return(0,E.useEffect)(()=>{if(r(e.now()),t)return e.subscribe(()=>r(e.now()))},[e,t]),n}function K({error:e,onRetry:t}){return e?(0,R.jsx)(m,{message:`Execution refresh failed; showing the last persisted snapshot.`,onRetry:t}):null}async function q(e,t){await Promise.all([e(),t?.()])}function Ae({repository:e,id:t,pollIntervalMs:n=1e4}){let{data:r,error:i,loading:a,refetch:o}=f(()=>e.get(t,`archive`),[e,t],{intervalMs:n});if(a&&!r)return(0,R.jsx)(g,{label:`Loading audit record…`});if(i&&!r)return(0,R.jsx)(h,{error:i,onRetry:o});let s=r?.execution;return s?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(K,{error:i,onRetry:o}),(0,R.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-line bg-surface`,children:[(0,R.jsxs)(`header`,{className:`flex items-start justify-between gap-3 border-b border-line px-4 py-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`Immutable audit record`}),(0,R.jsx)(`h2`,{className:`mt-1 break-all font-mono text-sm font-semibold text-fg`,children:s.id})]}),(0,R.jsx)(d,{status:s.state})]}),(0,R.jsxs)(`dl`,{className:`grid grid-cols-2 gap-3 border-b border-line p-4 text-xs sm:grid-cols-3`,children:[(0,R.jsx)(V,{label:`Workflow`,value:s.workflowName}),(0,R.jsx)(V,{label:`Runtime`,value:y(s.updatedAt-s.createdAt)}),(0,R.jsx)(V,{label:`Archived`,value:s.archivedAt?b(s.archivedAt):`Unavailable`}),(0,R.jsx)(V,{label:`Definition hash`,value:s.definitionHash??`Unavailable`}),(0,R.jsx)(V,{label:`Final node`,value:String(s.currentNodeIndex)}),(0,R.jsx)(V,{label:`Final transition`,value:b(s.updatedAt)})]}),(0,R.jsx)(`div`,{className:`p-4`,children:(0,R.jsx)(U,{execution:s})})]})]}):null}function je({repository:e,executionId:t,stuck:n,onApplied:r}){let i=F({operationGroup:`compensation`,scopeKey:`${t}:${n}`,onApplied:r,onSucceeded:e=>l.success(e===`resume`?`Compensation resumed`:`Compensation abandoned`,t)});return n?(0,R.jsxs)(`div`,{className:`border-t border-line p-4`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-faint`,children:`Operator decision`}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-muted`,children:`Retry after fixing the reversal, or explicitly abandon the remaining compensation steps.`}),(0,R.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:!!i.busy,onClick:()=>{window.confirm(`Retry the stuck compensation for ${t}? Handlers must be idempotent.`)&&i.run(`resume`,()=>e.resumeCompensation(t))},className:`rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:`Resume compensation`}),(0,R.jsx)(`button`,{type:`button`,disabled:!!i.busy,onClick:()=>{window.confirm(`Abandon remaining compensation for ${t}? This is irreversible.`)&&i.run(`abandon`,()=>e.abandonCompensation(t))},className:`rounded-md border border-danger/40 px-3 py-2 text-xs text-danger disabled:opacity-40`,children:`Abandon remainder`})]}),i.error&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:i.error}),i.succeeded&&(0,R.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:i.succeeded===`resume`?`Resume command accepted; recovery state refreshed.`:`Abandon command accepted; recovery state refreshed.`}),i.result!==void 0&&(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(B,{value:i.result})})]}):null}function Me({repository:e,controlRepository:t,id:n,onApplied:r,pollIntervalMs:i=5e3}){let{data:a,error:o,loading:s,refetch:c}=f(()=>e.get(n,`active`),[e,n],{intervalMs:i});if(s&&!a)return(0,R.jsx)(g,{label:`Loading recovery plan…`});if(o&&!a)return(0,R.jsx)(h,{error:o,onRetry:c});let l=a?.execution;if(!l)return null;let u=Object.entries(l.steps).filter(([,e])=>e.compensatable||e.compensation);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(K,{error:o,onRetry:c}),(0,R.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-line bg-surface`,children:[(0,R.jsxs)(`header`,{className:`flex items-start justify-between gap-3 border-b border-line px-4 py-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-violet-400`,children:`Recovery plan`}),(0,R.jsx)(`h2`,{className:`mt-1 break-all font-mono text-sm font-semibold text-fg`,children:l.id})]}),(0,R.jsx)(d,{status:l.state})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 border-b border-line p-4 text-xs`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-faint`,children:`Compensation pivot`}),(0,R.jsx)(`div`,{className:`mt-1 text-fg`,children:l.committedAt===void 0?`Not committed`:`Node ${l.committedAt}`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-faint`,children:`Rollback state`}),(0,R.jsx)(`div`,{className:`mt-1 text-fg`,children:l.rollbackStatus??l.state})]})]}),l.failureReason&&(0,R.jsx)(`div`,{role:`alert`,className:`border-b border-danger/30 bg-danger/[0.06] px-4 py-3 text-xs text-danger`,children:l.failureReason}),(0,R.jsxs)(`div`,{className:`p-4`,children:[(0,R.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-faint`,children:`Compensation ledger`}),u.length?(0,R.jsx)(`ol`,{className:`space-y-2`,children:u.reverse().map(([e,t])=>(0,R.jsxs)(`li`,{className:`grid gap-2 rounded-md border border-line px-3 py-2 text-xs sm:grid-cols-[1fr_auto]`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`font-mono text-fg`,children:e}),(0,R.jsx)(`div`,{className:`mt-1 text-faint`,children:t.compensation?.error??`Compensation handler registered`})]}),(0,R.jsxs)(`div`,{className:`text-right text-muted`,children:[t.compensation?t.compensation.status:`pending`,t.compensation?.at?(0,R.jsx)(`div`,{className:`mt-1 text-[10px] text-faint`,children:b(t.compensation.at)}):null]})]},e))}):(0,R.jsx)(`p`,{className:`text-sm text-muted`,children:`No compensatable step was persisted.`})]}),(0,R.jsx)(je,{repository:t,executionId:n,stuck:l.state===`compensation-stuck`,onApplied:()=>q(c,r)},n)]})]})}function Ne({execution:e}){return(0,R.jsxs)(`div`,{className:`space-y-5`,children:[(0,R.jsx)(J,{title:`Input`,value:e.input}),(0,R.jsx)(J,{title:`Signals`,value:e.signals}),(0,R.jsx)(J,{title:`Resolved steps`,value:e.resolvedSteps}),(0,R.jsx)(J,{title:`Decisions`,value:e.decisions})]})}function J({title:e,value:t}){return(0,R.jsxs)(`section`,{children:[(0,R.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-faint`,children:e}),(0,R.jsx)(B,{value:t})]})}function Pe({steps:e,onSelect:t}){let n=Object.entries(e);return n.length===0?(0,R.jsx)(`p`,{className:`text-xs text-faint`,children:`No persisted step records.`}):(0,R.jsx)(`ol`,{className:`space-y-3`,children:n.map(([e,r],i)=>(0,R.jsx)(Fe,{name:e,step:r,last:i===n.length-1,onSelect:t},e))})}function Fe({name:e,step:t,last:n,onSelect:r}){let i=t.startedAt!==void 0&&t.completedAt!==void 0?t.completedAt-t.startedAt:void 0;return(0,R.jsxs)(`li`,{className:`relative grid grid-cols-[18px_1fr] gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col items-center`,"aria-hidden":`true`,children:[(0,R.jsx)(`span`,{className:`mt-1 size-2.5 rounded-full bg-current text-accent`}),!n&&(0,R.jsx)(`span`,{className:`mt-1 w-px flex-1 bg-line`})]}),(0,R.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-line bg-surface-2 p-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{translate:`no`,className:`break-all font-mono text-sm font-medium text-fg`,children:e}),(0,R.jsx)(d,{status:t.status})]}),(0,R.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-x-4 gap-y-1 text-xs text-faint`,children:[t.attempts!==void 0&&(0,R.jsxs)(`span`,{children:[t.attempts,` attempt`,t.attempts===1?``:`s`]}),i!==void 0&&(0,R.jsx)(`span`,{children:y(i)}),t.occurrence!==void 0&&(0,R.jsxs)(`span`,{children:[`Occurrence `,t.occurrence]}),t.loopIndex!==void 0&&(0,R.jsxs)(`span`,{children:[`Loop index `,t.loopIndex]}),t.compensatable&&(0,R.jsx)(`span`,{children:`Compensatable`})]}),t.idempotencyKey&&(0,R.jsxs)(`div`,{className:`mt-2 break-all font-mono text-[11px] text-faint`,children:[`Idempotency: `,t.idempotencyKey]}),t.childExecutionId&&(0,R.jsxs)(`button`,{type:`button`,onClick:()=>r(t.childExecutionId),className:`mt-2 break-all font-mono text-xs text-accent hover:underline`,children:[`Child execution: `,t.childExecutionId]}),t.error&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-2 whitespace-pre-wrap text-xs text-danger`,children:t.error}),t.compensation&&(0,R.jsxs)(`div`,{className:`mt-3 rounded-md border border-line px-3 py-2 text-xs`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`text-faint`,children:`Compensation`}),(0,R.jsx)(d,{status:t.compensation.status}),(0,R.jsx)(`span`,{className:`text-faint`,children:b(t.compensation.at)})]}),t.compensation.error&&(0,R.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-danger`,children:t.compensation.error})]}),(0,R.jsx)(Ie,{step:t})]})]})}function Ie({step:e}){return(0,R.jsxs)(R.Fragment,{children:[Object.hasOwn(e,`result`)&&(0,R.jsx)(Y,{label:`Result`,value:e.result}),Object.hasOwn(e,`loopItem`)&&(0,R.jsx)(Y,{label:`Loop item`,value:e.loopItem})]})}function Y({label:e,value:t}){return(0,R.jsxs)(`details`,{className:`mt-3`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted`,children:e}),(0,R.jsx)(`div`,{className:`mt-2`,children:(0,R.jsx)(B,{value:t})})]})}function Le({execution:e,onSelect:t}){let n=Object.values(e.steps),r=n.filter(e=>e.status===`completed`).length;return(0,R.jsxs)(`div`,{className:`space-y-5`,children:[(0,R.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-4 gap-y-3 border-b border-line pb-5 text-xs sm:grid-cols-3`,children:[(0,R.jsx)(V,{label:`Current node`,value:String(e.currentNodeIndex)}),(0,R.jsx)(V,{label:`Step progress`,value:`${r}/${n.length} completed`}),(0,R.jsx)(V,{label:`Duration`,value:y(e.updatedAt-e.createdAt)}),(0,R.jsx)(V,{label:`Started`,value:b(e.createdAt)}),(0,R.jsx)(V,{label:`Last transition`,value:b(e.updatedAt)}),(0,R.jsx)(V,{label:`Rollback`,value:e.rollbackStatus??`Not started`})]}),e.failureReason&&(0,R.jsxs)(`div`,{role:`alert`,className:`border-l-2 border-danger bg-danger/[0.06] px-3 py-2 text-xs text-danger`,children:[(0,R.jsx)(`div`,{className:`mb-1 font-medium`,children:`Failure`}),(0,R.jsx)(`p`,{className:`whitespace-pre-wrap`,children:e.failureReason})]}),(0,R.jsx)(Re,{execution:e,onSelect:t}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-faint`,children:`Step state`}),(0,R.jsx)(Pe,{steps:e.steps,onSelect:t})]})]})}function Re({execution:e,onSelect:t}){return!e.parentExecutionId&&!e.definitionHash&&e.committedAt===void 0?null:(0,R.jsxs)(`div`,{className:`grid gap-3 border-b border-line pb-5 text-xs sm:grid-cols-2`,children:[e.parentExecutionId&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-faint`,children:`Parent execution`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>t(e.parentExecutionId),className:`mt-1 break-all font-mono text-accent hover:underline`,children:e.parentExecutionId})]}),e.definitionHash&&(0,R.jsx)(V,{label:`Definition hash`,value:e.definitionHash}),e.committedAt!==void 0&&(0,R.jsx)(V,{label:`Compensation pivot`,value:`Node ${e.committedAt}`}),(0,R.jsx)(`div`,{className:`flex items-end`,children:(0,R.jsx)(d,{status:e.state})})]})}var ze=[{id:`summary`,label:`Summary`},{id:`history`,label:`History`},{id:`payloads`,label:`Payloads`}];function X({repository:e,id:t,kind:n,onSelect:r}){return(0,R.jsx)(Be,{repository:e,id:t,kind:n,onSelect:r},`${n}:${t}`)}function Be({repository:e,id:n,kind:r,onSelect:i}){let[a,o]=t(),s=a.get(`tab`),c=se(s)?s:`summary`,{data:l,error:p,loading:_,refetch:v}=f(()=>e.get(n,r),[e,n,r],{intervalMs:5e3});if(_&&!l)return(0,R.jsx)(Z,{children:(0,R.jsx)(g,{label:`Loading execution…`})});if(p&&!l)return(0,R.jsx)(Z,{children:(0,R.jsx)(h,{error:p,onRetry:v})});let y=l?.execution;return y?(0,R.jsxs)(Z,{children:[p&&(0,R.jsx)(m,{message:`Execution refresh failed. Showing the last snapshot.`,onRetry:v}),(0,R.jsx)(`header`,{className:`border-b border-line px-4 py-3`,children:(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`Execution`}),(0,R.jsx)(`h2`,{translate:`no`,className:`mt-1 break-all font-mono text-sm font-semibold text-fg`,children:y.id}),(0,R.jsx)(`div`,{className:`mt-1 text-xs text-muted`,children:y.workflowName})]}),(0,R.jsx)(d,{status:y.state})]})}),(0,R.jsx)(`nav`,{"aria-label":`Execution detail`,className:`flex border-b border-line px-2`,children:ze.map(e=>(0,R.jsx)(`button`,{type:`button`,"aria-pressed":c===e.id,onClick:()=>{o(t=>{let n=new URLSearchParams(t);return e.id===`summary`?n.delete(`tab`):n.set(`tab`,e.id),n})},className:u(`border-b-2 px-3 py-2 text-xs font-medium`,c===e.id?`border-accent text-fg`:`border-transparent text-faint hover:text-muted`),children:e.label},e.id))}),(0,R.jsxs)(`div`,{className:`p-4`,"aria-live":`polite`,children:[c===`summary`&&(0,R.jsx)(Le,{execution:y,onSelect:i}),c===`history`&&(0,R.jsx)(U,{execution:y}),c===`payloads`&&(0,R.jsx)(Ne,{execution:y})]})]}):null}function Z({children:e}){return(0,R.jsx)(`section`,{className:`min-w-0 overflow-hidden rounded-lg border border-line bg-surface`,children:e})}function Q({total:e,offset:t,pageSize:n,count:r,onPage:i}){let a=r===0?0:t+1,o=Math.min(t+r,e);return(0,R.jsxs)(`nav`,{"aria-label":`Workflow execution pages`,className:`mt-3 flex items-center justify-between`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:t===0,onClick:()=>i(Math.max(0,t-n)),className:`rounded-lg border border-line px-3 py-1.5 text-xs text-muted disabled:opacity-40`,children:`Previous`}),(0,R.jsxs)(`span`,{className:`text-xs text-faint`,children:[a,`–`,o,` of `,e]}),(0,R.jsx)(`button`,{type:`button`,disabled:t+n>=e,onClick:()=>i(t+n),className:`rounded-lg border border-line px-3 py-1.5 text-xs text-muted disabled:opacity-40`,children:`Next`})]})}var Ve=e=>e.length>22?`${e.slice(0,12)}…${e.slice(-7)}`:e;function He({executions:e,total:t,offset:n,pageSize:r,selected:i,onSelect:a,onPage:o}){return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-line bg-surface`,children:(0,R.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,R.jsx)(`thead`,{className:`bg-surface-2/80`,children:(0,R.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,R.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Workflow / execution`}),(0,R.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Status`}),(0,R.jsx)(`th`,{className:`hidden px-3 py-2 font-medium md:table-cell`,children:`Node`}),(0,R.jsx)(`th`,{className:`hidden px-3 py-2 font-medium lg:table-cell`,children:`Elapsed`}),(0,R.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:`Updated`})]})}),(0,R.jsx)(`tbody`,{children:e.map(e=>(0,R.jsx)(Ue,{execution:e,selected:i?.id===e.id,onSelect:a},e.id))})]})}),(0,R.jsx)(Q,{total:t,offset:n,pageSize:r,count:e.length,onPage:o})]})}function Ue({execution:e,selected:t,onSelect:n}){return(0,R.jsxs)(`tr`,{className:u(`border-b border-line/70 last:border-0`,t&&`bg-surface-2`),children:[(0,R.jsx)(`td`,{className:`p-0`,children:(0,R.jsxs)(`button`,{type:`button`,onClick:()=>n({id:e.id,source:`page`}),className:`block w-full px-3 py-2.5 text-left focus-visible:outline-2 focus-visible:outline-inset focus-visible:outline-accent`,children:[(0,R.jsx)(`span`,{className:`block truncate font-medium text-fg`,children:e.workflowName}),(0,R.jsx)(`span`,{translate:`no`,title:e.id,className:`mt-0.5 block font-mono text-[11px] text-faint`,children:Ve(e.id)})]})}),(0,R.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,R.jsx)(d,{status:e.state})}),(0,R.jsx)(`td`,{className:`hidden px-3 py-2.5 font-mono text-xs text-muted md:table-cell`,children:e.currentNodeIndex}),(0,R.jsx)(`td`,{className:`hidden whitespace-nowrap px-3 py-2.5 font-mono text-xs text-muted lg:table-cell`,children:y(e.updatedAt-e.createdAt)}),(0,R.jsx)(`td`,{title:b(e.updatedAt),className:`whitespace-nowrap px-3 py-2.5 text-right text-xs text-muted`,children:x(e.updatedAt)})]})}function We({mode:e,rows:t,selected:n,onSelect:r,total:i,offset:a,pageSize:o,onPage:s,clock:c=W}){let l=G(c,e===`waiting`);return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`section`,{className:`overflow-x-auto rounded-lg border border-line bg-surface`,children:(0,R.jsxs)(`table`,{className:`w-full min-w-[560px] text-sm`,children:[(0,R.jsx)(`thead`,{className:`border-b border-line bg-surface-2/80 text-left text-[10px] uppercase tracking-wider text-faint`,children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:e===`archive`?`Execution record`:`Execution`}),(0,R.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Workflow`}),(0,R.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:Ge(e)}),(0,R.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:Ke(e)})]})}),(0,R.jsx)(`tbody`,{children:t.map(t=>(0,R.jsxs)(`tr`,{className:u(`border-b border-line last:border-0`,n?.id===t.id&&`bg-surface-2`),children:[(0,R.jsx)(`td`,{className:`p-0`,children:(0,R.jsx)(`button`,{type:`button`,className:`block w-full px-3 py-3 text-left font-mono text-xs text-fg`,onClick:()=>r({id:t.id,source:`page`}),children:t.id})}),(0,R.jsx)(`td`,{className:`px-3 py-3 text-muted`,children:t.workflowName}),(0,R.jsx)(`td`,{className:`px-3 py-3`,children:(0,R.jsx)(qe,{mode:e,row:t})}),(0,R.jsx)(`td`,{className:`whitespace-nowrap px-3 py-3 text-right text-xs text-muted`,children:Je(e,t,l)})]},t.id))})]})}),(0,R.jsx)(Q,{total:i,offset:a,pageSize:o,count:t.length,onPage:s})]})}var Ge=e=>e===`waiting`?`Resume node`:e===`compensation`?`Recovery state`:`Outcome`,Ke=e=>e===`archive`?`Archived`:e===`waiting`?`Waiting`:`Updated`;function qe({mode:e,row:t}){return e===`waiting`?(0,R.jsxs)(`span`,{className:`font-mono text-xs text-warning`,children:[`Node `,t.currentNodeIndex]}):(0,R.jsx)(d,{status:t.state})}function Je(e,t,n){return e===`archive`?t.archivedAt?b(t.archivedAt):`Unavailable`:e===`waiting`?y(Math.max(0,n-t.updatedAt)):x(t.updatedAt)}function $({stats:e,page:t,repository:n,kind:r,selected:i,onSelect:a}){let o=t.executions.filter(e=>[`waiting`,`failed`,`compensation-stuck`].includes(e.state));return(0,R.jsxs)(`div`,{className:`space-y-5`,children:[(0,R.jsx)(Ye,{stats:e}),(0,R.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(320px,0.7fr)_minmax(0,1.3fr)]`,children:[(0,R.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface`,children:[(0,R.jsxs)(`header`,{className:`border-b border-line px-4 py-3`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Needs attention`}),(0,R.jsxs)(`p`,{className:`mt-0.5 text-xs text-faint`,children:[`Waiting, failed, and stuck executions · showing `,o.length,` of `,t.total,`.`]})]}),(0,R.jsx)(Xe,{rows:o,selected:i,onSelect:a})]}),i&&(0,R.jsx)(X,{repository:n,id:i.id,kind:r,onSelect:e=>a({id:e,source:`link`})})]})]})}function Ye({stats:e}){return(0,R.jsx)(`dl`,{className:`grid overflow-hidden rounded-lg border border-line bg-surface sm:grid-cols-2 xl:grid-cols-4`,children:[[`Open executions`,e.activeTotal],[`Waiting for signal`,e.states.waiting],[`Recovery required`,e.states[`compensation-stuck`]+e.states.failed],[`Retained in archive`,e.archiveTotal]].map(([e,t])=>(0,R.jsxs)(`div`,{className:`border-b border-line px-4 py-3 sm:border-r xl:border-b-0`,children:[(0,R.jsx)(`dt`,{className:`text-[10px] uppercase tracking-wider text-faint`,children:e}),(0,R.jsx)(`dd`,{className:`mt-1 font-mono text-xl font-semibold text-fg`,children:t})]},e))})}function Xe({rows:e,selected:t,onSelect:n}){return e.length?(0,R.jsx)(`ul`,{className:`divide-y divide-line`,children:e.map(e=>(0,R.jsx)(`li`,{className:t?.id===e.id?`bg-surface-2`:void 0,children:(0,R.jsxs)(`button`,{type:`button`,className:`w-full px-4 py-3 text-left`,onClick:()=>n({id:e.id,source:`page`}),children:[(0,R.jsxs)(`span`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.workflowName}),(0,R.jsx)(`span`,{className:`text-xs text-faint`,children:x(e.updatedAt)})]}),(0,R.jsxs)(`span`,{className:`mt-1 flex items-center justify-between gap-3 font-mono text-[11px] text-faint`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:e.id}),(0,R.jsx)(`span`,{children:e.state})]})]})},e.id))}):(0,R.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-muted`,children:`No intervention required.`})}function Ze({repository:e,executionId:t,onApplied:n}){let[r,i]=(0,E.useState)(``),[a,o]=(0,E.useState)(`{}`),s=F({operationGroup:`signal`,scopeKey:t,onApplied:n,onSucceeded:()=>l.success(`Workflow signal accepted`,`${r.trim()} · ${t}`)});return(0,R.jsxs)(`div`,{className:`border-t border-line p-4`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-faint`,children:`Send signal`}),(0,R.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Event name`,(0,R.jsx)(`input`,{"aria-label":`Workflow signal event`,value:r,onChange:e=>i(e.target.value),className:`mt-1 h-9 w-full rounded-lg border border-line bg-surface-2 px-3 font-mono text-sm text-fg`})]}),(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Payload JSON`,(0,R.jsx)(`textarea`,{"aria-label":`Workflow signal payload`,value:a,onChange:e=>o(e.target.value),className:`mt-1 min-h-20 w-full resize-y rounded-lg border border-line bg-surface-2 p-2 font-mono text-xs text-fg`})]})]}),(0,R.jsx)(`button`,{type:`button`,disabled:!r.trim()||!!s.busy,onClick:()=>{let n;try{n=JSON.parse(a)}catch{s.run(`signal`,async()=>{throw Error(`Signal payload must be valid JSON.`)});return}window.confirm(`Send durable signal "${r.trim()}" to ${t}?`)&&s.run(`signal`,()=>e.signal(t,r.trim(),n))},className:`mt-3 rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:s.busy?`Sending…`:`Send durable signal`}),s.error&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:s.error}),s.succeeded&&(0,R.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:`Durable signal accepted; execution and list refreshed.`}),s.result!==void 0&&(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(B,{value:s.result})})]})}function Qe({repository:e,controlRepository:t,id:n,onApplied:r,clock:i,pollIntervalMs:a=5e3}){let{data:o,error:s,loading:c,refetch:l}=f(()=>e.get(n,`active`),[e,n],{intervalMs:a});if(c&&!o)return(0,R.jsx)(g,{label:`Loading signal inbox…`});if(s&&!o)return(0,R.jsx)(h,{error:s,onRetry:l});let u=o?.execution;if(!u)return null;let d=Object.entries(u.signals);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(K,{error:s,onRetry:l}),(0,R.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-line bg-surface`,children:[(0,R.jsxs)(`header`,{className:`border-b border-line px-4 py-3`,children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-warning`,children:`Signal inbox`}),(0,R.jsx)(`h2`,{className:`mt-1 break-all font-mono text-sm font-semibold text-fg`,children:u.id})]}),(0,R.jsxs)(`dl`,{className:`grid grid-cols-2 gap-3 border-b border-line p-4 text-xs sm:grid-cols-3`,children:[(0,R.jsx)(V,{label:`Waiting at node`,value:String(u.currentNodeIndex)}),(0,R.jsx)(V,{label:`Parked for`,value:(0,R.jsx)(ke,{since:u.updatedAt,clock:i})}),(0,R.jsx)(V,{label:`Last transition`,value:b(u.updatedAt)})]}),(0,R.jsxs)(`div`,{className:`p-4`,children:[(0,R.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-faint`,children:`Durable signals`}),d.length?d.map(([e,t])=>(0,R.jsxs)(`div`,{className:`mb-3 last:mb-0`,children:[(0,R.jsx)(`div`,{className:`mb-1 font-mono text-xs text-warning`,children:e}),(0,R.jsx)(B,{value:t})]},e)):(0,R.jsx)(`p`,{className:`text-sm text-muted`,children:`No signal has been persisted yet. The execution remains parked.`})]}),(0,R.jsx)(Ze,{repository:t,executionId:n,onApplied:()=>q(l,r)},n)]})]})}function $e(e){return e.section.id===`overview`?(0,R.jsx)($,{...e}):e.section.id===`executions`?(0,R.jsx)(et,{...e}):(0,R.jsx)(tt,{...e})}function et({repository:e,kind:t,page:n,selected:r,offset:i,pageSize:a,onSelect:o,onPage:s}){return(0,R.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(390px,0.8fr)_minmax(0,1.4fr)]`,children:[(0,R.jsx)(He,{executions:n.executions,total:n.total,offset:i,pageSize:a,selected:r,onSelect:o,onPage:s}),r&&(0,R.jsx)(X,{repository:e,id:r.id,kind:t,onSelect:e=>o({id:e,source:`link`})})]})}function tt(e){let t=e.section.id;return(0,R.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(420px,0.95fr)_minmax(0,1.05fr)]`,children:[(0,R.jsx)(We,{mode:t,rows:e.page.executions,selected:e.selected,onSelect:e.onSelect,total:e.page.total,offset:e.offset,pageSize:e.pageSize,onPage:e.onPage}),e.selected&&(0,R.jsx)(nt,{...e,id:e.selected.id})]})}function nt({section:e,repository:t,controlRepository:n,onRefresh:r,id:i}){return e.id===`waiting`?(0,R.jsx)(Qe,{repository:t,controlRepository:n,id:i,onApplied:r}):e.id===`compensation`?(0,R.jsx)(Me,{repository:t,controlRepository:n,id:i,onApplied:r}):(0,R.jsx)(Ae,{repository:t,id:i})}function rt({repository:e=fe,controlRepository:t=P}){let{pathname:n}=r(),i=ee(n),a=pe(i),{kind:o,workflowName:s,state:c,offset:l,selected:u,update:d,select:p}=a,h={kind:o,workflowName:s||void 0,state:c||void 0,limit:25,offset:l},{data:g,error:_,loading:y,refetch:b}=f(()=>i.id===`overview`?ie(e,25):re(e,h),[e,i.id,o,s,c,l],{intervalMs:5e3});(0,E.useEffect)(()=>{let e=g?.page.total;if(e===void 0||l===0)return;let t=e===0?0:Math.floor((e-1)/25)*25;l>t&&d({offset:t,executionId:null,tab:`summary`},!0)},[g?.page.total,l,d]),(0,E.useEffect)(()=>{let e=g?.page.executions;if(e){let t=i.id===`overview`?e.filter(e=>[`waiting`,`failed`,`compensation-stuck`].includes(e.state)):e,n=te(u,t);n?.id!==u?.id&&p(n,!0)}},[g?.page.executions,i.id,u,p]);let x=g?.stats,S=g?.page;return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(v,{title:(0,R.jsxs)(R.Fragment,{children:[`Workflow `,(0,R.jsxs)(`span`,{className:`text-faint`,children:[`/ `,i.label]})]}),description:i.description,live:!!(g&&!_),actions:(0,R.jsx)(`button`,{type:`button`,onClick:()=>void b(),className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Refresh`})}),i.id===`overview`&&(0,R.jsx)(ve,{repository:t,onApplied:b}),i.id===`archive`&&(0,R.jsx)(he,{repository:t,onApplied:b}),i.id===`executions`&&x&&(0,R.jsx)(_e,{stats:x}),(0,R.jsx)(Te,{section:i,kind:o,workflowName:s,state:c,stats:x??void 0,total:S?.total,onKind:e=>{a.update({kind:e,offset:0,executionId:null,tab:`summary`},!1)},onWorkflowName:e=>{a.update({workflowName:e,offset:0,executionId:null,tab:`summary`},!1)},onState:e=>{a.update({state:e,offset:0,executionId:null,tab:`summary`},!1)}}),_&&g&&(0,R.jsx)(m,{message:`Workflow refresh failed — showing the last snapshot.`,onRetry:b}),(0,R.jsx)(it,{repository:e,controlRepository:t,section:i,stats:x,kind:o,page:S,error:_,loading:y,dataPresent:!!g,selected:u,offset:l,onRetry:b,onSelect:e=>a.select(e),onPage:e=>{a.update({offset:e,executionId:null,tab:`summary`})}})]})}function it({repository:e,controlRepository:t,section:n,stats:r,kind:i,page:a,error:o,loading:s,dataPresent:c,selected:l,offset:u,onRetry:d,onSelect:f,onPage:p}){return o&&!c?(0,R.jsx)(h,{error:o,onRetry:d}):s&&!c?(0,R.jsx)(g,{label:`Loading workflows…`}):a?.available?a.executions.length===0&&a.total>0&&u>0?(0,R.jsx)(g,{label:`Loading workflow page…`}):a.executions.length===0?(0,R.jsx)(_,{title:`No executions match these filters`,hint:`Change the store, workflow, or state filter.`}):r?(0,R.jsx)($e,{section:n,repository:e,controlRepository:t,kind:i,stats:r,page:a,selected:l,offset:u,pageSize:25,onSelect:f,onPage:p,onRefresh:d}):null:(0,R.jsx)(_,{title:`Workflow store not initialized`,hint:`Start a Bunqueue Workflow Engine with this server dataPath; its official workflow_executions tables will appear here automatically.`})}export{rt as Workflows};
@@ -1 +0,0 @@
1
- import{a as e,i as t,n,r}from"./connectionStore-CVjQyIZv.js";import{a as i,i as a,n as o,r as s,s as c}from"./upstreamPaths-DQeKSxGc.js";var l=class extends Error{status;constructor(e,t){super(e),this.status=t,this.name=`BqError`}},u=3e4,d=()=>u;async function f(e,t,n,r,i=!0,a=`server`,o=[],s=u){let c=AbortSignal.timeout(s),d=r?.signal?AbortSignal.any([r.signal,c]):c,f=new Headers(n);r?.headers&&new Headers(r.headers).forEach((e,t)=>{f.set(t,e)}),r?.body!=null&&!f.has(`Content-Type`)&&f.set(`Content-Type`,`application/json`);let p;try{p=await fetch(e+t,{...r,headers:f,signal:d})}catch(e){throw c.aborted&&!r?.signal?.aborted||e?.name===`TimeoutError`?new l(`Request timed out`,0):e}if(!p.ok&&!o.includes(p.status)){let t=`HTTP ${p.status}`;try{let e=await p.json();e?.error&&(t=e.error)}catch{}throw p.status===401&&typeof window<`u`&&window.dispatchEvent(new CustomEvent(`auth:required`,{detail:{scope:a,auth:f.get(`Authorization`)??void 0,target:e}})),new l(t,p.status)}if(p.status===204)return;let m;try{m=await p.text()}catch(e){throw c.aborted&&!r?.signal?.aborted?new l(`Request timed out`,0):e}if(!m)return;let h;try{h=JSON.parse(m)}catch{throw new l(`Invalid JSON response (HTTP ${p.status})`,p.status)}if(i&&h&&typeof h==`object`&&h.ok===!1)throw new l(h.error??`Operation failed`,p.status);return h}var p=(n,r,i=!0,a=[],o=u)=>f(e(),n,t(),r,i,`server`,a,o),m=()=>r(),h=(e,t,r=u)=>f(m(),e,n(),t,!0,`agent`,[],r),g=(e,t)=>({method:e,body:t===void 0?void 0:JSON.stringify(t)}),_=3e5,ee=(e,t)=>g(e,t),v=new WeakMap,y=new WeakMap;function b(){let n=Object.freeze({baseUrl:e()});return v.set(n,Object.freeze({...t()})),n}function x(){let e=Object.freeze({baseUrl:m()});return y.set(e,Object.freeze({...n()})),e}function S(e){let t=v.get(e);if(!t)throw TypeError(`Invalid server request target.`);return t}function C(e){let t=y.get(e);if(!t)throw TypeError(`Invalid agent request target.`);return t}async function w(e,t,n){n?.throwIfAborted();let r=await f(e.baseUrl,`/jobs/${i(t)}`,{...S(e)},n?{signal:n}:void 0);return n?.throwIfAborted(),r}var T=encodeURIComponent,te={info:()=>h(`/db/info`),tables:()=>h(`/db/tables`),schema:e=>h(`/db/tables/${o(e,`Database table`)}/schema`),rows:(e,t=50,n=0,r,i=`asc`,a)=>h(`/db/tables/${o(e,`Database table`)}?limit=${t}&offset=${n}${r?`&orderBy=${T(r)}&dir=${i}`:``}${a?.value?`&fcol=${T(a.column)}&fop=${a.op}&fval=${T(a.value)}`:``}`),cell:(e,t,n)=>h(`/db/tables/${o(e,`Database table`)}/cell?rowid=${T(String(t))}&column=${T(n)}`),query:e=>h(`/db/query`,g(`POST`,{sql:e}))},ne={status:()=>h(`/control/status`),start:()=>h(`/control/start`,{method:`POST`}),stop:()=>h(`/control/stop`,{method:`POST`}),restart:()=>h(`/control/restart`,{method:`POST`}),logs:()=>h(`/control/logs`),getConfig:()=>h(`/control/config`),setConfig:(e,t)=>h(`/control/config`,g(`PUT`,{...e,...t===void 0?{}:{expectedRevision:t}}))},re={stats:()=>h(`/workflows/stats`),list:(e={})=>{let t=new URLSearchParams;return e.kind&&t.set(`kind`,e.kind),e.workflowName&&t.set(`workflowName`,e.workflowName),e.state&&t.set(`state`,e.state),e.limit!==void 0&&t.set(`limit`,String(e.limit)),e.offset!==void 0&&t.set(`offset`,String(e.offset)),h(`/workflows${t.size?`?${t}`:``}`)},get:(e,t=`active`)=>h(`/workflows/${o(e,`Workflow execution id`)}?kind=${t}`)},ie=2e5,ae=16*1024*1024,oe=12e4,se=64*1024,E=encodeURIComponent;async function ce(e,t,n=50,r=0,i,a=`asc`,s,c){c?.throwIfAborted();let l=await f(e.baseUrl,`/db/tables/${o(t,`Database table`)}?limit=${n}&offset=${r}${i?`&orderBy=${E(i)}&dir=${a}`:``}${s?.value?`&fcol=${E(s.column)}&fop=${s.op}&fval=${E(s.value)}`:``}`,{...C(e)},c?{signal:c}:void 0,!0,`agent`);return c?.throwIfAborted(),l}function D(e,t,n,r=!0){let i=e.get(t);if(!i||!/^\d+$/.test(i))throw new l(`Malformed database export response: invalid ${t} header.`,200);let a=Number(i);if(!Number.isSafeInteger(a)||a>n||!r&&a===0)throw new l(`Malformed database export response: invalid ${t} header.`,200);return a}async function le(e){if(!e.body)return``;let t=e.body.getReader(),n=new Uint8Array(se),r=0;try{for(;;){let e=await t.read();if(e.done)break;if(r+e.value.byteLength>n.byteLength)return t.cancel().catch(()=>void 0),``;n.set(e.value,r),r+=e.value.byteLength}}finally{t.releaseLock()}return new TextDecoder().decode(n.subarray(0,r))}async function ue(e,t,n){if(!e.body)throw new l(`Malformed database export response: missing CSV body.`,200);let r=new Uint8Array(t),i=e.body.getReader(),a=0;try{for(;;){n?.throwIfAborted();let e=await i.read();if(e.done)break;if(a+e.value.byteLength>t)throw i.cancel().catch(()=>void 0),new l(`Malformed database export response: body exceeds declared ${t} bytes.`,200);r.set(e.value,a),a+=e.value.byteLength}}finally{i.releaseLock()}if(n?.throwIfAborted(),a!==t)throw new l(`Malformed database export response: received ${a} of ${t} declared bytes.`,200);return r}function de(e){if(!e||typeof e!=`object`||Array.isArray(e))throw TypeError(`Invalid database export request.`);if(typeof e.table!=`string`||!e.table)throw TypeError(`Database export table must not be empty.`);if(e.dir!==`asc`&&e.dir!==`desc`)throw TypeError(`Invalid database export sort direction.`);if(e.orderBy!==void 0&&(typeof e.orderBy!=`string`||!e.orderBy))throw TypeError(`Database export sort column must not be empty.`);let t=e.filter;if(t&&(typeof t!=`object`||Array.isArray(t)||typeof t.column!=`string`||!t.column||typeof t.value!=`string`||!t.value||![`contains`,`eq`,`ne`].includes(t.op)))throw TypeError(`Invalid database export filter.`);return Object.freeze({table:e.table,orderBy:e.orderBy,dir:e.dir,filter:t?Object.freeze({...t}):void 0})}async function fe(e,t,n){e.status===401&&typeof window<`u`&&window.dispatchEvent(new CustomEvent(`auth:required`,{detail:{scope:`agent`,auth:new Headers(n).get(`Authorization`)??void 0,target:t.baseUrl}}));let r=`HTTP ${e.status}`,i=await le(e);if(i)try{let e=JSON.parse(i);typeof e?.error==`string`&&(r=e.error)}catch{}return new l(r,e.status)}async function pe(e,t,n){n?.throwIfAborted();let r={...C(e)},i=de(t),a=new URLSearchParams;i.orderBy&&a.set(`orderBy`,i.orderBy),a.set(`dir`,i.dir),i.filter&&(a.set(`fcol`,i.filter.column),a.set(`fop`,i.filter.op),a.set(`fval`,i.filter.value));let s=`/db/tables/${o(i.table,`Database table`)}/export?${a}`,c=AbortSignal.timeout(oe),u=n?AbortSignal.any([n,c]):c;try{let t=await fetch(e.baseUrl+s,{headers:r,signal:u});if(!t.ok)throw await fe(t,e,r);if(t.headers.get(`X-Bunqueue-Db-Export-Version`)!==`1`)throw new l(`Malformed database export response: unsupported contract version.`,200);if(!/^text\/csv(?:;|$)/i.test(t.headers.get(`Content-Type`)??``))throw new l(`Malformed database export response: expected CSV content.`,200);let a;try{let e=t.headers.get(`X-Bunqueue-Db-Export-Table`);if(!e)throw Error(`missing`);a=decodeURIComponent(e)}catch{throw new l(`Malformed database export response: invalid table identity.`,200)}if(a!==i.table)throw new l(`Database export target changed: requested "${i.table}", received "${a}".`,200);let o=D(t.headers,`X-Bunqueue-Db-Export-Rows`,ie),c=D(t.headers,`X-Bunqueue-Db-Export-Bytes`,ae,!1);if(D(t.headers,`Content-Length`,16777216,!1)!==c)throw new l(`Malformed database export response: Content-Length does not match X-Bunqueue-Db-Export-Bytes.`,200);let d=t.headers.get(`X-Bunqueue-Db-Export-Cap`);if(d!==`none`&&d!==`rows`&&d!==`bytes`)throw new l(`Malformed database export response: invalid export cap.`,200);if(d===`rows`&&o!==2e5)throw new l(`Malformed database export response: inconsistent row cap.`,200);let f=await ue(t,c,u);return n?.throwIfAborted(),{table:a,content:f,rowCount:o,bytes:c,cap:d===`none`?null:d}}catch(e){throw c.aborted&&!n?.aborted?new l(`Database export timed out`,0):e}}var me={counts:e=>p(`/queues/${c(e)}/counts`),pause:e=>p(`/queues/${c(e)}/pause`,g(`POST`)),resume:e=>p(`/queues/${c(e)}/resume`,g(`POST`)),drain:e=>p(`/queues/${c(e)}/drain`,ee(`POST`),!0,[],_),obliterate:e=>p(`/queues/${c(e)}/obliterate`,ee(`POST`),!0,[],_),clean:(e,t={})=>p(`/queues/${c(e)}/clean`,g(`POST`,t)),promoteJobs:(e,t)=>p(`/queues/${c(e)}/promote-jobs`,g(`POST`,t==null?void 0:{count:t})),retryCompleted:(e,t)=>{throw TypeError(`Completed-job requeue is unavailable in Bunqueue v2.9.3 because flow dependency registration is not rebuilt.`)},setRateLimit:(e,t,n,r)=>p(`/queues/${c(e)}/rate-limit`,g(`PUT`,{limit:t,...n===void 0?{}:{duration:n},...r===void 0?{}:{ttl:r}})),clearRateLimit:e=>p(`/queues/${c(e)}/rate-limit`,{method:`DELETE`}),setConcurrency:(e,t)=>p(`/queues/${c(e)}/concurrency`,g(`PUT`,{concurrency:t})),clearConcurrency:e=>p(`/queues/${c(e)}/concurrency`,{method:`DELETE`}),getStallConfig:e=>p(`/queues/${c(e)}/stall-config`),setStallConfig:(e,t)=>p(`/queues/${c(e)}/stall-config`,g(`PUT`,{config:t})),getDlqConfig:e=>p(`/queues/${c(e)}/dlq-config`),setDlqConfig:(e,t)=>{if(t.autoRetry===!0)throw TypeError(`DLQ auto-retry is unavailable: Bunqueue v2.9.3 does not rebuild flow dependency registration.`);if(t.maxAge!==void 0||t.maxEntries!==void 0)throw TypeError(`DLQ retention is read-only: maxAge/maxEntries can destructively expire or evict flow jobs without an atomic dependency check.`);return p(`/queues/${c(e)}/dlq-config`,g(`PUT`,{config:t}))},dlq:(e,t=100,n=0)=>p(`/queues/${c(e)}/dlq?limit=${t}&offset=${n}`),dlqStats:e=>p(`/queues/${c(e)}/dlq/stats`),retryDlq:(e,t)=>{throw TypeError(`DLQ retry is unavailable in Bunqueue v2.9.3 because the endpoint has no atomic job-generation, state, or flow-topology precondition.`)},purgeDlq:e=>p(`/queues/${c(e)}/dlq/purge`,g(`POST`))},O=()=>encodeURIComponent(e()),he={limits:(e,t)=>{let n=t===void 0?``:`&maxJobs=${t}`;return h(`/queue-operations/${c(e)}/limits?target=${O()}${n}`)},group:(t,n,r,i,a,o)=>{let s=new URLSearchParams({target:e(),groupId:n});return r!==void 0&&s.set(`maxJobs`,String(r)),i!==void 0&&s.set(`maxCount`,String(i)),a!==void 0&&s.set(`start`,String(a)),o!==void 0&&s.set(`end`,String(o)),h(`/queue-operations/${c(t)}/groups?${s}`)},setGroupRateLimit:(e,t,n,r)=>h(`/queue-operations/${c(e)}/groups/rate-limit?target=${O()}`,g(`POST`,{groupId:t,max:n,duration:r})),removeGroupRateLimit:(e,t)=>h(`/queue-operations/${c(e)}/groups/rate-limit/remove?target=${O()}`,g(`POST`,{groupId:t})),setGroupConcurrency:(e,t,n)=>h(`/queue-operations/${c(e)}/groups/concurrency?target=${O()}`,g(`POST`,{groupId:t,concurrency:n})),removeGroupConcurrency:(e,t)=>h(`/queue-operations/${c(e)}/groups/concurrency/remove?target=${O()}`,g(`POST`,{groupId:t})),pauseGroup:(e,t)=>h(`/queue-operations/${c(e)}/groups/pause?target=${O()}`,g(`POST`,{groupId:t})),resumeGroup:(e,t)=>h(`/queue-operations/${c(e)}/groups/resume?target=${O()}`,g(`POST`,{groupId:t})),deduplicationJobId:(t,n)=>h(`/queue-operations/${c(t)}/deduplication?${new URLSearchParams({target:e(),deduplicationId:n})}`),removeDeduplicationKey:(e,t)=>h(`/queue-operations/${c(e)}/deduplication/remove?target=${O()}`,g(`POST`,{deduplicationId:t})),metrics:(t,n,r,i)=>h(`/queue-operations/${c(t)}/metrics?${new URLSearchParams({target:e(),type:n,start:String(r),end:String(i)})}`),trimEvents:(e,t)=>h(`/queue-operations/${c(e)}/events/trim?target=${O()}`,g(`POST`,{maxLength:t}))},k=1e4,ge=1e3,_e=864e13,ve=new Set([`job.pushed`,`job.started`,`job.completed`,`job.failed`,`job.progress`,`job.stalled`]);function A(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function j(e,t,n=!1){if(typeof e!=`string`||e.length>t||!n&&e.length===0)return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<32||n===127)return!1}return!0}function M(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function ye(e){return typeof e==`number`&&Number.isFinite(e)}function N(e){return M(e)&&e<=_e}function be(e,t){return e===null||j(e,t)}function xe(e,t,n){if(!Array.isArray(e)||e.length>t)return!1;let r=new Set;for(let t of e){if(!j(t,n)||r.has(t))return!1;r.add(t)}return!0}function P(e,t){let n=A(e),r=n&&A(n.data);if(n?.ok!==!0||!r)throw Error(`Malformed ${t} response.`);return r}function F(e){if(!Array.isArray(e))throw Error(`Malformed queue summary response.`);let t=new Set,n=[];for(let r of e){let e=A(r),i=e&&A(e.counts);if(!e||!j(e.name,256)||t.has(e.name)||typeof e.paused!=`boolean`||!i||!M(i.waiting)||!M(i.prioritized)||!M(i.active)||!M(i.completed)||!M(i.failed)||!M(i.delayed))throw Error(`Malformed queue summary response.`);t.add(e.name),n.push(r)}return n}function I(e){let t=P(e,`workers`);if(!Array.isArray(t.workers)||t.workers.length>k)throw Error(`Malformed workers response.`);let n=new Set,r=[],i=[];for(let e=0;e<t.workers.length;e++){let a=t.workers[e],o=A(a),s=o&&typeof o.id==`string`?o.id:null,c=[];if(o?(j(o.id,1024)?n.has(o.id)&&c.push(`duplicate id`):c.push(`id`),j(o.name,512,!0)||c.push(`name`),xe(o.queues,ge,256)||c.push(`queues`),(!M(o.concurrency)||o.concurrency<1)&&c.push(`concurrency`),j(o.hostname,512,!0)||c.push(`hostname`),M(o.pid)||c.push(`pid`),o.status!==`active`&&o.status!==`stale`&&c.push(`status`),N(o.registeredAt)||c.push(`registeredAt`),N(o.lastSeen)||c.push(`lastSeen`),M(o.activeJobs)||c.push(`activeJobs`),M(o.processedJobs)||c.push(`processedJobs`),M(o.failedJobs)||c.push(`failedJobs`),be(o.currentJob,1024)||c.push(`currentJob`),ye(o.uptime)||c.push(`uptime`)):c.push(`entry is not an object`),s&&n.add(s),c.length>0){i.push({index:e,id:s,reason:c.join(`, `)});continue}r.push(a)}return{ok:!0,data:{workers:r,quarantinedWorkers:i,...Object.hasOwn(t,`stats`)?{stats:t.stats}:{}}}}function Se(e){if(!j(e,2048))return!1;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function Ce(e){let t=P(e,`webhooks`);if(!Array.isArray(t.webhooks)||t.webhooks.length>k)throw Error(`Malformed webhooks response.`);let n=new Set,r=[];for(let e of t.webhooks){let t=A(e);if(!t||!j(t.id,1024)||n.has(t.id)||!Se(t.url)||!Array.isArray(t.events)||!t.events.every(e=>ve.has(e))||!(t.queue===null||typeof t.queue==`string`)||!N(t.createdAt)||!(t.lastTriggered===null||N(t.lastTriggered))||!M(t.successCount)||!M(t.failureCount)||typeof t.enabled!=`boolean`)throw Error(`Malformed webhooks response.`);n.add(t.id),r.push(e)}return{ok:!0,data:{webhooks:r,...Object.hasOwn(t,`stats`)?{stats:t.stats}:{}}}}var we={crons:()=>p(`/crons`),createCron:e=>p(`/crons`,g(`POST`,e)),deleteCron:e=>p(`/crons/${o(e,`Cron name`,256)}`,{method:`DELETE`}),webhooks:async()=>Ce(await p(`/webhooks`)),addWebhook:e=>p(`/webhooks`,g(`POST`,e)),removeWebhook:e=>p(`/webhooks/${i(e)}`,{method:`DELETE`}),setWebhookEnabled:(e,t)=>p(`/webhooks/${i(e)}/enabled`,g(`PUT`,{enabled:t})),workers:async()=>I(await p(`/workers`)),unregisterWorker:e=>p(`/workers/${i(e)}`,{method:`DELETE`}),eventsUrl:t=>e()+(t?`/events/queues/${s(t)}`:`/events`)},L=365*24*60*60*1e3,R=2097151,z=64*1024*1024,B=1e4,Te=[`childrenIds`,`parentId`,`failParentOnFailure`,`removeDependencyOnFailure`,`continueParentOnFailure`,`ignoreDependencyOnFailure`,`keepLogs`,`sizeLimit`,`debounceId`,`debounceTtl`],V=[`__parentId`,`__parentQueue`,`__childrenIds`,`__flowParentId`,`__flowParentIds`];function H(e){if(e===void 0)return;if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(`Repeat must be an object with a positive "every" interval`);let t=Object.keys(e).filter(e=>e!==`every`&&e!==`limit`);if(t.length)throw TypeError(`Unsupported repeat option(s): ${t.join(`, `)}. bunqueue v2.9.3 pattern repeats are unsafe; use the Cron API instead.`);if(!Number.isSafeInteger(e.every)||e.every<1||e.every>L)throw TypeError(`Repeat "every" must be a whole number from 1 to ${L} ms`);if(e.limit!==void 0&&(!Number.isSafeInteger(e.limit)||e.limit<1))throw TypeError(`Repeat "limit" must be a whole number of at least 1`)}function U(e){if(e!==void 0&&(typeof e!=`string`||!e||e.length>256))throw TypeError(`Job name must be a non-empty string of at most 256 characters`)}function W(e){let t=e,n=Te.filter(e=>t[e]!==void 0);if(n.length)throw TypeError(`Unsupported Bunqueue v2.9.3 enqueue option(s): ${n.join(`, `)}. Flow topology must use the atomic flow API; inert compatibility fields are not sent.`)}function G(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=V.filter(t=>Object.hasOwn(e,t));if(t.length)throw TypeError(`Job data must not contain broker-owned flow metadata: ${t.join(`, `)}. A plain enqueue with these keys would be misread as a flow child; use the atomic flow API for topology.`)}function K(e){let t=e.groupId;if(t!==void 0&&(typeof t!=`string`||!t||t.length>256||t.includes(`\0`)))throw TypeError(`groupId must be a non-empty string of at most 256 characters without NUL`);if(e.groupMaxSize!==void 0){if(t===void 0)throw TypeError(`groupMaxSize requires groupId`);if(!Number.isSafeInteger(e.groupMaxSize)||e.groupMaxSize<1)throw TypeError(`groupMaxSize must be a positive safe integer`)}if(t!==void 0&&e.priority!==void 0&&(!Number.isSafeInteger(e.priority)||e.priority<0||e.priority>R))throw TypeError(`Grouped priority must be an integer from 0 to ${R}`)}function q(e,t){let n=a(t);if(n)throw TypeError(`${e}: ${n}. The job would not be manageable through v2.9.3 HTTP.`)}function Ee(e){if(U(e.name),H(e.repeat),W(e),G(e.data),K(e),e.groupMaxSize!==void 0)throw TypeError(`groupMaxSize is not forwarded by Bunqueue 2.9.3 single-job HTTP; use the bulk transport`);if(e.dependsOn!==void 0&&(!Array.isArray(e.dependsOn)||!e.dependsOn.every(e=>typeof e==`string`)))throw TypeError(`dependsOn must be an array of job ID strings`);e.jobId!==void 0&&q(`jobId`,e.jobId);for(let t of e.dependsOn??[])q(`dependsOn`,t)}function De(e){let t;try{t=JSON.stringify(e)}catch{throw TypeError(`Job payload must be JSON serializable`)}if(t===void 0)throw TypeError(`Job payload must be JSON serializable`);let n;try{n=JSON.parse(t)}catch{throw TypeError(`Job payload encoding failed`)}if(typeof n!=`object`||!n||Array.isArray(n))throw TypeError(`Job payload must serialize to a JSON object`);return Ee(n),t}function Oe({jobId:e,...t}){return e===void 0?t:{...t,customId:e}}function ke(e){let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw TypeError(`must serialize to a JSON object`);let n=t;if(n.jobId!==void 0)throw TypeError(`serialized jobId is invalid; the bulk transport requires customId`);if(U(n.name),H(n.repeat),W(n),G(n.data),K(n),n.customId!==void 0){if(typeof n.customId!=`string`)throw TypeError(`customId must be a string`);q(`customId`,n.customId)}if(n.dependsOn!==void 0){if(!Array.isArray(n.dependsOn)||!n.dependsOn.every(e=>typeof e==`string`))throw TypeError(`dependsOn must be an array of job ID strings`);for(let e of n.dependsOn)q(`dependsOn`,e)}}function Ae(e,t){let n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);if(i<=127?n+=1:i<=2047?n+=2:i>=55296&&i<=56319&&r+1<e.length&&e.charCodeAt(r+1)>=56320&&e.charCodeAt(r+1)<=57343?(n+=4,r+=1):n+=3,n>t)return n}return n}function J(e,t,n){if(!Array.isArray(e)||e.length>1e4)return{ok:!1,error:`Bulk request must contain at most ${B} jobs`};if(!Number.isSafeInteger(t)||t<0)return{ok:!1,error:`Bulk request payload limit is invalid`};let r=11,i=n?Array(e.length):null;for(let a=0;a<e.length;a++){if(a&&(r+=1),r>t)return{ok:!1,error:`Bulk request payload exceeds the 64 MiB UTF-8 safety limit`};let o;try{o=JSON.stringify(Oe(e[a]))}catch{return{ok:!1,error:`Bulk request payload must be JSON serializable`}}if(o===void 0)return{ok:!1,error:`Bulk request payload must be JSON serializable`};if(r+=Ae(o,t-r),r>t)return{ok:!1,error:`Bulk request payload exceeds the 64 MiB UTF-8 safety limit`};if(n)try{ke(o)}catch(e){return{ok:!1,error:`Bulk job ${a+1}: ${e instanceof Error?e.message:String(e)}`}}i&&(i[a]=o)}return{ok:!0,bytes:r,body:i?`{"jobs":[${i.join(`,`)}]}`:void 0}}function je(e,t=z){let n=J(e,t,!1);return n.ok?null:n.error}function Y(e){let t=J(e,z,!0);if(!t.ok)throw TypeError(t.error);if(t.body===void 0)throw TypeError(`Bulk request payload encoding failed`);return t.body}function Me(e){if(!Array.isArray(e)||e.length>1e4)throw TypeError(`Bulk request must contain at most ${B} jobs`)}var Ne={overview:e=>p(`/dashboard`,e),queues:(e=500,t=0)=>p(`/dashboard/queues?limit=${e}&offset=${t}`),queuesSummary:async()=>F(await p(`/queues/summary`)),queueDetail:(e,t=!0)=>p(`/dashboard/queues/${c(e)}?includeJobs=${t}`),stats:e=>p(`/stats`,e),storage:()=>p(`/storage`,void 0,!1),health:()=>p(`/health`,void 0,!1,[503]),ping:()=>p(`/ping`),prometheusUrl:()=>`${e()}/prometheus`,gc:()=>p(`/gc`,g(`POST`)),heapStats:()=>p(`/heapstats`)},Pe={jobsList:(e,t,n=50,r=0)=>{let i=new URLSearchParams;return t?.length&&i.set(`states`,t.join(`,`)),i.set(`limit`,String(n)),i.set(`offset`,String(r)),p(`/queues/${c(e)}/jobs/list?${i}`)},job:e=>p(`/jobs/${i(e)}`),jobByCustomId:e=>p(`/jobs/custom/${o(e,`Custom job ID`)}`),jobResult:e=>p(`/jobs/${i(e)}/result`),jobLogs:e=>p(`/jobs/${i(e)}/logs`),jobChildren:e=>p(`/jobs/${i(e)}/children`),addJob:async(e,t)=>p(`/queues/${c(e)}/jobs`,{method:`POST`,body:De(t)}),addJobsBulk:async(e,t)=>(Me(t),p(`/queues/${c(e)}/jobs/bulk`,{method:`POST`,body:Y(t)},!0,[],_)),pullBatch:(e,t,n)=>p(`/queues/${c(e)}/jobs/pull-batch`,g(`POST`,{count:t,...n?{owner:n}:{}})),ackBatch:(e,t)=>p(`/jobs/ack-batch`,g(`POST`,{ids:e,...t?{tokens:t}:{}})),cancelJob:e=>p(`/jobs/${i(e)}`,{method:`DELETE`}),promoteJob:e=>p(`/jobs/${i(e)}/promote`,g(`POST`)),discardJob:e=>p(`/jobs/${i(e)}/discard`,g(`POST`)),retryJob:e=>p(`/jobs/${i(e)}/move-to-wait`,g(`POST`)),failJob:(e,t,n={})=>p(`/jobs/${i(e)}/fail`,g(`POST`,{error:t,...n})),updateJobData:(e,t)=>p(`/jobs/${i(e)}/data`,g(`PUT`,{data:t})),changePriority:(e,t,n)=>p(`/jobs/${i(e)}/priority`,g(`PUT`,{priority:t,...n===void 0?{}:{lifo:n}})),changeDelay:(e,t)=>p(`/jobs/${i(e)}/delay`,g(`PUT`,{delay:t})),moveToDelayed:(e,t)=>p(`/jobs/${i(e)}/move-to-delayed`,g(`POST`,{delay:t})),addJobLog:(e,t,n)=>p(`/jobs/${i(e)}/logs`,g(`POST`,{message:t,level:n})),clearJobLogs:e=>p(`/jobs/${i(e)}/logs`,{method:`DELETE`}),setJobProgress:(e,t,n)=>p(`/jobs/${i(e)}/progress`,g(`POST`,{progress:t,message:n}))};function X(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw new l(`Malformed ${t} response.`,200);return e}function Z(e,t){let n=X(e,t);if(n.ok!==!0)throw new l(`Malformed ${t} response.`,200);return n}var Q=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0;function $(e,t){if(e!==void 0)return Z(e,t)}function Fe(e,t){let n={...S(e)},r=(r,i,a=d())=>{let o=t?{...i,signal:i?.signal?AbortSignal.any([i.signal,t]):t}:i;return f(e.baseUrl,r,n,o,!0,`server`,[],a)};return Object.freeze({queuesSummary:async()=>F(await r(`/queues/summary`)),overview:()=>r(`/dashboard`),counts:async e=>{let t=X(Z(await r(`/queues/${c(e)}/counts`),`queue counts`).counts,`queue counts`);if(!Object.values(t).every(Q))throw new l(`Malformed queue counts response.`,200);return{ok:!0,counts:t}},jobsList:async(e,t,n=50,i=0)=>{let a=new URLSearchParams;t?.length&&a.set(`states`,t.join(`,`)),a.set(`limit`,String(n)),a.set(`offset`,String(i));let o=Z(await r(`/queues/${c(e)}/jobs/list?${a}`),`jobs list`);if(!Array.isArray(o.jobs)||!o.jobs.every(t=>{let n=t;return typeof n==`object`&&!!n&&!Array.isArray(n)&&typeof n.id==`string`&&n.id.length>0&&(n.queue===void 0||n.queue===e)}))throw new l(`Malformed jobs list response.`,200);return{ok:!0,jobs:o.jobs}},job:async e=>{let t=X(Z(await r(`/jobs/${i(e)}`),`job`).job,`job`);if(t.id!==e)throw new l(`Malformed job response.`,200);return{ok:!0,job:t}},dlqStats:async e=>{let t=X(Z(await r(`/queues/${c(e)}/dlq/stats`),`DLQ stats`).stats,`DLQ stats`);if(!Q(t.total))throw new l(`Malformed DLQ stats response.`,200);return{ok:!0,stats:t}},dlq:async(e,t=100,n=0)=>{let i=Z(await r(`/queues/${c(e)}/dlq?limit=${t}&offset=${n}`),`DLQ list`);if(!Array.isArray(i.entries)||!Q(i.total))throw new l(`Malformed DLQ list response.`,200);for(let e of i.entries){let t=X(X(e,`DLQ list`).job,`DLQ list`);if(typeof t.id!=`string`||!t.id)throw new l(`Malformed DLQ list response.`,200)}return{ok:!0,entries:i.entries,total:i.total}},health:async()=>X(await f(e.baseUrl,`/health`,n,t?{signal:t}:void 0,!1,`server`,[503]),`health`),stats:async()=>{let e=await r(`/stats`);return X(Z(e,`server stats`).stats,`server stats`),e},workers:async()=>I(await r(`/workers`)),crons:async()=>{let e=Z(await r(`/crons`),`crons`);if(!Array.isArray(e.crons)||!e.crons.every(e=>{let t=e;return typeof t==`object`&&!!t&&!Array.isArray(t)&&typeof t.name==`string`&&!!t.name&&typeof t.queue==`string`&&!!t.queue}))throw new l(`Malformed crons response.`,200);return{ok:!0,crons:e.crons}},addJobsBulk:async(e,t)=>(Me(t),r(`/queues/${c(e)}/jobs/bulk`,{method:`POST`,body:Y(t)},_)),pullBatch:(e,t,n)=>r(`/queues/${c(e)}/jobs/pull-batch`,g(`POST`,{count:t,...n?{owner:n}:{}})),heartbeatBatch:(e,t)=>r(`/jobs/heartbeat-batch`,g(`POST`,{ids:e,...t?{tokens:t}:{}})),ackBatch:(e,t)=>r(`/jobs/ack-batch`,g(`POST`,{ids:e,...t?{tokens:t}:{}})),retryJob:(e,t)=>r(`/jobs/${i(e)}/move-to-wait`,g(`POST`,t?{token:t}:{})),promoteJob:async e=>$(await r(`/jobs/${i(e)}/promote`,g(`POST`)),`promote job`),pause:async e=>$(await r(`/queues/${c(e)}/pause`,g(`POST`)),`pause queue`),resume:async e=>$(await r(`/queues/${c(e)}/resume`,g(`POST`)),`resume queue`),clean:(e,t={})=>r(`/queues/${c(e)}/clean`,g(`POST`,t))})}var Ie={...Ne,captureServerRequestTarget:b,createServerTargetClient:Fe,getJobAtTarget:w,captureAgentRequestTarget:x,getDbRowsAtTarget:ce,getDbExportAtTarget:pe,...Pe,...me,queueOperations:he,...we,db:te,get agentBase(){return m()},control:ne,workflows:re};Object.defineProperty(Ie,"agentBase",{configurable:!1});export{l as a,f as c,w as d,ae as i,x as l,V as n,C as o,je as r,h as s,Ie as t,b as u};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t}from"./react-vendor-CFL9l8LK.js";var n=e(t(),1),r=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},i=(e=>e?r(e):r),a=e=>e;function o(e,t=a){let r=n.useSyncExternalStore(e.subscribe,n.useCallback(()=>t(e.getState()),[e,t]),n.useCallback(()=>t(e.getInitialState()),[e,t]));return n.useDebugValue(r),r}var s=e=>{let t=i(e),n=e=>o(t,e);return Object.assign(n,t),n},c=(e=>e?s(e):s);function l(e,t){let n;try{n=e()}catch{return}return{getItem:e=>{let r=e=>e===null?null:JSON.parse(e,t?.reviver),i=n.getItem(e)??null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,t?.replacer)),removeItem:e=>n.removeItem(e)}}var u=e=>t=>{try{let n=e(t);return n instanceof Promise?n:{then(e){return u(e)(n)},catch(e){return this}}}catch(e){return{then(e){return this},catch(t){return u(t)(e)}}}},d=(e,t)=>(n,r,i)=>{let a={storage:l(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},o=!1,s=0,c=new Set,d=new Set,f=a.storage;if(!f)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...e)},r,i);let p=()=>{let e=a.partialize({...r()});return f.setItem(a.name,{state:e,version:a.version})},m=i.setState;i.setState=(e,t)=>(m(e,t),p());let h=e((...e)=>(n(...e),p()),r,i);i.getInitialState=()=>h;let g,_=()=>{if(!f)return;let e=++s;o=!1,c.forEach(e=>e(r()??h));let t=a.onRehydrateStorage?.call(a,r()??h)||void 0;return u(f.getItem.bind(f))(a.name).then(e=>{if(e)if(typeof e.version==`number`&&e.version!==a.version){if(a.migrate){let t=a.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error(`State loaded from storage couldn't be migrated since no migrate function was provided`)}else return[!1,e.state];return[!1,void 0]}).then(t=>{if(e!==s)return;let[i,o]=t;if(g=a.merge(o,r()??h),n(g,!0),i)return p()}).then(()=>{e===s&&(t?.(r(),void 0),g=r(),o=!0,d.forEach(e=>e(g)))}).catch(n=>{e===s&&t?.(void 0,n)})};return i.persist={setOptions:e=>{a={...a,...e},e.storage&&(f=e.storage)},clearStorage:()=>{f?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>_(),hasHydrated:()=>o,onHydrate:e=>(c.add(e),()=>{c.delete(e)}),onFinishHydration:e=>(d.add(e),()=>{d.delete(e)})},a.skipHydration||_(),g||h},f=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function p(e,t=!1){try{let n=globalThis.localStorage??null;return!n&&t&&e.reportMissingWrites&&e.onError?.(Error(`localStorage is unavailable`)),n}catch(t){return e.onError?.(t),null}}function m(e,t){try{let n=JSON.parse(e),r=f(n)?n:{},i=typeof r.version==`number`?r.version:void 0,a=t.sanitizeState(`state`in r?r.state:r,i);return{hydration:JSON.stringify({state:a,...i===void 0?{}:{version:i}}),canonical:JSON.stringify({state:a,version:t.version})}}catch(e){return t.onError?.(e),null}}function h(e){let t=t=>e.onError?.(t);return{getItem(n){let r=p(e);if(!r)return null;let i;try{i=r.getItem(n)}catch(e){return t(e),null}if(i===null||n!==e.key)return i;let a=m(i,e);if(!a){try{r.removeItem(n)}catch(e){t(e)}return null}if(i!==a.canonical)try{r.setItem(n,a.canonical)}catch(e){t(e);try{r.removeItem(n)}catch(e){t(e)}}return a.hydration},setItem(n,r){let i=p(e,!0);if(i)try{i.setItem(n,r)}catch(e){t(e)}},removeItem(n){let r=p(e);if(r)try{r.removeItem(n)}catch(e){t(e)}}}}var g=/^\/(?:[A-Za-z0-9._~-]+(?:\/[A-Za-z0-9._~-]+)*)?\/?$/;function _(e){try{return globalThis[e]}catch{return}}function v(e){if(typeof e!=`string`)return null;let t=e.trim();return!g.test(t)||t.split(`/`).some(e=>e===`.`||e===`..`)?null:t.replace(/\/+$/,``)||`/`}function y(e,t){return v(e)??v(t)??`/`}var b=`Use an http(s) URL without credentials, query, or fragment, or a non-root path starting with '/'.`,x=`https://bunqueue-dashboard.invalid`,ee=/\s/u;function te(e){return[...e].some(e=>{let t=e.charCodeAt(0);return e===`\\`||ee.test(e)||t<32||t===127})}function S(e){if(typeof e!=`string`)return null;let t=e.trim();if(!t||t.includes(`?`)||t.includes(`#`)||te(t))return null;if(t.startsWith(`/`)){if(t.startsWith(`//`))return null;try{let e=new URL(t,x),n=e.pathname.replace(/\/+$/,``);return e.origin!==x||!n||n===`/`||n.startsWith(`//`)?null:n}catch{return null}}let n=t.match(/^https?:\/\//i)?.[0];if(!n)return null;let r=t.slice(n.length).split(`/`,1)[0];if(!r||r.includes(`@`))return null;try{let e=new URL(t);if(e.protocol!==`http:`&&e.protocol!==`https:`||!e.hostname||e.username||e.password)return null;let n=e.pathname.replace(/\/+$/,``);return n.startsWith(`//`)?null:`${e.origin}${n}`}catch{return null}}function C(e,t){return S(e)??S(t)??`/api`}function w(e,t){return S(e)??S(t)??`http://localhost:6800`}function T(e,t){return S(e)??t}function E(e){return typeof e==`string`?e.trim():``}var ne=`default`,re=64,D=/^[a-zA-Z0-9_-]{1,64}$/u;function O(e){return{id:ne,name:`Local Bunqueue`,baseUrl:e.baseUrl,agentBaseUrl:e.agentBaseUrl}}function k(e,t){if(typeof e!=`string`)return t;let n=[...e].map(e=>{let t=e.codePointAt(0)??0;return t<=31||t===127?` `:e}).join(``).trim();return n?[...n].slice(0,re).join(``):t}function A(e,t){return typeof e==`string`&&D.test(e)?e:t}function j(e,t,n){if(!e||typeof e!=`object`||Array.isArray(e))return null;let r=e,i=S(r.baseUrl);return i?{id:A(r.id,`profile-${t+1}`),name:k(r.name,`Bunqueue ${t+1}`),baseUrl:i,agentBaseUrl:T(r.agentBaseUrl,n.agentBaseUrl)}:null}function M(e,t){if(!Array.isArray(e))return[O(t)];let n=[],r=new Set;for(let[i,a]of e.slice(0,32).entries()){let e=j(a,i,t);!e||r.has(e.id)||(r.add(e.id),n.push(e))}return n.length?n:[O(t)]}function N(e,t,n){let r=e&&typeof e==`object`&&!Array.isArray(e)?e:{},i=M(r.profiles,t),a=typeof r.activeProfileId==`string`?r.activeProfileId:``;return{profiles:i,activeProfileId:i.some(e=>e.id===a)?a:i[0].id,refreshMs:n(r.refreshMs)}}function P(e,t,n){let r=e&&typeof e==`object`&&!Array.isArray(e)?e:{};if(Array.isArray(r.profiles))return N(r,t,n);let i=O({...t,baseUrl:T(r.baseUrl,t.baseUrl)});return{profiles:[i],activeProfileId:i.id,refreshMs:n(r.refreshMs)}}function ie(e){let t=new Set(e.map(e=>e.id)),n=globalThis.crypto?.randomUUID?.().replaceAll(`-`,``).slice(0,16)||`${Date.now().toString(36)}${Math.random().toString(36).slice(2,8)}`,r=`node-${n}`,i=2;for(;t.has(r);)r=`node-${n}-${i++}`;return r}var F=`bq-dash-connection`,I=3e3,ae=500,oe=6e4,L={baseUrl:C(void 0,_(`__BUNQUEUE_API_URL__`)),agentBaseUrl:w(_(`__BUNQUEUE_AGENT_URL__`),void 0),refreshMs:I},R=O(L);function z(e){return typeof e!=`number`||!Number.isFinite(e)?I:Math.min(oe,Math.max(ae,Math.round(e)))}function B(e){let t=e;return N({profiles:t?.profiles??(t?.baseUrl?[{...R,baseUrl:t.baseUrl}]:void 0),activeProfileId:t?.activeProfileId,refreshMs:t?.refreshMs},L,z)}function V(e,t){if(t!==void 0&&t<4)return H(e,t);let n=e;return Array.isArray(n?.profiles)?N(e,L,z):P(e,L,z)}function H(e,t,n=L.baseUrl){let r={...L,baseUrl:C(void 0,n)},i=e&&typeof e==`object`&&!Array.isArray(e)?e:{},a=t<3&&i.baseUrl===`/api`?{...i,baseUrl:r.baseUrl}:e;return t<4?P(a,r,z):N(e,r,z)}var U=null;function W(e){U=e instanceof Error?e:Error(String(e))}function G(){U=null}function K(){return U?{persisted:!1,error:`${U.name&&U.name!==`Error`?`${U.name}: `:``}${U.message}`}:{persisted:!0}}var se=l(()=>h({key:F,version:4,sanitizeState:V,onError:W,reportMissingWrites:!0})),q=new Map;function J(e){return e.profiles.find(t=>t.id===e.activeProfileId)??e.profiles[0]??R}function Y(e,t){let n=J(e),r={...n,...t,id:n.id};return e.profiles.map(e=>e.id===n.id?r:e)}function X(e,t,n){q.set(e,{token:E(t),agentToken:E(n)})}var Z=c()(d((e,t)=>({profiles:[R],activeProfileId:R.id,baseUrl:R.baseUrl,agentBaseUrl:R.agentBaseUrl,token:``,agentToken:``,refreshMs:L.refreshMs,saveConnection:n=>{G();let r=t(),i=J(r),a={...i,name:k(n.name,i.name),baseUrl:T(n.baseUrl,L.baseUrl),agentBaseUrl:T(n.agentBaseUrl??i.agentBaseUrl,L.agentBaseUrl)};return X(i.id,n.token,n.agentToken),e({profiles:Y(r,a),baseUrl:a.baseUrl,agentBaseUrl:a.agentBaseUrl,token:E(n.token),agentToken:E(n.agentToken)}),K()},addProfile:n=>{let r=t();if(r.profiles.length>=32)return{persisted:!1,error:`At most 32 Bunqueue nodes are supported.`};G();let i=ie(r.profiles),a={id:i,name:k(n.name,`Bunqueue ${r.profiles.length+1}`),baseUrl:T(n.baseUrl,L.baseUrl),agentBaseUrl:T(n.agentBaseUrl,L.agentBaseUrl)};return X(i,n.token,n.agentToken),e({profiles:[...r.profiles,a],activeProfileId:i,baseUrl:a.baseUrl,agentBaseUrl:a.agentBaseUrl,token:E(n.token),agentToken:E(n.agentToken)}),{...K(),id:i}},activateProfile:n=>{let r=t(),i=r.profiles.find(e=>e.id===n);if(!i)return!1;X(r.activeProfileId,r.token,r.agentToken);let a=q.get(n)??{token:``,agentToken:``};return e({activeProfileId:n,baseUrl:i.baseUrl,agentBaseUrl:i.agentBaseUrl,...a}),!0},removeProfile:n=>{let r=t();if(r.profiles.length===1||!r.profiles.some(e=>e.id===n))return!1;q.delete(n);let i=r.profiles.filter(e=>e.id!==n);if(n!==r.activeProfileId)return e({profiles:i}),!0;let a=i[0],o=q.get(a.id)??{token:``,agentToken:``};return e({profiles:i,activeProfileId:a.id,baseUrl:a.baseUrl,agentBaseUrl:a.agentBaseUrl,...o}),!0},setBaseUrl:t=>e(e=>{let n=T(t,L.baseUrl);return{baseUrl:n,profiles:Y(e,{baseUrl:n})}}),setAgentBaseUrl:t=>e(e=>{let n=T(t,L.agentBaseUrl);return{agentBaseUrl:n,profiles:Y(e,{agentBaseUrl:n})}}),setToken:t=>e(e=>{let n=E(t);return X(e.activeProfileId,n,e.agentToken),{token:n}}),setAgentToken:t=>e(e=>{let n=E(t);return X(e.activeProfileId,e.token,n),{agentToken:n}}),setRefreshMs:t=>e({refreshMs:z(t)})}),{name:F,storage:se,version:4,partialize:B,migrate:H,merge:(e,t)=>{q.clear();let n=V(e),r=n.profiles.find(e=>e.id===n.activeProfileId)??n.profiles[0];return{...t,...n,baseUrl:r.baseUrl,agentBaseUrl:r.agentBaseUrl,token:``,agentToken:``}}}));function ce(e){let t=Z.getState(),n=t.profiles.find(t=>t.id===e);if(!n)return null;let r=e===t.activeProfileId?{token:E(t.token),agentToken:E(t.agentToken)}:q.get(e)??{token:``,agentToken:``};return Object.freeze({...n,...r})}var le=()=>T(Z.getState().baseUrl,L.baseUrl),ue=()=>T(Z.getState().agentBaseUrl,L.agentBaseUrl),Q=()=>$(Z.getState().token),de=()=>$(Z.getState().agentToken);function $(e){let t=E(e);return t?{Authorization:`Bearer ${t}`}:{}}export{le as a,S as c,h as d,l as f,Q as i,y as l,c as m,de as n,Z as o,d as p,ue as r,b as s,ce as t,_ as u};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t}from"./react-vendor-CFL9l8LK.js";import{o as n}from"./connectionStore-CVjQyIZv.js";var r=e(t(),1),i=0,a=new Set;n.subscribe((e,t)=>{if(!(e.baseUrl===t.baseUrl&&e.agentBaseUrl===t.agentBaseUrl&&e.activeProfileId===t.activeProfileId&&e.token===t.token&&e.agentToken===t.agentToken)){i+=1;for(let e of a)e()}});function o(){return i}function s(){return(0,r.useSyncExternalStore)(c,o,o)}function c(e){return a.add(e),()=>a.delete(e)}export{s as n,o as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./react-vendor-CFL9l8LK.js";import{r as t}from"./StatusBadge-DereLzOj.js";var n=e();function r({className:e,decorative:r=!1}){let i=t(`inline-block size-4 animate-spin rounded-full border-2 border-current border-t-transparent`,e);return r?(0,n.jsx)(`span`,{className:i,"aria-hidden":`true`}):(0,n.jsx)(`span`,{className:i,role:`status`,"aria-label":`Loading`})}function i({label:e=`Loading…`}){return(0,n.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`flex items-center justify-center gap-3 py-16 text-sm text-muted`,children:[(0,n.jsx)(r,{decorative:!0}),e]})}function a({icon:e,title:t,hint:r,action:i}){return(0,n.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-xl border border-dashed border-line py-14 text-center`,children:[e&&(0,n.jsx)(`div`,{className:`text-faint [&>svg]:size-8`,children:e}),(0,n.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t}),r&&(0,n.jsx)(`div`,{className:`max-w-sm text-xs text-faint`,children:r}),i&&(0,n.jsx)(`div`,{className:`mt-2`,children:i})]})}function o({onRetry:e,message:t=`Could not refresh bunqueue data — the view may be unavailable or stale.`}){return(0,n.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`mb-4 flex flex-wrap items-center gap-3 rounded-lg border border-amber-500/25 bg-amber-500/[0.06] px-4 py-2.5 text-sm`,children:[(0,n.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-amber-400`,"aria-hidden":`true`}),(0,n.jsx)(`span`,{className:`text-amber-300/90 light:text-amber-700`,children:t}),e&&(0,n.jsx)(`button`,{type:`button`,onClick:e,className:`ml-auto shrink-0 rounded-md border border-amber-500/30 px-2.5 py-1 text-xs font-medium text-amber-200 light:text-amber-700 hover:border-amber-400/50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`,children:`Retry`})]})}function s({error:e,onRetry:t}){return(0,n.jsxs)(`div`,{role:`alert`,"aria-atomic":`true`,className:`flex flex-col items-center justify-center gap-3 rounded-xl border border-red-500/20 bg-red-500/5 py-14 text-center`,children:[(0,n.jsx)(`div`,{className:`text-sm font-medium text-danger`,children:`Something went wrong`}),(0,n.jsx)(`div`,{className:`max-w-md text-xs text-faint`,children:e.message}),t&&(0,n.jsx)(`button`,{type:`button`,onClick:t,className:`mt-1 rounded-lg border border-line bg-surface-2 px-3 py-1.5 text-xs font-medium text-fg hover:border-line-strong focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`,children:`Retry`})]})}export{o as i,s as n,i as r,a as t};
@@ -1 +0,0 @@
1
- var e=new Intl.NumberFormat(`de-DE`),t=new Intl.DateTimeFormat(`it-IT`,{day:`2-digit`,month:`2-digit`,year:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`});function n(t){return t==null||!Number.isFinite(t)?`0`:e.format(t)}function r(e,t=2){return e==null||!Number.isFinite(e)?`0%`:`${(e*100).toFixed(t)}%`}function i(e,t){let n=e+t;return n>0?t/n:null}function a(e){if(e==null||!Number.isFinite(e))return`—`;let n=new Date(e);return Number.isNaN(n.getTime())?`—`:t.format(n)}function o(e,t=Date.now()){if(e==null||!Number.isFinite(e))return`—`;let n=Math.max(0,t-e),r=Math.floor(n/1e3);if(r<60)return`${r}s ago`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function s(e){if(e==null||!Number.isFinite(e)||e<0)return`—`;let t=Math.round(e);if(t<1e3)return`${t}ms`;let n=e/1e3;if(n<59.95)return`${n.toFixed(1)}s`;let r=Math.round(n);return`${Math.floor(r/60)}m ${r%60}s`}function c(e,t){if(e==null||t==null)return;let n=t-e;return n>=0?n:void 0}function l(e){if(e==null||!Number.isFinite(e))return`—`;let t=Math.max(0,Math.floor(e)),n=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60),a=[];return n&&a.push(`${n}d`),(r||n)&&a.push(`${r}h`),a.push(`${i}m`),a.join(` `)}function u(e){return e==null||!Number.isFinite(e)?`0`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?Number((e/1e3).toFixed(1))>=1e3?`${(e/1e6).toFixed(1)}M`:`${(e/1e3).toFixed(1)}K`:String(Math.round(e))}function d(e){if(e==null||!Number.isFinite(e))return`—`;if(e>=1e3)return`${(e/1e3).toFixed(2)}s`;let t=+(e<10);return Number(e.toFixed(t))>=1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(t)}ms`}var f=/(?:\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b[@-Z\\^_])/g;function p(e){return e.replace(f,``)}function m(e){if(e==null||!Number.isFinite(e))return`—`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r++;return r<t.length-1&&Number(n.toFixed(r===0?0:1))>=1024&&(n/=1024,r++),`${n.toFixed(r===0?0:1)} ${t[r]}`}export{s as a,r as c,c as d,p as f,a as i,o as l,m as n,d as o,u as r,n as s,i as t,l as u};