@fgv/ts-agent-memory-sqlite-vec 5.1.0-46 → 5.1.0-48

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.
Files changed (46) hide show
  1. package/LICENSE +21 -0
  2. package/dist/packlets/sqlite-vec-index/sqliteVecVectorIndex.js +107 -1
  3. package/dist/packlets/sqlite-vec-index/sqliteVecVectorIndex.js.map +1 -1
  4. package/dist/ts-agent-memory-sqlite-vec.d.ts +26 -0
  5. package/lib/packlets/sqlite-vec-index/sqliteVecVectorIndex.d.ts +23 -1
  6. package/lib/packlets/sqlite-vec-index/sqliteVecVectorIndex.d.ts.map +1 -1
  7. package/lib/packlets/sqlite-vec-index/sqliteVecVectorIndex.js +106 -0
  8. package/lib/packlets/sqlite-vec-index/sqliteVecVectorIndex.js.map +1 -1
  9. package/package.json +17 -7
  10. package/.rush/temp/b39f85377e1ce7a5b4a0aad208a6f48e4fba124b.tar.log +0 -60
  11. package/.rush/temp/chunked-rush-logs/ts-agent-memory-sqlite-vec.build.chunks.jsonl +0 -9
  12. package/.rush/temp/operation/build/all.log +0 -9
  13. package/.rush/temp/operation/build/log-chunks.jsonl +0 -9
  14. package/.rush/temp/operation/build/state.json +0 -3
  15. package/.rush/temp/shrinkwrap-deps.json +0 -720
  16. package/config/api-extractor.json +0 -38
  17. package/config/jest.config.json +0 -13
  18. package/config/rig.json +0 -6
  19. package/dist/test/unit/sqliteVecFragmentIndex.test.js +0 -513
  20. package/dist/test/unit/sqliteVecFragmentIndex.test.js.map +0 -1
  21. package/dist/test/unit/sqliteVecVectorIndex.test.js +0 -199
  22. package/dist/test/unit/sqliteVecVectorIndex.test.js.map +0 -1
  23. package/eslint.config.js +0 -15
  24. package/etc/ts-agent-memory-sqlite-vec.api.md +0 -66
  25. package/lib/test/unit/sqliteVecFragmentIndex.test.d.ts +0 -2
  26. package/lib/test/unit/sqliteVecFragmentIndex.test.d.ts.map +0 -1
  27. package/lib/test/unit/sqliteVecFragmentIndex.test.js +0 -551
  28. package/lib/test/unit/sqliteVecFragmentIndex.test.js.map +0 -1
  29. package/lib/test/unit/sqliteVecVectorIndex.test.d.ts +0 -2
  30. package/lib/test/unit/sqliteVecVectorIndex.test.d.ts.map +0 -1
  31. package/lib/test/unit/sqliteVecVectorIndex.test.js +0 -237
  32. package/lib/test/unit/sqliteVecVectorIndex.test.js.map +0 -1
  33. package/rush-logs/ts-agent-memory-sqlite-vec.build.cache.log +0 -3
  34. package/rush-logs/ts-agent-memory-sqlite-vec.build.log +0 -9
  35. package/src/index.ts +0 -6
  36. package/src/packlets/sqlite-vec-index/index.ts +0 -8
  37. package/src/packlets/sqlite-vec-index/model.ts +0 -56
  38. package/src/packlets/sqlite-vec-index/sqliteVecFragmentIndex.ts +0 -540
  39. package/src/packlets/sqlite-vec-index/sqliteVecVectorIndex.ts +0 -255
  40. package/src/test/unit/sqliteVecFragmentIndex.test.ts +0 -691
  41. package/src/test/unit/sqliteVecVectorIndex.test.ts +0 -253
  42. package/temp/build/lint/_eslint-5eVG3S6w.json +0 -34
  43. package/temp/build/typescript/ts_8nwakTlr.json +0 -1
  44. package/temp/ts-agent-memory-sqlite-vec.api.json +0 -1167
  45. package/temp/ts-agent-memory-sqlite-vec.api.md +0 -66
  46. package/tsconfig.json +0 -8
