@kybernesis/brain-storage-vec 0.8.1 → 0.8.3
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/LICENSE +21 -0
- package/README.md +62 -0
- package/package.json +3 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kybernesis
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @kybernesis/brain-storage-vec
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@kybernesis/brain-storage-vec)
|
|
4
|
+
|
|
5
|
+
The **`VectorRepository`** for [Cortex](../../README.md) — a [sqlite-vec](https://github.com/asg017/sqlite-vec)
|
|
6
|
+
implementation of the vector store. It holds the embeddings that power semantic recall.
|
|
7
|
+
|
|
8
|
+
**Used with [`@kybernesis/brain-core`](../brain-core), via
|
|
9
|
+
[`@kybernesis/brain-storage-sqlite`](../brain-storage-sqlite).** The SQLite storage provider
|
|
10
|
+
lazy-loads this package for its vector store — you don't usually import it directly, you just
|
|
11
|
+
install it alongside the SQLite provider.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add @kybernesis/brain-storage-vec @kybernesis/brain-storage-sqlite @kybernesis/brain-core
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Peer dependencies (host-provided): `better-sqlite3` (`>= 9`) and `sqlite-vec` (`>= 0.1`).
|
|
20
|
+
This package carries the **native sqlite-vec binary**, which is why it's split out from the
|
|
21
|
+
SQLite provider and loaded lazily.
|
|
22
|
+
|
|
23
|
+
## How it fits
|
|
24
|
+
|
|
25
|
+
You typically never call this directly — wiring the SQLite provider is enough:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { createSqliteStorageProvider } from '@kybernesis/brain-storage-sqlite';
|
|
29
|
+
import { setStorageProvider, indexChunk, semanticSearch } from '@kybernesis/brain-core';
|
|
30
|
+
import { createOpenAIEmbedder } from '@kybernesis/brain-embed-openai';
|
|
31
|
+
import { setEmbeddingProvider } from '@kybernesis/brain-core';
|
|
32
|
+
|
|
33
|
+
setStorageProvider(createSqliteStorageProvider()); // lazy-loads brain-storage-vec
|
|
34
|
+
setEmbeddingProvider(createOpenAIEmbedder());
|
|
35
|
+
|
|
36
|
+
await indexChunk(tenant, 'apples are red', { ts: '2026-06-06T09:00:00Z', origin_id: 'a' });
|
|
37
|
+
await semanticSearch(tenant, 'fruit colour');
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Direct API (advanced)
|
|
41
|
+
|
|
42
|
+
For tooling or custom providers, the low-level handle is exported:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import { getVectorDb, vectorCount, toFloat32Buffer, closeAllVectorDbs } from '@kybernesis/brain-storage-vec';
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The schema (matching KAD's `vectors.db`): a single `chunks` `vec0` virtual table
|
|
49
|
+
(`embedding float[1536]`) plus a `chunk_meta` table for the searchable fields.
|
|
50
|
+
|
|
51
|
+
## Constraint: 1536 dimensions
|
|
52
|
+
|
|
53
|
+
The schema is fixed at `EMBEDDING_DIM = 1536` (`text-embedding-3-small`). A different
|
|
54
|
+
embedding model must emit 1536-dim vectors, or `EMBEDDING_DIM` and the schema move together
|
|
55
|
+
and you re-index. Don't mix models within one populated `vectors.db` — distances across
|
|
56
|
+
models aren't comparable.
|
|
57
|
+
|
|
58
|
+
## Notes
|
|
59
|
+
|
|
60
|
+
- ESM-only, TypeScript strict. Native module — needs the `sqlite-vec` binary for your platform.
|
|
61
|
+
- Search is brute-force `vec_distance_l2` (port-faithful to KAD) — fine at brain scale.
|
|
62
|
+
- Part of [Cortex](../../README.md) — `@kybernesis/brain-*`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kybernesis/brain-storage-vec",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "sqlite-vec VectorStore implementation for brain-core (1536-dim, cap 8192)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "David Cruwys (AppyDave)",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"README.md"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@kybernesis/brain-contracts": "0.8.
|
|
30
|
+
"@kybernesis/brain-contracts": "0.8.3"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"better-sqlite3": ">=9.0.0",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@types/better-sqlite3": "^7.6.0",
|
|
38
38
|
"better-sqlite3": "^12.0.0",
|
|
39
39
|
"sqlite-vec": "^0.1.9",
|
|
40
|
-
"@kybernesis/brain-testkit": "0.8.
|
|
40
|
+
"@kybernesis/brain-testkit": "0.8.3"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|