@lmzhen/dsh-memory 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 +39 -0
- package/lib/invariant.js +8 -0
- package/lib/types/index.d.ts +50 -0
- package/lib/types/invariant.d.ts +5 -0
- package/package.json +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# @deepseek-ai/dsh-memory
|
|
2
|
+
|
|
3
|
+
Memory provider registry for self-evolution
|
|
4
|
+
|
|
5
|
+
## Model Experience
|
|
6
|
+
|
|
7
|
+
### Indirect model surface
|
|
8
|
+
|
|
9
|
+
#### What the model sees
|
|
10
|
+
|
|
11
|
+
`@deepseek-ai/dsh-memory` 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,39 @@
|
|
|
1
|
+
import { Service } from "@deepseek-ai/cordis";
|
|
2
|
+
//#region lib/types/index.js
|
|
3
|
+
/**
|
|
4
|
+
* Memory provider registry for the evolution family.
|
|
5
|
+
* Service Definition role; concrete providers register here.
|
|
6
|
+
* @module @lmzhen/dsh-memory
|
|
7
|
+
*/
|
|
8
|
+
var MemoryRegistry = class extends Service {
|
|
9
|
+
providers = /* @__PURE__ */ new Map();
|
|
10
|
+
constructor(ctx) {
|
|
11
|
+
super(ctx, "memory");
|
|
12
|
+
}
|
|
13
|
+
registerProvider(provider) {
|
|
14
|
+
if (this.providers.has(provider.name)) throw new Error(`memory provider "${provider.name}" already registered`);
|
|
15
|
+
this.providers.set(provider.name, provider);
|
|
16
|
+
return () => {
|
|
17
|
+
if (this.providers.get(provider.name) === provider) this.providers.delete(provider.name);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
provider() {
|
|
21
|
+
const first = this.providers.values().next().value;
|
|
22
|
+
if (!first) throw new Error("memory: no provider registered");
|
|
23
|
+
return first;
|
|
24
|
+
}
|
|
25
|
+
read(target, signal) {
|
|
26
|
+
return this.provider().read(target, signal);
|
|
27
|
+
}
|
|
28
|
+
applyBatch(target, operations, signal) {
|
|
29
|
+
return this.provider().applyBatch(target, operations, signal);
|
|
30
|
+
}
|
|
31
|
+
snapshot(signal) {
|
|
32
|
+
return this.provider().snapshot(signal);
|
|
33
|
+
}
|
|
34
|
+
renderContext() {
|
|
35
|
+
return this.provider().renderContext();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
//#endregion
|
|
39
|
+
export { MemoryRegistry, MemoryRegistry as default };
|
package/lib/invariant.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region lib/types/invariant.js
|
|
2
|
+
const PACKAGE_NAME = "@deepseek-ai/dsh-memory";
|
|
3
|
+
const name = "memory-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,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory provider registry for the evolution family.
|
|
3
|
+
* Service Definition role; concrete providers register here.
|
|
4
|
+
* @module @deepseek-ai/dsh-memory
|
|
5
|
+
*/
|
|
6
|
+
import { Context, Service } from '@deepseek-ai/cordis';
|
|
7
|
+
export type MemoryTarget = 'memory' | 'user';
|
|
8
|
+
export interface MemoryOperation {
|
|
9
|
+
action: 'add' | 'replace' | 'remove';
|
|
10
|
+
facts?: string | undefined;
|
|
11
|
+
content?: string | undefined;
|
|
12
|
+
old_text?: string | undefined;
|
|
13
|
+
}
|
|
14
|
+
export interface MemoryApplyResult {
|
|
15
|
+
ok: boolean;
|
|
16
|
+
message: string;
|
|
17
|
+
entries: string[];
|
|
18
|
+
chars: number;
|
|
19
|
+
limit: number;
|
|
20
|
+
}
|
|
21
|
+
export interface MemorySnapshot {
|
|
22
|
+
version: number;
|
|
23
|
+
sha256: string;
|
|
24
|
+
memory: string[];
|
|
25
|
+
user: string[];
|
|
26
|
+
}
|
|
27
|
+
export interface MemoryProvider {
|
|
28
|
+
readonly name: string;
|
|
29
|
+
read(target: MemoryTarget, signal?: AbortSignal): Promise<string[]>;
|
|
30
|
+
applyBatch(target: MemoryTarget, operations: MemoryOperation[], signal?: AbortSignal): Promise<MemoryApplyResult>;
|
|
31
|
+
snapshot(signal?: AbortSignal): Promise<MemorySnapshot>;
|
|
32
|
+
renderContext(): Promise<string>;
|
|
33
|
+
}
|
|
34
|
+
declare module '@deepseek-ai/cordis' {
|
|
35
|
+
interface Context {
|
|
36
|
+
memory: MemoryRegistry;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export declare class MemoryRegistry extends Service {
|
|
40
|
+
private readonly providers;
|
|
41
|
+
constructor(ctx: Context);
|
|
42
|
+
registerProvider(provider: MemoryProvider): () => void;
|
|
43
|
+
private provider;
|
|
44
|
+
read(target: MemoryTarget, signal?: AbortSignal): Promise<string[]>;
|
|
45
|
+
applyBatch(target: MemoryTarget, operations: MemoryOperation[], signal?: AbortSignal): Promise<MemoryApplyResult>;
|
|
46
|
+
snapshot(signal?: AbortSignal): Promise<MemorySnapshot>;
|
|
47
|
+
renderContext(): Promise<string>;
|
|
48
|
+
}
|
|
49
|
+
export default MemoryRegistry;
|
|
50
|
+
//# sourceMappingURL=index.d.ts.map
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lmzhen/dsh-memory",
|
|
3
|
+
"description": "Memory provider registry for self-evolution (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"
|
|
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
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@deepseek-ai/dsh-invariants": "^0.1.0-rc.6",
|
|
39
|
+
"@deepseek-ai/cordis": "^4.0.1"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@deepseek-ai/dsh-invariants": "^0.1.0-rc.6"
|
|
43
|
+
}
|
|
44
|
+
}
|