bazilion 0.55.0 → 0.56.0

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 (191) hide show
  1. package/dist/cli.js +192 -37
  2. package/dist/cli.js.map +1 -1
  3. package/dist/daemon.js +1164 -412
  4. package/dist/daemon.js.map +1 -1
  5. package/dist/web/client/assets/AddProviderDialog-DZ9mXFdq.js +1 -0
  6. package/dist/web/client/assets/AgentTemplateParts-BfG3a-ri.js +1 -0
  7. package/dist/web/client/assets/{Button-bTJUy9Qf.js → Button-CoKQRO-s.js} +1 -1
  8. package/dist/web/client/assets/ConfigPage-Ch-DSJUO.js +1 -0
  9. package/dist/web/client/assets/ConfirmDialog-B_jXAPmh.js +1 -0
  10. package/dist/web/client/assets/ConnectionsView-D1Liebtf.js +1 -0
  11. package/dist/web/client/assets/ManagePage-kd7iWYEL.js +1 -0
  12. package/dist/web/client/assets/{SectionTabs-D7kPQGoh.js → SectionTabs-Dc0bNn-J.js} +1 -1
  13. package/dist/web/client/assets/{Segmented-oPkAHPO1.js → Segmented-iylzLwE6.js} +1 -1
  14. package/dist/web/client/assets/SkillsParts-C5T7sYDA.js +1 -0
  15. package/dist/web/client/assets/SpawnTeamModal-DatFF4f_.js +1 -0
  16. package/dist/web/client/assets/TeamForm-l-N_PYeE.js +1 -0
  17. package/dist/web/client/assets/TeamThread-BWmIQiAh.js +1 -0
  18. package/dist/web/client/assets/UnsavedChangesGuard-vQBdMl8h.js +1 -0
  19. package/dist/web/client/assets/_id-C6SADaiD.js +1 -0
  20. package/dist/web/client/assets/_id-CC9r0qsr.js +1 -0
  21. package/dist/web/client/assets/access-BbQFbTPh.js +1 -0
  22. package/dist/web/client/assets/{agent-actions-CUee6aJq.js → agent-actions-B-9KIwn6.js} +1 -1
  23. package/dist/web/client/assets/agents-BXwzmHu8.js +1 -0
  24. package/dist/web/client/assets/agents-BtETzVIY.js +1 -0
  25. package/dist/web/client/assets/arrow-right-BqqfPqVi.js +1 -0
  26. package/dist/web/client/assets/attention-BMrZJ9ui.js +1 -0
  27. package/dist/web/client/assets/{bot-BCone8es.js → bot-BHky7KAX.js} +1 -1
  28. package/dist/web/client/assets/chart-column-DTsDbzL0.js +1 -0
  29. package/dist/web/client/assets/chevron-right-D1shxvdo.js +1 -0
  30. package/dist/web/client/assets/config-B2ZDYo52.js +1 -0
  31. package/dist/web/client/assets/{createLucideIcon-jxSFpY0Q.js → createLucideIcon-CZHSSDYA.js} +1 -1
  32. package/dist/web/client/assets/{download-Dy88XavQ.js → download-Dr0PgyMr.js} +1 -1
  33. package/dist/web/client/assets/es2015-D1pnOGPG.js +41 -0
  34. package/dist/web/client/assets/{file-text-DPsZ8-h9.js → file-text-D6OTHixJ.js} +1 -1
  35. package/dist/web/client/assets/{images-QBh_rL8b.js → images-BULrW-FC.js} +1 -1
  36. package/dist/web/client/assets/index-B-N6NIX4.js +14 -0
  37. package/dist/web/client/assets/{key-round-C-I8fAG0.js → key-round-DmSZN0Kq.js} +1 -1
  38. package/dist/web/client/assets/{list-checks-C9Q-bjEi.js → list-checks-DdTdAQXS.js} +1 -1
  39. package/dist/web/client/assets/login-DM3q-V4R.js +1 -0
  40. package/dist/web/client/assets/{manage-BaIU5zKy.js → manage-R57MUzsY.js} +1 -1
  41. package/dist/web/client/assets/mcp-CSHrVH1t.js +1 -0
  42. package/dist/web/client/assets/{message-square-Bwf9cHOx.js → message-square-B_pULba_.js} +1 -1
  43. package/dist/web/client/assets/{network-B3FA93gC.js → network-BqmVqC4_.js} +1 -1
  44. package/dist/web/client/assets/parts-68zf8Fgw.js +1 -0
  45. package/dist/web/client/assets/plus-CEKaHPBw.js +1 -0
  46. package/dist/web/client/assets/preload-helper-CZOd_z6l.js +1 -0
  47. package/dist/web/client/assets/routes-DOoeKVwr.js +85 -0
  48. package/dist/web/client/assets/skills-CPZftp9O.js +1 -0
  49. package/dist/web/client/assets/{square-terminal-DaNLwvEs.js → square-terminal-CYfGBHPC.js} +1 -1
  50. package/dist/web/client/assets/style-Bm9QsFpy.js +7 -0
  51. package/dist/web/client/assets/styles-B-kTTvCo.css +2 -0
  52. package/dist/web/client/assets/{system-CrTSr5_t.js → system-Dd2P9eqE.js} +1 -1
  53. package/dist/web/client/assets/teams-7FEpSZg1.js +1 -0
  54. package/dist/web/client/assets/teams-ClirFbDV.js +1 -0
  55. package/dist/web/client/assets/telegram-BJnT5THs.js +1 -0
  56. package/dist/web/client/assets/tools-DqNXLMpc.js +1 -0
  57. package/dist/web/client/assets/usage-BC_TStVj.js +1 -0
  58. package/dist/web/client/assets/use-resource-Bn0Sx7r6.js +1 -0
  59. package/dist/web/client/assets/{users-round-BElBVSnw.js → users-round-cxQ5HF-C.js} +1 -1
  60. package/dist/web/client/assets/welcome-g8wtn_or.js +1 -0
  61. package/dist/web/client/assets/{wrench-DotqSqSm.js → wrench-BLEJjETg.js} +1 -1
  62. package/dist/web/server/assets/{AddProviderDialog-BbpuvC2a.js → AddProviderDialog-DtkjBMv4.js} +5 -2
  63. package/dist/web/server/assets/AgentAvatar-8gTAy_tP.js +37 -0
  64. package/dist/web/server/assets/{AgentTemplateParts-Ce7snK3m.js → AgentTemplateParts-CxWyovvM.js} +6 -2
  65. package/dist/web/server/assets/Button-Dsnw22OF.js +17 -0
  66. package/dist/web/server/assets/{ConfigPage-qP9ejjuw.js → ConfigPage-usZi48Zr.js} +2 -2
  67. package/dist/web/server/assets/{ConfirmDialog-Z-uYbE9B.js → ConfirmDialog-DAcSBHkT.js} +3 -1
  68. package/dist/web/server/assets/{ConnectionsView-CLIV7V5D.js → ConnectionsView-Dy6uYSRI.js} +9 -7
  69. package/dist/web/server/assets/Dialog-DTeF-nOZ.js +85 -0
  70. package/dist/web/server/assets/{ManagePage-BR9FwVZM.js → ManagePage-Dy1EdovO.js} +2 -2
  71. package/dist/web/server/assets/{SectionTabs-CWQ5orUW.js → SectionTabs-BVrMn76H.js} +2 -1
  72. package/dist/web/server/assets/{SkillsParts-DWpdydCJ.js → SkillsParts-Cw05b3al.js} +6 -2
  73. package/dist/web/server/assets/SpawnDialog-BAE8W91z.js +125 -0
  74. package/dist/web/server/assets/{SpawnTeamModal-C-YMvoaB.js → SpawnTeamModal-CgBY0HuN.js} +6 -2
  75. package/dist/web/server/assets/{TeamForm-CL45gBdt.js → TeamForm-JyO5xJXX.js} +6 -2
  76. package/dist/web/server/assets/{TeamThread-CVVH6kKj.js → TeamThread-5o48EbXL.js} +52 -4
  77. package/dist/web/server/assets/{UnsavedChangesGuard-CXK75QQp.js → UnsavedChangesGuard-CJQGu45L.js} +1 -1
  78. package/dist/web/server/assets/{_id-8zsImuGa.js → _id-BE_RSvuN.js} +14 -9
  79. package/dist/web/server/assets/{_id-d2OwovYV.js → _id-BNvm89oJ.js} +2 -2
  80. package/dist/web/server/assets/{_id-De3Bm0SG.js → _id-BW6sVrvw.js} +1 -1
  81. package/dist/web/server/assets/{_id-2I4CSMQj.js → _id-BfjTS4JO.js} +15 -9
  82. package/dist/web/server/assets/{_id-BKzOw78O.js → _id-BpumuCYL.js} +1 -1
  83. package/dist/web/server/assets/{_id-BpfoPuTv.js → _id-C54t_nX6.js} +2 -2
  84. package/dist/web/server/assets/_tanstack-start-manifest_v-BPwQX_5b.js +275 -0
  85. package/dist/web/server/assets/{access-CwZ27Wsl.js → access-6FWih7nC.js} +7 -4
  86. package/dist/web/server/assets/{access-WWspT0v4.js → access-BhAMfi7U.js} +1 -1
  87. package/dist/web/server/assets/{access-CyUoElTP.js → access-DEyq3uP_.js} +2 -2
  88. package/dist/web/server/assets/activity-Czfq-5_F.js +471 -0
  89. package/dist/web/server/assets/{agent-actions-C07Cp5Ue.js → agent-actions-ChH7Mne4.js} +1 -1
  90. package/dist/web/server/assets/{agents-CRtMfKqX.js → agents-3hBjrd8B.js} +1 -1
  91. package/dist/web/server/assets/{agents-vuXrAv1j.js → agents-BXuglv4G.js} +12 -6
  92. package/dist/web/server/assets/{agents-DTub-rJk.js → agents-DhenbitX.js} +2 -2
  93. package/dist/web/server/assets/{agents-CwzhpDPm.js → agents-KJcDMj0Y.js} +9 -6
  94. package/dist/web/server/assets/{agents-DCWEoaxY.js → agents-ncyhVx-T.js} +2 -2
  95. package/dist/web/server/assets/{agents-DQowl6Ly.js → agents-rTDlRZa5.js} +1 -1
  96. package/dist/web/server/assets/{attention-BqCnJ1hg.js → attention-CDdOCOio.js} +2 -2
  97. package/dist/web/server/assets/{attention-DwGaur_w.js → attention-DM__BzWY.js} +8 -6
  98. package/dist/web/server/assets/{attention-Dki8rmGZ.js → attention-X0U6ZmiA.js} +1 -1
  99. package/dist/web/server/assets/{auth-dJnrFW6y.js → auth-BexhV8Yq.js} +1 -1
  100. package/dist/web/server/assets/{config-B9dJiji_.js → config-Cld8Q8N7.js} +2 -2
  101. package/dist/web/server/assets/{config-X7qWbbpH.js → config-Cx5ri2DL2.js} +1 -1
  102. package/dist/web/server/assets/{config-D3MR2VjE.js → config-DpgYAXQ3.js} +9 -6
  103. package/dist/web/server/assets/createSsrRpc-6LHNEsSK.js +16 -0
  104. package/dist/web/server/assets/{daemon-client-B_ZRIIrT.js → daemon-client-RxAllljf.js} +1 -1
  105. package/dist/web/server/assets/form-BEjeiSy3.js +416 -0
  106. package/dist/web/server/assets/live-DbJeq6KP.js +263 -0
  107. package/dist/web/server/assets/{login-CRd1yTH5.js → login-BJdJ219n.js} +1 -1
  108. package/dist/web/server/assets/{login-ZN6KV8n-.js → login-C4lL4AxI.js} +2 -2
  109. package/dist/web/server/assets/{manage-Ce6cI4eW.js → manage-C6ucNYZW.js} +2 -1
  110. package/dist/web/server/assets/{mcp-BQ15a9dG.js → mcp-BXnWQOwM.js} +7 -4
  111. package/dist/web/server/assets/{mcp-C97uAZe1.js → mcp-C8VLspco.js} +1 -1
  112. package/dist/web/server/assets/{mcp-CYQuYWGX.js → mcp-DwCzj7eO.js} +2 -2
  113. package/dist/web/server/assets/open-groups-BMGYUTtY.js +12 -0
  114. package/dist/web/server/assets/{page-title-CVY-c2Pd.js → page-title-PTpFHXWo.js} +1 -1
  115. package/dist/web/server/assets/parts-k9M-atPa.js +436 -0
  116. package/dist/web/server/assets/{router-CPdWGKQ5.js → router-BttfLktO.js} +185 -77
  117. package/dist/web/server/assets/{routes-BPloBDc8.js → routes-A7UcreVX.js} +3 -3
  118. package/dist/web/server/assets/{routes-Dw1K3TQw.js → routes-B9jw-MJ8.js} +1175 -321
  119. package/dist/web/server/assets/{routes-xDPesCQu.js → routes-BX2FV8rS.js} +3 -3
  120. package/dist/web/server/assets/{skills-D0xrNc2_.js → skills-BVAH93cd.js} +8 -6
  121. package/dist/web/server/assets/{skills-DWzlT_hC.js → skills-Cd5Cfdaz.js} +1 -1
  122. package/dist/web/server/assets/{skills-6VSpEORe.js → skills-y3GsyKce.js} +2 -2
  123. package/dist/web/server/assets/src-vrZVrV9u.js +103 -0
  124. package/dist/web/server/assets/{start-DhW7sy23.js → start-Dl8gQ-95.js} +1 -1
  125. package/dist/web/server/assets/{style-aMybyKzc.js → style-BQ3H9I7Y.js} +1 -1
  126. package/dist/web/server/assets/{system-B5sPgdQW.js → system-BJPKqM6b.js} +2 -2
  127. package/dist/web/server/assets/{system-CXmiWyDG.js → system-C7mejQSc.js} +3 -3
  128. package/dist/web/server/assets/{system-D3th6n2E.js → system-LsLcuVzY.js} +1 -1
  129. package/dist/web/server/assets/{teams-yF3I_Zjq.js → teams-B6gbflsZ.js} +10 -6
  130. package/dist/web/server/assets/{teams-iXiCnN2i.js → teams-C7kXMNgc.js} +10 -6
  131. package/dist/web/server/assets/{teams-BopOP4x7.js → teams-CPXoTggb.js} +1 -1
  132. package/dist/web/server/assets/{teams-70u1XQTr.js → teams-CeLLd2Mf.js} +1 -1
  133. package/dist/web/server/assets/{teams-ClRBVSYU.js → teams-CiX8LUQo.js} +2 -2
  134. package/dist/web/server/assets/{teams-Dq4RCxis.js → teams-D-XdIkCr.js} +2 -2
  135. package/dist/web/server/assets/{telegram-CGol0CKX2.js → telegram-D7TW3LNZ.js} +1 -1
  136. package/dist/web/server/assets/{telegram-DwEgyR1x.js → telegram-D8_V7_sW.js} +286 -272
  137. package/dist/web/server/assets/{telegram-D9U9c1MN.js → telegram-DA2dwLID.js} +2 -2
  138. package/dist/web/server/assets/{tools-VPIKjr3y.js → tools-CckcG9Jl.js} +5 -3
  139. package/dist/web/server/assets/{tools-DflVIdDd.js → tools-CluiJywK.js} +2 -2
  140. package/dist/web/server/assets/{tools-C-wwWjLI.js → tools-D1BBVkRh.js} +1 -1
  141. package/dist/web/server/assets/usage-CrYyvPgf.js +46 -0
  142. package/dist/web/server/assets/usage-PNNb3pPj.js +465 -0
  143. package/dist/web/server/assets/{use-resource-CbHGYti0.js → use-resource-BUA9qGGY.js} +1 -1
  144. package/dist/web/server/assets/{welcome-CxXMI4HI.js → welcome-CUTYf8UG.js} +1 -1
  145. package/dist/web/server/assets/{welcome-966nOyyK.js → welcome-CYhh3iUU.js} +8 -6
  146. package/dist/web/server/assets/{welcome-7DrYZVs6.js → welcome-CwzLt6Rp.js} +2 -2
  147. package/dist/web/server/assets/workspace-0XPILV1W.js +82 -0
  148. package/dist/web/server/server.js +20 -20
  149. package/dist/worker.js +27 -6
  150. package/dist/worker.js.map +1 -1
  151. package/package.json +1 -1
  152. package/dist/web/client/assets/AddProviderDialog-DfFOaCjC.js +0 -1
  153. package/dist/web/client/assets/AgentTemplateParts-IMJmAQjN.js +0 -1
  154. package/dist/web/client/assets/ConfigPage-CzLHZa5o.js +0 -1
  155. package/dist/web/client/assets/ConfirmDialog-Cu_evkgc.js +0 -1
  156. package/dist/web/client/assets/ConnectionsView-D7Fmutl2.js +0 -1
  157. package/dist/web/client/assets/ManagePage-BfvlCrmz.js +0 -1
  158. package/dist/web/client/assets/SkillsParts-BuTxcCam.js +0 -1
  159. package/dist/web/client/assets/SpawnTeamModal-B1UnOvtp.js +0 -1
  160. package/dist/web/client/assets/TeamForm-DbzxtRjj.js +0 -1
  161. package/dist/web/client/assets/TeamThread-jpsWq6vI.js +0 -1
  162. package/dist/web/client/assets/UnsavedChangesGuard-BfyU9v9i.js +0 -1
  163. package/dist/web/client/assets/_id-BCNBLF-2.js +0 -1
  164. package/dist/web/client/assets/_id-D8_H79U2.js +0 -1
  165. package/dist/web/client/assets/access-CDWe1Kwy.js +0 -1
  166. package/dist/web/client/assets/agents-sE686DTf.js +0 -1
  167. package/dist/web/client/assets/agents-yrur1NDa.js +0 -1
  168. package/dist/web/client/assets/arrow-right-U66krZnr.js +0 -1
  169. package/dist/web/client/assets/attention-DYEHDfmx.js +0 -1
  170. package/dist/web/client/assets/chevron-right-CuqJFXTe.js +0 -1
  171. package/dist/web/client/assets/config-BHv886pr.js +0 -1
  172. package/dist/web/client/assets/index-GOthyyE-.js +0 -14
  173. package/dist/web/client/assets/login-Dhe15Uuc.js +0 -1
  174. package/dist/web/client/assets/mcp-A_Eo7x3q.js +0 -1
  175. package/dist/web/client/assets/parts-CpIfn_BH.js +0 -41
  176. package/dist/web/client/assets/plus-CQPjc8uR.js +0 -1
  177. package/dist/web/client/assets/routes-CTg_yjbY.js +0 -85
  178. package/dist/web/client/assets/skills-CLjtYtkA.js +0 -1
  179. package/dist/web/client/assets/style-mjEbxhf5.js +0 -7
  180. package/dist/web/client/assets/styles-DzcEC3Rd.css +0 -2
  181. package/dist/web/client/assets/teams-Bhje5n2h.js +0 -1
  182. package/dist/web/client/assets/teams-Cbgw0Qhv.js +0 -1
  183. package/dist/web/client/assets/telegram-HtUczmaA.js +0 -1
  184. package/dist/web/client/assets/tools-BpjFvmoX.js +0 -1
  185. package/dist/web/client/assets/use-resource-BnvgCpBi.js +0 -1
  186. package/dist/web/client/assets/welcome-D47LKWYO.js +0 -1
  187. package/dist/web/server/assets/Rail-b6EbjBB-.js +0 -605
  188. package/dist/web/server/assets/SpawnDialog-3wNx0W1R.js +0 -1851
  189. package/dist/web/server/assets/_tanstack-start-manifest_v-kkY_s_uR.js +0 -256
  190. package/dist/web/server/assets/createSsrRpc-qesavJv-.js +0 -72
  191. package/dist/web/server/assets/public-origin-BpDkdS5Q.js +0 -34
