bazilion 0.55.0 → 0.57.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 (193) hide show
  1. package/dist/cli.js +193 -37
  2. package/dist/cli.js.map +1 -1
  3. package/dist/daemon.js +1821 -788
  4. package/dist/daemon.js.map +1 -1
  5. package/dist/web/client/assets/AddProviderDialog-DwUu2FGE.js +1 -0
  6. package/dist/web/client/assets/AgentTemplateParts-C3BasVck.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-DFmHgEaL.js +1 -0
  9. package/dist/web/client/assets/ConfirmDialog-BCOfW63x.js +1 -0
  10. package/dist/web/client/assets/ConnectionsView-BbpY5YbI.js +1 -0
  11. package/dist/web/client/assets/ManagePage-BzyMHGqs.js +1 -0
  12. package/dist/web/client/assets/SectionTabs-C8H_LunZ.js +1 -0
  13. package/dist/web/client/assets/{Segmented-oPkAHPO1.js → Segmented-iylzLwE6.js} +1 -1
  14. package/dist/web/client/assets/SkillsParts-DoygBgF2.js +1 -0
  15. package/dist/web/client/assets/SpawnTeamModal-BVf4yN9X.js +1 -0
  16. package/dist/web/client/assets/TeamForm-Bfb5hVUX.js +1 -0
  17. package/dist/web/client/assets/TeamThread-BFmaBj82.js +1 -0
  18. package/dist/web/client/assets/UnsavedChangesGuard-BUsIHSxO.js +1 -0
  19. package/dist/web/client/assets/_id-BRD3kxrX.js +1 -0
  20. package/dist/web/client/assets/_id-BapVoTMJ.js +1 -0
  21. package/dist/web/client/assets/access-CqcKius1.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-BC_ITk28.js +1 -0
  24. package/dist/web/client/assets/agents-DQ8nQnD6.js +1 -0
  25. package/dist/web/client/assets/arrow-right-BqqfPqVi.js +1 -0
  26. package/dist/web/client/assets/attention-BnCihfi0.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-DYS8bkQl.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-DZDOQ3kj.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-CxXsZzDC.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-DFVsVP0s.js +1 -0
  40. package/dist/web/client/assets/{manage-BaIU5zKy.js → manage-CpXaObuS.js} +1 -1
  41. package/dist/web/client/assets/mcp-DslGDHmN.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-C104qEuC.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-D1wFPm0n.js +85 -0
  48. package/dist/web/client/assets/skills-DmIo3vN3.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-CqkCFvvz.js +7 -0
  51. package/dist/web/client/assets/styles-C7NsCHeU.css +2 -0
  52. package/dist/web/client/assets/{system-CrTSr5_t.js → system-CUW9JZ9c.js} +1 -1
  53. package/dist/web/client/assets/teams-DJzYsuh9.js +1 -0
  54. package/dist/web/client/assets/teams-DrhG8KiS.js +1 -0
  55. package/dist/web/client/assets/telegram-Bk_kg8hb.js +1 -0
  56. package/dist/web/client/assets/tools-z9Ixmuu2.js +1 -0
  57. package/dist/web/client/assets/usage-DGe3x1m7.js +1 -0
  58. package/dist/web/client/assets/use-resource-qjIkNQDY.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-DDKqxHkF.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-CpLDHOcA.js} +6 -3
  63. package/dist/web/server/assets/AgentAvatar-8gTAy_tP.js +37 -0
  64. package/dist/web/server/assets/{AgentTemplateParts-Ce7snK3m.js → AgentTemplateParts-Dh9F_-T_.js} +7 -3
  65. package/dist/web/server/assets/Button-Dsnw22OF.js +17 -0
  66. package/dist/web/server/assets/{ConfigPage-qP9ejjuw.js → ConfigPage-CrxctbtN.js} +2 -2
  67. package/dist/web/server/assets/{ConfirmDialog-Z-uYbE9B.js → ConfirmDialog-C89B8qKM.js} +3 -1
  68. package/dist/web/server/assets/{ConnectionsView-CLIV7V5D.js → ConnectionsView-DslcKQmA.js} +9 -7
  69. package/dist/web/server/assets/Dialog-_Gt_Nt86.js +85 -0
  70. package/dist/web/server/assets/{ManagePage-BR9FwVZM.js → ManagePage-DGYNJ6XG.js} +2 -2
  71. package/dist/web/server/assets/{ModelMenu-D-hTgYOO.js → ModelMenu-DEJoYASj.js} +13 -1
  72. package/dist/web/server/assets/{SectionTabs-CWQ5orUW.js → SectionTabs--vMBvaUz.js} +9 -2
  73. package/dist/web/server/assets/{SkillsParts-DWpdydCJ.js → SkillsParts-CqS2B45v.js} +7 -3
  74. package/dist/web/server/assets/SpawnDialog-BNKj2Lup.js +127 -0
  75. package/dist/web/server/assets/{SpawnTeamModal-C-YMvoaB.js → SpawnTeamModal-zcLxtFOO.js} +6 -2
  76. package/dist/web/server/assets/{TeamForm-CL45gBdt.js → TeamForm-XFP0l2TB.js} +11 -5
  77. package/dist/web/server/assets/{TeamThread-CVVH6kKj.js → TeamThread-gYV_ToRM.js} +59 -12
  78. package/dist/web/server/assets/{UnsavedChangesGuard-CXK75QQp.js → UnsavedChangesGuard-CB_TugFF.js} +1 -1
  79. package/dist/web/server/assets/{_id-d2OwovYV.js → _id-517adSuB.js} +2 -2
  80. package/dist/web/server/assets/{_id-BKzOw78O.js → _id-BTyd2i5U.js} +1 -1
  81. package/dist/web/server/assets/{_id-8zsImuGa.js → _id-BsQnL9LV.js} +14 -9
  82. package/dist/web/server/assets/{_id-2I4CSMQj.js → _id-CyinHJam.js} +17 -11
  83. package/dist/web/server/assets/{_id-De3Bm0SG.js → _id-D4RFNqaJ.js} +2 -2
  84. package/dist/web/server/assets/{_id-BpfoPuTv.js → _id-josYXBx3.js} +2 -2
  85. package/dist/web/server/assets/_tanstack-start-manifest_v-w2xn07aY.js +275 -0
  86. package/dist/web/server/assets/{access-WWspT0v4.js → access-B97-94Wt.js} +1 -1
  87. package/dist/web/server/assets/{access-CyUoElTP.js → access-BdQmjMJV.js} +2 -2
  88. package/dist/web/server/assets/{access-CwZ27Wsl.js → access-Cc7fMMod.js} +7 -4
  89. package/dist/web/server/assets/activity-Czfq-5_F.js +471 -0
  90. package/dist/web/server/assets/{agent-actions-C07Cp5Ue.js → agent-actions-ChH7Mne4.js} +1 -1
  91. package/dist/web/server/assets/{agents-DCWEoaxY.js → agents-BL918wVc.js} +2 -2
  92. package/dist/web/server/assets/{agents-vuXrAv1j.js → agents-BlUZqqJn.js} +14 -8
  93. package/dist/web/server/assets/{agents-CRtMfKqX.js → agents-BzJFjA2i.js} +2 -2
  94. package/dist/web/server/assets/{agents-CwzhpDPm.js → agents-CjrkaEz8.js} +11 -8
  95. package/dist/web/server/assets/{agents-DQowl6Ly.js → agents-Tg3zkmQv.js} +2 -2
  96. package/dist/web/server/assets/{agents-DTub-rJk.js → agents-uw32jPWx.js} +2 -2
  97. package/dist/web/server/assets/{attention-Dki8rmGZ.js → attention-2unmuO-q.js} +1 -1
  98. package/dist/web/server/assets/{attention-BqCnJ1hg.js → attention-C94WWwQe.js} +2 -2
  99. package/dist/web/server/assets/{attention-DwGaur_w.js → attention-a_OmC6L3.js} +9 -7
  100. package/dist/web/server/assets/{auth-dJnrFW6y.js → auth-DuIqEAed.js} +1 -1
  101. package/dist/web/server/assets/{config-B9dJiji_.js → config-BG1KOtwA.js} +2 -2
  102. package/dist/web/server/assets/{config-D3MR2VjE.js → config-Bhem9XER.js} +10 -7
  103. package/dist/web/server/assets/{config-X7qWbbpH.js → config-D1Li_7Yt2.js} +1 -1
  104. package/dist/web/server/assets/createSsrRpc-6LHNEsSK.js +16 -0
  105. package/dist/web/server/assets/{daemon-client-B_ZRIIrT.js → daemon-client-D-NWKQto.js} +1 -1
  106. package/dist/web/server/assets/form-Bwsyt9OY.js +416 -0
  107. package/dist/web/server/assets/live-DbJeq6KP.js +263 -0
  108. package/dist/web/server/assets/{login-CRd1yTH5.js → login-BJdJ219n.js} +1 -1
  109. package/dist/web/server/assets/{login-ZN6KV8n-.js → login-C4lL4AxI.js} +2 -2
  110. package/dist/web/server/assets/{manage-Ce6cI4eW.js → manage-C7ReF2ZZ.js} +3 -2
  111. package/dist/web/server/assets/{mcp-CYQuYWGX.js → mcp-BFixpBQk.js} +2 -2
  112. package/dist/web/server/assets/{mcp-BQ15a9dG.js → mcp-BTZkDvdc.js} +7 -4
  113. package/dist/web/server/assets/{mcp-C97uAZe1.js → mcp-Ceg9gzKE.js} +1 -1
  114. package/dist/web/server/assets/open-groups-C89TEK85.js +12 -0
  115. package/dist/web/server/assets/{page-title-CVY-c2Pd.js → page-title-PTpFHXWo.js} +1 -1
  116. package/dist/web/server/assets/parts-B0wbj_yK.js +436 -0
  117. package/dist/web/server/assets/{router-CPdWGKQ5.js → router-Ci_9VxDk.js} +244 -104
  118. package/dist/web/server/assets/{routes-BPloBDc8.js → routes-CVrH9qgo.js} +3 -3
  119. package/dist/web/server/assets/{routes-Dw1K3TQw.js → routes-D9Mw1_VV.js} +1453 -403
  120. package/dist/web/server/assets/{routes-xDPesCQu.js → routes-DsuaDPTO.js} +3 -3
  121. package/dist/web/server/assets/{skills-DWzlT_hC.js → skills-BNbZ75am.js} +1 -1
  122. package/dist/web/server/assets/{skills-6VSpEORe.js → skills-BWwEFc4a.js} +2 -2
  123. package/dist/web/server/assets/{skills-D0xrNc2_.js → skills-D5rnOmKJ.js} +9 -7
  124. package/dist/web/server/assets/src-BeMh8Fze.js +113 -0
  125. package/dist/web/server/assets/{start-DhW7sy23.js → start-2MvkBRdC.js} +1 -1
  126. package/dist/web/server/assets/{style-aMybyKzc.js → style-B3l0Wtlf.js} +1 -1
  127. package/dist/web/server/assets/{system-B5sPgdQW.js → system-Cr4C-YRw.js} +2 -2
  128. package/dist/web/server/assets/{system-CXmiWyDG.js → system-DT7AU0e6.js} +3 -3
  129. package/dist/web/server/assets/{system-D3th6n2E.js → system-DsmXkgqn.js} +1 -1
  130. package/dist/web/server/assets/{teams-ClRBVSYU.js → teams-BeStcDvQ.js} +2 -2
  131. package/dist/web/server/assets/{teams-yF3I_Zjq.js → teams-CsEBLW8-.js} +14 -8
  132. package/dist/web/server/assets/{teams-Dq4RCxis.js → teams-Dix5XVIx.js} +2 -2
  133. package/dist/web/server/assets/{teams-iXiCnN2i.js → teams-DjE0swAZ.js} +10 -6
  134. package/dist/web/server/assets/{teams-70u1XQTr.js → teams-Rk_RED7X.js} +1 -1
  135. package/dist/web/server/assets/{teams-BopOP4x7.js → teams-u6m6JzuU.js} +1 -1
  136. package/dist/web/server/assets/{telegram-DwEgyR1x.js → telegram-BjqABrl-.js} +287 -273
  137. package/dist/web/server/assets/{telegram-CGol0CKX2.js → telegram-CQpF3EHA.js} +1 -1
  138. package/dist/web/server/assets/{telegram-D9U9c1MN.js → telegram-DhzHgDfg.js} +2 -2
  139. package/dist/web/server/assets/{tools-C-wwWjLI.js → tools-DC69leH7.js} +1 -1
  140. package/dist/web/server/assets/{tools-DflVIdDd.js → tools-Dn6RnOFu.js} +2 -2
  141. package/dist/web/server/assets/{tools-VPIKjr3y.js → tools-x_DQTQtE.js} +6 -4
  142. package/dist/web/server/assets/usage-4zMG0sab.js +465 -0
  143. package/dist/web/server/assets/usage-mvQegG4l.js +46 -0
  144. package/dist/web/server/assets/{use-resource-CbHGYti0.js → use-resource-BjN1uJoL.js} +10 -2
  145. package/dist/web/server/assets/{welcome-7DrYZVs6.js → welcome-BuE9FRf4.js} +2 -2
  146. package/dist/web/server/assets/{welcome-CxXMI4HI.js → welcome-DYw35wl5.js} +1 -1
  147. package/dist/web/server/assets/{welcome-966nOyyK.js → welcome-DrYbWGd_.js} +8 -6
  148. package/dist/web/server/assets/workspace-0XPILV1W.js +82 -0
  149. package/dist/web/server/server.js +20 -20
  150. package/dist/worker.js +143 -18
  151. package/dist/worker.js.map +1 -1
  152. package/package.json +1 -1
  153. package/dist/web/client/assets/AddProviderDialog-DfFOaCjC.js +0 -1
  154. package/dist/web/client/assets/AgentTemplateParts-IMJmAQjN.js +0 -1
  155. package/dist/web/client/assets/ConfigPage-CzLHZa5o.js +0 -1
  156. package/dist/web/client/assets/ConfirmDialog-Cu_evkgc.js +0 -1
  157. package/dist/web/client/assets/ConnectionsView-D7Fmutl2.js +0 -1
  158. package/dist/web/client/assets/ManagePage-BfvlCrmz.js +0 -1
  159. package/dist/web/client/assets/SectionTabs-D7kPQGoh.js +0 -1
  160. package/dist/web/client/assets/SkillsParts-BuTxcCam.js +0 -1
  161. package/dist/web/client/assets/SpawnTeamModal-B1UnOvtp.js +0 -1
  162. package/dist/web/client/assets/TeamForm-DbzxtRjj.js +0 -1
  163. package/dist/web/client/assets/TeamThread-jpsWq6vI.js +0 -1
  164. package/dist/web/client/assets/UnsavedChangesGuard-BfyU9v9i.js +0 -1
  165. package/dist/web/client/assets/_id-BCNBLF-2.js +0 -1
  166. package/dist/web/client/assets/_id-D8_H79U2.js +0 -1
  167. package/dist/web/client/assets/access-CDWe1Kwy.js +0 -1
  168. package/dist/web/client/assets/agents-sE686DTf.js +0 -1
  169. package/dist/web/client/assets/agents-yrur1NDa.js +0 -1
  170. package/dist/web/client/assets/arrow-right-U66krZnr.js +0 -1
  171. package/dist/web/client/assets/attention-DYEHDfmx.js +0 -1
  172. package/dist/web/client/assets/chevron-right-CuqJFXTe.js +0 -1
  173. package/dist/web/client/assets/config-BHv886pr.js +0 -1
  174. package/dist/web/client/assets/index-GOthyyE-.js +0 -14
  175. package/dist/web/client/assets/login-Dhe15Uuc.js +0 -1
  176. package/dist/web/client/assets/mcp-A_Eo7x3q.js +0 -1
  177. package/dist/web/client/assets/parts-CpIfn_BH.js +0 -41
  178. package/dist/web/client/assets/plus-CQPjc8uR.js +0 -1
  179. package/dist/web/client/assets/routes-CTg_yjbY.js +0 -85
  180. package/dist/web/client/assets/skills-CLjtYtkA.js +0 -1
  181. package/dist/web/client/assets/style-mjEbxhf5.js +0 -7
  182. package/dist/web/client/assets/styles-DzcEC3Rd.css +0 -2
  183. package/dist/web/client/assets/teams-Bhje5n2h.js +0 -1
  184. package/dist/web/client/assets/teams-Cbgw0Qhv.js +0 -1
  185. package/dist/web/client/assets/telegram-HtUczmaA.js +0 -1
  186. package/dist/web/client/assets/tools-BpjFvmoX.js +0 -1
  187. package/dist/web/client/assets/use-resource-BnvgCpBi.js +0 -1
  188. package/dist/web/client/assets/welcome-D47LKWYO.js +0 -1
  189. package/dist/web/server/assets/Rail-b6EbjBB-.js +0 -605
  190. package/dist/web/server/assets/SpawnDialog-3wNx0W1R.js +0 -1851
  191. package/dist/web/server/assets/_tanstack-start-manifest_v-kkY_s_uR.js +0 -256
  192. package/dist/web/server/assets/createSsrRpc-qesavJv-.js +0 -72
  193. 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";
