bazilion 0.52.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 (210) 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-CUbHBhzx.js +1 -0
  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-BJWZd1ts.js +1 -0
  12. package/dist/web/client/assets/SectionTabs-ViZKm3-B.js +1 -0
  13. package/dist/web/client/assets/Segmented-MYKKTuZO.js +1 -0
  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-BmdwLH99.js +1 -0
  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-C4t9l5wR.js +1 -0
  32. package/dist/web/client/assets/file-text-DzbjpYrV.js +1 -0
  33. package/dist/web/client/assets/images-DSYgPKM7.js +1 -0
  34. package/dist/web/client/assets/index-YW0gXPfk.js +14 -0
  35. package/dist/web/client/assets/key-round-BpK4-E3T.js +1 -0
  36. package/dist/web/client/assets/list-checks-JNXcmws9.js +1 -0
  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-DM2MP9vF.js +1 -0
  41. package/dist/web/client/assets/network-BJ4iPjQO.js +1 -0
  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-Dmm6cV-G.js +1 -0
  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-Tn4AskPm.js → AddProviderDialog-Nc5mc_P6.js} +106 -8
  59. package/dist/web/server/assets/AgentTemplateParts-DZK_r3nQ.js +266 -0
  60. package/dist/web/server/assets/{ConfigPage-DqDUujmt.js → ConfigPage-CxzL-gTm.js} +2 -2
  61. package/dist/web/server/assets/{ConfirmDialog-DfaJ--A6.js → ConfirmDialog-4xeCXKHe.js} +1 -2
  62. package/dist/web/server/assets/{ConnectionsView-DAG-zNBz.js → ConnectionsView-B02FjNsM.js} +9 -9
  63. package/dist/web/server/assets/ManagePage-BfCWE8Lj.js +29 -0
  64. package/dist/web/server/assets/ModelMenu-D-hTgYOO.js +278 -0
  65. package/dist/web/server/assets/{Rail-BIC_4ptO.js → Rail-3gbidhyv.js} +17 -110
  66. package/dist/web/server/assets/{SectionTabs-BGsrf-UQ.js → SectionTabs-CWQ5orUW.js} +9 -2
  67. package/dist/web/server/assets/SkillsParts-D58l8voo.js +199 -0
  68. package/dist/web/server/assets/SpawnDialog-MJWwppgC.js +1648 -0
  69. package/dist/web/server/assets/SpawnTeamModal-RjzAeX_Q.js +124 -0
  70. package/dist/web/server/assets/TeamForm-DdOgIMiV.js +138 -0
  71. package/dist/web/server/assets/{TeamThread-DuLlGDcw.js → TeamThread-D-PvO3fu.js} +9 -9
  72. package/dist/web/server/assets/{UnsavedChangesGuard-DrOvPV14.js → UnsavedChangesGuard-Bb5frygQ.js} +1 -1
  73. package/dist/web/server/assets/{_id-TVruGcOd.js → _id-BKzOw78O.js} +11 -3
  74. package/dist/web/server/assets/_id-BPjVkcNb.js +396 -0
  75. package/dist/web/server/assets/_id-BUfy-GwH.js +16 -0
  76. package/dist/web/server/assets/{_id-yN0z7VqE.js → _id-C1_l6oSR.js} +257 -207
  77. package/dist/web/server/assets/{_id-DJnYgisy.js → _id-CHvYQhWt.js} +8 -4
  78. package/dist/web/server/assets/_id-De3Bm0SG.js +39 -0
  79. package/dist/web/server/assets/_tanstack-start-manifest_v-CR3jm1nY.js +256 -0
  80. package/dist/web/server/assets/access-CNfvQ3NB.js +295 -0
  81. package/dist/web/server/assets/{access-GMGed5O8.js → access-Cm_izIIC.js} +2 -2
  82. package/dist/web/server/assets/{access-C_pupPks.js → access-WWspT0v4.js} +2 -1
  83. package/dist/web/server/assets/agent-actions-COnfW5AU.js +20 -0
  84. package/dist/web/server/assets/agents-C7UmTjfO.js +13 -0
  85. package/dist/web/server/assets/{agents-BnWgFo6o.js → agents-CRtMfKqX.js} +9 -6
  86. package/dist/web/server/assets/agents-D0hfGIMK.js +134 -0
  87. package/dist/web/server/assets/agents-DQowl6Ly.js +31 -0
  88. package/dist/web/server/assets/agents-DzpqlIuJ.js +12 -0
  89. package/dist/web/server/assets/agents-NOkh61dV.js +323 -0
  90. package/dist/web/server/assets/attention-CRvxt22X.js +232 -0
  91. package/dist/web/server/assets/{attention-Cr7puThv.js → attention-CgWhXjX7.js} +4 -1
  92. package/dist/web/server/assets/{attention-DS3O9UmJ.js → attention-Cx9ZWPOO.js} +4 -2
  93. package/dist/web/server/assets/{config-DjTGA4iZ.js → config-B5CS8juO.js} +2 -2
  94. package/dist/web/server/assets/{config-Q7livfa3.js → config-D117117T.js} +51 -102
  95. package/dist/web/server/assets/createSsrRpc-CwTd0zrB.js +72 -0
  96. package/dist/web/server/assets/{login-VV10kZBl.js → login-IF0Gbsuq.js} +36 -2
  97. package/dist/web/server/assets/{login-JoIjlcmu.js → login-va4EtvA8.js} +34 -45
  98. package/dist/web/server/assets/manage-Ce6cI4eW.js +240 -0
  99. package/dist/web/server/assets/{mcp-ZARSOxZW.js → mcp-Bm9U6x7N.js} +2 -2
  100. package/dist/web/server/assets/mcp-C96PBxpb.js +376 -0
  101. package/dist/web/server/assets/page-title-CwcbXMhx.js +95 -0
  102. package/dist/web/server/assets/{router-Dh2-IvLL.js → router-8Iq19GOz.js} +366 -203
  103. package/dist/web/server/assets/{routes-C9NawqcV.js → routes-BLo-fWbQ.js} +2681 -1667
  104. package/dist/web/server/assets/{routes-CDskMy5C.js → routes-BXvYYFrN.js} +2 -2
  105. package/dist/web/server/assets/routes-Kwam6JmS.js +89 -0
  106. package/dist/web/server/assets/{skills-StN15QhC.js → skills-BqCnA-74.js} +2 -2
  107. package/dist/web/server/assets/skills-DSezIdDc.js +157 -0
  108. package/dist/web/server/assets/{skills-h5aHa7Q8.js → skills-DWzlT_hC.js} +9 -1
  109. package/dist/web/server/assets/{style-GYDODk2F.js → style-C2hIPY_Y.js} +2 -2
  110. package/dist/web/server/assets/{system-Dl-1RhoP.js → system-CcLCmkIC.js} +2 -2
  111. package/dist/web/server/assets/{system-DtswhLW6.js → system-D3th6n2E.js} +4 -2
  112. package/dist/web/server/assets/system-E0VePdzO.js +145 -0
  113. package/dist/web/server/assets/{teams-BxnvFTyn.js → teams-70u1XQTr.js} +1 -3
  114. package/dist/web/server/assets/{teams-YrmyutM4.js → teams-BopOP4x7.js} +8 -1
  115. package/dist/web/server/assets/teams-CQVV18D3.js +216 -0
  116. package/dist/web/server/assets/teams-CdCmBJIj.js +174 -0
  117. package/dist/web/server/assets/{teams-5PMGvHuM.js → teams-DScFp8mK.js} +2 -2
  118. package/dist/web/server/assets/{teams-CbIPKf99.js → teams-DxA-vnzY.js} +4 -2
  119. package/dist/web/server/assets/telegram-DJ8s_91Y.js +1057 -0
  120. package/dist/web/server/assets/{telegram-Cv0D4gyz.js → telegram-DR7xijeS.js} +2 -2
  121. package/dist/web/server/assets/{tools-ioJcPzMW.js → tools-CsH9DI-4.js} +2 -2
  122. package/dist/web/server/assets/{tools-OfD22R-C.js → tools-V6kezUpL.js} +55 -218
  123. package/dist/web/server/assets/{use-resource-DVzK0toP.js → use-resource-CjcJwn7F.js} +1 -1
  124. package/dist/web/server/assets/{welcome-jxmpE_Jb.js → welcome-BpmcD-ia.js} +2 -2
  125. package/dist/web/server/assets/{welcome-FFEbrNT1.js → welcome-Ya8TkL4v.js} +10 -10
  126. package/dist/web/server/server.js +19 -19
  127. package/dist/worker.js +17 -0
  128. package/dist/worker.js.map +1 -1
  129. package/package.json +1 -1
  130. package/dist/web/client/assets/AddProviderDialog-BiGLKnu2.js +0 -1
  131. package/dist/web/client/assets/ConfigPage-DvBzy2MN.js +0 -1
  132. package/dist/web/client/assets/ConfirmDialog-CiZ5tk9R.js +0 -1
  133. package/dist/web/client/assets/ConnectionsView-Czkpm2JY.js +0 -1
  134. package/dist/web/client/assets/Dialog-s_kPtI-W.js +0 -1
  135. package/dist/web/client/assets/ModelMenu-BfUPoRjV.js +0 -1
  136. package/dist/web/client/assets/SectionTabs-DENNb6Nw.js +0 -1
  137. package/dist/web/client/assets/Segmented-Dh77vmpp.js +0 -1
  138. package/dist/web/client/assets/SkillFindings-Xng11qqx.js +0 -1
  139. package/dist/web/client/assets/SkillsPicker-hI3YXvib.js +0 -1
  140. package/dist/web/client/assets/SpawnDialog-CKWFQ6jk.js +0 -1
  141. package/dist/web/client/assets/Tabs-f6bHvCGn.js +0 -1
  142. package/dist/web/client/assets/TeamForm-kda1HYZG.js +0 -1
  143. package/dist/web/client/assets/TeamThread-2rm1JGSk.js +0 -1
  144. package/dist/web/client/assets/UnsavedChangesGuard-nx6dv2Yw.js +0 -1
  145. package/dist/web/client/assets/_id-B72mIpcE.js +0 -1
  146. package/dist/web/client/assets/_id-Bzavnza1.js +0 -1
  147. package/dist/web/client/assets/access-Yw9jODuk.js +0 -1
  148. package/dist/web/client/assets/agents-C9xoyL7o.js +0 -1
  149. package/dist/web/client/assets/agents-TviG16wx.js +0 -1
  150. package/dist/web/client/assets/api-HC_YzjBy.js +0 -1
  151. package/dist/web/client/assets/arrow-right-Gm_FDWJ_.js +0 -1
  152. package/dist/web/client/assets/attention-DmURtlJm.js +0 -1
  153. package/dist/web/client/assets/check-BjgKoGvU.js +0 -1
  154. package/dist/web/client/assets/chevron-right-CUZiA2aG.js +0 -1
  155. package/dist/web/client/assets/config-UZz_mjO5.js +0 -1
  156. package/dist/web/client/assets/createLucideIcon-C6gOo8sD.js +0 -1
  157. package/dist/web/client/assets/dist-BWppw70N.js +0 -41
  158. package/dist/web/client/assets/dist-D2dwY7MR.js +0 -1
  159. package/dist/web/client/assets/entities-xVoB-p2j.js +0 -1
  160. package/dist/web/client/assets/index-Df1oUtAP.js +0 -14
  161. package/dist/web/client/assets/link-Cbztlp_R.js +0 -1
  162. package/dist/web/client/assets/login-CPfdaqsV.js +0 -1
  163. package/dist/web/client/assets/mcp-FlYnNon0.js +0 -1
  164. package/dist/web/client/assets/model-facts-DoB6QD5y.js +0 -1
  165. package/dist/web/client/assets/parts-tIDBNsYA.js +0 -1
  166. package/dist/web/client/assets/plus-CWrKMtvA.js +0 -1
  167. package/dist/web/client/assets/routes-BZaWCoQj.js +0 -76
  168. package/dist/web/client/assets/save-f9O-CQia.js +0 -1
  169. package/dist/web/client/assets/skills-C7yDPC8s.js +0 -1
  170. package/dist/web/client/assets/style-DDuTFJUu.js +0 -7
  171. package/dist/web/client/assets/styles-BviXU81u.css +0 -2
  172. package/dist/web/client/assets/system-CL3Kz36L.js +0 -1
  173. package/dist/web/client/assets/teams-CQTEF5gV.js +0 -1
  174. package/dist/web/client/assets/teams-DQ7SqVyF.js +0 -1
  175. package/dist/web/client/assets/telegram-BLgxtGhZ.js +0 -1
  176. package/dist/web/client/assets/tools-pOQyGVYo.js +0 -1
  177. package/dist/web/client/assets/use-resource-C3MBZJop.js +0 -1
  178. package/dist/web/client/assets/welcome-Hr6JpMef.js +0 -1
  179. package/dist/web/client/assets/wrench-6BEIqKDn.js +0 -1
  180. package/dist/web/server/assets/Dialog-aup_yJv5.js +0 -85
  181. package/dist/web/server/assets/ModelMenu-DUY9aHkE.js +0 -138
  182. package/dist/web/server/assets/SkillFindings-BdATze1A.js +0 -46
  183. package/dist/web/server/assets/SkillsPicker-DlqEfRWh.js +0 -67
  184. package/dist/web/server/assets/SpawnDialog-D_SMPCG_.js +0 -132
  185. package/dist/web/server/assets/Tabs-BhF41MfQ.js +0 -20
  186. package/dist/web/server/assets/TeamForm-ilBaeLI4.js +0 -96
  187. package/dist/web/server/assets/_id-BsZcsabI.js +0 -383
  188. package/dist/web/server/assets/_id-D8Kj0F30.js +0 -18
  189. package/dist/web/server/assets/_id-QYifTM9w.js +0 -28
  190. package/dist/web/server/assets/_tanstack-start-manifest_v-D6zrzUC7.js +0 -223
  191. package/dist/web/server/assets/access-DKOpcHIJ.js +0 -232
  192. package/dist/web/server/assets/agents-B6OR3x99.js +0 -327
  193. package/dist/web/server/assets/agents-B7642eRO.js +0 -130
  194. package/dist/web/server/assets/agents-BJ-_oC2e.js +0 -14
  195. package/dist/web/server/assets/agents-CjV0w-Zy.js +0 -12
  196. package/dist/web/server/assets/agents-Dy_Q-9lG.js +0 -27
  197. package/dist/web/server/assets/attention-CLP4HYBz.js +0 -216
  198. package/dist/web/server/assets/createSsrRpc-GCCF14VW.js +0 -169
  199. package/dist/web/server/assets/entities-Dn2xzKIw.js +0 -16
  200. package/dist/web/server/assets/mcp-BI-FD-JI.js +0 -250
  201. package/dist/web/server/assets/model-facts-mrfrWQne.js +0 -136
  202. package/dist/web/server/assets/parts-B31PJkhi.js +0 -190
  203. package/dist/web/server/assets/routes-BJIJWCIE.js +0 -16
  204. package/dist/web/server/assets/skills-BqLq3ZXq.js +0 -275
  205. package/dist/web/server/assets/system-BtRA2HUs.js +0 -138
  206. package/dist/web/server/assets/teams-COaU0wN9.js +0 -108
  207. package/dist/web/server/assets/teams-Ca8W4mvl.js +0 -88
  208. package/dist/web/server/assets/telegram-Yx8nm6Ei.js +0 -984
  209. package/dist/web/server/assets/utils-C_uf36nf.js +0 -8
  210. package/dist/web/server/assets/workspace-DaitCM0t.js +0 -651
