kernl 0.6.2 → 0.7.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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-check-types.log +1 -1
- package/CHANGELOG.md +44 -0
- package/dist/agent/__tests__/concurrency.test.js +1 -1
- package/dist/agent/__tests__/run.test.js +1 -1
- package/dist/agent/__tests__/systools.test.d.ts +2 -0
- package/dist/agent/__tests__/systools.test.d.ts.map +1 -0
- package/dist/agent/__tests__/systools.test.js +121 -0
- package/dist/{types/agent.d.ts → agent/types.d.ts} +19 -2
- package/dist/agent/types.d.ts.map +1 -0
- package/dist/agent.d.ts +48 -6
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +100 -13
- package/dist/api/models/thread.d.ts +1 -1
- package/dist/api/resources/agents/agents.d.ts +38 -0
- package/dist/api/resources/agents/agents.d.ts.map +1 -0
- package/dist/api/resources/agents/agents.js +44 -0
- package/dist/api/resources/agents/index.d.ts +2 -0
- package/dist/api/resources/agents/index.d.ts.map +1 -0
- package/dist/api/resources/agents/index.js +1 -0
- package/dist/api/resources/threads/threads.d.ts +1 -1
- package/dist/api/resources/threads/threads.d.ts.map +1 -1
- package/dist/api/resources/threads/threads.js +1 -1
- package/dist/api/resources/threads/types.d.ts +2 -2
- package/dist/api/resources/threads/types.d.ts.map +1 -1
- package/dist/context.d.ts +10 -4
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +5 -0
- package/dist/guardrail.d.ts +2 -2
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/internal.d.ts +2 -2
- package/dist/internal.js +1 -1
- package/dist/kernl/index.d.ts +1 -1
- package/dist/kernl/index.d.ts.map +1 -1
- package/dist/kernl/index.js +0 -1
- package/dist/kernl/kernl.d.ts +11 -20
- package/dist/kernl/kernl.d.ts.map +1 -1
- package/dist/kernl/kernl.js +37 -34
- package/dist/kernl/types.d.ts +91 -0
- package/dist/kernl/types.d.ts.map +1 -0
- package/dist/lib/error.d.ts +2 -2
- package/dist/lifecycle.d.ts +2 -2
- package/dist/memory/codec.d.ts +32 -0
- package/dist/memory/codec.d.ts.map +1 -0
- package/dist/memory/codec.js +97 -0
- package/dist/memory/codecs/domain.d.ts +34 -0
- package/dist/memory/codecs/domain.d.ts.map +1 -0
- package/dist/memory/codecs/domain.js +99 -0
- package/dist/memory/codecs/identity.d.ts +12 -0
- package/dist/memory/codecs/identity.d.ts.map +1 -0
- package/dist/memory/codecs/identity.js +17 -0
- package/dist/memory/codecs/index.d.ts +31 -0
- package/dist/memory/codecs/index.d.ts.map +1 -0
- package/dist/memory/codecs/index.js +39 -0
- package/dist/memory/codecs/tpuf.d.ts +38 -0
- package/dist/memory/codecs/tpuf.d.ts.map +1 -0
- package/dist/memory/codecs/tpuf.js +90 -0
- package/dist/memory/encoder.d.ts +29 -0
- package/dist/memory/encoder.d.ts.map +1 -0
- package/dist/memory/encoder.js +45 -0
- package/dist/memory/handle.d.ts +89 -0
- package/dist/memory/handle.d.ts.map +1 -0
- package/dist/memory/handle.js +128 -0
- package/dist/memory/index.d.ts +12 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +7 -0
- package/dist/memory/indexes.d.ts +91 -0
- package/dist/memory/indexes.d.ts.map +1 -0
- package/dist/memory/indexes.js +7 -0
- package/dist/memory/memory.d.ts +55 -0
- package/dist/memory/memory.d.ts.map +1 -0
- package/dist/memory/memory.js +113 -0
- package/dist/memory/schema.d.ts +41 -0
- package/dist/memory/schema.d.ts.map +1 -0
- package/dist/memory/schema.js +112 -0
- package/dist/memory/store.d.ts +36 -0
- package/dist/memory/store.d.ts.map +1 -0
- package/dist/memory/store.js +4 -0
- package/dist/memory/types.d.ts +250 -0
- package/dist/memory/types.d.ts.map +1 -0
- package/dist/memory/types.js +4 -0
- package/dist/storage/base.d.ts +6 -1
- package/dist/storage/base.d.ts.map +1 -1
- package/dist/storage/in-memory.d.ts +24 -2
- package/dist/storage/in-memory.d.ts.map +1 -1
- package/dist/storage/in-memory.js +131 -0
- package/dist/storage/thread.d.ts +1 -1
- package/dist/thread/__tests__/integration.test.js +1 -1
- package/dist/thread/__tests__/mock.d.ts +1 -1
- package/dist/thread/__tests__/namespace.test.js +1 -1
- package/dist/thread/__tests__/thread.test.js +1 -1
- package/dist/thread/thread.d.ts +2 -2
- package/dist/thread/thread.d.ts.map +1 -1
- package/dist/thread/thread.js +3 -1
- package/dist/{types/thread.d.ts → thread/types.d.ts} +2 -2
- package/dist/thread/types.d.ts.map +1 -0
- package/dist/thread/utils.d.ts +2 -2
- package/dist/thread/utils.d.ts.map +1 -1
- package/dist/tool/index.d.ts +1 -0
- package/dist/tool/index.d.ts.map +1 -1
- package/dist/tool/index.js +2 -0
- package/dist/tool/sys/index.d.ts +7 -0
- package/dist/tool/sys/index.d.ts.map +1 -0
- package/dist/tool/sys/index.js +6 -0
- package/dist/tool/sys/memory.d.ts +14 -0
- package/dist/tool/sys/memory.d.ts.map +1 -0
- package/dist/tool/sys/memory.js +103 -0
- package/dist/tool/tool.d.ts +1 -1
- package/dist/tool/tool.d.ts.map +1 -1
- package/dist/tool/tool.js +2 -2
- package/package.json +4 -2
- package/src/agent/__tests__/systools.test.ts +146 -0
- package/src/{types/agent.ts → agent/types.ts} +22 -1
- package/src/agent.ts +144 -36
- package/src/api/__tests__/threads.test.ts +2 -2
- package/src/api/models/thread.ts +1 -1
- package/src/api/resources/agents/agents.ts +56 -0
- package/src/api/resources/agents/index.ts +1 -0
- package/src/api/resources/threads/events.ts +1 -1
- package/src/api/resources/threads/threads.ts +2 -2
- package/src/api/resources/threads/types.ts +2 -2
- package/src/context.ts +14 -136
- package/src/guardrail.ts +2 -2
- package/src/index.ts +35 -6
- package/src/internal.ts +2 -2
- package/src/kernl/index.ts +8 -0
- package/src/{kernl.ts → kernl/kernl.ts} +50 -10
- package/src/kernl/types.ts +106 -0
- package/src/lib/error.ts +2 -2
- package/src/lifecycle.ts +2 -2
- package/src/memory/codecs/domain.ts +115 -0
- package/src/memory/codecs/identity.ts +28 -0
- package/src/memory/codecs/index.ts +61 -0
- package/src/memory/codecs/tpuf.ts +115 -0
- package/src/memory/encoder.ts +56 -0
- package/src/memory/handle.ts +189 -0
- package/src/memory/index.ts +49 -0
- package/src/memory/indexes.ts +108 -0
- package/src/memory/memory.ts +151 -0
- package/src/memory/schema.ts +142 -0
- package/src/memory/store.ts +47 -0
- package/src/memory/types.ts +282 -0
- package/src/storage/__tests__/in-memory.test.ts +1 -1
- package/src/storage/base.ts +7 -1
- package/src/storage/in-memory.ts +170 -2
- package/src/storage/thread.ts +1 -1
- package/src/thread/__tests__/integration.test.ts +1 -1
- package/src/thread/__tests__/mock.ts +1 -1
- package/src/thread/__tests__/thread.test.ts +1 -1
- package/src/thread/thread.ts +5 -3
- package/src/{types/thread.ts → thread/types.ts} +1 -1
- package/src/thread/utils.ts +2 -2
- package/src/tool/index.ts +3 -0
- package/src/tool/sys/index.ts +7 -0
- package/src/tool/sys/memory.ts +120 -0
- package/src/tool/tool.ts +8 -4
- package/tsconfig.tsbuildinfo +1 -0
- package/dist/api/__tests__/cursor-page.test.d.ts +0 -2
- package/dist/api/__tests__/cursor-page.test.d.ts.map +0 -1
- package/dist/api/__tests__/cursor-page.test.js +0 -414
- package/dist/api/__tests__/offset-page.test.d.ts +0 -2
- package/dist/api/__tests__/offset-page.test.d.ts.map +0 -1
- package/dist/api/__tests__/offset-page.test.js +0 -510
- package/dist/api/pagination/base.d.ts +0 -48
- package/dist/api/pagination/base.d.ts.map +0 -1
- package/dist/api/pagination/base.js +0 -45
- package/dist/api/pagination/cursor.d.ts +0 -44
- package/dist/api/pagination/cursor.d.ts.map +0 -1
- package/dist/api/pagination/cursor.js +0 -52
- package/dist/api/pagination/offset.d.ts +0 -42
- package/dist/api/pagination/offset.d.ts.map +0 -1
- package/dist/api/pagination/offset.js +0 -55
- package/dist/kernl/threads.d.ts +0 -110
- package/dist/kernl/threads.d.ts.map +0 -1
- package/dist/kernl/threads.js +0 -126
- package/dist/kernl.d.ts +0 -51
- package/dist/kernl.d.ts.map +0 -1
- package/dist/kernl.js +0 -91
- package/dist/types/agent.d.ts.map +0 -1
- package/dist/types/kernl.d.ts +0 -42
- package/dist/types/kernl.d.ts.map +0 -1
- package/dist/types/thread.d.ts.map +0 -1
- package/src/api/__tests__/cursor-page.test.ts +0 -512
- package/src/api/__tests__/offset-page.test.ts +0 -624
- package/src/api/pagination/base.ts +0 -79
- package/src/api/pagination/cursor.ts +0 -86
- package/src/api/pagination/offset.ts +0 -89
- package/src/types/kernl.ts +0 -51
- /package/dist/{types/agent.js → agent/types.js} +0 -0
- /package/dist/{types/kernl.js → kernl/types.js} +0 -0
- /package/dist/{types/thread.js → thread/types.js} +0 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory index handle with lazy initialization.
|
|
3
|
+
*/
|
|
4
|
+
import { planQuery, } from "@kernl-sdk/retrieval";
|
|
5
|
+
import { getAdapterCodecs } from "./codecs/index.js";
|
|
6
|
+
/**
|
|
7
|
+
* Domain-aware index handle for memory records with lazy initialization.
|
|
8
|
+
*
|
|
9
|
+
* - Wraps a SearchIndex and ensures the memory index is created before any operation.
|
|
10
|
+
* - Normalizes the idiosyncrasies of search adapters (capabilities, weird rules, ... - e.g. tpuf requires vector fields named
|
|
11
|
+
* literally 'vector' - dumb shit like this..)
|
|
12
|
+
*/
|
|
13
|
+
export class MemoryIndexHandle {
|
|
14
|
+
id;
|
|
15
|
+
index;
|
|
16
|
+
schema;
|
|
17
|
+
caps;
|
|
18
|
+
codecs;
|
|
19
|
+
providerOptions;
|
|
20
|
+
initPromise = null;
|
|
21
|
+
constructor(config) {
|
|
22
|
+
this.index = config.index;
|
|
23
|
+
this.id = config.indexId;
|
|
24
|
+
this.schema = config.schema;
|
|
25
|
+
this.caps = this.index.capabilities();
|
|
26
|
+
this.codecs = getAdapterCodecs(this.index.id);
|
|
27
|
+
this.providerOptions = config.providerOptions;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Ensure memory index exists (lazy initialization).
|
|
31
|
+
*
|
|
32
|
+
* Safe to call multiple times - initialization only runs once.
|
|
33
|
+
*/
|
|
34
|
+
async ensureInit() {
|
|
35
|
+
if (!this.initPromise) {
|
|
36
|
+
this.initPromise = this.createIndex().catch((err) => {
|
|
37
|
+
this.initPromise = null;
|
|
38
|
+
throw err;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
await this.initPromise;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Create the memory index if it doesn't exist.
|
|
45
|
+
*/
|
|
46
|
+
async createIndex() {
|
|
47
|
+
try {
|
|
48
|
+
await this.index.createIndex({
|
|
49
|
+
id: this.id,
|
|
50
|
+
schema: this.codecs.schema.encode(this.schema),
|
|
51
|
+
providerOptions: this.providerOptions,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
// (TODO): we should probably enforce a stricter contract w/ tighter error types
|
|
56
|
+
//
|
|
57
|
+
// Ignore "already exists" errors
|
|
58
|
+
if (err.message?.includes("already exists") ||
|
|
59
|
+
err.message?.includes("AlreadyExists")) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
throw err;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Search for memory records matching the query.
|
|
67
|
+
*
|
|
68
|
+
* Adapts the query to backend capabilities, degrading gracefully
|
|
69
|
+
* when hybrid or multi-signal queries aren't supported.
|
|
70
|
+
*/
|
|
71
|
+
async query(input) {
|
|
72
|
+
const { input: planned } = planQuery(input, this.caps);
|
|
73
|
+
const q = this.codecs.query.encode(planned);
|
|
74
|
+
const handle = await this.handle();
|
|
75
|
+
const hits = await handle.query(q);
|
|
76
|
+
// decode hits back to IndexMemoryRecord format
|
|
77
|
+
return hits.map((hit) => ({
|
|
78
|
+
...hit,
|
|
79
|
+
document: hit.document
|
|
80
|
+
? this.codecs.doc.decode(hit.document)
|
|
81
|
+
: undefined,
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Insert or update memory records in the index.
|
|
86
|
+
*/
|
|
87
|
+
async upsert(docs) {
|
|
88
|
+
const arr = Array.isArray(docs) ? docs : [docs];
|
|
89
|
+
const encoded = arr.map((doc) => this.codecs.doc.encode(doc));
|
|
90
|
+
const handle = await this.handle();
|
|
91
|
+
return handle.upsert(encoded);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Partially update memory records without re-indexing vectors.
|
|
95
|
+
*
|
|
96
|
+
* Note: Patches don't include vector fields so we cast directly.
|
|
97
|
+
* Metadata field type mismatch (JSONObject vs FieldValue) is handled at runtime.
|
|
98
|
+
*/
|
|
99
|
+
async patch(patches) {
|
|
100
|
+
const handle = await this.handle();
|
|
101
|
+
return handle.patch(patches);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Remove memory records from the index.
|
|
105
|
+
*/
|
|
106
|
+
async delete(ids) {
|
|
107
|
+
const handle = await this.handle();
|
|
108
|
+
return handle.delete(ids);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Add a new field to the index schema.
|
|
112
|
+
*
|
|
113
|
+
* @throws Always throws - dynamic schema modification not supported
|
|
114
|
+
*/
|
|
115
|
+
async addField(_field, _schema) {
|
|
116
|
+
throw new Error("addField not supported for MemoryIndexHandle");
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get an initialized underlying index handle.
|
|
120
|
+
*
|
|
121
|
+
* Returns a handle typed for UnknownDocument since we encode/decode
|
|
122
|
+
* through the adapter codecs for backend-specific field mapping.
|
|
123
|
+
*/
|
|
124
|
+
async handle() {
|
|
125
|
+
await this.ensureInit();
|
|
126
|
+
return this.index.index(this.id);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory module.
|
|
3
|
+
*/
|
|
4
|
+
export { Memory } from "./memory.js";
|
|
5
|
+
export { MemoryByteEncoder } from "./encoder.js";
|
|
6
|
+
export { buildMemoryIndexSchema } from "./schema.js";
|
|
7
|
+
export { MemoryIndexHandle } from "./handle.js";
|
|
8
|
+
export type { MemoryIndexHandleConfig } from "./handle.js";
|
|
9
|
+
export type { TextByte, ImageByte, AudioByte, VideoByte, MemoryByte, IndexableByte, MemoryByteCodec, MemoryScope, MemoryKind, NewMemory, AgentMemoryCreate, MemoryConfig, MemoryReindexParams, MemoryRecord, MemoryRecordUpdate, MemoryFilter, MemoryListOptions, MemorySearchQuery, IndexMemoryRecord, IndexMemoryRecordPatch, WorkingMemorySnapshot, ShortTermMemorySnapshot, } from "./types.js";
|
|
10
|
+
export type { MemoryStore } from "./store.js";
|
|
11
|
+
export type { MemoryIndexBase, MemorySearchIndex, MemoryGraphIndex, MemoryArchiveIndex, GraphTraversalQuery, GraphTraversalResult, ArchiveQuery, ArchiveResult, } from "./indexes.js";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/memory/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,YAAY,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAExD,YAAY,EAEV,QAAQ,EACR,SAAS,EACT,SAAS,EACT,SAAS,EACT,UAAU,EACV,aAAa,EACb,eAAe,EAEf,WAAW,EACX,UAAU,EACV,SAAS,EACT,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,aAAa,GACd,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory index interfaces.
|
|
3
|
+
*
|
|
4
|
+
* Indexes are projections of the primary store (DB) that enable
|
|
5
|
+
* specialized query patterns (vector search, graph traversal, archival).
|
|
6
|
+
*/
|
|
7
|
+
import type { SearchHit } from "@kernl-sdk/retrieval";
|
|
8
|
+
import type { MemoryRecord, MemoryRecordUpdate, MemorySearchQuery, IndexMemoryRecord } from "./types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Base interface for memory indexes.
|
|
11
|
+
*
|
|
12
|
+
* All indexes share common lifecycle operations (index, patch, delete)
|
|
13
|
+
* but differ in their query interface.
|
|
14
|
+
*/
|
|
15
|
+
export interface MemoryIndexBase<TQuery, TResult> {
|
|
16
|
+
readonly id: string;
|
|
17
|
+
/**
|
|
18
|
+
* Query the index.
|
|
19
|
+
*/
|
|
20
|
+
query(query: TQuery): Promise<TResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Index one or more memory records (idempotent upsert).
|
|
23
|
+
*/
|
|
24
|
+
index(memories: MemoryRecord | MemoryRecord[]): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Partially update one or more records' projections.
|
|
27
|
+
*/
|
|
28
|
+
update(updates: MemoryRecordUpdate | MemoryRecordUpdate[]): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Remove one or more records from this index (DB row remains).
|
|
31
|
+
*/
|
|
32
|
+
delete(ids: string | string[]): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Index warming (optional).
|
|
35
|
+
*/
|
|
36
|
+
warm(index: string): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Memory search index - vector/semantic search over memories.
|
|
40
|
+
*/
|
|
41
|
+
export interface MemorySearchIndex extends MemoryIndexBase<MemorySearchQuery, SearchHit<IndexMemoryRecord>[]> {
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Graph traversal query (stub).
|
|
45
|
+
*/
|
|
46
|
+
export interface GraphTraversalQuery {
|
|
47
|
+
depth?: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Graph traversal result (stub).
|
|
51
|
+
*/
|
|
52
|
+
export interface GraphTraversalResult {
|
|
53
|
+
nodes: Array<{
|
|
54
|
+
id: string;
|
|
55
|
+
record?: MemoryRecord;
|
|
56
|
+
}>;
|
|
57
|
+
edges: Array<{
|
|
58
|
+
from: string;
|
|
59
|
+
to: string;
|
|
60
|
+
relation: string;
|
|
61
|
+
}>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Memory graph index - relationship/graph traversal over memories (stub).
|
|
65
|
+
*/
|
|
66
|
+
export interface MemoryGraphIndex extends MemoryIndexBase<GraphTraversalQuery, GraphTraversalResult> {
|
|
67
|
+
/**
|
|
68
|
+
* Explicit traversal API (alias for query).
|
|
69
|
+
*/
|
|
70
|
+
traverse(query: GraphTraversalQuery): Promise<GraphTraversalResult>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Archive query (stub).
|
|
74
|
+
*/
|
|
75
|
+
export interface ArchiveQuery {
|
|
76
|
+
before?: number;
|
|
77
|
+
collections?: string[];
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Archive result (stub).
|
|
81
|
+
*/
|
|
82
|
+
export interface ArchiveResult {
|
|
83
|
+
id: string;
|
|
84
|
+
uri: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Memory archive index - cold storage/archival backend (stub).
|
|
88
|
+
*/
|
|
89
|
+
export interface MemoryArchiveIndex extends MemoryIndexBase<ArchiveQuery, ArchiveResult[]> {
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=indexes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexes.d.ts","sourceRoot":"","sources":["../../src/memory/indexes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAEjB;;;;;GAKG;AACH,MAAM,WAAW,eAAe,CAAC,MAAM,EAAE,OAAO;IAC9C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAqD;IAExE;;OAEG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEvC;;OAEG;IACH,KAAK,CAAC,QAAQ,EAAE,YAAY,GAAG,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9D;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,kBAAkB,GAAG,kBAAkB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1E;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9C;;OAEG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,iBACf,SAAQ,eAAe,CAAC,iBAAiB,EAAE,SAAS,CAAC,iBAAiB,CAAC,EAAE,CAAC;CAAG;AAE/E;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAElC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IAEnC,KAAK,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,YAAY,CAAA;KAAE,CAAC,CAAC;IACpD,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC9D;AAED;;GAEG;AACH,MAAM,WAAW,gBACf,SAAQ,eAAe,CAAC,mBAAmB,EAAE,oBAAoB,CAAC;IAClE;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACrE;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAE3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAE5B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,kBACf,SAAQ,eAAe,CAAC,YAAY,EAAE,aAAa,EAAE,CAAC;CAAG"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { SearchHit } from "@kernl-sdk/retrieval";
|
|
2
|
+
import type { NewMemory, MemoryRecord, MemoryRecordUpdate, MemoryScope, MemoryConfig, MemorySearchQuery, MemoryListOptions, IndexMemoryRecord, WorkingMemorySnapshot, ShortTermMemorySnapshot, MemoryReindexParams } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Memory is the primary memory abstraction for agents.
|
|
5
|
+
*
|
|
6
|
+
* Sits above storage/index layers + owns cognitive policy, eviction/TTL, consolidation.
|
|
7
|
+
*
|
|
8
|
+
* - L1 / wmem: active working set exposed to the model
|
|
9
|
+
* - L2 / smem: bounded recent context with a TTL
|
|
10
|
+
* - L3 / lmem: durable, structured long-term store
|
|
11
|
+
*
|
|
12
|
+
* Delegates persistence to storage adapters and optional indexes as
|
|
13
|
+
* _projections_ of the primary memory store.
|
|
14
|
+
*/
|
|
15
|
+
export declare class Memory {
|
|
16
|
+
private readonly store;
|
|
17
|
+
private readonly _search;
|
|
18
|
+
private readonly encoder;
|
|
19
|
+
private readonly rcodec;
|
|
20
|
+
constructor(config: MemoryConfig);
|
|
21
|
+
/**
|
|
22
|
+
* Create a new memory record.
|
|
23
|
+
* Writes to primary store first, then indexes if configured.
|
|
24
|
+
*/
|
|
25
|
+
create(memory: NewMemory): Promise<MemoryRecord>;
|
|
26
|
+
/**
|
|
27
|
+
* Update an existing memory record.
|
|
28
|
+
* Updates primary store, then re-indexes or patches search index.
|
|
29
|
+
*/
|
|
30
|
+
update(update: MemoryRecordUpdate): Promise<MemoryRecord>;
|
|
31
|
+
/**
|
|
32
|
+
* Semantic/metadata search across memories.
|
|
33
|
+
*
|
|
34
|
+
* Sends rich query with both text and vector - the index handle
|
|
35
|
+
* adapts based on backend capabilities (e.g. drops text for pgvector).
|
|
36
|
+
*/
|
|
37
|
+
search(q: MemorySearchQuery): Promise<SearchHit<IndexMemoryRecord>[]>;
|
|
38
|
+
/**
|
|
39
|
+
* List memories matching the filter.
|
|
40
|
+
*/
|
|
41
|
+
list(options?: MemoryListOptions): Promise<MemoryRecord[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Repair indexing for a memory without modifying the DB row.
|
|
44
|
+
*/
|
|
45
|
+
reindex(params: MemoryReindexParams): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Load working memory (L1) - wmem-pinned memories for the scope.
|
|
48
|
+
*/
|
|
49
|
+
loadWorkingMemory(scope: MemoryScope): Promise<WorkingMemorySnapshot>;
|
|
50
|
+
/**
|
|
51
|
+
* Load short-term memory (L2) - active smem for the scope.
|
|
52
|
+
*/
|
|
53
|
+
loadShortTermMemory(scope: MemoryScope): Promise<ShortTermMemorySnapshot>;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/memory/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAInE,OAAO,KAAK,EACV,SAAS,EACT,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EAEjB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAGjB;;;;;;;;;;;GAWG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAc;IACpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwC;IAEhE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkB;IAC1C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8C;gBAEzD,MAAM,EAAE,YAAY;IAShC;;;OAGG;IACG,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC;IAYtD;;;OAGG;IACG,MAAM,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC;IAe/D;;;;;OAKG;IACG,MAAM,CAAC,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,SAAS,CAAC,iBAAiB,CAAC,EAAE,CAAC;IAc3E;;OAEG;IACG,IAAI,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAIhE;;OAEG;IACG,OAAO,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBzD;;OAEG;IACG,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAO3E;;OAEG;IACG,mBAAmB,CACvB,KAAK,EAAE,WAAW,GACjB,OAAO,CAAC,uBAAuB,CAAC;CAMpC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { MEMORY_FILTER, PATCH_CODEC, recordCodec } from "./codecs/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Memory is the primary memory abstraction for agents.
|
|
4
|
+
*
|
|
5
|
+
* Sits above storage/index layers + owns cognitive policy, eviction/TTL, consolidation.
|
|
6
|
+
*
|
|
7
|
+
* - L1 / wmem: active working set exposed to the model
|
|
8
|
+
* - L2 / smem: bounded recent context with a TTL
|
|
9
|
+
* - L3 / lmem: durable, structured long-term store
|
|
10
|
+
*
|
|
11
|
+
* Delegates persistence to storage adapters and optional indexes as
|
|
12
|
+
* _projections_ of the primary memory store.
|
|
13
|
+
*/
|
|
14
|
+
export class Memory {
|
|
15
|
+
store;
|
|
16
|
+
_search;
|
|
17
|
+
encoder;
|
|
18
|
+
rcodec;
|
|
19
|
+
constructor(config) {
|
|
20
|
+
this.store = config.store;
|
|
21
|
+
this._search = config.search ?? null;
|
|
22
|
+
// TODO: default encoder using text-embedding-3-small
|
|
23
|
+
this.encoder = config.encoder;
|
|
24
|
+
this.rcodec = recordCodec(config.encoder);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create a new memory record.
|
|
28
|
+
* Writes to primary store first, then indexes if configured.
|
|
29
|
+
*/
|
|
30
|
+
async create(memory) {
|
|
31
|
+
const record = await this.store.create(memory);
|
|
32
|
+
// index into search if avail
|
|
33
|
+
if (this._search) {
|
|
34
|
+
const indexed = await this.rcodec.encode(record);
|
|
35
|
+
await this._search.upsert(indexed);
|
|
36
|
+
}
|
|
37
|
+
return record;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Update an existing memory record.
|
|
41
|
+
* Updates primary store, then re-indexes or patches search index.
|
|
42
|
+
*/
|
|
43
|
+
async update(update) {
|
|
44
|
+
const record = await this.store.update(update.id, update);
|
|
45
|
+
if (!this._search)
|
|
46
|
+
return record;
|
|
47
|
+
if (update.content) {
|
|
48
|
+
const indexed = await this.rcodec.encode(record); // content changed → full re-index with new embeddings
|
|
49
|
+
await this._search.upsert(indexed);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const patch = PATCH_CODEC.encode(update); // metadata only → cheap patch
|
|
53
|
+
await this._search.patch(patch);
|
|
54
|
+
}
|
|
55
|
+
return record;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Semantic/metadata search across memories.
|
|
59
|
+
*
|
|
60
|
+
* Sends rich query with both text and vector - the index handle
|
|
61
|
+
* adapts based on backend capabilities (e.g. drops text for pgvector).
|
|
62
|
+
*/
|
|
63
|
+
async search(q) {
|
|
64
|
+
if (!this._search) {
|
|
65
|
+
throw new Error("search index not configured");
|
|
66
|
+
}
|
|
67
|
+
const tvec = await this.encoder.embed(q.query);
|
|
68
|
+
return this._search.query({
|
|
69
|
+
query: [{ text: q.query, tvec }],
|
|
70
|
+
filter: q.filter ? MEMORY_FILTER.encode(q.filter) : undefined,
|
|
71
|
+
topK: q.limit ?? 20,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* List memories matching the filter.
|
|
76
|
+
*/
|
|
77
|
+
async list(options) {
|
|
78
|
+
return this.store.list(options);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Repair indexing for a memory without modifying the DB row.
|
|
82
|
+
*/
|
|
83
|
+
async reindex(params) {
|
|
84
|
+
const record = await this.store.get(params.id);
|
|
85
|
+
if (!record) {
|
|
86
|
+
throw new Error(`memory not found: ${params.id}`);
|
|
87
|
+
}
|
|
88
|
+
const indexes = params.indexes ?? ["search", "graph", "archive"];
|
|
89
|
+
if (indexes.includes("search") && this._search) {
|
|
90
|
+
const indexed = await this.rcodec.encode(record);
|
|
91
|
+
await this._search.upsert(indexed);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/* --- (TODO): unclear what the shape of these should be.. --- */
|
|
95
|
+
/**
|
|
96
|
+
* Load working memory (L1) - wmem-pinned memories for the scope.
|
|
97
|
+
*/
|
|
98
|
+
async loadWorkingMemory(scope) {
|
|
99
|
+
const records = await this.store.list({
|
|
100
|
+
filter: { scope, wmem: true },
|
|
101
|
+
});
|
|
102
|
+
return { scope, records };
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Load short-term memory (L2) - active smem for the scope.
|
|
106
|
+
*/
|
|
107
|
+
async loadShortTermMemory(scope) {
|
|
108
|
+
const records = await this.store.list({
|
|
109
|
+
filter: { scope, smem: true },
|
|
110
|
+
});
|
|
111
|
+
return { scope, records };
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory index schema builder.
|
|
3
|
+
*/
|
|
4
|
+
import type { FieldSchema } from "@kernl-sdk/retrieval";
|
|
5
|
+
/**
|
|
6
|
+
* Options for building memory index schema.
|
|
7
|
+
*/
|
|
8
|
+
export interface MemoryIndexSchemaOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Vector dimensions for embeddings.
|
|
11
|
+
* @default 1536 (OpenAI text-embedding-3-small)
|
|
12
|
+
*/
|
|
13
|
+
dimensions?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Similarity metric for vector search.
|
|
16
|
+
* @default "cosine"
|
|
17
|
+
*/
|
|
18
|
+
similarity?: "cosine" | "euclidean" | "dot_product";
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Build a canonical memory index schema for vector search.
|
|
22
|
+
*
|
|
23
|
+
* Returns a schema Record that can be used with SearchIndex.createIndex().
|
|
24
|
+
*
|
|
25
|
+
* Schema includes all fields from IndexMemoryRecord:
|
|
26
|
+
* - id: primary key
|
|
27
|
+
* - namespace, entityId, agentId: scope fields (filterable, nullable)
|
|
28
|
+
* - kind, collection: memory attributes (filterable)
|
|
29
|
+
* - timestamp, createdAt, updatedAt: timestamps (filterable + sortable)
|
|
30
|
+
* - text: content text (full-text search)
|
|
31
|
+
* - tvec, ivec, avec, vvec: vector embeddings for text/image/audio/video
|
|
32
|
+
* - metadata: structured metadata (object)
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* const schema = buildMemoryIndexSchema({ dimensions: 1536 });
|
|
37
|
+
* const handle = new MemoryIndexHandle({ index: vector, indexId: "kernl_memories", schema });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildMemoryIndexSchema(options?: MemoryIndexSchemaOptions): Record<string, FieldSchema>;
|
|
41
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/memory/schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,UAAU,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,aAAa,CAAC;CACrD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,GAAE,wBAA6B,GACrC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAgG7B"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory index schema builder.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Build a canonical memory index schema for vector search.
|
|
6
|
+
*
|
|
7
|
+
* Returns a schema Record that can be used with SearchIndex.createIndex().
|
|
8
|
+
*
|
|
9
|
+
* Schema includes all fields from IndexMemoryRecord:
|
|
10
|
+
* - id: primary key
|
|
11
|
+
* - namespace, entityId, agentId: scope fields (filterable, nullable)
|
|
12
|
+
* - kind, collection: memory attributes (filterable)
|
|
13
|
+
* - timestamp, createdAt, updatedAt: timestamps (filterable + sortable)
|
|
14
|
+
* - text: content text (full-text search)
|
|
15
|
+
* - tvec, ivec, avec, vvec: vector embeddings for text/image/audio/video
|
|
16
|
+
* - metadata: structured metadata (object)
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const schema = buildMemoryIndexSchema({ dimensions: 1536 });
|
|
21
|
+
* const handle = new MemoryIndexHandle({ index: vector, indexId: "kernl_memories", schema });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export function buildMemoryIndexSchema(options = {}) {
|
|
25
|
+
const dimensions = options.dimensions ?? 1536;
|
|
26
|
+
const similarity = options.similarity ?? "cosine";
|
|
27
|
+
const schema = {
|
|
28
|
+
id: {
|
|
29
|
+
type: "string",
|
|
30
|
+
pk: true,
|
|
31
|
+
sortable: true,
|
|
32
|
+
},
|
|
33
|
+
// scope fields (filterable, nullable)
|
|
34
|
+
namespace: {
|
|
35
|
+
type: "string",
|
|
36
|
+
filterable: true,
|
|
37
|
+
optional: true,
|
|
38
|
+
},
|
|
39
|
+
entityId: {
|
|
40
|
+
type: "string",
|
|
41
|
+
filterable: true,
|
|
42
|
+
optional: true,
|
|
43
|
+
},
|
|
44
|
+
agentId: {
|
|
45
|
+
type: "string",
|
|
46
|
+
filterable: true,
|
|
47
|
+
optional: true,
|
|
48
|
+
},
|
|
49
|
+
// memory attributes (filterable)
|
|
50
|
+
kind: {
|
|
51
|
+
type: "string",
|
|
52
|
+
filterable: true,
|
|
53
|
+
},
|
|
54
|
+
collection: {
|
|
55
|
+
type: "string",
|
|
56
|
+
filterable: true,
|
|
57
|
+
},
|
|
58
|
+
// timestamps (filterable + sortable) - store as bigint to safely handle
|
|
59
|
+
// millisecond Unix epoch values without overflow in SQL backends.
|
|
60
|
+
timestamp: {
|
|
61
|
+
type: "bigint",
|
|
62
|
+
filterable: true,
|
|
63
|
+
sortable: true,
|
|
64
|
+
},
|
|
65
|
+
createdAt: {
|
|
66
|
+
type: "bigint",
|
|
67
|
+
filterable: true,
|
|
68
|
+
sortable: true,
|
|
69
|
+
},
|
|
70
|
+
updatedAt: {
|
|
71
|
+
type: "bigint",
|
|
72
|
+
filterable: true,
|
|
73
|
+
sortable: true,
|
|
74
|
+
},
|
|
75
|
+
// content fields
|
|
76
|
+
text: {
|
|
77
|
+
type: "string",
|
|
78
|
+
fts: true,
|
|
79
|
+
optional: true,
|
|
80
|
+
},
|
|
81
|
+
// vector fields for different modalities
|
|
82
|
+
tvec: {
|
|
83
|
+
type: "vector",
|
|
84
|
+
dimensions,
|
|
85
|
+
similarity,
|
|
86
|
+
optional: true,
|
|
87
|
+
},
|
|
88
|
+
ivec: {
|
|
89
|
+
type: "vector",
|
|
90
|
+
dimensions,
|
|
91
|
+
similarity,
|
|
92
|
+
optional: true,
|
|
93
|
+
},
|
|
94
|
+
avec: {
|
|
95
|
+
type: "vector",
|
|
96
|
+
dimensions,
|
|
97
|
+
similarity,
|
|
98
|
+
optional: true,
|
|
99
|
+
},
|
|
100
|
+
vvec: {
|
|
101
|
+
type: "vector",
|
|
102
|
+
dimensions,
|
|
103
|
+
similarity,
|
|
104
|
+
optional: true,
|
|
105
|
+
},
|
|
106
|
+
metadata: {
|
|
107
|
+
type: "object",
|
|
108
|
+
optional: true,
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
return schema;
|
|
112
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory store interface.
|
|
3
|
+
*/
|
|
4
|
+
import type { MemoryRecord, NewMemory, MemoryRecordUpdate, MemoryListOptions } from "./types.js";
|
|
5
|
+
/**
|
|
6
|
+
* Memory persistence store.
|
|
7
|
+
*
|
|
8
|
+
* Follows the same pattern as ThreadStore - simple CRUD operations.
|
|
9
|
+
*/
|
|
10
|
+
export interface MemoryStore {
|
|
11
|
+
/**
|
|
12
|
+
* Get a memory by ID.
|
|
13
|
+
*/
|
|
14
|
+
get(id: string): Promise<MemoryRecord | null>;
|
|
15
|
+
/**
|
|
16
|
+
* List memories matching the filter.
|
|
17
|
+
*/
|
|
18
|
+
list(options?: MemoryListOptions): Promise<MemoryRecord[]>;
|
|
19
|
+
/**
|
|
20
|
+
* Create a new memory.
|
|
21
|
+
*/
|
|
22
|
+
create(memory: NewMemory): Promise<MemoryRecord>;
|
|
23
|
+
/**
|
|
24
|
+
* Update an existing memory.
|
|
25
|
+
*/
|
|
26
|
+
update(id: string, patch: MemoryRecordUpdate): Promise<MemoryRecord>;
|
|
27
|
+
/**
|
|
28
|
+
* Delete a memory.
|
|
29
|
+
*/
|
|
30
|
+
delete(id: string): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Delete multiple memories.
|
|
33
|
+
*/
|
|
34
|
+
mdelete(ids: string[]): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/memory/store.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACT,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAEjB;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IAE9C;;OAEG;IACH,IAAI,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IAE3D;;OAEG;IACH,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAEjD;;OAEG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAErE;;OAEG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAElC;;OAEG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC"}
|