@alexsun-top/opencode-chat-room 0.7.2 → 0.7.4

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 (77) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +11 -4
  3. package/README.zh-CN.md +11 -4
  4. package/cli.ts +26 -6
  5. package/dist/cli.js +7804 -0
  6. package/package.json +19 -6
  7. package/plugin.ts +7 -4
  8. package/server/admin-auth.ts +1 -1
  9. package/server/admin-routes.ts +2 -2
  10. package/server/admin-state.ts +2 -1
  11. package/server/assets/chat/admin.js +43 -3
  12. package/server/assets/chat/announcements.js +5 -3
  13. package/server/assets/chat/confirm-dialog.js +12 -2
  14. package/server/assets/chat/create-room-dialog.js +5 -3
  15. package/server/assets/chat/events.js +32 -7
  16. package/server/assets/chat/files.js +368 -0
  17. package/server/assets/chat/index.js +6 -0
  18. package/server/assets/chat/locales/de.js +17 -1
  19. package/server/assets/chat/locales/es.js +17 -1
  20. package/server/assets/chat/locales/fr.js +17 -1
  21. package/server/assets/chat/locales/it.js +17 -1
  22. package/server/assets/chat/locales/ja.js +17 -1
  23. package/server/assets/chat/locales/ko.js +17 -1
  24. package/server/assets/chat/markdown.js +10 -3
  25. package/server/assets/chat/message-polling.js +61 -6
  26. package/server/assets/chat/message-window.js +28 -0
  27. package/server/assets/chat/messages.js +29 -4
  28. package/server/assets/chat/palette.js +384 -0
  29. package/server/assets/chat/rooms.js +8 -3
  30. package/server/assets/chat/search.js +137 -0
  31. package/server/assets/chat/settings.js +11 -5
  32. package/server/assets/chat/state.js +34 -2
  33. package/server/assets/code-highlight.css +2 -5
  34. package/server/assets/edit-room.css +77 -0
  35. package/server/assets/files.css +237 -0
  36. package/server/assets/palette.css +277 -0
  37. package/server/assets/responsive.css +3 -2
  38. package/server/assets/room-create.css +42 -43
  39. package/server/assets/settings.css +6 -3
  40. package/server/chat-server.ts +46 -29
  41. package/server/chat.html +129 -33
  42. package/server/http-server.ts +182 -0
  43. package/server/join-requests.ts +5 -4
  44. package/server/manifest.webmanifest +1 -1
  45. package/server/member-routes.ts +3 -3
  46. package/server/message-recall-routes.ts +1 -1
  47. package/server/newrooms.ts +4 -4
  48. package/server/resource-routes.ts +19 -4
  49. package/server/room-join.ts +8 -3
  50. package/server/room-payload.ts +1 -1
  51. package/server/sw.js +3 -0
  52. package/server/wake.ts +1 -1
  53. package/skills/chatroom/SKILL.md +1 -1
  54. package/src/README.md +4 -2
  55. package/src/config/file-config.ts +294 -0
  56. package/src/rooms/resource-read.ts +2 -1
  57. package/src/rooms/resource-upload.ts +6 -3
  58. package/src/rooms/resources.ts +7 -2
  59. package/src/runtime/v2-plugin.ts +2 -2
  60. package/src/runtime/watch.ts +13 -8
  61. package/src/state/receiver-state.ts +3 -5
  62. package/src/state/sqlite-state.ts +11 -7
  63. package/src/state/sqlite.ts +80 -0
  64. package/src/state/store.ts +1 -0
  65. package/src/tui/app.mjs +417 -0
  66. package/src/tui/config.mjs +194 -0
  67. package/src/tui/http.mjs +103 -0
  68. package/src/tui/main.mjs +176 -0
  69. package/src/tui/messages.mjs +67 -0
  70. package/src/tui/palette-app.mjs +265 -0
  71. package/src/tui/palette.mjs +101 -0
  72. package/src/tui/session.mjs +40 -0
  73. package/src/tui/ui-content.mjs +426 -0
  74. package/src/tui/ui-theme.mjs +60 -0
  75. package/src/tui/ui-view.mjs +452 -0
  76. package/src/tui/ui.mjs +262 -0
  77. package/src/tests/announcement-board.ts +0 -186
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.4 — 2026-11-21
4
+
5
+ - Run the central server on Node.js 24.2+, Deno 2, or Bun. The server uses Node's HTTP and SQLite modules, the container runtime is Node instead of Bun, and the npm CLI ships as bundled JavaScript so `npx` works under Node.
6
+ - Add a terminal client to the main package, opened with `opencode-chat-room cli`, with room and message navigation, pending-join handling, and an Alt+Space or Ctrl+P search and command palette. Its OpenTUI interface follows the terminal theme, groups messages, and includes a status bar, bordered composer, and narrow layout. It requires Bun 1.3.14+ or Node.js 26.4+ with `--experimental-ffi`; the server remains Node.js 24.2+, Deno 2, and Bun compatible.
7
+ - Add a Files browser to room Options: list every resource in the room, filter by uploader, preview images, audio, and video, download, and delete by the same permissions as attachments.
8
+ - Read configuration from `chatroom.json`, `chatroom.jsonc`, `chatroom.yaml`, or `chatroom.yml` on the server and all clients. Environment variables override the file; use `CHAT_ROOM_CONFIG` to choose a file explicitly. Ship Codex 0.1.4 and dsh 0.1.3 with the same file support.
9
+ - Group the Edit room dialog into Room details, Joining & approval, Members & roles, and Ownership tabs. The Ownership tab is visible only to the room owner; delegated human administrators keep the room details, approval, roster, and successor controls. The Save action and status stay visible below every tab.
10
+ - Add an Alt+Space search and command palette: full-text message search in the current room or all joined rooms, common room commands, keyboard navigation, and a highlighted jump to the matching message.
11
+ - Show the date on messages from earlier days, and keep the reader's viewport fixed when new messages arrive while older history is being read.
12
+ - Return focus to the message composer when Settings or the create-room dialog closes in chat, and focus it with a double Escape when no dialog, panel, drawer, reader, or mention picker is open.
13
+ - Move Announcements into room Options while keeping the Members button in the header, and ask for confirmation before a human leaves a room.
14
+ - Set the PageUp/PageDown distance with a slider, and restore live messages when scrolling back to the tail after a search jump.
15
+ - Clear the reconnect banner as soon as an authenticated recovery probe or a successful request proves the network is back, even while an old inbox long-poll is still hanging.
16
+ - Match the web app manifest theme color to the default page background, so Android browsers that paint the bottom navigation bar from the manifest no longer show a different color below the composer on first load.
17
+
18
+ ## 0.7.3 — 2026-11-21
19
+
20
+ - Deliver an approved join request to the original Agent session: the join event stays unread for the approved member, pending Codex joins start the delivery loop, and the OpenCode V2 schema exposes `join_status`. Ship Codex 0.1.3 with this fix.
21
+ - Align the create-room dialog with the other dialogs: 560px width, matching title, compact desktop buttons, and full-height touch targets on phones.
22
+ - Keep code-block tools out of the way on touch screens: they appear when the block is tapped and hide when tapping elsewhere.
23
+
3
24
  ## 0.7.2 — 2026-11-20
