@alexsun-top/opencode-chat-room 0.8.0 → 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.
Files changed (161) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/LICENSE +2 -2
  3. package/README.md +38 -6
  4. package/README.zh-CN.md +38 -6
  5. package/cli.ts +27 -1
  6. package/dist/cli.js +5074 -3212
  7. package/package.json +23 -3
  8. package/packages/chat-room-channeld/README.md +98 -25
  9. package/packages/chat-room-channeld/dist/feishu-adapter.js +912 -149
  10. package/packages/chat-room-channeld/src/adapter.ts +36 -2
  11. package/packages/chat-room-channeld/src/config.ts +63 -1
  12. package/packages/chat-room-channeld/src/delivery.ts +6 -1
  13. package/packages/chat-room-channeld/src/feishu-adapter.ts +122 -292
  14. package/packages/chat-room-channeld/src/feishu-card.ts +27 -0
  15. package/packages/chat-room-channeld/src/feishu-inbound.ts +158 -0
  16. package/packages/chat-room-channeld/src/feishu-live.ts +355 -0
  17. package/packages/chat-room-channeld/src/feishu-send.ts +342 -0
  18. package/packages/chat-room-channeld/src/feishu-ws-frames.ts +173 -0
  19. package/packages/chat-room-channeld/src/host-helpers.ts +11 -0
  20. package/packages/chat-room-channeld/src/host.ts +120 -2
  21. package/packages/chat-room-channeld/src/inbound.ts +26 -0
  22. package/packages/chat-room-channeld/src/state.ts +17 -0
  23. package/packages/chat-room-channeld/src/stats.ts +43 -1
  24. package/server/admin-state.ts +13 -13
  25. package/server/app.ts +95 -0
  26. package/server/assets/NOTICE.txt +2 -1
  27. package/server/assets/base.css +15 -9
  28. package/server/assets/chat/announcements.js +70 -7
  29. package/server/assets/chat/doc-preview.js +184 -35
  30. package/server/assets/chat/events.js +3 -0
  31. package/server/assets/chat/files.js +46 -4
  32. package/server/assets/chat/index.js +2 -0
  33. package/server/assets/chat/integration-editor.js +163 -0
  34. package/server/assets/chat/integration-values.js +124 -0
  35. package/server/assets/chat/integrations.js +498 -0
  36. package/server/assets/chat/locales/de.js +40 -4
  37. package/server/assets/chat/locales/es.js +40 -4
  38. package/server/assets/chat/locales/fr.js +40 -4
  39. package/server/assets/chat/locales/it.js +40 -4
  40. package/server/assets/chat/locales/ja.js +40 -4
  41. package/server/assets/chat/locales/ko.js +40 -4
  42. package/server/assets/chat/markdown.js +22 -8
  43. package/server/assets/chat/messages.js +5 -5
  44. package/server/assets/chat/office-preview.js +69 -0
  45. package/server/assets/chat/panels.js +36 -0
  46. package/server/assets/chat/recall.js +58 -7
  47. package/server/assets/chat/receipts.js +15 -3
  48. package/server/assets/chat/reminders.js +69 -8
  49. package/server/assets/chat/resource-format.js +11 -0
  50. package/server/assets/chat/settings.js +30 -2
  51. package/server/assets/chat/side-pane.js +1 -2
  52. package/server/assets/chat/state.js +93 -10
  53. package/server/assets/chat/system-events.js +32 -0
  54. package/server/assets/chat/system-messages.js +23 -14
  55. package/server/assets/chat/task-row.js +0 -6
  56. package/server/assets/chat/tasks.js +121 -33
  57. package/server/assets/code-highlight.css +55 -32
  58. package/server/assets/conversation.css +123 -23
  59. package/server/assets/doc-preview.css +35 -3
  60. package/server/assets/files.css +5 -0
  61. package/server/assets/fluent-icons.svg +2 -0
  62. package/server/assets/monaco/LICENSE +21 -0
  63. package/server/assets/monaco/ThirdPartyNotices.txt +448 -0
  64. package/server/assets/monaco/codicon-jdswhhtn.ttf +0 -0
  65. package/server/assets/monaco/editor.worker.js +45 -0
  66. package/server/assets/monaco/integration-rules.css +1 -0
  67. package/server/assets/monaco/integration-rules.js +1297 -0
  68. package/server/assets/monaco/json.worker.js +77 -0
  69. package/server/assets/office/THIRD-PARTY-NOTICES.txt +11 -0
  70. package/server/assets/office/docx.bundle.js +33 -0
  71. package/server/assets/office/licenses/docx-preview-LICENSE.txt +201 -0
  72. package/server/assets/office/licenses/echarts-LICENSE.txt +222 -0
  73. package/server/assets/office/licenses/jszip-LICENSE.txt +651 -0
  74. package/server/assets/office/licenses/lodash-LICENSE.txt +47 -0
  75. package/server/assets/office/licenses/pptx-preview-LICENSE.txt +8 -0
  76. package/server/assets/office/licenses/tslib-LICENSE.txt +12 -0
  77. package/server/assets/office/licenses/uuid-LICENSE.txt +9 -0
  78. package/server/assets/office/licenses/xlsx-LICENSE.txt +201 -0
  79. package/server/assets/office/licenses/zrender-LICENSE.txt +29 -0
  80. package/server/assets/office/pptx.bundle.js +104 -0
  81. package/server/assets/office/xlsx.bundle.js +141 -0
  82. package/server/assets/recall.css +5 -4
  83. package/server/assets/responsive.css +50 -11
  84. package/server/assets/settings.css +73 -1
  85. package/server/assets/tasks.css +57 -7
  86. package/server/channel-integration.ts +519 -0
  87. package/server/channel-settings.ts +77 -0
  88. package/server/channels.ts +261 -18
  89. package/server/chat-server.ts +32 -580
  90. package/server/chat.html +187 -21
  91. package/server/http-server.ts +3 -182
  92. package/server/resource-routes.ts +16 -16
  93. package/server/routes/inbox.ts +100 -0
  94. package/server/routes/pages.ts +83 -0
  95. package/server/routes/questions.ts +39 -0
  96. package/server/routes/room-actions.ts +162 -0
  97. package/server/routes/rooms.ts +160 -0
  98. package/server/startup.ts +84 -0
  99. package/server/sw.js +4 -0
  100. package/server/task-routes.ts +1 -1
  101. package/src/center/center-client.ts +2 -10
  102. package/src/config/file-config.ts +7 -54
  103. package/src/platform/http-server.ts +182 -0
  104. package/src/protocol/addressing.ts +21 -0
  105. package/src/protocol/config.ts +58 -0
  106. package/src/protocol/room.ts +51 -0
  107. package/src/rooms/resources.ts +26 -16
  108. package/src/rooms/room-service.ts +2 -48
  109. package/src/rooms/storage.ts +329 -0
  110. package/src/rooms/tasks.ts +21 -5
  111. package/src/runtime/watch.ts +1 -1
  112. package/src/state/pg-database.ts +183 -0
  113. package/src/state/pg-migrate.ts +175 -0
  114. package/src/state/pg-sql.mjs +175 -0
  115. package/src/state/pg-worker.mjs +148 -0
  116. package/src/state/sqlite-announcements.ts +25 -0
  117. package/src/state/sqlite-database.ts +121 -0
  118. package/src/state/sqlite-legacy.ts +90 -0
  119. package/src/state/sqlite-members.ts +155 -0
  120. package/src/state/sqlite-messages.ts +288 -0
  121. package/src/state/sqlite-resources.ts +39 -0
  122. package/src/state/sqlite-rooms.ts +87 -0
  123. package/src/state/sqlite-schema.ts +80 -0
  124. package/src/state/sqlite-state-store.ts +33 -0
  125. package/src/state/sqlite-state.ts +15 -897
  126. package/src/state/sqlite-tasks.ts +65 -0
  127. package/src/state/sqlite-transaction.ts +13 -0
  128. package/src/state/sqlite.ts +21 -1
  129. package/src/state/store.ts +5 -1
  130. package/src/tui/app.mjs +32 -19
  131. package/src/tui/config.mjs +12 -4
  132. package/src/tui/i18n.mjs +38 -0
  133. package/src/tui/info-app.mjs +50 -51
  134. package/src/tui/info-content.mjs +79 -44
  135. package/src/tui/join-app.mjs +9 -9
  136. package/src/tui/locales/en.mjs +349 -0
  137. package/src/tui/locales/zh-CN.mjs +349 -0
  138. package/src/tui/main.mjs +85 -37
  139. package/src/tui/markdown.mjs +3 -2
  140. package/src/tui/mentions.mjs +3 -1
  141. package/src/tui/message-app.mjs +22 -21
  142. package/src/tui/message-view.mjs +2 -1
  143. package/src/tui/palette-app.mjs +9 -8
  144. package/src/tui/palette.mjs +30 -24
  145. package/src/tui/prefs.mjs +92 -0
  146. package/src/tui/reminder-app.mjs +18 -17
  147. package/src/tui/room-settings-app.mjs +30 -28
  148. package/src/tui/settings-app.mjs +153 -0
  149. package/src/tui/ui-content.mjs +65 -86
  150. package/src/tui/ui-help.mjs +73 -0
  151. package/src/tui/ui-overlay-view.mjs +23 -7
  152. package/src/tui/ui-suggest.mjs +6 -5
  153. package/src/tui/ui-theme.mjs +37 -33
  154. package/src/tui/ui-view.mjs +22 -7
  155. package/src/tui/ui.mjs +15 -3
  156. package/src/web/editor.worker.ts +1 -0
  157. package/src/web/integration-rules-editor.ts +439 -0
  158. package/src/web/integration-rules.ts +22 -0
  159. package/src/web/integration-schema.ts +228 -0
  160. package/src/web/json.worker.ts +1 -0
  161. package/src/web/office-viewer.ts +221 -0