@@ -1,22 +1,31 @@
1
- import { A as RowMenu, B as isTeamSection, E as Facts, G as DialogActions, K as Button, L as PANEL_LABELS, M as SetupCard, N as Switch, O as ListRow, Q as ActivityProvider, R as PANEL_TABS, T as Fact, U as writePanelCookie, W as Dialog$1, Z as REASONING_LEVELS, _ as CardEmpty, at as lineChange, c as SelectField, d as TextAreaField, dt as api, et as shortTime, f as TextField, ft as apiFetch, g as CardBody, h as CARD_ROW, i as FilterSelect, it as describeStep, j as SearchField, k as Notice, l as SelectMenu, lt as useLive, nt as useActivity, o as SaveBar, ot as parseArgs, p as saveStatus, pt as errorMessage, q as AgentAvatar, r as ChoiceCards, rt as useActivityOptional, st as summarizeSteps, t as SpawnDialog, tt as teamSummary, u as SwitchRow, ut as ApiError, v as CardForm, w as Chip, x as CardToolbar, y as CardList, z as isAgentSection } from "./SpawnDialog-3wNx0W1R.js";
2
- import { n as useMediaQuery, r as useResource, t as useHydrated } from "./use-resource-CbHGYti0.js";
1
+ import { a as apiFetch, i as api, n as useLive, o as errorMessage, r as ApiError } from "./live-DbJeq6KP.js";
2
+ import { a as useActivity, c as lineChange, i as teamSummary, l as parseArgs, o as useActivityOptional, r as shortTime, s as describeStep, t as ActivityProvider, u as summarizeSteps } from "./activity-Czfq-5_F.js";
3
+ import { c as DEFAULT_TEAM_ID, i as isTextPreview, r as usageSummary, s as DEFAULT_PROFILE_ID, u as REASONING_LEVELS } from "./src-vrZVrV9u.js";
4
+ import { n as useMediaQuery, r as useResource, t as useHydrated } from "./use-resource-BUA9qGGY.js";
5
+ import { t as AgentAvatar } from "./AgentAvatar-8gTAy_tP.js";
6
+ import { t as Button } from "./Button-Dsnw22OF.js";
3
7
  import { l as modelName, n as ModelMenu, p as cn, t as MODELS_PATH } from "./ModelMenu-D-hTgYOO.js";
4
- import { t as ConfirmDialog } from "./ConfirmDialog-Z-uYbE9B.js";
8
+ import { n as DialogActions, t as Dialog$1 } from "./Dialog-DTeF-nOZ.js";
9
+ import { t as ConfirmDialog } from "./ConfirmDialog-DAcSBHkT.js";
5
10
  import { t as Segmented } from "./Segmented-3ZLdqa5U.js";
