dsh-dot-life 0.11.2 → 0.11.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/docs/computer.md +1 -0
- package/docs/qq.md +4 -0
- package/package.json +1 -1
- package/src/computer/backends/microsandbox.js +1 -0
- package/src/computer/vm.js +4 -0
- package/src/qq/qq.js +20 -3
package/docs/computer.md
CHANGED
|
@@ -136,6 +136,7 @@ tailscale serve --bg --https=443 http://127.0.0.1:<dsh 端口> # 只在你的
|
|
|
136
136
|
|---|---|---|
|
|
137
137
|
| `mounts` / `DSH_COMPUTER_MOUNTS` | 自动(见第三节) | 固定共享的文件夹;环境变量用 `:` 分隔(Windows 用 `;`) |
|
|
138
138
|
| `memory` / `cpus` | `4G` / `2` | 虚拟机资源上限 |
|
|
139
|
+
| `rootDisk` | `16G` | 她的磁盘(可写根层)。msb 默认约 4 GB,镜像自己占 3 GB,装了 QQ 就满(`/qq log` 里 `no space left on device`)。**只在新建虚拟机时生效**:已有的虚拟机不能扩,要换大盘得删掉重建(装过的东西和 QQ 登录会丢;0.11.3 之前建的都是 4 GB) |
|
|
139
140
|
| `publicUrl` / `DSH_COMPUTER_PUBLIC_URL` | 空 | 你暴露出去的 **dsh 本身**的地址(见第四节),实时画面链接用它,用于审批消息和状态接口;不是虚拟机端口 |
|
|
140
141
|
| `apiKey` | 自动生成 | 虚拟机网关密钥(`SANDBOX_API_KEY`);空则用 `~/.dsh/dsh-computer.key` 里自动生成的那把 |
|
|
141
142
|
| `mcp` | `true` | 由本组件挂载虚拟机的 `mcp__dot-vm__*` 工具(MCP 客户端带网关密钥);不要再在 `cordis.patch.yml` 里单独配 dsh-mcp-client 指向 `/mcp` |
|
package/docs/qq.md
CHANGED
|
@@ -131,6 +131,10 @@ QQ 的电脑登录码**不接受相册导入,只认摄像头**。她手机的
|
|
|
131
131
|
- 她电脑上的 QQ(SnowLuma 用的图形界面)会记住登录过的账号和密码。别在那里登你自己的号。
|
|
132
132
|
- 这是她的"电脑端 QQ",和手机同号同时在线;手机那边不要退出登录。
|
|
133
133
|
|
|
134
|
+
## 磁盘
|
|
135
|
+
|
|
136
|
+
虚拟机的盘很小(0.11.3 之前建的约 4 GB,镜像占 3 GB)。NapCat + 它的 QQ 约 1 GB,SnowLuma + 干净 QQ + Node 24 又 0.5 GB,两个都装过就满了,症状是 SnowLuma 日志 `ENOSPC`、连接正常但收不到消息。`/qq log` 末尾有一行磁盘用量;安装前剩余不足 1.5 GB 会拒绝;`/qq clean` 清安装包残留、QQ 热更新下载、apt 缓存并截短日志,`/qq clean napcat` 再把 NapCat 整个删掉。新建的虚拟机默认 16 GB(computer 的 `rootDisk`)。
|
|
137
|
+
|
|
134
138
|
## 已知限制
|
|
135
139
|
|
|
136
140
|
- 收发文字和图片;语音、视频进来显示为 `[语音]` `[视频]`。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-dot-life",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.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",
|
|
@@ -187,6 +187,7 @@ export function createMicrosandboxBackend(config, logger) {
|
|
|
187
187
|
const args = [
|
|
188
188
|
'create', '--name', name, '--hostname', config.name,
|
|
189
189
|
'-m', config.memory, '-c', String(config.cpus),
|
|
190
|
+
...(config.rootDisk ? ['--root-disk', String(config.rootDisk)] : []),
|
|
190
191
|
'-p', `127.0.0.1:${port}:8080`,
|
|
191
192
|
'--label', 'dsh-computer=1',
|
|
192
193
|
'--label', `dsh-computer.mounts=${JSON.stringify(mounts)}`,
|
package/src/computer/vm.js
CHANGED
|
@@ -24,6 +24,10 @@ export const defaults = {
|
|
|
24
24
|
user: 'gem',
|
|
25
25
|
memory: '4G',
|
|
26
26
|
cpus: 2,
|
|
27
|
+
// Her disk (the writable root layer), fixed when the computer is created: msb's default is ~4 GB, of
|
|
28
|
+
// which the image itself takes ~3 — NapCat or SnowLuma with a Linux QQ filled the rest ("no space
|
|
29
|
+
// left on device" in /qq log). Only a new computer gets it; an existing one keeps its size.
|
|
30
|
+
rootDisk: '16G',
|
|
27
31
|
mounts: [],
|
|
28
32
|
readyTimeoutMs: 240_000,
|
|
29
33
|
// Public origin of *dsh itself* (your own exposure, e.g. `tailscale serve` → https://my-mac.tailnet.ts.net):
|
package/src/qq/qq.js
CHANGED
|
@@ -107,6 +107,11 @@ const ZXING_PY = 'import sys, zxingcpp; from PIL import Image; r = zxingcpp.read
|
|
|
107
107
|
const SL_NODE_DIR = '/root/snowluma-node';
|
|
108
108
|
const SL_NODE = `${SL_NODE_DIR}/bin/node`;
|
|
109
109
|
const SL_NODE_MIRRORS = ['https://npmmirror.com/mirrors/node', 'https://nodejs.org/dist'];
|
|
110
|
+
// The computer's disk is small (msb's default root layer is ~4 GB, the image takes ~3): a line in
|
|
111
|
+
// /qq log, a check before an install, and `/qq clean` for what the installers leave behind.
|
|
112
|
+
const DISK_LINE = 'echo "== disk: $(df -h / | awk \'NR==2 { print $3 " used of " $2 ", " $4 " free" }\')"';
|
|
113
|
+
const MIN_INSTALL_FREE_MB = 1500;
|
|
114
|
+
const CLEAN_SCRIPT = `rm -f ${VM_HOME}/QQ.deb.* ${VM_HOME}/snowluma.tgz ${VM_HOME}/napcat-install.sh ${VM_HOME}/.config/QQ/versions/*.zip /tmp/node-v24* /tmp/*.tar.xz; apt-get clean 2>/dev/null; for f in ${LOG_FILE} ${SL_LOG} ${SL_QQ_LOG}; do [ -f $f ] && tail -c 200000 $f > $f.tmp && mv $f.tmp $f; done; true`;
|
|
110
115
|
|
|
111
116
|
/** OneBot 11 message segments → plain text the way a person would read them. */
|
|
112
117
|
export function segmentsToText(message, selfId = '') {
|
|
@@ -474,7 +479,9 @@ export function apply(ctx, config = {}, deps = {}) {
|
|
|
474
479
|
return [
|
|
475
480
|
'nodeok() { [ -x "$1" ] && "$1" -e \'process.exit(+process.versions.node.split(".")[0] >= 24 ? 0 : 1)\' 2>/dev/null; }',
|
|
476
481
|
`if ! nodeok ${SL_NODE}; then`,
|
|
477
|
-
|
|
482
|
+
// The image's fnm may already hold a Node 24 (121 MB saved on a 4 GB disk); else the system node; else download.
|
|
483
|
+
` f24=$(ls -d /opt/fnm/node-versions/v24.*/installation/bin/node 2>/dev/null | sort -V | tail -1); if nodeok "$f24"; then mkdir -p ${SL_NODE_DIR}/bin && ln -sf "$f24" ${SL_NODE};`,
|
|
484
|
+
` elif nodeok "$(command -v node)"; then mkdir -p ${SL_NODE_DIR}/bin && ln -sf "$(command -v node)" ${SL_NODE};`,
|
|
478
485
|
' else ok=;',
|
|
479
486
|
` for base in ${SL_NODE_MIRRORS.join(' ')}; do`,
|
|
480
487
|
' line=$(curl -fsSL --connect-timeout 15 --max-time 60 "$base/latest-v24.x/SHASUMS256.txt" | grep -E " node-v24\\.[0-9.]+-linux-$arch\\.tar\\.xz$" | head -1); [ -n "$line" ] || continue',
|
|
@@ -527,6 +534,8 @@ export function apply(ctx, config = {}, deps = {}) {
|
|
|
527
534
|
/** Install a backend: 'napcat' (NapCat + its patched linuxqq) or 'snowluma' (its own pinned linuxqq, Node 24, SnowLuma). */
|
|
528
535
|
qq.install = (which = 'napcat') => (installing ??= (async () => {
|
|
529
536
|
const snow = which === 'snowluma';
|
|
537
|
+
const free = Number((await vmShell("df -Pm / | awk 'NR==2 { print $4 }'").catch(() => '0')).trim());
|
|
538
|
+
if (free && free < MIN_INSTALL_FREE_MB) { setState('error', `only ${free} MB free on the computer's disk; an install needs ~${MIN_INSTALL_FREE_MB} MB — /qq clean, or /qq clean napcat (removes NapCat), or a new computer with a bigger rootDisk`); logger.warn(qq.error); installing = null; return false; }
|
|
530
539
|
setState('installing');
|
|
531
540
|
logger.info(snow ? 'installing SnowLuma in the computer (lite release); /qq log follows it' : 'installing NapCat in the computer (apt deps, linuxqq, NapCat.Shell) — several minutes; /qq log follows it');
|
|
532
541
|
try {
|
|
@@ -697,6 +706,7 @@ export function apply(ctx, config = {}, deps = {}) {
|
|
|
697
706
|
`echo "== processes =="; pgrep -af "[o]pt/QQ/qq|${SL_PGREP}" || echo "(none)"`,
|
|
698
707
|
`echo "== listening =="; (ss -ltnp 2>/dev/null || netstat -ltnp 2>/dev/null) | grep -E ":${cfg.wsPort}|:${SL_HTTP_PORT}|:5099" || echo "(nothing on ${cfg.wsPort}/${SL_HTTP_PORT}/5099)"`,
|
|
699
708
|
`echo "== ptrace_scope: $(cat /proc/sys/kernel/yama/ptrace_scope 2>/dev/null || echo n/a) · version: $(cat ${SL_DIR}/.dot-version 2>/dev/null || echo ?)"`,
|
|
709
|
+
DISK_LINE,
|
|
700
710
|
].join('\n'));
|
|
701
711
|
return await vmShell([
|
|
702
712
|
`if [ -f ${INSTALL_LOG} ] && [ ! -f ${INSTALL_DONE} ]; then echo "== installing =="; tail -n ${lines} ${INSTALL_LOG}; exit 0; fi`,
|
|
@@ -704,6 +714,7 @@ export function apply(ctx, config = {}, deps = {}) {
|
|
|
704
714
|
'echo "== processes =="; pgrep -af "[o]pt/QQ/qq|[X]vfb" || echo "(none)"',
|
|
705
715
|
'echo "== listening =="; (ss -ltnp 2>/dev/null || netstat -ltnp 2>/dev/null) | grep -E ":3001|:6099" || echo "(nothing on 3001/6099)"',
|
|
706
716
|
`echo "== files =="; ls -la ${QQ_BIN} ${CONFIG_DIR} 2>&1 | head -12; which xvfb-run Xvfb || echo "(no xvfb-run)"`,
|
|
717
|
+
DISK_LINE,
|
|
707
718
|
].join('\n'));
|
|
708
719
|
} catch (err) { return `log unavailable: ${err.message}`; }
|
|
709
720
|
};
|
|
@@ -1016,8 +1027,8 @@ export function apply(ctx, config = {}, deps = {}) {
|
|
|
1016
1027
|
ctx.inject(['commands'], (scope) => {
|
|
1017
1028
|
scope.effect(() => scope.commands.register({
|
|
1018
1029
|
name: 'qq',
|
|
1019
|
-
description: 'her QQ on the computer (NapCat or SnowLuma): status; "install" (NapCat + QQ), "install snowluma", "backend <napcat|snowluma>", "account <number>", "start", "stop", "qr" (login QR → her camera and album), "log", "owner <number>", "group <mention|all|none|score>" (which group messages wake her)',
|
|
1020
|
-
input: { hint: '[install [snowluma] | backend <napcat|snowluma> | account <n> | start | stop | qr | log | owner <n> | group <mention|all|none|score>]' },
|
|
1030
|
+
description: 'her QQ on the computer (NapCat or SnowLuma): status; "install" (NapCat + QQ), "install snowluma", "backend <napcat|snowluma>", "account <number>", "start", "stop", "qr" (login QR → her camera and album), "log", "clean [napcat]" (free disk: installer leftovers, caches; with napcat also NapCat itself), "owner <number>", "group <mention|all|none|score>" (which group messages wake her)',
|
|
1031
|
+
input: { hint: '[install [snowluma] | backend <napcat|snowluma> | account <n> | start | stop | qr | log | clean [napcat] | owner <n> | group <mention|all|none|score>]' },
|
|
1021
1032
|
handler: async ({ rawInput }) => {
|
|
1022
1033
|
const [verb, arg] = String(rawInput ?? '').trim().split(/\s+/);
|
|
1023
1034
|
let extra = '';
|
|
@@ -1036,6 +1047,12 @@ export function apply(ctx, config = {}, deps = {}) {
|
|
|
1036
1047
|
if (['mention', 'all', 'none', 'score'].includes(arg)) { cfg.groupPolicy = arg; writeSettings({ groupPolicy: arg }); audit({ kind: 'group-policy', policy: arg }); extra = `\ngroup policy: ${arg}`; }
|
|
1037
1048
|
else extra = `\ngroup policy: ${cfg.groupPolicy} (mention | all | none | score — score rates each message with a short model call, threshold ${cfg.scoreThreshold})`;
|
|
1038
1049
|
}
|
|
1050
|
+
else if (verb === 'clean') {
|
|
1051
|
+
// Installer leftovers, QQ's hot-update downloads, apt's cache, logs trimmed; `clean napcat` also removes NapCat's install.
|
|
1052
|
+
const out = await vmShell(`${arg === 'napcat' ? `${KILL_ALL}; rm -rf ${NAPCAT} ${VM_HOME}/NapCat ${INSTALL_DONE}; ` : ''}${CLEAN_SCRIPT}; ${DISK_LINE}`, 300_000);
|
|
1053
|
+
audit({ kind: 'cleaned', napcat: arg === 'napcat' });
|
|
1054
|
+
extra = `\ncleaned${arg === 'napcat' ? ' (NapCat removed; /qq install to put it back)' : ''} · ${String(out).trim()}`;
|
|
1055
|
+
}
|
|
1039
1056
|
else if (verb === 'start') { extra = (await qq.start()) ? '\nstarting; if this account is new here, /qq qr to log in' : `\n${qq.error}`; }
|
|
1040
1057
|
else if (verb === 'stop') { await qq.stop(); extra = '\nstopped'; }
|
|
1041
1058
|
else if (verb === 'log') { extra = `\n${await qq.log(30)}`; }
|