@@ -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
- export const ANNOUNCEMENT_HINT = "n new · d delete · Enter read · Esc close";
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("open a joined room first", "error");
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 = "open a joined room first";
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", "Members", "Read-only · Esc close", async (room) =>
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", "Announcements", ANNOUNCEMENT_HINT, async (room) =>
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", "Questions", "Enter answer · Esc close", async (room) =>
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", "Files", "Enter download · u upload · d delete · Esc close", async (room) => {
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() || "(empty announcement)",
119
+ markdown: String(item.content ?? "").trim() || t("common.emptyAnnouncement"),
133
120
  kind: "announcements",
134
121
  };
135
- palette.hint = "d delete · Esc back";
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: `Answer "${sanitizeText(item.text).slice(0, 40)}"`,
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 = "Enter post · Esc cancel";
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: "Announcement name (existing name replaces)", value: "", action: "announcement-name", data: {} };
149
+ palette.prompt = { label: t("info.announcementName"), value: "", action: "announcement-name", data: {} };
163
150
  palette.error = "";
164
- palette.hint = "Enter next · Esc cancel";
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: `Delete file "${sanitizeText(item.resource.name)}"?`,
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 = "Enter or y deletes · n or Esc cancels";
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(`deleted ${confirm.data.name}`, "success");
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 = "Enter download · u upload · d delete · Esc close";
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: "Absolute file path (max 100 MiB)", value: "", action: "file-upload", data: {} };
201
+ palette.prompt = { label: t("info.filePath"), value: "", action: "file-upload", data: {} };
215
202
  palette.error = "";
