@wrongstack/vector-memory 0.308.0 → 0.308.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +926 -67
- package/dist/sage-event-mirror.d.ts +47 -0
- package/dist/sage-fusion.d.ts +87 -0
- package/dist/sage-port-wrapper.d.ts +53 -0
- package/dist/sage-sync-source.d.ts +39 -0
- package/dist/sage-sync.d.ts +55 -0
- package/dist/schema.d.ts +29 -5
- package/dist/search-race.d.ts +75 -0
- package/dist/store.d.ts +78 -1
- package/dist/types.d.ts +15 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -12,6 +12,69 @@ stores cannot contend on the same file lock. A built-in `syncFromSage`
|
|
|
12
12
|
bridge indexes active SAGE memories into the vector store, giving
|
|
13
13
|
semantic search over your existing knowledge.
|
|
14
14
|
|
|
15
|
+
## Parallel operation with SAGE
|
|
16
|
+
|
|
17
|
+
`wrapMemoryPortWithVectorRecall(port, { store })` returns a new
|
|
18
|
+
`MemoryPort` whose `searchSage` calls automatically fuse lexical and
|
|
19
|
+
semantic recall via Reciprocal Rank Fusion. Hosts that opt in get
|
|
20
|
+
**vector-augmented retrieval without changing any caller code** — the
|
|
21
|
+
tool-call middleware, the turn middleware, and the surface/retrieval
|
|
22
|
+
capabilities all see the same `searchSage(query, options)` shape.
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import {
|
|
26
|
+
VectorMemoryStore,
|
|
27
|
+
TransformersEmbeddingProvider,
|
|
28
|
+
wrapMemoryPortWithVectorRecall,
|
|
29
|
+
} from '@wrongstack/vector-memory';
|
|
30
|
+
|
|
31
|
+
const vectorStore = new VectorMemoryStore({
|
|
32
|
+
provider: new TransformersEmbeddingProvider({ cacheDir }),
|
|
33
|
+
projectRoot,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const augmentedPort = wrapMemoryPortWithVectorRecall(sagePort, {
|
|
37
|
+
store: vectorStore,
|
|
38
|
+
weight: 0.3, // default; mirrors SAGE's hybridRerankMemories baseline
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Every downstream searchSage(query, options) now does
|
|
42
|
+
// lexical candidates + vector hits → RRF → fused result list
|
|
43
|
+
const hits = await augmentedPort
|
|
44
|
+
.getCapability(SAGE_RETRIEVAL_CAPABILITY)!
|
|
45
|
+
.searchSage('quantum entanglement', { limit: 10 });
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The wrapper is fail-open: a thrown error from the vector backend
|
|
49
|
+
(offline model, missing dependency) falls back to the lexical list
|
|
50
|
+
unchanged. The vector channel only **re-orders and boosts** — it does
|
|
51
|
+
not inject foreign memories, because vector hits that map to SAGE
|
|
52
|
+
memories not present in the lexical list are dropped (no Sage object to
|
|
53
|
+
materialize).
|
|
54
|
+
|
|
55
|
+
## Embedding result cache
|
|
56
|
+
|
|
57
|
+
A provider-level cache keyed by `(content_hash, provider_id, dimensions)`
|
|
58
|
+
skips the ONNX forward pass for repeated text. Both `remember()` and
|
|
59
|
+
`search()` use the same cache, so the second embedding of an identical
|
|
60
|
+
text costs only a SQLite lookup. Hosts that want to bound cache growth
|
|
61
|
+
can call `store.evictCache(keepMostRecent)` for an LRU sweep.
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
const stats = store.cacheStats();
|
|
65
|
+
// { entries: 142, providers: 1, totalUseCount: 1834, oldestLastUsedAt: '...' }
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Cross-process safety
|
|
69
|
+
|
|
70
|
+
Mutating operations (`remember`, `forget`, `reindexAll`, `syncFromSage`,
|
|
71
|
+
`evictCache`) are wrapped in a host-OS file lock. Two processes pointing
|
|
72
|
+
at the same `.wrongstack/vector-memory/vector-memory.db` cannot interleave
|
|
73
|
+
a read-modify-write. `remember()` is also idempotent on `content_hash`:
|
|
74
|
+
calling it twice with the same text returns the existing entry instead of
|
|
75
|
+
inserting a duplicate (the `UNIQUE` index on `entries.content_hash` is
|
|
76
|
+
the second line of defense).
|
|
77
|
+
|
|
15
78
|
## Installation
|
|
16
79
|
|
|
17
80
|
`@huggingface/transformers` is listed as an **optional** dependency so
|
package/dist/index.d.ts
CHANGED
|
@@ -2,9 +2,15 @@
|
|
|
2
2
|
* @wrongstack/vector-memory — public exports.
|
|
3
3
|
*/
|
|
4
4
|
export { DEFAULT_VECTOR_DIMENSIONS, DEFAULT_VECTOR_DTYPE, DEFAULT_VECTOR_MODEL_ID, TransformersEmbeddingProvider, type TransformersEmbeddingProviderOptions, } from './transformers-provider.js';
|
|
5
|
-
export { VECTOR_DIMENSIONS_KEY, VECTOR_PROVIDER_KEY, VECTOR_SCHEMA_VERSION, decodeVector, encodeVector, initVectorSchema, } from './schema.js';
|
|
5
|
+
export { VECTOR_DIMENSIONS_KEY, VECTOR_PROVIDER_KEY, VECTOR_SCHEMA_VERSION, decodeVector, encodeVector, initVectorSchema, lookupEmbeddingCache, upsertEmbeddingCache, } from './schema.js';
|
|
6
6
|
export { VectorMemoryStore, fallbackHashingProvider, type SageSyncSource, } from './store.js';
|
|
7
|
+
export { createSageSurfaceSyncSource, type SageSurfaceSyncOptions, } from './sage-sync-source.js';
|
|
8
|
+
export { SAGE_SYNC_MARKER_FILENAME, decideWhetherToSync, startFirstBootSageSync, type FirstBootSageSyncOptions, type FirstBootSageSyncResult, type SageSyncMarker, } from './sage-sync.js';
|
|
7
9
|
export { createVectorMemoryTools } from './tools.js';
|
|
10
|
+
export { asVectorRecallProvider, fuseWithVectorMemory, type SageFusionHit, type SageFusionOptions, } from './sage-fusion.js';
|
|
11
|
+
export { wrapMemoryPortWithVectorRecall, type VectorPortWrappingOptions, } from './sage-port-wrapper.js';
|
|
12
|
+
export { forgetStaleSageMirrors, subscribeVectorMemoryToSage, type VectorMemoryMirrorHandle, type VectorMemoryMirrorOptions, } from './sage-event-mirror.js';
|
|
13
|
+
export { runSearchRace, type SearchRaceChannelHit, type SearchRaceOptions, type SearchRaceResult, } from './search-race.js';
|
|
8
14
|
export type { SageSyncReport, VectorEntry, VectorEntryInput, VectorEntryWithVector, VectorKind, VectorMemoryStoreOptions, VectorScope, VectorSearchHit, VectorSearchOptions, VectorStoreStats, } from './types.js';
|
|
9
15
|
export { VectorMemoryError, VectorMemoryProviderUnavailableError, } from './errors.js';
|
|
10
16
|
//# sourceMappingURL=index.d.ts.map
|