@langgraph-js/pure-graph 3.1.2 → 3.2.0
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/dist/adapter/fetch/index.js +2 -2
- package/dist/adapter/nextjs/index.js +1 -1
- package/dist/{checkpoint-1sAx_j1E.js → checkpoint-C5AFBYE-.js} +77 -34
- package/dist/checkpoint-C5AFBYE-.js.map +1 -0
- package/dist/{createEndpoint-D1nfguxg.js → createEndpoint-C2KsYHDx.js} +2 -2
- package/dist/{createEndpoint-D1nfguxg.js.map → createEndpoint-C2KsYHDx.js.map} +1 -1
- package/dist/index.js +2 -2
- package/dist/{queue-Cu_nO_wt.js → queue-DySatFkr.js} +2 -2
- package/dist/{queue-Cu_nO_wt.js.map → queue-DySatFkr.js.map} +1 -1
- package/dist/remote/index.js +1 -1
- package/dist/shallow-checkpoint-BEhTdp7z.js +466 -0
- package/dist/shallow-checkpoint-BEhTdp7z.js.map +1 -0
- package/dist/{sqlite-adapter-BKOLSdoL.js → sqlite-adapter-oBA95xba.js} +19 -1
- package/dist/sqlite-adapter-oBA95xba.js.map +1 -0
- package/dist/storage/index.d.ts +4 -2
- package/dist/storage/kysely/sqlite-adapter.d.ts +7 -0
- package/dist/storage/sqlite/shallow-checkpoint.d.ts +59 -0
- package/dist/{stream-CsqWsCjt.js → stream-pZfO6Y-p.js} +14 -7
- package/dist/{stream-CsqWsCjt.js.map → stream-pZfO6Y-p.js.map} +1 -1
- package/package.json +1 -1
- package/dist/checkpoint-1sAx_j1E.js.map +0 -1
- package/dist/sqlite-adapter-BKOLSdoL.js.map +0 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Dialect, Kysely } from 'kysely';
|
|
2
|
+
import type { RunnableConfig } from '@langchain/core/runnables';
|
|
3
|
+
import { BaseCheckpointSaver, type Checkpoint, type CheckpointListOptions, type CheckpointTuple, type SerializerProtocol, type PendingWrite, type CheckpointMetadata } from '@langchain/langgraph-checkpoint';
|
|
4
|
+
interface ShallowCheckpointsTable {
|
|
5
|
+
thread_id: string;
|
|
6
|
+
checkpoint_ns: string;
|
|
7
|
+
checkpoint_id: string;
|
|
8
|
+
parent_checkpoint_id: string | null;
|
|
9
|
+
type: string | null;
|
|
10
|
+
checkpoint: Uint8Array;
|
|
11
|
+
metadata: Uint8Array;
|
|
12
|
+
checkpoint_ts: number;
|
|
13
|
+
}
|
|
14
|
+
interface WritesTable {
|
|
15
|
+
thread_id: string;
|
|
16
|
+
checkpoint_ns: string;
|
|
17
|
+
checkpoint_id: string;
|
|
18
|
+
task_id: string;
|
|
19
|
+
idx: number;
|
|
20
|
+
channel: string;
|
|
21
|
+
type: string | null;
|
|
22
|
+
value: Uint8Array | null;
|
|
23
|
+
}
|
|
24
|
+
interface ShallowCheckpointDatabase {
|
|
25
|
+
shallow_checkpoints: ShallowCheckpointsTable;
|
|
26
|
+
writes: WritesTable;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* SqliteShallowSaver - SQLite 浅层检查点存储器
|
|
30
|
+
*
|
|
31
|
+
* 特性:
|
|
32
|
+
* - 每个 thread_id + checkpoint_ns 组合只保留最新的 checkpoint
|
|
33
|
+
* - 新 checkpoint 写入时自动清理旧 checkpoint 的 writes
|
|
34
|
+
* - 使用 checkpoint_ts 时间戳排序
|
|
35
|
+
* - 大幅减少存储数据量
|
|
36
|
+
*/
|
|
37
|
+
export declare class SqliteShallowSaver extends BaseCheckpointSaver {
|
|
38
|
+
db: Kysely<ShallowCheckpointDatabase>;
|
|
39
|
+
protected isSetup: boolean;
|
|
40
|
+
constructor(dialect: Dialect, serde?: SerializerProtocol);
|
|
41
|
+
static fromConnStringAsync(connStringOrLocalPath: string): Promise<SqliteShallowSaver>;
|
|
42
|
+
protected setup(): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* 获取 checkpoint(便捷方法)
|
|
45
|
+
*/
|
|
46
|
+
get(config: RunnableConfig): Promise<Checkpoint | undefined>;
|
|
47
|
+
getTuple(config: RunnableConfig): Promise<CheckpointTuple | undefined>;
|
|
48
|
+
list(config: RunnableConfig, options?: CheckpointListOptions): AsyncGenerator<CheckpointTuple>;
|
|
49
|
+
/**
|
|
50
|
+
* Check metadata filter matches (with deep comparison support)
|
|
51
|
+
* Matches ShallowMemorySaver behavior
|
|
52
|
+
*/
|
|
53
|
+
private _checkMetadataFilterMatch;
|
|
54
|
+
put(config: RunnableConfig, checkpoint: Checkpoint, metadata: CheckpointMetadata, _newVersions?: Record<string, string | number>): Promise<RunnableConfig>;
|
|
55
|
+
putWrites(config: RunnableConfig, writes: PendingWrite[], taskId: string): Promise<void>;
|
|
56
|
+
deleteThread(threadId: string): Promise<void>;
|
|
57
|
+
protected migratePendingSends(checkpoint: Checkpoint, threadId: string, parentCheckpointId: string): Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
export {};
|
|
@@ -5,6 +5,7 @@ import { EventEmitter } from 'eventemitter3';
|
|
|
5
5
|
import { load } from '@langchain/core/load';
|
|
6
6
|
import { v7 } from 'uuid';
|
|
7
7
|
import { BaseCheckpointSaver, TASKS, maxChannelVersion, getCheckpointId, copyCheckpoint, uuid6, WRITES_IDX_MAP } from '@langchain/langgraph-checkpoint';
|
|
8
|
+
import 'kysely';
|
|
8
9
|
|
|
9
10
|
const getLangGraphCommand = (command) => {
|
|
10
11
|
let goto = command.goto != null && !Array.isArray(command.goto) ? [command.goto] : command.goto;
|
|
@@ -1599,7 +1600,7 @@ class MemoryThreadsManager {
|
|
|
1599
1600
|
}
|
|
1600
1601
|
|
|
1601
1602
|
const createCheckPointer = async () => {
|
|
1602
|
-
if (process.env.REDIS_URL && process.env.CHECKPOINT_TYPE === "redis" || process.env.CHECKPOINT_TYPE === "shallow/redis") {
|
|
1603
|
+
if (process.env.REDIS_URL && (process.env.CHECKPOINT_TYPE === "redis" || process.env.CHECKPOINT_TYPE === "shallow/redis")) {
|
|
1603
1604
|
if (process.env.CHECKPOINT_TYPE === "redis") {
|
|
1604
1605
|
console.debug("LG | Using redis as checkpoint");
|
|
1605
1606
|
const { RedisSaver } = await import('@langchain/langgraph-checkpoint-redis');
|
|
@@ -1621,9 +1622,15 @@ const createCheckPointer = async () => {
|
|
|
1621
1622
|
return createPGCheckpoint();
|
|
1622
1623
|
}
|
|
1623
1624
|
if (process.env.SQLITE_DATABASE_URI) {
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1625
|
+
if (process.env.CHECKPOINT_TYPE === "sqlite") {
|
|
1626
|
+
console.debug("LG | Using sqlite (full) as checkpoint");
|
|
1627
|
+
const { SqliteSaver } = await import('./checkpoint-C5AFBYE-.js');
|
|
1628
|
+
const db2 = await SqliteSaver.fromConnStringAsync(process.env.SQLITE_DATABASE_URI);
|
|
1629
|
+
return db2;
|
|
1630
|
+
}
|
|
1631
|
+
console.debug("LG | Using shallow sqlite as checkpoint (default)");
|
|
1632
|
+
const { SqliteShallowSaver: SqliteShallowSaver2 } = await import('./shallow-checkpoint-BEhTdp7z.js');
|
|
1633
|
+
const db = await SqliteShallowSaver2.fromConnStringAsync(process.env.SQLITE_DATABASE_URI);
|
|
1627
1634
|
return db;
|
|
1628
1635
|
}
|
|
1629
1636
|
console.log("LG | You are using memory as checkpoint!");
|
|
@@ -1641,7 +1648,7 @@ const createMessageQueue = async () => {
|
|
|
1641
1648
|
let q;
|
|
1642
1649
|
if (process.env.REDIS_URL) {
|
|
1643
1650
|
console.debug("LG | Using redis as stream queue");
|
|
1644
|
-
const { RedisStreamQueue } = await import('./queue-
|
|
1651
|
+
const { RedisStreamQueue } = await import('./queue-DySatFkr.js');
|
|
1645
1652
|
q = RedisStreamQueue;
|
|
1646
1653
|
} else {
|
|
1647
1654
|
q = MemoryStreamQueue;
|
|
@@ -1681,7 +1688,7 @@ const createThreadManager = async (config) => {
|
|
|
1681
1688
|
}
|
|
1682
1689
|
if (process.env.SQLITE_DATABASE_URI && config.checkpointer) {
|
|
1683
1690
|
console.debug("LG | Using SQLite ThreadsManager");
|
|
1684
|
-
const { SQLiteAdapter } = await import('./sqlite-adapter-
|
|
1691
|
+
const { SQLiteAdapter } = await import('./sqlite-adapter-oBA95xba.js');
|
|
1685
1692
|
const database = config.checkpointer.db;
|
|
1686
1693
|
const threadsManager = new KyselyThreadsManager(new SQLiteAdapter(database));
|
|
1687
1694
|
await threadsManager.setup();
|
|
@@ -1879,4 +1886,4 @@ async function* streamState(threads, run, payload, options) {
|
|
|
1879
1886
|
}
|
|
1880
1887
|
|
|
1881
1888
|
export { BaseStreamQueue as B, CancelEventMessage as C, GRAPHS as G, KyselyThreadsManager as K, LangGraphGlobal as L, streamState as a, getGraph as g, registerGraph as r, serialiseAsDict as s };
|
|
1882
|
-
//# sourceMappingURL=stream-
|
|
1889
|
+
//# sourceMappingURL=stream-pZfO6Y-p.js.map
|