agent-relay-server 0.127.2 → 0.127.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 (156) hide show
  1. package/docs/openapi.json +1 -1
  2. package/package.json +7 -5
  3. package/public/assets/{MessageBubble-DnXnkt4a.js → MessageBubble-D2Wzxied.js} +2 -2
  4. package/public/assets/{MessageBubble-DnXnkt4a.js.map → MessageBubble-D2Wzxied.js.map} +1 -1
  5. package/public/assets/{PlanGraphPanel-D6CPEpQD.js → PlanGraphPanel-DH_xoWZi.js} +2 -2
  6. package/public/assets/{PlanGraphPanel-D6CPEpQD.js.map → PlanGraphPanel-DH_xoWZi.js.map} +1 -1
  7. package/public/assets/{activity-ZPwHcPLK.js → activity-B-ozOwNq.js} +2 -2
  8. package/public/assets/{activity-ZPwHcPLK.js.map → activity-B-ozOwNq.js.map} +1 -1
  9. package/public/assets/{agent-profiles-CT0E9LV1.js → agent-profiles-DZgjO25A.js} +2 -2
  10. package/public/assets/{agent-profiles-CT0E9LV1.js.map → agent-profiles-DZgjO25A.js.map} +1 -1
  11. package/public/assets/{agent-type-icon-BmBR-9CH.js → agent-type-icon-B9cLaOoz.js} +2 -2
  12. package/public/assets/{agent-type-icon-BmBR-9CH.js.map → agent-type-icon-B9cLaOoz.js.map} +1 -1
  13. package/public/assets/agents-mXBLSY6O.js +2 -0
  14. package/public/assets/{agents-Dt5TncjC.js.map → agents-mXBLSY6O.js.map} +1 -1
  15. package/public/assets/{analytics-BZtRycyL.js → analytics-5Ize_UL5.js} +3 -3
  16. package/public/assets/{analytics-BZtRycyL.js.map → analytics-5Ize_UL5.js.map} +1 -1
  17. package/public/assets/{automation-yzUJbvT2.js → automation-CidMvW2e.js} +2 -2
  18. package/public/assets/{automation-yzUJbvT2.js.map → automation-CidMvW2e.js.map} +1 -1
  19. package/public/assets/{badge-BCvp7LK3.js → badge-BkNNvFNa.js} +2 -2
  20. package/public/assets/{badge-BCvp7LK3.js.map → badge-BkNNvFNa.js.map} +1 -1
  21. package/public/assets/{branch-state-badge-Cscjqf-E.js → branch-state-badge-DnS40KCb.js} +2 -2
  22. package/public/assets/{branch-state-badge-Cscjqf-E.js.map → branch-state-badge-DnS40KCb.js.map} +1 -1
  23. package/public/assets/{button-DyHjsHY3.js → button-DUaC2wSQ.js} +2 -2
  24. package/public/assets/{button-DyHjsHY3.js.map → button-DUaC2wSQ.js.map} +1 -1
  25. package/public/assets/{card-BoqYxpVW.js → card-r-yAV4cH.js} +2 -2
  26. package/public/assets/{card-BoqYxpVW.js.map → card-r-yAV4cH.js.map} +1 -1
  27. package/public/assets/{channels-DAtOnA6o.js → channels-MPO2FOBv.js} +2 -2
  28. package/public/assets/{channels-DAtOnA6o.js.map → channels-MPO2FOBv.js.map} +1 -1
  29. package/public/assets/chat-Ca4ERso5.js +2 -0
  30. package/public/assets/chat-Ca4ERso5.js.map +1 -0
  31. package/public/assets/{connectors-B2grC-hl.js → connectors-BbYdtRkW.js} +2 -2
  32. package/public/assets/{connectors-B2grC-hl.js.map → connectors-BbYdtRkW.js.map} +1 -1
  33. package/public/assets/copy-button-u463GPZR.js +2 -0
  34. package/public/assets/{copy-button-C67FUG3E.js.map → copy-button-u463GPZR.js.map} +1 -1
  35. package/public/assets/{display-aTnwsqQh.js → display-BNI-7rdq.js} +2 -2
  36. package/public/assets/{display-aTnwsqQh.js.map → display-BNI-7rdq.js.map} +1 -1
  37. package/public/assets/{dist-D5w04z0l.js → dist-5e_is3Xr.js} +2 -2
  38. package/public/assets/{dist-D5w04z0l.js.map → dist-5e_is3Xr.js.map} +1 -1
  39. package/public/assets/{dist-BD4Xc13v.js → dist-ActI2qb5.js} +2 -2
  40. package/public/assets/{dist-BD4Xc13v.js.map → dist-ActI2qb5.js.map} +1 -1
  41. package/public/assets/dist-B-FQ0-X3.js +2 -0
  42. package/public/assets/{dist-G8YBD-wp.js.map → dist-B-FQ0-X3.js.map} +1 -1
  43. package/public/assets/{dist-f6MW74eX.js → dist-BduURKro.js} +2 -2
  44. package/public/assets/{dist-f6MW74eX.js.map → dist-BduURKro.js.map} +1 -1
  45. package/public/assets/{dist-BFDfbfNC.js → dist-Bp0-OBcd.js} +2 -2
  46. package/public/assets/{dist-BFDfbfNC.js.map → dist-Bp0-OBcd.js.map} +1 -1
  47. package/public/assets/{dist-C_VOBSaK.js → dist-CJ7e7uqU.js} +2 -2
  48. package/public/assets/{dist-C_VOBSaK.js.map → dist-CJ7e7uqU.js.map} +1 -1
  49. package/public/assets/{dist-BNB3fTO-.js → dist-CYzOsD_n.js} +2 -2
  50. package/public/assets/{dist-BNB3fTO-.js.map → dist-CYzOsD_n.js.map} +1 -1
  51. package/public/assets/{dist-CQMQ5iku.js → dist-CpcQJrKV.js} +2 -2
  52. package/public/assets/{dist-CQMQ5iku.js.map → dist-CpcQJrKV.js.map} +1 -1
  53. package/public/assets/dist-DFgmDjLv.js +2 -0
  54. package/public/assets/{dist-CHKra2JV.js.map → dist-DFgmDjLv.js.map} +1 -1
  55. package/public/assets/{dist-DG75bvPp.js → dist-DrpSpMKL.js} +2 -2
  56. package/public/assets/{dist-DG75bvPp.js.map → dist-DrpSpMKL.js.map} +1 -1
  57. package/public/assets/dist-DzWoiN2z.js +2 -0
  58. package/public/assets/{dist-BJKxqIQd.js.map → dist-DzWoiN2z.js.map} +1 -1
  59. package/public/assets/{es2015-a6fysEVz.js → es2015-DNuudVtQ.js} +2 -2
  60. package/public/assets/{es2015-a6fysEVz.js.map → es2015-DNuudVtQ.js.map} +1 -1
  61. package/public/assets/formatted-body-BEI1zP7i.js +3 -0
  62. package/public/assets/{formatted-body-D5-1aiyB.js.map → formatted-body-BEI1zP7i.js.map} +1 -1
  63. package/public/assets/{formatted-body-impl-Do5NbJUA.js → formatted-body-impl-CNQ5sqwK.js} +2 -2
  64. package/public/assets/{formatted-body-impl-Do5NbJUA.js.map → formatted-body-impl-CNQ5sqwK.js.map} +1 -1
  65. package/public/assets/index-D2Mpzpft.js +26 -0
  66. package/public/assets/{index-BdNafiPz.js.map → index-D2Mpzpft.js.map} +1 -1
  67. package/public/assets/{input-Rc4oWv4q.js → input-BvNUEkDd.js} +2 -2
  68. package/public/assets/{input-Rc4oWv4q.js.map → input-BvNUEkDd.js.map} +1 -1
  69. package/public/assets/{insights-i6AEZT_a.js → insights-5rkMFRgf.js} +2 -2
  70. package/public/assets/{insights-i6AEZT_a.js.map → insights-5rkMFRgf.js.map} +1 -1
  71. package/public/assets/{integrations-9c6IdRU4.js → integrations-BEaqjfP4.js} +2 -2
  72. package/public/assets/{integrations-9c6IdRU4.js.map → integrations-BEaqjfP4.js.map} +1 -1
  73. package/public/assets/{lib-BZ6WPg2t.js → lib-BvrbNA2I.js} +2 -2
  74. package/public/assets/{lib-BZ6WPg2t.js.map → lib-BvrbNA2I.js.map} +1 -1
  75. package/public/assets/{lucide-react-NXHPIMsX.js → lucide-react-DD_zIava.js} +2 -2
  76. package/public/assets/{lucide-react-NXHPIMsX.js.map → lucide-react-DD_zIava.js.map} +1 -1
  77. package/public/assets/maintenance-CEiURaYZ.js +2 -0
  78. package/public/assets/{maintenance-CJ6wikpg.js.map → maintenance-CEiURaYZ.js.map} +1 -1
  79. package/public/assets/{managed-agents-JZn0xNJR.js → managed-agents-CetHyuQW.js} +4 -4
  80. package/public/assets/{managed-agents-JZn0xNJR.js.map → managed-agents-CetHyuQW.js.map} +1 -1
  81. package/public/assets/{markdown-preview-impl-BsvAkpR4.js → markdown-preview-impl-ZwGYvObh.js} +2 -2
  82. package/public/assets/{markdown-preview-impl-BsvAkpR4.js.map → markdown-preview-impl-ZwGYvObh.js.map} +1 -1
  83. package/public/assets/memory-BTm8XzCg.js +2 -0
  84. package/public/assets/{memory-BE9IwCdC.js.map → memory-BTm8XzCg.js.map} +1 -1
  85. package/public/assets/{messages-vXgdc3H4.js → messages-fJd17pzv.js} +2 -2
  86. package/public/assets/{messages-vXgdc3H4.js.map → messages-fJd17pzv.js.map} +1 -1
  87. package/public/assets/{orchestrators-CribhLg-.js → orchestrators-C5XQ2UYy.js} +2 -2
  88. package/public/assets/{orchestrators-CribhLg-.js.map → orchestrators-C5XQ2UYy.js.map} +1 -1
  89. package/public/assets/overview-Bhk-tqKc.js +2 -0
  90. package/public/assets/{overview-q3O9K9VK.js.map → overview-Bhk-tqKc.js.map} +1 -1
  91. package/public/assets/{pairs-BNOnd0IE.js → pairs-CBrszSZh.js} +2 -2
  92. package/public/assets/{pairs-BNOnd0IE.js.map → pairs-CBrszSZh.js.map} +1 -1
  93. package/public/assets/{projects-iDkxAGBW.js → projects-DXy9JviE.js} +2 -2
  94. package/public/assets/{projects-iDkxAGBW.js.map → projects-DXy9JviE.js.map} +1 -1
  95. package/public/assets/prompt-settings-DEQhAt2X.js +2 -0
  96. package/public/assets/{prompt-settings-Bdz_xCgD.js.map → prompt-settings-DEQhAt2X.js.map} +1 -1
  97. package/public/assets/{react-dom-8yaD9iJG.js → react-dom-CADlISeR.js} +2 -2
  98. package/public/assets/{react-dom-8yaD9iJG.js.map → react-dom-CADlISeR.js.map} +1 -1
  99. package/public/assets/{registry-DPcyGypi.js → registry-DsZILce1.js} +4 -4
  100. package/public/assets/{registry-DPcyGypi.js.map → registry-DsZILce1.js.map} +1 -1
  101. package/public/assets/{security-Z3l3u-Pl.js → security-C-wVZm5k.js} +2 -2
  102. package/public/assets/{security-Z3l3u-Pl.js.map → security-C-wVZm5k.js.map} +1 -1
  103. package/public/assets/{select-BX_lW49D.js → select-DsEGBLJk.js} +2 -2
  104. package/public/assets/{select-BX_lW49D.js.map → select-DsEGBLJk.js.map} +1 -1
  105. package/public/assets/settings-D3_r5IGA.js +6 -0
  106. package/public/assets/{settings-Y381jZt7.js.map → settings-D3_r5IGA.js.map} +1 -1
  107. package/public/assets/{store-D-Frk_EC.js → store-DKTb9O0v.js} +5 -5
  108. package/public/assets/{store-D-Frk_EC.js.map → store-DKTb9O0v.js.map} +1 -1
  109. package/public/assets/{task-chip-CeujtXYT.js → task-chip-DwdauC08.js} +2 -2
  110. package/public/assets/{task-chip-CeujtXYT.js.map → task-chip-DwdauC08.js.map} +1 -1
  111. package/public/assets/{tasks-Di6d0_Ch.js → tasks-DnEzBku4.js} +2 -2
  112. package/public/assets/{tasks-Di6d0_Ch.js.map → tasks-DnEzBku4.js.map} +1 -1
  113. package/public/assets/{teams-DJv4l-_l.js → teams-DpAbZ3ye.js} +2 -2
  114. package/public/assets/{teams-DJv4l-_l.js.map → teams-DpAbZ3ye.js.map} +1 -1
  115. package/public/assets/{terminal-viewer-impl-3zBLpRel.js → terminal-viewer-impl-_IU5o8ya.js} +3 -3
  116. package/public/assets/{terminal-viewer-impl-3zBLpRel.js.map → terminal-viewer-impl-_IU5o8ya.js.map} +1 -1
  117. package/public/assets/types-BqeSkWrv.js.map +1 -1
  118. package/public/assets/{use-keyboard-viewport-cGEmrGE7.js → use-keyboard-viewport-wTh5CR4-.js} +2 -2
  119. package/public/assets/{use-keyboard-viewport-cGEmrGE7.js.map → use-keyboard-viewport-wTh5CR4-.js.map} +1 -1
  120. package/public/assets/user-avatar-CZ3XO8ml.js +2 -0
  121. package/public/assets/{user-avatar-qbo-B3dQ.js.map → user-avatar-CZ3XO8ml.js.map} +1 -1
  122. package/public/assets/{work-queue-D73-hP0c.js → work-queue-DKcLZWRl.js} +2 -2
  123. package/public/assets/{work-queue-D73-hP0c.js.map → work-queue-DKcLZWRl.js.map} +1 -1
  124. package/public/assets/workspaces-Cs2IZZOI.js +3 -0
  125. package/public/assets/{workspaces-CoDz-iZd.js.map → workspaces-Cs2IZZOI.js.map} +1 -1
  126. package/public/index.html +24 -24
  127. package/runner/plugins/claude/.claude-plugin/plugin.json +1 -1
  128. package/runner/plugins/claude/monitors/relay-monitor.provisioned.mjs +4 -1
  129. package/runner/src/adapter.ts +5 -1
  130. package/runner/src/adapters/claude-delivery.ts +5 -1
  131. package/runner/src/adapters/claude-transcript.ts +52 -3
  132. package/runner/src/control-server.ts +34 -17
  133. package/runner/src/runner-core.ts +73 -32
  134. package/scripts/orchestrator-spawn-smoke.ts +81 -15
  135. package/src/bus.ts +6 -41
  136. package/src/db/messages.ts +20 -8
  137. package/src/prompt-resolver.ts +12 -12
  138. package/src/self-resume.ts +50 -8
  139. package/src/services/bus-command-update.ts +59 -0
  140. package/src/services/task-delivery.ts +30 -3
  141. package/public/assets/agents-Dt5TncjC.js +0 -2
  142. package/public/assets/chat-DhYX9BDG.js +0 -2
  143. package/public/assets/chat-DhYX9BDG.js.map +0 -1
  144. package/public/assets/copy-button-C67FUG3E.js +0 -2
  145. package/public/assets/dist-BJKxqIQd.js +0 -2
  146. package/public/assets/dist-CHKra2JV.js +0 -2
  147. package/public/assets/dist-G8YBD-wp.js +0 -2
  148. package/public/assets/formatted-body-D5-1aiyB.js +0 -3
  149. package/public/assets/index-BdNafiPz.js +0 -26
  150. package/public/assets/maintenance-CJ6wikpg.js +0 -2
  151. package/public/assets/memory-BE9IwCdC.js +0 -2
  152. package/public/assets/overview-q3O9K9VK.js +0 -2
  153. package/public/assets/prompt-settings-Bdz_xCgD.js +0 -2
  154. package/public/assets/settings-Y381jZt7.js +0 -6
  155. package/public/assets/user-avatar-qbo-B3dQ.js +0 -2
  156. package/public/assets/workspaces-CoDz-iZd.js +0 -3
