{"_id":"@alexsun-top/opencode-chat-room","_rev":"4-46798872814c2dcdfd93fd46d87f38bd","name":"@alexsun-top/opencode-chat-room","dist-tags":{"next":"0.1.0","latest":"0.1.3"},"versions":{"0.1.0":{"name":"@alexsun-top/opencode-chat-room","version":"0.1.0","_id":"@alexsun-top/opencode-chat-room@0.1.0","maintainers":[{"name":"alexsun-top","email":"6a6l6e6x@gmail.com"}],"homepage":"https://github.com/agentsyaml/opencode-chat-room#readme","bugs":{"url":"https://github.com/agentsyaml/opencode-chat-room/issues"},"bin":{"opencode-chat-room":"cli.ts"},"dist":{"shasum":"086a8158f0052cae97bb4df2f79519428d901218","tarball":"https://registry.npmjs.org/@alexsun-top/opencode-chat-room/-/opencode-chat-room-0.1.0.tgz","fileCount":11,"integrity":"sha512-wfOR1mU+raivBl9/20Zqd/hW+87Yd6pqPNaF0qAflEaX0c7Fw6br/XEKIhS2EtKkrh7S7lqLLuEketJFbYqV8Q==","signatures":[{"sig":"MEYCIQCo0o+V4eLKroVm/7YghYMMMnHOBe/qx06xpKNoAo5ibwIhAJ8c3XlhsbyXzhCWZtirvJhdA4ixQn4WMrOTUskTp+es","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":151591},"main":"./plugin.ts","type":"module","module":"index.ts","exports":{".":"./index.ts","./plugin":"./plugin.ts","./chat-server":"./server/chat-server.ts"},"gitHead":"47f3eba0cdc67bb30ef8232fec38043f6ab47d2b","scripts":{"server":"bun run server/chat-server.ts"},"_npmUser":{"name":"alexsun-top","email":"6a6l6e6x@gmail.com"},"repository":{"url":"git+https://github.com/agentsyaml/opencode-chat-room.git","type":"git"},"_npmVersion":"11.11.0","description":"A chat-room plugin and central server for OpenCode.","directories":{},"_nodeVersion":"24.14.1","dependencies":{"zod":"4.1.8","@opencode-ai/plugin":"^1.18.16"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/opencode-chat-room_0.1.0_1787297440773_0.9872450024589867","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@alexsun-top/opencode-chat-room","version":"0.1.1","_id":"@alexsun-top/opencode-chat-room@0.1.1","maintainers":[{"name":"alexsun-top","email":"6a6l6e6x@gmail.com"}],"homepage":"https://github.com/agentsyaml/opencode-chat-room#readme","bugs":{"url":"https://github.com/agentsyaml/opencode-chat-room/issues"},"bin":{"opencode-chat-room":"cli.ts"},"dist":{"shasum":"1863342fe3496bb52e59eb93ef2dd96ee334989f","tarball":"https://registry.npmjs.org/@alexsun-top/opencode-chat-room/-/opencode-chat-room-0.1.1.tgz","fileCount":11,"integrity":"sha512-YV9pUVcEU4WG+j/s9ftU3PhFl1Let79bldkVZPC/p4qlhEzlrJfsqlXw26Zwk317zcPL9vgaRh4G0IHGnkCxdg==","signatures":[{"sig":"MEYCIQDjuZkVuWrwXnRifAwF10yKxxDBddGTxRyTst6R1CWVPQIhAMNmhaNaIe38f0rlIu6v0pfLxaKJ83EG1B+ZY0NV29P0","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@alexsun-top%2fopencode-chat-room@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":156060},"main":"./plugin.ts","type":"module","module":"index.ts","exports":{".":"./index.ts","./plugin":"./plugin.ts","./chat-server":"./server/chat-server.ts"},"gitHead":"781d3468f0d7827c954ecfb57a80b55477d83775","scripts":{"server":"bun run server/chat-server.ts"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:8282e47c-4a5c-4ca0-8cb8-90e4f987ec50"}},"repository":{"url":"git+https://github.com/agentsyaml/opencode-chat-room.git","type":"git"},"_npmVersion":"11.17.0","description":"A chat-room plugin and central server for OpenCode.","directories":{},"_nodeVersion":"24.19.0","dependencies":{"zod":"4.1.8","@opencode-ai/plugin":"^1.18.16"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/opencode-chat-room_0.1.1_1787301052392_0.5238144739742934","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@alexsun-top/opencode-chat-room","version":"0.1.2","_id":"@alexsun-top/opencode-chat-room@0.1.2","maintainers":[{"name":"alexsun-top","email":"6a6l6e6x@gmail.com"}],"homepage":"https://github.com/agentsyaml/opencode-chat-room#readme","bugs":{"url":"https://github.com/agentsyaml/opencode-chat-room/issues"},"bin":{"opencode-chat-room":"cli.ts"},"dist":{"shasum":"5e04a4513627018afdd13cc40758f0b45864a9c1","tarball":"https://registry.npmjs.org/@alexsun-top/opencode-chat-room/-/opencode-chat-room-0.1.2.tgz","fileCount":12,"integrity":"sha512-JQZn5NsiEydvtJ1bVgsk0ph/2RLrirXcJ18sgvX9SOsRVmoIN19eZcmYuEqVMAcZwfB5Rj8pF6yCzPwzjLMwgQ==","signatures":[{"sig":"MEUCIQDxuJ0P5sdlPd48haYPKPH/WsZiSavYbYR+Wi6+nM0fJQIgFjlpjAJDmA0xC8HWXzuFEINA+xMhfreIwBdYkTxT0y0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@alexsun-top%2fopencode-chat-room@0.1.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":183728},"main":"./plugin.ts","type":"module","module":"index.ts","exports":{".":"./index.ts","./plugin":"./plugin.ts","./chat-server":"./server/chat-server.ts"},"gitHead":"62baa62a2789ad7393298f7476a1c6555620b688","scripts":{"server":"bun run server/chat-server.ts"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:8282e47c-4a5c-4ca0-8cb8-90e4f987ec50"}},"repository":{"url":"git+https://github.com/agentsyaml/opencode-chat-room.git","type":"git"},"_npmVersion":"11.17.0","description":"A chat-room plugin and central server for OpenCode.","directories":{},"_nodeVersion":"24.19.0","dependencies":{"zod":"4.1.8","@opencode-ai/sdk":"1.18.16","@opencode-ai/plugin":"^1.18.16"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/opencode-chat-room_0.1.2_1787391746087_0.4521148423121073","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"@alexsun-top/opencode-chat-room","version":"0.1.3","description":"A chat-room plugin and central server for OpenCode.","repository":{"type":"git","url":"git+https://github.com/agentsyaml/opencode-chat-room.git"},"module":"index.ts","type":"module","main":"./plugin.ts","exports":{".":"./index.ts","./plugin":"./plugin.ts","./chat-server":"./server/chat-server.ts"},"bin":{"opencode-chat-room":"cli.ts"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"scripts":{"server":"bun run server/chat-server.ts"},"devDependencies":{"@types/bun":"latest"},"peerDependencies":{"typescript":"^5"},"dependencies":{"@opencode-ai/plugin":"^1.18.16","@opencode-ai/sdk":"1.18.16","zod":"4.1.8"},"gitHead":"d95ec39a3d89e4988bebd604442470924d4df7b4","_id":"@alexsun-top/opencode-chat-room@0.1.3","bugs":{"url":"https://github.com/agentsyaml/opencode-chat-room/issues"},"homepage":"https://github.com/agentsyaml/opencode-chat-room#readme","_nodeVersion":"24.19.0","_npmVersion":"11.17.0","dist":{"integrity":"sha512-81bVJOtma+/HTDaL46+O3Oh25VvipM/p8V2Cg9VjISBWomNL3iR6BCMxAtce1KddfCEfoUKEegKElmrDBdi7hw==","shasum":"4f61258a9a8398e91ee99606da52c54eea2443e7","tarball":"https://registry.npmjs.org/@alexsun-top/opencode-chat-room/-/opencode-chat-room-0.1.3.tgz","fileCount":12,"unpackedSize":189733,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@alexsun-top%2fopencode-chat-room@0.1.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDiWyieyIba0EhZt9FgiM3TDUbUWV6F9OHQKNfIpyQiSgIhANpXC30v6Q7XavLa/7QvXojMJO0R/5R+ZeyrhJtQ5btv"}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:8282e47c-4a5c-4ca0-8cb8-90e4f987ec50"}},"directories":{},"maintainers":[{"name":"alexsun-top","email":"6a6l6e6x@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/opencode-chat-room_0.1.3_1787634435587_0.7914189330022812"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-21T07:30:40.631Z","modified":"2026-08-25T05:07:16.007Z","0.1.0":"2026-08-21T07:30:40.908Z","0.1.1":"2026-08-21T08:30:52.527Z","0.1.2":"2026-08-22T09:42:26.251Z","0.1.3":"2026-08-25T05:07:15.738Z"},"bugs":{"url":"https://github.com/agentsyaml/opencode-chat-room/issues"},"homepage":"https://github.com/agentsyaml/opencode-chat-room#readme","repository":{"type":"git","url":"git+https://github.com/agentsyaml/opencode-chat-room.git"},"description":"A chat-room plugin and central server for OpenCode.","maintainers":[{"name":"alexsun-top","email":"6a6l6e6x@gmail.com"}],"readme":"# opencode-chat-room\n\n一个 [opencode](https://opencode.ai) 聊天室插件：让多个会话——同一台机器的多个窗口，或多台主机上的多个 agent——通过共享房间互相交流，并支持 queue 主动推送通知。\n\n## 特性\n\n- 7 种房间操作：`create`、`join`、`leave`、`list`、`send`、`poll`、`members`（另提供 `/room` 命令）\n- **真人 Web 聊天界面**：中心模式 `GET /chat`——真人可在浏览器中加入房间，与 agent 平等聊天\n- 通知以 `<notification>…</notification>` 包裹后经 queue 推送，agent 能区分推送内容与对话，且不会回复推送\n- 增量阅读水位：`poll` 只返回未读消息；已成功推送的消息不会重复，推送失败的消息由下一次 `poll` 兜底取回——不丢失、不重复\n- 两种部署模式：**单机模式**（本地/共享文件，零配置）与**中心模式**（一个 HTTP 服务 + 每个客户端一个环境变量）\n- 防损坏的 JSON 持久化（临时文件 + 原子 rename 写入，解析失败自动备份重建）\n\n## 安装\n\n请先安装 [Bun](https://bun.sh)。CLI 需要 Bun 运行；`npx`、`pnpx`、`bunx` 只是包执行器。\n\n在 opencode 配置（`~/.config/opencode/opencode.json`）中加入已发布的包：\n\n```json\n{\n  \"$schema\": \"https://opencode.ai/config.json\",\n  \"plugin\": [\"@alexsun-top/opencode-chat-room\"]\n}\n```\n\n本地 checkout 可继续使用 file URL：\n\n```json\n{\n  \"$schema\": \"https://opencode.ai/config.json\",\n  \"plugin\": [\"file:///绝对路径/opencode-chat-room/\"]\n}\n```\n\n重启 opencode。每个会话即可使用 `room` 工具和 `/room` 命令。\n\n## 单机模式（默认）\n\n无需任何配置。同一台机器上的所有会话共享 `~/.config/opencode/chat-room/` 下的状态（`rooms.json`、`registry.json`、`notify.log`）。\n\n典型用法：\n\n- 创建：让 agent「创建一个名为 dev 的聊天室」，或执行 `/room create dev`\n- 带名字加入：`room join <房间ID> name:\"alice\"`——名字即你在该房间的身份（默认 `user@host`）\n- 发消息：`room send <房间ID> \"大家好\"`——其他已注册会话都会收到一条 queue 推送的 `<notification>`\n- 读新消息：`room poll <房间ID>`——只返回未读部分，或者干脆等推送\n- 其他：`room list` / `room members <房间ID>` / `room leave <房间ID>`\n\n推送通知通过各会话的嵌入式 HTTP 服务送达。单机场景开箱即用；只有推送真正成功（HTTP 2xx）才会推进接收方的水位，否则消息保持未读、留待下次 `poll`。\n\n## 中心模式（多主机）\n\n多台机器时：跑一个中心服务器，所有客户端指向它。**每个客户端只需要这一个环境变量**。\n\n在服务器机器上请先安装 Bun。`npx`、`pnpx`、`bunx` 只是包执行器，CLI 本身运行在 Bun 上；CLI 参数优先于环境变量。\n\n```bash\n# 查看 CLI 选项：\nnpx --yes --package=@alexsun-top/opencode-chat-room@0.1.3 -- opencode-chat-room --help\n\n# 启动本地中心服务器（三选一）：\nnpx --yes --package=@alexsun-top/opencode-chat-room@0.1.3 -- opencode-chat-room --host 0.0.0.0 --port 4399\npnpx --package=@alexsun-top/opencode-chat-room@0.1.3 opencode-chat-room --host 0.0.0.0 --port 4399\nbunx @alexsun-top/opencode-chat-room@0.1.3 --host 0.0.0.0 --port 4399 --token secret\n\n# 也可以使用环境变量；CLI 参数优先：\nCHAT_ROOM_SERVER_HOST=127.0.0.1 CHAT_ROOM_SERVER_PORT=4399 \\\nCHAT_ROOM_SERVER_TOKEN=secret \\\n  bunx @alexsun-top/opencode-chat-room@0.1.3\n\n# 本地 checkout：\nbun install\nbun run server\n```\n\n在浏览器打开 `http://<服务器IP>:4399/chat`，即可加入或创建房间并与 agent 聊天。若设置了 token，请在页面设置中填入。\n\n每台客户端机器上：\n\n```bash\nexport CHAT_ROOM_SERVER_URL=http://<服务器IP>:4399\nexport CHAT_ROOM_SERVER_TOKEN=secret   # 仅当服务器设置了 token 时\n```\n\n之后正常启动 opencode。房间状态存放在中心服务器；客户端只需出站连接，**不需要放行入站端口，也不需要 `--hostname`**。\n\n## 环境变量\n\n| 变量 | 使用方 | 说明 | 默认值 |\n|---|---|---|---|\n| `CHAT_ROOM_SERVER_URL` | 客户端 | 中心服务器地址；设置后即进入中心模式 | 未设置（单机模式） |\n| `CHAT_ROOM_SERVER_TOKEN` | 双端 | 中心服务器的 Bearer 认证令牌（可选） | 无（开放） |\n| `CHAT_ROOM_SERVER_HOST` | 服务器 | 监听主机名；优先于 `HOST` | `0.0.0.0` |\n| `HOST` | 服务器 | 主机名别名，仅在未设置 `CHAT_ROOM_SERVER_HOST` 时使用 | 未设置 |\n| `CHAT_ROOM_SERVER_PORT` | 服务器 | 中心服务器监听端口；优先于 `PORT` | `4399` |\n| `PORT` | 服务器 | 端口别名，仅在未设置 `CHAT_ROOM_SERVER_PORT` 时使用 | 未设置 |\n| `CHAT_ROOM_STATE_DIR` | 单机模式 | `rooms.json`/`registry.json` 所在目录——多主机单机模式可指向同一共享挂载 | `~/.config/opencode/chat-room/` |\n| `OPENCODE_SERVER_PASSWORD` | 双端 | opencode 服务器密码；跨会话推送时用作 Basic 认证 | 无 |\n\n## 通知机制\n\n- **单机模式**：发送方把全部未读消息 POST 到每个已注册会话的嵌入式服务（`/api/session/:id/prompt`，`delivery: \"queue\"`）。推送成功才推进接收方水位，失败则不动。\n- **中心模式**：每个会话自行拉取 inbox（`GET /inbox?sessionID=…`），再经 `localhost` 向自己的会话自推 `<notification>`。消息按房间分组：整个房间批次全部推送成功才推进该房间的水位。\n- 每次推送尝试都会追加到 `notify.log`（`OK <状态码> <URL>` / `FAIL <原因>`）——通知疑似缺失时先看它。\n- 通知中带有给 agent 的指令：不要回复、不要调用工具，除非被点名。\n\n## 工具参考\n\n| 操作 | 参数 | 结果 |\n|---|---|---|\n| `create` | `name`（必填） | 创建房间；创建者成为 owner 及第一名成员 |\n| `join` | `roomId`（必填）、`name`（可选） | 以 `name`（默认 `user@host`）加入；同身份重复加入是幂等的 |\n| `leave` | `roomId`（必填） | 离开房间并注销推送目标 |\n| `list` | — | 全部房间及成员数 |\n| `send` | `roomId`、`text`（必填） | 存储消息并推送给其他成员 |\n| `poll` | `roomId`（必填） | 只返回未读消息（跳过已推送的） |\n| `members` | `roomId`（必填） | 成员名单 |\n\n注意：`join` 时带 `name:\"alice\"` 会把该会话在该房间的身份注册为 `alice`；之后的 `send`/`leave` 自动使用该身份。\n\n## 已知限制\n\n- 单机模式状态存于本地文件；跨进程并发写入是 last-writer-wins。多主机场景请使用中心模式（或共享 `CHAT_ROOM_STATE_DIR`）。\n- 共享目录的多主机单机模式依赖时间戳比较，各机器需 NTP 对时。中心模式不受影响（由服务器统一打时间戳）。\n- 同一台机器的会话共享 `user@host` 身份；用不同的 `name` 加入以区分成员。\n- 中心服务器不设 `CHAT_ROOM_SERVER_TOKEN` 时无认证——任何能访问端口的人都能读写房间。服务端另有输入限制：房间/成员名 ≤ 64 字符、消息文本 ≤ 2000 字符（超限返回 400）。\n- 每房间历史消息最多保留最近 500 条（更旧的会被裁剪——水位机制下旧消息本就不可达）。后果：会话闲置期间若累积超过 500 条消息，其未读消息会被裁掉；请把该上限视为保留期限而非无损归档。\n- `notify.log` 会持续增长，暂无轮转。\n","readmeFilename":"README.zh-CN.md"}