6
- import { t as UnsavedChangesGuard } from "./UnsavedChangesGuard-CXK75QQp.js";
7
- import { a as STATE_TEXT, c as useWorkspace, i as STATE_DOT, l as useWorkspaceOptional, n as RenameAgentDialog, o as SlimRail, s as WorkspaceProvider, t as Rail } from "./Rail-b6EbjBB-.js";
8
- import { a as trafficByPair, i as pairKey, n as useTeamMessages, o as FocusFrame, r as messageText, t as TeamThread } from "./TeamThread-CVVH6kKj.js";
9
- import { i as unarchiveAgent, n as deleteAgent, t as archiveAgent } from "./agent-actions-C07Cp5Ue.js";
10
- import { S as slugify, _ as skillState, x as slugProblem } from "./manage-Ce6cI4eW.js";
11
- import { t as SpawnTeamModal } from "./SpawnTeamModal-C-YMvoaB.js";
12
- import { i as useAttentionCount, n as usePageTitle } from "./page-title-CVY-c2Pd.js";
13
- import { i as StatusBadge } from "./createSsrRpc-qesavJv-.js";
14
- import { a as neighbour, i as isTyping, n as NEW_CONVERSATION_EVENT, t as Route } from "./routes-BPloBDc8.js";
15
- import { n as FindingsNotice, t as FindingLines } from "./SkillsParts-DWpdydCJ.js";
11
+ import { t as UnsavedChangesGuard } from "./UnsavedChangesGuard-CJQGu45L.js";
12
+ import { a as trafficByPair, c as FocusFrame, d as useWorkspaceOptional, i as pairKey, l as WorkspaceProvider, n as useTeamMessages, o as STATE_DOT, r as messageText, s as STATE_TEXT, t as TeamThread, u as useWorkspace } from "./TeamThread-5o48EbXL.js";
13
+ import { a as isAgentSection, i as PANEL_TABS, l as writePanelCookie, o as isTeamSection, r as PANEL_LABELS } from "./workspace-0XPILV1W.js";
14
+ import { i as useAttentionCount, n as usePageTitle } from "./page-title-PTpFHXWo.js";
15
+ import { _ as RowMenu, a as CardForm, b as Switch, c as CardToolbar, d as Chip, f as Fact, g as Notice, h as ListRow, i as CardEmpty, n as CARD_ROW, o as CardList, p as Facts, r as CardBody, v as SearchField, w as StatusBadge, y as SetupCard } from "./parts-k9M-atPa.js";
16
+ import { a as neighbour, i as isTyping, n as NEW_CONVERSATION_EVENT, t as Route } from "./routes-A7UcreVX.js";
17
+ import { a as SaveBar, c as SelectMenu, d as TextField, f as saveStatus, l as SwitchRow, n as ChoiceCards, r as FilterSelect, s as SelectField, u as TextAreaField } from "./form-BEjeiSy3.js";
18
+ import { t as SpawnDialog } from "./SpawnDialog-BAE8W91z.js";
19
+ import { i as unarchiveAgent, n as deleteAgent, r as renameAgent, t as archiveAgent } from "./agent-actions-ChH7Mne4.js";
20
+ import { S as slugify, _ as skillState, x as slugProblem } from "./manage-C6ucNYZW.js";
21
+ import { t as SpawnTeamModal } from "./SpawnTeamModal-CgBY0HuN.js";
22
+ import { t as TeamForm } from "./TeamForm-JyO5xJXX.js";
23
+ import { n as isGroupOpen, r as writeOpenGroupsCookie } from "./open-groups-BMGYUTtY.js";
24
+ import { n as FindingsNotice, t as FindingLines } from "./SkillsParts-Cw05b3al.js";
16
25
  import { Fragment, Suspense, createContext, lazy, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
17
- import { Link, useRouter } from "@tanstack/react-router";
26
+ import { Link, useNavigate, useRouter } from "@tanstack/react-router";
18
27
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
19
- import { ArrowLeft, ArrowLeftRight, ArrowRight, BellRing, BookOpen, BookOpenCheck, CalendarClock, Check, ChevronDown, ChevronRight, CircleHelp, Code2, Columns2, Download, FileText, FolderOpen, GitBranch, Globe, History, Image, Images, Inbox, LayoutTemplate, Lightbulb, ListChecks, MessageSquare, MessageSquarePlus, MessagesSquare, Network, NotebookText, OctagonX, PanelRight, Paperclip, Pencil, PencilLine, Plus, RefreshCw, Search, Send, Settings2, Sparkles, StickyNote, Terminal, Trash2, UserRound, Wrench, X } from "lucide-react";
28
+ import { Archive, ArrowLeft, ArrowLeftRight, ArrowRight, BarChart3, BellRing, BookOpen, BookOpenCheck, Bot, CalendarClock, Check, ChevronDown, ChevronRight, CircleHelp, Code2, Columns2, Download, Ellipsis, FileText, FolderOpen, GitBranch, Globe, History, Image, Images, Inbox, LayoutTemplate, Lightbulb, ListChecks, MessageSquare, MessageSquarePlus, MessagesSquare, Network, NotebookText, OctagonX, PanelLeft, PanelRight, Paperclip, Pencil, PencilLine, Plus, RefreshCw, Search, Send, Settings2, Sparkles, StickyNote, Terminal, Trash2, UserRound, UsersRound, Wrench, X } from "lucide-react";
20
29
  import { DropdownMenu } from "radix-ui";
21
30
  import DOMPurify from "dompurify";
22
31
  import { marked } from "marked";
@@ -275,7 +284,7 @@ function BaseBar({ changes, base, loading, onBase, onRefresh }) {
275
284
  //#region src/components/changes/DiffView.tsx
276
285
  /** Rows drawn before "show the rest": a very long diff stays quick to open. */
277
286
  var ROWS_AT_FIRST = 1500;
278
- var NUMBER = "select-none px-2 text-right text-xs leading-[1.6] text-mocha-light tabular-nums";
287
+ var NUMBER = "select-none px-2 text-right text-xs leading-[1.6] text-muted-foreground tabular-nums";
279
288
  var TEXT = "whitespace-pre-wrap px-2 leading-[1.6] [overflow-wrap:anywhere]";
280
289
  /** The line number of a commentable line: click to comment on it. */
281
290
  function LineButton({ line, active, onClick }) {
@@ -652,7 +661,7 @@ var STATUS_TONE = {
652
661
  type_changed: "bg-accent text-accent-foreground",
653
662
  deleted: "bg-danger/15 text-danger",
654
663
  unmerged: "bg-warning/15 text-warning",
655
- unknown: "bg-frost text-mocha"
664
+ unknown: "bg-frost text-foreground"
656
665
  };
657
666
  /** The one-letter mark of a change: A added, M modified, D deleted… */
658
667
  function StatusMark({ status }) {
@@ -1099,6 +1108,66 @@ function AgentModel({ agent }) {
1099
1108
  });
1100
1109
  }
1101
1110
  //#endregion
1111
+ //#region src/components/agent/RenameAgentDialog.tsx
1112
+ /** A new display name for an Agent, from its row in the rail or from its panel. */
1113
+ function RenameAgentDialog({ agent, onClose, onRenamed }) {
1114
+ const [name, setName] = useState(agent.name);
1115
+ const [busy, setBusy] = useState(false);
1116
+ const [error, setError] = useState(null);
1117
+ const unchanged = !name.trim() || name.trim() === agent.name;
1118
+ async function submit(event) {
1119
+ event.preventDefault();
1120
+ if (unchanged) return;
1121
+ setBusy(true);
1122
+ setError(null);
1123
+ try {
1124
+ await renameAgent(agent.id, name.trim());
1125
+ await onRenamed();
1126
+ onClose();
1127
+ } catch (cause) {
1128
+ setError(errorMessage(cause));
1129
+ setBusy(false);
1130
+ }
1131
+ }
1132
+ return /* @__PURE__ */ jsx(Dialog$1, {
1133
+ title: `Rename ${agent.name}`,
1134
+ description: "This changes the display name only; the Agent ID and history stay the same.",
1135
+ busy,
1136
+ onClose,
1137
+ className: "max-w-md",
1138
+ children: /* @__PURE__ */ jsxs("form", {
1139
+ onSubmit: (event) => void submit(event),
1140
+ children: [
1141
+ /* @__PURE__ */ jsxs("label", { children: ["Agent name", /* @__PURE__ */ jsx("input", {
1142
+ autoFocus: true,
1143
+ value: name,
1144
+ onChange: (event) => setName(event.target.value),
1145
+ maxLength: 120
1146
+ })] }),
1147
+ error && /* @__PURE__ */ jsx("p", {
1148
+ role: "alert",
1149
+ className: "mt-3 text-sm text-danger",
1150
+ children: error
1151
+ }),
1152
+ /* @__PURE__ */ jsx("div", {
1153
+ className: "mt-4",
1154
+ children: /* @__PURE__ */ jsxs(DialogActions, { children: [/* @__PURE__ */ jsx(Button, {
1155
+ variant: "ghost",
1156
+ disabled: busy,
1157
+ onClick: onClose,
1158
+ children: "Cancel"
1159
+ }), /* @__PURE__ */ jsx(Button, {
1160
+ variant: "primary",
1161
+ type: "submit",
1162
+ disabled: busy || unchanged,
1163
+ children: busy ? "Renaming…" : "Rename agent"
1164
+ })] })
1165
+ })
1166
+ ]
1167
+ })
1168
+ });
1169
+ }
1170
+ //#endregion
1102
1171
  //#region src/components/CopyButton.tsx
1103
1172
  function CopyButton({ value, className, ariaLabel = "Copy to clipboard", title = "Copy to clipboard" }) {
1104
1173
  const [copied, setCopied] = useState(false);
@@ -1562,7 +1631,7 @@ function ConnectionsPanel({ team }) {
1562
1631
  }),
1563
1632
  reach.map((entry) => /* @__PURE__ */ jsxs("span", {
1564
1633
  title: entry.out && entry.back ? `${member.name} and ${entry.name} can message each other` : entry.out ? `${member.name} can message ${entry.name}` : `${entry.name} can message ${member.name}`,
1565
- className: `inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs ${entry.out ? "bg-accent text-accent-foreground" : "bg-frost text-mocha"}`,
1634
+ className: `inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs ${entry.out ? "bg-accent text-accent-foreground" : "bg-frost text-foreground"}`,
1566
1635
  children: [entry.out && entry.back ? /* @__PURE__ */ jsx(ArrowLeftRight, {
1567
1636
  className: "size-3",
1568
1637
  "aria-hidden": "true"
@@ -1666,15 +1735,16 @@ var PREVIEW_IMAGE = [
1666
1735
  "image/gif",
1667
1736
  "image/webp"
1668
1737
  ];
1669
- var PREVIEW_TEXT = ["text/plain", "text/markdown"];
1670
1738
  /** The daemon previews these images up to 10 MiB. */
1671
1739
  function isPreviewImage(result) {
1672
1740
  return PREVIEW_IMAGE.includes(result.mimeType) && result.byteLength <= 10 * 1024 * 1024;
1673
1741
  }
1674
- /** The daemon previews plain text and Markdown up to 256 KiB. */
1742
+ /** The daemon previews text up to 256 KiB: by its type, or by its name when sent untyped. */
1675
1743
  function isPreviewText(result) {
1676
- return PREVIEW_TEXT.includes(result.mimeType) && result.byteLength <= 256 * 1024;
1744
+ return isTextPreview(result);
1677
1745
  }
1746
+ /** How much of a text file a grid tile shows. */
1747
+ var TILE_TEXT_BYTES = 1200;
1678
1748
  function formatBytes$1(bytes) {
1679
1749
  if (bytes < 1024) return `${bytes} B`;
1680
1750
  if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(bytes < 10 * 1024 ? 1 : 0)} KB`;
@@ -1690,6 +1760,8 @@ function kindLabel(mimeType, name) {
1690
1760
  return extension ? extension.toUpperCase() : mimeType;
1691
1761
  }
1692
1762
  var resultPath = (id, action) => `/api/results/${encodeURIComponent(id)}${action ? `/${action}` : ""}`;
1763
+ /** The start of a text file, for a tile. */
1764
+ var tileTextPath = (id) => `${resultPath(id, "preview")}?bytes=${TILE_TEXT_BYTES}`;
1693
1765
  /** The archive of a Team's, an Agent's or a conversation's saved files. */
1694
1766
  function archivePath(filter) {
1695
1767
  const params = new URLSearchParams();
@@ -1757,35 +1829,30 @@ function ResultTile({ resultId, result: preloaded, detail, open, selected = fals
1757
1829
  if (compact) {
1758
1830
  const face = isPreviewImage(result) ? /* @__PURE__ */ jsx("img", {
1759
1831
  src: resultPath(result.id, "preview"),
1760
- alt: result.name,
1832
+ alt: "",
1761
1833
  loading: "lazy",
1762
1834
  className: "block aspect-[4/3] w-full bg-card object-contain p-1.5"
1763
- }) : /* @__PURE__ */ jsxs("span", {
1764
- className: "flex aspect-[4/3] w-full flex-col items-center justify-center gap-1.5 bg-card text-mocha",
1765
- children: [/* @__PURE__ */ jsx(FileText, {
1766
- className: "size-7",
1767
- "aria-hidden": "true"
1768
- }), /* @__PURE__ */ jsx("span", {
1769
- className: "max-w-full truncate px-2 font-mono text-xs font-medium uppercase tracking-wide",
1770
- children: kindLabel(result.mimeType, result.name)
1771
- })]
1772
- });
1835
+ }) : isPreviewText(result) ? /* @__PURE__ */ jsx(TextFace, { result }) : /* @__PURE__ */ jsx(KindFace, { result });
1773
1836
  return /* @__PURE__ */ jsxs("figure", {
1774
1837
  className: `m-0 ${frame}`,
1775
- children: [onPick ? /* @__PURE__ */ jsx("button", {
1838
+ children: [onPick ? /* @__PURE__ */ jsxs("button", {
1776
1839
  type: "button",
1777
1840
  onClick: onPick,
1778
- "aria-label": `Choose ${result.name}`,
1779
1841
  "aria-pressed": selected,
1780
1842
  className: "unstyled block w-full",
1781
- children: face
1782
- }) : open ? /* @__PURE__ */ jsx(Link, {
1843
+ children: [/* @__PURE__ */ jsxs("span", {
1844
+ className: "sr-only",
1845
+ children: ["Choose ", result.name]
1846
+ }), face]
1847
+ }) : open ? /* @__PURE__ */ jsxs(Link, {
1783
1848
  to: "/",
1784
1849
  search: open,
1785
- "aria-label": `Open ${result.name}`,
1786
1850
  "aria-current": selected ? "true" : void 0,
1787
1851
  className: "block",
1788
- children: face
1852
+ children: [/* @__PURE__ */ jsxs("span", {
1853
+ className: "sr-only",
1854
+ children: ["Open ", result.name]
1855
+ }), face]
1789
1856
  }) : face, /* @__PURE__ */ jsxs("figcaption", {
1790
1857
  className: "flex items-center gap-1.5 py-1.5 pl-2.5 pr-1.5",
1791
1858
  children: [/* @__PURE__ */ jsxs("span", {
@@ -1878,6 +1945,42 @@ function ResultTile({ resultId, result: preloaded, detail, open, selected = fals
1878
1945
  ]
1879
1946
  });
1880
1947
  }
1948
+ /** A file shown by its kind: an icon and "PDF", "ZIP". */
1949
+ function KindFace({ result }) {
1950
+ return /* @__PURE__ */ jsxs("span", {
1951
+ "aria-hidden": "true",
1952
+ className: "flex aspect-[4/3] w-full flex-col items-center justify-center gap-1.5 bg-card text-mocha",
1953
+ children: [/* @__PURE__ */ jsx(FileText, { className: "size-7" }), /* @__PURE__ */ jsx("span", {
1954
+ className: "max-w-full truncate px-2 font-mono text-xs font-medium uppercase tracking-wide",
1955
+ children: kindLabel(result.mimeType, result.name)
1956
+ })]
1957
+ });
1958
+ }
1959
+ /** A text file shown by its first lines, fading out; by its kind until they arrive or if not. */
1960
+ function TextFace({ result }) {
1961
+ const [start, setStart] = useState(null);
1962
+ useEffect(() => {
1963
+ const controller = new AbortController();
1964
+ apiFetch(tileTextPath(result.id), { signal: controller.signal }).then((response) => response.text()).then((text) => setStart(text.trim() ? text : null)).catch(() => setStart(null));
1965
+ return () => controller.abort();
1966
+ }, [result.id]);
1967
+ if (start === null) return /* @__PURE__ */ jsx(KindFace, { result });
1968
+ return /* @__PURE__ */ jsxs("span", {
1969
+ "aria-hidden": "true",
1970
+ className: "relative block aspect-[4/3] w-full overflow-hidden bg-card text-left",
1971
+ children: [
1972
+ /* @__PURE__ */ jsx("pre", {
1973
+ className: "m-0 h-full overflow-hidden whitespace-pre-wrap break-words p-2.5 font-mono text-[10px] leading-[1.45] text-mocha",
1974
+ children: start
1975
+ }),
1976
+ /* @__PURE__ */ jsx("span", { className: "pointer-events-none absolute inset-x-0 bottom-0 h-10 bg-gradient-to-t from-card to-transparent" }),
1977
+ /* @__PURE__ */ jsx("span", {
1978
+ className: "absolute bottom-1.5 right-2 rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] font-medium uppercase tracking-wide text-mocha",
1979
+ children: kindLabel(result.mimeType, result.name)
1980
+ })
1981
+ ]
1982
+ });
1983
+ }
1881
1984
  //#endregion
1882
1985
  //#region src/components/files/use-results.ts
1883
1986
  /** The daemon lists at most this many at once. */
@@ -2829,6 +2932,64 @@ function ChangesView({ team }) {
2829
2932
  });
2830
2933
  }
2831
2934
  //#endregion
2935
+ //#region src/lib/find-in-transcript.ts
2936
+ var GIVE_UP_MS = 8e3;
2937
+ var MARK_MS = 2500;
2938
+ /**
2939
+ * The `nth` element marked `data-message` whose text holds every word (oldest first, from 0), or
2940
+ * the last one that does when there are fewer.
2941
+ */
2942
+ function findMessage(root, find, nth = 0) {
2943
+ const words = find.toLowerCase().split(/\s+/).filter(Boolean);
2944
+ if (words.length === 0) return null;
2945
+ const found = [];
2946
+ for (const element of root.querySelectorAll("[data-message]")) {
2947
+ const text = (element.textContent ?? "").toLowerCase();
2948
+ if (words.every((word) => text.includes(word))) found.push(element);
2949
+ }
2950
+ return found[Math.min(nth, found.length - 1)] ?? null;
2951
+ }
2952
+ /**
2953
+ * Scroll to the message `find` and `nth` name, then call `done` (found or not) to drop them from
2954
+ * the address. `done` is the latest one passed: what was opened meanwhile stays open.
2955
+ */
2956
+ function useFindInTranscript(container, find, nth, done) {
2957
+ const latest = useRef(done);
2958
+ latest.current = done;
2959
+ useEffect(() => {
2960
+ const root = container.current;
2961
+ if (!find || !root) return;
2962
+ let finished = false;
2963
+ const finish = () => {
2964
+ finished = true;
2965
+ observer.disconnect();
2966
+ window.clearTimeout(giveUp);
2967
+ latest.current();
2968
+ };
2969
+ const look = () => {
2970
+ if (finished) return;
2971
+ const found = findMessage(root, find, nth);
2972
+ if (!found) return;
2973
+ found.scrollIntoView({ block: "center" });
2974
+ found.classList.add("found-message");
2975
+ window.setTimeout(() => found.classList.remove("found-message"), MARK_MS);
2976
+ finish();
2977
+ };
2978
+ const observer = new MutationObserver(look);
2979
+ observer.observe(root, {
2980
+ childList: true,
2981
+ subtree: true
2982
+ });
2983
+ const giveUp = window.setTimeout(finish, GIVE_UP_MS);
2984
+ look();
2985
+ return () => {
2986
+ finished = true;
2987
+ observer.disconnect();
2988
+ window.clearTimeout(giveUp);
2989
+ };
2990
+ }, [find, nth]);
2991
+ }
2992
+ //#endregion
2832
2993
  //#region src/components/chat/AgentQuestions.tsx
2833
2994
  /**
2834
2995
  * Questions the Agent is waiting on. The chat reloads them when it opens, when a turn starts or
@@ -2999,6 +3160,17 @@ function shellApprovalsUrl(agentId) {
2999
3160
  return `/api/shell-approvals?agentId=${encodeURIComponent(agentId)}`;
3000
3161
  }
3001
3162
  var isImageMime = (mimeType) => mimeType.startsWith("image/");
3163
+ /** The message being sent, shown at once: the `done` frame replaces it with the saved history. */
3164
+ function draftEntry(text, attachments) {
3165
+ const images = attachments.filter((file) => isImageMime(file.mimeType));
3166
+ const files = attachments.filter((file) => !isImageMime(file.mimeType)).map((file) => ({ name: file.name ?? "file" }));
3167
+ return {
3168
+ type: "user",
3169
+ content: text,
3170
+ ...images.length > 0 ? { images } : {},
3171
+ ...files.length > 0 ? { files } : {}
3172
+ };
3173
+ }
3002
3174
  /**
3003
3175
  * Persisted messages as entries: assistant text, then its tool calls and the tool results that
3004
3176
  * answer them grouped into one tool box. Saved results and images are deliverables, so they stand
@@ -3899,54 +4071,59 @@ function Handoffs({ steps }) {
3899
4071
  const recipient = workspace?.agentById(to);
3900
4072
  const message = typeof args?.text === "string" ? args.text : "";
3901
4073
  const state = recipient ? activity?.stateOf(recipient.id) : void 0;
3902
- return /* @__PURE__ */ jsxs("details", {
3903
- className: "group border-t border-frost/70",
3904
- children: [
3905
- /* @__PURE__ */ jsxs("summary", {
3906
- className: "flex min-h-11 cursor-pointer list-none items-center gap-2.5 px-3 py-1.5 [&::-webkit-details-marker]:hidden",
3907
- children: [
3908
- /* @__PURE__ */ jsx(AgentAvatar, {
3909
- identity: recipient?.identity,
3910
- size: 24
3911
- }),
3912
- /* @__PURE__ */ jsx("span", {
3913
- className: "shrink-0 font-semibold text-foreground",
3914
- children: recipient?.name ?? (to ? to.slice(0, 8) : "Teammate")
3915
- }),
3916
- /* @__PURE__ */ jsx("span", {
3917
- className: "min-w-0 flex-1 truncate text-mocha group-open:invisible",
3918
- children: message
3919
- }),
3920
- step.status === "failed" ? /* @__PURE__ */ jsx("span", {
3921
- className: "shrink-0 text-xs font-semibold text-danger",
3922
- children: "not sent"
3923
- }) : step.status === "running" ? /* @__PURE__ */ jsx("span", {
3924
- className: "shrink-0 text-xs text-mocha",
3925
- children: "sending…"
3926
- }) : state && /* @__PURE__ */ jsx("span", {
3927
- className: "shrink-0 text-xs text-mocha",
3928
- children: state.text
3929
- }),
3930
- workspace && recipient && /* @__PURE__ */ jsx(Link, {
3931
- to: "/",
3932
- search: {
3933
- agent: recipient.id,
3934
- ...workspace.search.panel ? { panel: workspace.search.panel } : {}
3935
- },
3936
- className: "flex h-7 shrink-0 items-center rounded-[10px] border border-border bg-card px-2.5 text-xs font-semibold text-foreground hover:border-sapphire-light hover:text-sapphire",
3937
- children: "Open"
3938
- })
3939
- ]
3940
- }),
3941
- /* @__PURE__ */ jsx("p", {
3942
- className: "m-0 whitespace-pre-wrap break-words px-3 pb-2.5 pl-[3.1rem] text-chocolate",
3943
- children: message
3944
- }),
3945
- step.status === "failed" && /* @__PURE__ */ jsx("p", {
3946
- className: "m-0 break-words px-3 pb-2.5 pl-[3.1rem] text-xs text-danger",
3947
- children: step.output
3948
- })
3949
- ]
4074
+ return /* @__PURE__ */ jsxs("div", {
4075
+ className: "relative border-t border-frost/70",
4076
+ children: [/* @__PURE__ */ jsxs("details", {
4077
+ className: "group",
4078
+ children: [
4079
+ /* @__PURE__ */ jsxs("summary", {
4080
+ className: `flex min-h-11 cursor-pointer list-none items-center gap-2.5 py-1.5 pl-3 [&::-webkit-details-marker]:hidden ${workspace && recipient ? "pr-[4.5rem]" : "pr-3"}`,
4081
+ children: [
4082
+ /* @__PURE__ */ jsx(AgentAvatar, {
4083
+ identity: recipient?.identity,
4084
+ size: 24
4085
+ }),
4086
+ /* @__PURE__ */ jsx("span", {
4087
+ className: "shrink-0 font-semibold text-foreground",
4088
+ children: recipient?.name ?? (to ? to.slice(0, 8) : "Teammate")
4089
+ }),
4090
+ /* @__PURE__ */ jsx("span", {
4091
+ className: "min-w-0 flex-1 truncate text-mocha group-open:invisible",
4092
+ children: message
4093
+ }),
4094
+ step.status === "failed" ? /* @__PURE__ */ jsx("span", {
4095
+ className: "shrink-0 text-xs font-semibold text-danger",
4096
+ children: "not sent"
4097
+ }) : step.status === "running" ? /* @__PURE__ */ jsx("span", {
4098
+ className: "shrink-0 text-xs text-mocha",
4099
+ children: "sending…"
4100
+ }) : state && /* @__PURE__ */ jsx("span", {
4101
+ className: "shrink-0 text-xs text-mocha",
4102
+ children: state.text
4103
+ })
4104
+ ]
4105
+ }),
4106
+ /* @__PURE__ */ jsx("p", {
4107
+ className: "m-0 whitespace-pre-wrap break-words px-3 pb-2.5 pl-[3.1rem] text-chocolate",
4108
+ children: message
4109
+ }),
4110
+ step.status === "failed" && /* @__PURE__ */ jsx("p", {
4111
+ className: "m-0 break-words px-3 pb-2.5 pl-[3.1rem] text-xs text-danger",
4112
+ children: step.output
4113
+ })
4114
+ ]
4115
+ }), workspace && recipient && /* @__PURE__ */ jsxs(Link, {
4116
+ to: "/",
4117
+ search: {
4118
+ agent: recipient.id,
4119
+ ...workspace.search.panel ? { panel: workspace.search.panel } : {}
4120
+ },
4121
+ className: "absolute right-3 top-2 flex h-7 items-center rounded-[10px] border border-border bg-card px-2.5 text-xs font-semibold text-foreground hover:border-sapphire-light hover:text-sapphire",
4122
+ children: ["Open", /* @__PURE__ */ jsxs("span", {
4123
+ className: "sr-only",
4124
+ children: [" ", recipient.name]
4125
+ })]
4126
+ })]
3950
4127
  }, index);
3951
4128
  })]
3952
4129
  });
@@ -4010,6 +4187,7 @@ function Bubble({ entry, markdownReady, onEdit, dropped = false, approvals }) {
4010
4187
  if (entry.content.startsWith(INBOX_WAKE_PREFIX)) {
4011
4188
  const body = entry.content.slice(24);
4012
4189
  return /* @__PURE__ */ jsxs("details", {
4190
+ "data-message": "",
4013
4191
  className: `my-3 rounded-lg border border-fawn bg-ivory px-3 py-2 text-sm text-mocha ${dropClass}`,
4014
4192
  "aria-label": "Teammate update",
4015
4193
  children: [
@@ -4029,6 +4207,7 @@ function Bubble({ entry, markdownReady, onEdit, dropped = false, approvals }) {
4029
4207
  });
4030
4208
  }
4031
4209
  return /* @__PURE__ */ jsxs("div", {
4210
+ "data-message": "",
4032
4211
  className: `group relative my-4 flex flex-col items-end ${dropClass}`,
4033
4212
  children: [
4034
4213
  /* @__PURE__ */ jsx("span", {
@@ -4081,6 +4260,7 @@ function Bubble({ entry, markdownReady, onEdit, dropped = false, approvals }) {
4081
4260
  });
4082
4261
  }
4083
4262
  return /* @__PURE__ */ jsxs("div", {
4263
+ "data-message": "",
4084
4264
  className: `my-4 flex flex-col items-start ${dropClass}`,
4085
4265
  children: [/* @__PURE__ */ jsx("span", {
4086
4266
  className: "sr-only",
@@ -4257,68 +4437,164 @@ function formatContext(context) {
4257
4437
  function formatCompaction(result) {
4258
4438
  return `/compact: ${result.before} → ${result.after} entries (${result.summarized} summarized, ${result.keptTail} kept verbatim; ~${result.tokensBefore.toLocaleString()} → ~${result.tokensAfter.toLocaleString()} tok). reloading…`;
4259
4439
  }
4440
+ async function compact(rest, chat) {
4441
+ if (chat.messageCount < 2) {
4442
+ chat.pushNote("/compact: need ≥2 messages to compact");
4443
+ return;
4444
+ }
4445
+ chat.setCompacting(true);
4446
+ try {
4447
+ const result = await api(`${chat.base}/chat/compact`, { body: { keepTail: parseKeepTail(rest) } });
4448
+ chat.pushNote(formatCompaction(result));
4449
+ setTimeout(() => window.location.reload(), 400);
4450
+ } catch (error) {
4451
+ chat.pushNote(`/compact failed: ${errorMessage(error)}`);
4452
+ } finally {
4453
+ chat.setCompacting(false);
4454
+ }
4455
+ }
4456
+ /** True when `command` is a slash command, which then ran. */
4457
+ async function runSlashCommand(command, rest, chat) {
4458
+ switch (command) {
4459
+ case "/help":
4460
+ chat.pushNote(SLASH_HELP);
4461
+ return true;
4462
+ case "/context":
4463
+ try {
4464
+ chat.pushNote(formatContext(await api(`${chat.base}/chat/context`)));
4465
+ } catch (error) {
4466
+ chat.pushNote(`/context failed: ${errorMessage(error)}`);
4467
+ }
4468
+ return true;
4469
+ case "/new":
4470
+ chat.onOpenLibrary();
4471
+ return true;
4472
+ case "/compact":
4473
+ await compact(rest, chat);
4474
+ return true;
4475
+ default: return false;
4476
+ }
4477
+ }
4260
4478
  //#endregion
4261
- //#region src/components/chat/useChatSession.ts
4262
- var SESSION_POLL_MS = 1e4;
4263
- var QUEUE_POLL_MS = 5e3;
4479
+ //#region src/components/chat/useCommandApprovals.ts
4480
+ function useCommandApprovals({ agentId, setLive }) {
4481
+ const [recoveredTurn, setRecoveredTurn] = useState(false);
4482
+ const [approvalBusy, setApprovalBusy] = useState({});
4483
+ const [approvalErrors, setApprovalErrors] = useState({});
4484
+ const approvalTurnRef = useRef(false);
4485
+ useEffect(() => {
4486
+ const controller = new AbortController();
4487
+ api(shellApprovalsUrl(agentId), { signal: controller.signal }).then(({ approvals }) => {
4488
+ const pending = approvals.filter((approval) => approval.agentId === agentId && approval.status === "pending");
4489
+ if (pending.length === 0) return;
4490
+ approvalTurnRef.current = true;
4491
+ setLive((entries) => pending.reduce(upsertCommandApprovalEntry, entries));
4492
+ setRecoveredTurn(true);
4493
+ }).catch(() => {});
4494
+ return () => controller.abort();
4495
+ }, [agentId, setLive]);
4496
+ async function reconcileApproval(id) {
4497
+ try {
4498
+ const { approvals } = await api(shellApprovalsUrl(agentId));
4499
+ const approval = approvals.find((item) => item.id === id && item.agentId === agentId);
4500
+ if (approval) setLive((entries) => upsertCommandApprovalEntry(entries, approval));
4501
+ return approval ?? null;
4502
+ } catch {
4503
+ return null;
4504
+ }
4505
+ }
4506
+ async function decide(approval, decision) {
4507
+ if (approval.agentId !== agentId || approval.status !== "pending") return;
4508
+ setApprovalBusy((current) => ({
4509
+ ...current,
4510
+ [approval.id]: true
4511
+ }));
4512
+ setApprovalErrors(({ [approval.id]: _cleared, ...rest }) => rest);
4513
+ try {
4514
+ const body = await api(`/api/shell-approvals/${encodeURIComponent(approval.id)}`, { body: { decision } });
4515
+ if (body.approval.agentId === agentId) setLive((entries) => upsertCommandApprovalEntry(entries, body.approval));
4516
+ } catch (error) {
4517
+ const current = await reconcileApproval(approval.id);
4518
+ if (!current || current.status === "pending") setApprovalErrors((errors) => ({
4519
+ ...errors,
4520
+ [approval.id]: errorMessage(error)
4521
+ }));
4522
+ } finally {
4523
+ setApprovalBusy((current) => ({
4524
+ ...current,
4525
+ [approval.id]: false
4526
+ }));
4527
+ }
4528
+ }
4529
+ return {
4530
+ recoveredTurn,
4531
+ setRecoveredTurn,
4532
+ approvalTurnRef,
4533
+ approvalBusy,
4534
+ approvalErrors,
4535
+ decide,
4536
+ /** A turn starts or ends: no approval is being decided or failed any more. */
4537
+ resetApprovals: () => {
4538
+ setApprovalBusy({});
4539
+ setApprovalErrors({});
4540
+ }
4541
+ };
4542
+ }
4543
+ //#endregion
4544
+ //#region src/components/chat/session-sync.ts
4264
4545
  var EMPTY_HEAD = {
4265
4546
  file: null,
4266
4547
  size: 0,
4267
4548
  conversationId: null
4268
4549
  };
4550
+ /** Follow-ups that wait or run. */
4269
4551
  function openFollowUps(queue) {
4270
4552
  return queue?.items.filter((item) => item.status === "pending" || item.status === "running").length ?? 0;
4271
4553
  }
4272
- function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLibrary, onConversation }) {
4273
- const base = `/api/agents/${encodeURIComponent(agentId)}`;
4274
- const [messages, setMessages] = useState(initialMessages);
4275
- const [live, setLive] = useState([]);
4276
- const [notes, setNotes] = useState([]);
4277
- const [thinking, setThinking] = useState(false);
4278
- const [streaming, setStreaming] = useState(false);
4279
- const [recoveredTurn, setRecoveredTurn] = useState(false);
4280
- const [editing, setEditing] = useState(false);
4554
+ /** A turn runs, or a follow-up runs or is about to. */
4555
+ function isQueueWorking(queue) {
4556
+ return queue?.turnActive || queue?.items.some((item) => item.status === "running" || item.status === "pending" && !queue.paused);
4557
+ }
4558
+ /** The conversation file is not the one `known` describes: another source wrote to it. */
4559
+ function headMoved(head, known) {
4560
+ return Boolean(head.unavailable) !== Boolean(known.unavailable) || head.file !== known.file || head.size !== known.size;
4561
+ }
4562
+ /**
4563
+ * What a new activity reading of the Agent asks of the chat: look at the conversation's head, read
4564
+ * the queue again, read the queue and then look at the head when that did not reload the history
4565
+ * (a turn ended), or nothing.
4566
+ */
4567
+ function activityReaction(was, now) {
4568
+ if (!was) return "head";
4569
+ if (now.working !== was.working || now.queuePaused !== was.queuePaused || now.followUps !== was.followUps) return was.working && !now.working ? "queue-then-head" : "queue";
4570
+ if (!now.working && now.lastActivityAt !== was.lastActivityAt) return "head";
4571
+ return null;
4572
+ }
4573
+ //#endregion
4574
+ //#region src/components/chat/useSessionSync.ts
4575
+ var SESSION_POLL_MS = 1e4;
4576
+ var QUEUE_POLL_MS = 5e3;
4577
+ function useSessionSync({ agentId, base, initialSessionHead, onConversation, streamingRef, pushNote, onHistory }) {
4281
4578
  const [stale, setStale] = useState(false);
4282
4579
  const [historyUnavailable, setHistoryUnavailable] = useState(initialSessionHead?.unavailable ?? false);
4283
4580
  const [queue, setQueue] = useState(null);
4284
- const [questionsKey, setQuestionsKey] = useState(0);
4285
- const [approvalBusy, setApprovalBusy] = useState({});
4286
- const [approvalErrors, setApprovalErrors] = useState({});
4287
- const abortRef = useRef(null);
4288
- const approvalTurnRef = useRef(false);
4289
4581
  const knownHeadRef = useRef(initialSessionHead ?? EMPTY_HEAD);
4290
4582
  const queueRef = useRef(null);
4291
- const noteIdRef = useRef(0);
4292
- const entryCountRef = useRef(0);
4293
- const streamingRef = useRef(false);
4294
- streamingRef.current = streaming;
4295
4583
  const staleRef = useRef(stale);
4296
4584
  staleRef.current = stale;
4297
4585
  const activityRef = useRef(null);
4298
4586
  const feed = useLive();
4299
- const turnBusy = streaming || recoveredTurn;
4300
- const agentBusy = turnBusy || Boolean(queue?.turnActive);
4301
- const queueWorking = queue?.turnActive || queue?.items.some((item) => item.status === "running" || item.status === "pending" && !queue.paused);
4587
+ const queueWorking = isQueueWorking(queue);
4302
4588
  function know(head) {
4303
4589
  if (head.conversationId !== knownHeadRef.current.conversationId) onConversation?.(head.conversationId);
4304
4590
  knownHeadRef.current = head;
4305
4591
  }
4306
- function pushNote(content) {
4307
- const note = {
4308
- id: noteIdRef.current++,
4309
- content,
4310
- afterIndex: entryCountRef.current
4311
- };
4312
- setNotes((current) => [...current, note]);
4313
- }
4314
4592
  async function refreshHistory() {
4315
4593
  if (streamingRef.current) return;
4316
4594
  try {
4317
4595
  const body = await api(`${base}/sessions/messages`);
4318
4596
  setHistoryUnavailable(body.head.unavailable ?? false);
4319
- setMessages(body.messages);
4320
- setLive([]);
4321
- setEditing(false);
4597
+ onHistory(body.messages);
4322
4598
  know(body.head);
4323
4599
  setStale(false);
4324
4600
  } catch {
@@ -4354,15 +4630,26 @@ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLi
4354
4630
  async function checkHead() {
4355
4631
  if (!initialSessionHead || staleRef.current || streamingRef.current) return;
4356
4632
  try {
4357
- const head = await api(`${base}/sessions/head`);
4358
- const known = knownHeadRef.current;
4359
- if (Boolean(head.unavailable) !== Boolean(known.unavailable) || head.file !== known.file || head.size !== known.size) {
4633
+ if (headMoved(await api(`${base}/sessions/head`), knownHeadRef.current)) {
4360
4634
  setStale(true);
4361
4635
  refreshQueue();
4362
4636
  }
4363
4637
  } catch {}
4364
4638
  }
4365
- useEffect(() => () => abortRef.current?.abort(), []);
4639
+ /** Queue a follow-up; returns the draft to give back to the composer when it was not queued. */
4640
+ async function enqueue(draft) {
4641
+ try {
4642
+ await api(`${base}/queue`, { body: {
4643
+ message: draft.text,
4644
+ attachments: draft.attachments
4645
+ } });
4646
+ refreshQueue();
4647
+ return null;
4648
+ } catch (error) {
4649
+ pushNote(`The follow-up was not queued: ${errorMessage(error)}. Your draft is kept.`);
4650
+ return draft;
4651
+ }
4652
+ }
4366
4653
  useEffect(() => {
4367
4654
  refreshQueue();
4368
4655
  }, []);
@@ -4371,13 +4658,11 @@ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLi
4371
4658
  const was = activityRef.current;
4372
4659
  activityRef.current = now;
4373
4660
  if (!now || streamingRef.current) return;
4374
- if (!was) return void checkHead();
4375
- if (now.working !== was.working || now.queuePaused !== was.queuePaused || now.followUps !== was.followUps) {
4376
- const ended = was.working && !now.working;
4377
- refreshQueue().then((reloaded) => {
4378
- if (ended && !reloaded) checkHead();
4379
- });
4380
- } else if (!now.working && now.lastActivityAt !== was.lastActivityAt) checkHead();
4661
+ const reaction = activityReaction(was, now);
4662
+ if (reaction === "head") checkHead();
4663
+ else if (reaction !== null) refreshQueue().then((reloaded) => {
4664
+ if (reaction === "queue-then-head" && !reloaded) checkHead();
4665
+ });
4381
4666
  }), [feed.subscribe, agentId]);
4382
4667
  useEffect(() => {
4383
4668
  if (!queueWorking || feed.connected) return;
@@ -4398,70 +4683,63 @@ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLi
4398
4683
  stale,
4399
4684
  feed.connected
4400
4685
  ]);
4401
- useEffect(() => {
4402
- const controller = new AbortController();
4403
- api(shellApprovalsUrl(agentId), { signal: controller.signal }).then(({ approvals }) => {
4404
- const pending = approvals.filter((approval) => approval.agentId === agentId && approval.status === "pending");
4405
- if (pending.length === 0) return;
4406
- approvalTurnRef.current = true;
4407
- setLive((entries) => pending.reduce(upsertCommandApprovalEntry, entries));
4408
- setRecoveredTurn(true);
4409
- }).catch(() => {});
4410
- return () => controller.abort();
4411
- }, [agentId]);
4412
- async function enqueue(draft) {
4413
- try {
4414
- await api(`${base}/queue`, { body: {
4415
- message: draft.text,
4416
- attachments: draft.attachments
4417
- } });
4418
- refreshQueue();
4419
- return null;
4420
- } catch (error) {
4421
- pushNote(`The follow-up was not queued: ${errorMessage(error)}. Your draft is kept.`);
4422
- return draft;
4423
- }
4424
- }
4425
- async function compact(rest) {
4426
- if (messages.length < 2) {
4427
- pushNote("/compact: need ≥2 messages to compact");
4428
- return;
4429
- }
4430
- setEditing(false);
4431
- setStreaming(true);
4432
- setThinking(true);
4433
- try {
4434
- pushNote(formatCompaction(await api(`${base}/chat/compact`, { body: { keepTail: parseKeepTail(rest) } })));
4435
- setTimeout(() => window.location.reload(), 400);
4436
- } catch (error) {
4437
- pushNote(`/compact failed: ${errorMessage(error)}`);
4438
- } finally {
4439
- setThinking(false);
4440
- setStreaming(false);
4441
- }
4686
+ return {
4687
+ stale,
4688
+ dismissStale: () => setStale(false),
4689
+ historyUnavailable,
4690
+ queue,
4691
+ /** The conversation this tab last knew of; null before the Agent's first turn. */
4692
+ knownConversationId: () => knownHeadRef.current.conversationId,
4693
+ refreshHistory,
4694
+ refreshKnownHead,
4695
+ refreshQueue,
4696
+ enqueue
4697
+ };
4698
+ }
4699
+ //#endregion
4700
+ //#region src/components/chat/useChatSession.ts
4701
+ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLibrary, onConversation }) {
4702
+ const base = `/api/agents/${encodeURIComponent(agentId)}`;
4703
+ const [messages, setMessages] = useState(initialMessages);
4704
+ const [live, setLive] = useState([]);
4705
+ const [notes, setNotes] = useState([]);
4706
+ const [thinking, setThinking] = useState(false);
4707
+ const [streaming, setStreaming] = useState(false);
4708
+ const [editing, setEditing] = useState(false);
4709
+ const [questionsKey, setQuestionsKey] = useState(0);
4710
+ const abortRef = useRef(null);
4711
+ const noteIdRef = useRef(0);
4712
+ const entryCountRef = useRef(0);
4713
+ const streamingRef = useRef(false);
4714
+ streamingRef.current = streaming;
4715
+ function pushNote(content) {
4716
+ const note = {
4717
+ id: noteIdRef.current++,
4718
+ content,
4719
+ afterIndex: entryCountRef.current
4720
+ };
4721
+ setNotes((current) => [...current, note]);
4442
4722
  }
4443
- /** True when `command` is a slash command, which then ran. */
4444
- async function runSlashCommand(command, rest) {
4445
- switch (command) {
4446
- case "/help":
4447
- pushNote(SLASH_HELP);
4448
- return true;
4449
- case "/context":
4450
- try {
4451
- pushNote(formatContext(await api(`${base}/chat/context`)));
4452
- } catch (error) {
4453
- pushNote(`/context failed: ${errorMessage(error)}`);
4454
- }
4455
- return true;
4456
- case "/new":
4457
- onOpenLibrary();
4458
- return true;
4459
- case "/compact":
4460
- await compact(rest);
4461
- return true;
4462
- default: return false;
4723
+ useEffect(() => () => abortRef.current?.abort(), []);
4724
+ const sync = useSessionSync({
4725
+ agentId,
4726
+ base,
4727
+ initialSessionHead,
4728
+ onConversation,
4729
+ streamingRef,
4730
+ pushNote,
4731
+ onHistory: (saved) => {
4732
+ setMessages(saved);
4733
+ setLive([]);
4734
+ setEditing(false);
4463
4735
  }
4464
- }
4736
+ });
4737
+ const { recoveredTurn, setRecoveredTurn, approvalTurnRef, approvalBusy, approvalErrors, decide, resetApprovals } = useCommandApprovals({
4738
+ agentId,
4739
+ setLive
4740
+ });
4741
+ const turnBusy = streaming || recoveredTurn;
4742
+ const agentBusy = turnBusy || Boolean(sync.queue?.turnActive);
4465
4743
  function lastUserMessage() {
4466
4744
  return messages.findLastIndex((message) => message.role === "user");
4467
4745
  }
@@ -4480,8 +4758,7 @@ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLi
4480
4758
  setMessages(frame.messages);
4481
4759
  setLive([]);
4482
4760
  setRecoveredTurn(false);
4483
- setApprovalBusy({});
4484
- setApprovalErrors({});
4761
+ resetApprovals();
4485
4762
  return;
4486
4763
  }
4487
4764
  const event = frame.event;
@@ -4500,12 +4777,22 @@ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLi
4500
4777
  */
4501
4778
  async function send(draft) {
4502
4779
  const slash = parseSlashCommand(draft.text);
4503
- if (slash && await runSlashCommand(slash.command, slash.rest)) return draft.attachments.length > 0 ? {
4780
+ if (slash && await runSlashCommand(slash.command, slash.rest, {
4781
+ base,
4782
+ messageCount: messages.length,
4783
+ pushNote,
4784
+ onOpenLibrary,
4785
+ setCompacting: (compacting) => {
4786
+ if (compacting) setEditing(false);
4787
+ setStreaming(compacting);
4788
+ setThinking(compacting);
4789
+ }
4790
+ })) return draft.attachments.length > 0 ? {
4504
4791
  text: "",
4505
4792
  attachments: draft.attachments
4506
4793
  } : null;
4507
4794
  if (turnBusy) {
4508
- if (!editing) return enqueue(draft);
4795
+ if (!editing) return sync.enqueue(draft);
4509
4796
  pushNote("Wait for the current turn to finish before replacing the last message.");
4510
4797
  return draft;
4511
4798
  }
@@ -4514,7 +4801,7 @@ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLi
4514
4801
  try {
4515
4802
  await api(`${base}/chat/truncate`, { body: {
4516
4803
  keepCount,
4517
- conversationId: knownHeadRef.current.conversationId ?? void 0
4804
+ conversationId: sync.knownConversationId() ?? void 0
4518
4805
  } });
4519
4806
  } catch (error) {
4520
4807
  pushNote(`Could not replace the last turn: ${errorMessage(error)}`);
@@ -4523,17 +4810,9 @@ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLi
4523
4810
  setMessages((current) => current.slice(0, keepCount));
4524
4811
  setEditing(false);
4525
4812
  }
4526
- const images = draft.attachments.filter((file) => isImageMime(file.mimeType));
4527
- const files = draft.attachments.filter((file) => !isImageMime(file.mimeType)).map((file) => ({ name: file.name ?? "file" }));
4528
- setLive([{
4529
- type: "user",
4530
- content: draft.text,
4531
- ...images.length > 0 ? { images } : {},
4532
- ...files.length > 0 ? { files } : {}
4533
- }]);
4813
+ setLive([draftEntry(draft.text, draft.attachments)]);
4534
4814
  setRecoveredTurn(false);
4535
- setApprovalBusy({});
4536
- setApprovalErrors({});
4815
+ resetApprovals();
4537
4816
  approvalTurnRef.current = false;
4538
4817
  const abort = new AbortController();
4539
4818
  abortRef.current = abort;
@@ -4551,11 +4830,11 @@ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLi
4551
4830
  if (frame.kind !== "event") finished = true;
4552
4831
  handleFrame(frame);
4553
4832
  }
4554
- await refreshKnownHead();
4833
+ await sync.refreshKnownHead();
4555
4834
  } catch (error) {
4556
4835
  if (error instanceof ApiError) if (error.code === "agent_turn_active") {
4557
4836
  setLive([]);
4558
- restore = await enqueue(draft);
4837
+ restore = await sync.enqueue(draft);
4559
4838
  } else {
4560
4839
  setLive([{
4561
4840
  type: "error",
@@ -4573,7 +4852,7 @@ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLi
4573
4852
  setThinking(false);
4574
4853
  setStreaming(false);
4575
4854
  abortRef.current = null;
4576
- refreshQueue();
4855
+ sync.refreshQueue();
4577
4856
  setQuestionsKey((key) => key + 1);
4578
4857
  }
4579
4858
  }
@@ -4586,40 +4865,7 @@ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLi
4586
4865
  } catch (error) {
4587
4866
  if (!(error instanceof ApiError && error.status === 409)) pushNote("Stop was not confirmed; the response may still be running.");
4588
4867
  }
4589
- refreshQueue();
4590
- }
4591
- async function reconcileApproval(id) {
4592
- try {
4593
- const { approvals } = await api(shellApprovalsUrl(agentId));
4594
- const approval = approvals.find((item) => item.id === id && item.agentId === agentId);
4595
- if (approval) setLive((entries) => upsertCommandApprovalEntry(entries, approval));
4596
- return approval ?? null;
4597
- } catch {
4598
- return null;
4599
- }
4600
- }
4601
- async function decide(approval, decision) {
4602
- if (approval.agentId !== agentId || approval.status !== "pending") return;
4603
- setApprovalBusy((current) => ({
4604
- ...current,
4605
- [approval.id]: true
4606
- }));
4607
- setApprovalErrors(({ [approval.id]: _cleared, ...rest }) => rest);
4608
- try {
4609
- const body = await api(`/api/shell-approvals/${encodeURIComponent(approval.id)}`, { body: { decision } });
4610
- if (body.approval.agentId === agentId) setLive((entries) => upsertCommandApprovalEntry(entries, body.approval));
4611
- } catch (error) {
4612
- const current = await reconcileApproval(approval.id);
4613
- if (!current || current.status === "pending") setApprovalErrors((errors) => ({
4614
- ...errors,
4615
- [approval.id]: errorMessage(error)
4616
- }));
4617
- } finally {
4618
- setApprovalBusy((current) => ({
4619
- ...current,
4620
- [approval.id]: false
4621
- }));
4622
- }
4868
+ sync.refreshQueue();
4623
4869
  }
4624
4870
  /** Put the last user message back in the composer; sending it replaces the last turn. */
4625
4871
  function startEdit() {
@@ -4644,10 +4890,10 @@ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLi
4644
4890
  turnBusy,
4645
4891
  agentBusy,
4646
4892
  editing,
4647
- stale,
4893
+ stale: sync.stale,
4648
4894
  recoveredTurn,
4649
- historyUnavailable,
4650
- queue,
4895
+ historyUnavailable: sync.historyUnavailable,
4896
+ queue: sync.queue,
4651
4897
  questionsKey,
4652
4898
  approvals: {
4653
4899
  busy: approvalBusy,
@@ -4658,9 +4904,9 @@ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLi
4658
4904
  stop,
4659
4905
  startEdit,
4660
4906
  cancelEdit: () => setEditing(false),
4661
- refreshHistory,
4662
- refreshQueue,
4663
- dismissStale: () => setStale(false)
4907
+ refreshHistory: sync.refreshHistory,
4908
+ refreshQueue: sync.refreshQueue,
4909
+ dismissStale: sync.dismissStale
4664
4910
  };
4665
4911
  }
4666
4912
  //#endregion
@@ -4688,6 +4934,19 @@ function AgentChat({ agentId, agentName, initialMessages, initialSessionHead, he
4688
4934
  const inputRef = useRef(null);
4689
4935
  const logRef = useRef(null);
4690
4936
  const nearBottomRef = useRef(true);
4937
+ const workspace = useWorkspaceOptional();
4938
+ const navigate = useNavigate();
4939
+ useFindInTranscript(logRef, workspace?.search.find, workspace?.search.match, () => {
4940
+ nearBottomRef.current = false;
4941
+ if (workspace) navigate({
4942
+ to: "/",
4943
+ search: workspace.to({
4944
+ find: void 0,
4945
+ match: void 0
4946
+ }),
4947
+ replace: true
4948
+ });
4949
+ });
4691
4950
  useLayoutEffect(() => {
4692
4951
  const log = logRef.current;
4693
4952
  if (log && nearBottomRef.current) log.scrollTop = log.scrollHeight;
@@ -5234,7 +5493,7 @@ function Preview({ result }) {
5234
5493
  //#endregion
5235
5494
  //#region src/components/workspace/ConversationHeader.tsx
5236
5495
  var CHIP = "inline-flex h-[26px] shrink-0 items-center gap-1 rounded-full border border-border bg-muted px-2.5 text-xs font-semibold text-mocha hover:border-sapphire-light hover:text-sapphire";
5237
- var MENU_ITEM = "flex min-h-10 w-full cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-sm text-foreground outline-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50";
5496
+ var MENU_ITEM$1 = "flex min-h-10 w-full cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-sm text-foreground outline-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50";
5238
5497
  /** The model without its provider: `lmstudio:paper-coder-32b` reads as `paper-coder-32b`. */
5239
5498
  function shortModel(model) {
5240
5499
  const colon = model.indexOf(":");
@@ -5260,7 +5519,7 @@ function ConversationHeader({ agent, chat, panel, lastPanel }) {
5260
5519
  size: 32
5261
5520
  }),
5262
5521
  /* @__PURE__ */ jsx("h1", {
5263
- className: "m-0 min-w-0 truncate font-display text-xl leading-tight text-charcoal",
5522
+ className: "m-0 min-w-0 max-w-[14rem] shrink-0 truncate font-display text-xl leading-tight text-charcoal",
5264
5523
  children: agent.agent.name
5265
5524
  }),
5266
5525
  /* @__PURE__ */ jsx(Link, {
@@ -5298,7 +5557,6 @@ function ConversationHeader({ agent, chat, panel, lastPanel }) {
5298
5557
  }),
5299
5558
  "aria-label": panel === "none" ? "Show the side panel" : "Hide the side panel",
5300
5559
  title: panel === "none" ? "Show the side panel" : "Hide the side panel",
5301
- "aria-pressed": panel !== "none",
5302
5560
  className: `flex size-8 shrink-0 items-center justify-center rounded-[10px] border ${panel === "none" ? "border-border bg-card text-mocha hover:text-sapphire" : "border-primary/25 bg-accent text-accent-foreground"}`,
5303
5561
  children: /* @__PURE__ */ jsx(PanelRight, {
5304
5562
  className: "size-4",
@@ -5370,7 +5628,7 @@ function ConversationMenu({ agentId, chat }) {
5370
5628
  asChild: true,
5371
5629
  children: /* @__PURE__ */ jsxs("button", {
5372
5630
  type: "button",
5373
- "aria-label": "Conversations",
5631
+ "aria-label": shown ? `${shown.title}: conversations` : "Conversations",
5374
5632
  className: "unstyled inline-flex h-8 min-w-0 max-w-[15rem] items-center gap-1.5 rounded-[10px] border border-border bg-card px-2.5 text-sm font-semibold text-foreground hover:border-sapphire-light",
5375
5633
  children: [
5376
5634
  /* @__PURE__ */ jsx(MessageSquare, {
@@ -5419,17 +5677,24 @@ function ConversationMenu({ agentId, chat }) {
5419
5677
  conversations.map((conversation) => {
5420
5678
  const active = conversation.id === activeId;
5421
5679
  const reading = conversation.id === shownId;
5680
+ const used = list.data?.usage[conversation.id];
5422
5681
  return /* @__PURE__ */ jsx(DropdownMenu.Item, {
5423
5682
  asChild: true,
5424
- className: MENU_ITEM,
5683
+ className: MENU_ITEM$1,
5425
5684
  children: /* @__PURE__ */ jsxs(Link, {
5426
5685
  to: "/",
5427
5686
  search: to({ conversation: active ? void 0 : conversation.id }),
5428
5687
  "aria-current": reading ? "true" : void 0,
5429
5688
  className: reading ? "bg-accent/70 text-accent-foreground" : "",
5430
- children: [/* @__PURE__ */ jsx("span", {
5431
- className: "min-w-0 flex-1 truncate font-medium",
5432
- children: conversation.title
5689
+ children: [/* @__PURE__ */ jsxs("span", {
5690
+ className: "min-w-0 flex-1",
5691
+ children: [/* @__PURE__ */ jsx("span", {
5692
+ className: "block truncate font-medium",
5693
+ children: conversation.title
5694
+ }), used && /* @__PURE__ */ jsx("span", {
5695
+ className: "block truncate text-xs text-muted-foreground",
5696
+ children: usageSummary(used)
5697
+ })]
5433
5698
  }), active ? /* @__PURE__ */ jsxs("span", {
5434
5699
  className: "flex shrink-0 items-center gap-1 text-xs font-semibold text-success",
5435
5700
  children: [/* @__PURE__ */ jsx(Check, {
@@ -5458,7 +5723,7 @@ function ConversationMenu({ agentId, chat }) {
5458
5723
  }),
5459
5724
  /* @__PURE__ */ jsx(DropdownMenu.Separator, { className: "my-1.5 h-px bg-border" }),
5460
5725
  /* @__PURE__ */ jsxs(DropdownMenu.Item, {
5461
- className: `${MENU_ITEM} font-semibold`,
5726
+ className: `${MENU_ITEM$1} font-semibold`,
5462
5727
  disabled: chat?.agentBusy ?? false,
5463
5728
  onSelect: () => void startNew(),
5464
5729
  children: [
@@ -5474,7 +5739,7 @@ function ConversationMenu({ agentId, chat }) {
5474
5739
  ]
5475
5740
  }),
5476
5741
  shown && /* @__PURE__ */ jsxs(DropdownMenu.Item, {
5477
- className: MENU_ITEM,
5742
+ className: MENU_ITEM$1,
5478
5743
  onSelect: () => setRenaming(shown),
5479
5744
  children: [
5480
5745
  /* @__PURE__ */ jsx(Pencil, {
@@ -5485,6 +5750,18 @@ function ConversationMenu({ agentId, chat }) {
5485
5750
  shown.title.length > 24 ? `${shown.title.slice(0, 24)}…` : shown.title,
5486
5751
  "”"
5487
5752
  ]
5753
+ }),
5754
+ /* @__PURE__ */ jsx(DropdownMenu.Item, {
5755
+ asChild: true,
5756
+ className: MENU_ITEM$1,
5757
+ children: /* @__PURE__ */ jsxs(Link, {
5758
+ to: "/usage",
5759
+ search: { agent: agentId },
5760
+ children: [/* @__PURE__ */ jsx(BarChart3, {
5761
+ className: "size-3.5",
5762
+ "aria-hidden": "true"
5763
+ }), "This Agent's usage"]
5764
+ })
5488
5765
  })
5489
5766
  ]
5490
5767
  }) })]
@@ -5557,8 +5834,20 @@ function RenameConversation({ base, conversation, onClose, onRenamed }) {
5557
5834
  //#endregion
5558
5835
  //#region src/components/workspace/EarlierConversation.tsx
5559
5836
  function EarlierConversation({ agentId, agentName, conversationId, header }) {
5560
- const { to } = useWorkspace();
5837
+ const { search, to } = useWorkspace();
5561
5838
  const router = useRouter();
5839
+ const navigate = useNavigate();
5840
+ const logRef = useRef(null);
5841
+ useFindInTranscript(logRef, search.find, search.match, () => {
5842
+ navigate({
5843
+ to: "/",
5844
+ search: to({
5845
+ find: void 0,
5846
+ match: void 0
5847
+ }),
5848
+ replace: true
5849
+ });
5850
+ });
5562
5851
  const path = `/api/agents/${encodeURIComponent(agentId)}/conversations/${encodeURIComponent(conversationId)}`;
5563
5852
  const [busy, setBusy] = useState(false);
5564
5853
  const [error, setError] = useState("");
@@ -5630,6 +5919,7 @@ function EarlierConversation({ agentId, agentName, conversationId, header }) {
5630
5919
  children: error
5631
5920
  }),
5632
5921
  /* @__PURE__ */ jsx("div", {
5922
+ ref: logRef,
5633
5923
  className: "min-h-0 flex-1 overflow-y-auto px-5 py-4",
5634
5924
  children: /* @__PURE__ */ jsxs("div", {
5635
5925
  className: "mx-auto max-w-[50rem]",
@@ -5864,6 +6154,543 @@ function TeamCard({ team, members, summary }) {
5864
6154
  }) });
5865
6155
  }
5866
6156
  //#endregion
6157
+ //#region src/components/workspace/rail/menu.ts
6158
+ var MENU_ITEM = "flex min-h-8 w-full cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-sm text-foreground outline-none transition-colors data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50";
6159
+ var MENU_LABEL = "flex items-center gap-1.5 px-2.5 pb-1 pt-1 text-xs font-semibold uppercase tracking-[0.08em] text-muted-foreground";
6160
+ //#endregion
6161
+ //#region src/components/workspace/rail/NewMenu.tsx
6162
+ function NewMenu({ buttonRef, profiles, teamTemplates, onSpawnAgent, onSpawnTeam, onCreateTeam }) {
6163
+ return /* @__PURE__ */ jsxs(DropdownMenu.Root, {
6164
+ modal: false,
6165
+ children: [/* @__PURE__ */ jsx(DropdownMenu.Trigger, {
6166
+ asChild: true,
6167
+ children: /* @__PURE__ */ jsxs("button", {
6168
+ ref: buttonRef,
6169
+ type: "button",
6170
+ "aria-label": "Create a new Agent or Team",
6171
+ className: "unstyled group inline-flex h-8 items-center gap-1 rounded-lg border border-border bg-card px-2.5 text-xs font-semibold text-foreground shadow-baziu-sm transition-colors hover:border-primary/30 hover:bg-accent hover:text-accent-foreground",
6172
+ children: [
6173
+ /* @__PURE__ */ jsx(Plus, {
6174
+ className: "size-3.5",
6175
+ "aria-hidden": "true"
6176
+ }),
6177
+ "New",
6178
+ /* @__PURE__ */ jsx(ChevronDown, {
6179
+ className: "size-3.5 text-muted-foreground transition-transform group-data-[state=open]:rotate-180",
6180
+ "aria-hidden": "true"
6181
+ })
6182
+ ]
6183
+ })
6184
+ }), /* @__PURE__ */ jsx(DropdownMenu.Portal, { children: /* @__PURE__ */ jsxs(DropdownMenu.Content, {
6185
+ align: "end",
6186
+ sideOffset: 6,
6187
+ className: "z-50 w-60 rounded-xl border border-border bg-popover p-1.5 text-popover-foreground shadow-baziu-lg outline-none",
6188
+ children: [
6189
+ /* @__PURE__ */ jsxs(DropdownMenu.Label, {
6190
+ className: MENU_LABEL,
6191
+ children: [/* @__PURE__ */ jsx(Bot, {
6192
+ className: "size-3",
6193
+ "aria-hidden": "true"
6194
+ }), "Agent templates"]
6195
+ }),
6196
+ profiles.length === 0 ? /* @__PURE__ */ jsx(DropdownMenu.Item, {
6197
+ asChild: true,
6198
+ className: MENU_ITEM,
6199
+ children: /* @__PURE__ */ jsx("a", {
6200
+ href: "/templates/agents?new=1",
6201
+ children: "Create an Agent template"
6202
+ })
6203
+ }) : profiles.map((profile) => /* @__PURE__ */ jsxs(DropdownMenu.Item, {
6204
+ className: MENU_ITEM,
6205
+ onSelect: () => onSpawnAgent(profile.id),
6206
+ children: [/* @__PURE__ */ jsx("span", {
6207
+ className: "min-w-0 flex-1 truncate",
6208
+ children: profile.name || profile.id
6209
+ }), profile.id === "default" && /* @__PURE__ */ jsx("span", {
6210
+ className: "rounded-full border border-border bg-muted px-1.5 py-0.5 text-xs font-semibold text-muted-foreground",
6211
+ children: "Default"
6212
+ })]
6213
+ }, profile.id)),
6214
+ /* @__PURE__ */ jsx(DropdownMenu.Separator, { className: "my-1.5 h-px bg-border" }),
6215
+ /* @__PURE__ */ jsxs(DropdownMenu.Label, {
6216
+ className: MENU_LABEL,
6217
+ children: [/* @__PURE__ */ jsx(UsersRound, {
6218
+ className: "size-3",
6219
+ "aria-hidden": "true"
6220
+ }), "Team templates"]
6221
+ }),
6222
+ teamTemplates.length === 0 ? /* @__PURE__ */ jsx(DropdownMenu.Item, {
6223
+ asChild: true,
6224
+ className: MENU_ITEM,
6225
+ children: /* @__PURE__ */ jsx("a", {
6226
+ href: "/templates/teams?new=1",
6227
+ children: "Create a Team template"
6228
+ })
6229
+ }) : teamTemplates.map((entry) => /* @__PURE__ */ jsxs(DropdownMenu.Item, {
6230
+ className: MENU_ITEM,
6231
+ disabled: entry.slots.length === 0,
6232
+ title: entry.slots.length === 0 ? "Add at least one member before spawning" : void 0,
6233
+ onSelect: () => onSpawnTeam(entry.id),
6234
+ children: [/* @__PURE__ */ jsx("span", {
6235
+ className: "min-w-0 flex-1 truncate",
6236
+ children: entry.name || entry.id
6237
+ }), /* @__PURE__ */ jsx("span", {
6238
+ className: "inline-flex min-w-6 items-center justify-center rounded-full bg-muted px-1.5 font-mono text-xs text-muted-foreground",
6239
+ children: entry.slots.length
6240
+ })]
6241
+ }, entry.id)),
6242
+ /* @__PURE__ */ jsx(DropdownMenu.Separator, { className: "my-1.5 h-px bg-border" }),
6243
+ /* @__PURE__ */ jsxs(DropdownMenu.Item, {
6244
+ className: MENU_ITEM,
6245
+ onSelect: onCreateTeam,
6246
+ children: [/* @__PURE__ */ jsx(Plus, {
6247
+ className: "size-3.5",
6248
+ "aria-hidden": "true"
6249
+ }), "Create a Team"]
6250
+ })
6251
+ ]
6252
+ }) })]
6253
+ });
6254
+ }
6255
+ //#endregion
6256
+ //#region src/components/workspace/rail/order.ts
6257
+ /** The Default Team first, then the rest as the daemon lists them. */
6258
+ function sortTeams(teams) {
6259
+ return [...teams].sort((a, b) => Number(b.id === DEFAULT_TEAM_ID) - Number(a.id === DEFAULT_TEAM_ID));
6260
+ }
6261
+ /** The seeded default template first: the one-click path for a new install. */
6262
+ function sortProfiles(profiles) {
6263
+ return [...profiles].sort((a, b) => Number(b.id === DEFAULT_PROFILE_ID) - Number(a.id === DEFAULT_PROFILE_ID));
6264
+ }
6265
+ /** The folded rail's Teams: only those with Agents, the Team in view first. */
6266
+ function slimTeams(teams, agents, inViewId) {
6267
+ const sorted = sortTeams(teams).filter((team) => agents.some((agent) => agent.teamId === team.id));
6268
+ sorted.sort((a, b) => Number(b.id === inViewId) - Number(a.id === inViewId));
6269
+ return sorted;
6270
+ }
6271
+ //#endregion
6272
+ //#region src/components/workspace/rail/AgentRow.tsx
6273
+ function AgentRow({ agent, selected, state, lastActivityAt, panel, onRename, onArchive }) {
6274
+ const hydrated = useHydrated();
6275
+ return /* @__PURE__ */ jsxs("div", {
6276
+ className: "group/row relative rounded-2xl",
6277
+ children: [/* @__PURE__ */ jsxs(Link, {
6278
+ to: "/",
6279
+ search: {
6280
+ agent: agent.id,
6281
+ ...panel ? { panel } : {}
6282
+ },
6283
+ "aria-current": selected ? "page" : void 0,
6284
+ className: `flex min-h-[3.1rem] items-center gap-2.5 rounded-2xl border py-1.5 pl-2 pr-9 transition-colors hover:bg-accent/60 ${selected ? "border-primary/20 bg-accent shadow-baziu-sm" : "border-transparent"}`,
6285
+ children: [/* @__PURE__ */ jsx(AgentAvatar, {
6286
+ identity: agent.identity,
6287
+ size: 30
6288
+ }), /* @__PURE__ */ jsxs("span", {
6289
+ className: "block min-w-0 flex-1",
6290
+ children: [/* @__PURE__ */ jsxs("span", {
6291
+ className: "flex items-center gap-1.5",
6292
+ children: [
6293
+ /* @__PURE__ */ jsx("span", {
6294
+ className: `min-w-0 truncate text-sm font-semibold leading-tight ${selected ? "text-accent-foreground" : "text-foreground"}`,
6295
+ children: agent.name
6296
+ }),
6297
+ agent.telegramTopicId !== null && /* @__PURE__ */ jsx("span", {
6298
+ className: "shrink-0 text-primary",
6299
+ title: `Telegram topic #${agent.telegramTopicId}`,
6300
+ role: "img",
6301
+ "aria-label": `Bound to Telegram topic ${agent.telegramTopicId}`,
6302
+ children: /* @__PURE__ */ jsx(Send, {
6303
+ className: "size-3",
6304
+ "aria-hidden": "true"
6305
+ })
6306
+ }),
6307
+ hydrated && lastActivityAt !== null && /* @__PURE__ */ jsx("time", {
6308
+ dateTime: new Date(lastActivityAt).toISOString(),
6309
+ className: "ml-auto shrink-0 text-xs font-normal text-muted-foreground",
6310
+ children: shortTime(lastActivityAt)
6311
+ })
6312
+ ]
6313
+ }), /* @__PURE__ */ jsxs("span", {
6314
+ className: `mt-0.5 flex items-center gap-1.5 text-xs leading-snug ${STATE_TEXT[state.kind]}`,
6315
+ children: [/* @__PURE__ */ jsx("span", {
6316
+ className: `size-[7px] shrink-0 rounded-full ${STATE_DOT[state.kind]}`,
6317
+ "aria-hidden": "true"
6318
+ }), /* @__PURE__ */ jsx("span", {
6319
+ className: "min-w-0 truncate",
6320
+ children: state.text
6321
+ })]
6322
+ })]
6323
+ })]
6324
+ }), /* @__PURE__ */ jsxs(DropdownMenu.Root, {
6325
+ modal: false,
6326
+ children: [/* @__PURE__ */ jsx(DropdownMenu.Trigger, {
6327
+ asChild: true,
6328
+ children: /* @__PURE__ */ jsx("button", {
6329
+ type: "button",
6330
+ "aria-label": `More for ${agent.name}`,
6331
+ className: "unstyled absolute right-1 top-1/2 flex size-7 -translate-y-1/2 items-center justify-center rounded-lg text-muted-foreground opacity-0 transition-opacity hover:bg-card hover:text-primary focus-visible:opacity-100 group-hover/row:opacity-100 data-[state=open]:opacity-100 [@media(hover:none)]:opacity-100",
6332
+ children: /* @__PURE__ */ jsx(Ellipsis, {
6333
+ className: "size-4",
6334
+ "aria-hidden": "true"
6335
+ })
6336
+ })
6337
+ }), /* @__PURE__ */ jsx(DropdownMenu.Portal, { children: /* @__PURE__ */ jsxs(DropdownMenu.Content, {
6338
+ align: "start",
6339
+ sideOffset: 4,
6340
+ className: "z-50 w-48 rounded-xl border border-border bg-popover p-1.5 text-popover-foreground shadow-baziu-lg outline-none",
6341
+ children: [
6342
+ /* @__PURE__ */ jsx(DropdownMenu.Item, {
6343
+ asChild: true,
6344
+ className: MENU_ITEM,
6345
+ children: /* @__PURE__ */ jsxs(Link, {
6346
+ to: "/",
6347
+ search: {
6348
+ agent: agent.id,
6349
+ panel: "agent"
6350
+ },
6351
+ children: [/* @__PURE__ */ jsx(Settings2, {
6352
+ className: "size-3.5",
6353
+ "aria-hidden": "true"
6354
+ }), "Agent settings"]
6355
+ })
6356
+ }),
6357
+ /* @__PURE__ */ jsxs(DropdownMenu.Item, {
6358
+ className: MENU_ITEM,
6359
+ onSelect: onRename,
6360
+ children: [/* @__PURE__ */ jsx(Pencil, {
6361
+ className: "size-3.5",
6362
+ "aria-hidden": "true"
6363
+ }), "Rename"]
6364
+ }),
6365
+ /* @__PURE__ */ jsxs(DropdownMenu.Item, {
6366
+ className: MENU_ITEM,
6367
+ onSelect: onArchive,
6368
+ children: [/* @__PURE__ */ jsx(Archive, {
6369
+ className: "size-3.5",
6370
+ "aria-hidden": "true"
6371
+ }), "Archive"]
6372
+ })
6373
+ ]
6374
+ }) })]
6375
+ })]
6376
+ });
6377
+ }
6378
+ //#endregion
6379
+ //#region src/components/workspace/rail/TeamGroup.tsx
6380
+ function TeamGroup({ team, members, current, isOpen, onOpenChange, openAgentId, selectedId, activity, panel, onRename, onArchive }) {
6381
+ const summary = teamSummary(members.map((agent) => activity.stateOf(agent.id)));
6382
+ return /* @__PURE__ */ jsxs("div", {
6383
+ className: "relative mb-1 last:mb-0",
6384
+ children: [/* @__PURE__ */ jsxs("details", {
6385
+ open: isOpen,
6386
+ onToggle: (event) => {
6387
+ const next = event.currentTarget.open;
6388
+ if (next === isOpen) return;
6389
+ onOpenChange(next);
6390
+ },
6391
+ className: "group/details",
6392
+ children: [/* @__PURE__ */ jsxs("summary", {
6393
+ className: `flex min-h-9 cursor-pointer list-none items-center gap-1.5 rounded-lg py-1 pl-2 pr-9 text-sm transition-colors hover:bg-accent/60 [&::-webkit-details-marker]:hidden ${current ? "bg-muted text-foreground" : "text-mocha"}`,
6394
+ children: [
6395
+ /* @__PURE__ */ jsx(ChevronRight, {
6396
+ className: "size-3.5 shrink-0 text-muted-foreground transition-transform group-open/details:rotate-90",
6397
+ "aria-hidden": "true"
6398
+ }),
6399
+ /* @__PURE__ */ jsx("span", {
6400
+ className: "min-w-0 flex-1 truncate font-semibold",
6401
+ children: team.name
6402
+ }),
6403
+ /* @__PURE__ */ jsx("span", {
6404
+ className: "shrink-0 text-xs text-muted-foreground",
6405
+ children: summary || members.length
6406
+ })
6407
+ ]
6408
+ }), members.length === 0 ? /* @__PURE__ */ jsx("div", {
6409
+ className: "py-2 pl-7 pr-2 text-xs text-muted-foreground",
6410
+ children: "No agents in this team"
6411
+ }) : /* @__PURE__ */ jsx("div", {
6412
+ className: "space-y-0.5 py-1 pl-1.5",
6413
+ children: members.map((agent) => /* @__PURE__ */ jsx(AgentRow, {
6414
+ agent,
6415
+ selected: agent.id === selectedId,
6416
+ state: activity.stateOf(agent.id),
6417
+ lastActivityAt: activity.byAgent.get(agent.id)?.lastActivityAt ?? null,
6418
+ panel,
6419
+ onRename: () => onRename(agent),
6420
+ onArchive: () => onArchive(agent)
6421
+ }, agent.id))
6422
+ })]
6423
+ }), /* @__PURE__ */ jsx(Link, {
6424
+ to: "/",
6425
+ search: {
6426
+ ...openAgentId !== null ? { agent: openAgentId } : {},
6427
+ team: team.id,
6428
+ panel: "team"
6429
+ },
6430
+ "aria-label": `Open ${team.name}: members, USER.md, memory`,
6431
+ title: "Open the Team",
6432
+ className: "absolute right-1 top-1 flex size-7 items-center justify-center rounded-lg text-muted-foreground hover:bg-card hover:text-primary",
6433
+ children: /* @__PURE__ */ jsx(PanelRight, {
6434
+ className: "size-3.5",
6435
+ "aria-hidden": "true"
6436
+ })
6437
+ })]
6438
+ });
6439
+ }
6440
+ //#endregion
6441
+ //#region src/components/workspace/rail/Rail.tsx
6442
+ function Rail({ initialOpenGroups }) {
6443
+ const { agents, teams, profiles, teamTemplates, agent: open, team: inView, search } = useWorkspace();
6444
+ const activity = useActivity();
6445
+ const router = useRouter();
6446
+ const [spawnProfile, setSpawnProfile] = useState(null);
6447
+ const [spawnTeam, setSpawnTeam] = useState(void 0);
6448
+ const [spawnTemplate, setSpawnTemplate] = useState(null);
6449
+ const [createTeamOpen, setCreateTeamOpen] = useState(false);
6450
+ const [createTeamBusy, setCreateTeamBusy] = useState(false);
6451
+ const [renameTarget, setRenameTarget] = useState(null);
6452
+ const [archiveTarget, setArchiveTarget] = useState(null);
6453
+ const [openGroups, setOpenGroups] = useState(initialOpenGroups);
6454
+ const newButton = useRef(null);
6455
+ const refocusNewButton = () => window.requestAnimationFrame(() => newButton.current?.focus());
6456
+ const sortedProfiles = sortProfiles(profiles);
6457
+ const sortedTeams = sortTeams(teams);
6458
+ const template = teamTemplates.find((entry) => entry.id === spawnTemplate);
6459
+ const selectedId = open?.agent.id ?? null;
6460
+ return /* @__PURE__ */ jsxs("aside", {
6461
+ className: "flex h-full flex-col overflow-hidden rounded-2xl border border-border bg-card shadow-baziu-sm",
6462
+ children: [
6463
+ /* @__PURE__ */ jsxs("header", {
6464
+ className: "flex items-center justify-between gap-3 border-b border-border bg-muted/60 px-3 py-2.5",
6465
+ children: [/* @__PURE__ */ jsxs("div", {
6466
+ className: "flex min-w-0 items-center gap-2",
6467
+ children: [/* @__PURE__ */ jsx("span", {
6468
+ className: "flex size-7 shrink-0 items-center justify-center rounded-[10px] bg-accent text-accent-foreground",
6469
+ children: /* @__PURE__ */ jsx(UsersRound, {
6470
+ className: "size-4",
6471
+ "aria-hidden": "true"
6472
+ })
6473
+ }), /* @__PURE__ */ jsxs("div", {
6474
+ className: "min-w-0",
6475
+ children: [/* @__PURE__ */ jsx("div", {
6476
+ className: "text-sm font-semibold leading-tight text-foreground",
6477
+ children: "Teams"
6478
+ }), /* @__PURE__ */ jsxs("p", {
6479
+ className: "m-0 truncate text-xs leading-snug text-muted-foreground",
6480
+ children: [
6481
+ agents.length,
6482
+ " agent",
6483
+ agents.length === 1 ? "" : "s",
6484
+ " in ",
6485
+ teams.length,
6486
+ " team",
6487
+ teams.length === 1 ? "" : "s"
6488
+ ]
6489
+ })]
6490
+ })]
6491
+ }), /* @__PURE__ */ jsx(NewMenu, {
6492
+ buttonRef: newButton,
6493
+ profiles: sortedProfiles,
6494
+ teamTemplates,
6495
+ onSpawnAgent: (profileId) => {
6496
+ setSpawnTeam(inView?.id);
6497
+ setSpawnProfile(profileId);
6498
+ },
6499
+ onSpawnTeam: (templateId) => setSpawnTemplate(templateId),
6500
+ onCreateTeam: () => setCreateTeamOpen(true)
6501
+ })]
6502
+ }),
6503
+ /* @__PURE__ */ jsxs("nav", {
6504
+ className: "flex-1 overflow-y-auto p-1.5",
6505
+ "aria-label": "Teams and agents",
6506
+ children: [agents.length === 0 && /* @__PURE__ */ jsxs("div", {
6507
+ className: "m-1 mb-2 flex flex-col items-center rounded-xl border border-dashed border-border bg-muted/30 px-4 py-6 text-center",
6508
+ children: [
6509
+ /* @__PURE__ */ jsx("p", {
6510
+ className: "m-0 text-sm font-semibold text-foreground",
6511
+ children: "No agents yet"
6512
+ }),
6513
+ /* @__PURE__ */ jsx("p", {
6514
+ className: "mt-1 text-xs leading-5 text-muted-foreground",
6515
+ children: "Your default Team is ready. Spawn the first agent to start a conversation."
6516
+ }),
6517
+ sortedProfiles[0] ? /* @__PURE__ */ jsx(Button, {
6518
+ variant: "primary",
6519
+ className: "mt-3",
6520
+ onClick: () => setSpawnProfile(sortedProfiles[0]?.id ?? "default"),
6521
+ children: "Spawn first agent"
6522
+ }) : /* @__PURE__ */ jsx("a", {
6523
+ href: "/templates/agents?new=1",
6524
+ className: "mt-3 text-xs font-semibold",
6525
+ children: "Create an Agent template"
6526
+ })
6527
+ ]
6528
+ }), sortedTeams.map((team) => {
6529
+ const current = inView?.id === team.id;
6530
+ return /* @__PURE__ */ jsx(TeamGroup, {
6531
+ team,
6532
+ members: agents.filter((agent) => agent.teamId === team.id),
6533
+ current,
6534
+ isOpen: isGroupOpen(openGroups, team.id, current),
6535
+ onOpenChange: (next) => {
6536
+ const merged = {
6537
+ ...openGroups,
6538
+ [team.id]: next
6539
+ };
6540
+ writeOpenGroupsCookie(merged);
6541
+ setOpenGroups(merged);
6542
+ },
6543
+ openAgentId: open?.team.id === team.id ? open.agent.id : null,
6544
+ selectedId,
6545
+ activity,
6546
+ panel: search.panel,
6547
+ onRename: (agent) => setRenameTarget(agent),
6548
+ onArchive: (agent) => setArchiveTarget(agent)
6549
+ }, team.id);
6550
+ })]
6551
+ }),
6552
+ spawnProfile && /* @__PURE__ */ jsx(SpawnDialog, {
6553
+ profiles: sortedProfiles,
6554
+ teams: sortedTeams,
6555
+ profileId: spawnProfile,
6556
+ teamId: spawnTeam,
6557
+ onClose: () => {
6558
+ setSpawnProfile(null);
6559
+ refocusNewButton();
6560
+ }
6561
+ }),
6562
+ template && /* @__PURE__ */ jsx(SpawnTeamModal, {
6563
+ template,
6564
+ teams: sortedTeams,
6565
+ onClose: () => {
6566
+ setSpawnTemplate(null);
6567
+ refocusNewButton();
6568
+ },
6569
+ onSpawned: (slug) => {
6570
+ setSpawnTemplate(null);
6571
+ router.navigate({
6572
+ to: "/",
6573
+ search: {
6574
+ team: slug,
6575
+ panel: "team"
6576
+ }
6577
+ });
6578
+ }
6579
+ }),
6580
+ createTeamOpen && /* @__PURE__ */ jsx(Dialog$1, {
6581
+ title: "Create a Team",
6582
+ description: "A Team is one workspace: its folder, its Agents, its USER.md and shared memory, and who may message whom.",
6583
+ busy: createTeamBusy,
6584
+ onClose: () => {
6585
+ setCreateTeamOpen(false);
6586
+ refocusNewButton();
6587
+ },
6588
+ children: /* @__PURE__ */ jsx(TeamForm, {
6589
+ onBusyChange: setCreateTeamBusy,
6590
+ onCreated: async (team) => {
6591
+ setCreateTeamOpen(false);
6592
+ await router.navigate({
6593
+ to: "/",
6594
+ search: {
6595
+ team: team.id,
6596
+ panel: "team"
6597
+ }
6598
+ });
6599
+ },
6600
+ extraActions: (busy) => /* @__PURE__ */ jsx(Button, {
6601
+ variant: "ghost",
6602
+ disabled: busy,
6603
+ onClick: () => setCreateTeamOpen(false),
6604
+ children: "Cancel"
6605
+ })
6606
+ })
6607
+ }),
6608
+ renameTarget && /* @__PURE__ */ jsx(RenameAgentDialog, {
6609
+ agent: renameTarget,
6610
+ onClose: () => setRenameTarget(null),
6611
+ onRenamed: () => router.invalidate()
6612
+ }),
6613
+ /* @__PURE__ */ jsx(ConfirmDialog, {
6614
+ open: archiveTarget !== null,
6615
+ onOpenChange: (next) => {
6616
+ if (!next) setArchiveTarget(null);
6617
+ },
6618
+ title: `Archive ${archiveTarget?.name ?? "agent"}?`,
6619
+ description: /* @__PURE__ */ jsx("p", { children: "The Agent leaves this list and receives no work. Restore it later under Manage → Agents, in Archived." }),
6620
+ confirmLabel: "Archive agent",
6621
+ confirmVariant: "primary",
6622
+ onConfirm: async () => {
6623
+ if (!archiveTarget) return;
6624
+ await archiveAgent(archiveTarget.id);
6625
+ if (archiveTarget.id === selectedId) await router.navigate({
6626
+ to: "/",
6627
+ search: {}
6628
+ });
6629
+ else await router.invalidate();
6630
+ }
6631
+ })
6632
+ ]
6633
+ });
6634
+ }
6635
+ //#endregion
6636
+ //#region src/components/workspace/rail/SlimRail.tsx
6637
+ /** The rail folded to avatars, beside a full-width view. */
6638
+ function SlimRail() {
6639
+ const { agents, teams, agent: open, team: inView, search } = useWorkspace();
6640
+ const activity = useActivity();
6641
+ const sortedTeams = slimTeams(teams, agents, inView?.id);
6642
+ return /* @__PURE__ */ jsxs("nav", {
6643
+ "aria-label": "Agents",
6644
+ className: "flex h-full w-16 flex-col items-center gap-2 overflow-y-auto rounded-xl border border-border bg-card py-2.5 shadow-baziu-sm",
6645
+ children: [/* @__PURE__ */ jsx(Link, {
6646
+ to: "/",
6647
+ search: {
6648
+ ...search,
6649
+ view: void 0,
6650
+ file: void 0,
6651
+ result: void 0
6652
+ },
6653
+ "aria-label": "Back to the conversation and the full list",
6654
+ title: "Back to the conversation",
6655
+ className: "flex size-10 shrink-0 items-center justify-center rounded-xl text-mocha hover:bg-accent hover:text-accent-foreground",
6656
+ children: /* @__PURE__ */ jsx(PanelLeft, {
6657
+ className: "size-[18px]",
6658
+ "aria-hidden": "true"
6659
+ })
6660
+ }), sortedTeams.map((team) => /* @__PURE__ */ jsxs("div", {
6661
+ className: "flex w-full flex-col items-center gap-2",
6662
+ children: [
6663
+ /* @__PURE__ */ jsx("div", { className: "h-px w-8 bg-border" }),
6664
+ /* @__PURE__ */ jsx("span", {
6665
+ className: `max-w-14 truncate text-xs font-bold uppercase tracking-[0.06em] ${team.id === inView?.id ? "text-accent-foreground" : "text-muted-foreground"}`,
6666
+ title: team.name,
6667
+ children: team.name
6668
+ }),
6669
+ agents.filter((agent) => agent.teamId === team.id).map((agent) => {
6670
+ const state = activity.stateOf(agent.id);
6671
+ return /* @__PURE__ */ jsxs(Link, {
6672
+ to: "/",
6673
+ search: {
6674
+ agent: agent.id,
6675
+ ...search.panel ? { panel: search.panel } : {}
6676
+ },
6677
+ "aria-label": `${agent.name}: ${state.text}`,
6678
+ title: `${agent.name}: ${state.text}`,
6679
+ className: `relative flex size-10 shrink-0 items-center justify-center rounded-full ${agent.id === open?.agent.id ? "ring-2 ring-primary ring-offset-2 ring-offset-card" : ""}`,
6680
+ children: [/* @__PURE__ */ jsx(AgentAvatar, {
6681
+ identity: agent.identity,
6682
+ size: 40
6683
+ }), /* @__PURE__ */ jsx("span", {
6684
+ className: `absolute -bottom-px -right-px size-3 rounded-full border-2 border-card ${STATE_DOT[state.kind]}`,
6685
+ "aria-hidden": "true"
6686
+ })]
6687
+ }, agent.id);
6688
+ })
6689
+ ]
6690
+ }, team.id))]
6691
+ });
6692
+ }
6693
+ //#endregion
5867
6694
  //#region src/components/AgentBrowserCard.tsx
