@lmzhen/dsh-tool-memory 0.23.0 → 0.25.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/lib/index.js +14 -14
- package/package.json +7 -7
package/lib/index.js
CHANGED
|
@@ -101,7 +101,7 @@ async function apply(ctx, rawConfig = {}) {
|
|
|
101
101
|
return raw === null || typeof raw !== "object";
|
|
102
102
|
})) return {
|
|
103
103
|
ok: false,
|
|
104
|
-
message: "
|
|
104
|
+
message: "operations 的每一项都必须是对象。",
|
|
105
105
|
entries: [],
|
|
106
106
|
chars: 0,
|
|
107
107
|
limit: 0
|
|
@@ -109,7 +109,7 @@ async function apply(ctx, rawConfig = {}) {
|
|
|
109
109
|
const target = normalized.target;
|
|
110
110
|
if (target !== "memory" && target !== "user") return {
|
|
111
111
|
ok: false,
|
|
112
|
-
message: `memory
|
|
112
|
+
message: `memory:"target" 必须是 "memory" 或 "user"(收到 ${String(target)});拒绝写入。`,
|
|
113
113
|
entries: [],
|
|
114
114
|
chars: 0,
|
|
115
115
|
limit: 0
|
|
@@ -122,7 +122,7 @@ async function apply(ctx, rawConfig = {}) {
|
|
|
122
122
|
const value = normalized[field];
|
|
123
123
|
if (value !== void 0 && value !== null && typeof value !== "string") return {
|
|
124
124
|
ok: false,
|
|
125
|
-
message: `memory
|
|
125
|
+
message: `memory:"${field}" 必须是字符串(收到 ${typeof value});拒绝写入。`,
|
|
126
126
|
entries: [],
|
|
127
127
|
chars: 0,
|
|
128
128
|
limit: 0
|
|
@@ -137,7 +137,7 @@ async function apply(ctx, rawConfig = {}) {
|
|
|
137
137
|
if (value === void 0 || value === null || typeof value === "string") continue;
|
|
138
138
|
return {
|
|
139
139
|
ok: false,
|
|
140
|
-
message: `memory
|
|
140
|
+
message: `memory:operations[${index}].${field} 必须是字符串(收到 ${typeof value});拒绝写入 —— 重新批准无法修复载荷缺陷,请驳回该记录。`,
|
|
141
141
|
entries: [],
|
|
142
142
|
chars: 0,
|
|
143
143
|
limit: 0
|
|
@@ -158,10 +158,10 @@ async function apply(ctx, rawConfig = {}) {
|
|
|
158
158
|
}
|
|
159
159
|
const requiredFieldRejection = (op, position) => {
|
|
160
160
|
const body = payloadText(op);
|
|
161
|
-
if (op.action === "add") return body ? null :
|
|
162
|
-
if (op.action !== "remove" && op.action !== "replace") return
|
|
163
|
-
if (!(op.old_text ?? "").trim()) return
|
|
164
|
-
if (op.action === "replace" && !body) return
|
|
161
|
+
if (op.action === "add") return body ? null : `第 ${position} 个操作(add):必须提供 facts。未应用任何操作。`;
|
|
162
|
+
if (op.action !== "remove" && op.action !== "replace") return `第 ${position} 个操作:未知动作「${String(op.action)}」(应为 add/remove/replace)。未应用任何操作。`;
|
|
163
|
+
if (!(op.old_text ?? "").trim()) return `第 ${position} 个操作(${op.action}):必须提供 old_text。未应用任何操作。`;
|
|
164
|
+
if (op.action === "replace" && !body) return `第 ${position} 个操作(replace):必须提供 facts。`;
|
|
165
165
|
return null;
|
|
166
166
|
};
|
|
167
167
|
if (!memoryDisabled) ctx.tools.register(defineTool({
|
|
@@ -251,14 +251,14 @@ async function apply(ctx, rawConfig = {}) {
|
|
|
251
251
|
const raw = op;
|
|
252
252
|
if (raw === null || typeof raw !== "object") return {
|
|
253
253
|
ok: false,
|
|
254
|
-
message: "
|
|
254
|
+
message: "operations 的每一项都必须是对象。",
|
|
255
255
|
entries: [],
|
|
256
256
|
chars: 0,
|
|
257
257
|
limit: 0
|
|
258
258
|
};
|
|
259
259
|
if (conflict(op)) return {
|
|
260
260
|
ok: false,
|
|
261
|
-
message: "
|
|
261
|
+
message: "每个操作只能提供 facts 或 content 之一(同一字段):两者给了不同的值。",
|
|
262
262
|
entries: [],
|
|
263
263
|
chars: 0,
|
|
264
264
|
limit: 0
|
|
@@ -266,21 +266,21 @@ async function apply(ctx, rawConfig = {}) {
|
|
|
266
266
|
}
|
|
267
267
|
else if (conflict(args)) return {
|
|
268
268
|
ok: false,
|
|
269
|
-
message: "
|
|
269
|
+
message: "只能提供 facts 或 content 之一(同一字段):两者给了不同的值。",
|
|
270
270
|
entries: [],
|
|
271
271
|
chars: 0,
|
|
272
272
|
limit: 0
|
|
273
273
|
};
|
|
274
274
|
if (Array.isArray(args.operations) && args.operations.length === 0) return {
|
|
275
275
|
ok: false,
|
|
276
|
-
message: "
|
|
276
|
+
message: "没有提供任何操作(operations 数组为空)。",
|
|
277
277
|
entries: [],
|
|
278
278
|
chars: 0,
|
|
279
279
|
limit: 0
|
|
280
280
|
};
|
|
281
281
|
if (args.operations !== void 0 && !Array.isArray(args.operations)) return {
|
|
282
282
|
ok: false,
|
|
283
|
-
message: "
|
|
283
|
+
message: "形状不合法:operations 必须是 {action, content?, old_text?} 对象的数组(单个操作时可省略 operations)。",
|
|
284
284
|
entries: [],
|
|
285
285
|
chars: 0,
|
|
286
286
|
limit: 0
|
|
@@ -345,7 +345,7 @@ async function apply(ctx, rawConfig = {}) {
|
|
|
345
345
|
const approval = approvalCtx.evolutionApproval;
|
|
346
346
|
const dispose = memoryDisabled ? approval.registerRunner("memory", () => Promise.resolve({
|
|
347
347
|
ok: false,
|
|
348
|
-
message: "
|
|
348
|
+
message: "拒绝:记忆工具已禁用(tool-memory memoryEnabled:false)—— 它的回放运行器无法执行这条暂存写入。请驳回该记录;若仍需要该写入,请在重新启用该工具后再暂存。"
|
|
349
349
|
})) : approval.registerRunner("memory", (args) => executeCore(args));
|
|
350
350
|
approvalCtx.effect(() => dispose, memoryDisabled ? "tool-memory.approval-runner-disabled" : "tool-memory.approval-runner");
|
|
351
351
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmzhen/dsh-tool-memory",
|
|
3
3
|
"description": "Model-facing memory tool and prompt context (community build)",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.25.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -27,21 +27,21 @@
|
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@deepseek-ai/schemastery": "^3.18.4",
|
|
30
|
-
"@lmzhen/dsh-evolution-approval": "^0.
|
|
31
|
-
"@lmzhen/dsh-evolution-core": "^0.
|
|
30
|
+
"@lmzhen/dsh-evolution-approval": "^0.25.0",
|
|
31
|
+
"@lmzhen/dsh-evolution-core": "^0.25.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
35
35
|
"@deepseek-ai/dsh-tools": "^0.2.0-rc.1",
|
|
36
36
|
"@deepseek-ai/dsh-system-prompt": "^0.2.0-rc.1",
|
|
37
|
-
"@lmzhen/dsh-memory": "^0.
|
|
37
|
+
"@lmzhen/dsh-memory": "^0.25.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@deepseek-ai/dsh-tools": "^0.2.0-rc.1",
|
|
41
41
|
"@deepseek-ai/dsh-system-prompt": "^0.2.0-rc.1",
|
|
42
42
|
"@deepseek-ai/dsh-agent-loop-testkit": "^0.2.0-rc.1",
|
|
43
|
-
"@lmzhen/dsh-evolution-approval": "^0.
|
|
44
|
-
"@lmzhen/dsh-memory": "^0.
|
|
45
|
-
"@lmzhen/dsh-memory-files": "^0.
|
|
43
|
+
"@lmzhen/dsh-evolution-approval": "^0.25.0",
|
|
44
|
+
"@lmzhen/dsh-memory": "^0.25.0",
|
|
45
|
+
"@lmzhen/dsh-memory-files": "^0.25.0"
|
|
46
46
|
}
|
|
47
47
|
}
|