@alexsun-top/opencode-chat-room 0.8.1 → 0.8.2

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 (84) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +10 -10
  3. package/README.zh-CN.md +10 -10
  4. package/dist/cli.js +544 -88
  5. package/package.json +4 -4
  6. package/packages/chat-room-channeld/README.md +17 -12
  7. package/packages/chat-room-channeld/src/adapter.ts +145 -7
  8. package/packages/chat-room-channeld/src/host.ts +24 -9
  9. package/packages/chat-room-channeld/src/inbound.ts +13 -4
  10. package/packages/chat-room-channeld/src/protocol.ts +52 -1
  11. package/packages/chat-room-channeld/src/rules.ts +7 -2
  12. package/plugin.ts +1 -1
  13. package/server/assets/base.css +8 -2
  14. package/server/assets/chat/admin.js +0 -2
  15. package/server/assets/chat/announcements.js +2 -4
  16. package/server/assets/chat/chat-background.js +177 -0
  17. package/server/assets/chat/confirm-dialog.js +0 -1
  18. package/server/assets/chat/create-room-dialog.js +0 -1
  19. package/server/assets/chat/diagram-viewer.js +7 -1
  20. package/server/assets/chat/doc-preview.js +71 -15
  21. package/server/assets/chat/events.js +13 -5
  22. package/server/assets/chat/files.js +10 -6
  23. package/server/assets/chat/image-zoom.js +8 -1
  24. package/server/assets/chat/index.js +4 -2
  25. package/server/assets/chat/integration-account-schema.js +99 -0
  26. package/server/assets/chat/integration-editor.js +1 -1
  27. package/server/assets/chat/integrations.js +207 -57
  28. package/server/assets/chat/locales/de.js +1 -1
  29. package/server/assets/chat/locales/es.js +1 -1
  30. package/server/assets/chat/locales/fr.js +1 -1
  31. package/server/assets/chat/locales/it.js +1 -1
  32. package/server/assets/chat/locales/ja.js +1 -1
  33. package/server/assets/chat/locales/ko.js +1 -1
  34. package/server/assets/chat/markdown-footnotes.js +1 -1
  35. package/server/assets/chat/markdown.js +23 -0
  36. package/server/assets/chat/messages.js +1 -0
  37. package/server/assets/chat/palette.js +6 -1
  38. package/server/assets/chat/panels.js +23 -3
  39. package/server/assets/chat/receipts.js +2 -3
  40. package/server/assets/chat/reminders.js +2 -4
  41. package/server/assets/chat/replies.js +0 -6
  42. package/server/assets/chat/rooms.js +1 -6
  43. package/server/assets/chat/settings.js +69 -3
  44. package/server/assets/chat/shortcuts.js +0 -3
  45. package/server/assets/chat/side-pane.js +33 -8
  46. package/server/assets/chat/state.js +48 -18
  47. package/server/assets/chat/system-events.js +29 -3
  48. package/server/assets/chat/system-messages.js +9 -0
  49. package/server/assets/chat/tasks.js +2 -8
  50. package/server/assets/chat/window-controls.js +37 -0
  51. package/server/assets/code-highlight.css +22 -6
  52. package/server/assets/conversation.css +55 -12
  53. package/server/assets/doc-preview.css +6 -1
  54. package/server/assets/files.css +3 -0
  55. package/server/assets/monaco/integration-rules.css +1 -1
  56. package/server/assets/monaco/integration-rules.js +841 -533
  57. package/server/assets/responsive.css +32 -2
  58. package/server/assets/settings.css +117 -13
  59. package/server/assets/window-controls.css +36 -0
  60. package/server/channel-attachments.ts +133 -0
  61. package/server/channel-integration.ts +79 -26
  62. package/server/channels.ts +15 -5
  63. package/server/chat.html +71 -37
  64. package/server/manifest.webmanifest +1 -0
  65. package/server/sw.js +1 -0
  66. package/src/center/center-client.ts +1 -1
  67. package/src/state/pg-database.ts +5 -5
  68. package/src/state/pg-migrate.ts +7 -7
  69. package/src/state/pg-worker.mjs +2 -17
  70. package/src/state/sqlite-database.ts +14 -5
  71. package/src/state/sqlite-rooms.ts +130 -23
  72. package/src/state/sqlite-state-store.ts +6 -5
  73. package/src/state/sqlite.ts +3 -3
  74. package/src/web/integration-rules-editor.ts +139 -5
  75. package/src/web/integration-rules.ts +6 -2
  76. package/src/web/integration-schema.ts +7 -6
  77. package/packages/chat-room-channeld/dist/feishu-adapter.js +0 -1262
  78. package/packages/chat-room-channeld/src/feishu-adapter.ts +0 -303
  79. package/packages/chat-room-channeld/src/feishu-card.ts +0 -27
  80. package/packages/chat-room-channeld/src/feishu-inbound.ts +0 -158
  81. package/packages/chat-room-channeld/src/feishu-live.ts +0 -355
  82. package/packages/chat-room-channeld/src/feishu-send.ts +0 -342
  83. package/packages/chat-room-channeld/src/feishu-ws-frames.ts +0 -173
  84. package/server/assets/chat/forward.js +0 -69
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ - Add a browser-only chat background in Settings → Appearance: choose an image up to 2 MiB, set its opacity, and show it behind the whole client for every room. The picker shows a thumbnail and the chosen file name, reports reading, applied, and failure states, and choosing Default clears the image. The controls are a single column with no separate Reset button. Add a sixth custom theme after the five built-in themes: pick any color, apply it across the app, derive light or dark text from the color's luminance for contrast, and preview changes live while dragging while persisting only the settled value. Default background mode hides the opacity control.
6
+ - Never prompt for an access key on an unauthenticated instance; the key dialog opens only after a request is actually rejected with 401.
7
+ - Remove the manual Forward action and dialog from the browser UI. Agent forwarding through `GET /rooms/:id/forward-targets` and `POST /rooms/:id/forward`, plus the Channel D outbound queue, stay available; inbound relay, attachments, and notice styling are unchanged.
8
+ - Keep the Apache text for the bundled ECharts license regardless of filesystem order. Office prepack now fails instead of publishing the 168-byte NOTICE as `echarts-LICENSE.txt`, with a regression covering a mixed `LICENSE`/`NOTICE`/`licenses/` directory.
9
+ - Persist only the rows a state write actually changed instead of rewriting every room, participant, message, and registry entry. Concurrent PostgreSQL instances keep each other's committed rooms and registry rows, startup schema creation is serialized, and the single-writer advisory lock is gone. Wake delivery and pending admissions remain host-affine: run one watcher per host.
10
+ - Show the all-read check beside the bubble, bottom-aligned, for both own and incoming messages instead of reserving a separate column or moving it into the action row.
11
+ - Close the active side pane with Alt+Esc and restore focus to its opener. At large sizes the app may grow to 2200px and the pane takes up to 1080px while the conversation keeps at least 650px; the room rail stays fixed at 252px. The pane column animates open and closed unless reduced motion is requested, and adjacent footnote references render as `[1]`, `[2]` with spacing.
12
+ - Forward room images and files to Feishu as native image/file messages instead of dropping them, and import Feishu image/file attachments into room resources. Uploads are size-checked (10 MiB images, 30 MiB files), retries reuse the same Feishu message UUID, and failures appear as an explicit room message.
13
+ - Move platform adapters into the top-level `plugins/` directory as single files (`plugins/feishu`, with the adapter contract in `plugins/README.md`). The Feishu adapter builds to `plugins/feishu/dist/feishu-adapter.ts` by concatenating its typed source without a bundler, so the file keeps real TypeScript annotations, has no relative imports, and runs directly under Node 22.18+; the typed source stays in `plugins/feishu/src`, and the service ships no built-in adapter; the adapter is attached to the GitHub Release. The core launches any adapter through its account's `adapter.command`. Adapters now declare their display name, attachment limits, and account fields during `initialize`; the channeld core contains no platform-specific code, limits, or build step.
14
+ - Render system notices as Markdown with the date first and muted: notices up to three rendered lines keep a 50% pill, longer notices become a 12px rounded card, and inbound Channel relays use the normal message block with attachment cards.
15
+ - Upload a plugin as a single JavaScript or TypeScript file. The server runs an initialize-only probe without credentials, derives the platform, display name, account schema, and declared environment from the adapter, and rejects a file that cannot complete the handshake. The integration account dialog renders the plugin's schema form in place of raw environment rows, with environment variables under Advanced settings; existing accounts keep their stored environment.
16
+ - Download an uploaded plugin from its row with the original adapter filename. Only the file registered for that plugin is served; unknown ids and path-like ids return 404.
17
+ - Preview text and code files in a read-only Monaco editor, and reveal message code-block controls only on hover or keyboard focus; touch screens keep them visible. The integration rule editors default to YAML on the left and JSON on the right, and both use the same JSON Schema validation markers; YAML also shows schema descriptions on hover.
18
+ - Center icon-only buttons consistently, show a rotating chevron on the Advanced settings disclosure, remove the settings backdrop blur and scale animation so hovering cannot create compositing seams, and use one 168×38, 8px-radius size for settings selects and the chat-background opacity control.
19
+ - Support multiple accounts per platform: each account gets its own adapter process, environment, and `CHANNELD_ACCOUNT_ID`, and rules and inbound routes select the exact account. Feishu still permits one long connection per app, so accounts that share an App ID and enable inbound lose events; use separate apps or keep only one inbound account per app.
20
+ - Run adapter child processes with `--experimental-transform-types` in `NODE_OPTIONS` so TypeScript plugins may use enum, namespace, and constructor parameter properties. The server stays strip-only, experimental warnings are suppressed only for adapters, and a compiled `.js` remains the stable long-term form.
21
+ - Align message avatars to the message metadata line, right-align shortcut descriptions, and keep wheel panning responsive while the page is pinch-zoomed.
22
+ - Distinguish the conversation surface with a subtle background, rebalance the side gutters, and show avatars once the layout is wide enough.
23
+ - Use a borderless window-controls-overlay layout when an installed PWA exposes it, and keep the normal framed layout everywhere else.
24
+ - Print `message_id=… room_id=…` in send results and `message_id=… chat_id=… sender=…` in inbound relay headers, so IDs can be copied without parsing prose.
25
+
3
26
  ## 0.8.1 — 2026-11-26
