@langchain/langgraph-checkpoint 0.0.10 → 0.0.12
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/base.d.ts +1 -1
- package/dist/memory.cjs +7 -6
- package/dist/memory.js +7 -6
- package/package.json +1 -1
package/dist/base.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ type ChannelVersion = number | string;
|
|
|
6
6
|
export type ChannelVersions = Record<string, ChannelVersion>;
|
|
7
7
|
export interface Checkpoint<N extends string = string, C extends string = string> {
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* The version of the checkpoint format. Currently 1
|
|
10
10
|
*/
|
|
11
11
|
v: number;
|
|
12
12
|
/**
|
package/dist/memory.cjs
CHANGED
|
@@ -125,13 +125,13 @@ class MemorySaver extends base_js_1.BaseCheckpointSaver {
|
|
|
125
125
|
}
|
|
126
126
|
async *list(config, options) {
|
|
127
127
|
// eslint-disable-next-line prefer-const
|
|
128
|
-
let { before, limit } = options ?? {};
|
|
128
|
+
let { before, limit, filter } = options ?? {};
|
|
129
129
|
const threadIds = config.configurable?.thread_id
|
|
130
130
|
? [config.configurable?.thread_id]
|
|
131
131
|
: Object.keys(this.storage);
|
|
132
132
|
const configCheckpointNamespace = config.configurable?.checkpoint_ns;
|
|
133
133
|
for (const threadId of threadIds) {
|
|
134
|
-
for (const checkpointNamespace of Object.keys(this.storage[threadId])) {
|
|
134
|
+
for (const checkpointNamespace of Object.keys(this.storage[threadId] ?? {})) {
|
|
135
135
|
if (configCheckpointNamespace !== undefined &&
|
|
136
136
|
checkpointNamespace !== configCheckpointNamespace) {
|
|
137
137
|
continue;
|
|
@@ -147,6 +147,10 @@ class MemorySaver extends base_js_1.BaseCheckpointSaver {
|
|
|
147
147
|
}
|
|
148
148
|
// Parse metadata
|
|
149
149
|
const metadata = (await this.serde.loadsTyped("json", metadataStr));
|
|
150
|
+
if (filter &&
|
|
151
|
+
!Object.entries(filter).every(([key, value]) => metadata[key] === value)) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
150
154
|
// Limit search results
|
|
151
155
|
if (limit !== undefined) {
|
|
152
156
|
if (limit <= 0)
|
|
@@ -197,13 +201,10 @@ class MemorySaver extends base_js_1.BaseCheckpointSaver {
|
|
|
197
201
|
const preparedCheckpoint = (0, base_js_1.copyCheckpoint)(checkpoint);
|
|
198
202
|
delete preparedCheckpoint.pending_sends;
|
|
199
203
|
const threadId = config.configurable?.thread_id;
|
|
200
|
-
const checkpointNamespace = config.configurable?.checkpoint_ns;
|
|
204
|
+
const checkpointNamespace = config.configurable?.checkpoint_ns ?? "";
|
|
201
205
|
if (threadId === undefined) {
|
|
202
206
|
throw new Error(`Failed to put checkpoint. The passed RunnableConfig is missing a required "thread_id" field in its "configurable" property.`);
|
|
203
207
|
}
|
|
204
|
-
if (checkpointNamespace === undefined) {
|
|
205
|
-
throw new Error(`Failed to put checkpoint. The passed RunnableConfig is missing a required "checkpoint_ns" field in its "configurable" property.`);
|
|
206
|
-
}
|
|
207
208
|
if (!this.storage[threadId]) {
|
|
208
209
|
this.storage[threadId] = {};
|
|
209
210
|
}
|
package/dist/memory.js
CHANGED
|
@@ -122,13 +122,13 @@ export class MemorySaver extends BaseCheckpointSaver {
|
|
|
122
122
|
}
|
|
123
123
|
async *list(config, options) {
|
|
124
124
|
// eslint-disable-next-line prefer-const
|
|
125
|
-
let { before, limit } = options ?? {};
|
|
125
|
+
let { before, limit, filter } = options ?? {};
|
|
126
126
|
const threadIds = config.configurable?.thread_id
|
|
127
127
|
? [config.configurable?.thread_id]
|
|
128
128
|
: Object.keys(this.storage);
|
|
129
129
|
const configCheckpointNamespace = config.configurable?.checkpoint_ns;
|
|
130
130
|
for (const threadId of threadIds) {
|
|
131
|
-
for (const checkpointNamespace of Object.keys(this.storage[threadId])) {
|
|
131
|
+
for (const checkpointNamespace of Object.keys(this.storage[threadId] ?? {})) {
|
|
132
132
|
if (configCheckpointNamespace !== undefined &&
|
|
133
133
|
checkpointNamespace !== configCheckpointNamespace) {
|
|
134
134
|
continue;
|
|
@@ -144,6 +144,10 @@ export class MemorySaver extends BaseCheckpointSaver {
|
|
|
144
144
|
}
|
|
145
145
|
// Parse metadata
|
|
146
146
|
const metadata = (await this.serde.loadsTyped("json", metadataStr));
|
|
147
|
+
if (filter &&
|
|
148
|
+
!Object.entries(filter).every(([key, value]) => metadata[key] === value)) {
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
147
151
|
// Limit search results
|
|
148
152
|
if (limit !== undefined) {
|
|
149
153
|
if (limit <= 0)
|
|
@@ -194,13 +198,10 @@ export class MemorySaver extends BaseCheckpointSaver {
|
|
|
194
198
|
const preparedCheckpoint = copyCheckpoint(checkpoint);
|
|
195
199
|
delete preparedCheckpoint.pending_sends;
|
|
196
200
|
const threadId = config.configurable?.thread_id;
|
|
197
|
-
const checkpointNamespace = config.configurable?.checkpoint_ns;
|
|
201
|
+
const checkpointNamespace = config.configurable?.checkpoint_ns ?? "";
|
|
198
202
|
if (threadId === undefined) {
|
|
199
203
|
throw new Error(`Failed to put checkpoint. The passed RunnableConfig is missing a required "thread_id" field in its "configurable" property.`);
|
|
200
204
|
}
|
|
201
|
-
if (checkpointNamespace === undefined) {
|
|
202
|
-
throw new Error(`Failed to put checkpoint. The passed RunnableConfig is missing a required "checkpoint_ns" field in its "configurable" property.`);
|
|
203
|
-
}
|
|
204
205
|
if (!this.storage[threadId]) {
|
|
205
206
|
this.storage[threadId] = {};
|
|
206
207
|
}
|