4
25
 
5
26
  - Keep the room rail inside short windows even while a join request is pending, by compacting the rail footer, header, and composer instead of letting content stretch the rail.
package/README.md CHANGED
@@ -24,9 +24,11 @@ When upgrading an existing install, quit OpenCode first or use `opencode plugin
24
24
  On a machine reachable by the other devices, start the server. Replace `your-password` with a shared password:
25
25
 
26
26
  ```bash
27
- bunx @alexsun-top/opencode-chat-room@0.7.2 --host 0.0.0.0 --port 4399 --token 'your-password'
27
+ npx --yes --package=@alexsun-top/opencode-chat-room@0.7.4 -- opencode-chat-room --host 0.0.0.0 --port 4399 --token 'your-password'
28
28
  ```
29
29
 
30
+ The server runs on Node.js 24.2+, Deno 2, or Bun; `bunx` and Deno commands are in the [reference](docs/reference.en.md#central-mode-multi-host). OpenCode itself still runs on Bun.
31
+
30
32
  On each machine running OpenCode, set the server address and the same password, then start OpenCode from that environment:
31
33
 
32
34
  ```bash
@@ -35,6 +37,8 @@ export CHAT_ROOM_SERVER_TOKEN="your-password"
35
37
  opencode
36
38
  ```
37
39
 
40
+ Environment variables can be replaced by an optional `chatroom.json`, `chatroom.jsonc`, `chatroom.yaml`, or `chatroom.yml`; see the [configuration reference](docs/reference.en.md#configuration-file). Environment variables still override the file.
41
+
38
42
  Open `http://SERVER_IP:4399/chat` in a browser and enter the same password in Settings. The same dialog, available before joining and from the chat menu, groups language, theme, scrolling, and the access token under General, Appearance, and Connection. Create or join a room there, and ask each agent to join it too.
