open-index/open-npm huggingface dataset:
npm package: @skroyc/bun-sqlite-checkpointer
Description: Bun native SQLite checkpointer for LangGraph
Latest version: 1.0.1

# Bun SQLite Checkpointer

[![npm version](https://img.shields.io/npm/v/@skroyc/bun-sqlite-checkpointer.svg)](https://www.npmjs.com/package/@skroyc/bun-sqlite-checkpointer)

Native SQLite checkpointer for LangGraph using Bun's built-in SQLite implementation.

## Installation

```bash
bun add @skroyc/bun-sqlite-checkpointer
```

Requires `bun >= 1.0.0`.

## Quick Start

```typescript
import { BunSqliteSaver } from "@skroyc/bun-sqlite-checkpointer";
import { createReactAgent } from "@langchain/langgraph/prelanggraph";

// Initialize the saver with an in-memory database
const saver = new BunSqliteSaver(":memory:");

// Or with a persistent database
const saver = new BunSqliteSaver("./checkpoints.db");

// Create your agent with the checkpointer
const agent = createReactAgent({
  llm: model,
  tools: [],
  checkpointSaver: saver,
});
```

## API

### `BunSqliteSaver`

```typescript
class BunSqliteSaver extends BaseCheckpointSaver<number> {
  constructor(db: Bun.SqliteDb, serde?: SerializerProtocol);
  static fromConnString(connString: string, serde?: SerializerProtocol): BunSqliteSaver;
}
```

### Constructor Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `db` | `Bun.SqliteDb` | Bun SQLite Database instance |
| `serde` | `SerializerProtocol` | Optional custom serializer |

### Connection String

Use `BunSqliteSaver.fromConnString()` for convenience:

```typescript
// In-memory database
const saver = BunSqliteSaver.fromConnString(":memory:");

// Persistent file
const saver = BunSqliteSaver.fromConnString("./checkpoints.db");

// Read-only in-memory
const saver = BunSqliteSaver.fromConnString(":readonly:");

// Temporary (not persisted)
const saver = BunSqliteSaver.fromConnString(":temp:");
```

### Sharing a Database Connection

```typescript
import { Database } from "bun:sqlite";

const db = new Database("./shared.db");
const saver = new BunSqliteSaver(db);
```

## Usage with LangGraph

```typescript
import { BunSqliteSaver } from "@skroyc/bun-sqlite-checkpointer";

const saver = new BunSqliteSaver(":memory:");

// All threads will be persisted automatically
const config = { configurable: { thread_id: "user-123" } };

for await (const event of agent.streamEvents(
  { messages: userInput },
  { ...config, version: "v2" }
)) {
  // Events are checkpointed automatically
}
```

## Database Schema

The checkpointer creates the following tables:

- `checkpoints` - Stores checkpoint data and metadata
- `writes` - Stores incremental writes

## Requirements

- Bun >= 1.0.0
- @langchain/langgraph-checkpoint >= 1.0.0

## License

Apache-2.0