@alexsun-top/opencode-chat-room 0.7.8 → 0.8.1
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 +43 -1
- package/LICENSE +21 -0
- package/README.md +77 -36
- package/README.zh-CN.md +82 -41
- package/cli.ts +27 -1
- package/dist/cli.js +6905 -2764
- package/package.json +33 -3
- package/packages/chat-room-channeld/README.md +315 -0
- package/packages/chat-room-channeld/dist/feishu-adapter.js +1262 -0
- package/packages/chat-room-channeld/dist/mock-adapter.js +295 -0
- package/packages/chat-room-channeld/src/adapter.ts +509 -0
- package/packages/chat-room-channeld/src/cli.ts +124 -0
- package/packages/chat-room-channeld/src/config.ts +269 -0
- package/packages/chat-room-channeld/src/delivery.ts +163 -0
- package/packages/chat-room-channeld/src/feishu-adapter.ts +303 -0
- package/packages/chat-room-channeld/src/feishu-card.ts +27 -0
- package/packages/chat-room-channeld/src/feishu-inbound.ts +158 -0
- package/packages/chat-room-channeld/src/feishu-live.ts +355 -0
- package/packages/chat-room-channeld/src/feishu-send.ts +342 -0
- package/packages/chat-room-channeld/src/feishu-ws-frames.ts +173 -0
- package/packages/chat-room-channeld/src/framing.ts +128 -0
- package/packages/chat-room-channeld/src/host-helpers.ts +52 -0
- package/packages/chat-room-channeld/src/host.ts +627 -0
- package/packages/chat-room-channeld/src/inbound.ts +26 -0
- package/packages/chat-room-channeld/src/ingest-gate.ts +108 -0
- package/packages/chat-room-channeld/src/log.ts +26 -0
- package/packages/chat-room-channeld/src/mock-adapter.ts +206 -0
- package/packages/chat-room-channeld/src/protocol.ts +75 -0
- package/packages/chat-room-channeld/src/published.ts +37 -0
- package/packages/chat-room-channeld/src/rules.ts +127 -0
- package/packages/chat-room-channeld/src/state.ts +502 -0
- package/packages/chat-room-channeld/src/stats.ts +209 -0
- package/plugin.ts +22 -5
- package/server/addressing-routes.ts +130 -0
- package/server/admin-state.ts +13 -13
- package/server/app.ts +95 -0
- package/server/assets/NOTICE.txt +3 -2
- package/server/assets/SHIKI-LICENSE +22 -0
- package/server/assets/base.css +24 -10
- package/server/assets/chat/announcements.js +70 -7
- package/server/assets/chat/doc-preview.js +187 -39
- package/server/assets/chat/events.js +3 -0
- package/server/assets/chat/files.js +46 -4
- package/server/assets/chat/forward.js +69 -0
- package/server/assets/chat/index.js +4 -0
- package/server/assets/chat/integration-editor.js +163 -0
- package/server/assets/chat/integration-values.js +124 -0
- package/server/assets/chat/integrations.js +498 -0
- package/server/assets/chat/locales/de.js +45 -4
- package/server/assets/chat/locales/es.js +45 -4
- package/server/assets/chat/locales/fr.js +45 -4
- package/server/assets/chat/locales/it.js +45 -4
- package/server/assets/chat/locales/ja.js +45 -4
- package/server/assets/chat/locales/ko.js +45 -4
- package/server/assets/chat/markdown-footnotes.js +115 -0
- package/server/assets/chat/markdown.js +46 -43
- package/server/assets/chat/messages.js +5 -5
- package/server/assets/chat/office-preview.js +69 -0
- package/server/assets/chat/palette.js +1 -1
- package/server/assets/chat/panels.js +36 -0
- package/server/assets/chat/recall.js +58 -7
- package/server/assets/chat/receipts.js +15 -3
- package/server/assets/chat/reminders.js +69 -8
- package/server/assets/chat/replies.js +7 -1
- package/server/assets/chat/resource-format.js +11 -0
- package/server/assets/chat/settings.js +30 -2
- package/server/assets/chat/shiki.js +87 -0
- package/server/assets/chat/side-pane.js +9 -3
- package/server/assets/chat/state.js +107 -11
- package/server/assets/chat/system-events.js +32 -0
- package/server/assets/chat/system-messages.js +23 -12
- package/server/assets/chat/task-row.js +0 -6
- package/server/assets/chat/tasks.js +121 -33
- package/server/assets/code-highlight.css +74 -62
- package/server/assets/conversation.css +126 -25
- package/server/assets/doc-preview.css +36 -3
- package/server/assets/files.css +5 -0
- package/server/assets/fluent-icons.svg +2 -0
- package/server/assets/monaco/LICENSE +21 -0
- package/server/assets/monaco/ThirdPartyNotices.txt +448 -0
- package/server/assets/monaco/codicon-jdswhhtn.ttf +0 -0
- package/server/assets/monaco/editor.worker.js +45 -0
- package/server/assets/monaco/integration-rules.css +1 -0
- package/server/assets/monaco/integration-rules.js +1297 -0
- package/server/assets/monaco/json.worker.js +77 -0
- package/server/assets/office/THIRD-PARTY-NOTICES.txt +11 -0
- package/server/assets/office/docx.bundle.js +33 -0
- package/server/assets/office/licenses/docx-preview-LICENSE.txt +201 -0
- package/server/assets/office/licenses/echarts-LICENSE.txt +222 -0
- package/server/assets/office/licenses/jszip-LICENSE.txt +651 -0
- package/server/assets/office/licenses/lodash-LICENSE.txt +47 -0
- package/server/assets/office/licenses/pptx-preview-LICENSE.txt +8 -0
- package/server/assets/office/licenses/tslib-LICENSE.txt +12 -0
- package/server/assets/office/licenses/uuid-LICENSE.txt +9 -0
- package/server/assets/office/licenses/xlsx-LICENSE.txt +201 -0
- package/server/assets/{HIGHLIGHT-LICENSE → office/licenses/zrender-LICENSE.txt} +2 -2
- package/server/assets/office/pptx.bundle.js +104 -0
- package/server/assets/office/xlsx.bundle.js +141 -0
- package/server/assets/recall.css +5 -4
- package/server/assets/responsive.css +52 -8
- package/server/assets/settings.css +73 -1
- package/server/assets/shiki.bundle.js +152 -0
- package/server/assets/tasks.css +57 -7
- package/server/channel-integration.ts +519 -0
- package/server/channel-settings.ts +77 -0
- package/server/channels.ts +557 -0
- package/server/chat-server.ts +33 -558
- package/server/chat.html +195 -22
- package/server/http-server.ts +3 -182
- package/server/resource-routes.ts +16 -16
- package/server/routes/inbox.ts +100 -0
- package/server/routes/pages.ts +83 -0
- package/server/routes/questions.ts +39 -0
- package/server/routes/room-actions.ts +162 -0
- package/server/routes/rooms.ts +160 -0
- package/server/startup.ts +84 -0
- package/server/sw.js +5 -2
- package/server/task-routes.ts +1 -1
- package/skills/chatroom/SKILL.md +1 -1
- package/src/center/center-client.ts +71 -1
- package/src/config/file-config.ts +29 -42
- package/src/platform/http-server.ts +182 -0
- package/src/protocol/addressing.ts +21 -0
- package/src/protocol/config.ts +58 -0
- package/src/protocol/room.ts +51 -0
- package/src/rooms/resources.ts +26 -16
- package/src/rooms/room-service.ts +2 -48
- package/src/rooms/storage.ts +329 -0
- package/src/rooms/tasks.ts +21 -5
- package/src/runtime/v2-plugin.ts +8 -2
- package/src/runtime/watch.ts +4 -3
- package/src/state/pg-database.ts +183 -0
- package/src/state/pg-migrate.ts +175 -0
- package/src/state/pg-sql.mjs +175 -0
- package/src/state/pg-worker.mjs +148 -0
- package/src/state/sqlite-announcements.ts +25 -0
- package/src/state/sqlite-database.ts +121 -0
- package/src/state/sqlite-legacy.ts +90 -0
- package/src/state/sqlite-members.ts +155 -0
- package/src/state/sqlite-messages.ts +288 -0
- package/src/state/sqlite-resources.ts +39 -0
- package/src/state/sqlite-rooms.ts +87 -0
- package/src/state/sqlite-schema.ts +80 -0
- package/src/state/sqlite-state-store.ts +33 -0
- package/src/state/sqlite-state.ts +15 -866
- package/src/state/sqlite-tasks.ts +65 -0
- package/src/state/sqlite-transaction.ts +13 -0
- package/src/state/sqlite.ts +21 -1
- package/src/state/store.ts +13 -3
- package/src/tui/app.mjs +32 -19
- package/src/tui/config.mjs +12 -4
- package/src/tui/http.mjs +16 -2
- package/src/tui/i18n.mjs +38 -0
- package/src/tui/info-app.mjs +50 -51
- package/src/tui/info-content.mjs +79 -44
- package/src/tui/join-app.mjs +9 -9
- package/src/tui/locales/en.mjs +349 -0
- package/src/tui/locales/zh-CN.mjs +349 -0
- package/src/tui/main.mjs +85 -37
- package/src/tui/markdown.mjs +3 -2
- package/src/tui/mentions.mjs +3 -1
- package/src/tui/message-app.mjs +22 -21
- package/src/tui/message-view.mjs +2 -1
- package/src/tui/palette-app.mjs +9 -8
- package/src/tui/palette.mjs +30 -24
- package/src/tui/prefs.mjs +92 -0
- package/src/tui/reminder-app.mjs +18 -17
- package/src/tui/room-settings-app.mjs +30 -28
- package/src/tui/settings-app.mjs +153 -0
- package/src/tui/ui-content.mjs +65 -86
- package/src/tui/ui-help.mjs +73 -0
- package/src/tui/ui-overlay-view.mjs +23 -7
- package/src/tui/ui-suggest.mjs +6 -5
- package/src/tui/ui-theme.mjs +37 -33
- package/src/tui/ui-view.mjs +22 -7
- package/src/tui/ui.mjs +15 -3
- package/src/web/editor.worker.ts +1 -0
- package/src/web/integration-rules-editor.ts +439 -0
- package/src/web/integration-rules.ts +22 -0
- package/src/web/integration-schema.ts +228 -0
- package/src/web/json.worker.ts +1 -0
- package/src/web/office-viewer.ts +221 -0
- package/server/assets/highlight-10.7.3.min.js +0 -1358
package/src/tui/info-app.mjs
CHANGED
|
@@ -6,13 +6,13 @@ import {
|
|
|
6
6
|
fileRows,
|
|
7
7
|
memberRows,
|
|
8
8
|
questionRows,
|
|
9
|
-
settingsMarkdown,
|
|
10
9
|
} from "./info-content.mjs";
|
|
10
|
+
import { t } from "./i18n.mjs";
|
|
11
11
|
import { sanitizeText } from "./messages.mjs";
|
|
12
12
|
|
|
13
13
|
const errorText = (error) => (error instanceof Error ? error.message : String(error ?? "unknown error"));
|
|
14
14
|
export const MAX_UPLOAD_BYTES = 100 * 1024 * 1024;
|
|
15
|
-
|
|
15
|
+
const announcementHint = () => t("info.announcementHint");
|
|
16
16
|
|
|
17
17
|
export function createInfoPalette(kind, title, subtitle) {
|
|
18
18
|
return {
|
|
@@ -41,7 +41,7 @@ export function attachInfo(Class) {
|
|
|
41
41
|
currentInfoRoom() {
|
|
42
42
|
if (this.state.current && this.state.joined) return this.state.current;
|
|
43
43
|
this.state.palette = null;
|
|
44
|
-
this.setStatus("
|
|
44
|
+
this.setStatus(t("info.joinFirst"), "error");
|
|
45
45
|
return null;
|
|
46
46
|
},
|
|
47
47
|
|
|
@@ -51,7 +51,7 @@ export function attachInfo(Class) {
|
|
|
51
51
|
paletteRoomId(palette) {
|
|
52
52
|
const roomId = palette.roomId || this.state.current?.id;
|
|
53
53
|
if (!roomId) {
|
|
54
|
-
palette.error = "
|
|
54
|
+
palette.error = t("info.joinFirst");
|
|
55
55
|
this.touch();
|
|
56
56
|
}
|
|
57
57
|
return roomId;
|
|
@@ -82,69 +82,56 @@ export function attachInfo(Class) {
|
|
|
82
82
|
},
|
|
83
83
|
|
|
84
84
|
openMembers() {
|
|
85
|
-
return this.openInfo("members", "
|
|
85
|
+
return this.openInfo("members", t("info.members"), t("info.readOnlyHint"), async (room) =>
|
|
86
86
|
memberRows(await this.api.members(room.id), this.sessionID));
|
|
87
87
|
},
|
|
88
88
|
|
|
89
89
|
openAnnouncements() {
|
|
90
|
-
return this.openInfo("announcements", "
|
|
90
|
+
return this.openInfo("announcements", t("info.announcements"), announcementHint(), async (room) =>
|
|
91
91
|
announcementRows(await this.api.announcements(room.id)));
|
|
92
92
|
},
|
|
93
93
|
|
|
94
94
|
openQuestions() {
|
|
95
|
-
return this.openInfo("questions", "
|
|
95
|
+
return this.openInfo("questions", t("info.questions"), t("info.questionHint"), async (room) =>
|
|
96
96
|
questionRows(await this.api.questions(room.id), this.state.messages));
|
|
97
97
|
},
|
|
98
98
|
|
|
99
99
|
openFiles() {
|
|
100
|
-
return this.openInfo("files", "
|
|
100
|
+
return this.openInfo("files", t("info.files"), t("info.fileHint"), async (room) => {
|
|
101
101
|
const result = await this.api.resources(room.id, this.sessionID);
|
|
102
102
|
return fileRows(Array.isArray(result) ? result : result?.resources);
|
|
103
103
|
});
|
|
104
104
|
},
|
|
105
105
|
|
|
106
|
-
openSettings() {
|
|
107
|
-
const text = settingsMarkdown({
|
|
108
|
-
...this.settings,
|
|
109
|
-
participant: this.participant,
|
|
110
|
-
theme: this.state.theme,
|
|
111
|
-
token: this.token,
|
|
112
|
-
});
|
|
113
|
-
this.state.help = false;
|
|
114
|
-
this.state.palette = {
|
|
115
|
-
...createInfoPalette("settings", "Settings", "read-only"),
|
|
116
|
-
mode: "detail",
|
|
117
|
-
detail: { title: "Settings", markdown: text, kind: "settings" },
|
|
118
|
-
hint: "↑↓ scroll · Esc close",
|
|
119
|
-
};
|
|
120
|
-
this.touch();
|
|
121
|
-
},
|
|
122
|
-
|
|
123
106
|
async runInfoSelection() {
|
|
124
107
|
const palette = this.state.palette;
|
|
125
108
|
if (!palette || palette.mode !== "info" || palette.loading) return;
|
|
126
109
|
const item = this.paletteItems()[palette.selected];
|
|
127
110
|
if (!item) return;
|
|
111
|
+
if (palette.kind === "settings") {
|
|
112
|
+
this.editSetting(item);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
128
115
|
if (palette.kind === "announcements") {
|
|
129
116
|
palette.mode = "detail";
|
|
130
117
|
palette.detail = {
|
|
131
118
|
title: String(item.value),
|
|
132
|
-
markdown: String(item.content ?? "").trim() || "
|
|
119
|
+
markdown: String(item.content ?? "").trim() || t("common.emptyAnnouncement"),
|
|
133
120
|
kind: "announcements",
|
|
134
121
|
};
|
|
135
|
-
palette.hint = "
|
|
122
|
+
palette.hint = t("info.announcementBackHint");
|
|
136
123
|
this.touch();
|
|
137
124
|
return;
|
|
138
125
|
}
|
|
139
126
|
if (palette.kind === "questions" && item.open) {
|
|
140
127
|
palette.mode = "prompt";
|
|
141
128
|
palette.prompt = {
|
|
142
|
-
label:
|
|
129
|
+
label: t("info.answerLabel", { text: sanitizeText(item.text).slice(0, 40) }),
|
|
143
130
|
value: "",
|
|
144
131
|
action: "question-answer",
|
|
145
132
|
data: { id: String(item.value) },
|
|
146
133
|
};
|
|
147
|
-
palette.hint = "
|
|
134
|
+
palette.hint = t("palette.enterPostHint");
|
|
148
135
|
this.touch();
|
|
149
136
|
return;
|
|
150
137
|
}
|
|
@@ -159,9 +146,9 @@ export function attachInfo(Class) {
|
|
|
159
146
|
const palette = this.state.palette;
|
|
160
147
|
if (!palette || palette.mode !== "info" || palette.kind !== "announcements") return;
|
|
161
148
|
palette.mode = "prompt";
|
|
162
|
-
palette.prompt = { label: "
|
|
149
|
+
palette.prompt = { label: t("info.announcementName"), value: "", action: "announcement-name", data: {} };
|
|
163
150
|
palette.error = "";
|
|
164
|
-
palette.hint = "
|
|
151
|
+
palette.hint = t("palette.enterNextHint");
|
|
165
152
|
this.touch();
|
|
166
153
|
},
|
|
167
154
|
|
|
@@ -173,12 +160,12 @@ export function attachInfo(Class) {
|
|
|
173
160
|
palette.mode = "confirm";
|
|
174
161
|
palette.previous = { mode: "info", hint: palette.hint };
|
|
175
162
|
palette.confirm = {
|
|
176
|
-
text:
|
|
163
|
+
text: t("info.deleteFile", { name: sanitizeText(item.resource.name) }),
|
|
177
164
|
action: "file-delete",
|
|
178
165
|
data: { id: item.resource.id, name: item.resource.name },
|
|
179
166
|
};
|
|
180
167
|
palette.error = "";
|
|
181
|
-
palette.hint = "
|
|
168
|
+
palette.hint = t("palette.deleteHint");
|
|
182
169
|
this.touch();
|
|
183
170
|
},
|
|
184
171
|
|
|
@@ -192,7 +179,7 @@ export function attachInfo(Class) {
|
|
|
192
179
|
this.touch();
|
|
193
180
|
try {
|
|
194
181
|
await this.api.deleteResource(roomId, confirm.data.id, this.sessionID);
|
|
195
|
-
this.setStatus(
|
|
182
|
+
this.setStatus(t("info.fileDeleted", { name: confirm.data.name }), "success");
|
|
196
183
|
await this.openFiles();
|
|
197
184
|
} catch (error) {
|
|
198
185
|
if (this.state.palette === palette) {
|
|
@@ -200,7 +187,7 @@ export function attachInfo(Class) {
|
|
|
200
187
|
palette.confirm = null;
|
|
201
188
|
palette.previous = null;
|
|
202
189
|
palette.searching = false;
|
|
203
|
-
palette.hint = "
|
|
190
|
+
palette.hint = t("info.fileHint");
|
|
204
191
|
palette.error = errorText(error);
|
|
205
192
|
this.touch();
|
|
206
193
|
}
|
|
@@ -211,9 +198,9 @@ export function attachInfo(Class) {
|
|
|
211
198
|
const palette = this.state.palette;
|
|
212
199
|
if (!palette || palette.mode !== "info" || palette.kind !== "files") return;
|
|
213
200
|
palette.mode = "prompt";
|
|
214
|
-
palette.prompt = { label: "
|
|
201
|
+
palette.prompt = { label: t("info.filePath"), value: "", action: "file-upload", data: {} };
|
|
215
202
|
palette.error = "";
|
|
216
|
-
palette.hint = "
|
|
203
|
+
palette.hint = t("palette.enterUploadHint");
|
|
217
204
|
this.touch();
|
|
218
205
|
},
|
|
219
206
|
|
|
@@ -225,11 +212,11 @@ export function attachInfo(Class) {
|
|
|
225
212
|
palette.error = "";
|
|
226
213
|
palette.previous = { mode: "info", hint: palette.hint };
|
|
227
214
|
palette.confirm = {
|
|
228
|
-
text:
|
|
215
|
+
text: t("info.deleteAnnouncement", { name: sanitizeText(selected) }),
|
|
229
216
|
action: "announcement-delete",
|
|
230
217
|
data: { name: String(selected) },
|
|
231
218
|
};
|
|
232
|
-
palette.hint = "
|
|
219
|
+
palette.hint = t("palette.deleteHint");
|
|
233
220
|
this.touch();
|
|
234
221
|
},
|
|
235
222
|
|
|
@@ -262,7 +249,7 @@ export function attachInfo(Class) {
|
|
|
262
249
|
this.touch();
|
|
263
250
|
try {
|
|
264
251
|
await this.api.deleteAnnouncement(palette.roomId, confirm.data.name, this.sessionID);
|
|
265
|
-
this.setStatus(
|
|
252
|
+
this.setStatus(t("info.announcementDeleted", { name: confirm.data.name }), "success");
|
|
266
253
|
await this.openAnnouncements();
|
|
267
254
|
} catch (error) {
|
|
268
255
|
if (this.state.palette === palette) {
|
|
@@ -286,7 +273,7 @@ export function attachInfo(Class) {
|
|
|
286
273
|
palette.hint = previous.hint ?? "";
|
|
287
274
|
} else {
|
|
288
275
|
palette.mode = "info";
|
|
289
|
-
palette.hint =
|
|
276
|
+
palette.hint = announcementHint();
|
|
290
277
|
}
|
|
291
278
|
this.touch();
|
|
292
279
|
},
|
|
@@ -294,13 +281,21 @@ export function attachInfo(Class) {
|
|
|
294
281
|
backFromDetail() {
|
|
295
282
|
const palette = this.state.palette;
|
|
296
283
|
if (!palette) return;
|
|
284
|
+
if (palette.previous?.mode === "info") {
|
|
285
|
+
palette.mode = "info";
|
|
286
|
+
palette.detail = null;
|
|
287
|
+
palette.hint = palette.previous.hint ?? t("palette.listHint");
|
|
288
|
+
palette.previous = null;
|
|
289
|
+
this.touch();
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
297
292
|
if (palette.kind !== "announcements") {
|
|
298
293
|
this.closePalette();
|
|
299
294
|
return;
|
|
300
295
|
}
|
|
301
296
|
palette.mode = "info";
|
|
302
297
|
palette.detail = null;
|
|
303
|
-
palette.hint =
|
|
298
|
+
palette.hint = announcementHint();
|
|
304
299
|
this.touch();
|
|
305
300
|
},
|
|
306
301
|
|
|
@@ -329,7 +324,7 @@ export function attachInfo(Class) {
|
|
|
329
324
|
}
|
|
330
325
|
await writeFile(target, payload.bytes ?? payload);
|
|
331
326
|
this.closePalette();
|
|
332
|
-
this.setStatus(
|
|
327
|
+
this.setStatus(t("info.fileSaved", { target }), "success");
|
|
333
328
|
} catch (error) {
|
|
334
329
|
if (this.state.palette === palette) {
|
|
335
330
|
palette.searching = false;
|
|
@@ -342,6 +337,10 @@ export function attachInfo(Class) {
|
|
|
342
337
|
async submitCommandPrompt(prompt, value) {
|
|
343
338
|
const palette = this.state.palette;
|
|
344
339
|
if (!palette || palette.mode !== "prompt") return;
|
|
340
|
+
if (typeof prompt.action === "string" && prompt.action.startsWith("settings-")) {
|
|
341
|
+
await this.submitPreferencePrompt(prompt, value);
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
345
344
|
if (typeof prompt.action === "string" && prompt.action.startsWith("reminder-")) {
|
|
346
345
|
await this.submitReminderPrompt(prompt, value);
|
|
347
346
|
return;
|
|
@@ -359,11 +358,11 @@ export function attachInfo(Class) {
|
|
|
359
358
|
if (prompt.action === "announcement-name") {
|
|
360
359
|
const name = String(value ?? "").trim();
|
|
361
360
|
if (!name) {
|
|
362
|
-
palette.error = "
|
|
361
|
+
palette.error = t("info.announcementNameRequired");
|
|
363
362
|
this.touch();
|
|
364
363
|
return;
|
|
365
364
|
}
|
|
366
|
-
palette.prompt = { label:
|
|
365
|
+
palette.prompt = { label: t("info.announcementContent", { name: sanitizeText(name) }), value: "", action: "announcement-content", data: { name } };
|
|
367
366
|
palette.error = "";
|
|
368
367
|
this.touch();
|
|
369
368
|
return;
|
|
@@ -375,7 +374,7 @@ export function attachInfo(Class) {
|
|
|
375
374
|
this.touch();
|
|
376
375
|
try {
|
|
377
376
|
await this.api.saveAnnouncement(roomId, name, String(value ?? ""), this.sessionID);
|
|
378
|
-
this.setStatus(
|
|
377
|
+
this.setStatus(t("info.announcementSaved", { name }), "success");
|
|
379
378
|
await this.openAnnouncements();
|
|
380
379
|
} catch (error) {
|
|
381
380
|
if (this.state.palette === palette) {
|
|
@@ -389,7 +388,7 @@ export function attachInfo(Class) {
|
|
|
389
388
|
if (prompt.action === "question-answer") {
|
|
390
389
|
const answer = String(value ?? "").trim();
|
|
391
390
|
if (!answer) {
|
|
392
|
-
palette.error = "
|
|
391
|
+
palette.error = t("info.answerRequired");
|
|
393
392
|
this.touch();
|
|
394
393
|
return;
|
|
395
394
|
}
|
|
@@ -397,7 +396,7 @@ export function attachInfo(Class) {
|
|
|
397
396
|
this.touch();
|
|
398
397
|
try {
|
|
399
398
|
await this.api.answerQuestion(roomId, prompt.data?.id, this.sessionID, answer);
|
|
400
|
-
this.setStatus("
|
|
399
|
+
this.setStatus(t("info.answerPosted"), "success");
|
|
401
400
|
await this.openQuestions();
|
|
402
401
|
} catch (error) {
|
|
403
402
|
if (this.state.palette === palette) {
|
|
@@ -412,7 +411,7 @@ export function attachInfo(Class) {
|
|
|
412
411
|
const file = String(value ?? "").trim();
|
|
413
412
|
const path = await import("node:path");
|
|
414
413
|
if (!file || !path.isAbsolute(file)) {
|
|
415
|
-
palette.error = "
|
|
414
|
+
palette.error = t("info.filePathRequired");
|
|
416
415
|
this.touch();
|
|
417
416
|
return;
|
|
418
417
|
}
|
|
@@ -423,13 +422,13 @@ export function attachInfo(Class) {
|
|
|
423
422
|
const info = await fs.stat(file);
|
|
424
423
|
if (info.size > MAX_UPLOAD_BYTES) {
|
|
425
424
|
palette.searching = false;
|
|
426
|
-
palette.error = "
|
|
425
|
+
palette.error = t("info.fileTooLarge");
|
|
427
426
|
this.touch();
|
|
428
427
|
return;
|
|
429
428
|
}
|
|
430
429
|
const bytes = new Uint8Array(await fs.readFile(file));
|
|
431
430
|
await this.api.uploadResource(roomId, this.sessionID, path.basename(file), bytes);
|
|
432
|
-
this.setStatus(
|
|
431
|
+
this.setStatus(t("info.fileUploaded", { name: path.basename(file) }), "success");
|
|
433
432
|
await this.openFiles();
|
|
434
433
|
} catch (error) {
|
|
435
434
|
if (this.state.palette === palette) {
|
package/src/tui/info-content.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Pure formatting for the CLI parity commands. No terminal or network code, so
|
|
2
2
|
// the row text and the settings redaction can be checked directly in tests.
|
|
3
3
|
import { sanitizeText } from "./messages.mjs";
|
|
4
|
+
import { t } from "./i18n.mjs";
|
|
4
5
|
|
|
5
6
|
const oneLine = (value, max = 100) => {
|
|
6
7
|
const text = sanitizeText(value).replace(/\s+/g, " ").trim();
|
|
@@ -9,7 +10,7 @@ const oneLine = (value, max = 100) => {
|
|
|
9
10
|
|
|
10
11
|
function timeLabel(value) {
|
|
11
12
|
const ms = typeof value === "number" ? value : Date.parse(String(value ?? ""));
|
|
12
|
-
if (!Number.isFinite(ms)) return "unknown
|
|
13
|
+
if (!Number.isFinite(ms)) return t("time.unknown");
|
|
13
14
|
const date = new Date(ms);
|
|
14
15
|
const pad = (part) => String(part).padStart(2, "0");
|
|
15
16
|
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
|
@@ -33,10 +34,15 @@ export function memberRows(members, selfID) {
|
|
|
33
34
|
return (Array.isArray(members) ? members : []).map((member) => {
|
|
34
35
|
const self = Boolean(selfID) && member.sessionID === selfID;
|
|
35
36
|
const name = sanitizeText(member.name || member.sessionID || "?");
|
|
36
|
-
const type = member.type === "agent" ? "
|
|
37
|
-
const activity = sanitizeText(member.activity?.state || "
|
|
37
|
+
const type = member.type === "agent" ? t("member.typeAgent") : t("member.typeHuman");
|
|
38
|
+
const activity = sanitizeText(member.activity?.state || t("member.activityUnknown"));
|
|
38
39
|
return {
|
|
39
|
-
name:
|
|
40
|
+
name: t("member.row", {
|
|
41
|
+
marker: self ? "●" : "○",
|
|
42
|
+
name: self ? t("member.self", { name }) : name,
|
|
43
|
+
type,
|
|
44
|
+
activity,
|
|
45
|
+
}),
|
|
40
46
|
value: String(member.sessionID ?? name),
|
|
41
47
|
};
|
|
42
48
|
});
|
|
@@ -44,7 +50,7 @@ export function memberRows(members, selfID) {
|
|
|
44
50
|
|
|
45
51
|
export function announcementRows(announcements) {
|
|
46
52
|
return (Array.isArray(announcements) ? announcements : []).map((item) => ({
|
|
47
|
-
name:
|
|
53
|
+
name: t("announcement.row", { name: sanitizeText(item.name), time: timeLabel(item.updatedAt) }),
|
|
48
54
|
value: String(item.name),
|
|
49
55
|
content: String(item.content ?? ""),
|
|
50
56
|
updatedAt: item.updatedAt,
|
|
@@ -54,11 +60,17 @@ export function announcementRows(announcements) {
|
|
|
54
60
|
export function questionRows(open, messages = []) {
|
|
55
61
|
const rows = [];
|
|
56
62
|
const seen = new Set();
|
|
63
|
+
const rowOf = (marker, sender, text, answered) => t("question.row", {
|
|
64
|
+
marker,
|
|
65
|
+
sender: sanitizeText(sender || "?"),
|
|
66
|
+
text: oneLine(text),
|
|
67
|
+
answered: answered ? t("question.answered") : "",
|
|
68
|
+
});
|
|
57
69
|
for (const question of Array.isArray(open) ? open : []) {
|
|
58
70
|
seen.add(question.id);
|
|
59
71
|
const answered = Boolean(question.answeredByMessageID);
|
|
60
72
|
rows.push({
|
|
61
|
-
name:
|
|
73
|
+
name: rowOf(answered ? "✓" : "?", question.senderId, question.text, answered),
|
|
62
74
|
value: String(question.id),
|
|
63
75
|
text: String(question.text ?? ""),
|
|
64
76
|
open: !answered,
|
|
@@ -68,7 +80,7 @@ export function questionRows(open, messages = []) {
|
|
|
68
80
|
if (!message?.isQuestion || !message.answeredByMessageID || seen.has(message.id)) continue;
|
|
69
81
|
seen.add(message.id);
|
|
70
82
|
rows.push({
|
|
71
|
-
name:
|
|
83
|
+
name: rowOf("✓", message.senderId, message.text, true),
|
|
72
84
|
value: String(message.id),
|
|
73
85
|
open: false,
|
|
74
86
|
});
|
|
@@ -78,7 +90,12 @@ export function questionRows(open, messages = []) {
|
|
|
78
90
|
|
|
79
91
|
export function fileRows(resources) {
|
|
80
92
|
return (Array.isArray(resources) ? resources : []).map((item) => ({
|
|
81
|
-
name:
|
|
93
|
+
name: t("file.row", {
|
|
94
|
+
name: sanitizeText(item.name),
|
|
95
|
+
size: formatBytes(item.size),
|
|
96
|
+
uploader: sanitizeText(item.uploaderName || item.uploaderSessionID || t("file.uploaderUnknown")),
|
|
97
|
+
time: timeLabel(item.createdAt),
|
|
98
|
+
}),
|
|
82
99
|
value: String(item.id),
|
|
83
100
|
resource: item,
|
|
84
101
|
}));
|
|
@@ -86,7 +103,11 @@ export function fileRows(resources) {
|
|
|
86
103
|
|
|
87
104
|
export function joinRequestRows(requests) {
|
|
88
105
|
return (Array.isArray(requests) ? requests : []).map((item) => ({
|
|
89
|
-
name:
|
|
106
|
+
name: t("join.row", {
|
|
107
|
+
name: sanitizeText(item.name || item.participantId || "?"),
|
|
108
|
+
type: item.isAgent ? t("common.agent") : t("common.human"),
|
|
109
|
+
time: timeLabel(item.createdAt),
|
|
110
|
+
}),
|
|
90
111
|
value: String(item.sessionID),
|
|
91
112
|
request: item,
|
|
92
113
|
}));
|
|
@@ -95,11 +116,19 @@ export function joinRequestRows(requests) {
|
|
|
95
116
|
export function reminderRows(reminders) {
|
|
96
117
|
return (Array.isArray(reminders) ? reminders : []).map((item) => {
|
|
97
118
|
const schedule = item.schedule?.type === "cron"
|
|
98
|
-
?
|
|
99
|
-
|
|
119
|
+
? t("reminder.cron", {
|
|
120
|
+
expression: sanitizeText(item.schedule.expression),
|
|
121
|
+
timezone: sanitizeText(item.schedule.timezone || t("common.server")),
|
|
122
|
+
})
|
|
123
|
+
: t("reminder.once", { time: timeLabel(Date.parse(item.schedule?.at ?? "")) });
|
|
100
124
|
const next = typeof item.nextRunAt === "string" ? timeLabel(Date.parse(item.nextRunAt)) : timeLabel(item.nextRunAt);
|
|
101
125
|
return {
|
|
102
|
-
name:
|
|
126
|
+
name: t("reminder.row", {
|
|
127
|
+
marker: item.paused ? "⏸" : "●",
|
|
128
|
+
text: oneLine(item.text),
|
|
129
|
+
schedule,
|
|
130
|
+
time: next,
|
|
131
|
+
}),
|
|
103
132
|
value: String(item.id),
|
|
104
133
|
paused: Boolean(item.paused),
|
|
105
134
|
text: String(item.text ?? ""),
|
|
@@ -114,7 +143,7 @@ function timezoneOrThrow(value) {
|
|
|
114
143
|
new Intl.DateTimeFormat("en-US", { timeZone: value });
|
|
115
144
|
return value;
|
|
116
145
|
} catch {
|
|
117
|
-
throw new Error(
|
|
146
|
+
throw new Error(t("schedule.timezone", { value }));
|
|
118
147
|
}
|
|
119
148
|
}
|
|
120
149
|
|
|
@@ -123,24 +152,24 @@ export function parseReminderSchedule(input) {
|
|
|
123
152
|
const parts = String(input ?? "").trim().split(/\s+/);
|
|
124
153
|
const kind = parts.shift()?.toLowerCase();
|
|
125
154
|
if (kind === "cron") {
|
|
126
|
-
if (parts.length < 5) throw new Error("
|
|
127
|
-
if (parts.length > 6) throw new Error("
|
|
155
|
+
if (parts.length < 5) throw new Error(t("schedule.cronFields"));
|
|
156
|
+
if (parts.length > 6) throw new Error(t("schedule.cronAccept"));
|
|
128
157
|
const expression = parts.slice(0, 5).join(" ");
|
|
129
158
|
const timezone = parts[5] ? timezoneOrThrow(parts[5]) : undefined;
|
|
130
159
|
return { type: "cron", expression, ...(timezone ? { timezone } : {}) };
|
|
131
160
|
}
|
|
132
161
|
if (kind === "once") {
|
|
133
|
-
if (!parts.length) throw new Error("
|
|
134
|
-
if (parts.length > 2) throw new Error("
|
|
162
|
+
if (!parts.length) throw new Error(t("schedule.onceNeeds"));
|
|
163
|
+
if (parts.length > 2) throw new Error(t("schedule.onceAccept"));
|
|
135
164
|
const at = parts[0];
|
|
136
165
|
if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(at) || !Number.isFinite(Date.parse(at))) {
|
|
137
|
-
throw new Error("
|
|
166
|
+
throw new Error(t("schedule.onceInvalid"));
|
|
138
167
|
}
|
|
139
168
|
const timezone = parts[1] ? timezoneOrThrow(parts[1]) : undefined;
|
|
140
|
-
if (Date.parse(at) <= Date.now()) throw new Error("
|
|
169
|
+
if (Date.parse(at) <= Date.now()) throw new Error(t("schedule.onceFuture"));
|
|
141
170
|
return { type: "once", at, ...(timezone ? { timezone } : {}) };
|
|
142
171
|
}
|
|
143
|
-
throw new Error(
|
|
172
|
+
throw new Error(t("schedule.start"));
|
|
144
173
|
}
|
|
145
174
|
|
|
146
175
|
function safeValue(value, token) {
|
|
@@ -161,14 +190,16 @@ function safeValue(value, token) {
|
|
|
161
190
|
export function settingsMarkdown(settings = {}) {
|
|
162
191
|
const token = settings.token ? String(settings.token) : "";
|
|
163
192
|
const lines = [
|
|
164
|
-
`-
|
|
165
|
-
`-
|
|
166
|
-
`-
|
|
167
|
-
`-
|
|
168
|
-
`-
|
|
169
|
-
`-
|
|
170
|
-
`-
|
|
171
|
-
`-
|
|
193
|
+
`- **${t("settings.labelServer")}**: ${safeValue(settings.server || t("common.notSet"), token)}`,
|
|
194
|
+
`- **${t("settings.labelParticipant")}**: ${safeValue(settings.participant || "?", token)}`,
|
|
195
|
+
`- **${t("settings.labelLanguage")}**: ${safeValue(settings.language || "en", token)}`,
|
|
196
|
+
`- **${t("settings.labelSessionFile")}**: ${safeValue(settings.sessionFile || t("common.unknown"), token)}`,
|
|
197
|
+
`- **${t("settings.labelConfigFile")}**: ${safeValue(settings.configFile || t("settings.environmentOnly"), token)}`,
|
|
198
|
+
`- **${t("settings.labelTheme")}**: ${safeValue(settings.theme || "dark", token)}`,
|
|
199
|
+
`- **${t("settings.labelDelivery")}**: ${t("settings.deliveryValue", { seconds: Math.round((settings.pollTimeoutMs ?? 20000) / 1000) })}`,
|
|
200
|
+
`- **${t("settings.labelRequestTimeout")}**: ${t("settings.requestTimeoutValue", { seconds: Math.round((settings.requestTimeoutMs ?? 10000) / 1000) })}`,
|
|
201
|
+
`- **${t("settings.labelToken")}**: ${token ? t("settings.tokenSet") : t("common.notSet")}`,
|
|
202
|
+
`- **${t("room.labelEditing")}**: ${t("settings.editAvailable")}`,
|
|
172
203
|
];
|
|
173
204
|
return lines.join("\n");
|
|
174
205
|
}
|
|
@@ -177,22 +208,26 @@ export function roomSettingsMarkdown(room = {}, { participant, sessionID, canEdi
|
|
|
177
208
|
const owner = Boolean(participant) && room.ownerId === participant;
|
|
178
209
|
const admin = owner || (room.adminIds ?? []).includes(participant);
|
|
179
210
|
const agentAdmin = Boolean(room.adminSessionID) && room.adminSessionID === sessionID;
|
|
180
|
-
const role = owner ? "
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const
|
|
185
|
-
const
|
|
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)}**`;
|
|
186
221
|
return [
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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")}`,
|
|
197
232
|
].join("\n");
|
|
198
233
|
}
|
package/src/tui/join-app.mjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
// Pending join-request review for the current room. Reuses the info/confirm
|
|
2
2
|
// overlay and maps 403s to the server's reviewer rule in plain language.
|
|
3
3
|
import { joinRequestRows } from "./info-content.mjs";
|
|
4
|
+
import { t } from "./i18n.mjs";
|
|
4
5
|
|
|
5
|
-
const
|
|
6
|
-
const REVIEW_HINT = "Enter approve · d deny · Esc close";
|
|
6
|
+
const reviewHint = () => t("join.reviewHint");
|
|
7
7
|
const errorText = (error) => (error instanceof Error ? error.message : String(error ?? "unknown error"));
|
|
8
8
|
|
|
9
9
|
export function attachJoinRequests(Class) {
|
|
10
10
|
Object.assign(Class.prototype, {
|
|
11
11
|
openJoinRequests() {
|
|
12
|
-
return this.openInfo("join-requests", "
|
|
12
|
+
return this.openInfo("join-requests", t("join.title"), reviewHint(), async (room) => {
|
|
13
13
|
try {
|
|
14
14
|
const result = await this.api.joinRequests(room.id, this.sessionID);
|
|
15
15
|
return joinRequestRows(result.requests);
|
|
16
16
|
} catch (error) {
|
|
17
|
-
if (error?.status === 403) throw new Error(
|
|
17
|
+
if (error?.status === 403) throw new Error(t("join.adminError"));
|
|
18
18
|
throw error;
|
|
19
19
|
}
|
|
20
20
|
});
|
|
@@ -34,12 +34,12 @@ export function attachJoinRequests(Class) {
|
|
|
34
34
|
palette.mode = "confirm";
|
|
35
35
|
palette.previous = { mode: "info", hint: palette.hint };
|
|
36
36
|
palette.confirm = {
|
|
37
|
-
text:
|
|
37
|
+
text: decision === "approve" ? t("join.approve", { name }) : t("join.deny", { name }),
|
|
38
38
|
action: `join-${decision}`,
|
|
39
39
|
data: { sessionID: request.value, name },
|
|
40
40
|
};
|
|
41
41
|
palette.error = "";
|
|
42
|
-
palette.hint = "
|
|
42
|
+
palette.hint = t("palette.confirmHint");
|
|
43
43
|
this.touch();
|
|
44
44
|
},
|
|
45
45
|
|
|
@@ -53,7 +53,7 @@ export function attachJoinRequests(Class) {
|
|
|
53
53
|
this.touch();
|
|
54
54
|
try {
|
|
55
55
|
await this.api.decideJoin(roomId, confirm.data.sessionID, this.sessionID, decision);
|
|
56
|
-
this.setStatus(
|
|
56
|
+
this.setStatus(t(decision === "approve" ? "join.approved" : "join.denied", { name: confirm.data.name }), "success");
|
|
57
57
|
await this.openJoinRequests();
|
|
58
58
|
} catch (error) {
|
|
59
59
|
if (this.state.palette === palette) {
|
|
@@ -61,8 +61,8 @@ export function attachJoinRequests(Class) {
|
|
|
61
61
|
palette.confirm = null;
|
|
62
62
|
palette.previous = null;
|
|
63
63
|
palette.searching = false;
|
|
64
|
-
palette.hint =
|
|
65
|
-
palette.error = error?.status === 403 ?
|
|
64
|
+
palette.hint = reviewHint();
|
|
65
|
+
palette.error = error?.status === 403 ? t("join.adminError") : errorText(error);
|
|
66
66
|
this.touch();
|
|
67
67
|
}
|
|
68
68
|
}
|