4
27
 
5
28
  - Split the server entry into focused startup, application, and route modules, and split the SQLite state layer into schema, message, member, task, resource, announcement, and transaction modules behind the same public barrel. Shared addressing, room, and configuration types now live in `src/protocol` instead of being duplicated. The TUI and browser asset layers remain JavaScript in this release; a complete TypeScript migration is planned for 0.9.0.
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.1 -- opencode-chat-room --host 0.0.0.0 --port 4399 --token 'your-password'
29
+ npx --yes --package=@alexsun-top/opencode-chat-room@0.8.2 -- 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:
@@ -49,7 +49,7 @@ docker run --rm -p 4399:4399 -v chat-room-data:/data \
49
49
  ghcr.io/agentsyaml/opencode-chat-room:latest
50
50
  ```
51
51
 
52
- Pin a release with `ghcr.io/agentsyaml/opencode-chat-room:v0.8.1`. Rooms and files live in the `/data` volume; keep it across upgrades. A host bind mount must be writable by uid `10001`.
52
+ Pin a release with `ghcr.io/agentsyaml/opencode-chat-room:v0.8.2`. Rooms and files live in the `/data` volume; keep it across upgrades. A host bind mount must be writable by uid `10001`.
53
53
 
54
54
  ### Docker Compose
55
55
 
@@ -61,15 +61,15 @@ docker compose --profile postgres up -d # optional PostgreSQL state
61
61
  docker compose --profile rustfs up -d # optional S3-compatible storage
62
62
  ```
