@lmzhen/dsh-tool-memory 0.1.0-rc.22 → 0.1.0-rc.24

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 -1
  2. package/package.json +5 -5
package/lib/index.js CHANGED
@@ -27,6 +27,17 @@ const MEMORY_GUIDANCE = "You have durable memory across sessions. Save stable us
27
27
  * `MEMORY_GUIDANCE` system prompt.
28
28
  */
29
29
  const MEMORY_TOOL_DESCRIPTION = "Save durable facts to persistent memory that survive across sessions. Memory is injected into future turns, so keep entries compact and high-signal.\n\nHOW: make all changes in ONE call via an `operations` array (each item {action, content?, old_text?}). The batch applies atomically and the char limit is checked on the final result — so one call can remove/replace stale entries to free room AND add new ones. Use bare action/content/old_text only for a single lone change.\n\nWHEN: save proactively when the user states a preference, correction, or personal detail, or you learn a stable fact about their environment, conventions, or workflow. Priority: user preferences & corrections > environment facts > procedures. The best memory stops the user repeating themselves.\n\nTARGETS: \"user\" = who the user is (name, role, preferences, style). \"memory\" = your notes (environment, conventions, tool quirks, lessons).\n\nSKIP: trivial/obvious info, easily re-discovered facts, task progress, completed-work logs, temporary TODO state. To recall a past session use `session_search`, not memory. Reusable procedures belong in a skill, not memory.";
30
+ /**
31
+ * The requesting session's effective approval policy, mirroring
32
+ * `dsh-user-approval` (override ?? configured default). Returns undefined when
33
+ * the approval service is not mounted or no session is available — callers
34
+ * keep their previous behavior.
35
+ */
36
+ function effectiveSessionPolicy(ctx, session) {
37
+ const approval = ctx.get("approval");
38
+ if (!approval || session === void 0) return void 0;
39
+ return approval.overrideOf(session) ?? approval.config.policy ?? "ask";
40
+ }
30
41
  const Config = z.object({
31
42
  memoryEnabled: z.boolean().default(true),
32
43
  entryPreviewChars: z.number().default(200)
@@ -148,13 +159,15 @@ async function apply(ctx, rawConfig) {
148
159
  old_text: args.old_text
149
160
  };
150
161
  const origin = exec.agent?.session.header.origin === "subagent" ? "background_review" : "foreground";
162
+ const sessionPolicy = effectiveSessionPolicy(ctx, exec.agent?.session);
151
163
  const approval = ctx.get("evolutionApproval");
152
164
  if (approval) {
153
165
  const decision = await approval.request({
154
166
  kind: "memory",
155
167
  summary: `memory ${target} ${Array.isArray(args.operations) ? `${args.operations.length} ops` : args.action ?? "add"}`,
156
168
  args: normalized,
157
- origin
169
+ origin,
170
+ ...sessionPolicy !== void 0 ? { sessionPolicy } : {}
158
171
  });
159
172
  if (decision.action === "staged") return {
160
173
  ok: true,
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.1.0-rc.22",
4
+ "version": "0.1.0-rc.24",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -39,15 +39,15 @@
39
39
  "@deepseek-ai/cordis": "^4.0.1",
40
40
  "@deepseek-ai/dsh-tools": "^0.1.0-rc.6",
41
41
  "@deepseek-ai/dsh-system-prompt": "^0.1.0-rc.6",
42
- "@lmzhen/dsh-memory": "^0.1.0-rc.22",
43
- "@lmzhen/dsh-memory-files": "^0.1.0-rc.22"
42
+ "@lmzhen/dsh-memory": "^0.1.0-rc.24",
43
+ "@lmzhen/dsh-memory-files": "^0.1.0-rc.24"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6",
47
47
  "@deepseek-ai/dsh-tools": "^0.1.0-rc.6",
48
48
  "@deepseek-ai/dsh-system-prompt": "^0.1.0-rc.6",
49
49
  "@deepseek-ai/dsh-agent-loop-testkit": "^0.1.0-rc.6",
50
- "@lmzhen/dsh-memory": "^0.1.0-rc.22",
51
- "@lmzhen/dsh-memory-files": "^0.1.0-rc.22"
50
+ "@lmzhen/dsh-memory": "^0.1.0-rc.24",
51
+ "@lmzhen/dsh-memory-files": "^0.1.0-rc.24"
52
52
  }
53
53
  }