5868
6695
  var MODE = {
5869
6696
  headless: "without a window",
@@ -7132,6 +7959,19 @@ function AgentSchedules({ agent }) {
7132
7959
  onChanged: data.reload
7133
7960
  });
7134
7961
  }
7962
+ /** "Next run in 5 min", "Next run Mon 24 Nov, 09:00": when a schedule runs next, in words. */
7963
+ function nextRunWords(at, now) {
7964
+ const wait = at - now;
7965
+ if (wait < 6e4) return "Next run now";
7966
+ if (wait < 36e5) return `Next run in ${Math.round(wait / 6e4)} min`;
7967
+ return `Next run ${new Date(at).toLocaleString(void 0, {
7968
+ weekday: "short",
7969
+ day: "numeric",
7970
+ month: "short",
7971
+ hour: "2-digit",
7972
+ minute: "2-digit"
7973
+ })}`;
7974
+ }
7135
7975
  var RUN = {
7136
7976
  pending: {
7137
7977
  label: "Waiting for the Agent",
@@ -7155,7 +7995,7 @@ var RUN = {
7155
7995
  }
7156
7996
  };
7157
7997
  /** The schedules and their recent runs, as loaded. */
7158
- function SchedulesView({ agentId, agentName = "The Agent", triggers, dispatches, onChanged }) {
7998
+ function SchedulesView({ agentId, agentName = "The Agent", triggers, dispatches, nextRuns, schedulerOff, onChanged }) {
7159
7999
  const [adding, setAdding] = useState(false);
7160
8000
  const [removing, setRemoving] = useState(null);
7161
8001
  const [error, setError] = useState(null);
@@ -7194,64 +8034,78 @@ function SchedulesView({ agentId, agentName = "The Agent", triggers, dispatches,
7194
8034
  "aria-hidden": "true"
7195
8035
  }), "Add a schedule"]
7196
8036
  }),