3
- 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";
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-BeMh8Fze.js";
4
+ import { n as useMediaQuery, r as useResource, t as useHydrated } from "./use-resource-BjN1uJoL.js";
5
+ import { t as AgentAvatar } from "./AgentAvatar-8gTAy_tP.js";
6
+ import { t as Button } from "./Button-Dsnw22OF.js";
7
+ import { l as modelName, m as revealInStrip, n as ModelMenu, p as cn, t as MODELS_PATH } from "./ModelMenu-DEJoYASj.js";
8
+ import { i as restoreDialogFocus, n as DialogActions, r as getDialogFocusRestoreTarget, t as Dialog$1 } from "./Dialog-_Gt_Nt86.js";
9
+ import { t as ConfirmDialog } from "./ConfirmDialog-C89B8qKM.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-CB_TugFF.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-gYV_ToRM.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-B0wbj_yK.js";
16
+ import { a as neighbour, i as isTyping, n as NEW_CONVERSATION_EVENT, t as Route } from "./routes-CVrH9qgo.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-Bwsyt9OY.js";
18
+ import { t as SpawnDialog } from "./SpawnDialog-BNKj2Lup.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-C7ReF2ZZ.js";
21
+ import { t as SpawnTeamModal } from "./SpawnTeamModal-zcLxtFOO.js";
22
+ import { t as TeamForm } from "./TeamForm-XFP0l2TB.js";
23
+ import { n as isGroupOpen, r as writeOpenGroupsCookie } from "./open-groups-C89TEK85.js";
24
+ import { n as FindingsNotice, t as FindingLines } from "./SkillsParts-CqS2B45v.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 }) {
@@ -587,11 +596,16 @@ function useReviewList(teamId, base) {
587
596
  const { turnsEnded } = useActivity();
588
597
  return useResource(async (signal) => {
589
598
  try {
599
+ const review = await api(reviewPath(teamId, {
600
+ authors: "1",
601
+ ...base ? { base } : {}
602
+ }), { signal });
603
+ if ("unavailable" in review) return {
604
+ review: null,
605
+ unavailable: review.unavailable
606
+ };
590
607
  return {
591
- review: await api(reviewPath(teamId, {
592
- authors: "1",
593
- ...base ? { base } : {}
594
- }), { signal }),
608
+ review,
595
609
  unavailable: null
596
610
  };
597
611
  } catch (cause) {
@@ -604,21 +618,19 @@ function useReviewList(teamId, base) {
604
618
  }
605
619
  };
606
620
  }
607
- }, [
608
- teamId,
609
- base,
610
- turnsEnded
611
- ]);
621
+ }, [teamId, base], { refreshOn: turnsEnded });
612
622
  }
613
623
  /** One file's diff; `path` null loads nothing. */
614
624
  function useFileDiff(teamId, base, path, revision) {
615
625
  return useResource(async (signal) => {
616
626
  if (!path) return null;
617
- const change = (await api(reviewPath(teamId, {
627
+ const response = await api(reviewPath(teamId, {
618
628
  patches: "1",
619
629
  path,
620
630
  ...base ? { base } : {}
621
- }), { signal })).changes.changes.find((entry) => entry.path === path);
631
+ }), { signal });
632
+ if ("unavailable" in response) throw new Error(response.unavailable.message);
633
+ const change = response.changes.changes.find((entry) => entry.path === path);
622
634
  return {
623
635
  path,
624
636
  patch: change?.patch ?? null,
@@ -628,9 +640,8 @@ function useFileDiff(teamId, base, path, revision) {
628
640
  }, [
629
641
  teamId,
630
642
  base,
631
- path,
632
- revision
633
- ]);
643
+ path
644
+ ], { refreshOn: revision });
634
645
  }
635
646
  var STATUS_LETTER = {
636
647
  added: "A",
@@ -652,7 +663,7 @@ var STATUS_TONE = {
652
663
  type_changed: "bg-accent text-accent-foreground",
653
664
  deleted: "bg-danger/15 text-danger",
654
665
  unmerged: "bg-warning/15 text-warning",
655
- unknown: "bg-frost text-mocha"
666
+ unknown: "bg-frost text-foreground"
656
667
  };
657
668
  /** The one-letter mark of a change: A added, M modified, D deleted… */
658
669
  function StatusMark({ status }) {
@@ -987,12 +998,12 @@ function useTeamCounts(teamId) {
987
998
  files: null
988
999
  };
989
1000
  const team = encodeURIComponent(teamId);
990
- const [changes, files] = await Promise.all([api(`/api/teams/${team}/review`, { signal }).then((review) => review.changes.changes.length).catch(() => null), api(`/api/results?teamId=${team}&limit=1`, { signal }).then((list) => list.total).catch(() => null)]);
1001
+ const [changes, files] = await Promise.all([api(`/api/teams/${team}/review`, { signal }).then((review) => "unavailable" in review ? null : review.changes.changes.length).catch(() => null), api(`/api/results?teamId=${team}&limit=1`, { signal }).then((list) => list.total).catch(() => null)]);
991
1002
  return {
992
1003
  changes,
993
1004
  files
994
1005
  };
995
- }, [teamId, turnsEnded]).data ?? {
1006
+ }, [teamId], { refreshOn: turnsEnded }).data ?? {
996
1007
  changes: null,
997
1008
  files: null
998
1009
  };
@@ -1099,6 +1110,66 @@ function AgentModel({ agent }) {
1099
1110
  });
1100
1111
  }
1101
1112
  //#endregion
1113
+ //#region src/components/agent/RenameAgentDialog.tsx
1114
+ /** A new display name for an Agent, from its row in the rail or from its panel. */
1115
+ function RenameAgentDialog({ agent, onClose, onRenamed }) {
1116
+ const [name, setName] = useState(agent.name);
1117
+ const [busy, setBusy] = useState(false);
1118
+ const [error, setError] = useState(null);
1119
+ const unchanged = !name.trim() || name.trim() === agent.name;
1120
+ async function submit(event) {
1121
+ event.preventDefault();
1122
+ if (unchanged) return;
1123
+ setBusy(true);
1124
+ setError(null);
1125
+ try {
1126
+ await renameAgent(agent.id, name.trim());
1127
+ await onRenamed();
1128
+ onClose();
1129
+ } catch (cause) {
1130
+ setError(errorMessage(cause));
1131
+ setBusy(false);
1132
+ }
1133
+ }
1134
+ return /* @__PURE__ */ jsx(Dialog$1, {
1135
+ title: `Rename ${agent.name}`,
1136
+ description: "This changes the display name only; the Agent ID and history stay the same.",
1137
+ busy,
1138
+ onClose,
1139
+ className: "max-w-md",
1140
+ children: /* @__PURE__ */ jsxs("form", {
1141
+ onSubmit: (event) => void submit(event),
1142
+ children: [
1143
+ /* @__PURE__ */ jsxs("label", { children: ["Agent name", /* @__PURE__ */ jsx("input", {
1144
+ autoFocus: true,
1145
+ value: name,
1146
+ onChange: (event) => setName(event.target.value),
1147
+ maxLength: 120
1148
+ })] }),
1149
+ error && /* @__PURE__ */ jsx("p", {
1150
+ role: "alert",
1151
+ className: "mt-3 text-sm text-danger",
1152
+ children: error
1153
+ }),
1154
+ /* @__PURE__ */ jsx("div", {
1155
+ className: "mt-4",
1156
+ children: /* @__PURE__ */ jsxs(DialogActions, { children: [/* @__PURE__ */ jsx(Button, {
1157
+ variant: "ghost",
1158
+ disabled: busy,
1159
+ onClick: onClose,
1160
+ children: "Cancel"
1161
+ }), /* @__PURE__ */ jsx(Button, {
1162
+ variant: "primary",
1163
+ type: "submit",
1164
+ disabled: busy || unchanged,
1165
+ children: busy ? "Renaming…" : "Rename agent"
1166
+ })] })
1167
+ })
1168
+ ]
1169
+ })
1170
+ });
1171
+ }
1172
+ //#endregion
1102
1173
  //#region src/components/CopyButton.tsx
1103
1174
  function CopyButton({ value, className, ariaLabel = "Copy to clipboard", title = "Copy to clipboard" }) {
1104
1175
  const [copied, setCopied] = useState(false);
@@ -1166,11 +1237,7 @@ function AgentPanel({ agent: resolved }) {
1166
1237
  proposals: proposals.proposals.filter((proposal) => proposal.status === "pending").length,
1167
1238
  unread: unread.messages.length
1168
1239
  };
1169
- }, [
1170
- base,
1171
- activity.turnsEnded,
1172
- search.section
1173
- ]);
1240
+ }, [base, search.section], { refreshOn: activity.turnsEnded });
1174
1241
  const telegram = useResource((signal) => api("/api/config/telegram", { signal }).catch(() => ({ configured: false })), []);
