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,1851 +0,0 @@
1
- import { r as readCookie, t as CSRF_COOKIES } from "./cookies-HnTYjKRp.js";
2
- import { n as ModelMenu, p as cn, t as MODELS_PATH } from "./ModelMenu-D-hTgYOO.js";
3
- import { createContext, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
4
- import { useNavigate } from "@tanstack/react-router";
5
- import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
6
- import { AlertTriangle, Check, ChevronDown, Info, MoreHorizontal, Search, X } from "lucide-react";
7
- import { Dialog, DropdownMenu, Select } from "radix-ui";
8
- //#region src/lib/api.ts
9
- var ApiError = class extends Error {
10
- status;
11
- /** The daemon's machine-readable `code`, when it sent one. */
12
- code;
13
- /** The parsed JSON error body, when there was one. */
14
- body;
15
- constructor(message, status, code, body) {
16
- super(message);
17
- this.status = status;
18
- this.code = code;
19
- this.body = body;
20
- }
21
- };
22
- function csrfHeader() {
23
- for (const name of CSRF_COOKIES) {
24
- const value = readCookie(document.cookie, name);
25
- if (value) return { "x-bazilion-csrf": value };
26
- }
27
- return {};
28
- }
29
- async function failure(response) {
30
- const text = await response.text().catch(() => "");
31
- let body = {};
32
- try {
33
- const parsed = JSON.parse(text);
34
- if (parsed && typeof parsed === "object") body = parsed;
35
- } catch {}
36
- const message = typeof body.error === "string" ? body.error : text.slice(0, 300) || `HTTP ${response.status}`;
37
- const code = typeof body.code === "string" ? body.code : void 0;
38
- return new ApiError(message, response.status, code, body);
39
- }
40
- /** The raw response (streams, downloads, text); throws ApiError unless it is ok. */
41
- async function apiFetch(path, init = {}) {
42
- const method = init.method ?? (init.body === void 0 ? "GET" : "POST");
43
- const headers = method === "GET" ? {} : csrfHeader();
44
- let body;
45
- if (init.body instanceof FormData) body = init.body;
46
- else if (init.body !== void 0) {
47
- headers["content-type"] = "application/json";
48
- body = JSON.stringify(init.body);
49
- }
50
- const response = await fetch(path, {
51
- method,
52
- headers,
53
- body,
54
- signal: init.signal
55
- });
56
- if (!response.ok) throw await failure(response);
57
- return response;
58
- }
59
- /** The daemon's JSON answer (undefined for an empty body); throws ApiError with its message. */
60
- async function api(path, init = {}) {
61
- const text = await (await apiFetch(path, init)).text();
62
- return text ? JSON.parse(text) : void 0;
63
- }
64
- function errorMessage(error) {
65
- return error instanceof Error ? error.message : String(error);
66
- }
67
- //#endregion
68
- //#region src/lib/live.tsx
69
- var CHANNEL = "bazilion-live";
70
- var LOCK = "bazilion-live";
71
- var EVENT_TYPES = ["activity", "attention"];
72
- /** After a failed stream: wait, then try again, longer each time up to the last. */
73
- var RETRY_MS = [
74
- 1e3,
75
- 3e3,
76
- 1e4,
77
- 3e4
78
- ];
79
- var LiveContext = createContext({
80
- connected: false,
81
- subscribe: () => () => {},
82
- isLeader: () => false,
83
- anyTabFocused: () => true
84
- });
85
- function useLive() {
86
- return useContext(LiveContext);
87
- }
88
- /** Parse one SSE message's data; null for anything that is not a live event. */
89
- function parseLiveEvent(data) {
90
- try {
91
- const event = JSON.parse(data);
92
- return event && EVENT_TYPES.includes(event.type) ? event : null;
93
- } catch {
94
- return null;
95
- }
96
- }
97
- function LiveProvider({ enabled, children }) {
98
- const [connected, setConnected] = useState(false);
99
- const handlers = useRef(/* @__PURE__ */ new Map());
100
- const latest = useRef(/* @__PURE__ */ new Map());
101
- const leading = useRef(false);
102
- const focusedTabs = useRef(/* @__PURE__ */ new Set());
103
- const deliver = useCallback((event) => {
104
- latest.current.set(event.type, event);
105
- for (const handler of handlers.current.get(event.type) ?? []) try {
106
- handler(event);
107
- } catch (error) {
108
- console.warn("live feed reader failed:", error);
109
- }
110
- }, []);
111
- useEffect(() => {
112
- if (!enabled) return;
113
- let stopped = false;
114
- let source = null;
115
- let retry;
116
- let failures = 0;
117
- const tab = Math.random().toString(36).slice(2);
118
- const channel = typeof BroadcastChannel === "undefined" ? null : new BroadcastChannel(CHANNEL);
119
- const shared = Boolean(channel && typeof navigator !== "undefined" && navigator.locks);
120
- const post = (message) => channel?.postMessage(message);
121
- const share = (message) => {
122
- if (shared) post(message);
123
- };
124
- let releaseLock = () => {};
125
- const status = (value) => {
126
- setConnected(value);
127
- share({
128
- kind: "status",
129
- connected: value
130
- });
131
- };
132
- const open = () => {
133
- if (stopped || !shared && document.visibilityState === "hidden") return;
134
- source = new EventSource("/api/events");
135
- for (const type of EVENT_TYPES) source.addEventListener(type, (message) => {
136
- const event = parseLiveEvent(message.data);
137
- if (!event) return;
138
- failures = 0;
139
- deliver(event);
140
- share({
141
- kind: "event",
142
- event
143
- });
144
- });
145
- source.onopen = () => status(true);
146
- source.onerror = () => {
147
- status(false);
148
- if (source?.readyState === EventSource.CLOSED) {
149
- source = null;
150
- const wait = RETRY_MS[Math.min(failures, RETRY_MS.length - 1)] ?? 3e4;
151
- failures++;
152
- retry = window.setTimeout(open, wait);
153
- }
154
- };
155
- };
156
- const lead = () => {
157
- leading.current = true;
158
- open();
159
- };
160
- const reportFocus = () => {
161
- const focused = document.visibilityState === "visible" && document.hasFocus();
162
- if (focused) focusedTabs.current.add(tab);
163
- else focusedTabs.current.delete(tab);
164
- post({
165
- kind: "focus",
166
- tab,
167
- focused
168
- });
169
- };
170
- if (channel) channel.onmessage = ({ data }) => {
171
- if (data.kind === "event") {
172
- if (shared) deliver(data.event);
173
- } else if (data.kind === "status") {
174
- if (shared) setConnected(data.connected);
175
- } else if (data.kind === "focus") if (data.focused) focusedTabs.current.add(data.tab);
176
- else focusedTabs.current.delete(data.tab);
177
- else if (data.kind === "hello") {
178
- if (leading.current) {
179
- for (const event of latest.current.values()) post({
180
- kind: "event",
181
- event
182
- });
183
- post({
184
- kind: "status",
185
- connected: source?.readyState === EventSource.OPEN
186
- });
187
- }
188
- reportFocus();
189
- }
190
- };
191
- const close = () => {
192
- window.clearTimeout(retry);
193
- source?.close();
194
- source = null;
195
- setConnected(false);
196
- };
197
- const onVisibility = () => {
198
- if (document.visibilityState === "hidden") close();
199
- else if (!source) open();
200
- };
201
- if (shared) {
202
- navigator.locks.request(LOCK, () => {
203
- if (stopped) return;
204
- lead();
205
- return new Promise((resolve) => {
206
- releaseLock = resolve;
207
- });
208
- }).catch(() => {});
209
- post({ kind: "hello" });
210
- } else {
211
- leading.current = true;
212
- if (document.visibilityState !== "hidden") open();
213
- document.addEventListener("visibilitychange", onVisibility);
214
- }
215
- reportFocus();
216
- window.addEventListener("focus", reportFocus);
217
- window.addEventListener("blur", reportFocus);
218
- document.addEventListener("visibilitychange", reportFocus);
219
- const leave = () => post({
220
- kind: "focus",
221
- tab,
222
- focused: false
223
- });
224
- window.addEventListener("pagehide", leave);
225
- return () => {
226
- stopped = true;
227
- leave();
228
- document.removeEventListener("visibilitychange", onVisibility);
229
- window.clearTimeout(retry);
230
- source?.close();
231
- leading.current = false;
232
- releaseLock();
233
- window.removeEventListener("focus", reportFocus);
234
- window.removeEventListener("blur", reportFocus);
235
- document.removeEventListener("visibilitychange", reportFocus);
236
- window.removeEventListener("pagehide", leave);
237
- channel?.close();
238
- setConnected(false);
239
- };
240
- }, [enabled, deliver]);
241
- const subscribe = useCallback((type, handler) => {
242
- const generic = handler;
243
- let set = handlers.current.get(type);
244
- if (!set) {
245
- set = /* @__PURE__ */ new Set();
246
- handlers.current.set(type, set);
247
- }
248
- set.add(generic);
249
- const last = latest.current.get(type);
250
- if (last) generic(last);
251
- return () => {
252
- set.delete(generic);
253
- };
254
- }, []);
255
- const value = useMemo(() => ({
256
- connected,
257
- subscribe,
258
- isLeader: () => leading.current,
259
- anyTabFocused: () => focusedTabs.current.size > 0
260
- }), [connected, subscribe]);
261
- return /* @__PURE__ */ jsx(LiveContext.Provider, {
262
- value,
263
- children
264
- });
265
- }
266
- //#endregion
267
- //#region src/lib/tool-steps.ts
268
- var TARGET_CHARS = 96;
269
- function clip(value, limit = TARGET_CHARS) {
270
- const line = value.trim().split("\n")[0] ?? "";
271
- return line.length > limit ? `${line.slice(0, limit - 1)}…` : line;
272
- }
273
- /** The last segment of a path: what a person would call the file. */
274
- function baseName(path) {
275
- const parts = path.replace(/[\\/]+$/, "").split(/[\\/]/);
276
- return parts[parts.length - 1] || path;
277
- }
278
- function hostOf(url) {
279
- try {
280
- return new URL(url).host || clip(url, 40);
281
- } catch {
282
- return clip(url, 40);
283
- }
284
- }
285
- /** A tool call's arguments as an object; null when they are not one. */
286
- function parseArgs(raw) {
287
- try {
288
- const parsed = JSON.parse(raw);
289
- return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
290
- } catch {
291
- return null;
292
- }
293
- }
294
- var str = (value) => typeof value === "string" && value.trim() ? value : null;
295
- /** Describe one tool call. `args` may be partial: a running turn only reports its main target. */
296
- function describeStep(tool, args) {
297
- const path = str(args?.path);
298
- const file = path ? baseName(path) : "a file";
299
- switch (tool) {
300
- case "bash": return {
301
- doing: "running a command",
302
- verb: "Ran",
303
- target: str(args?.command) ? clip(String(args?.command)) : null,
304
- icon: "terminal",
305
- kind: "command"
306
- };
307
- case "read": return {
308
- doing: `reading ${file}`,
309
- verb: "Read",
310
- target: path,
311
- icon: "read",
312
- kind: "read"
313
- };
314
- case "write": return {
315
- doing: `writing ${file}`,
316
- verb: "Wrote",
317
- target: path,
318
- icon: "write",
319
- kind: "write"
320
- };
321
- case "edit": return {
322
- doing: `editing ${file}`,
323
- verb: "Edited",
324
- target: path,
325
- icon: "write",
326
- kind: "write"
327
- };
328
- case "grep":
329
- case "find": return {
330
- doing: "searching the files",
331
- verb: "Searched for",
332
- target: str(args?.pattern) ? clip(String(args?.pattern)) : null,
333
- icon: "search",
334
- kind: "read"
335
- };
336
- case "ls": return {
337
- doing: "listing files",
338
- verb: "Listed",
339
- target: path ?? ".",
340
- icon: "search",
341
- kind: "read"
342
- };
343
- case "web_search": return {
344
- doing: "searching the web",
345
- verb: "Searched the web for",
346
- target: str(args?.query) ? clip(String(args?.query)) : null,
347
- icon: "web",
348
- kind: "web"
349
- };
350
- case "web_fetch":
351
- case "browser_navigate": {
352
- const url = str(args?.url);
353
- return {
354
- doing: url ? `reading ${hostOf(url)}` : "reading a web page",
355
- verb: "Opened",
356
- target: url ? clip(url) : null,
357
- icon: "web",
358
- kind: "web"
359
- };
360
- }
361
- case "browser_take_screenshot": return {
362
- doing: "taking a screenshot",
363
- verb: "Took a screenshot",
364
- target: null,
365
- icon: "image",
366
- kind: "web"
367
- };
368
- case "send_message": return {
369
- doing: "messaging a teammate",
370
- verb: "Messaged",
371
- target: str(args?.to),
372
- icon: "message",
373
- kind: "message"
374
- };
375
- case "read_inbox": return {
376
- doing: "reading its inbox",
377
- verb: "Read its inbox",
378
- target: null,
379
- icon: "message",
380
- kind: "other"
381
- };
382
- case "wait_for_reply": return {
383
- doing: "waiting for a reply",
384
- verb: "Waited for a reply",
385
- target: null,
386
- icon: "message",
387
- kind: "other"
388
- };
389
- case "deliver_file": return {
390
- doing: `delivering ${file}`,
391
- verb: "Delivered",
392
- target: path,
393
- icon: "file",
394
- kind: "deliver"
395
- };
396
- case "image_generate": return {
397
- doing: "drawing an image",
398
- verb: "Generated an image",
399
- target: null,
400
- icon: "image",
401
- kind: "deliver"
402
- };
403
- case "memory_write": return {
404
- doing: "saving a note",
405
- verb: "Saved the note",
406
- target: str(args?.key),
407
- icon: "note",
408
- kind: "other"
409
- };
410
- case "memory_read": return {
411
- doing: "reading a note",
412
- verb: "Read the note",
413
- target: str(args?.key),
414
- icon: "note",
415
- kind: "other"
416
- };
417
- case "memory_search": return {
418
- doing: "searching the notes",
419
- verb: "Searched the notes for",
420
- target: str(args?.query) ? clip(String(args?.query)) : null,
421
- icon: "note",
422
- kind: "other"
423
- };
424
- case "memory_list": return {
425
- doing: "listing the notes",
426
- verb: "Listed the notes",
427
- target: null,
428
- icon: "note",
429
- kind: "other"
430
- };
431
- case "user_md_get": return {
432
- doing: "reading USER.md",
433
- verb: "Read USER.md",
434
- target: null,
435
- icon: "read",
436
- kind: "other"
437
- };
438
- case "user_md_write": return {
439
- doing: "updating USER.md",
440
- verb: "Updated USER.md",
441
- target: null,
442
- icon: "write",
443
- kind: "other"
444
- };
445
- case "ask_user": return {
446
- doing: "asking you a question",
447
- verb: "Asked you a question",
448
- target: null,
449
- icon: "question",
450
- kind: "other"
451
- };
452
- case "propose_lesson": return {
453
- doing: "proposing a lesson",
454
- verb: "Proposed a lesson",
455
- target: null,
456
- icon: "note",
457
- kind: "other"
458
- };
459
- default: break;
460
- }
461
- if (tool.startsWith("home_")) {
462
- const own = str(args?.file);
463
- return tool === "home_write" ? {
464
- doing: "updating its own files",
465
- verb: "Updated its file",
466
- target: own,
467
- icon: "write",
468
- kind: "other"
469
- } : {
470
- doing: "reading its own files",
471
- verb: "Read its file",
472
- target: own,
473
- icon: "read",
474
- kind: "other"
475
- };
476
- }
477
- if (tool.startsWith("browser_")) return {
478
- doing: "using the browser",
479
- verb: "In the browser:",
480
- target: tool.slice(8).replaceAll("_", " "),
481
- icon: "web",
482
- kind: "web"
483
- };
484
- return {
485
- doing: `using ${tool}`,
486
- verb: "Used",
487
- target: tool,
488
- icon: "tool",
489
- kind: "other"
490
- };
491
- }
492
- var KIND_LABEL = {
493
- command: ["command", "commands"],
494
- read: ["lookup", "lookups"],
495
- write: ["file written", "files written"],
496
- web: ["web step", "web steps"],
497
- message: ["message", "messages"],
498
- deliver: ["file delivered", "files delivered"],
499
- other: ["more", "more"]
500
- };
501
- /** "2 commands, 1 lookup, 3 files written" for a group of steps. */
502
- function summarizeSteps(kinds) {
503
- return [
504
- "command",
505
- "read",
506
- "write",
507
- "web",
508
- "message",
509
- "deliver",
510
- "other"
511
- ].map((kind) => {
512
- const count = kinds.filter((entry) => entry === kind).length;
513
- if (count === 0) return null;
514
- const [one, many] = KIND_LABEL[kind];
515
- return `${count} ${count === 1 ? one : many}`;
516
- }).filter(Boolean).join(", ");
517
- }
518
- /** Lines a write or an edit added and removed, from its arguments; null for other tools. */
519
- function lineChange(tool, args) {
520
- const lines = (value) => typeof value === "string" && value.length > 0 ? value.replace(/\n$/, "").split("\n").length : 0;
521
- if (tool === "write") return {
522
- added: lines(args?.content),
523
- removed: 0
524
- };
525
- if (tool !== "edit" || !Array.isArray(args?.edits)) return null;
526
- let added = 0;
527
- let removed = 0;
528
- for (const edit of args.edits) {
529
- added += lines(edit?.newText);
530
- removed += lines(edit?.oldText);
531
- }
532
- return {
533
- added,
534
- removed
535
- };
536
- }
537
- //#endregion
538
- //#region src/lib/activity.tsx
539
- var POLL_MS = 3e3;
540
- var SEEN_KEY = "bz_seen";
541
- var plural = (count, one, many = `${one}s`) => `${count} ${count === 1 ? one : many}`;
542
- /**
543
- * One line for an Agent. What needs the operator comes first, then work in progress, then what
544
- * is new since they last looked.
545
- */
546
- function agentState(activity, seen, nameOf = () => void 0) {
547
- if (!activity) return {
548
- kind: "idle",
549
- text: "Idle"
550
- };
551
- if (activity.questions > 0) return {
552
- kind: "needs",
553
- text: `Waiting for you: ${activity.questions === 1 ? "a question" : plural(activity.questions, "question")}`
554
- };
555
- if (activity.approvals > 0) return {
556
- kind: "needs",
557
- text: `Waiting for you: ${activity.approvals === 1 ? "a command" : plural(activity.approvals, "command")} to approve`
558
- };
559
- if (activity.working) {
560
- const step = activity.step;
561
- if (!step) return {
562
- kind: "working",
563
- text: "Working"
564
- };
565
- if (step.tool === "send_message") return {
566
- kind: "working",
567
- text: `Working: messaging ${(step.target ? nameOf(step.target) : void 0) ?? "a teammate"}`
568
- };
569
- const target = step.target;
570
- const args = target ? {
571
- path: target,
572
- command: target,
573
- url: target,
574
- query: target,
575
- key: target,
576
- file: target
577
- } : null;
578
- return {
579
- kind: "working",
580
- text: `Working: ${describeStep(step.tool, args).doing}`
581
- };
582
- }
583
- if (activity.queuePaused) return {
584
- kind: "paused",
585
- text: "Follow-ups paused"
586
- };
587
- if (seen) {
588
- const files = activity.results - seen.results;
589
- if (files > 0) return {
590
- kind: "fresh",
591
- text: plural(files, "new file")
592
- };
593
- if (activity.lastActivityAt !== null && activity.lastActivityAt > seen.at) return {
594
- kind: "fresh",
595
- text: "New activity"
596
- };
597
- }
598
- return {
599
- kind: "idle",
600
- text: activity.lastActivityAt === null ? "No conversation yet" : "Idle"
601
- };
602
- }
603
- /** "1 waiting · 2 working" for a Team's header; empty when everyone is idle. */
604
- function teamSummary(states) {
605
- const count = (kind) => states.filter((state) => state.kind === kind).length;
606
- return [
607
- count("needs") ? `${count("needs")} waiting` : null,
608
- count("working") ? `${count("working")} working` : null,
609
- count("fresh") ? `${count("fresh")} new` : null
610
- ].filter(Boolean).join(" · ");
611
- }
612
- /**
613
- * Whether a turn ended between two readings of the feed: an Agent stopped working, or an idle
614
- * Agent's conversation or saved files moved on (a turn shorter than the time between readings).
615
- */
616
- function turnEnded(before, after) {
617
- const known = new Map(before.map((activity) => [activity.agentId, activity]));
618
- return after.some((now) => {
619
- const was = known.get(now.agentId);
620
- if (!was || now.working) return false;
621
- return was.working || was.lastActivityAt !== now.lastActivityAt || was.results !== now.results;
622
- });
623
- }
624
- var ActivityContext = createContext(null);
625
- function readSeen() {
626
- try {
627
- const parsed = JSON.parse(window.localStorage.getItem(SEEN_KEY) ?? "{}");
628
- return parsed && typeof parsed === "object" ? parsed : {};
629
- } catch {
630
- return {};
631
- }
632
- }
633
- function ActivityProvider({ initial, openAgentId, names, children }) {
634
- const [agents, setAgents] = useState(initial);
635
- const [seen, setSeen] = useState(null);
636
- const [turnsEnded, setTurnsEnded] = useState(0);
637
- const lastRef = useRef(initial);
638
- const live = useLive();
639
- const apply = useCallback((next) => {
640
- const ended = turnEnded(lastRef.current, next);
641
- lastRef.current = next;
642
- setAgents(next);
643
- if (ended) setTurnsEnded((count) => count + 1);
644
- }, []);
645
- const refresh = useCallback(() => {
646
- api("/api/activity").then((body) => apply(body.agents)).catch(() => {});
647
- }, [apply]);
648
- useEffect(() => live.subscribe("activity", (event) => apply(event.agents)), [live.subscribe, apply]);
649
- useEffect(() => {
650
- if (live.connected) return;
651
- const timer = setInterval(() => {
652
- if (!document.hidden) refresh();
653
- }, POLL_MS);
654
- const onVisible = () => {
655
- if (!document.hidden) refresh();
656
- };
657
- document.addEventListener("visibilitychange", onVisible);
658
- return () => {
659
- clearInterval(timer);
660
- document.removeEventListener("visibilitychange", onVisible);
661
- };
662
- }, [refresh, live.connected]);
663
- useEffect(() => setSeen(readSeen()), []);
664
- useEffect(() => {
665
- if (!seen) return;
666
- let next = null;
667
- for (const activity of agents) {
668
- const current = seen[activity.agentId];
669
- const now = {
670
- at: activity.lastActivityAt ?? 0,
671
- results: activity.results
672
- };
673
- const open = activity.agentId === openAgentId && !document.hidden;
674
- if (!current || open && (current.at !== now.at || current.results !== now.results)) next = {
675
- ...next ?? seen,
676
- [activity.agentId]: now
677
- };
678
- }
679
- if (!next) return;
680
- setSeen(next);
681
- try {
682
- window.localStorage.setItem(SEEN_KEY, JSON.stringify(next));
683
- } catch {}
684
- }, [
685
- agents,
686
- seen,
687
- openAgentId
688
- ]);
689
- const value = useMemo(() => {
690
- const byAgent = new Map(agents.map((activity) => [activity.agentId, activity]));
691
- return {
692
- byAgent,
693
- stateOf: (agentId) => agentState(byAgent.get(agentId), agentId === openAgentId ? void 0 : seen?.[agentId], (id) => names.get(id)),
694
- turnsEnded,
695
- refresh
696
- };
697
- }, [
698
- agents,
699
- seen,
700
- openAgentId,
701
- names,
702
- turnsEnded,
703
- refresh
704
- ]);
705
- return /* @__PURE__ */ jsx(ActivityContext.Provider, {
706
- value,
707
- children
708
- });
709
- }
710
- function useActivity() {
711
- const value = useContext(ActivityContext);
712
- if (!value) throw new Error("useActivity needs an ActivityProvider");
713
- return value;
714
- }
715
- /** The feed when there is one: a conversation can also render on its own. */
716
- function useActivityOptional() {
717
- return useContext(ActivityContext);
718
- }
719
- /** A short clock or date for "last active": 12:04 today, Tue this week, 12 Nov otherwise. */
720
- function shortTime(at, now = Date.now()) {
721
- const date = new Date(at);
722
- const today = new Date(now);
723
- if (date.toDateString() === today.toDateString()) return date.toLocaleTimeString([], {
724
- hour: "2-digit",
725
- minute: "2-digit"
726
- });
727
- if (now - at < 144 * 36e5) return date.toLocaleDateString([], { weekday: "short" });
728
- return date.toLocaleDateString([], {
729
- day: "numeric",
730
- month: "short"
731
- });
732
- }
733
- //#endregion
734
- //#region ../../packages/api-types/src/entities.ts
735
- /** The Team and the Profile first-run setup creates. */
736
- var DEFAULT_TEAM_ID = "default";
737
- var DEFAULT_PROFILE_ID = "default";
738
- /** Edge endpoint standing for every Agent in other Teams. */
739
- var OUTSIDE_TEAM = "outside";
740
- var REASONING_LEVELS = [
741
- "off",
742
- "minimal",
743
- "low",
744
- "medium",
745
- "high",
746
- "xhigh"
747
- ];
748
- //#endregion
749
- //#region src/components/AgentAvatar.tsx
750
- /** Whether an avatar string is something the browser can render directly. */
751
- function isRenderableAvatar(avatar) {
752
- if (!avatar) return false;
753
- return /^https?:\/\//i.test(avatar) || /^data:image\//i.test(avatar);
754
- }
755
- function AgentAvatar({ identity, size = 28, className }) {
756
- const avatar = identity?.avatar;
757
- const emoji = identity?.emoji;
758
- const dim = {
759
- width: size,
760
- height: size
761
- };
762
- const base = "inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full";
763
- const cls = className ? `${base} ${className}` : base;
764
- if (isRenderableAvatar(avatar)) return /* @__PURE__ */ jsx("img", {
765
- src: avatar,
766
- alt: "",
767
- style: dim,
768
- className: `${cls} object-cover`,
769
- onError: (e) => {
770
- e.currentTarget.style.display = "none";
771
- }
772
- });
773
- return /* @__PURE__ */ jsx("span", {
774
- style: {
775
- ...dim,
776
- fontSize: Math.round(size * .6)
777
- },
778
- className: `${cls} bg-frost leading-none`,
779
- "aria-hidden": true,
780
- children: emoji ?? "🤖"
781
- });
782
- }
783
- //#endregion
784
- //#region src/components/Button.tsx
785
- var VARIANT_CLASS = {
786
- primary: "btn-primary",
787
- ghost: "ghost-btn",
788
- danger: "danger-btn"
789
- };
790
- function Button({ variant, type, className, ...rest }) {
791
- const cls = className ? `${VARIANT_CLASS[variant]} ${className}` : VARIANT_CLASS[variant];
792
- return /* @__PURE__ */ jsx("button", {
793
- type: type ?? "button",
794
- className: cls,
795
- ...rest
796
- });
797
- }
798
- //#endregion
799
- //#region src/components/Dialog.tsx
800
- var useBrowserLayoutEffect = typeof document === "undefined" ? useEffect : useLayoutEffect;
801
- /** The element to refocus when a dialog closes: whatever had focus when it opened. */
802
- function getDialogFocusRestoreTarget(doc) {
803
- const target = doc.activeElement;
804
- if (!target || target === doc.body || target === doc.documentElement || !("focus" in target) || typeof target.focus !== "function") return null;
805
- return target;
806
- }
807
- function restoreDialogFocus(target, doc) {
808
- if (!target?.isConnected || target.ownerDocument !== doc) return;
809
- target.focus({ preventScroll: true });
810
- }
811
- /**
812
- * The app's one modal. While `busy`, it cannot be dismissed. Radix refocuses a DialogTrigger on
813
- * close; these dialogs open from state, so the element focused at opening is restored instead.
814
- */
815
- function Dialog$1({ open = true, onClose, busy = false, title, description, className, children }) {
816
- const opener = useRef(null);
817
- const wasOpen = useRef(false);
818
- useBrowserLayoutEffect(() => {
819
- if (open && !wasOpen.current) opener.current = getDialogFocusRestoreTarget(document);
820
- wasOpen.current = open;
821
- }, [open]);
822
- return /* @__PURE__ */ jsx(Dialog.Root, {
823
- open,
824
- onOpenChange: (next) => {
825
- if (!next && !busy) onClose();
826
- },
827
- children: /* @__PURE__ */ jsxs(Dialog.Portal, { children: [/* @__PURE__ */ jsx(Dialog.Overlay, { className: "fixed inset-0 z-50 bg-chocolate/35 backdrop-blur-[2px] data-[state=open]:animate-in data-[state=open]:fade-in-0" }), /* @__PURE__ */ jsxs(Dialog.Content, {
828
- className: cn("fixed left-1/2 top-1/2 z-50 grid max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 overflow-y-auto rounded-[16px] border border-frost bg-snow p-5 text-chocolate shadow-baziu-lg outline-none data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:p-6", className),
829
- onCloseAutoFocus: (event) => {
830
- event.preventDefault();
831
- restoreDialogFocus(opener.current, document);
832
- opener.current = null;
833
- },
834
- onEscapeKeyDown: (event) => {
835
- if (busy) event.preventDefault();
836
- },
837
- onPointerDownOutside: (event) => {
838
- if (busy) event.preventDefault();
839
- },
840
- children: [
841
- /* @__PURE__ */ jsxs("div", {
842
- className: "flex flex-col gap-2 pr-6",
843
- children: [/* @__PURE__ */ jsx(Dialog.Title, {
844
- className: "font-serif text-xl text-chocolate",
845
- children: title
846
- }), description ? /* @__PURE__ */ jsx(Dialog.Description, {
847
- asChild: true,
848
- children: /* @__PURE__ */ jsx("div", {
849
- className: "text-sm leading-6 text-mocha",
850
- children: description
851
- })
852
- }) : /* @__PURE__ */ jsx(Dialog.Description, {
853
- className: "sr-only",
854
- children: title
855
- })]
856
- }),
857
- children,
858
- !busy && /* @__PURE__ */ jsx(Dialog.Close, {
859
- "aria-label": "Close",
860
- className: "absolute right-3 top-3 inline-flex size-8 items-center justify-center rounded-lg text-mocha hover:bg-ivory hover:text-sapphire",
861
- children: /* @__PURE__ */ jsx(X, {
862
- className: "size-4",
863
- "aria-hidden": "true"
864
- })
865
- })
866
- ]
867
- })] })
868
- });
869
- }
870
- /** The button row at the bottom of a dialog. */
871
- function DialogActions({ children }) {
872
- return /* @__PURE__ */ jsx("div", {
873
- className: "flex flex-col-reverse gap-2 border-t border-frost pt-4 sm:flex-row sm:justify-end",
874
- children
875
- });
876
- }
877
- //#endregion
878
- //#region src/lib/workspace.ts
879
- var isOneOf = (values, value) => typeof value === "string" && values.includes(value);
880
- var PANEL_TABS = [
881
- "agent",
882
- "team",
883
- "connections",
884
- "changes",
885
- "files"
886
- ];
887
- /** The three screens that take the whole width, with the Agent list folded to avatars. */
888
- var FOCUS_VIEWS = [
889
- "connections",
890
- "changes",
891
- "files"
892
- ];
893
- var PANEL_LABELS = {
894
- agent: "Agent",
895
- team: "Team",
896
- connections: "Connections",
897
- changes: "Changes",
898
- files: "Files"
899
- };
900
- /** Sheets of the Agent tab. */
901
- var AGENT_SECTIONS = [
902
- "schedules",
903
- "learning",
904
- "mailbox",
905
- "skills",
906
- "telegram",
907
- "browser"
908
- ];
909
- /** Sheets of the Team tab. */
910
- var TEAM_SECTIONS = [
911
- "user-md",
912
- "memory",
913
- "settings"
914
- ];
915
- var SECTIONS = [...AGENT_SECTIONS, ...TEAM_SECTIONS];
916
- var isAgentSection = (value) => isOneOf(AGENT_SECTIONS, value);
917
- var isTeamSection = (value) => isOneOf(TEAM_SECTIONS, value);
918
- var text = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
919
- /** The search params the workspace understands; anything else is dropped. */
920
- function parseWorkspaceSearch(search) {
921
- const panel = search.panel;
922
- return {
923
- agent: text(search.agent),
924
- team: text(search.team),
925
- panel: panel === "none" || isOneOf(PANEL_TABS, panel) ? panel : void 0,
926
- view: isOneOf(FOCUS_VIEWS, search.view) ? search.view : void 0,
927
- file: text(search.file),
928
- result: text(search.result),
929
- conversation: text(search.conversation),
930
- section: isOneOf(SECTIONS, search.section) ? search.section : void 0,
931
- note: text(search.note)
932
- };
933
- }
934
- /**
935
- * Cookie that remembers the side panel between visits, so the first paint has it: the last tab,
936
- * prefixed with `none:` while the panel is hidden.
937
- */
938
- var PANEL_COOKIE = "bz_panel";
939
- function parsePanelCookie(raw) {
940
- const hidden = raw?.startsWith("none:") ?? false;
941
- const tab = hidden ? raw?.slice(5) : raw;
942
- return {
943
- open: !hidden,
944
- tab: isOneOf(PANEL_TABS, tab) ? tab : "team"
945
- };
946
- }
947
- function writePanelCookie(memory) {
948
- const value = memory.open ? memory.tab : `none:${memory.tab}`;
949
- document.cookie = `${PANEL_COOKIE}=${value}; Path=/; Max-Age=31536000; SameSite=Lax`;
950
- }
951
- //#endregion
952
- //#region src/components/ui/parts.tsx
953
- var CHIP = {
954
- success: "bg-success/10 text-success",
955
- warning: "bg-warning/10 text-warning",
956
- neutral: "bg-muted text-muted-foreground"
957
- };
958
- function Chip({ tone, children }) {
959
- return /* @__PURE__ */ jsxs("span", {
960
- className: cn("inline-flex min-h-7 items-center gap-1.5 rounded-full px-3 text-xs font-semibold", CHIP[tone]),
961
- children: [/* @__PURE__ */ jsx("span", {
962
- "aria-hidden": "true",
963
- className: "size-1.5 shrink-0 rounded-full bg-current"
964
- }), children]
965
- });
966
- }
967
- /** A search box: the magnifier and the input are one field, with one focus ring. */
968
- function SearchField({ label, placeholder, value, onChange, className }) {
969
- return /* @__PURE__ */ jsxs("label", {
970
- className: cn("m-0 flex min-w-0 items-center gap-2 rounded-xl border border-border bg-muted/40 px-3 transition-shadow focus-within:border-primary focus-within:bg-card focus-within:shadow-[0_0_0_3px_var(--color-sapphire-glow)]", className),
971
- children: [/* @__PURE__ */ jsx(Search, {
972
- className: "size-4 shrink-0 text-muted-foreground",
973
- "aria-hidden": "true"
974
- }), /* @__PURE__ */ jsx("input", {
975
- type: "search",
976
- "aria-label": label,
977
- placeholder,
978
- value,
979
- onChange: (event) => onChange(event.target.value),
980
- className: "min-h-10 border-0 bg-transparent px-0 shadow-none focus:bg-transparent focus:shadow-none",
981
- style: { outline: "none" }
982
- })]
983
- });
984
- }
985
- /** A yes/no setting. */
986
- function Switch({ checked, label, disabled = false, onChange }) {
987
- return /* @__PURE__ */ jsx("button", {
988
- type: "button",
989
- role: "switch",
990
- "aria-checked": checked,
991
- "aria-label": label,
992
- disabled,
993
- onClick: () => onChange(!checked),
994
- className: cn("relative h-7 w-[46px] shrink-0 rounded-full transition-colors disabled:opacity-50", checked ? "bg-primary" : "bg-fawn"),
995
- children: /* @__PURE__ */ jsx("span", { className: cn("absolute top-[3px] size-[22px] rounded-full bg-white shadow transition-[left]", checked ? "left-[21px]" : "left-[3px]") })
996
- });
997
- }
998
- /** Something is being waited for. */
999
- function Waiting({ children }) {
1000
- return /* @__PURE__ */ jsxs("div", {
1001
- role: "status",
1002
- className: "flex items-center gap-3 text-sm font-semibold text-foreground",
1003
- children: [/* @__PURE__ */ jsx("span", {
1004
- "aria-hidden": "true",
1005
- className: "flex size-5 shrink-0 items-center justify-center",
1006
- children: /* @__PURE__ */ jsx("span", { className: "size-2.5 animate-pulse rounded-full bg-primary" })
1007
- }), /* @__PURE__ */ jsx("span", { children })]
1008
- });
1009
- }
1010
- /**
1011
- * A card of a Setup page: an icon, what the card holds, its state or its main action, then its
1012
- * rows (`CardRow`), its text and controls (`CardBody`, `CardForm`) or its facts (`Facts`).
1013
- */
1014
- function SetupCard({ icon, title, description, action, labelledBy, children }) {
1015
- return /* @__PURE__ */ jsxs("section", {
1016
- "aria-labelledby": labelledBy,
1017
- className: "min-w-0 overflow-hidden rounded-2xl border border-border bg-card shadow-baziu-sm",
1018
- children: [/* @__PURE__ */ jsxs("div", {
1019
- className: "flex flex-wrap items-center gap-x-4 gap-y-3 px-4 py-4 sm:px-5",
1020
- children: [/* @__PURE__ */ jsxs("div", {
1021
- className: "flex min-w-0 flex-1 basis-64 items-center gap-4",
1022
- children: [/* @__PURE__ */ jsx("span", {
1023
- "aria-hidden": "true",
1024
- className: "flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent text-accent-foreground",
1025
- children: icon
1026
- }), /* @__PURE__ */ jsxs("div", {
1027
- className: "min-w-0",
1028
- children: [/* @__PURE__ */ jsx("h2", {
1029
- id: labelledBy,
1030
- className: "m-0 font-body text-lg font-semibold text-foreground",
1031
- children: title
1032
- }), /* @__PURE__ */ jsx("div", {
1033
- className: "text-sm text-muted-foreground",
1034
- children: description
1035
- })]
1036
- })]
1037
- }), action]
1038
- }), children]
1039
- });
1040
- }
1041
- /** A row that spans a card under its heading: the unit of every list. */
1042
- var CARD_ROW = "flex flex-wrap items-center gap-x-4 gap-y-1 border-t border-border px-4 sm:px-5";
1043
- function CardRow({ className, ...props }) {
1044
- return /* @__PURE__ */ jsx("div", {
1045
- className: cn(CARD_ROW, className),
1046
- ...props
1047
- });
1048
- }
1049
- /** A card's list of things, each a `ListRow`. */
1050
- function CardList({ className, ...props }) {
1051
- return /* @__PURE__ */ jsx("ul", {
1052
- className: cn("m-0 list-none p-0", className),
1053
- ...props
1054
- });
1055
- }
1056
- /**
1057
- * One thing in a card's list: its name with its state, a line of what there is to know about it,
1058
- * what can be done with it, and under all that whatever it last reported.
1059
- */
1060
- function ListRow({ leading, title, chip, meta, actions, children, inline = false }) {
1061
- return /* @__PURE__ */ jsxs("li", {
1062
- className: cn(CARD_ROW, "min-h-14 py-2.5"),
1063
- children: [/* @__PURE__ */ jsxs("div", {
1064
- className: cn("flex min-w-0 flex-1 basis-full items-center gap-x-4 gap-y-1", inline ? "flex-nowrap" : "flex-wrap"),
1065
- children: [
1066
- leading && /* @__PURE__ */ jsx("span", {
1067
- className: "flex shrink-0 self-start pt-0.5",
1068
- children: leading
1069
- }),
1070
- /* @__PURE__ */ jsxs("div", {
1071
- className: cn("min-w-0 flex-1", inline ? "basis-0" : "basis-64"),
1072
- children: [/* @__PURE__ */ jsxs("div", {
1073
- className: "flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-1",
1074
- children: [/* @__PURE__ */ jsx("span", {
1075
- className: "min-w-0 break-words text-base font-semibold text-foreground",
1076
- children: title
1077
- }), chip]
1078
- }), meta && /* @__PURE__ */ jsx("div", {
1079
- className: "mt-0.5 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-0.5 text-sm text-muted-foreground",
1080
- children: meta
1081
- })]
1082
- }),
1083
- actions && /* @__PURE__ */ jsx("div", {
1084
- className: "flex shrink-0 flex-wrap items-center gap-2",
1085
- children: actions
1086
- })
1087
- ]
1088
- }), children && /* @__PURE__ */ jsx("div", {
1089
- className: "min-w-0 basis-full pb-1",
1090
- children
1091
- })]
1092
- });
1093
- }
1094
- var CARD_BODY = "grid gap-4 border-t border-border px-4 py-4 sm:px-5";
1095
- /** The part of a card that holds text and controls, with the card's own margins. */
1096
- function CardBody({ className, ...props }) {
1097
- return /* @__PURE__ */ jsx("div", {
1098
- className: cn(CARD_BODY, className),
1099
- ...props
1100
- });
1101
- }
1102
- /** A card's form: the same space as `CardBody`. */
1103
- function CardForm({ className, ...props }) {
1104
- return /* @__PURE__ */ jsx("form", {
1105
- className: cn(CARD_BODY, className),
1106
- ...props
1107
- });
1108
- }
1109
- var NOTICE = {
1110
- success: {
1111
- box: "border-success/30 bg-success/10",
1112
- mark: "text-success",
1113
- icon: Check
1114
- },
1115
- warning: {
1116
- box: "border-warning/35 bg-warning/10",
1117
- mark: "text-warning",
1118
- icon: AlertTriangle
1119
- },
1120
- danger: {
1121
- box: "border-danger/30 bg-danger/10",
1122
- mark: "text-danger",
1123
- icon: AlertTriangle
1124
- },
1125
- neutral: {
1126
- box: "border-border bg-muted/40",
1127
- mark: "text-muted-foreground",
1128
- icon: Info
1129
- }
1130
- };
1131
- /** Something to know inside a card: a warning, a result, a thing to do next. */
1132
- function Notice({ tone = "warning", title, children, actions, role = "status", className }) {
1133
- const { box, mark, icon: Icon } = NOTICE[tone];
1134
- return /* @__PURE__ */ jsxs("div", {
1135
- role,
1136
- className: cn("flex items-start gap-2.5 rounded-xl border px-3.5 py-3 text-sm text-foreground", box, className),
1137
- children: [/* @__PURE__ */ jsx(Icon, {
1138
- className: cn("mt-0.5 size-4 shrink-0", mark),
1139
- "aria-hidden": "true"
1140
- }), /* @__PURE__ */ jsxs("div", {
1141
- className: "min-w-0 flex-1 break-words",
1142
- children: [
1143
- title && /* @__PURE__ */ jsx("div", {
1144
- className: "font-semibold",
1145
- children: title
1146
- }),
1147
- children,
1148
- actions && /* @__PURE__ */ jsx("div", {
1149
- className: "mt-2.5 flex flex-wrap gap-2",
1150
- children: actions
1151
- })
1152
- ]
1153
- })]
1154
- });
1155
- }
1156
- var BANNER = {
1157
- success: "border-success/30 bg-success/10",
1158
- warning: "border-warning/35 bg-warning/10",
1159
- danger: "border-danger/30 bg-danger/10",
1160
- neutral: "border-border bg-card shadow-baziu-sm"
1161
- };
1162
- /** The line above a page's cards: how things stand as a whole, with the one thing to do. */
1163
- function Banner({ tone, lead, children, action, role = "status" }) {
1164
- const Icon = tone === "neutral" ? null : NOTICE[tone].icon;
1165
- return /* @__PURE__ */ jsxs("div", {
1166
- role,
1167
- className: cn("flex flex-wrap items-center gap-3 rounded-2xl border px-4 py-3 text-sm", BANNER[tone]),
1168
- children: [/* @__PURE__ */ jsxs("div", {
1169
- className: cn("flex min-w-0 flex-1 items-start gap-3", Icon ? "basis-64" : "basis-72"),
1170
- children: [Icon && /* @__PURE__ */ jsx(Icon, {
1171
- className: cn("mt-0.5 size-5 shrink-0", NOTICE[tone].mark),
1172
- "aria-hidden": "true"
1173
- }), /* @__PURE__ */ jsxs("div", {
1174
- className: "min-w-0",
1175
- children: [/* @__PURE__ */ jsx("span", {
1176
- className: "font-semibold text-foreground",
1177
- children: lead
1178
- }), children && /* @__PURE__ */ jsxs(Fragment$1, { children: [" ", /* @__PURE__ */ jsx("span", {
1179
- className: "text-muted-foreground",
1180
- children
1181
- })] })]
1182
- })]
1183
- }), action]
1184
- });
1185
- }
1186
- /** Facts about something: a name and what it is now, one to a row. */
1187
- function Facts({ children, className }) {
1188
- return /* @__PURE__ */ jsx("dl", {
1189
- className: cn("m-0 divide-y divide-border border-t border-border px-4 text-sm sm:px-5", className),
1190
- children
1191
- });
1192
- }
1193
- function Fact({ label, tone, children }) {
1194
- return /* @__PURE__ */ jsxs("div", {
1195
- className: "grid gap-x-4 gap-y-0.5 py-3 sm:grid-cols-[14rem_minmax(0,1fr)]",
1196
- children: [/* @__PURE__ */ jsx("dt", {
1197
- className: "text-muted-foreground",
1198
- children: label
1199
- }), /* @__PURE__ */ jsx("dd", {
1200
- className: cn("m-0 min-w-0 break-words font-medium", tone === "success" && "text-success", tone === "warning" && "text-warning", (tone === void 0 || tone === "neutral") && "text-foreground"),
1201
- children
1202
- })]
1203
- });
1204
- }
1205
- /** The outcome of some checks, one to a line. */
1206
- function CheckList({ children, ...props }) {
1207
- return /* @__PURE__ */ jsx("ul", {
1208
- className: "m-0 grid list-none gap-2.5 p-0",
1209
- ...props,
1210
- children
1211
- });
1212
- }
1213
- function CheckItem({ ok, label, children }) {
1214
- return /* @__PURE__ */ jsxs("li", {
1215
- className: "flex items-start gap-2.5 text-sm",
1216
- children: [/* @__PURE__ */ jsx("span", {
1217
- "aria-hidden": "true",
1218
- className: cn("mt-px flex size-5 shrink-0 items-center justify-center rounded-full", ok ? "bg-success/10 text-success" : "bg-warning/10 text-warning"),
1219
- children: ok ? /* @__PURE__ */ jsx(Check, { className: "size-3.5" }) : /* @__PURE__ */ jsx(X, { className: "size-3.5" })
1220
- }), /* @__PURE__ */ jsxs("span", {
1221
- className: "min-w-0 break-words",
1222
- children: [
1223
- /* @__PURE__ */ jsx("span", {
1224
- className: "sr-only",
1225
- children: ok ? "Passed: " : "Failed: "
1226
- }),
1227
- /* @__PURE__ */ jsx("span", {
1228
- className: "font-semibold text-foreground",
1229
- children: label
1230
- }),
1231
- children && /* @__PURE__ */ jsx("span", {
1232
- className: cn("ml-2", ok ? "text-muted-foreground" : "font-medium text-warning"),
1233
- children
1234
- })
1235
- ]
1236
- })]
1237
- });
1238
- }
1239
- /** A card's line of controls above its list: a search box, a filter, an action. */
1240
- function CardToolbar({ className, ...props }) {
1241
- return /* @__PURE__ */ jsx("div", {
1242
- className: cn(CARD_ROW, "gap-y-2 py-3", className),
1243
- ...props
1244
- });
1245
- }
1246
- /** The heading of a group of rows inside a card's list. */
1247
- function GroupHeader({ title, meta, action }) {
1248
- return /* @__PURE__ */ jsxs("div", {
1249
- className: cn(CARD_ROW, "min-h-10 bg-muted/50 py-2"),
1250
- children: [
1251
- /* @__PURE__ */ jsx("h3", {
1252
- className: "m-0 min-w-0 font-body text-xs font-bold uppercase tracking-[0.08em] text-muted-foreground",
1253
- children: title
1254
- }),
1255
- meta && /* @__PURE__ */ jsx("span", {
1256
- className: "text-xs text-muted-foreground",
1257
- children: meta
1258
- }),
1259
- action && /* @__PURE__ */ jsx("span", {
1260
- className: "ml-auto text-xs font-semibold",
1261
- children: action
1262
- })
1263
- ]
1264
- });
1265
- }
1266
- /** What a card shows when it has nothing to list: what would be here, and how to get it. */
1267
- function CardEmpty({ icon, title, children, action }) {
1268
- return /* @__PURE__ */ jsxs("div", {
1269
- className: "flex flex-col items-center gap-2 border-t border-border px-4 py-9 text-center sm:px-5",
1270
- children: [
1271
- icon && /* @__PURE__ */ jsx("span", {
1272
- "aria-hidden": "true",
1273
- className: "mb-1 flex size-10 items-center justify-center rounded-full bg-muted text-muted-foreground",
1274
- children: icon
1275
- }),
1276
- /* @__PURE__ */ jsx("p", {
1277
- className: "m-0 text-base font-semibold text-foreground",
1278
- children: title
1279
- }),
1280
- children && /* @__PURE__ */ jsx("p", {
1281
- className: "m-0 max-w-md text-sm text-muted-foreground",
1282
- children
1283
- }),
1284
- action && /* @__PURE__ */ jsx("div", {
1285
- className: "mt-2 flex flex-wrap justify-center gap-2",
1286
- children: action
1287
- })
1288
- ]
1289
- });
1290
- }
1291
- var MENU_ITEM = "flex w-full cursor-pointer flex-col items-start gap-0.5 rounded-lg px-2.5 py-2 text-left text-sm outline-none transition-colors data-[highlighted]:bg-accent data-[disabled]:cursor-not-allowed";
1292
- /**
1293
- * The rarer and the destructive actions on one row, behind a "More" button: the row itself keeps
1294
- * only what is done most.
1295
- */
1296
- function RowMenu({ label, items, disabled = false }) {
1297
- const shown = items.filter((item) => Boolean(item));
1298
- return /* @__PURE__ */ jsxs(DropdownMenu.Root, { children: [/* @__PURE__ */ jsx(DropdownMenu.Trigger, {
1299
- "aria-label": label,
1300
- disabled,
1301
- className: "inline-flex size-9 shrink-0 items-center justify-center rounded-lg border border-transparent text-muted-foreground transition-colors hover:border-border hover:bg-card hover:text-foreground disabled:opacity-50 data-[state=open]:border-border data-[state=open]:bg-card data-[state=open]:text-foreground",
1302
- children: /* @__PURE__ */ jsx(MoreHorizontal, {
1303
- className: "size-[18px]",
1304
- "aria-hidden": "true"
1305
- })
1306
- }), /* @__PURE__ */ jsx(DropdownMenu.Portal, { children: /* @__PURE__ */ jsx(DropdownMenu.Content, {
1307
- align: "end",
1308
- sideOffset: 6,
1309
- className: "z-50 min-w-[13rem] max-w-[calc(100vw-1.5rem)] rounded-xl border border-border bg-popover p-1.5 text-popover-foreground shadow-baziu-lg",
1310
- children: shown.map((item) => /* @__PURE__ */ jsxs(DropdownMenu.Item, {
1311
- "aria-disabled": item.disabledReason ? true : void 0,
1312
- onSelect: (event) => {
1313
- if (item.disabledReason) event.preventDefault();
1314
- else item.onSelect();
1315
- },
1316
- className: cn(MENU_ITEM, item.disabledReason && "cursor-not-allowed"),
1317
- style: { outline: "none" },
1318
- children: [/* @__PURE__ */ jsx("span", {
1319
- className: cn("font-semibold", item.disabledReason ? "text-muted-foreground" : item.danger ? "text-danger" : "text-foreground"),
1320
- children: item.label
1321
- }), item.disabledReason && /* @__PURE__ */ jsx("span", {
1322
- className: "text-xs text-muted-foreground",
1323
- children: item.disabledReason
1324
- })]
1325
- }, item.label))
1326
- }) })] });
1327
- }
1328
- //#endregion
1329
- //#region src/components/ui/form.tsx
1330
- var LABEL = "m-0 text-sm font-semibold text-foreground";
1331
- var HINT = "mt-1 block text-xs text-muted-foreground";
1332
- /** What is wrong with a value, said under its field. */
1333
- function Problem({ children }) {
1334
- return /* @__PURE__ */ jsx("span", {
1335
- role: "alert",
1336
- className: "mt-1 block text-xs font-semibold text-warning",
1337
- children
1338
- });
1339
- }
1340
- /** A line of text to type: an address, an id, a name. Or a time of day. */
1341
- function TextField({ label, value, onChange, type = "text", placeholder, hint, problem, notes, invalid, disabled, required, mono = false, inputMode, className }) {
1342
- const id = useId();
1343
- return /* @__PURE__ */ jsxs("div", { children: [
1344
- /* @__PURE__ */ jsx("label", {
1345
- htmlFor: id,
1346
- className: LABEL,
1347
- children: label
1348
- }),
1349
- /* @__PURE__ */ jsx("input", {
1350
- id,
1351
- type,
1352
- value,
1353
- disabled,
1354
- required,
1355
- inputMode,
1356
- autoComplete: "off",
1357
- spellCheck: false,
1358
- placeholder: placeholder ?? "",
1359
- "aria-invalid": problem || invalid ? true : void 0,
1360
- onChange: (event) => onChange(event.target.value),
1361
- className: cn("mt-1.5 max-w-xl", mono && "font-mono", className)
1362
- }),
1363
- hint && /* @__PURE__ */ jsx("span", {
1364
- className: HINT,
1365
- children: hint
1366
- }),
1367
- notes,
1368
- problem && /* @__PURE__ */ jsx(Problem, { children: problem })
1369
- ] });
1370
- }
1371
- /** Several lines of text: a message, a note. */
1372
- function TextAreaField({ label, value, onChange, placeholder, hint, problem, rows = 4, mono = false, disabled, required }) {
1373
- const id = useId();
1374
- return /* @__PURE__ */ jsxs("div", { children: [
1375
- /* @__PURE__ */ jsx("label", {
1376
- htmlFor: id,
1377
- className: LABEL,
1378
- children: label
1379
- }),
1380
- /* @__PURE__ */ jsx("textarea", {
1381
- id,
1382
- value,
1383
- rows,
1384
- disabled,
1385
- required,
1386
- spellCheck: !mono,
1387
- placeholder: placeholder ?? "",
1388
- "aria-invalid": problem ? true : void 0,
1389
- onChange: (event) => onChange(event.target.value),
1390
- className: cn("mt-1.5 w-full", mono && "font-mono text-[0.9em]")
1391
- }),
1392
- hint && /* @__PURE__ */ jsx("span", {
1393
- className: HINT,
1394
- children: hint
1395
- }),
1396
- problem && /* @__PURE__ */ jsx(Problem, { children: problem })
1397
- ] });
1398
- }
1399
- /** A choice between a few options that each need a sentence: radio cards, two abreast. */
1400
- function ChoiceCards({ legend, name, value, options, onChange, disabled = false, notes, columns = 2 }) {
1401
- const id = useId();
1402
- return /* @__PURE__ */ jsxs("fieldset", {
1403
- className: "m-0 min-w-0 border-0 p-0",
1404
- disabled,
1405
- children: [
1406
- /* @__PURE__ */ jsx("legend", {
1407
- className: "mb-2 p-0 text-sm font-semibold text-foreground",
1408
- children: legend
1409
- }),
1410
- /* @__PURE__ */ jsx("div", {
1411
- className: cn("grid gap-2", columns === 3 ? "md:grid-cols-3" : "md:grid-cols-2"),
1412
- children: options.map((option, index) => {
1413
- const selected = option.value === value;
1414
- const titleId = `${id}-${index}`;
1415
- return /* @__PURE__ */ jsxs("label", {
1416
- className: cn("m-0 flex items-start gap-3 rounded-xl border px-3.5 py-3 transition-colors", disabled ? "cursor-default opacity-70" : "cursor-pointer", selected ? "border-primary/50 bg-accent/40" : "border-border bg-card hover:bg-muted/40"),
1417
- children: [/* @__PURE__ */ jsx("input", {
1418
- type: "radio",
1419
- name,
1420
- value: option.value,
1421
- checked: selected,
1422
- onChange: () => onChange(option.value),
1423
- "aria-labelledby": titleId,
1424
- "aria-describedby": `${titleId}-about`,
1425
- className: "mt-[3px] size-[18px] shrink-0 accent-[var(--color-sapphire)]"
1426
- }), /* @__PURE__ */ jsxs("span", {
1427
- className: "min-w-0",
1428
- children: [/* @__PURE__ */ jsx("span", {
1429
- id: titleId,
1430
- className: "block text-sm font-semibold text-foreground",
1431
- children: option.label
1432
- }), /* @__PURE__ */ jsxs("span", {
1433
- id: `${titleId}-about`,
1434
- className: "block",
1435
- children: [option.hint && /* @__PURE__ */ jsx("span", {
1436
- className: "block break-words text-sm text-muted-foreground",
1437
- children: option.hint
1438
- }), selected && option.note && /* @__PURE__ */ jsx("span", {
1439
- className: cn("mt-1 block break-words text-sm font-medium", option.note.tone === "ok" ? "text-success" : "text-warning"),
1440
- children: option.note.text
1441
- })]
1442
- })]
1443
- })]
1444
- }, option.value);
1445
- })
1446
- }),
1447
- notes
1448
- ]
1449
- });
1450
- }
1451
- var EMPTY = ":none";
1452
- var FIELD_TRIGGER = "flex min-h-[2.65rem] w-full items-center justify-between gap-2 rounded-[var(--radius-md)] border border-frost bg-[color-mix(in_srgb,var(--color-snow)_82%,var(--color-ivory))] px-[0.8rem] py-[0.5rem] text-left text-[0.95em] text-chocolate transition-all focus-visible:border-sapphire focus-visible:bg-snow focus-visible:shadow-[0_0_0_3px_var(--color-sapphire-glow)] disabled:cursor-not-allowed disabled:opacity-60 data-[state=open]:border-sapphire";
1453
- var FILTER_TRIGGER = "inline-flex min-h-9 w-auto max-w-full items-center gap-2 rounded-[12px] border border-border bg-card py-1 pl-2.5 pr-2 text-left text-xs font-semibold text-foreground transition-all hover:border-sapphire-light focus-visible:border-sapphire focus-visible:shadow-[0_0_0_3px_var(--color-sapphire-glow)] disabled:opacity-60 data-[state=open]:border-sapphire";
1454
- var ITEM = "relative flex cursor-pointer select-none items-baseline gap-x-3 rounded-lg py-2 pl-8 pr-3 text-sm outline-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground";
1455
- /**
1456
- * The app's one dropdown, drawn like the model menu: the choice in a field, the options in a list
1457
- * with a tick by the chosen one. The keyboard works as in any list (arrows, letters, Enter).
1458
- */
1459
- function SelectMenu({ value, options, onChange, disabled, id, labelledBy, ariaLabel, placeholder, compact = false, className }) {
1460
- const valueId = useId();
1461
- const chosen = options.find((option) => option.value === value);
1462
- return /* @__PURE__ */ jsxs(Select.Root, {
1463
- value: value === "" ? chosen ? EMPTY : "" : value,
1464
- onValueChange: (next) => onChange(next === EMPTY ? "" : next),
1465
- disabled,
1466
- children: [/* @__PURE__ */ jsxs(Select.Trigger, {
1467
- id,
1468
- "aria-label": ariaLabel,
1469
- "aria-labelledby": labelledBy ? `${labelledBy} ${valueId}` : void 0,
1470
- className: cn(compact ? FILTER_TRIGGER : FIELD_TRIGGER, className),
1471
- style: { outline: "none" },
1472
- children: [/* @__PURE__ */ jsx("span", {
1473
- id: valueId,
1474
- className: "min-w-0 flex-1 truncate",
1475
- children: chosen ? chosen.label : /* @__PURE__ */ jsx("span", {
1476
- className: "text-mocha-light",
1477
- children: placeholder ?? "Choose…"
1478
- })
1479
- }), /* @__PURE__ */ jsx(Select.Icon, {
1480
- asChild: true,
1481
- children: /* @__PURE__ */ jsx(ChevronDown, {
1482
- className: cn("shrink-0 text-mocha-light", compact ? "size-3.5" : "size-4"),
1483
- "aria-hidden": "true"
1484
- })
1485
- })]
1486
- }), /* @__PURE__ */ jsx(Select.Portal, { children: /* @__PURE__ */ jsx(Select.Content, {
1487
- position: "popper",
1488
- sideOffset: 6,
1489
- className: "z-50 max-h-[min(24rem,var(--radix-select-content-available-height))] min-w-[max(var(--radix-select-trigger-width),12rem)] max-w-[calc(100vw-1.5rem)] overflow-hidden rounded-xl border border-border bg-popover text-popover-foreground shadow-baziu-lg",
1490
- children: /* @__PURE__ */ jsx(Select.Viewport, {
1491
- className: "p-1.5",
1492
- children: options.map((option) => /* @__PURE__ */ jsxs(Select.Item, {
1493
- value: option.value === "" ? EMPTY : option.value,
1494
- className: ITEM,
1495
- style: { outline: "none" },
1496
- children: [
1497
- /* @__PURE__ */ jsx(Select.ItemIndicator, {
1498
- className: "absolute left-2.5 top-1/2 -translate-y-1/2",
1499
- children: /* @__PURE__ */ jsx(Check, {
1500
- className: "size-4 text-primary",
1501
- "aria-hidden": "true"
1502
- })
1503
- }),
1504
- /* @__PURE__ */ jsx(Select.ItemText, {
1505
- asChild: true,
1506
- children: /* @__PURE__ */ jsx("span", {
1507
- className: "min-w-0 flex-1 break-words font-semibold",
1508
- children: option.label
1509
- })
1510
- }),
1511
- option.hint && /* @__PURE__ */ jsx("span", {
1512
- className: "shrink-0 text-xs text-muted-foreground",
1513
- children: option.hint
1514
- })
1515
- ]
1516
- }, option.value))
1517
- })
1518
- }) })]
1519
- });
1520
- }
1521
- /** One of a few fixed choices, where a line of radio cards would be too much. */
1522
- function SelectField({ label, value, options, onChange, hint, disabled, placeholder, className }) {
1523
- const id = useId();
1524
- return /* @__PURE__ */ jsxs("div", { children: [
1525
- /* @__PURE__ */ jsx("label", {
1526
- id: `${id}-label`,
1527
- htmlFor: id,
1528
- className: LABEL,
1529
- children: label
1530
- }),
1531
- /* @__PURE__ */ jsx(SelectMenu, {
1532
- id,
1533
- labelledBy: `${id}-label`,
1534
- value,
1535
- options,
1536
- onChange,
1537
- disabled,
1538
- placeholder,
1539
- className: cn("mt-1.5 max-w-xl", className)
1540
- }),
1541
- hint && /* @__PURE__ */ jsx("span", {
1542
- className: HINT,
1543
- children: hint
1544
- })
1545
- ] });
1546
- }
1547
- /** A filter in a card's toolbar: a small dropdown named by its label, which is read, not shown. */
1548
- function FilterSelect({ label, value, options, onChange }) {
1549
- return /* @__PURE__ */ jsx(SelectMenu, {
1550
- compact: true,
1551
- ariaLabel: label,
1552
- value,
1553
- options,
1554
- onChange
1555
- });
1556
- }
1557
- /**
1558
- * A key or token. A saved one is never shown or put back into a field: the row says that it is
1559
- * saved, and it is replaced or removed from there. Both wait for the form's Save.
1560
- */
1561
- function SecretField({ label, saved, preview, value, onChange, removed = false, onRemove, open = false, placeholder, hint, notes, disabled }) {
1562
- const id = useId();
1563
- const [replacing, setReplacing] = useState(false);
1564
- const [kept, setKept] = useState(false);
1565
- const [moved, setMoved] = useState(null);
1566
- const typing = !saved || replacing || open;
1567
- return /* @__PURE__ */ jsxs("div", { children: [
1568
- /* @__PURE__ */ jsx("label", {
1569
- id: `${id}-label`,
1570
- htmlFor: typing ? id : void 0,
1571
- className: LABEL,
1572
- children: label
1573
- }),
1574
- typing ? /* @__PURE__ */ jsxs("div", {
1575
- className: "mt-1.5 flex max-w-xl flex-wrap items-center gap-2",
1576
- children: [/* @__PURE__ */ jsx("input", {
1577
- id,
1578
- type: "password",
1579
- value,
1580
- disabled,
1581
- autoComplete: "off",
1582
- spellCheck: false,
1583
- placeholder: placeholder ?? "",
1584
- autoFocus: replacing,
1585
- onChange: (event) => onChange(event.target.value),
1586
- className: "min-w-0 flex-1 basis-56 font-mono"
1587
- }), saved && !open && /* @__PURE__ */ jsx(Button, {
1588
- variant: "ghost",
1589
- disabled,
1590
- onClick: () => {
1591
- onChange("");
1592
- setReplacing(false);
1593
- setKept(true);
1594
- },
1595
- children: "Keep the saved one"
1596
- })]
1597
- }) : /* @__PURE__ */ jsxs("div", {
1598
- role: "group",
1599
- "aria-labelledby": `${id}-label`,
1600
- className: "mt-1.5 flex min-h-[2.65rem] max-w-xl flex-wrap items-center gap-x-3 gap-y-2 rounded-xl border border-border bg-muted/40 px-3.5 py-1.5 text-sm",
1601
- children: [/* @__PURE__ */ jsx("span", {
1602
- className: "min-w-0 flex-1 basis-40 text-foreground",
1603
- children: removed ? "Will be removed when you save." : /* @__PURE__ */ jsxs(Fragment$1, { children: [
1604
- "Saved: ",
1605
- /* @__PURE__ */ jsx("span", {
1606
- className: "font-mono",
1607
- children: preview || "•••"
1608
- }),
1609
- ", stored encrypted"
1610
- ] })
1611
- }), removed ? /* @__PURE__ */ jsx(Button, {
1612
- variant: "ghost",
1613
- disabled,
1614
- autoFocus: moved === "keep",
1615
- onClick: () => {
1616
- setMoved("remove");
1617
- onRemove?.(false);
1618
- },
1619
- children: "Keep it"
1620
- }) : /* @__PURE__ */ jsxs("span", {
1621
- className: "flex gap-2",
1622
- children: [/* @__PURE__ */ jsx(Button, {
1623
- variant: "ghost",
1624
- disabled,
1625
- autoFocus: kept,
1626
- onClick: () => setReplacing(true),
1627
- children: "Replace"
1628
- }), onRemove && /* @__PURE__ */ jsx(Button, {
1629
- variant: "ghost",
1630
- disabled,
1631
- autoFocus: moved === "remove",
1632
- onClick: () => {
1633
- setMoved("keep");
1634
- onRemove(true);
1635
- },
1636
- children: "Remove"
1637
- })]
1638
- })]
1639
- }),
1640
- hint && /* @__PURE__ */ jsx("span", {
1641
- className: HINT,
1642
- children: hint
1643
- }),
1644
- notes
1645
- ] });
1646
- }
1647
- /** A yes/no setting: what it is on the left, the switch on the right. */
1648
- function SwitchRow({ label, description, notes, checked, disabled, onChange }) {
1649
- return /* @__PURE__ */ jsxs("div", {
1650
- className: "flex items-start justify-between gap-4",
1651
- children: [/* @__PURE__ */ jsxs("div", {
1652
- className: "min-w-0",
1653
- children: [
1654
- /* @__PURE__ */ jsx("div", {
1655
- className: "text-sm font-semibold text-foreground",
1656
- children: label
1657
- }),
1658
- description && /* @__PURE__ */ jsx("div", {
1659
- className: "text-sm text-muted-foreground",
1660
- children: description
1661
- }),
1662
- notes
1663
- ]
1664
- }), /* @__PURE__ */ jsx(Switch, {
1665
- label,
1666
- checked,
1667
- disabled,
1668
- onChange
1669
- })]
1670
- });
1671
- }
1672
- /** One of several things to tick. */
1673
- function CheckboxRow({ label, checked, disabled, onChange }) {
1674
- return /* @__PURE__ */ jsxs("label", {
1675
- className: "m-0 flex items-center gap-2.5 text-sm text-foreground",
1676
- children: [/* @__PURE__ */ jsx("input", {
1677
- type: "checkbox",
1678
- checked,
1679
- disabled,
1680
- onChange: (event) => onChange(event.target.checked),
1681
- className: "m-0 size-[18px] shrink-0"
1682
- }), label]
1683
- });
1684
- }
1685
- /**
1686
- * Where a form stands, in the words every Setup form uses: what was refused, what is not saved
1687
- * yet, what was just saved, or else what to know about saving it.
1688
- */
1689
- function saveStatus({ refused = false, error, dirty, saved, savedText = "Saved.", footnote = "" }) {
1690
- if (refused) return {
1691
- text: "Nothing was saved: see above.",
1692
- tone: "warning"
1693
- };
1694
- if (error) return {
1695
- text: `Nothing was saved: ${error}`,
1696
- tone: "warning"
1697
- };
1698
- if (dirty) return {
1699
- text: "Not saved yet.",
1700
- tone: "warning"
1701
- };
1702
- if (saved) return {
1703
- text: savedText,
1704
- tone: "success"
1705
- };
1706
- return {
1707
- text: footnote,
1708
- tone: "neutral"
1709
- };
1710
- }
1711
- var STATUS = {
1712
- success: "text-success",
1713
- warning: "text-warning",
1714
- neutral: "text-muted-foreground"
1715
- };
1716
- /** A form's last line: Save, and where things stand. */
1717
- function SaveBar({ busy, disabled, status, label = "Save", busyLabel = "Saving…", extra }) {
1718
- return /* @__PURE__ */ jsxs("div", {
1719
- className: "flex flex-wrap items-center gap-x-4 gap-y-2",
1720
- children: [
1721
- /* @__PURE__ */ jsx(Button, {
1722
- variant: "primary",
1723
- type: "submit",
1724
- disabled: disabled || busy,
1725
- children: busy ? busyLabel : label
1726
- }),
1727
- extra,
1728
- /* @__PURE__ */ jsx("p", {
1729
- role: "status",
1730
- className: cn("m-0 min-w-0 flex-1 basis-56 text-sm font-medium", STATUS[status.tone]),
1731
- children: status.text
1732
- })
1733
- ]
1734
- });
1735
- }
1736
- //#endregion
1737
- //#region src/components/SpawnDialog.tsx
1738
- /** The one way to spawn an Agent; opens its chat afterwards. */
1739
- function SpawnDialog({ profiles, teams, profileId: initialProfileId, teamId: initialTeamId, onClose }) {
1740
- const navigate = useNavigate();
1741
- const [profileId, setProfileId] = useState(initialProfileId ?? profiles.find((profile) => profile.id === "default")?.id ?? profiles[0]?.id ?? "");
1742
- const [name, setName] = useState("");
1743
- const [model, setModel] = useState("");
1744
- const [chatModels, setChatModels] = useState([]);
1745
- const [teamId, setTeamId] = useState(teams.find((team) => team.id === initialTeamId)?.id ?? teams.find((team) => team.id === "default")?.id ?? teams[0]?.id ?? "");
1746
- const [busy, setBusy] = useState(false);
1747
- const [error, setError] = useState(null);
1748
- const restricted = teams.find((team) => team.id === teamId)?.policyMode === "restricted";
1749
- useEffect(() => {
1750
- const controller = new AbortController();
1751
- api(MODELS_PATH, { signal: controller.signal }).then((response) => setChatModels(response.chat)).catch(() => {});
1752
- return () => controller.abort();
1753
- }, []);
1754
- async function submit(event) {
1755
- event.preventDefault();
1756
- setError(null);
1757
- setBusy(true);
1758
- try {
1759
- const request = {
1760
- profileId,
1761
- teamId
1762
- };
1763
- if (name.trim()) request.name = name.trim();
1764
- if (model) request.model = model;
1765
- const { agent } = await api("/api/agents", { body: request });
1766
- onClose();
1767
- await navigate({
1768
- to: "/",
1769
- search: { agent: agent.id }
1770
- });
1771
- } catch (cause) {
1772
- setError(errorMessage(cause));
1773
- setBusy(false);
1774
- }
1775
- }
1776
- const template = profiles.find((profile) => profile.id === profileId);
1777
- return /* @__PURE__ */ jsx(Dialog$1, {
1778
- title: "Spawn an agent",
1779
- description: "It starts with its template's files, model and skills, in the Team you choose.",
1780
- busy,
1781
- onClose,
1782
- children: /* @__PURE__ */ jsxs("form", {
1783
- onSubmit: (event) => void submit(event),
1784
- className: "grid gap-4",
1785
- children: [
1786
- /* @__PURE__ */ jsx(SelectField, {
1787
- label: "Agent template",
1788
- value: profileId,
1789
- options: profiles.map((profile) => ({
1790
- value: profile.id,
1791
- label: profile.name || profile.id
1792
- })),
1793
- disabled: busy,
1794
- className: "max-w-none",
1795
- onChange: setProfileId
1796
- }),
1797
- /* @__PURE__ */ jsx(TextField, {
1798
- label: "Name",
1799
- value: name,
1800
- disabled: busy,
1801
- placeholder: template?.name || template?.id || "The template’s name",
1802
- hint: "Leave it empty to use the template’s name.",
1803
- className: "max-w-none",
1804
- onChange: setName
1805
- }),
1806
- /* @__PURE__ */ jsx(ModelMenu, {
1807
- kit: true,
1808
- label: "Model",
1809
- value: model,
1810
- onChange: setModel,
1811
- models: chatModels,
1812
- inherited: {
1813
- label: "The template’s model",
1814
- model: template?.defaultModel
1815
- }
1816
- }),
1817
- /* @__PURE__ */ jsx(SelectField, {
1818
- label: "Team",
1819
- value: teamId,
1820
- options: teams.map((team) => ({
1821
- value: team.id,
1822
- label: team.id === "default" ? `${team.name} (default)` : team.name
1823
- })),
1824
- disabled: busy,
1825
- className: "max-w-none",
1826
- hint: restricted ? "This Team is restricted: the new Agent starts with no connections. Add them under Connections." : void 0,
1827
- onChange: setTeamId
1828
- }),
1829
- error && /* @__PURE__ */ jsx(Notice, {
1830
- tone: "warning",
1831
- role: "alert",
1832
- title: "It was not spawned.",
1833
- children: error
1834
- }),
1835
- /* @__PURE__ */ jsxs(DialogActions, { children: [/* @__PURE__ */ jsx(Button, {
1836
- variant: "ghost",
1837
- disabled: busy,
1838
- onClick: onClose,
1839
- children: "Cancel"
1840
- }), /* @__PURE__ */ jsx(Button, {
1841
- variant: "primary",
1842
- type: "submit",
1843
- disabled: busy || !profileId || !teamId,
1844
- children: busy ? "Spawning…" : "Spawn agent"
1845
- })] })
1846
- ]
1847
- })
1848
- });
1849
- }
1850
- //#endregion
1851
- export { agentState as $, RowMenu as A, isTeamSection as B, CheckList as C, GroupHeader as D, Facts as E, FOCUS_VIEWS as F, DialogActions as G, parseWorkspaceSearch as H, PANEL_COOKIE as I, DEFAULT_PROFILE_ID as J, Button as K, PANEL_LABELS as L, SetupCard as M, Switch as N, ListRow as O, Waiting as P, ActivityProvider as Q, PANEL_TABS as R, CheckItem as S, Fact as T, writePanelCookie as U, parsePanelCookie as V, Dialog$1 as W, OUTSIDE_TEAM as X, DEFAULT_TEAM_ID as Y, REASONING_LEVELS as Z, CardEmpty as _, Problem as a, lineChange as at, CardRow as b, SelectField as c, LiveProvider as ct, TextAreaField as d, api as dt, shortTime as et, TextField as f, apiFetch as ft, CardBody as g, CARD_ROW as h, FilterSelect as i, describeStep as it, SearchField as j, Notice as k, SelectMenu as l, useLive as lt, Banner as m, CheckboxRow as n, useActivity as nt, SaveBar as o, parseArgs as ot, saveStatus as p, errorMessage as pt, AgentAvatar as q, ChoiceCards as r, useActivityOptional as rt, SecretField as s, summarizeSteps as st, SpawnDialog as t, teamSummary as tt, SwitchRow as u, ApiError as ut, CardForm as v, Chip as w, CardToolbar as x, CardList as y, isAgentSection as z };