@@ -1,984 +0,0 @@
1
- import { C as api, T as errorMessage, u as Button } from "./workspace-DaitCM0t.js";
2
- import { t as ConfirmDialog } from "./ConfirmDialog-DfaJ--A6.js";
3
- import { t as Route } from "./telegram-Cv0D4gyz.js";
4
- import { t as ConfigPage } from "./ConfigPage-DqDUujmt.js";
5
- import { useEffect, useState } from "react";
6
- import { useRouter } from "@tanstack/react-router";
7
- import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
- //#region src/components/NotificationSettings.tsx
9
- var kinds = {
10
- lesson_proposal: "Lesson proposals",
11
- review_failure: "Review failures",
12
- trigger_failure: "Scheduled trigger failures",
13
- agent_loop_break: "Agent message loop breaks",
14
- queue_interrupted: "Queues paused after restart"
15
- };
16
- function browserTimezone() {
17
- try {
18
- return Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
19
- } catch {
20
- return "UTC";
21
- }
22
- }
23
- /** Telegram notices for new Attention items: on/off, kinds, quiet hours. */
24
- function NotificationSettings() {
25
- const [state, setState] = useState(null);
26
- const [enabled, setEnabled] = useState(false);
27
- const [selected, setSelected] = useState([]);
28
- const [timezone, setTimezone] = useState("UTC");
29
- const [quiet, setQuiet] = useState(false);
30
- const [start, setStart] = useState("22:00");
31
- const [end, setEnd] = useState("07:00");
32
- const [busy, setBusy] = useState(false);
33
- const [error, setError] = useState(null);
34
- const [notice, setNotice] = useState(null);
35
- function show(value) {
36
- setState(value);
37
- setEnabled(value.enabled);
38
- setSelected(value.kinds);
39
- setTimezone(value.enabled || value.quietHours ? value.timezone : browserTimezone());
40
- setQuiet(value.quietHours !== null);
41
- setStart(value.quietHours?.start ?? "22:00");
42
- setEnd(value.quietHours?.end ?? "07:00");
43
- }
44
- useEffect(() => {
45
- api("/api/notifications").then(show).catch((e) => setError(errorMessage(e)));
46
- }, []);
47
- async function save() {
48
- setBusy(true);
49
- setError(null);
50
- setNotice(null);
51
- try {
52
- show(await api("/api/notifications", {
53
- method: "PUT",
54
- body: {
55
- enabled,
56
- kinds: selected,
57
- timezone,
58
- quietHours: quiet ? {
59
- start,
60
- end
61
- } : null
62
- }
63
- }));
64
- setNotice("Saved.");
65
- } catch (e) {
66
- setError(errorMessage(e));
67
- } finally {
68
- setBusy(false);
69
- }
70
- }
71
- return /* @__PURE__ */ jsxs("section", {
72
- className: "card",
73
- style: {
74
- marginTop: "1.5rem",
75
- padding: "1.25rem",
76
- minWidth: 0
77
- },
78
- "aria-labelledby": "notification-title",
79
- children: [
80
- /* @__PURE__ */ jsx("h2", {
81
- id: "notification-title",
82
- children: "Attention notifications"
83
- }),
84
- /* @__PURE__ */ jsx("p", {
85
- className: "muted",
86
- children: "Posts each new Attention item of the selected kinds to the bot's service topic, once. Items that were already open when you switch this on are not sent."
87
- }),
88
- error && /* @__PURE__ */ jsx("p", {
89
- role: "alert",
90
- children: error
91
- }),
92
- notice && /* @__PURE__ */ jsx("p", {
93
- role: "status",
94
- children: notice
95
- }),
96
- !state ? !error && /* @__PURE__ */ jsx("p", { children: "Loading notification settings…" }) : /* @__PURE__ */ jsxs("form", {
97
- onSubmit: (event) => {
98
- event.preventDefault();
99
- save();
100
- },
101
- children: [!state.telegramReady && /* @__PURE__ */ jsx("p", {
102
- className: "muted",
103
- children: "The bot is not running yet; notices go out once it is connected and activated."
104
- }), /* @__PURE__ */ jsxs("fieldset", {
105
- disabled: busy,
106
- style: {
107
- border: 0,
108
- padding: 0,
109
- minWidth: 0
110
- },
111
- children: [
112
- /* @__PURE__ */ jsxs("label", {
113
- style: {
114
- display: "block",
115
- marginBlock: ".75rem"
116
- },
117
- children: [
118
- /* @__PURE__ */ jsx("input", {
119
- type: "checkbox",
120
- checked: enabled,
121
- onChange: (event) => setEnabled(event.target.checked)
122
- }),
123
- " ",
124
- "Send Attention notifications to Telegram"
125
- ]
126
- }),
127
- /* @__PURE__ */ jsxs("fieldset", {
128
- style: {
129
- marginBlock: "1rem",
130
- minWidth: 0
131
- },
132
- children: [/* @__PURE__ */ jsx("legend", { children: "Kinds" }), Object.keys(kinds).map((kind) => /* @__PURE__ */ jsxs("label", {
133
- style: {
134
- display: "block",
135
- marginBlock: ".5rem"
136
- },
137
- children: [
138
- /* @__PURE__ */ jsx("input", {
139
- type: "checkbox",
140
- checked: selected.includes(kind),
141
- onChange: (event) => setSelected(event.target.checked ? [...selected, kind] : selected.filter((value) => value !== kind))
142
- }),
143
- " ",
144
- kinds[kind]
145
- ]
146
- }, kind))]
147
- }),
148
- /* @__PURE__ */ jsxs("label", {
149
- style: {
150
- display: "block",
151
- marginBlock: ".75rem"
152
- },
153
- children: [
154
- /* @__PURE__ */ jsx("input", {
155
- type: "checkbox",
156
- checked: quiet,
157
- onChange: (event) => setQuiet(event.target.checked)
158
- }),
159
- " ",
160
- "Quiet hours (notices wait until they end)"
161
- ]
162
- }),
163
- quiet && /* @__PURE__ */ jsxs("div", {
164
- style: {
165
- display: "flex",
166
- flexWrap: "wrap",
167
- gap: "1rem",
168
- alignItems: "end"
169
- },
170
- children: [
171
- /* @__PURE__ */ jsxs("label", { children: [
172
- "From",
173
- " ",
174
- /* @__PURE__ */ jsx("input", {
175
- type: "time",
176
- value: start,
177
- required: true,
178
- onChange: (event) => setStart(event.target.value)
179
- })
180
- ] }),
181
- /* @__PURE__ */ jsxs("label", { children: [
182
- "To",
183
- " ",
184
- /* @__PURE__ */ jsx("input", {
185
- type: "time",
186
- value: end,
187
- required: true,
188
- onChange: (event) => setEnd(event.target.value)
189
- })
190
- ] }),
191
- /* @__PURE__ */ jsxs("label", {
192
- style: {
193
- display: "grid",
194
- gap: ".35rem",
195
- minWidth: 0
196
- },
197
- children: ["Timezone", /* @__PURE__ */ jsx("input", {
198
- value: timezone,
199
- onChange: (event) => setTimezone(event.target.value),
200
- placeholder: "Europe/Warsaw",
201
- required: true,
202
- style: {
203
- maxWidth: "100%",
204
- minWidth: 0
205
- }
206
- })]
207
- })
208
- ]
209
- }),
210
- /* @__PURE__ */ jsx("div", {
211
- style: { marginTop: "1rem" },
212
- children: /* @__PURE__ */ jsx(Button, {
213
- variant: "primary",
214
- type: "submit",
215
- disabled: !selected.length,
216
- children: "Save"
217
- })
218
- })
219
- ]
220
- })]
221
- })
222
- ]
223
- });
224
- }
225
- //#endregion
226
- //#region src/routes/config/telegram.tsx?tsr-split=component
227
- var BASE = "/api/config/telegram";
228
- function TelegramIntegrationPage() {
229
- const initial = Route.useLoaderData();
230
- const router = useRouter();
231
- const [token, setToken] = useState("");
232
- const [chatId, setChatId] = useState(initial.chatId);
233
- const [saving, setSaving] = useState(false);
234
- const [saveError, setSaveError] = useState(null);
235
- const [saveOk, setSaveOk] = useState(false);
236
- const [confirmDisconnect, setConfirmDisconnect] = useState(false);
237
- const [health, setHealth] = useState(null);
238
- const [checking, setChecking] = useState(false);
239
- const [restartNote, setRestartNote] = useState(null);
240
- const [restartError, setRestartError] = useState(null);
241
- async function save(e) {
242
- e.preventDefault();
243
- if (initial.configured && token.trim().length === 0) {
244
- setSaveOk(false);
245
- setSaveError(chatId.trim() === initial.chatId ? "Nothing changed. Paste a replacement token to update credentials." : "Paste the bot token again when changing the supergroup, so the existing secret is never cleared or reused silently.");
246
- return;
247
- }
248
- setSaving(true);
249
- setSaveError(null);
250
- setSaveOk(false);
251
- try {
252
- await api(BASE, {
253
- method: "PUT",
254
- body: {
255
- botToken: token,
256
- chatId
257
- }
258
- });
259
- setToken("");
260
- setSaveOk(true);
261
- await router.invalidate();
262
- } catch (e) {
263
- setSaveError(errorMessage(e));
264
- } finally {
265
- setSaving(false);
266
- }
267
- }
268
- async function disconnect() {
269
- await api(BASE, { method: "DELETE" });
270
- setToken("");
271
- setChatId("");
272
- setHealth(null);
273
- setSaveOk(false);
274
- setSaveError(null);
275
- await router.invalidate();
276
- }
277
- async function restartBot() {
278
- setChecking(true);
279
- setRestartNote(null);
280
- setRestartError(null);
281
- try {
282
- await api(`${BASE}/restart`, { method: "POST" });
283
- setHealth(null);
284
- setRestartNote("Restarting… run the preflight in a few seconds to see the bot state.");
285
- } catch (e) {
286
- setRestartError(errorMessage(e));
287
- } finally {
288
- setChecking(false);
289
- }
290
- }
291
- async function runHealth() {
292
- setChecking(true);
293
- setHealth(null);
294
- setRestartNote(null);
295
- setRestartError(null);
296
- try {
297
- setHealth(await api(`${BASE}/health`));
298
- } catch (e) {
299
- setHealth({
300
- configured: true,
301
- preflight: null,
302
- error: {
303
- step: "getMe",
304
- message: errorMessage(e)
305
- },
306
- polling: null
307
- });
308
- } finally {
309
- setChecking(false);
310
- }
311
- }
312
- return /* @__PURE__ */ jsxs(ConfigPage, {
313
- title: "Telegram",
314
- description: "Connect one forum-supergroup bot with one topic per agent, so conversations stay reachable from your phone.",
315
- size: "narrow",
316
- children: [
317
- initial.migratedChatId && /* @__PURE__ */ jsx(MigrationBanner, { toChatId: initial.migratedChatId }),
318
- /* @__PURE__ */ jsxs("section", {
319
- className: "rounded-lg border bg-card p-5",
320
- children: [
321
- /* @__PURE__ */ jsx("h3", {
322
- className: "text-sm font-semibold uppercase tracking-wide text-muted-foreground mb-3",
323
- children: "Credentials"
324
- }),
325
- initial.configured && /* @__PURE__ */ jsxs("p", {
326
- className: "text-xs text-success mb-3",
327
- children: [
328
- "✓ Stored: ",
329
- /* @__PURE__ */ jsx("code", {
330
- className: "font-mono",
331
- children: initial.botTokenPreview
332
- }),
333
- " ",
334
- initial.chatId && /* @__PURE__ */ jsxs(Fragment$1, { children: ["· chat ", /* @__PURE__ */ jsx("code", {
335
- className: "font-mono",
336
- children: initial.chatId
337
- })] })
338
- ]
339
- }),
340
- /* @__PURE__ */ jsxs("form", {
341
- onSubmit: save,
342
- className: "space-y-3",
343
- children: [
344
- /* @__PURE__ */ jsxs("label", {
345
- className: "block",
346
- children: [
347
- /* @__PURE__ */ jsx("span", {
348
- className: "block text-sm font-medium mb-1",
349
- children: "Bot token"
350
- }),
351
- /* @__PURE__ */ jsx("input", {
352
- type: "password",
353
- autoComplete: "off",
354
- value: token,
355
- onChange: (e) => {
356
- setToken(e.target.value);
357
- setSaveError(null);
358
- },
359
- placeholder: initial.configured ? "(leave blank to keep stored value)" : "1234567890:ABC...",
360
- className: "w-full rounded-md border bg-background px-2 py-1.5 font-mono text-sm outline-none focus:ring-2 focus:ring-ring/30",
361
- required: !initial.configured
362
- }),
363
- /* @__PURE__ */ jsxs("p", {
364
- className: "text-xs text-muted-foreground mt-1",
365
- children: [
366
- "From @BotFather → /newbot. Disable Privacy Mode in",
367
- " ",
368
- /* @__PURE__ */ jsx("em", { children: "Bot Settings → Group Privacy → Turn off" }),
369
- "."
370
- ]
371
- }),
372
- initial.configured && /* @__PURE__ */ jsx("p", {
373
- className: "mt-1 text-xs text-muted-foreground",
374
- children: "Blank preserves the stored token. To remove it, use clear credentials and confirm the integration shutdown."
375
- })
376
- ]
377
- }),
378
- /* @__PURE__ */ jsxs("label", {
379
- className: "block",
380
- children: [
381
- /* @__PURE__ */ jsx("span", {
382
- className: "block text-sm font-medium mb-1",
383
- children: "Supergroup chat ID"
384
- }),
385
- /* @__PURE__ */ jsx("input", {
386
- type: "text",
387
- value: chatId,
388
- onChange: (e) => {
389
- setChatId(e.target.value);
390
- setSaveError(null);
391
- },
392
- placeholder: "-1001234567890",
393
- className: "w-full rounded-md border bg-background px-2 py-1.5 font-mono text-sm outline-none focus:ring-2 focus:ring-ring/30",
394
- required: true
395
- }),
396
- /* @__PURE__ */ jsxs("p", {
397
- className: "text-xs text-muted-foreground mt-1",
398
- children: [
399
- "Forum-enabled supergroup the bot is admin in (with",
400
- " ",
401
- /* @__PURE__ */ jsx("code", {
402
- className: "font-mono",
403
- children: "can_manage_topics"
404
- }),
405
- ")."
406
- ]
407
- })
408
- ]
409
- }),
410
- /* @__PURE__ */ jsxs("div", {
411
- className: "flex flex-wrap items-center gap-3 pt-1",
412
- children: [
413
- /* @__PURE__ */ jsx(Button, {
414
- variant: "primary",
415
- type: "submit",
416
- disabled: saving,
417
- children: saving ? "saving…" : "save credentials"
418
- }),
419
- initial.configured && /* @__PURE__ */ jsx(Button, {
420
- variant: "danger",
421
- onClick: () => setConfirmDisconnect(true),
422
- children: "clear credentials"
423
- }),
424
- saveOk && /* @__PURE__ */ jsx("span", {
425
- className: "text-xs text-success",
426
- children: "saved ✓"
427
- }),
428
- saveError && /* @__PURE__ */ jsxs("span", {
429
- role: "alert",
430
- className: "text-xs text-danger",
431
- children: ["error: ", saveError]
432
- })
433
- ]
434
- })
435
- ]
436
- })
437
- ]
438
- }),
439
- /* @__PURE__ */ jsxs("section", {
440
- className: "rounded-lg border bg-card p-5",
441
- children: [
442
- /* @__PURE__ */ jsxs("div", {
443
- className: "mb-3 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",
444
- children: [/* @__PURE__ */ jsx("h3", {
445
- className: "text-sm font-semibold uppercase tracking-wide text-muted-foreground",
446
- children: "Preflight checks"
447
- }), /* @__PURE__ */ jsxs("div", {
448
- className: "flex flex-wrap gap-2",
449
- children: [/* @__PURE__ */ jsx(Button, {
450
- variant: "ghost",
451
- onClick: runHealth,
452
- disabled: checking || !initial.configured,
453
- children: checking ? "checking…" : "run preflight"
454
- }), /* @__PURE__ */ jsx(Button, {
455
- variant: "ghost",
456
- onClick: restartBot,
457
- disabled: checking || !initial.configured,
458
- children: "restart bot"
459
- })]
460
- })]
461
- }),
462
- restartNote && /* @__PURE__ */ jsx("p", {
463
- className: "mb-3 text-xs text-muted-foreground",
464
- children: restartNote
465
- }),
466
- restartError && /* @__PURE__ */ jsxs("p", {
467
- role: "alert",
468
- className: "mb-3 text-xs text-danger",
469
- children: ["error: ", restartError]
470
- }),
471
- !initial.configured && /* @__PURE__ */ jsx("p", {
472
- className: "text-xs text-muted-foreground italic",
473
- children: "Save credentials above first."
474
- }),
475
- initial.configured && !health && !checking && /* @__PURE__ */ jsxs("p", {
476
- className: "text-xs text-muted-foreground italic",
477
- children: [
478
- "Click ",
479
- /* @__PURE__ */ jsx("em", { children: "run preflight" }),
480
- " to validate the stored credentials against the Telegram Bot API."
481
- ]
482
- }),
483
- health && /* @__PURE__ */ jsx(PreflightResult, { health }),
484
- health?.polling && /* @__PURE__ */ jsx(PollingState, { polling: health.polling })
485
- ]
486
- }),
487
- initial.configured && /* @__PURE__ */ jsx(OwnerPairingCard, {}),
488
- /* @__PURE__ */ jsx(NotificationSettings, {}),
489
- initial.configured && /* @__PURE__ */ jsx(AccessControlCard, {}),
490
- /* @__PURE__ */ jsx(ConfirmDialog, {
491
- open: confirmDisconnect,
492
- title: "Disconnect Telegram?",
493
- description: /* @__PURE__ */ jsx("p", { children: "This permanently removes the saved bot token and supergroup ID. Telegram polling, ingress, and outbound delivery stop until new credentials are saved and pairing is completed again." }),
494
- confirmLabel: "clear credentials and disconnect",
495
- onConfirm: async () => {
496
- try {
497
- await disconnect();
498
- } catch (error) {
499
- setSaveError(errorMessage(error));
500
- throw error;
501
- }
502
- },
503
- onOpenChange: setConfirmDisconnect
504
- })
505
- ]
506
- });
507
- }
508
- function OwnerPairingCard() {
509
- const [status, setStatus] = useState(null);
510
- const [code, setCode] = useState(null);
511
- const [err, setErr] = useState(null);
512
- const [confirmReset, setConfirmReset] = useState(false);
513
- const load = async () => setStatus(await api(`${BASE}/pairing`));
514
- useEffect(() => {
515
- load().catch((e) => setErr(errorMessage(e)));
516
- }, []);
517
- async function createChallenge() {
518
- setErr(null);
519
- try {
520
- const challenge = await api(`${BASE}/pairing/challenge`, { method: "POST" });
521
- setCode(challenge.code);
522
- setStatus(challenge);
523
- } catch (e) {
524
- setErr(errorMessage(e));
525
- }
526
- }
527
- async function cancelChallenge() {
528
- await api(`${BASE}/pairing/challenge`, { method: "DELETE" });
529
- setCode(null);
530
- await load();
531
- }
532
- async function resetOwner() {
533
- await api(`${BASE}/pairing/reset`, { body: { confirm: true } });
534
- setCode(null);
535
- await load();
536
- }
537
- return /* @__PURE__ */ jsxs("section", {
538
- className: "rounded-lg border bg-card p-5",
539
- children: [
540
- /* @__PURE__ */ jsx("h3", {
541
- className: "text-sm font-semibold uppercase tracking-wide text-muted-foreground mb-1",
542
- children: "Owner pairing"
543
- }),
544
- /* @__PURE__ */ jsxs("p", {
545
- className: "text-xs text-muted-foreground mb-3",
546
- children: [
547
- "Telegram stays closed until one owner consumes a short-lived code in the configured",
548
- " ",
549
- /* @__PURE__ */ jsx("code", {
550
- className: "font-mono",
551
- children: "⚙ bazilion"
552
- }),
553
- " service topic."
554
- ]
555
- }),
556
- status?.paired ? /* @__PURE__ */ jsxs("div", {
557
- className: "flex flex-wrap items-center gap-3",
558
- children: [/* @__PURE__ */ jsx("span", {
559
- className: "text-sm text-success",
560
- children: "✓ owner paired"
561
- }), /* @__PURE__ */ jsx(Button, {
562
- variant: "danger",
563
- onClick: () => setConfirmReset(true),
564
- children: "reset owner"
565
- })]
566
- }) : /* @__PURE__ */ jsxs("div", {
567
- className: "space-y-2",
568
- children: [
569
- /* @__PURE__ */ jsx("p", {
570
- className: "text-sm text-warning",
571
- children: "Unpaired — all Telegram ingress is closed."
572
- }),
573
- code ? /* @__PURE__ */ jsxs("div", {
574
- className: "rounded-md border bg-muted/30 p-3 text-sm",
575
- children: [
576
- "Send ",
577
- /* @__PURE__ */ jsxs("code", {
578
- className: "font-mono",
579
- children: ["/pair ", code]
580
- }),
581
- " in the service topic. This code is shown once and expires in ten minutes."
582
- ]
583
- }) : null,
584
- /* @__PURE__ */ jsxs("div", {
585
- className: "flex flex-wrap gap-2",
586
- children: [/* @__PURE__ */ jsx(Button, {
587
- variant: "primary",
588
- onClick: createChallenge,
589
- children: "generate pairing code"
590
- }), status?.challengeActive && /* @__PURE__ */ jsx(Button, {
591
- variant: "ghost",
592
- onClick: () => void cancelChallenge().catch((error) => setErr(errorMessage(error))),
593
- children: "cancel code"
594
- })]
595
- })
596
- ]
597
- }),
598
- err && /* @__PURE__ */ jsx("p", {
599
- role: "alert",
600
- className: "mt-2 text-xs text-danger",
601
- children: err
602
- }),
603
- /* @__PURE__ */ jsx(ConfirmDialog, {
604
- open: confirmReset,
605
- title: "Revoke the paired Telegram owner?",
606
- description: /* @__PURE__ */ jsx("p", { children: "This immediately revokes the current owner and closes all Telegram ingress. No one can use the bot until a new one-time pairing code is generated and consumed." }),
607
- confirmLabel: "revoke owner and close ingress",
608
- onConfirm: async () => {
609
- try {
610
- await resetOwner();
611
- } catch (error) {
612
- setErr(errorMessage(error));
613
- throw error;
614
- }
615
- },
616
- onOpenChange: setConfirmReset
617
- })
618
- ]
619
- });
620
- }
621
- function AccessControlCard() {
622
- const [users, setUsers] = useState(null);
623
- const [userId, setUserId] = useState("");
624
- const [label, setLabel] = useState("");
625
- const [busy, setBusy] = useState(false);
626
- const [err, setErr] = useState(null);
627
- const [removeTarget, setRemoveTarget] = useState(null);
628
- async function load() {
629
- try {
630
- setUsers(await api(`${BASE}/acl`));
631
- } catch (e) {
632
- setErr(errorMessage(e));
633
- }
634
- }
635
- useEffect(() => {
636
- load();
637
- }, []);
638
- async function add(e) {
639
- e.preventDefault();
640
- const id = Number(userId);
641
- if (!Number.isInteger(id)) {
642
- setErr("user id must be an integer");
643
- return;
644
- }
645
- setBusy(true);
646
- setErr(null);
647
- try {
648
- await api(`${BASE}/acl`, { body: {
649
- userId: id,
650
- label: label.trim() || null
651
- } });
652
- setUserId("");
653
- setLabel("");
654
- await load();
655
- } catch (e) {
656
- setErr(errorMessage(e));
657
- } finally {
658
- setBusy(false);
659
- }
660
- }
661
- async function remove(id) {
662
- setErr(null);
663
- await api(`${BASE}/acl/${id}`, { method: "DELETE" });
664
- await load();
665
- }
666
- return /* @__PURE__ */ jsxs("section", {
667
- className: "rounded-lg border bg-card p-5",
668
- children: [
669
- /* @__PURE__ */ jsx("h3", {
670
- className: "text-sm font-semibold uppercase tracking-wide text-muted-foreground mb-1",
671
- children: "Access control"
672
- }),
673
- /* @__PURE__ */ jsxs("p", {
674
- className: "text-xs text-muted-foreground mb-3",
675
- children: [
676
- "Allowlisted Telegram users can use the bot (commands + chat). An empty list is closed; ownership begins only through the one-time pairing flow. Users find their id via",
677
- " ",
678
- /* @__PURE__ */ jsx("code", {
679
- className: "font-mono",
680
- children: "/whoami"
681
- }),
682
- "."
683
- ]
684
- }),
685
- users === null ? /* @__PURE__ */ jsx("p", {
686
- className: "text-xs text-muted-foreground italic",
687
- children: "loading…"
688
- }) : users.length === 0 ? /* @__PURE__ */ jsx("p", {
689
- className: "text-xs text-warning mb-3",
690
- children: "Closed — no paired owner or allowlisted members."
691
- }) : /* @__PURE__ */ jsx("ul", {
692
- className: "mb-3 space-y-1 text-sm",
693
- children: users.map((u) => /* @__PURE__ */ jsxs("li", {
694
- className: "flex flex-wrap items-center gap-2",
695
- children: [
696
- /* @__PURE__ */ jsx("code", {
697
- className: "font-mono",
698
- children: u.userId
699
- }),
700
- /* @__PURE__ */ jsxs("span", {
701
- className: "text-muted-foreground",
702
- children: [
703
- u.label ?? (u.username ? `@${u.username}` : "—"),
704
- " · ",
705
- u.role
706
- ]
707
- }),
708
- u.role !== "owner" && /* @__PURE__ */ jsx(Button, {
709
- variant: "danger",
710
- className: "text-xs",
711
- onClick: () => setRemoveTarget(u),
712
- children: "remove"
713
- })
714
- ]
715
- }, u.userId))
716
- }),
717
- /* @__PURE__ */ jsxs("form", {
718
- onSubmit: add,
719
- className: "flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-end",
720
- children: [
721
- /* @__PURE__ */ jsxs("label", {
722
- className: "m-0 flex flex-col gap-1 text-xs font-medium text-foreground",
723
- children: ["Telegram user ID", /* @__PURE__ */ jsx("input", {
724
- value: userId,
725
- onChange: (e) => setUserId(e.target.value),
726
- placeholder: "123456789",
727
- inputMode: "numeric",
728
- className: "w-full rounded-md border bg-background px-2 py-1 font-mono text-sm sm:w-32"
729
- })]
730
- }),
731
- /* @__PURE__ */ jsxs("label", {
732
- className: "m-0 flex flex-col gap-1 text-xs font-medium text-foreground",
733
- children: [
734
- "Label ",
735
- /* @__PURE__ */ jsx("span", {
736
- className: "font-normal text-muted-foreground",
737
- children: "(optional)"
738
- }),
739
- /* @__PURE__ */ jsx("input", {
740
- value: label,
741
- onChange: (e) => setLabel(e.target.value),
742
- placeholder: "e.g. Pat",
743
- className: "w-full rounded-md border bg-background px-2 py-1 text-sm sm:w-40"
744
- })
745
- ]
746
- }),
747
- /* @__PURE__ */ jsx(Button, {
748
- variant: "ghost",
749
- type: "submit",
750
- disabled: busy,
751
- children: "add"
752
- }),
753
- err && /* @__PURE__ */ jsx("span", {
754
- role: "alert",
755
- className: "text-xs text-danger",
756
- children: err
757
- })
758
- ]
759
- }),
760
- /* @__PURE__ */ jsx(ConfirmDialog, {
761
- open: removeTarget !== null,
762
- title: `Remove ${removeTarget?.label ?? removeTarget?.username ?? removeTarget?.userId ?? ""}?`,
763
- description: /* @__PURE__ */ jsxs("p", { children: [
764
- "Telegram user ",
765
- /* @__PURE__ */ jsx("code", {
766
- className: "font-mono",
767
- children: removeTarget?.userId
768
- }),
769
- " immediately loses command and chat access. Their Telegram account is not changed, and they can be allowlisted again later."
770
- ] }),
771
- confirmLabel: "remove Telegram access",
772
- onConfirm: async () => {
773
- if (!removeTarget) return;
774
- try {
775
- await remove(removeTarget.userId);
776
- } catch (error) {
777
- setErr(errorMessage(error));
778
- throw error;
779
- }
780
- },
781
- onOpenChange: (open) => {
782
- if (!open) setRemoveTarget(null);
783
- }
784
- })
785
- ]
786
- });
787
- }
788
- function MigrationBanner({ toChatId }) {
789
- const [busy, setBusy] = useState(false);
790
- const [err, setErr] = useState(null);
791
- async function reconnect() {
792
- setBusy(true);
793
- setErr(null);
794
- try {
795
- await api(`${BASE}/reconnect`, { method: "POST" });
796
- window.location.reload();
797
- } catch (e) {
798
- setErr(errorMessage(e));
799
- setBusy(false);
800
- }
801
- }
802
- return /* @__PURE__ */ jsxs("div", {
803
- className: "rounded-md border-2 border-danger/25 bg-danger/10 px-4 py-3 text-sm",
804
- children: [
805
- /* @__PURE__ */ jsx("div", {
806
- className: "font-semibold text-danger mb-1",
807
- children: "Supergroup chat id changed"
808
- }),
809
- /* @__PURE__ */ jsxs("p", {
810
- className: "text-danger mb-2",
811
- children: [
812
- "Telegram migrated this supergroup to a new chat id (",
813
- /* @__PURE__ */ jsx("code", {
814
- className: "font-mono",
815
- children: toChatId
816
- }),
817
- "). The bot is still pointed at the old id. Reconnect to repoint it and re-create the ",
818
- /* @__PURE__ */ jsx("code", {
819
- className: "font-mono",
820
- children: "⚙ bazilion"
821
- }),
822
- " ",
823
- "service chat in the new group. Agent topic bindings will reconcile on next use."
824
- ]
825
- }),
826
- /* @__PURE__ */ jsx(Button, {
827
- variant: "primary",
828
- onClick: reconnect,
829
- disabled: busy,
830
- children: busy ? "reconnecting…" : `Reconnect to ${toChatId}`
831
- }),
832
- err && /* @__PURE__ */ jsx("span", {
833
- role: "alert",
834
- className: "ml-3 text-xs text-danger",
835
- children: err
836
- })
837
- ]
838
- });
839
- }
840
- function PollingState({ polling }) {
841
- const startedAt = polling.startedAt ? new Date(polling.startedAt).toISOString() : null;
842
- const lastPoll = polling.lastSuccessfulPollAt ? new Date(polling.lastSuccessfulPollAt).toISOString() : null;
843
- return /* @__PURE__ */ jsxs("div", {
844
- className: "mt-4 rounded-md border bg-muted/30 px-3 py-2 text-xs space-y-1",
845
- children: [
846
- /* @__PURE__ */ jsx("p", {
847
- className: "font-semibold uppercase tracking-wide text-muted-foreground",
848
- children: "Polling state"
849
- }),
850
- /* @__PURE__ */ jsxs("div", {
851
- className: "flex flex-wrap gap-x-4 gap-y-1 font-mono",
852
- children: [
853
- /* @__PURE__ */ jsx("span", {
854
- className: polling.running ? "text-success" : "text-danger",
855
- children: polling.running ? "running" : "stopped"
856
- }),
857
- /* @__PURE__ */ jsx("span", {
858
- className: polling.activated ? "text-success" : "text-warning",
859
- children: polling.activated ? "activated" : "awaiting activation"
860
- }),
861
- polling.lastUpdateId !== null && /* @__PURE__ */ jsxs("span", { children: ["last update ", polling.lastUpdateId] }),
862
- startedAt && /* @__PURE__ */ jsxs("span", { children: ["started ", startedAt] }),
863
- lastPoll && /* @__PURE__ */ jsxs("span", { children: ["last poll ", lastPoll] })
864
- ]
865
- }),
866
- polling.error && /* @__PURE__ */ jsxs("p", {
867
- role: "alert",
868
- className: "text-danger",
869
- children: ["error: ", polling.error]
870
- })
871
- ]
872
- });
873
- }
874
- function PreflightResult({ health }) {
875
- if (health.error) return /* @__PURE__ */ jsxs("div", {
876
- role: "alert",
877
- className: "rounded-md border border-danger/25 bg-danger/10 px-3 py-2 text-sm",
878
- children: [
879
- /* @__PURE__ */ jsxs("p", {
880
- className: "font-semibold text-danger",
881
- children: ["Failed at ", /* @__PURE__ */ jsx("code", {
882
- className: "font-mono",
883
- children: health.error.step
884
- })]
885
- }),
886
- /* @__PURE__ */ jsx("p", {
887
- className: "text-danger mt-1",
888
- children: health.error.message
889
- }),
890
- hintFor(health.error.step)
891
- ]
892
- });
893
- if (!health.preflight) return /* @__PURE__ */ jsx("p", {
894
- role: "status",
895
- className: "text-xs text-muted-foreground italic",
896
- children: "No preflight data."
897
- });
898
- const p = health.preflight;
899
- return /* @__PURE__ */ jsxs("ul", {
900
- role: "status",
901
- "aria-live": "polite",
902
- "aria-atomic": "true",
903
- className: "space-y-1.5",
904
- children: [
905
- /* @__PURE__ */ jsxs(Check, {
906
- ok: p.botUsername.length > 0,
907
- label: "Bot identity",
908
- children: ["@", p.botUsername]
909
- }),
910
- /* @__PURE__ */ jsx(Check, {
911
- ok: p.chatTitle.length > 0,
912
- label: "Supergroup reachable",
913
- children: p.chatTitle
914
- }),
915
- /* @__PURE__ */ jsx(Check, {
916
- ok: p.isForum,
917
- label: "Forum topics enabled",
918
- children: p.isForum ? "is_forum: true" : "is_forum: false — the supergroup owner must enable Topics in group settings"
919
- }),
920
- /* @__PURE__ */ jsx(Check, {
921
- ok: p.hasManageTopics,
922
- label: "Bot has can_manage_topics",
923
- children: p.hasManageTopics ? "admin with can_manage_topics" : "promote the bot to admin in the supergroup with the \"Manage topics\" permission"
924
- }),
925
- /* @__PURE__ */ jsx(Check, {
926
- ok: p.privacyModeOff,
927
- label: "Privacy Mode is OFF",
928
- children: p.privacyModeOff ? "can_read_all_group_messages: true" : "BotFather → /mybots → select bot → Bot Settings → Group Privacy → Turn off"
929
- }),
930
- /* @__PURE__ */ jsx(Check, {
931
- ok: p.chatIsPrivate,
932
- label: "Supergroup is private",
933
- children: p.chatIsPrivate ? "no public @username" : "public groups expose topic content to readers"
934
- }),
935
- /* @__PURE__ */ jsxs("li", {
936
- className: "text-sm text-muted-foreground",
937
- children: [
938
- "Group members: ",
939
- p.memberCount ?? "unknown",
940
- " — everyone in the group can read the agents' replies."
941
- ]
942
- }),
943
- p.ownerPresent !== null && /* @__PURE__ */ jsx(Check, {
944
- ok: p.ownerPresent,
945
- label: "Paired owner is present",
946
- children: p.ownerPresent ? "owner membership confirmed" : "owner missing — Telegram ingress is degraded"
947
- })
948
- ]
949
- });
950
- }
951
- function Check({ ok, label, children }) {
952
- return /* @__PURE__ */ jsxs("li", {
953
- className: "flex items-start gap-2 text-sm",
954
- children: [/* @__PURE__ */ jsx("span", {
955
- className: `mt-0.5 inline-flex h-4 w-4 items-center justify-center rounded-full text-[10px] font-bold leading-none ${ok ? "bg-success/10 text-success" : "bg-danger/10 text-danger"}`,
956
- "aria-hidden": true,
957
- children: ok ? "✓" : "✕"
958
- }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("span", {
959
- className: "font-medium",
960
- children: label
961
- }), /* @__PURE__ */ jsx("span", {
962
- className: `ml-2 text-xs ${ok ? "text-muted-foreground" : "text-danger"}`,
963
- children
964
- })] })]
965
- });
966
- }
967
- function hintFor(step) {
968
- switch (step) {
969
- case "getMe": return /* @__PURE__ */ jsx("p", {
970
- className: "text-xs text-danger mt-1",
971
- children: "The token is invalid or revoked. Re-issue with @BotFather → /token, or paste a fresh one above."
972
- });
973
- case "getChat": return /* @__PURE__ */ jsx("p", {
974
- className: "text-xs text-danger mt-1",
975
- children: "The chat id either doesn't exist, points at a basic group (not a supergroup), or the bot isn't a member. Forward any message from the supergroup to the bot to double-check the id, then add the bot to the group."
976
- });
977
- case "getChatMember": return /* @__PURE__ */ jsx("p", {
978
- className: "text-xs text-danger mt-1",
979
- children: "The bot is in the chat but the membership lookup failed. Usually means the bot was kicked or the chat id was migrated — confirm the bot is still in the supergroup."
980
- });
981
- }
982
- }
983
- //#endregion
984
- export { TelegramIntegrationPage as component };