1175
1242
  async function restore() {
1176
1243
  setError(null);
@@ -1461,11 +1528,7 @@ function MoveTeam({ agentId, teamId: currentTeamId, teams }) {
1461
1528
  function ConnectionsPanel({ team }) {
1462
1529
  const { to, search, agentById } = useWorkspace();
1463
1530
  const { turnsEnded } = useActivity();
1464
- const policy = useResource((signal) => api(`/api/teams/${encodeURIComponent(team.id)}/policy`, { signal }), [
1465
- team.id,
1466
- turnsEnded,
1467
- search.view
1468
- ]);
1531
+ const policy = useResource((signal) => api(`/api/teams/${encodeURIComponent(team.id)}/policy`, { signal }), [team.id, search.view], { refreshOn: turnsEnded });
1469
1532
  const messages = useTeamMessages(team.id);
1470
1533
  if (policy.error) return /* @__PURE__ */ jsx("p", {
1471
1534
  role: "alert",
@@ -1562,7 +1625,7 @@ function ConnectionsPanel({ team }) {
1562
1625
  }),
1563
1626
  reach.map((entry) => /* @__PURE__ */ jsxs("span", {
1564
1627
  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"}`,
1628
+ 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
1629
  children: [entry.out && entry.back ? /* @__PURE__ */ jsx(ArrowLeftRight, {
1567
1630
  className: "size-3",
1568
1631
  "aria-hidden": "true"
@@ -1666,15 +1729,16 @@ var PREVIEW_IMAGE = [
1666
1729
  "image/gif",
1667
1730
  "image/webp"
1668
1731
  ];
1669
- var PREVIEW_TEXT = ["text/plain", "text/markdown"];
1670
1732
  /** The daemon previews these images up to 10 MiB. */
1671
1733
  function isPreviewImage(result) {
1672
1734
  return PREVIEW_IMAGE.includes(result.mimeType) && result.byteLength <= 10 * 1024 * 1024;
1673
1735
  }
1674
- /** The daemon previews plain text and Markdown up to 256 KiB. */
1736
+ /** The daemon previews text up to 256 KiB: by its type, or by its name when sent untyped. */
1675
1737
  function isPreviewText(result) {
1676
- return PREVIEW_TEXT.includes(result.mimeType) && result.byteLength <= 256 * 1024;
1738
+ return isTextPreview(result);
1677
1739
  }
1740
+ /** How much of a text file a grid tile shows. */
1741
+ var TILE_TEXT_BYTES = 1200;
1678
1742
  function formatBytes$1(bytes) {
1679
1743
  if (bytes < 1024) return `${bytes} B`;
1680
1744
  if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(bytes < 10 * 1024 ? 1 : 0)} KB`;
@@ -1690,6 +1754,8 @@ function kindLabel(mimeType, name) {
1690
1754
  return extension ? extension.toUpperCase() : mimeType;
1691
1755
  }
1692
1756
  var resultPath = (id, action) => `/api/results/${encodeURIComponent(id)}${action ? `/${action}` : ""}`;
1757
+ /** The start of a text file, for a tile. */
1758
+ var tileTextPath = (id) => `${resultPath(id, "preview")}?bytes=${TILE_TEXT_BYTES}`;
1693
1759
  /** The archive of a Team's, an Agent's or a conversation's saved files. */
1694
1760
  function archivePath(filter) {
1695
1761
  const params = new URLSearchParams();
@@ -1757,35 +1823,30 @@ function ResultTile({ resultId, result: preloaded, detail, open, selected = fals
1757
1823
  if (compact) {
1758
1824
  const face = isPreviewImage(result) ? /* @__PURE__ */ jsx("img", {
1759
1825
  src: resultPath(result.id, "preview"),
1760
- alt: result.name,
1826
+ alt: "",
1761
1827
  loading: "lazy",
1762
1828
  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
- });
1829
+ }) : isPreviewText(result) ? /* @__PURE__ */ jsx(TextFace, { result }) : /* @__PURE__ */ jsx(KindFace, { result });
1773
1830
  return /* @__PURE__ */ jsxs("figure", {
1774
1831
  className: `m-0 ${frame}`,
1775
- children: [onPick ? /* @__PURE__ */ jsx("button", {
1832
+ children: [onPick ? /* @__PURE__ */ jsxs("button", {
1776
1833
  type: "button",
1777
1834
  onClick: onPick,
1778
- "aria-label": `Choose ${result.name}`,
1779
1835
  "aria-pressed": selected,
1780
1836
  className: "unstyled block w-full",
1781
- children: face
1782
- }) : open ? /* @__PURE__ */ jsx(Link, {
1837
+ children: [/* @__PURE__ */ jsxs("span", {
1838
+ className: "sr-only",
1839
+ children: ["Choose ", result.name]
1840
+ }), face]
1841
+ }) : open ? /* @__PURE__ */ jsxs(Link, {
1783
1842
  to: "/",
1784
1843
  search: open,
1785
- "aria-label": `Open ${result.name}`,
1786
1844
  "aria-current": selected ? "true" : void 0,
1787
1845
  className: "block",
1788
- children: face
1846
+ children: [/* @__PURE__ */ jsxs("span", {
1847
+ className: "sr-only",
1848
+ children: ["Open ", result.name]
1849
+ }), face]
1789
1850
  }) : face, /* @__PURE__ */ jsxs("figcaption", {
1790
1851
  className: "flex items-center gap-1.5 py-1.5 pl-2.5 pr-1.5",
1791
1852
  children: [/* @__PURE__ */ jsxs("span", {
@@ -1878,6 +1939,42 @@ function ResultTile({ resultId, result: preloaded, detail, open, selected = fals
1878
1939
  ]
1879
1940
  });
1880
1941
  }
1942
+ /** A file shown by its kind: an icon and "PDF", "ZIP". */
1943
+ function KindFace({ result }) {
1944
+ return /* @__PURE__ */ jsxs("span", {
1945
+ "aria-hidden": "true",
1946
+ className: "flex aspect-[4/3] w-full flex-col items-center justify-center gap-1.5 bg-card text-mocha",
1947
+ children: [/* @__PURE__ */ jsx(FileText, { className: "size-7" }), /* @__PURE__ */ jsx("span", {
1948
+ className: "max-w-full truncate px-2 font-mono text-xs font-medium uppercase tracking-wide",
1949
+ children: kindLabel(result.mimeType, result.name)
1950
+ })]
1951
+ });
1952
+ }
1953
+ /** A text file shown by its first lines, fading out; by its kind until they arrive or if not. */
1954
+ function TextFace({ result }) {
1955
+ const [start, setStart] = useState(null);
1956
+ useEffect(() => {
1957
+ const controller = new AbortController();
1958
+ apiFetch(tileTextPath(result.id), { signal: controller.signal }).then((response) => response.text()).then((text) => setStart(text.trim() ? text : null)).catch(() => setStart(null));
1959
+ return () => controller.abort();
1960
+ }, [result.id]);
1961
+ if (start === null) return /* @__PURE__ */ jsx(KindFace, { result });
1962
+ return /* @__PURE__ */ jsxs("span", {
1963
+ "aria-hidden": "true",
1964
+ className: "relative block aspect-[4/3] w-full overflow-hidden bg-card text-left",
1965
+ children: [
1966
+ /* @__PURE__ */ jsx("pre", {
1967
+ className: "m-0 h-full overflow-hidden whitespace-pre-wrap break-words p-2.5 font-mono text-[10px] leading-[1.45] text-mocha",
1968
+ children: start
1969
+ }),
1970
+ /* @__PURE__ */ jsx("span", { className: "pointer-events-none absolute inset-x-0 bottom-0 h-10 bg-gradient-to-t from-card to-transparent" }),
1971
+ /* @__PURE__ */ jsx("span", {
1972
+ 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",
1973
+ children: kindLabel(result.mimeType, result.name)
1974
+ })
1975
+ ]
1976
+ });
1977
+ }
1881
1978
  //#endregion
1882
1979
  //#region src/components/files/use-results.ts
1883
1980
  /** The daemon lists at most this many at once. */
@@ -1911,11 +2008,7 @@ function useResults(teamId, filter, pageSize = 24) {
1911
2008
  results,
1912
2009
  total
1913
2010
  };
1914
- }, [
1915
- key,
1916
- wanted,
1917
- turnsEnded
1918
- ]);
2011
+ }, [key, wanted], { refreshOn: turnsEnded });
1919
2012
  const results = pages.data?.results ?? [];
1920
2013
  const total = pages.data?.total ?? 0;
1921
2014
  return {
@@ -2102,11 +2195,7 @@ var SMALL_ACTION = "inline-flex h-7 items-center gap-1 rounded-[10px] border bor
2102
2195
  function TeamPanel({ team }) {
2103
2196
  const { agents, profiles, teams, teamTemplates, agent: open, to, search } = useWorkspace();
2104
2197
  const { turnsEnded } = useActivity();
2105
- const fresh = useResource((signal) => api(`/api/teams/${encodeURIComponent(team.id)}`, { signal }), [
2106
- team.id,
2107
- turnsEnded,
2108
- search.section
2109
- ]);
2198
+ const fresh = useResource((signal) => api(`/api/teams/${encodeURIComponent(team.id)}`, { signal }), [team.id, search.section], { refreshOn: turnsEnded });
2110
2199
  const userMd = fresh.data?.id === team.id ? fresh.data.userMd : team.userMd;
2111
2200
  const activity = useActivity();
2112
2201
  const router = useRouter();
@@ -2152,7 +2241,7 @@ function TeamPanel({ team }) {
2152
2241
  children: [/* @__PURE__ */ jsx(Plus, {
2153
2242
  className: "size-3.5",
2154
2243
  "aria-hidden": "true"
2155
- }), "Add agent"]
2244
+ }), "Add an Agent"]
2156
2245
  })]
2157
2246
  }), members.length === 0 ? /* @__PURE__ */ jsxs("div", {
2158
2247
  className: "rounded-2xl border border-dashed border-border bg-muted/40 px-3 py-4 text-sm text-muted-foreground",
@@ -2327,11 +2416,7 @@ function MemoryGlance({ team }) {
2327
2416
  rows: [...entries].sort((a, b) => b.updatedAt - a.updatedAt).slice(0, 5).map((entry) => noteRow$1(entry.key, entry.content)),
2328
2417
  total: entries.length
2329
2418
  };
2330
- }, [
2331
- base,
2332
- debounced,
2333
- turnsEnded
2334
- ]);
2419
+ }, [base, debounced], { refreshOn: turnsEnded });
2335
2420
  const total = notes.data?.total;
2336
2421
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
2337
2422
  /* @__PURE__ */ jsxs("div", {
@@ -2395,6 +2480,8 @@ function MemoryGlance({ team }) {
2395
2480
  function SidePanel({ tab }) {
2396
2481
  const { agent, team, to } = useWorkspace();
2397
2482
  const counts = useTeamCounts(team?.id);
2483
+ const strip = useRef(null);
2484
+ useEffect(() => revealInStrip(strip.current, "[aria-selected=\"true\"]"), [tab]);
2398
2485
  const count = {
2399
2486
  changes: counts.changes,
2400
2487
  files: counts.files
@@ -2405,6 +2492,7 @@ function SidePanel({ tab }) {
2405
2492
  children: [/* @__PURE__ */ jsxs("div", {
2406
2493
  className: "flex items-center gap-1 border-b border-border bg-muted/60 p-2",
2407
2494
  children: [/* @__PURE__ */ jsx("div", {
2495
+ ref: strip,
2408
2496
  role: "tablist",
2409
2497
  "aria-label": "Side panel",
2410
2498
  className: "flex min-w-0 flex-1 items-center gap-1 overflow-x-auto [scrollbar-width:none]",
@@ -2829,10 +2917,160 @@ function ChangesView({ team }) {
2829
2917
  });
2830
2918
  }
2831
2919
  //#endregion
2920
+ //#region src/lib/find-in-transcript.ts
2921
+ var GIVE_UP_MS = 8e3;
2922
+ var MARK_MS = 2500;
2923
+ /**
2924
+ * The `nth` element marked `data-message` whose text holds every word (oldest first, from 0), or
2925
+ * the last one that does when there are fewer.
2926
+ */
2927
+ function findMessage(root, find, nth = 0) {
2928
+ const words = find.toLowerCase().split(/\s+/).filter(Boolean);
2929
+ if (words.length === 0) return null;
2930
+ const found = [];
2931
+ for (const element of root.querySelectorAll("[data-message]")) {
2932
+ const text = (element.textContent ?? "").toLowerCase();
2933
+ if (words.every((word) => text.includes(word))) found.push(element);
2934
+ }
2935
+ return found[Math.min(nth, found.length - 1)] ?? null;
2936
+ }
2937
+ /**
2938
+ * Scroll to the message `find` and `nth` name, then call `done` (found or not) to drop them from
2939
+ * the address. `done` is the latest one passed: what was opened meanwhile stays open.
2940
+ */
2941
+ function useFindInTranscript(container, find, nth, done) {
2942
+ const latest = useRef(done);
2943
+ latest.current = done;
2944
+ useEffect(() => {
2945
+ const root = container.current;
2946
+ if (!find || !root) return;
2947
+ let finished = false;
2948
+ const finish = () => {
2949
+ finished = true;
2950
+ observer.disconnect();
2951
+ window.clearTimeout(giveUp);
2952
+ latest.current();
2953
+ };
2954
+ const look = () => {
2955
+ if (finished) return;
2956
+ const found = findMessage(root, find, nth);
2957
+ if (!found) return;
2958
+ found.scrollIntoView({ block: "center" });
2959
+ found.classList.add("found-message");
2960
+ window.setTimeout(() => found.classList.remove("found-message"), MARK_MS);
2961
+ finish();
2962
+ };
2963
+ const observer = new MutationObserver(look);
2964
+ observer.observe(root, {
2965
+ childList: true,
2966
+ subtree: true
2967
+ });
2968
+ const giveUp = window.setTimeout(finish, GIVE_UP_MS);
2969
+ look();
2970
+ return () => {
2971
+ finished = true;
2972
+ observer.disconnect();
2973
+ window.clearTimeout(giveUp);
2974
+ };
2975
+ }, [find, nth]);
2976
+ }
2977
+ //#endregion
2978
+ //#region src/lib/transcript-scroll.ts
2979
+ var MESSAGE = "[data-message]";
2980
+ /** Enough for every conversation one sitting opens; the oldest place is dropped past it. */
2981
+ var KEEP = 200;
2982
+ var places = /* @__PURE__ */ new Map();
2983
+ function placeKey(agentId, conversationId) {
2984
+ return `${agentId}:${conversationId ?? ""}`;
2985
+ }
2986
+ function isAtEnd(log) {
2987
+ return log.scrollHeight - log.scrollTop - log.clientHeight < 40;
2988
+ }
2989
+ /** Where the reader is in `log`. */
2990
+ function readPlace(log) {
2991
+ if (isAtEnd(log)) return { atEnd: true };
2992
+ const top = log.getBoundingClientRect().top;
2993
+ const messages = log.querySelectorAll(MESSAGE);
2994
+ for (let index = 0; index < messages.length; index++) {
2995
+ const box = messages[index]?.getBoundingClientRect();
2996
+ if (box && box.bottom > top) return {
2997
+ atEnd: false,
2998
+ index,
2999
+ offset: box.top - top
3000
+ };
3001
+ }
3002
+ return { atEnd: true };
3003
+ }
3004
+ /** Put `log` back at `place`; false when the message it names is not there. */
3005
+ function applyPlace(log, place) {
3006
+ if (place.atEnd) {
3007
+ log.scrollTop = log.scrollHeight;
3008
+ return true;
3009
+ }
3010
+ const message = log.querySelectorAll(MESSAGE)[place.index];
3011
+ if (!message) return false;
3012
+ const top = log.getBoundingClientRect().top;
3013
+ log.scrollTop += message.getBoundingClientRect().top - top - place.offset;
3014
+ return true;
3015
+ }
3016
+ function rememberPlace(key, place) {
3017
+ places.delete(key);
3018
+ places.set(key, place);
3019
+ if (places.size > KEEP) {
3020
+ const oldest = places.keys().next().value;
3021
+ if (oldest !== void 0) places.delete(oldest);
3022
+ }
3023
+ }
3024
+ function rememberedPlace(key) {
3025
+ return places.get(key);
3026
+ }
3027
+ /**
3028
+ * Remember where the reader is in `log`, under `key()` as it is when they scroll, and put them
3029
+ * back there once `ready` (the messages are on screen), unless `skip` (a search result opens the
3030
+ * conversation at its message instead). `onRestored` hears of a place put back that is not the
3031
+ * end, so the caller stops following new output. Call it before the effect that follows the end.
3032
+ */
3033
+ function useTranscriptPlace(log, key, { ready, skip, onRestored }) {
3034
+ const keyRef = useRef(key);
3035
+ keyRef.current = key;
3036
+ const restored = useRef(false);
3037
+ useLayoutEffect(() => {
3038
+ const element = log.current;
3039
+ if (restored.current || !ready || !element) return;
3040
+ restored.current = true;
3041
+ if (skip) return;
3042
+ const place = rememberedPlace(keyRef.current());
3043
+ if (place && applyPlace(element, place) && !place.atEnd) onRestored?.();
3044
+ });
3045
+ const pending = useRef(0);
3046
+ const saveNow = useRef(() => {});
3047
+ useEffect(() => {
3048
+ const element = log.current;
3049
+ if (!element) return;
3050
+ saveNow.current = () => {
3051
+ pending.current = 0;
3052
+ if (element.isConnected) rememberPlace(keyRef.current(), readPlace(element));
3053
+ };
3054
+ const onScroll = () => {
3055
+ if (!restored.current) return;
3056
+ pending.current ||= window.requestAnimationFrame(() => saveNow.current());
3057
+ };
3058
+ element.addEventListener("scroll", onScroll, { passive: true });
3059
+ return () => element.removeEventListener("scroll", onScroll);
3060
+ }, []);
3061
+ useLayoutEffect(() => () => {
3062
+ if (!pending.current) return;
3063
+ window.cancelAnimationFrame(pending.current);
3064
+ saveNow.current();
3065
+ }, []);
3066
+ }
3067
+ //#endregion
2832
3068
  //#region src/components/chat/AgentQuestions.tsx
2833
3069
  /**
2834
3070
  * Questions the Agent is waiting on. The chat reloads them when it opens, when a turn starts or
2835
- * ends and when its stream carries a new question (`refreshKey` changes).
3071
+ * ends and when its stream carries a new question (`refreshKey` changes); the live feed's count
3072
+ * of the Agent's questions reloads them too, so a question asked or answered elsewhere (a turn
3073
+ * started from the terminal, an answer given there or in Telegram, a timeout) shows here at once.
2836
3074
  */
2837
3075
  function AgentQuestions({ agentId, agentName, refreshKey }) {
2838
3076
  const [items, setItems] = useState([]);
@@ -2840,7 +3078,11 @@ function AgentQuestions({ agentId, agentName, refreshKey }) {
2840
3078
  const controller = new AbortController();
2841
3079
  api(`/api/agents/${encodeURIComponent(agentId)}/questions`, { signal: controller.signal }).then((body) => setItems(body.questions)).catch(() => {});
2842
3080
  return () => controller.abort();
2843
- }, [agentId, refreshKey]);
3081
+ }, [
3082
+ agentId,
3083
+ refreshKey,
3084
+ useActivityOptional()?.byAgent.get(agentId)?.questions ?? 0
3085
+ ]);
2844
3086
  if (!items.length) return null;
2845
3087
  return /* @__PURE__ */ jsx("section", {
2846
3088
  "aria-label": "Agent questions",
@@ -2999,6 +3241,17 @@ function shellApprovalsUrl(agentId) {
2999
3241
  return `/api/shell-approvals?agentId=${encodeURIComponent(agentId)}`;
3000
3242
  }
3001
3243
  var isImageMime = (mimeType) => mimeType.startsWith("image/");
3244
+ /** The message being sent, shown at once: the `done` frame replaces it with the saved history. */
3245
+ function draftEntry(text, attachments) {
3246
+ const images = attachments.filter((file) => isImageMime(file.mimeType));
3247
+ const files = attachments.filter((file) => !isImageMime(file.mimeType)).map((file) => ({ name: file.name ?? "file" }));
3248
+ return {
3249
+ type: "user",
3250
+ content: text,
3251
+ ...images.length > 0 ? { images } : {},
3252
+ ...files.length > 0 ? { files } : {}
3253
+ };
3254
+ }
3002
3255
  /**
3003
3256
  * Persisted messages as entries: assistant text, then its tool calls and the tool results that
3004
3257
  * answer them grouped into one tool box. Saved results and images are deliverables, so they stand
@@ -3038,6 +3291,13 @@ function projectMessages(messages) {
3038
3291
  name: call.name,
3039
3292
  body: call.arguments
3040
3293
  });
3294
+ if (message.stopped) {
3295
+ openTool = null;
3296
+ entries.push({
3297
+ type: "stopped",
3298
+ reason: message.stopped
3299
+ });
3300
+ }
3041
3301
  } else if (message.role === "tool") {
3042
3302
  toolBox().items.push({
3043
3303
  kind: /^error:/i.test(message.content) ? "error" : "result",
@@ -3220,10 +3480,15 @@ function applyEvent(entries, event) {
3220
3480
  type: "result",
3221
3481
  resultId: event.result.resultId
3222
3482
  }];
3223
- case "error": return [...entries, {
3224
- type: "error",
3225
- content: `[error] ${event.error}`
3226
- }];
3483
+ case "error":
3484
+ if (event.error === "cancelled") return [...entries, {
3485
+ type: "stopped",
3486
+ reason: "cancelled"
3487
+ }];
3488
+ return [...entries, {
3489
+ type: "error",
3490
+ content: `[error] ${event.error}`
3491
+ }];
3227
3492
  default: return entries;
3228
3493
  }
3229
3494
  }
@@ -3286,15 +3551,15 @@ function Composer({ agentName, value, onChange, onSubmit, attachments, onAddFile
3286
3551
  if (!element) return;
3287
3552
  element.style.height = "auto";
3288
3553
  element.style.height = `${Math.min(element.scrollHeight, MAX_INPUT_HEIGHT)}px`;
3289
- }, [value]);
3554
+ }, [value, agentName]);
3290
3555
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
3291
3556
  editing && /* @__PURE__ */ jsxs("div", {
3292
3557
  className: "flex items-center gap-2 border-t border-frost bg-sapphire-glow px-5 py-2 text-[0.85em] text-sapphire-deep",
3293
- children: [/* @__PURE__ */ jsx("span", { children: "editing last message — submit to replace, or" }), /* @__PURE__ */ jsx("button", {
3558
+ children: [/* @__PURE__ */ jsx("span", { children: "Editing your last message: send to replace it." }), /* @__PURE__ */ jsx("button", {
3294
3559
  type: "button",
3295
3560
  onClick: onCancelEdit,
3296
3561
  className: "ml-auto rounded-sm border border-sapphire-light bg-transparent px-2 py-0.5 text-[0.92em] text-sapphire-deep hover:bg-snow",
3297
- children: "cancel"
3562
+ children: "Cancel"
3298
3563
  })]
3299
3564
  }),
3300
3565
  attachments.length > 0 && /* @__PURE__ */ jsx("div", {
@@ -3413,7 +3678,7 @@ function Composer({ agentName, value, onChange, onSubmit, attachments, onAddFile
3413
3678
  //#endregion
3414
3679
  //#region src/components/chat/FollowUps.tsx
3415
3680
  /** Follow-ups waiting for the Agent's current turn. Hidden while there are none. */
3416
- function FollowUps({ agentId, queue, onChanged, onViewConversation }) {
3681
+ function FollowUps({ agentId, queue, onChanged, onViewConversation, conversationId }) {
3417
3682
  const [editing, setEditing] = useState(null);
3418
3683
  const [busy, setBusy] = useState(false);
3419
3684
  const [error, setError] = useState("");
@@ -3465,11 +3730,11 @@ function FollowUps({ agentId, queue, onChanged, onViewConversation }) {
3465
3730
  className: "text-xs text-mocha",
3466
3731
  children: item.source === "telegram" ? "Telegram" : "Web / API"
3467
3732
  }),
3468
- /* @__PURE__ */ jsx(Button, {
3733
+ item.conversationId !== conversationId && /* @__PURE__ */ jsx(Button, {
3469
3734
  variant: "ghost",
3470
3735
  className: "ml-auto",
3471
3736
  onClick: () => onViewConversation(item.conversationId),
3472
- children: "View conversation"
3737
+ children: "View its conversation"
3473
3738
  })
3474
3739
  ]
3475
3740
  }),
@@ -3899,54 +4164,59 @@ function Handoffs({ steps }) {
3899
4164
  const recipient = workspace?.agentById(to);
3900
4165
  const message = typeof args?.text === "string" ? args.text : "";
3901
4166
  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
- ]
4167
+ return /* @__PURE__ */ jsxs("div", {
4168
+ className: "relative border-t border-frost/70",
4169
+ children: [/* @__PURE__ */ jsxs("details", {
4170
+ className: "group",
4171
+ children: [
4172
+ /* @__PURE__ */ jsxs("summary", {
4173
+ 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"}`,
4174
+ children: [
4175
+ /* @__PURE__ */ jsx(AgentAvatar, {
4176
+ identity: recipient?.identity,
4177
+ size: 24
4178
+ }),
4179
+ /* @__PURE__ */ jsx("span", {
4180
+ className: "shrink-0 font-semibold text-foreground",
4181
+ children: recipient?.name ?? (to ? to.slice(0, 8) : "Teammate")
4182
+ }),
4183
+ /* @__PURE__ */ jsx("span", {
4184
+ className: "min-w-0 flex-1 truncate text-mocha group-open:invisible",
4185
+ children: message
4186
+ }),
4187
+ step.status === "failed" ? /* @__PURE__ */ jsx("span", {
4188
+ className: "shrink-0 text-xs font-semibold text-danger",
4189
+ children: "not sent"
4190
+ }) : step.status === "running" ? /* @__PURE__ */ jsx("span", {
4191
+ className: "shrink-0 text-xs text-mocha",
4192
+ children: "sending…"
4193
+ }) : state && /* @__PURE__ */ jsx("span", {
4194
+ className: "shrink-0 text-xs text-mocha",
4195
+ children: state.text
4196
+ })
4197
+ ]
4198
+ }),
4199
+ /* @__PURE__ */ jsx("p", {
4200
+ className: "m-0 whitespace-pre-wrap break-words px-3 pb-2.5 pl-[3.1rem] text-chocolate",
4201
+ children: message
4202
+ }),
4203
+ step.status === "failed" && /* @__PURE__ */ jsx("p", {
4204
+ className: "m-0 break-words px-3 pb-2.5 pl-[3.1rem] text-xs text-danger",
4205
+ children: step.output
4206
+ })
4207
+ ]
4208
+ }), workspace && recipient && /* @__PURE__ */ jsxs(Link, {
4209
+ to: "/",
4210
+ search: {
4211
+ agent: recipient.id,
4212
+ ...workspace.search.panel ? { panel: workspace.search.panel } : {}
4213
+ },
4214
+ 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",
4215
+ children: ["Open", /* @__PURE__ */ jsxs("span", {
4216
+ className: "sr-only",
4217
+ children: [" ", recipient.name]
4218
+ })]
4219
+ })]
3950
4220
  }, index);
3951
4221
  })]
