pi-mono/packages/session-backends/sqlite-node
Armin Ronacher 34dc9d055a feat: move facet services into Chord
Move service, replicated-state, facet host, and loader ownership into the standalone Chord package. Migrate consumers and leave runtime JSON enforcement to serializers.
2026-08-29 14:55:51 +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 Add [Unreleased] section for next cycle 2026-08-28 23:56:06 +02:00
package.json Merge remote-tracking branch 'origin/main' into dev 2026-08-29 08:21:44 +00:00
README.md docs(agent): audit post-WP05 roadmap 2026-08-26 22:41:05 +02:00
tsconfig.build.json chore: rename storage package to session-backends 2026-08-05 09:28:44 +02:00
vitest.benchmark.config.ts feat: move facet services into Chord 2026-08-29 14:55:51 +02:00
vitest.config.ts feat: move facet services into Chord 2026-08-29 14:55:51 +02:00

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

Node node:sqlite Session backend for @earendil-works/pi-agent-core.

import { BACKGROUND_CONTEXT } from "@earendil-works/pi-agent-core";
import {
  createNodeSqliteFactory,
  SqliteSessionRepo,
} from "@earendil-works/pi-session-backend-sqlite-node";

const repository = new SqliteSessionRepo({
  directory: "/var/lib/pi/sessions",
  databaseFactory: createNodeSqliteFactory(),
});

const session = await repository.create({}, BACKGROUND_CONTEXT);
const main = await session.createBranch("main", null, BACKGROUND_CONTEXT);
await main.appendMessage(
  { role: "user", content: "hello", timestamp: Date.now() },
  BACKGROUND_CONTEXT,
);
await session.close(BACKGROUND_CONTEXT);
await repository.close(BACKGROUND_CONTEXT);

The default layout creates one {sessionId}.sqlite file per Session under directory; path-safe encoding for arbitrary explicit IDs is tracked by WP07. Pass databasePath to place multiple Sessions in one supported shared container. Open Sessions own separate SQLite connections; repository listing, deletion, and closed-source forks open temporary connections.

The backend provides the Session repository, storage implementation, writer leases, branch projections, and maintained statistics. WP07 tracks transaction-local fence enforcement, deletion fencing, and path safety. The package does not currently export a search service or FTS index; search is the separate S3 projection.