dsh-dot-life 0.9.0 → 0.9.3

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 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, four components:
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 `mcp__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. [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. [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/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-im](https://github.com/xmanrui/dsh-im) for IM; dsh's built-in schedule service |
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) (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`. `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),开机、保活,以 `mcp__phone__*` 暴露给模型([mobile-mcp](https://github.com/mobile-next/mobile-mcp) 走 adb)。模拟器窗口就是实时画面;App 和登录态在 AVD 里,重启不丢。详见 [docs/phone.md](docs/phone.md) | 硬件虚拟化:Apple silicon / Intel Mac,Linux 要 KVM,Windows 要 WHPX |
38
- | **`dsh-dot/interlude`** 幕间 | 按 [HDS-Interlude](https://github.com/REcklessNOLOve117/HDS-Interlude):Canon(人设,HDSI 分享码导入)作为系统提示的一段;两次对话之间的生活——剧本、连续性、打算;想看什么就拿手机(或电脑浏览器)去看,只读、无审批;可选的主动联系。详见 [docs/interlude.md](docs/interlude.md) | — |
39
- | **`dsh-dot/qq`** 她电脑上的 QQ | [NapCat](https://github.com/NapNeko/NapCatQQ)(OneBot 11)跑在她的电脑 VM 里,和手机上的 QQ 同一个账号;消息到的瞬间叫醒她,她用 `qq_send` 秒回;dot 的提醒和她的主动联系也走这里,官方机器人退为后备。详见 [docs/qq.md](docs/qq.md) | 电脑组件 |
40
- | **`dsh-dot/memory`** 她记得的 | 关于你的画像和她自己的笔记(按 Hermes 的做法,有字数上限,她自己能改),她在各个 App 里遇到的人(每人一张卡:互动次数由代码根据真实事件记,印象和事由模型写;只在帖子里互动过的人只记次数和一句印象;关于别人的事先进待核实区),发生过的事(按 dsh-whale-inurqq:碎片带重要度、被说起几次、会老化)。她的对话到 15 万 token 就交班换一个新会话,远早于 dsh 自己在 80% 窗口时的压缩。详见 [docs/memory.md](docs/memory.md) | — |
41
- | **`dsh-dot/dot`** 联系人层 | 定时任务的结果推到 IM(回复只是 `DOT_SILENT` 就不发)、审批和设备状况的提醒、工作规则作为系统提示的一段 | IM 用 [dsh-im](https://github.com/xmanrui/dsh-im);定时用 dsh 内置的定时服务 |
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)(OneBot 11)跑在她的电脑 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 历史一起并了。对外没变:`mcp__vm__*`、`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`、虚拟机都不用动。
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` 服务;被挡了就自己去看。实现是往她最近的会话里追加一条"[幕间观察]"消息,她用 `mcp__phone__*` / `mcp__vm__browser_*` 自己看,最后那段回复作为 `webContext` 进入之后的幕间。这一轮不算幕,**也没有审批**——只读工具直接放行,输入、安装、下单一类直接拒绝。
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 mcp__phone__* (mobile-mcp over adb). The emulator window is the live view.
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: mcp__vm__*) are mounted by the
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
@@ -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(`mcp__vm__browser_*`)、界面行。
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
- - **对外不变**:`mcp__vm__*` 工具、`dshComputer` 服务名、`~/.dsh/dsh-computer*` 文件、VM 名 `dsh-computer`、`DSH_COMPUTER_*` 环境变量都保留——已经跑着的虚拟机、快照、审计日志不用迁移。
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 标签页,`mcp__phone__*` | 真机:装好 → 她自己装了 QQ、登录、回了消息 |
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 模拟器 ── mcp__phone__* ── 通知事件
24
- dot (联系人层) ──┼─ computer ─ microVM(可选)── mcp__vm__*
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** (`mcp__vm__browser_*` tools), with logins that persist across restarts.
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 的浏览器(`mcp__vm__browser_*` 工具)在虚拟机里,登录态长期保留。
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
  - 会话所在的工作区文件夹自动共享进虚拟机,路径不变。