63
63
 
64
- Set `CHAT_ROOM_DATABASE_URL=postgresql://chatroom:CHANGEME@postgres:5432/chatroom` in `.env` when using the PostgreSQL profile. For RustFS, set `CHAT_ROOM_STORAGE=s3`, `CHAT_ROOM_S3_ENDPOINT=http://rustfs:9000`, `CHAT_ROOM_S3_BUCKET=chat-room`, and matching access keys, and create the bucket before starting the app. Pin the image with `BUILD_VERSION=v0.8.1`; `DOCKER_REGISTRY` and `SERVICE_NAME` override the image. The healthcheck probes `/chat`.
64
+ Set `CHAT_ROOM_DATABASE_URL=postgresql://chatroom:CHANGEME@postgres:5432/chatroom` in `.env` when using the PostgreSQL profile. For RustFS, set `CHAT_ROOM_STORAGE=s3`, `CHAT_ROOM_S3_ENDPOINT=http://rustfs:9000`, `CHAT_ROOM_S3_BUCKET=chat-room`, and matching access keys, and create the bucket before starting the app. Pin the image with `BUILD_VERSION=v0.8.2`; `DOCKER_REGISTRY` and `SERVICE_NAME` override the image. The healthcheck probes `/chat`.
65
65
 
66
66
  ### S3 file storage
67
67
 
