@functional-systems/memdrive 0.0.0-stage → 0.1.0-dev.5
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/CHANGELOG.md +13 -0
- package/LICENSE +201 -0
- package/README.md +229 -2
- package/dist/commonjs/chunking.d.ts +7 -0
- package/dist/commonjs/chunking.d.ts.map +1 -0
- package/dist/commonjs/chunking.js +46 -0
- package/dist/commonjs/chunking.js.map +1 -0
- package/dist/commonjs/errors.d.ts +17 -0
- package/dist/commonjs/errors.d.ts.map +1 -0
- package/dist/commonjs/errors.js +44 -0
- package/dist/commonjs/errors.js.map +1 -0
- package/dist/commonjs/filter.d.ts +30 -0
- package/dist/commonjs/filter.d.ts.map +1 -0
- package/dist/commonjs/filter.js +224 -0
- package/dist/commonjs/filter.js.map +1 -0
- package/dist/commonjs/index.d.ts +8 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +343 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/storage.d.ts +274 -0
- package/dist/commonjs/storage.d.ts.map +1 -0
- package/dist/commonjs/storage.js +861 -0
- package/dist/commonjs/storage.js.map +1 -0
- package/dist/commonjs/tools/definitions.d.ts +5 -0
- package/dist/commonjs/tools/definitions.d.ts.map +1 -0
- package/dist/commonjs/tools/definitions.js +129 -0
- package/dist/commonjs/tools/definitions.js.map +1 -0
- package/dist/commonjs/tools/index.d.ts +6 -0
- package/dist/commonjs/tools/index.d.ts.map +1 -0
- package/dist/commonjs/tools/index.js +104 -0
- package/dist/commonjs/tools/index.js.map +1 -0
- package/dist/commonjs/tools/types.d.ts +50 -0
- package/dist/commonjs/tools/types.d.ts.map +1 -0
- package/dist/commonjs/tools/types.js +3 -0
- package/dist/commonjs/tools/types.js.map +1 -0
- package/dist/commonjs/types.d.ts +277 -0
- package/dist/commonjs/types.d.ts.map +1 -0
- package/dist/commonjs/types.js +3 -0
- package/dist/commonjs/types.js.map +1 -0
- package/dist/commonjs/values.d.ts +17 -0
- package/dist/commonjs/values.d.ts.map +1 -0
- package/dist/commonjs/values.js +90 -0
- package/dist/commonjs/values.js.map +1 -0
- package/dist/esm/chunking.d.ts +7 -0
- package/dist/esm/chunking.d.ts.map +1 -0
- package/dist/esm/chunking.js +42 -0
- package/dist/esm/chunking.js.map +1 -0
- package/dist/esm/errors.d.ts +17 -0
- package/dist/esm/errors.d.ts.map +1 -0
- package/dist/esm/errors.js +36 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/filter.d.ts +30 -0
- package/dist/esm/filter.d.ts.map +1 -0
- package/dist/esm/filter.js +209 -0
- package/dist/esm/filter.js.map +1 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +335 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/storage.d.ts +274 -0
- package/dist/esm/storage.d.ts.map +1 -0
- package/dist/esm/storage.js +845 -0
- package/dist/esm/storage.js.map +1 -0
- package/dist/esm/tools/definitions.d.ts +5 -0
- package/dist/esm/tools/definitions.d.ts.map +1 -0
- package/dist/esm/tools/definitions.js +126 -0
- package/dist/esm/tools/definitions.js.map +1 -0
- package/dist/esm/tools/index.d.ts +6 -0
- package/dist/esm/tools/index.d.ts.map +1 -0
- package/dist/esm/tools/index.js +101 -0
- package/dist/esm/tools/index.js.map +1 -0
- package/dist/esm/tools/types.d.ts +50 -0
- package/dist/esm/tools/types.d.ts.map +1 -0
- package/dist/esm/tools/types.js +2 -0
- package/dist/esm/tools/types.js.map +1 -0
- package/dist/esm/types.d.ts +277 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/values.d.ts +17 -0
- package/dist/esm/values.d.ts.map +1 -0
- package/dist/esm/values.js +87 -0
- package/dist/esm/values.js.map +1 -0
- package/docs/tools.md +163 -0
- package/package.json +100 -4
- package/src/chunking.ts +32 -0
- package/src/errors.ts +40 -0
- package/src/filter.ts +189 -0
- package/src/index.ts +323 -0
- package/src/storage.ts +765 -0
- package/src/tools/definitions.ts +156 -0
- package/src/tools/index.ts +97 -0
- package/src/tools/types.ts +45 -0
- package/src/types.ts +273 -0
- package/src/values.ts +103 -0
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import type { LambdaDBClient } from '@functional-systems/lambdadb';
|
|
2
|
+
export type MetadataType = 'string' | 'string[]' | 'number' | 'boolean' | 'datetime';
|
|
3
|
+
export type MetadataValue = string | string[] | number | boolean;
|
|
4
|
+
export type Metadata = Record<string, MetadataValue>;
|
|
5
|
+
export type MetadataSchema = Record<string, {
|
|
6
|
+
type: MetadataType;
|
|
7
|
+
description?: string | undefined;
|
|
8
|
+
}>;
|
|
9
|
+
export interface RequestOptions {
|
|
10
|
+
signal?: AbortSignal | undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface TextSearch {
|
|
13
|
+
analyzers: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface ManagedEmbedding {
|
|
16
|
+
mode: 'managed';
|
|
17
|
+
provider: 'openai';
|
|
18
|
+
model: 'text-embedding-3-small';
|
|
19
|
+
dimensions: 1536;
|
|
20
|
+
similarity: 'cosine';
|
|
21
|
+
}
|
|
22
|
+
export interface ExternalEmbedding {
|
|
23
|
+
mode: 'external';
|
|
24
|
+
dimensions: number;
|
|
25
|
+
similarity: 'cosine';
|
|
26
|
+
identity: string;
|
|
27
|
+
}
|
|
28
|
+
export type EmbeddingOptions = {
|
|
29
|
+
mode: 'managed';
|
|
30
|
+
} | ExternalEmbedding;
|
|
31
|
+
export type EmbeddingConfig = ManagedEmbedding | ExternalEmbedding;
|
|
32
|
+
export interface MemAttributes {
|
|
33
|
+
timestamp?: string | undefined;
|
|
34
|
+
metadata?: Metadata | undefined;
|
|
35
|
+
}
|
|
36
|
+
export interface TextMemInput extends MemAttributes {
|
|
37
|
+
id?: string | undefined;
|
|
38
|
+
content: string;
|
|
39
|
+
embedding?: never;
|
|
40
|
+
}
|
|
41
|
+
export interface VectorMemInput extends MemAttributes {
|
|
42
|
+
id?: string | undefined;
|
|
43
|
+
embedding: number[];
|
|
44
|
+
content?: never;
|
|
45
|
+
}
|
|
46
|
+
export type MemInput = TextMemInput | VectorMemInput;
|
|
47
|
+
export interface TextMem extends MemAttributes {
|
|
48
|
+
id: string;
|
|
49
|
+
content: string;
|
|
50
|
+
}
|
|
51
|
+
/** External-vector reads return source references and metadata, not vectors. */
|
|
52
|
+
export interface VectorMem extends MemAttributes {
|
|
53
|
+
id: string;
|
|
54
|
+
content?: never;
|
|
55
|
+
}
|
|
56
|
+
export type Mem = TextMem | VectorMem;
|
|
57
|
+
export interface TextMatch extends MemAttributes {
|
|
58
|
+
kind: 'mem' | 'chunk';
|
|
59
|
+
memId: string;
|
|
60
|
+
content: string;
|
|
61
|
+
start: number;
|
|
62
|
+
end: number;
|
|
63
|
+
}
|
|
64
|
+
export interface VectorMatch extends MemAttributes {
|
|
65
|
+
kind: 'mem';
|
|
66
|
+
memId: string;
|
|
67
|
+
content?: never;
|
|
68
|
+
start?: never;
|
|
69
|
+
end?: never;
|
|
70
|
+
}
|
|
71
|
+
export type Match = TextMatch | VectorMatch;
|
|
72
|
+
export type FilterScalar = string | number | boolean;
|
|
73
|
+
export type Filter = {
|
|
74
|
+
and: Filter[];
|
|
75
|
+
or?: never;
|
|
76
|
+
field?: never;
|
|
77
|
+
op?: never;
|
|
78
|
+
value?: never;
|
|
79
|
+
} | {
|
|
80
|
+
or: Filter[];
|
|
81
|
+
and?: never;
|
|
82
|
+
field?: never;
|
|
83
|
+
op?: never;
|
|
84
|
+
value?: never;
|
|
85
|
+
} | {
|
|
86
|
+
field: string;
|
|
87
|
+
op: 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte';
|
|
88
|
+
value: FilterScalar;
|
|
89
|
+
and?: never;
|
|
90
|
+
or?: never;
|
|
91
|
+
} | {
|
|
92
|
+
field: string;
|
|
93
|
+
op: 'in';
|
|
94
|
+
value: FilterScalar[];
|
|
95
|
+
and?: never;
|
|
96
|
+
or?: never;
|
|
97
|
+
} | {
|
|
98
|
+
field: string;
|
|
99
|
+
op: 'exists';
|
|
100
|
+
value: boolean;
|
|
101
|
+
and?: never;
|
|
102
|
+
or?: never;
|
|
103
|
+
};
|
|
104
|
+
export interface RecallOptions {
|
|
105
|
+
filter?: Filter | undefined;
|
|
106
|
+
excludeIds?: string[] | undefined;
|
|
107
|
+
limit?: number | undefined;
|
|
108
|
+
rerank?: boolean | undefined;
|
|
109
|
+
}
|
|
110
|
+
export interface TextRecallRequest extends RecallOptions {
|
|
111
|
+
query: string;
|
|
112
|
+
queryVector?: never;
|
|
113
|
+
context?: string | undefined;
|
|
114
|
+
recentDialogue?: Array<{
|
|
115
|
+
role: 'user' | 'assistant';
|
|
116
|
+
content: string;
|
|
117
|
+
}> | undefined;
|
|
118
|
+
}
|
|
119
|
+
export interface VectorRecallRequest extends Omit<RecallOptions, 'rerank'> {
|
|
120
|
+
queryVector: number[];
|
|
121
|
+
query?: never;
|
|
122
|
+
rerank?: false | undefined;
|
|
123
|
+
context?: never;
|
|
124
|
+
recentDialogue?: never;
|
|
125
|
+
}
|
|
126
|
+
export type RecallRequest = TextRecallRequest | VectorRecallRequest;
|
|
127
|
+
export interface Usage {
|
|
128
|
+
elapsedMs: number;
|
|
129
|
+
databaseRequests: number;
|
|
130
|
+
}
|
|
131
|
+
export interface RecallResult {
|
|
132
|
+
matches: Match[];
|
|
133
|
+
usage: Usage;
|
|
134
|
+
}
|
|
135
|
+
export interface RecallFailure {
|
|
136
|
+
error: {
|
|
137
|
+
code: string;
|
|
138
|
+
message: string;
|
|
139
|
+
status?: number;
|
|
140
|
+
};
|
|
141
|
+
usage: Usage;
|
|
142
|
+
}
|
|
143
|
+
export interface BatchRecallResult {
|
|
144
|
+
results: Array<RecallResult | RecallFailure>;
|
|
145
|
+
}
|
|
146
|
+
export interface Observation {
|
|
147
|
+
type: 'retrieved';
|
|
148
|
+
/** Diagnostic physical evidence IDs, not canonical memId values. */
|
|
149
|
+
ids: string[];
|
|
150
|
+
matches: Match[];
|
|
151
|
+
requestIndex?: number | undefined;
|
|
152
|
+
}
|
|
153
|
+
export type RecordEvent = Record<string, unknown> & {
|
|
154
|
+
phase: string;
|
|
155
|
+
requestIndex?: number | undefined;
|
|
156
|
+
};
|
|
157
|
+
export interface RuntimeOptions {
|
|
158
|
+
maxConcurrentRequests?: number | undefined;
|
|
159
|
+
observe?: ((event: Observation) => void | Promise<void>) | undefined;
|
|
160
|
+
record?: ((event: RecordEvent) => void | Promise<void>) | undefined;
|
|
161
|
+
}
|
|
162
|
+
export interface ConnectionOptions {
|
|
163
|
+
client: LambdaDBClient;
|
|
164
|
+
name: string;
|
|
165
|
+
}
|
|
166
|
+
export interface CreateOptions extends ConnectionOptions, RuntimeOptions {
|
|
167
|
+
metadataSchema: MetadataSchema;
|
|
168
|
+
textSearch?: TextSearch | undefined;
|
|
169
|
+
embedding?: EmbeddingOptions | undefined;
|
|
170
|
+
labels?: Record<string, string> | undefined;
|
|
171
|
+
description?: string | undefined;
|
|
172
|
+
}
|
|
173
|
+
export interface OpenOptions extends ConnectionOptions, RuntimeOptions {
|
|
174
|
+
branch?: string | undefined;
|
|
175
|
+
}
|
|
176
|
+
export interface DriveDescriptor {
|
|
177
|
+
name: string;
|
|
178
|
+
description?: string | undefined;
|
|
179
|
+
labels: Record<string, string>;
|
|
180
|
+
metadataSchema: MetadataSchema;
|
|
181
|
+
embedding: EmbeddingConfig;
|
|
182
|
+
textSearch?: TextSearch | undefined;
|
|
183
|
+
}
|
|
184
|
+
export interface CatalogRequest {
|
|
185
|
+
client: LambdaDBClient;
|
|
186
|
+
labels?: Record<string, string> | undefined;
|
|
187
|
+
limit?: number | undefined;
|
|
188
|
+
cursor?: string | undefined;
|
|
189
|
+
}
|
|
190
|
+
export interface CatalogResult {
|
|
191
|
+
drives: DriveDescriptor[];
|
|
192
|
+
nextCursor?: string | undefined;
|
|
193
|
+
}
|
|
194
|
+
export interface ListRequest {
|
|
195
|
+
limit?: number | undefined;
|
|
196
|
+
cursor?: string | undefined;
|
|
197
|
+
}
|
|
198
|
+
export interface ListResult {
|
|
199
|
+
mems: Mem[];
|
|
200
|
+
nextCursor?: string | undefined;
|
|
201
|
+
}
|
|
202
|
+
export type ForgetRequest = {
|
|
203
|
+
ids: string[];
|
|
204
|
+
filter?: never;
|
|
205
|
+
} | {
|
|
206
|
+
filter: Filter;
|
|
207
|
+
ids?: never;
|
|
208
|
+
};
|
|
209
|
+
export type ConfigureRequest = {
|
|
210
|
+
metadataSchema: MetadataSchema;
|
|
211
|
+
description?: string | undefined;
|
|
212
|
+
} | {
|
|
213
|
+
description: string;
|
|
214
|
+
metadataSchema?: MetadataSchema | undefined;
|
|
215
|
+
};
|
|
216
|
+
export interface BranchRequest {
|
|
217
|
+
name: string;
|
|
218
|
+
source?: {
|
|
219
|
+
branch: string;
|
|
220
|
+
} | undefined;
|
|
221
|
+
}
|
|
222
|
+
export type Branch = Awaited<ReturnType<ReturnType<LambdaDBClient['collection']>['branches']['create']>>['branch'];
|
|
223
|
+
/** Counts distinct keyword values across original memories, not chunks. */
|
|
224
|
+
export interface CountValuesRequest {
|
|
225
|
+
/** One to five distinct keyword fields, matching the native facet limit. */
|
|
226
|
+
fields: string[];
|
|
227
|
+
filter?: Filter | undefined;
|
|
228
|
+
excludeIds?: string[] | undefined;
|
|
229
|
+
/** Values per field: defaults to 10, maximum 100. */
|
|
230
|
+
limit?: number | undefined;
|
|
231
|
+
}
|
|
232
|
+
export interface CountValuesResult {
|
|
233
|
+
values: Record<string, {
|
|
234
|
+
buckets: Array<{
|
|
235
|
+
value: string;
|
|
236
|
+
count: number;
|
|
237
|
+
}>;
|
|
238
|
+
/** Null when the native bucket limit prevents determining completeness. */
|
|
239
|
+
hasMore: boolean | null;
|
|
240
|
+
}>;
|
|
241
|
+
/** Time the cached result was fetched, in ISO 8601 UTC. */
|
|
242
|
+
asOf: string;
|
|
243
|
+
}
|
|
244
|
+
export interface DriveData {
|
|
245
|
+
readonly embedding: Readonly<EmbeddingConfig>;
|
|
246
|
+
remember(request: {
|
|
247
|
+
mems: MemInput[];
|
|
248
|
+
}, options?: RequestOptions): Promise<{
|
|
249
|
+
ids: string[];
|
|
250
|
+
}>;
|
|
251
|
+
read(request: {
|
|
252
|
+
ids: string[];
|
|
253
|
+
}, options?: RequestOptions): Promise<{
|
|
254
|
+
mems: Mem[];
|
|
255
|
+
}>;
|
|
256
|
+
list(request?: ListRequest, options?: RequestOptions): Promise<ListResult>;
|
|
257
|
+
countValues(request: CountValuesRequest, options?: RequestOptions): Promise<CountValuesResult>;
|
|
258
|
+
forget(request: ForgetRequest, options?: RequestOptions): Promise<void>;
|
|
259
|
+
recall(request: RecallRequest, options?: RequestOptions): Promise<RecallResult>;
|
|
260
|
+
recall(request: {
|
|
261
|
+
requests: RecallRequest[];
|
|
262
|
+
}, options?: RequestOptions): Promise<BatchRecallResult>;
|
|
263
|
+
}
|
|
264
|
+
export interface MemDrive extends DriveData {
|
|
265
|
+
at(reference: {
|
|
266
|
+
branch: string;
|
|
267
|
+
}): DriveData;
|
|
268
|
+
readonly branches: {
|
|
269
|
+
create(request: BranchRequest, options?: RequestOptions): Promise<Branch>;
|
|
270
|
+
list(options?: RequestOptions): Promise<Branch[]>;
|
|
271
|
+
delete(name: string, options?: RequestOptions): Promise<void>;
|
|
272
|
+
};
|
|
273
|
+
configure(request: ConfigureRequest, options?: RequestOptions): Promise<void>;
|
|
274
|
+
describe(options?: RequestOptions): Promise<DriveDescriptor>;
|
|
275
|
+
destroy(options?: RequestOptions): Promise<void>;
|
|
276
|
+
}
|
|
277
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc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 -0,0 +1,17 @@
|
|
|
1
|
+
import type { CountValuesResult, MetadataSchema, RequestOptions } from './types.js';
|
|
2
|
+
type NativeObject = Record<string, unknown>;
|
|
3
|
+
export type ValueSchedule = <T>(operation: (options?: RequestOptions) => Promise<T>) => Promise<T>;
|
|
4
|
+
interface CounterOptions {
|
|
5
|
+
describe: (options?: RequestOptions) => Promise<unknown>;
|
|
6
|
+
query: (body: NativeObject, options?: RequestOptions) => Promise<unknown>;
|
|
7
|
+
metadataSchema: () => MetadataSchema;
|
|
8
|
+
schemaTtlMs?: number;
|
|
9
|
+
valuesTtlMs?: number;
|
|
10
|
+
now?: () => number;
|
|
11
|
+
}
|
|
12
|
+
export declare function createValueCounter({ describe, query, metadataSchema, schemaTtlMs, valuesTtlMs, now }: CounterOptions): {
|
|
13
|
+
invalidate(): void;
|
|
14
|
+
countValues(input: unknown, schedule?: ValueSchedule, signal?: AbortSignal): Promise<CountValuesResult>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=values.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../../src/values.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEpF,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC5C,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,OAAO,CAAC,EAAE,cAAc,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AACnG,UAAU,cAAc;IACpB,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,cAAc,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACzD,KAAK,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,cAAc,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1E,cAAc,EAAE,MAAM,cAAc,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACtB;AAYD,wBAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAChE,WAAoB,EAAE,WAAmB,EAAE,GAAc,EAAE,EAAE,cAAc;;uBA2B9C,OAAO,aAAa,aAAa,WAAW,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC;EAiDpH"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { MemDriveError, requireInput, checkAbort } from './errors.js';
|
|
2
|
+
import { buildFilter, fieldType } from './filter.js';
|
|
3
|
+
const array = (value) => Array.isArray(value);
|
|
4
|
+
const object = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
5
|
+
// Each counter is bound to one collection/branch. Writes through any view of the
|
|
6
|
+
// same backend invalidate its cache; outside writes become visible after the TTL.
|
|
7
|
+
export function createValueCounter({ describe, query, metadataSchema, schemaTtlMs = 300000, valuesTtlMs = 60000, now = Date.now }) {
|
|
8
|
+
const cache = new Map();
|
|
9
|
+
const cached = async (key, ttl, load, signal) => {
|
|
10
|
+
checkAbort(signal);
|
|
11
|
+
for (const [oldKey, entry] of cache)
|
|
12
|
+
if (entry.expires !== null && entry.expires <= now())
|
|
13
|
+
cache.delete(oldKey);
|
|
14
|
+
let entry = cache.get(key);
|
|
15
|
+
// Different cancellation scopes cannot share an in-flight request.
|
|
16
|
+
if (!entry || (entry.expires === null && entry.signal !== signal)) {
|
|
17
|
+
const loading = { expires: null, signal, promise: Promise.resolve().then(load).then(value => {
|
|
18
|
+
loading.expires = now() + ttl;
|
|
19
|
+
loading.signal = undefined;
|
|
20
|
+
return value;
|
|
21
|
+
}, error => {
|
|
22
|
+
if (cache.get(key) === loading)
|
|
23
|
+
cache.delete(key);
|
|
24
|
+
throw error;
|
|
25
|
+
}) };
|
|
26
|
+
entry = loading;
|
|
27
|
+
cache.set(key, loading);
|
|
28
|
+
}
|
|
29
|
+
const value = await entry.promise;
|
|
30
|
+
checkAbort(signal);
|
|
31
|
+
// Private key namespaces bind entries to the same loader result type.
|
|
32
|
+
return structuredClone(value);
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
invalidate() { cache.clear(); },
|
|
36
|
+
async countValues(input, schedule, signal) {
|
|
37
|
+
checkAbort(signal);
|
|
38
|
+
let args;
|
|
39
|
+
try {
|
|
40
|
+
args = structuredClone(input);
|
|
41
|
+
}
|
|
42
|
+
catch (cause) {
|
|
43
|
+
throw new MemDriveError('INVALID_INPUT', 'Value count input must be cloneable data.', { cause });
|
|
44
|
+
}
|
|
45
|
+
requireInput(object(args) && Object.keys(args).every(key => ['fields', 'filter', 'excludeIds', 'limit'].includes(key)), 'Use fields, filter, excludeIds and limit for value counts.');
|
|
46
|
+
const { fields, filter, excludeIds = [], limit = 10 } = args;
|
|
47
|
+
requireInput(array(fields) && fields.length > 0 && fields.length <= 5
|
|
48
|
+
&& fields.every((field) => typeof field === 'string' && field.length > 0)
|
|
49
|
+
&& new Set(fields).size === fields.length, 'fields must contain 1 to 5 distinct keyword field names (the native facet limit).');
|
|
50
|
+
requireInput(array(excludeIds) && excludeIds.every((id) => typeof id === 'string' && id.trim().length > 0)
|
|
51
|
+
&& new Set(excludeIds).size === excludeIds.length, 'excludeIds must contain distinct canonical IDs.');
|
|
52
|
+
requireInput(typeof limit === 'number' && Number.isSafeInteger(limit) && limit >= 1 && limit <= 100, 'limit must be an integer from 1 to 100.');
|
|
53
|
+
const execute = schedule ?? (operation => operation({ signal }));
|
|
54
|
+
const schema = await cached('schema', schemaTtlMs, async () => {
|
|
55
|
+
// The backend refresh validates the complete collection configuration.
|
|
56
|
+
await execute(describe);
|
|
57
|
+
return metadataSchema();
|
|
58
|
+
}, signal);
|
|
59
|
+
requireInput(fields.every(field => ['string', 'string[]'].includes(fieldType(field, schema) ?? '')), 'countValues supports id and declared string or string[] metadata fields.');
|
|
60
|
+
const population = { bool: [
|
|
61
|
+
{ ...buildFilter([filter], excludeIds, schema), occur: 'filter' },
|
|
62
|
+
{ queryString: { query: '"mem"', defaultField: 'kind' }, occur: 'filter' },
|
|
63
|
+
] };
|
|
64
|
+
const sorted = [...fields].sort();
|
|
65
|
+
const size = limit < 100 ? limit + 1 : limit;
|
|
66
|
+
const key = JSON.stringify(['counts', population, sorted, limit, schema]);
|
|
67
|
+
return cached(key, valuesTtlMs, async () => {
|
|
68
|
+
const response = await execute(options => query({ size: 0, query: population,
|
|
69
|
+
facets: Object.fromEntries(sorted.map(field => [field === 'id' ? 'memId' : field, { size }])) }, options));
|
|
70
|
+
const facets = object(response) && object(response.facets) ? response.facets : undefined;
|
|
71
|
+
const values = Object.fromEntries(sorted.map(field => {
|
|
72
|
+
const facet = facets?.[field === 'id' ? 'memId' : field];
|
|
73
|
+
const buckets = object(facet) ? facet.buckets : undefined;
|
|
74
|
+
if (!array(buckets) || buckets.length > size
|
|
75
|
+
|| !buckets.every((bucket) => object(bucket) && typeof bucket.value === 'string'
|
|
76
|
+
&& typeof bucket.count === 'number' && Number.isSafeInteger(bucket.count) && bucket.count >= 0)
|
|
77
|
+
|| new Set(buckets.map(bucket => bucket.value)).size !== buckets.length)
|
|
78
|
+
throw new MemDriveError('INVALID_RESPONSE', 'Value counts returned invalid facet buckets.');
|
|
79
|
+
return [field, { buckets: buckets.slice(0, limit),
|
|
80
|
+
hasMore: buckets.length > limit ? true : buckets.length < 100 ? false : null }];
|
|
81
|
+
}));
|
|
82
|
+
return { values, asOf: new Date(now()).toISOString() };
|
|
83
|
+
}, signal);
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=values.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"values.js","sourceRoot":"","sources":["../../src/values.ts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AAE,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;4BAC7C,OAAO,EAAE,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;gBACxF,CAAC,CAAC,CAAC,CAAC;gBACJ,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;YAC3D,CAAC,EAAE,MAAM,CAAC,CAAC;QACf,CAAC;KACJ,CAAC;AACN,CAAC"}
|
package/docs/tools.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# Common memory tools
|
|
2
|
+
|
|
3
|
+
`@functional-systems/memdrive/tools` supplies provider-independent tool definitions
|
|
4
|
+
and execution functions. Calling agents plan queries, choose evidence and generate
|
|
5
|
+
answers. A separate hosted MCP service owns authentication, authorization,
|
|
6
|
+
protocol handling, deployment and operational limits. No MCP or model client is
|
|
7
|
+
bundled with MemDrive.
|
|
8
|
+
|
|
9
|
+
## Bind tools
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { createTools } from '@functional-systems/memdrive/tools';
|
|
13
|
+
|
|
14
|
+
// The application has already opened and authorized this drive.
|
|
15
|
+
const tools = await createTools({ drive });
|
|
16
|
+
const result = await tools.execute('memdrive_recall', {
|
|
17
|
+
requests: [{ query: 'What was agreed about the meeting?', limit: 10 }],
|
|
18
|
+
}, { signal });
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Creation reads `drive.describe()` once to build schemas from the actual embedding
|
|
22
|
+
configuration and metadata declarations, including field descriptions. Pass an
|
|
23
|
+
optional `branch` to bind data operations to that branch; otherwise the supplied
|
|
24
|
+
handle's branch is used. Model arguments cannot change the drive, connection or
|
|
25
|
+
branch. `describe` remains collection-scoped, as it is in the SDK.
|
|
26
|
+
|
|
27
|
+
The default tools are read-only. `createTools({ drive, writable: true })` also
|
|
28
|
+
exposes `remember` and `forget`. This switch and tool annotations are not access
|
|
29
|
+
control: the service must authorize each call and select the correct handle.
|
|
30
|
+
Collection creation/destruction, configuration and branch administration are not
|
|
31
|
+
part of this memory-tool surface.
|
|
32
|
+
|
|
33
|
+
`definitions` returns detached JSON data. Recreate the registry after changing
|
|
34
|
+
the metadata schema; existing input schemas describe the creation-time fields.
|
|
35
|
+
A `describe` call reads fresh metadata but does not silently change the registered
|
|
36
|
+
tool definitions. Hosted services own any tool-list refresh notification.
|
|
37
|
+
|
|
38
|
+
## Tool catalog
|
|
39
|
+
|
|
40
|
+
| Tool | Purpose | Input and result |
|
|
41
|
+
| --- | --- | --- |
|
|
42
|
+
| `memdrive_recall` | Retrieve evidence for questions or missing facts | `{requests: [...]}` with 1–5 SDK recall requests; `value.results` follows input order, including per-request failures. |
|
|
43
|
+
| `memdrive_read` | Expand excerpts to complete originals | `{ids: [...]}` using canonical `memId`; returns `value.mems`, omitting missing IDs. |
|
|
44
|
+
| `memdrive_describe` | Discover fields, meanings and search configuration | `{}`; returns the existing SDK drive descriptor. |
|
|
45
|
+
| `memdrive_count_values` | Inspect keyword value distributions | `{fields, filter?, excludeIds?, limit?}`; returns buckets, per-field `hasMore` and `asOf`. |
|
|
46
|
+
| `memdrive_list` | Browse inventory without a relevance query | `{limit?, cursor?}`; returns original mems and optional `nextCursor`. Continue even after an empty page when a cursor exists. |
|
|
47
|
+
| `memdrive_remember` | Add memories or fully replace supplied IDs | `{mems: [...]}`; returns IDs in input order. Available only when writable. |
|
|
48
|
+
| `memdrive_forget` | Delete whole memories and their chunks | Exactly `{ids: [...]}` or `{filter: ...}`; success returns `{acknowledged: true}`, not a deletion count. Available only when writable. |
|
|
49
|
+
|
|
50
|
+
Descriptions state when to use each operation, parameter meanings and important
|
|
51
|
+
limitations. Field schemas carry the actual metadata types and descriptions.
|
|
52
|
+
Closed objects reject extra top-level arguments, filters use explicit Boolean
|
|
53
|
+
expressions, and SDK validation remains authoritative for dates, byte limits,
|
|
54
|
+
vector values and other semantic constraints. No silent coercion or null-to-omit
|
|
55
|
+
conversion is performed. Input is detached before asynchronous execution.
|
|
56
|
+
|
|
57
|
+
Recall uses the SDK's existing vector or hybrid pipeline and native reranking
|
|
58
|
+
settings. It does not add a query-rewriting model, select evidence or execute a
|
|
59
|
+
second search. The tool's five-request bound is separate from the SDK's uncapped
|
|
60
|
+
batch length; SDK concurrency remains shared across branch views.
|
|
61
|
+
|
|
62
|
+
External-vector drives have vector-input schemas. They return references and
|
|
63
|
+
metadata without vectors or source text. A model must not invent embeddings;
|
|
64
|
+
the caller provides values from the configured vector space.
|
|
65
|
+
|
|
66
|
+
Counts accept up to five keyword fields and 100 values per field, matching native
|
|
67
|
+
facet limits. They count original memories once rather than counting chunks.
|
|
68
|
+
An array may contribute to several buckets. Counts can be cached for 60 seconds;
|
|
69
|
+
`asOf` is the fetch time, and `hasMore: null` means completeness is unknown.
|
|
70
|
+
|
|
71
|
+
## Evidence and writes
|
|
72
|
+
|
|
73
|
+
A match with `kind: 'mem'` is already complete; `kind: 'chunk'` contains an excerpt
|
|
74
|
+
with UTF-16 offsets. Pass its canonical `memId` to `memdrive_read` for surrounding
|
|
75
|
+
context. There are no short aliases, session-specific evidence tables, automatic
|
|
76
|
+
deduplication or finish/report tools. Callers retain earlier results and decide
|
|
77
|
+
whether more retrieval is useful. `excludeIds` excludes whole memories and all
|
|
78
|
+
their chunks, so it is not equivalent to hiding only previously seen excerpts.
|
|
79
|
+
|
|
80
|
+
Remember without an ID creates a new memory, including when repeated. Supplying
|
|
81
|
+
an existing ID fully replaces content and metadata; it is not a patch. Errors may
|
|
82
|
+
contain `completedIds`, `uncertainIds` and `notAttemptedIds`. Preserve these outcomes
|
|
83
|
+
and reconcile them before retrying; neither tools nor SDK automatically retry a
|
|
84
|
+
multi-request write. Deletion success acknowledges the request and does not prove
|
|
85
|
+
that any specified ID existed. Cancellation propagates through `AbortSignal` but
|
|
86
|
+
does not undo accepted writes.
|
|
87
|
+
|
|
88
|
+
## One execution contract, different transports
|
|
89
|
+
|
|
90
|
+
Every execution returns JSON data in one of these envelopes:
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
{ ok: true, value: /* SDK result, or forget acknowledgement */ }
|
|
94
|
+
{ ok: false, error: { code, message, status?, details? } }
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The tool's `outputSchema` describes both. Errors expose actionable SDK codes and
|
|
98
|
+
safe write outcomes, without causes, stack traces or raw transport bodies.
|
|
99
|
+
Unexpected exceptions use `TOOL_EXECUTION_FAILED` with a generic message. A batch
|
|
100
|
+
recall that ran has `ok: true` even when some `value.results` items contain errors;
|
|
101
|
+
inspect each item. Unknown or disabled tools return `UNKNOWN_TOOL` before dispatch.
|
|
102
|
+
|
|
103
|
+
Direct function calling can register the same definitions. For OpenAI Responses,
|
|
104
|
+
the registration shape is:
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
const functions = tools.definitions.map(tool => ({
|
|
108
|
+
type: 'function', name: tool.name, description: tool.description,
|
|
109
|
+
parameters: tool.inputSchema, strict: false,
|
|
110
|
+
}));
|
|
111
|
+
// On a function call, parse its arguments and pass the same object to execute.
|
|
112
|
+
const result = await tools.execute(call.name, JSON.parse(call.arguments), { signal });
|
|
113
|
+
const output = JSON.stringify(result);
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
These portable schemas preserve optional fields and SDK omission semantics.
|
|
117
|
+
They are not advertised as OpenAI strict schemas: that mode requires every
|
|
118
|
+
property to be required and uses nullable fields for optionality. Explicitly use
|
|
119
|
+
`strict: false`; a future provider-specific strict conversion must also define
|
|
120
|
+
and test its argument normalization. Claude registration uses the same `name`
|
|
121
|
+
and `description` with `input_schema: tool.inputSchema`.
|
|
122
|
+
|
|
123
|
+
A hosted MCP service lists the same definitions and packages the execution data:
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
const result = await tools.execute(name, argumentsObject, { signal });
|
|
127
|
+
const mcpResult = {
|
|
128
|
+
isError: !result.ok,
|
|
129
|
+
structuredContent: result,
|
|
130
|
+
content: [{ type: 'text', text: JSON.stringify(result) }],
|
|
131
|
+
};
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
This is a mapping example, not an MCP server implementation. The MCP service
|
|
135
|
+
handles protocol errors, unknown-tool routing, sessions, cancellation messages
|
|
136
|
+
and authentication. In particular, it maps unknown names to the protocol's
|
|
137
|
+
unknown-tool error instead of treating them as successful tool dispatches.
|
|
138
|
+
It must not change defaults, truncate results silently or implement separate
|
|
139
|
+
search logic. Direct function-call output and MCP `structuredContent`/JSON text
|
|
140
|
+
carry the same canonical execution result. Provider context limits and differing
|
|
141
|
+
agent prompts can still change the model's choices and final answer.
|
|
142
|
+
|
|
143
|
+
## Standards and validation
|
|
144
|
+
|
|
145
|
+
Definitions use JSON Schema 2020-12, structured output schemas and tool annotations
|
|
146
|
+
following the [MCP tools specification](https://modelcontextprotocol.io/specification/2025-11-25/server/tools).
|
|
147
|
+
The [MCP annotation reference](https://modelcontextprotocol.io/specification/2025-11-25/schema#toolannotations)
|
|
148
|
+
defines effect hints, not authorization. Reads are marked read-only; remember and
|
|
149
|
+
forget can destroy prior data, and remember is not generally idempotent because
|
|
150
|
+
IDs may be generated. The tools operate on a bound memory database rather than
|
|
151
|
+
arbitrary external destinations.
|
|
152
|
+
|
|
153
|
+
The [OpenAI function-calling guide](https://developers.openai.com/api/docs/guides/function-calling)
|
|
154
|
+
documents strict-mode requirements and explicit non-strict registration.
|
|
155
|
+
The [Claude tool-definition guide](https://platform.claude.com/docs/en/agents-and-tools/tool-use/define-tools)
|
|
156
|
+
emphasizes clear purposes, parameter meanings and limitations. These sources
|
|
157
|
+
inform the shared contract; they do not imply live certification by a provider.
|
|
158
|
+
|
|
159
|
+
Maintained tests compile the schemas with Ajv 2020, validate real SDK fixture
|
|
160
|
+
results, exercise branch binding, writable selection, batch correspondence,
|
|
161
|
+
partial failures and cancellation, and compare direct/MCP result packaging.
|
|
162
|
+
Package checks exercise ESM, CommonJS, public TypeScript types and browser bundles.
|
|
163
|
+
Simulated envelope equality is not a live MCP transport or model-quality test.
|