39
43
 
40
44
  **Security:** Anyone with the shared password can access and manage rooms, including direct chats. Share it only with trusted people and protect network access to the server. Join approval controls the normal join flow; it is not per-user authentication, so it does not stop a password holder from misrepresenting itself.
@@ -49,17 +53,20 @@ docker run --rm -p 4399:4399 -v chat-room-data:/data \
49
53
  ghcr.io/agentsyaml/opencode-chat-room:latest
50
54
  ```
51
55
 
52
- Pin a release with `ghcr.io/agentsyaml/opencode-chat-room:v0.7.2`. Rooms, messages and receipts live in the `/data` volume; keep it mounted across upgrades. If you bind-mount a host directory instead of a named volume, make it writable by uid `10001`.
56
+ Pin a release with `ghcr.io/agentsyaml/opencode-chat-room:v0.7.4`. Rooms, messages and receipts live in the `/data` volume; keep it mounted across upgrades. If you bind-mount a host directory instead of a named volume, make it writable by uid `10001`.
53
57
 
54
58
  ## 3. Start chatting
55
59
 
56
60
  - Ask an agent to create a room, join a room, or send a message; you can also use the web interface.
57
61
  - When creating or editing a room, turn on **Require approval to join**. You and other human administrators approve people and Agents from the member panel; a designated management agent can also approve Agent requests. A pending applicant is not a member yet.
62
+ - The Edit room dialog groups room details, joining and approval, members and roles, and ownership. Only the owner sees the ownership tab.
58
63
  - Use Reply to respond to a message. Mark a message as a question when you need an answer.
59
64
  - Use the room's reminder button for one-time or recurring reminders. Times default to the server's time zone.
60
65
  - Reminder text supports `{{time}}`, `{{initiator}}`, and `{{room}}`.
61
- - A compact shortcut chip under the composer shows Alt+/ (Option+/ on Mac); click it or press the keys to open the sheet. Alt+1…9 switches to a joined room by its position in the rail, Alt+Home/Alt+End smoothly scroll to the oldest/latest loaded message, and PageUp/PageDown scrolls the conversation in one animated step while you type, and Settings sets that step as a percentage of the conversation height (default 90%).
62
- - Attach files, drag them in, or paste images. The default limit is 500 MiB per file.
66
+ - A compact shortcut chip under the composer shows Alt+/ (Option+/ on Mac); click it or press the keys to open the sheet. Alt+1…9 switches to a joined room by its position in the rail, Alt+Home/Alt+End smoothly scroll to the oldest/latest loaded message, and PageUp/PageDown scrolls the conversation in one animated step while you type, and Settings sets that step with a slider as a percentage of the conversation height (default 90%).
67
+ - Press Alt+Space (Option+Space on Mac) anywhere, including the composer, to search messages. Search starts in the current room; Tab switches to all joined rooms and back. Type `>` to filter common commands instead. ↑/↓ and Enter open a result and highlight it in the conversation; Esc or a backdrop click closes and returns to the composer.
68
+ - Attach files, drag them in, or paste images. The default limit is 500 MiB per file. Room Options also opens Announcements and Files, where Files can be filtered by uploader, preview supported media, and downloaded or deleted.
69
+ - In a terminal, run `bunx --bun --package @alexsun-top/opencode-chat-room@0.7.4 opencode-chat-room cli` against the same server. The terminal client is built into the main package and supports room navigation, pending joins, sending, and Alt+Space (or Ctrl+P) search. It uses OpenTUI: Bun 1.3.14+ is recommended, Node.js 26.4+ needs `--experimental-ffi`, and Deno is not supported for this client. Only `cli` loads OpenTUI; the server and `watch` stay on Node.js 24.2+, Deno 2, and Bun.
63
70
  - Fenced code blocks are syntax-highlighted locally. Hover or focus a block for icon-only wrap and copy controls.
64
71
  - Agents can recall a message by ID; the original stays available to current members.
65
72
  - Agents can use the `room` tool's `read_resource` action to save an attachment to a temporary file before opening it.
package/README.zh-CN.md CHANGED
@@ -24,9 +24,11 @@
24
24
  在一台可被其他设备访问的机器上启动服务器,把 `换成自己的密码` 换成共享密码:
25
25
 
26
26
  ```bash
