pi-mono/packages/session-backends/sqlite-node
Mario Zechner 5507d76ee8 feat(agent,ai): add narrow subpath exports so clients skip the barrel
A barrel forces Node to evaluate its whole graph: importing reduceLaneSnapshot
(1 file, 6 KB) through pi-agent-core's index evaluated 106 files, and mini's
server loaded 112 files to enumerate JSONL headers. Types are free, so this only
ever affected value imports.

pi-ai gains ./utils/* alongside the existing ./providers/* and ./api/*
wildcards. pi-agent-core gains ./harness/context, ./harness/env/nodejs,
./harness/runtime/reducer and ./harness/session, and ./session/testing becomes
./harness/session/testing so every export mirrors its source path. The barrel
and ./node keep their batteries-included semantics.

The session layer takes uuidv7 from @earendil-works/pi-ai/utils/uuid rather than
the pi-ai barrel, which is what let ./harness/session drop from 42 files to 19.
Two imports there were written `import { type Usage } from` - not a type-only
statement, so it emitted a runtime import of the barrel.

scripts/check-entry-graphs.mjs walks each declared entry's value-import graph and
enforces per-entry budgets and forbidden paths, so a stray `export *` cannot
silently undo this. It caught the two `import { type ... }` regressions above.

Measured with mini: server 112 files and 98 MB to 28 files and 69 MB, presentation
204 files and 125 MB to 99 files and 110 MB. The worker still loads the provider
graph, correctly.
2026-08-26 22:02:31 +02:00
..
benchmark/session feat(agent,ai): add narrow subpath exports so clients skip the barrel 2026-08-26 22:02:31 +02:00
scripts fix(sqlite): ENOENT, copy migs into dist 2026-08-13 14:26:09 +02:00
src feat(agent): expose durable lane operations 2026-08-26 21:14:59 +02:00
test feat(agent,ai): add narrow subpath exports so clients skip the barrel 2026-08-26 22:02:31 +02:00
CHANGELOG.md feat: merge main into dev 2026-08-24 13:13:03 +02:00
package.json feat: merge main into dev 2026-08-24 13:13:03 +02:00
README.md refactor: search (#7797) 2026-08-11 13:27:48 +02:00
tsconfig.build.json chore: rename storage package to session-backends 2026-08-05 09:28:44 +02:00
vitest.benchmark.config.ts test(sqlite): timing benchmark 2026-08-18 18:25:34 +02:00
vitest.config.ts feat(agent): add SQLite storage conformance coverage 2026-08-14 10:50:23 +02:00

@earendil-works/pi-session-backend-sqlite-node

Node sqlite session backend for @earendil-works/pi-agent-core sessions. Provides the node:sqlite adapter (SqliteDatabase implementation), SQLite session repository, migrations, materialized views, and optional FTS search.

await using repository = new SqliteSessionRepository(options);
const search = createSqliteSessionSearch(options);
const session = await repository.create({ cwd });
await session.appendMessage(message);

const hits = [];
for await (const hit of search.search("needle")) hits.push(hit);

The repository lazily owns one shared database connection. Search is an independent service over the same canonical database: repositories do not expose search(). The FTS table and triggers are created lazily on the first non-blank search; when FTS is first created, search performs a one-time rebuild from canonical entries. After that, SQLite triggers keep FTS in sync with canonical entry inserts, deletes, and payload updates.