Bundle
dsh-live-room
dsh 插件:把会话变成免鉴权、只读、可分享的实时直播间(SSE 观看页 + 弹幕)
- Source
- Britneycode
- License
- BSD-3-Clause
- Updated
- Updated 5 days ago
Readme
# dsh-live-room · 会话直播间
dsh(DeepSeek Harness)插件:把任意会话变成**免登录、只读、可分享的实时观看页**。观众在浏览器里实时围观 agent 干活(打字机式 token 流、工具调用状态、思考过程),可发轻量弹幕;主播端一键开播/停播,也支持让 agent 自己开播。

## 功能
- **设置页「直播间」面板**:选择会话开播(可自定义标题与 TTL),房间卡片展示观众数、缓冲条数、过期时间,一键复制本机/局域网观看链接,随时停播
- **观看页**:自包含单文件页面(无外部依赖),SSE 实时推送 + 全量快照(断线自动重连),token 打字机、思考流(暗色折叠样式)、工具调用行(运行中/完成/出错)、轮次分隔;弹幕飞屏 + 快捷表情
- **agent 工具三件套**:`start_live_room` / `stop_live_room` / `list_live_rooms`,会话里一句"帮我把这个任务直播给同事看"即可
- **归一化协议**:宿主 ~50 种会话事件 + 持久层 chunk-run 打包行统一归一为 6 种观看帧,未知事件降级为提示行,永不崩页
## 安装
```bash
dsh plugin --profile web add dsh-live-room
```
或从源码:`pnpm build` 后 `dsh plugin --profile web add <本目录路径>`。
## 安全模型(必读)
- **观看链接免登录、凭链接即看**:任何拿到链接的人(同一局域网)都能实时看到该会话的完整内容,请只发给可信观众
- 房间密钥为 24 字节随机值(SHA-256 + `timingSafeEqual` 校验),停播/过期立即失效
- 观看页**构造上只读**:不含任何会话写路径;弹幕仅在观看层广播,不会进入会话
- 观看服务**首房自动启动、末房自动停**,最小暴露窗口;绑定了独立端口(默认 `0.0.0.0:33210`),可在插件配置里把 host 改为 `127.0.0.1` 收紧到本机
- 直播间为内存态:dsh 重启后自动清空;Windows 首次监听会弹防火墙授权
## 配置项
| 键 | 默认 | 说明 |
|---|---|---|
| `port` | 33210 | 观看服务端口 |
| `host` | 0.0.0.0 | 监听地址(改 127.0.0.1 仅本机可看) |
| `maxFrames` | 2000 | 每房间环形缓冲上限(按事件数) |
| `snapshotMaxEvents` | 500 | 建房时回填持久化历史的末尾事件数 |
| `defaultTtlHours` | 8 | 房间默认存活时长 |
| `allowReactions` | true | 是否开放弹幕 |
| `reactionCooldownMs` | 2000 | 同 IP 两条弹幕最小间隔 |
## 架构
```
宿主进程内 dsh-live-room
├─ ctx.on('session/event', …, { global: true }) ← 数据源(post-commit 免轮询)
│ └─ RoomManager(环形缓冲 · seq 去重 · callId→工具名补全 · TTL)
├─ 独立观看服务 node:http(SSE:hello → snapshot → live/viewers/chat/ended)
├─ 管理 API /live-room/api(宿主主服务同源前缀,POST 双重防御)
├─ 设置页面板(settings.section 槽位 · order 62 · React 壳 + 原生 DOM)
└─ agent 工具三件套
```
## 开发
```bash
DSH_CHECKOUT=<dsh checkout 路径> npm run typecheck
DSH_CHECKOUT=<dsh checkout 路径> npm test
DSH_CHECKOUT=<dsh checkout 路径> npm run build
node scripts/verify-live-room.mjs --base http://127.0.0.1:3080 --token <启动 token>
```
## License
BSD-3-Clause
Install
dsh plugin --profile web add github:Britneycode/dsh-live-room
Profile: web
With the hub plugin installed, ask your agent to install it by name — it resolves the same plan shown here.
dsh plugin --profile web add github:stvlynn/dsh.fish#path:packages/dsh-plugin-hub
install dsh-live-room from the hub
- This package builds from source on install. pnpm will ask you to allow its build script — that is permission to run the package’s code on your machine, outside the agent sandbox. Only allow sources you trust.
- This source has no pinned commit, so a later push upstream changes what installs. Prefer pinning a commit.