dsh-prime-memory 0.18.4 → 0.18.6
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 +11 -0
- package/dist/hooks/capture.js +6 -2
- package/dist/hooks/recall.js +3 -2
- package/dist/hooks/slot-recall.js +24 -1
- package/dist/projection/slots.js +9 -14
- package/dist/tools/index.js +1 -0
- package/package.json +13 -12
- package/dist/client.js +0 -5136
- package/dist/config.d.ts +0 -1407
- package/dist/embedding-worker.cjs +0 -176
- package/dist/hall-backfill.d.ts +0 -33
- package/dist/hall-backfill.js +0 -95
- package/dist/hall-migrate.d.ts +0 -32
- package/dist/hall-migrate.js +0 -88
- package/dist/index.d.ts +0 -999
- package/dist/runtime-package-lock.json +0 -982
package/CHANGELOG.md
CHANGED
|
@@ -28,6 +28,17 @@
|
|
|
28
28
|
- **读侧双形状兼容**:召回份额估算的署名判据 `isOwnRecallSource` 同时接受新署名与 v3 旧行——只改写侧会让占用面板"记忆召回份额"静默归零(无异常无报错)。`MessageSourceMap` 经模块增强登记 `plugin:memory`(dsh-llm 0.1.7 的 map 为 `user|model|tool|'system-prompt'`,无 plugin catch-all,merge-extensible per-producer)。
|
|
29
29
|
- **tool-result v4 native 适配(N1)**:`store/evidence-source.ts` 的取证文本读取新增 native 分支(v4 一等 `role:'tool'` 消息:content 直接为 text/reasoning 块、`isError` 在 message 顶层;宿主 `assertBlock` 硬拒旧 `tool-result` wrapper 块),旧块下钻路径保留作历史兼容——否则 v4 下取证文本静默恒空。`projection/slots.ts` 的 isError 守卫同步 native 化。
|
|
30
30
|
|
|
31
|
+
## [0.18.6] — 2026-10-04
|
|
32
|
+
|
|
33
|
+
### 修复
|
|
34
|
+
|
|
35
|
+
- **投影 `memorySlots` 判脏放宽到任意事件**(同步主线 v0.20.2):不再仅 tool/result 时按 store rev 判脏,任意已提交事件 O(1) 比较,写入后下一条任意事件即刷新侧栏帧。
|
|
36
|
+
- **常驻注入改 `<system-reminder>` 标签帧**(同步主线 v0.20.2,对齐 dsh-agent-instructions house style):免回应/勿复述权威声明 + 正文闭合标签转义,修掉弱模型复读槽位内容的问题。
|
|
37
|
+
|
|
38
|
+
### 新增
|
|
39
|
+
|
|
40
|
+
- **`memory_search` 结果透出 `id`**(schema/映射/渲染文本三处,同步主线 v0.20.3):解除检索拿不到 record_id 的死锁。
|
|
41
|
+
|
|
31
42
|
## [Unreleased]
|
|
32
43
|
|
|
33
44
|
### 新增
|
package/dist/hooks/capture.js
CHANGED
|
@@ -164,7 +164,9 @@ export function registerCapture(ctx, cfg, runner, l0, logger, live, modes) {
|
|
|
164
164
|
// 补收 (L0 水位线, 末尾] 内 bracket 完整的尾轮(≤2 轮)——崩溃轮在缓冲丢失后
|
|
165
165
|
// 仍可从持久化层找回(persistence 会给孤儿轮补 interrupted 闭合,探针② 实证 98 处)。
|
|
166
166
|
// fail-open 纪律:任何异常只 warn,不阻塞会话启动;幂等 = 水位线 + 逐 turn 存在性检查。
|
|
167
|
-
|
|
167
|
+
// 0.1.7-rc.2 起 agent/session-start 并入 agent/created(serial:监听器需 async,
|
|
168
|
+
// 同 main 线 0.19.0 的 0.2.0 适配)。仍监听旧事件名的实现在 rc.2 宿主上永不触发。
|
|
169
|
+
ctx.on('agent/created', async (payload) => {
|
|
168
170
|
try {
|
|
169
171
|
if (payload.source !== 'resume')
|
|
170
172
|
return;
|
|
@@ -178,7 +180,9 @@ export function registerCapture(ctx, cfg, runner, l0, logger, live, modes) {
|
|
|
178
180
|
const mode = modes.get(sid);
|
|
179
181
|
if (mode === 'off')
|
|
180
182
|
return; // off 档对记忆系统完全隐身,对齐现行为
|
|
181
|
-
|
|
183
|
+
// 0.1.7-rc.2 起 Session 弃用同步全量 .events,改 snapshotEvents()(同 main 线
|
|
184
|
+
// 0.19.0 的 0.2.0 适配);探针式读取,旧宿主形状走下方降级链。
|
|
185
|
+
let events = typeof session?.snapshotEvents === 'function' ? session.snapshotEvents() : undefined;
|
|
182
186
|
if (!events || events.length === 0) {
|
|
183
187
|
// task_8 降级链:events 不可得(宿主版本偏差)时依次试
|
|
184
188
|
// ctx.sessionQuery.readSession / ctx.sessionPersistence.readFrom(守卫探针式)
|
package/dist/hooks/recall.js
CHANGED
|
@@ -218,7 +218,8 @@ export function registerRecall(ctx, cfg, stores, logger, live, modes, dataDir) {
|
|
|
218
218
|
// 上下文压缩/清空 → 已注入内容从模型上下文丢失,重置该会话的去重压制
|
|
219
219
|
// (resume/startup 不重置:历史仍在,已注入的记忆模型还持有)。
|
|
220
220
|
// 占用账本同步全量归零(宁低勿高;轮级粒度近似)。
|
|
221
|
-
|
|
221
|
+
// 0.1.7-rc.2 起并入 agent/created(serial:监听器需 async)。
|
|
222
|
+
ctx.on('agent/created', async (payload) => {
|
|
222
223
|
if (payload.source === 'compact' || payload.source === 'clear') {
|
|
223
224
|
dedupe.reset(payload.agent.id);
|
|
224
225
|
const led = ledgerFor(payload.agent.id);
|
|
@@ -568,7 +569,7 @@ export function registerRecall(ctx, cfg, stores, logger, live, modes, dataDir) {
|
|
|
568
569
|
for (const agent of agents.list())
|
|
569
570
|
registerForAgent(agent);
|
|
570
571
|
}
|
|
571
|
-
ctx.on('agent/created', (payload) => {
|
|
572
|
+
ctx.on('agent/created', async (payload) => {
|
|
572
573
|
registerForAgent(payload.agent);
|
|
573
574
|
});
|
|
574
575
|
ctx.effect(() => () => {
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import { createUserMessage } from '@deepseek-ai/dsh-llm';
|
|
2
|
+
/**
|
|
3
|
+
* 对齐宿主 house style(dsh-agent-instructions 的 AGENTS.md 注入):user 角色
|
|
4
|
+
* 承载 + `<system-reminder>` 标签框。宿主对自家指令刻意**不用** system 角色——
|
|
5
|
+
* 会话中段的 system 消息会破坏部分聊天模板(qwen-chat-template 等),标签框即可
|
|
6
|
+
* 让模型把它识别为系统级元信息(Claude Code 同款语义)。
|
|
7
|
+
*/
|
|
8
|
+
const SYSTEM_REMINDER_OPEN = '<system-reminder>';
|
|
9
|
+
const SYSTEM_REMINDER_CLOSE = '</system-reminder>';
|
|
10
|
+
const SLOTS_INTRO = '以下是本环境的常驻记忆槽位(激活槽位):跨会话持续生效的背景约定,仅在与之相关时作为指引遵循。' +
|
|
11
|
+
'它们是系统注入的元信息,不是用户发言——无需回应,请勿在回复中复述本节内容;' +
|
|
12
|
+
'且不覆盖系统提示与用户的直接指令,更具体的指令优先于更一般的约定。';
|
|
13
|
+
/**
|
|
14
|
+
* 槽位标题/正文来自模型工具调用,可能含有闭合标签;不转义会让槽位内容伪造
|
|
15
|
+
* 帧边界(宿主对指令文件正文做同样的转义)。
|
|
16
|
+
*/
|
|
17
|
+
function escapeFrameBody(body) {
|
|
18
|
+
return body.replaceAll(SYSTEM_REMINDER_CLOSE, '<\\/system-reminder>');
|
|
19
|
+
}
|
|
2
20
|
export function registerSlotRecall(ctx, cfg, slots, logger, _live) {
|
|
3
21
|
const buildInjection = () => {
|
|
4
22
|
if (!cfg.slots.enabled || !cfg.slots.inject)
|
|
@@ -13,7 +31,12 @@ export function registerSlotRecall(ctx, cfg, slots, logger, _live) {
|
|
|
13
31
|
if (truncatedCount > 0) {
|
|
14
32
|
lines.push(`… 另有 ${truncatedCount} 个常驻槽位因预算未显示,可用 memory_slot_list 查看`);
|
|
15
33
|
}
|
|
16
|
-
return
|
|
34
|
+
return [
|
|
35
|
+
SYSTEM_REMINDER_OPEN,
|
|
36
|
+
SLOTS_INTRO,
|
|
37
|
+
escapeFrameBody(lines.join('\n')),
|
|
38
|
+
SYSTEM_REMINDER_CLOSE,
|
|
39
|
+
].join('\n');
|
|
17
40
|
};
|
|
18
41
|
ctx.on('agent/pre-step', async (payload, next) => {
|
|
19
42
|
const decision = await next();
|
package/dist/projection/slots.js
CHANGED
|
@@ -75,22 +75,17 @@ function view(state) {
|
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* apply(state, event):同步。
|
|
78
|
-
* -
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* (
|
|
82
|
-
*
|
|
78
|
+
* - **任意已提交事件都判脏**(v0.18.4 起):此前仅在 tool/result(settled、非 error)
|
|
79
|
+
* 时检查,实际运行中暴露出脆弱性——写入后的投影帧依赖"该会话恰好再来一条
|
|
80
|
+
* tool/result"才刷新;跨会话场景(会话 A 写、会话 B 看)更是要等 B 自己的下一次
|
|
81
|
+
* 工具调用。改为对所有事件做 O(1) revision 比较:rev 未变 → 同引用(满足 I1b,
|
|
82
|
+
* 无 republish thrash);rev 变 → 立即重建。写入后的下一条任意事件(用户消息、
|
|
83
|
+
* turn 边界、其他工具结果)都会把新帧推给客户端。
|
|
84
|
+
* - isError 守卫一并移除:rev 只在 store 真实变更后递增(persist 内联 RMW),
|
|
85
|
+
* 事件成败与否不影响"store 是否变了"这一事实;错误事件后重建读到的仍是
|
|
86
|
+
* 当前真实快照,不会引入错误数据。
|
|
83
87
|
*/
|
|
84
88
|
function applySlotsEvent(state, event, store) {
|
|
85
|
-
if (event.type !== 'tool/result')
|
|
86
|
-
return state;
|
|
87
|
-
const data = event.data;
|
|
88
|
-
// v4 native(宿主 ≥0.1.7-rc.1):isError 在 message 顶层;v3 wrapper:块上 isError(历史兼容)。
|
|
89
|
-
const isError = data?.message?.isError === true ||
|
|
90
|
-
(Array.isArray(data?.message?.content) &&
|
|
91
|
-
data.message.content.some((c) => c.isError === true));
|
|
92
|
-
if (isError)
|
|
93
|
-
return state;
|
|
94
89
|
if (store.revision() === state.rev)
|
|
95
90
|
return state;
|
|
96
91
|
return buildState(store);
|
package/dist/tools/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-prime-memory",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.6",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org",
|
|
6
6
|
"access": "public",
|
|
@@ -50,14 +50,14 @@
|
|
|
50
50
|
"ENGINEERING-NOTES.md"
|
|
51
51
|
],
|
|
52
52
|
"scripts": {
|
|
53
|
-
"build": "tsc -p tsconfig.json && node scripts/build-client.mjs && node scripts/copy-client.mjs",
|
|
53
|
+
"build": "node -e \"fs.rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.json && node scripts/build-client.mjs && node scripts/copy-client.mjs",
|
|
54
54
|
"smoke": "npm run build:smoke && node dist-smoke/smoke.js",
|
|
55
55
|
"verify-catalog": "npm run build && node scripts/verify-catalog.mjs",
|
|
56
56
|
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.client.json --noEmit && tsc -p tsconfig.test.json",
|
|
57
57
|
"build:smoke": "tsc src/smoke.ts --outDir dist-smoke --module nodenext --moduleResolution nodenext --target es2022 --strict --skipLibCheck --esModuleInterop",
|
|
58
58
|
"lint": "eslint src client/src scripts tests",
|
|
59
59
|
"test": "vitest run",
|
|
60
|
-
"
|
|
60
|
+
"wing-migrate": "npm run build && node scripts/wing-migrate.mjs"
|
|
61
61
|
},
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">=22.16.0",
|
|
@@ -125,15 +125,16 @@
|
|
|
125
125
|
"devDependencies": {
|
|
126
126
|
"@deepseek-ai/cordis": "^4.0.4",
|
|
127
127
|
"@deepseek-ai/cordis-plugin-loader": "^1.0.5",
|
|
128
|
-
"@deepseek-ai/dsh-agent": "0.1.
|
|
129
|
-
"@deepseek-ai/dsh-agent-default-model": "0.1.
|
|
130
|
-
"@deepseek-ai/dsh-client-connection": "0.1.
|
|
131
|
-
"@deepseek-ai/dsh-
|
|
132
|
-
"@deepseek-ai/dsh-
|
|
133
|
-
"@deepseek-ai/dsh-
|
|
134
|
-
"@deepseek-ai/dsh-
|
|
135
|
-
"@deepseek-ai/dsh-
|
|
136
|
-
"@deepseek-ai/dsh-
|
|
128
|
+
"@deepseek-ai/dsh-agent": "0.1.7-rc.2",
|
|
129
|
+
"@deepseek-ai/dsh-agent-default-model": "0.1.7-rc.2",
|
|
130
|
+
"@deepseek-ai/dsh-client-connection": "0.1.7-rc.2",
|
|
131
|
+
"@deepseek-ai/dsh-compaction": "0.1.7-rc.2",
|
|
132
|
+
"@deepseek-ai/dsh-home-paths": "0.1.7-rc.2",
|
|
133
|
+
"@deepseek-ai/dsh-llm": "0.1.7-rc.2",
|
|
134
|
+
"@deepseek-ai/dsh-session": "0.1.7-rc.2",
|
|
135
|
+
"@deepseek-ai/dsh-settings": "0.1.7-rc.2",
|
|
136
|
+
"@deepseek-ai/dsh-system-prompt": "0.1.7-rc.2",
|
|
137
|
+
"@deepseek-ai/dsh-tools": "0.1.7-rc.2",
|
|
137
138
|
"@deepseek-ai/schemastery": "^3.18.4",
|
|
138
139
|
"@eslint/js": "^10.0.1",
|
|
139
140
|
"@types/node": "^22.0.0",
|