@alexsun-top/opencode-chat-room 0.2.3 → 0.3.0
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 +12 -0
- package/README.md +23 -7
- package/README.zh-CN.md +23 -7
- package/package.json +5 -2
- package/plugin.ts +6 -5
- package/server/assets/DOMPURIFY-LICENSE +202 -0
- package/server/assets/MARKED-LICENSE +44 -0
- package/server/assets/NOTICE.txt +6 -0
- package/server/assets/base.css +225 -0
- package/server/assets/chat/events.js +146 -0
- package/server/assets/chat/index.js +12 -0
- package/server/assets/chat/markdown.js +65 -0
- package/server/assets/chat/members.js +95 -0
- package/server/assets/chat/mentions.js +131 -0
- package/server/assets/chat/messages.js +417 -0
- package/server/assets/chat/rooms.js +443 -0
- package/server/assets/chat/state.js +316 -0
- package/server/assets/conversation.css +350 -0
- package/server/assets/dompurify-3.4.7.js +3 -0
- package/server/assets/marked-18.0.4.js +79 -0
- package/server/assets/responsive.css +119 -0
- package/server/chat-server.ts +34 -10
- package/server/chat.html +27 -1984
- package/server/history-route.ts +2 -1
- package/server/inbox.ts +1 -1
- package/server/newrooms.ts +90 -0
- package/server/wake.ts +13 -14
- package/src/background.ts +70 -25
- package/src/center-client.ts +3 -1
- package/src/center-inbox.ts +71 -37
- package/src/center-wake.ts +43 -9
- package/src/mentions.ts +7 -0
- package/src/plugin-notifications.ts +69 -23
- package/src/queue-transport.ts +17 -1
- package/src/queue.ts +36 -2
- package/src/receiver-state.ts +58 -1
- package/src/room-service.ts +19 -1
- package/src/sqlite-state.ts +24 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.0 — 2026-10-30
|
|
4
|
+
|
|
5
|
+
- Central web chat can switch among joined group rooms and direct conversations without leaving them. It keeps drafts and read positions per tab, renders sanitized GitHub Flavored Markdown from local vendor assets, and supports confirmed member removal and permanent room deletion.
|
|
6
|
+
- Direct conversations target the selected registered session and are implicitly addressed. Group `@all` and `@所有人` broadcasts address other members. The shared token grants all holders room-management and message-reading access; direct conversations are not private from token holders or the server.
|
|
7
|
+
- Central messages retain sender session IDs to distinguish same-name members. Reopening a direct conversation avoids replaying old messages and preserves the other participant's read cursor; room-switch races and mixed V1/V2 session updates preserve per-room state.
|
|
8
|
+
- V2 makes one best-effort session-wide backgrounding attempt before steering each eligible notification. Failure is logged and does not block steering; message-delivery retries remain separate. The session-wide API cannot guarantee detachment of a particular task, and backgrounding does not cancel work.
|
|
9
|
+
- Installations carrying ambiguous background-retry rows from an intermediate development build conservatively disable backgrounding for the affected service/room; normal steering continues.
|
|
10
|
+
|
|
11
|
+
### Verification
|
|
12
|
+
|
|
13
|
+
Initial host checks covered OpenCode 2.2.0 and 2.2.1. The final single-attempt implementation was verified on 2.2.1 with the actual plugin, native foreground Shell work, and a general subagent using `@all`. Subsequent watermark changes passed regression checks without an API change. These checks did not establish a specific cause for the reported user failure.
|
|
14
|
+
|
|
3
15
|
## 0.2.3
|
|
4
16
|
|
|
5
17
|
- V2 room notifications steer the running session by default. Direct requests ask the agent to acknowledge once in the originating room before working, then provide useful progress and a final reply there; routine updates and broadcasts do not trigger acknowledgements. Mention-triggered backgrounding remains best-effort and no longer changes delivery mode.
|
package/README.md
CHANGED
|
@@ -6,8 +6,10 @@ A chat-room plugin for [opencode](https://opencode.ai) that lets multiple sessio
|
|
|
6
6
|
|
|
7
7
|
- 7 room actions: `create`, `join`, `leave`, `list`, `send`, `poll`, `members` (plus a `/room` command)
|
|
8
8
|
- **Human web chat UI** served at `GET /chat` (central mode): humans join rooms in the browser and chat with agents on equal footing
|
|
9
|
+
- Web chat supports switching among joined group rooms and direct conversations without leaving them; drafts and read positions are stored per tab
|
|
10
|
+
- Group broadcasts support `@all` and `@所有人`; direct messages are addressed to the other participant without an @mention
|
|
9
11
|
- Notifications wrapped in `<notification>…</notification>`; V2 steers the persistent session, while V1 uses asynchronous prompts
|
|
10
|
-
- Incremental read watermark: `poll` returns unread messages; failed
|
|
12
|
+
- Incremental read watermark: `poll` returns unread messages; failed message-delivery attempts remain available for retry. V1 asynchronous acceptance does not guarantee durable delivery.
|
|
11
13
|
- Two deployment modes: **standalone** (local SQLite, zero config) and **central** (one HTTP server, one env var per client)
|
|
12
14
|
- Normalized SQLite storage with transactional legacy JSON migration and append-only message history
|
|
13
15
|
|
|
@@ -55,9 +57,11 @@ Typical usage in a session:
|
|
|
55
57
|
- Read new messages: `room poll <roomId>` — only unread ones, or just wait for the push
|
|
56
58
|
- `room list` / `room members <roomId>` / `room leave <roomId>`
|
|
57
59
|
|
|
60
|
+
In group rooms, `@all` or `@所有人` addresses the other room members. A direct conversation notifies its other participant without requiring an @mention.
|
|
61
|
+
|
|
58
62
|
Push notifications use the host's supported transport. V1 notifications are ordinary asynchronous prompts; V2 notifications steer the persistent session. In both cases the unread watermark advances only after the host accepts the notification. V2 steering takes effect at a safe boundary; it is not an instant interrupt and does not guarantee that a currently blocking task can be detached.
|
|
59
63
|
|
|
60
|
-
On V2, every notification steers the session when observed.
|
|
64
|
+
On V2, every notification steers the session when observed. For an eligible mention (`@alice`, `@all`, or `@所有人`) or direct message, the plugin makes one best-effort backgrounding attempt before steering. OpenCode exposes session-wide backgrounding, not an atomic operation bound to a particular shell or subagent task, so the plugin cannot guarantee which active work is detached. It calls only the current OS user's registered OpenCode service after verifying its PID and version. Failure is logged and does not block steering; message-delivery retries are separate. Backgrounding does not cancel work, and success does not guarantee task completion. A session must still be a room member to receive notifications; only explicitly addressed sessions can be restored by the watcher when OpenCode is not running. No service is started and no ports are probed. Polling is every five seconds, so this is not instant push.
|
|
61
65
|
|
|
62
66
|
For a direct request, the notification asks the agent to acknowledge it once in the originating room before working, then send useful progress updates and its final response there. Routine confirmations, status or membership updates, system messages, and ordinary broadcasts do not call for an acknowledgement. The prompt includes the room ID so the agent can address the right room.
|
|
63
67
|
|
|
@@ -65,6 +69,8 @@ For a direct request, the notification asks the agent to acknowledge it once in
|
|
|
65
69
|
|
|
66
70
|
Run `opencode-chat-room watch start` to keep V2 delivery polling after the project that loaded the plugin closes. The watcher uses the current user's registered OpenCode service and joined-room owner bindings; it does not start OpenCode. In central mode it inherits `CHAT_ROOM_SERVER_URL` and `CHAT_ROOM_SERVER_TOKEN` from the command environment. If the service is offline, it stays running and retries. `watch status` checks its authenticated loopback control endpoint, `watch stop` shuts it down gracefully, and `watch run` runs it in the foreground. Start it manually or under an OS supervisor if desired; the package does not install startup services. The watcher also does not auto-start when you send or receive a message. Its private control state and cross-process delivery leases live under the user's XDG state directory. If status reports an unreadable legacy control file, remove only that user's `watch-*.json` after confirming the watcher is not running; the default directory is `~/.local/state/opencode/chat-room`.
|
|
67
71
|
|
|
72
|
+
OpenCode 2.2.1 unloads idle project-location services after a default 60-minute idle timeout. The watcher keeps delivery polling possible, not sessions awake; it can restore only joined sessions addressed by `@name`, `@all`, `@所有人`, or a direct message. Start it explicitly. If the OpenCode service is offline, it retries and resumes when the service returns. It sends no synthetic messages or model requests to keep sessions alive.
|
|
73
|
+
|
|
68
74
|
## Central mode (multi-host)
|
|
69
75
|
|
|
70
76
|
For several machines: run one central server, point every client at it. This is the only per-client configuration.
|
|
@@ -73,17 +79,17 @@ On the server machine, install Bun first. `npx`, `pnpx`, and `bunx` only execute
|
|
|
73
79
|
|
|
74
80
|
```bash
|
|
75
81
|
# Show CLI options:
|
|
76
|
-
npx --yes --package=@alexsun-top/opencode-chat-room@0.
|
|
82
|
+
npx --yes --package=@alexsun-top/opencode-chat-room@0.3.0 -- opencode-chat-room --help
|
|
77
83
|
|
|
78
84
|
# Start the local central server (choose any one runner):
|
|
79
|
-
npx --yes --package=@alexsun-top/opencode-chat-room@0.
|
|
80
|
-
pnpx --package=@alexsun-top/opencode-chat-room@0.
|
|
81
|
-
bunx @alexsun-top/opencode-chat-room@0.
|
|
85
|
+
npx --yes --package=@alexsun-top/opencode-chat-room@0.3.0 -- opencode-chat-room --host 0.0.0.0 --port 4399
|
|
86
|
+
pnpx --package=@alexsun-top/opencode-chat-room@0.3.0 opencode-chat-room --host 0.0.0.0 --port 4399
|
|
87
|
+
bunx @alexsun-top/opencode-chat-room@0.3.0 --host 0.0.0.0 --port 4399 --token secret
|
|
82
88
|
|
|
83
89
|
# Environment variables also work; CLI options take precedence:
|
|
84
90
|
CHAT_ROOM_SERVER_HOST=127.0.0.1 CHAT_ROOM_SERVER_PORT=4399 \
|
|
85
91
|
CHAT_ROOM_SERVER_TOKEN=secret \
|
|
86
|
-
bunx @alexsun-top/opencode-chat-room@0.
|
|
92
|
+
bunx @alexsun-top/opencode-chat-room@0.3.0
|
|
87
93
|
|
|
88
94
|
# Local checkout:
|
|
89
95
|
bun install
|
|
@@ -92,6 +98,14 @@ bun run server
|
|
|
92
98
|
|
|
93
99
|
Open `http://<server-ip>:4399/chat` in a browser to join or create a room and chat with agents. If a token is configured, enter it in the page settings.
|
|
94
100
|
|
|
101
|
+
### Browser chat
|
|
102
|
+
|
|
103
|
+
Rooms you joined remain joined as you switch the sidebar selection; switching views does not leave a room. Direct conversations are created with the selected registered member session. Each tab stores its joined-room list, drafts, and read positions separately, and tracks unread counts within that tab. This is tab-scoped convenience state, not account identity: if browser tab storage is blocked, the generated session identity lasts only for that page lifetime.
|
|
104
|
+
|
|
105
|
+
The chat renders GitHub Flavored Markdown using locally bundled Marked and DOMPurify assets. Message text is sanitized before rendered HTML is inserted. No CDN is required.
|
|
106
|
+
|
|
107
|
+
The central server uses a trusted shared-token model, not per-user authorization or private DMs: anyone holding the token can read messages, manage rooms, remove members, and delete rooms. The server and its SQLite database can read direct-message content. Removing a member requires confirmation; deleting a room requires confirmation and permanently deletes its messages and history.
|
|
108
|
+
|
|
95
109
|
On every client machine:
|
|
96
110
|
|
|
97
111
|
```bash
|
|
@@ -120,6 +134,7 @@ Then start opencode normally. Room state lives on the central server. Clients on
|
|
|
120
134
|
- **Standalone**: V1 sends asynchronous prompts to registered session servers; V2 polls shared local state and steers notifications through its persistent session API. The watermark advances only on host acceptance.
|
|
121
135
|
- **Central**: sessions pull their inbox (`GET /inbox?sessionID=…`) and steer `<notification>` messages through the host API. Items are grouped per room; a room's queued watermark advances only after admission.
|
|
122
136
|
- Standalone V1 HTTP attempts are appended to `notify.log` (`OK <status> <url>` / `FAIL <reason>`). V2 notification admissions are not currently written there.
|
|
137
|
+
- Backgrounding is attempted once per eligible notification. Failures are reported to process diagnostics but do not block steering; message-delivery retries are separate. The session-wide API cannot guarantee task-specific detachment, and backgrounding does not cancel existing work.
|
|
123
138
|
- Notifications include instructions for the agent: do not reply, do not call tools, unless explicitly addressed.
|
|
124
139
|
|
|
125
140
|
## Tool reference
|
|
@@ -142,4 +157,5 @@ Note: `join` with `name:"alice"` registers the identity `alice` for that session
|
|
|
142
157
|
- Sessions on the same machine share the host identity (`user@host`); pass distinct `name` values on join to tell members apart.
|
|
143
158
|
- The central server is unauthenticated unless `CHAT_ROOM_SERVER_TOKEN` is set — anyone who can reach the port can read/write rooms. It also enforces limits: room/member names ≤ 64 chars, message text ≤ 2000 chars (rejected with 400).
|
|
144
159
|
- SQLite retains message history without automatic deletion. The 500-message in-memory window does not limit persisted history; unread messages and history are read in bounded pages. Back up the database regularly.
|
|
160
|
+
- Only installations carrying retry rows from an intermediate development build are affected: records without a recoverable message timestamp migrate conservatively, permanently disabling backgrounding for that service/room. Normal notification steering continues.
|
|
145
161
|
- `notify.log` grows without rotation.
|
package/README.zh-CN.md
CHANGED
|
@@ -6,8 +6,10 @@
|
|
|
6
6
|
|
|
7
7
|
- 7 种房间操作:`create`、`join`、`leave`、`list`、`send`、`poll`、`members`(另提供 `/room` 命令)
|
|
8
8
|
- **真人 Web 聊天界面**:中心模式 `GET /chat`——真人可在浏览器中加入房间,与 agent 平等聊天
|
|
9
|
+
- Web 聊天可在已加入的群组和私聊之间切换,不必离开房间;草稿和阅读位置按标签页保存
|
|
10
|
+
- 群组广播支持 `@all` 和 `@所有人`;私聊会直接通知另一位成员,无需 @ 提及
|
|
9
11
|
- 通知以 `<notification>…</notification>` 包裹;V2 steer 持久会话,V1 使用异步 prompt
|
|
10
|
-
- 增量阅读水位:`poll`
|
|
12
|
+
- 增量阅读水位:`poll` 返回未读消息;消息投递失败后仍可重试。V1 的异步接受不保证通知已持久化送达。
|
|
11
13
|
- 两种部署模式:**单机模式**(本地 SQLite,零配置)与**中心模式**(一个 HTTP 服务 + 每个客户端一个环境变量)
|
|
12
14
|
- 规范化 SQLite 持久化、事务式迁移旧 JSON,并保留完整追加式消息历史
|
|
13
15
|
|
|
@@ -53,9 +55,11 @@ SQLite WAL 需要本地文件系统。不要把单机状态放在 NFS/SMB 等网
|
|
|
53
55
|
- 读新消息:`room poll <房间ID>`——只返回未读部分,或者干脆等推送
|
|
54
56
|
- 其他:`room list` / `room members <房间ID>` / `room leave <房间ID>`
|
|
55
57
|
|
|
58
|
+
群组中可用 `@all` 或 `@所有人` 寻址其他成员。私聊会直接通知另一位成员,无需 @ 提及。
|
|
59
|
+
|
|
56
60
|
推送通知使用宿主支持的传输方式。V1 通知是普通异步 prompt;V2 通知通过持久会话 API steer。两者都只有在宿主接受通知后才推进未读水位。V2 steer 会在安全边界生效,并非即时打断,也不保证正在阻塞的任务一定能够移至后台。
|
|
57
61
|
|
|
58
|
-
V2 在观察到通知时都会 steer
|
|
62
|
+
V2 在观察到通知时都会 steer 会话。对于符合条件的提及(例如 `@alice`、`@all` 或 `@所有人`)及私聊,插件会在 steer 前尝试一次尽力而为的后台操作。OpenCode 提供的是会话级后台接口,并非与某个 shell 或子 agent 任务原子绑定的操作,因此无法保证具体移走哪项活动任务。插件只会调用当前操作系统用户注册、且已验证 PID 和版本的 OpenCode 服务。失败会记入诊断信息,但不会阻止 steer;消息投递重试与后台操作无关。后台操作不会取消任务,成功也不保证任务完成。会话仍需加入房间才能收到通知;OpenCode 未运行时,watcher 只会恢复明确收到寻址的会话。插件不会启动服务或扫描端口。消息每五秒轮询一次,并非即时推送。
|
|
59
63
|
|
|
60
64
|
对于直接请求,通知会要求 agent 先在原房间发送一次简短确认,再开始处理,之后可发送有用的进度更新和最终回复。例行确认、状态或成员变更、系统消息及普通广播不需要确认。提示中包含房间 ID,确保回复发往正确房间。
|
|
61
65
|
|
|
@@ -63,6 +67,8 @@ V2 在观察到通知时都会 steer 会话。收到明确提及房间注册名
|
|
|
63
67
|
|
|
64
68
|
运行 `opencode-chat-room watch start`,即可在关闭加载插件的项目后继续轮询 V2 消息。Watcher 使用当前用户已注册的 OpenCode 服务及已加入房间的所有者绑定,不会启动 OpenCode。中心模式下会继承执行该命令时的 `CHAT_ROOM_SERVER_URL` 和 `CHAT_ROOM_SERVER_TOKEN`。服务离线时,watcher 会继续运行并重试。`watch status` 检查经过认证的本机回环控制接口,`watch stop` 会优雅停止,`watch run` 则在前台运行。可手动启动,也可交由操作系统的进程管理器监督;包不会安装开机启动服务,也不会在消息收发时自动启动 watcher。私有控制状态和跨进程投递租约保存在用户的 XDG 状态目录中。若状态显示控制文件无法读取,请确认 watcher 已停止后,仅删除该用户的 `watch-*.json`;默认目录为 `~/.local/state/opencode/chat-room`。
|
|
65
69
|
|
|
70
|
+
OpenCode 2.2.1 会在默认 60 分钟无活动后卸载闲置项目的服务。Watcher 维持消息投递轮询,但不会阻止项目服务卸载;它只会恢复被 `@昵称`、`@all`、`@所有人` 或私聊寻址的已加入会话。Watcher 需要显式启动。OpenCode 服务离线时会持续重试,并在服务恢复后继续;它不会发送虚构消息或调用模型来保持会话活跃。
|
|
71
|
+
|
|
66
72
|
## 中心模式(多主机)
|
|
67
73
|
|
|
68
74
|
多台机器时:跑一个中心服务器,所有客户端指向它。**每个客户端只需要这一个环境变量**。
|
|
@@ -71,17 +77,17 @@ V2 在观察到通知时都会 steer 会话。收到明确提及房间注册名
|
|
|
71
77
|
|
|
72
78
|
```bash
|
|
73
79
|
# 查看 CLI 选项:
|
|
74
|
-
npx --yes --package=@alexsun-top/opencode-chat-room@0.
|
|
80
|
+
npx --yes --package=@alexsun-top/opencode-chat-room@0.3.0 -- opencode-chat-room --help
|
|
75
81
|
|
|
76
82
|
# 启动本地中心服务器(三选一):
|
|
77
|
-
npx --yes --package=@alexsun-top/opencode-chat-room@0.
|
|
78
|
-
pnpx --package=@alexsun-top/opencode-chat-room@0.
|
|
79
|
-
bunx @alexsun-top/opencode-chat-room@0.
|
|
83
|
+
npx --yes --package=@alexsun-top/opencode-chat-room@0.3.0 -- opencode-chat-room --host 0.0.0.0 --port 4399
|
|
84
|
+
pnpx --package=@alexsun-top/opencode-chat-room@0.3.0 opencode-chat-room --host 0.0.0.0 --port 4399
|
|
85
|
+
bunx @alexsun-top/opencode-chat-room@0.3.0 --host 0.0.0.0 --port 4399 --token secret
|
|
80
86
|
|
|
81
87
|
# 也可以使用环境变量;CLI 参数优先:
|
|
82
88
|
CHAT_ROOM_SERVER_HOST=127.0.0.1 CHAT_ROOM_SERVER_PORT=4399 \
|
|
83
89
|
CHAT_ROOM_SERVER_TOKEN=secret \
|
|
84
|
-
bunx @alexsun-top/opencode-chat-room@0.
|
|
90
|
+
bunx @alexsun-top/opencode-chat-room@0.3.0
|
|
85
91
|
|
|
86
92
|
# 本地 checkout:
|
|
87
93
|
bun install
|
|
@@ -90,6 +96,14 @@ bun run server
|
|
|
90
96
|
|
|
91
97
|
在浏览器打开 `http://<服务器IP>:4399/chat`,即可加入或创建房间并与 agent 聊天。若设置了 token,请在页面设置中填入。
|
|
92
98
|
|
|
99
|
+
### 浏览器聊天
|
|
100
|
+
|
|
101
|
+
侧栏切换房间只切换当前视图,不会离开已加入的房间。私聊由你在成员列表中选中的已注册会话创建。每个标签页分别保存已加入房间、草稿和阅读位置,并在各自标签页中跟踪未读计数;这些只是标签页级的便捷状态,并非账户身份。若浏览器阻止标签页存储,生成的会话身份只在当前页面生命周期内有效。
|
|
102
|
+
|
|
103
|
+
聊天内容使用本地打包的 Marked 解析 GitHub Flavored Markdown,并由 DOMPurify 清理后再插入页面,不依赖 CDN。
|
|
104
|
+
|
|
105
|
+
中心服务器使用团队共享令牌,不提供逐用户授权或私密私聊:任何持有令牌的人都能读取消息、管理房间、移除成员和删除房间;服务器及其 SQLite 数据库也能读取私聊内容。移除成员前会要求确认;删除房间也会要求确认,并永久删除房间消息和历史记录,无法恢复。
|
|
106
|
+
|
|
93
107
|
每台客户端机器上:
|
|
94
108
|
|
|
95
109
|
```bash
|
|
@@ -118,6 +132,7 @@ export CHAT_ROOM_SERVER_TOKEN=secret # 仅当服务器设置了 token 时
|
|
|
118
132
|
- **单机模式**:V1 向已注册会话的服务发送异步 prompt;V2 轮询共享本地状态,并通过持久会话 API steer 通知。只有宿主接受通知后才推进水位。
|
|
119
133
|
- **中心模式**:会话拉取 inbox(`GET /inbox?sessionID=…`),并通过宿主 API steer `<notification>`。消息按房间分组;V1 异步接受或 V2 成功接收后,才推进该房间的投递水位。
|
|
120
134
|
- 单机 V1 HTTP 推送尝试会追加到 `notify.log`(`OK <状态码> <URL>` / `FAIL <原因>`);V2 推送目前不会写入该日志。
|
|
135
|
+
- 每条符合条件的通知只尝试一次后台操作。失败会写入进程诊断信息,但不会阻止 steer;消息投递重试与后台操作无关。会话级接口无法保证移走特定任务,后台操作也不会取消现有工作。
|
|
121
136
|
|
|
122
137
|
## 工具参考
|
|
123
138
|
|
|
@@ -139,4 +154,5 @@ export CHAT_ROOM_SERVER_TOKEN=secret # 仅当服务器设置了 token 时
|
|
|
139
154
|
- 同一台机器的会话共享 `user@host` 身份;用不同的 `name` 加入以区分成员。
|
|
140
155
|
- 中心服务器不设 `CHAT_ROOM_SERVER_TOKEN` 时无认证——任何能访问端口的人都能读写房间。服务端另有输入限制:房间/成员名 ≤ 64 字符、消息文本 ≤ 2000 字符(超限返回 400)。
|
|
141
156
|
- SQLite 持续保留历史消息,不自动删除。500 条只是内存工作窗口,不是磁盘保留上限;未读消息和历史记录均分页读取。请定期备份数据库。
|
|
157
|
+
- 仅包含某个过渡开发版重试记录的安装会受影响:若旧后台重试记录无法恢复消息时间戳,迁移会采取保守处理,永久停用该服务/房间的后台操作;正常通知 steer 仍会继续。
|
|
142
158
|
- `notify.log` 会持续增长,暂无轮转。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alexsun-top/opencode-chat-room",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A chat-room plugin and central server for OpenCode.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,8 +27,10 @@
|
|
|
27
27
|
"server/chat-server.ts",
|
|
28
28
|
"server/inbox.ts",
|
|
29
29
|
"server/history-route.ts",
|
|
30
|
+
"server/newrooms.ts",
|
|
30
31
|
"server/wake.ts",
|
|
31
32
|
"server/chat.html",
|
|
33
|
+
"server/assets",
|
|
32
34
|
"CHANGELOG.md",
|
|
33
35
|
"README.md",
|
|
34
36
|
"README.zh-CN.md"
|
|
@@ -44,7 +46,8 @@
|
|
|
44
46
|
},
|
|
45
47
|
"devDependencies": {
|
|
46
48
|
"@opencode/plugin": "2.0.29",
|
|
47
|
-
"@types/bun": "latest"
|
|
49
|
+
"@types/bun": "latest",
|
|
50
|
+
"playwright": "1.64.1"
|
|
48
51
|
},
|
|
49
52
|
"peerDependencies": {
|
|
50
53
|
"typescript": "^5"
|
package/plugin.ts
CHANGED
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
clearPendingAdmission,
|
|
27
27
|
} from "./src/queue";
|
|
28
28
|
import { createNotifier } from "./src/plugin-notifications";
|
|
29
|
-
import {
|
|
29
|
+
import { explicitlyAddresses } from "./src/mentions";
|
|
30
30
|
import { createV2Setup, type V2Runtime } from "./src/v2-plugin";
|
|
31
31
|
import { createV1Server } from "./src/v1-plugin";
|
|
32
32
|
|
|
@@ -201,14 +201,14 @@ export async function pollKnownSessions(
|
|
|
201
201
|
if (mentionOnly && (scan.untilTs === undefined || scan.untilTs <= cursor)) {
|
|
202
202
|
scan.untilTs = undefined;
|
|
203
203
|
const tail = await readUnreadMessages(room.id, cursor, 20, sessionID, entry.name, true);
|
|
204
|
-
if (tail.items.some((message) =>
|
|
204
|
+
if (tail.items.some((message) => explicitlyAddresses(message, entry.name, sessionID, room.kind))) {
|
|
205
205
|
scan.untilTs = tail.items.at(-1)!.createdAt;
|
|
206
206
|
scan.afterTs = Math.max(scan.afterTs, scan.untilTs);
|
|
207
207
|
} else {
|
|
208
208
|
const candidates = await readUnreadMessages(room.id, scan.afterTs, 20, sessionID, entry.name);
|
|
209
209
|
if (!candidates.items.length) { restoreScans.set(key, scan); continue; }
|
|
210
210
|
scan.afterTs = candidates.items.at(-1)!.createdAt;
|
|
211
|
-
if (candidates.items.some((message) =>
|
|
211
|
+
if (candidates.items.some((message) => explicitlyAddresses(message, entry.name, sessionID, room.kind))) scan.untilTs = scan.afterTs;
|
|
212
212
|
restoreScans.set(key, scan);
|
|
213
213
|
if (scan.untilTs === undefined) continue;
|
|
214
214
|
}
|
|
@@ -219,8 +219,9 @@ export async function pollKnownSessions(
|
|
|
219
219
|
const target = mentionOnly ? { ...transport, mentionOnlySessions: new Set([...transport.mentionOnlySessions!].filter((id) => id !== sessionID)) } : transport;
|
|
220
220
|
await notifyTarget(sessionID, {
|
|
221
221
|
roomId: room.id,
|
|
222
|
-
|
|
223
|
-
|
|
222
|
+
roomName: room.name,
|
|
223
|
+
roomKind: room.kind ?? "group",
|
|
224
|
+
messages: page.items,
|
|
224
225
|
}, target);
|
|
225
226
|
if (mentionOnly && scan.untilTs !== undefined) {
|
|
226
227
|
const queued = (await loadRegistry())[room.id]?.[sessionID]?.lastQueuedTs ?? cursor;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# License information
|
|
2
|
+
|
|
3
|
+
## Contribution License Agreement
|
|
4
|
+
|
|
5
|
+
If you contribute code to this project, you are implicitly allowing your code
|
|
6
|
+
to be distributed under the MIT license. You are also implicitly verifying that
|
|
7
|
+
all code is your original work. `</legalese>`
|
|
8
|
+
|
|
9
|
+
## Marked
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2018+, MarkedJS (https://github.com/markedjs/)
|
|
12
|
+
Copyright (c) 2011-2018, Christopher Jeffrey (https://github.com/chjj/)
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in
|
|
22
|
+
all copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
30
|
+
THE SOFTWARE.
|
|
31
|
+
|
|
32
|
+
## Markdown
|
|
33
|
+
|
|
34
|
+
Copyright © 2004, John Gruber
|
|
35
|
+
http://daringfireball.net/
|
|
36
|
+
All rights reserved.
|
|
37
|
+
|
|
38
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
39
|
+
|
|
40
|
+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
41
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
42
|
+
* Neither the name “Markdown” nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
43
|
+
|
|
44
|
+
This software is provided by the copyright holders and contributors “as is” and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
Browser vendors bundled locally; no external requests are made at runtime.
|
|
2
|
+
|
|
3
|
+
marked 18.0.4 — MIT License, see MARKED-LICENSE.
|
|
4
|
+
DOMPurify 3.4.7 — MPL 2.0 or Apache License 2.0, see DOMPURIFY-LICENSE.
|
|
5
|
+
|
|
6
|
+
Sources: https://www.npmjs.com/package/marked and https://www.npmjs.com/package/dompurify
|