27
- bunx @alexsun-top/opencode-chat-room@0.7.2 --host 0.0.0.0 --port 4399 --token '换成自己的密码'
27
+ npx --yes --package=@alexsun-top/opencode-chat-room@0.7.4 -- opencode-chat-room --host 0.0.0.0 --port 4399 --token '换成自己的密码'
28
28
  ```
29
29
 
30
+ 服务端可在 Node.js 24.2+、Deno 2 或 Bun 上运行;`bunx` 与 Deno 命令见[参考文档](docs/reference.zh-CN.md)。OpenCode 本身仍运行在 Bun 上。
31
+
30
32
  在每台运行 OpenCode 的机器上设置服务器地址和相同密码,再从该环境启动 OpenCode:
31
33
 
32
34
  ```bash
@@ -35,6 +37,8 @@ export CHAT_ROOM_SERVER_TOKEN="换成自己的密码"
35
37
  opencode
36
38
  ```
37
39
 
40
+ 也可以用可选的 `chatroom.json`、`chatroom.jsonc`、`chatroom.yaml` 或 `chatroom.yml` 替代环境变量;详见[配置文件说明](docs/reference.zh-CN.md#配置文件)。环境变量仍然优先于文件。
41
+
38
42
  在浏览器打开 `http://服务器IP:4399/chat`,在设置窗口中填入相同密码。同一个设置窗口在加入房间前和聊天菜单中都能打开,按通用、外观、连接三个类别组织语言、主题、滚动选项和访问令牌。然后创建或加入房间,每个 Agent 也需要加入同一个房间。
39
43
 
40
44
  **安全提示:**共享密码的持有人可以访问和管理房间,包括私聊;请只分享给可信任的人,并保护服务器网络访问。加入审核只约束正常加入流程,不是按用户认证,无法阻止密码持有人伪装身份。
@@ -49,17 +53,20 @@ docker run --rm -p 4399:4399 -v chat-room-data:/data \
49
53
  ghcr.io/agentsyaml/opencode-chat-room:latest
50
54
  ```
51
55
 
52
- 用 `ghcr.io/agentsyaml/opencode-chat-room:v0.7.2` 可以固定到具体版本。房间、消息和回执都保存在 `/data` 卷里,升级时保留该卷即可。如果改用宿主目录做挂载,需要让该目录对 uid `10001` 可写。
56
+ 用 `ghcr.io/agentsyaml/opencode-chat-room:v0.7.4` 可以固定到具体版本。房间、消息和回执都保存在 `/data` 卷里,升级时保留该卷即可。如果改用宿主目录做挂载,需要让该目录对 uid `10001` 可写。
53
57
 
54
58
  ## 3. 开始聊天
55
59
 
56
60
  - 让 Agent 创建房间、加入房间或发送消息;也可以在网页里操作。
57
61
  - 创建或编辑房间时可开启「需审核加入」。你和其他人类管理员在成员面板审核人和 Agent;被指定的管理 Agent 也可以审核 Agent 的申请。待审核的申请人还不算成员。
62
+ - 编辑房间按房间资料、加入与审核、成员与角色、所有权分组;所有权仅房主可见。
58
63
  - 回复消息时点击回复;需要对方回答的问题可标记为「问题」。
59
64
  - 点击房间里的提醒按钮,可创建一次性或周期提醒。默认使用服务器时区。
60
65
  - 提醒正文支持 `{{time}}`、`{{initiator}}`、`{{room}}` 模板变量。
61
- - 输入框下方保留唯一快捷键入口,以紧凑标签显示 Alt+/(Mac 为 Option+/);点击或按快捷键都能打开面板。Alt+1…9 按房间在侧栏中的位置切换已加入房间,Alt+Home/Alt+End 平滑滚动到最早/最新的已加载消息,输入时用 PageUp/PageDown 按动画滚动一屏,步长可在设置中按会话高度百分比调整(默认 90%)。
62
- - 点击附件按钮、拖入文件或粘贴图片即可分享;默认单文件上限为 500 MiB。
66
+ - 输入框下方保留唯一快捷键入口,以紧凑标签显示 Alt+/(Mac 为 Option+/);点击或按快捷键都能打开面板。Alt+1…9 按房间在侧栏中的位置切换已加入房间,Alt+Home/Alt+End 平滑滚动到最早/最新的已加载消息,输入时用 PageUp/PageDown 按动画滚动一屏,步长可在设置中用滑动条按会话高度百分比调整(默认 90%)。
67
+ - 在任意位置(包括输入框)按 Alt+Space(Mac 为 Option+Space)打开搜索:默认搜索当前房间,按 Tab 切换到全部已加入房间;输入 `>` 可改为过滤常用命令。↑/↓ 加 Enter 打开结果并在会话中高亮;Esc 或点击遮罩关闭并回到输入框。
68
+ - 点击附件按钮、拖入文件或粘贴图片即可分享;默认单文件上限为 500 MiB。房间选项里还有“公告”和“文件”;文件可以按上传者筛选、预览支持的媒体,并下载或删除。
69
+ - 终端里可以运行 `bunx --bun --package @alexsun-top/opencode-chat-room@0.7.4 opencode-chat-room cli` 连接同一个服务器。终端客户端已并入主包,支持房间切换、待审批加入、发消息和 Alt+Space(或 Ctrl+P)搜索。它使用 OpenTUI:推荐 Bun 1.3.14+,Node.js 26.4+ 需要 `--experimental-ffi`,Deno 不支持该客户端。只有 `cli` 会加载 OpenTUI;服务端和 `watch` 仍支持 Node.js 24.2+、Deno 2 和 Bun。
63
70
  - 围栏代码块会在本地做语法高亮;鼠标悬停或键盘聚焦时显示纯图标的自动换行和复制按钮。
64
71
  - Agent 可按消息 ID 撤回;当前成员仍可查看原文。
65
72
  - Agent 收到附件后可通过 `room` 的 `read_resource` 操作保存到临时文件,再打开查看。
package/cli.ts CHANGED
@@ -1,4 +1,7 @@
1
- #!/usr/bin/env bun
1
+ #!/usr/bin/env node
2
+ import { existsSync } from "node:fs";
3
+ import { readFile } from "node:fs/promises";
4
+ import { fileURLToPath } from "node:url";
2
5
 
3
6
  const usage = `Usage: opencode-chat-room [options]
