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