dsh-world 0.6.6 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/CONTRIBUTING.md +163 -161
- package/INSTALL.md +314 -314
- package/LICENSE +21 -21
- package/NOTES.md +173 -152
- package/README.md +236 -227
- package/client/index.js +849 -738
- package/cordis.patch.yml +6 -6
- package/lib/compaction.js +8 -0
- package/lib/compactionSwap.d.ts +29 -2
- package/lib/compactionSwap.js +62 -7
- package/lib/console/homeApply.d.ts +11 -2
- package/lib/console/homeApply.js +36 -7
- package/lib/console/routes.d.ts +8 -0
- package/lib/console/routes.js +32 -0
- package/lib/console/snapshot.d.ts +3 -0
- package/lib/console/snapshot.js +2 -1
- package/lib/ecosystem/bridge/route.d.ts +7 -0
- package/lib/ecosystem/bridge/route.js +30 -0
- package/lib/hostContract.d.ts +1 -0
- package/lib/index.js +37 -12
- package/lib/memory.d.ts +57 -0
- package/lib/memory.js +210 -0
- package/lib/memoryFiles.d.ts +53 -0
- package/lib/memoryFiles.js +193 -0
- package/lib/memoryStore.d.ts +114 -0
- package/lib/memoryStore.js +159 -0
- package/lib/memoryTools.d.ts +31 -0
- package/lib/memoryTools.js +106 -0
- package/lib/promptSection.d.ts +2 -0
- package/lib/runtime.d.ts +1 -1
- package/lib/runtime.js +61 -29
- package/lib/sourceArchive.d.ts +1 -0
- package/lib/sourceArchive.js +1 -1
- package/lib/store.d.ts +14 -0
- package/lib/store.js +11 -1
- package/lib/worldPrompt.d.ts +6 -0
- package/lib/worldPrompt.js +7 -1
- package/package.json +128 -117
- package/scripts/compact-home.mjs +29 -0
- package/scripts/enable-tool-free-compaction.ps1 +33 -33
- package/scripts/import-stickers.mjs +17 -17
- package/scripts/update-world.mjs +5 -3
- package/src/ecosystem/wechat/windows/README.md +6 -4
- package/src/ecosystem/wechat/windows/adapter.py +80 -31
- package/src/ecosystem/wechat/windows/engine/NOTICE.md +1 -1
- package/src/ecosystem/wechat/windows/engine/bridge.cpp +9 -1
- package/src/ecosystem/wechat/windows/engine/profiles.json +114 -58
- package/src/ecosystem/wechat/windows/native.py +4 -1
- package/src/ecosystem/wechat/windows/outgoing.py +21 -0
- package/src/ecosystem/wechat/windows/presence.py +109 -109
- package/src/ecosystem/wechat/windows/sender.py +9 -1
- package/templates/alarm.md +3 -4
- package/templates/world-prompt-memory.md +10 -0
- package/templates/world-prompt.md +7 -2
package/package.json
CHANGED
|
@@ -1,117 +1,128 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "dsh-world",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Cross-session memory, persona and life routines for DSH, with a world console, tool-free compaction, native QQ and Windows WeChat messaging, group history and quoted replies",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"publishConfig": {
|
|
7
|
-
"registry": "https://registry.npmjs.org/",
|
|
8
|
-
"access": "public"
|
|
9
|
-
},
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "git+https://github.com/chenkezhen480/dsh-world.git"
|
|
13
|
-
},
|
|
14
|
-
"type": "module",
|
|
15
|
-
"main": "lib/index.js",
|
|
16
|
-
"types": "lib/index.d.ts",
|
|
17
|
-
"exports": {
|
|
18
|
-
".": {
|
|
19
|
-
"types": "./lib/index.d.ts",
|
|
20
|
-
"default": "./lib/index.js"
|
|
21
|
-
},
|
|
22
|
-
"./compaction": {
|
|
23
|
-
"types": "./lib/compaction.d.ts",
|
|
24
|
-
"default": "./lib/compaction.js"
|
|
25
|
-
},
|
|
26
|
-
"./client": "./client/index.js",
|
|
27
|
-
"./package.json": "./package.json"
|
|
28
|
-
},
|
|
29
|
-
"files": [
|
|
30
|
-
"lib",
|
|
31
|
-
"client",
|
|
32
|
-
"src/ecosystem/wechat/windows",
|
|
33
|
-
"src/ecosystem/README.md",
|
|
34
|
-
"templates",
|
|
35
|
-
"cordis.patch.yml",
|
|
36
|
-
"README.md",
|
|
37
|
-
"INSTALL.md",
|
|
38
|
-
"CONTRIBUTING.md",
|
|
39
|
-
"CHANGELOG.md",
|
|
40
|
-
"NOTES.md",
|
|
41
|
-
"assets",
|
|
42
|
-
"scripts/enable-tool-free-compaction.ps1",
|
|
43
|
-
"scripts/update-world.mjs",
|
|
44
|
-
"scripts/import-stickers.mjs"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"test
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"0.2.1-rc.
|
|
71
|
-
"0.2.1-rc.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"@
|
|
81
|
-
"@deepseek-ai/dsh-
|
|
82
|
-
"@deepseek-ai/
|
|
83
|
-
"@deepseek-ai/
|
|
84
|
-
"@deepseek-ai/dsh-
|
|
85
|
-
"@deepseek-ai/dsh-
|
|
86
|
-
"@deepseek-ai/dsh-
|
|
87
|
-
"@deepseek-ai/dsh-
|
|
88
|
-
"@deepseek-ai/dsh-
|
|
89
|
-
"@deepseek-ai/dsh-session
|
|
90
|
-
"@deepseek-ai/dsh-
|
|
91
|
-
"@deepseek-ai/
|
|
92
|
-
"@deepseek-ai/
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
"@
|
|
108
|
-
"@deepseek-ai/dsh-
|
|
109
|
-
"@deepseek-ai/dsh-
|
|
110
|
-
"@deepseek-ai/dsh-session-
|
|
111
|
-
"@deepseek-ai/dsh-
|
|
112
|
-
"@deepseek-ai/dsh-
|
|
113
|
-
"@deepseek-ai/dsh-
|
|
114
|
-
"@
|
|
115
|
-
"
|
|
116
|
-
|
|
117
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-world",
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "Cross-session memory, persona and life routines for DSH, with a world console, tool-free compaction, native QQ and Windows WeChat messaging, group history and quoted replies",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"registry": "https://registry.npmjs.org/",
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/chenkezhen480/dsh-world.git"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "lib/index.js",
|
|
16
|
+
"types": "lib/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./lib/index.d.ts",
|
|
20
|
+
"default": "./lib/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./compaction": {
|
|
23
|
+
"types": "./lib/compaction.d.ts",
|
|
24
|
+
"default": "./lib/compaction.js"
|
|
25
|
+
},
|
|
26
|
+
"./client": "./client/index.js",
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"lib",
|
|
31
|
+
"client",
|
|
32
|
+
"src/ecosystem/wechat/windows",
|
|
33
|
+
"src/ecosystem/README.md",
|
|
34
|
+
"templates",
|
|
35
|
+
"cordis.patch.yml",
|
|
36
|
+
"README.md",
|
|
37
|
+
"INSTALL.md",
|
|
38
|
+
"CONTRIBUTING.md",
|
|
39
|
+
"CHANGELOG.md",
|
|
40
|
+
"NOTES.md",
|
|
41
|
+
"assets",
|
|
42
|
+
"scripts/enable-tool-free-compaction.ps1",
|
|
43
|
+
"scripts/update-world.mjs",
|
|
44
|
+
"scripts/import-stickers.mjs",
|
|
45
|
+
"scripts/compact-home.mjs"
|
|
46
|
+
],
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=22.16.0",
|
|
49
|
+
"dsh": ">=0.2.1-rc.2 <0.3.0-0"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "node -e \"require('fs').rmSync('lib',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
|
|
53
|
+
"typecheck": "tsc --noEmit",
|
|
54
|
+
"test": "node --experimental-strip-types --disable-warning=ExperimentalWarning --test",
|
|
55
|
+
"test:package": "node scripts/check-package.mjs",
|
|
56
|
+
"prepack": "npm run typecheck && npm run build"
|
|
57
|
+
},
|
|
58
|
+
"dsh": {
|
|
59
|
+
"bundle": {
|
|
60
|
+
"patch": "./cordis.patch.yml"
|
|
61
|
+
},
|
|
62
|
+
"client": {
|
|
63
|
+
"inject": [
|
|
64
|
+
"@deepseek-ai/dsh-client-ui-settings"
|
|
65
|
+
],
|
|
66
|
+
"platform": "web"
|
|
67
|
+
},
|
|
68
|
+
"compatibility": {
|
|
69
|
+
"dshReleases": {
|
|
70
|
+
"0.2.1-rc.2": "compatible",
|
|
71
|
+
"0.2.1-rc.3": "compatible",
|
|
72
|
+
"0.2.1-rc.5": "compatible"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"dependencies": {
|
|
77
|
+
"ws": "^8.18.0"
|
|
78
|
+
},
|
|
79
|
+
"peerDependencies": {
|
|
80
|
+
"@snowluma/sdk": "^2.2.1",
|
|
81
|
+
"@deepseek-ai/dsh-plugin-manager": ">=0.2.1-rc.3 <0.3.0-0",
|
|
82
|
+
"@deepseek-ai/dsh-atomic-write": ">=0.2.1-rc.3 <0.3.0-0",
|
|
83
|
+
"@deepseek-ai/cordis": "~4.0.5",
|
|
84
|
+
"@deepseek-ai/dsh-agent": ">=0.2.1-rc.2 <0.3.0-0",
|
|
85
|
+
"@deepseek-ai/dsh-attachment": ">=0.2.1-rc.2 <0.3.0-0",
|
|
86
|
+
"@deepseek-ai/dsh-compaction": ">=0.2.1-rc.2 <0.3.0-0",
|
|
87
|
+
"@deepseek-ai/dsh-home-paths": ">=0.2.1-rc.2 <0.3.0-0",
|
|
88
|
+
"@deepseek-ai/dsh-llm": ">=0.2.1-rc.2 <0.3.0-0",
|
|
89
|
+
"@deepseek-ai/dsh-session": ">=0.2.1-rc.2 <0.3.0-0",
|
|
90
|
+
"@deepseek-ai/dsh-session-persistence": ">=0.2.1-rc.2 <0.3.0-0",
|
|
91
|
+
"@deepseek-ai/dsh-tools": ">=0.2.1-rc.2 <0.3.0-0",
|
|
92
|
+
"@deepseek-ai/schemastery": "~3.18.5",
|
|
93
|
+
"@deepseek-ai/dsh-commands": ">=0.2.1-rc.2 <0.3.0-0"
|
|
94
|
+
},
|
|
95
|
+
"peerDependenciesMeta": {
|
|
96
|
+
"@snowluma/sdk": {
|
|
97
|
+
"optional": true
|
|
98
|
+
},
|
|
99
|
+
"@deepseek-ai/dsh-plugin-manager": {
|
|
100
|
+
"optional": true
|
|
101
|
+
},
|
|
102
|
+
"@deepseek-ai/dsh-atomic-write": {
|
|
103
|
+
"optional": true
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"devDependencies": {
|
|
107
|
+
"@snowluma/sdk": "2.2.1",
|
|
108
|
+
"@deepseek-ai/dsh-agent-loop": "0.2.1-rc.2",
|
|
109
|
+
"@deepseek-ai/dsh-compaction-basic": "0.2.1-rc.2",
|
|
110
|
+
"@deepseek-ai/dsh-session-persistence-jsonl": "0.2.1-rc.2",
|
|
111
|
+
"@deepseek-ai/dsh-session-projection": "0.2.1-rc.2",
|
|
112
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.1-rc.2",
|
|
113
|
+
"@deepseek-ai/dsh-token-meter": "0.2.1-rc.2",
|
|
114
|
+
"@deepseek-ai/dsh-tools": "0.2.1-rc.2",
|
|
115
|
+
"@types/node": "^22.16.0",
|
|
116
|
+
"typescript": "^5.9.3",
|
|
117
|
+
"@deepseek-ai/cordis": "4.0.5",
|
|
118
|
+
"@deepseek-ai/schemastery": "3.18.5",
|
|
119
|
+
"@deepseek-ai/dsh-agent": "0.2.1-rc.2",
|
|
120
|
+
"@deepseek-ai/dsh-attachment": "0.2.1-rc.2",
|
|
121
|
+
"@deepseek-ai/dsh-commands": "0.2.1-rc.2",
|
|
122
|
+
"@deepseek-ai/dsh-compaction": "0.2.1-rc.2",
|
|
123
|
+
"@deepseek-ai/dsh-home-paths": "0.2.1-rc.2",
|
|
124
|
+
"@deepseek-ai/dsh-llm": "0.2.1-rc.2",
|
|
125
|
+
"@deepseek-ai/dsh-session": "0.2.1-rc.2",
|
|
126
|
+
"@deepseek-ai/dsh-session-persistence": "0.2.1-rc.2"
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Asks a running world to compact her home conversation once (held behind her running turn).
|
|
3
|
+
// Needs `bridge: true` in the plugin config. Usage: node scripts/compact-home.mjs [world directory]
|
|
4
|
+
// The world directory defaults to $DSH_WORLD_DIR, then ~/.dsh/worlds/<the only world there>.
|
|
5
|
+
import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
|
6
|
+
import { homedir } from 'node:os';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
|
|
9
|
+
function worldDir() {
|
|
10
|
+
if (process.argv[2]) return process.argv[2];
|
|
11
|
+
if (process.env.DSH_WORLD_DIR) return process.env.DSH_WORLD_DIR;
|
|
12
|
+
const root = join(homedir(), '.dsh', 'worlds');
|
|
13
|
+
const worlds = existsSync(root) ? readdirSync(root, { withFileTypes: true }).filter(entry => entry.isDirectory()).map(entry => entry.name) : [];
|
|
14
|
+
if (worlds.length !== 1) throw new Error(`找不到唯一的世界目录,请把路径作为参数传入(在 ${root} 下找到 ${worlds.length} 个)`);
|
|
15
|
+
return join(root, worlds[0]);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
const file = join(worldDir(), 'bridge.json');
|
|
20
|
+
if (!existsSync(file)) throw new Error(`没有 ${file}:世界没有在运行,或者没有开启 bridge`);
|
|
21
|
+
const { origin, token } = JSON.parse(readFileSync(file, 'utf8'));
|
|
22
|
+
const response = await fetch(new URL('/dsh-world/bridge/compact', origin), { method: 'POST', headers: { 'x-dsh-world-token': token }, signal: AbortSignal.timeout(15000) });
|
|
23
|
+
const body = await response.json().catch(() => ({}));
|
|
24
|
+
if (response.status === 202) console.log('已请求压缩家会话;她正在忙的话会等这一轮结束后再压缩。');
|
|
25
|
+
else { console.error(`没有受理(${response.status}):${body.error ?? '未知原因'}`); process.exitCode = 1; }
|
|
26
|
+
} catch (error) {
|
|
27
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
28
|
+
process.exitCode = 1;
|
|
29
|
+
}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
param(
|
|
2
|
-
[Parameter(Mandatory = $true)]
|
|
3
|
-
[string] $profilePath
|
|
4
|
-
)
|
|
5
|
-
|
|
6
|
-
$ErrorActionPreference = 'Stop'
|
|
7
|
-
try {
|
|
8
|
-
$resolvedProfile = (Resolve-Path -LiteralPath $profilePath).Path
|
|
9
|
-
$packagePath = Join-Path $resolvedProfile 'package.json'
|
|
10
|
-
$patchPath = Join-Path $resolvedProfile 'cordis.patch.yml'
|
|
11
|
-
$package = Get-Content -LiteralPath $packagePath -Raw | ConvertFrom-Json
|
|
12
|
-
if (-not $package.dependencies.'dsh-world') {
|
|
13
|
-
throw 'Install the built dsh-world package in this profile before enabling its compaction backend.'
|
|
14
|
-
}
|
|
15
|
-
$content = [System.IO.File]::ReadAllText($patchPath)
|
|
16
|
-
if ($content -match '(?m)^\s*name:\s*[''"'']?dsh-world/compaction[''"'']?\s*$') {
|
|
17
|
-
Write-Output 'Tool-free compaction is already configured.'
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
$pattern = '(?m)^(\s*name:\s*)([''"'']?)@deepseek-ai/dsh-compaction-basic\2([ \t]*(?:#.*)?\r?)$'
|
|
21
|
-
$matchesFound = [regex]::Matches($content, $pattern)
|
|
22
|
-
if ($matchesFound.Count -ne 1) {
|
|
23
|
-
throw "Expected exactly one explicit compaction-basic entry in cordis.patch.yml; found $($matchesFound.Count). No configuration was changed."
|
|
24
|
-
}
|
|
25
|
-
$updated = [regex]::Replace($content, $pattern, '${1}''dsh-world/compaction''${3}')
|
|
26
|
-
$backupPath = "$patchPath.dsh-world.$([Guid]::NewGuid().ToString('N')).bak"
|
|
27
|
-
$temporaryPath = "$patchPath.$([Guid]::NewGuid().ToString('N')).tmp"
|
|
28
|
-
[System.IO.File]::WriteAllText($temporaryPath, $updated, [System.Text.UTF8Encoding]::new($false))
|
|
29
|
-
[System.IO.File]::Replace($temporaryPath, $patchPath, $backupPath)
|
|
30
|
-
Write-Output "Configured tool-free compaction. Restart this DSH profile to load it. Backup: $backupPath"
|
|
31
|
-
} catch {
|
|
32
|
-
throw "Cannot configure dsh-world compaction: $($_.Exception.Message)"
|
|
33
|
-
}
|
|
1
|
+
param(
|
|
2
|
+
[Parameter(Mandatory = $true)]
|
|
3
|
+
[string] $profilePath
|
|
4
|
+
)
|
|
5
|
+
|
|
6
|
+
$ErrorActionPreference = 'Stop'
|
|
7
|
+
try {
|
|
8
|
+
$resolvedProfile = (Resolve-Path -LiteralPath $profilePath).Path
|
|
9
|
+
$packagePath = Join-Path $resolvedProfile 'package.json'
|
|
10
|
+
$patchPath = Join-Path $resolvedProfile 'cordis.patch.yml'
|
|
11
|
+
$package = Get-Content -LiteralPath $packagePath -Raw | ConvertFrom-Json
|
|
12
|
+
if (-not $package.dependencies.'dsh-world') {
|
|
13
|
+
throw 'Install the built dsh-world package in this profile before enabling its compaction backend.'
|
|
14
|
+
}
|
|
15
|
+
$content = [System.IO.File]::ReadAllText($patchPath)
|
|
16
|
+
if ($content -match '(?m)^\s*name:\s*[''"'']?dsh-world/compaction[''"'']?\s*$') {
|
|
17
|
+
Write-Output 'Tool-free compaction is already configured.'
|
|
18
|
+
return
|
|
19
|
+
}
|
|
20
|
+
$pattern = '(?m)^(\s*name:\s*)([''"'']?)@deepseek-ai/dsh-compaction-basic\2([ \t]*(?:#.*)?\r?)$'
|
|
21
|
+
$matchesFound = [regex]::Matches($content, $pattern)
|
|
22
|
+
if ($matchesFound.Count -ne 1) {
|
|
23
|
+
throw "Expected exactly one explicit compaction-basic entry in cordis.patch.yml; found $($matchesFound.Count). No configuration was changed."
|
|
24
|
+
}
|
|
25
|
+
$updated = [regex]::Replace($content, $pattern, '${1}''dsh-world/compaction''${3}')
|
|
26
|
+
$backupPath = "$patchPath.dsh-world.$([Guid]::NewGuid().ToString('N')).bak"
|
|
27
|
+
$temporaryPath = "$patchPath.$([Guid]::NewGuid().ToString('N')).tmp"
|
|
28
|
+
[System.IO.File]::WriteAllText($temporaryPath, $updated, [System.Text.UTF8Encoding]::new($false))
|
|
29
|
+
[System.IO.File]::Replace($temporaryPath, $patchPath, $backupPath)
|
|
30
|
+
Write-Output "Configured tool-free compaction. Restart this DSH profile to load it. Backup: $backupPath"
|
|
31
|
+
} catch {
|
|
32
|
+
throw "Cannot configure dsh-world compaction: $($_.Exception.Message)"
|
|
33
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
// One-time import of the older sticker plugin's library (catalog.json + assets/) into the world's own sticker library.
|
|
2
|
-
// Usage: node scripts/import-stickers.mjs <older library folder, e.g. ~/.dsh/memes> <world folder, e.g. ~/.dsh/worlds/<id>>
|
|
3
|
-
// Ids, names and tags carry over; packs and long meanings do not. Running it again adds nothing. The older folder is only read.
|
|
4
|
-
import { join, resolve } from 'node:path';
|
|
5
|
-
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
6
|
-
|
|
7
|
-
const [legacy, world] = process.argv.slice(2);
|
|
8
|
-
if (!legacy || !world) {
|
|
9
|
-
console.error('用法:node scripts/import-stickers.mjs <旧表情包目录> <世界目录>');
|
|
10
|
-
process.exit(2);
|
|
11
|
-
}
|
|
12
|
-
const modulePath = join(fileURLToPath(new URL('..', import.meta.url)), 'lib', 'ecosystem', 'wechat', 'stickerLibrary.js');
|
|
13
|
-
const { createStickerLibrary, importLegacyStickers } = await import(pathToFileURL(modulePath).href);
|
|
14
|
-
const library = createStickerLibrary(join(resolve(world), 'stickers'));
|
|
15
|
-
const report = await importLegacyStickers(resolve(legacy), library);
|
|
16
|
-
console.log(`导入 ${report.imported} 张,已在库里的 ${report.duplicates} 张,跳过 ${report.skipped.length} 张;表情库现有 ${(await library.list()).length} 张。`);
|
|
17
|
-
for (const line of report.skipped) console.log(` 跳过 ${line}`);
|
|
1
|
+
// One-time import of the older sticker plugin's library (catalog.json + assets/) into the world's own sticker library.
|
|
2
|
+
// Usage: node scripts/import-stickers.mjs <older library folder, e.g. ~/.dsh/memes> <world folder, e.g. ~/.dsh/worlds/<id>>
|
|
3
|
+
// Ids, names and tags carry over; packs and long meanings do not. Running it again adds nothing. The older folder is only read.
|
|
4
|
+
import { join, resolve } from 'node:path';
|
|
5
|
+
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
const [legacy, world] = process.argv.slice(2);
|
|
8
|
+
if (!legacy || !world) {
|
|
9
|
+
console.error('用法:node scripts/import-stickers.mjs <旧表情包目录> <世界目录>');
|
|
10
|
+
process.exit(2);
|
|
11
|
+
}
|
|
12
|
+
const modulePath = join(fileURLToPath(new URL('..', import.meta.url)), 'lib', 'ecosystem', 'wechat', 'stickerLibrary.js');
|
|
13
|
+
const { createStickerLibrary, importLegacyStickers } = await import(pathToFileURL(modulePath).href);
|
|
14
|
+
const library = createStickerLibrary(join(resolve(world), 'stickers'));
|
|
15
|
+
const report = await importLegacyStickers(resolve(legacy), library);
|
|
16
|
+
console.log(`导入 ${report.imported} 张,已在库里的 ${report.duplicates} 张,跳过 ${report.skipped.length} 张;表情库现有 ${(await library.list()).length} 张。`);
|
|
17
|
+
for (const line of report.skipped) console.log(` 跳过 ${line}`);
|
package/scripts/update-world.mjs
CHANGED
|
@@ -8,6 +8,8 @@ import { isDeepStrictEqual, parseArgs, promisify } from 'node:util';
|
|
|
8
8
|
|
|
9
9
|
const execute = promisify(execFile);
|
|
10
10
|
const command = (file, args, options = {}) => execute(file, args, { windowsHide: true, maxBuffer: 16 * 1024 * 1024, ...options });
|
|
11
|
+
// GNU tar (the one Git Bash puts first) reads the `C:` of an archive path as a remote host; naming the archive from its own folder works with every tar.
|
|
12
|
+
const readArchive = (run, archive, args, options = {}) => run('tar', [args[0], basename(archive), ...args.slice(1)], { ...options, cwd: dirname(archive) });
|
|
11
13
|
const json = async file => JSON.parse((await readFile(file, 'utf8')).replace(/^\uFEFF/, ''));
|
|
12
14
|
async function exists(file) {
|
|
13
15
|
try { await lstat(file); return true; }
|
|
@@ -73,10 +75,10 @@ export async function updateWorld({ profile: profilePath, archive: archivePath,
|
|
|
73
75
|
if (active.length) throw new Error(`Please exit DSH and its WeChat adapter normally before updating: ${active.join(', ')}`);
|
|
74
76
|
};
|
|
75
77
|
await stopped();
|
|
76
|
-
const { stdout: listing } = await run
|
|
78
|
+
const { stdout: listing } = await readArchive(run, archive, ['-tzf']);
|
|
77
79
|
const entries = listing.trim().split(/\r?\n/);
|
|
78
80
|
if (entries.filter(file => file === 'package/package.json').length !== 1 || !entries.includes('package/lib/index.js')) throw new Error('A compiled dsh-world archive with lib/index.js is required');
|
|
79
|
-
const { stdout: manifestText } = await run
|
|
81
|
+
const { stdout: manifestText } = await readArchive(run, archive, ['-xOzf', 'package/package.json']);
|
|
80
82
|
const target = JSON.parse(manifestText.replace(/^\uFEFF/, ''));
|
|
81
83
|
if (target.name !== 'dsh-world' || !/^\d+\.\d+\.\d+(?:-[\w.-]+)?$/.test(target.version) || target.main !== 'lib/index.js') throw new Error('The archive must be a compiled dsh-world package');
|
|
82
84
|
|
|
@@ -120,7 +122,7 @@ export async function updateWorld({ profile: profilePath, archive: archivePath,
|
|
|
120
122
|
const installed = await json(join(installedRoot, 'package.json'));
|
|
121
123
|
if (installed.name !== 'dsh-world' || installed.version !== target.version) throw new Error('Installed dsh-world version does not match the archive');
|
|
122
124
|
for (const entry of ['lib/index.js', 'scripts/update-world.mjs'].filter(file => entries.includes('package/' + file))) {
|
|
123
|
-
const { stdout } = await run
|
|
125
|
+
const { stdout } = await readArchive(run, savedArchive, ['-xOzf', 'package/' + entry], { encoding: 'buffer' });
|
|
124
126
|
if (createHash('sha256').update(stdout).digest('hex') !== await digest(join(installedRoot, entry))) throw new Error(`Installed package content does not match: ${entry}`);
|
|
125
127
|
}
|
|
126
128
|
await run(process.execPath, ['--check', join(installedRoot, 'lib', 'index.js')], { cwd: profile });
|
|
@@ -7,10 +7,10 @@ DSH 端代码在 `src/ecosystem/wechat/`,此目录只负责 Windows 微信收
|
|
|
7
7
|
- 已配置群聊的普通消息只累计账号隔离的群动态元数据(未读数、最后发言人和时间),不因这些消息唤醒模型或注入正文;自己的消息不计未读。计数持久化到原适配器状态库,重启保留,不读未配置群。现有闹钟响起时,在线适配器的新鲜概况会在自定义闹钟措辞之后追加,最多展示 8 个群,未读超过 99 显示 `99+`,不规定是否看群或发言。
|
|
8
8
|
- `wechat_history` 成功读取最新页并得到宿主确认后,清零截至该页的未读;翻更早页不会清掉新未读,失败读取也不会清零。概况不包含群消息正文,离线或过期概况不展示;不修改个人 `alarm.md`、`world-prompt.md` 或「我是谁」。
|
|
9
9
|
- 接收文字与普通图片私聊、指定家庭群;首启从最新位置监听,不重放旧聊天。原生动图表情仍不接收。
|
|
10
|
-
-
|
|
10
|
+
- 收到要交给她的消息后先缓冲(默认 3 秒,`bufferSeconds`):同一聊天、同一发言人在等待中又发来文字(私聊还包括图片),就重新计时,安静下来后合并为一次模型请求;最长等 30 秒、最多 16 条、合并文字不超过 2000 字,私聊最多两张图片。别人发言、引用、表情包等其他类型让批次立即结束。群聊只有 @ 她的消息会等待,同一人随后的文字合并进来,身份仍是 @ 她的那条。批次开始处理后才收到的消息留在微信数据库中,下一轮按序读取,不中断当前回复。
|
|
11
11
|
- 批次成员保留原平台消息 ID,在同一事务中进入待处理与完成状态;缓冲期间不推进游标,处理中断后保留待核对状态,不自动重跑模型。图片单发仅进入会话图片上下文;图片加文字时只把真实文字按原范围归档。图片及附件引用不写入共享记忆块,是否另行留存其中信息由她自己判断。
|
|
12
12
|
- 暂不接收视频号分享卡片:卡片会被跳过,不进入宿主会话或共享记忆。视频号卡片解析、视频内容读取,以及朋友圈浏览/发布,均预留为微信模块后续扩展,尚未实现;朋友圈发布需要独立接口,不能复用私聊/群聊发送接口。
|
|
13
|
-
- 后台原生发送文字、图片及 GIF 表情,不操作窗口、鼠标、键盘或剪贴板。按 `engine/profiles.json` 中的文件大小与 SHA256 自动选择 Windows x64 微信 4.1.15.13 / 4.1.15.56
|
|
13
|
+
- 后台原生发送文字、图片及 GIF 表情,不操作窗口、鼠标、键盘或剪贴板。按 `engine/profiles.json` 中的文件大小与 SHA256 自动选择 Windows x64 微信 4.1.15.13 / 4.1.15.56 / 4.2.0.11 / 4.2.0.12 的指定构建(4.2 不能发原生 GIF 表情,表情包改为截取一帧作为图片发送,见下);未知或匹配不唯一的构建会在加载原生桥前报错,不能只凭版本号判断兼容。
|
|
14
14
|
- 发言人使用真实 wxid,消息保持 `role: user`;昵称只作显示。
|
|
15
15
|
- 每个群按平台、登录账号、聊天类型和群 ID 绑定独立会话,列在原房间工作区下,重启继续复用;群名变化不产生新会话。QQ 的相同参数可使用同一映射结构,但本模块仍只提供微信传输。
|
|
16
16
|
- 群消息只在微信来源元数据的 `atuserlist` 包含她的真实 wxid 时触发,正文里手打 `@昵称` 不触发。回复携带当前消息之前默认 5 条(控制台可调,1–20)、最多 16KB 的同群上下文,保留各自的发言人 ID;每轮最多读取其中最近两张图片。
|
|
@@ -31,7 +31,7 @@ DSH 端代码在 `src/ecosystem/wechat/`,此目录只负责 Windows 微信收
|
|
|
31
31
|
- 发送正文作为独立的微信出站上下文写入发起会话总日志,按原记忆范围记录真实正文和目标;普通工具参数、回执查询和群图片上下文仍不进入共享记忆。她留在 DSH 的最终文字与微信正文可以不同,归档分别保留。
|
|
32
32
|
- 生成时先记为待发送,适配器逐条核对目标聊天中的本人消息、内容及服务器消息编号,再更新同一条记忆的已确认条数。中断则记录已确认部分与结果不明项;这不是对方已读回执。
|
|
33
33
|
- 回执先保存在适配器本地,宿主暂时不可用时,重启监听只补报回执,不重发消息。旧版本的待发送记录不会凭空改成已发送。
|
|
34
|
-
- 宿主队列保存在世界目录 `wechat-outbox.sqlite`。适配器离线时已排队消息会等待恢复;已领取任务按同一 ID 恢复,适配器已有回执时只补报,不再发送。入站处理结果不明时保留 pending
|
|
34
|
+
- 宿主队列保存在世界目录 `wechat-outbox.sqlite`。适配器离线时已排队消息会等待恢复;已领取任务按同一 ID 恢复,适配器已有回执时只补报,不再发送。入站处理结果不明时保留 pending,只暂停这一个聊天的接收(其他聊天照常),日志提示人工核对,独立发送任务仍继续轮询;主动发送的待核对消息 ID 为 `outgoing:<发送 ID>`。结果不明的原发送任务不会重发,其余任务按各自 ID 和回执处理。
|
|
35
35
|
- 回执、任务领取、账号状态和群读取结果的单键请求遇到 HTTP 502/503/504 或连接错误时最多尝试 5 次,单次网络超时为 5 秒,间隔 1/2/4/8 秒,每次重读 `wechat.json` 的地址和令牌;响应正文读取中断也按此处理,HTTP 错误保留响应正文(最多 1024 字节)。生成回复的请求仍保留 190 秒网络超时,只发送一次,不能因超时或 503 自动再次调用模型。
|
|
36
36
|
- 群会话沿用现有归档范围:`archiveScope: home` 时能读取家的记忆,但群正文不写入共享记忆;群自己的宿主会话日志保留正文,发送状态单独保存,不绕过归档范围。
|
|
37
37
|
- `archiveScope: workspace` 会归档家所在工作区的普通会话,包括独立群会话;群图片上下文依旧不进入共享归档。控制台修改范围后重启 DSH 生效,回扫范围内历史并按时间重建近期记忆,保留原始日志和旧归档。
|
|
@@ -105,7 +105,7 @@ wechatAdapter:
|
|
|
105
105
|
config: C:/path/to/.host/wechat/config.json
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
-
两项都填才生效。微信模块启动时插件用等同于 `Start -AllowSend` 的参数拉起适配器,微信模块停止(控制台停止、重启 DSH、退出)时结束整个进程树,适配器意外退出则按 1 秒起翻倍、最长 30 秒的间隔自动重启;日志写在 `<world>/wechat-adapter.log`(超过 1MB 时清空)。**写下这两项即视为长期允许适配器发送消息**,默认关闭。启用前先用 `wechat.ps1 Stop` 停掉手动启动的实例,否则两个实例会争用单实例锁。入站 pending
|
|
108
|
+
两项都填才生效。微信模块启动时插件用等同于 `Start -AllowSend` 的参数拉起适配器,微信模块停止(控制台停止、重启 DSH、退出)时结束整个进程树,适配器意外退出则按 1 秒起翻倍、最长 30 秒的间隔自动重启;日志写在 `<world>/wechat-adapter.log`(超过 1MB 时清空)。**写下这两项即视为长期允许适配器发送消息**,默认关闭。启用前先用 `wechat.ps1 Stop` 停掉手动启动的实例,否则两个实例会争用单实例锁。入站 pending 只暂停它所在聊天的接收并在日志提示,其他聊天和独立发送队列继续运行;若适配器以需要人工核对的退出码 2 退出,插件不会重复拉起。核对后先停适配器,使用 `acknowledge` 处理,再从控制台重启。启动时若 Python、配置或脚本暂时缺失,插件会按同样的间隔重试,文件回来后自动启动。微信自身重启不需要插件处理:适配器会等待同一账号重新登录并沿用游标,控制台「微信」卡片会显示“微信离线,等待重新登录”。
|
|
109
109
|
|
|
110
110
|
`Start -AllowSend` 会把所选聊天的新文字交给家的 Agent,并实际发送回复。家仍有原来的工具权限,第一版不会把群成员自动变成独立权限主体;接入群聊前应决定允许哪些人向家下指令。
|
|
111
111
|
|
|
@@ -144,6 +144,8 @@ node <dsh-world 包目录>scriptsimport-stickers.mjs C:Usersyou.dshmemes C:Users
|
|
|
144
144
|
|
|
145
145
|
4.1.15.56 的指纹与 19 个原生地址映射来自 [helper 的版本表](https://github.com/Prometheus-first/helper/blob/main/native/core_version.h)。两版沿用相同请求 ABI、账号核对和消息对象字段布局;版本表选择、地址编码及未知构建拒绝由离线测试覆盖。上游已实测新版文字收发及桥接加载卸载,媒体未逐项重做真实网络操作,详见其 [验证范围](https://github.com/Prometheus-first/helper/blob/main/native/README.md);本项目实测范围见下方日期记录。本次仅更新 Python 和版本表,无须重新编译未改动的 C++ 桥;新增构建或结构发生变化时仍需校准并实测。
|
|
146
146
|
|
|
147
|
+
4.2.0.11 与 4.2.0.12 的指纹和地址同样取自 helper 的版本表(按同一方法推出的 4.1.15.56 地址与已实测的配置逐项一致)。上游 4.2 只映射了文字、撤回和图片收发路径,原生 GIF 表情的 5 个地址没有映射,上游自己的表情发送在 4.2 上也直接拒绝;所以这两个构建的这 5 项为 null,原生桥只在发表情包时要求它们,文字和图片照常发送。在 4.2 上发表情包时,适配器把 GIF 转成一张静态 PNG 按图片发送:取第一帧,第一帧完全透明或只有一种颜色时改取最后一帧。**本项目没有 4.2 实机,以上未经真实微信验证**;首次使用请先向测试私聊各发一次文字、图片和表情包核对。原生桥源码因此改动,升级后需要重新运行 `wechat.ps1 Build`,否则适配器会以“原生桥源码已变化”拒绝加载。
|
|
148
|
+
|
|
147
149
|
2026-10-25 已在绑定的专用账号私聊中确认两条独立文字及一条原生表情(类型 47),并在选定家庭群补发确认一张原生表情和一条文字;均核对服务器消息编号,媒体内容同时核对 MD5。首次群会话的技能目录误判已修复并有回归测试。2026-10-26 已确认家庭群真实 @ 触发时读取两张缓存图片、模型描述图片并回群发送成功,附件引用保存在群会话日志,该群共享归档记录数仍为 0。该轮未测独立图片发送和锁屏运行。
|
|
148
150
|
|
|
149
151
|
2026-10-27 已在 Windows 微信 4.1.15.56 上独立验证:构建指纹、绑定账号及原生调度 Probe 通过;13 个数据库密钥通过校验;私聊、群聊各分页读取 40 条历史消息样本,解析到 9 条群历史消息的真实 @ 元数据;解码私聊 1 张及群聊 2 张缓存图片,并完成一条私聊表情的 CDN 下载与解码。经用户明确确认,向已配置私聊各发送一次文字、PNG 和两帧原生 GIF 表情,三条均核对服务器消息编号,两项媒体同时核对 MD5。测试全程未启动 DSH、未调用模型、未向家庭群发送测试消息,原有本地消息游标及待核对状态保持不变。本轮未测 4.1.15.56 下的群实际发送、退出重连、锁屏或 DSH 联动。
|