@@ -1,2 +0,0 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{R as t,W as n,er as r,gr as i,h as a,o,rr as s,tr as c,un as l,yn as u}from"./lucide-react-NXHPIMsX.js";import{p as d,t as f}from"./store-D-Frk_EC.js";import{K as p,h as m}from"./display-aTnwsqQh.js";import{t as h}from"./badge-BCvp7LK3.js";import{t as g}from"./button-DyHjsHY3.js";import{G as _}from"./index-BdNafiPz.js";var v=e(i(),1),y=s(),b={succeeded:`bg-emerald-500/10 text-emerald-400 border-emerald-500/30`,running:`bg-blue-500/10 text-blue-400 border-blue-500/30`,failed:`bg-red-500/10 text-red-400 border-red-500/30`,idle:`bg-zinc-500/10 text-zinc-400 border-zinc-500/30`,disabled:`bg-zinc-500/10 text-zinc-500 border-zinc-500/20`};function x(){let e=d(),n=f(e=>e.maintenanceJobs),r=f(e=>e.fetchMaintenanceJobs),i=f(e=>e.runMaintenanceJob),a=(0,v.useMemo)(()=>({failed:n.filter(e=>e.lastStatus===`failed`).length,running:n.filter(e=>e.running||e.lastStatus===`running`).length,dueSoon:n.filter(t=>t.nextRunAt&&t.nextRunAt<=e+300*1e3).length}),[n,e]);return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between flex-wrap gap-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,y.jsx)(o,{className:`h-5 w-5 text-muted-foreground`}),(0,y.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Maintenance`}),(0,y.jsx)(h,{variant:`secondary`,children:n.length}),a.running>0&&(0,y.jsxs)(h,{className:`border border-blue-500/30 bg-blue-500/10 text-blue-400`,children:[a.running,` running`]}),a.failed>0&&(0,y.jsxs)(h,{variant:`destructive`,children:[a.failed,` failing`]}),a.dueSoon>0&&(0,y.jsxs)(h,{className:`border border-yellow-500/30 bg-yellow-500/10 text-yellow-400`,children:[a.dueSoon,` due soon`]})]}),(0,y.jsxs)(g,{size:`sm`,variant:`outline`,onClick:()=>void r(),children:[(0,y.jsx)(t,{className:`h-3.5 w-3.5`}),` Refresh`]})]}),(0,y.jsx)(_,{className:`h-[calc(100dvh-10rem)]`,children:n.length===0?(0,y.jsx)(`div`,{className:`rounded-md border border-border px-3 py-12 text-center text-sm text-muted-foreground`,children:`No maintenance jobs registered`}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:`hidden overflow-x-auto rounded-md border border-border md:block`,children:(0,y.jsxs)(`table`,{className:`w-full min-w-[980px] text-sm`,children:[(0,y.jsx)(`thead`,{className:`bg-muted/40 text-xs text-muted-foreground`,children:(0,y.jsxs)(`tr`,{children:[(0,y.jsx)(`th`,{className:`px-3 py-2 text-left font-medium`,children:`Job`}),(0,y.jsx)(`th`,{className:`px-3 py-2 text-left font-medium`,children:`Status`}),(0,y.jsx)(`th`,{className:`px-3 py-2 text-left font-medium`,children:`Last run`}),(0,y.jsx)(`th`,{className:`px-3 py-2 text-left font-medium`,children:`Next run`}),(0,y.jsx)(`th`,{className:`px-3 py-2 text-left font-medium`,children:`Duration`}),(0,y.jsx)(`th`,{className:`px-3 py-2 text-left font-medium`,children:`Result`}),(0,y.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:`Action`})]})}),(0,y.jsx)(`tbody`,{children:n.map(t=>(0,y.jsx)(T,{job:t,now:e,onRun:()=>void i(t.id)},t.id))})]})}),(0,y.jsx)(`div`,{className:`space-y-3 md:hidden`,children:n.map(t=>(0,y.jsx)(w,{job:t,now:e,onRun:()=>void i(t.id)},t.id))})]})})]})}function S(e){return e.running?`running`:e.enabled?e.lastStatus:`disabled`}function C({status:e}){return(0,y.jsxs)(h,{variant:`outline`,className:c(`border`,b[e]||b.idle),children:[E(e),e]})}function w({job:e,now:t,onRun:r}){let i=S(e);return(0,y.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,y.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsx)(`div`,{className:`font-medium`,children:e.title}),(0,y.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e.description}),(0,y.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-muted-foreground/80`,children:e.id})]}),(0,y.jsx)(C,{status:i})]}),e.consecutiveFailures>0&&(0,y.jsxs)(`div`,{className:`mt-2 text-xs text-red-400`,children:[e.consecutiveFailures,` failure`,e.consecutiveFailures===1?``:`s`]}),(0,y.jsxs)(`dl`,{className:`mt-3 grid grid-cols-3 gap-2 text-xs`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`dt`,{className:`text-muted-foreground`,children:`Last run`}),(0,y.jsx)(`dd`,{children:e.lastRunAt?(0,y.jsx)(`span`,{title:m(e.lastRunAt),children:p(t,e.lastRunAt)}):`never`})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`dt`,{className:`text-muted-foreground`,children:`Next run`}),(0,y.jsx)(`dd`,{children:e.nextRunAt?(0,y.jsx)(`span`,{title:m(e.nextRunAt),children:O(t,e.nextRunAt)}):`-`})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`dt`,{className:`text-muted-foreground`,children:`Duration`}),(0,y.jsx)(`dd`,{children:e.lastDurationMs===void 0?`-`:`${e.lastDurationMs}ms`})]})]}),(0,y.jsxs)(`div`,{className:`mt-3`,children:[(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Result`}),e.lastError?(0,y.jsx)(`div`,{className:`mt-0.5 text-xs text-red-400 line-clamp-3`,children:e.lastError}):(0,y.jsx)(`div`,{className:`mt-0.5 font-mono text-[11px] text-muted-foreground line-clamp-3`,children:D(e)})]}),(0,y.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,y.jsxs)(g,{size:`sm`,variant:`outline`,disabled:!e.enabled||e.running,onClick:r,children:[(0,y.jsx)(n,{className:`h-3.5 w-3.5`}),` Run`]})})]})}function T({job:e,now:t,onRun:r}){let i=S(e);return(0,y.jsxs)(`tr`,{className:`border-t border-border align-top`,children:[(0,y.jsxs)(`td`,{className:`px-3 py-3`,children:[(0,y.jsx)(`div`,{className:`font-medium`,children:e.title}),(0,y.jsx)(`div`,{className:`mt-0.5 max-w-md text-xs text-muted-foreground`,children:e.description}),(0,y.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-muted-foreground/80`,children:e.id})]}),(0,y.jsxs)(`td`,{className:`px-3 py-3`,children:[(0,y.jsx)(C,{status:i}),e.consecutiveFailures>0&&(0,y.jsxs)(`div`,{className:`mt-1 text-xs text-red-400`,children:[e.consecutiveFailures,` failure`,e.consecutiveFailures===1?``:`s`]})]}),(0,y.jsx)(`td`,{className:`px-3 py-3 text-xs text-muted-foreground`,children:e.lastRunAt?(0,y.jsx)(`span`,{title:m(e.lastRunAt),children:p(t,e.lastRunAt)}):`never`}),(0,y.jsx)(`td`,{className:`px-3 py-3 text-xs text-muted-foreground`,children:e.nextRunAt?(0,y.jsx)(`span`,{title:m(e.nextRunAt),children:O(t,e.nextRunAt)}):`-`}),(0,y.jsx)(`td`,{className:`px-3 py-3 text-xs text-muted-foreground`,children:e.lastDurationMs===void 0?`-`:`${e.lastDurationMs}ms`}),(0,y.jsx)(`td`,{className:`px-3 py-3`,children:e.lastError?(0,y.jsx)(`div`,{className:`max-w-sm text-xs text-red-400 line-clamp-3`,children:e.lastError}):(0,y.jsx)(`div`,{className:`max-w-sm font-mono text-[11px] text-muted-foreground line-clamp-3`,children:D(e)})}),(0,y.jsx)(`td`,{className:`px-3 py-3 text-right`,children:(0,y.jsxs)(g,{size:`sm`,variant:`outline`,disabled:!e.enabled||e.running,onClick:r,children:[(0,y.jsx)(n,{className:`h-3.5 w-3.5`}),` Run`]})})]})}function E(e){return e===`succeeded`?(0,y.jsx)(u,{className:`mr-1 h-3 w-3`}):e===`running`?(0,y.jsx)(r,{className:`mr-1 h-3 w-3`}):e===`failed`?(0,y.jsx)(a,{className:`mr-1 h-3 w-3`}):(0,y.jsx)(l,{className:`mr-1 h-3 w-3`})}function D(e){if(!e.lastResult)return`-`;let t=Object.entries(e.lastResult).filter(([,e])=>Array.isArray(e)?e.length>0:e!=null&&e!==0).map(([e,t])=>`${e}: ${Array.isArray(t)?t.length:String(t)}`);return t.length?t.join(`, `):`no changes`}function O(e,t){if(t<=e)return`due now`;let n=Math.max(0,(t-e)/1e3);return n<60?`in ${Math.ceil(n)}s`:n<3600?`in ${Math.ceil(n/60)}m`:n<86400?`in ${Math.ceil(n/3600)}h`:`in ${Math.ceil(n/86400)}d`}export{x as MaintenanceView};
2
- //# sourceMappingURL=maintenance-CJ6wikpg.js.map
@@ -1,2 +0,0 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{A as t,Fn as n,H as r,R as ee,g as te,gr as i,j as a,nn as ne,q as re,rr as o}from"./lucide-react-NXHPIMsX.js";import{p as ie,t as s}from"./store-D-Frk_EC.js";import{K as c,d as ae,h as l}from"./display-aTnwsqQh.js";import{t as u}from"./badge-BCvp7LK3.js";import{t as d}from"./button-DyHjsHY3.js";import{t as f}from"./input-Rc4oWv4q.js";import{G as oe,W as se,vt as p}from"./index-BdNafiPz.js";import{o as m,r as h,s as g,t as _}from"./card-BoqYxpVW.js";var v=e(i(),1),y=o(),b=[`organization`,`role`,`project`,`task`,`interaction`,`agent`],ce=[`private`,`project`,`org`,`public`],le=[`public`,`normal`,`sensitive`,`secret`],x=[`reported`,`inferred`,`verified`];function S(){return{type:`project`,scope:`default`,title:``,content:``,tags:``,visibility:`project`,sensitivity:`normal`,confidence:`reported`,relevanceScore:`0.7`}}function C(e){return{type:e.type,scope:e.scope,title:e.title,content:e.content,tags:e.tags.join(`, `),visibility:e.visibility,sensitivity:e.sensitivity,confidence:e.confidence,relevanceScore:String(e.relevanceScore)}}function w(e){return e.split(`,`).map(e=>e.trim()).filter(Boolean)}function ue(e){let t={limit:100};e.type&&(t.type=e.type),e.scope.trim()&&(t.scope=e.scope.trim()),e.visibility&&(t.visibility=e.visibility);let n=w(e.tags);if(n.length&&(t.tags=n),e.minRelevance.trim()){let n=Number(e.minRelevance);Number.isFinite(n)&&(t.minRelevance=Math.max(0,Math.min(1,n)))}return t}function T(e){return e===`secret`?`bg-red-500/10 text-red-400 border-red-500/30`:e===`sensitive`?`bg-yellow-500/10 text-yellow-400 border-yellow-500/30`:e===`public`?`bg-blue-500/10 text-blue-400 border-blue-500/30`:`bg-zinc-500/10 text-zinc-400 border-zinc-500/30`}function E(e){return e>=.8?`text-emerald-400`:e>=.5?`text-yellow-400`:`text-zinc-400`}function D(e){return e?Object.entries(e).map(([e,t])=>`${e}=${Array.isArray(t)?t.join(` `):String(t)}`).join(` `):`default`}function de(e){return e.filter(e=>![`system`,`user`,`channel`].includes(e.kind||``))}function O(){let e=ie(),i=s(e=>e.agents),o=s(e=>e.memories),O=s(e=>e.memoryTotal),A=s(e=>e.memoryStats),j=s(e=>e.memoryBrokerInfo),M=s(e=>e.memoryFilters),N=s(e=>e.selectedMemoryId),pe=s(e=>e.memoryLoading),P=s(e=>e.set),me=s(e=>e.fetchMemories),he=s(e=>e.refreshMemory),F=s(e=>e.saveMemory),I=s(e=>e.deleteMemory),L=s(e=>e.injectMemory),R=o.find(e=>e.id===N),[z,B]=(0,v.useState)(`create`),[V,H]=(0,v.useState)(S),[U,W]=(0,v.useState)(``),[G,ge]=(0,v.useState)(`manual`),[K,_e]=(0,v.useState)(`1600`),[q,ve]=(0,v.useState)(`8`),[J,ye]=(0,v.useState)(``),Y=(0,v.useMemo)(()=>de(i),[i]);(0,v.useEffect)(()=>{!U&&Y[0]&&W(Y[0].id)},[Y,U]),(0,v.useEffect)(()=>{R&&z===`edit`&&H(C(R))},[R?.id,z]);let X=(0,v.useMemo)(()=>{let e=M.search.trim().toLowerCase();return e?o.filter(t=>[t.id,t.type,t.scope,t.title,t.content,...t.tags].some(t=>String(t).toLowerCase().includes(e))):o},[o,M.search]);function Z(e){P({memoryFilters:{...M,...e}})}async function be(){let e=Number(V.relevanceScore),t={title:V.title.trim(),content:V.content.trim(),tags:w(V.tags),visibility:V.visibility,sensitivity:V.sensitivity,confidence:V.confidence,relevanceScore:Number.isFinite(e)?Math.max(0,Math.min(1,e)):.7};if(z===`edit`&&R){await F(t,R.id);return}await F({...t,type:V.type,scope:V.scope.trim()}),B(`create`),H(S())}async function Q(e){if(!U)return;let t=await L({agentId:U,memoryIds:e,query:e?.length?void 0:ue(M),reason:G.trim()||`manual`,budget:{maxTokens:Math.max(200,Number(K)||1600),maxMemories:Math.max(1,Number(q)||8),priorityCutoff:3}});t?.command?.id&&ye(t.command.id)}function xe(){B(`create`),H(S())}function Se(){R&&(B(`edit`),H(C(R)))}let Ce=V.title.trim()&&V.content.trim()&&(z===`edit`||V.scope.trim()),$=D(j?.config);return(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(n,{className:`w-5 h-5 text-muted-foreground`}),(0,y.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Memory`}),(0,y.jsx)(u,{variant:`secondary`,children:A?.total??O}),j&&(0,y.jsx)(u,{className:j.external?`bg-blue-500/15 text-blue-400 border-blue-500/30`:`bg-emerald-500/15 text-emerald-400 border-emerald-500/30`,children:j.type})]}),(0,y.jsxs)(d,{size:`sm`,variant:`outline`,className:`gap-1.5`,onClick:()=>he(),children:[(0,y.jsx)(ee,{className:`w-3.5 h-3.5 ${pe?`animate-spin`:``}`}),`Refresh`]})]}),(0,y.jsxs)(`div`,{className:`grid gap-3 xl:grid-cols-[1.2fr_0.8fr]`,children:[(0,y.jsxs)(_,{children:[(0,y.jsx)(m,{className:`py-3 px-4`,children:(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,y.jsxs)(g,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,y.jsx)(ne,{className:`w-4 h-4 text-muted-foreground`}),`Broker`]}),j?.capabilities&&(0,y.jsx)(`div`,{className:`flex flex-wrap gap-1 justify-end`,children:Object.entries(j.capabilities).filter(([,e])=>!!e).map(([e])=>(0,y.jsx)(u,{variant:`outline`,className:`text-[10px] px-1.5 py-0`,children:e},e))})]})}),(0,y.jsxs)(h,{className:`px-4 pb-4 space-y-3`,children:[(0,y.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-5 gap-2`,children:[(0,y.jsx)(k,{label:`total`,value:A?.total??O}),(0,y.jsx)(k,{label:`project`,value:A?.byType?.project??0}),(0,y.jsx)(k,{label:`task`,value:A?.byType?.task??0}),(0,y.jsx)(k,{label:`agent`,value:A?.byType?.agent??0}),(0,y.jsx)(k,{label:`sensitive`,value:(A?.bySensitivity?.sensitive??0)+(A?.bySensitivity?.secret??0)})]}),(0,y.jsx)(`div`,{className:`font-mono text-xs text-muted-foreground truncate`,title:$,children:$})]})]}),(0,y.jsxs)(_,{children:[(0,y.jsx)(m,{className:`py-3 px-4`,children:(0,y.jsx)(g,{className:`text-sm font-medium`,children:`Inject`})}),(0,y.jsxs)(h,{className:`px-4 pb-4 space-y-2`,children:[(0,y.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:[(0,y.jsxs)(`select`,{className:`rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:U,onChange:e=>W(e.target.value),children:[(0,y.jsx)(`option`,{value:``,children:`Agent`}),Y.map(e=>(0,y.jsx)(`option`,{value:e.id,children:ae(e)},e.id))]}),(0,y.jsx)(f,{value:G,onChange:e=>ge(e.target.value),placeholder:`reason`}),(0,y.jsx)(f,{value:K,onChange:e=>_e(e.target.value),inputMode:`numeric`,placeholder:`tokens`}),(0,y.jsx)(f,{value:q,onChange:e=>ve(e.target.value),inputMode:`numeric`,placeholder:`memories`})]}),(0,y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,y.jsxs)(d,{size:`sm`,className:`gap-1.5`,disabled:!U||!R,onClick:()=>R&&Q([R.id]),children:[(0,y.jsx)(t,{className:`w-3.5 h-3.5`}),`Selected`]}),(0,y.jsxs)(d,{size:`sm`,variant:`outline`,className:`gap-1.5`,disabled:!U,onClick:()=>Q(),children:[(0,y.jsx)(a,{className:`w-3.5 h-3.5`}),`Filtered`]}),J&&(0,y.jsx)(u,{variant:`outline`,className:`font-mono text-[10px]`,children:J})]})]})]})]}),(0,y.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1fr)_420px]`,children:[(0,y.jsxs)(`div`,{className:`space-y-3`,children:[(0,y.jsx)(_,{children:(0,y.jsx)(h,{className:`p-3`,children:(0,y.jsxs)(`div`,{className:`grid grid-cols-2 lg:grid-cols-6 gap-2`,children:[(0,y.jsx)(f,{className:`lg:col-span-2`,value:M.search,onChange:e=>Z({search:e.target.value}),placeholder:`Search visible memories`}),(0,y.jsxs)(`select`,{className:`rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:M.type,onChange:e=>Z({type:e.target.value}),children:[(0,y.jsx)(`option`,{value:``,children:`All types`}),b.map(e=>(0,y.jsx)(`option`,{value:e,children:e},e))]}),(0,y.jsx)(f,{value:M.scope,onChange:e=>Z({scope:e.target.value}),placeholder:`scope`}),(0,y.jsx)(f,{value:M.tags,onChange:e=>Z({tags:e.target.value}),placeholder:`tags`}),(0,y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,y.jsx)(f,{value:M.minRelevance,onChange:e=>Z({minRelevance:e.target.value}),placeholder:`score`}),(0,y.jsx)(d,{size:`sm`,variant:`outline`,className:`h-8 px-2`,onClick:()=>me(),children:(0,y.jsx)(a,{className:`w-4 h-4`})})]})]})})}),(0,y.jsx)(oe,{className:`h-[calc(100dvh-24rem)] min-h-[360px]`,children:(0,y.jsxs)(`div`,{className:`space-y-2 pr-2`,children:[X.length===0&&(0,y.jsx)(`div`,{className:`text-center text-sm text-muted-foreground py-16`,children:`No memories`}),X.map(t=>(0,y.jsx)(fe,{memory:t,selected:t.id===N,now:e,onSelect:()=>P({selectedMemoryId:t.id})},t.id))]})})]}),(0,y.jsxs)(_,{children:[(0,y.jsx)(m,{className:`py-3 px-4`,children:(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,y.jsx)(g,{className:`text-sm font-medium`,children:z===`edit`?`Edit Memory`:`New Memory`}),(0,y.jsxs)(`div`,{className:`flex gap-1`,children:[(0,y.jsx)(d,{size:`sm`,variant:`ghost`,className:`h-7 px-2`,onClick:xe,title:`New memory`,children:(0,y.jsx)(r,{className:`w-3.5 h-3.5`})}),(0,y.jsx)(d,{size:`sm`,variant:`ghost`,className:`h-7 px-2`,onClick:Se,disabled:!R,title:`Edit selected`,children:(0,y.jsx)(re,{className:`w-3.5 h-3.5`})}),(0,y.jsx)(d,{size:`sm`,variant:`ghost`,className:`h-7 px-2 text-red-400 hover:text-red-300`,disabled:!R,onClick:()=>R&&I(R.id),title:`Delete selected`,children:(0,y.jsx)(te,{className:`w-3.5 h-3.5`})})]})]})}),(0,y.jsxs)(h,{className:`px-4 pb-4 space-y-3`,children:[R&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,y.jsx)(u,{variant:`secondary`,children:R.type}),(0,y.jsx)(u,{variant:`outline`,children:R.scope}),(0,y.jsx)(u,{className:T(R.sensitivity),children:R.sensitivity}),(0,y.jsx)(u,{variant:`outline`,className:E(R.relevanceScore),children:R.relevanceScore.toFixed(2)})]}),(0,y.jsxs)(`div`,{className:`text-xs text-muted-foreground`,title:l(R.updatedAt),children:[`updated `,c(e,R.updatedAt)]}),(0,y.jsx)(`p`,{className:`text-sm font-medium`,children:R.title}),(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground whitespace-pre-wrap max-h-24 overflow-auto`,children:R.content})]}),(0,y.jsx)(p,{})]}),(0,y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,y.jsx)(`select`,{className:`rounded-md border border-input bg-background px-2 py-1.5 text-sm`,disabled:z===`edit`,value:V.type,onChange:e=>H({...V,type:e.target.value}),children:b.map(e=>(0,y.jsx)(`option`,{value:e,children:e},e))}),(0,y.jsx)(f,{disabled:z===`edit`,value:V.scope,onChange:e=>H({...V,scope:e.target.value}),placeholder:`scope`}),(0,y.jsx)(f,{className:`col-span-2`,value:V.title,onChange:e=>H({...V,title:e.target.value}),placeholder:`title`}),(0,y.jsx)(se,{className:`col-span-2 min-h-32`,value:V.content,onChange:e=>H({...V,content:e.target.value}),placeholder:`content`}),(0,y.jsx)(f,{className:`col-span-2`,value:V.tags,onChange:e=>H({...V,tags:e.target.value}),placeholder:`tags`}),(0,y.jsx)(`select`,{className:`rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:V.visibility,onChange:e=>H({...V,visibility:e.target.value}),children:ce.map(e=>(0,y.jsx)(`option`,{value:e,children:e},e))}),(0,y.jsx)(`select`,{className:`rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:V.sensitivity,onChange:e=>H({...V,sensitivity:e.target.value}),children:le.map(e=>(0,y.jsx)(`option`,{value:e,children:e},e))}),(0,y.jsx)(`select`,{className:`rounded-md border border-input bg-background px-2 py-1.5 text-sm`,value:V.confidence,onChange:e=>H({...V,confidence:e.target.value}),children:x.map(e=>(0,y.jsx)(`option`,{value:e,children:e},e))}),(0,y.jsx)(f,{value:V.relevanceScore,onChange:e=>H({...V,relevanceScore:e.target.value}),inputMode:`decimal`,placeholder:`score`})]}),(0,y.jsx)(d,{size:`sm`,className:`w-full`,disabled:!Ce,onClick:be,children:z===`edit`?`Save memory`:`Create memory`})]})]})]})]})}function k({label:e,value:t}){return(0,y.jsxs)(`div`,{className:`rounded-md border border-border bg-muted/20 px-3 py-2`,children:[(0,y.jsx)(`div`,{className:`text-lg font-semibold tabular-nums`,children:t}),(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e})]})}function fe({memory:e,selected:t,now:n,onSelect:r}){return(0,y.jsx)(`button`,{onClick:r,className:`w-full text-left rounded-md border p-3 transition-colors ${t?`border-primary bg-primary/5`:`border-border bg-card hover:border-zinc-600`}`,children:(0,y.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[(0,y.jsx)(u,{variant:`secondary`,className:`text-[10px]`,children:e.type}),(0,y.jsx)(u,{variant:`outline`,className:`text-[10px] font-mono`,children:e.scope}),(0,y.jsx)(u,{className:`text-[10px] ${T(e.sensitivity)}`,children:e.sensitivity})]}),(0,y.jsx)(`div`,{className:`font-medium text-sm mt-2 truncate`,children:e.title}),(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground line-clamp-2 mt-1`,children:e.content}),e.tags.length>0&&(0,y.jsx)(`div`,{className:`flex gap-1 flex-wrap mt-2`,children:e.tags.slice(0,8).map(e=>(0,y.jsxs)(u,{variant:`outline`,className:`text-[10px] text-zinc-400`,children:[`#`,e]},e))})]}),(0,y.jsxs)(`div`,{className:`text-right shrink-0 space-y-1`,children:[(0,y.jsx)(`div`,{className:`text-sm font-semibold tabular-nums ${E(e.relevanceScore)}`,children:e.relevanceScore.toFixed(2)}),(0,y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,title:l(e.updatedAt),children:c(n,e.updatedAt)}),e.accessCount>0&&(0,y.jsxs)(`div`,{className:`text-[10px] text-muted-foreground`,children:[e.accessCount,` hits`]})]})]})})}export{O as MemoryView};
2
- //# sourceMappingURL=memory-BE9IwCdC.js.map
@@ -1,2 +0,0 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{Et as t,Rn as n,_t as r,ct as i,er as a,gr as o,gt as s,h as c,rr as l,rt as u,u as d}from"./lucide-react-NXHPIMsX.js";import{p as f,t as p}from"./store-D-Frk_EC.js";import{K as m,M as h,X as g,d as _,f as v,g as y,lt as b,q as x}from"./display-aTnwsqQh.js";import{t as S}from"./badge-BCvp7LK3.js";import{t as C}from"./agent-type-icon-BmBR-9CH.js";import{Ct as w,G as T,St as E,Tt as D,ct as O,vt as k}from"./index-BdNafiPz.js";import{o as A,r as j,s as M,t as N}from"./card-BoqYxpVW.js";var P=e(o(),1),F=l();function I(){let e=p(e=>e.stats),o=p(e=>e.agents),l=p(e=>e.messages),I=p(e=>e.health),L=f(),R=p(e=>e.agentsById),z=p(e=>e.switchView),B=p(e=>e.runHealthAction),V=p(e=>e.managedPolicies),H=p(e=>e.showOffline),U=D(),W=w(),G=E(),K=(0,P.useMemo)(()=>{let e=g(o,!1,V);return H||(e=e.filter(e=>e.status!==`offline`)),[...e].sort((e,t)=>(b[e.status]??9)-(b[t.status]??9)||x(t.lastSeen)-x(e.lastSeen))},[o,H,V]),q=K.slice(0,20),J=[...l].sort((e,t)=>t.id-e.id).slice(0,15),Y=I&&I.status!==`ok`?y(I.checks||[]):[];function X(e){z(e)}return(0,F.jsxs)(`div`,{className:`space-y-6`,children:[(0,F.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:[(0,F.jsxs)(N,{className:`cursor-pointer hover:border-zinc-600 transition-colors`,onClick:()=>X(`agents`),children:[(0,F.jsx)(A,{className:`pb-1 pt-4 px-4`,children:(0,F.jsxs)(M,{className:`text-xs font-medium text-muted-foreground flex items-center gap-1.5`,children:[(0,F.jsx)(d,{className:`w-3.5 h-3.5`}),`Agents`]})}),(0,F.jsxs)(j,{className:`px-4 pb-4`,children:[(0,F.jsx)(`div`,{className:`text-2xl font-bold`,children:K.length}),(0,F.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:[U,` online`]})]})]}),(0,F.jsxs)(N,{className:`cursor-pointer hover:border-zinc-600 transition-colors`,onClick:()=>X(`agents`),children:[(0,F.jsx)(A,{className:`pb-1 pt-4 px-4`,children:(0,F.jsxs)(M,{className:`text-xs font-medium text-muted-foreground flex items-center gap-1.5`,children:[(0,F.jsx)(a,{className:`w-3.5 h-3.5`}),`Busy`]})}),(0,F.jsxs)(j,{className:`px-4 pb-4`,children:[(0,F.jsx)(`div`,{className:`text-2xl font-bold`,children:W}),(0,F.jsx)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:`in a turn now`})]})]}),(0,F.jsxs)(N,{className:`cursor-pointer hover:border-zinc-600 transition-colors`,onClick:()=>X(`messages`),children:[(0,F.jsx)(A,{className:`pb-1 pt-4 px-4`,children:(0,F.jsxs)(M,{className:`text-xs font-medium text-muted-foreground flex items-center gap-1.5`,children:[(0,F.jsx)(u,{className:`w-3.5 h-3.5`}),`Messages 24h`]})}),(0,F.jsxs)(j,{className:`px-4 pb-4`,children:[(0,F.jsx)(`div`,{className:`text-2xl font-bold`,children:e.messagesLast24h??`—`}),(0,F.jsx)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:`last 24 hours`})]})]}),(0,F.jsxs)(N,{className:`cursor-pointer hover:border-zinc-600 transition-colors`,onClick:()=>X(`messages`),children:[(0,F.jsx)(A,{className:`pb-1 pt-4 px-4`,children:(0,F.jsxs)(M,{className:`text-xs font-medium text-muted-foreground flex items-center gap-1.5`,children:[(0,F.jsx)(i,{className:`w-3.5 h-3.5`}),`Total Messages`]})}),(0,F.jsxs)(j,{className:`px-4 pb-4`,children:[(0,F.jsx)(`div`,{className:`text-2xl font-bold`,children:e.messages??`—`}),(0,F.jsx)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:`all time`})]})]})]}),Y.length>0&&(0,F.jsxs)(N,{className:`border-yellow-500/40 bg-yellow-500/5`,children:[(0,F.jsx)(A,{className:`pb-2 pt-4 px-4`,children:(0,F.jsxs)(M,{className:`text-sm font-medium text-yellow-400 flex items-center gap-2`,children:[(0,F.jsx)(c,{className:`w-4 h-4`}),`Health Alerts (`,Y.length,`)`]})}),(0,F.jsx)(j,{className:`px-4 pb-4 space-y-2`,children:Y.map(e=>(0,F.jsxs)(`div`,{className:`text-sm space-y-1`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(S,{variant:`outline`,className:e.status===`error`?`border-red-500/40 text-red-400`:`border-yellow-500/40 text-yellow-400`,children:e.status}),(0,F.jsx)(`span`,{className:`font-medium`,children:e.name})]}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.detail}),e.subjects.length>0&&(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.subjects.map(e=>(0,F.jsxs)(S,{variant:`secondary`,className:`max-w-full truncate text-[11px]`,title:[e.id,e.status,e.detail].filter(Boolean).join(` · `),children:[e.label||e.id,e.status?` · ${e.status}`:``,e.detail?` · ${e.detail}`:``]},e.id))}),e.actions.length>0&&(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-0.5`,children:e.actions.slice(0,3).map(e=>(0,F.jsx)(`button`,{onClick:()=>B(e),className:`text-xs text-blue-400 hover:text-blue-300 underline underline-offset-2`,children:e.label},e.label))})]},e.name))})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-4`,children:[(0,F.jsx)(N,{className:`cursor-pointer hover:border-zinc-600 transition-colors ${G.unreadInbox>0?`border-red-500/40`:``}`,onClick:()=>X(`chat`),children:(0,F.jsxs)(j,{className:`p-4 flex items-center gap-3`,children:[(0,F.jsx)(`div`,{className:`p-2 rounded-lg ${G.unreadInbox>0?`bg-red-500/15`:`bg-zinc-800`}`,children:(0,F.jsx)(t,{className:`w-4 h-4 ${G.unreadInbox>0?`text-red-400`:`text-zinc-400`}`})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`text-lg font-bold`,children:G.unreadInbox}),(0,F.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Unread`})]})]})}),(0,F.jsx)(N,{className:`cursor-pointer hover:border-zinc-600 transition-colors ${G.pendingPairInvites>0?`border-yellow-500/40`:``}`,onClick:()=>X(`pairs`),children:(0,F.jsxs)(j,{className:`p-4 flex items-center gap-3`,children:[(0,F.jsx)(`div`,{className:`p-2 rounded-lg ${G.pendingPairInvites>0?`bg-yellow-500/15`:`bg-zinc-800`}`,children:(0,F.jsx)(r,{className:`w-4 h-4 ${G.pendingPairInvites>0?`text-yellow-400`:`text-zinc-400`}`})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`text-lg font-bold`,children:G.pendingPairInvites}),(0,F.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Pair invites`})]})]})}),(0,F.jsx)(N,{className:`cursor-pointer hover:border-zinc-600 transition-colors ${G.claimableTasks>0?`border-orange-500/40`:``}`,onClick:()=>X(`work`),children:(0,F.jsxs)(j,{className:`p-4 flex items-center gap-3`,children:[(0,F.jsx)(`div`,{className:`p-2 rounded-lg ${G.claimableTasks>0?`bg-orange-500/15`:`bg-zinc-800`}`,children:(0,F.jsx)(s,{className:`w-4 h-4 ${G.claimableTasks>0?`text-orange-400`:`text-zinc-400`}`})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`text-lg font-bold`,children:G.claimableTasks}),(0,F.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Claimable waiting`})]})]})})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,F.jsxs)(N,{children:[(0,F.jsx)(A,{className:`pb-2 pt-4 px-4`,children:(0,F.jsxs)(M,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,F.jsx)(n,{className:`w-4 h-4 text-muted-foreground`}),`Agents`,(0,F.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground font-normal`,children:q.length})]})}),(0,F.jsx)(j,{className:`px-0 pb-0`,children:(0,F.jsx)(T,{className:`h-[340px]`,children:q.length===0?(0,F.jsx)(`div`,{className:`px-4 pb-4 text-sm text-muted-foreground`,children:`No agents registered.`}):(0,F.jsx)(`div`,{className:`space-y-0`,children:q.map((e,t)=>(0,F.jsxs)(`div`,{children:[t>0&&(0,F.jsx)(k,{}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2.5 px-4 py-2.5 hover:bg-zinc-800/50 transition-colors cursor-pointer`,onClick:()=>p.getState().openAgentDetail(e),children:[(0,F.jsx)(O,{agent:e,now:L}),(0,F.jsx)(C,{agent:e}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsx)(`div`,{className:`text-sm font-medium truncate`,children:_(e)}),e.tags.length>0&&(0,F.jsx)(`div`,{className:`flex gap-1 mt-0.5 flex-wrap`,children:e.tags.slice(0,2).map(e=>(0,F.jsx)(S,{variant:`outline`,className:`text-[9px] px-1 py-0 h-4`,children:e},e))})]}),(0,F.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:m(L,e.lastSeen)})]})]},e.id))})})})]}),(0,F.jsxs)(N,{children:[(0,F.jsx)(A,{className:`pb-2 pt-4 px-4`,children:(0,F.jsxs)(M,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,F.jsx)(a,{className:`w-4 h-4 text-muted-foreground`}),`Recent Activity`,(0,F.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground font-normal`,children:J.length})]})}),(0,F.jsx)(j,{className:`px-0 pb-0`,children:(0,F.jsx)(T,{className:`h-[340px]`,children:J.length===0?(0,F.jsx)(`div`,{className:`px-4 pb-4 text-sm text-muted-foreground`,children:`No recent messages.`}):(0,F.jsx)(`div`,{className:`space-y-0`,children:J.map((e,t)=>(0,F.jsxs)(`div`,{children:[t>0&&(0,F.jsx)(k,{}),(0,F.jsxs)(`div`,{className:`px-4 py-2.5 hover:bg-zinc-800/50 transition-colors`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground mb-0.5`,children:[(0,F.jsx)(`span`,{className:`text-foreground font-medium truncate max-w-[100px]`,children:v(e.from,R)}),(0,F.jsx)(`span`,{children:`→`}),(0,F.jsx)(`span`,{className:`truncate max-w-[100px]`,children:v(e.to,R)}),(0,F.jsxs)(`span`,{className:`ml-auto shrink-0 tabular-nums`,children:[(0,F.jsxs)(`span`,{className:`opacity-40 mr-1`,children:[`#`,e.id]}),m(L,e.createdAt)]})]}),(0,F.jsx)(`div`,{className:`text-xs text-foreground line-clamp-2 leading-snug`,children:h(e)})]})]},e.id))})})})]})]})]})}export{I as OverviewView};
2
- //# sourceMappingURL=overview-q3O9K9VK.js.map
@@ -1,2 +0,0 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{F as t,In as n,M as r,R as ee,Wt as i,gr as a,ir as o,rr as s,tr as c,xn as l}from"./lucide-react-NXHPIMsX.js";import{f as u}from"./types-BqeSkWrv.js";import{K as d}from"./display-aTnwsqQh.js";import{t as f}from"./badge-BCvp7LK3.js";import{t as p}from"./button-DyHjsHY3.js";import{W as m}from"./index-BdNafiPz.js";import{a as h,i as g,o as _,r as v,s as y,t as b}from"./card-BoqYxpVW.js";var x=e(a(),1),S=s(),C=`all`;function w(e){return e.split(/[^a-zA-Z0-9]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function T(e){return Array.isArray(e)?[...e].sort((e,t)=>{let n=e.category.localeCompare(t.category);if(n!==0)return n;let r=e.title.localeCompare(t.title);return r===0?e.slug.localeCompare(t.slug):r}):[]}function E(){let[e,a]=(0,x.useState)([]),[s,E]=(0,x.useState)(!0),[D,O]=(0,x.useState)(``),[k,A]=(0,x.useState)(``),[j,M]=(0,x.useState)(``),[N,P]=(0,x.useState)(C),[F,I]=(0,x.useState)(``),[L,R]=(0,x.useState)({}),[z,B]=(0,x.useState)(``),[V,H]=(0,x.useState)(()=>Date.now());async function U(){E(!0),O(``);try{a(T((await o(`GET`,`/settings/prompts`)).templates)),H(Date.now())}catch(e){O(u(e))}finally{E(!1)}}(0,x.useEffect)(()=>{U()},[]);let W=(0,x.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.category,(t.get(n.category)??0)+1);return[...t.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({key:e,count:t,label:w(e)}))},[e]),G=N===C||W.some(e=>e.key===N)?N:C,K=(0,x.useMemo)(()=>G===C?e:e.filter(e=>e.category===G),[G,e]),q=K.some(e=>e.slug===F)?F:K[0]?.slug??``,J=K.find(e=>e.slug===q)??null,Y=J?L[J.slug]??J.template:``,X=J?Y!==J.template:!1,Z=e.filter(e=>e.template!==e.defaultTemplate).length,Q=J?z===J.slug:!1;function te(e){I(e),A(``),M(``)}function $(e){a(t=>T(t.map(t=>t.slug===e.slug?e:t))),R(t=>({...t,[e.slug]:e.template})),H(Date.now())}async function ne(){if(!(!J||!X)){B(J.slug),A(``),M(``);try{let e=await o(`PUT`,`/settings/prompts/${encodeURIComponent(J.slug)}`,{template:Y});$(e),M(`Saved ${e.title}.`)}catch(e){A(u(e))}finally{B(``)}}}async function re(){if(!(!J||J.template===J.defaultTemplate)){B(J.slug),A(``),M(``);try{let e=await o(`POST`,`/settings/prompts/${encodeURIComponent(J.slug)}/reset`);$(e),M(`Reset ${e.title} to the built-in default.`)}catch(e){A(u(e))}finally{B(``)}}}function ie(){J&&(R(e=>({...e,[J.slug]:J.template})),A(``),M(`Unsaved edits discarded.`))}return(0,S.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Prompts`}),(0,S.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`View and edit the externalized prompt templates used across Relay lifecycle, routing, workspace, and automation flows.`})]}),(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,S.jsxs)(f,{variant:`outline`,className:`gap-1`,children:[(0,S.jsx)(i,{className:`size-3`}),e.length,` template`,e.length===1?``:`s`]}),(0,S.jsxs)(f,{variant:`outline`,className:c(`gap-1`,Z>0&&`border-amber-500/40 bg-amber-500/10 text-amber-300`),children:[Z,` modified`]}),(0,S.jsxs)(p,{variant:`outline`,size:`sm`,onClick:()=>void U(),disabled:s,children:[(0,S.jsx)(ee,{className:c(`size-4`,s&&`animate-spin`)}),`Refresh`]})]})]}),D&&(0,S.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:[(0,S.jsx)(l,{className:`mt-0.5 size-4`}),(0,S.jsx)(`span`,{children:D})]}),s&&e.length===0?(0,S.jsx)(b,{size:`sm`,children:(0,S.jsx)(v,{className:`text-sm text-muted-foreground`,children:`Loading prompt templates…`})}):e.length===0?(0,S.jsx)(b,{children:(0,S.jsx)(v,{className:`py-10 text-center text-sm text-muted-foreground`,children:`No prompt templates are available yet.`})}):(0,S.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[220px_minmax(0,0.9fr)_minmax(0,1.1fr)]`,children:[(0,S.jsxs)(`nav`,{className:`space-y-1 xl:sticky xl:top-4 xl:self-start`,children:[(0,S.jsxs)(`button`,{type:`button`,className:c(`w-full rounded-md border px-3 py-2 text-left text-sm transition-colors`,G===C?`border-primary/50 bg-primary/10 text-foreground`:`border-transparent hover:border-border hover:bg-accent`),onClick:()=>P(C),children:[(0,S.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`span`,{className:`font-medium`,children:`All`}),(0,S.jsx)(f,{variant:`outline`,className:`ml-auto h-4 px-1 text-[10px]`,children:e.length})]}),(0,S.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:`Every externalized prompt template`})]}),W.map(e=>(0,S.jsxs)(`button`,{type:`button`,className:c(`w-full rounded-md border px-3 py-2 text-left text-sm transition-colors`,G===e.key?`border-primary/50 bg-primary/10 text-foreground`:`border-transparent hover:border-border hover:bg-accent`),onClick:()=>P(e.key),children:[(0,S.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`span`,{className:`font-medium`,children:e.label}),(0,S.jsx)(f,{variant:`outline`,className:`ml-auto h-4 px-1 text-[10px]`,children:e.count})]}),(0,S.jsx)(`span`,{className:`block truncate text-xs font-mono text-muted-foreground`,children:e.key})]},e.key))]}),(0,S.jsxs)(`div`,{className:`min-w-0 space-y-3`,children:[(0,S.jsx)(`div`,{className:`flex items-center justify-between gap-2 px-1`,children:(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h2`,{className:`text-sm font-semibold`,children:G===C?`All templates`:`${w(G)} templates`}),(0,S.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[K.length,` template`,K.length===1?``:`s`,` in this view`]})]})}),K.map(e=>{let t=e.slug===q,n=e.template!==e.defaultTemplate;return(0,S.jsx)(`button`,{type:`button`,className:c(`w-full rounded-xl border p-4 text-left transition-colors`,t?`border-primary/50 bg-primary/10 ring-1 ring-primary/20`:`border-border bg-card hover:border-primary/30 hover:bg-accent`),onClick:()=>te(e.slug),children:(0,S.jsx)(`div`,{className:`flex flex-wrap items-start gap-2`,children:(0,S.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,S.jsx)(`span`,{className:`font-medium text-foreground`,children:e.title}),n&&(0,S.jsx)(f,{className:`bg-amber-500/15 text-amber-300 hover:bg-amber-500/15`,children:`Modified`}),(0,S.jsx)(f,{variant:`outline`,className:`text-[10px]`,children:w(e.category)})]}),(0,S.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-muted-foreground`,children:e.slug}),e.description&&(0,S.jsx)(`p`,{className:`mt-2 line-clamp-2 text-sm text-muted-foreground`,children:e.description}),(0,S.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,S.jsxs)(`span`,{children:[e.variables.length,` variable`,e.variables.length===1?``:`s`]}),(0,S.jsxs)(`span`,{children:[`Updated `,d(V,e.updatedAt)]})]})]})})},e.slug)})]}),(0,S.jsx)(`div`,{className:`min-w-0`,children:J?(0,S.jsxs)(b,{children:[(0,S.jsxs)(_,{className:`border-b border-border`,children:[(0,S.jsxs)(y,{className:`flex flex-wrap items-center gap-2`,children:[(0,S.jsx)(`span`,{children:J.title}),J.template!==J.defaultTemplate&&(0,S.jsx)(f,{className:`bg-amber-500/15 text-amber-300 hover:bg-amber-500/15`,children:`Customized`}),X&&(0,S.jsx)(f,{variant:`outline`,children:`Unsaved`})]}),(0,S.jsxs)(g,{className:`space-y-1`,children:[(0,S.jsx)(`div`,{className:`font-mono text-[11px]`,children:J.slug}),J.description&&(0,S.jsx)(`div`,{children:J.description})]})]}),(0,S.jsxs)(v,{className:`space-y-4 pt-4`,children:[k&&(0,S.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 p-2 text-xs text-destructive`,children:[(0,S.jsx)(l,{className:`mt-0.5 size-3.5`}),(0,S.jsx)(`span`,{children:k})]}),j&&(0,S.jsx)(`div`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-2 text-xs text-emerald-300`,children:j}),(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,S.jsx)(n,{className:`size-3.5`}),`Available variables`]}),J.variables.length>0?(0,S.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:J.variables.map(e=>(0,S.jsx)(f,{variant:`secondary`,className:`font-mono text-[11px]`,children:`{{${e}}}`},e))}):(0,S.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`This template has no placeholder variables.`})]}),J.template!==J.defaultTemplate&&(0,S.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-200`,children:`This template differs from the built-in default. Reset will restore the original text.`}),(0,S.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,S.jsx)(`label`,{htmlFor:`prompt-template-editor`,className:`text-xs font-medium text-muted-foreground`,children:`Template text`}),(0,S.jsx)(m,{id:`prompt-template-editor`,value:Y,onChange:e=>{let t=e.target.value;R(e=>({...e,[J.slug]:t})),k&&A(``),j&&M(``)},rows:18,spellCheck:!1,className:`min-h-[360px] resize-y font-mono text-xs leading-5`})]})]}),(0,S.jsxs)(h,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,S.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:X?`Editing local changes.`:`Updated ${d(V,J.updatedAt)}.`}),(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[J.template!==J.defaultTemplate&&(0,S.jsxs)(p,{variant:`outline`,size:`sm`,onClick:()=>void re(),disabled:Q,children:[(0,S.jsx)(t,{className:`size-4`}),`Reset to default`]}),(0,S.jsx)(p,{variant:`outline`,size:`sm`,onClick:ie,disabled:!X||Q,children:`Cancel`}),(0,S.jsxs)(p,{size:`sm`,onClick:()=>void ne(),disabled:!X||Q,children:[(0,S.jsx)(r,{className:`size-4`}),`Save`]})]})]})]}):(0,S.jsx)(b,{size:`sm`,children:(0,S.jsx)(v,{className:`text-sm text-muted-foreground`,children:`Select a prompt template to edit it.`})})})]})]})}export{E as PromptSettingsView};
2
- //# sourceMappingURL=prompt-settings-Bdz_xCgD.js.map
@@ -1,6 +0,0 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{$ as t,An as n,C as r,Cn as i,H as a,K as o,M as s,N as c,Pn as l,Pt as u,R as d,Tn as f,Wn as p,Xt as m,Yn as h,Yt as g,cr as _,en as v,g as y,gr as b,ir as x,k as S,l as C,m as w,mt as T,rr as E,tr as D,xn as O,yn as ee}from"./lucide-react-NXHPIMsX.js";import{_ as te,d as ne,h as k,t as A}from"./store-D-Frk_EC.js";import{_ as j,h as re,p as ie,u as ae}from"./types-BqeSkWrv.js";import{t as oe}from"./themes-DjSwmAZN.js";import{a as M,i as N,n as P,r as F,t as I}from"./select-BX_lW49D.js";import{t as L}from"./badge-BCvp7LK3.js";import{t as R}from"./button-DyHjsHY3.js";import{t as z}from"./input-Rc4oWv4q.js";import{W as se,yt as B}from"./index-BdNafiPz.js";import{i as V,n as ce,o as H,r as U,s as W,t as G}from"./card-BoqYxpVW.js";import{t as le}from"./user-avatar-qbo-B3dQ.js";var K=e(b(),1);function q(e){return`${e.namespace}/${e.key}`}function ue(e){return`/settings/${encodeURIComponent(e.namespace)}/${encodeURIComponent(e.key)}`}function de(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`settings`}function fe(e){let t=new Map;for(let n of e.filter(e=>e.readable)){let e=n.display?.group?.trim()||n.namespace;t.set(e,[...t.get(e)??[],n])}return[...t.entries()].map(([e,t])=>({group:e,slug:de(e),settings:t.sort(pe)})).sort((e,t)=>me(e.settings)-me(t.settings)||e.group.localeCompare(t.group))}function pe(e,t){return(e.display?.order??2**53-1)-(t.display?.order??2**53-1)||e.display?.label?.localeCompare(t.display?.label??``)||q(e).localeCompare(q(t))}function me(e){return Math.min(...e.map(e=>e.display?.order??2**53-1))}function he(e){return Array.isArray(e.type)?e.type.find(e=>e!==`null`):e.type}function ge(e,t,n){if(!t.length)return n;let[r,...i]=t;if(r===void 0)return n;if(typeof r==`number`){let t=Array.isArray(e)?[...e]:[];return t[r]=ge(t[r],i,n),t}let a=ie(e)?{...e}:{},o=ge(a[r],i,n);return o===void 0?delete a[r]:a[r]=o,a}function _e(e){if(e.default!==void 0)return e.default;if(e.const!==void 0)return e.const;if(e.enum?.length)return e.enum[0];switch(he(e)){case`boolean`:return!1;case`integer`:case`number`:return 0;case`array`:return[];case`object`:return{};case`string`:return``;default:return}}function ve(e){return e.split(/\r?\n|,/).map(e=>e.trim()).filter(Boolean)}function ye(e){return Array.isArray(e)?e.map(e=>String(e)).join(`
2
- `):``}function be(e){return ie(e)?Object.entries(e).map(([e,t])=>`${e}=${String(t??``)}`).join(`
3
- `):``}function xe(e){return Object.fromEntries(e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map(e=>{let t=e.indexOf(`=`);return t>=0?[e.slice(0,t).trim(),e.slice(t+1)]:[e,``]}))}var J=E(),Se=`__unset__`;function Ce(e){return e===`server-runtime`?`Server runtime`:e===`bootstrap`?`Bootstrap`:`Browser`}function we(e){return e===`server-runtime`?`Stored by Relay and mutable while the server is running.`:e===`bootstrap`?`Read from startup configuration; restart or host config changes are required.`:`Stored only in this browser profile.`}function Te(e){return e===`browser`?(0,J.jsx)(t,{className:`size-3.5`}):(0,J.jsx)(S,{className:`size-3.5`})}function Ee(e){return e.details??[]}function De({group:e,settings:t,onSaved:n}){let r=[...new Set(t.map(e=>e.tier))];return(0,J.jsxs)(`section`,{className:`space-y-3`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,J.jsx)(`h2`,{className:`text-base font-semibold`,children:e}),(0,J.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map(e=>(0,J.jsxs)(L,{variant:`outline`,className:`gap-1`,title:we(e),children:[Te(e),Ce(e)]},e))})]}),t.length===0?(0,J.jsx)(G,{size:`sm`,children:(0,J.jsx)(U,{className:`text-sm text-muted-foreground`,children:`No settings in this group.`})}):(0,J.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>(0,J.jsx)(Oe,{setting:e,onSaved:n},q(e)))})]})}function Oe({setting:e,onSaved:t}){let[n,r]=(0,K.useState)(()=>e.value??e.defaults??_e(e.schema)),[i,a]=(0,K.useState)(!1),[o,c]=(0,K.useState)(``),[l,u]=(0,K.useState)([]),d=e.writable&&e.tier===`server-runtime`;function f(e,t){r(n=>ge(n,e,t)),u([]),c(``)}async function p(){if(d){a(!0),u([]),c(``);try{let i=await x(`PUT`,ue(e),{value:n,updatedBy:`dashboard`});r(i.value),t(i),c(`Saved`)}catch(e){let t=Ee(e);u(t.length?t:[e.message])}finally{a(!1)}}}return(0,J.jsxs)(G,{size:`sm`,children:[(0,J.jsxs)(H,{children:[(0,J.jsxs)(W,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[e.display.label,(0,J.jsxs)(L,{variant:`outline`,className:`gap-1`,title:we(e.tier),children:[Te(e.tier),Ce(e.tier)]}),!e.writable&&(0,J.jsx)(L,{variant:`secondary`,children:`Read only`})]}),e.display.description&&(0,J.jsx)(V,{children:e.display.description}),(0,J.jsx)(ce,{children:(0,J.jsxs)(R,{size:`sm`,onClick:p,disabled:!d||i,children:[(0,J.jsx)(s,{className:`size-4`}),i?`Saving`:`Save`]})})]}),(0,J.jsxs)(U,{className:`space-y-3`,children:[(0,J.jsx)(ke,{schema:e.schema,value:n,path:[],label:e.display.label,required:!0,disabled:!d||i,onChange:f}),(0,J.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 text-[11px] text-muted-foreground`,children:[(0,J.jsxs)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono`,children:[e.namespace,`/`,e.key]}),(0,J.jsxs)(`span`,{children:[`read `,(0,J.jsx)(`span`,{className:`text-foreground/70`,children:e.scope.read})]}),(0,J.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,J.jsxs)(`span`,{children:[`write `,(0,J.jsx)(`span`,{className:`text-foreground/70`,children:e.scope.write})]})]}),l.length>0&&(0,J.jsxs)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:[(0,J.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 font-medium`,children:[(0,J.jsx)(O,{className:`size-4`}),`Save failed`]}),(0,J.jsx)(`ul`,{className:`list-disc space-y-1 pl-5`,children:l.map(e=>(0,J.jsx)(`li`,{children:e},e))})]}),o&&(0,J.jsxs)(`p`,{className:`flex items-center gap-1 text-sm text-emerald-500`,children:[(0,J.jsx)(ee,{className:`size-4`}),o]})]})]})}function ke(e){let{schema:t,value:n,path:r,label:i,required:a,disabled:o,onChange:s}=e,c=he(t);if(t.enum?.length){let e=n==null||n===``?Se:String(n);return(0,J.jsx)(Y,{label:i,description:t.description,children:(0,J.jsxs)(I,{value:e,onValueChange:e=>s(r,e===`__unset__`?void 0:e),disabled:o,children:[(0,J.jsx)(N,{children:(0,J.jsx)(M,{})}),(0,J.jsxs)(P,{children:[!a&&(0,J.jsx)(F,{value:`__unset__`,children:`Not set`}),t.enum.map(e=>(0,J.jsx)(F,{value:String(e),children:String(e)},String(e)))]})]})})}if(c===`boolean`)return(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border bg-muted/20 p-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm font-medium`,children:i}),t.description&&(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t.description})]}),(0,J.jsx)(B,{checked:!!n,onCheckedChange:e=>s(r,e),disabled:o})]});if(c===`integer`||c===`number`)return(0,J.jsx)(Y,{label:i,description:t.description,children:(0,J.jsx)(z,{type:`number`,min:typeof t.minimum==`number`?t.minimum:void 0,max:typeof t.maximum==`number`?t.maximum:void 0,step:c===`integer`?1:`any`,value:typeof n==`number`?n:``,disabled:o,onChange:e=>s(r,e.target.value===``&&!a?void 0:Number(e.target.value))})});if(c===`array`)return(0,J.jsx)(Y,{label:i,description:t.description??`One item per line.`,children:(0,J.jsx)(se,{rows:Math.min(8,Math.max(3,Array.isArray(n)?n.length+1:3)),value:ye(n),disabled:o,onChange:e=>s(r,ve(e.target.value))})});if(c===`object`){let e=t.properties??{},a=new Set(t.required??[]);return Object.keys(e).length===0&&t.additionalProperties?(0,J.jsx)(Y,{label:i,description:t.description??`KEY=value, one entry per line.`,children:(0,J.jsx)(se,{rows:5,value:be(n),disabled:o,onChange:e=>s(r,xe(e.target.value))})}):(0,J.jsxs)(`div`,{className:`space-y-3`,children:[r.length>0&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm font-medium`,children:i}),t.description&&(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t.description})]}),(0,J.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:Object.entries(e).map(([e,t])=>{let i=ie(n)?n[e]:void 0;return(0,J.jsx)(ke,{schema:t,value:i===void 0&&a.has(e)?_e(t):i,path:[...r,e],label:t.title||Ae(e),required:a.has(e),disabled:o,onChange:s},e)})})]})}return(0,J.jsx)(Y,{label:i,description:t.description,children:(0,J.jsx)(z,{value:typeof n==`string`?n:n==null?``:String(n),disabled:o,onChange:e=>s(r,e.target.value===``&&!a?void 0:e.target.value)})})}function Y({label:e,description:t,children:n}){return(0,J.jsxs)(`label`,{className:`block space-y-1.5 text-sm`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:e}),n,t&&(0,J.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:t})]})}function Ae(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[-_]+/g,` `).replace(/^\w/,e=>e.toUpperCase())}function je(){let e=A(e=>e.theme),n=A(e=>e.showReasoning),r=A(e=>e.set);return(0,J.jsxs)(`section`,{className:`space-y-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-base font-semibold`,children:`Browser preferences`}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`These are stored in local dashboard state, not in Relay server config.`})]}),(0,J.jsxs)(G,{size:`sm`,children:[(0,J.jsxs)(H,{children:[(0,J.jsx)(W,{className:`text-sm`,children:`Dashboard display`}),(0,J.jsx)(V,{className:`text-xs`,children:`Browser tier · persisted in this browser profile.`}),(0,J.jsx)(ce,{children:(0,J.jsxs)(L,{variant:`outline`,className:`gap-1`,children:[(0,J.jsx)(t,{className:`size-3.5`}),`Browser`]})})]}),(0,J.jsxs)(U,{className:`grid gap-3 md:grid-cols-2`,children:[(0,J.jsx)(Y,{label:`Theme`,children:(0,J.jsxs)(I,{value:e,onValueChange:e=>r({theme:e}),children:[(0,J.jsx)(N,{children:(0,J.jsx)(M,{})}),(0,J.jsx)(P,{children:oe.map(e=>(0,J.jsx)(F,{value:e.id,children:e.label},e.id))})]})}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border bg-muted/20 p-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(l,{className:`size-4`}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm font-medium`,children:`Show reasoning details`}),(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Display captured reasoning/tool steps in chat. Server capture is controlled separately by provider reasoningCapture.`})]})]}),(0,J.jsx)(B,{checked:n,onCheckedChange:e=>r({showReasoning:e})})]})]})]}),(0,J.jsx)(Me,{})]})}function Me(){let e=A(e=>e.voiceTtsEnabled),t=A(e=>e.setVoiceTtsEnabled),n=A(e=>e.voiceTtsMode),r=A(e=>e.setVoiceTtsMode),i=A(e=>e.voiceTtsKokoroVoice),a=A(e=>e.setVoiceTtsKokoroVoice),o=A(e=>e.voiceTtsBrowserVoice),s=A(e=>e.setVoiceTtsBrowserVoice),c=A(e=>e.voiceInputMode),l=A(e=>e.setVoiceInputMode),[u,d]=(0,K.useState)(()=>te());(0,K.useEffect)(()=>{if(typeof window>`u`||!(`speechSynthesis`in window))return;let e=()=>d(te());return e(),window.speechSynthesis.addEventListener?.(`voiceschanged`,e),()=>window.speechSynthesis.removeEventListener?.(`voiceschanged`,e)},[]);let f=k.some(e=>e.id===i)?k:[...k,{id:i,label:i}];return(0,J.jsxs)(G,{size:`sm`,children:[(0,J.jsxs)(H,{children:[(0,J.jsxs)(W,{className:`flex items-center gap-2 text-sm`,children:[(0,J.jsx)(C,{className:`size-4`}),`Voice`]}),(0,J.jsx)(V,{className:`text-xs`,children:`Browser tier TTS and push-to-talk behavior.`}),(0,J.jsx)(ce,{children:(0,J.jsx)(B,{checked:e,onCheckedChange:t})})]}),(0,J.jsxs)(U,{className:`grid gap-3 md:grid-cols-2`,children:[(0,J.jsx)(Y,{label:`Speech engine`,children:(0,J.jsxs)(I,{value:n,onValueChange:e=>r(e),children:[(0,J.jsx)(N,{children:(0,J.jsx)(M,{})}),(0,J.jsxs)(P,{children:[(0,J.jsx)(F,{value:`kokoro`,children:`Kokoro (server, fallback to browser)`}),(0,J.jsx)(F,{value:`browser`,children:`Browser Web Speech API`})]})]})}),(0,J.jsx)(Y,{label:`Kokoro voice`,children:(0,J.jsxs)(I,{value:i,onValueChange:a,children:[(0,J.jsx)(N,{children:(0,J.jsx)(M,{})}),(0,J.jsx)(P,{children:f.map(e=>(0,J.jsx)(F,{value:e.id,children:e.label},e.id))})]})}),(0,J.jsx)(Y,{label:`Browser voice`,children:(0,J.jsxs)(I,{value:o||`__unset__`,onValueChange:e=>s(e===`__unset__`?``:e),children:[(0,J.jsx)(N,{children:(0,J.jsx)(M,{})}),(0,J.jsxs)(P,{children:[(0,J.jsx)(F,{value:Se,children:`System default`}),u.map(e=>(0,J.jsx)(F,{value:e.uri,children:e.label},e.uri))]})]})}),(0,J.jsx)(Y,{label:`Push-to-talk input`,children:(0,J.jsxs)(I,{value:c,onValueChange:e=>l(e),children:[(0,J.jsx)(N,{children:(0,J.jsx)(M,{})}),(0,J.jsxs)(P,{children:[(0,J.jsx)(F,{value:`compose`,children:`Fill message box`}),(0,J.jsx)(F,{value:`autosend`,children:`Send immediately`})]})]})})]})]})}function Ne({catalog:e,error:t,canWrite:n,onCatalog:i}){let s=e[0]?.provider??``,[c,l]=(0,K.useState)(s),[u,d]=(0,K.useState)(()=>Pe(s)),[f,p]=(0,K.useState)(``),[h,_]=(0,K.useState)([]),v=e.some(e=>e.provider===c)?c:s,b=e.find(e=>e.provider===v)??e[0],C=e.map(e=>e.provider);function w(e){d(t=>({...t,...e})),_([]),p(``)}function T(e){l(e),d(Pe(e)),_([]),p(``)}async function E(){i((await x(`GET`,`/providers`)).catalog)}async function D(){if(n){_([]),p(``);try{await x(`PUT`,`/providers/${encodeURIComponent(u.provider)}/models/${encodeURIComponent(u.alias)}`,{label:u.label,providerModel:u.providerModel,efforts:ve(u.efforts),defaultEffort:u.defaultEffort.trim()||void 0,limits:u.limits,capabilities:u.capabilities,contextThreshold:Fe(u),disabled:u.disabled,updatedBy:`dashboard`}),await E(),p(`${u.alias} saved`),d(Pe(u.provider))}catch(e){let t=Ee(e);_(t.length?t:[e.message])}}}async function O(e,t){if(n){_([]),p(``);try{await x(`PATCH`,`/providers/${encodeURIComponent(v)}/models/${encodeURIComponent(e.alias)}`,{disabled:t,updatedBy:`dashboard`}),await E(),p(`${e.alias} ${t?`disabled`:`enabled`}`)}catch(e){let t=Ee(e);_(t.length?t:[e.message])}}}async function te(e){if(n){_([]),p(``);try{await x(`DELETE`,`/providers/${encodeURIComponent(v)}/models/${encodeURIComponent(e.alias)}`),await E(),p(`${e.alias} removed`)}catch(e){let t=Ee(e);_(t.length?t:[e.message])}}}function ne(e){d({provider:v,alias:e.alias,label:e.label,providerModel:e.providerModel,efforts:e.efforts.join(`, `),defaultEffort:e.defaultEffort??``,selfCompactUtilization:e.contextThreshold?.selfCompactUtilization?.toString()??``,warnUtilization:e.contextThreshold?.warnUtilization?.toString()??``,hardBackstopUtilization:e.contextThreshold?.hardBackstopUtilization?.toString()??``,disabled:!!e.disabled,limits:e.limits,capabilities:e.capabilities}),_([]),p(``)}return t?(0,J.jsx)(G,{size:`sm`,children:(0,J.jsxs)(U,{className:`text-sm text-muted-foreground`,children:[(0,J.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 font-medium text-foreground`,children:[(0,J.jsx)(r,{className:`size-4`}),`Model catalog`]}),t]})}):(0,J.jsxs)(`section`,{className:`space-y-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-base font-semibold`,children:`Model catalog`}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Add override models, disable unavailable models, or remove custom entries from the provider catalog.`})]}),!n&&(0,J.jsx)(L,{variant:`secondary`,children:`Read only: needs settings:write:provider`})]}),(0,J.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:C.map(e=>(0,J.jsx)(R,{variant:e===v?`default`:`outline`,size:`sm`,onClick:()=>T(e),children:e},e))}),(0,J.jsxs)(G,{size:`sm`,children:[(0,J.jsxs)(H,{children:[(0,J.jsx)(W,{className:`text-sm`,children:`Add or edit model`}),(0,J.jsx)(ce,{children:(0,J.jsxs)(L,{variant:`outline`,className:`gap-1`,children:[(0,J.jsx)(S,{className:`size-3.5`}),`Server runtime`]})})]}),(0,J.jsxs)(U,{className:`space-y-3`,children:[(0,J.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,J.jsx)(Y,{label:`Alias`,children:(0,J.jsx)(z,{value:u.alias,disabled:!n,placeholder:`nightly`,onChange:e=>w({alias:e.target.value.trim()})})}),(0,J.jsx)(Y,{label:`Label`,children:(0,J.jsx)(z,{value:u.label,disabled:!n,placeholder:`Nightly Codex`,onChange:e=>w({label:e.target.value})})}),(0,J.jsx)(Y,{label:`Provider model`,children:(0,J.jsx)(z,{value:u.providerModel,disabled:!n,placeholder:`codex-nightly`,onChange:e=>w({providerModel:e.target.value})})}),(0,J.jsx)(Y,{label:`Efforts`,children:(0,J.jsx)(z,{value:u.efforts,disabled:!n,placeholder:`low, medium, high`,onChange:e=>w({efforts:e.target.value})})}),(0,J.jsx)(Y,{label:`Default effort`,children:(0,J.jsx)(z,{value:u.defaultEffort,disabled:!n,placeholder:`medium`,onChange:e=>w({defaultEffort:e.target.value})})}),(0,J.jsx)(Y,{label:`Self compact utilization`,children:(0,J.jsx)(z,{value:u.selfCompactUtilization,disabled:!n,placeholder:`0.80`,inputMode:`decimal`,onChange:e=>w({selfCompactUtilization:e.target.value})})}),(0,J.jsx)(Y,{label:`Warn utilization`,children:(0,J.jsx)(z,{value:u.warnUtilization,disabled:!n,placeholder:`default: self - 0.10`,inputMode:`decimal`,onChange:e=>w({warnUtilization:e.target.value})})}),(0,J.jsx)(Y,{label:`Hard backstop utilization`,children:(0,J.jsx)(z,{value:u.hardBackstopUtilization,disabled:!n,placeholder:`0.90`,inputMode:`decimal`,onChange:e=>w({hardBackstopUtilization:e.target.value})})}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border bg-muted/20 p-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm font-medium`,children:`Disabled`}),(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Keep visible but unavailable for new launches.`})]}),(0,J.jsx)(B,{checked:u.disabled,disabled:!n,onCheckedChange:e=>w({disabled:e})})]})]}),(0,J.jsxs)(R,{onClick:D,disabled:!n||!u.alias||!u.label||!u.providerModel,children:[(0,J.jsx)(a,{className:`size-4`}),`Save model`]})]})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[b&&b.models.length===0&&(0,J.jsx)(G,{size:`sm`,children:(0,J.jsx)(U,{className:`text-sm text-muted-foreground`,children:`No models in this provider catalog yet.`})}),b?.models.map(e=>(0,J.jsx)(G,{size:`sm`,children:(0,J.jsxs)(U,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:e.label}),(0,J.jsx)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-xs`,children:e.alias}),e.disabled&&(0,J.jsx)(L,{variant:`secondary`,children:`Disabled`})]}),(0,J.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.providerModel,e.efforts.length>0?` · efforts ${e.efforts.join(`, `)}`:` · no effort levels`,e.defaultEffort?` · default ${e.defaultEffort}`:``,` · context ${Le(e)}`]})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,J.jsxs)(R,{variant:`outline`,size:`sm`,onClick:()=>ne(e),children:[(0,J.jsx)(o,{className:`size-4`}),`Edit`]}),(0,J.jsxs)(R,{variant:`outline`,size:`sm`,disabled:!n,onClick:()=>void O(e,!e.disabled),children:[e.disabled?(0,J.jsx)(g,{className:`size-4`}):(0,J.jsx)(m,{className:`size-4`}),e.disabled?`Enable`:`Disable`]}),(0,J.jsxs)(R,{variant:`outline`,size:`sm`,disabled:!n,onClick:()=>void te(e),children:[(0,J.jsx)(y,{className:`size-4`}),`Remove`]})]})]})},e.alias))]}),h.length>0&&(0,J.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:(0,J.jsx)(`ul`,{className:`list-disc space-y-1 pl-5`,children:h.map(e=>(0,J.jsx)(`li`,{children:e},e))})}),f&&(0,J.jsxs)(`p`,{className:`flex items-center gap-1 text-sm text-emerald-500`,children:[(0,J.jsx)(ee,{className:`size-4`}),f]})]})}function Pe(e){return{provider:e,alias:``,label:``,providerModel:``,efforts:``,defaultEffort:``,selfCompactUtilization:``,warnUtilization:``,hardBackstopUtilization:``,disabled:!1}}function Fe(e){let t=Ie(e.selfCompactUtilization,`Self compact utilization`),n=Ie(e.warnUtilization,`Warn utilization`),r=Ie(e.hardBackstopUtilization,`Hard backstop utilization`);if(!(t===void 0&&n===void 0&&r===void 0)){if(t===void 0)throw Error(`Self compact utilization is required when setting context thresholds`);return{selfCompactUtilization:t,...n===void 0?{}:{warnUtilization:n},...r===void 0?{}:{hardBackstopUtilization:r}}}}function Ie(e,t){let n=e.trim();if(!n)return;let r=Number(n);if(!Number.isFinite(r))throw Error(`${t} must be a number`);return r}function Le(e){if(e.contextThreshold)return`self ${Re(e.contextThreshold.selfCompactUtilization)}, warn ${Re(e.contextThreshold.warnUtilization??Math.max(0,e.contextThreshold.selfCompactUtilization-.1))}`;let t=ne(e.limits?.contextWindowTokens?.value);return`derived self ${Re(t.selfCompactUtilization)}, warn ${Re(t.warnUtilization)}`}function Re(e){return`${Math.round(e*100)}%`}var ze=5,Be=15,Ve={claude:`Claude`,codex:`Codex`};function He(e){return Math.round(e/6e4)}function Ue(e){return`${He(e)} min`}function We({canWrite:e}){let[t,n]=(0,K.useState)(null),[r,i]=(0,K.useState)(``),[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(null);(0,K.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await x(`GET`,`/providers/quota-config`);e||n(t)}catch(t){e||i(t.message)}})(),()=>{e=!0}},[]);async function l(e,t){n(n=>({...n??{},[e]:t})),o(``),c(e);try{let r=await x(`PUT`,`/providers/${e}/quota-config`,t);n(t=>({...t??{},[e]:r}))}catch(t){o(`${Ve[e]??e}: ${t.message}`)}finally{c(null)}}let d=t?Object.keys(t).sort():[];return(0,J.jsxs)(`section`,{className:`space-y-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-base font-semibold`,children:`Quota`}),(0,J.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Per-provider quota collection and display. `,(0,J.jsx)(`strong`,{children:`Enabled`}),` governs collection (disabled stops polling — no API calls);`,(0,J.jsx)(`strong`,{children:` Show in widget`}),` governs display only.`]})]}),r&&(0,J.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:[(0,J.jsx)(O,{className:`mt-0.5 size-4`}),(0,J.jsx)(`span`,{children:r})]}),a&&(0,J.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:[(0,J.jsx)(O,{className:`mt-0.5 size-4`}),(0,J.jsx)(`span`,{children:a})]}),!t&&!r&&(0,J.jsx)(G,{size:`sm`,children:(0,J.jsxs)(U,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,J.jsx)(T,{className:`size-4 animate-spin`}),`Loading quota config…`]})}),d.map(r=>{let i=t[r],a=!e||s===r;return(0,J.jsxs)(G,{size:`sm`,children:[(0,J.jsxs)(H,{children:[(0,J.jsxs)(W,{className:`flex items-center gap-2 text-sm`,children:[(0,J.jsx)(u,{className:`size-4`}),Ve[r]??r,s===r&&(0,J.jsx)(T,{className:`size-3 animate-spin text-muted-foreground`})]}),(0,J.jsxs)(V,{className:`text-xs`,children:[i.enabled?`Polled every ${Ue(i.pollIntervalMs)}`:`Collection disabled`,i.enabled&&!i.showInWidget?` · hidden from widget`:``]})]}),(0,J.jsxs)(U,{className:`space-y-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border bg-muted/20 p-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm font-medium`,children:`Enabled`}),(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Collect quota for this provider. Off stops all polling (no API calls, no token spend).`})]}),(0,J.jsx)(B,{checked:i.enabled,disabled:a,onCheckedChange:e=>void l(r,{...i,enabled:e})})]}),(0,J.jsxs)(`div`,{className:`rounded-md border bg-muted/20 p-3 space-y-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`div`,{className:`text-sm font-medium`,children:`Polling interval`}),(0,J.jsx)(L,{variant:`outline`,className:`tabular-nums`,children:Ue(i.pollIntervalMs)})]}),(0,J.jsx)(`input`,{type:`range`,min:ze,max:Be,step:1,value:He(i.pollIntervalMs),disabled:a||!i.enabled,onChange:e=>{let t=Number(e.target.value)*6e4;n(e=>({...e??{},[r]:{...i,pollIntervalMs:t}}))},onPointerUp:e=>void l(r,{...i,pollIntervalMs:Number(e.target.value)*6e4}),onKeyUp:e=>void l(r,{...i,pollIntervalMs:Number(e.target.value)*6e4}),className:`w-full accent-primary disabled:opacity-50`}),(0,J.jsxs)(`div`,{className:`flex justify-between text-[10px] text-muted-foreground`,children:[(0,J.jsxs)(`span`,{children:[ze,` min`]}),(0,J.jsxs)(`span`,{children:[Be,` min`]})]})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border bg-muted/20 p-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm font-medium`,children:`Show in quota widget`}),(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Display only. Off hides this provider from the dashboard widget; collection continues if enabled.`})]}),(0,J.jsx)(B,{checked:i.showInWidget,disabled:a,onCheckedChange:e=>void l(r,{...i,showInWidget:e})})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border bg-muted/20 p-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm font-medium`,children:`Burn-rate sparkline`}),(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Show a mini utilization chart per window in the expanded widget.`})]}),(0,J.jsx)(B,{checked:i.sparklineEnabled??!0,disabled:a,onCheckedChange:e=>void l(r,{...i,sparklineEnabled:e})})]}),(0,J.jsxs)(`div`,{className:`rounded-md border bg-muted/20 p-3 space-y-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`div`,{className:`text-sm font-medium`,children:`Sparkline range`}),(0,J.jsxs)(L,{variant:`outline`,className:`tabular-nums`,children:[i.sparklineRangeHours??8,`h`]})]}),(0,J.jsx)(`input`,{type:`range`,min:1,max:8,step:1,value:i.sparklineRangeHours??8,disabled:a||!(i.sparklineEnabled??!0),onChange:e=>{let t=Number(e.target.value);n(e=>({...e??{},[r]:{...i,sparklineRangeHours:t}}))},onPointerUp:e=>void l(r,{...i,sparklineRangeHours:Number(e.target.value)}),onKeyUp:e=>void l(r,{...i,sparklineRangeHours:Number(e.target.value)}),className:`w-full accent-primary disabled:opacity-50`}),(0,J.jsxs)(`div`,{className:`flex justify-between text-[10px] text-muted-foreground`,children:[(0,J.jsx)(`span`,{children:`1h`}),(0,J.jsx)(`span`,{children:`8h`})]})]})]})]},r)})]})}function Ge({message:e}){return(0,J.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:[(0,J.jsx)(O,{className:`mt-0.5 size-4 shrink-0`}),(0,J.jsx)(`span`,{children:e})]})}var Ke=re(),X={cautionAt:.15,avoidLargeAt:.5,hardAvoidAt:1},qe=.99,Je=.5;function Z(e,t){return((e??t)*100).toFixed(0)}function Q(e){let t=e.trim();if(!t)return null;let n=Number(t);return!Number.isFinite(n)||n<0||n>100?null:n/100}function Ye(e,t){return e.trim()?Q(e):t}function Xe({policy:e,canWrite:t,onPolicy:n}){let r=e.quotaBands,i=e.providerQuota??{},[a,o]=(0,K.useState)(Z(r?.cautionAt,X.cautionAt)),[c,l]=(0,K.useState)(Z(r?.avoidLargeAt,X.avoidLargeAt)),[u,d]=(0,K.useState)(Z(r?.hardAvoidAt,X.hardAvoidAt)),[f,p]=(0,K.useState)(()=>{let e={};for(let t of Ke){let n=i[t]??{};e[t]={backstop:Z(n.hardBackstopUtilization,qe),floor:Z(n.burnPenaltyUtilizationFloor,Je)}}return e}),[m,h]=(0,K.useState)(!1),[g,_]=(0,K.useState)(``),[v,y]=(0,K.useState)(!1),[b,S]=(0,K.useState)(``);async function C(){let t=Q(a),r=Q(c),i=Q(u);if(t===null){S(`Caution threshold must be 0–100%.`);return}if(r===null){S(`Avoid-large threshold must be 0–100%.`);return}if(i===null){S(`Hard-avoid threshold must be 0–100%.`);return}if(t>=r){S(`Caution must be less than avoid-large.`);return}if(r>=i){S(`Avoid-large must be less than hard-avoid.`);return}let o={};for(let e of Ke){let t=f[e],n=Ye(t.backstop,qe),r=Q(t.floor);if(n===null){S(`${j(e)}: hard-backstop must be 0–100%.`);return}if(r===null){S(`${j(e)}: burn-penalty floor must be 0–100%.`);return}o[e]={hardBackstopUtilization:n,burnPenaltyUtilizationFloor:r}}S(``),h(!0),_(``),y(!1);try{n(await x(`PUT`,`/routing-policy`,{...e,quotaBands:{cautionAt:t,avoidLargeAt:r,hardAvoidAt:i},providerQuota:o})),y(!0),setTimeout(()=>y(!1),2e3)}catch(e){_(e.message)}finally{h(!1)}}function w(e,t){p(n=>({...n,[e]:{...n[e],...t}})),S(``),y(!1)}function E(){S(``),y(!1)}return(0,J.jsxs)(G,{size:`sm`,children:[(0,J.jsxs)(H,{children:[(0,J.jsx)(W,{className:`text-sm`,children:`Quota thresholds`}),(0,J.jsx)(V,{className:`text-xs`,children:`Band cutoffs govern when the orchestrator starts penalising or blocking high-quota providers. Values are utilization percentages (0–100).`})]}),(0,J.jsxs)(U,{className:`space-y-4`,children:[(g||b)&&(0,J.jsx)(Ge,{message:g||b}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:`Band cutoffs`}),(0,J.jsx)(Ze,{caution:Number(a),avoidLarge:Number(c),hardAvoid:Number(u)}),(0,J.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[(0,J.jsx)($,{label:`Caution at`,hint:`Default: ${(X.cautionAt*100).toFixed(0)}%`,value:a,disabled:!t||m,onChange:e=>{o(e),E()}}),(0,J.jsx)($,{label:`Avoid-large at`,hint:`Default: ${(X.avoidLargeAt*100).toFixed(0)}%`,value:c,disabled:!t||m,onChange:e=>{l(e),E()}}),(0,J.jsx)($,{label:`Hard-avoid at`,hint:`Default: ${(X.hardAvoidAt*100).toFixed(0)}%`,value:u,disabled:!t||m,onChange:e=>{d(e),E()}})]})]}),Ke.map(e=>{let n=f[e];return(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:[j(e),` overrides`]}),(0,J.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,J.jsx)($,{label:`Hard-backstop utilization`,hint:`0 = disable backstop (never block on this quota); blank uses the ${(qe*100).toFixed(0)}% default.`,value:n.backstop,disabled:!t||m,onChange:t=>w(e,{backstop:t})}),(0,J.jsx)($,{label:`Burn-penalty floor`,hint:`Penalties suppressed below this. Default: ${(Je*100).toFixed(0)}%`,value:n.floor,disabled:!t||m,onChange:t=>w(e,{floor:t})})]})]},e)}),t&&(0,J.jsxs)(R,{size:`sm`,onClick:()=>void C(),disabled:m,children:[m?(0,J.jsx)(T,{className:`size-4 animate-spin`}):(0,J.jsx)(s,{className:`size-4`}),v?`Saved`:`Save thresholds`]})]})]})}function Ze({caution:e,avoidLarge:t,hardAvoid:n}){let r=e=>Math.max(0,Math.min(100,Number.isFinite(e)?e:0)),i=r(e),a=Math.max(i,r(t)),o=Math.max(a,r(n)),s=e=>`${e.toFixed(0)}%`,c=[{key:`normal`,label:`normal`,color:`bg-emerald-500`,from:0,to:i,range:`0–${s(i)}`},{key:`caution`,label:`caution`,color:`bg-amber-500`,from:i,to:a,range:`${s(i)}–${s(a)}`},{key:`avoid-large`,label:`avoid large`,color:`bg-orange-500`,from:a,to:o,range:`${s(a)}–${s(o)}`},{key:`hard-avoid`,label:`hard avoid`,color:`bg-red-500`,from:o,to:100,range:`≥ ${s(o)}`}];return(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`div`,{className:`flex h-2.5 overflow-hidden rounded-full bg-muted`,role:`img`,"aria-label":`Quota penalty bands from 0 to 100 percent`,children:c.map(e=>(0,J.jsx)(`div`,{className:D(e.color,`transition-[width] duration-300`),style:{width:`${e.to-e.from}%`},title:`${e.label} · ${e.range}`},e.key))}),(0,J.jsx)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-[10px] text-muted-foreground`,children:c.map(e=>(0,J.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(`span`,{className:D(`size-2 shrink-0 rounded-full`,e.color)}),e.label,` `,(0,J.jsx)(`span`,{className:`tabular-nums text-foreground/70`,children:e.range})]},e.key))})]})}function $({label:e,hint:t,value:n,disabled:r,onChange:i}){return(0,J.jsxs)(`label`,{className:`space-y-1`,children:[(0,J.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground`,children:e}),(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(z,{value:n,onChange:e=>i(e.target.value),disabled:r,className:`h-8 pr-6 text-xs tabular-nums`}),(0,J.jsx)(`span`,{className:`pointer-events-none absolute inset-y-0 right-2.5 flex items-center text-xs text-muted-foreground`,children:`%`})]}),(0,J.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:t})]})}function Qe(){let[e,t]=(0,K.useState)(null),[n,r]=(0,K.useState)(!1),[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(!1),[l,u]=(0,K.useState)(!1);async function p(){if(!l){r(!0),o(``);try{let[e,n]=await Promise.all([x(`GET`,`/routing-policy`),x(`GET`,`/agent-profiles/coordinator`).catch(()=>null)]);t({policy:e,profile:n}),u(!0)}catch(e){o(e.message)}finally{r(!1)}}}async function m(){u(!1),r(!0),o(``);try{let[e,n]=await Promise.all([x(`GET`,`/routing-policy`),x(`GET`,`/agent-profiles/coordinator`).catch(()=>null)]);t({policy:e,profile:n}),u(!0)}catch(e){o(e.message)}finally{r(!1)}}function h(){let e=!s;c(e),e&&!l&&p()}return(0,J.jsx)(G,{size:`sm`,children:(0,J.jsxs)(U,{className:`space-y-3`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 text-left`,onClick:h,children:[(0,J.jsx)(g,{className:`size-4 text-muted-foreground`}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-sm font-semibold`,children:`What your coordinator knows`}),(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Active routing policy + coordinator profile instructions (read-only)`})]}),s?(0,J.jsx)(f,{className:`size-4 shrink-0 text-muted-foreground`}):(0,J.jsx)(i,{className:`size-4 shrink-0 text-muted-foreground`})]}),s&&(0,J.jsxs)(`div`,{className:`space-y-4 pt-1`,children:[(0,J.jsx)(`div`,{className:`flex justify-end`,children:(0,J.jsxs)(R,{variant:`outline`,size:`sm`,onClick:()=>void m(),disabled:n,children:[(0,J.jsx)(d,{className:D(`size-3.5`,n&&`animate-spin`)}),`Refresh`]})}),a&&(0,J.jsx)(Ge,{message:a}),n&&!e&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground py-2`,children:[(0,J.jsx)(T,{className:`size-3.5 animate-spin`}),`Loading…`]}),e&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($e,{policy:e.policy}),e.profile?(0,J.jsx)(tt,{profile:e.profile}):(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`Coordinator profile not found.`})]})]})]})})}function $e({policy:e}){let t=e.quotaBands,n=e.providerQuota??{};return(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:`Active routing policy`}),e.rules.length===0?(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`No rules — coordinators use their own heuristics.`}):(0,J.jsxs)(`div`,{className:`overflow-hidden rounded-md border border-border text-xs`,children:[(0,J.jsxs)(`div`,{className:`grid grid-cols-[1.5rem_minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)] gap-px bg-border text-[10px] font-medium text-muted-foreground uppercase tracking-wide`,children:[(0,J.jsx)(`div`,{className:`bg-muted/40 px-2 py-1.5`,children:`#`}),(0,J.jsx)(`div`,{className:`bg-muted/40 px-2 py-1.5`,children:`Match`}),(0,J.jsx)(`div`,{className:`bg-muted/40 px-2 py-1.5`,children:`Target`}),(0,J.jsx)(`div`,{className:`bg-muted/40 px-2 py-1.5`,children:`Status`})]}),e.rules.map((e,t)=>(0,J.jsxs)(`div`,{className:D(`grid grid-cols-[1.5rem_minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)] gap-px bg-border`,e.enabled===!1&&`opacity-50`),children:[(0,J.jsx)(`div`,{className:`bg-card px-2 py-1.5 text-muted-foreground tabular-nums`,children:t+1}),(0,J.jsxs)(`div`,{className:`bg-card px-2 py-1.5`,children:[e.label&&(0,J.jsx)(`div`,{className:`font-medium`,children:e.label}),e.match.taskType&&(0,J.jsxs)(`div`,{className:`font-mono`,children:[`task: `,e.match.taskType]}),e.match.capability&&(0,J.jsxs)(`div`,{className:`font-mono`,children:[`cap: `,e.match.capability]})]}),(0,J.jsxs)(`div`,{className:`bg-card px-2 py-1.5`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:e.target.provider}),e.target.model&&(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[` / `,e.target.model]}),e.target.effort&&(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[` (`,e.target.effort,`)`]})]}),(0,J.jsx)(`div`,{className:`bg-card px-2 py-1.5`,children:e.enabled===!1?(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`disabled`}):(0,J.jsx)(`span`,{className:`text-emerald-500`,children:`active`})})]},t))]}),(t||Object.keys(n).length>0)&&(0,J.jsxs)(`div`,{className:`rounded-md border border-border bg-muted/10 px-3 py-2 text-xs space-y-1`,children:[t&&(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-0.5`,children:[t.cautionAt!==void 0&&(0,J.jsxs)(`span`,{children:[`caution ≥ `,(t.cautionAt*100).toFixed(0),`%`]}),t.avoidLargeAt!==void 0&&(0,J.jsxs)(`span`,{children:[`avoid-large ≥ `,(t.avoidLargeAt*100).toFixed(0),`%`]}),t.hardAvoidAt!==void 0&&(0,J.jsxs)(`span`,{children:[`hard-avoid ≥ `,(t.hardAvoidAt*100).toFixed(0),`%`]})]}),Object.entries(n).map(([e,t])=>(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-0.5 text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`font-medium text-foreground`,children:j(e)}),t?.hardBackstopUtilization!==void 0&&(0,J.jsxs)(`span`,{children:[`backstop: `,(t.hardBackstopUtilization*100).toFixed(0),`%`]}),t?.burnPenaltyUtilizationFloor!==void 0&&(0,J.jsxs)(`span`,{children:[`floor: `,(t.burnPenaltyUtilizationFloor*100).toFixed(0),`%`]})]},e))]})]})}function et({text:e,index:t}){return(0,J.jsxs)(`div`,{className:`relative max-h-72 overflow-y-auto rounded-md border border-border bg-muted/20`,children:[t!==void 0&&(0,J.jsxs)(`span`,{className:`sticky top-0 float-right m-1.5 rounded bg-muted px-1.5 py-0.5 text-[9px] font-medium tabular-nums text-muted-foreground`,children:[`#`,t]}),(0,J.jsx)(`pre`,{className:`whitespace-pre-wrap break-words px-3 py-2.5 font-sans text-[11px] leading-relaxed text-foreground/90`,children:e})]})}function tt({profile:e}){return(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsxs)(`div`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:[`Coordinator profile instructions`,(0,J.jsx)(L,{variant:`secondary`,className:`ml-2 text-[10px]`,children:e.name}),e.builtIn&&(0,J.jsx)(L,{variant:`outline`,className:`ml-1 text-[10px]`,children:`built-in`})]}),e.description&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.description}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[10px]`,children:[(0,J.jsxs)(L,{variant:`outline`,children:[`base: `,e.base]}),(0,J.jsxs)(L,{variant:`outline`,children:[`repo: `,e.instructions.repoInstructions]}),(0,J.jsxs)(L,{variant:`outline`,children:[`global: `,e.instructions.globalInstructions]}),e.provider&&(0,J.jsxs)(L,{variant:`outline`,children:[`provider: `,e.provider]})]}),e.instructions.system&&(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wide`,children:`System prompt`}),(0,J.jsx)(et,{text:e.instructions.system})]}),e.instructions.append.length>0&&(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsxs)(`div`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wide`,children:[`Appended instructions (`,e.instructions.append.length,`)`]}),e.instructions.append.map((e,t)=>(0,J.jsx)(et,{text:e,index:t+1},t))]}),e.instructions.append.length===0&&!e.instructions.system&&(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:`No instruction blocks defined.`})]})}var nt=re();function rt(){return{label:``,matchTaskType:``,matchCapability:``,targetProvider:nt[0]??``,targetModel:``,targetEffort:``,enabled:!0}}function it(e){return{label:e.label??``,matchTaskType:e.match.taskType??``,matchCapability:e.match.capability??``,targetProvider:e.target.provider,targetModel:e.target.model??``,targetEffort:e.target.effort??``,enabled:e.enabled!==!1}}function at(e){return{...e.label.trim()?{label:e.label.trim()}:{},match:{...e.matchTaskType.trim()?{taskType:e.matchTaskType.trim()}:{},...e.matchCapability.trim()?{capability:e.matchCapability.trim()}:{}},target:{provider:e.targetProvider,...e.targetModel.trim()?{model:e.targetModel.trim()}:{},...e.targetEffort.trim()?{effort:e.targetEffort.trim()}:{}},enabled:e.enabled}}function ot(e){return!e.matchTaskType.trim()&&!e.matchCapability.trim()?`At least one match criterion (task type or capability) is required.`:null}function st({message:e}){return(0,J.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:[(0,J.jsx)(O,{className:`mt-0.5 size-4 shrink-0`}),(0,J.jsx)(`span`,{children:e})]})}function ct({canWrite:e}){let[t,n]=(0,K.useState)(null),[r,i]=(0,K.useState)(!1),[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(!1);!s&&!r&&!a&&(i(!0),(async()=>{try{n(await x(`GET`,`/routing-policy`)),c(!0)}catch(e){o(e.message)}finally{i(!1)}})());async function l(){i(!0),o(``);try{n(await x(`GET`,`/routing-policy`)),c(!0)}catch(e){o(e.message)}finally{i(!1)}}return(0,J.jsxs)(`div`,{className:`space-y-6`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-base font-semibold`,children:`Routing`}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Declarative rules mapping task types and capabilities to providers. Rules are advisory — coordinators apply them; explicit per-spawn arguments always take precedence.`})]}),(0,J.jsxs)(R,{variant:`outline`,size:`sm`,onClick:()=>void l(),disabled:r,children:[(0,J.jsx)(d,{className:D(`size-4`,r&&`animate-spin`)}),`Refresh`]})]}),a&&(0,J.jsx)(st,{message:a}),r&&!t&&(0,J.jsx)(G,{size:`sm`,children:(0,J.jsxs)(U,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,J.jsx)(T,{className:`size-4 animate-spin`}),`Loading routing policy…`]})}),t&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(lt,{policy:t,canWrite:e,onPolicy:n}),(0,J.jsx)(Xe,{policy:t,canWrite:e,onPolicy:n})]}),(0,J.jsx)(Qe,{})]})}function lt({policy:e,canWrite:t,onPolicy:n}){let[r,i]=(0,K.useState)(!1),[o,s]=(0,K.useState)(``),[l,u]=(0,K.useState)(!1),[d,f]=(0,K.useState)(rt),[p,m]=(0,K.useState)(``),[h,g]=(0,K.useState)(null),[_,v]=(0,K.useState)(rt),[y,b]=(0,K.useState)(``);async function S(e){i(!0),s(``);try{n(await x(`PUT`,`/routing-policy`,e))}catch(e){s(e.message)}finally{i(!1)}}function C(t,n){let r=[...e.rules],i=t+n;i<0||i>=r.length||([r[t],r[i]]=[r[i],r[t]],S({...e,rules:r}))}function w(t){let n=e.rules.map((e,n)=>n===t?{...e,enabled:e.enabled===!1}:e);S({...e,rules:n})}function E(t){S({...e,rules:e.rules.filter((e,n)=>n!==t)})}function D(){f(rt()),m(``),u(!0)}function O(){u(!1),m(``)}function ee(){let t=ot(d);if(t){m(t);return}u(!1),S({...e,rules:[...e.rules,at(d)]})}function te(t){g(t),v(it(e.rules[t])),b(``)}function ne(){g(null),b(``)}function k(){if(h===null)return;let t=ot(_);if(t){b(t);return}let n=e.rules.map((e,t)=>t===h?at(_):e);g(null),S({...e,rules:n})}return(0,J.jsxs)(G,{size:`sm`,children:[(0,J.jsxs)(H,{children:[(0,J.jsxs)(W,{className:`flex items-center gap-2 text-sm`,children:[(0,J.jsx)(c,{className:`size-4`}),`Rules`,(0,J.jsxs)(L,{variant:`outline`,className:`ml-auto text-[10px]`,children:[e.rules.length,` rule`,e.rules.length===1?``:`s`]}),r&&(0,J.jsx)(T,{className:`size-3 animate-spin text-muted-foreground`})]}),(0,J.jsx)(V,{className:`text-xs`,children:`Evaluated in order — first matching enabled rule wins. Rules are advisory; explicit spawn arguments override them.`})]}),(0,J.jsxs)(U,{className:`space-y-2`,children:[o&&(0,J.jsx)(st,{message:o}),e.rules.length===0&&!l&&(0,J.jsx)(`div`,{className:`rounded-md border border-dashed border-border py-6 text-center text-xs text-muted-foreground`,children:`No rules — coordinators fall back to their own heuristics.`}),e.rules.map((n,i)=>h===i?(0,J.jsx)(dt,{form:_,error:y,onChange:v,onSave:k,onCancel:ne},i):(0,J.jsx)(ut,{rule:n,idx:i,total:e.rules.length,canWrite:t,saving:r,onMoveUp:()=>C(i,-1),onMoveDown:()=>C(i,1),onToggle:()=>w(i),onEdit:()=>te(i),onRemove:()=>E(i)},i)),l&&(0,J.jsx)(dt,{form:d,error:p,onChange:f,onSave:ee,onCancel:O,isNew:!0}),t&&!l&&h===null&&(0,J.jsxs)(R,{variant:`outline`,size:`sm`,className:`w-full gap-1`,onClick:D,disabled:r,children:[(0,J.jsx)(a,{className:`size-4`}),`Add rule`]})]})]})}function ut({rule:e,idx:t,total:n,canWrite:r,saving:i,onMoveUp:a,onMoveDown:o,onToggle:s,onEdit:c,onRemove:l}){return(0,J.jsxs)(`div`,{className:D(`group flex items-start gap-3 rounded-md border bg-muted/20 p-3`,e.enabled===!1&&`opacity-60`),children:[(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-0.5 pt-0.5`,children:[(0,J.jsx)(`button`,{type:`button`,title:`Move up`,onClick:a,disabled:!r||i||t===0,className:`rounded p-0.5 text-muted-foreground hover:bg-accent hover:text-foreground disabled:pointer-events-none disabled:opacity-30`,children:(0,J.jsx)(p,{className:`size-3.5`})}),(0,J.jsx)(`button`,{type:`button`,title:`Move down`,onClick:o,disabled:!r||i||t===n-1,className:`rounded p-0.5 text-muted-foreground hover:bg-accent hover:text-foreground disabled:pointer-events-none disabled:opacity-30`,children:(0,J.jsx)(h,{className:`size-3.5`})})]}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsxs)(`span`,{className:`text-[10px] tabular-nums text-muted-foreground`,children:[`#`,t+1]}),e.label&&(0,J.jsx)(`span`,{className:`text-xs font-medium`,children:e.label}),(0,J.jsx)(L,{variant:`outline`,className:`text-[10px]`,children:e.target.provider}),e.target.model&&(0,J.jsx)(L,{variant:`outline`,className:`text-[10px] font-mono`,children:e.target.model}),e.target.effort&&(0,J.jsx)(L,{variant:`outline`,className:`text-[10px]`,children:e.target.effort})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-0.5 text-[10px] text-muted-foreground`,children:[e.match.taskType&&(0,J.jsxs)(`span`,{children:[`task-type: `,(0,J.jsx)(`span`,{className:`font-mono text-foreground`,children:e.match.taskType})]}),e.match.capability&&(0,J.jsxs)(`span`,{children:[`capability: `,(0,J.jsx)(`span`,{className:`font-mono text-foreground`,children:e.match.capability})]})]})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 opacity-70 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100`,children:[(0,J.jsx)(B,{checked:e.enabled!==!1,disabled:!r||i,onCheckedChange:s,title:e.enabled===!1?`Enable rule`:`Disable rule`}),r&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,title:`Edit`,onClick:c,disabled:i,className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground disabled:pointer-events-none`,children:(0,J.jsxs)(`svg`,{className:`size-3.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,children:[(0,J.jsx)(`path`,{d:`M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`}),(0,J.jsx)(`path`,{d:`M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z`})]})}),(0,J.jsx)(`button`,{type:`button`,title:`Remove`,onClick:l,disabled:i,className:`rounded p-1 text-destructive hover:bg-destructive/10 disabled:pointer-events-none`,children:(0,J.jsx)(y,{className:`size-3.5`})})]})]})]})}function dt({form:e,error:t,onChange:n,onSave:r,onCancel:i,isNew:a}){function o(t){n({...e,...t})}return(0,J.jsxs)(`div`,{className:`rounded-md border border-primary/30 bg-primary/5 p-3 space-y-3`,children:[(0,J.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:a?`New rule`:`Edit rule`}),(0,J.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,J.jsxs)(`label`,{className:`space-y-1`,children:[(0,J.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground`,children:`Label (optional)`}),(0,J.jsx)(z,{value:e.label,onChange:e=>o({label:e.target.value}),placeholder:`e.g. Route GUI tasks to Claude`,className:`h-8 text-xs`})]}),(0,J.jsxs)(`label`,{className:`space-y-1`,children:[(0,J.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground`,children:`Target provider`}),(0,J.jsxs)(I,{value:e.targetProvider,onValueChange:e=>o({targetProvider:e}),children:[(0,J.jsx)(N,{className:`h-8 text-xs`,children:(0,J.jsx)(M,{})}),(0,J.jsx)(P,{children:nt.map(e=>(0,J.jsx)(F,{value:e,className:`text-xs`,children:j(e)},e))})]})]})]}),(0,J.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,J.jsxs)(`label`,{className:`space-y-1`,children:[(0,J.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground`,children:`Match task-type (prefix)`}),(0,J.jsx)(z,{value:e.matchTaskType,onChange:e=>o({matchTaskType:e.target.value}),placeholder:`e.g. gui, backend, mechanical`,className:`h-8 font-mono text-xs`}),(0,J.jsxs)(`span`,{className:`block text-[10px] leading-snug text-muted-foreground`,children:[`Prefix match — `,(0,J.jsx)(`span`,{className:`font-mono text-foreground`,children:`gui`}),` matches `,(0,J.jsx)(`span`,{className:`font-mono text-foreground`,children:`gui/ux`}),`, `,(0,J.jsx)(`span`,{className:`font-mono text-foreground`,children:`gui/layout`}),`.`]})]}),(0,J.jsxs)(`label`,{className:`space-y-1`,children:[(0,J.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground`,children:`Match capability (exact)`}),(0,J.jsx)(z,{value:e.matchCapability,onChange:e=>o({matchCapability:e.target.value}),placeholder:`e.g. code, research, bounded`,className:`h-8 font-mono text-xs`}),(0,J.jsx)(`span`,{className:`block text-[10px] leading-snug text-muted-foreground`,children:`Exact match against the agent's capability tag. Both fields are AND-ed.`})]})]}),(0,J.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,J.jsxs)(`label`,{className:`space-y-1`,children:[(0,J.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground`,children:`Model alias (optional)`}),(0,J.jsx)(z,{value:e.targetModel,onChange:e=>o({targetModel:e.target.value}),placeholder:`e.g. opus, gpt-5.4`,className:`h-8 font-mono text-xs`})]}),(0,J.jsxs)(`label`,{className:`space-y-1`,children:[(0,J.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground`,children:`Effort (optional)`}),(0,J.jsx)(z,{value:e.targetEffort,onChange:e=>o({targetEffort:e.target.value}),placeholder:`e.g. high, low`,className:`h-8 text-xs`})]})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(B,{checked:e.enabled,onCheckedChange:e=>o({enabled:e})}),(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Enabled`})]}),t&&(0,J.jsx)(st,{message:t}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsxs)(R,{size:`sm`,onClick:r,children:[(0,J.jsx)(s,{className:`size-4`}),a?`Add`:`Save`]}),(0,J.jsx)(R,{size:`sm`,variant:`outline`,onClick:i,children:`Cancel`})]})]})}var ft=`browser`,pt=`models`,mt=`profile`,ht=`routing`,gt=[`branch.landed`,`landed-failure`,`agent.ready`,`agent.exited`,`agent.spawn_failed`,`agent.context_threshold`,`agent.quota_threshold`,`workspace.steward_task`,`workspace.conflict`,`workspace.review_request`];function _t(){if(typeof window>`u`)return``;let e=window.location.hash.replace(/^#/,``);return e.startsWith(`settings/`)?decodeURIComponent(e.slice(9)):``}function vt(e){if(typeof window>`u`)return;let t=new URL(window.location.href);t.hash=`settings/${encodeURIComponent(e)}`,window.history.pushState({},``,t)}function yt(){let[e,t]=(0,K.useState)([]),[n,r]=(0,K.useState)(null),[i,a]=(0,K.useState)([]),[o,s]=(0,K.useState)(()=>_t()),[c,l]=(0,K.useState)(!0),[u,f]=(0,K.useState)(``),[p,m]=(0,K.useState)(``);async function h(){l(!0),f(``),m(``);try{let[e,n,i]=await Promise.all([x(`GET`,`/settings`),x(`GET`,`/tokens/me`),x(`GET`,`/providers`).catch(e=>(m(e.message),{catalog:[]}))]);t(e.settings),r(n),a(i.catalog)}catch(e){f(e.message)}finally{l(!1)}}(0,K.useEffect)(()=>{h()},[]),(0,K.useEffect)(()=>{let e=()=>s(_t());return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]);let g=(0,K.useMemo)(()=>fe(e),[e]),_=(0,K.useMemo)(()=>[...g.map(e=>({slug:e.slug,label:e.group,description:`${e.settings.length} schema setting${e.settings.length===1?``:`s`}`,kind:`descriptors`,settings:e.settings})),{slug:ht,label:`Routing`,description:`Rules, quota thresholds, coordinator view`,kind:`routing`,settings:[]},{slug:mt,label:`Profile`,description:`Display name and avatar`,kind:`profile`,settings:[]},{slug:ft,label:`Browser`,description:`Local dashboard preferences`,kind:`browser`,settings:[]},{slug:pt,label:`Models`,description:`Provider model catalog`,kind:`models`,settings:[]}],[g]),y=_.find(e=>e.slug===o)??_[0];function b(e){s(e),vt(e)}function S(e){t(t=>t.map(t=>q(t)===q(e)?e:t))}return(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Settings`}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Schema-driven Relay settings, browser preferences, and model catalog controls.`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n&&(0,J.jsxs)(L,{variant:`outline`,className:`gap-1`,children:[(0,J.jsx)(v,{className:`size-3`}),n.kind,`:`,n.actor]}),(0,J.jsxs)(R,{variant:`outline`,size:`sm`,onClick:()=>void h(),disabled:c,children:[(0,J.jsx)(d,{className:D(`size-4`,c&&`animate-spin`)}),`Refresh`]})]})]}),u&&(0,J.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:[(0,J.jsx)(O,{className:`mt-0.5 size-4`}),(0,J.jsx)(`span`,{children:u})]}),(0,J.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[230px_minmax(0,1fr)]`,children:[(0,J.jsx)(`nav`,{className:`space-y-1 lg:sticky lg:top-4 lg:self-start`,children:_.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:D(`w-full rounded-md border px-3 py-2 text-left text-sm transition-colors`,y?.slug===e.slug?`border-primary/50 bg-primary/10 text-foreground`:`border-transparent hover:border-border hover:bg-accent`),onClick:()=>b(e.slug),children:[(0,J.jsx)(`span`,{className:`block font-medium`,children:e.label}),(0,J.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:e.description})]},e.slug))}),(0,J.jsx)(`div`,{className:`min-w-0 space-y-4`,children:c&&!e.length?(0,J.jsx)(G,{size:`sm`,children:(0,J.jsx)(U,{className:`text-sm text-muted-foreground`,children:`Loading settings…`})}):y?.kind===`routing`?(0,J.jsx)(ct,{canWrite:ae(n?.scopes,`settings:write:routing`)}):y?.kind===`descriptors`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(De,{group:y.label,settings:y.settings,onSaved:S}),y.label===`Providers`&&(0,J.jsx)(We,{canWrite:ae(n?.scopes,`settings:write:provider`)}),y.label===`Notifications`&&(0,J.jsx)(bt,{})]}):y?.kind===`profile`?(0,J.jsx)(xt,{}):y?.kind===`browser`?(0,J.jsx)(je,{}):(0,J.jsx)(Ne,{catalog:i,error:p,canWrite:ae(n?.scopes,`settings:write:provider`),onCatalog:a})})]})]})}function bt(){let[e,t]=(0,K.useState)(`branch.landed`),[n,r]=(0,K.useState)(`{
4
- "repoRoot": "/repo"
5
- }`),[i,a]=(0,K.useState)(null),[o,s]=(0,K.useState)(!1),[l,u]=(0,K.useState)(``);async function d(){s(!0),u(``);try{let t=JSON.parse(n);if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Scope must be a JSON object`);a((await x(`POST`,`/notifications/preview`,{type:e,scope:t})).preview)}catch(e){a(null),u(e.message)}finally{s(!1)}}return(0,J.jsx)(G,{size:`sm`,children:(0,J.jsxs)(U,{className:`space-y-3`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Who gets what`}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Dry-run notification routing without sending.`})]}),(0,J.jsxs)(R,{size:`sm`,onClick:()=>void d(),disabled:o,children:[(0,J.jsx)(c,{className:`size-4`}),`Preview`]})]}),(0,J.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Type`}),(0,J.jsxs)(I,{value:e,onValueChange:t,children:[(0,J.jsx)(N,{className:`w-full`,children:(0,J.jsx)(M,{})}),(0,J.jsx)(P,{children:gt.map(e=>(0,J.jsx)(F,{value:e,children:e},e))})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Scope`}),(0,J.jsx)(se,{value:n,onChange:e=>r(e.target.value),rows:4,className:`font-mono text-xs`})]})]}),l&&(0,J.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 p-2 text-xs text-destructive`,children:[(0,J.jsx)(O,{className:`mt-0.5 size-3.5`}),(0,J.jsx)(`span`,{children:l})]}),i&&(0,J.jsx)(`div`,{className:`overflow-hidden rounded-md border border-border`,children:i.recipients.length===0?(0,J.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:`No recipients`}):i.recipients.map(e=>(0,J.jsxs)(`div`,{className:`grid gap-1 border-b border-border px-3 py-2 text-xs last:border-b-0 md:grid-cols-[minmax(0,180px)_minmax(0,160px)_minmax(0,1fr)]`,children:[(0,J.jsx)(`span`,{className:`truncate font-medium`,children:e.recipient}),(0,J.jsx)(`span`,{className:`truncate font-mono text-muted-foreground`,children:e.matchedRule}),(0,J.jsx)(`span`,{className:`truncate text-muted-foreground`,children:e.reason})]},`${e.recipient}-${e.matchedRule}`))})]})})}function xt(){let e=A(e=>e.fetchUsers),t=(0,K.useRef)(null),[r,i]=(0,K.useState)(null),[a,o]=(0,K.useState)(``),[c,l]=(0,K.useState)(!0),[u,d]=(0,K.useState)(!1),[f,p]=(0,K.useState)(``);async function m(){l(!0),p(``);try{let e=await x(`GET`,`/users/me`);i(e),o(e.displayName||e.handle)}catch(e){p(e.message)}finally{l(!1)}}(0,K.useEffect)(()=>{m()},[]);async function h(){d(!0),p(``);try{let t=await x(`PATCH`,`/users/me`,{displayName:a});i(t),o(t.displayName||t.handle),await e()}catch(e){p(e.message)}finally{d(!1)}}async function g(n){if(n){d(!0),p(``);try{let t=await _(`/users/me/avatar`,n);i(t.user),o(t.user.displayName||t.user.handle),await e()}catch(e){p(e.message)}finally{d(!1),t.current&&(t.current.value=``)}}}async function v(){d(!0),p(``);try{i(await x(`DELETE`,`/users/me/avatar`)),await e()}catch(e){p(e.message)}finally{d(!1)}}return(0,J.jsx)(G,{size:`sm`,children:(0,J.jsxs)(U,{className:`space-y-4`,children:[f&&(0,J.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:[(0,J.jsx)(O,{className:`mt-0.5 size-4`}),(0,J.jsx)(`span`,{children:f})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,J.jsx)(le,{user:r??void 0,distinct:!0,className:`size-16 text-lg`}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,J.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground`,htmlFor:`profile-display-name`,children:`Display name`}),(0,J.jsx)(`input`,{id:`profile-display-name`,className:`h-9 w-full rounded-md border border-input bg-background px-3 text-sm`,value:a,onChange:e=>o(e.target.value),disabled:c||u,maxLength:120})]})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsxs)(R,{size:`sm`,onClick:()=>void h(),disabled:c||u||!a.trim(),children:[(0,J.jsx)(s,{className:`size-4`}),`Save`]}),(0,J.jsxs)(R,{size:`sm`,variant:`outline`,onClick:()=>t.current?.click(),disabled:c||u,children:[(0,J.jsx)(w,{className:`size-4`}),`Upload`]}),(0,J.jsxs)(R,{size:`sm`,variant:`outline`,onClick:()=>void v(),disabled:c||u||!r?.avatarArtifactId,children:[(0,J.jsx)(y,{className:`size-4`}),`Remove`]}),u&&(0,J.jsx)(n,{className:`size-4 animate-pulse text-muted-foreground`}),(0,J.jsx)(`input`,{ref:t,type:`file`,accept:`image/png,image/jpeg,image/gif,image/webp`,className:`hidden`,onChange:e=>void g(e.target.files?.[0])})]})]})})}export{yt as SettingsView};
6
- //# sourceMappingURL=settings-Y381jZt7.js.map
@@ -1,2 +0,0 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{ar as t,gr as n,rr as r,tr as i}from"./lucide-react-NXHPIMsX.js";import{_ as a,rt as o}from"./display-aTnwsqQh.js";import{t as s}from"./agent-type-icon-BmBR-9CH.js";var c=e(n(),1),l=r(),u={id:o};function d({user:e,address:n,distinct:r=!1,className:o}){let d=e?.avatarUrl??(e?.avatarArtifactId?`/artifacts/${encodeURIComponent(e.avatarArtifactId)}/content`:null),[f,p]=(0,c.useState)(null);(0,c.useEffect)(()=>{if(!d){p(null);return}let e=!1,n=null;return(async()=>{try{let r=await t(d);if(e)return;n=URL.createObjectURL(r),p(n)}catch{e||p(null)}})(),()=>{e=!0,n&&URL.revokeObjectURL(n)}},[d]);let m=e?.displayName||e?.handle||`User`;if(f)return(0,l.jsx)(`img`,{src:f,alt:m,title:m,className:i(`w-7 h-7 rounded-md object-cover`,o)});if(r){let e=(m.trim()[0]||`U`).toUpperCase();return(0,l.jsx)(`span`,{title:m,className:i(`inline-flex w-7 h-7 items-center justify-center rounded-md bg-muted text-xs font-semibold ring-1 ring-foreground/10`,a(n),o),children:e})}return(0,l.jsx)(s,{agent:u,className:o})}export{d as t};
2
- //# sourceMappingURL=user-avatar-qbo-B3dQ.js.map
@@ -1,3 +0,0 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{At as t,Cn as n,En as r,Gt as i,Ht as a,Mt as o,Nt as s,Q as c,R as l,Tn as u,Wn as d,Yn as f,Yt as p,a as m,g as h,gr as g,h as _,ir as v,ln as y,qt as b,rr as x,zt as S}from"./lucide-react-NXHPIMsX.js";import{p as C,t as w}from"./store-D-Frk_EC.js";import{d as T}from"./types-BqeSkWrv.js";import{K as E,d as D}from"./display-aTnwsqQh.js";import{t as O}from"./badge-BCvp7LK3.js";import{t as k}from"./button-DyHjsHY3.js";import{t as ee}from"./copy-button-C67FUG3E.js";import{t as A}from"./task-chip-CeujtXYT.js";import{o as j,r as M,s as N,t as P}from"./card-BoqYxpVW.js";var F=e(g(),1),I=x(),L=new Set([`active`,`ready`,`conflict`,`review_requested`,`merge_planned`,`cleanup_requested`]),R=new Set(T),z=`__all__`,B=`__unassigned__`;function V(e,t){let n=new Map;for(let t of e){let e=t.repoRoot||t.sourceCwd||`unknown repo`;n.set(e,[...n.get(e)||[],t])}return[...n.entries()].map(([e,n])=>({repoRoot:e,workspaces:n.sort(t)})).sort((e,t)=>e.repoRoot.localeCompare(t.repoRoot))}function H(e,t){let n=new Map;for(let t of e){let e=t.projectSlug||t.repoRoot||t.sourceCwd||`unassigned`;n.set(e,[...n.get(e)||[],t])}return[...n.entries()].map(([e,n])=>{let r=n[0],i=!r.projectId;return{key:e,title:i?r.repoRoot||r.sourceCwd||`unknown repo`:r.projectTitle||r.projectSlug||r.repoRoot,...r.projectId?{projectId:r.projectId}:{},...r.projectSlug?{projectSlug:r.projectSlug}:{},unassigned:i,repoGroups:V(n,t)}}).sort((e,t)=>{let n=e.repoGroups.some(e=>e.workspaces.some(e=>L.has(e.status)));return n===t.repoGroups.some(e=>e.workspaces.some(e=>L.has(e.status)))?e.title.localeCompare(t.title):n?-1:1})}function U(e,t,n){let r=t===`all`?e:t===`cleaned`?e.filter(e=>R.has(e.status)):e.filter(e=>!R.has(e.status));return n===`__all__`?r:n===`__unassigned__`?r.filter(e=>!e.projectId):r.filter(e=>e.projectId===n)}function W({group:e,renderWorkspaceRow:t}){let n=e.repoGroups.flatMap(e=>e.workspaces),r=n.filter(e=>L.has(e.status)).length,i=n.filter(e=>e.status===`ready`||e.status===`review_requested`||e.status===`merge_planned`).length,a=n.filter(e=>e.status===`conflict`).length,o=e.repoGroups.length>1;return(0,I.jsxs)(P,{children:[(0,I.jsx)(j,{className:`px-4 py-3`,children:(0,I.jsx)(`div`,{className:`flex min-w-0 items-start gap-3`,children:(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(N,{className:`truncate text-sm font-medium`,title:e.title,children:e.title}),e.unassigned&&(0,I.jsx)(O,{variant:`outline`,className:`text-[10px]`,children:`Unassigned`})]}),(0,I.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:[(0,I.jsxs)(O,{variant:`outline`,className:`text-[10px]`,children:[n.length,` total`]}),(0,I.jsxs)(O,{variant:`outline`,className:`text-[10px]`,children:[r,` live`]}),i>0&&(0,I.jsxs)(O,{variant:`outline`,className:`border-emerald-500/20 text-emerald-400 text-[10px]`,children:[i,` merge signal`]}),a>0&&(0,I.jsxs)(O,{variant:`outline`,className:`border-red-500/20 text-red-400 text-[10px]`,children:[a,` conflict`]})]})]})})}),(0,I.jsx)(M,{className:`p-0`,children:e.repoGroups.map(e=>(0,I.jsxs)(`div`,{className:`border-t border-border first:border-t-0`,children:[o&&(0,I.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-dashed border-border/80 px-3 py-2`,children:[(0,I.jsx)(S,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,I.jsx)(`span`,{className:`truncate font-mono text-[11px] text-muted-foreground`,title:e.repoRoot,children:e.repoRoot})]}),e.workspaces.map(e=>t(e))]},e.repoRoot))})]})}function G(e){let t=e.split(`/`).filter(Boolean);return t.length<=3?e||`-`:`/${t.slice(-3).join(`/`)}`}function K(){let e=w(e=>e.workspaceOrphans),t=w(e=>e.fetchWorkspaceOrphans),n=w(e=>e.reclaimWorkspaceOrphan);return(0,F.useEffect)(()=>{t()},[t]),e.length?(0,I.jsxs)(P,{className:`border-amber-500/30`,children:[(0,I.jsxs)(j,{className:`px-4 py-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(c,{className:`h-4 w-4 text-amber-400`}),(0,I.jsx)(N,{className:`text-sm font-medium`,children:`Orphaned worktrees`}),(0,I.jsx)(O,{variant:`outline`,className:`border-amber-500/30 text-amber-400 text-[10px]`,children:e.length}),(0,I.jsx)(k,{size:`icon-sm`,variant:`ghost`,className:`ml-auto h-6 w-6`,title:`Rescan`,onClick:()=>void t(),children:(0,I.jsx)(l,{className:`h-3.5 w-3.5`})})]}),(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Agent worktrees on disk with no live workspace. Reclaim removes them from the host.`})]}),(0,I.jsx)(M,{className:`p-0`,children:e.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center gap-3 border-t border-border px-4 py-2 text-xs`,children:[(0,I.jsx)(S,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,I.jsx)(`span`,{className:`truncate font-medium`,title:e.branch,children:e.branch||`(detached)`}),(0,I.jsx)(`span`,{className:`truncate font-mono text-muted-foreground`,title:e.worktreePath,children:G(e.worktreePath)}),e.hadTerminalRow&&(0,I.jsx)(O,{variant:`outline`,className:`text-[10px]`,children:`cleanup failed`}),(0,I.jsxs)(k,{size:`sm`,variant:`outline`,className:`ml-auto h-7 text-xs`,onClick:()=>void n(e),children:[(0,I.jsx)(c,{className:`mr-1 h-3.5 w-3.5`}),`Reclaim`]})]},e.worktreePath))})]}):null}function q(e,t,n){if(n){let t=e.find(e=>e.branch&&e.branch===n);if(t)return t}if(!t)return null;let r=e.filter(e=>e.ownerAgentId===t);return r.length===0?null:r.length===1?r[0]:null}var J=new Set([`active`,`ready`,`conflict`,`review_requested`,`merge_planned`]),Y=new Set([`active`,`ready`,`review_requested`,`merge_planned`,`conflict`]),X={active:`bg-blue-500/10 text-blue-400 border-blue-500/20`,ready:`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`,conflict:`bg-red-500/10 text-red-400 border-red-500/20`,review_requested:`bg-yellow-500/10 text-yellow-400 border-yellow-500/20`,merge_planned:`bg-indigo-500/10 text-indigo-400 border-indigo-500/20`,merged:`bg-violet-500/10 text-violet-400 border-violet-500/20`,abandoned:`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`,cleanup_requested:`bg-orange-500/10 text-orange-400 border-orange-500/20`,cleaned:`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`},Z={active:`active`,ready:`ready`,conflict:`conflict`,review_requested:`review`,merge_planned:`merge planned`,merged:`merged`,abandoned:`abandoned`,cleanup_requested:`cleanup`,cleaned:`cleaned`},Q={conflict:0,ready:1,review_requested:2,merge_planned:3,active:4,cleanup_requested:5,merged:6,abandoned:7,cleaned:8};function $(e,t){return e?D(e):t||`-`}function te(e){let t=e.split(`/`).filter(Boolean);return t.length<=3?e||`-`:`/${t.slice(-3).join(`/`)}`}function ne(e){return X[e]||`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`}function re(e,t){let n=(Q[e.status]??99)-(Q[t.status]??99);return n===0?Number(t.updatedAt||0)-Number(e.updatedAt||0):n}function ie({workspace:e,expanded:i,onToggleDetails:o}){let s=w(e=>e.workspaceAction),c=w(e=>e.purgeWorkspace),l=w(e=>e.fetchWorkspaceMergePreview),d=w(e=>e.openFilesAt),f=e.status===`cleaned`||e.status===`merged`||e.status===`abandoned`,g=f||e.status===`cleanup_requested`,_=e.worktreePath||e.sourceCwd||e.repoRoot,v=w(t=>t.workspaceGitState[e.id]),y=!!v&&v.available!==!1&&v.landed===!0,b=e.mode===`isolated`&&!!e.worktreePath&&Y.has(e.status)&&!y;async function x(){await l(e.id),await s(e.id,`merge`)}return(0,I.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-1.5`,children:[(0,I.jsx)(k,{size:`icon-sm`,variant:`ghost`,title:i?`Hide details`:`Show diff & timeline`,onClick:o,children:i?(0,I.jsx)(u,{className:`h-3.5 w-3.5`}):(0,I.jsx)(n,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(k,{size:`icon-sm`,variant:`ghost`,title:`Open workspace`,disabled:!_||e.status===`cleaned`,onClick:()=>void d({path:_}),children:(0,I.jsx)(S,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(ee,{value:_,label:`Copy path`,copiedLabel:`Copied path`,size:`icon-sm`,variant:`ghost`,disabled:!_}),(0,I.jsx)(k,{size:`icon-sm`,variant:`outline`,title:`Mark ready`,disabled:g||e.status===`ready`,onClick:()=>void s(e.id,`ready`),children:(0,I.jsx)(r,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(k,{size:`icon-sm`,variant:`outline`,title:`Request review`,disabled:g||e.status===`review_requested`,onClick:()=>void s(e.id,`request-review`),children:(0,I.jsx)(p,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(k,{size:`icon-sm`,variant:`outline`,title:`Mark merge planned`,disabled:g||e.status===`merge_planned`,onClick:()=>void s(e.id,`merge-plan`),children:(0,I.jsx)(a,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(k,{size:`icon-sm`,variant:`default`,title:y?`Already merged into base — nothing to land`:`Merge & land work`,disabled:!b,onClick:()=>void x(),children:(0,I.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(k,{size:`icon-sm`,variant:`outline`,title:`Request cleanup (removes the worktree on the host)`,disabled:e.status===`cleaned`||e.status===`cleanup_requested`,onClick:()=>void s(e.id,`cleanup`),children:(0,I.jsx)(h,{className:`h-3.5 w-3.5`})}),f&&(0,I.jsx)(k,{size:`icon-sm`,variant:`ghost`,title:`Purge record (clears the row, does not touch disk)`,onClick:()=>void c(e.id),children:(0,I.jsx)(m,{className:`h-3.5 w-3.5`})})]})}function ae({workspace:e,unmerged:t}){let n=w(t=>t.workspaceMergePreview[e.id]),i=w(e=>e.fetchWorkspaceMergePreview),a=t>0&&Y.has(e.status);return(0,F.useEffect)(()=>{a&&n===void 0&&i(e.id)},[a,n,e.id,i]),!a||n===void 0||n.available===!1?null:n.conflict?(0,I.jsxs)(`span`,{className:`flex items-center gap-0.5 text-amber-400`,title:`Merging into ${n.baseRef||`base`} would conflict — resolve before merging`,children:[(0,I.jsx)(_,{className:`h-3 w-3`}),`conflict`]}):n.conflict===!1?(0,I.jsxs)(`span`,{className:`flex items-center gap-0.5 text-emerald-400`,title:`Clean to merge via ${n.strategy===`pr`?`PR`:`rebase + fast-forward`} into ${n.baseRef||`base`}`,children:[(0,I.jsx)(r,{className:`h-3 w-3`}),n.strategy===`pr`?`PR ready`:`clean`]}):null}function oe({workspace:e}){let t=C(),n=w(t=>t.workspaceGitState[e.id]),a=w(e=>e.fetchWorkspaceGitState),s=e.mode===`isolated`&&!!e.worktreePath&&J.has(e.status);if((0,F.useEffect)(()=>{s&&n===void 0&&a(e.id)},[s,n,e.id,a]),!s)return null;let c=(0,I.jsx)(k,{size:`icon-sm`,variant:`ghost`,className:`h-5 w-5`,title:`Refresh git state`,onClick:()=>void a(e.id),children:(0,I.jsx)(l,{className:`h-3 w-3`})});if(n===void 0)return(0,I.jsx)(`div`,{className:`flex items-center gap-1 text-[11px] text-muted-foreground`,children:`Loading git state…`});if(n.available===!1)return(0,I.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-muted-foreground`,title:n.reason,children:[(0,I.jsx)(`span`,{children:`git state unavailable`}),c]});if(n.missing)return(0,I.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-muted-foreground`,children:[`worktree gone `,c]});if(n.error)return(0,I.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-red-400`,title:n.error,children:[(0,I.jsx)(`span`,{children:`git error`}),c]});let u=n.ahead??0,p=n.landed===!0,m=p?0:n.unmergedAhead??u,h=n.behind??0,g=n.dirtyCount??0,_=m===0&&g===0&&!p,v=n.lastCommit;return(0,I.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px]`,children:[_?(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`no unmerged work`}):(0,I.jsxs)(I.Fragment,{children:[p?(0,I.jsxs)(`span`,{className:`flex items-center gap-0.5 text-emerald-400`,title:`Work already landed in ${n.baseRef||`base`} via squash/cherry-pick — safe to clean up`,children:[(0,I.jsx)(r,{className:`h-3 w-3`}),`landed`]}):(0,I.jsxs)(`span`,{className:m>0?`flex items-center text-emerald-400`:`flex items-center text-muted-foreground`,title:u===m?`${m} commit(s) ahead of base`:`${m} unmerged commit(s) (${u} ahead of base)`,children:[(0,I.jsx)(d,{className:`h-3 w-3`}),m]}),(0,I.jsxs)(`span`,{className:h>0?`flex items-center text-amber-400`:`flex items-center text-muted-foreground`,title:`${h} commit(s) behind base`,children:[(0,I.jsx)(f,{className:`h-3 w-3`}),h]}),g>0&&(0,I.jsxs)(`span`,{className:`flex items-center text-orange-400`,title:`${g} uncommitted change(s)`,children:[(0,I.jsx)(i,{className:`h-3 w-3`}),g]}),!p&&(0,I.jsx)(ae,{workspace:e,unmerged:m})]}),c]}),v&&(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1 text-[11px] text-muted-foreground`,title:`${v.sha.slice(0,8)} — ${v.message}`,children:[(0,I.jsx)(o,{className:`h-3 w-3 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate`,children:v.message||v.sha.slice(0,8)}),v.at?(0,I.jsxs)(`span`,{className:`shrink-0 opacity-70`,children:[`· `,E(t,v.at)]}):null]})]})}function se({workspace:e}){let t=C(),n=typeof e.metadata?.mergedAt==`number`?e.metadata.mergedAt:void 0,r=[{label:`created`,at:e.createdAt},{label:`ready`,at:e.readyAt},{label:`merged`,at:n},{label:`cleaned`,at:e.cleanedAt}].filter(e=>typeof e.at==`number`&&e.at>0);return(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground`,children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-1 font-medium text-foreground`,children:[(0,I.jsx)(y,{className:`h-3 w-3`}),`Timeline`]}),r.map((e,n)=>(0,I.jsxs)(`span`,{className:`flex items-center gap-1`,children:[n>0&&(0,I.jsx)(`span`,{className:`opacity-40`,children:`→`}),(0,I.jsx)(`span`,{className:`text-foreground`,children:e.label}),(0,I.jsx)(`span`,{title:new Date(e.at).toLocaleString(),children:E(t,e.at)})]},e.label))]})}function ce(e){return e.startsWith(`+`)&&!e.startsWith(`+++`)?`text-emerald-400`:e.startsWith(`-`)&&!e.startsWith(`---`)?`text-red-400`:e.startsWith(`@@`)?`text-cyan-400`:e.startsWith(`diff `)||e.startsWith(`index `)||e.startsWith(`+++`)||e.startsWith(`---`)?`text-muted-foreground`:``}function le({workspace:e}){let t=w(t=>t.workspaceDiff[e.id]),n=w(e=>e.fetchWorkspaceDiff),r=e.mode===`isolated`&&!!e.worktreePath;if((0,F.useEffect)(()=>{r&&t===void 0&&n(e.id)},[r,t,e.id,n]),!r)return null;if(t===void 0)return(0,I.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:`Loading diff…`});if(t.available===!1)return(0,I.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[`Diff unavailable`,t.reason?`: ${t.reason}`:``]});if(t.missing)return(0,I.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:`Worktree no longer on disk`});if(t.error)return(0,I.jsxs)(`div`,{className:`text-[11px] text-red-400`,children:[`Diff error: `,t.error]});if(!t.files.length)return(0,I.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[`No committed changes against `,t.baseRef||`base`]});let i=(0,I.jsx)(k,{size:`icon-sm`,variant:`ghost`,className:`h-5 w-5`,title:`Refresh diff`,onClick:()=>void n(e.id),children:(0,I.jsx)(l,{className:`h-3 w-3`})});return(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-medium`,children:[(0,I.jsx)(b,{className:`h-3 w-3`}),(0,I.jsxs)(`span`,{children:[t.files.length,` file`,t.files.length===1?``:`s`,` vs `,t.baseRef||`base`]}),i]}),(0,I.jsx)(`ul`,{className:`space-y-0.5 text-[11px]`,children:t.files.map(e=>(0,I.jsxs)(`li`,{className:`flex items-center gap-2 font-mono`,children:[(0,I.jsx)(`span`,{className:`truncate`,title:e.path,children:e.path}),e.binary?(0,I.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`binary`}):(0,I.jsxs)(`span`,{className:`shrink-0`,children:[(0,I.jsxs)(`span`,{className:`text-emerald-400`,children:[`+`,e.additions??0]}),` `,(0,I.jsxs)(`span`,{className:`text-red-400`,children:[`−`,e.deletions??0]})]})]},e.path))}),t.patch&&(0,I.jsxs)(`pre`,{className:`max-h-80 overflow-auto rounded border border-border bg-muted/30 p-2 text-[10.5px] leading-relaxed`,children:[t.patch.split(`
2
- `).map((e,t)=>(0,I.jsx)(`div`,{className:ce(e),children:e||` `},t)),t.truncated&&(0,I.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:`… patch truncated`})]})]})}function ue({workspace:e}){return(0,I.jsxs)(`div`,{className:`space-y-3 border-t border-dashed border-border bg-muted/20 px-3 py-3`,children:[(0,I.jsx)(se,{workspace:e}),(0,I.jsx)(le,{workspace:e})]})}function de(e){let t=e.match(/\/pull\/(\d+)/);return t?`PR #${t[1]}`:`View PR`}function fe({workspace:e}){let n=e.metadata?.mergeResult,r=n?.prUrl,i=n?.error||e.metadata?.mergeError;return!r&&!i?null:(0,I.jsxs)(I.Fragment,{children:[r&&(0,I.jsxs)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,title:r,className:`inline-flex items-center gap-0.5 rounded border border-violet-500/30 px-1.5 py-0 text-[10px] text-violet-400 hover:text-violet-300`,children:[(0,I.jsx)(t,{className:`h-2.5 w-2.5`}),de(r)]}),i&&(0,I.jsxs)(O,{variant:`outline`,className:`max-w-[16rem] border-amber-500/30 text-amber-400 text-[10px]`,title:i,children:[(0,I.jsx)(_,{className:`mr-0.5 h-2.5 w-2.5 shrink-0`}),(0,I.jsxs)(`span`,{className:`truncate`,children:[`merge: `,i]})]})]})}function pe({workspace:e}){let t=C(),[n,r]=(0,F.useState)(!1),i=w(e=>e.agentsById),a=w(t=>t.workspaceFocusId===e.id),o=w(e=>e.deliverableTasks),c=w(e=>e.openTaskDetail),l=e.ownerAgentId?i[e.ownerAgentId]:void 0,u=q(o,e.ownerAgentId,e.branch),d=w(t=>t.workspaceGitState[e.id]),f=!!d&&d.available!==!1&&d.landed===!0,p=u!=null&&(e.status===`merged`||e.status===`cleaned`||e.status===`abandoned`||f),m=e.stewardAgentId?i[e.stewardAgentId]:void 0,h=e.worktreePath||e.sourceCwd||e.repoRoot,g=(0,F.useRef)(null);return(0,F.useEffect)(()=>{a&&g.current?.scrollIntoView({behavior:`smooth`,block:`center`})},[a]),(0,I.jsxs)(`div`,{ref:g,className:`border-t border-border ${a?`bg-primary/5 ring-1 ring-inset ring-primary/40`:``}`,children:[(0,I.jsxs)(`div`,{className:`grid gap-3 px-3 py-3 text-sm lg:grid-cols-[minmax(180px,1.2fr)_minmax(220px,1.5fr)_minmax(160px,1fr)_minmax(170px,auto)]`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(s,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,I.jsx)(`span`,{className:`truncate font-medium`,title:e.branch||e.id,children:e.branch||e.id})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,I.jsx)(O,{variant:`outline`,className:`text-[10px] ${e.mode===`isolated`?`border-sky-500/30 text-sky-400`:`border-zinc-500/30 text-zinc-400`}`,children:e.mode}),e.requestedMode&&e.requestedMode!==e.mode&&(0,I.jsxs)(O,{variant:`outline`,className:`text-[10px]`,children:[`requested `,e.requestedMode]}),(0,I.jsx)(O,{variant:`outline`,className:`text-[10px] ${ne(e.status)}`,children:Z[e.status]||e.status}),(0,I.jsx)(fe,{workspace:e}),p&&u&&(0,I.jsx)(A,{id:u.id,title:u.title,status:u.status,onClick:()=>c(u)})]})]}),(0,I.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,I.jsx)(`div`,{className:`truncate font-mono text-xs`,title:h,children:te(h)}),(0,I.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,title:e.sourceCwd,children:e.sourceCwd}),(0,I.jsx)(oe,{workspace:e})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-[4.5rem_minmax(0,1fr)] gap-x-2 gap-y-1 text-xs`,children:[(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`Owner`}),(0,I.jsx)(`span`,{className:`truncate`,title:e.ownerAgentId,children:$(l,e.ownerPolicyName||e.ownerAgentId)}),(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`Steward`}),(0,I.jsx)(`span`,{className:`truncate`,title:e.stewardAgentId,children:$(m,e.stewardAgentId)}),(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`Updated`}),(0,I.jsx)(`span`,{children:E(t,e.updatedAt)}),e.baseRef&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`Base`}),(0,I.jsx)(`span`,{className:`truncate`,title:e.baseSha,children:e.baseRef})]})]}),(0,I.jsx)(ie,{workspace:e,expanded:n,onToggleDetails:()=>r(e=>!e)})]}),n&&(0,I.jsx)(ue,{workspace:e})]})}function me(){let[e,t]=(0,F.useState)(`active`),[n,r]=(0,F.useState)(z),[i,a]=(0,F.useState)([]),o=w(e=>e.workspaces),s=w(e=>e.set),c=w(e=>e.workspaceFocusId);(0,F.useEffect)(()=>{c&&(t(`all`),r(z))},[c]),(0,F.useEffect)(()=>()=>{s({workspaceFocusId:null})},[s]),(0,F.useEffect)(()=>{let e=!1;return v(`GET`,`/projects`).then(t=>{e||a(t.projects??[])}).catch(()=>{e||a([])}),()=>{e=!0}},[]);let l=(0,F.useMemo)(()=>U(o,e,n),[o,e,n]),u=(0,F.useMemo)(()=>H(l,re),[l]),d=o.filter(e=>L.has(e.status)).length,f=o.filter(e=>e.mode===`isolated`).length,p=o.filter(e=>e.status===`ready`||e.status===`review_requested`||e.status===`merge_planned`).length,m=o.filter(e=>e.status===`conflict`).length,h=o.filter(e=>e.status===`merged`||e.status===`abandoned`||e.status===`cleaned`).length,g=[{key:`active`,label:`Active`,count:o.length-h},{key:`cleaned`,label:`Done`,count:h},{key:`all`,label:`All`,count:o.length}],_=(0,F.useMemo)(()=>{let e=[{value:z,label:`All Projects`}];for(let t of i)e.push({value:t.id,label:t.title||t.slug});return e.push({value:B,label:`Unassigned`}),e},[i]);return(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Workspaces`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Agent worktrees, ownership, and merge readiness.`})]}),(0,I.jsxs)(`div`,{className:`ml-auto flex flex-wrap gap-1.5`,children:[(0,I.jsxs)(O,{variant:`outline`,children:[f,` isolated`]}),(0,I.jsxs)(O,{variant:`outline`,children:[d,` live`]}),(0,I.jsxs)(O,{variant:`outline`,children:[p,` ready`]}),m>0&&(0,I.jsxs)(O,{variant:`outline`,className:`border-red-500/20 text-red-400`,children:[m,` conflict`]})]})]}),(0,I.jsx)(K,{}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(`div`,{className:`flex rounded-md border border-border bg-card p-1`,children:g.map(n=>(0,I.jsxs)(k,{size:`sm`,variant:e===n.key?`secondary`:`ghost`,className:`h-7 text-xs`,onClick:()=>t(n.key),children:[n.label,(0,I.jsx)(`span`,{className:`ml-1 text-muted-foreground`,children:n.count})]},n.key))}),(0,I.jsx)(`select`,{className:`h-8 min-w-[12rem] rounded-md border border-border bg-card px-2.5 text-sm text-foreground`,value:n,onChange:e=>r(e.target.value),children:_.map(e=>(0,I.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),u.length===0?(0,I.jsxs)(`div`,{className:`rounded-md border border-border px-3 py-12 text-center text-sm text-muted-foreground`,children:[`No `,e===`all`?``:e,` workspaces`,n===`__all__`?``:` in this project filter`]}):(0,I.jsx)(`div`,{className:`space-y-3`,children:u.map(e=>(0,I.jsx)(W,{group:e,renderWorkspaceRow:e=>(0,I.jsx)(pe,{workspace:e},e.id)},e.key))})]})}export{me as WorkspacesView};
3
- //# sourceMappingURL=workspaces-CoDz-iZd.js.map