3952
4222
  });
@@ -4010,6 +4280,7 @@ function Bubble({ entry, markdownReady, onEdit, dropped = false, approvals }) {
4010
4280
  if (entry.content.startsWith(INBOX_WAKE_PREFIX)) {
4011
4281
  const body = entry.content.slice(24);
4012
4282
  return /* @__PURE__ */ jsxs("details", {
4283
+ "data-message": "",
4013
4284
  className: `my-3 rounded-lg border border-fawn bg-ivory px-3 py-2 text-sm text-mocha ${dropClass}`,
4014
4285
  "aria-label": "Teammate update",
4015
4286
  children: [
@@ -4029,6 +4300,7 @@ function Bubble({ entry, markdownReady, onEdit, dropped = false, approvals }) {
4029
4300
  });
4030
4301
  }
4031
4302
  return /* @__PURE__ */ jsxs("div", {
4303
+ "data-message": "",
4032
4304
  className: `group relative my-4 flex flex-col items-end ${dropClass}`,
4033
4305
  children: [
4034
4306
  /* @__PURE__ */ jsx("span", {
@@ -4081,6 +4353,7 @@ function Bubble({ entry, markdownReady, onEdit, dropped = false, approvals }) {
4081
4353
  });
4082
4354
  }
4083
4355
  return /* @__PURE__ */ jsxs("div", {
4356
+ "data-message": "",
4084
4357
  className: `my-4 flex flex-col items-start ${dropClass}`,
4085
4358
  children: [/* @__PURE__ */ jsx("span", {
4086
4359
  className: "sr-only",
@@ -4114,6 +4387,10 @@ function Bubble({ entry, markdownReady, onEdit, dropped = false, approvals }) {
4114
4387
  children: entry.content
4115
4388
  })]
4116
4389
  });
4390
+ case "stopped": return /* @__PURE__ */ jsx("p", {
4391
+ className: "my-2 px-1 text-[0.85em] italic text-muted-foreground",
4392
+ children: entry.reason === "cancelled" ? "Stopped." : "This reply failed."
4393
+ });
4117
4394
  case "error": return /* @__PURE__ */ jsx("div", {
4118
4395
  className: "my-3 rounded-r-sm border-l-[3px] border-danger bg-danger/10 px-3 py-1 text-[0.92em] text-danger",
4119
4396
  children: entry.content
@@ -4257,68 +4534,164 @@ function formatContext(context) {
4257
4534
  function formatCompaction(result) {
4258
4535
  return `/compact: ${result.before} → ${result.after} entries (${result.summarized} summarized, ${result.keptTail} kept verbatim; ~${result.tokensBefore.toLocaleString()} → ~${result.tokensAfter.toLocaleString()} tok). reloading…`;
4259
4536
  }
4537
+ async function compact(rest, chat) {
4538
+ if (chat.messageCount < 2) {
4539
+ chat.pushNote("/compact: need ≥2 messages to compact");
4540
+ return;
4541
+ }
4542
+ chat.setCompacting(true);
4543
+ try {
4544
+ const result = await api(`${chat.base}/chat/compact`, { body: { keepTail: parseKeepTail(rest) } });
4545
+ chat.pushNote(formatCompaction(result));
4546
+ setTimeout(() => window.location.reload(), 400);
4547
+ } catch (error) {
4548
+ chat.pushNote(`/compact failed: ${errorMessage(error)}`);
4549
+ } finally {
4550
+ chat.setCompacting(false);
4551
+ }
4552
+ }
4553
+ /** True when `command` is a slash command, which then ran. */
4554
+ async function runSlashCommand(command, rest, chat) {
4555
+ switch (command) {
4556
+ case "/help":
4557
+ chat.pushNote(SLASH_HELP);
4558
+ return true;
4559
+ case "/context":
4560
+ try {
4561
+ chat.pushNote(formatContext(await api(`${chat.base}/chat/context`)));
4562
+ } catch (error) {
4563
+ chat.pushNote(`/context failed: ${errorMessage(error)}`);
4564
+ }
4565
+ return true;
4566
+ case "/new":
4567
+ chat.onOpenLibrary();
4568
+ return true;
4569
+ case "/compact":
4570
+ await compact(rest, chat);
4571
+ return true;
4572
+ default: return false;
4573
+ }
4574
+ }
4260
4575
  //#endregion
4261
- //#region src/components/chat/useChatSession.ts
4262
- var SESSION_POLL_MS = 1e4;
4263
- var QUEUE_POLL_MS = 5e3;
4576
+ //#region src/components/chat/useCommandApprovals.ts
4577
+ function useCommandApprovals({ agentId, setLive }) {
4578
+ const [recoveredTurn, setRecoveredTurn] = useState(false);
4579
+ const [approvalBusy, setApprovalBusy] = useState({});
4580
+ const [approvalErrors, setApprovalErrors] = useState({});
4581
+ const approvalTurnRef = useRef(false);
4582
+ useEffect(() => {
4583
+ const controller = new AbortController();
4584
+ api(shellApprovalsUrl(agentId), { signal: controller.signal }).then(({ approvals }) => {
4585
+ const pending = approvals.filter((approval) => approval.agentId === agentId && approval.status === "pending");
4586
+ if (pending.length === 0) return;
4587
+ approvalTurnRef.current = true;
4588
+ setLive((entries) => pending.reduce(upsertCommandApprovalEntry, entries));
4589
+ setRecoveredTurn(true);
4590
+ }).catch(() => {});
4591
+ return () => controller.abort();
4592
+ }, [agentId, setLive]);
4593
+ async function reconcileApproval(id) {
4594
+ try {
4595
+ const { approvals } = await api(shellApprovalsUrl(agentId));
4596
+ const approval = approvals.find((item) => item.id === id && item.agentId === agentId);
4597
+ if (approval) setLive((entries) => upsertCommandApprovalEntry(entries, approval));
4598
+ return approval ?? null;
4599
+ } catch {
4600
+ return null;
4601
+ }
4602
+ }
4603
+ async function decide(approval, decision) {
4604
+ if (approval.agentId !== agentId || approval.status !== "pending") return;
4605
+ setApprovalBusy((current) => ({
4606
+ ...current,
4607
+ [approval.id]: true
4608
+ }));
4609
+ setApprovalErrors(({ [approval.id]: _cleared, ...rest }) => rest);
4610
+ try {
4611
+ const body = await api(`/api/shell-approvals/${encodeURIComponent(approval.id)}`, { body: { decision } });
4612
+ if (body.approval.agentId === agentId) setLive((entries) => upsertCommandApprovalEntry(entries, body.approval));
4613
+ } catch (error) {
4614
+ const current = await reconcileApproval(approval.id);
4615
+ if (!current || current.status === "pending") setApprovalErrors((errors) => ({
4616
+ ...errors,
4617
+ [approval.id]: errorMessage(error)
4618
+ }));
4619
+ } finally {
4620
+ setApprovalBusy((current) => ({
4621
+ ...current,
4622
+ [approval.id]: false
4623
+ }));
4624
+ }
4625
+ }
4626
+ return {
4627
+ recoveredTurn,
4628
+ setRecoveredTurn,
4629
+ approvalTurnRef,
4630
+ approvalBusy,
4631
+ approvalErrors,
4632
+ decide,
4633
+ /** A turn starts or ends: no approval is being decided or failed any more. */
4634
+ resetApprovals: () => {
4635
+ setApprovalBusy({});
4636
+ setApprovalErrors({});
4637
+ }
4638
+ };
4639
+ }
4640
+ //#endregion
4641
+ //#region src/components/chat/session-sync.ts
4264
4642
  var EMPTY_HEAD = {
4265
4643
  file: null,
4266
4644
  size: 0,
4267
4645
  conversationId: null
4268
4646
  };
4647
+ /** Follow-ups that wait or run. */
4269
4648
  function openFollowUps(queue) {
4270
4649
  return queue?.items.filter((item) => item.status === "pending" || item.status === "running").length ?? 0;
4271
4650
  }
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);
4651
+ /** A turn runs, or a follow-up runs or is about to. */
4652
+ function isQueueWorking(queue) {
4653
+ return queue?.turnActive || queue?.items.some((item) => item.status === "running" || item.status === "pending" && !queue.paused);
4654
+ }
4655
+ /** The conversation file is not the one `known` describes: another source wrote to it. */
4656
+ function headMoved(head, known) {
4657
+ return Boolean(head.unavailable) !== Boolean(known.unavailable) || head.file !== known.file || head.size !== known.size;
4658
+ }
4659
+ /**
4660
+ * What a new activity reading of the Agent asks of the chat: look at the conversation's head, read
4661
+ * the queue again, read the queue and then look at the head when that did not reload the history
4662
+ * (a turn ended), or nothing.
4663
+ */
4664
+ function activityReaction(was, now) {
4665
+ if (!was) return "head";
4666
+ if (now.working !== was.working || now.queuePaused !== was.queuePaused || now.followUps !== was.followUps) return was.working && !now.working ? "queue-then-head" : "queue";
4667
+ if (!now.working && now.lastActivityAt !== was.lastActivityAt) return "head";
4668
+ return null;
4669
+ }
4670
+ //#endregion
4671
+ //#region src/components/chat/useSessionSync.ts
4672
+ var SESSION_POLL_MS = 1e4;
4673
+ var QUEUE_POLL_MS = 5e3;
4674
+ function useSessionSync({ agentId, base, initialSessionHead, onConversation, streamingRef, pushNote, onHistory }) {
4281
4675
  const [stale, setStale] = useState(false);
4282
4676
  const [historyUnavailable, setHistoryUnavailable] = useState(initialSessionHead?.unavailable ?? false);
4283
4677
  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
4678
  const knownHeadRef = useRef(initialSessionHead ?? EMPTY_HEAD);
4290
4679
  const queueRef = useRef(null);
4291
- const noteIdRef = useRef(0);
4292
- const entryCountRef = useRef(0);
4293
- const streamingRef = useRef(false);
4294
- streamingRef.current = streaming;
4295
4680
  const staleRef = useRef(stale);
4296
4681
  staleRef.current = stale;
4297
4682
  const activityRef = useRef(null);
4298
4683
  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);
4684
+ const queueWorking = isQueueWorking(queue);
4302
4685
  function know(head) {
4303
4686
  if (head.conversationId !== knownHeadRef.current.conversationId) onConversation?.(head.conversationId);
4304
4687
  knownHeadRef.current = head;
4305
4688
  }
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
4689
  async function refreshHistory() {
4315
4690
  if (streamingRef.current) return;
4316
4691
  try {
4317
4692
  const body = await api(`${base}/sessions/messages`);
4318
4693
  setHistoryUnavailable(body.head.unavailable ?? false);
4319
- setMessages(body.messages);
4320
- setLive([]);
4321
- setEditing(false);
4694
+ onHistory(body.messages);
4322
4695
  know(body.head);
4323
4696
  setStale(false);
4324
4697
  } catch {
@@ -4354,15 +4727,26 @@ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLi
4354
4727
  async function checkHead() {
4355
4728
  if (!initialSessionHead || staleRef.current || streamingRef.current) return;
4356
4729
  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) {
4730
+ if (headMoved(await api(`${base}/sessions/head`), knownHeadRef.current)) {
4360
4731
  setStale(true);
4361
4732
  refreshQueue();
4362
4733
  }
4363
4734
  } catch {}
4364
4735
  }
4365
- useEffect(() => () => abortRef.current?.abort(), []);
4736
+ /** Queue a follow-up; returns the draft to give back to the composer when it was not queued. */
4737
+ async function enqueue(draft) {
4738
+ try {
4739
+ await api(`${base}/queue`, { body: {
4740
+ message: draft.text,
4741
+ attachments: draft.attachments
4742
+ } });
4743
+ refreshQueue();
4744
+ return null;
4745
+ } catch (error) {
4746
+ pushNote(`The follow-up was not queued: ${errorMessage(error)}. Your draft is kept.`);
4747
+ return draft;
4748
+ }
4749
+ }
4366
4750
  useEffect(() => {
4367
4751
  refreshQueue();
4368
4752
  }, []);
@@ -4371,13 +4755,11 @@ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLi
4371
4755
  const was = activityRef.current;
4372
4756
  activityRef.current = now;
4373
4757
  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();
4758
+ const reaction = activityReaction(was, now);
4759
+ if (reaction === "head") checkHead();
4760
+ else if (reaction !== null) refreshQueue().then((reloaded) => {
4761
+ if (reaction === "queue-then-head" && !reloaded) checkHead();
4762
+ });
4381
4763
  }), [feed.subscribe, agentId]);
4382
4764
  useEffect(() => {
4383
4765
  if (!queueWorking || feed.connected) return;
@@ -4398,70 +4780,63 @@ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLi
4398
4780
  stale,
4399
4781
  feed.connected
4400
4782
  ]);
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
- }
4783
+ return {
4784
+ stale,
4785
+ dismissStale: () => setStale(false),
4786
+ historyUnavailable,
4787
+ queue,
4788
+ /** The conversation this tab last knew of; null before the Agent's first turn. */
4789
+ knownConversationId: () => knownHeadRef.current.conversationId,
4790
+ refreshHistory,
4791
+ refreshKnownHead,
4792
+ refreshQueue,
4793
+ enqueue
4794
+ };
4795
+ }
4796
+ //#endregion
4797
+ //#region src/components/chat/useChatSession.ts
4798
+ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLibrary, onConversation }) {
4799
+ const base = `/api/agents/${encodeURIComponent(agentId)}`;
4800
+ const [messages, setMessages] = useState(initialMessages);
4801
+ const [live, setLive] = useState([]);
4802
+ const [notes, setNotes] = useState([]);
4803
+ const [thinking, setThinking] = useState(false);
4804
+ const [streaming, setStreaming] = useState(false);
4805
+ const [editing, setEditing] = useState(false);
4806
+ const [questionsKey, setQuestionsKey] = useState(0);
4807
+ const abortRef = useRef(null);
4808
+ const noteIdRef = useRef(0);
4809
+ const entryCountRef = useRef(0);
4810
+ const streamingRef = useRef(false);
4811
+ streamingRef.current = streaming;
4812
+ function pushNote(content) {
4813
+ const note = {
4814
+ id: noteIdRef.current++,
4815
+ content,
4816
+ afterIndex: entryCountRef.current
4817
+ };
4818
+ setNotes((current) => [...current, note]);
4442
4819
  }
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;
4820
+ useEffect(() => () => abortRef.current?.abort(), []);
4821
+ const sync = useSessionSync({
4822
+ agentId,
4823
+ base,
4824
+ initialSessionHead,
4825
+ onConversation,
4826
+ streamingRef,
4827
+ pushNote,
4828
+ onHistory: (saved) => {
4829
+ setMessages(saved);
4830
+ setLive([]);
4831
+ setEditing(false);
4463
4832
  }
4464
- }
4833
+ });
4834
+ const { recoveredTurn, setRecoveredTurn, approvalTurnRef, approvalBusy, approvalErrors, decide, resetApprovals } = useCommandApprovals({
4835
+ agentId,
4836
+ setLive
4837
+ });
4838
+ const turnBusy = streaming || recoveredTurn;
4839
+ const agentBusy = turnBusy || Boolean(sync.queue?.turnActive);
4465
4840
  function lastUserMessage() {
4466
4841
  return messages.findLastIndex((message) => message.role === "user");
4467
4842
  }
@@ -4480,8 +4855,7 @@ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLi
4480
4855
  setMessages(frame.messages);
4481
4856
  setLive([]);
4482
4857
  setRecoveredTurn(false);
4483
- setApprovalBusy({});
4484
- setApprovalErrors({});
4858
+ resetApprovals();
4485
4859
  return;
4486
4860
  }
4487
4861
  const event = frame.event;
@@ -4500,12 +4874,22 @@ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLi
4500
4874
  */
4501
4875
  async function send(draft) {
4502
4876
  const slash = parseSlashCommand(draft.text);
4503
- if (slash && await runSlashCommand(slash.command, slash.rest)) return draft.attachments.length > 0 ? {
4877
+ if (slash && await runSlashCommand(slash.command, slash.rest, {
4878
+ base,
4879
+ messageCount: messages.length,
4880
+ pushNote,
4881
+ onOpenLibrary,
4882
+ setCompacting: (compacting) => {
4883
+ if (compacting) setEditing(false);
4884
+ setStreaming(compacting);
4885
+ setThinking(compacting);
4886
+ }
4887
+ })) return draft.attachments.length > 0 ? {
4504
4888
  text: "",
4505
4889
  attachments: draft.attachments
4506
4890
  } : null;
4507
4891
  if (turnBusy) {
4508
- if (!editing) return enqueue(draft);
4892
+ if (!editing) return sync.enqueue(draft);
4509
4893
  pushNote("Wait for the current turn to finish before replacing the last message.");
4510
4894
  return draft;
4511
4895
  }
@@ -4514,7 +4898,7 @@ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLi
4514
4898
  try {
4515
4899
  await api(`${base}/chat/truncate`, { body: {
4516
4900
  keepCount,
4517
- conversationId: knownHeadRef.current.conversationId ?? void 0
4901
+ conversationId: sync.knownConversationId() ?? void 0
4518
4902
  } });
4519
4903
  } catch (error) {
4520
4904
  pushNote(`Could not replace the last turn: ${errorMessage(error)}`);
@@ -4523,17 +4907,9 @@ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLi
4523
4907
  setMessages((current) => current.slice(0, keepCount));
4524
4908
  setEditing(false);
4525
4909
  }
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
- }]);
4910
+ setLive([draftEntry(draft.text, draft.attachments)]);
4534
4911
  setRecoveredTurn(false);
4535
- setApprovalBusy({});
4536
- setApprovalErrors({});
4912
+ resetApprovals();
4537
4913
  approvalTurnRef.current = false;
4538
4914
  const abort = new AbortController();
4539
4915
  abortRef.current = abort;
@@ -4551,11 +4927,11 @@ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLi
4551
4927
  if (frame.kind !== "event") finished = true;
4552
4928
  handleFrame(frame);
4553
4929
  }
