@lmzhen/dsh-tool-memory 0.23.0 → 0.24.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.
Files changed (2) hide show
  1. package/lib/index.js +14 -14
  2. 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: "Every entry of operations must be an object.",
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: "target" must be "memory" or "user" (got ${String(target)}); refusing the write.`,
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: "${field}" must be a string (got ${typeof value}); refusing the write.`,
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: operations[${index}].${field} must be a string (got ${typeof value}); refusing the write — re-approving cannot fix a payload defect, so reject the record.`,
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 : `Operation ${position} (add): facts is required. No operations were applied.`;
162
- if (op.action !== "remove" && op.action !== "replace") return `Operation ${position}: unknown action "${String(op.action)}" (expected add/remove/replace). No operations were applied.`;
163
- if (!(op.old_text ?? "").trim()) return `Operation ${position} (${op.action}): old_text is required. No operations were applied.`;
164
- if (op.action === "replace" && !body) return `Operation ${position} (replace): facts is required.`;
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: "Every entry of operations must be an object.",
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: "Provide only one of facts or content per operation (same field); different values were given.",
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: "Provide only one of facts or content (same field); different values were given.",
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: "No operations provided (the operations array is empty).",
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: "Invalid shape: operations must be an array of {action, content?, old_text?} objects (or omit operations for a single operation).",
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: "Refused: the memory tool is disabled (tool-memory memoryEnabled:false) — its replay runner cannot execute this staged write. Reject the record; re-stage after re-enabling the tool if the write is still wanted."
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.23.0",
4
+ "version": "0.24.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.23.0",
31
- "@lmzhen/dsh-evolution-core": "^0.23.0"
30
+ "@lmzhen/dsh-evolution-approval": "^0.24.0",
31
+ "@lmzhen/dsh-evolution-core": "^0.24.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.23.0"
37
+ "@lmzhen/dsh-memory": "^0.24.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.23.0",
44
- "@lmzhen/dsh-memory": "^0.23.0",
45
- "@lmzhen/dsh-memory-files": "^0.23.0"
43
+ "@lmzhen/dsh-evolution-approval": "^0.24.0",
44
+ "@lmzhen/dsh-memory": "^0.24.0",
45
+ "@lmzhen/dsh-memory-files": "^0.24.0"
46
46
  }
47
47
  }