@kybernesis/brain-storage-sqlite 0.8.2 → 0.8.4
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 +58 -0
- package/package.json +4 -4
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,58 @@
|
|
|
1
|
+
# @kybernesis/brain-storage-sqlite
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@kybernesis/brain-storage-sqlite)
|
|
4
|
+
|
|
5
|
+
The default **`StorageProvider`** for [Cortex](../../README.md) — a `better-sqlite3`
|
|
6
|
+
implementation of the persistence seam. It backs the timeline, entity-graph, facts, and sleep
|
|
7
|
+
subsystems, and bundles the vector store (lazy-loaded from
|
|
8
|
+
[`@kybernesis/brain-storage-vec`](../brain-storage-vec)).
|
|
9
|
+
|
|
10
|
+
**Used with [`@kybernesis/brain-core`](../brain-core).** It implements the `StorageProvider`
|
|
11
|
+
interface from [`@kybernesis/brain-contracts`](../brain-contracts); you inject it, the kernel
|
|
12
|
+
calls it.
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add @kybernesis/brain-storage-sqlite @kybernesis/brain-core
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
`better-sqlite3` (`>= 9`) is a peer dependency — the host provides it. Add
|
|
21
|
+
[`@kybernesis/brain-storage-vec`](../brain-storage-vec) too if you index vectors.
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { createSqliteStorageProvider } from '@kybernesis/brain-storage-sqlite';
|
|
27
|
+
import { setStorageProvider } from '@kybernesis/brain-core';
|
|
28
|
+
|
|
29
|
+
setStorageProvider(createSqliteStorageProvider());
|
|
30
|
+
// brain-core now persists every subsystem to per-tenant SQLite files.
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Each `TenantContext` maps to its own set of SQLite files (timeline, entity-graph, vectors,
|
|
34
|
+
sleep) under the tenant's paths. Connections are pooled per `slug:kind` and opened lazily
|
|
35
|
+
with `WAL` + `synchronous = NORMAL` + `foreign_keys = ON`.
|
|
36
|
+
|
|
37
|
+
## The vector store is lazy
|
|
38
|
+
|
|
39
|
+
The `StorageProvider` bundle includes a `VectorRepository`, but the sqlite-vec **native
|
|
40
|
+
binary** lives in [`@kybernesis/brain-storage-vec`](../brain-storage-vec). It is imported only
|
|
41
|
+
on first vector use. If it can't load (missing binary, unsupported platform), vector
|
|
42
|
+
operations degrade to safe no-ops instead of throwing — and `brain-core` maps those to its
|
|
43
|
+
graceful results.
|
|
44
|
+
|
|
45
|
+
## Lifecycle helpers
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { closeWorkspace, closeAll } from '@kybernesis/brain-storage-sqlite';
|
|
49
|
+
|
|
50
|
+
closeWorkspace(tenant.slug); // close one tenant's connections
|
|
51
|
+
closeAll(); // close everything (tests, shutdown)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Notes
|
|
55
|
+
|
|
56
|
+
- ESM-only, TypeScript strict. Native module — see `better-sqlite3` for platform/build notes.
|
|
57
|
+
- Conformance is proven against [`@kybernesis/brain-testkit`](../brain-testkit)'s storage cases.
|
|
58
|
+
- Part of [Cortex](../../README.md) — `@kybernesis/brain-*`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kybernesis/brain-storage-sqlite",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"description": "better-sqlite3 StructuredStore implementation for brain-core",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "David Cruwys (AppyDave)",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"README.md"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@kybernesis/brain-contracts": "0.8.
|
|
30
|
+
"@kybernesis/brain-contracts": "0.8.4"
|
|
31
31
|
},
|
|
32
32
|
"optionalDependencies": {
|
|
33
|
-
"@kybernesis/brain-storage-vec": "0.8.
|
|
33
|
+
"@kybernesis/brain-storage-vec": "0.8.4"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"better-sqlite3": ">=9.0.0"
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/better-sqlite3": "^7.6.0",
|
|
40
40
|
"better-sqlite3": "^12.0.0",
|
|
41
|
-
"@kybernesis/brain-testkit": "0.8.
|
|
41
|
+
"@kybernesis/brain-testkit": "0.8.4"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|