@alexsun-top/opencode-chat-room 0.8.4 → 0.8.6
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/CHANGELOG.md +17 -3
- package/README.md +5 -5
- package/README.zh-CN.md +5 -5
- package/cli.ts +20 -1
- package/dist/cli.js +3785 -1462
- package/package.json +19 -11
- package/packages/chat-room-channeld/README.md +16 -10
- package/packages/chat-room-channeld/src/delivery.ts +0 -4
- package/packages/chat-room-channeld/src/host.ts +48 -37
- package/packages/chat-room-channeld/src/inbound.ts +3 -6
- package/packages/chat-room-channeld/src/pg/database.ts +141 -49
- package/packages/chat-room-channeld/src/pg/sql.mjs +157 -142
- package/packages/chat-room-channeld/src/pg/sql.mts +175 -0
- package/packages/chat-room-channeld/src/pg/worker.mjs +148 -99
- package/packages/chat-room-channeld/src/pg/worker.mts +201 -0
- package/packages/chat-room-channeld/src/state-rows.ts +132 -0
- package/packages/chat-room-channeld/src/state.ts +129 -157
- package/plugin.ts +21 -5
- package/server/app.ts +9 -0
- package/server/assets/base.css +22 -2
- package/server/assets/chat/admin.js +17 -1
- package/server/assets/chat/announcements.js +79 -34
- package/server/assets/chat/attachments.js +3 -3
- package/server/assets/chat/clipboard.js +1 -1
- package/server/assets/chat/confirm-dialog.js +3 -0
- package/server/assets/chat/copy-action.js +1 -1
- package/server/assets/chat/create-room-dialog.js +7 -0
- package/server/assets/chat/diagram-viewer.js +4 -8
- package/server/assets/chat/doc-preview.js +71 -31
- package/server/assets/chat/editor.js +49 -10
- package/server/assets/chat/events.js +13 -6
- package/server/assets/chat/files.js +33 -27
- package/server/assets/chat/history-loader.js +31 -15
- package/server/assets/chat/integration-editor.js +27 -1
- package/server/assets/chat/integrations.js +108 -16
- package/server/assets/chat/join-requests.js +40 -2
- package/server/assets/chat/locales/de.js +5 -3
- package/server/assets/chat/locales/es.js +5 -3
- package/server/assets/chat/locales/fr.js +5 -3
- package/server/assets/chat/locales/it.js +5 -3
- package/server/assets/chat/locales/ja.js +5 -3
- package/server/assets/chat/locales/ko.js +5 -3
- package/server/assets/chat/markdown-footnotes.js +27 -15
- package/server/assets/chat/markdown.js +6 -12
- package/server/assets/chat/members.js +34 -22
- package/server/assets/chat/mentions.js +8 -5
- package/server/assets/chat/message-cache.js +9 -3
- package/server/assets/chat/message-polling.js +10 -4
- package/server/assets/chat/message-window.js +58 -1
- package/server/assets/chat/messages.js +90 -37
- package/server/assets/chat/office-preview.js +3 -3
- package/server/assets/chat/operator.js +624 -0
- package/server/assets/chat/palette.js +7 -10
- package/server/assets/chat/panels.js +42 -0
- package/server/assets/chat/questions.js +75 -58
- package/server/assets/chat/recall.js +14 -5
- package/server/assets/chat/receipts.js +63 -7
- package/server/assets/chat/refresh-timing.js +6 -0
- package/server/assets/chat/reminders.js +47 -13
- package/server/assets/chat/replies.js +39 -25
- package/server/assets/chat/resource-format.js +6 -3
- package/server/assets/chat/room-list.js +202 -3
- package/server/assets/chat/room-watcher.js +3 -1
- package/server/assets/chat/rooms.js +29 -7
- package/server/assets/chat/settings.js +37 -6
- package/server/assets/chat/shortcuts.js +3 -1
- package/server/assets/chat/side-pane.js +1 -1
- package/server/assets/chat/state.js +51 -18
- package/server/assets/chat/system-events.js +3 -2
- package/server/assets/chat/system-messages.js +15 -15
- package/server/assets/chat/tasks.js +37 -14
- package/server/assets/chat/window-controls.js +25 -15
- package/server/assets/code-highlight.css +0 -13
- package/server/assets/conversation.css +45 -5
- package/server/assets/doc-preview.css +9 -0
- package/server/assets/files.css +4 -0
- package/server/assets/monaco/integration-rules.js +1 -1
- package/server/assets/office/THIRD-PARTY-NOTICES.txt +23 -1
- package/server/assets/office/licenses/docx-preview-HEADER.txt +6 -0
- package/server/assets/office/licenses/echarts-LICENSE-d3.txt +27 -0
- package/server/assets/office/licenses/echarts-NOTICE.txt +5 -0
- package/server/assets/office/licenses/immediate-LICENSE.txt +20 -0
- package/server/assets/office/licenses/lie-LICENSE.txt +7 -0
- package/server/assets/office/licenses/pako-LICENSE.txt +21 -0
- package/server/assets/office/licenses/pako-ZLIB.txt +18 -0
- package/server/assets/office/licenses/setimmediate-LICENSE.txt +20 -0
- package/server/assets/responsive.css +12 -2
- package/server/assets/settings.css +3 -1
- package/server/assets/tasks.css +6 -1
- package/server/assets/window-controls.css +3 -1
- package/server/channels.ts +3 -2
- package/server/chat.html +7 -2
- package/server/inbox.ts +3 -1
- package/server/join-requests.ts +8 -1
- package/server/member-routes.ts +16 -2
- package/server/newrooms.ts +2 -13
- package/server/operator-auth.ts +21 -0
- package/server/operator-routes.ts +150 -0
- package/server/operator-state.ts +64 -0
- package/server/operator.css +139 -0
- package/server/room-owner.ts +17 -0
- package/server/routes/inbox.ts +15 -5
- package/server/routes/pages.ts +12 -2
- package/server/routes/room-actions.ts +4 -3
- package/server/sw.js +3 -1
- package/server/system.html +109 -0
- package/server/wake.ts +1 -1
- package/skills/chatroom/SKILL.md +9 -0
- package/src/README.md +1 -1
- package/src/acp/client.ts +254 -0
- package/src/acp/protocol.ts +300 -0
- package/src/acp/watch.ts +498 -0
- package/src/agent/agent-receipts.ts +98 -8
- package/src/center/center-client.ts +6 -1
- package/src/center/center-inbox.ts +54 -7
- package/src/center/center-wake.ts +57 -3
- package/src/center/forward-client.ts +48 -0
- package/src/center/mentions.ts +16 -3
- package/src/center/notification-delay.ts +139 -0
- package/src/center/queue.ts +3 -0
- package/src/config/file-config.ts +25 -0
- package/src/mcp/server.ts +389 -0
- package/src/protocol/config.ts +7 -0
- package/src/runtime/plugin-notifications.ts +43 -9
- package/src/runtime/v2-plugin.ts +14 -3
- package/src/runtime/v2-receiver.ts +10 -2
- package/src/runtime/watch.ts +5 -1
- package/src/state/pg-database.ts +133 -49
- package/src/state/pg-sql.mjs +157 -142
- package/src/state/pg-sql.mts +175 -0
- package/src/state/pg-worker.mjs +148 -99
- package/src/state/pg-worker.mts +201 -0
- package/src/state/receiver-state.ts +47 -0
- package/src/state/sqlite-database.ts +6 -2
- package/src/state/sqlite-members.ts +48 -4
- package/src/state/sqlite-messages.ts +25 -12
- package/src/state/sqlite-schema.ts +4 -1
- package/src/state/sqlite-state.ts +1 -1
- package/src/state/store.ts +31 -11
- package/src/tui/app-types.mjs +1 -0
- package/src/tui/app-types.mts +175 -0
- package/src/tui/app.mjs +473 -423
- package/src/tui/app.mts +543 -0
- package/src/tui/config.mjs +166 -158
- package/src/tui/config.mts +247 -0
- package/src/tui/http.mjs +239 -206
- package/src/tui/http.mts +412 -0
- package/src/tui/i18n.mjs +17 -20
- package/src/tui/i18n.mts +42 -0
- package/src/tui/info-app.mjs +431 -427
- package/src/tui/info-app.mts +500 -0
- package/src/tui/info-content.mjs +205 -199
- package/src/tui/info-content.mts +341 -0
- package/src/tui/join-app.mjs +75 -64
- package/src/tui/join-app.mts +99 -0
- package/src/tui/locales/en.mjs +302 -320
- package/src/tui/locales/en.mts +349 -0
- package/src/tui/locales/zh-CN.mjs +302 -320
- package/src/tui/locales/zh-CN.mts +349 -0
- package/src/tui/main.mjs +219 -213
- package/src/tui/main.mts +255 -0
- package/src/tui/markdown.mjs +128 -272
- package/src/tui/markdown.mts +152 -0
- package/src/tui/mentions.mjs +181 -184
- package/src/tui/mentions.mts +251 -0
- package/src/tui/message-app.mjs +181 -173
- package/src/tui/message-app.mts +213 -0
- package/src/tui/message-view.mjs +90 -111
- package/src/tui/message-view.mts +151 -0
- package/src/tui/messages.mjs +55 -49
- package/src/tui/messages.mts +106 -0
- package/src/tui/palette-app.mjs +364 -344
- package/src/tui/palette-app.mts +388 -0
- package/src/tui/palette.mjs +100 -98
- package/src/tui/palette.mts +176 -0
- package/src/tui/prefs.mjs +56 -63
- package/src/tui/prefs.mts +126 -0
- package/src/tui/reminder-app.mjs +191 -181
- package/src/tui/reminder-app.mts +228 -0
- package/src/tui/room-settings-app.mjs +275 -242
- package/src/tui/room-settings-app.mts +318 -0
- package/src/tui/session.mjs +30 -29
- package/src/tui/session.mts +51 -0
- package/src/tui/settings-app.mjs +151 -138
- package/src/tui/settings-app.mts +179 -0
- package/src/tui/ui-content.mjs +426 -421
- package/src/tui/ui-content.mts +499 -0
- package/src/tui/ui-help.mjs +58 -67
- package/src/tui/ui-help.mts +87 -0
- package/src/tui/ui-mentions.mjs +34 -36
- package/src/tui/ui-mentions.mts +60 -0
- package/src/tui/ui-overlay-view.mjs +259 -267
- package/src/tui/ui-overlay-view.mts +322 -0
- package/src/tui/ui-suggest-view.mjs +54 -57
- package/src/tui/ui-suggest-view.mts +78 -0
- package/src/tui/ui-suggest.mjs +164 -167
- package/src/tui/ui-suggest.mts +248 -0
- package/src/tui/ui-theme.mjs +52 -57
- package/src/tui/ui-theme.mts +98 -0
- package/src/tui/ui-view.mjs +267 -275
- package/src/tui/ui-view.mts +308 -0
- package/src/tui/ui.mjs +372 -359
- package/src/tui/ui.mts +440 -0
- package/src/tui/wire.mjs +215 -0
- package/src/tui/wire.mts +383 -0
- package/src/web/integration-rules-editor.ts +25 -2
package/src/tui/info-content.mjs
CHANGED
|
@@ -2,232 +2,238 @@
|
|
|
2
2
|
// the row text and the settings redaction can be checked directly in tests.
|
|
3
3
|
import { sanitizeText } from "./messages.mjs";
|
|
4
4
|
import { t } from "./i18n.mjs";
|
|
5
|
-
|
|
6
5
|
const oneLine = (value, max = 100) => {
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const text = sanitizeText(value).replace(/\s+/g, " ").trim();
|
|
7
|
+
return text.length > max ? `${text.slice(0, max - 1)}…` : text;
|
|
9
8
|
};
|
|
10
|
-
|
|
11
9
|
function timeLabel(value) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
const ms = typeof value === "number" ? value : Date.parse(String(value ?? ""));
|
|
11
|
+
if (!Number.isFinite(ms))
|
|
12
|
+
return t("time.unknown");
|
|
13
|
+
const date = new Date(ms);
|
|
14
|
+
const pad = (part) => String(part).padStart(2, "0");
|
|
15
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
|
17
16
|
}
|
|
18
|
-
|
|
19
17
|
export function formatBytes(size) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
unit
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
const bytes = Number(size);
|
|
19
|
+
if (!Number.isFinite(bytes) || bytes < 0)
|
|
20
|
+
return "?";
|
|
21
|
+
if (bytes < 1024)
|
|
22
|
+
return `${Math.round(bytes)} B`;
|
|
23
|
+
const units = ["KB", "MB", "GB", "TB"];
|
|
24
|
+
let value = bytes / 1024;
|
|
25
|
+
let unit = 0;
|
|
26
|
+
while (value >= 1024 && unit < units.length - 1) {
|
|
27
|
+
value /= 1024;
|
|
28
|
+
unit += 1;
|
|
29
|
+
}
|
|
30
|
+
return `${value < 10 ? value.toFixed(1) : Math.round(value)} ${units[unit]}`;
|
|
31
31
|
}
|
|
32
|
-
|
|
33
32
|
export function memberRows(members, selfID) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
33
|
+
const list = Array.isArray(members) ? members : [];
|
|
34
|
+
return list.map((member) => {
|
|
35
|
+
const self = Boolean(selfID) && member.sessionID === selfID;
|
|
36
|
+
const name = sanitizeText(member.name || member.sessionID || "?");
|
|
37
|
+
const type = member.type === "agent" ? t("member.typeAgent") : t("member.typeHuman");
|
|
38
|
+
const activity = sanitizeText(member.activity?.state || t("member.activityUnknown"));
|
|
39
|
+
return {
|
|
40
|
+
name: t("member.row", {
|
|
41
|
+
marker: self ? "●" : "○",
|
|
42
|
+
name: self ? t("member.self", { name }) : name,
|
|
43
|
+
type,
|
|
44
|
+
activity,
|
|
45
|
+
}),
|
|
46
|
+
value: String(member.sessionID ?? name),
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
49
|
}
|
|
50
|
-
|
|
51
50
|
export function announcementRows(announcements) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
const list = Array.isArray(announcements) ? announcements : [];
|
|
52
|
+
return list.map((item) => ({
|
|
53
|
+
name: t("announcement.row", { name: sanitizeText(item.name), time: timeLabel(item.updatedAt) }),
|
|
54
|
+
value: String(item.name),
|
|
55
|
+
content: String(item.content ?? ""),
|
|
56
|
+
updatedAt: item.updatedAt,
|
|
57
|
+
}));
|
|
58
58
|
}
|
|
59
|
-
|
|
60
59
|
export function questionRows(open, messages = []) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
for (const question of Array.isArray(open) ? open : []) {
|
|
70
|
-
seen.add(question.id);
|
|
71
|
-
const answered = Boolean(question.answeredByMessageID);
|
|
72
|
-
rows.push({
|
|
73
|
-
name: rowOf(answered ? "✓" : "?", question.senderId, question.text, answered),
|
|
74
|
-
value: String(question.id),
|
|
75
|
-
text: String(question.text ?? ""),
|
|
76
|
-
open: !answered,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
for (const message of Array.isArray(messages) ? messages : []) {
|
|
80
|
-
if (!message?.isQuestion || !message.answeredByMessageID || seen.has(message.id)) continue;
|
|
81
|
-
seen.add(message.id);
|
|
82
|
-
rows.push({
|
|
83
|
-
name: rowOf("✓", message.senderId, message.text, true),
|
|
84
|
-
value: String(message.id),
|
|
85
|
-
open: false,
|
|
60
|
+
const rows = [];
|
|
61
|
+
const seen = new Set();
|
|
62
|
+
const rowOf = (marker, sender, text, answered) => t("question.row", {
|
|
63
|
+
marker,
|
|
64
|
+
sender: sanitizeText(sender || "?"),
|
|
65
|
+
text: oneLine(text),
|
|
66
|
+
answered: answered ? t("question.answered") : "",
|
|
86
67
|
});
|
|
87
|
-
|
|
88
|
-
|
|
68
|
+
const openList = Array.isArray(open) ? open : [];
|
|
69
|
+
for (const question of openList) {
|
|
70
|
+
seen.add(question.id);
|
|
71
|
+
const answered = Boolean(question.answeredByMessageID);
|
|
72
|
+
rows.push({
|
|
73
|
+
name: rowOf(answered ? "✓" : "?", question.senderId, question.text, answered),
|
|
74
|
+
value: String(question.id),
|
|
75
|
+
text: String(question.text ?? ""),
|
|
76
|
+
open: !answered,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
const messageList = Array.isArray(messages) ? messages : [];
|
|
80
|
+
for (const message of messageList) {
|
|
81
|
+
if (!message?.isQuestion || !message.answeredByMessageID || seen.has(message.id))
|
|
82
|
+
continue;
|
|
83
|
+
seen.add(message.id);
|
|
84
|
+
rows.push({
|
|
85
|
+
name: rowOf("✓", message.senderId, message.text, true),
|
|
86
|
+
value: String(message.id),
|
|
87
|
+
open: false,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return rows;
|
|
89
91
|
}
|
|
90
|
-
|
|
91
92
|
export function fileRows(resources) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
93
|
+
const list = Array.isArray(resources) ? resources : [];
|
|
94
|
+
return list.map((item) => ({
|
|
95
|
+
name: t("file.row", {
|
|
96
|
+
name: sanitizeText(item.name),
|
|
97
|
+
size: formatBytes(item.size),
|
|
98
|
+
uploader: sanitizeText(item.uploaderName || item.uploaderSessionID || t("file.uploaderUnknown")),
|
|
99
|
+
time: timeLabel(item.createdAt),
|
|
100
|
+
}),
|
|
101
|
+
value: String(item.id),
|
|
102
|
+
resource: item,
|
|
103
|
+
}));
|
|
102
104
|
}
|
|
103
|
-
|
|
104
105
|
export function joinRequestRows(requests) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
106
|
+
const list = Array.isArray(requests) ? requests : [];
|
|
107
|
+
return list.map((item) => ({
|
|
108
|
+
name: t("join.row", {
|
|
109
|
+
name: sanitizeText(item.name || item.participantId || "?"),
|
|
110
|
+
type: item.isAgent ? t("common.agent") : t("common.human"),
|
|
111
|
+
time: timeLabel(item.createdAt),
|
|
112
|
+
}),
|
|
113
|
+
value: String(item.sessionID),
|
|
114
|
+
request: item,
|
|
115
|
+
}));
|
|
114
116
|
}
|
|
115
|
-
|
|
116
117
|
export function reminderRows(reminders) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
118
|
+
const list = Array.isArray(reminders) ? reminders : [];
|
|
119
|
+
return list.map((item) => {
|
|
120
|
+
const schedule = item.schedule?.type === "cron"
|
|
121
|
+
? t("reminder.cron", {
|
|
122
|
+
expression: sanitizeText(item.schedule.expression),
|
|
123
|
+
timezone: sanitizeText(item.schedule.timezone || t("common.server")),
|
|
124
|
+
})
|
|
125
|
+
: t("reminder.once", { time: timeLabel(Date.parse(item.schedule?.at ?? "")) });
|
|
126
|
+
const next = typeof item.nextRunAt === "string" ? timeLabel(Date.parse(item.nextRunAt)) : timeLabel(item.nextRunAt);
|
|
127
|
+
return {
|
|
128
|
+
name: t("reminder.row", {
|
|
129
|
+
marker: item.paused ? "⏸" : "●",
|
|
130
|
+
text: oneLine(item.text),
|
|
131
|
+
schedule,
|
|
132
|
+
time: next,
|
|
133
|
+
}),
|
|
134
|
+
value: String(item.id),
|
|
135
|
+
paused: Boolean(item.paused),
|
|
136
|
+
text: String(item.text ?? ""),
|
|
137
|
+
schedule: item.schedule,
|
|
138
|
+
nextRunAt: item.nextRunAt,
|
|
139
|
+
};
|
|
140
|
+
});
|
|
139
141
|
}
|
|
140
|
-
|
|
141
142
|
function timezoneOrThrow(value) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
143
|
+
try {
|
|
144
|
+
new Intl.DateTimeFormat("en-US", { timeZone: value });
|
|
145
|
+
return value;
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
throw new Error(t("schedule.timezone", { value }));
|
|
149
|
+
}
|
|
148
150
|
}
|
|
149
|
-
|
|
150
151
|
/** Parse "once <ISO datetime> [timezone]" or "cron <5 fields> [timezone]". */
|
|
151
152
|
export function parseReminderSchedule(input) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
153
|
+
const parts = String(input ?? "").trim().split(/\s+/);
|
|
154
|
+
const kind = parts.shift()?.toLowerCase();
|
|
155
|
+
if (kind === "cron") {
|
|
156
|
+
if (parts.length < 5)
|
|
157
|
+
throw new Error(t("schedule.cronFields"));
|
|
158
|
+
if (parts.length > 6)
|
|
159
|
+
throw new Error(t("schedule.cronAccept"));
|
|
160
|
+
const expression = parts.slice(0, 5).join(" ");
|
|
161
|
+
const tzField = parts[5];
|
|
162
|
+
const timezone = tzField ? timezoneOrThrow(tzField) : undefined;
|
|
163
|
+
return timezone ? { type: "cron", expression, timezone } : { type: "cron", expression };
|
|
164
|
+
}
|
|
165
|
+
if (kind === "once") {
|
|
166
|
+
if (!parts.length)
|
|
167
|
+
throw new Error(t("schedule.onceNeeds"));
|
|
168
|
+
if (parts.length > 2)
|
|
169
|
+
throw new Error(t("schedule.onceAccept"));
|
|
170
|
+
const at = parts[0] ?? "";
|
|
171
|
+
if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(at) || !Number.isFinite(Date.parse(at))) {
|
|
172
|
+
throw new Error(t("schedule.onceInvalid"));
|
|
173
|
+
}
|
|
174
|
+
const tzField = parts[1];
|
|
175
|
+
const timezone = tzField ? timezoneOrThrow(tzField) : undefined;
|
|
176
|
+
if (Date.parse(at) <= Date.now())
|
|
177
|
+
throw new Error(t("schedule.onceFuture"));
|
|
178
|
+
return timezone ? { type: "once", at, timezone } : { type: "once", at };
|
|
167
179
|
}
|
|
168
|
-
|
|
169
|
-
if (Date.parse(at) <= Date.now()) throw new Error(t("schedule.onceFuture"));
|
|
170
|
-
return { type: "once", at, ...(timezone ? { timezone } : {}) };
|
|
171
|
-
}
|
|
172
|
-
throw new Error(t("schedule.start"));
|
|
180
|
+
throw new Error(t("schedule.start"));
|
|
173
181
|
}
|
|
174
|
-
|
|
175
182
|
function safeValue(value, token) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
+
let text = String(value ?? "");
|
|
184
|
+
try {
|
|
185
|
+
const parsed = new URL(text);
|
|
186
|
+
if (parsed.username || parsed.password) {
|
|
187
|
+
parsed.username = "";
|
|
188
|
+
parsed.password = "";
|
|
189
|
+
text = parsed.toString().replace(/\/$/, "");
|
|
190
|
+
}
|
|
183
191
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
192
|
+
catch {
|
|
193
|
+
// Not a URL: keep the string.
|
|
194
|
+
}
|
|
195
|
+
return token ? text.split(token).join("***") : text;
|
|
188
196
|
}
|
|
189
|
-
|
|
190
197
|
export function settingsMarkdown(settings = {}) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
198
|
+
const token = settings.token ? String(settings.token) : "";
|
|
199
|
+
const lines = [
|
|
200
|
+
`- **${t("settings.labelServer")}**: ${safeValue(settings.server || t("common.notSet"), token)}`,
|
|
201
|
+
`- **${t("settings.labelParticipant")}**: ${safeValue(settings.participant || "?", token)}`,
|
|
202
|
+
`- **${t("settings.labelLanguage")}**: ${safeValue(settings.language || "en", token)}`,
|
|
203
|
+
`- **${t("settings.labelSessionFile")}**: ${safeValue(settings.sessionFile || t("common.unknown"), token)}`,
|
|
204
|
+
`- **${t("settings.labelConfigFile")}**: ${safeValue(settings.configFile || t("settings.environmentOnly"), token)}`,
|
|
205
|
+
`- **${t("settings.labelTheme")}**: ${safeValue(settings.theme || "dark", token)}`,
|
|
206
|
+
`- **${t("settings.labelDelivery")}**: ${t("settings.deliveryValue", { seconds: Math.round((settings.pollTimeoutMs ?? 20000) / 1000) })}`,
|
|
207
|
+
`- **${t("settings.labelRequestTimeout")}**: ${t("settings.requestTimeoutValue", { seconds: Math.round((settings.requestTimeoutMs ?? 10000) / 1000) })}`,
|
|
208
|
+
`- **${t("settings.labelToken")}**: ${token ? t("settings.tokenSet") : t("common.notSet")}`,
|
|
209
|
+
`- **${t("room.labelEditing")}**: ${t("settings.editAvailable")}`,
|
|
210
|
+
];
|
|
211
|
+
return lines.join("\n");
|
|
212
|
+
}
|
|
213
|
+
export function roomSettingsMarkdown(room = {}, { participant, sessionID, canEdit = false, agentName = "", } = {}) {
|
|
214
|
+
const owner = Boolean(participant) && room.ownerId === participant;
|
|
215
|
+
const admin = owner || (participant !== undefined && (room.adminIds ?? []).includes(participant));
|
|
216
|
+
const agentAdmin = Boolean(room.adminSessionID) && room.adminSessionID === sessionID;
|
|
217
|
+
const role = owner ? t("room.roleOwner")
|
|
218
|
+
: admin ? t("room.roleAdmin")
|
|
219
|
+
: agentAdmin ? t("room.roleManagement")
|
|
220
|
+
: t("room.roleMember");
|
|
221
|
+
const policy = room.joinPolicy === "approval" ? t("room.policyApproval") : t("room.policyOpen");
|
|
222
|
+
const description = room.description ? oneLine(room.description, 300) : t("common.notSet");
|
|
223
|
+
const admins = (room.adminIds ?? []).filter(Boolean).join(", ") || t("common.none");
|
|
224
|
+
const successor = room.successorId || t("common.none");
|
|
225
|
+
const management = room.adminSessionID ? (agentName || room.adminSessionID) : t("common.none");
|
|
226
|
+
const label = (key) => `- **${t(key)}**`;
|
|
227
|
+
return [
|
|
228
|
+
`${label("room.labelName")}: ${oneLine(room.name || "?", 80)}`,
|
|
229
|
+
`${label("room.labelDescription")}: ${description}`,
|
|
230
|
+
`${label("room.labelJoinPolicy")}: ${policy}`,
|
|
231
|
+
`${label("room.labelKind")}: ${room.kind === "direct" ? t("room.kindDirect") : t("room.kindGroup")}`,
|
|
232
|
+
`${label("room.labelOwner")}: ${oneLine(room.ownerId || "?", 80)}`,
|
|
233
|
+
`${label("room.labelAdmins")}: ${admins}`,
|
|
234
|
+
`${label("room.labelSuccessor")}: ${successor}`,
|
|
235
|
+
`${label("room.labelManagement")}: ${management}`,
|
|
236
|
+
`${label("room.labelRole")}: ${role}`,
|
|
237
|
+
`${label("room.labelEditing")}: ${canEdit ? t("room.editingAvailable") : t("room.editingReadOnly")}`,
|
|
238
|
+
].join("\n");
|
|
205
239
|
}
|
|
206
|
-
|
|
207
|
-
export function roomSettingsMarkdown(room = {}, { participant, sessionID, canEdit = false, agentName = "" } = {}) {
|
|
208
|
-
const owner = Boolean(participant) && room.ownerId === participant;
|
|
209
|
-
const admin = owner || (room.adminIds ?? []).includes(participant);
|
|
210
|
-
const agentAdmin = Boolean(room.adminSessionID) && room.adminSessionID === sessionID;
|
|
211
|
-
const role = owner ? t("room.roleOwner")
|
|
212
|
-
: admin ? t("room.roleAdmin")
|
|
213
|
-
: agentAdmin ? t("room.roleManagement")
|
|
214
|
-
: t("room.roleMember");
|
|
215
|
-
const policy = room.joinPolicy === "approval" ? t("room.policyApproval") : t("room.policyOpen");
|
|
216
|
-
const description = room.description ? oneLine(room.description, 300) : t("common.notSet");
|
|
217
|
-
const admins = (room.adminIds ?? []).filter(Boolean).join(", ") || t("common.none");
|
|
218
|
-
const successor = room.successorId || t("common.none");
|
|
219
|
-
const management = room.adminSessionID ? (agentName || room.adminSessionID) : t("common.none");
|
|
220
|
-
const label = (key) => `- **${t(key)}**`;
|
|
221
|
-
return [
|
|
222
|
-
`${label("room.labelName")}: ${oneLine(room.name || "?", 80)}`,
|
|
223
|
-
`${label("room.labelDescription")}: ${description}`,
|
|
224
|
-
`${label("room.labelJoinPolicy")}: ${policy}`,
|
|
225
|
-
`${label("room.labelKind")}: ${room.kind === "direct" ? t("room.kindDirect") : t("room.kindGroup")}`,
|
|
226
|
-
`${label("room.labelOwner")}: ${oneLine(room.ownerId || "?", 80)}`,
|
|
227
|
-
`${label("room.labelAdmins")}: ${admins}`,
|
|
228
|
-
`${label("room.labelSuccessor")}: ${successor}`,
|
|
229
|
-
`${label("room.labelManagement")}: ${management}`,
|
|
230
|
-
`${label("room.labelRole")}: ${role}`,
|
|
231
|
-
`${label("room.labelEditing")}: ${canEdit ? t("room.editingAvailable") : t("room.editingReadOnly")}`,
|
|
232
|
-
].join("\n");
|
|
233
|
-
}
|