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

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 (125) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +18 -62
  3. package/README.zh-CN.md +25 -69
  4. package/dist/cli.js +1008 -274
  5. package/package.json +10 -7
  6. package/packages/chat-room-channeld/README.md +42 -15
  7. package/packages/chat-room-channeld/dist/mock-adapter.js +5 -5
  8. package/packages/chat-room-channeld/src/adapter.ts +150 -7
  9. package/packages/chat-room-channeld/src/cli.ts +72 -5
  10. package/packages/chat-room-channeld/src/host.ts +41 -11
  11. package/packages/chat-room-channeld/src/inbound.ts +13 -4
  12. package/packages/chat-room-channeld/src/pg/database.ts +187 -0
  13. package/packages/chat-room-channeld/src/pg/migrate.ts +150 -0
  14. package/packages/chat-room-channeld/src/pg/schema.ts +60 -0
  15. package/packages/chat-room-channeld/src/pg/sql.mjs +175 -0
  16. package/packages/chat-room-channeld/src/pg/sqlite.ts +100 -0
  17. package/packages/chat-room-channeld/src/pg/worker.mjs +133 -0
  18. package/packages/chat-room-channeld/src/protocol.ts +53 -1
  19. package/packages/chat-room-channeld/src/rules.ts +7 -2
  20. package/packages/chat-room-channeld/src/state.ts +73 -97
  21. package/packages/chat-room-channeld/src/stats.ts +140 -109
  22. package/plugin.ts +1 -1
  23. package/server/assets/base.css +11 -3
  24. package/server/assets/chat/admin-badge.js +32 -30
  25. package/server/assets/chat/admin.js +198 -163
  26. package/server/assets/chat/announcements.js +295 -210
  27. package/server/assets/chat/attachment-store.js +106 -75
  28. package/server/assets/chat/attachments.js +686 -441
  29. package/server/assets/chat/chat-background.js +206 -0
  30. package/server/assets/chat/clipboard.js +44 -25
  31. package/server/assets/chat/confirm-dialog.js +36 -34
  32. package/server/assets/chat/copy-action.js +40 -40
  33. package/server/assets/chat/create-room-dialog.js +50 -48
  34. package/server/assets/chat/diagram-viewer.js +293 -228
  35. package/server/assets/chat/doc-preview.js +510 -388
  36. package/server/assets/chat/editor.js +423 -335
  37. package/server/assets/chat/events.js +637 -502
  38. package/server/assets/chat/files.js +476 -426
  39. package/server/assets/chat/history-loader.js +79 -73
  40. package/server/assets/chat/icons.js +9 -11
  41. package/server/assets/chat/image-zoom.js +239 -169
  42. package/server/assets/chat/index.js +6 -5
  43. package/server/assets/chat/install-prompt.js +86 -66
  44. package/server/assets/chat/integration-account-schema.js +101 -0
  45. package/server/assets/chat/integration-editor.js +162 -153
  46. package/server/assets/chat/integration-values.js +109 -100
  47. package/server/assets/chat/integrations.js +696 -479
  48. package/server/assets/chat/join-requests.js +408 -358
  49. package/server/assets/chat/locales/de.js +193 -194
  50. package/server/assets/chat/locales/es.js +193 -194
  51. package/server/assets/chat/locales/fr.js +193 -194
  52. package/server/assets/chat/locales/index.js +1 -2
  53. package/server/assets/chat/locales/it.js +193 -194
  54. package/server/assets/chat/locales/ja.js +193 -193
  55. package/server/assets/chat/locales/ko.js +193 -193
  56. package/server/assets/chat/markdown-footnotes.js +134 -102
  57. package/server/assets/chat/markdown.js +553 -386
  58. package/server/assets/chat/members.js +236 -197
  59. package/server/assets/chat/mentions.js +157 -133
  60. package/server/assets/chat/message-cache.js +40 -33
  61. package/server/assets/chat/message-polling.js +280 -227
  62. package/server/assets/chat/message-window.js +74 -55
  63. package/server/assets/chat/messages.js +552 -479
  64. package/server/assets/chat/office-preview.js +46 -45
  65. package/server/assets/chat/palette.js +450 -412
  66. package/server/assets/chat/panels.js +94 -58
  67. package/server/assets/chat/pwa.js +144 -73
  68. package/server/assets/chat/questions.js +372 -302
  69. package/server/assets/chat/recall.js +320 -273
  70. package/server/assets/chat/receipts.js +149 -122
  71. package/server/assets/chat/reminders.js +331 -216
  72. package/server/assets/chat/replies.js +165 -136
  73. package/server/assets/chat/resource-format.js +59 -62
  74. package/server/assets/chat/room-list.js +58 -55
  75. package/server/assets/chat/room-watcher.js +72 -50
  76. package/server/assets/chat/rooms.js +623 -505
  77. package/server/assets/chat/search.js +136 -114
  78. package/server/assets/chat/settings.js +229 -140
  79. package/server/assets/chat/shiki.js +61 -62
  80. package/server/assets/chat/shortcuts.js +212 -190
  81. package/server/assets/chat/side-pane.js +166 -131
  82. package/server/assets/chat/state.js +851 -707
  83. package/server/assets/chat/system-events.js +55 -27
  84. package/server/assets/chat/system-messages.js +59 -49
  85. package/server/assets/chat/task-form.js +178 -182
  86. package/server/assets/chat/task-row.js +158 -155
  87. package/server/assets/chat/tasks.js +653 -593
  88. package/server/assets/chat/viewport.js +32 -29
  89. package/server/assets/chat/window-controls.js +37 -0
  90. package/server/assets/code-highlight.css +22 -6
  91. package/server/assets/conversation.css +65 -16
  92. package/server/assets/doc-preview.css +6 -1
  93. package/server/assets/files.css +3 -0
  94. package/server/assets/monaco/integration-rules.css +1 -1
  95. package/server/assets/monaco/integration-rules.js +841 -533
  96. package/server/assets/responsive.css +32 -2
  97. package/server/assets/settings.css +117 -13
  98. package/server/assets/window-controls.css +36 -0
  99. package/server/channel-attachments.ts +133 -0
  100. package/server/channel-integration.ts +79 -26
  101. package/server/channels.ts +15 -5
  102. package/server/chat-server.ts +9 -1
  103. package/server/chat.html +73 -38
  104. package/server/manifest.webmanifest +1 -0
  105. package/server/routes/pages.ts +7 -5
  106. package/server/sw.js +346 -267
  107. package/src/center/center-client.ts +1 -1
  108. package/src/state/pg-database.ts +5 -5
  109. package/src/state/pg-migrate.ts +7 -7
  110. package/src/state/pg-worker.mjs +2 -17
  111. package/src/state/sqlite-database.ts +14 -5
  112. package/src/state/sqlite-rooms.ts +130 -23
  113. package/src/state/sqlite-state-store.ts +6 -5
  114. package/src/state/sqlite.ts +3 -3
  115. package/src/web/integration-rules-editor.ts +141 -5
  116. package/src/web/integration-rules.ts +6 -2
  117. package/src/web/integration-schema.ts +7 -6
  118. package/packages/chat-room-channeld/dist/feishu-adapter.js +0 -1262
  119. package/packages/chat-room-channeld/src/feishu-adapter.ts +0 -303
  120. package/packages/chat-room-channeld/src/feishu-card.ts +0 -27
  121. package/packages/chat-room-channeld/src/feishu-inbound.ts +0 -158
  122. package/packages/chat-room-channeld/src/feishu-live.ts +0 -355
  123. package/packages/chat-room-channeld/src/feishu-send.ts +0 -342
  124. package/packages/chat-room-channeld/src/feishu-ws-frames.ts +0 -173
  125. package/server/assets/chat/forward.js +0 -69
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ - 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. The published package and image contain only generated JavaScript, two builds are byte-for-byte reproducible, and a non-strict zero-diagnostic frontend check guards regressions; strict TypeScript convergence remains a separate task.
6
+ - 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.
7
+ - 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.
8
+ - Recover stale Channel D in-flight deliveries by adapter capability: adapters declaring `send.idempotency = "persistent_delivery_key"` return them to `pending` with the original delivery key, while every other adapter leaves them `unknown` and never resends automatically. Add `channeld retry --config <path> --delivery <id> --force` to move one `unknown` delivery back to `pending`; it rejects other states and a removed account, does not start the host, and `--force` acknowledges that a non-idempotent adapter resends from the first message part, so a duplicate is possible.
9
+ - Add a standalone Telegram Bot API adapter under `plugins/telegram`: long polling, text, image, and file delivery, inbound downloads with deduplication, 429 rate-limit mapping, and clean shutdown. Outbound text longer than Telegram's 4096-character limit is split in order without breaking a character, and a retried delivery resumes at the first unsent part within the same adapter process (a restart can repeat the first parts because Telegram has no idempotency key). It is one self-contained TypeScript file with no relative imports; real credentials and network are not exercised by the repository tests.
10
+ - Center the date on short system notice pills, keep long notice cards top-aligned, and treat the notice glyph as decoration instead of a button: no border, background, or pointer target. The announcements list and its status line reserve height so first load and refresh no longer jitter.
11
+ - Rename room reminder actions from pause/resume to disable/enable, gray out disabled reminders while keeping their actions usable, and reserve the list and status height so loading and refresh no longer shift the panel.
12
+ - Highlight TypeScript and JavaScript previews with Monaco's language definitions without starting a language-service worker. The editor keeps its read-only context menu, find, copy, download, and folding behavior; semantic diagnostics remain out of scope because the feature-register type graph breaks `tsc`.
13
+ - Build the channeld mock adapter through one command for local packs and CI, so the published file no longer depends on whether a previous bundle happened to exist.
14
+
15
+ - 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.
16
+ - Never prompt for an access key on an unauthenticated instance; the key dialog opens only after a request is actually rejected with 401.
17
+ - 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.
18
+ - 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.
19
+ - 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.
20
+ - 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.
21
+ - 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.
22
+ - 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.
23
+ - 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.
24
+ - 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.
25
+ - 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.
26
+ - 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.
27
+ - 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.
28
+ - 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.
29
+ - 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.
30
+ - 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.
31
+ - Align message avatars to the message metadata line, right-align shortcut descriptions, and keep wheel panning responsive while the page is pinch-zoomed.
32
+ - Distinguish the conversation surface with a subtle background, rebalance the side gutters, and show avatars once the layout is wide enough.
33
+ - Use a borderless window-controls-overlay layout when an installed PWA exposes it, and keep the normal framed layout everywhere else.
34
+ - 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.
35
+
3
36
  ## 0.8.1 — 2026-11-26
