dsh-quay-bot 1.0.2 → 1.0.6
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/README.md +28 -105
- package/botscreen/requirements.txt +1 -1
- package/client.js +123 -53
- package/cordis.patch.yml +1 -1
- package/host/api.js +4 -0
- package/host/remote.js +285 -8
- package/host/screen.js +22 -86
- package/package.json +34 -32
- package/remote/bin/dsh-remote.mjs +435 -0
- package/remote/package.json +27 -0
- package/remote/src/config.mjs +183 -0
- package/remote/src/crypto.mjs +220 -0
- package/remote/src/keys.mjs +226 -0
- package/remote/src/proxy.mjs +1028 -0
- package/remote/src/sessions.mjs +163 -0
- package/remote/src/shim.js +838 -0
- package/remote/src/supervisor.mjs +207 -0
- package/remote/src/tunnel.mjs +533 -0
- package/remote/src/upstream.mjs +403 -0
- package/remote/src/util.mjs +149 -0
- package/remote/src/ws.mjs +313 -0
- package/LICENSE +0 -21
- package/avatar/build.mjs +0 -81
- package/avatar/gallery/droid.json +0 -14
- package/avatar/gallery/ghost.json +0 -14
- package/avatar/gallery/grok-pod.json +0 -14
- package/avatar/gallery/guardian.json +0 -14
- package/avatar/gallery/mecha.json +0 -14
- package/avatar/gallery/mochi.json +0 -14
- package/avatar/gallery/neko.json +0 -14
- package/avatar/gallery/orbiter.json +0 -14
- package/avatar/gallery/relay.json +0 -14
- package/avatar/gallery/spark.json +0 -14
- package/avatar/src/bot/clay.ts +0 -135
- package/avatar/src/bot/effects.ts +0 -100
- package/avatar/src/bot/grok-bot.ts +0 -626
- package/avatar/src/bot/index.ts +0 -15
- package/avatar/src/bot/palettes.ts +0 -62
- package/avatar/src/bot/ring.ts +0 -219
- package/avatar/src/bot/scheduler.ts +0 -239
- package/avatar/src/bot/shapes.ts +0 -277
- package/avatar/src/bot/spring.ts +0 -196
- package/avatar/src/core/color.ts +0 -92
- package/avatar/src/core/eyes.ts +0 -297
- package/avatar/src/core/field.ts +0 -482
- package/avatar/src/core/frame.ts +0 -655
- package/avatar/src/core/fx.ts +0 -375
- package/avatar/src/core/index.ts +0 -49
- package/avatar/src/core/paint.ts +0 -331
- package/avatar/src/core/path.ts +0 -495
- package/avatar/src/core/pose.ts +0 -581
- package/avatar/src/core/svg.ts +0 -98
- package/avatar/src/core/types.ts +0 -153
- package/avatar/src/core/validate.ts +0 -296
- package/avatar/src/core/volume.ts +0 -681
- package/avatar/src/entry.ts +0 -260
- package/bin/doctor.mjs +0 -148
- package/botscreen/requirements-offline.txt +0 -11
- package/market/index.json +0 -41
- package/vendor/pip/pip-25.1.1-py3-none-any.whl +0 -0
- package/vendor/pip/setuptools-78.1.1-py3-none-any.whl +0 -0
package/README.md
CHANGED
|
@@ -1,114 +1,37 @@
|
|
|
1
|
-
# dsh-
|
|
2
|
-
|
|
3
|
-
DeepSeek Harness 的
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
- `
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
## 2. 依赖:一个都不用手动装
|
|
27
|
-
|
|
28
|
-
| 层 | 内容 | 包内自带? |
|
|
29
|
-
|---|---|---|
|
|
30
|
-
| Node | ≥ 22.13(`node:sqlite` 需无 flag 版本);DSH 本体要求 ≥ 24.9 | DSH 侧负责 |
|
|
31
|
-
| DSH | `>= 0.2.2-rc.3`(写进 `engines.dsh`,不满足会被安装器拦下) | — |
|
|
32
|
-
| JS 依赖 | **零**(无 `dependencies`;只动态 `import` 可选的 `@deepseek-ai/dsh-mcp-client`,缺失自动降级) | ✅ |
|
|
33
|
-
| Web Client | `dsh-client-locale` / `ui-layout` / `ui-sidebar` / `ui-workspace` / `dsh-api-session-controller` | 由 DSH 提供 |
|
|
34
|
-
| Python | `fastapi uvicorn python-multipart Pillow python-xlib websockets httpx mss` | ✅ `vendor/wheels/` 离线 wheel(linux **x86_64 + aarch64**,CPython **3.12**) |
|
|
35
|
-
| pip 自身 | `vendor/pip/` 内置 `pip` + `setuptools` wheel(宿主机没有 ensurepip 也能建 venv) | ✅ |
|
|
36
|
-
| 系统组件 | `xvfb x11vnc websockify novnc xauth xfwm4 xfdesktop4 xfconf dbus-x11 tint2 picom pcmanfm xterm xdotool xclip glib-networking gvfs gvfs-daemons feh adwaita-icon-theme fonts-noto-color-emoji fonts-noto-cjk` | 首次启动自动 `apt-get install`(需 root 或无密码 sudo) |
|
|
37
|
-
| 运行时底座 | cgroup v2 unified(屏幕冻结)、`Xvfb`(或 KasmVNC 提供的 `Xvnc`) | 检测/自动装 Xvfb;KasmVNC 可选 |
|
|
38
|
-
|
|
39
|
-
首次启动的顺序(`host/screen.js` → `bootstrapVenv` / `ensureSystemDependencies`):
|
|
40
|
-
|
|
41
|
-
1. 探活 `127.0.0.1:6200/healthz`,已就绪直接复用;
|
|
42
|
-
2. 找 Python:`BOTSCREEN_PYTHON` → `$DSH_HOME/botmode/screen-venv` → 插件内 `.venv` → 仓库 `.venv` → `python3`(只要它的 import 探针通过就原地用);
|
|
43
|
-
3. 否则建 venv,用包内 pip wheel 播种,再 **离线** `pip install --no-index --find-links vendor/wheels/{any,linux-<arch>}`;wheel 不匹配解释器(如 3.10/3.11/3.13)时回退 PyPI,仍是全自动;
|
|
44
|
-
4. 逐项探测 14 个系统 bin,缺哪个就 `apt-get install` 全套一次(无 root/免密 sudo 时打印可复制的一行命令,不阻断其它功能);
|
|
45
|
-
5. 拉起 `python -m botscreen`,写日志 `$DSH_HOME/botmode/botscreen-gateway.log`。
|
|
46
|
-
|
|
47
|
-
关掉自动安装:`BOTSCREEN_AUTO_INSTALL_DEPS=0`。
|
|
48
|
-
|
|
49
|
-
---
|
|
50
|
-
|
|
51
|
-
## 3. 自检
|
|
1
|
+
# @local/dsh-botmode
|
|
2
|
+
|
|
3
|
+
DeepSeek Harness 的 Bot 团队模式插件(Host + Web Client 双半区,v0.6.0)。
|
|
4
|
+
|
|
5
|
+
- 每个 Bot 独立目录、SOUL/MEMORY、永久私聊会话,以及**按房间隔离的隐藏 Group Session**(支持配置房间共享工程目录 `workDir`)
|
|
6
|
+
- 每个 Bot 可单独绑定模型:DSH 默认(空绑定,下一轮重新读取)、provider/model、思考档位;模型目录标出是否支持图片输入
|
|
7
|
+
- Bot 聊天可发图片(PNG/JPEG/WebP/GIF),纯文本模型由 Host 在入队前拒绝
|
|
8
|
+
- `message_agent` 异步队友消息(会话级 FIFO、跳数护栏 `MAX_AGENT_HOPS=4`、同链去重、回信降级、>16k 落盘、群聊隐藏会话严格禁止)
|
|
9
|
+
- **Hermes 底座 + 终态驱动全异步 Actor 并发群聊(Group Room)**:
|
|
10
|
+
- 2–6 人,支持 `auto`(并发协作 / `@` 接力)/ `everyone`(全员并发审阅)/ `lead`(Lead 统筹派工与验收)
|
|
11
|
+
- **全异步 `BotActor` 总线 + 快照水位线防漏看**:空闲 Bot 并发响应消除慢 Bot 木桶效应;提交前锁定 `snapshotSeq` + `selfSentSeqs` 跳过集,杜绝并发漏看;精准 `@` 他人消息零 Token 推进水位线
|
|
12
|
+
- **3 种显式业务终态(默认无回合数硬切)**:`completed`(仅显式调用 `room_finish_task` 触发,绝不靠正文正则误判)、`settled`(全员 `(pass)` 且无在途任务/待审批)、`waiting_user`(`@user` 询问,或局部挂起等待工具审批 / `ask_user_question`,不阻塞其他并行成员)
|
|
13
|
+
- **3 个病态异常探针兜底**:连续 5 轮纯文本零工具/零改文件/零认领空转软暂停(`idle_spin`)、单 Bot 连续 3 次重复报错指纹局部暂停并广播排障求助(`paused_error`)、软 Token 预算检查点(`token_budget`,点继续无损续跑)
|
|
14
|
+
- **共享任务板与文件软锁 + 分轨流式渲染**:`claim_subtask(taskId, paths)` 配合 DSH 工具拦截层软锁防并发覆写文件;前端底部按 `botId` 分轨实时流式展示思考与工具状态,完成后按 `seq` 到达顺序固化入主聊天流;人类中途发言采用 **Soft Steer 软插话**(不强杀在途脚本,仅 `Stop` / `/stop` 全局强停)
|
|
15
|
+
- **全局可插拔团队记忆库(Memory Hub)**:
|
|
16
|
+
- 所有 Bot 共用一套全局激活的记忆库插件,按 `team_id` + `agent_id (= bot.id)` + `user_id` 严格隔离各 Bot 记忆
|
|
17
|
+
- 默认内置 `memory_tencentdb`(对接 v3 HTTP Gateway `127.0.0.1:8420`,支持 L0–L3 并行预取与异步写入、熔断保护,网关未启动时自动回退至 Node 22 原生 SQLite FTS5)
|
|
18
|
+
- 同时内置 `local_sqlite`(纯本地零依赖 SQLite FTS5)与 `builtin`(仅 `MEMORY.md`)
|
|
19
|
+
- 支持在页面或 `/botmode memory install` 一键下载、安装、配置、热切换与卸载其他记忆库插件
|
|
20
|
+
- Host 持久 Routines:cron 解析 + 冷会话唤醒,定时器在 `ctx.effect()` 内
|
|
21
|
+
- Bot 审批与提问桥:`approval/request`(once / session / always / deny)与 `user-questions/request`(`ask_user_question`)同时覆盖私聊与隐藏群聊会话
|
|
22
|
+
|
|
23
|
+
安装(桌面端):
|
|
52
24
|
|
|
53
25
|
```bash
|
|
54
|
-
|
|
55
|
-
npx dsh-quay-bot --json # 给脚本用
|
|
56
|
-
npx dsh-quay-bot --fix-hint # 只输出需要执行的命令
|
|
26
|
+
dsh plugin --profile desktop install /path/to/dsh-bot/packages/dsh-botmode
|
|
57
27
|
```
|
|
58
28
|
|
|
59
|
-
|
|
29
|
+
状态根:`$DSH_HOME/botmode`。HTTP:`/botmode/api/state`、`/botmode/api/models`、`/botmode/api/memory`、`/botmode/api/image`、`/botmode/api/command`。
|
|
60
30
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
## 4. Market index(Discover 页搜索)
|
|
64
|
-
|
|
65
|
-
包内提供一份符合 DSH plugin market format 1 的索引:`market/index.json`。把它放到任意 https 可访问地址(或本机 http),在 DSH 的 Discover / 插件市场设置里添加为索引源,即可在页面里搜到 `dsh-quay-bot` 并一键安装:
|
|
66
|
-
|
|
67
|
-
```json
|
|
68
|
-
{
|
|
69
|
-
"format": 1,
|
|
70
|
-
"title": { "en": "Quay Bot", "zh": "Quay Bot 团队模式" },
|
|
71
|
-
"metadata": { "updated": 1764276000 },
|
|
72
|
-
"plugins": [
|
|
73
|
-
{
|
|
74
|
-
"name": "dsh-quay-bot",
|
|
75
|
-
"versions": [
|
|
76
|
-
{ "version": "1.0.0", "publishTimestamp": 1764276000, "source": { "type": "npm" }, "engines": { "dsh": ">=0.2.2-rc.3" } }
|
|
77
|
-
]
|
|
78
|
-
}
|
|
79
|
-
]
|
|
80
|
-
}
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
索引 URL 必须能被 DSH 以 `https:`(或同源的 http)读取;`source.type: "npm"` 会解析成 `dsh-quay-bot@1.0.0` 交给 profile 的包管理器。
|
|
84
|
-
|
|
85
|
-
---
|
|
86
|
-
|
|
87
|
-
## 5. 安装后去哪里找
|
|
88
|
-
|
|
89
|
-
- Host 行:`include:botmode`,模块 `dsh-quay-bot`
|
|
90
|
-
- Client 模块:`dsh-quay-bot/client`(侧边栏底部「Bot 模式」+ 机器人图标 → `main` 面板 `botmode`)
|
|
91
|
-
- 状态根:`$DSH_HOME/botmode`(`state.json` v4、`rooms/`、`bots/`、`memory-data/`、`memory-plugins/`、网关日志)
|
|
92
|
-
- HTTP:`/botmode/api/state`、`/models`、`/memory`、`/image`、`/command`、`/screen/*`、`/avatar/*`、`/artifacts/*`
|
|
93
|
-
|
|
94
|
-
改代码后:Plugin Manager 里关再开 `include:botmode` 重载 Host;Client 改动刷新页面即可(跑着 `pnpm run dev:web` 会热更新)。
|
|
95
|
-
|
|
96
|
-
---
|
|
97
|
-
|
|
98
|
-
## 6. 测试
|
|
31
|
+
测试:
|
|
99
32
|
|
|
100
33
|
```bash
|
|
101
|
-
node
|
|
102
|
-
&& node test/artifacts.test.mjs && node test/routines.test.mjs && node test/qr.test.mjs \
|
|
103
|
-
&& node test/remote.test.mjs && node test/isolation.test.mjs && node test/governance-channels.test.mjs
|
|
34
|
+
node packages/dsh-botmode/test/host.test.mjs
|
|
104
35
|
```
|
|
105
36
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
---
|
|
109
|
-
|
|
110
|
-
## 7. 与 `@local/dsh-botmode` 的关系
|
|
111
|
-
|
|
112
|
-
本包是同一套源码的**公开发布版**:包名、`dsh.bundle.patch` 的插件名、`client` 模块 id 改为 `dsh-quay-bot`;补上 `builtin-skills/**` 与 `vendor/wheels/**`;`bootstrapVenv` 改为离线优先;`ensureSystemDependencies` 从「5 个 bin」扩到「14 个 bin」。状态根、数据格式、`teamId=dsh-botmode` 保持不变,已有 Bot / 房间 / 记忆库可原样沿用。
|
|
113
|
-
|
|
114
|
-
同一 profile 里不要与 `@local/dsh-botmode` 同时启用(两者都插入 `include:botmode`)。
|
|
37
|
+
完整架构、命令表与限制见 [docs/BOTMODE.md](../../docs/BOTMODE.md);项目总览见仓库根 [README.md](../../README.md)。
|
package/client.js
CHANGED
|
@@ -1753,9 +1753,11 @@ window.__ModuleLoader__.load({
|
|
|
1753
1753
|
.bm-foot-toggle:not([data-wide='true']) span { display: none; }
|
|
1754
1754
|
.bm-foot-toggle { appearance: none; border: 0; background: transparent; color: var(--dsw-alias-label-secondary);
|
|
1755
1755
|
font: inherit; font-size: 12px; line-height: 16px; display: inline-flex; align-items: center; gap: 6px;
|
|
1756
|
-
padding: 5px 8px; border-radius: var(--dsw-radius-md); cursor: pointer;
|
|
1756
|
+
padding: 5px 8px; border-radius: var(--dsw-radius-md); cursor: pointer; flex: 1 1 auto; min-width: 0;
|
|
1757
|
+
white-space: nowrap; text-align: left; }
|
|
1757
1758
|
.bm-foot-toggle:hover { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
|
|
1758
1759
|
.bm-foot-toggle[data-active='true'] { color: var(--dsw-alias-brand-primary); }
|
|
1760
|
+
.bm-remote-trigger { flex: 0 0 auto; }
|
|
1759
1761
|
|
|
1760
1762
|
/* ---- 3-column workspace + Right Rail (Screen Card + Scheduled Tasks) ---- */
|
|
1761
1763
|
.bm-workspace { flex: 1; min-height: 0; display: flex; overflow: hidden; }
|
|
@@ -1967,10 +1969,19 @@ window.__ModuleLoader__.load({
|
|
|
1967
1969
|
return ''
|
|
1968
1970
|
}
|
|
1969
1971
|
}
|
|
1972
|
+
ctx.effect(() => {
|
|
1973
|
+
if (typeof document === 'undefined' || !document.head) return undefined
|
|
1974
|
+
const styleEl = document.createElement('style')
|
|
1975
|
+
styleEl.setAttribute('data-botmode-css', '1')
|
|
1976
|
+
styleEl.textContent = CSS
|
|
1977
|
+
document.head.appendChild(styleEl)
|
|
1978
|
+
return () => { styleEl.remove() }
|
|
1979
|
+
}, 'botmode: global styles')
|
|
1980
|
+
|
|
1970
1981
|
const useAvatarEngine = () => {
|
|
1971
1982
|
const snap = useSyncExternalStore(
|
|
1972
|
-
|
|
1973
|
-
|
|
1983
|
+
avatarEngineStore.subscribe,
|
|
1984
|
+
avatarEngineStore.getSnapshot,
|
|
1974
1985
|
)
|
|
1975
1986
|
useEffect(() => {
|
|
1976
1987
|
if (snap.status === 'idle') void ensureAvatarEngine()
|
|
@@ -2123,14 +2134,17 @@ window.__ModuleLoader__.load({
|
|
|
2123
2134
|
const markGroupSeen = () => {}
|
|
2124
2135
|
ctx.effect(() => {
|
|
2125
2136
|
void refreshHost()
|
|
2137
|
+
const isBotPanelActive = () => {
|
|
2138
|
+
const panel = ctx.layout.panelInfo.getSnapshot()
|
|
2139
|
+
const id = panel && (panel.activePanelId ?? panel.activeId)
|
|
2140
|
+
return id === PANEL_ID
|
|
2141
|
+
}
|
|
2126
2142
|
const timer = window.setInterval(() => {
|
|
2127
2143
|
if (document.visibilityState === 'hidden') return
|
|
2128
|
-
|
|
2129
|
-
if (panel && panel.activeId === PANEL_ID) void refreshHost()
|
|
2144
|
+
if (isBotPanelActive()) void refreshHost()
|
|
2130
2145
|
}, 3000)
|
|
2131
2146
|
const unsubPanel = ctx.layout.panelInfo.subscribe(() => {
|
|
2132
|
-
|
|
2133
|
-
if (panel && panel.activeId === PANEL_ID) void refreshHost()
|
|
2147
|
+
if (isBotPanelActive()) void refreshHost()
|
|
2134
2148
|
})
|
|
2135
2149
|
return () => {
|
|
2136
2150
|
window.clearInterval(timer)
|
|
@@ -2309,10 +2323,16 @@ window.__ModuleLoader__.load({
|
|
|
2309
2323
|
}
|
|
2310
2324
|
ctx.effect(registerLocales, 'botmode: dictionaries')
|
|
2311
2325
|
|
|
2312
|
-
const
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2326
|
+
const subscribeLocale = (listener) => locale.subscribe(listener)
|
|
2327
|
+
let cachedLocaleSnap = { active: 'en' }
|
|
2328
|
+
const getLocaleSnapshot = () => {
|
|
2329
|
+
const raw = locale.getLocale()
|
|
2330
|
+
const active = (raw && raw.active) || 'en'
|
|
2331
|
+
if (cachedLocaleSnap && cachedLocaleSnap.active === active) return cachedLocaleSnap
|
|
2332
|
+
cachedLocaleSnap = raw && typeof raw === 'object' ? raw : { active }
|
|
2333
|
+
return cachedLocaleSnap
|
|
2334
|
+
}
|
|
2335
|
+
const useLang = () => useSyncExternalStore(subscribeLocale, getLocaleSnapshot)
|
|
2316
2336
|
|
|
2317
2337
|
const useT = () => {
|
|
2318
2338
|
const snapshot = useLang()
|
|
@@ -2320,10 +2340,16 @@ window.__ModuleLoader__.load({
|
|
|
2320
2340
|
return useMemo(() => (key, vars) => interpolate(dict[key] ?? DICT.en[key] ?? key, vars), [dict])
|
|
2321
2341
|
}
|
|
2322
2342
|
|
|
2323
|
-
const
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2343
|
+
const subscribeMainPanel = (listener) => ctx.layout.panelInfo.subscribe(listener)
|
|
2344
|
+
let cachedPanelSnap = { activePanelId: null }
|
|
2345
|
+
const getMainPanelSnapshot = () => {
|
|
2346
|
+
const raw = ctx.layout.panelInfo.getSnapshot()
|
|
2347
|
+
const id = (raw && (raw.activePanelId ?? raw.activeId)) || null
|
|
2348
|
+
if (cachedPanelSnap && cachedPanelSnap.activePanelId === id) return cachedPanelSnap
|
|
2349
|
+
cachedPanelSnap = { activePanelId: id }
|
|
2350
|
+
return cachedPanelSnap
|
|
2351
|
+
}
|
|
2352
|
+
const useMainPanel = () => useSyncExternalStore(subscribeMainPanel, getMainPanelSnapshot)
|
|
2327
2353
|
|
|
2328
2354
|
const openBot = (bot) => {
|
|
2329
2355
|
if (!bot.sessionId) return
|
|
@@ -4195,14 +4221,24 @@ window.__ModuleLoader__.load({
|
|
|
4195
4221
|
useEffect(() => () => { if (reference) reference.release() }, [reference])
|
|
4196
4222
|
const binding = reference ? reference.binding : null
|
|
4197
4223
|
const session = binding ? binding.session : null
|
|
4198
|
-
const
|
|
4199
|
-
|
|
4200
|
-
|
|
4224
|
+
const subscribeSession = useMemo(
|
|
4225
|
+
() => (session ? (listener => session.subscribe(listener)) : NOOP_SUBSCRIBE),
|
|
4226
|
+
[session],
|
|
4227
|
+
)
|
|
4228
|
+
const getSessionSnap = useMemo(
|
|
4229
|
+
() => (session ? (() => session.getSnapshot()) : GET_ERROR_SESSION_SNAP),
|
|
4230
|
+
[session],
|
|
4231
|
+
)
|
|
4232
|
+
const subscribeEvents = useMemo(
|
|
4233
|
+
() => (binding ? (listener => binding.eventSource.subscribe(listener)) : NOOP_SUBSCRIBE),
|
|
4234
|
+
[binding],
|
|
4201
4235
|
)
|
|
4202
|
-
const
|
|
4203
|
-
|
|
4204
|
-
|
|
4236
|
+
const getEventsSnap = useMemo(
|
|
4237
|
+
() => (binding ? (() => binding.eventSource.getSnapshot()) : GET_EMPTY_EVENT_SNAP),
|
|
4238
|
+
[binding],
|
|
4205
4239
|
)
|
|
4240
|
+
const snapshot = useSyncExternalStore(subscribeSession, getSessionSnap)
|
|
4241
|
+
const events = useSyncExternalStore(subscribeEvents, getEventsSnap)
|
|
4206
4242
|
const turns = useMemo(() => buildTranscript(events.entries), [events])
|
|
4207
4243
|
const stickRef = useRef(true)
|
|
4208
4244
|
useEffect(() => {
|
|
@@ -4353,9 +4389,13 @@ window.__ModuleLoader__.load({
|
|
|
4353
4389
|
: h('button', { type: 'submit', className: 'bm-btn primary', disabled: busy || (text.trim() === '' && images.length === 0) }, busy ? t('form.busy') : t('chat.send')))))
|
|
4354
4390
|
}
|
|
4355
4391
|
|
|
4392
|
+
const NOOP_SUBSCRIBE = () => () => {}
|
|
4356
4393
|
const IDLE_SESSION_SNAP = Object.freeze({ running: false, openState: 'idle', hasMore: false })
|
|
4357
4394
|
const ERROR_SESSION_SNAP = Object.freeze({ running: false, openState: 'error', hasMore: false })
|
|
4358
4395
|
const EMPTY_EVENT_SNAP = Object.freeze({ entries: Object.freeze([]), hasMore: false, revision: 0 })
|
|
4396
|
+
const GET_IDLE_SESSION_SNAP = () => IDLE_SESSION_SNAP
|
|
4397
|
+
const GET_ERROR_SESSION_SNAP = () => ERROR_SESSION_SNAP
|
|
4398
|
+
const GET_EMPTY_EVENT_SNAP = () => EMPTY_EVENT_SNAP
|
|
4359
4399
|
|
|
4360
4400
|
function isClientPassToken(raw) {
|
|
4361
4401
|
let v = String(raw || '').trim()
|
|
@@ -4594,14 +4634,24 @@ window.__ModuleLoader__.load({
|
|
|
4594
4634
|
useEffect(() => () => { if (reference) reference.release() }, [reference])
|
|
4595
4635
|
const binding = reference ? reference.binding : null
|
|
4596
4636
|
const session = binding ? binding.session : null
|
|
4597
|
-
const
|
|
4598
|
-
|
|
4599
|
-
|
|
4637
|
+
const subscribeSession = useMemo(
|
|
4638
|
+
() => (session ? (listener => session.subscribe(listener)) : NOOP_SUBSCRIBE),
|
|
4639
|
+
[session],
|
|
4600
4640
|
)
|
|
4601
|
-
const
|
|
4602
|
-
|
|
4603
|
-
|
|
4641
|
+
const getSessionSnap = useMemo(
|
|
4642
|
+
() => (session ? (() => session.getSnapshot()) : GET_IDLE_SESSION_SNAP),
|
|
4643
|
+
[session],
|
|
4604
4644
|
)
|
|
4645
|
+
const subscribeEvents = useMemo(
|
|
4646
|
+
() => (binding ? (listener => binding.eventSource.subscribe(listener)) : NOOP_SUBSCRIBE),
|
|
4647
|
+
[binding],
|
|
4648
|
+
)
|
|
4649
|
+
const getEventsSnap = useMemo(
|
|
4650
|
+
() => (binding ? (() => binding.eventSource.getSnapshot()) : GET_EMPTY_EVENT_SNAP),
|
|
4651
|
+
[binding],
|
|
4652
|
+
)
|
|
4653
|
+
const snapshot = useSyncExternalStore(subscribeSession, getSessionSnap)
|
|
4654
|
+
const events = useSyncExternalStore(subscribeEvents, getEventsSnap)
|
|
4605
4655
|
|
|
4606
4656
|
const wasRunningRef = useRef(false)
|
|
4607
4657
|
useEffect(() => {
|
|
@@ -7776,14 +7826,14 @@ window.__ModuleLoader__.load({
|
|
|
7776
7826
|
}, t('rich.download')))))))
|
|
7777
7827
|
}
|
|
7778
7828
|
|
|
7829
|
+
const EMPTY_SESSION_LIST = Object.freeze({ ids: Object.freeze([]), byId: Object.freeze({}) })
|
|
7830
|
+
const getRawSessionListSafe = () => rawSessionSnapshot() || EMPTY_SESSION_LIST
|
|
7831
|
+
|
|
7779
7832
|
function BotsPage() {
|
|
7780
7833
|
const t = useT()
|
|
7781
7834
|
const stored = useSyncExternalStore(roster.subscribe, roster.getSnapshot)
|
|
7782
7835
|
const groups = useSyncExternalStore(groupStore.subscribe, groupStore.getSnapshot)
|
|
7783
|
-
const list = useSyncExternalStore(
|
|
7784
|
-
listener => sessions.list.subscribe(listener),
|
|
7785
|
-
rawSessionSnapshot,
|
|
7786
|
-
)
|
|
7836
|
+
const list = useSyncExternalStore(rawSessionSubscribe, getRawSessionListSafe)
|
|
7787
7837
|
const hostSnapshot = useSyncExternalStore(hostStore.subscribe, hostStore.getSnapshot)
|
|
7788
7838
|
const models = useSyncExternalStore(modelStore.subscribe, modelStore.getSnapshot)
|
|
7789
7839
|
useEffect(() => {
|
|
@@ -7840,6 +7890,7 @@ window.__ModuleLoader__.load({
|
|
|
7840
7890
|
const [query, setQuery] = useState('')
|
|
7841
7891
|
const [railOpen, setRailOpen] = useState(true)
|
|
7842
7892
|
const [takeoverModal, setTakeoverModal] = useState(null)
|
|
7893
|
+
const [remoteOpen, setRemoteOpen] = useState(false)
|
|
7843
7894
|
|
|
7844
7895
|
const openScreenTakeover = async (targetBot, helpEntry = null) => {
|
|
7845
7896
|
const botId = (targetBot && targetBot.id) || (helpEntry && helpEntry.botId)
|
|
@@ -8047,6 +8098,13 @@ window.__ModuleLoader__.load({
|
|
|
8047
8098
|
style: { display: 'inline-flex', alignItems: 'center', gap: '5px', flex: 1, justifyContent: 'center' },
|
|
8048
8099
|
onClick: () => openSettingsView('soul'),
|
|
8049
8100
|
}, h(SettingsIcon, { kind: 'gear' }), t('pane.settings')),
|
|
8101
|
+
h('button', {
|
|
8102
|
+
type: 'button',
|
|
8103
|
+
className: 'bm-btn small',
|
|
8104
|
+
style: { display: 'inline-flex', alignItems: 'center', gap: '4px', justifyContent: 'center' },
|
|
8105
|
+
title: t('remote.title'),
|
|
8106
|
+
onClick: () => setRemoteOpen(true),
|
|
8107
|
+
}, h(RemoteIcon, { size: 13 }), t('remote.button')),
|
|
8050
8108
|
h('button', { type: 'button', className: 'bm-btn small', onClick: toHarness }, t('foot.back'))))
|
|
8051
8109
|
|
|
8052
8110
|
const detailBody = activeBot
|
|
@@ -8198,7 +8256,8 @@ window.__ModuleLoader__.load({
|
|
|
8198
8256
|
onCommand: hostCommand,
|
|
8199
8257
|
onScreenInput: sendScreenInput,
|
|
8200
8258
|
onClose: () => setTakeoverModal(null),
|
|
8201
|
-
})
|
|
8259
|
+
}),
|
|
8260
|
+
remoteOpen ? h(RemoteDialog, { onClose: () => setRemoteOpen(false) }) : null)
|
|
8202
8261
|
}
|
|
8203
8262
|
|
|
8204
8263
|
function PanelIcon(props) {
|
|
@@ -8369,7 +8428,8 @@ window.__ModuleLoader__.load({
|
|
|
8369
8428
|
h('div', { className: 'bm-remote-hint' }, t('remote.appLabel')),
|
|
8370
8429
|
h('div', { className: 'bm-remote-link' }, data.appLink),
|
|
8371
8430
|
h('div', { className: 'bm-remote-hint' }, t('remote.appHint')))
|
|
8372
|
-
: h('div', { className: 'bm-remote-empty' },
|
|
8431
|
+
: h('div', { className: 'bm-remote-empty' },
|
|
8432
|
+
busy || (error ? t('remote.failed') : (data ? t('remote.appDisabled') : t('remote.starting'))))
|
|
8373
8433
|
|
|
8374
8434
|
const dialog = h('div', {
|
|
8375
8435
|
className: 'bm-modal-backdrop bm-remote-backdrop',
|
|
@@ -8418,25 +8478,26 @@ window.__ModuleLoader__.load({
|
|
|
8418
8478
|
open ? h(RemoteDialog, { onClose: () => setOpen(false) }) : null)
|
|
8419
8479
|
}
|
|
8420
8480
|
|
|
8421
|
-
ctx.slots.inject('sidebar.footer.action', ()
|
|
8422
|
-
|
|
8423
|
-
|
|
8424
|
-
|
|
8425
|
-
|
|
8426
|
-
|
|
8427
|
-
|
|
8428
|
-
|
|
8429
|
-
|
|
8430
|
-
|
|
8431
|
-
|
|
8432
|
-
|
|
8433
|
-
|
|
8434
|
-
|
|
8435
|
-
|
|
8436
|
-
|
|
8437
|
-
|
|
8438
|
-
|
|
8439
|
-
|
|
8481
|
+
ctx.slots.inject('sidebar.footer.action', function* () {
|
|
8482
|
+
yield ctx.slots.register({
|
|
8483
|
+
name: 'sidebar.footer.action',
|
|
8484
|
+
id: 'botmode.mode-switch',
|
|
8485
|
+
order: 10,
|
|
8486
|
+
label: () => (typeof locale.getLocale === 'function'
|
|
8487
|
+
? (String((locale.getLocale() || {}).active || '').startsWith('zh') ? 'Bot 模式' : 'Bot mode')
|
|
8488
|
+
: 'Bot mode'),
|
|
8489
|
+
locale: NS,
|
|
8490
|
+
}, FooterToggle)
|
|
8491
|
+
yield ctx.slots.register({
|
|
8492
|
+
name: 'sidebar.footer.action',
|
|
8493
|
+
id: 'botmode.remote',
|
|
8494
|
+
order: 11,
|
|
8495
|
+
label: () => (typeof locale.getLocale === 'function'
|
|
8496
|
+
? (String((locale.getLocale() || {}).active || '').startsWith('zh') ? '远程访问' : 'Remote')
|
|
8497
|
+
: 'Remote'),
|
|
8498
|
+
locale: NS,
|
|
8499
|
+
}, RemoteFooterButton)
|
|
8500
|
+
})
|
|
8440
8501
|
|
|
8441
8502
|
const panelLabel = () => {
|
|
8442
8503
|
const active = String((locale.getLocale() && locale.getLocale().active) || '').toLowerCase()
|
|
@@ -8462,17 +8523,26 @@ window.__ModuleLoader__.load({
|
|
|
8462
8523
|
if (this.state.error) {
|
|
8463
8524
|
return h('div', { className: 'bm-page', style: { padding: '32px', overflow: 'auto' } },
|
|
8464
8525
|
h('h2', null, 'Bot 模式渲染失败 / Bot mode failed to render'),
|
|
8526
|
+
h('div', { style: { display: 'flex', gap: '8px', margin: '12px 0' } },
|
|
8527
|
+
h('button', {
|
|
8528
|
+
type: 'button',
|
|
8529
|
+
className: 'bm-btn small primary',
|
|
8530
|
+
onClick: () => this.setState({ error: null }),
|
|
8531
|
+
}, '重试 / Retry')),
|
|
8465
8532
|
h('pre', { style: { whiteSpace: 'pre-wrap', fontSize: '12px', opacity: 0.8 } },
|
|
8466
8533
|
String((this.state.error && this.state.error.stack) || this.state.error)))
|
|
8467
8534
|
}
|
|
8468
8535
|
return this.props.children
|
|
8469
8536
|
}
|
|
8470
8537
|
}
|
|
8538
|
+
function BotsMainSlot() {
|
|
8539
|
+
return h(PageBoundary, null, h(BotsPage))
|
|
8540
|
+
}
|
|
8471
8541
|
ctx.slots.inject('main', () => ctx.slots.register({
|
|
8472
8542
|
name: 'main',
|
|
8473
8543
|
key: PANEL_ID,
|
|
8474
8544
|
locale: NS,
|
|
8475
|
-
},
|
|
8545
|
+
}, BotsMainSlot))
|
|
8476
8546
|
},
|
|
8477
8547
|
}
|
|
8478
8548
|
},
|
package/cordis.patch.yml
CHANGED
package/host/api.js
CHANGED
|
@@ -283,6 +283,7 @@ export class BotApi {
|
|
|
283
283
|
}
|
|
284
284
|
if (route === 'remote' && req.method === 'GET') {
|
|
285
285
|
try {
|
|
286
|
+
await this.remote?.recordUpstreamHintFromRequest?.(req)
|
|
286
287
|
sendJson(res, 200, await this.remote.status({ qr: url.searchParams.get('qr') !== '0' }))
|
|
287
288
|
} catch (error) {
|
|
288
289
|
sendJson(res, 500, { ok: false, error: error instanceof Error ? error.message : String(error) })
|
|
@@ -892,6 +893,9 @@ export class BotApi {
|
|
|
892
893
|
sendJson(res, 400, { ok: false, error: 'invalid JSON' })
|
|
893
894
|
return
|
|
894
895
|
}
|
|
896
|
+
if (String(payload?.type ?? '').startsWith('remote.')) {
|
|
897
|
+
await this.remote?.recordUpstreamHintFromRequest?.(req)
|
|
898
|
+
}
|
|
895
899
|
const result = await this.command(payload)
|
|
896
900
|
sendJson(res, 200, { ok: true, state: this.publicState(), result })
|
|
897
901
|
return
|