@alexsun-top/opencode-chat-room 0.8.4 → 0.8.5
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 +5 -1
- package/README.md +4 -4
- package/README.zh-CN.md +4 -4
- package/cli.ts +1 -1
- package/dist/cli.js +35 -16
- package/package.json +14 -11
- package/packages/chat-room-channeld/README.md +3 -2
- package/packages/chat-room-channeld/src/inbound.ts +3 -6
- 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 +107 -99
- package/packages/chat-room-channeld/src/pg/worker.mts +166 -0
- package/plugin.ts +1 -1
- package/server/assets/chat/admin.js +4 -1
- package/server/assets/chat/announcements.js +3 -0
- package/server/assets/chat/attachments.js +3 -3
- package/server/assets/chat/clipboard.js +1 -1
- package/server/assets/chat/copy-action.js +1 -1
- package/server/assets/chat/doc-preview.js +1 -1
- package/server/assets/chat/editor.js +11 -7
- package/server/assets/chat/events.js +7 -5
- package/server/assets/chat/files.js +5 -1
- package/server/assets/chat/integration-editor.js +2 -0
- package/server/assets/chat/integrations.js +1 -1
- package/server/assets/chat/join-requests.js +1 -1
- package/server/assets/chat/markdown-footnotes.js +8 -7
- package/server/assets/chat/markdown.js +6 -5
- package/server/assets/chat/members.js +3 -3
- package/server/assets/chat/mentions.js +8 -5
- package/server/assets/chat/message-cache.js +1 -1
- package/server/assets/chat/message-polling.js +2 -2
- package/server/assets/chat/message-window.js +1 -1
- package/server/assets/chat/messages.js +17 -3
- package/server/assets/chat/office-preview.js +3 -3
- package/server/assets/chat/palette.js +5 -3
- package/server/assets/chat/panels.js +19 -0
- package/server/assets/chat/questions.js +3 -2
- package/server/assets/chat/reminders.js +3 -0
- package/server/assets/chat/replies.js +6 -3
- package/server/assets/chat/resource-format.js +2 -2
- package/server/assets/chat/rooms.js +7 -4
- package/server/assets/chat/settings.js +4 -3
- package/server/assets/chat/shortcuts.js +3 -1
- package/server/assets/chat/side-pane.js +1 -1
- package/server/assets/chat/state.js +30 -11
- package/server/assets/chat/system-events.js +3 -2
- package/server/assets/chat/system-messages.js +15 -15
- package/server/assets/chat/tasks.js +4 -3
- package/server/assets/chat/window-controls.js +3 -2
- package/server/assets/conversation.css +14 -2
- package/server/assets/doc-preview.css +6 -0
- 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/sw.js +3 -1
- package/skills/chatroom/SKILL.md +9 -0
- package/src/README.md +1 -1
- package/src/agent/agent-receipts.ts +12 -4
- package/src/center/center-client.ts +1 -1
- package/src/state/pg-sql.mjs +157 -142
- package/src/state/pg-sql.mts +175 -0
- package/src/state/pg-worker.mjs +107 -99
- package/src/state/pg-worker.mts +166 -0
- package/src/state/store.ts +21 -7
- package/src/tui/app-types.mjs +1 -0
- package/src/tui/app-types.mts +175 -0
- package/src/tui/app.mjs +426 -423
- package/src/tui/app.mts +500 -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 +257 -242
- package/src/tui/room-settings-app.mts +301 -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/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
-
-
|
|
5
|
+
- When a server stops responding during session restore, show Retry and Settings after the 20-second request deadline instead of spinning indefinitely.
|
|
6
|
+
- Upgrade to TypeScript 7. One root `tsconfig.json` now checks the web client, service worker, and server with the same strict settings. Web assets still build to their existing URLs.
|
|
7
|
+
- Type the terminal client, Codex plugin, PostgreSQL workers, and release tooling. The terminal and workers still run from the same `.mjs` paths, and the compiled Codex plugin still supports Node 20.
|
|
8
|
+
- Upgrade the interactive terminal client to OpenTUI 0.9.12 and require Bun 1.3.14+. Use `bunx --bun` to include OpenTUI. Server support for Node.js 24.2+, Deno 2, and Bun is unchanged.
|
|
9
|
+
- Keep the web client and service worker sources in TypeScript under `server/chat-src` and `server/sw.ts`, built by `tsc` into the existing `server/assets/chat/*.js` and `server/sw.js` URLs. All 70 sources are covered by strict TypeScript checking; the published package and image still contain only generated JavaScript, and two builds are byte-for-byte reproducible.
|
|
6
10
|
- When the app opens offline without a restored session, the cached shell now shows a Settings button next to Retry, so local appearance, language, and connection settings stay reachable without the server. Room data still requires a connection.
|
|
7
11
|
- Serve the PWA shell and static assets from the service worker cache first, so opening the app no longer re-downloads every precached file from the server. Install reports downloading, ready with the number of optional cache gaps, or failed; a missing shell or chat entry module fails the install, while a missing optional asset becomes a runtime miss. The update prompt appears only for a waiting worker and never reloads on its own.
|
|
8
12
|
- Add an optional PostgreSQL backend to Channel D. Set `CHAT_ROOM_DATABASE_URL` to share the same `ChannelState` implementation on PostgreSQL 16 with `pg_advisory_xact_lock` serialization, or leave it unset for SQLite. `channeld migrate --state <sqlite> --to-postgres <url>` copies events, deliveries, receipts, and echoes with primary keys, ingress sequences, echo timestamps, per-table counts, and non-empty target refusal; removing the variable rolls back without touching SQLite. Single-instance only.
|
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ When upgrading, quit OpenCode first or run `opencode plugin add @alexsun-top/ope
|
|
|
26
26
|
On a machine reachable by the other devices:
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
|
-
npx --yes --package=@alexsun-top/opencode-chat-room@0.8.
|
|
29
|
+
npx --yes --package=@alexsun-top/opencode-chat-room@0.8.5 -- opencode-chat-room --host 0.0.0.0 --port 4399 --token 'your-password'
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
The server runs on Node.js 24.2+, Deno 2, or Bun. On each OpenCode machine, set the address and the same token, then start OpenCode:
|
|
@@ -46,7 +46,7 @@ Open `http://SERVER_IP:4399/chat` and enter the token in Settings. Instead of en
|
|
|
46
46
|
```bash
|
|
47
47
|
docker run --rm -p 4399:4399 -v chat-room-data:/data \
|
|
48
48
|
-e CHAT_ROOM_SERVER_TOKEN='your-password' \
|
|
49
|
-
ghcr.io/agentsyaml/opencode-chat-room:v0.8.
|
|
49
|
+
ghcr.io/agentsyaml/opencode-chat-room:v0.8.5
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
Rooms and files live in the `/data` volume; keep it across upgrades. A host bind mount must be writable by uid `10001`.
|
|
@@ -60,7 +60,7 @@ For Docker Compose, PostgreSQL state, S3-compatible storage, and all environment
|
|
|
60
60
|
- **Files:** attach, drag, or paste up to 500 MiB; preview images, media, Markdown, text, code, PDF, Word, Excel, and PowerPoint; open any preview full screen; download or delete.
|
|
61
61
|
- **Tasks and reminders:** track tasks in a side pane or modal; schedule one-time or cron reminders.
|
|
62
62
|
- **Search and shortcuts:** Alt+Space or Ctrl+P searches messages; `/` filters commands. More shortcuts are in Settings.
|
|
63
|
-
- **Terminal:** run `bunx --
|
|
63
|
+
- **Terminal (Bun 1.3.14+):** run `bunx --bun @alexsun-top/opencode-chat-room@0.8.5 cli` against the same server.
|
|
64
64
|
- **Web app:** installs to a phone home screen and starts offline from cache; chat data is never cached.
|
|
65
65
|
|
|
66
66
|
## Optional services
|
|
@@ -77,4 +77,4 @@ S3-compatible storage and PostgreSQL state are configured through environment va
|
|
|
77
77
|
|
|
78
78
|
## License
|
|
79
79
|
|
|
80
|
-
MIT
|
|
80
|
+
MIT
|
package/README.zh-CN.md
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
在一台其他设备可以访问的机器上运行:
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
|
-
npx --yes --package=@alexsun-top/opencode-chat-room@0.8.
|
|
29
|
+
npx --yes --package=@alexsun-top/opencode-chat-room@0.8.5 -- opencode-chat-room --host 0.0.0.0 --port 4399 --token 'your-password'
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
服务端支持 Node.js 24.2+、Deno 2 或 Bun。在每台 OpenCode 机器上设置地址和同一个 token,然后启动 OpenCode:
|
|
@@ -46,7 +46,7 @@ opencode
|
|
|
46
46
|
```bash
|
|
47
47
|
docker run --rm -p 4399:4399 -v chat-room-data:/data \
|
|
48
48
|
-e CHAT_ROOM_SERVER_TOKEN='your-password' \
|
|
49
|
-
ghcr.io/agentsyaml/opencode-chat-room:v0.8.
|
|
49
|
+
ghcr.io/agentsyaml/opencode-chat-room:v0.8.5
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
房间和文件保存在 `/data` 卷里,升级时不要删除。宿主目录挂载必须允许 uid `10001` 写入。
|
|
@@ -60,7 +60,7 @@ Docker Compose、PostgreSQL 状态、S3 兼容存储和全部环境变量见[部
|
|
|
60
60
|
- **文件:** 添加、拖入或粘贴最大 500 MiB 的文件;预览图片、媒体、Markdown、文本、代码、PDF、Word、Excel 和 PowerPoint;全屏查看预览;下载或删除。
|
|
61
61
|
- **任务和提醒:** 在侧栏或弹窗里跟踪任务;设置一次性或 cron 提醒。
|
|
62
62
|
- **搜索和快捷键:** Alt+Space 或 Ctrl+P 搜索消息,`/` 过滤命令;更多快捷键在设置里。
|
|
63
|
-
-
|
|
63
|
+
- **终端(Bun 1.3.14+):** 运行 `bunx --bun @alexsun-top/opencode-chat-room@0.8.5 cli` 连接同一个服务端。
|
|
64
64
|
- **网页应用:** 可安装到手机主屏,离线时从缓存启动;聊天数据不会缓存。
|
|
65
65
|
|
|
66
66
|
## 可选服务
|
|
@@ -77,4 +77,4 @@ S3 兼容存储和 PostgreSQL 状态通过环境变量配置。PostgreSQL 支持
|
|
|
77
77
|
|
|
78
78
|
## 许可证
|
|
79
79
|
|
|
80
|
-
MIT
|
|
80
|
+
MIT
|
package/cli.ts
CHANGED
|
@@ -64,7 +64,7 @@ function relaunchTuiWithBun(): void {
|
|
|
64
64
|
|
|
65
65
|
if (args[0] === "cli") {
|
|
66
66
|
relaunchTuiWithBun();
|
|
67
|
-
// Keep the
|
|
67
|
+
// Keep the TUI outside dist so bundling cannot hoist OpenTUI into
|
|
68
68
|
// every CLI command. The packaged layout has dist/cli.js beside src/tui.
|
|
69
69
|
const packaged = new URL("../src/tui/main.mjs", import.meta.url);
|
|
70
70
|
const source = new URL("./src/tui/main.mjs", import.meta.url);
|
package/dist/cli.js
CHANGED
|
@@ -2172,6 +2172,23 @@ ${lines.join(`
|
|
|
2172
2172
|
`)}
|
|
2173
2173
|
</notification>`;
|
|
2174
2174
|
}
|
|
2175
|
+
function notificationPreview(text) {
|
|
2176
|
+
if (text.length <= MAX_LINE)
|
|
2177
|
+
return text;
|
|
2178
|
+
let end = MAX_LINE;
|
|
2179
|
+
for (const mention of text.matchAll(/<at>@[^<\r\n]+<\/at>/g)) {
|
|
2180
|
+
if (mention.index >= end)
|
|
2181
|
+
break;
|
|
2182
|
+
if (mention.index + mention[0].length > end) {
|
|
2183
|
+
end = mention.index;
|
|
2184
|
+
break;
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
return `${text.slice(0, end)}…`;
|
|
2188
|
+
}
|
|
2189
|
+
function notificationMessageLine(item, text = item.text) {
|
|
2190
|
+
return `- [${timeOf(item.createdAt)}] ${item.senderId}: ${text}`;
|
|
2191
|
+
}
|
|
2175
2192
|
function formatNotificationLines(items) {
|
|
2176
2193
|
const visible = [];
|
|
2177
2194
|
let lineCount = 0;
|
|
@@ -2184,14 +2201,12 @@ function formatNotificationLines(items) {
|
|
|
2184
2201
|
lineCount += required;
|
|
2185
2202
|
}
|
|
2186
2203
|
const countCapped = visible.length < items.length;
|
|
2187
|
-
const textCapped = items.some((it) =>
|
|
2204
|
+
const textCapped = items.some((it) => it.text.length > MAX_LINE);
|
|
2188
2205
|
const capped = countCapped || textCapped;
|
|
2189
2206
|
const lines = visible.flatMap(({ item: it }) => {
|
|
2190
|
-
const plain = visibleText(it.text);
|
|
2191
|
-
const text = plain.length > MAX_LINE ? `${plain.slice(0, MAX_LINE)}…` : plain;
|
|
2192
2207
|
return [
|
|
2193
2208
|
...it.answerQuestionExcerpt ? [` ↳ Answer to: “${it.answerQuestionExcerpt.replace(/[\r\n]+/g, " ")}”`] : [],
|
|
2194
|
-
|
|
2209
|
+
notificationMessageLine(it, notificationPreview(it.text))
|
|
2195
2210
|
];
|
|
2196
2211
|
});
|
|
2197
2212
|
if (countCapped) {
|
|
@@ -2221,11 +2236,10 @@ function formatRoom(svc, room) {
|
|
|
2221
2236
|
return lines.join(`
|
|
2222
2237
|
`);
|
|
2223
2238
|
}
|
|
2224
|
-
var MAX_LINE = 300, MAX_LINES = 20
|
|
2239
|
+
var MAX_LINE = 300, MAX_LINES = 20;
|
|
2225
2240
|
var init_store = __esm(() => {
|
|
2226
2241
|
init_room_service();
|
|
2227
2242
|
init_sqlite_state();
|
|
2228
|
-
MENTION_MARKER = /<at>([\s\S]*?)<\/at>/g;
|
|
2229
2243
|
});
|
|
2230
2244
|
|
|
2231
2245
|
// src/center/queue.ts
|
|
@@ -3188,9 +3202,7 @@ ${result.announcement.content}`;
|
|
|
3188
3202
|
});
|
|
3189
3203
|
const parsed = toRoom(room);
|
|
3190
3204
|
const sentID = [...parsed.messages].reverse().find((message) => message.senderSessionID === sessionID && message.text === args.text.trim())?.id ?? parsed.messages.at(-1)?.id;
|
|
3191
|
-
return `sent:
|
|
3192
|
-
${sentID ? `message_id=${sentID} room_id=${parsed.id}
|
|
3193
|
-
` : ""}${formatRoom(svcOf(room), parsed)}`;
|
|
3205
|
+
return `sent${sentID ? ` message_id=${sentID}` : ""} room_id=${parsed.id}`;
|
|
3194
3206
|
}
|
|
3195
3207
|
case "recall": {
|
|
3196
3208
|
if (!args.roomId)
|
|
@@ -3631,11 +3643,11 @@ ${rendered.lines.join(`
|
|
|
3631
3643
|
displayedCounts.set(line, (displayedCounts.get(line) ?? 0) + 1);
|
|
3632
3644
|
const candidateCounts = new Map;
|
|
3633
3645
|
for (const item of cappedItems) {
|
|
3634
|
-
const line =
|
|
3646
|
+
const line = notificationMessageLine(item);
|
|
3635
3647
|
candidateCounts.set(line, (candidateCounts.get(line) ?? 0) + 1);
|
|
3636
3648
|
}
|
|
3637
3649
|
evidenceItems = rendered.visibleIndices.map((index) => cappedItems[index]).filter((item) => {
|
|
3638
|
-
const line =
|
|
3650
|
+
const line = notificationMessageLine(item);
|
|
3639
3651
|
return candidateCounts.get(line) === 1 && displayedCounts.get(line) === 1 && !formatNotificationLines([item]).capped;
|
|
3640
3652
|
});
|
|
3641
3653
|
}
|
|
@@ -3670,6 +3682,14 @@ function contextText(message) {
|
|
|
3670
3682
|
return;
|
|
3671
3683
|
return { id: value.id, text: value.content.map((part) => part.text).join("") };
|
|
3672
3684
|
}
|
|
3685
|
+
function matchesReceiptText(text, expectedHash) {
|
|
3686
|
+
if (hash(text) === expectedHash)
|
|
3687
|
+
return true;
|
|
3688
|
+
const closing = "</notification>";
|
|
3689
|
+
const end = text.lastIndexOf(`${closing}
|
|
3690
|
+
`);
|
|
3691
|
+
return end >= 0 && text.startsWith("<notification>") && hash(text.slice(0, end + closing.length)) === expectedHash;
|
|
3692
|
+
}
|
|
3673
3693
|
function observeReceiptContext(sessionID, messages, destination, ownerID) {
|
|
3674
3694
|
let observed = 0;
|
|
3675
3695
|
for (const message of messages) {
|
|
@@ -3677,7 +3697,7 @@ function observeReceiptContext(sessionID, messages, destination, ownerID) {
|
|
|
3677
3697
|
if (!context)
|
|
3678
3698
|
continue;
|
|
3679
3699
|
for (const candidate of receiptCandidates(sessionID, context.id, destination, ownerID, Date.now())) {
|
|
3680
|
-
if (
|
|
3700
|
+
if (!matchesReceiptText(context.text, candidate.textHash))
|
|
3681
3701
|
continue;
|
|
3682
3702
|
const key = hash(JSON.stringify([candidate.sessionID, candidate.admissionID, candidate.roomID, candidate.destination, candidate.receiverOwnerID, candidate.membershipID]));
|
|
3683
3703
|
if (markReceiptCandidateReady(key))
|
|
@@ -5737,9 +5757,7 @@ var connection, centerUrl, centerToken, serveWakeUrl, runtimeContext, defaultRun
|
|
|
5737
5757
|
const msg = svc.sendMessage(args.roomId, selfName, args.text, context.sessionID, args.isQuestion);
|
|
5738
5758
|
const room = svc.getRoom(args.roomId);
|
|
5739
5759
|
notifications.push({ roomId: args.roomId, roomName: room.name, messages: [...room.messages] });
|
|
5740
|
-
return `sent
|
|
5741
|
-
message_id=${msg.id} room_id=${room.id}
|
|
5742
|
-
${formatRoom(svc, room)}`;
|
|
5760
|
+
return `sent message_id=${msg.id} room_id=${room.id}`;
|
|
5743
5761
|
}
|
|
5744
5762
|
case "poll": {
|
|
5745
5763
|
if (!args.roomId) {
|
|
@@ -12511,10 +12529,11 @@ function inboundRoomText(event, route) {
|
|
|
12511
12529
|
if (!text && attachments.length === 0)
|
|
12512
12530
|
return;
|
|
12513
12531
|
const actor = event.actor.nativeUserId || "unknown";
|
|
12532
|
+
const actorField = event.actor.identityNamespace === "open_id" ? "open_id" : "user_id";
|
|
12514
12533
|
const messageID = event.message?.nativeMessageId ?? event.providerEventId ?? "unknown";
|
|
12515
12534
|
const names = attachments.map((attachment) => attachment.kind === "image" ? "[image]" : `[file ${attachment.name}]`).join(", ");
|
|
12516
12535
|
const body = text ? text.length > MAX_RELAY_TEXT ? `${text.slice(0, MAX_RELAY_TEXT)}…` : text : names;
|
|
12517
|
-
return `[${platformLabel(event.source.platform)} ${route.from.account}] message_id=${messageID}
|
|
12536
|
+
return `[${platformLabel(event.source.platform)} ${route.from.account}] message_id=${messageID} room_id=${event.source.roomId} ${actorField}=${actor}: ${body}`;
|
|
12518
12537
|
}
|
|
12519
12538
|
var MAX_RELAY_TEXT = 4000;
|
|
12520
12539
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alexsun-top/opencode-chat-room",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.5",
|
|
4
4
|
"description": "A chat-room server, web client, terminal client, and OpenCode/Codex/dsh plugins.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,7 +26,11 @@
|
|
|
26
26
|
"plugin.ts",
|
|
27
27
|
"index.ts",
|
|
28
28
|
"src",
|
|
29
|
+
"src/state/pg-*.mjs",
|
|
30
|
+
"src/tui/*.mjs",
|
|
31
|
+
"src/tui/locales/*.mjs",
|
|
29
32
|
"packages/chat-room-channeld/src",
|
|
33
|
+
"packages/chat-room-channeld/src/pg/*.mjs",
|
|
30
34
|
"packages/chat-room-channeld/dist/mock-adapter.js",
|
|
31
35
|
"!src/tests",
|
|
32
36
|
"!src/**/*.test.*",
|
|
@@ -76,8 +80,9 @@
|
|
|
76
80
|
"registry": "https://registry.npmjs.org/"
|
|
77
81
|
},
|
|
78
82
|
"scripts": {
|
|
79
|
-
"build:web": "
|
|
80
|
-
"build:
|
|
83
|
+
"build:web": "bun scripts/build-web.ts",
|
|
84
|
+
"build:runtime": "tsc --ignoreConfig --target es2022 --module nodenext --strict --noUncheckedIndexedAccess --skipLibCheck src/state/pg-*.mts packages/chat-room-channeld/src/pg/*.mts && tsc --ignoreConfig --target es2022 --module nodenext --noCheck src/tui/*.mts src/tui/locales/*.mts",
|
|
85
|
+
"build:cli": "bun run build:runtime && bun build cli.ts --target=node --packages external --outfile dist/cli.js >&2",
|
|
81
86
|
"build:channeld-mock": "bun run --cwd packages/chat-room-channeld build:mock",
|
|
82
87
|
"build:adapter-feishu": "bun scripts/build-feishu-adapter.ts",
|
|
83
88
|
"build:monaco": "bun scripts/build-monaco.ts",
|
|
@@ -86,11 +91,9 @@
|
|
|
86
91
|
"server": "node cli.ts",
|
|
87
92
|
"server:bun": "bun cli.ts",
|
|
88
93
|
"server:deno": "deno run --allow-env --allow-read --allow-write --allow-net cli.ts",
|
|
89
|
-
"test": "bun run build:web && bun
|
|
94
|
+
"test": "bun run build:web && bun run build:runtime && bun scripts/check-web-build.ts && for file in src/tests/*.test.ts server/*.test.ts; do bun test \"$file\" || exit; done && bun run test:plugins && bun test src/tui/test --isolate",
|
|
90
95
|
"test:plugins": "for dir in plugins/*/tests; do bun test \"$dir\" || exit; done",
|
|
91
|
-
"typecheck": "bun run build:web && tsc --noEmit
|
|
92
|
-
"typecheck:web-strict": "tsc -p tsconfig.web.strict.json",
|
|
93
|
-
"typecheck:sw-strict": "tsc -p tsconfig.sw.strict.json"
|
|
96
|
+
"typecheck": "bun run build:web && tsc --noEmit"
|
|
94
97
|
},
|
|
95
98
|
"engines": {
|
|
96
99
|
"node": ">=24.2.0"
|
|
@@ -105,21 +108,21 @@
|
|
|
105
108
|
"playwright": "1.64.1",
|
|
106
109
|
"pptx-preview": "1.0.7",
|
|
107
110
|
"shiki": "4.6.0",
|
|
111
|
+
"typescript": "7.0.2",
|
|
108
112
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
|
|
109
113
|
},
|
|
110
|
-
"peerDependencies": {
|
|
111
|
-
"typescript": "^5"
|
|
112
|
-
},
|
|
113
114
|
"dependencies": {
|
|
114
115
|
"@aws-sdk/client-s3": "^3.1178.0",
|
|
115
116
|
"@opencode-ai/plugin": "^1.18.29",
|
|
116
117
|
"@opencode/client": "2.0.32",
|
|
117
|
-
"@opentui/core": "0.2.16",
|
|
118
118
|
"croner": "11.0.0",
|
|
119
119
|
"pg": "^8.23.1",
|
|
120
120
|
"yaml": "^2.9.0",
|
|
121
121
|
"zod": "4.1.8"
|
|
122
122
|
},
|
|
123
|
+
"optionalDependencies": {
|
|
124
|
+
"@opentui/core": "0.9.12"
|
|
125
|
+
},
|
|
123
126
|
"overrides": {
|
|
124
127
|
"echarts": "6.1.0",
|
|
125
128
|
"lodash": "4.18.1",
|
|
@@ -74,8 +74,9 @@ Run the suite from a checkout:
|
|
|
74
74
|
bun test tests/*.test.ts
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
The standalone tarball, once published, includes `tests/` and
|
|
78
|
-
|
|
77
|
+
The standalone tarball, once published, includes `tests/` and the `.mts`
|
|
78
|
+
sources. The build script passes every compiler flag explicitly, so no
|
|
79
|
+
`tsconfig` file ships with it. To build and test from an installed tarball:
|
|
79
80
|
|
|
80
81
|
```sh
|
|
81
82
|
cd node_modules/@alexsun-top/chat-room-channeld
|
|
@@ -13,10 +13,6 @@ export function matchInboundRoutes(config: ChannelConfig, event: IngestEvent): I
|
|
|
13
13
|
);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* Room-notification text. The native user id is opaque but stable; the account
|
|
18
|
-
* label shows which external bot and avoids exposing the chat id in room content.
|
|
19
|
-
*/
|
|
20
16
|
export function platformLabel(platform: string): string {
|
|
21
17
|
const value = platform.trim();
|
|
22
18
|
return value ? value[0]!.toUpperCase() + value.slice(1) : "Channel";
|
|
@@ -27,9 +23,10 @@ export function inboundRoomText(event: IngestEvent, route: InboundRoute): string
|
|
|
27
23
|
const attachments = event.content?.attachments ?? [];
|
|
28
24
|
if (!text && attachments.length === 0) return undefined;
|
|
29
25
|
const actor = event.actor.nativeUserId || "unknown";
|
|
26
|
+
const actorField = event.actor.identityNamespace === "open_id" ? "open_id" : "user_id";
|
|
30
27
|
const messageID = event.message?.nativeMessageId ?? event.providerEventId ?? "unknown";
|
|
31
28
|
const names = attachments.map((attachment) =>
|
|
32
29
|
attachment.kind === "image" ? "[image]" : `[file ${attachment.name}]`).join(", ");
|
|
33
30
|
const body = text ? (text.length > MAX_RELAY_TEXT ? `${text.slice(0, MAX_RELAY_TEXT)}…` : text) : names;
|
|
34
|
-
return `[${platformLabel(event.source.platform)} ${route.from.account}] message_id=${messageID}
|
|
35
|
-
}
|
|
31
|
+
return `[${platformLabel(event.source.platform)} ${route.from.account}] message_id=${messageID} room_id=${event.source.roomId} ${actorField}=${actor}: ${body}`;
|
|
32
|
+
}
|