Chat SQLite
chat/sqlite
Section titled “chat/sqlite”Classes
Section titled “Classes”SQLiteProviderStore
Section titled “SQLiteProviderStore”Defined in: chat/sqlite/provider-store.ts:25
Provider storage interface for server-side provider management
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SQLiteProviderStore(
db):SQLiteProviderStore
Defined in: chat/sqlite/provider-store.ts:28
Parameters
Section titled “Parameters”Database
Returns
Section titled “Returns”Methods
Section titled “Methods”create()
Section titled “create()”create(
config):Promise<void>
Defined in: chat/sqlite/provider-store.ts:33
Create a new provider. Generates UUID if id not set on config.
Parameters
Section titled “Parameters”config
Section titled “config”Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”delete()
Section titled “delete()”delete(
id):Promise<void>
Defined in: chat/sqlite/provider-store.ts:61
Delete a provider by id.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”get(
id):Promise<ProviderConfig|null>
Defined in: chat/sqlite/provider-store.ts:40
Get a provider by id. Returns null if not found.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<ProviderConfig | null>
Implementation of
Section titled “Implementation of”list()
Section titled “list()”list():
Promise<ProviderConfig[]>
Defined in: chat/sqlite/provider-store.ts:65
List all providers.
Returns
Section titled “Returns”Promise<ProviderConfig[]>
Implementation of
Section titled “Implementation of”update()
Section titled “update()”update(
id,changes):Promise<void>
Defined in: chat/sqlite/provider-store.ts:45
Update an existing provider. Throws if not found.
Parameters
Section titled “Parameters”string
changes
Section titled “changes”Partial<Omit<ProviderConfig, "id" | "createdAt">>
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”SQLiteSessionStore
Section titled “SQLiteSessionStore”Defined in: chat/sqlite/session-store.ts:61
Full session store interface — union of reader and writer. Backward-compatible: all existing implementations continue to work.
Example
Section titled “Example”const store = new InMemorySessionStore();const session = await store.createSession({ config: { model: "gpt-4", backend: "vercel-ai" } });await store.appendMessage(session.id, message);const page = await store.loadMessages(session.id, { limit: 20, offset: 0 });Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SQLiteSessionStore(
db):SQLiteSessionStore
Defined in: chat/sqlite/session-store.ts:64
Parameters
Section titled “Parameters”Database
Returns
Section titled “Returns”Methods
Section titled “Methods”appendMessage()
Section titled “appendMessage()”appendMessage(
sessionId,message):Promise<void>
Defined in: chat/sqlite/session-store.ts:137
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”message
Section titled “message”Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”IChatSessionStore.appendMessage
clear()
Section titled “clear()”clear():
Promise<void>
Defined in: chat/sqlite/session-store.ts:243
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”count()
Section titled “count()”count():
Promise<number>
Defined in: chat/sqlite/session-store.ts:239
Returns
Section titled “Returns”Promise<number>
Implementation of
Section titled “Implementation of”createSession()
Section titled “createSession()”createSession(
options?):Promise<ChatSession<Record<string,unknown>>>
Defined in: chat/sqlite/session-store.ts:71
Parameters
Section titled “Parameters”options?
Section titled “options?”CreateSessionOptions = {}
Returns
Section titled “Returns”Promise<ChatSession<Record<string, unknown>>>
Implementation of
Section titled “Implementation of”IChatSessionStore.createSession
deleteSession()
Section titled “deleteSession()”deleteSession(
id):Promise<void>
Defined in: chat/sqlite/session-store.ts:132
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”IChatSessionStore.deleteSession
getSession()
Section titled “getSession()”getSession(
id):Promise<ChatSession<Record<string,unknown>> |null>
Defined in: chat/sqlite/session-store.ts:94
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<ChatSession<Record<string, unknown>> | null>
Implementation of
Section titled “Implementation of”listSessions()
Section titled “listSessions()”listSessions(
options?):Promise<ChatSession<Record<string,unknown>>[]>
Defined in: chat/sqlite/session-store.ts:102
Parameters
Section titled “Parameters”options?
Section titled “options?”Returns
Section titled “Returns”Promise<ChatSession<Record<string, unknown>>[]>
Implementation of
Section titled “Implementation of”IChatSessionStore.listSessions
loadMessages()
Section titled “loadMessages()”loadMessages(
sessionId,options?):Promise<PaginatedMessages>
Defined in: chat/sqlite/session-store.ts:187
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”options?
Section titled “options?”limit?
Section titled “limit?”number
offset?
Section titled “offset?”number
Returns
Section titled “Returns”Promise<PaginatedMessages>
Implementation of
Section titled “Implementation of”IChatSessionStore.loadMessages
saveMessages()
Section titled “saveMessages()”saveMessages(
sessionId,messages):Promise<void>
Defined in: chat/sqlite/session-store.ts:161
Parameters
Section titled “Parameters”sessionId
Section titled “sessionId”messages
Section titled “messages”ChatMessage<unknown>[]
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”IChatSessionStore.saveMessages
searchSessions()
Section titled “searchSessions()”searchSessions(
options):Promise<ChatSession<Record<string,unknown>>[]>
Defined in: chat/sqlite/session-store.ts:212
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”Promise<ChatSession<Record<string, unknown>>[]>
Implementation of
Section titled “Implementation of”IChatSessionStore.searchSessions
updateConfig()
Section titled “updateConfig()”updateConfig(
id,config):Promise<void>
Defined in: chat/sqlite/session-store.ts:122
Parameters
Section titled “Parameters”config
Section titled “config”Partial<ChatSessionConfig>
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”IChatSessionStore.updateConfig
updateTitle()
Section titled “updateTitle()”updateTitle(
id,title):Promise<void>
Defined in: chat/sqlite/session-store.ts:115
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”SQLiteTokenStore
Section titled “SQLiteTokenStore”Defined in: chat/sqlite/token-store.ts:24
Token storage interface for server-side token management
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SQLiteTokenStore(
db):SQLiteTokenStore
Defined in: chat/sqlite/token-store.ts:27
Parameters
Section titled “Parameters”Database
Returns
Section titled “Returns”Methods
Section titled “Methods”clear()
Section titled “clear()”clear(
provider):Promise<void>
Defined in: chat/sqlite/token-store.ts:44
Remove a specific provider’s token.
Parameters
Section titled “Parameters”provider
Section titled “provider”string
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”clearAll()
Section titled “clearAll()”clearAll():
Promise<void>
Defined in: chat/sqlite/token-store.ts:48
Remove all stored tokens.
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”list()
Section titled “list()”list():
Promise<string[]>
Defined in: chat/sqlite/token-store.ts:52
List provider names that have saved tokens.
Returns
Section titled “Returns”Promise<string[]>
Implementation of
Section titled “Implementation of”load()
Section titled “load()”load(
provider):Promise<AuthToken|null>
Defined in: chat/sqlite/token-store.ts:39
Load a previously saved token. Returns null if not found.
Parameters
Section titled “Parameters”provider
Section titled “provider”string
Returns
Section titled “Returns”Promise<AuthToken | null>
Implementation of
Section titled “Implementation of”save()
Section titled “save()”save(
provider,token):Promise<void>
Defined in: chat/sqlite/token-store.ts:32
Save a token for a provider. Overwrites if exists.
Parameters
Section titled “Parameters”provider
Section titled “provider”string
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”Interfaces
Section titled “Interfaces”Migration
Section titled “Migration”Defined in: chat/sqlite/migrations.ts:17
Properties
Section titled “Properties”description
Section titled “description”description:
string
Defined in: chat/sqlite/migrations.ts:21
Human-readable description
up: (
db) =>void
Defined in: chat/sqlite/migrations.ts:23
DDL statements to apply. Runs inside a transaction.
Parameters
Section titled “Parameters”Database
Returns
Section titled “Returns”void
version
Section titled “version”version:
number
Defined in: chat/sqlite/migrations.ts:19
Sequential version number (1-based)
SQLiteStorage
Section titled “SQLiteStorage”Defined in: chat/sqlite/factory.ts:35
Properties
Section titled “Properties”db:
Database
Defined in: chat/sqlite/factory.ts:37
The underlying better-sqlite3 Database instance
providerStore
Section titled “providerStore”providerStore:
IProviderStore
Defined in: chat/sqlite/factory.ts:41
Provider store for provider configurations
sessionStore
Section titled “sessionStore”sessionStore:
IChatSessionStore
Defined in: chat/sqlite/factory.ts:39
Session store for chat sessions and messages
tokenStore
Section titled “tokenStore”tokenStore:
ITokenStore
Defined in: chat/sqlite/factory.ts:43
Token store for auth tokens
SQLiteStorageOptions
Section titled “SQLiteStorageOptions”Defined in: chat/sqlite/factory.ts:28
Properties
Section titled “Properties”
optionaldb:Database
Defined in: chat/sqlite/factory.ts:32
Optional pre-created Database instance. If provided, dbPath is ignored.
dbPath
Section titled “dbPath”dbPath:
string
Defined in: chat/sqlite/factory.ts:30
Path to SQLite database file. Use “:memory:” for in-memory database.
Variables
Section titled “Variables”migrations
Section titled “migrations”
constmigrations: readonlyMigration[]
Defined in: chat/sqlite/migrations.ts:42
Migration registry. Append new migrations here. Version numbers must be sequential (1, 2, 3, …).
Functions
Section titled “Functions”createSQLiteStorage()
Section titled “createSQLiteStorage()”createSQLiteStorage(
pathOrOptions):SQLiteStorage
Defined in: chat/sqlite/factory.ts:59
Create all three SQLite stores sharing a single database.
Requires better-sqlite3 as a peer dependency.
Schema tables are auto-created on first use.
Parameters
Section titled “Parameters”pathOrOptions
Section titled “pathOrOptions”Database file path string, or options object
string | SQLiteStorageOptions
Returns
Section titled “Returns”Object with db, sessionStore, providerStore, tokenStore
Throws
Section titled “Throws”If better-sqlite3 is not installed
getSchemaVersion()
Section titled “getSchemaVersion()”getSchemaVersion(
db):number
Defined in: chat/sqlite/migrations.ts:102
Get current schema version (0 if no migrations applied).
Parameters
Section titled “Parameters”Database
Returns
Section titled “Returns”number
runMigrations()
Section titled “runMigrations()”runMigrations(
db):void
Defined in: chat/sqlite/migrations.ts:117
Apply pending migrations sequentially. Each runs in a transaction.
Safe to call multiple times — already-applied migrations are skipped. For existing databases without schema_version table, detects current tables and fast-forwards to the matching version.
Parameters
Section titled “Parameters”Database
Returns
Section titled “Returns”void