@langgraph-js/pure-graph 1.4.0 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +158 -2
- package/dist/__vite-browser-external-DGN5jhtd.js +4 -0
- package/dist/__vite-browser-external-DGN5jhtd.js.map +1 -0
- package/dist/checkpoint-BHKV54sL.js +386 -0
- package/dist/checkpoint-BHKV54sL.js.map +1 -0
- package/dist/checkpoint-DxiUsHMy.js +13 -0
- package/dist/checkpoint-DxiUsHMy.js.map +1 -0
- package/dist/global.js +3 -0
- package/dist/index-DcXE-SZb.js +1264 -0
- package/dist/index-DcXE-SZb.js.map +1 -0
- package/dist/index.js.map +1 -0
- package/dist/queue-C6iEVbd2.js +120 -0
- package/dist/queue-C6iEVbd2.js.map +1 -0
- package/dist/storage/index.js +13 -7
- package/dist/storage/memory/threads.d.ts +1 -0
- package/dist/storage/memory/threads.js +3 -0
- package/dist/storage/pg/checkpoint.js +1 -1
- package/dist/storage/pg/threads.d.ts +1 -1
- package/dist/storage/pg/threads.js +0 -1
- package/dist/storage/sqlite/DB.js +1 -1
- package/dist/storage/sqlite/threads.d.ts +1 -1
- package/dist/storage/sqlite/threads.js +1 -2
- package/dist/threads/index.d.ts +1 -0
- package/dist/threads-BUgBiCiK.js +302 -0
- package/dist/threads-BUgBiCiK.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -27,6 +27,25 @@ yarn add @langgraph-js/pure-graph
|
|
|
27
27
|
|
|
28
28
|
### Next.js Example
|
|
29
29
|
|
|
30
|
+
```text
|
|
31
|
+
my-nextjs-app/
|
|
32
|
+
├── app/
|
|
33
|
+
│ ├── api/
|
|
34
|
+
│ │ └── langgraph/
|
|
35
|
+
│ │ └── [...path]/
|
|
36
|
+
│ │ └── route.ts # LangGraph API endpoint
|
|
37
|
+
│ ├── layout.tsx # Root layout
|
|
38
|
+
│ └── page.tsx # Your page
|
|
39
|
+
├── agent/
|
|
40
|
+
│ └── graph-name/
|
|
41
|
+
│ ├── graph.ts # Main graph implementation
|
|
42
|
+
│ ├── state.ts # Graph state definitions
|
|
43
|
+
│ └── prompt.ts # Prompt templates
|
|
44
|
+
├── .env.local # Environment variables
|
|
45
|
+
├── package.json # Dependencies and scripts
|
|
46
|
+
└── tsconfig.json # TypeScript configuration
|
|
47
|
+
```
|
|
48
|
+
|
|
30
49
|
To integrate Pure Graph into a Next.js project, follow these steps:
|
|
31
50
|
|
|
32
51
|
1. **Create a Route Handler**
|
|
@@ -37,7 +56,7 @@ To integrate Pure Graph into a Next.js project, follow these steps:
|
|
|
37
56
|
// app/api/langgraph/[...path]/route.ts
|
|
38
57
|
import { GET, POST, DELETE } from '@langgraph-js/pure-graph/dist/adapter/nextjs/router.js';
|
|
39
58
|
import { registerGraph } from '@langgraph-js/pure-graph';
|
|
40
|
-
import { graph } from '
|
|
59
|
+
import { graph } from '../../../agent/graph-name/graph';
|
|
41
60
|
|
|
42
61
|
registerGraph('test', graph);
|
|
43
62
|
|
|
@@ -65,7 +84,7 @@ To integrate Pure Graph into a Hono.js project, follow these steps:
|
|
|
65
84
|
```js
|
|
66
85
|
// app.js
|
|
67
86
|
import { registerGraph } from '@langgraph-js/pure-graph';
|
|
68
|
-
import { graph } from './
|
|
87
|
+
import { graph } from './agent/graph-name/graph';
|
|
69
88
|
import { Hono } from 'hono';
|
|
70
89
|
import LangGraphApp from '@langgraph-js/pure-graph/dist/adapter/hono/index';
|
|
71
90
|
|
|
@@ -93,9 +112,146 @@ Here are the environment variables you need to configure:
|
|
|
93
112
|
|
|
94
113
|
- `SQLITE_DATABASE_URI`: Path to your SQLite database (e.g., `./.langgraph_api/chat.db`).
|
|
95
114
|
- `DATABASE_URL`: PostgreSQL connection string (required for PostgreSQL checkpoint storage).
|
|
115
|
+
- `DATABASE_INIT`: Set to `true` for initial PostgreSQL database setup (required only on first run with PostgreSQL).
|
|
96
116
|
- `CHECKPOINT_TYPE`: Type of checkpoint storage (optional, defaults to memory; options: `postgres`, `redis`, `shallow/redis`).
|
|
97
117
|
- `REDIS_URL`: URL for Redis (required if using Redis checkpoint or message queue).
|
|
98
118
|
|
|
119
|
+
## Persistence Configuration
|
|
120
|
+
|
|
121
|
+
Pure Graph supports multiple storage backends for persisting graph state, checkpoints, and thread data. Choose the appropriate storage type based on your requirements for scalability, persistence, and performance.
|
|
122
|
+
|
|
123
|
+
### Memory Storage (Default)
|
|
124
|
+
|
|
125
|
+
**Best for**: Development, testing, or stateless applications.
|
|
126
|
+
|
|
127
|
+
**Configuration**:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# No additional configuration required - this is the default
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Characteristics**:
|
|
134
|
+
|
|
135
|
+
- Fastest performance
|
|
136
|
+
- No persistence across restarts
|
|
137
|
+
- Data is lost when the application stops
|
|
138
|
+
- Suitable for development and testing
|
|
139
|
+
|
|
140
|
+
### SQLite Storage
|
|
141
|
+
|
|
142
|
+
**Best for**: Single-server applications, development, or small-scale production.
|
|
143
|
+
|
|
144
|
+
**Configuration**:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
SQLITE_DATABASE_URI=./.langgraph_api/chat.db
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**Setup**:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
# Create the database directory
|
|
154
|
+
mkdir -p .langgraph_api
|
|
155
|
+
|
|
156
|
+
# The database file will be created automatically on first run
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**Characteristics**:
|
|
160
|
+
|
|
161
|
+
- File-based database
|
|
162
|
+
- Good performance for moderate workloads
|
|
163
|
+
- ACID compliant
|
|
164
|
+
- Single-writer limitation
|
|
165
|
+
|
|
166
|
+
### PostgreSQL Storage
|
|
167
|
+
|
|
168
|
+
**Best for**: Production applications requiring high reliability and scalability.
|
|
169
|
+
|
|
170
|
+
**Configuration**:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
DATABASE_URL=postgresql://username:password@localhost:5432/langgraph_db
|
|
174
|
+
DATABASE_INIT=true # Only needed for initial setup
|
|
175
|
+
CHECKPOINT_TYPE=postgres
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
**Setup**:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# First run with DATABASE_INIT=true to create tables
|
|
182
|
+
export DATABASE_INIT=true
|
|
183
|
+
# Run your application once to initialize the database
|
|
184
|
+
|
|
185
|
+
# Remove DATABASE_INIT for subsequent runs
|
|
186
|
+
unset DATABASE_INIT
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
**Characteristics**:
|
|
190
|
+
|
|
191
|
+
- Full ACID compliance
|
|
192
|
+
- Concurrent access support
|
|
193
|
+
- Scalable for high-throughput applications
|
|
194
|
+
- Requires PostgreSQL server setup
|
|
195
|
+
|
|
196
|
+
### Redis Storage
|
|
197
|
+
|
|
198
|
+
Pure Graph supports two Redis checkpoint modes:
|
|
199
|
+
|
|
200
|
+
#### Full Redis Checkpoint
|
|
201
|
+
|
|
202
|
+
**Best for**: High-performance caching with full persistence.
|
|
203
|
+
|
|
204
|
+
**Configuration**:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
REDIS_URL=redis://localhost:6379
|
|
208
|
+
CHECKPOINT_TYPE=redis
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
#### Shallow Redis Checkpoint
|
|
212
|
+
|
|
213
|
+
**Best for**: Memory-efficient Redis usage with lighter persistence.
|
|
214
|
+
|
|
215
|
+
**Configuration**:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
REDIS_URL=redis://localhost:6379
|
|
219
|
+
CHECKPOINT_TYPE=shallow/redis
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
**Characteristics**:
|
|
223
|
+
|
|
224
|
+
- High performance
|
|
225
|
+
- TTL-based automatic cleanup
|
|
226
|
+
- Distributed caching capabilities
|
|
227
|
+
- Requires Redis server setup
|
|
228
|
+
|
|
229
|
+
### Redis Message Queue
|
|
230
|
+
|
|
231
|
+
When using Redis, message queues are automatically enabled for better performance:
|
|
232
|
+
|
|
233
|
+
**Configuration**:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
REDIS_URL=redis://localhost:6379
|
|
237
|
+
# Message queues will use Redis automatically when REDIS_URL is set
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
**Characteristics**:
|
|
241
|
+
|
|
242
|
+
- Automatic TTL management (300 seconds)
|
|
243
|
+
- Improved streaming performance
|
|
244
|
+
- Better resource utilization
|
|
245
|
+
|
|
246
|
+
### Configuration Priority
|
|
247
|
+
|
|
248
|
+
Storage backends are selected in this priority order:
|
|
249
|
+
|
|
250
|
+
1. **Redis** (if `REDIS_URL` set and `CHECKPOINT_TYPE` matches)
|
|
251
|
+
2. **PostgreSQL** (if `DATABASE_URL` set)
|
|
252
|
+
3. **SQLite** (if `SQLITE_DATABASE_URI` set)
|
|
253
|
+
4. **Memory** (fallback default)
|
|
254
|
+
|
|
99
255
|
## API Endpoints
|
|
100
256
|
|
|
101
257
|
### Assistants
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"__vite-browser-external-DGN5jhtd.js","sources":["../__vite-browser-external"],"sourcesContent":["export default {}"],"names":[],"mappings":"AAAA,8BAAe;;;;"}
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import { BaseCheckpointSaver, TASKS, copyCheckpoint, maxChannelVersion } from '@langchain/langgraph-checkpoint';
|
|
2
|
+
|
|
3
|
+
let Database;
|
|
4
|
+
if (globalThis.Bun) {
|
|
5
|
+
console.debug("LG | Using Bun Sqlite, pid:", process.pid);
|
|
6
|
+
const BunSqlite = await import('./__vite-browser-external-DGN5jhtd.js');
|
|
7
|
+
Database = BunSqlite.default;
|
|
8
|
+
} else {
|
|
9
|
+
const CommonSqlite = await import('better-sqlite3');
|
|
10
|
+
Database = CommonSqlite.default;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const checkpointMetadataKeys = ["source", "step", "parents"];
|
|
14
|
+
function validateKeys(keys) {
|
|
15
|
+
return keys;
|
|
16
|
+
}
|
|
17
|
+
const validCheckpointMetadataKeys = validateKeys(
|
|
18
|
+
checkpointMetadataKeys
|
|
19
|
+
);
|
|
20
|
+
function prepareSql(db, checkpointId) {
|
|
21
|
+
const sql = `
|
|
22
|
+
SELECT
|
|
23
|
+
thread_id,
|
|
24
|
+
checkpoint_ns,
|
|
25
|
+
checkpoint_id,
|
|
26
|
+
parent_checkpoint_id,
|
|
27
|
+
type,
|
|
28
|
+
checkpoint,
|
|
29
|
+
metadata,
|
|
30
|
+
(
|
|
31
|
+
SELECT
|
|
32
|
+
json_group_array(
|
|
33
|
+
json_object(
|
|
34
|
+
'task_id', pw.task_id,
|
|
35
|
+
'channel', pw.channel,
|
|
36
|
+
'type', pw.type,
|
|
37
|
+
'value', CAST(pw.value AS TEXT)
|
|
38
|
+
)
|
|
39
|
+
)
|
|
40
|
+
FROM writes as pw
|
|
41
|
+
WHERE pw.thread_id = checkpoints.thread_id
|
|
42
|
+
AND pw.checkpoint_ns = checkpoints.checkpoint_ns
|
|
43
|
+
AND pw.checkpoint_id = checkpoints.checkpoint_id
|
|
44
|
+
) as pending_writes,
|
|
45
|
+
(
|
|
46
|
+
SELECT
|
|
47
|
+
json_group_array(
|
|
48
|
+
json_object(
|
|
49
|
+
'type', ps.type,
|
|
50
|
+
'value', CAST(ps.value AS TEXT)
|
|
51
|
+
)
|
|
52
|
+
)
|
|
53
|
+
FROM writes as ps
|
|
54
|
+
WHERE ps.thread_id = checkpoints.thread_id
|
|
55
|
+
AND ps.checkpoint_ns = checkpoints.checkpoint_ns
|
|
56
|
+
AND ps.checkpoint_id = checkpoints.parent_checkpoint_id
|
|
57
|
+
AND ps.channel = '${TASKS}'
|
|
58
|
+
ORDER BY ps.idx
|
|
59
|
+
) as pending_sends
|
|
60
|
+
FROM checkpoints
|
|
61
|
+
WHERE thread_id = ? AND checkpoint_ns = ? ${checkpointId ? "AND checkpoint_id = ?" : "ORDER BY checkpoint_id DESC LIMIT 1"}`;
|
|
62
|
+
return db.prepare(sql);
|
|
63
|
+
}
|
|
64
|
+
class SqliteSaver extends BaseCheckpointSaver {
|
|
65
|
+
db;
|
|
66
|
+
isSetup;
|
|
67
|
+
withoutCheckpoint;
|
|
68
|
+
withCheckpoint;
|
|
69
|
+
constructor(db, serde) {
|
|
70
|
+
super(serde);
|
|
71
|
+
this.db = db;
|
|
72
|
+
this.isSetup = false;
|
|
73
|
+
}
|
|
74
|
+
static fromConnString(connStringOrLocalPath) {
|
|
75
|
+
return new SqliteSaver(new Database(connStringOrLocalPath));
|
|
76
|
+
}
|
|
77
|
+
setup() {
|
|
78
|
+
if (this.isSetup) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
this.db.exec("PRAGMA journal_mode = WAL;");
|
|
82
|
+
this.db.exec(`
|
|
83
|
+
CREATE TABLE IF NOT EXISTS checkpoints (
|
|
84
|
+
thread_id TEXT NOT NULL,
|
|
85
|
+
checkpoint_ns TEXT NOT NULL DEFAULT '',
|
|
86
|
+
checkpoint_id TEXT NOT NULL,
|
|
87
|
+
parent_checkpoint_id TEXT,
|
|
88
|
+
type TEXT,
|
|
89
|
+
checkpoint BLOB,
|
|
90
|
+
metadata BLOB,
|
|
91
|
+
PRIMARY KEY (thread_id, checkpoint_ns, checkpoint_id)
|
|
92
|
+
);`);
|
|
93
|
+
this.db.exec(`
|
|
94
|
+
CREATE TABLE IF NOT EXISTS writes (
|
|
95
|
+
thread_id TEXT NOT NULL,
|
|
96
|
+
checkpoint_ns TEXT NOT NULL DEFAULT '',
|
|
97
|
+
checkpoint_id TEXT NOT NULL,
|
|
98
|
+
task_id TEXT NOT NULL,
|
|
99
|
+
idx INTEGER NOT NULL,
|
|
100
|
+
channel TEXT NOT NULL,
|
|
101
|
+
type TEXT,
|
|
102
|
+
value BLOB,
|
|
103
|
+
PRIMARY KEY (thread_id, checkpoint_ns, checkpoint_id, task_id, idx)
|
|
104
|
+
);`);
|
|
105
|
+
this.withoutCheckpoint = prepareSql(this.db, false);
|
|
106
|
+
this.withCheckpoint = prepareSql(this.db, true);
|
|
107
|
+
this.isSetup = true;
|
|
108
|
+
}
|
|
109
|
+
async getTuple(config) {
|
|
110
|
+
this.setup();
|
|
111
|
+
const { thread_id, checkpoint_ns = "", checkpoint_id } = config.configurable ?? {};
|
|
112
|
+
const args = [thread_id, checkpoint_ns];
|
|
113
|
+
if (checkpoint_id) args.push(checkpoint_id);
|
|
114
|
+
const stm = checkpoint_id ? this.withCheckpoint : this.withoutCheckpoint;
|
|
115
|
+
const row = stm.get(...args);
|
|
116
|
+
if (row === void 0 || row === null) return void 0;
|
|
117
|
+
let finalConfig = config;
|
|
118
|
+
if (!checkpoint_id) {
|
|
119
|
+
finalConfig = {
|
|
120
|
+
configurable: {
|
|
121
|
+
thread_id: row.thread_id,
|
|
122
|
+
checkpoint_ns,
|
|
123
|
+
checkpoint_id: row.checkpoint_id
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
if (finalConfig.configurable?.thread_id === void 0 || finalConfig.configurable?.checkpoint_id === void 0) {
|
|
128
|
+
throw new Error("Missing thread_id or checkpoint_id");
|
|
129
|
+
}
|
|
130
|
+
const pendingWrites = await Promise.all(
|
|
131
|
+
JSON.parse(row.pending_writes).map(async (write) => {
|
|
132
|
+
return [
|
|
133
|
+
write.task_id,
|
|
134
|
+
write.channel,
|
|
135
|
+
await this.serde.loadsTyped(write.type ?? "json", write.value ?? "")
|
|
136
|
+
];
|
|
137
|
+
})
|
|
138
|
+
);
|
|
139
|
+
const checkpoint = await this.serde.loadsTyped(row.type ?? "json", row.checkpoint);
|
|
140
|
+
if (checkpoint.v < 4 && row.parent_checkpoint_id != null) {
|
|
141
|
+
await this.migratePendingSends(checkpoint, row.thread_id, row.parent_checkpoint_id);
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
checkpoint,
|
|
145
|
+
config: finalConfig,
|
|
146
|
+
metadata: await this.serde.loadsTyped(row.type ?? "json", row.metadata),
|
|
147
|
+
parentConfig: row.parent_checkpoint_id ? {
|
|
148
|
+
configurable: {
|
|
149
|
+
thread_id: row.thread_id,
|
|
150
|
+
checkpoint_ns,
|
|
151
|
+
checkpoint_id: row.parent_checkpoint_id
|
|
152
|
+
}
|
|
153
|
+
} : void 0,
|
|
154
|
+
pendingWrites
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
async *list(config, options) {
|
|
158
|
+
const { limit, before, filter } = options ?? {};
|
|
159
|
+
this.setup();
|
|
160
|
+
const thread_id = config.configurable?.thread_id;
|
|
161
|
+
const checkpoint_ns = config.configurable?.checkpoint_ns;
|
|
162
|
+
let sql = `
|
|
163
|
+
SELECT
|
|
164
|
+
thread_id,
|
|
165
|
+
checkpoint_ns,
|
|
166
|
+
checkpoint_id,
|
|
167
|
+
parent_checkpoint_id,
|
|
168
|
+
type,
|
|
169
|
+
checkpoint,
|
|
170
|
+
metadata,
|
|
171
|
+
(
|
|
172
|
+
SELECT
|
|
173
|
+
json_group_array(
|
|
174
|
+
json_object(
|
|
175
|
+
'task_id', pw.task_id,
|
|
176
|
+
'channel', pw.channel,
|
|
177
|
+
'type', pw.type,
|
|
178
|
+
'value', CAST(pw.value AS TEXT)
|
|
179
|
+
)
|
|
180
|
+
)
|
|
181
|
+
FROM writes as pw
|
|
182
|
+
WHERE pw.thread_id = checkpoints.thread_id
|
|
183
|
+
AND pw.checkpoint_ns = checkpoints.checkpoint_ns
|
|
184
|
+
AND pw.checkpoint_id = checkpoints.checkpoint_id
|
|
185
|
+
) as pending_writes,
|
|
186
|
+
(
|
|
187
|
+
SELECT
|
|
188
|
+
json_group_array(
|
|
189
|
+
json_object(
|
|
190
|
+
'type', ps.type,
|
|
191
|
+
'value', CAST(ps.value AS TEXT)
|
|
192
|
+
)
|
|
193
|
+
)
|
|
194
|
+
FROM writes as ps
|
|
195
|
+
WHERE ps.thread_id = checkpoints.thread_id
|
|
196
|
+
AND ps.checkpoint_ns = checkpoints.checkpoint_ns
|
|
197
|
+
AND ps.checkpoint_id = checkpoints.parent_checkpoint_id
|
|
198
|
+
AND ps.channel = '${TASKS}'
|
|
199
|
+
ORDER BY ps.idx
|
|
200
|
+
) as pending_sends
|
|
201
|
+
FROM checkpoints
|
|
202
|
+
`;
|
|
203
|
+
const whereClause = [];
|
|
204
|
+
if (thread_id) {
|
|
205
|
+
whereClause.push("thread_id = ?");
|
|
206
|
+
}
|
|
207
|
+
if (checkpoint_ns !== void 0 && checkpoint_ns !== null) {
|
|
208
|
+
whereClause.push("checkpoint_ns = ?");
|
|
209
|
+
}
|
|
210
|
+
if (before?.configurable?.checkpoint_id !== void 0) {
|
|
211
|
+
whereClause.push("checkpoint_id < ?");
|
|
212
|
+
}
|
|
213
|
+
const sanitizedFilter = Object.fromEntries(
|
|
214
|
+
Object.entries(filter ?? {}).filter(
|
|
215
|
+
([key, value]) => value !== void 0 && validCheckpointMetadataKeys.includes(key)
|
|
216
|
+
)
|
|
217
|
+
);
|
|
218
|
+
whereClause.push(
|
|
219
|
+
...Object.entries(sanitizedFilter).map(([key]) => `jsonb(CAST(metadata AS TEXT))->'$.${key}' = ?`)
|
|
220
|
+
);
|
|
221
|
+
if (whereClause.length > 0) {
|
|
222
|
+
sql += `WHERE
|
|
223
|
+
${whereClause.join(" AND\n ")}
|
|
224
|
+
`;
|
|
225
|
+
}
|
|
226
|
+
sql += "\nORDER BY checkpoint_id DESC";
|
|
227
|
+
if (limit) {
|
|
228
|
+
sql += ` LIMIT ${parseInt(limit, 10)}`;
|
|
229
|
+
}
|
|
230
|
+
const args = [
|
|
231
|
+
thread_id,
|
|
232
|
+
checkpoint_ns,
|
|
233
|
+
before?.configurable?.checkpoint_id,
|
|
234
|
+
...Object.values(sanitizedFilter).map((value) => JSON.stringify(value))
|
|
235
|
+
].filter((value) => value !== void 0 && value !== null);
|
|
236
|
+
const rows = this.db.prepare(sql).all(...args);
|
|
237
|
+
if (rows) {
|
|
238
|
+
for (const row of rows) {
|
|
239
|
+
const pendingWrites = await Promise.all(
|
|
240
|
+
JSON.parse(row.pending_writes).map(async (write) => {
|
|
241
|
+
return [
|
|
242
|
+
write.task_id,
|
|
243
|
+
write.channel,
|
|
244
|
+
await this.serde.loadsTyped(write.type ?? "json", write.value ?? "")
|
|
245
|
+
];
|
|
246
|
+
})
|
|
247
|
+
);
|
|
248
|
+
const checkpoint = await this.serde.loadsTyped(row.type ?? "json", row.checkpoint);
|
|
249
|
+
if (checkpoint.v < 4 && row.parent_checkpoint_id != null) {
|
|
250
|
+
await this.migratePendingSends(checkpoint, row.thread_id, row.parent_checkpoint_id);
|
|
251
|
+
}
|
|
252
|
+
yield {
|
|
253
|
+
config: {
|
|
254
|
+
configurable: {
|
|
255
|
+
thread_id: row.thread_id,
|
|
256
|
+
checkpoint_ns: row.checkpoint_ns,
|
|
257
|
+
checkpoint_id: row.checkpoint_id
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
checkpoint,
|
|
261
|
+
metadata: await this.serde.loadsTyped(row.type ?? "json", row.metadata),
|
|
262
|
+
parentConfig: row.parent_checkpoint_id ? {
|
|
263
|
+
configurable: {
|
|
264
|
+
thread_id: row.thread_id,
|
|
265
|
+
checkpoint_ns: row.checkpoint_ns,
|
|
266
|
+
checkpoint_id: row.parent_checkpoint_id
|
|
267
|
+
}
|
|
268
|
+
} : void 0,
|
|
269
|
+
pendingWrites
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
async put(config, checkpoint, metadata) {
|
|
275
|
+
this.setup();
|
|
276
|
+
if (!config.configurable) {
|
|
277
|
+
throw new Error("Empty configuration supplied.");
|
|
278
|
+
}
|
|
279
|
+
const thread_id = config.configurable?.thread_id;
|
|
280
|
+
const checkpoint_ns = config.configurable?.checkpoint_ns ?? "";
|
|
281
|
+
const parent_checkpoint_id = config.configurable?.checkpoint_id;
|
|
282
|
+
if (!thread_id) {
|
|
283
|
+
throw new Error(`Missing "thread_id" field in passed "config.configurable".`);
|
|
284
|
+
}
|
|
285
|
+
const preparedCheckpoint = copyCheckpoint(checkpoint);
|
|
286
|
+
const [[type1, serializedCheckpoint], [type2, serializedMetadata]] = await Promise.all([
|
|
287
|
+
this.serde.dumpsTyped(preparedCheckpoint),
|
|
288
|
+
this.serde.dumpsTyped(metadata)
|
|
289
|
+
]);
|
|
290
|
+
if (type1 !== type2) {
|
|
291
|
+
throw new Error("Failed to serialized checkpoint and metadata to the same type.");
|
|
292
|
+
}
|
|
293
|
+
const row = [
|
|
294
|
+
thread_id,
|
|
295
|
+
checkpoint_ns,
|
|
296
|
+
checkpoint.id,
|
|
297
|
+
parent_checkpoint_id,
|
|
298
|
+
type1,
|
|
299
|
+
serializedCheckpoint,
|
|
300
|
+
serializedMetadata
|
|
301
|
+
];
|
|
302
|
+
this.db.prepare(
|
|
303
|
+
`INSERT OR REPLACE INTO checkpoints (thread_id, checkpoint_ns, checkpoint_id, parent_checkpoint_id, type, checkpoint, metadata) VALUES (?, ?, ?, ?, ?, ?, ?)`
|
|
304
|
+
).run(...row);
|
|
305
|
+
return {
|
|
306
|
+
configurable: {
|
|
307
|
+
thread_id,
|
|
308
|
+
checkpoint_ns,
|
|
309
|
+
checkpoint_id: checkpoint.id
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
async putWrites(config, writes, taskId) {
|
|
314
|
+
this.setup();
|
|
315
|
+
if (!config.configurable) {
|
|
316
|
+
throw new Error("Empty configuration supplied.");
|
|
317
|
+
}
|
|
318
|
+
if (!config.configurable?.thread_id) {
|
|
319
|
+
throw new Error("Missing thread_id field in config.configurable.");
|
|
320
|
+
}
|
|
321
|
+
if (!config.configurable?.checkpoint_id) {
|
|
322
|
+
throw new Error("Missing checkpoint_id field in config.configurable.");
|
|
323
|
+
}
|
|
324
|
+
const stmt = this.db.prepare(`
|
|
325
|
+
INSERT OR REPLACE INTO writes
|
|
326
|
+
(thread_id, checkpoint_ns, checkpoint_id, task_id, idx, channel, type, value)
|
|
327
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
328
|
+
`);
|
|
329
|
+
const transaction = this.db.transaction((rows2) => {
|
|
330
|
+
for (const row of rows2) {
|
|
331
|
+
stmt.run(...row);
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
const rows = await Promise.all(
|
|
335
|
+
writes.map(async (write, idx) => {
|
|
336
|
+
const [type, serializedWrite] = await this.serde.dumpsTyped(write[1]);
|
|
337
|
+
return [
|
|
338
|
+
config.configurable?.thread_id,
|
|
339
|
+
config.configurable?.checkpoint_ns,
|
|
340
|
+
config.configurable?.checkpoint_id,
|
|
341
|
+
taskId,
|
|
342
|
+
idx,
|
|
343
|
+
write[0],
|
|
344
|
+
type,
|
|
345
|
+
serializedWrite
|
|
346
|
+
];
|
|
347
|
+
})
|
|
348
|
+
);
|
|
349
|
+
transaction(rows);
|
|
350
|
+
}
|
|
351
|
+
async deleteThread(threadId) {
|
|
352
|
+
const transaction = this.db.transaction(() => {
|
|
353
|
+
this.db.prepare(`DELETE FROM checkpoints WHERE thread_id = ?`).run(threadId);
|
|
354
|
+
this.db.prepare(`DELETE FROM writes WHERE thread_id = ?`).run(threadId);
|
|
355
|
+
});
|
|
356
|
+
transaction();
|
|
357
|
+
}
|
|
358
|
+
async migratePendingSends(checkpoint, threadId, parentCheckpointId) {
|
|
359
|
+
const { pending_sends } = this.db.prepare(
|
|
360
|
+
`
|
|
361
|
+
SELECT
|
|
362
|
+
checkpoint_id,
|
|
363
|
+
json_group_array(
|
|
364
|
+
json_object(
|
|
365
|
+
'type', ps.type,
|
|
366
|
+
'value', CAST(ps.value AS TEXT)
|
|
367
|
+
)
|
|
368
|
+
) as pending_sends
|
|
369
|
+
FROM writes as ps
|
|
370
|
+
WHERE ps.thread_id = ?
|
|
371
|
+
AND ps.checkpoint_id = ?
|
|
372
|
+
AND ps.channel = '${TASKS}'
|
|
373
|
+
ORDER BY ps.idx
|
|
374
|
+
`
|
|
375
|
+
).get(threadId, parentCheckpointId);
|
|
376
|
+
const mutableCheckpoint = checkpoint;
|
|
377
|
+
mutableCheckpoint.channel_values ??= {};
|
|
378
|
+
mutableCheckpoint.channel_values[TASKS] = await Promise.all(
|
|
379
|
+
JSON.parse(pending_sends).map(({ type, value }) => this.serde.loadsTyped(type, value))
|
|
380
|
+
);
|
|
381
|
+
mutableCheckpoint.channel_versions[TASKS] = Object.keys(checkpoint.channel_versions).length > 0 ? maxChannelVersion(...Object.values(checkpoint.channel_versions)) : this.getNextVersion(void 0);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
export { SqliteSaver };
|
|
386
|
+
//# sourceMappingURL=checkpoint-BHKV54sL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkpoint-BHKV54sL.js","sources":["../src/storage/sqlite/DB.ts","../src/storage/sqlite/checkpoint.ts"],"sourcesContent":["import { DatabaseType } from './type';\n\nlet Database: new (uri: string) => DatabaseType;\n/** @ts-ignore */\nif (globalThis.Bun) {\n console.debug('LG | Using Bun Sqlite, pid:', process.pid);\n const BunSqlite = await import('bun:sqlite');\n /** @ts-ignore */\n Database = BunSqlite.default;\n} else {\n /** @ts-ignore */\n const CommonSqlite = await import('better-sqlite3');\n Database = CommonSqlite.default;\n}\n\nexport { Database };\n","import { DatabaseType } from './type.js';\nimport { Database } from './DB.js';\nimport type { RunnableConfig } from '@langchain/core/runnables';\nimport {\n BaseCheckpointSaver,\n type Checkpoint,\n type CheckpointListOptions,\n type CheckpointTuple,\n type SerializerProtocol,\n type PendingWrite,\n type CheckpointMetadata,\n TASKS,\n copyCheckpoint,\n maxChannelVersion,\n} from '@langchain/langgraph-checkpoint';\n\ninterface CheckpointRow {\n checkpoint: string;\n metadata: string;\n parent_checkpoint_id?: string;\n thread_id: string;\n checkpoint_id: string;\n checkpoint_ns?: string;\n type?: string;\n pending_writes: string;\n}\n\ninterface PendingWriteColumn {\n task_id: string;\n channel: string;\n type: string;\n value: string;\n}\n\ninterface PendingSendColumn {\n type: string;\n value: string;\n}\n\n// In the `SqliteSaver.list` method, we need to sanitize the `options.filter` argument to ensure it only contains keys\n// that are part of the `CheckpointMetadata` type. The lines below ensure that we get compile-time errors if the list\n// of keys that we use is out of sync with the `CheckpointMetadata` type.\nconst checkpointMetadataKeys = ['source', 'step', 'parents'] as const;\n\ntype CheckKeys<T, K extends readonly (keyof T)[]> = [K[number]] extends [keyof T]\n ? [keyof T] extends [K[number]]\n ? K\n : never\n : never;\n\nfunction validateKeys<T, K extends readonly (keyof T)[]>(keys: CheckKeys<T, K>): K {\n return keys;\n}\n\n// If this line fails to compile, the list of keys that we use in the `SqliteSaver.list` method is out of sync with the\n// `CheckpointMetadata` type. In that case, just update `checkpointMetadataKeys` to contain all the keys in\n// `CheckpointMetadata`\nconst validCheckpointMetadataKeys = validateKeys<CheckpointMetadata, typeof checkpointMetadataKeys>(\n checkpointMetadataKeys,\n);\n\nfunction prepareSql(db: DatabaseType, checkpointId: boolean) {\n const sql = `\n SELECT\n thread_id,\n checkpoint_ns,\n checkpoint_id,\n parent_checkpoint_id,\n type,\n checkpoint,\n metadata,\n (\n SELECT\n json_group_array(\n json_object(\n 'task_id', pw.task_id,\n 'channel', pw.channel,\n 'type', pw.type,\n 'value', CAST(pw.value AS TEXT)\n )\n )\n FROM writes as pw\n WHERE pw.thread_id = checkpoints.thread_id\n AND pw.checkpoint_ns = checkpoints.checkpoint_ns\n AND pw.checkpoint_id = checkpoints.checkpoint_id\n ) as pending_writes,\n (\n SELECT\n json_group_array(\n json_object(\n 'type', ps.type,\n 'value', CAST(ps.value AS TEXT)\n )\n )\n FROM writes as ps\n WHERE ps.thread_id = checkpoints.thread_id\n AND ps.checkpoint_ns = checkpoints.checkpoint_ns\n AND ps.checkpoint_id = checkpoints.parent_checkpoint_id\n AND ps.channel = '${TASKS}'\n ORDER BY ps.idx\n ) as pending_sends\n FROM checkpoints\n WHERE thread_id = ? AND checkpoint_ns = ? ${\n checkpointId ? 'AND checkpoint_id = ?' : 'ORDER BY checkpoint_id DESC LIMIT 1'\n }`;\n\n return db.prepare(sql);\n}\n\nexport class SqliteSaver extends BaseCheckpointSaver {\n db: DatabaseType;\n\n protected isSetup: boolean;\n\n protected withoutCheckpoint: any;\n\n protected withCheckpoint: any;\n\n constructor(db: DatabaseType, serde?: SerializerProtocol) {\n super(serde);\n this.db = db;\n this.isSetup = false;\n }\n\n static fromConnString(connStringOrLocalPath: string): SqliteSaver {\n return new SqliteSaver(new Database(connStringOrLocalPath));\n }\n\n protected setup(): void {\n if (this.isSetup) {\n return;\n }\n\n // this.db.pragma('journal_mode=WAL');\n this.db.exec('PRAGMA journal_mode = WAL;');\n this.db.exec(`\nCREATE TABLE IF NOT EXISTS checkpoints (\n thread_id TEXT NOT NULL,\n checkpoint_ns TEXT NOT NULL DEFAULT '',\n checkpoint_id TEXT NOT NULL,\n parent_checkpoint_id TEXT,\n type TEXT,\n checkpoint BLOB,\n metadata BLOB,\n PRIMARY KEY (thread_id, checkpoint_ns, checkpoint_id)\n);`);\n this.db.exec(`\nCREATE TABLE IF NOT EXISTS writes (\n thread_id TEXT NOT NULL,\n checkpoint_ns TEXT NOT NULL DEFAULT '',\n checkpoint_id TEXT NOT NULL,\n task_id TEXT NOT NULL,\n idx INTEGER NOT NULL,\n channel TEXT NOT NULL,\n type TEXT,\n value BLOB,\n PRIMARY KEY (thread_id, checkpoint_ns, checkpoint_id, task_id, idx)\n);`);\n\n this.withoutCheckpoint = prepareSql(this.db, false);\n this.withCheckpoint = prepareSql(this.db, true);\n\n this.isSetup = true;\n }\n\n async getTuple(config: RunnableConfig): Promise<CheckpointTuple | undefined> {\n this.setup();\n const { thread_id, checkpoint_ns = '', checkpoint_id } = config.configurable ?? {};\n\n const args = [thread_id, checkpoint_ns];\n if (checkpoint_id) args.push(checkpoint_id);\n\n const stm = checkpoint_id ? this.withCheckpoint : this.withoutCheckpoint;\n const row = stm.get(...args) as CheckpointRow;\n if (row === undefined || row === null) return undefined;\n\n let finalConfig = config;\n\n if (!checkpoint_id) {\n finalConfig = {\n configurable: {\n thread_id: row.thread_id,\n checkpoint_ns,\n checkpoint_id: row.checkpoint_id,\n },\n };\n }\n\n if (\n finalConfig.configurable?.thread_id === undefined ||\n finalConfig.configurable?.checkpoint_id === undefined\n ) {\n throw new Error('Missing thread_id or checkpoint_id');\n }\n\n const pendingWrites = await Promise.all(\n (JSON.parse(row.pending_writes) as PendingWriteColumn[]).map(async (write) => {\n return [\n write.task_id,\n write.channel,\n await this.serde.loadsTyped(write.type ?? 'json', write.value ?? ''),\n ] as [string, string, unknown];\n }),\n );\n\n const checkpoint = (await this.serde.loadsTyped(row.type ?? 'json', row.checkpoint)) as Checkpoint;\n\n if (checkpoint.v < 4 && row.parent_checkpoint_id != null) {\n await this.migratePendingSends(checkpoint, row.thread_id, row.parent_checkpoint_id);\n }\n\n return {\n checkpoint,\n config: finalConfig,\n metadata: (await this.serde.loadsTyped(row.type ?? 'json', row.metadata)) as CheckpointMetadata,\n parentConfig: row.parent_checkpoint_id\n ? {\n configurable: {\n thread_id: row.thread_id,\n checkpoint_ns,\n checkpoint_id: row.parent_checkpoint_id,\n },\n }\n : undefined,\n pendingWrites,\n };\n }\n\n async *list(config: RunnableConfig, options?: CheckpointListOptions): AsyncGenerator<CheckpointTuple> {\n const { limit, before, filter } = options ?? {};\n this.setup();\n const thread_id = config.configurable?.thread_id;\n const checkpoint_ns = config.configurable?.checkpoint_ns;\n let sql = `\n SELECT\n thread_id,\n checkpoint_ns,\n checkpoint_id,\n parent_checkpoint_id,\n type,\n checkpoint,\n metadata,\n (\n SELECT\n json_group_array(\n json_object(\n 'task_id', pw.task_id,\n 'channel', pw.channel,\n 'type', pw.type,\n 'value', CAST(pw.value AS TEXT)\n )\n )\n FROM writes as pw\n WHERE pw.thread_id = checkpoints.thread_id\n AND pw.checkpoint_ns = checkpoints.checkpoint_ns\n AND pw.checkpoint_id = checkpoints.checkpoint_id\n ) as pending_writes,\n (\n SELECT\n json_group_array(\n json_object(\n 'type', ps.type,\n 'value', CAST(ps.value AS TEXT)\n )\n )\n FROM writes as ps\n WHERE ps.thread_id = checkpoints.thread_id\n AND ps.checkpoint_ns = checkpoints.checkpoint_ns\n AND ps.checkpoint_id = checkpoints.parent_checkpoint_id\n AND ps.channel = '${TASKS}'\n ORDER BY ps.idx\n ) as pending_sends\n FROM checkpoints\\n`;\n\n const whereClause: string[] = [];\n\n if (thread_id) {\n whereClause.push('thread_id = ?');\n }\n\n if (checkpoint_ns !== undefined && checkpoint_ns !== null) {\n whereClause.push('checkpoint_ns = ?');\n }\n\n if (before?.configurable?.checkpoint_id !== undefined) {\n whereClause.push('checkpoint_id < ?');\n }\n\n const sanitizedFilter = Object.fromEntries(\n Object.entries(filter ?? {}).filter(\n ([key, value]) =>\n value !== undefined && validCheckpointMetadataKeys.includes(key as keyof CheckpointMetadata),\n ),\n );\n\n whereClause.push(\n ...Object.entries(sanitizedFilter).map(([key]) => `jsonb(CAST(metadata AS TEXT))->'$.${key}' = ?`),\n );\n if (whereClause.length > 0) {\n sql += `WHERE\\n ${whereClause.join(' AND\\n ')}\\n`;\n }\n\n sql += '\\nORDER BY checkpoint_id DESC';\n\n if (limit) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n sql += ` LIMIT ${parseInt(limit as any, 10)}`; // parseInt here (with cast to make TS happy) to sanitize input, as limit may be user-provided\n }\n\n const args = [\n thread_id,\n checkpoint_ns,\n before?.configurable?.checkpoint_id,\n ...Object.values(sanitizedFilter).map((value) => JSON.stringify(value)),\n ].filter((value) => value !== undefined && value !== null);\n\n const rows: CheckpointRow[] = this.db.prepare(sql).all(...args) as CheckpointRow[];\n\n if (rows) {\n for (const row of rows) {\n const pendingWrites = await Promise.all(\n (JSON.parse(row.pending_writes) as PendingWriteColumn[]).map(async (write) => {\n return [\n write.task_id,\n write.channel,\n await this.serde.loadsTyped(write.type ?? 'json', write.value ?? ''),\n ] as [string, string, unknown];\n }),\n );\n\n const checkpoint = (await this.serde.loadsTyped(row.type ?? 'json', row.checkpoint)) as Checkpoint;\n\n if (checkpoint.v < 4 && row.parent_checkpoint_id != null) {\n await this.migratePendingSends(checkpoint, row.thread_id, row.parent_checkpoint_id);\n }\n\n yield {\n config: {\n configurable: {\n thread_id: row.thread_id,\n checkpoint_ns: row.checkpoint_ns,\n checkpoint_id: row.checkpoint_id,\n },\n },\n checkpoint,\n metadata: (await this.serde.loadsTyped(row.type ?? 'json', row.metadata)) as CheckpointMetadata,\n parentConfig: row.parent_checkpoint_id\n ? {\n configurable: {\n thread_id: row.thread_id,\n checkpoint_ns: row.checkpoint_ns,\n checkpoint_id: row.parent_checkpoint_id,\n },\n }\n : undefined,\n pendingWrites,\n };\n }\n }\n }\n\n async put(config: RunnableConfig, checkpoint: Checkpoint, metadata: CheckpointMetadata): Promise<RunnableConfig> {\n this.setup();\n\n if (!config.configurable) {\n throw new Error('Empty configuration supplied.');\n }\n\n const thread_id = config.configurable?.thread_id;\n const checkpoint_ns = config.configurable?.checkpoint_ns ?? '';\n const parent_checkpoint_id = config.configurable?.checkpoint_id;\n\n if (!thread_id) {\n throw new Error(`Missing \"thread_id\" field in passed \"config.configurable\".`);\n }\n\n const preparedCheckpoint: Partial<Checkpoint> = copyCheckpoint(checkpoint);\n\n const [[type1, serializedCheckpoint], [type2, serializedMetadata]] = await Promise.all([\n this.serde.dumpsTyped(preparedCheckpoint),\n this.serde.dumpsTyped(metadata),\n ]);\n\n if (type1 !== type2) {\n throw new Error('Failed to serialized checkpoint and metadata to the same type.');\n }\n const row = [\n thread_id,\n checkpoint_ns,\n checkpoint.id,\n parent_checkpoint_id,\n type1,\n serializedCheckpoint,\n serializedMetadata,\n ];\n\n this.db\n .prepare(\n `INSERT OR REPLACE INTO checkpoints (thread_id, checkpoint_ns, checkpoint_id, parent_checkpoint_id, type, checkpoint, metadata) VALUES (?, ?, ?, ?, ?, ?, ?)`,\n )\n .run(...row);\n\n return {\n configurable: {\n thread_id,\n checkpoint_ns,\n checkpoint_id: checkpoint.id,\n },\n };\n }\n\n async putWrites(config: RunnableConfig, writes: PendingWrite[], taskId: string): Promise<void> {\n this.setup();\n\n if (!config.configurable) {\n throw new Error('Empty configuration supplied.');\n }\n\n if (!config.configurable?.thread_id) {\n throw new Error('Missing thread_id field in config.configurable.');\n }\n\n if (!config.configurable?.checkpoint_id) {\n throw new Error('Missing checkpoint_id field in config.configurable.');\n }\n\n const stmt = this.db.prepare(`\n INSERT OR REPLACE INTO writes \n (thread_id, checkpoint_ns, checkpoint_id, task_id, idx, channel, type, value) \n VALUES (?, ?, ?, ?, ?, ?, ?, ?)\n `);\n\n const transaction = this.db.transaction((rows) => {\n for (const row of rows) {\n stmt.run(...row);\n }\n });\n\n const rows = await Promise.all(\n writes.map(async (write, idx) => {\n const [type, serializedWrite] = await this.serde.dumpsTyped(write[1]);\n return [\n config.configurable?.thread_id,\n config.configurable?.checkpoint_ns,\n config.configurable?.checkpoint_id,\n taskId,\n idx,\n write[0],\n type,\n serializedWrite,\n ];\n }),\n );\n\n transaction(rows);\n }\n\n async deleteThread(threadId: string) {\n const transaction = this.db.transaction(() => {\n this.db.prepare(`DELETE FROM checkpoints WHERE thread_id = ?`).run(threadId);\n this.db.prepare(`DELETE FROM writes WHERE thread_id = ?`).run(threadId);\n });\n\n transaction();\n }\n\n protected async migratePendingSends(checkpoint: Checkpoint, threadId: string, parentCheckpointId: string) {\n const { pending_sends } = this.db\n .prepare(\n `\n SELECT\n checkpoint_id,\n json_group_array(\n json_object(\n 'type', ps.type,\n 'value', CAST(ps.value AS TEXT)\n )\n ) as pending_sends\n FROM writes as ps\n WHERE ps.thread_id = ?\n AND ps.checkpoint_id = ?\n AND ps.channel = '${TASKS}'\n ORDER BY ps.idx\n `,\n )\n .get(threadId, parentCheckpointId) as { pending_sends: string };\n\n const mutableCheckpoint = checkpoint;\n\n // add pending sends to checkpoint\n mutableCheckpoint.channel_values ??= {};\n mutableCheckpoint.channel_values[TASKS] = await Promise.all(\n JSON.parse(pending_sends).map(({ type, value }: PendingSendColumn) => this.serde.loadsTyped(type, value)),\n );\n\n // add to versions\n mutableCheckpoint.channel_versions[TASKS] =\n Object.keys(checkpoint.channel_versions).length > 0\n ? maxChannelVersion(...Object.values(checkpoint.channel_versions))\n : this.getNextVersion(undefined);\n }\n}\n"],"names":["rows"],"mappings":";;AAEA,IAAI,QAAA;AAEJ,IAAI,WAAW,GAAA,EAAK;AAChB,EAAA,OAAA,CAAQ,KAAA,CAAM,6BAAA,EAA+B,OAAA,CAAQ,GAAG,CAAA;AACxD,EAAA,MAAM,SAAA,GAAY,MAAM,OAAO,uCAAY,CAAA;AAE3C,EAAA,QAAA,GAAW,SAAA,CAAU,OAAA;AACzB,CAAA,MAAO;AAEH,EAAA,MAAM,YAAA,GAAe,MAAM,OAAO,gBAAgB,CAAA;AAClD,EAAA,QAAA,GAAW,YAAA,CAAa,OAAA;AAC5B;;AC6BA,MAAM,sBAAA,GAAyB,CAAC,QAAA,EAAU,MAAA,EAAQ,SAAS,CAAA;AAQ3D,SAAS,aAAgD,IAAA,EAA0B;AAC/E,EAAA,OAAO,IAAA;AACX;AAKA,MAAM,2BAAA,GAA8B,YAAA;AAAA,EAChC;AACJ,CAAA;AAEA,SAAS,UAAA,CAAW,IAAkB,YAAA,EAAuB;AACzD,EAAA,MAAM,GAAA,GAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAA,EAoCY,KAAK,CAAA;AAAA;AAAA;AAAA;AAAA,4CAAA,EAK3B,YAA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A,8BAAA,EAYgB,KAAK,CAAA;AAAA;AAAA,QAAA;AAAA,KAGzB,CACC,GAAA,CAAI,QAAA,EAAU,kBAAkB,CAAA;AAErC,IAAA,MAAM,iBAAA,GAAoB,UAAA;AAG1B,IAAA,iBAAA,CAAkB,mBAAmB,EAAC;AACtC,IAAA,iBAAA,CAAkB,cAAA,CAAe,KAAK,CAAA,GAAI,MAAM,OAAA,CAAQ,GAAA;AAAA,MACpD,IAAA,CAAK,KAAA,CAAM,aAAa,CAAA,CAAE,IAAI,CAAC,EAAE,IAAA,EAAM,KAAA,OAA+B,IAAA,CAAK,KAAA,CAAM,UAAA,CAAW,IAAA,EAAM,KAAK,CAAC;AAAA,KAC5G;AAGA,IAAA,iBAAA,CAAkB,gBAAA,CAAiB,KAAK,CAAA,GACpC,MAAA,CAAO,KAAK,UAAA,CAAW,gBAAgB,EAAE,MAAA,GAAS,CAAA,GAC5C,kBAAkB,GAAG,MAAA,CAAO,OAAO,UAAA,CAAW,gBAAgB,CAAC,CAAA,GAC/D,IAAA,CAAK,eAAe,MAAS,CAAA;AAAA,EAC3C;AACJ;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PostgresSaver } from '@langchain/langgraph-checkpoint-postgres';
|
|
2
|
+
|
|
3
|
+
const createPGCheckpoint = async () => {
|
|
4
|
+
const checkpointer = PostgresSaver.fromConnString(process.env.DATABASE_URL);
|
|
5
|
+
if (process.env.DATABASE_INIT === "true") {
|
|
6
|
+
console.debug("LG | Initializing postgres checkpoint");
|
|
7
|
+
await checkpointer.setup();
|
|
8
|
+
}
|
|
9
|
+
return checkpointer;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { createPGCheckpoint };
|
|
13
|
+
//# sourceMappingURL=checkpoint-DxiUsHMy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkpoint-DxiUsHMy.js","sources":["../src/storage/pg/checkpoint.ts"],"sourcesContent":["import { PostgresSaver } from '@langchain/langgraph-checkpoint-postgres';\n\nexport const createPGCheckpoint = async () => {\n const checkpointer = PostgresSaver.fromConnString(process.env.DATABASE_URL!);\n if (process.env.DATABASE_INIT === 'true') {\n console.debug('LG | Initializing postgres checkpoint');\n await checkpointer.setup();\n }\n\n return checkpointer;\n};\n"],"names":[],"mappings":";;AAEO,MAAM,qBAAqB,YAAY;AAC1C,EAAA,MAAM,YAAA,GAAe,aAAA,CAAc,cAAA,CAAe,OAAA,CAAQ,IAAI,YAAa,CAAA;AAC3E,EAAA,IAAI,OAAA,CAAQ,GAAA,CAAI,aAAA,KAAkB,MAAA,EAAQ;AACtC,IAAA,OAAA,CAAQ,MAAM,uCAAuC,CAAA;AACrD,IAAA,MAAM,aAAa,KAAA,EAAM;AAAA,EAC7B;AAEA,EAAA,OAAO,YAAA;AACX;;;;"}
|
package/dist/global.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { createCheckPointer, createMessageQueue, createThreadManager } from './storage/index.js';
|
|
2
2
|
const [globalMessageQueue, globalCheckPointer] = await Promise.all([createMessageQueue(), createCheckPointer()]);
|
|
3
|
+
console.debug('LG | checkpointer created');
|
|
3
4
|
const globalThreadsManager = await createThreadManager({
|
|
4
5
|
checkpointer: globalCheckPointer,
|
|
5
6
|
});
|
|
7
|
+
console.debug('LG | threads manager created');
|
|
8
|
+
console.debug('LG | global init done');
|
|
6
9
|
export class LangGraphGlobal {
|
|
7
10
|
static globalMessageQueue = globalMessageQueue;
|
|
8
11
|
static globalCheckPointer = globalCheckPointer;
|