dsh-dot-life 0.9.0 → 0.10.0
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 +45 -14
- package/cordis.patch.yml +11 -4
- package/docs/COMPUTER-DESIGN.md +1 -1
- package/docs/DESIGN.md +1 -1
- package/docs/ROADMAP.md +3 -3
- package/docs/computer.md +5 -5
- package/docs/interlude.md +7 -1
- package/docs/memory.md +5 -1
- package/docs/phone.md +2 -2
- package/docs/qq.md +42 -2
- package/package.json +1 -1
- package/src/computer/gate.js +8 -7
- package/src/computer/live-view.js +31 -15
- package/src/computer/vm.js +19 -7
- package/src/dot/core.js +16 -6
- package/src/dot/panel.js +2 -2
- package/src/interlude/core.js +8 -5
- package/src/memory/memory.js +23 -3
- package/src/memory/store.js +4 -3
- package/src/phone/phone.js +9 -8
- package/src/qq/qq.js +479 -62
- package/src/tool-prefixes.js +11 -0
package/README.md
CHANGED
|
@@ -4,14 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
A character who lives on her own phone, for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (dsh). She has her own Android phone (this plugin installs and runs it), her own accounts, her own days: between your conversations she keeps living — writes what happened, goes to look at things she is curious about on her phone, and sometimes has a real reason to message you. You are one of her contacts on QQ / WeChat / Feishu…; dsh-im carries the chat. If you also want her to *work* — shell, scripts, a desktop browser, scheduled jobs — give her the optional computer.
|
|
6
6
|
|
|
7
|
-
One plugin,
|
|
7
|
+
One plugin, six components (living next to other dsh plugins: see 「与其他插件共存」 in the Chinese section):
|
|
8
8
|
|
|
9
9
|
| Component | What it is | Needs |
|
|
10
10
|
|---|---|---|
|
|
11
|
-
| **`dsh-dot/phone`** | Her phone: an Android emulator the plugin downloads (emulator + platform-tools + one system image, ~2 GB, after you accept the SDK license), boots, keeps alive and exposes as `
|
|
12
|
-
| **`dsh-dot/interlude`** | 幕间, after [HDS-Interlude](https://github.com/REcklessNOLOve117/HDS-Interlude): the Canon (persona; HDSI presets by share code) as a prompt section; a life between conversations — script, continuity, intents; going to look at things on her phone or in her browser (read-only, no approvals); optional proactive contact. [Details](docs/interlude.md) | — |
|
|
13
|
-
| **`dsh-dot/qq`** | Her QQ on her computer: [NapCat](https://github.com/NapNeko/NapCatQQ) (OneBot 11) inside the computer VM, the same account as the QQ app on her phone; messages wake her the moment they arrive, she answers with `qq_send`. [Details](docs/qq.md) | the computer component |
|
|
14
|
-
| **`dsh-dot/
|
|
11
|
+
| **`dsh-dot/phone`** | Her phone: an Android emulator the plugin downloads (emulator + platform-tools + one system image, ~2 GB, after you accept the SDK license), boots, keeps alive and exposes as `mcp__dot-phone__*` ([mobile-mcp](https://github.com/mobile-next/mobile-mcp) over adb). The emulator window is the live view; her apps and logins live in the AVD and survive restarts. `DSH_DOT_PHONE=off` turns it off. [Details](docs/phone.md) | hardware virtualization (Apple silicon or Intel Mac, Linux with KVM, Windows with WHPX) |
|
|
12
|
+
| **`dsh-dot/interlude`** | 幕间, after [HDS-Interlude](https://github.com/REcklessNOLOve117/HDS-Interlude): the Canon (persona; HDSI presets by share code) as a prompt section; a life between conversations — script, continuity, intents; going to look at things on her phone or in her browser (read-only, no approvals); optional proactive contact. `DSH_DOT_INTERLUDE=off` turns it off. [Details](docs/interlude.md) | — |
|
|
13
|
+
| **`dsh-dot/qq`** | Her QQ on her computer: [NapCat](https://github.com/NapNeko/NapCatQQ) or [SnowLuma](https://github.com/SnowLuma/SnowLuma) (OneBot 11, `/qq backend`) inside the computer VM, the same account as the QQ app on her phone; messages wake her the moment they arrive, she answers with `qq_send`. `DSH_DOT_QQ=off` turns it off. [Details](docs/qq.md) | the computer component |
|
|
14
|
+
| **`dsh-dot/memory`** | What she remembers: you, her own notes, the people she meets, what happened; hands her conversation over to a fresh session past 150k tokens. `DSH_DOT_MEMORY=off` turns it off. [Details](docs/memory.md) | — |
|
|
15
|
+
| **`dsh-dot/dot`** | The contact layer: scheduled results → IM unless the reply is `DOT_SILENT`, approval and device notices on IM, working rules as a prompt section. `DSH_DOT_CONTACT=off` turns it off | [dsh-im](https://github.com/xmanrui/dsh-im) for IM; dsh's built-in schedule service |
|
|
15
16
|
| **`dsh-dot/computer`** (optional) | A bundled microVM (no Docker needed) with shell, browser, desktop, live view, approval gates and an audit log — the isolation boundary for work. `DSH_DOT_COMPUTER=off` turns it off. [Details](docs/computer.md) | [microsandbox](https://github.com/zerocore-ai/microsandbox) (bundled) or Docker |
|
|
16
17
|
|
|
17
18
|
```bash
|
|
@@ -34,14 +35,14 @@ dsh-dot 让 dsh 里住进一个**在自己手机上过日子的角色**。她有
|
|
|
34
35
|
|
|
35
36
|
| 组件 | 是什么 | 依赖 |
|
|
36
37
|
|---|---|---|
|
|
37
|
-
| **`dsh-dot/phone`** 她的手机 | Android 模拟器。插件自己从 Google 仓库下载模拟器、platform-tools 和一个系统镜像(约 2 GB,先要你接受 SDK 许可),自己写 AVD(不需要 Java / Android Studio),开机、保活,以 `
|
|
38
|
-
| **`dsh-dot/interlude`** 幕间 | 按 [HDS-Interlude](https://github.com/REcklessNOLOve117/HDS-Interlude):Canon(人设,HDSI
|
|
39
|
-
| **`dsh-dot/qq`** 她电脑上的 QQ | [NapCat](https://github.com/NapNeko/NapCatQQ)(OneBot 11
|
|
40
|
-
| **`dsh-dot/memory`** 她记得的 | 关于你的画像和她自己的笔记(按 Hermes 的做法,有字数上限,她自己能改),她在各个 App 里遇到的人(每人一张卡:互动次数由代码根据真实事件记,印象和事由模型写;只在帖子里互动过的人只记次数和一句印象;关于别人的事先进待核实区),发生过的事(按 dsh-whale-inurqq:碎片带重要度、被说起几次、会老化)。她的对话到 15 万 token 就交班换一个新会话,远早于 dsh 自己在 80%
|
|
41
|
-
| **`dsh-dot/dot`** 联系人层 | 定时任务的结果推到 IM(回复只是 `DOT_SILENT`
|
|
38
|
+
| **`dsh-dot/phone`** 她的手机 | Android 模拟器。插件自己从 Google 仓库下载模拟器、platform-tools 和一个系统镜像(约 2 GB,先要你接受 SDK 许可),自己写 AVD(不需要 Java / Android Studio),开机、保活,以 `mcp__dot-phone__*` 暴露给模型([mobile-mcp](https://github.com/mobile-next/mobile-mcp) 走 adb)。模拟器窗口就是实时画面;App 和登录态在 AVD 里,重启不丢。`DSH_DOT_PHONE=off` 关掉。详见 [docs/phone.md](docs/phone.md) | 硬件虚拟化:Apple silicon / Intel Mac,Linux 要 KVM,Windows 要 WHPX |
|
|
39
|
+
| **`dsh-dot/interlude`** 幕间 | 按 [HDS-Interlude](https://github.com/REcklessNOLOve117/HDS-Interlude):Canon(人设,HDSI 分享码导入)作为系统提示的一段;两次对话之间的生活——剧本、连续性、打算;想看什么就拿手机(或电脑浏览器)去看,只读、无审批;可选的主动联系。`DSH_DOT_INTERLUDE=off` 关掉。详见 [docs/interlude.md](docs/interlude.md) | — |
|
|
40
|
+
| **`dsh-dot/qq`** 她电脑上的 QQ | [NapCat](https://github.com/NapNeko/NapCatQQ) 或 [SnowLuma](https://github.com/SnowLuma/SnowLuma)(OneBot 11,`/qq backend` 切换)跑在她的电脑 VM 里,和手机上的 QQ 同一个账号;消息到的瞬间叫醒她,她用 `qq_send` 秒回;dot 的提醒和她的主动联系也走这里,官方机器人退为后备。`DSH_DOT_QQ=off` 关掉(电脑关了它也关)。详见 [docs/qq.md](docs/qq.md) | 电脑组件 |
|
|
41
|
+
| **`dsh-dot/memory`** 她记得的 | 关于你的画像和她自己的笔记(按 Hermes 的做法,有字数上限,她自己能改),她在各个 App 里遇到的人(每人一张卡:互动次数由代码根据真实事件记,印象和事由模型写;只在帖子里互动过的人只记次数和一句印象;关于别人的事先进待核实区),发生过的事(按 dsh-whale-inurqq:碎片带重要度、被说起几次、会老化)。她的对话到 15 万 token 就交班换一个新会话,远早于 dsh 自己在 80% 窗口时的压缩。`DSH_DOT_MEMORY=off` 关掉。详见 [docs/memory.md](docs/memory.md) | — |
|
|
42
|
+
| **`dsh-dot/dot`** 联系人层 | 定时任务的结果推到 IM(回复只是 `DOT_SILENT` 就不发)、审批和设备状况的提醒、工作规则作为系统提示的一段。`DSH_DOT_CONTACT=off` 关掉 | IM 用 [dsh-im](https://github.com/xmanrui/dsh-im);定时用 dsh 内置的定时服务 |
|
|
42
43
|
| **`dsh-dot/computer`**(可选)她的电脑 | 自带 microVM(不需要 Docker),里面有 shell、浏览器、桌面;实时画面、审批闸门、审计日志。干活时的隔离边界。`DSH_DOT_COMPUTER=off` 关掉。详见 [docs/computer.md](docs/computer.md) | [microsandbox](https://github.com/zerocore-ai/microsandbox)(自带)或 Docker |
|
|
43
44
|
|
|
44
|
-
v0.2 之前"电脑"(dsh-computer)和"幕间"(dsh-interlude)是独立插件;v0.3 / v0.4 起并进来做组件,git 历史一起并了。对外没变:`
|
|
45
|
+
v0.2 之前"电脑"(dsh-computer)和"幕间"(dsh-interlude)是独立插件;v0.3 / v0.4 起并进来做组件,git 历史一起并了。对外没变:`dshComputer`、`~/.dsh/dsh-computer*`、`~/dot/interlude/`、`/dot` `/interlude`。已经装了它们的,先 `dsh plugin --profile desktop remove dsh-computer dsh-interlude` 再装新版 dsh-dot。**v0.9 起 npm 包名是 `dsh-dot-life`**(`dsh-dot` 在 npm 上被占位包占着;v0.8.x 曾叫 `@kevinwu901113/dsh-dot`,已标记 deprecated):之前装过旧名的,先 `dsh plugin --profile desktop remove @kevinwu901113/dsh-dot`(或 `dsh-dot`)再装;`~/dot`、`~/.dsh/phone`、虚拟机都不用动。**v0.9.2 起 MCP 工具名带了命名空间**:`mcp__vm__*` → `mcp__dot-vm__*`,`mcp__phone__*` → `mcp__dot-phone__*`(见下文「与其他插件共存」);自己写过这些工具名的规则或提示要跟着改。
|
|
45
46
|
|
|
46
47
|
### 二、安装
|
|
47
48
|
|
|
@@ -75,7 +76,7 @@ Web 版:`dsh plugin --profile web add dsh-dot-life`。从源码装:把包名
|
|
|
75
76
|
|
|
76
77
|
- 你们聊天:dsh 自己跑对话,dsh-im 接 IM;她的人设(Canon)和工作规则是系统提示里的两段,不需要 `AGENTS.md`。
|
|
77
78
|
- 聊天安静下来 `idleMinutes` 后、或每 `advanceEveryMinutes` 一次(只在 `activeHours` 内)、或某个打算到了时间:**幕间一轮**——一次模型调用,她写下这段时间过的日子、更新连续性快照、记下打算,顺便说她想去看点什么(`browserIntents`)。
|
|
78
|
-
- **去看**:有 App 的站用手机(`phoneApps`),登录过的网站用电脑浏览器(`vmSites`),其他先走 dsh 的 `web` 服务;被挡了就自己去看。实现是往她最近的会话里追加一条"[幕间观察]"消息,她用 `
|
|
79
|
+
- **去看**:有 App 的站用手机(`phoneApps`),登录过的网站用电脑浏览器(`vmSites`),其他先走 dsh 的 `web` 服务;被挡了就自己去看。实现是往她最近的会话里追加一条"[幕间观察]"消息,她用 `mcp__dot-phone__*` / `mcp__dot-vm__browser_*` 自己看,最后那段回复作为 `webContext` 进入之后的幕间。这一轮不算幕,**也没有审批**——只读工具直接放行,输入、安装、下单一类直接拒绝。
|
|
79
80
|
- **跑腿会话**:拿起手机、App 通知、幕间的「去看」和「玩」都在她的另一个会话「dot · 跑腿」里跑,截图和屏幕元素不进你们的对话;跑腿有结果时,只在她的对话里留一句「[刚才拿起手机看了一眼] …」(不叫醒她,下一轮她就知道)。跑腿会话超过 6 万 token 自动换新。QQ / 微信的消息和你的话照常直接叫醒她的对话。
|
|
80
81
|
- **拿起手机**:手机没响她也会隔一阵拿起来看一眼(`phoneCheckEveryMinutes`,默认 30,最近没被叫醒过时):有没回的消息就回,App 里有新动态就看,没事 `DOT_SILENT` 回桌面。`/dot check` 立刻来一次。
|
|
81
82
|
- **手机响了**:任何 App 的新通知(QQ 消息、小黑盒的更新、以后她自己装的任何 App)都会叫醒她:`[手机通知] QQ · 宽:在吗`,她自己去 App 里回,或者不理。按 App 静音:`/phone notify mute <包名>`。
|
|
@@ -105,10 +106,40 @@ dot 的通知相关:`notifyBatchMs`(1 秒内的通知合成一次叫醒)
|
|
|
105
106
|
- **可审计**:她看到什么、为什么没出声、哪次工具被拒了,`calls.jsonl` 和两份审计日志里都有。
|
|
106
107
|
- **用小号**。
|
|
107
108
|
|
|
108
|
-
###
|
|
109
|
+
### 七、与其他插件共存
|
|
110
|
+
|
|
111
|
+
dsh-dot 尽量不占公共名字,但有几处是全局的,装别的插件前先看一眼:
|
|
112
|
+
|
|
113
|
+
- **电脑组件开着时会改全局设置**(`cordis.patch.yml` 顶部三段):本机 subprocess provider 换成虚拟机里的那个(`dot-subprocess`),`sandbox-policy` 设成 `danger-full-access`(虚拟机才是隔离边界),权限预设整套改写成 `computer` / `computer-auto`。所以**不要同时装别的沙箱、subprocess 或权限预设插件**;要用它们,就 `DSH_DOT_COMPUTER=off`,这三处恢复 dsh 默认。
|
|
114
|
+
- **MCP 工具名有命名空间**:虚拟机的工具是 `mcp__dot-vm__*`,手机是 `mcp__dot-phone__*`(serverName `dot-vm` / `dot-phone`;dsh 规范化工具名时 `-` 合法、原样保留)。别的插件挂一个叫 `vm` 或 `phone` 的 MCP 不会再撞名。前缀定义在 `src/tool-prefixes.js`,改名只改一处。
|
|
115
|
+
- **每个组件都能单独关**,在启动 dsh 的环境里设:
|
|
116
|
+
|
|
117
|
+
| 组件 | 关掉 |
|
|
118
|
+
|---|---|
|
|
119
|
+
| computer(连带 qq) | `DSH_DOT_COMPUTER=off` |
|
|
120
|
+
| phone | `DSH_DOT_PHONE=off` |
|
|
121
|
+
| qq | `DSH_DOT_QQ=off` |
|
|
122
|
+
| memory | `DSH_DOT_MEMORY=off` |
|
|
123
|
+
| interlude | `DSH_DOT_INTERLUDE=off` |
|
|
124
|
+
| dot(联系人层) | `DSH_DOT_CONTACT=off` |
|
|
125
|
+
|
|
126
|
+
组件之间只通过 `ctx.get(...)?.` 找彼此,缺了哪个其余的照常跑(比如关了 dot,记忆不再自动交班;关了 memory,通知里不带人物卡)。
|
|
127
|
+
- **记忆共存模式**:`dot-memory` 的 `coexist`(环境变量 `DSH_DOT_MEMORY_COEXIST`),默认 `auto`——发现另一个记忆服务(`otherMemoryServices`,默认 `hermesMemory`、`autoMemory`、`dshMemory`、`memoryBank`;不含过于通用的 `memory`,遇到别的名字自己加;cordis 没有公开的服务枚举,所以是名单)就打一行 info 日志,切到 `people-only`:人物卡、碎片、日记照旧,但**关于他 / 她自己记下的**两栏不再写进系统提示,整理时也不再改这两栏,免得两个插件一起"讲记忆"。`full` 强制全开,`people-only` 强制只留人物。
|
|
128
|
+
- **一个 QQ 号只能有一个应答者**:她电脑上的 NapCat 已经用这个号收发消息,不要再在同一个号上跑 qq-bridge 或别的 OneBot 机器人,否则两边都会回。
|
|
129
|
+
- **上下文压缩插件**:dsh-dot 注入会话的消息带固定的 `source`,压缩时请保留(或至少别把它们当成用户原话):
|
|
130
|
+
- `{ kind: 'dsh-dot', form: 'phone-notification' }` 手机通知叫醒她
|
|
131
|
+
- `{ kind: 'dsh-dot', form: 'phone-check' }` 定时看一眼手机
|
|
132
|
+
- `{ kind: 'dsh-dot', form: 'errand-note' }` 跑腿会话做完的事回写到主对话
|
|
133
|
+
- `{ kind: 'dsh-interlude', form: 'observation' }` 幕间观察
|
|
134
|
+
- `{ kind: 'dsh-interlude', form: 'play' }` 幕间「玩」
|
|
135
|
+
- `{ kind: 'handoff', generation }` 记忆交班时注入新会话的交接
|
|
136
|
+
- 来自她 QQ 上主人的消息是 `{ kind: 'user', rpcId: 'qq-…' }`,即普通用户消息。
|
|
137
|
+
- **`bash` 也过 dsh-dot 的电脑闸门**(`dot-gate` 的 `shellTools` 含 `bash`),别的插件再给 `bash` 加审批,同一条命令会弹两次审批。
|
|
138
|
+
|
|
139
|
+
### 八、路线
|
|
109
140
|
|
|
110
141
|
现状、分期和待定的决定见 [docs/ROADMAP.md](docs/ROADMAP.md)。
|
|
111
142
|
|
|
112
|
-
###
|
|
143
|
+
### 九、许可证
|
|
113
144
|
|
|
114
145
|
AGPL-3.0-only。幕间组件按原文使用 HDS-Interlude(AGPL-3.0)的提示词,所以整个包按 AGPL 发布;v0.3 之前以 MIT 发布的 computer / dot 代码,那些版本仍按 MIT 可用。
|
package/cordis.patch.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# dsh-dot: one plugin, five components. The character lives on her own devices.
|
|
2
2
|
# phone — her phone: an Android emulator this plugin installs, boots and keeps alive;
|
|
3
|
-
# tools
|
|
3
|
+
# tools mcp__dot-phone__* (mobile-mcp over adb). The emulator window is the live view.
|
|
4
4
|
# DSH_DOT_PHONE=off turns it off.
|
|
5
5
|
# computer — optional: a microVM (microsandbox, bundled; Docker as fallback) with shell, browser,
|
|
6
6
|
# desktop, live view, approval gates, audit log. The VM is the isolation boundary.
|
|
@@ -10,11 +10,13 @@
|
|
|
10
10
|
# DSH_DOT_QQ=off turns it off.
|
|
11
11
|
# dot — the always-on glue: scheduled runs → IM, silence protocol, approval cards with the
|
|
12
12
|
# live view, working rules as a prompt section. Needs dsh-im and the official
|
|
13
|
-
# schedule bundle (see README).
|
|
13
|
+
# schedule bundle (see README). DSH_DOT_CONTACT=off turns it off.
|
|
14
|
+
# memory — what she remembers (people, fragments, diary, owner/self banks). DSH_DOT_MEMORY=off.
|
|
14
15
|
# interlude — 幕间, after HDS-Interlude: the Canon (persona, HDSI presets by share code) as a
|
|
15
16
|
# prompt section, and a life between conversations — script, continuity, intents,
|
|
16
17
|
# going to look at things on her phone / in her browser (read-only), optional
|
|
17
|
-
# proactive contact over dsh-im.
|
|
18
|
+
# proactive contact over dsh-im. DSH_DOT_INTERLUDE=off turns it off.
|
|
19
|
+
# Every component tolerates a sibling being off (services are looked up with ctx.get(...)?.).
|
|
18
20
|
|
|
19
21
|
# 1. Replace the host subprocess provider with the VM-backed one.
|
|
20
22
|
- id: subprocess
|
|
@@ -54,7 +56,7 @@
|
|
|
54
56
|
name: 'dsh-dot-life/gate'
|
|
55
57
|
config:
|
|
56
58
|
mode: !!js "process.env.DSH_COMPUTER_GATE ?? 'risky'"
|
|
57
|
-
# 3. Browser + desktop tools served from inside the VM (tool names:
|
|
59
|
+
# 3. Browser + desktop tools served from inside the VM (tool names: mcp__dot-vm__*) are mounted by the
|
|
58
60
|
# computer component itself, so the MCP client carries the gateway key (see docs/computer.md).
|
|
59
61
|
# 4. Desktop/Web UI: right-Sidebar "Computer" tab (live view) and a header toggle.
|
|
60
62
|
- id: dot-ui
|
|
@@ -74,6 +76,7 @@
|
|
|
74
76
|
# 6. The always-on glue (was the standalone dsh-dot plugin).
|
|
75
77
|
- id: dot
|
|
76
78
|
name: 'dsh-dot-life/dot'
|
|
79
|
+
disabled: !!js "process.env.DSH_DOT_CONTACT === 'off'"
|
|
77
80
|
config:
|
|
78
81
|
# dot's home: its working files live here and sessions started here are dot's.
|
|
79
82
|
home: !!js "process.env.DSH_DOT_HOME ?? ''"
|
|
@@ -82,12 +85,16 @@
|
|
|
82
85
|
# handoffTokens (long before dsh's own compaction at 80% of the window). Files: <home>/memory/.
|
|
83
86
|
- id: dot-memory
|
|
84
87
|
name: 'dsh-dot-life/memory'
|
|
88
|
+
disabled: !!js "process.env.DSH_DOT_MEMORY === 'off'"
|
|
85
89
|
config:
|
|
86
90
|
home: !!js "process.env.DSH_DOT_HOME ?? ''"
|
|
91
|
+
# Next to another memory plugin: auto (people-only when one is found) · full · people-only.
|
|
92
|
+
coexist: !!js "process.env.DSH_DOT_MEMORY_COEXIST ?? 'auto'"
|
|
87
93
|
# handoffTokens: 150000
|
|
88
94
|
# 7. 幕间 (was the standalone dsh-interlude plugin). Shares dot's home: <home>/interlude/.
|
|
89
95
|
- id: dot-interlude
|
|
90
96
|
name: 'dsh-dot-life/interlude'
|
|
97
|
+
disabled: !!js "process.env.DSH_DOT_INTERLUDE === 'off'"
|
|
91
98
|
config:
|
|
92
99
|
home: !!js "process.env.DSH_INTERLUDE_HOME ?? process.env.DSH_DOT_HOME ?? ''"
|
|
93
100
|
# Going to look (HDSI browserIntent): auto = web first; a host listed below is always
|
package/docs/COMPUTER-DESIGN.md
CHANGED
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
- `src/backends/docker.js`:Intel Mac 的后备。
|
|
38
38
|
- `src/subprocess.js`:替换 dsh 的 `ctx.subprocess`,所有命令在虚拟机里执行;`spawn` 保持同步,虚拟机未就绪或换绑中时用等待前缀排队。
|
|
39
39
|
- `src/gate.js`:`tools/pre-execute` 审批闸门(危险命令、敏感浏览器动作),审批信息附实时画面链接。
|
|
40
|
-
- `cordis.patch.yml`:禁用本机 subprocess、`danger-full-access`(虚拟机即隔离边界)、Computer 权限预设、接入虚拟机里的 MCP(`
|
|
40
|
+
- `cordis.patch.yml`:禁用本机 subprocess、`danger-full-access`(虚拟机即隔离边界)、Computer 权限预设、接入虚拟机里的 MCP(`mcp__dot-vm__browser_*`)、界面行。
|
|
41
41
|
- `lib/client.js`(源码在 `ui/`):右侧栏“虚拟机”标签页(noVNC 内嵌)和会话顶部的显示器按钮。
|
|
42
42
|
|
|
43
43
|
### 已验证(Mac 桌面版 0.2.0-rc.2,Apple 芯片)
|
package/docs/DESIGN.md
CHANGED
|
@@ -121,7 +121,7 @@ Kevin:"把 computer 和 dot 合并为一个插件的不同组件"。做法:
|
|
|
121
121
|
- dsh-computer 仓库的历史用 `git merge --allow-unrelated-histories` 并进来(提交记录保留),文件移到 `src/computer/`(vm / subprocess / gate / audit / backends / ui-host),原 dsh-dot 的 core 移到 `src/dot/core.js`。
|
|
122
122
|
- `cordis.patch.yml` 合并:电脑那部分(关掉宿主 subprocess、沙箱策略、权限预设、`dot-computer` / `dot-subprocess` / `dot-gate` / `dot-mcp` / `dot-ui`)在前,`dot` 在后。组件名 `dsh-dot/computer`、`dsh-dot/subprocess`、`dsh-dot/gate`、`dsh-dot/dot`;`package.json` 的 `exports` 对应。
|
|
123
123
|
- 客户端 bundle `lib/client.js` 的 `__ModuleLoader__` id 必须等于包名,改成 `dsh-dot`(CSS tag 同步);标签页内部 id 不动。`ui/` 源码的 tsdown 配置同步。
|
|
124
|
-
-
|
|
124
|
+
- **对外不变**(v0.9.2 前):`mcp__vm__*` 工具(v0.9.2 起改为 `mcp__dot-vm__*`,避免和别的插件撞名)、`dshComputer` 服务名、`~/.dsh/dsh-computer*` 文件、VM 名 `dsh-computer`、`DSH_COMPUTER_*` 环境变量都保留——已经跑着的虚拟机、快照、审计日志不用迁移。
|
|
125
125
|
- dsh-interlude 不并:它是 AGPL-3.0(移植自 HDS-Interlude),并进 MIT 包会把整个包拖成 AGPL;而且它不依赖 dot,独立装卸更干净。
|
|
126
126
|
- 原 dsh-computer 仓库保留作为历史,README 指向这里。
|
|
127
127
|
|
package/docs/ROADMAP.md
CHANGED
|
@@ -8,7 +8,7 @@ dot 是一个**在自己手机上过日子的角色**:有自己的手机、账
|
|
|
8
8
|
|
|
9
9
|
| 层 | 状态 | 证据 |
|
|
10
10
|
|---|---|---|
|
|
11
|
-
| 手机(`phone`) | ✅ 开箱即用:自动下载/建 AVD/开机/接管,live view 标签页,`
|
|
11
|
+
| 手机(`phone`) | ✅ 开箱即用:自动下载/建 AVD/开机/接管,live view 标签页,`mcp__dot-phone__*` | 真机:装好 → 她自己装了 QQ、登录、回了消息 |
|
|
12
12
|
| 通知 → 叫醒 | ✅ 事件 + 快照模型,任何 App,按 App 静音,后台不冻结 | 真机:发出 → 叫醒 2–4 s(原 3.5 min) |
|
|
13
13
|
| 她回消息 | ⚠️ 能回,一条 ~78 s;连发时第二条叫醒会撞上她正在跑的一轮,上下文残缺 | 真机 09:07 |
|
|
14
14
|
| 幕间(`interlude`) | ✅ HDSI 移植:Canon、剧本、连续性、打算、web/vm/phone 三路"去看"(只读无审批) | 真机跑了 14 轮;0 次 browserIntent(剧情没给理由) |
|
|
@@ -20,8 +20,8 @@ dot 是一个**在自己手机上过日子的角色**:有自己的手机、账
|
|
|
20
20
|
## 架构(不再变的部分)
|
|
21
21
|
|
|
22
22
|
```
|
|
23
|
-
┌─ phone ──── Android 模拟器 ──
|
|
24
|
-
dot (联系人层) ──┼─ computer ─ microVM(可选)──
|
|
23
|
+
┌─ phone ──── Android 模拟器 ── mcp__dot-phone__* ── 通知事件
|
|
24
|
+
dot (联系人层) ──┼─ computer ─ microVM(可选)── mcp__dot-vm__*
|
|
25
25
|
└─ interlude ─ 幕间:剧本/连续性/打算/去看/主动联系
|
|
26
26
|
▲ 叫醒(通知、定时、幕间观察) ▼ 投递(dsh-im send / 未来 qq_send)
|
|
27
27
|
她的会话(dsh 自己跑对话,人设 = Canon 段 + 工作规则段)
|
package/docs/computer.md
CHANGED
|
@@ -11,7 +11,7 @@ Give [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (dsh) i
|
|
|
11
11
|
*The agent runs commands and opens a page inside its own VM; the Computer panel in dsh shows its desktop live. (Recorded with a scripted model.)*
|
|
12
12
|
|
|
13
13
|
- **Every agent command runs in the VM**, never on your machine. The session's workspace folder is shared into the VM at the same path.
|
|
14
|
-
- **Its own browser** (`
|
|
14
|
+
- **Its own browser** (`mcp__dot-vm__browser_*` tools), with logins that persist across restarts.
|
|
15
15
|
- **Live view inside dsh**: a monitor button in the session header opens a Computer tab in the right sidebar. Watch, click, type, or take over for a QR login or CAPTCHA.
|
|
16
16
|
- **Audit log**: every command, VM tool call, approval and folder change is appended to `~/.dsh/dsh-computer-audit.jsonl`.
|
|
17
17
|
- **Phone-friendly live view**: the desktop is served on dsh's own web server behind dsh's login (`/dsh-dot/computer/`); the VM gateway port is keyed (`SANDBOX_API_KEY`, generated per machine). Expose dsh itself (e.g. `tailscale serve`), set `publicUrl`, and approval messages — including IM approval cards — link to it.
|
|
@@ -41,7 +41,7 @@ Status: v0.5.0, verified on dsh desktop 0.2.0-rc.2 (macOS, Apple silicon). Want
|
|
|
41
41
|
给 DeepSeek Harness(dsh)一台自己的电脑:一台常驻的 Linux 微型虚拟机,带浏览器、实时桌面画面和审批闸门。不需要装 Docker。
|
|
42
42
|
|
|
43
43
|
- agent 的 bash 命令在虚拟机里执行,不碰你的系统。
|
|
44
|
-
- agent 的浏览器(`
|
|
44
|
+
- agent 的浏览器(`mcp__dot-vm__browser_*` 工具)在虚拟机里,登录态长期保留。
|
|
45
45
|
- 你随时可以打开实时画面观看或接手操作(扫码、验证码)。
|
|
46
46
|
- 虚拟机的每个工具都有分类,审批信息附实时画面链接:只读工具(截图、取文本、看目录)不问;shell(dsh 的 `bash`、虚拟机的 `sandbox_execute_bash` / `sandbox_execute_code`)按命令文本判——`sudo`、`rm -rf`、`curl | sh`、`base64 -d | sh`、`python -c`、`eval`、`git push`、`crontab` 等问;文件工具(`sandbox_file_operations`、`sandbox_str_replace_editor`)删除/移动问,普通读写不问;浏览器动作按页面内容判(支付、登录、删除等问);`browser_evaluate`(在登录态页面里跑任意 JS)和 `browser_gui_execute_action`(绕过浏览器工具的桌面级输入)**总是问**;任何工具的参数里出现受保护位置(`~/.ssh`、浏览器 profile/Cookies、`.aws`、`.env`、`/etc/shadow`、NapCat 配置等)**总是问**;镜像以后新增的、这里没见过的工具按浏览器动作对待并记一条审计。
|
|
47
47
|
- 会话所在的工作区文件夹自动共享进虚拟机,路径不变。
|
|
@@ -102,7 +102,7 @@ computer ready — live view: http://127.0.0.1:<dsh 端口>/dsh-dot/computer/vnc
|
|
|
102
102
|
|
|
103
103
|
**在 dsh 界面里**:会话顶部右侧有一个显示器按钮,点一下就在右侧栏打开"虚拟机"标签页,可以直接点击和输入;再点一下收起。也可以在右侧栏的"+"引导页里选"虚拟机"。虚拟机还没就绪时,标签页会显示等待状态并自动重试。
|
|
104
104
|
|
|
105
|
-
**在浏览器里**:打开 dsh 的地址加 `/dsh-dot/computer/`(日志 `computer ready — live view:` 一行有完整链接)。它挂在 dsh 自己的 web server 上,每个请求先过 dsh 的登录态(和手机实时画面、dot 面板同一道门),然后由插件带着网关密钥转给虚拟机。VNC 的 WebSocket 也经同一中继:入口页在通过登录态后发一张 120 秒、一次性的连接票(桌面版的界面走的是 app 内部桥,WebSocket 带不上登录 cookie,所以用票),WebSocket
|
|
105
|
+
**在浏览器里**:打开 dsh 的地址加 `/dsh-dot/computer/`(日志 `computer ready — live view:` 一行有完整链接)。它挂在 dsh 自己的 web server 上,每个请求先过 dsh 的登录态(和手机实时画面、dot 面板同一道门),然后由插件带着网关密钥转给虚拟机。VNC 的 WebSocket 也经同一中继:入口页在通过登录态后发一张 120 秒、一次性的连接票(桌面版的界面走的是 app 内部桥,WebSocket 带不上登录 cookie,所以用票),WebSocket 凭票或凭登录态进入。票绑定领票时的客户端地址,换个地址拿着同一张票进不来;入口页和 noVNC 页面带 `cache-control: no-store`、`referrer-policy: no-referrer`,票不会经缓存或 Referer 泄露。看到的就是 agent 的电脑桌面,可以直接点击、输入。
|
|
106
106
|
|
|
107
107
|
**在手机上(不在电脑旁时)**:暴露 **dsh 本身**,而不是虚拟机端口。推荐用 [Tailscale](https://tailscale.com):
|
|
108
108
|
|
|
@@ -114,7 +114,7 @@ tailscale serve --bg --https=443 http://127.0.0.1:<dsh 端口> # 只在你的
|
|
|
114
114
|
|
|
115
115
|
### 网关密钥
|
|
116
116
|
|
|
117
|
-
虚拟机镜像(AIO sandbox)的网关在本机的 `127.0.0.1:18080` 上同时提供 shell、文件、浏览器 CDP、MCP、noVNC 和网页终端;镜像默认不设密钥时这些全部开放给本机任何进程。插件在第一次启动时生成一把密钥,存在 `~/.dsh/dsh-computer.key`(仅属主可读),创建虚拟机和每次启动镜像服务时作为 `SANDBOX_API_KEY` 交给镜像;插件内部所有调用方(就绪探测、`
|
|
117
|
+
虚拟机镜像(AIO sandbox)的网关在本机的 `127.0.0.1:18080` 上同时提供 shell、文件、浏览器 CDP、MCP、noVNC 和网页终端;镜像默认不设密钥时这些全部开放给本机任何进程。插件在第一次启动时生成一把密钥,存在 `~/.dsh/dsh-computer.key`(仅属主可读),创建虚拟机和每次启动镜像服务时作为 `SANDBOX_API_KEY` 交给镜像;插件内部所有调用方(就绪探测、`mcp__dot-vm__*` 的 MCP 客户端、实时画面中继、QQ 桥接)都带着这把钥匙,别的程序没有。已存在的虚拟机会在下次启动时自动补上密钥(microsandbox 重启镜像服务,Docker 重建容器、保留家目录卷);如果重启后网关仍然不要密钥就放行、或者端口转发关不掉,电脑组件**不会进入就绪**:状态是 `unsafe`,浏览器工具(`mcp__dot-vm__*`)不挂载、实时桌面不可用、她的 QQ 不连(只剩 shell),dot 面板亮红色的「电脑网关」,日志里有 error——那是镜像版本不认 `SANDBOX_API_KEY`,请升级镜像或换 `image`。
|
|
118
118
|
|
|
119
119
|
想和别的工具共用一把钥匙,在设置文件里写 `apiKey`。
|
|
120
120
|
|
|
@@ -138,7 +138,7 @@ tailscale serve --bg --https=443 http://127.0.0.1:<dsh 端口> # 只在你的
|
|
|
138
138
|
| `memory` / `cpus` | `4G` / `2` | 虚拟机资源上限 |
|
|
139
139
|
| `publicUrl` / `DSH_COMPUTER_PUBLIC_URL` | 空 | 你暴露出去的 **dsh 本身**的地址(见第四节),实时画面链接用它,用于审批消息和状态接口;不是虚拟机端口 |
|
|
140
140
|
| `apiKey` | 自动生成 | 虚拟机网关密钥(`SANDBOX_API_KEY`);空则用 `~/.dsh/dsh-computer.key` 里自动生成的那把 |
|
|
141
|
-
| `mcp` | `true` | 由本组件挂载虚拟机的 `
|
|
141
|
+
| `mcp` | `true` | 由本组件挂载虚拟机的 `mcp__dot-vm__*` 工具(MCP 客户端带网关密钥);不要再在 `cordis.patch.yml` 里单独配 dsh-mcp-client 指向 `/mcp` |
|
|
142
142
|
| `DSH_COMPUTER_PORT` | `18080` | 虚拟机网关在本机的端口(仅监听 127.0.0.1,需要密钥);只能用环境变量设置 |
|
|
143
143
|
| `image` / `DSH_COMPUTER_IMAGE` | `ghcr.io/agent-infra/sandbox:latest` | 虚拟机镜像 |
|
|
144
144
|
| `backend` / `DSH_COMPUTER_BACKEND` | `auto` | `microsandbox` 或 `docker` |
|
package/docs/interlude.md
CHANGED
|
@@ -49,7 +49,7 @@ dsh 这边不需要重做一个对话系统——对话由 dsh 自己跑,IM
|
|
|
49
49
|
4. **带进下一幕**:`~/dot` 里之后的每一轮,系统提示里多一段 `<interlude>`:状态、最近的剧本、待办的打算、距上次幕间多久、期间 dsh 有没有重启过。放在对话历史之后,不影响提示前缀缓存。
|
|
50
50
|
5. **网页观察(HDSI 的 browserIntent)**:主角在幕间里"想查点什么"(搜索或打开一个公开页面)时写进 `browserIntents`,这一轮写完后插件去看,结果存进 `web-context.jsonl`,作为下一轮的 `webContext`。这是她自己的好奇心驱动的"闲逛",不是兴趣清单定时抓取;每天有上限。看的方式有两种:
|
|
51
51
|
- **web**:dsh 的 `web` 服务。匿名、只读、便宜、看不见。适合好奇心:搜个新闻、看个公开页。
|
|
52
|
-
- **vm**:她自己的电脑(dsh-computer 的虚拟机浏览器)。带着她的登录态和标签页,实时画面里看得见。适合"她的站"——微博、B 站、小红书、X 这些登录后才像样的地方。实现上是往她最近一个会话里追加一条 `[幕间观察]` 消息,让她用 `
|
|
52
|
+
- **vm**:她自己的电脑(dsh-computer 的虚拟机浏览器)。带着她的登录态和标签页,实时画面里看得见。适合"她的站"——微博、B 站、小红书、X 这些登录后才像样的地方。实现上是往她最近一个会话里追加一条 `[幕间观察]` 消息,让她用 `mcp__dot-vm__browser_*` 自己去看,最后那段回复就是观察结果;这一轮**不算幕**(不进剧本),也**没有审批**:只读工具(打开、滚动、读文字、截图、标签页)直接放行,其他任何工具——点击、输入、下载、shell——直接拒绝,不弹审批卡。她只能看,不能动。
|
|
53
53
|
- `browser: auto`(默认):先走 web;URL 的主机在 `vmSites` 里就直接走 vm(她的站从不匿名看);web 结果太薄或被挡(JS 墙、验证码、登录墙)也升级到 vm,一天最多 `vmDailyCap` 次。
|
|
54
54
|
6. **玩(默认关)**:`play: true` 时,幕间里她可以写一个 `playIntent`——此刻真想在手机上做的一件小事:给哪篇点个赞、评论一句、关注谁(`playActions`,发帖 / 私信 / 花钱不在其中,也写不进去)。这一轮写完后变成她会话里的一条 `[想玩会儿手机] …` 消息,她用手机去做(正常轮次,手机闸门的审批照常),做完只回 `DOT_SILENT`。门控和主动联系一样:活跃时段、意愿 ≥ 阈值、每天 ≤ `maxPlaysPerDay`、App 在 `playApps` 里。行为准则不是我们写的,是 [Moltbook](https://www.moltbook.com/heartbeat.md) 给住在社交网络上的 agent 定的守则(节译):先回别人的回复,再慷慨点赞,再用心评论,再关注,最后才发新内容——而且只在真有话说时;参与 > 创造;真诚,不为凑数。
|
|
55
55
|
7. **主动联系(Agency,默认关)**:`speak: true` 时,模型给出的 `contact` 过四道闸——在活跃时段、意愿 ≥ `willingnessThreshold`、当天未超 `maxContactsPerDay`、dsh-im 有投递目标——才通过 `dshIm.send()` 发出去。被拦下的会记在审计日志里。
|
|
@@ -85,6 +85,7 @@ dsh 这边不需要重做一个对话系统——对话由 dsh 自己跑,IM
|
|
|
85
85
|
|
|
86
86
|
| 配置项 | 默认值 | 作用 |
|
|
87
87
|
|---|---|---|
|
|
88
|
+
| `DSH_DOT_INTERLUDE=off` | | 整个组件不加载 |
|
|
88
89
|
| `home` / `DSH_INTERLUDE_HOME` | `~/dot`(跟随 `DSH_DOT_HOME`) | 幕间文件所在目录 |
|
|
89
90
|
| `browser` | `auto` | HDSI 的「网页观察」怎么看:`auto`(web 优先,`vmSites` 或 web 被挡时用 vm)、`web`、`vm`、`disabled` |
|
|
90
91
|
| `browseDailyCap` | `6` | 每天最多观察几次(两种方式合计) |
|
|
@@ -135,3 +136,8 @@ dsh 0.2.0-rc.2,云端,模拟模型:一幕结束后 `/interlude now` 发起
|
|
|
135
136
|
待验证:真机上用真实模型跑几天,看剧本是否自然、主动联系是否节制。
|
|
136
137
|
|
|
137
138
|
AGPL-3.0-only(随 dsh-dot)。想法和 lite 档提示词来自 HDS-Interlude(AGPL-3.0);对话层没有复用其代码。
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
## 说话的样子(口癖、标点、长度)
|
|
142
|
+
|
|
143
|
+
她怎么说话由 Canon 决定,三处:`storyDefaults.replyRules`(长度、先情绪后内容、标点习惯)、`blacklist`(出现即失败的 AI 口癖、转折套话、夸张修辞、符号)、`examples`(对话范例和「只学结构不照抄」的真人句式)。改 `~/dot/interlude/canon.json` 即可,立刻生效。机械能保证的一层放在代码里:`dsh-dot/qq` 的 `tidy` 会把发出去的文字里的句号、引号、破折号、冒号、星号、井号去掉;二十字、先情绪后内容、不用套话这些只能靠 Canon 和模型。
|
package/docs/memory.md
CHANGED
|
@@ -60,4 +60,8 @@ dsh 自己的压缩要到窗口的 80%(DeepSeek 是约 84 万 token)才发
|
|
|
60
60
|
|
|
61
61
|
## 配置(`dot-memory`)
|
|
62
62
|
|
|
63
|
-
`handoffTokens` 150000 · `minTokensBetweenHandoffs` 40000 · `consolidateEveryLines` 20 · `consolidateIdleMinutes` 30 · `dailyAt` 23:30 · `fragmentBudgetTokens` 600 · `agingEveryGens` 5 · `maxFragments` 300 · `handoffTailLines` 12 · `maxTokens` 16384 · `limits: { owner: 1375, self: 2200, person: 400, impression: 40 }`
|
|
63
|
+
`handoffTokens` 150000 · `minTokensBetweenHandoffs` 40000 · `consolidateEveryLines` 20 · `consolidateIdleMinutes` 30 · `dailyAt` 23:30 · `fragmentBudgetTokens` 600 · `agingEveryGens` 5 · `maxFragments` 300 · `handoffTailLines` 12 · `maxTokens` 16384 · `limits: { owner: 1375, self: 2200, person: 400, impression: 40 }` · `coexist` auto · `otherMemoryServices` [hermesMemory, autoMemory, dshMemory, memoryBank]
|
|
64
|
+
|
|
65
|
+
`DSH_DOT_MEMORY=off` 整个组件不加载。
|
|
66
|
+
|
|
67
|
+
**和别的记忆插件共存**(`coexist`,环境变量 `DSH_DOT_MEMORY_COEXIST`):`auto` 时,`otherMemoryServices` 里任何一个服务存在(每次用到时用 `ctx.get` 查,所以晚启动的插件也算;cordis 没有公开的服务枚举,只能按名单)就打一行 info 日志,进入 `people-only`:人物卡、碎片、日记、交班照旧,画像的 `owner` / `self` 两栏不再进系统提示,整理时模型给的这两栏改动也丢掉,交给那个插件。`full` 强制全开;`people-only` 强制只留人物。
|
package/docs/phone.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# dsh-dot/phone · 她的手机
|
|
2
2
|
|
|
3
|
-
An Android phone the plugin installs and runs for the character, exposed to the model as `
|
|
3
|
+
An Android phone the plugin installs and runs for the character, exposed to the model as `mcp__dot-phone__*`. No Android Studio, no Java: the plugin fetches three archives from Google's repository, writes the AVD itself, boots the emulator and mounts [mobile-mcp](https://github.com/mobile-next/mobile-mcp) over adb.
|
|
4
4
|
|
|
5
5
|
## 它做什么
|
|
6
6
|
|
|
7
7
|
1. **安装**(第一次):接受 [Android SDK 许可](https://developer.android.com/studio/terms)后(`/phone accept`,或配置 `acceptLicense: true`,或 `~/.dsh/dsh-phone.json` 里 `{"acceptLicense": true}`),从 `dl.google.com/android/repository` 读索引,下载 stable 通道的 emulator、platform-tools 和 `system-images;android-<api>;google_apis;<abi>`(约 1.7 GB),解压到 `~/.dsh/phone/`。`google_apis` 镜像没有 Play 商店——检测面最小,App 用 APK 装。
|
|
8
8
|
2. **AVD**:`~/.dsh/phone/avd/dot.avd/config.ini` 由插件写(Pixel 6 尺寸、1080×2400、3 GB 内存、8 GB 数据分区、不带 Play)。想改尺寸或内存,改配置后删掉这个目录重建。
|
|
9
9
|
3. **开机**:`emulator -avd dot -port 5554 -no-boot-anim -gpu auto`,等 `sys.boot_completed`,然后常亮屏幕、关动画、解锁。上一次 dsh 留下的还在跑的模拟器会被直接接管,不会开两个。模拟器自己退出会在 `restartDelayMs` 后重开。
|
|
10
|
-
4. **MCP**:开机后以 stdio 挂一个 mobile-mcp(随插件一起安装,`ANDROID_HOME` 指向 `~/.dsh/phone`,`ANDROID_SERIAL=emulator-5554`),工具名 `
|
|
10
|
+
4. **MCP**:开机后以 stdio 挂一个 mobile-mcp(随插件一起安装,`ANDROID_HOME` 指向 `~/.dsh/phone`,`ANDROID_SERIAL=emulator-5554`),工具名 `mcp__dot-phone__mobile_*`:列设备、截图、列屏幕元素(带坐标)、点、滑、长按、输入、按键、打开/关闭 App、装卸 App、开 URL。
|
|
11
11
|
5. **提示**:手机就绪后系统提示里多一段 `phone:device`,告诉模型设备号和用法(先看元素再点;验证码、人脸停下来叫用户)。
|
|
12
12
|
6. **闸门**:`mobile_install_app` / `mobile_uninstall_app` 弹审批;`mobile_type_keys` 的内容像密码 / 支付 / 验证码时弹审批(`sensitivePatterns`)。幕间的观察轮只放行只读工具(看、滑、点进去、开 App、返回),其余直接拒绝、不审批。
|
|
13
13
|
7. **通知叫醒她**:插件盯着系统的事件日志(`adb logcat -b events notification_enqueue`),每有 App 发通知就立刻读一次通知栏(`dumpsys notification`),另外每 `notifyPollMs` 兜底轮询一次——QQ 这类 App 在聊天窗口开着时会立刻撤回通知,光靠轮询会漏,新出现的通知(启动时已经在栏里的不算;系统包不算;`notifyApps` 可以只挑几个 App)交给 dot,dot 往她最近的会话里追加一条 `[手机通知] QQ · 宽:……`,她自己决定去 App 里回还是只回 `DOT_SILENT`。这条回复不会转发到任何 IM。所以她不需要定闹钟去看 QQ——有人找她,手机会响。**任何 App 都算**,包括她以后自己装的:新 App 默认叫醒;像手机自己的通知设置一样可以按 App 静音——`/phone notify mute <包名>` / `wake <包名>`(持久化在 `dsh-phone.json`),`/phone notify` 看每个 App 发过多少条和当前策略。她在 Android 设置里关掉某个 App 的通知也一样生效(通知栏里没有就不会叫)。几秒内连来的多条合成一次叫醒(dot 的 `notifyBatchMs`);dot 的 `notifyHours` 可以设一个静音时段(默认不设)。`/phone notifications` 看最近 20 条。
|
package/docs/qq.md
CHANGED
|
@@ -29,23 +29,63 @@ Her QQ on her computer: [NapCat](https://github.com/NapNeko/NapCatQQ) — a head
|
|
|
29
29
|
|
|
30
30
|
| | |
|
|
31
31
|
|---|---|
|
|
32
|
-
| **你**(owner)私聊她 | 你打的字原样进她的会话,以"人说的话"的身份(和 dsh-im 转发 IM 一样,`kind: user`)——所以你能在 QQ 上给她派长任务,她可以建目标(`create_goal
|
|
32
|
+
| **你**(owner)私聊她 | 你打的字原样进她的会话,以"人说的话"的身份(和 dsh-im 转发 IM 一样,`kind: user`)——所以你能在 QQ 上给她派长任务,她可以建目标(`create_goal`)一轮轮做下去。夜间静音对你不生效。**她这一轮的回答会送回你的 QQ**:她自己用 `qq_send(to: owner)` 发了就不重复,没发的话 dot 把她在对话里的最后一段回复转过去(`DOT_SILENT` 除外)。**只有电脑端 QQ 按 QQ 号认出的你才算**:手机通知只有昵称,谁都能改成和你一样,所以电脑端掉线时你从手机 QQ/微信发来的话会标成「未验证身份」,当普通消息看、不当指令 |
|
|
33
33
|
| 别人私聊她 / 群里 @ 她 | `[手机通知] QQ · 路人(123):在吗` 叫醒她,和手机通知一条路(1 秒合并、忙时攒着、按对话分组、夜间静音);这些不算人的直接输入,建不了目标 |
|
|
34
34
|
| 她回 | `qq_send(to: "owner" \| "user:<号>" \| "group:<号>", text, images)`,`<sep/>` 分几条发。**审批**(`sendPolicy: reply`):发给你永远不问;回最近 30 分钟内给她发过消息的人或群(文字、网图)不问;发给没找过她的人、沉默的群,或者发她手机/电脑上的文件(`phone:*`、`/sdcard/…`、电脑路径)——先弹审批 |
|
|
35
35
|
| 她发图 | `images` 里每一项直接作为**图片**发出(不是链接):网址(NapCat 下载)、`phone:screen`(手机此刻截图)、`phone:latest`(手机里最新的照片/截图/下载)、`/sdcard/…`(手机上的文件)、电脑上的绝对路径;≤10 MB |
|
|
36
|
+
| 图片网址规则 | 只接受公网 `http`/`https`、端口 80/443、不带账号密码;回环、私网、链路本地(含 169.254.169.254)、组播、`localhost`/`*.local`/`*.internal`/单段主机名一律拒绝并报错(NapCat 在 VM 里下载,防止她让它访问 VM 内部服务)。公网域名解析到内网(DNS rebinding)这里拦不住 |
|
|
36
37
|
| 别人发图给她 | 叫醒文本里是 `[图片 <网址>]`,她想看就打开 |
|
|
37
38
|
| dot 的提醒、幕间的主动联系 | 连上后优先走她的 QQ(发给 `owner`),dsh-im 的官方机器人退为后备 |
|
|
38
39
|
| 手机上 QQ 的通知 | 连上后自动忽略(否则同一条叫两次);手机 QQ 照常可以看空间、看群、发图 |
|
|
39
40
|
| 她能做什么 | 发文字和图片。加好友、进群、撤回、发文件都没有工具 |
|
|
40
41
|
|
|
42
|
+
## SnowLuma 后端
|
|
43
|
+
|
|
44
|
+
[SnowLuma](https://github.com/SnowLuma/SnowLuma) 是另一种 OneBot 11 实现:不自己当 QQ,而是用 ptrace 把钩子注入一个**正在运行的 Linux QQ 图形界面进程**,对外提供 OneBot 11(219 个 action)。dsh 这边(WebSocket、`qq_send`、审批、群打分、转发给你)对两个后端完全一样。
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
/qq install # 先装 NapCat:它顺带装好 Linux QQ,SnowLuma 用的就是这个 QQ
|
|
48
|
+
/qq install snowluma # 下载 SnowLuma lite 版(按 VM 的 arm64/x64,tag 取 latest,可用 snowlumaVersion 固定),解到 /root/snowluma,写配置,屏蔽 QQ 热更新(/etc/hosts 加 qqpatch.gtimg.cn)
|
|
49
|
+
/qq backend snowluma # 切后端,写进 dsh-qq.json
|
|
50
|
+
/qq start # 停掉 NapCat,在 VM 桌面上开 QQ 图形界面,再以 root 启动 SnowLuma(日志 /root/snowluma.log)
|
|
51
|
+
/qq qr # snowluma 下是「VM 屏幕的截图」:登录码在 QQ 窗口里,截图照样放到她手机摄像头前和相册;也可以直接打开「虚拟机」标签页扫
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
- **一个账号一个电脑端**:NapCat 和 SnowLuma 都是这个号的"电脑登录",不能同时跑。`/qq start` 总会先停掉另一个。
|
|
55
|
+
- **需要 ptrace**:`kernel.yama.ptrace_scope` 为 3 时 SnowLuma 注入不了,`/qq start` 会直接报错,请换回 `napcat`。
|
|
56
|
+
- **配置**:`config/runtime.json`(WebUI 5099、自动加载钩子)和 `config/onebot.json`(回环 WS 服务器用 `wsPort` + 同一个 OneBot token;回环 HTTP 服务器 3000 给 MCP 用)。文档没说清配置目录是工作目录下的 `config/` 还是 `data/config/`,所以两处都写;`/qq start` 每次都重写,token/端口改动会生效。
|
|
57
|
+
- **WebUI**:端口 5099,只在 VM 回环、网关不转发它。首次启动打印的一次性管理员密码在 `/qq log` 里。
|
|
58
|
+
- **早期软件**:SnowLuma 很新,QQ 版本一变钩子可能就失效(所以屏蔽了热更新)。出问题先 `/qq log`,不行就 `/qq backend napcat`。
|
|
59
|
+
|
|
60
|
+
### 219 个 action(MCP)
|
|
61
|
+
|
|
62
|
+
`snowlumaMcp: true`(snowluma 后端下默认开)时,WebSocket 连上后挂载 SnowLuma 官方的 MCP 服务器(`npx -y @snowluma/mcp`),工具名 `mcp__dot-qq__*`。它经网关的第二个认证路径 `/dsh-dot/onebot/` → VM 内 `127.0.0.1:3000`(同一个 conf 文件)访问 SnowLuma 的 HTTP API。MCP 只发一个 `Authorization: Bearer`:网关验它、原样透传,SnowLuma 再验同一个头,所以 HTTP 服务器的 accessToken 就是**网关密钥**;WS 仍用 OneBot token。
|
|
63
|
+
|
|
64
|
+
审批(`qqToolGate`):
|
|
65
|
+
|
|
66
|
+
| 调用 | 结果 |
|
|
67
|
+
|---|---|
|
|
68
|
+
| 文档类(`list_actions`、`search_actions`、`get_action`、`list_categories`、`get_runtime_info`、`query_action*`) | 直接跑 |
|
|
69
|
+
| 只读 action(`get_*`、`fetch_*`、`can_*`、`list_*`、`search_*`、`*preview*`、`*_check`、`ocr_image`、`download_file`) | 直接跑 |
|
|
70
|
+
| 发消息(`send_private_msg`、`send_group_msg`、`send_msg`、两个 forward) | 和 `qq_send` 同一道 `sendPolicy` 审批;参数里有 `file`/`path` 视为本地文件,问 |
|
|
71
|
+
| `send_packet`、`get_cookies`、`get_csrf_token`、`get_rkey`、改资料/头像、删好友、踢人/禁言/设管理/退群、`set_restart`、QQ 空间发/删 | 永远问 |
|
|
72
|
+
| 其他所有 action、读不出 action 名的调用 | 问,理由里写 action 名 |
|
|
73
|
+
|
|
74
|
+
**和官方部署的差异 / 前提**(对照 SnowLuma.Docker.Framework 的 host 安装脚本):`/qq install snowluma` 会装一个**干净的系统版 Linux QQ**(`/opt/QQ`,钉在 SnowLuma 官方安装脚本同一版本 3.2.32_260812,sha256 校验不过就不装),不复用 NapCat 解压的那份(它的启动器被改成加载 NapCat,两个客户端会挤进同一个 QQ)。SnowLuma 从工作目录读 `config/`,我们在 `/root/snowluma` 里启动它。它的 MCP(`@snowluma/mcp`)在**宿主机**上用 `npx` 跑,要求宿主有 `npx` 且 Node ≥ 24.22;没有就只是 `mcp__dot-qq__*` 不出现,收发消息照常。
|
|
75
|
+
|
|
41
76
|
## 配置
|
|
42
77
|
|
|
43
78
|
| 配置项 | 默认 | 作用 |
|
|
44
79
|
|---|---|---|
|
|
80
|
+
| `backend` | `napcat` | `napcat` / `snowluma`;`/qq backend <名>` 可改 |
|
|
81
|
+
| `snowlumaVersion` | 无 | 固定 SnowLuma 的 release tag;空 = latest |
|
|
82
|
+
| `snowlumaMcp` | `true` | snowluma 后端下挂载 SnowLuma 的 MCP(`mcp__dot-qq__*`) |
|
|
45
83
|
| `qq` / `DSH_DOT_QQ_ACCOUNT` | 无 | 账号;`/qq account` 也写进 `dsh-qq.json` |
|
|
46
84
|
| `owner` | 无 | 你的 QQ 号;`/qq owner <号>` 设置。只有它的私聊算你本人的话 |
|
|
47
85
|
| `wsPort` | `3001` | VM 内的 OneBot WS 端口(只听回环)。dsh 经网关的**认证**路径连它:插件在 VM 的 `/opt/gem/nginx/dsh-dot-napcat.conf` 放一个 `location /dsh-dot/napcat/`,网关先验密钥再转进来 |
|
|
48
|
-
|
|
|
86
|
+
| 校验 | 账号和 `owner` 必须是 5–12 位数字,`wsPort` 必须是 1–65535 的整数(它们会拼进 VM 里的 root shell 命令);`/qq account`、`/qq owner` 输错直接报错,`dsh-qq.json` 里的非法值按未设置处理并警告 |
|
|
87
|
+
| `groupPolicy` | `mention` | 群消息:`mention`(@她)/ `all` / `none` / `score`。`/qq group <值>` 可改。`score`:没 @ 她的群消息先用一次很短的模型调用打 0–10 分(和她相关、问到她、她明显有话说才高分),到 `scoreThreshold`(默认 7)才叫醒她,@ 永远算;每群每分钟最多 `scoreMaxPerMinute`(6)次打分;`scoreModel`("provider/model")可指定便宜模型,默认用当前模型。这就是"价值评分插话" |
|
|
88
|
+
| `tidy` | `true` | 发出去的文字按她的聊天口吻整理:去掉行末句号、引号、破折号、冒号、星号、井号(网址和时间不动)。关掉就原样发 |
|
|
49
89
|
| `sendPolicy` | `reply` | `qq_send` 审批:`reply`(见上表)/ `always`(除了你,发谁都问)/ `off`(不问) |
|
|
50
90
|
| `replyWindowMinutes` | `30` | `reply` 策略里"最近给她发过消息"的时间窗 |
|
|
51
91
|
| `githubProxy` / `DSH_DOT_GITHUB_PROXY` | 无 | 安装脚本下载 GitHub 资源的镜像前缀 |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-dot-life",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "dot — a character who lives on her own phone, for DeepSeek Harness (dsh): an Android phone the plugin installs and runs, her own QQ, memory and a diary from real events, a life between conversations (幕间, after HDS-Interlude), an optional microVM computer with approval gates. One plugin, six components.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
package/src/computer/gate.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
// and where, a browser action by what the page is about, and the protected locations in the VM
|
|
9
9
|
// (keys, browser profile, credentials) are watched in every argument of every tool.
|
|
10
10
|
|
|
11
|
+
import { VM_TOOL_PREFIX } from '../tool-prefixes.js';
|
|
11
12
|
import { clip } from './audit.js';
|
|
12
13
|
|
|
13
14
|
export const name = 'dot-gate';
|
|
@@ -19,7 +20,7 @@ export const defaults = {
|
|
|
19
20
|
mode: 'risky',
|
|
20
21
|
// Tools whose arguments reach a shell in the VM. dsh's own `bash` is routed into the VM; the VM's
|
|
21
22
|
// MCP server also exposes its own shell and code runners, which must pass the same gate.
|
|
22
|
-
shellTools: ['bash',
|
|
23
|
+
shellTools: ['bash', `${VM_TOOL_PREFIX}sandbox_execute_bash`, `${VM_TOOL_PREFIX}sandbox_execute_code`],
|
|
23
24
|
shellPatterns: [
|
|
24
25
|
String.raw`\brm\s+-[a-zA-Z]*[rf]`, String.raw`\bsudo\b`, String.raw`\b(curl|wget)\b[^|]*\|\s*(ba|z|da)?sh\b`,
|
|
25
26
|
String.raw`\b(curl|wget)\b[^|]*\|\s*(python|node|perl)`, String.raw`\bbase64\s+(-d|--decode)\b[^|]*\|`,
|
|
@@ -30,7 +31,7 @@ export const defaults = {
|
|
|
30
31
|
],
|
|
31
32
|
// VM tools that read or write files directly (no shell): asked when the operation is destructive
|
|
32
33
|
// or touches a protected location.
|
|
33
|
-
fileTools: [
|
|
34
|
+
fileTools: [`${VM_TOOL_PREFIX}sandbox_file_operations`, `${VM_TOOL_PREFIX}sandbox_str_replace_editor`],
|
|
34
35
|
destructivePatterns: [String.raw`"(operation|action|command|op)"\s*:\s*"(delete|remove|rm|move|rename|mv|chmod|chown|truncate)`, String.raw`\bdelete\b|\bremove\b|\brmdir\b`],
|
|
35
36
|
// Locations in the VM whose mention in any argument of any VM tool asks: her keys, logins and the
|
|
36
37
|
// browser profile (cookies, saved passwords), system credentials.
|
|
@@ -54,7 +55,7 @@ export const defaults = {
|
|
|
54
55
|
alwaysAskTools: ['browser_evaluate', 'browser_gui_execute_action'],
|
|
55
56
|
};
|
|
56
57
|
|
|
57
|
-
/** Browser/desktop action tools this file knows; any other
|
|
58
|
+
/** Browser/desktop action tools this file knows; any other mcp__dot-vm__ tool is audited once as unknown and treated like them. */
|
|
58
59
|
const KNOWN_ACTIONS = new Set(['browser_navigate', 'browser_go_back', 'browser_go_forward', 'browser_form_input_fill', 'browser_new_tab', 'browser_switch_tab', 'browser_close_tab', 'browser_click', 'browser_select', 'browser_close', 'browser_press_key']);
|
|
59
60
|
|
|
60
61
|
export function compile(cfg) {
|
|
@@ -69,7 +70,7 @@ export function compile(cfg) {
|
|
|
69
70
|
export function decide(call, cfg, compiled = compile(cfg)) {
|
|
70
71
|
if (cfg.mode === 'off') return null;
|
|
71
72
|
const { name: tool, args } = call;
|
|
72
|
-
const vmTool = tool.startsWith(
|
|
73
|
+
const vmTool = tool.startsWith(VM_TOOL_PREFIX) ? tool.slice(VM_TOOL_PREFIX.length) : '';
|
|
73
74
|
if (!vmTool && !cfg.shellTools.includes(tool)) return null;
|
|
74
75
|
// A protected location in any argument of any VM tool is a reason on its own.
|
|
75
76
|
if (compiled.protectedPaths.some((r) => r.test(args))) return `dsh-computer: touches a protected location in the VM (${vmTool || tool})`;
|
|
@@ -90,7 +91,7 @@ export function apply(ctx, config = {}) {
|
|
|
90
91
|
|
|
91
92
|
// Audit every VM-side tool call and its outcome (denied asks surface here as failures).
|
|
92
93
|
ctx.on('tools/result', (exec, result) => {
|
|
93
|
-
if (exec.name !== 'bash' && !exec.name.startsWith(
|
|
94
|
+
if (exec.name !== 'bash' && !exec.name.startsWith(VM_TOOL_PREFIX)) return;
|
|
94
95
|
audit({
|
|
95
96
|
kind: 'tool', tool: exec.name, session: sessionOf(exec), args: clip(exec.arguments, 300),
|
|
96
97
|
ok: !result.isError, ...(result.isError ? { error: clip(result.error?.code ?? result.error?.message ?? result.error, 200) } : {}),
|
|
@@ -105,12 +106,12 @@ export function apply(ctx, config = {}) {
|
|
|
105
106
|
const local = vm.liveViewUrl ?? '(starting)';
|
|
106
107
|
return vm.publicLiveViewUrl ? `\n实时画面 / live view: ${vm.publicLiveViewUrl}\n(本机 / local: ${local})` : `\n实时画面 / live view: ${local}`;
|
|
107
108
|
};
|
|
108
|
-
const classified = new Set([...cfg.readOnlyTools, ...cfg.alwaysAskTools, ...KNOWN_ACTIONS, ...cfg.shellTools, ...cfg.fileTools].map((t) => t.replace(
|
|
109
|
+
const classified = new Set([...cfg.readOnlyTools, ...cfg.alwaysAskTools, ...KNOWN_ACTIONS, ...cfg.shellTools, ...cfg.fileTools].map((t) => t.replace(new RegExp(`^${VM_TOOL_PREFIX}`), '')));
|
|
109
110
|
const unknown = new Set();
|
|
110
111
|
|
|
111
112
|
ctx.on('tools/pre-execute', async (exec, next) => {
|
|
112
113
|
const args = JSON.stringify(exec.input ?? exec.args ?? exec.arguments ?? {});
|
|
113
|
-
const vmTool = exec.name.startsWith(
|
|
114
|
+
const vmTool = exec.name.startsWith(VM_TOOL_PREFIX) ? exec.name.slice(VM_TOOL_PREFIX.length) : '';
|
|
114
115
|
if (vmTool && !classified.has(vmTool) && !unknown.has(vmTool)) {
|
|
115
116
|
unknown.add(vmTool);
|
|
116
117
|
audit({ kind: 'unknown-vm-tool', tool: exec.name, note: 'not classified here; treated as a browser/desktop action' });
|
|
@@ -30,6 +30,30 @@ export function vncPageUrl(origin, ticket) {
|
|
|
30
30
|
return `${LIVE_VIEW_PATH}/vnc/index.html?${q}`;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/** A peer address as one string: IPv4-mapped IPv6 (::ffff:127.0.0.1) and plain IPv4 compare equal. */
|
|
34
|
+
const peer = (addr) => String(addr ?? '').replace(/^::ffff:(?=\d+\.\d+\.\d+\.\d+$)/i, '');
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Socket tickets: single use, short life, and bound to the address that loaded the page — a ticket
|
|
38
|
+
* that leaks (it rides in the socket URL; noVNC can pass nothing else) is useless from elsewhere.
|
|
39
|
+
*/
|
|
40
|
+
export function createTicketStore({ ttlMs = TICKET_MS, max = TICKET_MAX, now = Date.now } = {}) {
|
|
41
|
+
const tickets = new Map(); // ticket → { exp, addr }
|
|
42
|
+
return {
|
|
43
|
+
mint(addr) {
|
|
44
|
+
const t0 = now();
|
|
45
|
+
for (const [t, v] of tickets) if (v.exp < t0) tickets.delete(t);
|
|
46
|
+
while (tickets.size >= max) tickets.delete(tickets.keys().next().value);
|
|
47
|
+
const t = randomBytes(24).toString('hex');
|
|
48
|
+
tickets.set(t, { exp: t0 + ttlMs, addr: peer(addr) });
|
|
49
|
+
return t;
|
|
50
|
+
},
|
|
51
|
+
// A page served over the desktop app's bridge has no TCP peer (addr ''): such a ticket is not
|
|
52
|
+
// bound, since the socket it unlocks will arrive on a real loopback connection.
|
|
53
|
+
redeem(t, addr) { const v = tickets.get(t); tickets.delete(t); return Boolean(v) && v.exp >= now() && (v.addr === '' || v.addr === peer(addr)); },
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
33
57
|
/** Only what the desktop view needs is relayed; the gateway's API, MCP, CDP and terminal are not. */
|
|
34
58
|
const ALLOWED = [/^\/vnc\//, /^\/websockify$/];
|
|
35
59
|
const HOP_BY_HOP = new Set(['connection', 'keep-alive', 'proxy-authenticate', 'proxy-authorization', 'te', 'trailer', 'transfer-encoding', 'upgrade', 'host', 'cookie', 'authorization', 'x-aio-api-key']);
|
|
@@ -50,16 +74,7 @@ export function mountComputerView({ webServer, connection, gateway, key, status,
|
|
|
50
74
|
const disposers = [];
|
|
51
75
|
const sockets = new Set();
|
|
52
76
|
// Socket tickets: minted only for a page request dsh already recognised as the owner's; one use, short life.
|
|
53
|
-
const tickets =
|
|
54
|
-
const mint = () => {
|
|
55
|
-
const now = Date.now();
|
|
56
|
-
for (const [t, exp] of tickets) if (exp < now) tickets.delete(t);
|
|
57
|
-
while (tickets.size >= TICKET_MAX) tickets.delete(tickets.keys().next().value);
|
|
58
|
-
const t = randomBytes(24).toString('hex');
|
|
59
|
-
tickets.set(t, now + TICKET_MS);
|
|
60
|
-
return t;
|
|
61
|
-
};
|
|
62
|
-
const redeem = (t) => { const exp = tickets.get(t); tickets.delete(t); return Boolean(exp) && exp >= Date.now(); };
|
|
77
|
+
const tickets = createTicketStore();
|
|
63
78
|
const currentOrigin = () => { try { return origin?.() || webServer.getOrigin?.() || ''; } catch { return ''; } };
|
|
64
79
|
|
|
65
80
|
const route = webServer.register({
|
|
@@ -71,9 +86,10 @@ export function mountComputerView({ webServer, connection, gateway, key, status,
|
|
|
71
86
|
const rest = url.pathname.slice(LIVE_VIEW_PATH.length) || '/';
|
|
72
87
|
if (rest === '/' || rest === '') {
|
|
73
88
|
// The owner (dsh said so): a page that sends the browser on to noVNC with a fresh ticket.
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
89
|
+
// The ticket is in the URL: no caching, and no Referer carrying it anywhere.
|
|
90
|
+
const next = vncPageUrl(currentOrigin(), tickets.mint(req.socket?.remoteAddress));
|
|
91
|
+
const html = `<!doctype html><meta charset="utf-8"><meta name="referrer" content="no-referrer"><title>computer</title><meta http-equiv="refresh" content="0;url=${next}"><script>location.replace(${JSON.stringify(next)})</script>`;
|
|
92
|
+
res.writeHead(200, { 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-store', 'referrer-policy': 'no-referrer' }).end(html);
|
|
77
93
|
return;
|
|
78
94
|
}
|
|
79
95
|
if (rest === '/status') {
|
|
@@ -85,7 +101,7 @@ export function mountComputerView({ webServer, connection, gateway, key, status,
|
|
|
85
101
|
return;
|
|
86
102
|
}
|
|
87
103
|
const up = http.request({ host: gateway.host, port: gateway.port, method: req.method, path: `${rest}${url.search}`, headers: upstreamHeaders(req, key()) }, (r) => {
|
|
88
|
-
const headers = { ...r.headers, 'cache-control': 'no-store' };
|
|
104
|
+
const headers = { ...r.headers, 'cache-control': 'no-store', 'referrer-policy': 'no-referrer' }; // noVNC's page URL holds the ticket too
|
|
89
105
|
delete headers['set-cookie'];
|
|
90
106
|
res.writeHead(r.statusCode ?? 502, headers);
|
|
91
107
|
r.pipe(res);
|
|
@@ -102,7 +118,7 @@ export function mountComputerView({ webServer, connection, gateway, key, status,
|
|
|
102
118
|
handler: (req, socket, head) => {
|
|
103
119
|
// A valid ticket (from a page load dsh admitted) or dsh's own recognition of the caller.
|
|
104
120
|
const ticket = new URL(req.url, 'http://x').searchParams.get('t');
|
|
105
|
-
const admitted = ticket ? redeem(ticket) : false;
|
|
121
|
+
const admitted = ticket ? tickets.redeem(ticket, req.socket?.remoteAddress) : false;
|
|
106
122
|
const rejection = admitted ? undefined : (() => { try { return connection?.requestRejection?.(req) ?? (connection ? undefined : 503); } catch { return 403; } })();
|
|
107
123
|
if (rejection !== undefined) { socket.end(`HTTP/1.1 ${rejection === 401 ? '401 Unauthorized' : '403 Forbidden'}\r\nconnection: close\r\n\r\n`); return; }
|
|
108
124
|
const headers = upstreamHeaders(req, key(), { connection: 'Upgrade', upgrade: 'websocket' });
|