4
7
 
@@ -10,6 +13,7 @@ Options:
10
13
  -t, --token <token> Enable bearer token authentication
11
14
 
12
15
  Commands:
16
+ cli [--name <name>] Open the terminal client
13
17
  watch run|start|status|stop`;
14
18
 
15
19
  type ValueOption = "host" | "port" | "token";
@@ -37,6 +41,15 @@ function validatePort(value: string): void {
37
41
  }
38
42
 
39
43
  const args = process.argv.slice(2);
44
+ if (args[0] === "cli") {
45
+ // Keep the plain-JS TUI outside dist so bundling cannot hoist OpenTUI into
46
+ // every CLI command. The packaged layout has dist/cli.js beside src/tui.
47
+ const packaged = new URL("../src/tui/main.mjs", import.meta.url);
48
+ const source = new URL("./src/tui/main.mjs", import.meta.url);
49
+ const entry = existsSync(fileURLToPath(packaged)) ? packaged : source;
50
+ const { main } = await import(entry.href);
51
+ process.exit(await main(args.slice(1)));
52
+ }
40
53
  if (args[0] === "watch") {
41
54
  const action = args[1];
42
55
  if ((args.length === 2 && (action === "help" || action === "--help")) ||
@@ -102,9 +115,15 @@ if (help) {
102
115
  }
103
116
 
104
117
  if (version) {
105
- const packageJson = (await Bun.file(
106
- new URL("./package.json", import.meta.url),
107
- ).json()) as { version?: string };
118
+ let packageJson: { version?: string } = {};
119
+ for (const candidate of ["./package.json", "../package.json"]) {
120
+ try {
121
+ packageJson = JSON.parse(await readFile(new URL(candidate, import.meta.url), "utf8"));
122
+ break;
123
+ } catch {
124
+ // The bundled CLI lives in dist/, while source runs from the package root.
125
+ }
126
+ }
108
127
  console.log(packageJson.version ?? "unknown");
109
128
  process.exit(0);
110
129
  }
@@ -120,5 +139,6 @@ if (values.token !== undefined) {
120
139
  process.env.CHAT_ROOM_SERVER_TOKEN = values.token;
121
140
  }
122
141
 
123
- const { default: server } = await import("./server/chat-server");
124
- Bun.serve(server);
142
+ const { default: server } = await import("./server/chat-server.ts");
143
+ const { startServer } = await import("./server/http-server.ts");
144
+ await startServer(server);