@reinsjs/store-sqlite

中文文档
0.3.3发布于 2026/11/02MITTypeScriptES Module

reins — SQLite-backed EventLog / BlobStore / MemoryStore. One SQL layer, driver supplied by the runtime (node:sqlite, bun:sqlite)

原始使用文档
文档目录3 节
  1. Layout
  2. Verified
  3. Documentation

@reinsjs/store-sqlite

SQLite-backed EventLog, BlobStore and MemoryStore for reins. One SQL layer, driver supplied by the runtime: Node 22.13+ ships node:sqlite, Bun ships bun:sqlite. The main entry has no node:* import and only needs an object with exec(sql) and prepare(sql).

pnpm add @reinsjs/store-sqlite
// Node
import { sqliteStores } from "@reinsjs/store-sqlite"
import { openSqlite } from "@reinsjs/store-sqlite/node"

const store = sqliteStores(openSqlite("./agent.db"))   // WAL on by default; ":memory:" for tests

// Bun
import { Database } from "bun:sqlite"
const store = sqliteStores(new Database("./agent.db"))

sqliteStores(db, { memoryTable }) creates the tables if missing and returns { log, blobs, memory }, ready for createAgent({ store }).

Layout

tablekeyed bynotes
reins_eventssession_id, seqappend-only; seq must be contiguous per session (the store enforces it and throws seq_conflict)
reins_blobssession_id, idspilled tool results and other large payloads
reins_memory (configurable)paththe model's memory files; memoryTable lets each role or tenant have its own table

Table names are validated against ^[A-Za-z_][A-Za-z0-9_]{0,62}$ before any SQL is assembled — identifiers cannot be bound as parameters, so this whitelist is the injection guard. Only the memory table is renamable; events and blobs are isolated by session_id on purpose.

fork(from, atSeq, to) copies a session prefix verbatim (ids and seq preserved) into an empty session in one statement.

Verified

Passes the conformance suite in @reinsjs/core/testing. The published dist keeps the node:sqlite protocol prefix (tsup's default would strip it to a bare sqlite, which only fails at runtime — pnpm check:dist guards this).

Cloudflare Workers are not a target of this package; Durable Objects SQLite would be a separate store.

Documentation

docs/系统全景图_模块盘点/store.md and docs/archive/implementation-plans/2026-09-08-技术方案v1.0.md §5 — in Chinese, at the repository root.

MIT © 2026 NewRate Limited.

版本与发布记录

@reinsjs/store-sqlite 共发布 8 个版本,首次发布于 2026/09/14;过去 12 个月发布了 8 个版本。

版本发布日期距今
0.3.3latest2026/11/021 天前
0.3.22026/10/313 天前
0.3.12026/10/303 天前
0.3.02026/09/221 个月前
0.2.12026/09/151 个月前
0.2.02026/09/151 个月前

关于 @reinsjs/store-sqlite 的常见问题

@reinsjs/store-sqlite 是什么?

缰绳- sqlite支持的EventLog / BlobStore / MemoryStore。一个SQL层,驱动程序由运行时提供(node:sqlite, bun:sqlite)

如何安装 @reinsjs/store-sqlite?

在项目目录运行 npm install @reinsjs/store-sqlite,或使用 pnpm add / yarn add / bun add。

@reinsjs/store-sqlite 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@reinsjs/store-sqlite 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@reinsjs/store-sqlite 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.13。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@reinsjs/store-sqlite 可以商用吗?

@reinsjs/store-sqlite 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@reinsjs/store-sqlite 还在维护吗?

最新版本 0.3.3 发布于 2026/11/02(1 天前);至今共发布 8 个版本,其中过去 12 个月发布了 8 个;首次发布于 2026/09/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。