4554
- await refreshKnownHead();
4930
+ await sync.refreshKnownHead();
4555
4931
  } catch (error) {
4556
4932
  if (error instanceof ApiError) if (error.code === "agent_turn_active") {
4557
4933
  setLive([]);
4558
- restore = await enqueue(draft);
4934
+ restore = await sync.enqueue(draft);
4559
4935
  } else {
4560
4936
  setLive([{
4561
4937
  type: "error",
@@ -4573,7 +4949,7 @@ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLi
4573
4949
  setThinking(false);
4574
4950
  setStreaming(false);
4575
4951
  abortRef.current = null;
4576
- refreshQueue();
4952
+ sync.refreshQueue();
4577
4953
  setQuestionsKey((key) => key + 1);
4578
4954
  }
4579
4955
  }
@@ -4586,40 +4962,7 @@ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLi
4586
4962
  } catch (error) {
4587
4963
  if (!(error instanceof ApiError && error.status === 409)) pushNote("Stop was not confirmed; the response may still be running.");
4588
4964
  }
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
- }
4965
+ sync.refreshQueue();
4623
4966
  }
4624
4967
  /** Put the last user message back in the composer; sending it replaces the last turn. */
4625
4968
  function startEdit() {
@@ -4644,10 +4987,10 @@ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLi
4644
4987
  turnBusy,
4645
4988
  agentBusy,
4646
4989
  editing,
4647
- stale,
4990
+ stale: sync.stale,
4648
4991
  recoveredTurn,
4649
- historyUnavailable,
4650
- queue,
4992
+ historyUnavailable: sync.historyUnavailable,
4993
+ queue: sync.queue,
4651
4994
  questionsKey,
4652
4995
  approvals: {
4653
4996
  busy: approvalBusy,
@@ -4658,14 +5001,17 @@ function useChatSession({ agentId, initialMessages, initialSessionHead, onOpenLi
4658
5001
  stop,
4659
5002
  startEdit,
4660
5003
  cancelEdit: () => setEditing(false),
4661
- refreshHistory,
4662
- refreshQueue,
4663
- dismissStale: () => setStale(false)
5004
+ refreshHistory: sync.refreshHistory,
5005
+ refreshQueue: sync.refreshQueue,
5006
+ dismissStale: sync.dismissStale,
5007
+ /** The conversation on screen; null before the Agent's first turn. */
5008
+ conversationId: sync.knownConversationId
4664
5009
  };
4665
5010
  }
4666
5011
  //#endregion
4667
5012
  //#region src/components/chat/ChatPane.tsx
4668
- var AUTOSCROLL_THRESHOLD_PX = 40;
5013
+ /** Unsent text per Agent, kept while the page is open. */
5014
+ var drafts = /* @__PURE__ */ new Map();
4669
5015
  var CHAT_FRAME = "relative flex h-full flex-col overflow-hidden rounded-[16px] border border-frost bg-snow shadow-baziu-sm";
4670
5016
  /** One pane per Agent: switching Agents starts a fresh one. */
4671
5017
  function ChatPane(props) {
@@ -4682,12 +5028,44 @@ function AgentChat({ agentId, agentName, initialMessages, initialSessionHead, he
4682
5028
  onOpenLibrary: () => setConversationsOpen(true),
4683
5029
  onConversation: onConversationChange
4684
5030
  });
4685
- const [input, setInput] = useState("");
5031
+ const [input, setInputState] = useState(() => drafts.get(agentId) ?? "");
5032
+ const beforeEdit = useRef("");
5033
+ const editingRef = useRef(false);
5034
+ useEffect(() => {
5035
+ if (!chat.editing) editingRef.current = false;
5036
+ }, [chat.editing]);
5037
+ const setInput = (next) => setInputState((current) => {
5038
+ const value = typeof next === "function" ? next(current) : next;
5039
+ const kept = editingRef.current ? beforeEdit.current : value;
5040
+ if (kept) drafts.set(agentId, kept);
5041
+ else drafts.delete(agentId);
5042
+ return value;
5043
+ });
4686
5044
  const [attachments, setAttachments] = useState([]);
4687
5045
  const [dragging, setDragging] = useState(false);
4688
5046
  const inputRef = useRef(null);
4689
5047
  const logRef = useRef(null);
4690
5048
  const nearBottomRef = useRef(true);
5049
+ const workspace = useWorkspaceOptional();
5050
+ const navigate = useNavigate();
5051
+ useFindInTranscript(logRef, workspace?.search.find, workspace?.search.match, () => {
5052
+ nearBottomRef.current = false;
5053
+ if (workspace) navigate({
5054
+ to: "/",
5055
+ search: workspace.to({
5056
+ find: void 0,
5057
+ match: void 0
5058
+ }),
5059
+ replace: true
5060
+ });
5061
+ });
5062
+ useTranscriptPlace(logRef, () => placeKey(agentId, chat.conversationId()), {
5063
+ ready: true,
5064
+ skip: Boolean(workspace?.search.find),
5065
+ onRestored: () => {
5066
+ nearBottomRef.current = false;
5067
+ }
5068
+ });
4691
5069
  useLayoutEffect(() => {
4692
5070
  const log = logRef.current;
4693
5071
  if (log && nearBottomRef.current) log.scrollTop = log.scrollHeight;
@@ -4702,18 +5080,23 @@ function AgentChat({ agentId, agentName, initialMessages, initialSessionHead, he
4702
5080
  attachments
4703
5081
  };
4704
5082
  if (!draft.text.trim() && draft.attachments.length === 0) return;
4705
- setInput("");
5083
+ const earlier = editingRef.current ? beforeEdit.current : "";
5084
+ editingRef.current = false;
5085
+ beforeEdit.current = "";
5086
+ setInput(earlier);
4706
5087
  setAttachments([]);
4707
5088
  const restore = await chat.send(draft);
4708
5089
  activity?.refresh();
4709
5090
  if (restore) {
4710
- setInput((current) => current || restore.text);
5091
+ setInput((current) => current && current !== earlier ? current : restore.text);
4711
5092
  setAttachments((current) => current.length > 0 ? current : restore.attachments);
4712
5093
  }
4713
5094
  }
4714
5095
  function edit() {
4715
5096
  const text = chat.startEdit();
4716
5097
  if (text === null) return;
5098
+ beforeEdit.current = input;
5099
+ editingRef.current = true;
4717
5100
  setInput(text);
4718
5101
  inputRef.current?.focus();
4719
5102
  }
@@ -4773,7 +5156,7 @@ function AgentChat({ agentId, agentName, initialMessages, initialSessionHead, he
4773
5156
  }),
4774
5157
  /* @__PURE__ */ jsx("span", {
4775
5158
  className: "flex-1",
4776
- children: chat.recoveredTurn ? "The recovered turn has new activity." : "There is new activity from another source (a follow-up, Telegram or a schedule)."
5159
+ children: chat.recoveredTurn ? "The recovered turn has new activity." : "There is new activity from elsewhere (the terminal, a follow-up, Telegram or a schedule)."
4777
5160
  }),
4778
5161
  /* @__PURE__ */ jsx("button", {
4779
5162
  type: "button",
@@ -4793,8 +5176,7 @@ function AgentChat({ agentId, agentName, initialMessages, initialSessionHead, he
4793
5176
  /* @__PURE__ */ jsx("div", {
4794
5177
  ref: logRef,
4795
5178
  onScroll: (event) => {
4796
- const log = event.currentTarget;
4797
- nearBottomRef.current = log.scrollHeight - log.scrollTop - log.clientHeight < AUTOSCROLL_THRESHOLD_PX;
5179
+ nearBottomRef.current = isAtEnd(event.currentTarget);
4798
5180
  },
4799
5181
  role: "log",
4800
5182
  "aria-label": `Conversation with ${agentName}`,
@@ -4844,7 +5226,8 @@ function AgentChat({ agentId, agentName, initialMessages, initialSessionHead, he
4844
5226
  agentId,
4845
5227
  queue: chat.queue,
4846
5228
  onChanged: () => void chat.refreshQueue(),
4847
- onViewConversation: (id) => onViewConversation?.(id)
5229
+ onViewConversation: (id) => onViewConversation?.(id),
5230
+ conversationId: chat.conversationId()
4848
5231
  }),
4849
5232
  /* @__PURE__ */ jsx(AgentQuestions, {
4850
5233
  agentId,
@@ -4860,7 +5243,12 @@ function AgentChat({ agentId, agentName, initialMessages, initialSessionHead, he
4860
5243
  onAddFiles: (files) => void addFiles(files),
4861
5244
  onRemoveAttachment: (index) => setAttachments((current) => current.filter((_, i) => i !== index)),
4862
5245
  editing: chat.editing,
4863
- onCancelEdit: chat.cancelEdit,
5246
+ onCancelEdit: () => {
5247
+ chat.cancelEdit();
5248
+ editingRef.current = false;
5249
+ setInput(beforeEdit.current);
5250
+ beforeEdit.current = "";
5251
+ },
4864
5252
  agentBusy: chat.agentBusy,
4865
5253
  onStop: () => void chat.stop(),
4866
5254
  inputRef
@@ -5233,8 +5621,8 @@ function Preview({ result }) {
5233
5621
  }
5234
5622
  //#endregion
5235
5623
  //#region src/components/workspace/ConversationHeader.tsx
5236
- 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";
5624
+ var CHIP = "inline-flex h-[26px] min-w-0 max-w-[11rem] shrink 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";
5625
+ 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
5626
  /** The model without its provider: `lmstudio:paper-coder-32b` reads as `paper-coder-32b`. */
5239
5627
  function shortModel(model) {
5240
5628
  const colon = model.indexOf(":");
@@ -5260,7 +5648,8 @@ function ConversationHeader({ agent, chat, panel, lastPanel }) {
5260
5648
  size: 32
5261
5649
  }),
5262
5650
  /* @__PURE__ */ jsx("h1", {
5263
- className: "m-0 min-w-0 truncate font-display text-xl leading-tight text-charcoal",
5651
+ title: agent.agent.name,
5652
+ className: "m-0 min-w-0 max-w-[14rem] shrink-0 truncate font-display text-xl leading-tight text-charcoal",
5264
5653
  children: agent.agent.name
5265
5654
  }),
5266
5655
  /* @__PURE__ */ jsx(Link, {
@@ -5269,8 +5658,12 @@ function ConversationHeader({ agent, chat, panel, lastPanel }) {
5269
5658
  panel: "team",
5270
5659
  section: void 0
5271
5660
  }),
5272
- className: CHIP,
5273
- children: agent.team.name
5661
+ title: agent.team.name,
5662
+ className: cn(CHIP, agent.team.name.length <= 16 && "shrink-0"),
5663
+ children: /* @__PURE__ */ jsx("span", {
5664
+ className: "min-w-0 truncate",
5665
+ children: agent.team.name
5666
+ })
5274
5667
  }),
5275
5668
  /* @__PURE__ */ jsxs(Link, {
5276
5669
  to: "/",
@@ -5279,14 +5672,17 @@ function ConversationHeader({ agent, chat, panel, lastPanel }) {
5279
5672
  section: void 0
5280
5673
  }),
5281
5674
  title: `Model: ${agent.model}`,
5282
- className: cn(CHIP, "hidden font-mono font-normal sm:inline-flex"),
5283
- children: [shortModel(agent.model), /* @__PURE__ */ jsx(ChevronDown, {
5284
- className: "size-[11px]",
5675
+ className: cn(CHIP, "hidden min-w-[4.5rem] shrink-[4] font-mono font-normal sm:inline-flex"),
5676
+ children: [/* @__PURE__ */ jsx("span", {
5677
+ className: "min-w-0 truncate",
5678
+ children: shortModel(agent.model)
5679
+ }), /* @__PURE__ */ jsx(ChevronDown, {
5680
+ className: "size-[11px] shrink-0",
5285
5681
  "aria-hidden": "true"
5286
5682
  })]
5287
5683
  }),
5288
5684
  /* @__PURE__ */ jsxs("div", {
5289
- className: "ml-auto flex min-w-16 shrink items-center justify-end gap-1.5",
5685
+ className: "ml-auto flex min-w-[7.75rem] shrink-[20] items-center justify-end gap-1.5",
5290
5686
  children: [/* @__PURE__ */ jsx(ConversationMenu, {
5291
5687
  agentId: agent.agent.id,
5292
5688
  chat
@@ -5298,7 +5694,6 @@ function ConversationHeader({ agent, chat, panel, lastPanel }) {
5298
5694
  }),
5299
5695
  "aria-label": panel === "none" ? "Show the side panel" : "Hide the side panel",
5300
5696
  title: panel === "none" ? "Show the side panel" : "Hide the side panel",
5301
- "aria-pressed": panel !== "none",
5302
5697
  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
5698
  children: /* @__PURE__ */ jsx(PanelRight, {
5304
5699
  className: "size-4",
@@ -5319,7 +5714,7 @@ function ConversationMenu({ agentId, chat }) {
5319
5714
  const [ownOpen, setOwnOpen] = useState(false);
5320
5715
  const [renaming, setRenaming] = useState(null);
5321
5716
  const [error, setError] = useState("");
5322
- const list = useResource((signal) => api(`${base}?limit=20`, { signal }), [base, turnsEnded]);
5717
+ const list = useResource((signal) => api(`${base}?limit=20`, { signal }), [base], { refreshOn: turnsEnded });
5323
5718
  const open = chat ? chat.conversationsOpen : ownOpen;
5324
5719
  const setOpen = chat ? chat.setConversationsOpen : setOwnOpen;
5325
5720
  const conversations = list.data?.conversations ?? [];
@@ -5370,7 +5765,7 @@ function ConversationMenu({ agentId, chat }) {
5370
5765
  asChild: true,
5371
5766
  children: /* @__PURE__ */ jsxs("button", {
5372
5767
  type: "button",
5373
- "aria-label": "Conversations",
5768
+ "aria-label": shown ? `${shown.title}: conversations` : "Conversations",
5374
5769
  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
5770
  children: [
5376
5771
  /* @__PURE__ */ jsx(MessageSquare, {
@@ -5419,17 +5814,24 @@ function ConversationMenu({ agentId, chat }) {
5419
5814
  conversations.map((conversation) => {
5420
5815
  const active = conversation.id === activeId;
5421
5816
  const reading = conversation.id === shownId;
5817
+ const used = list.data?.usage[conversation.id];
5422
5818
  return /* @__PURE__ */ jsx(DropdownMenu.Item, {
5423
5819
  asChild: true,
5424
- className: MENU_ITEM,
5820
+ className: MENU_ITEM$1,
5425
5821
  children: /* @__PURE__ */ jsxs(Link, {
5426
5822
  to: "/",
5427
5823
  search: to({ conversation: active ? void 0 : conversation.id }),
5428
5824
  "aria-current": reading ? "true" : void 0,
5429
5825
  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
5826
+ children: [/* @__PURE__ */ jsxs("span", {
5827
+ className: "min-w-0 flex-1",
5828
+ children: [/* @__PURE__ */ jsx("span", {
5829
+ className: "block truncate font-medium",
5830
+ children: conversation.title
5831
+ }), used && /* @__PURE__ */ jsx("span", {
5832
+ className: "block truncate text-xs text-muted-foreground",
5833
+ children: usageSummary(used)
5834
+ })]
5433
5835
  }), active ? /* @__PURE__ */ jsxs("span", {
5434
5836
  className: "flex shrink-0 items-center gap-1 text-xs font-semibold text-success",
5435
5837
  children: [/* @__PURE__ */ jsx(Check, {
@@ -5458,7 +5860,7 @@ function ConversationMenu({ agentId, chat }) {
5458
5860
  }),
5459
5861
  /* @__PURE__ */ jsx(DropdownMenu.Separator, { className: "my-1.5 h-px bg-border" }),
5460
5862
  /* @__PURE__ */ jsxs(DropdownMenu.Item, {
5461
- className: `${MENU_ITEM} font-semibold`,
5863
+ className: `${MENU_ITEM$1} font-semibold`,
5462
5864
  disabled: chat?.agentBusy ?? false,
5463
5865
  onSelect: () => void startNew(),
5464
5866
  children: [
@@ -5474,7 +5876,7 @@ function ConversationMenu({ agentId, chat }) {
5474
5876
  ]
5475
5877
  }),
5476
5878
  shown && /* @__PURE__ */ jsxs(DropdownMenu.Item, {
5477
- className: MENU_ITEM,
5879
+ className: MENU_ITEM$1,
5478
5880
  onSelect: () => setRenaming(shown),
5479
5881
  children: [
5480
5882
  /* @__PURE__ */ jsx(Pencil, {
@@ -5485,6 +5887,18 @@ function ConversationMenu({ agentId, chat }) {
5485
5887
  shown.title.length > 24 ? `${shown.title.slice(0, 24)}…` : shown.title,
5486
5888
  "”"
5487
5889
  ]
5890
+ }),
5891
+ /* @__PURE__ */ jsx(DropdownMenu.Item, {
5892
+ asChild: true,
5893
+ className: MENU_ITEM$1,
5894
+ children: /* @__PURE__ */ jsxs(Link, {
5895
+ to: "/usage",
5896
+ search: { agent: agentId },
5897
+ children: [/* @__PURE__ */ jsx(BarChart3, {
5898
+ className: "size-3.5",
5899
+ "aria-hidden": "true"
5900
+ }), "This Agent's usage"]
5901
+ })
5488
5902
  })
5489
5903
  ]
5490
5904
  }) })]
@@ -5557,8 +5971,20 @@ function RenameConversation({ base, conversation, onClose, onRenamed }) {
5557
5971
  //#endregion
5558
5972
  //#region src/components/workspace/EarlierConversation.tsx
5559
5973
  function EarlierConversation({ agentId, agentName, conversationId, header }) {
5560
- const { to } = useWorkspace();
5974
+ const { search, to } = useWorkspace();
5561
5975
  const router = useRouter();
5976
+ const navigate = useNavigate();
5977
+ const logRef = useRef(null);
5978
+ useFindInTranscript(logRef, search.find, search.match, () => {
5979
+ navigate({
5980
+ to: "/",
5981
+ search: to({
5982
+ find: void 0,
5983
+ match: void 0
5984
+ }),
5985
+ replace: true
5986
+ });
5987
+ });
5562
5988
  const path = `/api/agents/${encodeURIComponent(agentId)}/conversations/${encodeURIComponent(conversationId)}`;
5563
5989
  const [busy, setBusy] = useState(false);
5564
5990
  const [error, setError] = useState("");
@@ -5573,6 +5999,10 @@ function EarlierConversation({ agentId, agentName, conversationId, header }) {
5573
5999
  throw cause;
5574
6000
  }
5575
6001
  }, [path]);
6002
+ useTranscriptPlace(logRef, () => placeKey(agentId, conversationId), {
6003
+ ready: opened.data !== void 0,
6004
+ skip: Boolean(search.find)
6005
+ });
5576
6006
  async function continueHere() {
5577
6007
  setBusy(true);
5578
6008
  setError("");
@@ -5604,7 +6034,7 @@ function EarlierConversation({ agentId, agentName, conversationId, header }) {
5604
6034
  " ",
5605
6035
  title ? /* @__PURE__ */ jsx("strong", {
5606
6036
  className: "text-foreground",
5607
- children: title
6037
+ children: title.replace(/\.+$/, "")
5608
6038
  }) : "an earlier conversation",
5609
6039
  ". New messages go to the active conversation."
5610
6040
  ]
@@ -5630,6 +6060,7 @@ function EarlierConversation({ agentId, agentName, conversationId, header }) {
5630
6060
  children: error
5631
6061
  }),
5632
6062
  /* @__PURE__ */ jsx("div", {
6063
+ ref: logRef,
5633
6064
  className: "min-h-0 flex-1 overflow-y-auto px-5 py-4",
5634
6065
  children: /* @__PURE__ */ jsxs("div", {
5635
6066
  className: "mx-auto max-w-[50rem]",
@@ -5800,7 +6231,7 @@ function Overview() {
5800
6231
  children: [/* @__PURE__ */ jsx(Plus, {
5801
6232
  className: "size-4",
5802
6233
  "aria-hidden": "true"
5803
- }), "Add your first agent"]
6234
+ }), "Add your first Agent"]
5804
6235
  })
5805
6236
  }),
5806
6237
  files.results.length > 0 && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("h2", {
@@ -5864,6 +6295,544 @@ function TeamCard({ team, members, summary }) {
5864
6295
  }) });
5865
6296
  }
5866
6297
  //#endregion
6298
+ //#region src/components/workspace/rail/menu.ts
6299
+ 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";
6300
+ 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";
6301
+ //#endregion
6302
+ //#region src/components/workspace/rail/NewMenu.tsx
6303
+ function NewMenu({ buttonRef, profiles, teamTemplates, onSpawnAgent, onSpawnTeam, onCreateTeam }) {
6304
+ return /* @__PURE__ */ jsxs(DropdownMenu.Root, {
6305
+ modal: false,
6306
+ children: [/* @__PURE__ */ jsx(DropdownMenu.Trigger, {
6307
+ asChild: true,
6308
+ children: /* @__PURE__ */ jsxs("button", {
6309
+ ref: buttonRef,
6310
+ type: "button",
6311
+ "aria-label": "Create a new Agent or Team",
6312
+ 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",
6313
+ children: [
6314
+ /* @__PURE__ */ jsx(Plus, {
6315
+ className: "size-3.5",
6316
+ "aria-hidden": "true"
6317
+ }),
6318
+ "New",
6319
+ /* @__PURE__ */ jsx(ChevronDown, {
6320
+ className: "size-3.5 text-muted-foreground transition-transform group-data-[state=open]:rotate-180",
6321
+ "aria-hidden": "true"
6322
+ })
6323
+ ]
6324
+ })
6325
+ }), /* @__PURE__ */ jsx(DropdownMenu.Portal, { children: /* @__PURE__ */ jsxs(DropdownMenu.Content, {
6326
+ align: "end",
6327
+ sideOffset: 6,
6328
+ className: "z-50 w-60 rounded-xl border border-border bg-popover p-1.5 text-popover-foreground shadow-baziu-lg outline-none",
6329
+ children: [
6330
+ /* @__PURE__ */ jsxs(DropdownMenu.Label, {
6331
+ className: MENU_LABEL,
6332
+ children: [/* @__PURE__ */ jsx(Bot, {
6333
+ className: "size-3",
6334
+ "aria-hidden": "true"
6335
+ }), "Agent templates"]
6336
+ }),
6337
+ profiles.length === 0 ? /* @__PURE__ */ jsx(DropdownMenu.Item, {
6338
+ asChild: true,
6339
+ className: MENU_ITEM,
6340
+ children: /* @__PURE__ */ jsx("a", {
6341
+ href: "/templates/agents?new=1",
6342
+ children: "Create an Agent template"
6343
+ })
6344
+ }) : profiles.map((profile) => /* @__PURE__ */ jsxs(DropdownMenu.Item, {
6345
+ className: MENU_ITEM,
6346
+ onSelect: () => onSpawnAgent(profile.id),
6347
+ children: [/* @__PURE__ */ jsx("span", {
6348
+ className: "min-w-0 flex-1 truncate",
6349
+ children: profile.name || profile.id
6350
+ }), profile.id === "default" && /* @__PURE__ */ jsx("span", {
6351
+ className: "rounded-full border border-border bg-muted px-1.5 py-0.5 text-xs font-semibold text-muted-foreground",
6352
+ children: "Default"
6353
+ })]
6354
+ }, profile.id)),
6355
+ /* @__PURE__ */ jsx(DropdownMenu.Separator, { className: "my-1.5 h-px bg-border" }),
6356
+ /* @__PURE__ */ jsxs(DropdownMenu.Label, {
6357
+ className: MENU_LABEL,
6358
+ children: [/* @__PURE__ */ jsx(UsersRound, {
6359
+ className: "size-3",
6360
+ "aria-hidden": "true"
6361
+ }), "Team templates"]
6362
+ }),
6363
+ teamTemplates.length === 0 ? /* @__PURE__ */ jsx(DropdownMenu.Item, {
6364
+ asChild: true,
6365
+ className: MENU_ITEM,
6366
+ children: /* @__PURE__ */ jsx("a", {
6367
+ href: "/templates/teams?new=1",
6368
+ children: "Create a Team template"
6369
+ })
6370
+ }) : teamTemplates.map((entry) => /* @__PURE__ */ jsxs(DropdownMenu.Item, {
6371
+ className: MENU_ITEM,
6372
+ disabled: entry.slots.length === 0,
6373
+ title: entry.slots.length === 0 ? "Add at least one member before spawning" : void 0,
6374
+ onSelect: () => onSpawnTeam(entry.id),
6375
+ children: [/* @__PURE__ */ jsx("span", {
6376
+ className: "min-w-0 flex-1 truncate",
6377
+ children: entry.name || entry.id
6378
+ }), /* @__PURE__ */ jsx("span", {
6379
+ className: "inline-flex min-w-6 items-center justify-center rounded-full bg-muted px-1.5 font-mono text-xs text-muted-foreground",
6380
+ children: entry.slots.length
6381
+ })]
6382
+ }, entry.id)),
6383
+ /* @__PURE__ */ jsx(DropdownMenu.Separator, { className: "my-1.5 h-px bg-border" }),
6384
+ /* @__PURE__ */ jsxs(DropdownMenu.Item, {
6385
+ className: MENU_ITEM,
6386
+ onSelect: onCreateTeam,
6387
+ children: [/* @__PURE__ */ jsx(Plus, {
6388
+ className: "size-3.5",
6389
+ "aria-hidden": "true"
6390
+ }), "Create a Team"]
6391
+ })
6392
+ ]
6393
+ }) })]
6394
+ });
6395
+ }
6396
+ //#endregion
6397
+ //#region src/components/workspace/rail/order.ts
6398
+ /** The Default Team first, then the rest as the daemon lists them. */
6399
+ function sortTeams(teams) {
6400
+ return [...teams].sort((a, b) => Number(b.id === DEFAULT_TEAM_ID) - Number(a.id === DEFAULT_TEAM_ID));
6401
+ }
6402
+ /** The seeded default template first: the one-click path for a new install. */
6403
+ function sortProfiles(profiles) {
6404
+ return [...profiles].sort((a, b) => Number(b.id === DEFAULT_PROFILE_ID) - Number(a.id === DEFAULT_PROFILE_ID));
6405
+ }
6406
+ /** The folded rail's Teams: only those with Agents, the Team in view first. */
6407
+ function slimTeams(teams, agents, inViewId) {
6408
+ const sorted = sortTeams(teams).filter((team) => agents.some((agent) => agent.teamId === team.id));
6409
+ sorted.sort((a, b) => Number(b.id === inViewId) - Number(a.id === inViewId));
6410
+ return sorted;
6411
+ }
6412
+ //#endregion
6413
+ //#region src/components/workspace/rail/AgentRow.tsx
6414
+ function AgentRow({ agent, selected, state, lastActivityAt, panel, onRename, onArchive }) {
6415
+ const hydrated = useHydrated();
6416
+ return /* @__PURE__ */ jsxs("div", {
6417
+ className: "group/row relative rounded-2xl",
6418
+ children: [/* @__PURE__ */ jsxs(Link, {
6419
+ to: "/",
6420
+ search: {
6421
+ agent: agent.id,
6422
+ ...panel ? { panel } : {}
6423
+ },
6424
+ "aria-current": selected ? "page" : void 0,
6425
+ 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"}`,
6426
+ children: [/* @__PURE__ */ jsx(AgentAvatar, {
6427
+ identity: agent.identity,
6428
+ size: 30
6429
+ }), /* @__PURE__ */ jsxs("span", {
6430
+ className: "block min-w-0 flex-1",
6431
+ children: [/* @__PURE__ */ jsxs("span", {
6432
+ className: "flex items-center gap-1.5",
6433
+ children: [
6434
+ /* @__PURE__ */ jsx("span", {
6435
+ className: `min-w-0 truncate text-sm font-semibold leading-tight ${selected ? "text-accent-foreground" : "text-foreground"}`,
6436
+ children: agent.name
6437
+ }),
6438
+ agent.telegramTopicId !== null && /* @__PURE__ */ jsx("span", {
6439
+ className: "shrink-0 text-primary",
6440
+ title: `Telegram topic #${agent.telegramTopicId}`,
6441
+ role: "img",
6442
+ "aria-label": `Bound to Telegram topic ${agent.telegramTopicId}`,
6443
+ children: /* @__PURE__ */ jsx(Send, {
6444
+ className: "size-3",
6445
+ "aria-hidden": "true"
6446
+ })
6447
+ }),
6448
+ hydrated && lastActivityAt !== null && /* @__PURE__ */ jsx("time", {
6449
+ dateTime: new Date(lastActivityAt).toISOString(),
6450
+ className: "ml-auto shrink-0 text-xs font-normal text-muted-foreground",
6451
+ children: shortTime(lastActivityAt)
6452
+ })
6453
+ ]
6454
+ }), /* @__PURE__ */ jsxs("span", {
6455
+ className: `mt-0.5 flex items-center gap-1.5 text-xs leading-snug ${STATE_TEXT[state.kind]}`,
6456
+ children: [/* @__PURE__ */ jsx("span", {
6457
+ className: `size-[7px] shrink-0 rounded-full ${STATE_DOT[state.kind]}`,
6458
+ "aria-hidden": "true"
6459
+ }), /* @__PURE__ */ jsx("span", {
6460
+ className: "min-w-0 truncate",
6461
+ children: state.text
6462
+ })]
6463
+ })]
6464
+ })]
6465
+ }), /* @__PURE__ */ jsxs(DropdownMenu.Root, {
6466
+ modal: false,
6467
+ children: [/* @__PURE__ */ jsx(DropdownMenu.Trigger, {
6468
+ asChild: true,
6469
+ children: /* @__PURE__ */ jsx("button", {
6470
+ type: "button",
6471
+ "aria-label": `More for ${agent.name}`,
6472
+ 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",
6473
+ children: /* @__PURE__ */ jsx(Ellipsis, {
6474
+ className: "size-4",
6475
+ "aria-hidden": "true"
6476
+ })
6477
+ })
6478
+ }), /* @__PURE__ */ jsx(DropdownMenu.Portal, { children: /* @__PURE__ */ jsxs(DropdownMenu.Content, {
6479
+ align: "start",
6480
+ sideOffset: 4,
6481
+ className: "z-50 w-48 rounded-xl border border-border bg-popover p-1.5 text-popover-foreground shadow-baziu-lg outline-none",
6482
+ children: [
6483
+ /* @__PURE__ */ jsx(DropdownMenu.Item, {
6484
+ asChild: true,
6485
+ className: MENU_ITEM,
6486
+ children: /* @__PURE__ */ jsxs(Link, {
6487
+ to: "/",
6488
+ search: {
6489
+ agent: agent.id,
6490
+ panel: "agent"
6491
+ },
6492
+ children: [/* @__PURE__ */ jsx(Settings2, {
6493
+ className: "size-3.5",
6494
+ "aria-hidden": "true"
6495
+ }), "Agent settings"]
6496
+ })
6497
+ }),
6498
+ /* @__PURE__ */ jsxs(DropdownMenu.Item, {
6499
+ className: MENU_ITEM,
6500
+ onSelect: onRename,
6501
+ children: [/* @__PURE__ */ jsx(Pencil, {
6502
+ className: "size-3.5",
6503
+ "aria-hidden": "true"
6504
+ }), "Rename"]
6505
+ }),
6506
+ /* @__PURE__ */ jsxs(DropdownMenu.Item, {
6507
+ className: MENU_ITEM,
6508
+ onSelect: onArchive,
6509
+ children: [/* @__PURE__ */ jsx(Archive, {
6510
+ className: "size-3.5",
6511
+ "aria-hidden": "true"
6512
+ }), "Archive"]
6513
+ })
6514
+ ]
6515
+ }) })]
6516
+ })]
6517
+ });
6518
+ }
6519
+ //#endregion
6520
+ //#region src/components/workspace/rail/TeamGroup.tsx
6521
+ function TeamGroup({ team, members, current, isOpen, onOpenChange, openAgentId, selectedId, activity, panel, onRename, onArchive }) {
6522
+ const summary = teamSummary(members.map((agent) => activity.stateOf(agent.id)));
6523
+ return /* @__PURE__ */ jsxs("div", {
6524
+ className: "relative mb-1 last:mb-0",
6525
+ children: [/* @__PURE__ */ jsxs("details", {
6526
+ open: isOpen,
6527
+ onToggle: (event) => {
6528
+ const next = event.currentTarget.open;
6529
+ if (next === isOpen) return;
6530
+ onOpenChange(next);
6531
+ },
6532
+ className: "group/details",
6533
+ children: [/* @__PURE__ */ jsxs("summary", {
6534
+ 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"}`,
6535
+ children: [
6536
+ /* @__PURE__ */ jsx(ChevronRight, {
6537
+ className: "size-3.5 shrink-0 text-muted-foreground transition-transform group-open/details:rotate-90",
6538
+ "aria-hidden": "true"
6539
+ }),
6540
+ /* @__PURE__ */ jsx("span", {
6541
+ className: "min-w-0 flex-1 truncate font-semibold",
6542
+ children: team.name
6543
+ }),
6544
+ /* @__PURE__ */ jsx("span", {
6545
+ className: "shrink-0 text-xs text-muted-foreground",
6546
+ children: summary || members.length
6547
+ })
6548
+ ]
6549
+ }), members.length === 0 ? /* @__PURE__ */ jsx("div", {
6550
+ className: "py-2 pl-7 pr-2 text-xs text-muted-foreground",
6551
+ children: "No agents in this team"
6552
+ }) : /* @__PURE__ */ jsx("div", {
6553
+ className: "space-y-0.5 py-1 pl-1.5",
6554
+ children: members.map((agent) => /* @__PURE__ */ jsx(AgentRow, {
6555
+ agent,
6556
+ selected: agent.id === selectedId,
6557
+ state: activity.stateOf(agent.id),
6558
+ lastActivityAt: activity.byAgent.get(agent.id)?.lastActivityAt ?? null,
6559
+ panel,
6560
+ onRename: () => onRename(agent),
6561
+ onArchive: () => onArchive(agent)
6562
+ }, agent.id))
6563
+ })]
6564
+ }), /* @__PURE__ */ jsx(Link, {
6565
+ to: "/",
6566
+ search: {
6567
+ ...openAgentId !== null ? { agent: openAgentId } : {},
6568
+ team: team.id,
6569
+ panel: "team"
6570
+ },
6571
+ "aria-label": `Open ${team.name}: members, USER.md, memory`,
6572
+ title: "Open the Team",
6573
+ className: "absolute right-1 top-1 flex size-7 items-center justify-center rounded-lg text-muted-foreground hover:bg-card hover:text-primary",
6574
+ children: /* @__PURE__ */ jsx(PanelRight, {
6575
+ className: "size-3.5",
6576
+ "aria-hidden": "true"
6577
+ })
6578
+ })]
6579
+ });
6580
+ }
6581
+ //#endregion
6582
+ //#region src/components/workspace/rail/Rail.tsx
6583
+ function Rail({ initialOpenGroups }) {
6584
+ const { agents, teams, profiles, teamTemplates, agent: open, team: inView, search } = useWorkspace();
6585
+ const activity = useActivity();
6586
+ const router = useRouter();
6587
+ const [spawnProfile, setSpawnProfile] = useState(null);
6588
+ const [spawnTeam, setSpawnTeam] = useState(void 0);
6589
+ const [spawnTemplate, setSpawnTemplate] = useState(null);
6590
+ const [createTeamOpen, setCreateTeamOpen] = useState(false);
6591
+ const [createTeamBusy, setCreateTeamBusy] = useState(false);
6592
+ const [renameTarget, setRenameTarget] = useState(null);
6593
+ const [archiveTarget, setArchiveTarget] = useState(null);
6594
+ const [openGroups, setOpenGroups] = useState(initialOpenGroups);
6595
+ const newButton = useRef(null);
6596
+ const refocusNewButton = () => window.requestAnimationFrame(() => newButton.current?.focus());
6597
+ const sortedProfiles = sortProfiles(profiles);
6598
+ const sortedTeams = sortTeams(teams);
6599
+ const template = teamTemplates.find((entry) => entry.id === spawnTemplate);
6600
+ const selectedId = open?.agent.id ?? null;
6601
+ return /* @__PURE__ */ jsxs("aside", {
6602
+ className: "flex h-full flex-col overflow-hidden rounded-2xl border border-border bg-card shadow-baziu-sm",
6603
+ children: [
6604
+ /* @__PURE__ */ jsxs("header", {
6605
+ className: "flex items-center justify-between gap-3 border-b border-border bg-muted/60 px-3 py-2.5",
6606
+ children: [/* @__PURE__ */ jsxs("div", {
6607
+ className: "flex min-w-0 items-center gap-2",
6608
+ children: [/* @__PURE__ */ jsx("span", {
6609
+ className: "flex size-7 shrink-0 items-center justify-center rounded-[10px] bg-accent text-accent-foreground",
6610
+ children: /* @__PURE__ */ jsx(UsersRound, {
6611
+ className: "size-4",
6612
+ "aria-hidden": "true"
6613
+ })
6614
+ }), /* @__PURE__ */ jsxs("div", {
6615
+ className: "min-w-0",
6616
+ children: [/* @__PURE__ */ jsx("div", {
6617
+ className: "text-sm font-semibold leading-tight text-foreground",
6618
+ children: "Teams"
6619
+ }), /* @__PURE__ */ jsxs("p", {
6620
+ className: "m-0 truncate text-xs leading-snug text-muted-foreground",
6621
+ children: [
6622
+ agents.length,
6623
+ " agent",
6624
+ agents.length === 1 ? "" : "s",
6625
+ " in ",
6626
+ teams.length,
6627
+ " team",
6628
+ teams.length === 1 ? "" : "s"
6629
+ ]
6630
+ })]
6631
+ })]
6632
+ }), /* @__PURE__ */ jsx(NewMenu, {
6633
+ buttonRef: newButton,
6634
+ profiles: sortedProfiles,
6635
+ teamTemplates,
6636
+ onSpawnAgent: (profileId) => {
6637
+ setSpawnTeam(inView?.id);
6638
+ setSpawnProfile(profileId);
6639
+ },
6640
+ onSpawnTeam: (templateId) => setSpawnTemplate(templateId),
6641
+ onCreateTeam: () => setCreateTeamOpen(true)
6642
+ })]
6643
+ }),
6644
+ /* @__PURE__ */ jsxs("nav", {
6645
+ className: "flex-1 overflow-y-auto p-1.5",
6646
+ "aria-label": "Teams and agents",
6647
+ children: [agents.length === 0 && /* @__PURE__ */ jsxs("div", {
6648
+ 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",
6649
+ children: [
6650
+ /* @__PURE__ */ jsx("p", {
6651
+ className: "m-0 text-sm font-semibold text-foreground",
6652
+ children: "No agents yet"
6653
+ }),
6654
+ /* @__PURE__ */ jsx("p", {
6655
+ className: "mt-1 text-xs leading-5 text-muted-foreground",
6656
+ children: "Your default Team is ready. Add the first Agent to start a conversation."
6657
+ }),
6658
+ sortedProfiles[0] ? /* @__PURE__ */ jsx(Button, {
6659
+ variant: "primary",
6660
+ className: "mt-3",
6661
+ onClick: () => setSpawnProfile(sortedProfiles[0]?.id ?? "default"),
6662
+ children: "Add the first Agent"
6663
+ }) : /* @__PURE__ */ jsx("a", {
6664
+ href: "/templates/agents?new=1",
6665
+ className: "mt-3 text-xs font-semibold",
6666
+ children: "Create an Agent template"
6667
+ })
6668
+ ]
6669
+ }), sortedTeams.map((team) => {
6670
+ const current = inView?.id === team.id;
6671
+ return /* @__PURE__ */ jsx(TeamGroup, {
6672
+ team,
6673
+ members: agents.filter((agent) => agent.teamId === team.id),
6674
+ current,
6675
+ isOpen: isGroupOpen(openGroups, team.id, current),
6676
+ onOpenChange: (next) => {
6677
+ const merged = {
6678
+ ...openGroups,
6679
+ [team.id]: next
6680
+ };
6681
+ writeOpenGroupsCookie(merged);
6682
+ setOpenGroups(merged);
6683
+ },
6684
+ openAgentId: open?.team.id === team.id ? open.agent.id : null,
6685
+ selectedId,
6686
+ activity,
6687
+ panel: search.panel,
6688
+ onRename: (agent) => setRenameTarget(agent),
6689
+ onArchive: (agent) => setArchiveTarget(agent)
6690
+ }, team.id);
6691
+ })]
6692
+ }),
6693
+ spawnProfile && /* @__PURE__ */ jsx(SpawnDialog, {
6694
+ profiles: sortedProfiles,
6695
+ teams: sortedTeams,
6696
+ profileId: spawnProfile,
6697
+ teamId: spawnTeam,
6698
+ onClose: () => {
6699
+ setSpawnProfile(null);
6700
+ refocusNewButton();
6701
+ }
6702
+ }),
6703
+ template && /* @__PURE__ */ jsx(SpawnTeamModal, {
6704
+ template,
6705
+ teams: sortedTeams,
6706
+ onClose: () => {
6707
+ setSpawnTemplate(null);
6708
+ refocusNewButton();
6709
+ },
6710
+ onSpawned: (slug) => {
6711
+ setSpawnTemplate(null);
6712
+ router.navigate({
6713
+ to: "/",
6714
+ search: {
6715
+ team: slug,
6716
+ panel: "team"
6717
+ }
6718
+ });
6719
+ }
6720
+ }),
6721
+ createTeamOpen && /* @__PURE__ */ jsx(Dialog$1, {
6722
+ title: "Create a Team",
6723
+ description: "A Team is one workspace: its folder, its Agents, its USER.md and shared memory, and who may message whom.",
6724
+ busy: createTeamBusy,
6725
+ onClose: () => {
6726
+ setCreateTeamOpen(false);
6727
+ refocusNewButton();
6728
+ },
6729
+ children: /* @__PURE__ */ jsx(TeamForm, {
6730
+ taken: teams.map((team) => team.id),
6731
+ onBusyChange: setCreateTeamBusy,
6732
+ onCreated: async (team) => {
6733
+ setCreateTeamOpen(false);
6734
+ await router.navigate({
6735
+ to: "/",
6736
+ search: {
6737
+ team: team.id,
6738
+ panel: "team"
6739
+ }
6740
+ });
6741
+ },
6742
+ extraActions: (busy) => /* @__PURE__ */ jsx(Button, {
6743
+ variant: "ghost",
6744
+ disabled: busy,
6745
+ onClick: () => setCreateTeamOpen(false),
6746
+ children: "Cancel"
6747
+ })
6748
+ })
6749
+ }),
6750
+ renameTarget && /* @__PURE__ */ jsx(RenameAgentDialog, {
6751
+ agent: renameTarget,
6752
+ onClose: () => setRenameTarget(null),
6753
+ onRenamed: () => router.invalidate()
6754
+ }),
6755
+ /* @__PURE__ */ jsx(ConfirmDialog, {
6756
+ open: archiveTarget !== null,
6757
+ onOpenChange: (next) => {
6758
+ if (!next) setArchiveTarget(null);
6759
+ },
6760
+ title: `Archive ${archiveTarget?.name ?? "agent"}?`,
6761
+ description: /* @__PURE__ */ jsx("p", { children: "The Agent leaves this list and receives no work. Restore it later under Manage → Agents, in Archived." }),
6762
+ confirmLabel: "Archive agent",
6763
+ confirmVariant: "primary",
6764
+ onConfirm: async () => {
6765
+ if (!archiveTarget) return;
6766
+ await archiveAgent(archiveTarget.id);
6767
+ if (archiveTarget.id === selectedId) await router.navigate({
6768
+ to: "/",
6769
+ search: {}
6770
+ });
6771
+ else await router.invalidate();
6772
+ }
6773
+ })
6774
+ ]
6775
+ });
6776
+ }
6777
+ //#endregion
6778
+ //#region src/components/workspace/rail/SlimRail.tsx
6779
+ /** The rail folded to avatars, beside a full-width view. */
6780
+ function SlimRail() {
6781
+ const { agents, teams, agent: open, team: inView, search } = useWorkspace();
6782
+ const activity = useActivity();
6783
+ const sortedTeams = slimTeams(teams, agents, inView?.id);
6784
+ return /* @__PURE__ */ jsxs("nav", {
6785
+ "aria-label": "Agents",
6786
+ 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",
6787
+ children: [/* @__PURE__ */ jsx(Link, {
6788
+ to: "/",
6789
+ search: {
6790
+ ...search,
6791
+ view: void 0,
6792
+ file: void 0,
6793
+ result: void 0
6794
+ },
6795
+ "aria-label": "Back to the conversation and the full list",
6796
+ title: "Back to the conversation",
6797
+ className: "flex size-10 shrink-0 items-center justify-center rounded-xl text-mocha hover:bg-accent hover:text-accent-foreground",
6798
+ children: /* @__PURE__ */ jsx(PanelLeft, {
6799
+ className: "size-[18px]",
6800
+ "aria-hidden": "true"
6801
+ })
6802
+ }), sortedTeams.map((team) => /* @__PURE__ */ jsxs("div", {
6803
+ className: "flex w-full flex-col items-center gap-2",
6804
+ children: [
6805
+ /* @__PURE__ */ jsx("div", { className: "h-px w-8 bg-border" }),
6806
+ /* @__PURE__ */ jsx("span", {
6807
+ className: `max-w-14 truncate text-xs font-bold uppercase tracking-[0.06em] ${team.id === inView?.id ? "text-accent-foreground" : "text-muted-foreground"}`,
6808
+ title: team.name,
6809
+ children: team.name
6810
+ }),
6811
+ agents.filter((agent) => agent.teamId === team.id).map((agent) => {
6812
+ const state = activity.stateOf(agent.id);
6813
+ return /* @__PURE__ */ jsxs(Link, {
6814
+ to: "/",
6815
+ search: {
6816
+ agent: agent.id,
6817
+ ...search.panel ? { panel: search.panel } : {}
6818
+ },
6819
+ "aria-label": `${agent.name}: ${state.text}`,
6820
+ title: `${agent.name}: ${state.text}`,
6821
+ 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" : ""}`,
6822
+ children: [/* @__PURE__ */ jsx(AgentAvatar, {
6823
+ identity: agent.identity,
6824
+ size: 40
6825
+ }), /* @__PURE__ */ jsx("span", {
6826
+ className: `absolute -bottom-px -right-px size-3 rounded-full border-2 border-card ${STATE_DOT[state.kind]}`,
6827
+ "aria-hidden": "true"
6828
+ })]
6829
+ }, agent.id);
6830
+ })
6831
+ ]
6832
+ }, team.id))]
6833
+ });
6834
+ }
6835
+ //#endregion
5867
6836
  //#region src/components/AgentBrowserCard.tsx
5868
6837
  var MODE = {
5869
6838
  headless: "without a window",
@@ -7132,6 +8101,19 @@ function AgentSchedules({ agent }) {
7132
8101
  onChanged: data.reload
7133
8102
  });
7134
8103
  }
8104
+ /** "Next run in 5 min", "Next run Mon 24 Nov, 09:00": when a schedule runs next, in words. */
8105
+ function nextRunWords(at, now) {
8106
+ const wait = at - now;
8107
+ if (wait < 6e4) return "Next run now";
8108
+ if (wait < 36e5) return `Next run in ${Math.round(wait / 6e4)} min`;
8109
+ return `Next run ${new Date(at).toLocaleString(void 0, {
8110
+ weekday: "short",
8111
+ day: "numeric",
8112
+ month: "short",
8113
+ hour: "2-digit",
8114
+ minute: "2-digit"
8115
+ })}`;
8116
+ }
7135
8117
  var RUN = {
7136
8118
  pending: {
7137
8119
  label: "Waiting for the Agent",
@@ -7155,7 +8137,7 @@ var RUN = {
7155
8137
  }
7156
8138
  };
7157
8139
  /** The schedules and their recent runs, as loaded. */
7158
- function SchedulesView({ agentId, agentName = "The Agent", triggers, dispatches, onChanged }) {
8140
+ function SchedulesView({ agentId, agentName = "The Agent", triggers, dispatches, nextRuns, schedulerOff, onChanged }) {
7159
8141
  const [adding, setAdding] = useState(false);
7160
8142
  const [removing, setRemoving] = useState(null);
7161
8143
  const [error, setError] = useState(null);
@@ -7194,64 +8176,78 @@ function SchedulesView({ agentId, agentName = "The Agent", triggers, dispatches,
7194
8176
  "aria-hidden": "true"
7195
8177
  }), "Add a schedule"]
7196
8178
  }),
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"]
8179
+ children: [
8180
+ error && /* @__PURE__ */ jsx("div", {
8181
+ className: "border-t border-border px-4 py-3 sm:px-5",
8182
+ children: /* @__PURE__ */ jsx(Notice, {
8183
+ role: "alert",
8184
+ title: "That did not work.",
8185
+ children: error
8186
+ })
7214
8187
  }),
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
8188
+ schedulerOff && triggers.length > 0 && /* @__PURE__ */ jsx("div", {
8189
+ className: "border-t border-border px-4 py-3 sm:px-5",
8190
+ children: /* @__PURE__ */ jsxs(Notice, {
8191
+ title: "No schedule runs on this daemon",
8192
+ children: [
8193
+ "It was started with ",
8194
+ /* @__PURE__ */ jsx("code", { children: "BAZILION_SCHEDULER=off" }),
8195
+ "."
8196
+ ]
7252
8197
  })
7253
- }, trigger.id);
7254
- }) })]
8198
+ }),
8199
+ triggers.length === 0 ? /* @__PURE__ */ jsxs(CardEmpty, {
8200
+ icon: /* @__PURE__ */ jsx(CalendarClock, { className: "size-5" }),
8201
+ title: "No schedules yet",
8202
+ action: /* @__PURE__ */ jsxs(Button, {
8203
+ variant: "primary",
8204
+ onClick: () => setAdding(true),
8205
+ children: [/* @__PURE__ */ jsx(Plus, {
8206
+ className: "size-4",
8207
+ "aria-hidden": "true"
8208
+ }), "Add a schedule"]
8209
+ }),
8210
+ children: [
8211
+ "A schedule gives ",
8212
+ agentName,
8213
+ " a message at set times: a morning check, a weekly summary."
8214
+ ]
8215
+ }) : /* @__PURE__ */ jsx(CardList, { children: triggers.map((trigger) => {
8216
+ const schedule = describeSchedule(trigger);
8217
+ return /* @__PURE__ */ jsx(ListRow, {
8218
+ inline: true,
8219
+ title: schedule.raw ? /* @__PURE__ */ jsx("code", {
8220
+ className: "font-mono text-[0.92em]",
8221
+ children: schedule.text
8222
+ }) : schedule.text,
8223
+ chip: trigger.enabled ? /* @__PURE__ */ jsx(Chip, {
8224
+ tone: "success",
8225
+ children: "On"
8226
+ }) : /* @__PURE__ */ jsx(Chip, {
8227
+ tone: "neutral",
8228
+ children: "Paused"
8229
+ }),
8230
+ 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" })] }),
8231
+ actions: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Switch, {
8232
+ label: `${schedule.text}: ${trigger.enabled ? "on" : "paused"}`,
8233
+ checked: trigger.enabled,
8234
+ disabled: busyId === trigger.id,
8235
+ onChange: () => void toggle(trigger)
8236
+ }), /* @__PURE__ */ jsx(RowMenu, {
8237
+ label: `More for ${schedule.text}`,
8238
+ items: [{
8239
+ label: "Delete…",
8240
+ danger: true,
8241
+ onSelect: () => setRemoving(trigger)
8242
+ }]
8243
+ })] }),
8244
+ children: /* @__PURE__ */ jsx("p", {
8245
+ className: "m-0 whitespace-pre-wrap break-words rounded-xl bg-muted/50 px-3 py-2 text-sm text-foreground",
8246
+ children: trigger.message
8247
+ })
8248
+ }, trigger.id);
8249
+ }) })
8250
+ ]
7255
8251
  }),
7256
8252
  /* @__PURE__ */ jsx(SetupCard, {
7257
8253
  labelledBy: "agent-schedule-runs",
@@ -7462,6 +8458,16 @@ function AddSchedule({ agentId, agentName, onClose, onAdded }) {
7462
8458
  });
7463
8459
  }
7464
8460
  //#endregion
8461
+ //#region src/lib/memory-key.ts
8462
+ function noteKey(typed) {
8463
+ let key = typed.trim().replace(/^(\.\/)+/, "");
8464
+ if (!key) return { error: "Give the note a name." };
8465
+ if (key.startsWith("/") || key.includes("\\")) return { error: "A name is a path inside the memory folder, such as people/sam.md." };
8466
+ if (key.split("/").some((segment) => segment === "" || segment === "." || segment === "..")) return { error: "A name cannot have empty parts, “.” or “..” in its path." };
8467
+ key = `${key.replace(/\.md$/i, "")}.md`;
8468
+ return { key };
8469
+ }
8470
+ //#endregion
7465
8471
  //#region src/components/team/TeamMemory.tsx
7466
8472
  /** A note's name in the list: its first heading, else the last part of its path. */
7467
8473
  function noteRow(key, text) {
@@ -7535,8 +8541,12 @@ function TeamMemory({ team, openKey }) {
7535
8541
  async function save(event) {
7536
8542
  event.preventDefault();
7537
8543
  if (open.mode !== "edit" && open.mode !== "new") return;
7538
- const key = open.key.trim();
7539
- if (!key) return;
8544
+ const named = open.mode === "new" ? noteKey(open.key) : { key: open.key };
8545
+ if ("error" in named) {
8546
+ setError(named.error);
8547
+ return;
8548
+ }
8549
+ const { key } = named;
7540
8550
  setBusy(true);
7541
8551
  setError(null);
7542
8552
  try {
@@ -7695,7 +8705,7 @@ function TeamMemory({ team, openKey }) {
7695
8705
  mono: true,
7696
8706
  disabled: busy,
7697
8707
  placeholder: "decisions/launch-date.md",
7698
- hint: "A path: folders group notes, such as people/sam.md.",
8708
+ hint: "A path: folders group notes, such as people/sam. It ends in .md, added when left out.",
7699
8709
  onChange: (value) => setOpen({
7700
8710
  ...current,
7701
8711
  key: value
@@ -7742,12 +8752,12 @@ function TeamMemory({ team, openKey }) {
7742
8752
  }),
7743
8753
  /* @__PURE__ */ jsx(ConfirmDialog, {
7744
8754
  open: pending !== null,
7745
- title: "Drop your unsaved edit?",
8755
+ title: "Discard your unsaved edit?",
7746
8756
  description: /* @__PURE__ */ jsx("p", {
7747
8757
  className: "m-0",
7748
8758
  children: "What you changed in this note is lost."
7749
8759
  }),
7750
- confirmLabel: "Drop the edit",
8760
+ confirmLabel: "Discard the edit",
7751
8761
  onConfirm: () => {
7752
8762
  const action = pending;
7753
8763
  setPending(null);
@@ -8380,7 +9390,7 @@ function TeamHome({ team }) {
8380
9390
  children: [/* @__PURE__ */ jsx(Plus, {
8381
9391
  className: "size-4",
8382
9392
  "aria-hidden": "true"
8383
- }), "Add an agent"]
9393
+ }), "Add an Agent"]
8384
9394
  })
8385
9395
  ]
8386
9396
  }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("ul", {
@@ -8430,7 +9440,7 @@ function TeamHome({ team }) {
8430
9440
  children: [/* @__PURE__ */ jsx(Plus, {
8431
9441
  className: "size-4",
8432
9442
  "aria-hidden": "true"
8433
- }), "Add an agent"]
9443
+ }), "Add an Agent"]
8434
9444
  })
8435
9445
  })] }),
8436
9446
  /* @__PURE__ */ jsx("div", {
@@ -8564,7 +9574,7 @@ function WaitingRow({ agent, team, text }) {
8564
9574
  //#endregion
8565
9575
  //#region src/routes/index.tsx?tsr-split=component
8566
9576
  /** The rail's open/closed Teams; a bad cookie is ignored. */
8567
- var ConnectionsView = lazy(() => import("./ConnectionsView-CLIV7V5D.js").then((module) => ({ default: module.ConnectionsView })));
9577
+ var ConnectionsView = lazy(() => import("./ConnectionsView-DslcKQmA.js").then((module) => ({ default: module.ConnectionsView })));
8568
9578
  function WorkspacePage() {
8569
9579
  const data = Route.useLoaderData();
8570
9580
  const search = Route.useSearch();
@@ -8634,6 +9644,43 @@ function WorkspacePage() {
8634
9644
  return () => window.removeEventListener("keydown", onKey);
8635
9645
  });
8636
9646
  const asked = search.panel !== void 0 && search.panel !== "none";
9647
+ const wide = useMediaQuery("(min-width: 1280px)");
9648
+ const shownPanel = panel !== "none" && (asked || wide) ? panel : "none";
9649
+ const overlay = shownPanel !== "none" && !wide;
9650
+ const overlayBox = useRef(null);
9651
+ const overlayOpener = useRef(null);
9652
+ useLayoutEffect(() => {
9653
+ if (!overlay) return;
9654
+ overlayOpener.current = getDialogFocusRestoreTarget(document);
9655
+ overlayBox.current?.querySelector("[role=\"tab\"][aria-selected=\"true\"]")?.focus();
9656
+ return () => {
9657
+ const opener = overlayOpener.current;
9658
+ overlayOpener.current = null;
9659
+ window.requestAnimationFrame(() => restoreDialogFocus(opener, document));
9660
+ };
9661
+ }, [overlay]);
9662
+ useEffect(() => {
9663
+ if (!overlay) return;
9664
+ const onKey = (event) => {
9665
+ if (event.key !== "Escape" || event.defaultPrevented) return;
9666
+ if (document.querySelector("[role=\"dialog\"], [role=\"alertdialog\"], [role=\"menu\"]")) return;
9667
+ event.preventDefault();
9668
+ router.navigate({
9669
+ to: "/",
9670
+ search: {
9671
+ ...search,
9672
+ panel: "none",
9673
+ section: void 0
9674
+ }
9675
+ });
9676
+ };
9677
+ window.addEventListener("keydown", onKey);
9678
+ return () => window.removeEventListener("keydown", onKey);
9679
+ }, [
9680
+ overlay,
9681
+ router,
9682
+ search
9683
+ ]);
8637
9684
  const [reported, setReported] = useState(null);
8638
9685
  const loadedConversation = selected?.head.conversationId ?? null;
8639
9686
  const activeConversation = open && reported?.agentId === open.agent.id && reported.loaded === loadedConversation ? reported.id : loadedConversation;
@@ -8661,7 +9708,7 @@ function WorkspacePage() {
8661
9708
  const header = (chat) => open && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(ConversationHeader, {
8662
9709
  agent: open,
8663
9710
  chat,
8664
- panel,
9711
+ panel: shownPanel,
8665
9712
  lastPanel: memory.tab
8666
9713
  }), open.agent.status === "archived" && /* @__PURE__ */ jsxs("p", {
8667
9714
  className: "m-0 flex flex-wrap items-center gap-2 border-b border-frost bg-warning/[0.07] px-4 py-2 text-sm text-chocolate",
@@ -8711,6 +9758,7 @@ function WorkspacePage() {
8711
9758
  className: `grid h-full min-h-0 grid-cols-1 gap-3 py-3 lg:grid-cols-[18rem_minmax(0,1fr)] ${panel === "none" ? "" : "xl:grid-cols-[18rem_minmax(0,1fr)_minmax(22rem,27rem)]"}`,
8712
9759
  children: [
8713
9760
  /* @__PURE__ */ jsxs("div", {
9761
+ inert: overlay || void 0,
8714
9762
  className: `flex min-h-0 flex-col gap-3 ${open || team ? "hidden lg:flex" : ""}`,
8715
9763
  children: [/* @__PURE__ */ jsx(WaitingStrip, { className: "lg:hidden" }), /* @__PURE__ */ jsx("div", {
8716
9764
  className: "min-h-0 flex-1",
@@ -8718,6 +9766,7 @@ function WorkspacePage() {
8718
9766
  })]
8719
9767
  }),
8720
9768
  /* @__PURE__ */ jsx("div", {
9769
+ inert: overlay || void 0,
8721
9770
  className: `min-h-0 min-w-0 ${open || team ? "" : "hidden lg:block"}`,
8722
9771
  children: open && selected ? reading ? /* @__PURE__ */ jsx(EarlierConversation, {
8723
9772
  agentId: open.agent.id,
@@ -8754,6 +9803,7 @@ function WorkspacePage() {
8754
9803
  "aria-label": "Close the side panel",
8755
9804
  className: "fixed inset-0 z-30 bg-chocolate/30 xl:hidden"
8756
9805
  }), /* @__PURE__ */ jsx("div", {
9806
+ ref: overlayBox,
8757
9807
  className: asked ? "fixed inset-y-0 right-0 z-40 w-[min(27rem,100vw)] p-2 xl:static xl:z-auto xl:min-h-0 xl:w-auto xl:min-w-0 xl:p-0" : "hidden min-h-0 min-w-0 xl:block",
8758
9808
  children: /* @__PURE__ */ jsx(SidePanel, { tab: panel })
8759
9809
  })] })