bazilion 0.5.1 → 0.7.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 (122) hide show
  1. package/README.md +17 -12
  2. package/dist/cli.js +383 -152
  3. package/dist/cli.js.map +1 -1
  4. package/dist/daemon.js +238 -14064
  5. package/dist/daemon.js.map +1 -1
  6. package/dist/web/client/assets/AgentAvatar-JYijLvZ2.js +1 -0
  7. package/dist/web/client/assets/AgentTabs-DioGqUVR.js +1 -0
  8. package/dist/web/client/assets/Button-ByiV6fpd.js +1 -0
  9. package/dist/web/client/assets/ChatPane-DzEgOEqS.js +74 -0
  10. package/dist/web/client/assets/ConfigTabs-pY-V0Rie.js +1 -0
  11. package/dist/web/client/assets/FieldRow-CNKma5LE.js +1 -0
  12. package/dist/web/client/assets/MembersEditor-C6UpqDdV.js +1 -0
  13. package/dist/web/client/assets/SpawnTeamModal-BEkNCKXm.js +1 -0
  14. package/dist/web/client/assets/TemplatesTabs-Da7mg9FI.js +1 -0
  15. package/dist/web/client/assets/_id-BdKmo0gb.js +1 -0
  16. package/dist/web/client/assets/_id-LT6Ejjr0.js +1 -0
  17. package/dist/web/client/assets/_id-MR2XjWh0.js +1 -0
  18. package/dist/web/client/assets/_id-_6jIt0_-.js +1 -0
  19. package/dist/web/client/assets/agents-0arKbVYG.js +1 -0
  20. package/dist/web/client/assets/config-BSAVT-17.js +3 -0
  21. package/dist/web/client/assets/groups-BqTkhHes.js +1 -0
  22. package/dist/web/client/assets/inbox-ozoCXzr5.js +1 -0
  23. package/dist/web/client/assets/index-iayCEuU2.js +12 -0
  24. package/dist/web/client/assets/jsx-runtime-DGeXAQPT.js +1 -0
  25. package/dist/web/client/assets/login-D8lNr2SX.js +1 -0
  26. package/dist/web/client/assets/mcp-BLnngDsj.js +1 -0
  27. package/dist/web/client/assets/memory-D1GQjEvN.js +1 -0
  28. package/dist/web/client/assets/preload-helper-CvnapA2_.js +1 -0
  29. package/dist/web/client/assets/profile-groups-C2yJPTaE.js +1 -0
  30. package/dist/web/client/assets/profiles-BV7AAZjj.js +1 -0
  31. package/dist/web/client/assets/routes-DSHQLA7K.js +1 -0
  32. package/dist/web/client/assets/services-BbCJe1Du.js +1 -0
  33. package/dist/web/client/assets/skills-C6czKR5I.js +1 -0
  34. package/dist/web/client/assets/styles-C06axZZk.css +2 -0
  35. package/dist/web/client/assets/telegram-gE4j8gte.js +1 -0
  36. package/dist/web/client/assets/tokens-D2_O9ARe.js +1 -0
  37. package/dist/web/client/assets/triggers-WljnfEfJ.js +1 -0
  38. package/dist/web/client/assets/welcome-Dn-zvmBE.js +1 -0
  39. package/dist/web/client/assets/wire-constants-BkT5-597.js +1 -0
  40. package/dist/web/client/baziu.svg +8 -0
  41. package/dist/web/server/assets/AgentAvatar-8gTAy_tP.js +37 -0
  42. package/dist/web/server/assets/AgentTabs-BOjTN7QF.js +34 -0
  43. package/dist/web/server/assets/Button-Dsnw22OF.js +17 -0
  44. package/dist/web/server/assets/ChatPane-BvpswYvF.js +1084 -0
  45. package/dist/web/server/assets/ConfigTabs-CyuxzesF.js +41 -0
  46. package/dist/web/server/assets/FieldRow-DwyqycWI.js +94 -0
  47. package/dist/web/server/assets/MembersEditor-BWQztvrX.js +131 -0
  48. package/dist/web/server/assets/Sidebar-DmEiewRN.js +529 -0
  49. package/dist/web/server/assets/SpawnTeamModal-dSN421k_.js +107 -0
  50. package/dist/web/server/assets/TemplatesTabs---7h5GYa.js +30 -0
  51. package/dist/web/server/assets/_id-81NrHA5d.js +16 -0
  52. package/dist/web/server/assets/_id-BKev9H1p.js +12 -0
  53. package/dist/web/server/assets/_id-BNwlbWHP.js +24 -0
  54. package/dist/web/server/assets/_id-BqnDy_Ca.js +16 -0
  55. package/dist/web/server/assets/_id-CRqqi8IE.js +161 -0
  56. package/dist/web/server/assets/_id-CXg-Blec.js +367 -0
  57. package/dist/web/server/assets/_id-CnQflrRv.js +16 -0
  58. package/dist/web/server/assets/_id-D0ytyXGY.js +662 -0
  59. package/dist/web/server/assets/_id-D8duqgd5.js +27 -0
  60. package/dist/web/server/assets/_id-DDixKEud.js +467 -0
  61. package/dist/web/server/assets/_id-D_Ew11ED.js +28 -0
  62. package/dist/web/server/assets/_id-Sjw0zhA6.js +38 -0
  63. package/dist/web/server/assets/_tanstack-start-manifest_v-DBlFH2gg.js +178 -0
  64. package/dist/web/server/assets/agents-C7SBPN0M.js +210 -0
  65. package/dist/web/server/assets/agents-ChcAJUI5.js +14 -0
  66. package/dist/web/server/assets/agents-k5QURC4I.js +26 -0
  67. package/dist/web/server/assets/auth-DzRAMwVt.js +26 -0
  68. package/dist/web/server/assets/config-Bq3o924J.js +12 -0
  69. package/dist/web/server/assets/config-CHaCv89D.js +19 -0
  70. package/dist/web/server/assets/config-CdVjqjin.js +391 -0
  71. package/dist/web/server/assets/createServerRpc-CeKECg65.js +12 -0
  72. package/dist/web/server/assets/createSsrRpc-ZBGxhl8t.js +16 -0
  73. package/dist/web/server/assets/daemon-client-2NRMzlTr.js +96 -0
  74. package/dist/web/server/assets/empty-plugin-adapters-DKUlnwwl.js +5 -0
  75. package/dist/web/server/assets/groups-CbSwND2r.js +12 -0
  76. package/dist/web/server/assets/groups-CeRRlZaZ.js +150 -0
  77. package/dist/web/server/assets/groups-pk4CYSuf.js +21 -0
  78. package/dist/web/server/assets/inbox-Bxb3W04M.js +27 -0
  79. package/dist/web/server/assets/inbox-CkiSvD14.js +42 -0
  80. package/dist/web/server/assets/inbox-DU27iHv_.js +133 -0
  81. package/dist/web/server/assets/login-CNznncgA.js +58 -0
  82. package/dist/web/server/assets/login-CQybKk7Y.js +74 -0
  83. package/dist/web/server/assets/mcp-BU_kKENi.js +268 -0
  84. package/dist/web/server/assets/mcp-BsFKEoXt.js +12 -0
  85. package/dist/web/server/assets/mcp-CKqwG4mt.js +12 -0
  86. package/dist/web/server/assets/memory-BaYnfm7K.js +28 -0
  87. package/dist/web/server/assets/memory-CQaqWnyM.js +284 -0
  88. package/dist/web/server/assets/memory-Ns2-Z31p.js +16 -0
  89. package/dist/web/server/assets/profile-groups-CiU06yN1.js +28 -0
  90. package/dist/web/server/assets/profile-groups-D21MYoLM.js +208 -0
  91. package/dist/web/server/assets/profile-groups-aoJleXHP.js +12 -0
  92. package/dist/web/server/assets/profiles-C6a3RKgu.js +26 -0
  93. package/dist/web/server/assets/profiles-CZ5NkmVw.js +12 -0
  94. package/dist/web/server/assets/profiles-LxcC_L6n.js +453 -0
  95. package/dist/web/server/assets/router-BpBZgRwn.js +460 -0
  96. package/dist/web/server/assets/routes-C61gBiXa.js +57 -0
  97. package/dist/web/server/assets/routes-Ce2VWrU9.js +33 -0
  98. package/dist/web/server/assets/routes-V9URcp1v.js +14 -0
  99. package/dist/web/server/assets/services-B91w2f-X.js +94 -0
  100. package/dist/web/server/assets/services-Ccc5s2bS.js +17 -0
  101. package/dist/web/server/assets/services-DhRiNeq0.js +12 -0
  102. package/dist/web/server/assets/skills-CFIWVg32.js +12 -0
  103. package/dist/web/server/assets/skills-CpsyR_WA.js +12 -0
  104. package/dist/web/server/assets/skills-dLyBZb3B.js +261 -0
  105. package/dist/web/server/assets/start-CYDpZ6cb.js +4 -0
  106. package/dist/web/server/assets/telegram-BdaUIjvs.js +12 -0
  107. package/dist/web/server/assets/telegram-DfAddLdv.js +583 -0
  108. package/dist/web/server/assets/telegram-T3l9KtiE.js +12 -0
  109. package/dist/web/server/assets/tokens-BCz3PSoT.js +12 -0
  110. package/dist/web/server/assets/tokens-CkKqrtk-.js +193 -0
  111. package/dist/web/server/assets/tokens-DdpnfV_Y.js +14 -0
  112. package/dist/web/server/assets/triggers-BcH_6PW1.js +26 -0
  113. package/dist/web/server/assets/triggers-BcTTwMfy.js +16 -0
  114. package/dist/web/server/assets/triggers-BzJG1nN5.js +191 -0
  115. package/dist/web/server/assets/welcome-CP4CZ9B6.js +85 -0
  116. package/dist/web/server/assets/wire-constants-Deb4NxBb.js +16 -0
  117. package/dist/web/server/server.js +5911 -0
  118. package/dist/web-server.js +42 -0
  119. package/dist/web-server.js.map +1 -0
  120. package/dist/worker.js +65 -2
  121. package/dist/worker.js.map +1 -1
  122. package/package.json +18 -12