7197
- children: [error && /* @__PURE__ */ jsx("div", {
7198
- className: "border-t border-border px-4 py-3 sm:px-5",
7199
- children: /* @__PURE__ */ jsx(Notice, {
7200
- role: "alert",
7201
- title: "That did not work.",
7202
- children: error
7203
- })
7204
- }), triggers.length === 0 ? /* @__PURE__ */ jsxs(CardEmpty, {
7205
- icon: /* @__PURE__ */ jsx(CalendarClock, { className: "size-5" }),
7206
- title: "No schedules yet",
7207
- action: /* @__PURE__ */ jsxs(Button, {
7208
- variant: "primary",
7209
- onClick: () => setAdding(true),
7210
- children: [/* @__PURE__ */ jsx(Plus, {
7211
- className: "size-4",
7212
- "aria-hidden": "true"
7213
- }), "Add a schedule"]
8037
+ children: [
8038
+ error && /* @__PURE__ */ jsx("div", {
8039
+ className: "border-t border-border px-4 py-3 sm:px-5",
8040
+ children: /* @__PURE__ */ jsx(Notice, {
8041
+ role: "alert",
8042
+ title: "That did not work.",
8043
+ children: error
8044
+ })
7214
8045
  }),
7215
- children: [
7216
- "A schedule gives ",
7217
- agentName,
7218
- " a message at set times: a morning check, a weekly summary."
7219
- ]
7220
- }) : /* @__PURE__ */ jsx(CardList, { children: triggers.map((trigger) => {
7221
- const schedule = describeSchedule(trigger);
7222
- return /* @__PURE__ */ jsx(ListRow, {
7223
- inline: true,
7224
- title: schedule.raw ? /* @__PURE__ */ jsx("code", {
7225
- className: "font-mono text-[0.92em]",
7226
- children: schedule.text
7227
- }) : schedule.text,
7228
- chip: trigger.enabled ? /* @__PURE__ */ jsx(Chip, {
7229
- tone: "success",
7230
- children: "On"
7231
- }) : /* @__PURE__ */ jsx(Chip, {
7232
- tone: "neutral",
7233
- children: "Paused"
7234
- }),
7235
- meta: /* @__PURE__ */ jsx("span", { children: trigger.lastFiredAt ? `Last ran ${when(trigger.lastFiredAt)}` : "Has not run yet" }),
7236
- actions: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Switch, {
7237
- label: `${schedule.text}: ${trigger.enabled ? "on" : "paused"}`,
7238
- checked: trigger.enabled,
7239
- disabled: busyId === trigger.id,
7240
- onChange: () => void toggle(trigger)
7241
- }), /* @__PURE__ */ jsx(RowMenu, {
7242
- label: `More for ${schedule.text}`,
7243
- items: [{
7244
- label: "Delete…",
7245
- danger: true,
7246
- onSelect: () => setRemoving(trigger)
7247
- }]
7248
- })] }),
7249
- children: /* @__PURE__ */ jsx("p", {
7250
- className: "m-0 whitespace-pre-wrap break-words rounded-xl bg-muted/50 px-3 py-2 text-sm text-foreground",
7251
- children: trigger.message
8046
+ schedulerOff && triggers.length > 0 && /* @__PURE__ */ jsx("div", {
8047
+ className: "border-t border-border px-4 py-3 sm:px-5",
8048
+ children: /* @__PURE__ */ jsxs(Notice, {
8049
+ title: "No schedule runs on this daemon",
8050
+ children: [
8051
+ "It was started with ",
8052
+ /* @__PURE__ */ jsx("code", { children: "BAZILION_SCHEDULER=off" }),
8053
+ "."
8054
+ ]
7252
8055
  })
7253
- }, trigger.id);
7254
- }) })]
8056
+ }),
8057
+ triggers.length === 0 ? /* @__PURE__ */ jsxs(CardEmpty, {
8058
+ icon: /* @__PURE__ */ jsx(CalendarClock, { className: "size-5" }),
8059
+ title: "No schedules yet",
8060
+ action: /* @__PURE__ */ jsxs(Button, {
8061
+ variant: "primary",
8062
+ onClick: () => setAdding(true),
8063
+ children: [/* @__PURE__ */ jsx(Plus, {
8064
+ className: "size-4",
8065
+ "aria-hidden": "true"
8066
+ }), "Add a schedule"]
8067
+ }),
8068
+ children: [
8069
+ "A schedule gives ",
8070
+ agentName,
8071
+ " a message at set times: a morning check, a weekly summary."
8072
+ ]
8073
+ }) : /* @__PURE__ */ jsx(CardList, { children: triggers.map((trigger) => {
8074
+ const schedule = describeSchedule(trigger);
8075
+ return /* @__PURE__ */ jsx(ListRow, {
8076
+ inline: true,
8077
+ title: schedule.raw ? /* @__PURE__ */ jsx("code", {
8078
+ className: "font-mono text-[0.92em]",
8079
+ children: schedule.text
8080
+ }) : schedule.text,
8081
+ chip: trigger.enabled ? /* @__PURE__ */ jsx(Chip, {
8082
+ tone: "success",
8083
+ children: "On"
8084
+ }) : /* @__PURE__ */ jsx(Chip, {
8085
+ tone: "neutral",
8086
+ children: "Paused"
8087
+ }),
8088
+ meta: /* @__PURE__ */ jsxs(Fragment$1, { children: [hydrated && typeof nextRuns[trigger.id] === "number" && /* @__PURE__ */ jsx("span", { children: nextRunWords(nextRuns[trigger.id], Date.now()) }), /* @__PURE__ */ jsx("span", { children: trigger.lastFiredAt ? `Last ran ${when(trigger.lastFiredAt)}` : "Has not run yet" })] }),
8089
+ actions: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Switch, {
8090
+ label: `${schedule.text}: ${trigger.enabled ? "on" : "paused"}`,
8091
+ checked: trigger.enabled,
8092
+ disabled: busyId === trigger.id,
8093
+ onChange: () => void toggle(trigger)
8094
+ }), /* @__PURE__ */ jsx(RowMenu, {
8095
+ label: `More for ${schedule.text}`,
8096
+ items: [{
8097
+ label: "Delete…",
8098
+ danger: true,
8099
+ onSelect: () => setRemoving(trigger)
8100
+ }]
8101
+ })] }),
8102
+ children: /* @__PURE__ */ jsx("p", {
8103
+ className: "m-0 whitespace-pre-wrap break-words rounded-xl bg-muted/50 px-3 py-2 text-sm text-foreground",
8104
+ children: trigger.message
8105
+ })
8106
+ }, trigger.id);
8107
+ }) })
8108
+ ]
7255
8109
  }),
7256
8110
  /* @__PURE__ */ jsx(SetupCard, {
7257
8111
  labelledBy: "agent-schedule-runs",
@@ -8564,7 +9418,7 @@ function WaitingRow({ agent, team, text }) {
8564
9418
  //#endregion
8565
9419
  //#region src/routes/index.tsx?tsr-split=component
8566
9420
  /** The rail's open/closed Teams; a bad cookie is ignored. */
8567
- var ConnectionsView = lazy(() => import("./ConnectionsView-CLIV7V5D.js").then((module) => ({ default: module.ConnectionsView })));
9421
+ var ConnectionsView = lazy(() => import("./ConnectionsView-Dy6uYSRI.js").then((module) => ({ default: module.ConnectionsView })));
8568
9422
  function WorkspacePage() {
8569
9423
  const data = Route.useLoaderData();
8570
9424
  const search = Route.useSearch();