dsh-dot-life 0.17.3 → 0.17.4
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 +2 -2
- package/docs/SETTINGS.md +1 -0
- package/docs/prompts.md +1 -1
- package/package.json +1 -1
- package/scripts/prompts.mjs +4 -1
- package/src/dot/core.js +64 -4
package/README.md
CHANGED
|
@@ -197,13 +197,13 @@ flowchart LR
|
|
|
197
197
|
```text
|
|
198
198
|
/phone [accept|restart|screenshot]
|
|
199
199
|
/interlude [now|advance|seed|preset <code>|canon]
|
|
200
|
-
/dot [test|check]
|
|
200
|
+
/dot [test|check|prompts [stop]]
|
|
201
201
|
/dot memory [now|diary|handoff|recall …]
|
|
202
202
|
/dot people [approve <id>|drop <id>|forget <名字>]
|
|
203
203
|
/qq [install|account|start|qr|backend|owner]
|
|
204
204
|
```
|
|
205
205
|
|
|
206
|
-
|
|
206
|
+
**改提示词和人设**:在 dsh 里发 `/dot prompts`,回一个本机网址(默认 http://127.0.0.1:7870/),打开就能改,第一项是人设 `canon.json`;`/dot prompts stop` 关掉。她收到的每段话都是 `src/prompts/` 里的纯文本,页面保存到 `~/dot/prompts/` 覆盖内置版本。开发时在仓库里 `npm run prompts` 也行,见 [docs/prompts.md](docs/prompts.md)。
|
|
207
207
|
|
|
208
208
|
**状态面板**:会话顶部 ◎ 按钮打开右侧栏 dot 标签页——设备状态、交班进度、她此刻在做什么、今天的 token,以及**最近 30 场**(每次被叫醒到结束是一场,展开看她做了什么、说了什么)。
|
|
209
209
|
|
package/docs/SETTINGS.md
CHANGED
|
@@ -187,6 +187,7 @@ setx DSH_DOT_COMPUTER off
|
|
|
187
187
|
| `enabled` | `true` | `false` 关掉联系人层 |
|
|
188
188
|
| `home` | `~/dot` | 和另外两处保持一致 |
|
|
189
189
|
| `phoneCheckEveryMinutes` | `30` | 隔多久拿起手机看一眼,0 关 |
|
|
190
|
+
| `promptsPort` | `7870` | `/dot prompts` 提示词页面的端口(只监听 127.0.0.1) |
|
|
190
191
|
| `notifyHours` | `""` | 只在这个时段内通知叫醒她;空 = 一直 |
|
|
191
192
|
| `notifyBatchMs` | `1000` | 多少毫秒内的通知合并成一次叫醒(别人的;你的话见下面四项) |
|
|
192
193
|
| `ownerQuietMs` | `1500` | 你的 QQ 消息:你停下多少毫秒没新消息才送给她,每来一条重新计时 |
|
package/docs/prompts.md
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
- `dot.rules.computer` / `dot.rules.phone` 各两行:第一行接在开头那段里,第二行是一条规则。
|
|
15
15
|
- `interlude.round` 是幕间一轮的整段系统提示词,从上到下就是模型看到的顺序(HDS-Interlude 1.0.1-rc57 的提示词,AGPL-3.0 © MOMOR1A/MomoiCore,译成中文后合并)。覆盖它就替换整段;`{phase}` `{length}` 这类占位符各对应一个 `interlude.round.<名字>` 小文件,空的那行省掉。
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
**页面**:在 dsh 里发 `/dot prompts`,打开它回的网址(默认 http://127.0.0.1:7870/,只监听本机,端口用 `dot.promptsPort` 换;日志 `~/.dsh/dsh-dot-prompts.log`),`/dot prompts stop` 关掉,dsh 退出时也跟着关。开发时在仓库根目录跑 `npm run prompts` 是同一个页面(`PORT=xxxx` 换端口)。左边第一项是人设(canon.json),其余按她看到的顺序列出全部文件,标着「内置」或「已改过」;右边是整个文件,「保存」写到 `<home>/prompts/`,「恢复内置」删掉覆盖文件,「预览」用样例数据跑真实代码(没保存的改动也能预览),「全貌」拼出她对话里插件加的整段系统提示词。`npm run prompts -- --src` 时「保存」直接写进 `src/prompts/`,改的是内置版本。
|
|
18
18
|
|
|
19
19
|
| 分组 | 是什么 | 文件 |
|
|
20
20
|
|---|---|---|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-dot-life",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.4",
|
|
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/scripts/prompts.mjs
CHANGED
|
@@ -291,4 +291,7 @@ export function serve(port = Number(process.env.PORT) || 7870, { src = process.a
|
|
|
291
291
|
return server;
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
-
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url))
|
|
294
|
+
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
295
|
+
serve();
|
|
296
|
+
process.on('disconnect', () => process.exit()); // started by /dot prompts: go when dsh goes
|
|
297
|
+
}
|
package/src/dot/core.js
CHANGED
|
@@ -13,9 +13,12 @@
|
|
|
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
15
|
import { PHONE_TOOL_PREFIX, VM_TOOL_PREFIX } from '../tool-prefixes.js';
|
|
16
|
-
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
16
|
+
import { closeSync, mkdirSync, openSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
17
|
+
import { spawn } from 'node:child_process';
|
|
18
|
+
import { get as httpGet } from 'node:http';
|
|
17
19
|
import { homedir } from 'node:os';
|
|
18
|
-
import { join, relative, isAbsolute } from 'node:path';
|
|
20
|
+
import { join, relative, isAbsolute, dirname } from 'node:path';
|
|
21
|
+
import { fileURLToPath } from 'node:url';
|
|
19
22
|
import { createUserMessage } from '@deepseek-ai/dsh-llm';
|
|
20
23
|
import { mountPanel } from './panel.js';
|
|
21
24
|
import { sectionOf, setValues } from '../settings.js';
|
|
@@ -170,6 +173,7 @@ export const defaults = {
|
|
|
170
173
|
errandMaxTokens: 60000, // the errand session is archived and a fresh one started past this
|
|
171
174
|
// Notifications from these apps are conversations: they wake her conversation, not the errand.
|
|
172
175
|
conversationApps: ['qq', 'com.tencent.mobileqq', 'com.tencent.mm'],
|
|
176
|
+
promptsPort: 7870, // /dot prompts: the prompt and persona editor page (scripts/prompts.mjs) on 127.0.0.1
|
|
173
177
|
};
|
|
174
178
|
|
|
175
179
|
/** Source of the note an errand leaves in her conversation (injected; it does not wake her). */
|
|
@@ -195,6 +199,55 @@ export function inHours(spec, date = new Date()) {
|
|
|
195
199
|
const start = +m[1] * 60 + +m[2], end = +m[3] * 60 + +m[4], now = date.getHours() * 60 + date.getMinutes();
|
|
196
200
|
return start <= end ? now >= start && now < end : now >= start || now < end;
|
|
197
201
|
}
|
|
202
|
+
const PACKAGE_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..', '..');
|
|
203
|
+
const answers = (url) => new Promise((r) => {
|
|
204
|
+
const q = httpGet(url, { agent: false, timeout: 1000 }, (res) => { res.resume(); r(res.statusCode === 200); });
|
|
205
|
+
q.on('error', () => r(false)).on('timeout', () => q.destroy());
|
|
206
|
+
});
|
|
207
|
+
/**
|
|
208
|
+
* /dot prompts: scripts/prompts.mjs in a child process (it rewrites process.env.DSH_HOME and the
|
|
209
|
+
* prompt home when imported, which must not happen inside the dsh host). Same <home> as hers.
|
|
210
|
+
*/
|
|
211
|
+
export function promptsPage({ home, port, timeoutMs = 20000 }) {
|
|
212
|
+
const url = `http://127.0.0.1:${port}/`;
|
|
213
|
+
const log = join(dshHome(), 'dsh-dot-prompts.log');
|
|
214
|
+
let child = null, starting = null;
|
|
215
|
+
async function start() {
|
|
216
|
+
if (child && child.exitCode === null) return url;
|
|
217
|
+
mkdirSync(dshHome(), { recursive: true });
|
|
218
|
+
try { if (statSync(log).size > 1_000_000) rmSync(log, { force: true }); } catch {}
|
|
219
|
+
const fd = openSync(log, 'a');
|
|
220
|
+
let failed = '';
|
|
221
|
+
try {
|
|
222
|
+
// dsh may be Electron: ELECTRON_RUN_AS_NODE makes its executable a plain Node.
|
|
223
|
+
child = spawn(process.execPath, [join(PACKAGE_ROOT, 'scripts', 'prompts.mjs')], {
|
|
224
|
+
cwd: PACKAGE_ROOT, stdio: ['ignore', fd, fd, 'ipc'], windowsHide: true,
|
|
225
|
+
env: { ...process.env, ELECTRON_RUN_AS_NODE: '1', DSH_DOT_HOME: home, PORT: String(port) },
|
|
226
|
+
});
|
|
227
|
+
} finally { closeSync(fd); }
|
|
228
|
+
const c = child;
|
|
229
|
+
c.unref(); c.channel?.unref(); // the channel only lets the page know when dsh is gone (see prompts.mjs)
|
|
230
|
+
c.on('error', (err) => { failed = err.message; });
|
|
231
|
+
c.on('exit', (code, sig) => { failed ||= `exited (${sig ?? code})`; if (child === c) child = null; });
|
|
232
|
+
for (const until = Date.now() + timeoutMs; Date.now() < until && !failed;) {
|
|
233
|
+
if (await answers(url)) return url;
|
|
234
|
+
await new Promise((r) => setTimeout(r, 200));
|
|
235
|
+
}
|
|
236
|
+
stop();
|
|
237
|
+
throw new Error(`${failed || `no answer within ${timeoutMs / 1000} s`} — log: ${log}`);
|
|
238
|
+
}
|
|
239
|
+
function stop() {
|
|
240
|
+
const c = child; child = null;
|
|
241
|
+
if (!c || c.exitCode !== null) return Promise.resolve(false);
|
|
242
|
+
return new Promise((r) => { c.once('exit', () => r(true)); c.kill(); });
|
|
243
|
+
}
|
|
244
|
+
return {
|
|
245
|
+
url,
|
|
246
|
+
start: () => (starting ??= start().finally(() => { starting = null; })),
|
|
247
|
+
stop,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
|
|
198
251
|
const today = (d = new Date()) => `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`;
|
|
199
252
|
|
|
200
253
|
/** Text of a message content array (or string). */
|
|
@@ -713,13 +766,16 @@ export function apply(ctx, config = {}) {
|
|
|
713
766
|
if (s.state === 'needs-license') void im.send('📱 dot: 手机还没装好——需要先接受 Android SDK 许可。在 dsh 里发 /phone accept(默认 16 GB 存储,要别的大小发 /phone accept 32 这样,建好后不能改)。', 'plain');
|
|
714
767
|
}) ?? (() => {}), 'dsh-dot: phone status'));
|
|
715
768
|
|
|
769
|
+
const prompts = promptsPage({ home, port: Number(cfg.promptsPort) || 7870 });
|
|
770
|
+
ctx.effect(() => () => { void prompts.stop(); }, 'dsh-dot: prompts page');
|
|
771
|
+
|
|
716
772
|
// /dot
|
|
717
773
|
// The command registry can come up after dot, so register through a child that waits for it.
|
|
718
774
|
ctx.inject(['commands'], (commandCtx) => {
|
|
719
775
|
commandCtx.effect(() => commandCtx.commands.register({
|
|
720
776
|
name: 'dot',
|
|
721
|
-
description: 'dot status; "test" sends a test message to your IM; "check" makes her pick up her phone now; "memory" / "people" show what she remembers',
|
|
722
|
-
input: { hint: '[test | check | memory [now|diary|handoff|recall [backend|key|model|rerank|mirror|rebuild|test]] | people [approve|drop <id> | forget <name>]]' },
|
|
777
|
+
description: 'dot status; "test" sends a test message to your IM; "check" makes her pick up her phone now; "memory" / "people" show what she remembers; "prompts" opens the prompt and persona editor page',
|
|
778
|
+
input: { hint: '[test | check | prompts [stop] | memory [now|diary|handoff|recall [backend|key|model|rerank|mirror|rebuild|test]] | people [approve|drop <id> | forget <name>]]' },
|
|
723
779
|
handler: async ({ rawInput }) => {
|
|
724
780
|
const arg = String(rawInput ?? '').trim();
|
|
725
781
|
// /dot memory … and /dot people … belong to dsh-dot/memory.
|
|
@@ -727,6 +783,10 @@ export function apply(ctx, config = {}) {
|
|
|
727
783
|
const mem = ctx.get('dotMemory');
|
|
728
784
|
return { kind: 'success', text: mem ? await mem.command(arg) : 'dsh-dot/memory is not loaded' };
|
|
729
785
|
}
|
|
786
|
+
if (arg === 'prompts stop') return { kind: 'success', text: (await prompts.stop()) ? 'prompts page stopped' : 'prompts page was not running' };
|
|
787
|
+
if (arg === 'prompts') {
|
|
788
|
+
try { return { kind: 'success', text: `提示词和人设页面:${await prompts.start()}\n(只在本机打开;/dot prompts stop 关掉)` }; } catch (err) { return { kind: 'success', text: `prompts page failed: ${err.message}` }; }
|
|
789
|
+
}
|
|
730
790
|
const t = await im.target();
|
|
731
791
|
let test = '';
|
|
732
792
|
if (arg === 'test') test = `\ntest message: ${(await im.send('👋 dot 测试消息:IM 通道正常。', 'plain')) ? 'sent' : 'FAILED'}`;
|