@@ -0,0 +1,583 @@
1
+ import { t as Route } from "./telegram-T3l9KtiE.js";
2
+ import { t as ConfigTabs } from "./ConfigTabs-CyuxzesF.js";
3
+ import { t as Button } from "./Button-Dsnw22OF.js";
4
+ import { useEffect, useState } from "react";
5
+ import { useRouter } from "@tanstack/react-router";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ //#region src/routes/config/integrations/telegram.tsx?tsr-split=component
8
+ function TelegramIntegrationPage() {
9
+ const initial = Route.useLoaderData();
10
+ const router = useRouter();
11
+ const [token, setToken] = useState("");
12
+ const [chatId, setChatId] = useState(initial.chatId);
13
+ const [saving, setSaving] = useState(false);
14
+ const [saveError, setSaveError] = useState(null);
15
+ const [saveOk, setSaveOk] = useState(false);
16
+ const [health, setHealth] = useState(null);
17
+ const [checking, setChecking] = useState(false);
18
+ async function save(e) {
19
+ e.preventDefault();
20
+ setSaving(true);
21
+ setSaveError(null);
22
+ setSaveOk(false);
23
+ try {
24
+ const res = await fetch("/api/config/telegram", {
25
+ method: "PUT",
26
+ headers: { "content-type": "application/json" },
27
+ body: JSON.stringify({
28
+ botToken: token,
29
+ chatId
30
+ })
31
+ });
32
+ if (!res.ok) {
33
+ const j = await res.json().catch(() => ({}));
34
+ throw new Error(j.error ?? `${res.status} ${res.statusText}`);
35
+ }
36
+ setToken("");
37
+ setSaveOk(true);
38
+ await router.invalidate();
39
+ } catch (e) {
40
+ setSaveError(e.message);
41
+ } finally {
42
+ setSaving(false);
43
+ }
44
+ }
45
+ async function disconnect() {
46
+ if (!confirm("Clear the saved Telegram credentials?")) return;
47
+ try {
48
+ await fetch("/api/config/telegram", { method: "DELETE" });
49
+ setToken("");
50
+ setChatId("");
51
+ setHealth(null);
52
+ setSaveOk(false);
53
+ setSaveError(null);
54
+ await router.invalidate();
55
+ } catch (e) {
56
+ setSaveError(e.message);
57
+ }
58
+ }
59
+ async function runHealth() {
60
+ setChecking(true);
61
+ setHealth(null);
62
+ try {
63
+ setHealth(await (await fetch("/api/config/telegram/health")).json());
64
+ } catch (e) {
65
+ setHealth({
66
+ configured: true,
67
+ preflight: null,
68
+ error: {
69
+ step: "getMe",
70
+ message: e.message
71
+ },
72
+ polling: null
73
+ });
74
+ } finally {
75
+ setChecking(false);
76
+ }
77
+ }
78
+ return /* @__PURE__ */ jsxs("main", {
79
+ className: "mx-auto max-w-3xl px-6 py-8",
80
+ children: [
81
+ /* @__PURE__ */ jsx("h1", {
82
+ className: "font-serif text-3xl text-foreground mb-2",
83
+ children: "config"
84
+ }),
85
+ /* @__PURE__ */ jsx(ConfigTabs, { active: "integrations" }),
86
+ /* @__PURE__ */ jsxs("header", {
87
+ className: "mb-6",
88
+ children: [/* @__PURE__ */ jsx("h2", {
89
+ className: "text-xl font-semibold",
90
+ children: "Telegram"
91
+ }), /* @__PURE__ */ jsx("p", {
92
+ className: "text-muted-foreground text-sm",
93
+ children: "One forum-supergroup bot, one topic per agent. Talk to any of your agents from a phone."
94
+ })]
95
+ }),
96
+ /* @__PURE__ */ jsx(Step2Banner, {}),
97
+ initial.migratedChatId && /* @__PURE__ */ jsx(MigrationBanner, { toChatId: initial.migratedChatId }),
98
+ /* @__PURE__ */ jsxs("section", {
99
+ className: "rounded-lg border bg-card p-5 mb-6",
100
+ children: [
101
+ /* @__PURE__ */ jsx("h3", {
102
+ className: "text-sm font-semibold uppercase tracking-wide text-muted-foreground mb-3",
103
+ children: "Credentials"
104
+ }),
105
+ initial.configured && /* @__PURE__ */ jsxs("p", {
106
+ className: "text-xs text-emerald-700 mb-3",
107
+ children: [
108
+ "✓ Stored: ",
109
+ /* @__PURE__ */ jsx("code", {
110
+ className: "font-mono",
111
+ children: initial.botTokenPreview
112
+ }),
113
+ " ",
114
+ initial.chatId && /* @__PURE__ */ jsxs(Fragment, { children: ["· chat ", /* @__PURE__ */ jsx("code", {
115
+ className: "font-mono",
116
+ children: initial.chatId
117
+ })] })
118
+ ]
119
+ }),
120
+ /* @__PURE__ */ jsxs("form", {
121
+ onSubmit: save,
122
+ className: "space-y-3",
123
+ children: [
124
+ /* @__PURE__ */ jsxs("label", {
125
+ className: "block",
126
+ children: [
127
+ /* @__PURE__ */ jsx("span", {
128
+ className: "block text-sm font-medium mb-1",
129
+ children: "Bot token"
130
+ }),
131
+ /* @__PURE__ */ jsx("input", {
132
+ type: "password",
133
+ autoComplete: "off",
134
+ value: token,
135
+ onChange: (e) => setToken(e.target.value),
136
+ placeholder: initial.configured ? "(leave blank to keep stored value)" : "1234567890:ABC...",
137
+ 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",
138
+ required: !initial.configured
139
+ }),
140
+ /* @__PURE__ */ jsxs("p", {
141
+ className: "text-xs text-muted-foreground mt-1",
142
+ children: [
143
+ "From @BotFather → /newbot. Disable Privacy Mode in ",
144
+ /* @__PURE__ */ jsx("em", { children: "Bot Settings → Group Privacy → Turn off" }),
145
+ "."
146
+ ]
147
+ })
148
+ ]
149
+ }),
150
+ /* @__PURE__ */ jsxs("label", {
151
+ className: "block",
152
+ children: [
153
+ /* @__PURE__ */ jsx("span", {
154
+ className: "block text-sm font-medium mb-1",
155
+ children: "Supergroup chat ID"
156
+ }),
157
+ /* @__PURE__ */ jsx("input", {
158
+ type: "text",
159
+ value: chatId,
160
+ onChange: (e) => setChatId(e.target.value),
161
+ placeholder: "-1001234567890",
162
+ 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",
163
+ required: true
164
+ }),
165
+ /* @__PURE__ */ jsxs("p", {
166
+ className: "text-xs text-muted-foreground mt-1",
167
+ children: [
168
+ "Forum-enabled supergroup the bot is admin in (with",
169
+ " ",
170
+ /* @__PURE__ */ jsx("code", {
171
+ className: "font-mono",
172
+ children: "can_manage_topics"
173
+ }),
174
+ ")."
175
+ ]
176
+ })
177
+ ]
178
+ }),
179
+ /* @__PURE__ */ jsxs("div", {
180
+ className: "flex items-center gap-3 pt-1",
181
+ children: [
182
+ /* @__PURE__ */ jsx(Button, {
183
+ variant: "primary",
184
+ type: "submit",
185
+ disabled: saving,
186
+ children: saving ? "saving…" : "save credentials"
187
+ }),
188
+ initial.configured && /* @__PURE__ */ jsx(Button, {
189
+ variant: "danger",
190
+ onClick: disconnect,
191
+ children: "clear credentials"
192
+ }),
193
+ saveOk && /* @__PURE__ */ jsx("span", {
194
+ className: "text-xs text-emerald-700",
195
+ children: "saved ✓"
196
+ }),
197
+ saveError && /* @__PURE__ */ jsxs("span", {
198
+ className: "text-xs text-rose-700",
199
+ children: ["error: ", saveError]
200
+ })
201
+ ]
202
+ })
203
+ ]
204
+ })
205
+ ]
206
+ }),
207
+ /* @__PURE__ */ jsxs("section", {
208
+ className: "rounded-lg border bg-card p-5",
209
+ children: [
210
+ /* @__PURE__ */ jsxs("div", {
211
+ className: "flex items-center justify-between mb-3",
212
+ children: [/* @__PURE__ */ jsx("h3", {
213
+ className: "text-sm font-semibold uppercase tracking-wide text-muted-foreground",
214
+ children: "Preflight checks"
215
+ }), /* @__PURE__ */ jsx(Button, {
216
+ variant: "ghost",
217
+ onClick: runHealth,
218
+ disabled: checking || !initial.configured,
219
+ children: checking ? "checking…" : "run preflight"
220
+ })]
221
+ }),
222
+ !initial.configured && /* @__PURE__ */ jsx("p", {
223
+ className: "text-xs text-muted-foreground italic",
224
+ children: "Save credentials above first."
225
+ }),
226
+ initial.configured && !health && !checking && /* @__PURE__ */ jsxs("p", {
227
+ className: "text-xs text-muted-foreground italic",
228
+ children: [
229
+ "Click ",
230
+ /* @__PURE__ */ jsx("em", { children: "run preflight" }),
231
+ " to validate the stored credentials against the Telegram Bot API."
232
+ ]
233
+ }),
234
+ health && /* @__PURE__ */ jsx(PreflightResult, { health }),
235
+ health?.polling && /* @__PURE__ */ jsx(PollingState, { polling: health.polling })
236
+ ]
237
+ }),
238
+ initial.configured && /* @__PURE__ */ jsx(AccessControlCard, {})
239
+ ]
240
+ });
241
+ }
242
+ function AccessControlCard() {
243
+ const [users, setUsers] = useState(null);
244
+ const [userId, setUserId] = useState("");
245
+ const [label, setLabel] = useState("");
246
+ const [busy, setBusy] = useState(false);
247
+ const [err, setErr] = useState(null);
248
+ async function load() {
249
+ try {
250
+ const res = await fetch("/api/config/telegram/acl");
251
+ if (!res.ok) throw new Error(res.statusText);
252
+ setUsers(await res.json());
253
+ } catch (e) {
254
+ setErr(e.message);
255
+ }
256
+ }
257
+ useEffect(() => {
258
+ load();
259
+ }, []);
260
+ async function add(e) {
261
+ e.preventDefault();
262
+ const id = Number(userId);
263
+ if (!Number.isInteger(id)) {
264
+ setErr("user id must be an integer");
265
+ return;
266
+ }
267
+ setBusy(true);
268
+ setErr(null);
269
+ try {
270
+ const res = await fetch("/api/config/telegram/acl", {
271
+ method: "POST",
272
+ headers: { "content-type": "application/json" },
273
+ body: JSON.stringify({
274
+ userId: id,
275
+ label: label.trim() || null
276
+ })
277
+ });
278
+ if (!res.ok) {
279
+ const j = await res.json().catch(() => ({}));
280
+ throw new Error(j.error ?? res.statusText);
281
+ }
282
+ setUserId("");
283
+ setLabel("");
284
+ await load();
285
+ } catch (e) {
286
+ setErr(e.message);
287
+ } finally {
288
+ setBusy(false);
289
+ }
290
+ }
291
+ async function remove(id) {
292
+ setErr(null);
293
+ try {
294
+ const res = await fetch(`/api/config/telegram/acl/${id}`, { method: "DELETE" });
295
+ if (!res.ok) {
296
+ const j = await res.json().catch(() => ({}));
297
+ throw new Error(j.error ?? res.statusText);
298
+ }
299
+ await load();
300
+ } catch (e) {
301
+ setErr(e.message);
302
+ }
303
+ }
304
+ return /* @__PURE__ */ jsxs("section", {
305
+ className: "rounded-lg border bg-card p-5 mt-6",
306
+ children: [
307
+ /* @__PURE__ */ jsx("h3", {
308
+ className: "text-sm font-semibold uppercase tracking-wide text-muted-foreground mb-1",
309
+ children: "Access control"
310
+ }),
311
+ /* @__PURE__ */ jsxs("p", {
312
+ className: "text-xs text-muted-foreground mb-3",
313
+ children: [
314
+ "Allowlisted Telegram users can use the bot (commands + chat). While the list is empty the bot is open and the first person to message it becomes owner. Users find their id via",
315
+ " ",
316
+ /* @__PURE__ */ jsx("code", {
317
+ className: "font-mono",
318
+ children: "/whoami"
319
+ }),
320
+ "."
321
+ ]
322
+ }),
323
+ users === null ? /* @__PURE__ */ jsx("p", {
324
+ className: "text-xs text-muted-foreground italic",
325
+ children: "loading…"
326
+ }) : users.length === 0 ? /* @__PURE__ */ jsx("p", {
327
+ className: "text-xs text-amber-700 mb-3",
328
+ children: "Open — no allowlist yet. The first user to message the bot claims owner."
329
+ }) : /* @__PURE__ */ jsx("ul", {
330
+ className: "mb-3 space-y-1 text-sm",
331
+ children: users.map((u) => /* @__PURE__ */ jsxs("li", {
332
+ className: "flex items-center gap-2",
333
+ children: [
334
+ /* @__PURE__ */ jsx("code", {
335
+ className: "font-mono",
336
+ children: u.userId
337
+ }),
338
+ /* @__PURE__ */ jsxs("span", {
339
+ className: "text-muted-foreground",
340
+ children: [
341
+ u.label ?? (u.username ? `@${u.username}` : "—"),
342
+ " · ",
343
+ u.role
344
+ ]
345
+ }),
346
+ u.role !== "owner" && /* @__PURE__ */ jsx("button", {
347
+ type: "button",
348
+ onClick: () => void remove(u.userId),
349
+ className: "ghost-btn text-xs text-[#9B3D3D]",
350
+ children: "remove"
351
+ })
352
+ ]
353
+ }, u.userId))
354
+ }),
355
+ /* @__PURE__ */ jsxs("form", {
356
+ onSubmit: add,
357
+ className: "flex items-center gap-2",
358
+ children: [
359
+ /* @__PURE__ */ jsx("input", {
360
+ value: userId,
361
+ onChange: (e) => setUserId(e.target.value),
362
+ placeholder: "user id",
363
+ className: "w-28 rounded-md border bg-background px-2 py-1 font-mono text-sm"
364
+ }),
365
+ /* @__PURE__ */ jsx("input", {
366
+ value: label,
367
+ onChange: (e) => setLabel(e.target.value),
368
+ placeholder: "label (optional)",
369
+ className: "w-40 rounded-md border bg-background px-2 py-1 text-sm"
370
+ }),
371
+ /* @__PURE__ */ jsx(Button, {
372
+ variant: "ghost",
373
+ type: "submit",
374
+ disabled: busy,
375
+ children: "add"
376
+ }),
377
+ err && /* @__PURE__ */ jsx("span", {
378
+ className: "text-xs text-rose-700",
379
+ children: err
380
+ })
381
+ ]
382
+ })
383
+ ]
384
+ });
385
+ }
386
+ function MigrationBanner({ toChatId }) {
387
+ const [busy, setBusy] = useState(false);
388
+ const [err, setErr] = useState(null);
389
+ async function reconnect() {
390
+ setBusy(true);
391
+ setErr(null);
392
+ try {
393
+ const res = await fetch("/api/config/telegram/reconnect", { method: "POST" });
394
+ if (!res.ok) {
395
+ const e = await res.json().catch(() => ({}));
396
+ throw new Error(e.error ?? res.statusText);
397
+ }
398
+ window.location.reload();
399
+ } catch (e) {
400
+ setErr(e.message);
401
+ setBusy(false);
402
+ }
403
+ }
404
+ return /* @__PURE__ */ jsxs("div", {
405
+ className: "rounded-md border-2 border-rose-400 bg-rose-50 px-4 py-3 mb-6 text-sm",
406
+ children: [
407
+ /* @__PURE__ */ jsx("div", {
408
+ className: "font-semibold text-rose-900 mb-1",
409
+ children: "Supergroup chat id changed"
410
+ }),
411
+ /* @__PURE__ */ jsxs("p", {
412
+ className: "text-rose-900 mb-2",
413
+ children: [
414
+ "Telegram migrated this supergroup to a new chat id (",
415
+ /* @__PURE__ */ jsx("code", {
416
+ className: "font-mono",
417
+ children: toChatId
418
+ }),
419
+ "). The bot is still pointed at the old id. Reconnect to repoint it and re-create the ",
420
+ /* @__PURE__ */ jsx("code", {
421
+ className: "font-mono",
422
+ children: "⚙ bazilion"
423
+ }),
424
+ " ",
425
+ "service chat in the new group. Agent topic bindings will reconcile on next use."
426
+ ]
427
+ }),
428
+ /* @__PURE__ */ jsx(Button, {
429
+ variant: "primary",
430
+ onClick: reconnect,
431
+ disabled: busy,
432
+ children: busy ? "reconnecting…" : `Reconnect to ${toChatId}`
433
+ }),
434
+ err && /* @__PURE__ */ jsx("span", {
435
+ className: "ml-3 text-xs text-rose-700",
436
+ children: err
437
+ })
438
+ ]
439
+ });
440
+ }
441
+ function Step2Banner() {
442
+ return /* @__PURE__ */ jsxs("div", {
443
+ className: "rounded-md border-2 border-amber-400 bg-amber-50 px-4 py-3 mb-6 text-sm",
444
+ children: [/* @__PURE__ */ jsx("div", {
445
+ className: "font-semibold text-amber-900 mb-1",
446
+ children: "Step 2 of the rollout"
447
+ }), /* @__PURE__ */ jsxs("p", {
448
+ className: "text-amber-900",
449
+ children: [
450
+ "The bot polls Telegram and creates the ",
451
+ /* @__PURE__ */ jsx("code", {
452
+ className: "font-mono",
453
+ children: "⚙ bazilion"
454
+ }),
455
+ " ",
456
+ "service chat on first start. Inbound messages are logged but not yet routed to agents —",
457
+ " ",
458
+ "slash commands and per-agent topics ship in the next release. Outbound from agents ships after that."
459
+ ]
460
+ })]
461
+ });
462
+ }
463
+ function PollingState({ polling }) {
464
+ const startedAt = polling.startedAt ? new Date(polling.startedAt).toISOString() : null;
465
+ const lastPoll = polling.lastSuccessfulPollAt ? new Date(polling.lastSuccessfulPollAt).toISOString() : null;
466
+ return /* @__PURE__ */ jsxs("div", {
467
+ className: "mt-4 rounded-md border bg-muted/30 px-3 py-2 text-xs space-y-1",
468
+ children: [
469
+ /* @__PURE__ */ jsx("p", {
470
+ className: "font-semibold uppercase tracking-wide text-muted-foreground",
471
+ children: "Polling state"
472
+ }),
473
+ /* @__PURE__ */ jsxs("div", {
474
+ className: "flex flex-wrap gap-x-4 gap-y-1 font-mono",
475
+ children: [
476
+ /* @__PURE__ */ jsx("span", {
477
+ className: polling.running ? "text-emerald-700" : "text-rose-700",
478
+ children: polling.running ? "running" : "stopped"
479
+ }),
480
+ /* @__PURE__ */ jsx("span", {
481
+ className: polling.activated ? "text-emerald-700" : "text-amber-700",
482
+ children: polling.activated ? "activated" : "awaiting activation"
483
+ }),
484
+ polling.lastUpdateId !== null && /* @__PURE__ */ jsxs("span", { children: ["last update ", polling.lastUpdateId] }),
485
+ startedAt && /* @__PURE__ */ jsxs("span", { children: ["started ", startedAt] }),
486
+ lastPoll && /* @__PURE__ */ jsxs("span", { children: ["last poll ", lastPoll] })
487
+ ]
488
+ }),
489
+ polling.error && /* @__PURE__ */ jsxs("p", {
490
+ className: "text-rose-700",
491
+ children: ["error: ", polling.error]
492
+ })
493
+ ]
494
+ });
495
+ }
496
+ function PreflightResult({ health }) {
497
+ if (health.error) return /* @__PURE__ */ jsxs("div", {
498
+ className: "rounded-md border border-rose-300 bg-rose-50 px-3 py-2 text-sm",
499
+ children: [
500
+ /* @__PURE__ */ jsxs("p", {
501
+ className: "font-semibold text-rose-900",
502
+ children: ["Failed at ", /* @__PURE__ */ jsx("code", {
503
+ className: "font-mono",
504
+ children: health.error.step
505
+ })]
506
+ }),
507
+ /* @__PURE__ */ jsx("p", {
508
+ className: "text-rose-900 mt-1",
509
+ children: health.error.message
510
+ }),
511
+ hintFor(health.error.step)
512
+ ]
513
+ });
514
+ if (!health.preflight) return /* @__PURE__ */ jsx("p", {
515
+ className: "text-xs text-muted-foreground italic",
516
+ children: "No preflight data."
517
+ });
518
+ const p = health.preflight;
519
+ return /* @__PURE__ */ jsxs("ul", {
520
+ className: "space-y-1.5",
521
+ children: [
522
+ /* @__PURE__ */ jsxs(Check, {
523
+ ok: p.botUsername.length > 0,
524
+ label: "Bot identity",
525
+ children: ["@", p.botUsername]
526
+ }),
527
+ /* @__PURE__ */ jsx(Check, {
528
+ ok: p.chatTitle.length > 0,
529
+ label: "Supergroup reachable",
530
+ children: p.chatTitle
531
+ }),
532
+ /* @__PURE__ */ jsx(Check, {
533
+ ok: p.isForum,
534
+ label: "Forum topics enabled",
535
+ children: p.isForum ? "is_forum: true" : "is_forum: false — the supergroup owner must enable Topics in group settings"
536
+ }),
537
+ /* @__PURE__ */ jsx(Check, {
538
+ ok: p.hasManageTopics,
539
+ label: "Bot has can_manage_topics",
540
+ children: p.hasManageTopics ? "admin with can_manage_topics" : "promote the bot to admin in the supergroup with the \"Manage topics\" permission"
541
+ }),
542
+ /* @__PURE__ */ jsx(Check, {
543
+ ok: p.privacyModeOff,
544
+ label: "Privacy Mode is OFF",
545
+ children: p.privacyModeOff ? "can_read_all_group_messages: true" : "BotFather → /mybots → select bot → Bot Settings → Group Privacy → Turn off"
546
+ })
547
+ ]
548
+ });
549
+ }
550
+ function Check({ ok, label, children }) {
551
+ return /* @__PURE__ */ jsxs("li", {
552
+ className: "flex items-start gap-2 text-sm",
553
+ children: [/* @__PURE__ */ jsx("span", {
554
+ className: `mt-0.5 inline-flex h-4 w-4 items-center justify-center rounded-full text-[10px] font-bold leading-none ${ok ? "bg-emerald-100 text-emerald-800" : "bg-rose-100 text-rose-800"}`,
555
+ "aria-hidden": true,
556
+ children: ok ? "✓" : "✕"
557
+ }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("span", {
558
+ className: "font-medium",
559
+ children: label
560
+ }), /* @__PURE__ */ jsx("span", {
561
+ className: `ml-2 text-xs ${ok ? "text-muted-foreground" : "text-rose-800"}`,
562
+ children
563
+ })] })]
564
+ });
565
+ }
566
+ function hintFor(step) {
567
+ switch (step) {
568
+ case "getMe": return /* @__PURE__ */ jsx("p", {
569
+ className: "text-xs text-rose-900 mt-1",
570
+ children: "The token is invalid or revoked. Re-issue with @BotFather → /token, or paste a fresh one above."
571
+ });
572
+ case "getChat": return /* @__PURE__ */ jsx("p", {
573
+ className: "text-xs text-rose-900 mt-1",
574
+ 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."
575
+ });
576
+ case "getChatMember": return /* @__PURE__ */ jsx("p", {
577
+ className: "text-xs text-rose-900 mt-1",
578
+ 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."
579
+ });
580
+ }
581
+ }
582
+ //#endregion
583
+ export { TelegramIntegrationPage as component };
@@ -0,0 +1,12 @@
1
+ import { t as createServerFn } from "../server.js";
2
+ import { t as createSsrRpc } from "./createSsrRpc-ZBGxhl8t.js";
3
+ import { createFileRoute, lazyRouteComponent } from "@tanstack/react-router";
4
+ //#region src/routes/config/integrations/telegram.tsx
5
+ var $$splitComponentImporter = () => import("./telegram-DfAddLdv.js");
6
+ var fetchTelegramConfig = createServerFn({ method: "GET" }).handler(createSsrRpc("00a157dd07824e1f126f06646effd1d876f280f6fc64c144d2f6429414a4e58a"));
7
+ var Route = createFileRoute("/config/integrations/telegram")({
8
+ loader: () => fetchTelegramConfig(),
9
+ component: lazyRouteComponent($$splitComponentImporter, "component")
10
+ });
11
+ //#endregion
12
+ export { Route as t };
@@ -0,0 +1,12 @@
1
+ import { t as createServerFn } from "../server.js";
2
+ import { t as createServerRpc } from "./createServerRpc-CeKECg65.js";
3
+ import { n as daemonClient } from "./daemon-client-2NRMzlTr.js";
4
+ //#region src/routes/config/tokens.tsx?tss-serverfn-split
5
+ var fetchTokens_createServerFn_handler = createServerRpc({
6
+ id: "46e35c9f1afc79423cb49703b454ef684344db08ec19775efd70a8768c7837f1",
7
+ name: "fetchTokens",
8
+ filename: "src/routes/config/tokens.tsx"
9
+ }, (opts) => fetchTokens.__executeServer(opts));
10
+ var fetchTokens = createServerFn({ method: "POST" }).inputValidator((d) => d).handler(fetchTokens_createServerFn_handler, ({ data }) => daemonClient().get(`/api/tokens${data.all ? "?includeRevoked=1" : ""}`));
11
+ //#endregion
12
+ export { fetchTokens_createServerFn_handler };