@@ -1,1167 +0,0 @@
1
- {
2
- "metadata": {
3
- "toolPackage": "@microsoft/api-extractor",
4
- "toolVersion": "7.58.9",
5
- "schemaVersion": 1011,
6
- "oldestForwardsCompatibleVersion": 1001,
7
- "tsdocConfig": {
8
- "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
9
- "noStandardTags": true,
10
- "tagDefinitions": [
11
- {
12
- "tagName": "@alpha",
13
- "syntaxKind": "modifier"
14
- },
15
- {
16
- "tagName": "@beta",
17
- "syntaxKind": "modifier"
18
- },
19
- {
20
- "tagName": "@defaultValue",
21
- "syntaxKind": "block"
22
- },
23
- {
24
- "tagName": "@decorator",
25
- "syntaxKind": "block",
26
- "allowMultiple": true
27
- },
28
- {
29
- "tagName": "@deprecated",
30
- "syntaxKind": "block"
31
- },
32
- {
33
- "tagName": "@eventProperty",
34
- "syntaxKind": "modifier"
35
- },
36
- {
37
- "tagName": "@example",
38
- "syntaxKind": "block",
39
- "allowMultiple": true
40
- },
41
- {
42
- "tagName": "@experimental",
43
- "syntaxKind": "modifier"
44
- },
45
- {
46
- "tagName": "@inheritDoc",
47
- "syntaxKind": "inline"
48
- },
49
- {
50
- "tagName": "@internal",
51
- "syntaxKind": "modifier"
52
- },
53
- {
54
- "tagName": "@label",
55
- "syntaxKind": "inline"
56
- },
57
- {
58
- "tagName": "@link",
59
- "syntaxKind": "inline",
60
- "allowMultiple": true
61
- },
62
- {
63
- "tagName": "@override",
64
- "syntaxKind": "modifier"
65
- },
66
- {
67
- "tagName": "@packageDocumentation",
68
- "syntaxKind": "modifier"
69
- },
70
- {
71
- "tagName": "@param",
72
- "syntaxKind": "block",
73
- "allowMultiple": true
74
- },
75
- {
76
- "tagName": "@privateRemarks",
77
- "syntaxKind": "block"
78
- },
79
- {
80
- "tagName": "@public",
81
- "syntaxKind": "modifier"
82
- },
83
- {
84
- "tagName": "@readonly",
85
- "syntaxKind": "modifier"
86
- },
87
- {
88
- "tagName": "@remarks",
89
- "syntaxKind": "block"
90
- },
91
- {
92
- "tagName": "@returns",
93
- "syntaxKind": "block"
94
- },
95
- {
96
- "tagName": "@sealed",
97
- "syntaxKind": "modifier"
98
- },
99
- {
100
- "tagName": "@see",
101
- "syntaxKind": "block"
102
- },
103
- {
104
- "tagName": "@throws",
105
- "syntaxKind": "block",
106
- "allowMultiple": true
107
- },
108
- {
109
- "tagName": "@typeParam",
110
- "syntaxKind": "block",
111
- "allowMultiple": true
112
- },
113
- {
114
- "tagName": "@virtual",
115
- "syntaxKind": "modifier"
116
- },
117
- {
118
- "tagName": "@jsx",
119
- "syntaxKind": "block"
120
- },
121
- {
122
- "tagName": "@jsxRuntime",
123
- "syntaxKind": "block"
124
- },
125
- {
126
- "tagName": "@jsxFrag",
127
- "syntaxKind": "block"
128
- },
129
- {
130
- "tagName": "@jsxImportSource",
131
- "syntaxKind": "block"
132
- },
133
- {
134
- "tagName": "@betaDocumentation",
135
- "syntaxKind": "modifier"
136
- },
137
- {
138
- "tagName": "@internalRemarks",
139
- "syntaxKind": "block"
140
- },
141
- {
142
- "tagName": "@preapproved",
143
- "syntaxKind": "modifier"
144
- }
145
- ],
146
- "supportForTags": {
147
- "@alpha": true,
148
- "@beta": true,
149
- "@defaultValue": true,
150
- "@decorator": true,
151
- "@deprecated": true,
152
- "@eventProperty": true,
153
- "@example": true,
154
- "@experimental": true,
155
- "@inheritDoc": true,
156
- "@internal": true,
157
- "@label": true,
158
- "@link": true,
159
- "@override": true,
160
- "@packageDocumentation": true,
161
- "@param": true,
162
- "@privateRemarks": true,
163
- "@public": true,
164
- "@readonly": true,
165
- "@remarks": true,
166
- "@returns": true,
167
- "@sealed": true,
168
- "@see": true,
169
- "@throws": true,
170
- "@typeParam": true,
171
- "@virtual": true,
172
- "@betaDocumentation": true,
173
- "@internalRemarks": true,
174
- "@preapproved": true
175
- },
176
- "reportUnsupportedHtmlElements": false
177
- }
178
- },
179
- "kind": "Package",
180
- "canonicalReference": "@fgv/ts-agent-memory-sqlite-vec!",
181
- "docComment": "",
182
- "name": "@fgv/ts-agent-memory-sqlite-vec",
183
- "preserveMemberOrder": false,
184
- "members": [
185
- {
186
- "kind": "EntryPoint",
187
- "canonicalReference": "@fgv/ts-agent-memory-sqlite-vec!",
188
- "name": "",
189
- "preserveMemberOrder": false,
190
- "members": [
191
- {
192
- "kind": "Interface",
193
- "canonicalReference": "@fgv/ts-agent-memory-sqlite-vec!ISqliteVecFragmentIndexCreateParams:interface",
194
- "docComment": "/**\n * Parameters for {@link SqliteVecFragmentIndex.create}.\n *\n * @public\n */\n",
195
- "excerptTokens": [
196
- {
197
- "kind": "Content",
198
- "text": "export interface ISqliteVecFragmentIndexCreateParams "
199
- }
200
- ],
201
- "fileUrlPath": "src/packlets/sqlite-vec-index/model.ts",
202
- "releaseTag": "Public",
203
- "name": "ISqliteVecFragmentIndexCreateParams",
204
- "preserveMemberOrder": false,
205
- "members": [
206
- {
207
- "kind": "PropertySignature",
208
- "canonicalReference": "@fgv/ts-agent-memory-sqlite-vec!ISqliteVecFragmentIndexCreateParams#database:member",
209
- "docComment": "/**\n * A `better-sqlite3` `Database` the consumer owns (bring-your-own, mirroring {@link ISqliteVecVectorIndexCreateParams.database}). The consumer opens it and owns its lifecycle — this index never closes it. `create` loads the `sqlite-vec` extension onto the connection and, if the fragment table already exists (a reopened persistent file), recovers its established dimension so no re-embedding is required on open.\n */\n",
210
- "excerptTokens": [
211
- {
212
- "kind": "Content",
213
- "text": "readonly database: "
214
- },
215
- {
216
- "kind": "Reference",
217
- "text": "BetterSqlite3.Database",
218
- "canonicalReference": "@types/better-sqlite3!Database.Database:type"
219
- },
220
- {
221
- "kind": "Content",
222
- "text": ";"
223
- }
224
- ],
225
- "isReadonly": true,
226
- "isOptional": false,
227
- "releaseTag": "Public",
228
- "name": "database",
229
- "propertyTypeTokenRange": {
230
- "startIndex": 1,
231
- "endIndex": 2
232
- }
233
- },
234
- {
235
- "kind": "PropertySignature",
236
- "canonicalReference": "@fgv/ts-agent-memory-sqlite-vec!ISqliteVecFragmentIndexCreateParams#tableName:member",
237
- "docComment": "/**\n * Name of the `vec0` virtual table that holds the fragment embeddings. Must be a simple SQL identifier (`[A-Za-z_][A-Za-z0-9_]*`). Defaults to `'memory_fragments'`. Supply a distinct name (distinct from any record-level {@link SqliteVecVectorIndex} table) to hold more than one independent index in a single database file.\n */\n",
238
- "excerptTokens": [
239
- {
240
- "kind": "Content",
241
- "text": "readonly tableName?: "
242
- },
243
- {
244
- "kind": "Content",
245
- "text": "string"
246
- },
247
- {
248
- "kind": "Content",
249
- "text": ";"
250
- }
251
- ],
252
- "isReadonly": true,
253
- "isOptional": true,
254
- "releaseTag": "Public",
255
- "name": "tableName",
256
- "propertyTypeTokenRange": {
257
- "startIndex": 1,
258
- "endIndex": 2
259
- }
260
- }
261
- ],
262
- "extendsTokenRanges": []
263
- },
264
- {
265
- "kind": "Interface",
266
- "canonicalReference": "@fgv/ts-agent-memory-sqlite-vec!ISqliteVecVectorIndexCreateParams:interface",
267
- "docComment": "/**\n * Parameters for {@link SqliteVecVectorIndex.create}.\n *\n * @public\n */\n",
268
- "excerptTokens": [
269
- {
270
- "kind": "Content",
271
- "text": "export interface ISqliteVecVectorIndexCreateParams "
272
- }
273
- ],
274
- "fileUrlPath": "src/packlets/sqlite-vec-index/model.ts",
275
- "releaseTag": "Public",
276
- "name": "ISqliteVecVectorIndexCreateParams",
277
- "preserveMemberOrder": false,
278
- "members": [
279
- {
280
- "kind": "PropertySignature",
281
- "canonicalReference": "@fgv/ts-agent-memory-sqlite-vec!ISqliteVecVectorIndexCreateParams#database:member",
282
- "docComment": "/**\n * A `better-sqlite3` `Database` the consumer owns (bring-your-own, mirroring the boundary-package convention). The consumer opens it (`new Database(path)` for a persistent file, or `new Database(':memory:')` for an ephemeral index) and owns its lifecycle — this index never closes it. `create` loads the `sqlite-vec` extension onto the connection and, if the vector table already exists (a reopened persistent file), recovers its established dimension so no re-embedding is required on open.\n */\n",
283
- "excerptTokens": [
284
- {
285
- "kind": "Content",
286
- "text": "readonly database: "
287
- },
288
- {
289
- "kind": "Reference",
290
- "text": "BetterSqlite3.Database",
291
- "canonicalReference": "@types/better-sqlite3!Database.Database:type"
292
- },
293
- {
294
- "kind": "Content",
295
- "text": ";"
296
- }
297
- ],
298
- "isReadonly": true,
299
- "isOptional": false,
300
- "releaseTag": "Public",
301
- "name": "database",
302
- "propertyTypeTokenRange": {
303
- "startIndex": 1,
304
- "endIndex": 2
305
- }
306
- },
307
- {
308
- "kind": "PropertySignature",
309
- "canonicalReference": "@fgv/ts-agent-memory-sqlite-vec!ISqliteVecVectorIndexCreateParams#tableName:member",
310
- "docComment": "/**\n * Name of the `vec0` virtual table that holds the embeddings. Must be a simple SQL identifier (`[A-Za-z_][A-Za-z0-9_]*`). Defaults to `'memory_vectors'`. Supply a distinct name to hold more than one independent index in a single database file.\n */\n",
311
- "excerptTokens": [
312
- {
313
- "kind": "Content",
314
- "text": "readonly tableName?: "
315
- },
316
- {
317
- "kind": "Content",
318
- "text": "string"
319
- },
320
- {
321
- "kind": "Content",
322
- "text": ";"
323
- }
324
- ],
325
- "isReadonly": true,
326
- "isOptional": true,
327
- "releaseTag": "Public",
328
- "name": "tableName",
329
- "propertyTypeTokenRange": {
330
- "startIndex": 1,
331
- "endIndex": 2
332
- }
333
- }
334
- ],
335
- "extendsTokenRanges": []
336
- },
337
- {
338
- "kind": "Class",
339
- "canonicalReference": "@fgv/ts-agent-memory-sqlite-vec!SqliteVecFragmentIndex:class",
340
- "docComment": "/**\n * A persistent, `sqlite-vec`-backed `IFragmentVectorIndex` (from `@fgv/ts-agent-memory`) — the fragment-granular sibling of {@link SqliteVecVectorIndex}, and the **durable** counterpart to the in-memory `InMemoryFragmentCosineIndex`.\n *\n * @remarks\n *\n * Where {@link SqliteVecVectorIndex} keys one vector per record on a `target_key` primary key, this index holds **many** vectors per record — one per fragment — so it keys the `vec0` table on `target_key` as a **`PARTITION KEY`** (many rows may share it) and stores each fragment's identity in three auxiliary columns (`+start_off`, `+end_off`, `+fragment_id`) that ride alongside the vector and are returned on query but never filtered — in particular `fragment_id` is stored and returned verbatim, never parsed and never part of the query path. A query is a brute-force `vec0` KNN scan across all partitions returning per-fragment hits, each carrying its record `target` plus whichever identity fields the stored fragment was added with (a fragment must carry at least one).\n *\n * **`vec0` schema changes require a drop-and-re-index.** A `CREATE VIRTUAL TABLE IF NOT EXISTS` is a no-op against an existing table (SQLite does not compare schemas) and `vec0` has no `ALTER TABLE ADD COLUMN`, so a database written by an earlier version of this package keeps its old auxiliary columns. `create` detects that by parsing the stored `CREATE VIRTUAL TABLE` SQL and fails with an actionable message naming the expected and found columns, rather than letting a widened `INSERT` surface an opaque `no such column` at statement-prepare time. There are no in-place migrations: drop the table (or use a fresh `tableName`) and re-index. Fragment vectors are re-derivable from the records, so this costs embedding time, never data.\n *\n * Semantics match `InMemoryFragmentCosineIndex` exactly: `addFragments` is whole-record-replace (a single transaction deletes every prior fragment of the target, then inserts the new set), `remove` drops every fragment of a target, and `query` applies the optional `maxPerRecord` cap **during selection, before the topK cut** — so one long document cannot crowd others out. The dimension is established by the first `addFragments` (the `vec0` column is fixed-width) and recovered from the table schema when a persistent file is reopened; similarity is cosine (`score = 1 - cosineDistance`), byte-identical to the in-memory index. Large-N ANN indexing is explicitly out of scope, same regime as the record index.\n *\n * The `better-sqlite3` `Database` is consumer-owned (bring-your-own): this index loads the `sqlite-vec` extension onto it and reads/writes the table, but never opens or closes the connection.\n *\n * @public\n */\n",
341
- "excerptTokens": [
342
- {
343
- "kind": "Content",
344
- "text": "export declare class SqliteVecFragmentIndex implements "
345
- },
346
- {
347
- "kind": "Reference",
348
- "text": "IFragmentVectorIndex",
349
- "canonicalReference": "@fgv/ts-agent-memory!IFragmentVectorIndex:interface"
350
- },
351
- {
352
- "kind": "Content",
353
- "text": " "
354
- }
355
- ],
356
- "fileUrlPath": "src/packlets/sqlite-vec-index/sqliteVecFragmentIndex.ts",
357
- "releaseTag": "Public",
358
- "isAbstract": false,
359
- "name": "SqliteVecFragmentIndex",
360
- "preserveMemberOrder": false,
361
- "members": [
362
- {
363
- "kind": "Method",
364
- "canonicalReference": "@fgv/ts-agent-memory-sqlite-vec!SqliteVecFragmentIndex#addFragments:member(1)",
365
- "docComment": "/**\n * {@inheritDoc IFragmentVectorIndex.addFragments}\n */\n",
366
- "excerptTokens": [
367
- {
368
- "kind": "Content",
369
- "text": "addFragments(target: "
370
- },
371
- {
372
- "kind": "Reference",
373
- "text": "IEdgeTarget",
374
- "canonicalReference": "@fgv/ts-agent-memory!IEdgeTarget:interface"
375
- },
376
- {
377
- "kind": "Content",
378
- "text": ", fragments: "
379
- },
380
- {
381
- "kind": "Reference",
382
- "text": "ReadonlyArray",
383
- "canonicalReference": "!ReadonlyArray:interface"
384
- },
385
- {
386
- "kind": "Content",
387
- "text": "<"
388
- },
389
- {
390
- "kind": "Reference",
391
- "text": "IEmbeddedFragment",
392
- "canonicalReference": "@fgv/ts-agent-memory!IEmbeddedFragment:interface"
393
- },
394
- {
395
- "kind": "Content",
396
- "text": ">"
397
- },
398
- {
399
- "kind": "Content",
400
- "text": "): "
401
- },
402
- {
403
- "kind": "Reference",
404
- "text": "Promise",
405
- "canonicalReference": "!Promise:interface"
406
- },
407
- {
408
- "kind": "Content",
409
- "text": "<"
410
- },
411
- {
412
- "kind": "Reference",
413
- "text": "Result",
414
- "canonicalReference": "@fgv/ts-utils!Result:type"
415
- },
416
- {
417
- "kind": "Content",
418
- "text": "<number>>"
419
- },
420
- {
421
- "kind": "Content",
422
- "text": ";"
423
- }
424
- ],
425
- "isStatic": false,
426
- "returnTypeTokenRange": {
427
- "startIndex": 8,
428
- "endIndex": 12
429
- },
430
- "releaseTag": "Public",
431
- "isProtected": false,
432
- "overloadIndex": 1,
433
- "parameters": [
434
- {
435
- "parameterName": "target",
436
- "parameterTypeTokenRange": {
437
- "startIndex": 1,
438
- "endIndex": 2
439
- },
440
- "isOptional": false
441
- },
442
- {
443
- "parameterName": "fragments",
444
- "parameterTypeTokenRange": {
445
- "startIndex": 3,
446
- "endIndex": 7
447
- },
448
- "isOptional": false
449
- }
450
- ],
451
- "isOptional": false,
452
- "isAbstract": false,
453
- "name": "addFragments"
454
- },
455
- {
456
- "kind": "Method",
457
- "canonicalReference": "@fgv/ts-agent-memory-sqlite-vec!SqliteVecFragmentIndex.create:member(1)",
458
- "docComment": "/**\n * Family-convention factory. Loads the `sqlite-vec` extension onto the supplied `better-sqlite3` connection and, if the fragment table already exists (a reopened persistent file), verifies its auxiliary-column set matches this version's and recovers its established dimension so no re-embedding is needed on open.\n *\n * @param params - See {@link ISqliteVecFragmentIndexCreateParams}.\n *\n * @returns `Success` with the index, or `Failure` if the table name is not a simple identifier, the extension fails to load, or the existing table was written by a version with a different auxiliary-column set (which requires a drop-and-re-index — `vec0` cannot be altered in place).\n */\n",
459
- "excerptTokens": [
460
- {
461
- "kind": "Content",
462
- "text": "static create(params: "
463
- },
464
- {
465
- "kind": "Reference",
466
- "text": "ISqliteVecFragmentIndexCreateParams",
467
- "canonicalReference": "@fgv/ts-agent-memory-sqlite-vec!ISqliteVecFragmentIndexCreateParams:interface"
468
- },
469
- {
470
- "kind": "Content",
471
- "text": "): "
472
- },
473
- {
474
- "kind": "Reference",
475
- "text": "Promise",
476
- "canonicalReference": "!Promise:interface"
477
- },
478
- {
479
- "kind": "Content",
480
- "text": "<"
481
- },
482
- {
483
- "kind": "Reference",
484
- "text": "Result",
485
- "canonicalReference": "@fgv/ts-utils!Result:type"
486
- },
487
- {
488
- "kind": "Content",
489
- "text": "<"
490
- },
491
- {
492
- "kind": "Reference",
493
- "text": "SqliteVecFragmentIndex",
494
- "canonicalReference": "@fgv/ts-agent-memory-sqlite-vec!SqliteVecFragmentIndex:class"
495
- },
496
- {
497
- "kind": "Content",
498
- "text": ">>"
499
- },
500
- {
501
- "kind": "Content",
502
- "text": ";"
503
- }
504
- ],
505
- "isStatic": true,
506
- "returnTypeTokenRange": {
507
- "startIndex": 3,
508
- "endIndex": 9
509
- },
510
- "releaseTag": "Public",
511
- "isProtected": false,
512
- "overloadIndex": 1,
513
- "parameters": [
514
- {
515
- "parameterName": "params",
516
- "parameterTypeTokenRange": {
517
- "startIndex": 1,
518
- "endIndex": 2
519
- },
520
- "isOptional": false
521
- }
522
- ],
523
- "isOptional": false,
524
- "isAbstract": false,
525
- "name": "create"
526
- },
527
- {
528
- "kind": "Property",
529
- "canonicalReference": "@fgv/ts-agent-memory-sqlite-vec!SqliteVecFragmentIndex#fragmentCount:member",
530
- "docComment": "/**\n * The total number of fragments currently held across all records. Zero before the first add.\n */\n",
531
- "excerptTokens": [
532
- {
533
- "kind": "Content",
534
- "text": "get fragmentCount(): "
535
- },
536
- {
537
- "kind": "Content",
538
- "text": "number"
539
- },
540
- {
541
- "kind": "Content",
542
- "text": ";"
543
- }
544
- ],
545
- "isReadonly": true,
546
- "isOptional": false,
547
- "releaseTag": "Public",
548
- "name": "fragmentCount",
549
- "propertyTypeTokenRange": {
550
- "startIndex": 1,
551
- "endIndex": 2
552
- },
553
- "isStatic": false,
554
- "isProtected": false,
555
- "isAbstract": false
556
- },
557
- {
558
- "kind": "Method",
559
- "canonicalReference": "@fgv/ts-agent-memory-sqlite-vec!SqliteVecFragmentIndex#query:member(1)",
560
- "docComment": "/**\n * {@inheritDoc IFragmentVectorIndex.query}\n */\n",
561
- "excerptTokens": [
562
- {
563
- "kind": "Content",
564
- "text": "query(vector: "
565
- },
566
- {
567
- "kind": "Reference",
568
- "text": "Float32Array",
569
- "canonicalReference": "!Float32Array:interface"
570
- },
571
- {
572
- "kind": "Content",
573
- "text": ", topK: "
574
- },
575
- {
576
- "kind": "Content",
577
- "text": "number"
578
- },
579
- {
580
- "kind": "Content",
581
- "text": ", maxPerRecord?: "
582
- },
583
- {
584
- "kind": "Content",
585
- "text": "number"
586
- },
587
- {
588
- "kind": "Content",
589
- "text": "): "
590
- },
591
- {
592
- "kind": "Reference",
593
- "text": "Promise",
594
- "canonicalReference": "!Promise:interface"
595
- },
596
- {
597
- "kind": "Content",
598
- "text": "<"
599
- },
600
- {
601
- "kind": "Reference",
602
- "text": "Result",
603
- "canonicalReference": "@fgv/ts-utils!Result:type"
604
- },
605
- {
606
- "kind": "Content",
607
- "text": "<"
608
- },
609
- {
610
- "kind": "Reference",
611
- "text": "ReadonlyArray",
612
- "canonicalReference": "!ReadonlyArray:interface"
613
- },
614
- {
615
- "kind": "Content",
616
- "text": "<"
617
- },
618
- {
619
- "kind": "Reference",
620
- "text": "IVectorQueryHit",
621
- "canonicalReference": "@fgv/ts-agent-memory!IVectorQueryHit:interface"
622
- },
623
- {
624
- "kind": "Content",
625
- "text": ">>>"
626
- },
627
- {
628
- "kind": "Content",
629
- "text": ";"
630
- }
631
- ],
632
- "isStatic": false,
633
- "returnTypeTokenRange": {
634
- "startIndex": 7,
635
- "endIndex": 15
636
- },
637
- "releaseTag": "Public",
638
- "isProtected": false,
639
- "overloadIndex": 1,
640
- "parameters": [
641
- {
642
- "parameterName": "vector",
643
- "parameterTypeTokenRange": {
644
- "startIndex": 1,
645
- "endIndex": 2
646
- },
647
- "isOptional": false
648
- },
649
- {
650
- "parameterName": "topK",
651
- "parameterTypeTokenRange": {
652
- "startIndex": 3,
653
- "endIndex": 4
654
- },
655
- "isOptional": false
656
- },
657
- {
658
- "parameterName": "maxPerRecord",
659
- "parameterTypeTokenRange": {
660
- "startIndex": 5,
661
- "endIndex": 6
662
- },
663
- "isOptional": true
664
- }
665
- ],
666
- "isOptional": false,
667
- "isAbstract": false,
668
- "name": "query"
669
- },
670
- {
671
- "kind": "Property",
672
- "canonicalReference": "@fgv/ts-agent-memory-sqlite-vec!SqliteVecFragmentIndex#recordCount:member",
673
- "docComment": "/**\n * The number of records that currently have at least one stored fragment. Zero before the first add.\n */\n",
674
- "excerptTokens": [
675
- {
676
- "kind": "Content",
677
- "text": "get recordCount(): "
678
- },
679
- {
680
- "kind": "Content",
681
- "text": "number"
682
- },
683
- {
684
- "kind": "Content",
685
- "text": ";"
686
- }
687
- ],
688
- "isReadonly": true,
689
- "isOptional": false,
690
- "releaseTag": "Public",
691
- "name": "recordCount",
692
- "propertyTypeTokenRange": {
693
- "startIndex": 1,
694
- "endIndex": 2
695
- },
696
- "isStatic": false,
697
- "isProtected": false,
698
- "isAbstract": false
699
- },
700
- {
701
- "kind": "Method",
702
- "canonicalReference": "@fgv/ts-agent-memory-sqlite-vec!SqliteVecFragmentIndex#remove:member(1)",
703
- "docComment": "/**\n * {@inheritDoc IFragmentVectorIndex.remove}\n */\n",
704
- "excerptTokens": [
705
- {
706
- "kind": "Content",
707
- "text": "remove(target: "
708
- },
709
- {
710
- "kind": "Reference",
711
- "text": "IEdgeTarget",
712
- "canonicalReference": "@fgv/ts-agent-memory!IEdgeTarget:interface"
713
- },
714
- {
715
- "kind": "Content",
716
- "text": "): "
717
- },
718
- {
719
- "kind": "Reference",
720
- "text": "Promise",
721
- "canonicalReference": "!Promise:interface"
722
- },
723
- {
724
- "kind": "Content",
725
- "text": "<"
726
- },
727
- {
728
- "kind": "Reference",
729
- "text": "Result",
730
- "canonicalReference": "@fgv/ts-utils!Result:type"
731
- },
732
- {
733
- "kind": "Content",
734
- "text": "<"
735
- },
736
- {
737
- "kind": "Reference",
738
- "text": "IEdgeTarget",
739
- "canonicalReference": "@fgv/ts-agent-memory!IEdgeTarget:interface"
740
- },
741
- {
742
- "kind": "Content",
743
- "text": ">>"
744
- },
745
- {
746
- "kind": "Content",
747
- "text": ";"
748
- }
749
- ],
750
- "isStatic": false,
751
- "returnTypeTokenRange": {
752
- "startIndex": 3,
753
- "endIndex": 9
754
- },
755
- "releaseTag": "Public",
756
- "isProtected": false,
757
- "overloadIndex": 1,
758
- "parameters": [
759
- {
760
- "parameterName": "target",
761
- "parameterTypeTokenRange": {
762
- "startIndex": 1,
763
- "endIndex": 2
764
- },
765
- "isOptional": false
766
- }
767
- ],
768
- "isOptional": false,
769
- "isAbstract": false,
770
- "name": "remove"
771
- }
772
- ],
773
- "implementsTokenRanges": [
774
- {
775
- "startIndex": 1,
776
- "endIndex": 2
777
- }
778
- ]
779
- },
780
- {
781
- "kind": "Class",
782
- "canonicalReference": "@fgv/ts-agent-memory-sqlite-vec!SqliteVecVectorIndex:class",
783
- "docComment": "/**\n * A persistent, `sqlite-vec`-backed `IVectorIndex` for `@fgv/ts-agent-memory`.\n *\n * @remarks\n *\n * This is the **durable** counterpart to the in-memory `InMemoryCosineIndex`: embeddings live in a `sqlite-vec` `vec0` virtual table inside a `better-sqlite3` database, so they survive a process restart. A consumer that wires this index into `FileTreeMemoryStore` (instead of the in-memory index) opens an existing vault **without re-embedding it** — the vectors are already on disk. New writes still flow through the store's incremental embed-on-write path; there is no core store change.\n *\n * The index is keyed by the canonical `edgeTargetKey` of each record's scope-qualified `(scope, id)` address (a `TEXT PRIMARY KEY` on the `vec0` table), so two records that share a filename stem across scopes never collide. The dimension is established by the first `add` (the `vec0` column is fixed-width) and recovered from the table schema when a persistent file is reopened; every later `add`/`query` must match it or fail loudly, exactly as the in-memory index does. Similarity is cosine (`distance_metric=cosine`): the returned `score` is `1 - cosineDistance`, i.e. cosine similarity in `[-1, 1]`, higher = more similar — byte-for-byte the same scoring contract as `InMemoryCosineIndex`.\n *\n * Query is a brute-force `vec0` KNN scan (not an ANN structure): correct and durable, appropriate for the same \"thousands of records\" regime the in-memory index targets. Large-N ANN indexing is explicitly out of scope — see the README.\n *\n * The `better-sqlite3` `Database` is consumer-owned (bring-your-own): this index loads the `sqlite-vec` extension onto it and reads/writes the table, but never opens or closes the connection.\n *\n * @public\n */\n",
784
- "excerptTokens": [
785
- {
786
- "kind": "Content",
787
- "text": "export declare class SqliteVecVectorIndex implements "
788
- },
789
- {
790
- "kind": "Reference",
791
- "text": "IVectorIndex",
792
- "canonicalReference": "@fgv/ts-agent-memory!IVectorIndex:interface"
793
- },
794
- {
795
- "kind": "Content",
796
- "text": " "
797
- }
798
- ],
799
- "fileUrlPath": "src/packlets/sqlite-vec-index/sqliteVecVectorIndex.ts",
800
- "releaseTag": "Public",
801
- "isAbstract": false,
802
- "name": "SqliteVecVectorIndex",
803
- "preserveMemberOrder": false,
804
- "members": [
805
- {
806
- "kind": "Method",
807
- "canonicalReference": "@fgv/ts-agent-memory-sqlite-vec!SqliteVecVectorIndex#add:member(1)",
808
- "docComment": "/**\n * {@inheritDoc IVectorIndex.add}\n */\n",
809
- "excerptTokens": [
810
- {
811
- "kind": "Content",
812
- "text": "add(target: "
813
- },
814
- {
815
- "kind": "Reference",
816
- "text": "IEdgeTarget",
817
- "canonicalReference": "@fgv/ts-agent-memory!IEdgeTarget:interface"
818
- },
819
- {
820
- "kind": "Content",
821
- "text": ", vector: "
822
- },
823
- {
824
- "kind": "Reference",
825
- "text": "Float32Array",
826
- "canonicalReference": "!Float32Array:interface"
827
- },
828
- {
829
- "kind": "Content",
830
- "text": "): "
831
- },
832
- {
833
- "kind": "Reference",
834
- "text": "Promise",
835
- "canonicalReference": "!Promise:interface"
836
- },
837
- {
838
- "kind": "Content",
839
- "text": "<"
840
- },
841
- {
842
- "kind": "Reference",
843
- "text": "Result",
844
- "canonicalReference": "@fgv/ts-utils!Result:type"
845
- },
846
- {
847
- "kind": "Content",
848
- "text": "<string>>"
849
- },
850
- {
851
- "kind": "Content",
852
- "text": ";"
853
- }
854
- ],
855
- "isStatic": false,
856
- "returnTypeTokenRange": {
857
- "startIndex": 5,
858
- "endIndex": 9
859
- },
860
- "releaseTag": "Public",
861
- "isProtected": false,
862
- "overloadIndex": 1,
863
- "parameters": [
864
- {
865
- "parameterName": "target",
866
- "parameterTypeTokenRange": {
867
- "startIndex": 1,
868
- "endIndex": 2
869
- },
870
- "isOptional": false
871
- },
872
- {
873
- "parameterName": "vector",
874
- "parameterTypeTokenRange": {
875
- "startIndex": 3,
876
- "endIndex": 4
877
- },
878
- "isOptional": false
879
- }
880
- ],
881
- "isOptional": false,
882
- "isAbstract": false,
883
- "name": "add"
884
- },
885
- {
886
- "kind": "Method",
887
- "canonicalReference": "@fgv/ts-agent-memory-sqlite-vec!SqliteVecVectorIndex.create:member(1)",
888
- "docComment": "/**\n * Family-convention factory. Loads the `sqlite-vec` extension onto the supplied `better-sqlite3` connection and, if the vector table already exists (a reopened persistent file), recovers its established dimension so no re-embedding is needed on open.\n *\n * @param params - See {@link ISqliteVecVectorIndexCreateParams}.\n *\n * @returns `Success` with the index, or `Failure` if the table name is not a simple identifier or the extension fails to load.\n */\n",
889
- "excerptTokens": [
890
- {
891
- "kind": "Content",
892
- "text": "static create(params: "
893
- },
894
- {
895
- "kind": "Reference",
896
- "text": "ISqliteVecVectorIndexCreateParams",
897
- "canonicalReference": "@fgv/ts-agent-memory-sqlite-vec!ISqliteVecVectorIndexCreateParams:interface"
898
- },
899
- {
900
- "kind": "Content",
901
- "text": "): "
902
- },
903
- {
904
- "kind": "Reference",
905
- "text": "Promise",
906
- "canonicalReference": "!Promise:interface"
907
- },
908
- {
909
- "kind": "Content",
910
- "text": "<"
911
- },
912
- {
913
- "kind": "Reference",
914
- "text": "Result",
915
- "canonicalReference": "@fgv/ts-utils!Result:type"
916
- },
917
- {
918
- "kind": "Content",
919
- "text": "<"
920
- },
921
- {
922
- "kind": "Reference",
923
- "text": "SqliteVecVectorIndex",
924
- "canonicalReference": "@fgv/ts-agent-memory-sqlite-vec!SqliteVecVectorIndex:class"
925
- },
926
- {
927
- "kind": "Content",
928
- "text": ">>"
929
- },
930
- {
931
- "kind": "Content",
932
- "text": ";"
933
- }
934
- ],
935
- "isStatic": true,
936
- "returnTypeTokenRange": {
937
- "startIndex": 3,
938
- "endIndex": 9
939
- },
940
- "releaseTag": "Public",
941
- "isProtected": false,
942
- "overloadIndex": 1,
943
- "parameters": [
944
- {
945
- "parameterName": "params",
946
- "parameterTypeTokenRange": {
947
- "startIndex": 1,
948
- "endIndex": 2
949
- },
950
- "isOptional": false
951
- }
952
- ],
953
- "isOptional": false,
954
- "isAbstract": false,
955
- "name": "create"
956
- },
957
- {
958
- "kind": "Method",
959
- "canonicalReference": "@fgv/ts-agent-memory-sqlite-vec!SqliteVecVectorIndex#query:member(1)",
960
- "docComment": "/**\n * {@inheritDoc IVectorIndex.query}\n */\n",
961
- "excerptTokens": [
962
- {
963
- "kind": "Content",
964
- "text": "query(vector: "
965
- },
966
- {
967
- "kind": "Reference",
968
- "text": "Float32Array",
969
- "canonicalReference": "!Float32Array:interface"
970
- },
971
- {
972
- "kind": "Content",
973
- "text": ", topK: "
974
- },
975
- {
976
- "kind": "Content",
977
- "text": "number"
978
- },
979
- {
980
- "kind": "Content",
981
- "text": "): "
982
- },
983
- {
984
- "kind": "Reference",
985
- "text": "Promise",
986
- "canonicalReference": "!Promise:interface"
987
- },
988
- {
989
- "kind": "Content",
990
- "text": "<"
991
- },
992
- {
993
- "kind": "Reference",
994
- "text": "Result",
995
- "canonicalReference": "@fgv/ts-utils!Result:type"
996
- },
997
- {
998
- "kind": "Content",
999
- "text": "<"
1000
- },
1001
- {
1002
- "kind": "Reference",
1003
- "text": "ReadonlyArray",
1004
- "canonicalReference": "!ReadonlyArray:interface"
1005
- },
1006
- {
1007
- "kind": "Content",
1008
- "text": "<"
1009
- },
1010
- {
1011
- "kind": "Reference",
1012
- "text": "IVectorQueryHit",
1013
- "canonicalReference": "@fgv/ts-agent-memory!IVectorQueryHit:interface"
1014
- },
1015
- {
1016
- "kind": "Content",
1017
- "text": ">>>"
1018
- },
1019
- {
1020
- "kind": "Content",
1021
- "text": ";"
1022
- }
1023
- ],
1024
- "isStatic": false,
1025
- "returnTypeTokenRange": {
1026
- "startIndex": 5,
1027
- "endIndex": 13
1028
- },
1029
- "releaseTag": "Public",
1030
- "isProtected": false,
1031
- "overloadIndex": 1,
1032
- "parameters": [
1033
- {
1034
- "parameterName": "vector",
1035
- "parameterTypeTokenRange": {
1036
- "startIndex": 1,
1037
- "endIndex": 2
1038
- },
1039
- "isOptional": false
1040
- },
1041
- {
1042
- "parameterName": "topK",
1043
- "parameterTypeTokenRange": {
1044
- "startIndex": 3,
1045
- "endIndex": 4
1046
- },
1047
- "isOptional": false
1048
- }
1049
- ],
1050
- "isOptional": false,
1051
- "isAbstract": false,
1052
- "name": "query"
1053
- },
1054
- {
1055
- "kind": "Method",
1056
- "canonicalReference": "@fgv/ts-agent-memory-sqlite-vec!SqliteVecVectorIndex#remove:member(1)",
1057
- "docComment": "/**\n * {@inheritDoc IVectorIndex.remove}\n */\n",
1058
- "excerptTokens": [
1059
- {
1060
- "kind": "Content",
1061
- "text": "remove(target: "
1062
- },
1063
- {
1064
- "kind": "Reference",
1065
- "text": "IEdgeTarget",
1066
- "canonicalReference": "@fgv/ts-agent-memory!IEdgeTarget:interface"
1067
- },
1068
- {
1069
- "kind": "Content",
1070
- "text": "): "
1071
- },
1072
- {
1073
- "kind": "Reference",
1074
- "text": "Promise",
1075
- "canonicalReference": "!Promise:interface"
1076
- },
1077
- {
1078
- "kind": "Content",
1079
- "text": "<"
1080
- },
1081
- {
1082
- "kind": "Reference",
1083
- "text": "Result",
1084
- "canonicalReference": "@fgv/ts-utils!Result:type"
1085
- },
1086
- {
1087
- "kind": "Content",
1088
- "text": "<"
1089
- },
1090
- {
1091
- "kind": "Reference",
1092
- "text": "IEdgeTarget",
1093
- "canonicalReference": "@fgv/ts-agent-memory!IEdgeTarget:interface"
1094
- },
1095
- {
1096
- "kind": "Content",
1097
- "text": ">>"
1098
- },
1099
- {
1100
- "kind": "Content",
1101
- "text": ";"
1102
- }
1103
- ],
1104
- "isStatic": false,
1105
- "returnTypeTokenRange": {
1106
- "startIndex": 3,
1107
- "endIndex": 9
1108
- },
1109
- "releaseTag": "Public",
1110
- "isProtected": false,
1111
- "overloadIndex": 1,
1112
- "parameters": [
1113
- {
1114
- "parameterName": "target",
1115
- "parameterTypeTokenRange": {
1116
- "startIndex": 1,
1117
- "endIndex": 2
1118
- },
1119
- "isOptional": false
1120
- }
1121
- ],
1122
- "isOptional": false,
1123
- "isAbstract": false,
1124
- "name": "remove"
1125
- },
1126
- {
1127
- "kind": "Property",
1128
- "canonicalReference": "@fgv/ts-agent-memory-sqlite-vec!SqliteVecVectorIndex#size:member",
1129
- "docComment": "/**\n * The number of vectors currently held. Zero before the first `add`.\n */\n",
1130
- "excerptTokens": [
1131
- {
1132
- "kind": "Content",
1133
- "text": "get size(): "
1134
- },
1135
- {
1136
- "kind": "Content",
1137
- "text": "number"
1138
- },
1139
- {
1140
- "kind": "Content",
1141
- "text": ";"
1142
- }
1143
- ],
1144
- "isReadonly": true,
1145
- "isOptional": false,
1146
- "releaseTag": "Public",
1147
- "name": "size",
1148
- "propertyTypeTokenRange": {
1149
- "startIndex": 1,
1150
- "endIndex": 2
1151
- },
1152
- "isStatic": false,
1153
- "isProtected": false,
1154
- "isAbstract": false
1155
- }
1156
- ],
1157
- "implementsTokenRanges": [
1158
- {
1159
- "startIndex": 1,
1160
- "endIndex": 2
1161
- }
1162
- ]
1163
- }
1164
- ]
1165
- }
1166
- ]
1167
- }