@alexsun-top/opencode-chat-room 0.8.2 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +18 -62
- package/README.zh-CN.md +25 -69
- package/dist/cli.js +466 -188
- package/package.json +11 -5
- package/packages/chat-room-channeld/README.md +25 -3
- package/packages/chat-room-channeld/dist/mock-adapter.js +5 -5
- package/packages/chat-room-channeld/src/adapter.ts +5 -0
- package/packages/chat-room-channeld/src/cli.ts +72 -5
- package/packages/chat-room-channeld/src/host.ts +17 -2
- package/packages/chat-room-channeld/src/pg/database.ts +187 -0
- package/packages/chat-room-channeld/src/pg/migrate.ts +150 -0
- package/packages/chat-room-channeld/src/pg/schema.ts +60 -0
- package/packages/chat-room-channeld/src/pg/sql.mjs +175 -0
- package/packages/chat-room-channeld/src/pg/sqlite.ts +100 -0
- package/packages/chat-room-channeld/src/pg/worker.mjs +133 -0
- package/packages/chat-room-channeld/src/protocol.ts +1 -0
- package/packages/chat-room-channeld/src/state.ts +73 -97
- package/packages/chat-room-channeld/src/stats.ts +140 -109
- package/server/assets/base.css +3 -1
- package/server/assets/chat/admin-badge.js +32 -30
- package/server/assets/chat/admin.js +201 -161
- package/server/assets/chat/announcements.js +302 -208
- package/server/assets/chat/attachment-store.js +116 -76
- package/server/assets/chat/attachments.js +701 -441
- package/server/assets/chat/chat-background.js +179 -156
- package/server/assets/chat/clipboard.js +45 -25
- package/server/assets/chat/confirm-dialog.js +38 -35
- package/server/assets/chat/copy-action.js +40 -41
- package/server/assets/chat/create-room-dialog.js +50 -47
- package/server/assets/chat/diagram-viewer.js +293 -236
- package/server/assets/chat/doc-preview.js +516 -443
- package/server/assets/chat/editor.js +446 -336
- package/server/assets/chat/events.js +650 -510
- package/server/assets/chat/files.js +505 -431
- package/server/assets/chat/history-loader.js +81 -73
- package/server/assets/chat/icons.js +9 -11
- package/server/assets/chat/image-zoom.js +246 -179
- package/server/assets/chat/index.js +2 -3
- package/server/assets/chat/install-prompt.js +90 -69
- package/server/assets/chat/integration-account-schema.js +91 -87
- package/server/assets/chat/integration-editor.js +162 -155
- package/server/assets/chat/integration-values.js +116 -101
- package/server/assets/chat/integrations.js +750 -626
- package/server/assets/chat/join-requests.js +415 -358
- package/server/assets/chat/locales/de.js +193 -194
- package/server/assets/chat/locales/es.js +193 -194
- package/server/assets/chat/locales/fr.js +193 -194
- package/server/assets/chat/locales/index.js +1 -2
- package/server/assets/chat/locales/it.js +193 -194
- package/server/assets/chat/locales/ja.js +193 -193
- package/server/assets/chat/locales/ko.js +193 -193
- package/server/assets/chat/markdown-footnotes.js +134 -103
- package/server/assets/chat/markdown.js +557 -404
- package/server/assets/chat/members.js +259 -197
- package/server/assets/chat/mentions.js +181 -133
- package/server/assets/chat/message-cache.js +40 -33
- package/server/assets/chat/message-polling.js +299 -227
- package/server/assets/chat/message-window.js +78 -55
- package/server/assets/chat/messages.js +562 -480
- package/server/assets/chat/office-preview.js +46 -45
- package/server/assets/chat/palette.js +464 -417
- package/server/assets/chat/panels.js +94 -79
- package/server/assets/chat/pwa.js +147 -75
- package/server/assets/chat/questions.js +374 -302
- package/server/assets/chat/recall.js +338 -273
- package/server/assets/chat/receipts.js +151 -121
- package/server/assets/chat/reminders.js +345 -214
- package/server/assets/chat/replies.js +181 -130
- package/server/assets/chat/resource-format.js +59 -62
- package/server/assets/chat/room-list.js +58 -55
- package/server/assets/chat/room-watcher.js +76 -50
- package/server/assets/chat/rooms.js +631 -500
- package/server/assets/chat/search.js +138 -114
- package/server/assets/chat/settings.js +225 -201
- package/server/assets/chat/shiki.js +62 -63
- package/server/assets/chat/shortcuts.js +212 -189
- package/server/assets/chat/side-pane.js +161 -150
- package/server/assets/chat/state.js +860 -737
- package/server/assets/chat/system-events.js +46 -44
- package/server/assets/chat/system-messages.js +57 -56
- package/server/assets/chat/task-form.js +179 -183
- package/server/assets/chat/task-row.js +158 -155
- package/server/assets/chat/tasks.js +665 -587
- package/server/assets/chat/viewport.js +32 -29
- package/server/assets/chat/window-controls.js +32 -32
- package/server/assets/conversation.css +10 -4
- package/server/chat-server.ts +9 -1
- package/server/chat.html +3 -1
- package/server/routes/pages.ts +7 -5
- package/server/sw.js +346 -268
- package/src/web/integration-rules-editor.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
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. All 67 sources now pass strict TypeScript checks with no `any`, `@ts-nocheck`, or other suppressions; the published package and image still contain only generated JavaScript, and two builds are byte-for-byte reproducible.
|
|
6
|
+
- When the app opens offline without a restored session, the cached shell now shows a Settings button next to Retry, so local appearance, language, and connection settings stay reachable without the server. Room data still requires a connection.
|
|
7
|
+
- Serve the PWA shell and static assets from the service worker cache first, so opening the app no longer re-downloads every precached file from the server. Install reports downloading, ready with the number of optional cache gaps, or failed; a missing shell or chat entry module fails the install, while a missing optional asset becomes a runtime miss. The update prompt appears only for a waiting worker and never reloads on its own.
|
|
8
|
+
- 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.
|
|
9
|
+
- 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.
|
|
10
|
+
- 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.
|
|
11
|
+
- Add seven standalone channel adapters covering ten platforms. Unit 1: Feishu (real-account verified, inbound and outbound, text/images/files). Unit 2: Telegram (protocol-tested, inbound and outbound text/images/files). Unit 3: Matrix (`/sync` inbound and text outbound). Unit 4: Slack (history polling inbound and text outbound). Unit 5: Discord (message polling inbound and text outbound, 2000-character chunking). Unit 6: Email (SMTP outbound with attachments; plaintext SMTP is refused unless `EMAIL_SMTP_ALLOW_PLAINTEXT=1` is set for a trusted relay). Unit 7: one webhook adapter for Microsoft Teams, Google Chat, WeCom, and DingTalk (outbound text, platform selected by account `platform`). Except for Feishu, protocol tests use local fake servers only; real credentials and production platform behavior are not exercised by the repository tests. The service still ships no built-in adapter; download the files from the GitHub Release and upload them in Platform integrations.
|
|
12
|
+
- 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.
|
|
13
|
+
- 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.
|
|
14
|
+
- 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`.
|
|
15
|
+
- 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.
|
|
16
|
+
|
|
5
17
|
- 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
18
|
- Never prompt for an access key on an unauthenticated instance; the key dialog opens only after a request is actually rejected with 401.
|
|
7
19
|
- 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.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OC Chat
|
|
2
2
|
|
|
3
|
-
Chat in shared rooms with OpenCode agents and people.
|
|
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>`.
|
|
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.
|
|
29
|
+
npx --yes --package=@alexsun-top/opencode-chat-room@0.8.4 -- 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.
|
|
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:
|
|
49
|
+
ghcr.io/agentsyaml/opencode-chat-room:v0.8.4
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
Rooms and files live in the `/data` volume; keep it across upgrades. A host bind mount must be writable by uid `10001`.
|
|
53
53
|
|
|
54
|
-
|
|
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.2`; `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, multi-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 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
|
-
|
|
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.2 -- \
|
|
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. 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
|
-
|
|
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-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 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.
|
|
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
|
|
109
|
-
- **Tasks:** track
|
|
110
|
-
- **
|
|
111
|
-
- **
|
|
112
|
-
- **
|
|
113
|
-
|
|
114
|
-
|
|
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.4 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. The release covers ten platforms — Feishu, Telegram, Matrix, Slack, Discord, Email, Microsoft Teams, Google Chat, WeCom, and DingTalk; the last four share one webhook adapter. Feishu is verified against a real account, while the others are protocol-tested until real credentials are supplied. 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
|
|
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
|
-
|
|
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,让
|
|
20
|
+
重启 OpenCode,让 agent 创建房间,或者输入 `/room create dev`。
|
|
21
21
|
|
|
22
|
-
升级时先退出 OpenCode
|
|
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.
|
|
29
|
+
npx --yes --package=@alexsun-top/opencode-chat-room@0.8.4 -- 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
|
|
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
|
|
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:
|
|
49
|
+
ghcr.io/agentsyaml/opencode-chat-room:v0.8.4
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
房间和文件保存在 `/data` 卷里,升级时不要删除。宿主目录挂载必须允许 uid `10001` 写入。
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
Docker Compose、PostgreSQL 状态、S3 兼容存储和全部环境变量见[部署参考](docs/reference.zh-CN.md#环境变量)。
|
|
55
55
|
|
|
56
|
-
|
|
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.2` 固定镜像;`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.2 多实例里程碑完成前仍属实验功能。多个服务端进程可以共用同一个数据库:每个写事务获取事务级 advisory lock,并且只写入发生变化的行,因此实例之间不再互相拒绝,也不会覆盖无关的房间、成员、消息和 registry 条目。唤醒投递和待处理准入是主机亲和的:只有会话登记的那台主机负责唤醒,每个主机只应运行一个 watcher;这个里程碑不把 watcher 做成多活。只应在服务端设置该变量;客户端、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.2 -- \
|
|
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 是顶层 `plugins/` 目录下的单文件:飞书 adapter 为 `plugins/feishu/dist/feishu-adapter.ts`,由带类型的源码拼接生成、不经过打包器,因此文件里保留真实 TypeScript 类型;它作为 GitHub Release 资产发布,不随本包分发,由 Node 直接运行。带类型源码在 `plugins/feishu/src`;核心只带用于测试的 mock adapter,并通过账号的 `adapter.command` 启动任意 adapter。只在中心模式用配置路径启用:
|
|
89
|
-
|
|
90
|
-
```json
|
|
91
|
-
{
|
|
92
|
-
"server": {
|
|
93
|
-
"channeld": {
|
|
94
|
-
"config": "/etc/chatroom/channeld.yml"
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
```
|
|
56
|
+
## 可以做什么
|
|
99
57
|
|
|
100
|
-
|
|
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.4 opencode-chat-room cli` 连接同一个服务端。只有 CLI 会加载 OpenTUI。
|
|
64
|
+
- **网页应用:** 可安装到手机主屏,离线时从缓存启动;聊天数据不会缓存。
|
|
101
65
|
|
|
102
|
-
|
|
66
|
+
## 可选服务
|
|
103
67
|
|
|
104
|
-
|
|
68
|
+
Channel D 是可选的转发侧车,把选定的房间消息发到外部平台。它不内置任何 adapter:从 GitHub Release 下载 adapter,在“设置 → 平台集成”上传,再添加账号和规则。Release 覆盖十个平台——飞书、Telegram、Matrix、Slack、Discord、Email、Microsoft Teams、Google Chat、WeCom 和钉钉;后四个共用一份 webhook 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.2 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
|
-
- [
|
|
74
|
+
- [配置、管理员功能和 API 参考](docs/reference.zh-CN.md)
|
|
119
75
|
- [更新日志](CHANGELOG.md)
|
|
120
|
-
- 在房间里问
|
|
76
|
+
- 在房间里问 agent;内置的 `chatroom` skill 说明了完整的房间工作流。
|
|
121
77
|
|
|
122
78
|
## 许可证
|
|
123
79
|
|