bazilion 0.52.0 → 0.53.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.
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/web/client/assets/AddProviderDialog-CO_uijWF.js +1 -0
- package/dist/web/client/assets/AgentTemplateParts-Dl35c-Ux.js +1 -0
- package/dist/web/client/assets/ConfigPage-DiQiJXP6.js +1 -0
- package/dist/web/client/assets/ConfirmDialog-BVytx3kN.js +1 -0
- package/dist/web/client/assets/ConnectionsView-DDrBaiLg.js +1 -0
- package/dist/web/client/assets/Dialog-BTDzv3J5.js +1 -0
- package/dist/web/client/assets/ManagePage-xlePXXx5.js +1 -0
- package/dist/web/client/assets/SectionTabs-BMiRKFfb.js +1 -0
- package/dist/web/client/assets/Segmented-Co4n2C5X.js +1 -0
- package/dist/web/client/assets/SpawnDialog-ejwXnyxy.js +1 -0
- package/dist/web/client/assets/SpawnTeamModal-Cp-nAvIC.js +1 -0
- package/dist/web/client/assets/TeamForm-Cz9uDVvb.js +1 -0
- package/dist/web/client/assets/TeamThread-D8xqE_gb.js +1 -0
- package/dist/web/client/assets/UnsavedChangesGuard-DmT4nBQU.js +1 -0
- package/dist/web/client/assets/_id-DEQxwq2v.js +1 -0
- package/dist/web/client/assets/_id-DSRgpxEc.js +1 -0
- package/dist/web/client/assets/access-34_ShgHU.js +1 -0
- package/dist/web/client/assets/agent-actions--EO4yJ4Q.js +1 -0
- package/dist/web/client/assets/agents-C87yBHaR.js +1 -0
- package/dist/web/client/assets/agents-DvCSl1Ro.js +1 -0
- package/dist/web/client/assets/api-CoLs57oO.js +1 -0
- package/dist/web/client/assets/arrow-right-BhTWtC9z.js +1 -0
- package/dist/web/client/assets/attention-CteEeRvX.js +1 -0
- package/dist/web/client/assets/chevron-right-BqOIX9UM.js +1 -0
- package/dist/web/client/assets/config-XJuQeEP4.js +1 -0
- package/dist/web/client/assets/createLucideIcon-dN8ooBD1.js +1 -0
- package/dist/web/client/assets/download-Dj-1ltZb.js +1 -0
- package/dist/web/client/assets/file-text-DiP-LaEg.js +1 -0
- package/dist/web/client/assets/form-Bvr_f9lR.js +1 -0
- package/dist/web/client/assets/images-BKjyhYUc.js +1 -0
- package/dist/web/client/assets/index-J_Uqj4md.js +54 -0
- package/dist/web/client/assets/key-round-QpqZklz6.js +1 -0
- package/dist/web/client/assets/list-checks-BeyG5SVQ.js +1 -0
- package/dist/web/client/assets/login-076Bc601.js +1 -0
- package/dist/web/client/assets/manage-CsrV2hhK.js +1 -0
- package/dist/web/client/assets/mcp-8N0BqZ0G.js +1 -0
- package/dist/web/client/assets/message-square-DnpSOYv4.js +1 -0
- package/dist/web/client/assets/network-BC7rNaOC.js +1 -0
- package/dist/web/client/assets/parts-B0JBolvG.js +1 -0
- package/dist/web/client/assets/plus-DZ3KVo7E.js +1 -0
- package/dist/web/client/assets/routes-3HkZZOOe.js +76 -0
- package/dist/web/client/assets/skills-DiaqZRXT.js +1 -0
- package/dist/web/client/assets/square-terminal-hQZ6pexU.js +1 -0
- package/dist/web/client/assets/style-BtcFIkOS.js +7 -0
- package/dist/web/client/assets/styles-C7Ztw15K.css +2 -0
- package/dist/web/client/assets/system-YWlJ8ogO.js +1 -0
- package/dist/web/client/assets/teams-DQwceMvk.js +1 -0
- package/dist/web/client/assets/teams-DTC3plIH.js +1 -0
- package/dist/web/client/assets/telegram-D4wINntt.js +1 -0
- package/dist/web/client/assets/tools-CZeQ9pDx.js +1 -0
- package/dist/web/client/assets/use-resource-BaTkTGvG.js +1 -0
- package/dist/web/client/assets/welcome-CnxP_RCk.js +1 -0
- package/dist/web/client/assets/wrench-BrwBswfo.js +1 -0
- package/dist/web/server/assets/{AddProviderDialog-Tn4AskPm.js → AddProviderDialog-Di5crZUB.js} +105 -4
- package/dist/web/server/assets/AgentTemplateParts-Cqy7kSzx.js +269 -0
- package/dist/web/server/assets/{ConfigPage-DqDUujmt.js → ConfigPage-oXM3wyOU.js} +2 -2
- package/dist/web/server/assets/{ConnectionsView-DAG-zNBz.js → ConnectionsView-DZrLoNoW.js} +3 -3
- package/dist/web/server/assets/ManagePage-0LKHEcT_.js +29 -0
- package/dist/web/server/assets/{ModelMenu-DUY9aHkE.js → ModelMenu-BAZeARx6.js} +3 -3
- package/dist/web/server/assets/{Rail-BIC_4ptO.js → Rail-7JU6ly2O.js} +14 -104
- package/dist/web/server/assets/{SectionTabs-BGsrf-UQ.js → SectionTabs-CWQ5orUW.js} +9 -2
- package/dist/web/server/assets/{SpawnDialog-D_SMPCG_.js → SpawnDialog-CYkwzETs.js} +49 -57
- package/dist/web/server/assets/SpawnTeamModal-CCe6P82H.js +127 -0
- package/dist/web/server/assets/TeamForm-BzQmdhVi.js +141 -0
- package/dist/web/server/assets/{TeamThread-DuLlGDcw.js → TeamThread-SyQpUvz5.js} +1 -1
- package/dist/web/server/assets/_id-AcyGvFrE.js +400 -0
- package/dist/web/server/assets/{_id-DJnYgisy.js → _id-BGTgqsWm.js} +8 -4
- package/dist/web/server/assets/{_id-TVruGcOd.js → _id-BKzOw78O.js} +11 -3
- package/dist/web/server/assets/{_id-yN0z7VqE.js → _id-DPGzfmjG.js} +255 -203
- package/dist/web/server/assets/_id-DXm9W55C.js +16 -0
- package/dist/web/server/assets/_id-DojvxRZn.js +39 -0
- package/dist/web/server/assets/_tanstack-start-manifest_v-D7RvKGRH.js +285 -0
- package/dist/web/server/assets/{access-GMGed5O8.js → access-BJe-NduL.js} +2 -2
- package/dist/web/server/assets/access-CKSW7MFH.js +297 -0
- package/dist/web/server/assets/{access-C_pupPks.js → access-WWspT0v4.js} +2 -1
- package/dist/web/server/assets/agent-actions-CUDMCG0F.js +20 -0
- package/dist/web/server/assets/agents-1sjSvp5p.js +12 -0
- package/dist/web/server/assets/{agents-BnWgFo6o.js → agents-6d9WxbYF.js} +9 -6
- package/dist/web/server/assets/agents-DKVGUwD1.js +31 -0
- package/dist/web/server/assets/agents-DUI4Yjtg.js +13 -0
- package/dist/web/server/assets/agents-DsHeRaLq.js +327 -0
- package/dist/web/server/assets/agents-DtLDoZ_u.js +136 -0
- package/dist/web/server/assets/{attention-Cr7puThv.js → attention-B6sSDR_4.js} +2 -1
- package/dist/web/server/assets/{attention-DS3O9UmJ.js → attention-DefKwvgm.js} +2 -2
- package/dist/web/server/assets/attention-johfkM0_.js +203 -0
- package/dist/web/server/assets/{config-Q7livfa3.js → config-Clz57LuN.js} +33 -82
- package/dist/web/server/assets/{config-DjTGA4iZ.js → config-DYAaaE9Z.js} +2 -2
- package/dist/web/server/assets/{createSsrRpc-GCCF14VW.js → createSsrRpc-BijMHgqE.js} +1 -45
- package/dist/web/server/assets/form-BRQAsKKq.js +319 -0
- package/dist/web/server/assets/manage-Ppyi3Y5y.js +230 -0
- package/dist/web/server/assets/mcp-Ce6O8Qs2.js +378 -0
- package/dist/web/server/assets/{mcp-ZARSOxZW.js → mcp-DB38leWS.js} +2 -2
- package/dist/web/server/assets/parts-mabERIJZ.js +380 -0
- package/dist/web/server/assets/{router-Dh2-IvLL.js → router-C97bwlXi.js} +35 -30
- package/dist/web/server/assets/{routes-C9NawqcV.js → routes-C4aGqXfr.js} +52 -8
- package/dist/web/server/assets/{routes-CDskMy5C.js → routes-DuOShl4q.js} +1 -1
- package/dist/web/server/assets/{routes-BJIJWCIE.js → routes-IHMVKpDK.js} +2 -2
- package/dist/web/server/assets/{skills-StN15QhC.js → skills-B7sg0QKS.js} +2 -2
- package/dist/web/server/assets/{skills-h5aHa7Q8.js → skills-DWzlT_hC.js} +9 -1
- package/dist/web/server/assets/skills-hfTSwqsG.js +353 -0
- package/dist/web/server/assets/{style-GYDODk2F.js → style-BR7ufS6Z.js} +1 -1
- package/dist/web/server/assets/system-CNQpt3JB.js +145 -0
- package/dist/web/server/assets/{system-DtswhLW6.js → system-D3th6n2E.js} +4 -2
- package/dist/web/server/assets/{system-Dl-1RhoP.js → system-DaP0ol67.js} +2 -2
- package/dist/web/server/assets/{teams-CbIPKf99.js → teams-4cEZ4_rw.js} +4 -2
- package/dist/web/server/assets/{teams-BxnvFTyn.js → teams-70u1XQTr.js} +1 -3
- package/dist/web/server/assets/teams-BKHe67f3.js +176 -0
- package/dist/web/server/assets/{teams-YrmyutM4.js → teams-BopOP4x7.js} +8 -1
- package/dist/web/server/assets/teams-C3xwTz8-.js +219 -0
- package/dist/web/server/assets/{teams-5PMGvHuM.js → teams-CuKE5iAK.js} +2 -2
- package/dist/web/server/assets/{telegram-Cv0D4gyz.js → telegram-BnQADwnj.js} +2 -2
- package/dist/web/server/assets/telegram-BpmK-HHV.js +1059 -0
- package/dist/web/server/assets/{tools-ioJcPzMW.js → tools-BQeWn7Tj.js} +2 -2
- package/dist/web/server/assets/{tools-OfD22R-C.js → tools-CURTfG2q.js} +56 -217
- package/dist/web/server/assets/{welcome-FFEbrNT1.js → welcome-OiZCAIHZ.js} +3 -4
- package/dist/web/server/assets/{welcome-jxmpE_Jb.js → welcome-SNsE49JO.js} +2 -2
- package/dist/web/server/server.js +20 -20
- package/package.json +1 -1
- package/dist/web/client/assets/AddProviderDialog-BiGLKnu2.js +0 -1
- package/dist/web/client/assets/ConfigPage-DvBzy2MN.js +0 -1
- package/dist/web/client/assets/ConfirmDialog-CiZ5tk9R.js +0 -1
- package/dist/web/client/assets/ConnectionsView-Czkpm2JY.js +0 -1
- package/dist/web/client/assets/Dialog-s_kPtI-W.js +0 -1
- package/dist/web/client/assets/ModelMenu-BfUPoRjV.js +0 -1
- package/dist/web/client/assets/SectionTabs-DENNb6Nw.js +0 -1
- package/dist/web/client/assets/Segmented-Dh77vmpp.js +0 -1
- package/dist/web/client/assets/SkillFindings-Xng11qqx.js +0 -1
- package/dist/web/client/assets/SkillsPicker-hI3YXvib.js +0 -1
- package/dist/web/client/assets/SpawnDialog-CKWFQ6jk.js +0 -1
- package/dist/web/client/assets/Tabs-f6bHvCGn.js +0 -1
- package/dist/web/client/assets/TeamForm-kda1HYZG.js +0 -1
- package/dist/web/client/assets/TeamThread-2rm1JGSk.js +0 -1
- package/dist/web/client/assets/UnsavedChangesGuard-nx6dv2Yw.js +0 -1
- package/dist/web/client/assets/_id-B72mIpcE.js +0 -1
- package/dist/web/client/assets/_id-Bzavnza1.js +0 -1
- package/dist/web/client/assets/access-Yw9jODuk.js +0 -1
- package/dist/web/client/assets/agents-C9xoyL7o.js +0 -1
- package/dist/web/client/assets/agents-TviG16wx.js +0 -1
- package/dist/web/client/assets/api-HC_YzjBy.js +0 -1
- package/dist/web/client/assets/arrow-right-Gm_FDWJ_.js +0 -1
- package/dist/web/client/assets/attention-DmURtlJm.js +0 -1
- package/dist/web/client/assets/check-BjgKoGvU.js +0 -1
- package/dist/web/client/assets/chevron-right-CUZiA2aG.js +0 -1
- package/dist/web/client/assets/config-UZz_mjO5.js +0 -1
- package/dist/web/client/assets/createLucideIcon-C6gOo8sD.js +0 -1
- package/dist/web/client/assets/dist-BWppw70N.js +0 -41
- package/dist/web/client/assets/dist-D2dwY7MR.js +0 -1
- package/dist/web/client/assets/index-Df1oUtAP.js +0 -14
- package/dist/web/client/assets/link-Cbztlp_R.js +0 -1
- package/dist/web/client/assets/login-CPfdaqsV.js +0 -1
- package/dist/web/client/assets/mcp-FlYnNon0.js +0 -1
- package/dist/web/client/assets/parts-tIDBNsYA.js +0 -1
- package/dist/web/client/assets/plus-CWrKMtvA.js +0 -1
- package/dist/web/client/assets/routes-BZaWCoQj.js +0 -76
- package/dist/web/client/assets/save-f9O-CQia.js +0 -1
- package/dist/web/client/assets/skills-C7yDPC8s.js +0 -1
- package/dist/web/client/assets/style-DDuTFJUu.js +0 -7
- package/dist/web/client/assets/styles-BviXU81u.css +0 -2
- package/dist/web/client/assets/system-CL3Kz36L.js +0 -1
- package/dist/web/client/assets/teams-CQTEF5gV.js +0 -1
- package/dist/web/client/assets/teams-DQ7SqVyF.js +0 -1
- package/dist/web/client/assets/telegram-BLgxtGhZ.js +0 -1
- package/dist/web/client/assets/tools-pOQyGVYo.js +0 -1
- package/dist/web/client/assets/use-resource-C3MBZJop.js +0 -1
- package/dist/web/client/assets/welcome-Hr6JpMef.js +0 -1
- package/dist/web/client/assets/wrench-6BEIqKDn.js +0 -1
- package/dist/web/server/assets/SkillFindings-BdATze1A.js +0 -46
- package/dist/web/server/assets/SkillsPicker-DlqEfRWh.js +0 -67
- package/dist/web/server/assets/Tabs-BhF41MfQ.js +0 -20
- package/dist/web/server/assets/TeamForm-ilBaeLI4.js +0 -96
- package/dist/web/server/assets/_id-BsZcsabI.js +0 -383
- package/dist/web/server/assets/_id-D8Kj0F30.js +0 -18
- package/dist/web/server/assets/_id-QYifTM9w.js +0 -28
- package/dist/web/server/assets/_tanstack-start-manifest_v-D6zrzUC7.js +0 -223
- package/dist/web/server/assets/access-DKOpcHIJ.js +0 -232
- package/dist/web/server/assets/agents-B6OR3x99.js +0 -327
- package/dist/web/server/assets/agents-B7642eRO.js +0 -130
- package/dist/web/server/assets/agents-BJ-_oC2e.js +0 -14
- package/dist/web/server/assets/agents-CjV0w-Zy.js +0 -12
- package/dist/web/server/assets/agents-Dy_Q-9lG.js +0 -27
- package/dist/web/server/assets/attention-CLP4HYBz.js +0 -216
- package/dist/web/server/assets/mcp-BI-FD-JI.js +0 -250
- package/dist/web/server/assets/parts-B31PJkhi.js +0 -190
- package/dist/web/server/assets/skills-BqLq3ZXq.js +0 -275
- package/dist/web/server/assets/system-BtRA2HUs.js +0 -138
- package/dist/web/server/assets/teams-COaU0wN9.js +0 -108
- package/dist/web/server/assets/teams-Ca8W4mvl.js +0 -88
- package/dist/web/server/assets/telegram-Yx8nm6Ei.js +0 -984
- /package/dist/web/server/assets/{telegram-CGol0CKX2.js → telegram-CGol0CKX.js} +0 -0
|
@@ -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 };
|