@lmzhen/dsh-tool-memory 0.5.0 → 0.6.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 +8 -3
- package/lib/types/index.d.ts +10 -0
- package/package.json +7 -7
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { effectiveSessionPolicy } from "@lmzhen/dsh-evolution-approval";
|
|
2
2
|
import z from "@deepseek-ai/schemastery";
|
|
3
3
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
4
|
-
import { MEMORY_GUIDANCE_SECTION_ORDER, clampedNumber, resolveExecOrigins } from "@lmzhen/dsh-evolution-core";
|
|
4
|
+
import { MEMORY_GUIDANCE_SECTION_ORDER, PARAM_NAMESPACES, clampedNumber, installParamSection, resolveExecOrigins } from "@lmzhen/dsh-evolution-core";
|
|
5
5
|
//#region lib/types/index.js
|
|
6
6
|
/**
|
|
7
7
|
* Model-facing memory tool and runtime-context memory snapshot.
|
|
@@ -10,6 +10,7 @@ import { MEMORY_GUIDANCE_SECTION_ORDER, clampedNumber, resolveExecOrigins } from
|
|
|
10
10
|
const name = "tool-memory";
|
|
11
11
|
/** Max characters of each echoed memory entry (single source for the Config default and the runtime slice). */
|
|
12
12
|
const DEFAULT_ENTRY_PREVIEW_CHARS = 200;
|
|
13
|
+
const TOOL_MEMORY_SETTINGS_SCHEMA = z.object({ entryPreviewChars: z.number().min(1).default(DEFAULT_ENTRY_PREVIEW_CHARS) });
|
|
13
14
|
const inject = ["tools", "memory"];
|
|
14
15
|
/**
|
|
15
16
|
* System-prompt memory guidance, aligned with Hermes `MEMORY_GUIDANCE`.
|
|
@@ -34,6 +35,10 @@ const Config = z.object({
|
|
|
34
35
|
async function apply(ctx, rawConfig = {}) {
|
|
35
36
|
const memoryDisabled = rawConfig.memoryEnabled === false;
|
|
36
37
|
const entryPreviewChars = clampedNumber(rawConfig.entryPreviewChars, DEFAULT_ENTRY_PREVIEW_CHARS, { min: 1 });
|
|
38
|
+
const previewOverrides = installParamSection(ctx, PARAM_NAMESPACES["tool-memory"] ?? "tool-memory", TOOL_MEMORY_SETTINGS_SCHEMA, { entryPreviewChars }, { warn: (message) => {
|
|
39
|
+
ctx.logger.warn("tool-memory: " + message);
|
|
40
|
+
} });
|
|
41
|
+
const previewChars = () => previewOverrides.get("entryPreviewChars") ?? entryPreviewChars;
|
|
37
42
|
if (entryPreviewChars !== (rawConfig.entryPreviewChars ?? DEFAULT_ENTRY_PREVIEW_CHARS)) ctx.logger.warn(`tool-memory: entryPreviewChars=${String(rawConfig.entryPreviewChars)} is invalid; falling back to the default ${DEFAULT_ENTRY_PREVIEW_CHARS}`);
|
|
38
43
|
const systemPrompt = ctx.get("systemPrompt");
|
|
39
44
|
let snapshotText = "";
|
|
@@ -115,7 +120,7 @@ async function apply(ctx, rawConfig = {}) {
|
|
|
115
120
|
return {
|
|
116
121
|
ok: result.ok,
|
|
117
122
|
message: result.message,
|
|
118
|
-
entries: result.entries.map((entry) => entry.slice(0,
|
|
123
|
+
entries: result.entries.map((entry) => entry.slice(0, previewChars())),
|
|
119
124
|
chars: result.chars,
|
|
120
125
|
limit: result.limit
|
|
121
126
|
};
|
|
@@ -314,4 +319,4 @@ async function apply(ctx, rawConfig = {}) {
|
|
|
314
319
|
});
|
|
315
320
|
}
|
|
316
321
|
//#endregion
|
|
317
|
-
export { Config, MEMORY_GUIDANCE, MEMORY_TOOL_DESCRIPTION, apply, inject, name };
|
|
322
|
+
export { Config, MEMORY_GUIDANCE, MEMORY_TOOL_DESCRIPTION, TOOL_MEMORY_SETTINGS_SCHEMA, apply, inject, name };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -5,6 +5,16 @@
|
|
|
5
5
|
import type { Context } from '@deepseek-ai/cordis';
|
|
6
6
|
import z from '@deepseek-ai/schemastery';
|
|
7
7
|
export declare const name = "tool-memory";
|
|
8
|
+
/** G3/S3.2: the memory TOOL's user-tunable display knob (canonical id).
|
|
9
|
+
* `memoryEnabled` stays a deployment switch on purpose: it decides whether the
|
|
10
|
+
* tool and its prompt section are REGISTERED at all, so making it live would mean
|
|
11
|
+
* dynamic registration with catalog-visible effects — a structural change this
|
|
12
|
+
* batch deliberately does not make (registry tier E2). */
|
|
13
|
+
export interface ToolMemorySettings {
|
|
14
|
+
/** Characters of one memory entry shown in a tool result preview. */
|
|
15
|
+
entryPreviewChars: number;
|
|
16
|
+
}
|
|
17
|
+
export declare const TOOL_MEMORY_SETTINGS_SCHEMA: z<ToolMemorySettings>;
|
|
8
18
|
export declare const inject: string[];
|
|
9
19
|
/**
|
|
10
20
|
* System-prompt memory guidance, aligned with Hermes `MEMORY_GUIDANCE`.
|
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.6.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.1",
|
|
30
|
-
"@lmzhen/dsh-evolution-approval": "^0.
|
|
31
|
-
"@lmzhen/dsh-evolution-core": "^0.
|
|
30
|
+
"@lmzhen/dsh-evolution-approval": "^0.6.0",
|
|
31
|
+
"@lmzhen/dsh-evolution-core": "^0.6.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
35
35
|
"@deepseek-ai/dsh-tools": "^0.1.5-rc.2",
|
|
36
36
|
"@deepseek-ai/dsh-system-prompt": "^0.1.5-rc.2",
|
|
37
|
-
"@lmzhen/dsh-memory": "^0.
|
|
37
|
+
"@lmzhen/dsh-memory": "^0.6.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@deepseek-ai/dsh-tools": "^0.1.5-rc.2",
|
|
41
41
|
"@deepseek-ai/dsh-system-prompt": "^0.1.5-rc.2",
|
|
42
42
|
"@deepseek-ai/dsh-agent-loop-testkit": "^0.1.5-rc.2",
|
|
43
|
-
"@lmzhen/dsh-evolution-approval": "^0.
|
|
44
|
-
"@lmzhen/dsh-memory": "^0.
|
|
45
|
-
"@lmzhen/dsh-memory-files": "^0.
|
|
43
|
+
"@lmzhen/dsh-evolution-approval": "^0.6.0",
|
|
44
|
+
"@lmzhen/dsh-memory": "^0.6.0",
|
|
45
|
+
"@lmzhen/dsh-memory-files": "^0.6.0"
|
|
46
46
|
}
|
|
47
47
|
}
|