@lmzhen/dsh-memory-files 0.1.0-rc.1
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/README.md +24 -0
- package/lib/index.js +56 -0
- package/lib/invariant.js +8 -0
- package/lib/types/index.d.ts +20 -0
- package/lib/types/invariant.d.ts +5 -0
- package/package.json +50 -0
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# @deepseek-ai/dsh-memory-files
|
|
2
|
+
|
|
3
|
+
Local layered memory provider
|
|
4
|
+
|
|
5
|
+
## Model Experience
|
|
6
|
+
|
|
7
|
+
### Indirect model surface
|
|
8
|
+
|
|
9
|
+
#### What the model sees
|
|
10
|
+
|
|
11
|
+
`@deepseek-ai/dsh-memory-files` registers no direct prompt or tool schema itself. Model-visible effects are owned by the packages that consume this service.
|
|
12
|
+
|
|
13
|
+
#### Token effect
|
|
14
|
+
|
|
15
|
+
Zero direct token effect from this package; consumers add any model-visible tokens.
|
|
16
|
+
|
|
17
|
+
#### KV Cache effect
|
|
18
|
+
|
|
19
|
+
Independent of request-prefix construction. This package does not alter the assembled prompt or tool list.
|
|
20
|
+
|
|
21
|
+
## Known Limitations and Deferred Work
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
- No known durable consumer gaps at this time. Runtime contracts are covered by package and boundary tests.
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import z from "@deepseek-ai/schemastery";
|
|
3
|
+
import { MemoryStore, evolutionIoAdapter } from "@lmzhen/dsh-evolution-core";
|
|
4
|
+
//#region lib/types/index.js
|
|
5
|
+
/**
|
|
6
|
+
* Local layered memory provider for `ctx.memory`.
|
|
7
|
+
* @module @lmzhen/dsh-memory-files
|
|
8
|
+
*/
|
|
9
|
+
const name = "memory-files";
|
|
10
|
+
const inject = ["memory", "evolutionIo"];
|
|
11
|
+
const Config = z.object({
|
|
12
|
+
providerName: z.string().default("files"),
|
|
13
|
+
memoryCharLimit: z.number().default(2200),
|
|
14
|
+
userCharLimit: z.number().default(1375),
|
|
15
|
+
addDatePrefix: z.boolean().default(false),
|
|
16
|
+
root: z.string().default(""),
|
|
17
|
+
maxConsolidationFailures: z.number().default(3)
|
|
18
|
+
});
|
|
19
|
+
function apply(ctx, rawConfig) {
|
|
20
|
+
const config = rawConfig;
|
|
21
|
+
const io = evolutionIoAdapter(() => ctx.evolutionIo.provider());
|
|
22
|
+
const store = new MemoryStore({
|
|
23
|
+
memoryCharLimit: config.memoryCharLimit,
|
|
24
|
+
userCharLimit: config.userCharLimit,
|
|
25
|
+
addDatePrefix: config.addDatePrefix,
|
|
26
|
+
maxConsolidationFailures: config.maxConsolidationFailures,
|
|
27
|
+
...config.root ? { root: config.root } : {},
|
|
28
|
+
io
|
|
29
|
+
});
|
|
30
|
+
const provider = {
|
|
31
|
+
name: config.providerName,
|
|
32
|
+
read: (target, _signal) => store.read(target),
|
|
33
|
+
applyBatch: async (target, operations) => {
|
|
34
|
+
const normalized = operations.map((op) => ({
|
|
35
|
+
action: op.action,
|
|
36
|
+
facts: op.facts ?? op.content,
|
|
37
|
+
old_text: op.old_text
|
|
38
|
+
}));
|
|
39
|
+
return store.applyBatch(target, normalized);
|
|
40
|
+
},
|
|
41
|
+
snapshot: async () => {
|
|
42
|
+
const [memory, user] = await Promise.all([store.read("memory"), store.read("user")]);
|
|
43
|
+
const text = JSON.stringify([memory, user]);
|
|
44
|
+
return {
|
|
45
|
+
version: 1,
|
|
46
|
+
sha256: createHash("sha256").update(text).digest("hex"),
|
|
47
|
+
memory,
|
|
48
|
+
user
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
renderContext: () => store.renderContext()
|
|
52
|
+
};
|
|
53
|
+
ctx.effect(() => ctx.memory.registerProvider(provider), "memory-files.provider");
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { Config, apply, inject, name };
|
package/lib/invariant.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region lib/types/invariant.js
|
|
2
|
+
const PACKAGE_NAME = "@deepseek-ai/dsh-memory-files";
|
|
3
|
+
const name = "memory-files-invariant";
|
|
4
|
+
const inject = ["invariants"];
|
|
5
|
+
const install = () => {};
|
|
6
|
+
const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
7
|
+
//#endregion
|
|
8
|
+
export { apply, inject, name };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local layered memory provider for `ctx.memory`.
|
|
3
|
+
* @module @deepseek-ai/dsh-memory-files
|
|
4
|
+
*/
|
|
5
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
6
|
+
import z from '@deepseek-ai/schemastery';
|
|
7
|
+
export declare const name = "memory-files";
|
|
8
|
+
export declare const inject: string[];
|
|
9
|
+
export interface Config {
|
|
10
|
+
providerName?: string;
|
|
11
|
+
memoryCharLimit?: number;
|
|
12
|
+
userCharLimit?: number;
|
|
13
|
+
addDatePrefix?: boolean;
|
|
14
|
+
root?: string;
|
|
15
|
+
/** How many consolidation failures one turn tolerates before the tool tells the model to stop retrying. */
|
|
16
|
+
maxConsolidationFailures?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare const Config: z<Config>;
|
|
19
|
+
export declare function apply(ctx: Context, rawConfig: Config): void;
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lmzhen/dsh-memory-files",
|
|
3
|
+
"description": "Local layered memory provider (community build)",
|
|
4
|
+
"version": "0.1.0-rc.1",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/lmzhen/dsh-evolution.git",
|
|
11
|
+
"directory": "packages/dsh-memory-files"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "lib/index.js",
|
|
15
|
+
"types": "lib/types/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./lib/types/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./invariant": {
|
|
22
|
+
"types": "./lib/types/invariant.d.ts",
|
|
23
|
+
"default": "./lib/invariant.js"
|
|
24
|
+
},
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"lib/index.js",
|
|
29
|
+
"lib/invariant.js",
|
|
30
|
+
"lib/types/**/*.d.ts",
|
|
31
|
+
"lib/types/invariant.d.ts"
|
|
32
|
+
],
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@deepseek-ai/schemastery": "^3.18.1",
|
|
36
|
+
"@lmzhen/dsh-evolution-core": "^0.1.0-rc.1"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
40
|
+
"@deepseek-ai/dsh-invariants": "^0.1.0-rc.6",
|
|
41
|
+
"@lmzhen/dsh-evolution-io": "^0.1.0-rc.1",
|
|
42
|
+
"@lmzhen/dsh-memory": "^0.1.0-rc.1"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@deepseek-ai/dsh-invariants": "^0.1.0-rc.6",
|
|
46
|
+
"@lmzhen/dsh-evolution-core": "^0.1.0-rc.1",
|
|
47
|
+
"@lmzhen/dsh-evolution-io": "^0.1.0-rc.1",
|
|
48
|
+
"@lmzhen/dsh-memory": "^0.1.0-rc.1"
|
|
49
|
+
}
|
|
50
|
+
}
|