216
- palette.hint = "Enter upload · Esc cancel";
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: `Delete announcement "${sanitizeText(selected)}"?`,
215
+ text: t("info.deleteAnnouncement", { name: sanitizeText(selected) }),
229
216
  action: "announcement-delete",
230
217
  data: { name: String(selected) },
231
218
  };
232
- palette.hint = "Enter or y deletes · n or Esc cancels";
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(`deleted announcement "${confirm.data.name}"`, "success");
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 = ANNOUNCEMENT_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 = ANNOUNCEMENT_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(`saved ${target}`, "success");
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 = "enter an announcement name";
361
+ palette.error = t("info.announcementNameRequired");
363
362
  this.touch();
364
363
  return;
365
364
  }
366
- palette.prompt = { label: `Content for "${sanitizeText(name)}"`, value: "", action: "announcement-content", data: { name } };
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(`saved announcement "${name}"`, "success");
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 = "answer text is required";
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("answer posted", "success");
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 = "enter an absolute file path";
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 = "file is too large for terminal upload; limit 100 MiB";
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(`uploaded ${path.basename(file)}`, "success");
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) {
@@ -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 time";
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" ? "agent" : "human";
37
- const activity = sanitizeText(member.activity?.state || "unknown");
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: `${self ? "●" : "○"} ${name}${self ? " (you)" : ""} · member · ${type} · ${activity}`,
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: `${sanitizeText(item.name)} · updated ${timeLabel(item.updatedAt)}`,
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: `${answered ? "✓" : "?"} ${sanitizeText(question.senderId || "?")}: ${oneLine(question.text)}${answered ? " (answered)" : ""}`,
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: `✓ ${sanitizeText(message.senderId || "?")}: ${oneLine(message.text)} (answered)`,
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: `${sanitizeText(item.name)} · ${formatBytes(item.size)} · ${sanitizeText(item.uploaderName || item.uploaderSessionID || "unknown")} · ${timeLabel(item.createdAt)}`,
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: `${sanitizeText(item.name || item.participantId || "?")} · ${item.isAgent ? "Agent" : "Human"} · ${timeLabel(item.createdAt)}`,
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
- ? `cron ${sanitizeText(item.schedule.expression)} (${sanitizeText(item.schedule.timezone || "server")})`
99
- : `once ${timeLabel(Date.parse(item.schedule?.at ?? ""))}`;
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: `${item.paused ? "⏸" : "●"} ${oneLine(item.text)} · ${schedule} · next ${next}`,
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(`invalid timezone: ${value}`);
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("cron needs 5 fields, for example: cron 0 9 * * *");
127
- if (parts.length > 6) throw new Error("cron accepts 5 fields plus an optional timezone");
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("once needs an ISO datetime, for example: once 2026-11-23T09:00");
134
- if (parts.length > 2) throw new Error("once accepts an ISO datetime plus an optional timezone");
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("once needs an ISO datetime, for example: 2026-11-23T09:00");
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("once datetime must be in the future");
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('schedule must start with "once" or "cron"');
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
- `- **Server**: ${safeValue(settings.server || "not set", token)}`,
165
- `- **Participant**: ${safeValue(settings.participant || "?", token)}`,
166
- `- **Session file**: ${safeValue(settings.sessionFile || "unknown", token)}`,
167
- `- **Config file**: ${safeValue(settings.configFile || "none (environment only)", token)}`,
168
- `- **Theme**: ${safeValue(settings.theme || "dark", token)}`,
169
- `- **Delivery**: server long-poll, ${Math.round((settings.pollTimeoutMs ?? 20000) / 1000)}s hold`,
170
- `- **Request timeout**: ${Math.round((settings.requestTimeoutMs ?? 10000) / 1000)}s`,
171
- `- **Token**: ${token ? "set (redacted)" : "not set"}`,
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 ? "owner" : admin ? "admin" : agentAdmin ? "management agent" : "member";
181
- const policy = room.joinPolicy === "approval" ? "approval" : "open";
182
- const description = room.description ? oneLine(room.description, 300) : "not set";
183
- const admins = (room.adminIds ?? []).filter(Boolean).join(", ") || "none";
184
- const successor = room.successorId || "none";
185
- const management = room.adminSessionID ? (agentName || room.adminSessionID) : "none";
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
- `- **Name**: ${oneLine(room.name || "?", 80)}`,
188
- `- **Description**: ${description}`,
189
- `- **Join policy**: ${policy}`,
190
- `- **Kind**: ${room.kind === "direct" ? "direct" : "group"}`,
191
- `- **Owner**: ${oneLine(room.ownerId || "?", 80)}`,
192
- `- **Admins**: ${admins}`,
193
- `- **Successor**: ${successor}`,
194
- `- **Management agent**: ${management}`,
195
- `- **Your role**: ${role}`,
196
- `- **Editing**: ${canEdit ? "available" : "read-only"}`,
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
  }
@@ -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 ADMIN_ERROR = "only a human administrator or the designated management agent may decide";
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", "Join requests", REVIEW_HINT, async (room) => {
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(ADMIN_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: `${decision === "approve" ? "Approve" : "Deny"} "${name}"?`,
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 = "Enter or y confirms · n or Esc cancels";
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(`${decision === "approve" ? "approved" : "denied"} ${confirm.data.name}`, "success");
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 = REVIEW_HINT;
65
- palette.error = error?.status === 403 ? ADMIN_ERROR : errorText(error);
64
+ palette.hint = reviewHint();
65
+ palette.error = error?.status === 403 ? t("join.adminError") : errorText(error);
66
66
  this.touch();
67
67
  }
68
68
  }