4
37
 
5
38
  - 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
@@ -1,6 +1,6 @@
1
1
  # OC Chat
2
2
 
3
- Chat in shared rooms with OpenCode agents and people. Use the web or terminal client; one server connects multiple hosts.
3
+ Chat in shared rooms with OpenCode agents and people. One server stores rooms, messages, and files; OpenCode hosts, the web client, and the terminal client connect to it.
4
4
 
5
5
  [简体中文](README.zh-CN.md) · [Technical reference](docs/reference.en.md) · [Changelog](CHANGELOG.md)
6
6
 
@@ -19,14 +19,14 @@ Install [Bun](https://bun.sh), then add the plugin to `~/.config/opencode/openco
19
19
 
20
20
  Restart OpenCode and ask an agent to create a room, or enter `/room create dev`.
21
21
 
22
- When upgrading, quit OpenCode first or run `opencode plugin add @alexsun-top/opencode-chat-room@<version>`. Editing the version while OpenCode is running can leave a broken package cache under `~/.cache/opencode/npm/`; delete that directory and add the plugin again to recover.
22
+ When upgrading, quit OpenCode first or run `opencode plugin add @alexsun-top/opencode-chat-room@<version>`. If a version change leaves a broken package cache, delete `~/.cache/opencode/npm/` and add the plugin again.
23
23
 
24
24
  ### 2. Start a server
25
25
 
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.3 -- 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:
@@ -37,7 +37,7 @@ export CHAT_ROOM_SERVER_TOKEN="your-password"
37
37
  opencode
38
38
  ```
39
39
 
40
- Open `http://SERVER_IP:4399/chat` and enter the token in Settings. Environment variables can be replaced by a `chatroom.json`, `chatroom.jsonc`, `chatroom.yaml`, or `chatroom.yml`; see the [configuration reference](docs/reference.en.md#configuration-file).
40
+ Open `http://SERVER_IP:4399/chat` and enter the token in Settings. Instead of environment variables you can use `chatroom.json`, `chatroom.jsonc`, `chatroom.yaml`, or `chatroom.yml`; see the [configuration reference](docs/reference.en.md#configuration-file).
41
41
 
42
42
  **Security:** anyone with the shared token can access and manage rooms, including direct chats. Join approval controls the normal join flow, not per-user authentication. Share the token only with trusted people and protect network access to the server.
43
43
 
@@ -46,72 +46,28 @@ Open `http://SERVER_IP:4399/chat` and enter the token in Settings. Environment v
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:latest
49
+ ghcr.io/agentsyaml/opencode-chat-room:v0.8.3
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
+ 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
- ### Docker Compose
55
-
56
- The repository's `docker-compose.yaml` runs the app by default and keeps PostgreSQL and RustFS behind optional profiles. Copy `.env.example` to `.env` and set `CHAT_ROOM_SERVER_TOKEN`; Compose refuses to start without it instead of exposing an unauthenticated server. Then:
57
-
58
- ```bash
59
- docker compose up -d --build
60
- docker compose --profile postgres up -d # optional PostgreSQL state
61
- docker compose --profile rustfs up -d # optional S3-compatible storage
62
- ```
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`.
65
-
66
- ### S3 file storage
67
-
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
-
70
- ### PostgreSQL state (experimental, single-instance)
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.
73
-
74
- Stop the server and make a WAL-safe SQLite backup before migrating:
75
-
76
- ```bash
77
- sqlite3 ~/.config/opencode/chat-room/chat-room.sqlite \
78
- ".backup '$HOME/chat-room.sqlite.backup'"
79
- CHAT_ROOM_DATABASE_URL=postgresql://user:password@host:5432/chatroom \
80
- npx --yes --package=@alexsun-top/opencode-chat-room@0.8.1 -- \
81
- opencode-chat-room migrate --to-postgres --yes
82
- ```
83
-
84
- The command copies all state tables in foreign-key order, preserves IDs and message `seq` values, advances the PostgreSQL sequence, verifies row counts, and refuses a non-empty target. Rollback is an environment switch: unset `CHAT_ROOM_DATABASE_URL` and start the server from the untouched SQLite file. Messages written while PostgreSQL was active are not copied back to SQLite.
85
-
86
- ## Channel D (Feishu outbound)
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:
89
-
90
- ```json
91
- {
92
- "server": {
93
- "channeld": {
94
- "config": "/etc/chatroom/channeld.yml"
95
- }
96
- }
97
- }
98
- ```
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`.
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.
54
+ For Docker Compose, PostgreSQL state, S3-compatible storage, and all environment variables, see the [deployment reference](docs/reference.en.md#environment-variables).
103
55
 
104
56
  ## What you can do
105
57
 
106
58
  - **Rooms and people:** create or join rooms, invite devices, approve joins, manage members and owners, and open direct chats.
107
59
  - **Messages:** reply, mark questions, recall with a recoverable original, and mention people or `@all`.
108
- - **Files:** attach, drag, or paste up to 500 MiB; preview images, media, Markdown, text, code, PDF, Word (.docx), Excel (.xlsx), and PowerPoint (.pptx); open any document preview full screen; download or delete.
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
- - **Reminders:** schedule one-time or cron reminders; text supports `{{time}}`, `{{initiator}}`, and `{{room}}`.
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.
113
- - **Code:** fenced blocks are highlighted by a lazily loaded Shiki bundle with wrap and copy controls.
114
- - **Web app:** the interface installs to a phone home screen and starts offline from cache; chat data is never cached.
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
+ - **Tasks and reminders:** track tasks in a side pane or modal; schedule one-time or cron reminders.
62
+ - **Search and shortcuts:** Alt+Space or Ctrl+P searches messages; `/` filters commands. More shortcuts are in Settings.
63
+ - **Terminal:** run `bunx --package @alexsun-top/opencode-chat-room@0.8.3 opencode-chat-room cli` against the same server. Only the CLI loads OpenTUI.
64
+ - **Web app:** installs to a phone home screen and starts offline from cache; chat data is never cached.
65
+
66
+ ## Optional services
67
+
68
+ Channel D is an optional forwarding sidecar for sending selected room messages to external platforms. It ships with no built-in adapter: download an adapter from the GitHub Release, upload it in Settings → Platform integrations, then add an account and a rule. Forwarding is explicit (`GET /rooms/:id/forward-targets`, `POST /rooms/:id/forward`); ordinary messages are never relayed automatically. See the [Channel D reference](docs/reference.en.md).
69
+
70
+ S3-compatible storage and PostgreSQL state are configured through environment variables. PostgreSQL supports multiple server instances; Channel D keeps its own single-host state. Both are covered in the [technical reference](docs/reference.en.md).
115
71
 
116
72
  ## More help
117
73
 
package/README.zh-CN.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # OC Chat
2
2
 
3
- 与 OpenCode Agent 和人在共享房间里聊天。用网页或终端客户端;一个服务端连接多台主机。
3
+ 与 OpenCode agent 和人在共享房间里聊天。一个服务端保存房间、消息和文件;OpenCode 主机、网页端和终端客户端都连接到它。
4
4
 
5
5
  [English](README.md) · [技术参考](docs/reference.zh-CN.md) · [更新日志](CHANGELOG.md)
6
6
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  ### 1. 安装插件
10
10
 
11
- 先安装 [Bun](https://bun.sh),再把插件加入 `~/.config/opencode/opencode.json`:
11
+ 安装 [Bun](https://bun.sh),然后把插件加入 `~/.config/opencode/opencode.json`:
12
12
 
13
13
  ```json
14
14
  {
@@ -17,19 +17,19 @@
17
17
  }
18
18
  ```
19
19
 
20
- 重启 OpenCode,让 Agent 创建一个房间,或输入 `/room create dev`。
20
+ 重启 OpenCode,让 agent 创建房间,或者输入 `/room create dev`。
21
21
 
22
- 升级时先退出 OpenCode,或运行 `opencode plugin add @alexsun-top/opencode-chat-room@<version>`。在 OpenCode 运行时改版本号可能在 `~/.cache/opencode/npm/` 留下损坏的包缓存;删除该目录后重新添加插件即可恢复。
22
+ 升级时先退出 OpenCode,或者运行 `opencode plugin add @alexsun-top/opencode-chat-room@<version>`。如果切换版本后包缓存损坏,删除 `~/.cache/opencode/npm/` 并重新安装插件。
23
23
 
24
24
  ### 2. 启动服务端
25
25
 
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.3 -- opencode-chat-room --host 0.0.0.0 --port 4399 --token 'your-password'
30
30
  ```
31
31
 
32
- 服务端支持 Node.js 24.2+、Deno 2 或 Bun。每台运行 OpenCode 的机器设置地址和同一个令牌,然后启动 OpenCode:
32
+ 服务端支持 Node.js 24.2+、Deno 2 或 Bun。在每台 OpenCode 机器上设置地址和同一个 token,然后启动 OpenCode:
33
33
 
34
34
  ```bash
35
35
  export CHAT_ROOM_SERVER_URL="http://SERVER_IP:4399"
@@ -37,87 +37,43 @@ export CHAT_ROOM_SERVER_TOKEN="your-password"
37
37
  opencode
38
38
  ```
39
39
 
40
- 打开 `http://SERVER_IP:4399/chat`,在设置里填入同一个令牌。也可以用 `chatroom.json`、`chatroom.jsonc`、`chatroom.yaml` 或 `chatroom.yml` 代替环境变量;详见[配置参考](docs/reference.zh-CN.md#配置文件)。
40
+ 打开 `http://SERVER_IP:4399/chat`,在设置里输入 token。也可以用 `chatroom.json`、`chatroom.jsonc`、`chatroom.yaml` 或 `chatroom.yml` 代替环境变量;见[配置参考](docs/reference.zh-CN.md#配置文件)。
41
41
 
42
- **安全:** 持有共享令牌的人可以访问和管理所有房间,包括私聊。加入审核只控制正常加入流程,不是按用户认证。令牌只发给可信的人,并保护服务端的网络访问。
42
+ **安全:** 拿到共享 token 的人可以访问和管理所有房间,包括私聊。加入审核只控制正常加入流程,不是按用户认证。只把 token 给可信的人,并保护服务端的网络访问。
43
43
 
44
44
  ### Docker
45
45
 
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:latest
49
+ ghcr.io/agentsyaml/opencode-chat-room:v0.8.3
50
50
  ```
51
51
 
52
- 用 `ghcr.io/agentsyaml/opencode-chat-room:v0.8.1` 固定版本。房间和文件保存在 `/data` 卷里,升级时不要删除。若改用宿主机目录绑定,目录需允许 uid `10001` 写入。
52
+ 房间和文件保存在 `/data` 卷里,升级时不要删除。宿主目录挂载必须允许 uid `10001` 写入。
53
53
 
54
- ### Docker Compose
54
+ Docker Compose、PostgreSQL 状态、S3 兼容存储和全部环境变量见[部署参考](docs/reference.zh-CN.md#环境变量)。
55
55
 
56
- 仓库里的 `docker-compose.yaml` 默认只运行主应用,PostgreSQL 和 RustFS 通过可选 profile 启动。先复制 `.env.example` 为 `.env` 并设置 `CHAT_ROOM_SERVER_TOKEN`;缺少该令牌时 Compose 会拒绝启动,避免暴露未认证服务。然后:
57
-
58
- ```bash
59
- docker compose up -d --build
60
- docker compose --profile postgres up -d # 可选 PostgreSQL 状态
61
- docker compose --profile rustfs up -d # 可选 S3 兼容存储
62
- ```
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`。
65
-
66
- ### S3 文件存储
67
-
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
-
70
- ### PostgreSQL 状态(实验性,单实例)
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 兼容资源存储已稳定,与数据库选择无关。
73
-
74
- 迁移前先停止服务端,并做一次 WAL 安全的 SQLite 备份:
75
-
76
- ```bash
77
- sqlite3 ~/.config/opencode/chat-room/chat-room.sqlite \
78
- ".backup '$HOME/chat-room.sqlite.backup'"
79
- CHAT_ROOM_DATABASE_URL=postgresql://user:password@host:5432/chatroom \
80
- npx --yes --package=@alexsun-top/opencode-chat-room@0.8.1 -- \
81
- opencode-chat-room migrate --to-postgres --yes
82
- ```
83
-
84
- 该命令按外键顺序复制全部状态表,保留 ID 和消息 `seq`,推进 PostgreSQL 序列,校验行数,并拒绝非空目标库。回滚只需切换环境变量:取消 `CHAT_ROOM_DATABASE_URL`,再用未改动的 SQLite 文件启动旧服务端。PostgreSQL 期间写入的消息不会回写到 SQLite。
85
-
86
- ## Channel D(飞书出站)
87
-
88
- Channel D 是可选的转发侧车,不是另一套聊天。它把选定的房间消息转发到外部目标。本版包含飞书出站 adapter 和用于测试的 mock adapter;只在中心模式用配置路径启用:
89
-
90
- ```json
91
- {
92
- "server": {
93
- "channeld": {
94
- "config": "/etc/chatroom/channeld.yml"
95
- }
96
- }
97
- }
98
- ```
56
+ ## 可以做什么
99
57
 
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`。
58
+ - **房间和人:** 创建或加入房间、邀请设备、审核加入、管理成员和所有者、打开私聊。
59
+ - **消息:** 回复、标记问题、带原文撤回、提及某个人或 `@all`。
60
+ - **文件:** 添加、拖入或粘贴最大 500 MiB 的文件;预览图片、媒体、Markdown、文本、代码、PDF、Word、Excel 和 PowerPoint;全屏查看预览;下载或删除。
61
+ - **任务和提醒:** 在侧栏或弹窗里跟踪任务;设置一次性或 cron 提醒。
62
+ - **搜索和快捷键:** Alt+Space 或 Ctrl+P 搜索消息,`/` 过滤命令;更多快捷键在设置里。
63
+ - **终端:** 运行 `bunx --package @alexsun-top/opencode-chat-room@0.8.3 opencode-chat-room cli` 连接同一个服务端。只有 CLI 会加载 OpenTUI。
64
+ - **网页应用:** 可安装到手机主屏,离线时从缓存启动;聊天数据不会缓存。
101
65
 
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 消息写成一条幂等的房间通知;入站事件不会匹配出站规则。
66
+ ## 可选服务
103
67
 
104
- ## 可以做什么
68
+ Channel D 是可选的转发侧车,把选定的房间消息发到外部平台。它不内置任何 adapter:从 GitHub Release 下载 adapter,在“设置 → 平台集成”上传,再添加账号和规则。转发是显式操作(`GET /rooms/:id/forward-targets`、`POST /rooms/:id/forward`),普通消息不会自动转发。见 [Channel D 参考](docs/reference.zh-CN.md)。
105
69
 
106
- - **房间与人:** 创建或加入房间,连接多台设备,审核加入,管理成员和房主,打开私聊。
107
- - **消息:** 回复、标记提问、撤回并保留可恢复的原文、点名成员或 `@all`。
108
- - **文件:** 附件、拖拽或粘贴,单文件默认上限 500 MiB;预览图片、媒体、Markdown、文本、代码、PDF、Word(.docx)、Excel(.xlsx)和 PowerPoint(.pptx);文档预览可全屏;支持下载和删除。
109
- - **任务:** 在侧栏或弹窗里跟踪标题、负责人、截止日期、参与人、步骤、结论和 todo/doing/done 状态。每个房间默认最多 10 个任务;设置 `CHAT_ROOM_MAX_ROOM_TASKS` 为正整数可调整上限,房间已满时先删除一个已完成的任务再添加。
110
- - **提醒:** 一次性或 cron 提醒;文本支持 `{{time}}`、`{{initiator}}` 和 `{{room}}`。
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。
113
- - **代码:** 围栏代码块由懒加载的 Shiki bundle 高亮,带换行和复制控件。
114
- - **Web App:** 界面可安装到手机主屏,离线时从缓存启动;聊天数据不会缓存。
70
+ S3 兼容存储和 PostgreSQL 状态通过环境变量配置。PostgreSQL 支持多个服务端实例;Channel D 保持自己的单实例状态。两者都写在[技术参考](docs/reference.zh-CN.md)里。
115
71
 
116
72
  ## 更多帮助
117
73
 
118
- - [配置、管理员功能与 API 参考](docs/reference.zh-CN.md)
74
+ - [配置、管理员功能和 API 参考](docs/reference.zh-CN.md)
119
75
  - [更新日志](CHANGELOG.md)
120
- - 在房间里问 Agent;内置的 `chatroom` skill 说明了完整的房间工作流。
76
+ - 在房间里问 agent;内置的 `chatroom` skill 说明了完整的房间工作流。
121
77
 
122
78
  ## 许可证
123
79