@@ -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` 交给镜像;插件内部所有调用方(就绪探测、`mcp__vm__*` 的 MCP 客户端、实时画面中继、QQ 桥接)都带着这把钥匙,别的程序没有。已存在的虚拟机会在下次启动时自动补上密钥(microsandbox 重启镜像服务,Docker 重建容器、保留家目录卷);如果重启后网关仍然不要密钥就放行,dot 面板会亮红色的「电脑网关 无密钥开放」,状态接口里 `gatewayOpen: true`,日志里有 error——那是镜像版本不认 `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 重建容器、保留家目录卷);如果重启后网关仍然不要密钥就放行,dot 面板会亮红色的「电脑网关 无密钥开放」,状态接口里 `gatewayOpen: true`,日志里有 error——那是镜像版本不认 `SANDBOX_API_KEY`,请升级镜像。
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` | 由本组件挂载虚拟机的 `mcp__vm__*` 工具(MCP 客户端带网关密钥);不要再在 `cordis.patch.yml` 里单独配 dsh-mcp-client 指向 `/mcp` |
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 这些登录后才像样的地方。实现上是往她最近一个会话里追加一条 `[幕间观察]` 消息,让她用 `mcp__vm__browser_*` 自己去看,最后那段回复就是观察结果;这一轮**不算幕**(不进剧本),也**没有审批**:只读工具(打开、滚动、读文字、截图、标签页)直接放行,其他任何工具——点击、输入、下载、shell——直接拒绝,不弹审批卡。她只能看,不能动。
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 `mcp__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.
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`),工具名 `mcp__phone__mobile_*`:列设备、截图、列屏幕元素(带坐标)、点、滑、长按、输入、按键、打开/关闭 App、装卸 App、开 URL。
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,7 +29,7 @@ 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`)一轮轮做下去。夜间静音对你不生效。**只有电脑端 QQ 按 QQ 号认出的你才算**:手机通知只有昵称,谁都能改成和你一样,所以电脑端掉线时你从手机 QQ/微信发来的话会标成「未验证身份」,当普通消息看、不当指令 |
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 |
@@ -45,7 +45,8 @@ Her QQ on her computer: [NapCat](https://github.com/NapNeko/NapCatQQ) — a head
45
45
  | `qq` / `DSH_DOT_QQ_ACCOUNT` | 无 | 账号;`/qq account` 也写进 `dsh-qq.json` |
46
46
  | `owner` | 无 | 你的 QQ 号;`/qq owner <号>` 设置。只有它的私聊算你本人的话 |
47
47
  | `wsPort` | `3001` | VM 内的 OneBot WS 端口(只听回环)。dsh 经网关的**认证**路径连它:插件在 VM 的 `/opt/gem/nginx/dsh-dot-napcat.conf` 放一个 `location /dsh-dot/napcat/`,网关先验密钥再转进来 |
48
- | `groupPolicy` | `mention` | 群消息:`mention`(@她)/ `all` / `none` |
48
+ | `groupPolicy` | `mention` | 群消息:`mention`(@她)/ `all` / `none` / `score`。`/qq group <值>` 可改。`score`:没 @ 她的群消息先用一次很短的模型调用打 0–10 分(和她相关、问到她、她明显有话说才高分),到 `scoreThreshold`(默认 7)才叫醒她,@ 永远算;每群每分钟最多 `scoreMaxPerMinute`(6)次打分;`scoreModel`("provider/model")可指定便宜模型,默认用当前模型。这就是"价值评分插话" |
49
+ | `tidy` | `true` | 发出去的文字按她的聊天口吻整理:去掉行末句号、引号、破折号、冒号、星号、井号(网址和时间不动)。关掉就原样发 |
49
50
  | `sendPolicy` | `reply` | `qq_send` 审批:`reply`(见上表)/ `always`(除了你,发谁都问)/ `off`(不问) |
50
51
  | `replyWindowMinutes` | `30` | `reply` 策略里"最近给她发过消息"的时间窗 |
51
52
  | `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.9.0",
3
+ "version": "0.9.3",
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",
@@ -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', 'mcp__vm__sandbox_execute_bash', 'mcp__vm__sandbox_execute_code'],
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: ['mcp__vm__sandbox_file_operations', 'mcp__vm__sandbox_str_replace_editor'],
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 mcp__vm__ tool is audited once as unknown and treated like them. */
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('mcp__vm__') ? tool.slice('mcp__vm__'.length) : '';
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('mcp__vm__')) return;
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(/^mcp__vm__/, '')));
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('mcp__vm__') ? exec.name.slice('mcp__vm__'.length) : '';
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' });
@@ -2,6 +2,7 @@
2
2
  // Backend: a microsandbox microVM by default (bundled, no Docker needed), Docker as fallback.
3
3
  // The service is provided immediately so tools register at boot; `ready` settles once the VM
4
4
  // answers. Disposal never stops the machine: files, logins and running apps outlive dsh restarts.
5
+ import { VM_SERVER, VM_TOOL_PREFIX } from '../tool-prefixes.js';
5
6
  import http from 'node:http';
6
7
  import { appendFileSync, existsSync, mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
7
8
  import { homedir } from 'node:os';
@@ -30,7 +31,7 @@ export const defaults = {
30
31
  publicUrl: '',
31
32
  // Gateway key handed to the VM as SANDBOX_API_KEY; '' = one generated per machine ($DSH_HOME/dsh-computer.key).
32
33
  apiKey: '',
33
- // Mount the VM's browser/desktop tools (mcp__vm__*) through dsh-mcp-client with the key attached.
34
+ // Mount the VM's browser/desktop tools (mcp__dot-vm__*) through dsh-mcp-client with the key attached.
34
35
  mcp: true,
35
36
  mcpToolCallTimeoutMs: 120_000,
36
37
  // Turn off AIO services the agent does not use (Jupyter, code-server, Node REPLs).
@@ -291,19 +292,19 @@ export function apply(ctx, config = {}) {
291
292
  return () => { view.close(); computer.liveViewUrl = undefined; };
292
293
  }));
293
294
 
294
- // The VM's browser/desktop tools (mcp__vm__*): mounted here, not in cordis.patch.yml, so the
295
+ // The VM's browser/desktop tools (mcp__dot-vm__*): mounted here, not in cordis.patch.yml, so the
295
296
  // client carries the gateway key (the gate in gate.js covers these tools like any other).
296
297
  let mcpFork = null;
297
298
  async function mountMcp() {
298
299
  if (!cfg.mcp || mcpFork) return;
299
300
  let mcpClient;
300
- try { mcpClient = config.mcpClient ?? await import('@deepseek-ai/dsh-mcp-client'); } catch (err) { logger.error(`mcp__vm__* unavailable: ${err.message}`); return; }
301
+ try { mcpClient = config.mcpClient ?? await import('@deepseek-ai/dsh-mcp-client'); } catch (err) { logger.error(`${VM_TOOL_PREFIX}* unavailable: ${err.message}`); return; }
301
302
  mcpFork = ctx.plugin(mcpClient, {
302
- serverName: 'vm', transport: 'streamable-http', url: computer.mcpUrl,
303
+ serverName: VM_SERVER, transport: 'streamable-http', url: computer.mcpUrl,
303
304
  headers: { ...computer.authHeaders(), authorization: `Bearer ${apiKey}` },
304
305
  toolCallTimeoutMs: cfg.mcpToolCallTimeoutMs, failOnStartupError: false, reconnect: { maxAttempts: 1000 },
305
306
  });
306
- logger.info('mcp__vm__* mounted (gateway key attached)');
307
+ logger.info(`${VM_TOOL_PREFIX}* mounted (gateway key attached)`);
307
308
  }
308
309
  computer.mcpMounted = () => Boolean(mcpFork);
309
310
  ctx.effect?.(() => () => { mcpFork?.dispose?.(); mcpFork = null; }, 'dsh-dot/computer: mcp client');
package/src/dot/core.js CHANGED
@@ -12,6 +12,7 @@
12
12
  // 2. an approval asked during such a turn is announced on IM with the live-view link;
13
13
  // 3. dsh-budget blocks are announced on IM, and the `daily` block is lifted at local midnight;
14
14
  // 4. VM failures are announced on IM; /dot shows the status.
15
+ import { PHONE_TOOL_PREFIX, VM_TOOL_PREFIX } from '../tool-prefixes.js';
15
16
  import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
16
17
  import { homedir } from 'node:os';
17
18
  import { join, relative, isAbsolute } from 'node:path';
@@ -88,11 +89,11 @@ export const SCHEDULED_RULE = '这一轮由定时任务触发,用户不在对
88
89
  /** Standing working rules for sessions in <home>: a prompt section, so no AGENTS.md is needed. */
89
90
  export const workingRules = ({ computer = true, phone = false } = {}) => [
90
91
  '# dot 的工作方式',
91
- [computer ? '你有一台自己的电脑(虚拟机):命令和浏览器都在那台电脑里运行,用户可以随时看到实时画面。' : '', phone ? '你有一部自己的手机(Android):App 都在手机上,用 mcp__phone__* 操作。' : '', '用户主要在 IM 里和你说话。'].filter(Boolean).join(''),
92
+ [computer ? '你有一台自己的电脑(虚拟机):命令和浏览器都在那台电脑里运行,用户可以随时看到实时画面。' : '', phone ? `你有一部自己的手机(Android):App 都在手机上,用 ${PHONE_TOOL_PREFIX}* 操作。` : '', '用户主要在 IM 里和你说话。'].filter(Boolean).join(''),
92
93
  '- 定时任务:用户的要求里只要带有未来的时间点或周期("2 分钟后"、"明天早上"、"每天 8 点"、"每周一"),一律用 `schedule_create` 建任务(带时区),现在不要去做。建好后只回复任务内容和触发时间。到点你会收到提醒,那时再去做。',
93
94
  `- 静默协议:被定时任务叫醒时,如果检查后没有值得告诉用户的内容,最终回复只写 ${SILENT},这条不会发给用户。有内容就简要说,附链接。用户主动跟你说话时,正常回复。`,
94
- computer ? '- 用你的电脑:网页在你电脑的浏览器里打开(`mcp__vm__browser_*` 工具),需要登录、扫码或验证码时,告诉用户并请他在实时画面里接管。' : '',
95
- phone ? '- 用你的手机:App 里的事在手机上做(`mcp__phone__*` 工具);遇到验证码、人脸、短信验证就停下来告诉用户。' : '',
95
+ computer ? `- 用你的电脑:网页在你电脑的浏览器里打开(\`${VM_TOOL_PREFIX}browser_*\` 工具),需要登录、扫码或验证码时,告诉用户并请他在实时画面里接管。` : '',
96
+ phone ? `- 用你的手机:App 里的事在手机上做(\`${PHONE_TOOL_PREFIX}*\` 工具);遇到验证码、人脸、短信验证就停下来告诉用户。` : '',
96
97
  '- 花钱和危险操作:付款、删除、对外发消息等都会弹审批,等用户批准;不要试图绕过。',
97
98
  '- 长一点的事:别人当面交给你一件一轮做不完的事("长任务""慢慢来""多逛逛""把能找到的都……""每 N 个跟我说一声"),即使他没说"目标",也用 `create_goal` 建一个目标——它会让你在这个会话里一轮接一轮地自动继续,直到你把它标记完成。先回一句收到;每做完一段就汇报一次;标记完成前先确认整件事真的做完了,没做完就留着让下一轮继续。一轮就能做完的事不用建目标。',
98
99
  '- 回复可以拆成几句很短的话,一句一行(IM 里直接投递,不要写 <sep/> 之类的分隔标记)。',
@@ -298,12 +299,14 @@ export function apply(ctx, config = {}) {
298
299
  return;
299
300
  }
300
301
  if (event.type === 'turn/start') {
301
- turns.set(id, { turn: event.data?.turn, scheduled: incoming.delete(id), text: '' });
302
+ turns.set(id, { turn: event.data?.turn, scheduled: incoming.delete(id), text: '', startedAt: Date.now() });
302
303
  return;
303
304
  }
304
305
  const t = turns.get(id);
305
306
  if (!t) return;
306
307
  if (event.type === 'user/message' && event.data?.source?.kind === 'schedule') { t.scheduled = true; return; }
308
+ // His words came over his QQ: the turn's answer goes back there (unless she already sent one herself).
309
+ if (event.type === 'user/message' && /^qq-/.test(String(event.data?.source?.rpcId ?? ''))) { t.fromQq = true; return; }
307
310
  const ended = event.type === 'turn/end' && (event.data?.turn === undefined || event.data.turn === t.turn);
308
311
  if (ended) {
309
312
  turns.delete(id); // every turn, scheduled or not: `turns` is also "is she busy right now"
@@ -322,7 +325,7 @@ export function apply(ctx, config = {}) {
322
325
  }
323
326
  return;
324
327
  }
325
- if (!t.scheduled) return;
328
+ if (!t.scheduled && !t.fromQq) return;
326
329
  if (event.type === 'assistant/message' && !event.data?.interrupted) {
327
330
  const text = contentText(event.data?.message?.content);
328
331
  if (text.trim()) t.text = text; // the last non-empty reply of the turn is its answer
@@ -330,7 +333,7 @@ export function apply(ctx, config = {}) {
330
333
  }
331
334
  if (event.type === 'approval/asked') {
332
335
  // Payload: { id, toolName, reason? }. dsh-computer's gate puts the live-view link in reason.
333
- const onPhone = String(event.data?.toolName ?? '').startsWith('mcp__phone__');
336
+ const onPhone = String(event.data?.toolName ?? '').startsWith(PHONE_TOOL_PREFIX);
334
337
  const vm = (onPhone ? phone()?.status?.() : computer()?.status?.()) ?? {};
335
338
  const link = vm.publicLiveViewUrl || vm.liveViewUrl;
336
339
  const reason = String(event.data?.reason ?? '').trim();
@@ -343,6 +346,13 @@ export function apply(ctx, config = {}) {
343
346
  if (ended) {
344
347
  const text = t.text.trim();
345
348
  if (!text || isSilent(text)) { audit('silent', { session: id }); return; }
349
+ if (t.fromQq && !t.scheduled) {
350
+ // She answered him in the conversation; if no qq_send to him happened during the turn, relay it.
351
+ const q = ctx.get('dshQq');
352
+ if (!q?.connected || (q.sentToOwnerAt ?? 0) >= t.startedAt) { audit('qq-answered-herself', { session: id }); return; }
353
+ q.send('owner', stripSilent(text)).then((r) => audit('qq-relayed', { session: id, sent: r.sent }), (err) => { logger.warn(`qq relay failed: ${err.message}`); audit('qq-relay-failed', { session: id, error: err.message }); });
354
+ return;
355
+ }
346
356
  void im.send(stripSilent(text)).then((sent) => audit('delivered', { session: id, sent }));
347
357
  }
348
358
  });
@@ -15,6 +15,7 @@
15
15
  // continuity snapshot (state.json), intents; slow change in who she is lives in dsh-dot/memory's self bank
16
16
  // (intents.json). Not ported: long-term facts with retrieval, Alter (mood drift), Perspective,
17
17
  // multi-participant stories, seen/delayed replies inside a conversation.
18
+ import { VM_TOOL_PREFIX, PHONE_TOOL_PREFIX } from '../tool-prefixes.js';
18
19
  import { appendFileSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
19
20
  import { homedir } from 'node:os';
20
21
  import { join, relative, isAbsolute } from 'node:path';
@@ -112,7 +113,7 @@ export function playPrompt(p, pkg) {
112
113
  const verb = { like: '点个赞', comment: '评论一句', follow: '关注' }[p.action] ?? p.action;
113
114
  return [
114
115
  `[想玩会儿手机] 你刚才想:在${p.app}${pkg ? `(${pkg})` : ''}给「${p.target}」${verb}${p.text ? `,想说的是:「${p.text}」` : ''}。${p.why ? `因为${p.why}。` : ''}`,
115
- '去做吧,用你的手机(mcp__phone__*)。只做这一件,顺手看看就行;不发新帖、不私信陌生人、不花钱、不改资料。做不成就算了,别硬来。',
116
+ `去做吧,用你的手机(${PHONE_TOOL_PREFIX}*)。只做这一件,顺手看看就行;不发新帖、不私信陌生人、不花钱、不改资料。做不成就算了,别硬来。`,
116
117
  PLAY_RULES,
117
118
  '做完把手机放回桌面(HOME),只回一句你做了什么,或者 DOT_SILENT。',
118
119
  ].join('\n');
@@ -147,8 +148,8 @@ export function observationPrompt(b, device = 'vm', app = '') {
147
148
  ? (app ? `打开你手机上的 App(${app})看看:${b.purpose || b.query || b.url}` : b.mode === 'visit' ? `用手机打开这个页面看看:${b.url}` : `在手机上搜一下:${b.query}`)
148
149
  : (b.mode === 'visit' ? `打开这个页面看看:${b.url}` : `在浏览器里搜一下:${b.query}`);
149
150
  const tools = device === 'phone'
150
- ? '用你的手机(mcp__phone__*)只看不动:打开 App、滑动、点进去看、截图都可以;不要输入文字、不要登录、不要点赞/关注/评论/发帖/下单、不要装卸 App。'
151
- : '用你电脑里的浏览器(mcp__vm__browser_*)只看不动:打开、滚动、读文字或截图都可以;不要登录、不要点赞/关注/评论/发帖/下单、不要填任何表单、不要下载。';
151
+ ? `用你的手机(${PHONE_TOOL_PREFIX}*)只看不动:打开 App、滑动、点进去看、截图都可以;不要输入文字、不要登录、不要点赞/关注/评论/发帖/下单、不要装卸 App。`
152
+ : `用你电脑里的浏览器(${VM_TOOL_PREFIX}browser_*)只看不动:打开、滚动、读文字或截图都可以;不要登录、不要点赞/关注/评论/发帖/下单、不要填任何表单、不要下载。`;
152
153
  return [
153
154
  '[幕间观察] 这不是一次对话,是你自己想去看一眼:' + (b.purpose ? `「${b.purpose}」` : ''),
154
155
  where,
@@ -670,8 +671,8 @@ export function apply(ctx, config = {}) {
670
671
  ctx.on('tools/pre-execute', async (exec, next) => {
671
672
  const sessionId = exec.agent?.session?.id;
672
673
  if (!sessionId || !observing.has(sessionId)) return next();
673
- const vmTool = exec.name.startsWith('mcp__vm__') ? exec.name.slice('mcp__vm__'.length) : '';
674
- const phoneTool = exec.name.startsWith('mcp__phone__') ? exec.name.slice('mcp__phone__'.length) : '';
674
+ const vmTool = exec.name.startsWith(VM_TOOL_PREFIX) ? exec.name.slice(VM_TOOL_PREFIX.length) : '';
675
+ const phoneTool = exec.name.startsWith(PHONE_TOOL_PREFIX) ? exec.name.slice(PHONE_TOOL_PREFIX.length) : '';
675
676
  if ((vmTool && cfg.vmObservationTools.includes(vmTool)) || (phoneTool && cfg.phoneObservationTools.includes(phoneTool))) return { kind: 'allow' };
676
677
  audit('observation-refused', { session: sessionId, tool: exec.name });
677
678
  return { kind: 'deny', reason: `dsh-interlude: this is an observation — looking only, nothing to approve. "${exec.name}" is not available here; look with ${cfg.vmObservationTools.slice(0, 2).join(', ')}, ${cfg.phoneObservationTools.slice(5, 7).join(', ')}… or write down what you saw.` };
@@ -936,6 +937,8 @@ export function apply(ctx, config = {}) {
936
937
 
937
938
  // For the panel (dsh-dot/dot): where her life stands, as data.
938
939
  ctx.provide?.('dshInterlude', {
940
+ /** One line on who she is (for the QQ group scorer): name + the character profile. */
941
+ who() { const sd = canon?.storyDefaults ?? {}; return `${sd.characterName ?? 'dot'}:${String(sd.characterProfile ?? '').replace(/\s+/g, ' ').slice(0, 240)}`; },
939
942
  status() {
940
943
  rollDay();
941
944
  const script = (() => { let t = ''; try { t = readFileSync(files.script, 'utf8'); } catch (error) { void error; } return t.split(/^## /m).filter((x) => x.trim()).slice(-2).map((x) => { const [head, ...body] = x.split('\n'); return { head: head.trim(), text: body.join('\n').trim() }; }); })();
@@ -40,6 +40,14 @@ export const defaults = {
40
40
  dailyAt: '23:30', // once a day, after her active hours: consolidate whatever is new and write her diary
41
41
  maxTokens: 16384,
42
42
  limits: DEFAULT_LIMITS,
43
+ // Living next to another memory plugin. full: everything on. people-only: keep people, fragments
44
+ // and the diary, but leave the owner/self banks (prompt text and consolidation) to the other one,
45
+ // so two plugins do not both narrate what she knows about him. auto: people-only when one of
46
+ // otherMemoryServices is provided (cordis has no public way to list services, so it is a list).
47
+ coexist: 'auto',
48
+ // Names other memory plugins provide. A bare 'memory' is deliberately not here: too generic a name
49
+ // to risk silencing her own banks because something unrelated provides it. Add names as you meet them.
50
+ otherMemoryServices: ['hermesMemory', 'autoMemory', 'dshMemory', 'memoryBank'],
43
51
  };
44
52
 
45
53
  export const HANDOFF_SOURCE = Object.freeze({ kind: 'handoff' });
@@ -193,6 +201,15 @@ export function apply(ctx, config = {}) {
193
201
  const files = { memory: join(dir, 'memory.json'), md: join(dir, 'memory.md'), transcript: join(dir, 'transcript.jsonl'), handoffs: join(dir, 'handoffs.jsonl'), calls: join(dir, 'calls.jsonl'), diary: join(dir, 'diary.md') };
194
202
  mkdirSync(dir, { recursive: true });
195
203
  const dot = () => ctx.get('dshDot');
204
+ // Checked when used, not once at boot: the other plugin may start after this one.
205
+ let coexistLogged = false;
206
+ const peopleOnly = () => {
207
+ if (cfg.coexist === 'people-only') return true;
208
+ if (cfg.coexist !== 'auto') return false;
209
+ const other = [].concat(cfg.otherMemoryServices ?? []).find((n) => { try { return ctx.get(n) != null; } catch { return false; } });
210
+ if (other && !coexistLogged) { coexistLogged = true; logger.info(`another memory service (${other}) is present: people-only mode (owner/self banks left to it)`); }
211
+ return Boolean(other);
212
+ };
196
213
  const audit = (event, data = {}) => (ctx.get('dshComputer')?.audit ?? ctx.get('dshPhone')?.audit)?.({ kind: 'memory', event, ...data });
197
214
 
198
215
  let memory;
@@ -345,6 +362,7 @@ export function apply(ctx, config = {}) {
345
362
  const sel = ctx.agentDefaultModel?.currentSelection?.() ?? {};
346
363
  if (!ctx.llm?.stream || !sel.model) return { skipped: 'no model' };
347
364
  const text = fresh.map(transcriptLine).join('\n');
365
+ const bankless = peopleOnly();
348
366
  // A handoff with little new: the last stretch of the conversation, so the handoff can be written.
349
367
  const recent = withHandoff && fresh.length < 30 ? lines.filter((l) => l.at <= memory.cursor).slice(-(30 - fresh.length)).map(transcriptLine).join('\n') : '';
350
368
  const known = Object.values(memory.people).filter((p) => p.tier !== 'contact').map((p) => `${p.id} · ${p.names.join('/') || '(无名)'} · ${p.handles.join(', ')} · ${p.tier}`).join('\n');
@@ -352,8 +370,9 @@ export function apply(ctx, config = {}) {
352
370
  const prompt = [
353
371
  ...(recent ? ['=== 更早一点的对话(已经整理过,只用来写 handoff,别重复记)===', clip(recent, 12000), ''] : []),
354
372
  '=== 这段时间的记录 ===', text || '(这段时间没有新记录)', '',
355
- '=== 已有:关于他 ===', memory.owner.map((e) => `- ${e}`).join('\n') || '(空)',
356
- '=== 已有:她自己记下的 ===', memory.self.map((e) => `- ${e}`).join('\n') || '(空)',
373
+ ...(bankless ? ['=== 关于他 / 她自己记下的 ===', '(由别的记忆插件负责:owner 和 self 都给 [])'] : [
374
+ '=== 已有:关于他 ===', memory.owner.map((e) => `- ${e}`).join('\n') || '(空)',
375
+ '=== 已有:她自己记下的 ===', memory.self.map((e) => `- ${e}`).join('\n') || '(空)']),
357
376
  '=== 已认识的人 ===', known || '(还没有)',
358
377
  '=== 已有碎片 ===', frags || '(还没有)',
359
378
  '=== 待核实(关于别人的事,说过一次)===', memory.pending.slice(-30).map((x) => `${x.id} | ${x.person} | ${x.text}`).join('\n') || '(没有)', '',
@@ -380,6 +399,7 @@ export function apply(ctx, config = {}) {
380
399
  try { appendFileSync(files.calls, `${JSON.stringify({ at: new Date().toISOString(), reason, lines: fresh.length, usage: spent, reply: clip(raw, 4000) })}\n`); } catch (error) { void error; }
381
400
  const out = parseLooseJson(raw);
382
401
  if (!out) { audit('consolidate-unparsed', { reason }); return { error: 'reply was not JSON' }; }
402
+ if (bankless) { delete out.owner; delete out.self; }
383
403
  const report = applyExtraction(memory, out, { limits: cfg.limits });
384
404
  memory.cursor = fresh.at(-1)?.at ?? memory.cursor;
385
405
  memory.consolidations++;
@@ -469,7 +489,7 @@ export function apply(ctx, config = {}) {
469
489
  text: (c) => {
470
490
  const s = c.agent?.session;
471
491
  if (!s || !(dot()?.isErrand?.(s.id) || isConversation(s.id, s.header?.cwd))) return '';
472
- return renderStanding(memory, { budgetTokens: cfg.fragmentBudgetTokens });
492
+ return renderStanding(memory, { budgetTokens: cfg.fragmentBudgetTokens, banks: !peopleOnly() });
473
493
  },
474
494
  });
475
495
  });
@@ -461,10 +461,11 @@ export function normalizeMemory(m) {
461
461
  * What every turn of hers sees: you, her own notes, what still matters. Byte-stable for the same
462
462
  * memory (no clocks, no counters), because a context snapshot is re-sent only when its text changes.
463
463
  */
464
- export function renderStanding(memory, { budgetTokens = 600 } = {}) {
464
+ export function renderStanding(memory, { budgetTokens = 600, banks = true } = {}) {
465
465
  const parts = [];
466
- if (memory.owner.length) parts.push(`## 关于他\n${memory.owner.map((e) => `- ${e}`).join('\n')}`);
467
- if (memory.self.length) parts.push(`## 你自己记下的\n${memory.self.map((e) => `- ${e}`).join('\n')}`);
466
+ // banks: false when another memory plugin narrates the owner/self memories (coexist people-only).
467
+ if (banks && memory.owner.length) parts.push(`## 关于他\n${memory.owner.map((e) => `- ${e}`).join('\n')}`);
468
+ if (banks && memory.self.length) parts.push(`## 你自己记下的\n${memory.self.map((e) => `- ${e}`).join('\n')}`);
468
469
  const picked = selectFragments(memory.fragments, budgetTokens);
469
470
  if (picked.length) parts.push(`## 最近的事(越靠前越要紧)\n${picked.map((f) => `- ${f.pinned ? '📌' : ''}${f.text}`).join('\n')}`);
470
471
  if (!parts.length) return '';
@@ -1,9 +1,10 @@
1
1
  // dsh-dot/phone: the character's own phone — an Android emulator this plugin installs, boots and
2
- // keeps alive, exposed to the model as mcp__phone__* (mobile-mcp over adb). Nothing to install by
2
+ // keeps alive, exposed to the model as mcp__dot-phone__* (mobile-mcp over adb). Nothing to install by
3
3
  // hand: on first start the plugin fetches the emulator, platform-tools and one system image from
4
4
  // Google's repository (after the SDK license is accepted), writes the AVD itself (no Java, no
5
5
  // sdkmanager), boots it, and mounts the MCP server once the phone answers. The phone's window is its
6
6
  // live view; state (apps, logins) lives in the AVD's data partition and survives dsh restarts.
7
+ import { PHONE_SERVER, PHONE_TOOL_PREFIX } from '../tool-prefixes.js';
7
8
  import { spawn, execFile } from 'node:child_process';
8
9
  import { chmodSync, closeSync, createWriteStream, existsSync, openSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync, appendFileSync } from 'node:fs';
9
10
  import { homedir, platform, arch as osArch } from 'node:os';
@@ -54,7 +55,7 @@ export const defaults = {
54
55
  notifyPollMs: 4000, // reconcile snapshot interval (events trigger immediate reads); 0 = events only
55
56
  notifyApps: [], // [] = every app she installs, now or later, until muted
56
57
  notifyMuted: [], // packages whose notifications never wake her (also /phone notify mute <pkg>, persisted)
57
- mcp: true, // mount mobile-mcp as mcp__phone__*
58
+ mcp: true, // mount mobile-mcp as mcp__dot-phone__*
58
59
  toolCallTimeoutMs: 60_000,
59
60
  // Gate: phone tools that are asked for approval (dsh-computer-style), and typed text that is.
60
61
  askTools: ['mobile_install_app', 'mobile_uninstall_app'],
@@ -142,8 +143,8 @@ export function avdConfig({ avd, api, tag, abi, device, ramMb, dataGb }) {
142
143
 
143
144
  /** Approval decision for a phone tool call (null = allow). */
144
145
  export function phoneGate(exec, cfg) {
145
- if (!exec.name.startsWith('mcp__phone__')) return null;
146
- const tool = exec.name.slice('mcp__phone__'.length);
146
+ if (!exec.name.startsWith(PHONE_TOOL_PREFIX)) return null;
147
+ const tool = exec.name.slice(PHONE_TOOL_PREFIX.length);
147
148
  if (cfg.askTools.includes(tool)) return `dsh-dot/phone: ${tool}`;
148
149
  if (tool === 'mobile_type_keys') {
149
150
  const text = JSON.stringify(exec.input ?? exec.args ?? exec.arguments ?? {});
@@ -406,14 +407,14 @@ export function apply(ctx, config = {}, deps = {}) {
406
407
  try {
407
408
  entry = createRequire(import.meta.url).resolve('@mobilenext/mobile-mcp/lib/index.js');
408
409
  mcpClient = deps.mcpClient ?? await import('@deepseek-ai/dsh-mcp-client');
409
- } catch (err) { logger.error(`mcp__phone__* unavailable: ${err.message}`); return; }
410
+ } catch (err) { logger.error(`${PHONE_TOOL_PREFIX}* unavailable: ${err.message}`); return; }
410
411
  mcpFork = ctx.plugin(mcpClient, {
411
- transport: 'stdio', serverName: 'phone', command: process.execPath, args: [entry], cwd: home,
412
+ transport: 'stdio', serverName: PHONE_SERVER, command: process.execPath, args: [entry], cwd: home,
412
413
  // ELECTRON_RUN_AS_NODE: inside the desktop app process.execPath is Electron; this makes it run as plain Node.
413
414
  env: { ANDROID_HOME: home, ANDROID_SDK_ROOT: home, ANDROID_SERIAL: serial, ELECTRON_RUN_AS_NODE: '1' },
414
415
  toolCallTimeoutMs: cfg.toolCallTimeoutMs, failOnStartupError: false, reconnect: { maxAttempts: 1000 },
415
416
  });
416
- logger.info('mcp__phone__* mounted (mobile-mcp over adb)');
417
+ logger.info(`${PHONE_TOOL_PREFIX}* mounted (mobile-mcp over adb)`);
417
418
  }
418
419
  /** Is this AVD already up (left from a previous dsh run)? Then attach instead of launching twice. */
419
420
  async function alreadyRunning() {
@@ -497,7 +498,7 @@ export function apply(ctx, config = {}, deps = {}) {
497
498
  name: 'phone:device',
498
499
  order: 60,
499
500
  text: () => (phone.state === 'ready'
500
- ? `你有一部自己的手机:Android(设备 ${serial},工具 mcp__phone__*)。手机上来了通知(QQ 消息之类)会直接叫醒你,用不着定闹钟去看——但 App 开在前台时不会有通知,所以每次用完 App 记得按 HOME 回到桌面。用法:先 mobile_list_elements_on_screen 看屏幕上有什么(带坐标),再 mobile_click_on_screen_at_coordinates 点;看不清就 mobile_take_screenshot;mobile_launch_app 打开 App,mobile_press_button BACK/HOME 返回。这部手机没有应用商店:想要什么 App 就像人一样自己装——用手机上的浏览器打开官网下载安装包,点开安装(浏览器已被允许安装)。登录、验证码、人脸、短信验证由用户来做:停下来告诉他,不要自己绕。`
501
+ ? `你有一部自己的手机:Android(设备 ${serial},工具 ${PHONE_TOOL_PREFIX}*)。手机上来了通知(QQ 消息之类)会直接叫醒你,用不着定闹钟去看——但 App 开在前台时不会有通知,所以每次用完 App 记得按 HOME 回到桌面。用法:先 mobile_list_elements_on_screen 看屏幕上有什么(带坐标),再 mobile_click_on_screen_at_coordinates 点;看不清就 mobile_take_screenshot;mobile_launch_app 打开 App,mobile_press_button BACK/HOME 返回。这部手机没有应用商店:想要什么 App 就像人一样自己装——用手机上的浏览器打开官网下载安装包,点开安装(浏览器已被允许安装)。登录、验证码、人脸、短信验证由用户来做:停下来告诉他,不要自己绕。`
501
502
  : ''),
502
503
  }), 'dsh-dot/phone: device section');
503
504
  });
package/src/qq/qq.js CHANGED
@@ -24,7 +24,17 @@ export const defaults = {
24
24
  installer: 'https://raw.githubusercontent.com/NapNeko/NapCat-Installer/main/script/install.sh',
25
25
  githubProxy: '', // mirror prefix for the installer's GitHub downloads, e.g. https://ghfast.top/ ; '' = direct
26
26
  autoStart: true, // start NapCat when the computer is ready and the account is set
27
- groupPolicy: 'mention', // group messages that wake her: 'mention' (@her), 'all', 'none'
27
+ groupPolicy: 'mention', // group messages that wake her: 'mention' (@her), 'all', 'none', 'score' (see below)
28
+ // groupPolicy 'score': a group message that does not @ her is rated 0–10 by a short model call
29
+ // (is this worth her chiming in, given who she is and the last few lines?); at or above the
30
+ // threshold it wakes her like a mention. @-mentions always count. Rated with the current model
31
+ // unless scoreModel names one ("provider/model"); at most scoreMaxPerMinute calls per group.
32
+ scoreThreshold: 7,
33
+ scoreModel: '',
34
+ scoreMaxPerMinute: 6,
35
+ // Outgoing text is tidied to her chat voice: no 。at line ends, no quotes/dashes/colons/asterisks/
36
+ // hashes (times and URLs keep theirs). Off = send exactly what the model wrote.
37
+ tidy: true,
28
38
  // qq_send approval: 'reply' (default) lets her write to the owner, and answer with text or web
29
39
  // images whoever wrote to her within replyWindowMinutes (a conversation, group or private); anything
30
40
  // else asks — a new contact, a group nobody spoke in, or files from her phone or computer (those
@@ -109,11 +119,36 @@ export function sendGate({ to, text = '', images = [] }, { owner, policy = 'repl
109
119
  return `dsh-dot/qq: message to ${who}, who has not written to her recently: ${String(text).slice(0, 80)}`;
110
120
  }
111
121
 
122
+ /**
123
+ * Her chat voice, enforced where it matters: the text that leaves for QQ. Removes the punctuation a
124
+ * real chat never types (full stops at line ends, quotes, dashes, colons, asterisks, hashes), keeps
125
+ * URLs and clock times intact, collapses the gaps left behind. Line structure is kept.
126
+ */
127
+ export function tidyVoice(text) {
128
+ return String(text ?? '').split('\n').map((line) => {
129
+ const keep = [];
130
+ let t = line.replace(/https?:\/\/\S+|\b\d{1,2}:\d{2}(:\d{2})?\b/g, (m) => { keep.push(m); return `\u0000${keep.length - 1}\u0000`; });
131
+ t = t.replace(/[“”"‘’「」『』]/g, '').replace(/[—–]+|--+/g, ' ').replace(/[::]/g, ' ').replace(/[*#]/g, '');
132
+ t = t.replace(/[。.]+(?=\s|$)/g, '').replace(/[。.]/g, ' ');
133
+ t = t.replace(/[ \t]{2,}/g, ' ').trim();
134
+ return t.replace(/\u0000(\d+)\u0000/g, (_, i) => keep[Number(i)]);
135
+ }).join('\n').replace(/\n{3,}/g, '\n\n').trim();
136
+ }
137
+
138
+ /** The scoring prompt for groupPolicy 'score': who she is (short), the last lines, the message. */
139
+ export function scorePrompt({ who, recent, message, group }) {
140
+ return {
141
+ system: `你是一个群聊的过滤器。判断下面这条群消息值不值得「她」插一句话。她是:${who || '一个话少、直接、有自己看法的群友'}。只有和她直接相关、问到她、她明显有话可说、或者她插嘴会很自然的消息才值得;寒暄、刷屏、与她无关的闲聊、纯表情、广告都不值得。只回一个 0 到 10 的整数,不要任何别的字。`,
142
+ user: `群 ${group} 最近几条:\n${recent || '(无)'}\n\n这条:${message}`,
143
+ };
144
+ }
145
+
112
146
  /** Does a group message count, under the policy? */
113
147
  export function groupWanted(ev, policy, selfId) {
114
148
  if (policy === 'all') return true;
115
149
  if (policy === 'none') return false;
116
- return (Array.isArray(ev.message) ? ev.message : []).some((s) => s?.type === 'at' && String(s.data?.qq) === String(selfId));
150
+ const mentioned = (Array.isArray(ev.message) ? ev.message : []).some((s) => s?.type === 'at' && String(s.data?.qq) === String(selfId));
151
+ return mentioned ? true : policy === 'score' ? 'score' : false;
117
152
  }
118
153
 
119
154
  /** NapCat's OneBot 11 config for this account: one WebSocket server on loopback, token required. */
@@ -155,7 +190,7 @@ export function apply(ctx, config = {}, deps = {}) {
155
190
  const computer = () => ctx.get('dshComputer');
156
191
  let WebSocketImpl = deps.WebSocket; // the `ws` package, loaded on first connect (tests inject a fake)
157
192
 
158
- const qq = { state: 'idle', error: undefined, connected: false, selfId: '', qq: cfg.qq, owner: cfg.owner, audit };
193
+ const qq = { state: 'idle', error: undefined, connected: false, selfId: '', qq: cfg.qq, owner: cfg.owner, audit, sentToOwnerAt: 0 };
159
194
  const listeners = new Set();
160
195
  qq.onMessage = (fn) => { listeners.add(fn); return () => listeners.delete(fn); };
161
196
  qq.status = () => ({ state: qq.state, connected: qq.connected, qq: qq.qq, owner: qq.owner, selfId: qq.selfId, error: qq.error, wsPort: cfg.wsPort });
@@ -347,15 +382,51 @@ export function apply(ctx, config = {}, deps = {}) {
347
382
  const text = segmentsToText(ev.message, selfId);
348
383
  if (!text) return;
349
384
  const isGroup = ev.message_type === 'group';
350
- if (isGroup && !groupWanted(ev, cfg.groupPolicy, selfId)) return;
351
385
  const who = ev.sender?.card || ev.sender?.nickname || String(ev.user_id);
386
+ const wanted = isGroup ? groupWanted(ev, cfg.groupPolicy, selfId) : true;
387
+ if (isGroup) {
388
+ // The last lines of each group, for the scorer's context (kept whether or not she is woken).
389
+ const g = groupLines.get(String(ev.group_id)) ?? [];
390
+ g.push(`${who}:${text.slice(0, 120)}`); while (g.length > 8) g.shift(); groupLines.set(String(ev.group_id), g);
391
+ }
392
+ if (!wanted) return;
352
393
  const fromOwner = !isGroup && Boolean(qq.owner) && String(ev.user_id) === String(qq.owner);
353
394
  const msg = { kind: isGroup ? 'group' : 'private', userId: String(ev.user_id), groupId: isGroup ? String(ev.group_id) : '', who, text, fromOwner, at: new Date().toISOString(), messageId: ev.message_id };
354
395
  recent.set(isGroup ? `group:${msg.groupId}` : `user:${msg.userId}`, Date.now());
355
396
  if (recent.size > 500) recent.delete(recent.keys().next().value);
356
- audit({ kind: 'message', ...msg, text: text.slice(0, 200) });
397
+ if (wanted === 'score') { void scoreAndDeliver(msg); return; }
398
+ deliver(msg);
399
+ }
400
+ function deliver(msg) {
401
+ audit({ kind: 'message', ...msg, text: msg.text.slice(0, 200) });
357
402
  for (const fn of listeners) { try { fn(msg); } catch (err) { logger.warn(`qq listener: ${err.message}`); } }
358
403
  }
404
+ /** groupPolicy 'score': one short model call decides whether this group message wakes her. */
405
+ const groupLines = new Map();
406
+ const scoreBudget = new Map(); // group → [timestamps of calls in the last minute]
407
+ async function scoreAndDeliver(msg) {
408
+ const llm = ctx.get?.('llm');
409
+ const sel = (() => { try { return ctx.get?.('agentDefaultModel')?.currentSelection?.(); } catch { return null; } })();
410
+ if (!llm?.stream) return;
411
+ const now = Date.now();
412
+ const used = (scoreBudget.get(msg.groupId) ?? []).filter((t) => now - t < 60_000);
413
+ if (used.length >= cfg.scoreMaxPerMinute) { audit({ kind: 'group-score-skipped', group: msg.groupId, why: 'budget' }); return; }
414
+ used.push(now); scoreBudget.set(msg.groupId, used);
415
+ const [provider, model] = cfg.scoreModel ? [cfg.scoreModel.split('/')[0], cfg.scoreModel.split('/').slice(1).join('/')] : [sel?.provider, sel?.model];
416
+ if (!provider || !model) return;
417
+ const lines = (groupLines.get(msg.groupId) ?? []).slice(0, -1).join('\n');
418
+ const who = (() => { try { return String(ctx.get?.('dshInterlude')?.who?.() ?? '').slice(0, 300); } catch { return ''; } })();
419
+ const { system, user } = scorePrompt({ who, recent: lines, message: `${msg.who}:${msg.text.slice(0, 300)}`, group: msg.groupId });
420
+ let text = '';
421
+ try {
422
+ for await (const chunk of llm.stream({ provider, model, system, maxTokens: 8, messages: [{ role: 'user', content: [{ type: 'text', text: user }] }] })) {
423
+ if (chunk?.type === 'text-delta') text += chunk.text ?? chunk.delta ?? '';
424
+ }
425
+ } catch (err) { logger.debug(`group score failed: ${err.message}`); return; }
426
+ const score = Number((/\d+/.exec(text) ?? [NaN])[0]);
427
+ audit({ kind: 'group-score', group: msg.groupId, from: msg.userId, score, text: msg.text.slice(0, 80) });
428
+ if (Number.isFinite(score) && score >= cfg.scoreThreshold) deliver({ ...msg, score });
429
+ }
359
430
  function call(action, params) {
360
431
  return new Promise((resolve, reject) => {
361
432
  if (!ws || ws.readyState !== 1) return reject(new Error('QQ is not connected'));
@@ -394,12 +465,13 @@ export function apply(ctx, config = {}, deps = {}) {
394
465
  const target = parseTarget(to, qq.owner);
395
466
  if (!target) throw new Error(`bad target "${to}" (user:<number> | group:<number> | owner)`);
396
467
  const action = target.group_id ? 'send_group_msg' : 'send_private_msg';
397
- const parts = String(text ?? '').split(/<sep\s*\/>/i).map((t) => t.trim()).filter(Boolean);
468
+ const parts = String(text ?? '').split(/<sep\s*\/>/i).map((t) => (cfg.tidy ? tidyVoice(t) : t.trim())).filter(Boolean);
398
469
  const ids = [];
399
470
  for (const part of parts) ids.push((await call(action, { ...target, message: [{ type: 'text', data: { text: part } }] }))?.message_id);
400
471
  for (const ref of [].concat(images ?? []).filter(Boolean)) ids.push((await call(action, { ...target, message: [await imageSegment(ref)] }))?.message_id);
401
472
  const n = ids.length;
402
473
  if (!n) throw new Error('nothing to send (text and images both empty)');
474
+ if (qq.owner && target.user_id === Number(qq.owner)) qq.sentToOwnerAt = Date.now();
403
475
  audit({ kind: 'sent', to: target, text: parts.join(' / ').slice(0, 200), images: [].concat(images ?? []).map((r) => (String(r).startsWith('http') ? r : String(r).slice(0, 80))) });
404
476
  return { sent: n, messageIds: ids };
405
477
  };
@@ -448,7 +520,7 @@ export function apply(ctx, config = {}, deps = {}) {
448
520
  name: 'qq:channel',
449
521
  order: 61,
450
522
  text: () => (qq.connected
451
- ? `你的 QQ(${qq.qq})在你电脑上也登着。${qq.owner ? `QQ ${qq.owner} 是你的人:他私聊你的话会原样出现在对话里,就是他本人对你说的,回他用 qq_send(to: "owner")。` : ''}其他人发来的消息会以「[QQ] 谁:内容」叫醒你,回复用 qq_send(立刻送达,to 用 user:<QQ号> 或 owner)。要给人看图就用 qq_send 的 images 直接发图片——网上的图给网址,手机屏幕给 "phone:screen",手机里刚存的给 "phone:latest"——别发链接让人自己点。别人发来的图片会带一个网址,想看就打开。手机上的 QQ 照常可以看空间、看群。`
523
+ ? `你的 QQ(${qq.qq})在你电脑上也登着。${qq.owner ? `QQ ${qq.owner} 是你的人:他私聊你的话会原样出现在对话里,就是他本人对你说的,回他用 qq_send(to: "owner")。` : ''}其他人发来的消息会以「[QQ] 谁:内容」叫醒你,回复用 qq_send(立刻送达,to 用 user:<QQ号> 或 owner)。${cfg.groupPolicy === 'score' ? '群消息先过了一道筛,叫醒你的都是和你相关或你明显有话说的;插话就只聊天,一两句,回 to 用 group:<群号>,没话说就不回。' : ''}要给人看图就用 qq_send 的 images 直接发图片——网上的图给网址,手机屏幕给 "phone:screen",手机里刚存的给 "phone:latest"——别发链接让人自己点。别人发来的图片会带一个网址,想看就打开。手机上的 QQ 照常可以看空间、看群。`
452
524
  : ''),
453
525
  }), 'dsh-dot/qq: channel section');
454
526
  });
@@ -456,8 +528,8 @@ export function apply(ctx, config = {}, deps = {}) {
456
528
  ctx.inject(['commands'], (scope) => {
457
529
  scope.effect(() => scope.commands.register({
458
530
  name: 'qq',
459
- description: 'her QQ on the computer (NapCat): status; "install", "account <number>", "start", "stop", "qr" (login QR → the phone album), "log", "owner <number>"',
460
- input: { hint: '[install | account <n> | start | stop | qr | log | owner <n>]' },
531
+ description: 'her QQ on the computer (NapCat): status; "install", "account <number>", "start", "stop", "qr" (login QR → her camera and album), "log", "owner <number>", "group <mention|all|none|score>" (which group messages wake her)',
532
+ input: { hint: '[install | account <n> | start | stop | qr | log | owner <n> | group <mention|all|none|score>]' },
461
533
  handler: async ({ rawInput }) => {
462
534
  const [verb, arg] = String(rawInput ?? '').trim().split(/\s+/);
463
535
  let extra = '';
@@ -465,6 +537,10 @@ export function apply(ctx, config = {}, deps = {}) {
465
537
  if (verb === 'install') { void qq.install(); extra = '\ninstalling in the background (several minutes) — /qq log to follow, /qq for the state'; }
466
538
  else if (verb === 'account' && arg) { qq.setAccount(arg); extra = `\naccount set: ${arg}; /qq start`; }
467
539
  else if (verb === 'owner' && arg) { qq.setOwner(arg); extra = `\nowner set: ${arg}`; }
540
+ else if (verb === 'group') {
541
+ if (['mention', 'all', 'none', 'score'].includes(arg)) { cfg.groupPolicy = arg; writeSettings({ groupPolicy: arg }); audit({ kind: 'group-policy', policy: arg }); extra = `\ngroup policy: ${arg}`; }
542
+ else extra = `\ngroup policy: ${cfg.groupPolicy} (mention | all | none | score — score rates each message with a short model call, threshold ${cfg.scoreThreshold})`;
543
+ }
468
544
  else if (verb === 'start') { extra = (await qq.start()) ? '\nstarting; if this account is new here, /qq qr to log in' : `\n${qq.error}`; }
469
545
  else if (verb === 'stop') { await qq.stop(); extra = '\nstopped'; }
470
546
  else if (verb === 'log') { extra = `\n${await qq.log(30)}`; }
@@ -0,0 +1,8 @@
1
+ // Public tool-name prefixes of the MCP servers dsh-dot mounts. dsh names an MCP tool
2
+ // `mcp__<serverName>__<tool>` (only [A-Za-z0-9_-] survive, so the hyphen is kept as-is); the
3
+ // serverNames carry a `dot-` namespace so another plugin's `vm` / `phone` server cannot collide.
4
+ // A rename is one line here plus the serverName in vm.js / phone.js.
5
+ export const VM_SERVER = 'dot-vm';
6
+ export const PHONE_SERVER = 'dot-phone';
7
+ export const VM_TOOL_PREFIX = `mcp__${VM_SERVER}__`;
8
+ export const PHONE_TOOL_PREFIX = `mcp__${PHONE_SERVER}__`;