Registry / database / chat-adapter-sqlite

chat-adapter-sqlite

JSON →
library0.4.0jsnpmunverified

SQLite state adapter for Chat SDK built with better-sqlite3. Current stable version: 0.4.0. Release cadence: irregular, based on upstream Chat SDK updates. Key differentiators: lightweight local persistent state without Redis or Postgres, supports subscriptions, locking, caching, lists, and message queueing; automatic table creation and key prefix namespacing; opportunistic cleanup of expired entries. Requires Node >=20.10.0 and peer dependencies better-sqlite3 ^12.6.2 and chat ^4.23.0.

npm install chat-adapter-sqlite
INSTALL
IMPORT
SIG · CHAT-ADAPTER-SQLIT
C
chat-adapter-sqlite
databasejavascriptv0.4.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createSqliteState
import { createSqliteState } from 'chat-adapter-sqlite'
const createSqliteState = require('chat-adapter-sqlite').createSqliteState
Package is ESM-only. Named export used.
SqliteStateOptions
import type { SqliteStateOptions } from 'chat-adapter-sqlite'
import { SqliteStateOptions } from 'chat-adapter-sqlite'
TypeScript type export; must use type import for runtime safety.
Database (better-sqlite3)
import Database from 'better-sqlite3'
const Database = require('better-sqlite3')
better-sqlite3 is a CommonJS package; default import works with ESM.

Creates a Chat bot with an SQLite state adapter, specifying the database path.

import { Chat } from 'chat'; import { createSqliteState } from 'chat-adapter-sqlite'; const bot = new Chat({ userName: 'mybot', adapters: { // ... }, state: createSqliteState({ path: './data/chat-state.db' }) }); bot.start();
Debug
Known issues
breakingRequires Node >=20.10.0
fix
Upgrade Node.js to v20.10.0 or later.
affects: all
deprecatedAutomatic database path detection via SQLITE_PATH environment variable may change in future versions.
fix
Explicitly pass path option when creating state adapter.
affects: <1.0.0
gotchaExpired rows are not automatically deleted; cleanup only occurs on specific operations.
fix
Call methods like get(), acquireLock() regularly to trigger cleanup, or implement a periodic cleanup mechanism.
affects: all
gotchaSQLite locking is host-local; not suitable for distributed multi-machine locking.
fix
Use Redis-based adapter for distributed locking.
affects: all
gotchaMust provide either path, SQLITE_PATH environment variable, or a client instance; otherwise createSqliteState() throws.
fix
Set SQLITE_PATH or pass path/client in options.
affects: all
Errors
Common errors & fixes
Error: No path or client provided to createSqliteState()
Missing required database path or client instance.
fix
Pass `{ path: './data/chat.db' }` or set `SQLITE_PATH` environment variable, or provide an existing `better-sqlite3` client.
TypeError: chat_adapter_sqlite_1.createSqliteState is not a function
Using CommonJS require() incorrectly; package is ESM-only.
fix
Use `import { createSqliteState } from 'chat-adapter-sqlite'` instead of `require()`.
Error: Cannot find module 'better-sqlite3'
Peer dependency better-sqlite3 is not installed.
fix
Run `npm install better-sqlite3` or `pnpm add better-sqlite3`.
Upgrade
Version history
0.4.0latest on npm
Audit
Dependencies
better-sqlite3requiredPeer dependency for SQLite database operations
chatrequiredPeer dependency; Chat SDK must be installed
Agent activity
13 hits · last 30 days
node
10
OpenAI (training)
1
Resources
chat-adapter-sqlite — npm install chat-adapter-sqlite · libregistry