@coopah/bentley-store-sqlite
v0.2.2
Published
SQLite storage backend for Bentley
Downloads
256
Readme
@coopah/bentley-store-sqlite
SQLite storage backend for Bentley workspace memory. Replaces the default file-based memory with a single SQLite database using better-sqlite3.
Install
pnpm add @coopah/bentley-store-sqliteDependencies
@coopah/bentley-corebetter-sqlite3^11.8.0
Usage
import { createBentley } from "@coopah/bentley-core";
import { bentleySqlitePlugin } from "@coopah/bentley-store-sqlite";
const bentley = createBentley({
plugins: [
bentleySqlitePlugin({
dbPath: "./data/bentley.db",
}),
],
});With Embeddings (Semantic Search)
import { embed } from "ai";
import { openai } from "@ai-sdk/openai";
bentleySqlitePlugin({
dbPath: "./data/bentley.db",
embedder: async (text) => {
const { embedding } = await embed({ model: openai.embedding("text-embedding-3-small"), value: text });
return embedding;
},
maxEmbeddingsToScan: 1000,
});API
bentleySqlitePlugin(config)—BentleyPluginthat registers SQLite as the workspace memory backendBentleySqliteStore— ImplementsBentleyWorkspaceMemoryfrom core
Configuration
interface SqliteStoreConfig {
dbPath: string; // Path to SQLite database file
embedder?: (text: string) => Promise<number[]>; // Optional embedding function for semantic search
maxEmbeddingsToScan?: number; // Limit for brute-force similarity scan
}BentleySqliteStore Methods
Implements the full BentleyWorkspaceMemory interface:
| Method | Description |
|--------|-------------|
| getSoul(shellId) | Get shell identity (SOUL.md equivalent) |
| updateSoul(shellId, content) | Update shell identity |
| getMemory(shellId) | Retrieve long-term memory facts |
| appendMemory(shellId, fact) | Add a memory fact |
| getRecentMessages(shellId, threadId, limit?) | Get conversation history |
| addMessage(shellId, threadId, message) | Store a message |
| semanticSearch(shellId, query, topK?) | Vector/keyword search across messages |
| getRecentMessagesWithStrategy() | Memory reduction with configurable strategies |
| getHeartbeatChecklist(shellId) | Recurring task state |
| close() | Close the database connection |
Database Tables
souls— Shell identity (SOUL.md content)memories— Long-term facts with timestampsmessages— Conversation history by shell/threadheartbeats— Task runner stateembeddings— Message embeddings for semantic search
Related Packages
| Package | Role |
|---------|------|
| @coopah/bentley-core | Core runtime (required) |
| @coopah/bentley-store-postgres | PostgreSQL backend (with native pgvector) |
License
MIT