68
68
  Files are stored beside the SQLite database by default. To keep them in S3 or an S3-compatible store (RustFS, MinIO, AWS S3), set `CHAT_ROOM_STORAGE=s3`, `CHAT_ROOM_S3_BUCKET`, `CHAT_ROOM_S3_ACCESS_KEY_ID`, and `CHAT_ROOM_S3_SECRET_ACCESS_KEY`; optionally set `CHAT_ROOM_S3_ENDPOINT`, `CHAT_ROOM_S3_REGION` (default `us-east-1`), `CHAT_ROOM_S3_PREFIX` (default `chat-room`), and `CHAT_ROOM_S3_FORCE_PATH_STYLE` (default true when an endpoint is set). The bucket must exist; startup fails if it is unreachable, credentials are rejected, or a required variable is missing. Uploads stream through a local temp file and only commit the database row after the S3 object is written. Files stay cached under the state directory unless `CHAT_ROOM_S3_LOCAL_CACHE=0` (also `false` or `off`); cached reads survive an S3 outage, but uploads and uncached reads fail instead of falling back to local storage. Minimal IAM permissions on the bucket: `s3:PutObject`, `s3:GetObject`, `s3:DeleteObject`, `s3:ListBucket`, and `s3:HeadBucket`, scoped to `<prefix>/*` where applicable. See the [reference](docs/reference.en.md#environment-variables).
69
69
 
70
- ### PostgreSQL state (experimental, single-instance)
70
+ ### PostgreSQL state (experimental, multi-instance)
71
71
 
72
- Set `CHAT_ROOM_DATABASE_URL=postgresql://user:password@host:5432/chatroom` on the **server** to keep room state in PostgreSQL 16+ instead of `chat-room.sqlite`. This backend is experimental in 0.8.1 and single-instance only: the server holds a session advisory lock, and a second chat-room process fails startup with a clear error. Multi-instance support is planned for 0.8.2. Set the variable only on the server; clients, watchers, and Channel D keep their own SQLite files. Channel D remains SQLite and single-host. S3-compatible resource storage is stable and independent of the database choice.
72
+ Set `CHAT_ROOM_DATABASE_URL=postgresql://user:password@host:5432/chatroom` on the **server** to keep room state in PostgreSQL 16+ instead of `chat-room.sqlite`. This backend remains experimental through the 0.8.2 multi-instance milestone. Multiple server processes can share one database: each write transaction takes a transaction-scoped advisory lock and applies only the rows it changed, so instances no longer reject each other or overwrite unrelated rooms, members, messages, and registry entries. Wake delivery and pending admissions are host-affine: only the host recorded for a session wakes it, so run one watcher per host; this milestone does not make watchers active-active. Set the variable only on the server; clients, watchers, and Channel D keep their own SQLite files. Channel D remains SQLite and single-host. S3-compatible resource storage is stable and independent of the database choice.
73
73
 
74
74
  Stop the server and make a WAL-safe SQLite backup before migrating:
75
75
 
@@ -77,7 +77,7 @@ Stop the server and make a WAL-safe SQLite backup before migrating:
77
77
  sqlite3 ~/.config/opencode/chat-room/chat-room.sqlite \
78
78
  ".backup '$HOME/chat-room.sqlite.backup'"
79
79
  CHAT_ROOM_DATABASE_URL=postgresql://user:password@host:5432/chatroom \
80
- npx --yes --package=@alexsun-top/opencode-chat-room@0.8.1 -- \
80
+ npx --yes --package=@alexsun-top/opencode-chat-room@0.8.2 -- \
81
81
  opencode-chat-room migrate --to-postgres --yes
82
82
  ```
83
83
 
@@ -85,7 +85,7 @@ The command copies all state tables in foreign-key order, preserves IDs and mess
85
85
 
86
86
  ## Channel D (Feishu outbound)
87
87
 
88
- Channel D is an optional forwarding sidecar, not a second chat. It forwards selected room messages to external targets. This release includes an outbound Feishu adapter and a mock adapter for tests; enable it only in central mode with a config path:
88
+ Channel D is an optional forwarding sidecar, not a second chat. It forwards selected room messages to external targets. Platform adapters are single files under the top-level `plugins/` directory: the Feishu adapter is `plugins/feishu/dist/feishu-adapter.ts`, generated by concatenating its typed source without a bundler so the file keeps real TypeScript annotations, attached to the GitHub Release, not shipped in this package and run directly by Node. Typed source lives in `plugins/feishu/src`; the core ships a mock adapter for tests. The core launches any adapter through its account's `adapter.command`. Enable it only in central mode with a config path:
89
89
 
90
90
  ```json
91
91
  {
@@ -97,9 +97,9 @@ Channel D is an optional forwarding sidecar, not a second chat. It forwards sele
97
97
  }
98
98
  ```
99
99
 
100
- Or set `CHAT_ROOM_CHANNELD_CONFIG=/path/channeld.yml`. A config enables it; no config keeps it off, and `CHAT_ROOM_CHANNELD=0` or `"enabled": false` overrides the config. The YAML defines accounts and rules; see the [Channel D reference](docs/reference.en.md#channel-d-feishu-outbound). The Feishu adapter reads `FEISHU_APP_ID` and `FEISHU_APP_SECRET`, with optional `FEISHU_BASE_URL`; a rule target's `room` is the Feishu `chat_id`.
100
+ Or set `CHAT_ROOM_CHANNELD_CONFIG=/path/channeld.yml`. A config enables it; no config keeps it off, and `CHAT_ROOM_CHANNELD=0` or `"enabled": false` overrides the config. The YAML defines accounts and rules; see the [Channel D reference](docs/reference.en.md#channel-d-outbound). The Feishu adapter reads `FEISHU_APP_ID` and `FEISHU_APP_SECRET`, with optional `FEISHU_BASE_URL`; a rule target's `room` is the Feishu `chat_id`.
101
101
 
102
- Forwarding is explicit: messages gain a Forward action when a rule matches, ordinary messages are never relayed automatically. Terminal deliveries record an ID/state-only `result.published` event and write a localized system message back to the room. State lives in `<stateDir>/channeld.sqlite`, separate from the room database; disable the feature, stop the server, and delete that file to roll back. With `CHATROOM_ALLOW_ADMIN=true`, Settings → Integrations manages accounts, uploaded JavaScript adapters, and forwarding rules without editing YAML. `POST /channeld/reload`, `/channeld/enable`, and `/channeld/disable` swap the relay runtime without restarting the center: invalid configs keep the old runtime, a failed restart restores the previous runtime, and in-flight deliveries become `unknown` without auto-resend. Persistence uses an existing writable JSON or YAML room config; otherwise the response reports that a restart is required. Admins can upload JavaScript adapters with `POST /channeld/plugins` (max 256 KiB, handshaken before saving) and manage accounts/rules with `GET`/`PUT /channeld/integration`; the server owns the `node` command and stores env values write-only under `<stateDir>/integrations`, returning only env keys plus the uploaded plugin list; omitting an account's `env` keeps its current values, a non-empty `env` merges only the listed keys, `env: {}` clears, and `envDelete` removes named keys. Feishu cards default to card 1.0 `lark_md`; set `FEISHU_CARD_VERSION=2.0` for block Markdown, and a forwarded room reply whose `answer_to` parent reached the same target uses a native Feishu reply. Opt-in inbound (`FEISHU_INBOUND=1` plus `FEISHU_INBOUND_CHATS` and an `inbound` route) turns allowlisted Feishu group text/post messages into one idempotent room notification each; inbound events never match outbound rules.
102
+ Forwarding is explicit and agent-driven: call `GET /rooms/:id/forward-targets` to list matching targets and `POST /rooms/:id/forward` to queue one; the browser UI has no Forward action, and ordinary messages are never relayed automatically. Terminal deliveries record an ID/state-only `result.published` event and write a localized system message back to the room. State lives in `<stateDir>/channeld.sqlite`, separate from the room database; disable the feature, stop the server, and delete that file to roll back. With `CHATROOM_ALLOW_ADMIN=true`, Settings → Integrations manages accounts, uploaded JavaScript adapters, and forwarding rules without editing YAML. `POST /channeld/reload`, `/channeld/enable`, and `/channeld/disable` swap the relay runtime without restarting the center: invalid configs keep the old runtime, a failed restart restores the previous runtime, and in-flight deliveries become `unknown` without auto-resend. Persistence uses an existing writable JSON or YAML room config; otherwise the response reports that a restart is required. Admins can upload JavaScript adapters with `POST /channeld/plugins` (max 256 KiB, handshaken before saving) and manage accounts/rules with `GET`/`PUT /channeld/integration`; the server owns the `node` command and stores env values write-only under `<stateDir>/integrations`, returning only env keys plus the uploaded plugin list; omitting an account's `env` keeps its current values, a non-empty `env` merges only the listed keys, `env: {}` clears, and `envDelete` removes named keys. Feishu cards default to card 1.0 `lark_md`; set `FEISHU_CARD_VERSION=2.0` for block Markdown, and a forwarded room reply whose `answer_to` parent reached the same target uses a native Feishu reply. Opt-in inbound (`FEISHU_INBOUND=1` plus `FEISHU_INBOUND_CHATS` and an `inbound` route) turns allowlisted Feishu group text, post, image, and file messages into one idempotent room notification each; attachments are imported into room resources. Inbound events never match outbound rules.
103
103
 
104
104
  ## What you can do
105
105
 
@@ -109,7 +109,7 @@ Forwarding is explicit: messages gain a Forward action when a rule matches, ordi
109
109
  - **Tasks:** track title, assignee, due date, participants, steps, conclusion, and todo/doing/done state in a side pane or modal. Each room holds at most 10 tasks by default; set `CHAT_ROOM_MAX_ROOM_TASKS` to a positive integer to change the cap, and delete a completed task first when the room is full.
110
110
  - **Reminders:** schedule one-time or cron reminders; text supports `{{time}}`, `{{initiator}}`, and `{{room}}`.
111
111
  - **Search and shortcuts:** Alt+Space or Ctrl+P searches messages; `/` filters commands in the composer. Alt+1…9 switches rooms. More shortcuts are in Settings.
112
- - **Terminal:** run `bunx --package @alexsun-top/opencode-chat-room@0.8.1 opencode-chat-room cli` against the same server. It supports rooms, messages, files, reminders, approval, search, editable settings for language/theme/name/server, and `/exit`. Bun 1.3.14+ is recommended; only the CLI loads OpenTUI.
112
+ - **Terminal:** run `bunx --package @alexsun-top/opencode-chat-room@0.8.2 opencode-chat-room cli` against the same server. It supports rooms, messages, files, reminders, approval, search, editable settings for language/theme/name/server, and `/exit`. Bun 1.3.14+ is recommended; only the CLI loads OpenTUI.
113
113
  - **Code:** fenced blocks are highlighted by a lazily loaded Shiki bundle with wrap and copy controls.
114
114
  - **Web app:** the interface installs to a phone home screen and starts offline from cache; chat data is never cached.
115
115
 
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.1 -- opencode-chat-room --host 0.0.0.0 --port 4399 --token 'your-password'
29
+ npx --yes --package=@alexsun-top/opencode-chat-room@0.8.2 -- 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 的机器设置地址和同一个令牌,然后启动 OpenCode:
@@ -49,7 +49,7 @@ docker run --rm -p 4399:4399 -v chat-room-data:/data \
49
49
  ghcr.io/agentsyaml/opencode-chat-room:latest
50
50
  ```
51
51
 
52
- 用 `ghcr.io/agentsyaml/opencode-chat-room:v0.8.1` 固定版本。房间和文件保存在 `/data` 卷里,升级时不要删除。若改用宿主机目录绑定,目录需允许 uid `10001` 写入。
52
+ 用 `ghcr.io/agentsyaml/opencode-chat-room:v0.8.2` 固定版本。房间和文件保存在 `/data` 卷里,升级时不要删除。若改用宿主机目录绑定,目录需允许 uid `10001` 写入。
53
53
 
54
54
  ### Docker Compose
55
55
 
@@ -61,15 +61,15 @@ docker compose --profile postgres up -d # 可选 PostgreSQL 状态
61
61
  docker compose --profile rustfs up -d # 可选 S3 兼容存储
62
62
  ```
63
63
 
64
- 使用 PostgreSQL profile 时,在 `.env` 里设置 `CHAT_ROOM_DATABASE_URL=postgresql://chatroom:CHANGEME@postgres:5432/chatroom`。使用 RustFS 时,设置 `CHAT_ROOM_STORAGE=s3`、`CHAT_ROOM_S3_ENDPOINT=http://rustfs:9000`、`CHAT_ROOM_S3_BUCKET=chat-room` 和对应的访问密钥,并在启动应用前创建存储桶。用 `BUILD_VERSION=v0.8.1` 固定镜像;`DOCKER_REGISTRY` 和 `SERVICE_NAME` 可以覆盖镜像地址。健康检查探测 `/chat`。
64
+ 使用 PostgreSQL profile 时,在 `.env` 里设置 `CHAT_ROOM_DATABASE_URL=postgresql://chatroom:CHANGEME@postgres:5432/chatroom`。使用 RustFS 时,设置 `CHAT_ROOM_STORAGE=s3`、`CHAT_ROOM_S3_ENDPOINT=http://rustfs:9000`、`CHAT_ROOM_S3_BUCKET=chat-room` 和对应的访问密钥,并在启动应用前创建存储桶。用 `BUILD_VERSION=v0.8.2` 固定镜像;`DOCKER_REGISTRY` 和 `SERVICE_NAME` 可以覆盖镜像地址。健康检查探测 `/chat`。
65
65
 
66
66
  ### S3 文件存储
67
67
 
68
68
  文件默认与 SQLite 数据库放在一起。要改用 S3 或兼容 S3 的存储(RustFS、MinIO、AWS S3),设置 `CHAT_ROOM_STORAGE=s3`、`CHAT_ROOM_S3_BUCKET`、`CHAT_ROOM_S3_ACCESS_KEY_ID` 和 `CHAT_ROOM_S3_SECRET_ACCESS_KEY`;可选 `CHAT_ROOM_S3_ENDPOINT`、`CHAT_ROOM_S3_REGION`(默认 `us-east-1`)、`CHAT_ROOM_S3_PREFIX`(默认 `chat-room`)和 `CHAT_ROOM_S3_FORCE_PATH_STYLE`(设置 endpoint 时默认 true)。存储桶必须已存在;桶不可达、凭证被拒或缺少必填变量时服务端拒绝启动。上传先写入本地临时文件,S3 对象写入成功后才提交数据库记录。除非设置 `CHAT_ROOM_S3_LOCAL_CACHE=0`(也支持 `false` 或 `off`),文件会同时缓存到状态目录;S3 故障时缓存读取仍可用,但上传和未缓存的读取会直接失败,不会回退到本地存储。桶上的最小 IAM 权限:`s3:PutObject`、`s3:GetObject`、`s3:DeleteObject`、`s3:ListBucket`、`s3:HeadBucket`,可按 `<prefix>/*` 缩小范围。详见[参考](docs/reference.zh-CN.md#环境变量)。
69
69
 
70
- ### PostgreSQL 状态(实验性,单实例)
70
+ ### PostgreSQL 状态(实验性,多实例)
71
71
 
72
- 在**服务端**设置 `CHAT_ROOM_DATABASE_URL=postgresql://user:password@host:5432/chatroom`,房间状态就会写入 PostgreSQL 16+,不再使用 `chat-room.sqlite`。该后端在 0.8.1 中属于实验功能,且只支持单实例:服务端会持有会话级 advisory lock,第二个 chat-room 进程会启动失败并给出明确错误。多实例支持计划在 0.8.2 提供。只应在服务端设置该变量;客户端、watcher 和 Channel D 继续使用各自的 SQLite 文件。Channel D 保持 SQLite、单主机。S3 兼容资源存储已稳定,与数据库选择无关。
72
+ 在**服务端**设置 `CHAT_ROOM_DATABASE_URL=postgresql://user:password@host:5432/chatroom`,房间状态就会写入 PostgreSQL 16+,不再使用 `chat-room.sqlite`。该后端在 0.8.2 多实例里程碑完成前仍属实验功能。多个服务端进程可以共用同一个数据库:每个写事务获取事务级 advisory lock,并且只写入发生变化的行,因此实例之间不再互相拒绝,也不会覆盖无关的房间、成员、消息和 registry 条目。唤醒投递和待处理准入是主机亲和的:只有会话登记的那台主机负责唤醒,每个主机只应运行一个 watcher;这个里程碑不把 watcher 做成多活。只应在服务端设置该变量;客户端、watcher 和 Channel D 继续使用各自的 SQLite 文件。Channel D 保持 SQLite、单主机。S3 兼容资源存储已稳定,与数据库选择无关。
73
73
 
74
74
  迁移前先停止服务端,并做一次 WAL 安全的 SQLite 备份:
75
75
 
@@ -77,7 +77,7 @@ docker compose --profile rustfs up -d # 可选 S3 兼容存储
77
77
  sqlite3 ~/.config/opencode/chat-room/chat-room.sqlite \
78
78
  ".backup '$HOME/chat-room.sqlite.backup'"
79
79
  CHAT_ROOM_DATABASE_URL=postgresql://user:password@host:5432/chatroom \
80
- npx --yes --package=@alexsun-top/opencode-chat-room@0.8.1 -- \
80
+ npx --yes --package=@alexsun-top/opencode-chat-room@0.8.2 -- \
81
81
  opencode-chat-room migrate --to-postgres --yes
82
82
  ```
83
83
 
@@ -85,7 +85,7 @@ CHAT_ROOM_DATABASE_URL=postgresql://user:password@host:5432/chatroom \
85
85
 
86
86
  ## Channel D(飞书出站)
87
87
 
88
- Channel D 是可选的转发侧车,不是另一套聊天。它把选定的房间消息转发到外部目标。本版包含飞书出站 adapter 和用于测试的 mock adapter;只在中心模式用配置路径启用:
88
+ Channel D 是可选的转发侧车,不是另一套聊天。它把选定的房间消息转发到外部目标。平台 adapter 是顶层 `plugins/` 目录下的单文件:飞书 adapter 为 `plugins/feishu/dist/feishu-adapter.ts`,由带类型的源码拼接生成、不经过打包器,因此文件里保留真实 TypeScript 类型;它作为 GitHub Release 资产发布,不随本包分发,由 Node 直接运行。带类型源码在 `plugins/feishu/src`;核心只带用于测试的 mock adapter,并通过账号的 `adapter.command` 启动任意 adapter。只在中心模式用配置路径启用:
89
89
 
90
90
  ```json
91
91
  {
@@ -97,9 +97,9 @@ Channel D 是可选的转发侧车,不是另一套聊天。它把选定的房
97
97
  }
98
98
  ```
99
99
 
100
- 或设置 `CHAT_ROOM_CHANNELD_CONFIG=/path/channeld.yml`。有配置就启用,没有配置保持关闭,`CHAT_ROOM_CHANNELD=0` 或 `"enabled": false` 可以覆盖配置强制关闭。YAML 定义账号和规则;详见 [Channel D 参考](docs/reference.zh-CN.md#channel-d飞书出站)。飞书 adapter 读取 `FEISHU_APP_ID` 和 `FEISHU_APP_SECRET`,可选 `FEISHU_BASE_URL`;规则目标的 `room` 就是飞书 `chat_id`。
100
+ 或设置 `CHAT_ROOM_CHANNELD_CONFIG=/path/channeld.yml`。有配置就启用,没有配置保持关闭,`CHAT_ROOM_CHANNELD=0` 或 `"enabled": false` 可以覆盖配置强制关闭。YAML 定义账号和规则;详见 [Channel D 参考](docs/reference.zh-CN.md#channel-d-outbound)。飞书 adapter 读取 `FEISHU_APP_ID` 和 `FEISHU_APP_SECRET`,可选 `FEISHU_BASE_URL`;规则目标的 `room` 就是飞书 `chat_id`。
101
101
 
102
- 转发是显式动作:规则命中后消息上出现“转发”操作,普通消息不会被自动转发。终态投递会记录一条仅含 ID/状态的 `result.published` 事件,再向房间写一条本地化系统消息。状态保存在 `<stateDir>/channeld.sqlite`,与房间数据库分开;关闭功能、停止服务并删除该文件即可回滚。设置 `CHATROOM_ALLOW_ADMIN=true` 后,可在“设置 → 平台集成”中管理账号、上传 JavaScript adapter 和编辑转发规则,无需手改 YAML。也可用 `POST /channeld/reload`、`/channeld/enable`、`/channeld/disable` 在不重启中心服务的情况下切换中继运行时:新配置无效时保留旧运行时,新运行时启动失败会恢复旧运行时,在途投递变为 `unknown` 且不会自动重发。只有存在可写的 JSON 或 YAML 房间配置时才会持久化,否则响应会提示需要重启。管理员还可用 `POST /channeld/plugins` 上传 JavaScript adapter(上限 256 KiB,保存前先握手),通过 `GET`/`PUT /channeld/integration` 管理账号和规则;`node` 命令由服务端固定,环境变量只写不读地保存在 `<stateDir>/integrations`,接口只返回变量名和已上传插件列表;账号的 `env` 非空时只合并列出的键,`{}` 清空,`envDelete` 删除指定键,省略 `env` 保留当前值。飞书卡片默认使用 card 1.0 `lark_md`;设置 `FEISHU_CARD_VERSION=2.0` 可启用块级 Markdown,房间回复的 `answer_to` 父消息若已投递到同一目标则使用飞书原生回复。可选入站(`FEISHU_INBOUND=1`、`FEISHU_INBOUND_CHATS` 和 `inbound` 路由)把允许列表群聊里的飞书 text/post 消息写成一条幂等的房间通知;入站事件不会匹配出站规则。
102
+ 转发是显式的 Agent 动作:用 `GET /rooms/:id/forward-targets` 列出匹配目标,用 `POST /rooms/:id/forward` 排队一次转发;浏览器界面不再提供“转发”操作,普通消息也不会被自动转发。终态投递会记录一条仅含 ID/状态的 `result.published` 事件,再向房间写一条本地化系统消息。状态保存在 `<stateDir>/channeld.sqlite`,与房间数据库分开;关闭功能、停止服务并删除该文件即可回滚。设置 `CHATROOM_ALLOW_ADMIN=true` 后,可在“设置 → 平台集成”中管理账号、上传 JavaScript adapter 和编辑转发规则,无需手改 YAML。也可用 `POST /channeld/reload`、`/channeld/enable`、`/channeld/disable` 在不重启中心服务的情况下切换中继运行时:新配置无效时保留旧运行时,新运行时启动失败会恢复旧运行时,在途投递变为 `unknown` 且不会自动重发。只有存在可写的 JSON 或 YAML 房间配置时才会持久化,否则响应会提示需要重启。管理员还可用 `POST /channeld/plugins` 上传 JavaScript adapter(上限 256 KiB,保存前先握手),通过 `GET`/`PUT /channeld/integration` 管理账号和规则;`node` 命令由服务端固定,环境变量只写不读地保存在 `<stateDir>/integrations`,接口只返回变量名和已上传插件列表;账号的 `env` 非空时只合并列出的键,`{}` 清空,`envDelete` 删除指定键,省略 `env` 保留当前值。飞书卡片默认使用 card 1.0 `lark_md`;设置 `FEISHU_CARD_VERSION=2.0` 可启用块级 Markdown,房间回复的 `answer_to` 父消息若已投递到同一目标则使用飞书原生回复。可选入站(`FEISHU_INBOUND=1`、`FEISHU_INBOUND_CHATS` 和 `inbound` 路由)把允许列表群聊里的飞书 text/post/image/file 消息写成一条幂等的房间通知,附件会导入房间资源;入站事件不会匹配出站规则。
103
103
 
104
104
  ## 可以做什么
105
105
 
@@ -109,7 +109,7 @@ Channel D 是可选的转发侧车,不是另一套聊天。它把选定的房
109
109
  - **任务:** 在侧栏或弹窗里跟踪标题、负责人、截止日期、参与人、步骤、结论和 todo/doing/done 状态。每个房间默认最多 10 个任务;设置 `CHAT_ROOM_MAX_ROOM_TASKS` 为正整数可调整上限,房间已满时先删除一个已完成的任务再添加。
110
110
  - **提醒:** 一次性或 cron 提醒;文本支持 `{{time}}`、`{{initiator}}` 和 `{{room}}`。
111
111
  - **搜索与快捷键:** Alt+Space 或 Ctrl+P 搜索消息;输入框开头输入 `/` 过滤命令。Alt+1…9 切换房间,更多快捷键在设置里。
112
- - **终端:** 用 `bunx --package @alexsun-top/opencode-chat-room@0.8.1 opencode-chat-room cli` 连接同一服务端,支持房间、消息、文件、提醒、审核、搜索、语言/主题/显示名/服务器设置和 `/exit`。推荐 Bun 1.3.14+;只有 CLI 加载 OpenTUI。
112
+ - **终端:** 用 `bunx --package @alexsun-top/opencode-chat-room@0.8.2 opencode-chat-room cli` 连接同一服务端,支持房间、消息、文件、提醒、审核、搜索、语言/主题/显示名/服务器设置和 `/exit`。推荐 Bun 1.3.14+;只有 CLI 加载 OpenTUI。
113
113
  - **代码:** 围栏代码块由懒加载的 Shiki bundle 高亮,带换行和复制控件。
114
114
  - **Web App:** 界面可安装到手机主屏,离线时从缓存启动;聊天数据不会缓存。
115
115