@langchain/langgraph 0.2.9 → 0.2.10-rc.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/constants.cjs +1 -2
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +0 -1
- package/dist/graph/state.d.ts +1 -2
- package/dist/managed/shared_value.cjs +11 -9
- package/dist/managed/shared_value.d.ts +6 -5
- package/dist/managed/shared_value.js +11 -9
- package/dist/pregel/algo.cjs +6 -1
- package/dist/pregel/algo.d.ts +11 -4
- package/dist/pregel/algo.js +6 -1
- package/dist/pregel/index.cjs +13 -7
- package/dist/pregel/index.d.ts +8 -5
- package/dist/pregel/index.js +15 -9
- package/dist/pregel/loop.cjs +2 -2
- package/dist/pregel/loop.d.ts +3 -4
- package/dist/pregel/loop.js +2 -2
- package/dist/pregel/read.d.ts +1 -1
- package/dist/pregel/runnable_types.cjs +2 -0
- package/dist/pregel/runnable_types.d.ts +5 -0
- package/dist/pregel/runnable_types.js +1 -0
- package/dist/pregel/types.d.ts +5 -5
- package/dist/pregel/utils/config.cjs +1 -0
- package/dist/pregel/utils/config.d.ts +2 -1
- package/dist/pregel/utils/config.js +1 -0
- package/dist/web.cjs +4 -2
- package/dist/web.d.ts +2 -2
- package/dist/web.js +1 -2
- package/package.json +1 -1
- package/dist/store/base.cjs +0 -12
- package/dist/store/base.d.ts +0 -7
- package/dist/store/base.js +0 -8
- package/dist/store/batch.cjs +0 -126
- package/dist/store/batch.d.ts +0 -55
- package/dist/store/batch.js +0 -122
- package/dist/store/index.cjs +0 -19
- package/dist/store/index.d.ts +0 -3
- package/dist/store/index.js +0 -3
- package/dist/store/memory.cjs +0 -43
- package/dist/store/memory.d.ts +0 -6
- package/dist/store/memory.js +0 -39
package/dist/constants.cjs
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._isSend = exports.Send = exports._isSendInterface = exports.CHECKPOINT_NAMESPACE_END = exports.CHECKPOINT_NAMESPACE_SEPARATOR = exports.RESERVED = exports.TASK_NAMESPACE = exports.PULL = exports.PUSH = exports.TASKS = exports.TAG_HIDDEN = exports.RECURSION_LIMIT_DEFAULT = exports.RUNTIME_PLACEHOLDER = exports.INTERRUPT = exports.CONFIG_KEY_CHECKPOINT_MAP = exports.CONFIG_KEY_STREAM = exports.CONFIG_KEY_TASK_ID = exports.CONFIG_KEY_RESUMING = exports.
|
|
3
|
+
exports._isSend = exports.Send = exports._isSendInterface = exports.CHECKPOINT_NAMESPACE_END = exports.CHECKPOINT_NAMESPACE_SEPARATOR = exports.RESERVED = exports.TASK_NAMESPACE = exports.PULL = exports.PUSH = exports.TASKS = exports.TAG_HIDDEN = exports.RECURSION_LIMIT_DEFAULT = exports.RUNTIME_PLACEHOLDER = exports.INTERRUPT = exports.CONFIG_KEY_CHECKPOINT_MAP = exports.CONFIG_KEY_STREAM = exports.CONFIG_KEY_TASK_ID = exports.CONFIG_KEY_RESUMING = exports.CONFIG_KEY_CHECKPOINTER = exports.CONFIG_KEY_READ = exports.CONFIG_KEY_SEND = exports.ERROR = exports.INPUT = void 0;
|
|
4
4
|
exports.INPUT = "__input__";
|
|
5
5
|
exports.ERROR = "__error__";
|
|
6
6
|
exports.CONFIG_KEY_SEND = "__pregel_send";
|
|
7
7
|
exports.CONFIG_KEY_READ = "__pregel_read";
|
|
8
8
|
exports.CONFIG_KEY_CHECKPOINTER = "__pregel_checkpointer";
|
|
9
|
-
exports.CONFIG_KEY_STORE = "__pregel_store";
|
|
10
9
|
exports.CONFIG_KEY_RESUMING = "__pregel_resuming";
|
|
11
10
|
exports.CONFIG_KEY_TASK_ID = "__pregel_task_id";
|
|
12
11
|
exports.CONFIG_KEY_STREAM = "__pregel_stream";
|
package/dist/constants.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ export declare const ERROR = "__error__";
|
|
|
3
3
|
export declare const CONFIG_KEY_SEND = "__pregel_send";
|
|
4
4
|
export declare const CONFIG_KEY_READ = "__pregel_read";
|
|
5
5
|
export declare const CONFIG_KEY_CHECKPOINTER = "__pregel_checkpointer";
|
|
6
|
-
export declare const CONFIG_KEY_STORE = "__pregel_store";
|
|
7
6
|
export declare const CONFIG_KEY_RESUMING = "__pregel_resuming";
|
|
8
7
|
export declare const CONFIG_KEY_TASK_ID = "__pregel_task_id";
|
|
9
8
|
export declare const CONFIG_KEY_STREAM = "__pregel_stream";
|
package/dist/constants.js
CHANGED
|
@@ -3,7 +3,6 @@ export const ERROR = "__error__";
|
|
|
3
3
|
export const CONFIG_KEY_SEND = "__pregel_send";
|
|
4
4
|
export const CONFIG_KEY_READ = "__pregel_read";
|
|
5
5
|
export const CONFIG_KEY_CHECKPOINTER = "__pregel_checkpointer";
|
|
6
|
-
export const CONFIG_KEY_STORE = "__pregel_store";
|
|
7
6
|
export const CONFIG_KEY_RESUMING = "__pregel_resuming";
|
|
8
7
|
export const CONFIG_KEY_TASK_ID = "__pregel_task_id";
|
|
9
8
|
export const CONFIG_KEY_STREAM = "__pregel_stream";
|
package/dist/graph/state.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { RunnableLike } from "@langchain/core/runnables";
|
|
2
|
-
import { All, BaseCheckpointSaver } from "@langchain/langgraph-checkpoint";
|
|
2
|
+
import { All, BaseCheckpointSaver, BaseStore } from "@langchain/langgraph-checkpoint";
|
|
3
3
|
import { BaseChannel } from "../channels/base.js";
|
|
4
4
|
import { END, CompiledGraph, Graph, START, Branch, AddNodeOptions, NodeSpec } from "./graph.js";
|
|
5
5
|
import { AnnotationRoot, SingleReducer, StateDefinition, StateType, UpdateType } from "./annotation.js";
|
|
6
6
|
import type { RetryPolicy } from "../pregel/utils/index.js";
|
|
7
|
-
import { BaseStore } from "../store/base.js";
|
|
8
7
|
import { ManagedValueSpec } from "../managed/base.js";
|
|
9
8
|
export type ChannelReducers<Channels extends object> = {
|
|
10
9
|
[K in keyof Channels]: SingleReducer<Channels[K], any>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.SharedValue = void 0;
|
|
4
5
|
const base_js_1 = require("./base.cjs");
|
|
5
|
-
const constants_js_1 = require("../constants.cjs");
|
|
6
6
|
const errors_js_1 = require("../errors.cjs");
|
|
7
7
|
class SharedValue extends base_js_1.WritableManagedValue {
|
|
8
8
|
constructor(config, params) {
|
|
@@ -32,7 +32,7 @@ class SharedValue extends base_js_1.WritableManagedValue {
|
|
|
32
32
|
value: {}
|
|
33
33
|
});
|
|
34
34
|
this.scope = params.scope;
|
|
35
|
-
this.store = config.
|
|
35
|
+
this.store = config.store || null;
|
|
36
36
|
if (!this.store) {
|
|
37
37
|
this.ns = null;
|
|
38
38
|
}
|
|
@@ -41,13 +41,12 @@ class SharedValue extends base_js_1.WritableManagedValue {
|
|
|
41
41
|
const scopedValueString = typeof scopeValue === "string"
|
|
42
42
|
? scopeValue
|
|
43
43
|
: JSON.stringify(scopeValue);
|
|
44
|
-
this.ns =
|
|
44
|
+
this.ns = ["scoped", this.scope, params.key, scopedValueString];
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
47
|
throw new Error(`Required scope "${this.scope}" for shared state key was not passed in "config.configurable".`);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
50
|
static async initialize(config, args) {
|
|
52
51
|
const instance = new this(config, args);
|
|
53
52
|
await instance.loadStore();
|
|
@@ -73,7 +72,7 @@ class SharedValue extends base_js_1.WritableManagedValue {
|
|
|
73
72
|
if (k in this.value) {
|
|
74
73
|
delete this.value[k];
|
|
75
74
|
if (this.ns) {
|
|
76
|
-
writes.push(
|
|
75
|
+
writes.push({ namespace: this.ns, id: k, value: null });
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
78
|
}
|
|
@@ -83,7 +82,7 @@ class SharedValue extends base_js_1.WritableManagedValue {
|
|
|
83
82
|
else {
|
|
84
83
|
this.value[k] = v;
|
|
85
84
|
if (this.ns) {
|
|
86
|
-
writes.push(
|
|
85
|
+
writes.push({ namespace: this.ns, id: k, value: v });
|
|
87
86
|
}
|
|
88
87
|
}
|
|
89
88
|
}
|
|
@@ -95,13 +94,16 @@ class SharedValue extends base_js_1.WritableManagedValue {
|
|
|
95
94
|
this.processUpdate(values);
|
|
96
95
|
}
|
|
97
96
|
else {
|
|
98
|
-
await this.store.
|
|
97
|
+
await this.store.batch(this.processUpdate(values));
|
|
99
98
|
}
|
|
100
99
|
}
|
|
101
100
|
async loadStore() {
|
|
102
101
|
if (this.store && this.ns) {
|
|
103
|
-
const saved = await this.store.
|
|
104
|
-
this.value = saved
|
|
102
|
+
const saved = await this.store.search(this.ns);
|
|
103
|
+
this.value = saved.reduce((acc, item) => {
|
|
104
|
+
acc[item.id] = item.value;
|
|
105
|
+
return acc;
|
|
106
|
+
}, {});
|
|
105
107
|
}
|
|
106
108
|
return false;
|
|
107
109
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { RunnableConfig } from "@langchain/core/runnables";
|
|
2
|
-
import { BaseStore
|
|
2
|
+
import { BaseStore } from "@langchain/langgraph-checkpoint";
|
|
3
3
|
import { ConfiguredManagedValue, ManagedValue, ManagedValueParams, WritableManagedValue } from "./base.js";
|
|
4
|
-
|
|
5
|
-
type
|
|
4
|
+
import { LangGraphRunnableConfig } from "../pregel/runnable_types.js";
|
|
5
|
+
type Value = Record<string, Record<string, any>>;
|
|
6
|
+
type Update = Record<string, Record<string, any> | null>;
|
|
6
7
|
export interface SharedValueParams extends ManagedValueParams {
|
|
7
8
|
scope: string;
|
|
8
9
|
key: string;
|
|
@@ -10,9 +11,9 @@ export interface SharedValueParams extends ManagedValueParams {
|
|
|
10
11
|
export declare class SharedValue extends WritableManagedValue<Value, Update> {
|
|
11
12
|
scope: string;
|
|
12
13
|
store: BaseStore | null;
|
|
13
|
-
ns: string | null;
|
|
14
|
+
ns: ["scoped", string, string, any] | null;
|
|
14
15
|
value: Value;
|
|
15
|
-
constructor(config:
|
|
16
|
+
constructor(config: LangGraphRunnableConfig, params: SharedValueParams);
|
|
16
17
|
static initialize<Value = any>(config: RunnableConfig, args: SharedValueParams): Promise<ManagedValue<Value>>;
|
|
17
18
|
static on(scope: string): ConfiguredManagedValue<Value>;
|
|
18
19
|
call(_step: number): Value;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1
2
|
import { ChannelKeyPlaceholder, WritableManagedValue, } from "./base.js";
|
|
2
|
-
import { CONFIG_KEY_STORE } from "../constants.js";
|
|
3
3
|
import { InvalidUpdateError } from "../errors.js";
|
|
4
4
|
export class SharedValue extends WritableManagedValue {
|
|
5
5
|
constructor(config, params) {
|
|
@@ -29,7 +29,7 @@ export class SharedValue extends WritableManagedValue {
|
|
|
29
29
|
value: {}
|
|
30
30
|
});
|
|
31
31
|
this.scope = params.scope;
|
|
32
|
-
this.store = config.
|
|
32
|
+
this.store = config.store || null;
|
|
33
33
|
if (!this.store) {
|
|
34
34
|
this.ns = null;
|
|
35
35
|
}
|
|
@@ -38,13 +38,12 @@ export class SharedValue extends WritableManagedValue {
|
|
|
38
38
|
const scopedValueString = typeof scopeValue === "string"
|
|
39
39
|
? scopeValue
|
|
40
40
|
: JSON.stringify(scopeValue);
|
|
41
|
-
this.ns =
|
|
41
|
+
this.ns = ["scoped", this.scope, params.key, scopedValueString];
|
|
42
42
|
}
|
|
43
43
|
else {
|
|
44
44
|
throw new Error(`Required scope "${this.scope}" for shared state key was not passed in "config.configurable".`);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
47
|
static async initialize(config, args) {
|
|
49
48
|
const instance = new this(config, args);
|
|
50
49
|
await instance.loadStore();
|
|
@@ -70,7 +69,7 @@ export class SharedValue extends WritableManagedValue {
|
|
|
70
69
|
if (k in this.value) {
|
|
71
70
|
delete this.value[k];
|
|
72
71
|
if (this.ns) {
|
|
73
|
-
writes.push(
|
|
72
|
+
writes.push({ namespace: this.ns, id: k, value: null });
|
|
74
73
|
}
|
|
75
74
|
}
|
|
76
75
|
}
|
|
@@ -80,7 +79,7 @@ export class SharedValue extends WritableManagedValue {
|
|
|
80
79
|
else {
|
|
81
80
|
this.value[k] = v;
|
|
82
81
|
if (this.ns) {
|
|
83
|
-
writes.push(
|
|
82
|
+
writes.push({ namespace: this.ns, id: k, value: v });
|
|
84
83
|
}
|
|
85
84
|
}
|
|
86
85
|
}
|
|
@@ -92,13 +91,16 @@ export class SharedValue extends WritableManagedValue {
|
|
|
92
91
|
this.processUpdate(values);
|
|
93
92
|
}
|
|
94
93
|
else {
|
|
95
|
-
await this.store.
|
|
94
|
+
await this.store.batch(this.processUpdate(values));
|
|
96
95
|
}
|
|
97
96
|
}
|
|
98
97
|
async loadStore() {
|
|
99
98
|
if (this.store && this.ns) {
|
|
100
|
-
const saved = await this.store.
|
|
101
|
-
this.value = saved
|
|
99
|
+
const saved = await this.store.search(this.ns);
|
|
100
|
+
this.value = saved.reduce((acc, item) => {
|
|
101
|
+
acc[item.id] = item.value;
|
|
102
|
+
return acc;
|
|
103
|
+
}, {});
|
|
102
104
|
}
|
|
103
105
|
return false;
|
|
104
106
|
}
|
package/dist/pregel/algo.cjs
CHANGED
|
@@ -277,6 +277,7 @@ function _prepareSingleTask(taskPath, checkpoint, processes, channels, managed,
|
|
|
277
277
|
config: (0, runnables_1.patchConfig)((0, runnables_1.mergeConfigs)(config, {
|
|
278
278
|
metadata,
|
|
279
279
|
tags: proc.tags,
|
|
280
|
+
store: extra.store ?? config.store,
|
|
280
281
|
}), {
|
|
281
282
|
runName: packet.node,
|
|
282
283
|
callbacks: manager?.getChild(`graph:step:${step}`),
|
|
@@ -369,7 +370,11 @@ function _prepareSingleTask(taskPath, checkpoint, processes, channels, managed,
|
|
|
369
370
|
input: val,
|
|
370
371
|
proc: node,
|
|
371
372
|
writes,
|
|
372
|
-
config: (0, runnables_1.patchConfig)((0, runnables_1.mergeConfigs)(config, {
|
|
373
|
+
config: (0, runnables_1.patchConfig)((0, runnables_1.mergeConfigs)(config, {
|
|
374
|
+
metadata,
|
|
375
|
+
tags: proc.tags,
|
|
376
|
+
store: extra.store ?? config?.store,
|
|
377
|
+
}), {
|
|
373
378
|
runName: name,
|
|
374
379
|
callbacks: manager?.getChild(`graph:step:${step}`),
|
|
375
380
|
configurable: {
|
package/dist/pregel/algo.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RunnableConfig } from "@langchain/core/runnables";
|
|
2
2
|
import { CallbackManagerForChainRun } from "@langchain/core/callbacks/manager";
|
|
3
|
-
import { All, BaseCheckpointSaver, Checkpoint, ReadonlyCheckpoint, type PendingWrite, type PendingWriteValue } from "@langchain/langgraph-checkpoint";
|
|
3
|
+
import { All, BaseCheckpointSaver, Checkpoint, ReadonlyCheckpoint, type PendingWrite, type PendingWriteValue, BaseStore } from "@langchain/langgraph-checkpoint";
|
|
4
4
|
import { BaseChannel } from "../channels/base.js";
|
|
5
5
|
import { PregelNode } from "./read.js";
|
|
6
6
|
import { PregelExecutableTask, PregelTaskDescription } from "./types.js";
|
|
@@ -26,9 +26,16 @@ export type NextTaskExtraFields = {
|
|
|
26
26
|
isResuming?: boolean;
|
|
27
27
|
checkpointer?: BaseCheckpointSaver;
|
|
28
28
|
manager?: CallbackManagerForChainRun;
|
|
29
|
+
store?: BaseStore;
|
|
29
30
|
};
|
|
30
|
-
export
|
|
31
|
-
|
|
31
|
+
export type NextTaskExtraFieldsWithStore = NextTaskExtraFields & {
|
|
32
|
+
store?: BaseStore;
|
|
33
|
+
};
|
|
34
|
+
export type NextTaskExtraFieldsWithoutStore = NextTaskExtraFields & {
|
|
35
|
+
store?: never;
|
|
36
|
+
};
|
|
37
|
+
export declare function _prepareNextTasks<Nn extends StrRecord<string, PregelNode>, Cc extends StrRecord<string, BaseChannel>>(checkpoint: ReadonlyCheckpoint, processes: Nn, channels: Cc, managed: ManagedValueMapping, config: RunnableConfig, forExecution: false, extra: NextTaskExtraFieldsWithoutStore): Record<string, PregelTaskDescription>;
|
|
38
|
+
export declare function _prepareNextTasks<Nn extends StrRecord<string, PregelNode>, Cc extends StrRecord<string, BaseChannel>>(checkpoint: ReadonlyCheckpoint, processes: Nn, channels: Cc, managed: ManagedValueMapping, config: RunnableConfig, forExecution: true, extra: NextTaskExtraFieldsWithStore): Record<string, PregelExecutableTask<keyof Nn, keyof Cc>>;
|
|
32
39
|
export declare function _prepareSingleTask<Nn extends StrRecord<string, PregelNode>, Cc extends StrRecord<string, BaseChannel>>(taskPath: [string, string | number], checkpoint: ReadonlyCheckpoint, processes: Nn, channels: Cc, managed: ManagedValueMapping, config: RunnableConfig, forExecution: false, extra: NextTaskExtraFields): PregelTaskDescription | undefined;
|
|
33
40
|
export declare function _prepareSingleTask<Nn extends StrRecord<string, PregelNode>, Cc extends StrRecord<string, BaseChannel>>(taskPath: [string, string | number], checkpoint: ReadonlyCheckpoint, processes: Nn, channels: Cc, managed: ManagedValueMapping, config: RunnableConfig, forExecution: true, extra: NextTaskExtraFields): PregelExecutableTask<keyof Nn, keyof Cc> | undefined;
|
|
34
|
-
export declare function _prepareSingleTask<Nn extends StrRecord<string, PregelNode>, Cc extends StrRecord<string, BaseChannel>>(taskPath: [string, string | number], checkpoint: ReadonlyCheckpoint, processes: Nn, channels: Cc, managed: ManagedValueMapping, config: RunnableConfig, forExecution: boolean, extra:
|
|
41
|
+
export declare function _prepareSingleTask<Nn extends StrRecord<string, PregelNode>, Cc extends StrRecord<string, BaseChannel>>(taskPath: [string, string | number], checkpoint: ReadonlyCheckpoint, processes: Nn, channels: Cc, managed: ManagedValueMapping, config: RunnableConfig, forExecution: boolean, extra: NextTaskExtraFieldsWithStore): PregelTaskDescription | PregelExecutableTask<keyof Nn, keyof Cc> | undefined;
|
package/dist/pregel/algo.js
CHANGED
|
@@ -268,6 +268,7 @@ export function _prepareSingleTask(taskPath, checkpoint, processes, channels, ma
|
|
|
268
268
|
config: patchConfig(mergeConfigs(config, {
|
|
269
269
|
metadata,
|
|
270
270
|
tags: proc.tags,
|
|
271
|
+
store: extra.store ?? config.store,
|
|
271
272
|
}), {
|
|
272
273
|
runName: packet.node,
|
|
273
274
|
callbacks: manager?.getChild(`graph:step:${step}`),
|
|
@@ -360,7 +361,11 @@ export function _prepareSingleTask(taskPath, checkpoint, processes, channels, ma
|
|
|
360
361
|
input: val,
|
|
361
362
|
proc: node,
|
|
362
363
|
writes,
|
|
363
|
-
config: patchConfig(mergeConfigs(config, {
|
|
364
|
+
config: patchConfig(mergeConfigs(config, {
|
|
365
|
+
metadata,
|
|
366
|
+
tags: proc.tags,
|
|
367
|
+
store: extra.store ?? config?.store,
|
|
368
|
+
}), {
|
|
364
369
|
runName: name,
|
|
365
370
|
callbacks: manager?.getChild(`graph:step:${step}`),
|
|
366
371
|
configurable: {
|
package/dist/pregel/index.cjs
CHANGED
|
@@ -550,7 +550,10 @@ class Pregel extends runnables_1.Runnable {
|
|
|
550
550
|
id: (0, langgraph_checkpoint_1.uuid5)(constants_js_1.INTERRUPT, checkpoint.id),
|
|
551
551
|
};
|
|
552
552
|
// execute task
|
|
553
|
-
await task.proc.invoke(task.input, (0, runnables_1.patchConfig)(
|
|
553
|
+
await task.proc.invoke(task.input, (0, runnables_1.patchConfig)({
|
|
554
|
+
...config,
|
|
555
|
+
store: config?.store ?? this.store,
|
|
556
|
+
}, {
|
|
554
557
|
runName: config.runName ?? `${this.getName()}UpdateState`,
|
|
555
558
|
configurable: {
|
|
556
559
|
[constants_js_1.CONFIG_KEY_SEND]: (items) => task.writes.push(...items),
|
|
@@ -613,6 +616,7 @@ class Pregel extends runnables_1.Runnable {
|
|
|
613
616
|
else {
|
|
614
617
|
defaultCheckpointer = this.checkpointer;
|
|
615
618
|
}
|
|
619
|
+
const defaultStore = config.store ?? this.store;
|
|
616
620
|
return [
|
|
617
621
|
defaultDebug,
|
|
618
622
|
defaultStreamMode,
|
|
@@ -622,6 +626,7 @@ class Pregel extends runnables_1.Runnable {
|
|
|
622
626
|
defaultInterruptBefore,
|
|
623
627
|
defaultInterruptAfter,
|
|
624
628
|
defaultCheckpointer,
|
|
629
|
+
defaultStore,
|
|
625
630
|
];
|
|
626
631
|
}
|
|
627
632
|
/**
|
|
@@ -643,9 +648,10 @@ class Pregel extends runnables_1.Runnable {
|
|
|
643
648
|
return super.stream(input, options);
|
|
644
649
|
}
|
|
645
650
|
async prepareSpecs(config, options) {
|
|
646
|
-
const configForManaged =
|
|
647
|
-
|
|
648
|
-
|
|
651
|
+
const configForManaged = {
|
|
652
|
+
...config,
|
|
653
|
+
store: this.store,
|
|
654
|
+
};
|
|
649
655
|
const channelSpecs = {};
|
|
650
656
|
const managedSpecs = {};
|
|
651
657
|
for (const [name, spec] of Object.entries(this.channels)) {
|
|
@@ -700,7 +706,7 @@ class Pregel extends runnables_1.Runnable {
|
|
|
700
706
|
const runManager = await callbackManager?.handleChainStart(this.toJSON(), (0, index_js_1._coerceToDict)(input, "input"), inputConfig.runId, undefined, undefined, undefined, inputConfig?.runName ?? this.getName());
|
|
701
707
|
delete inputConfig.runId;
|
|
702
708
|
// assign defaults
|
|
703
|
-
const [debug, streamMode, , outputKeys, config, interruptBefore, interruptAfter, checkpointer,] = this._defaults(inputConfig);
|
|
709
|
+
const [debug, streamMode, , outputKeys, config, interruptBefore, interruptAfter, checkpointer, store,] = this._defaults(inputConfig);
|
|
704
710
|
const { channelSpecs, managed } = await this.prepareSpecs(config);
|
|
705
711
|
let loop;
|
|
706
712
|
const stream = new double_ended_queue_1.default();
|
|
@@ -737,7 +743,7 @@ class Pregel extends runnables_1.Runnable {
|
|
|
737
743
|
managed,
|
|
738
744
|
outputKeys,
|
|
739
745
|
streamKeys: this.streamChannelsAsIs,
|
|
740
|
-
store
|
|
746
|
+
store,
|
|
741
747
|
stream: new loop_js_1.StreamProtocol((chunk) => stream.push(chunk), new Set(streamMode)),
|
|
742
748
|
});
|
|
743
749
|
if (options?.subgraphs) {
|
|
@@ -816,7 +822,7 @@ class Pregel extends runnables_1.Runnable {
|
|
|
816
822
|
finally {
|
|
817
823
|
// Call `.stop()` again incase it was not called in the loop, e.g due to an error.
|
|
818
824
|
if (loop) {
|
|
819
|
-
loop.store?.stop();
|
|
825
|
+
await loop.store?.stop();
|
|
820
826
|
}
|
|
821
827
|
await Promise.all([
|
|
822
828
|
loop?.checkpointerPromises ?? [],
|
package/dist/pregel/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Runnable, RunnableConfig, RunnableFunc } from "@langchain/core/runnables";
|
|
2
2
|
import { IterableReadableStream } from "@langchain/core/utils/stream";
|
|
3
|
-
import { All, BaseCheckpointSaver, CheckpointListOptions, CheckpointTuple } from "@langchain/langgraph-checkpoint";
|
|
3
|
+
import { All, BaseCheckpointSaver, BaseStore, CheckpointListOptions, CheckpointTuple } from "@langchain/langgraph-checkpoint";
|
|
4
4
|
import { BaseChannel } from "../channels/base.js";
|
|
5
5
|
import { PregelNode } from "./read.js";
|
|
6
6
|
import { ChannelWrite } from "./write.js";
|
|
7
7
|
import { PregelInterface, PregelParams, StateSnapshot, StreamMode } from "./types.js";
|
|
8
8
|
import { StrRecord } from "./algo.js";
|
|
9
9
|
import { RetryPolicy } from "./utils/index.js";
|
|
10
|
-
import { BaseStore } from "../store/base.js";
|
|
11
10
|
import { ManagedValueMapping, type ManagedValueSpec } from "../managed/base.js";
|
|
11
|
+
import { LangGraphRunnableConfig } from "./runnable_types.js";
|
|
12
12
|
type WriteValue = Runnable | RunnableFunc<unknown, unknown> | unknown;
|
|
13
13
|
export declare class Channel {
|
|
14
14
|
static subscribeTo(channels: string, options?: {
|
|
@@ -37,6 +37,8 @@ export interface PregelOptions<Nn extends StrRecord<string, PregelNode>, Cc exte
|
|
|
37
37
|
debug?: boolean;
|
|
38
38
|
/** Whether to stream subgraphs. */
|
|
39
39
|
subgraphs?: boolean;
|
|
40
|
+
/** The shared value store */
|
|
41
|
+
store?: BaseStore;
|
|
40
42
|
}
|
|
41
43
|
export type PregelInputType = any;
|
|
42
44
|
export type PregelOutputType = any;
|
|
@@ -56,7 +58,7 @@ export declare class Pregel<Nn extends StrRecord<string, PregelNode>, Cc extends
|
|
|
56
58
|
debug: boolean;
|
|
57
59
|
checkpointer?: BaseCheckpointSaver;
|
|
58
60
|
retryPolicy?: RetryPolicy;
|
|
59
|
-
config?:
|
|
61
|
+
config?: LangGraphRunnableConfig;
|
|
60
62
|
store?: BaseStore;
|
|
61
63
|
constructor(fields: PregelParams<Nn, Cc>);
|
|
62
64
|
withConfig(config: RunnableConfig): typeof this;
|
|
@@ -84,7 +86,7 @@ export declare class Pregel<Nn extends StrRecord<string, PregelNode>, Cc extends
|
|
|
84
86
|
* node `as_node`. If `as_node` is not provided, it will be set to the last node
|
|
85
87
|
* that updated the state, if not ambiguous.
|
|
86
88
|
*/
|
|
87
|
-
updateState(inputConfig:
|
|
89
|
+
updateState(inputConfig: LangGraphRunnableConfig, values: Record<string, unknown> | unknown, asNode?: keyof Nn | string): Promise<RunnableConfig>;
|
|
88
90
|
_defaults(config: PregelOptions<Nn, Cc>): [
|
|
89
91
|
boolean,
|
|
90
92
|
StreamMode[],
|
|
@@ -98,7 +100,8 @@ export declare class Pregel<Nn extends StrRecord<string, PregelNode>, Cc extends
|
|
|
98
100
|
// interrupt before
|
|
99
101
|
All | string[],
|
|
100
102
|
// interrupt after
|
|
101
|
-
BaseCheckpointSaver | undefined
|
|
103
|
+
BaseCheckpointSaver | undefined,
|
|
104
|
+
BaseStore | undefined
|
|
102
105
|
];
|
|
103
106
|
/**
|
|
104
107
|
* Stream graph steps for a single input.
|
package/dist/pregel/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-param-reassign */
|
|
2
|
-
import { Runnable, RunnableSequence,
|
|
2
|
+
import { Runnable, RunnableSequence, getCallbackManagerForConfig, mergeConfigs, patchConfig, _coerceToRunnable, } from "@langchain/core/runnables";
|
|
3
3
|
import { compareChannelVersions, copyCheckpoint, emptyCheckpoint, uuid5, } from "@langchain/langgraph-checkpoint";
|
|
4
4
|
import Deque from "double-ended-queue";
|
|
5
5
|
import { createCheckpoint, emptyChannels, isBaseChannel, } from "../channels/base.js";
|
|
@@ -8,7 +8,7 @@ import { validateGraph, validateKeys } from "./validate.js";
|
|
|
8
8
|
import { readChannels } from "./io.js";
|
|
9
9
|
import { printStepCheckpoint, printStepTasks, printStepWrites, tasksWithWrites, } from "./debug.js";
|
|
10
10
|
import { ChannelWrite, PASSTHROUGH } from "./write.js";
|
|
11
|
-
import { CONFIG_KEY_CHECKPOINTER, CONFIG_KEY_READ, CONFIG_KEY_SEND,
|
|
11
|
+
import { CONFIG_KEY_CHECKPOINTER, CONFIG_KEY_READ, CONFIG_KEY_SEND, ERROR, INTERRUPT, CHECKPOINT_NAMESPACE_SEPARATOR, CHECKPOINT_NAMESPACE_END, CONFIG_KEY_STREAM, CONFIG_KEY_TASK_ID, } from "../constants.js";
|
|
12
12
|
import { GraphRecursionError, GraphValueError, InvalidUpdateError, isGraphInterrupt, } from "../errors.js";
|
|
13
13
|
import { _prepareNextTasks, _localRead, _applyWrites, } from "./algo.js";
|
|
14
14
|
import { _coerceToDict, getNewChannelVersions, patchCheckpointMap, } from "./utils/index.js";
|
|
@@ -543,7 +543,10 @@ export class Pregel extends Runnable {
|
|
|
543
543
|
id: uuid5(INTERRUPT, checkpoint.id),
|
|
544
544
|
};
|
|
545
545
|
// execute task
|
|
546
|
-
await task.proc.invoke(task.input, patchConfig(
|
|
546
|
+
await task.proc.invoke(task.input, patchConfig({
|
|
547
|
+
...config,
|
|
548
|
+
store: config?.store ?? this.store,
|
|
549
|
+
}, {
|
|
547
550
|
runName: config.runName ?? `${this.getName()}UpdateState`,
|
|
548
551
|
configurable: {
|
|
549
552
|
[CONFIG_KEY_SEND]: (items) => task.writes.push(...items),
|
|
@@ -606,6 +609,7 @@ export class Pregel extends Runnable {
|
|
|
606
609
|
else {
|
|
607
610
|
defaultCheckpointer = this.checkpointer;
|
|
608
611
|
}
|
|
612
|
+
const defaultStore = config.store ?? this.store;
|
|
609
613
|
return [
|
|
610
614
|
defaultDebug,
|
|
611
615
|
defaultStreamMode,
|
|
@@ -615,6 +619,7 @@ export class Pregel extends Runnable {
|
|
|
615
619
|
defaultInterruptBefore,
|
|
616
620
|
defaultInterruptAfter,
|
|
617
621
|
defaultCheckpointer,
|
|
622
|
+
defaultStore,
|
|
618
623
|
];
|
|
619
624
|
}
|
|
620
625
|
/**
|
|
@@ -636,9 +641,10 @@ export class Pregel extends Runnable {
|
|
|
636
641
|
return super.stream(input, options);
|
|
637
642
|
}
|
|
638
643
|
async prepareSpecs(config, options) {
|
|
639
|
-
const configForManaged =
|
|
640
|
-
|
|
641
|
-
|
|
644
|
+
const configForManaged = {
|
|
645
|
+
...config,
|
|
646
|
+
store: this.store,
|
|
647
|
+
};
|
|
642
648
|
const channelSpecs = {};
|
|
643
649
|
const managedSpecs = {};
|
|
644
650
|
for (const [name, spec] of Object.entries(this.channels)) {
|
|
@@ -693,7 +699,7 @@ export class Pregel extends Runnable {
|
|
|
693
699
|
const runManager = await callbackManager?.handleChainStart(this.toJSON(), _coerceToDict(input, "input"), inputConfig.runId, undefined, undefined, undefined, inputConfig?.runName ?? this.getName());
|
|
694
700
|
delete inputConfig.runId;
|
|
695
701
|
// assign defaults
|
|
696
|
-
const [debug, streamMode, , outputKeys, config, interruptBefore, interruptAfter, checkpointer,] = this._defaults(inputConfig);
|
|
702
|
+
const [debug, streamMode, , outputKeys, config, interruptBefore, interruptAfter, checkpointer, store,] = this._defaults(inputConfig);
|
|
697
703
|
const { channelSpecs, managed } = await this.prepareSpecs(config);
|
|
698
704
|
let loop;
|
|
699
705
|
const stream = new Deque();
|
|
@@ -730,7 +736,7 @@ export class Pregel extends Runnable {
|
|
|
730
736
|
managed,
|
|
731
737
|
outputKeys,
|
|
732
738
|
streamKeys: this.streamChannelsAsIs,
|
|
733
|
-
store
|
|
739
|
+
store,
|
|
734
740
|
stream: new StreamProtocol((chunk) => stream.push(chunk), new Set(streamMode)),
|
|
735
741
|
});
|
|
736
742
|
if (options?.subgraphs) {
|
|
@@ -809,7 +815,7 @@ export class Pregel extends Runnable {
|
|
|
809
815
|
finally {
|
|
810
816
|
// Call `.stop()` again incase it was not called in the loop, e.g due to an error.
|
|
811
817
|
if (loop) {
|
|
812
|
-
loop.store?.stop();
|
|
818
|
+
await loop.store?.stop();
|
|
813
819
|
}
|
|
814
820
|
await Promise.all([
|
|
815
821
|
loop?.checkpointerPromises ?? [],
|
package/dist/pregel/loop.cjs
CHANGED
|
@@ -10,7 +10,6 @@ const io_js_1 = require("./io.cjs");
|
|
|
10
10
|
const errors_js_1 = require("../errors.cjs");
|
|
11
11
|
const index_js_1 = require("./utils/index.cjs");
|
|
12
12
|
const debug_js_1 = require("./debug.cjs");
|
|
13
|
-
const batch_js_1 = require("../store/batch.cjs");
|
|
14
13
|
const INPUT_DONE = Symbol.for("INPUT_DONE");
|
|
15
14
|
const INPUT_RESUMING = Symbol.for("INPUT_RESUMING");
|
|
16
15
|
const DEFAULT_LOOP_LIMIT = 25;
|
|
@@ -292,7 +291,7 @@ class PregelLoop {
|
|
|
292
291
|
const stop = step + (config.recursionLimit ?? DEFAULT_LOOP_LIMIT) + 1;
|
|
293
292
|
const checkpointPreviousVersions = { ...checkpoint.channel_versions };
|
|
294
293
|
const store = params.store
|
|
295
|
-
? new
|
|
294
|
+
? new langgraph_checkpoint_1.AsyncBatchedStore(params.store)
|
|
296
295
|
: undefined;
|
|
297
296
|
if (store) {
|
|
298
297
|
// Start the store. This is a batch store, so it will run continuously
|
|
@@ -447,6 +446,7 @@ class PregelLoop {
|
|
|
447
446
|
checkpointer: this.checkpointer,
|
|
448
447
|
isResuming: this.input === INPUT_RESUMING,
|
|
449
448
|
manager,
|
|
449
|
+
store: this.store,
|
|
450
450
|
});
|
|
451
451
|
this.tasks = nextTasks;
|
|
452
452
|
this.taskWritesLeft = Object.values(this.tasks).length - 1;
|
package/dist/pregel/loop.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { RunnableConfig } from "@langchain/core/runnables";
|
|
2
2
|
import type { CallbackManagerForChainRun } from "@langchain/core/callbacks/manager";
|
|
3
|
-
import { BaseCheckpointSaver, Checkpoint, PendingWrite, CheckpointPendingWrite, CheckpointMetadata, All } from "@langchain/langgraph-checkpoint";
|
|
3
|
+
import { BaseCheckpointSaver, Checkpoint, PendingWrite, CheckpointPendingWrite, CheckpointMetadata, All, BaseStore, AsyncBatchedStore } from "@langchain/langgraph-checkpoint";
|
|
4
4
|
import { BaseChannel } from "../channels/base.js";
|
|
5
5
|
import { PregelExecutableTask, StreamMode } from "./types.js";
|
|
6
6
|
import { PregelNode } from "./read.js";
|
|
7
|
-
import { BaseStore } from "../store/base.js";
|
|
8
|
-
import { AsyncBatchedStore } from "../store/batch.js";
|
|
9
7
|
import { ManagedValueMapping } from "../managed/base.js";
|
|
8
|
+
import { LangGraphRunnableConfig } from "./runnable_types.js";
|
|
10
9
|
export type StreamChunk = [string[], StreamMode, unknown];
|
|
11
10
|
export type PregelLoopInitializeParams = {
|
|
12
11
|
input?: any;
|
|
@@ -50,7 +49,7 @@ export declare class StreamProtocol {
|
|
|
50
49
|
export declare class PregelLoop {
|
|
51
50
|
protected input?: any;
|
|
52
51
|
output: any;
|
|
53
|
-
config:
|
|
52
|
+
config: LangGraphRunnableConfig;
|
|
54
53
|
protected checkpointer?: BaseCheckpointSaver;
|
|
55
54
|
protected checkpointerGetNextVersion: (current: number | undefined, channel: BaseChannel) => number;
|
|
56
55
|
channels: Record<string, BaseChannel>;
|
package/dist/pregel/loop.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { copyCheckpoint, emptyCheckpoint, } from "@langchain/langgraph-checkpoint";
|
|
1
|
+
import { copyCheckpoint, emptyCheckpoint, AsyncBatchedStore, } from "@langchain/langgraph-checkpoint";
|
|
2
2
|
import { createCheckpoint, emptyChannels, } from "../channels/base.js";
|
|
3
3
|
import { CHECKPOINT_NAMESPACE_SEPARATOR, CONFIG_KEY_CHECKPOINT_MAP, CONFIG_KEY_READ, CONFIG_KEY_RESUMING, CONFIG_KEY_STREAM, ERROR, INPUT, INTERRUPT, TAG_HIDDEN, TASKS, } from "../constants.js";
|
|
4
4
|
import { _applyWrites, _prepareNextTasks, increment, shouldInterrupt, } from "./algo.js";
|
|
@@ -7,7 +7,6 @@ import { mapInput, mapOutputUpdates, mapOutputValues, readChannels, } from "./io
|
|
|
7
7
|
import { EmptyInputError, GraphInterrupt, isGraphInterrupt, } from "../errors.js";
|
|
8
8
|
import { getNewChannelVersions, patchConfigurable } from "./utils/index.js";
|
|
9
9
|
import { mapDebugTasks, mapDebugCheckpoint, mapDebugTaskResults, } from "./debug.js";
|
|
10
|
-
import { AsyncBatchedStore } from "../store/batch.js";
|
|
11
10
|
const INPUT_DONE = Symbol.for("INPUT_DONE");
|
|
12
11
|
const INPUT_RESUMING = Symbol.for("INPUT_RESUMING");
|
|
13
12
|
const DEFAULT_LOOP_LIMIT = 25;
|
|
@@ -443,6 +442,7 @@ export class PregelLoop {
|
|
|
443
442
|
checkpointer: this.checkpointer,
|
|
444
443
|
isResuming: this.input === INPUT_RESUMING,
|
|
445
444
|
manager,
|
|
445
|
+
store: this.store,
|
|
446
446
|
});
|
|
447
447
|
this.tasks = nextTasks;
|
|
448
448
|
this.taskWritesLeft = Object.values(this.tasks).length - 1;
|
package/dist/pregel/read.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Runnable, RunnableBinding, RunnableBindingArgs, RunnableConfig, RunnableLike } from "@langchain/core/runnables";
|
|
1
|
+
import { Runnable, RunnableBinding, RunnableBindingArgs, RunnableConfig, type RunnableLike } from "@langchain/core/runnables";
|
|
2
2
|
import { RunnableCallable } from "../utils.js";
|
|
3
3
|
import type { RetryPolicy } from "./utils/index.js";
|
|
4
4
|
export declare class ChannelRead<RunInput = any> extends RunnableCallable {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/pregel/types.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Runnable, RunnableConfig } from "@langchain/core/runnables";
|
|
2
|
-
import type { All, PendingWrite, CheckpointMetadata, BaseCheckpointSaver } from "@langchain/langgraph-checkpoint";
|
|
2
|
+
import type { All, PendingWrite, CheckpointMetadata, BaseCheckpointSaver, BaseStore } from "@langchain/langgraph-checkpoint";
|
|
3
3
|
import type { BaseChannel } from "../channels/base.js";
|
|
4
4
|
import type { PregelNode } from "./read.js";
|
|
5
5
|
import { RetryPolicy } from "./utils/index.js";
|
|
6
6
|
import { Interrupt } from "../constants.js";
|
|
7
|
-
import { BaseStore } from "../store/base.js";
|
|
8
7
|
import { type ManagedValueSpec } from "../managed/base.js";
|
|
8
|
+
import { LangGraphRunnableConfig } from "./runnable_types.js";
|
|
9
9
|
export type StreamMode = "values" | "updates" | "debug";
|
|
10
10
|
/**
|
|
11
11
|
* Construct a type with a set of properties K of type T
|
|
@@ -46,7 +46,7 @@ export interface PregelInterface<Nn extends StrRecord<string, PregelNode>, Cc ex
|
|
|
46
46
|
debug?: boolean;
|
|
47
47
|
checkpointer?: BaseCheckpointSaver;
|
|
48
48
|
retryPolicy?: RetryPolicy;
|
|
49
|
-
config?:
|
|
49
|
+
config?: LangGraphRunnableConfig;
|
|
50
50
|
/**
|
|
51
51
|
* Memory store to use for SharedValues.
|
|
52
52
|
*/
|
|
@@ -58,7 +58,7 @@ export interface PregelTaskDescription {
|
|
|
58
58
|
readonly name: string;
|
|
59
59
|
readonly error?: unknown;
|
|
60
60
|
readonly interrupts: Interrupt[];
|
|
61
|
-
readonly state?:
|
|
61
|
+
readonly state?: LangGraphRunnableConfig | StateSnapshot;
|
|
62
62
|
readonly path?: [string, ...(string | number)[]];
|
|
63
63
|
}
|
|
64
64
|
export interface PregelExecutableTask<N extends PropertyKey, C extends PropertyKey> {
|
|
@@ -66,7 +66,7 @@ export interface PregelExecutableTask<N extends PropertyKey, C extends PropertyK
|
|
|
66
66
|
readonly input: unknown;
|
|
67
67
|
readonly proc: Runnable;
|
|
68
68
|
readonly writes: PendingWrite<C>[];
|
|
69
|
-
readonly config?:
|
|
69
|
+
readonly config?: LangGraphRunnableConfig;
|
|
70
70
|
readonly triggers: Array<string>;
|
|
71
71
|
readonly retry_policy?: RetryPolicy;
|
|
72
72
|
readonly id: string;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { RunnableConfig } from "@langchain/core/runnables";
|
|
2
|
-
|
|
2
|
+
import { LangGraphRunnableConfig } from "../runnable_types.js";
|
|
3
|
+
export declare function ensureLangGraphConfig(...configs: (LangGraphRunnableConfig | undefined)[]): RunnableConfig;
|
package/dist/web.cjs
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.BaseCheckpointSaver = exports.emptyCheckpoint = exports.copyCheckpoint = exports.MemorySaver = exports.Send = exports.BinaryOperatorAggregate = exports.BaseChannel = exports.Annotation = exports.messagesStateReducer = exports.MessageGraph = exports.StateGraph = exports.START = exports.Graph = exports.END = void 0;
|
|
17
|
+
exports.MemoryStore = exports.AsyncBatchedStore = exports.BaseStore = exports.BaseCheckpointSaver = exports.emptyCheckpoint = exports.copyCheckpoint = exports.MemorySaver = exports.Send = exports.BinaryOperatorAggregate = exports.BaseChannel = exports.Annotation = exports.messagesStateReducer = exports.MessageGraph = exports.StateGraph = exports.START = exports.Graph = exports.END = void 0;
|
|
18
18
|
var index_js_1 = require("./graph/index.cjs");
|
|
19
19
|
Object.defineProperty(exports, "END", { enumerable: true, get: function () { return index_js_1.END; } });
|
|
20
20
|
Object.defineProperty(exports, "Graph", { enumerable: true, get: function () { return index_js_1.Graph; } });
|
|
@@ -34,5 +34,7 @@ Object.defineProperty(exports, "MemorySaver", { enumerable: true, get: function
|
|
|
34
34
|
Object.defineProperty(exports, "copyCheckpoint", { enumerable: true, get: function () { return langgraph_checkpoint_1.copyCheckpoint; } });
|
|
35
35
|
Object.defineProperty(exports, "emptyCheckpoint", { enumerable: true, get: function () { return langgraph_checkpoint_1.emptyCheckpoint; } });
|
|
36
36
|
Object.defineProperty(exports, "BaseCheckpointSaver", { enumerable: true, get: function () { return langgraph_checkpoint_1.BaseCheckpointSaver; } });
|
|
37
|
-
|
|
37
|
+
Object.defineProperty(exports, "BaseStore", { enumerable: true, get: function () { return langgraph_checkpoint_1.BaseStore; } });
|
|
38
|
+
Object.defineProperty(exports, "AsyncBatchedStore", { enumerable: true, get: function () { return langgraph_checkpoint_1.AsyncBatchedStore; } });
|
|
39
|
+
Object.defineProperty(exports, "MemoryStore", { enumerable: true, get: function () { return langgraph_checkpoint_1.MemoryStore; } });
|
|
38
40
|
__exportStar(require("./managed/index.cjs"), exports);
|
package/dist/web.d.ts
CHANGED
|
@@ -5,6 +5,6 @@ export { BaseChannel, type BinaryOperator, BinaryOperatorAggregate, type AnyValu
|
|
|
5
5
|
export { type AnnotationRoot as _INTERNAL_ANNOTATION_ROOT } from "./graph/index.js";
|
|
6
6
|
export { type RetryPolicy } from "./pregel/utils/index.js";
|
|
7
7
|
export { Send } from "./constants.js";
|
|
8
|
-
export { MemorySaver, type Checkpoint, type CheckpointMetadata, type CheckpointTuple, copyCheckpoint, emptyCheckpoint, BaseCheckpointSaver, } from "@langchain/langgraph-checkpoint";
|
|
9
|
-
export * from "./store/index.js";
|
|
8
|
+
export { MemorySaver, type Checkpoint, type CheckpointMetadata, type CheckpointTuple, copyCheckpoint, emptyCheckpoint, BaseCheckpointSaver, type Item, type GetOperation, type SearchOperation, type PutOperation, type Operation, type OperationResults, BaseStore, AsyncBatchedStore, MemoryStore, type NameSpacePath, type NamespaceMatchType, type MatchCondition, type ListNamespacesOperation, } from "@langchain/langgraph-checkpoint";
|
|
10
9
|
export * from "./managed/index.js";
|
|
10
|
+
export { type LangGraphRunnableConfig } from "./pregel/runnable_types.js";
|
package/dist/web.js
CHANGED
|
@@ -2,6 +2,5 @@ export { END, Graph, START, StateGraph, MessageGraph, messagesStateReducer, Anno
|
|
|
2
2
|
export * from "./errors.js";
|
|
3
3
|
export { BaseChannel, BinaryOperatorAggregate, } from "./channels/index.js";
|
|
4
4
|
export { Send } from "./constants.js";
|
|
5
|
-
export { MemorySaver, copyCheckpoint, emptyCheckpoint, BaseCheckpointSaver, } from "@langchain/langgraph-checkpoint";
|
|
6
|
-
export * from "./store/index.js";
|
|
5
|
+
export { MemorySaver, copyCheckpoint, emptyCheckpoint, BaseCheckpointSaver, BaseStore, AsyncBatchedStore, MemoryStore, } from "@langchain/langgraph-checkpoint";
|
|
7
6
|
export * from "./managed/index.js";
|
package/package.json
CHANGED
package/dist/store/base.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseStore = void 0;
|
|
4
|
-
class BaseStore {
|
|
5
|
-
stop() {
|
|
6
|
-
// no-op if not implemented.
|
|
7
|
-
}
|
|
8
|
-
start() {
|
|
9
|
-
// no-op if not implemented.
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
exports.BaseStore = BaseStore;
|
package/dist/store/base.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export type Values = Record<string, any>;
|
|
2
|
-
export declare abstract class BaseStore {
|
|
3
|
-
abstract list(prefixes: string[]): Promise<Record<string, Record<string, Values>>>;
|
|
4
|
-
abstract put(writes: Array<[string, string, Values | null]>): Promise<void>;
|
|
5
|
-
stop(): void;
|
|
6
|
-
start(): void;
|
|
7
|
-
}
|
package/dist/store/base.js
DELETED
package/dist/store/batch.cjs
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AsyncBatchedStore = void 0;
|
|
4
|
-
const base_js_1 = require("./base.cjs");
|
|
5
|
-
/**
|
|
6
|
-
* AsyncBatchedStore extends BaseStore to provide batched operations for list and put methods.
|
|
7
|
-
* It queues operations and processes them in batches for improved efficiency. This store is
|
|
8
|
-
* designed to run for the full duration of the process, or until `stop()` is called.
|
|
9
|
-
*/
|
|
10
|
-
class AsyncBatchedStore extends base_js_1.BaseStore {
|
|
11
|
-
get isRunning() {
|
|
12
|
-
return this.running;
|
|
13
|
-
}
|
|
14
|
-
constructor(store) {
|
|
15
|
-
super();
|
|
16
|
-
/**
|
|
17
|
-
* The store to batch operations for.
|
|
18
|
-
* @type {BaseStore}
|
|
19
|
-
*/
|
|
20
|
-
Object.defineProperty(this, "store", {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
configurable: true,
|
|
23
|
-
writable: true,
|
|
24
|
-
value: void 0
|
|
25
|
-
});
|
|
26
|
-
/**
|
|
27
|
-
* A queue of operations to be processed in batch.
|
|
28
|
-
* @type {QueueItem[]}
|
|
29
|
-
*/
|
|
30
|
-
Object.defineProperty(this, "queue", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
configurable: true,
|
|
33
|
-
writable: true,
|
|
34
|
-
value: []
|
|
35
|
-
});
|
|
36
|
-
/**
|
|
37
|
-
* Whether or not the batched processing is currently running.
|
|
38
|
-
* @type {boolean}
|
|
39
|
-
* @default {false}
|
|
40
|
-
*/
|
|
41
|
-
Object.defineProperty(this, "running", {
|
|
42
|
-
enumerable: true,
|
|
43
|
-
configurable: true,
|
|
44
|
-
writable: true,
|
|
45
|
-
value: false
|
|
46
|
-
});
|
|
47
|
-
this.store = store;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Queues a list operation to be processed in batch.
|
|
51
|
-
* @param {string[]} prefixes An array of prefixes to list.
|
|
52
|
-
* @returns {Promise<Record<string, Record<string, Values>>>} A promise that resolves with the list results.
|
|
53
|
-
*/
|
|
54
|
-
async list(prefixes) {
|
|
55
|
-
return new Promise((resolve, reject) => {
|
|
56
|
-
this.queue.push({ resolve, reject, op: { prefixes } });
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Queues a put operation to be processed in batch.
|
|
61
|
-
* @param {Array<[string, string, Values | null]>} writes An array of write operations to be performed.
|
|
62
|
-
* @returns {Promise<void>} A promise that resolves when the put operation is complete.
|
|
63
|
-
*/
|
|
64
|
-
async put(writes) {
|
|
65
|
-
return new Promise((resolve, reject) => {
|
|
66
|
-
this.queue.push({ resolve, reject, op: { writes } });
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Start running the batched processing of operations.
|
|
71
|
-
* This process will run continuously until the store is stopped,
|
|
72
|
-
* which can be done by calling the `stop()` method.
|
|
73
|
-
*/
|
|
74
|
-
start() {
|
|
75
|
-
this.running = true;
|
|
76
|
-
void this.processBatchQueue();
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Stops the batched processing of operations.
|
|
80
|
-
*/
|
|
81
|
-
stop() {
|
|
82
|
-
this.running = false;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Runs the task that processes queued operations in batches.
|
|
86
|
-
* This method runs continuously until the store is stopped,
|
|
87
|
-
* or the process is terminated.
|
|
88
|
-
* @returns {Promise<void>} A promise that resolves when the task is complete.
|
|
89
|
-
*/
|
|
90
|
-
async processBatchQueue() {
|
|
91
|
-
while (this.running) {
|
|
92
|
-
await new Promise((resolve) => {
|
|
93
|
-
setTimeout(resolve, 0);
|
|
94
|
-
});
|
|
95
|
-
if (this.queue.length === 0)
|
|
96
|
-
continue;
|
|
97
|
-
const taken = this.queue.splice(0);
|
|
98
|
-
const lists = taken.filter((item) => "prefixes" in item.op);
|
|
99
|
-
if (lists.length > 0) {
|
|
100
|
-
try {
|
|
101
|
-
const allPrefixes = lists.flatMap((item) => item.op.prefixes);
|
|
102
|
-
const results = await this.store.list(allPrefixes);
|
|
103
|
-
lists.forEach((item) => {
|
|
104
|
-
const { prefixes } = item.op;
|
|
105
|
-
item.resolve(Object.fromEntries(prefixes.map((p) => [p, results[p] || {}])));
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
catch (e) {
|
|
109
|
-
lists.forEach((item) => item.reject(e));
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
const puts = taken.filter((item) => "writes" in item.op);
|
|
113
|
-
if (puts.length > 0) {
|
|
114
|
-
try {
|
|
115
|
-
const allWrites = puts.flatMap((item) => item.op.writes);
|
|
116
|
-
await this.store.put(allWrites);
|
|
117
|
-
puts.forEach((item) => item.resolve());
|
|
118
|
-
}
|
|
119
|
-
catch (e) {
|
|
120
|
-
puts.forEach((item) => item.reject(e));
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
exports.AsyncBatchedStore = AsyncBatchedStore;
|
package/dist/store/batch.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { BaseStore, type Values } from "./base.js";
|
|
2
|
-
/**
|
|
3
|
-
* AsyncBatchedStore extends BaseStore to provide batched operations for list and put methods.
|
|
4
|
-
* It queues operations and processes them in batches for improved efficiency. This store is
|
|
5
|
-
* designed to run for the full duration of the process, or until `stop()` is called.
|
|
6
|
-
*/
|
|
7
|
-
export declare class AsyncBatchedStore extends BaseStore {
|
|
8
|
-
/**
|
|
9
|
-
* The store to batch operations for.
|
|
10
|
-
* @type {BaseStore}
|
|
11
|
-
*/
|
|
12
|
-
private store;
|
|
13
|
-
/**
|
|
14
|
-
* A queue of operations to be processed in batch.
|
|
15
|
-
* @type {QueueItem[]}
|
|
16
|
-
*/
|
|
17
|
-
private queue;
|
|
18
|
-
/**
|
|
19
|
-
* Whether or not the batched processing is currently running.
|
|
20
|
-
* @type {boolean}
|
|
21
|
-
* @default {false}
|
|
22
|
-
*/
|
|
23
|
-
private running;
|
|
24
|
-
get isRunning(): boolean;
|
|
25
|
-
constructor(store: BaseStore);
|
|
26
|
-
/**
|
|
27
|
-
* Queues a list operation to be processed in batch.
|
|
28
|
-
* @param {string[]} prefixes An array of prefixes to list.
|
|
29
|
-
* @returns {Promise<Record<string, Record<string, Values>>>} A promise that resolves with the list results.
|
|
30
|
-
*/
|
|
31
|
-
list(prefixes: string[]): Promise<Record<string, Record<string, Values>>>;
|
|
32
|
-
/**
|
|
33
|
-
* Queues a put operation to be processed in batch.
|
|
34
|
-
* @param {Array<[string, string, Values | null]>} writes An array of write operations to be performed.
|
|
35
|
-
* @returns {Promise<void>} A promise that resolves when the put operation is complete.
|
|
36
|
-
*/
|
|
37
|
-
put(writes: Array<[string, string, Values | null]>): Promise<void>;
|
|
38
|
-
/**
|
|
39
|
-
* Start running the batched processing of operations.
|
|
40
|
-
* This process will run continuously until the store is stopped,
|
|
41
|
-
* which can be done by calling the `stop()` method.
|
|
42
|
-
*/
|
|
43
|
-
start(): void;
|
|
44
|
-
/**
|
|
45
|
-
* Stops the batched processing of operations.
|
|
46
|
-
*/
|
|
47
|
-
stop(): void;
|
|
48
|
-
/**
|
|
49
|
-
* Runs the task that processes queued operations in batches.
|
|
50
|
-
* This method runs continuously until the store is stopped,
|
|
51
|
-
* or the process is terminated.
|
|
52
|
-
* @returns {Promise<void>} A promise that resolves when the task is complete.
|
|
53
|
-
*/
|
|
54
|
-
private processBatchQueue;
|
|
55
|
-
}
|
package/dist/store/batch.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { BaseStore } from "./base.js";
|
|
2
|
-
/**
|
|
3
|
-
* AsyncBatchedStore extends BaseStore to provide batched operations for list and put methods.
|
|
4
|
-
* It queues operations and processes them in batches for improved efficiency. This store is
|
|
5
|
-
* designed to run for the full duration of the process, or until `stop()` is called.
|
|
6
|
-
*/
|
|
7
|
-
export class AsyncBatchedStore extends BaseStore {
|
|
8
|
-
get isRunning() {
|
|
9
|
-
return this.running;
|
|
10
|
-
}
|
|
11
|
-
constructor(store) {
|
|
12
|
-
super();
|
|
13
|
-
/**
|
|
14
|
-
* The store to batch operations for.
|
|
15
|
-
* @type {BaseStore}
|
|
16
|
-
*/
|
|
17
|
-
Object.defineProperty(this, "store", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
configurable: true,
|
|
20
|
-
writable: true,
|
|
21
|
-
value: void 0
|
|
22
|
-
});
|
|
23
|
-
/**
|
|
24
|
-
* A queue of operations to be processed in batch.
|
|
25
|
-
* @type {QueueItem[]}
|
|
26
|
-
*/
|
|
27
|
-
Object.defineProperty(this, "queue", {
|
|
28
|
-
enumerable: true,
|
|
29
|
-
configurable: true,
|
|
30
|
-
writable: true,
|
|
31
|
-
value: []
|
|
32
|
-
});
|
|
33
|
-
/**
|
|
34
|
-
* Whether or not the batched processing is currently running.
|
|
35
|
-
* @type {boolean}
|
|
36
|
-
* @default {false}
|
|
37
|
-
*/
|
|
38
|
-
Object.defineProperty(this, "running", {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
configurable: true,
|
|
41
|
-
writable: true,
|
|
42
|
-
value: false
|
|
43
|
-
});
|
|
44
|
-
this.store = store;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Queues a list operation to be processed in batch.
|
|
48
|
-
* @param {string[]} prefixes An array of prefixes to list.
|
|
49
|
-
* @returns {Promise<Record<string, Record<string, Values>>>} A promise that resolves with the list results.
|
|
50
|
-
*/
|
|
51
|
-
async list(prefixes) {
|
|
52
|
-
return new Promise((resolve, reject) => {
|
|
53
|
-
this.queue.push({ resolve, reject, op: { prefixes } });
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Queues a put operation to be processed in batch.
|
|
58
|
-
* @param {Array<[string, string, Values | null]>} writes An array of write operations to be performed.
|
|
59
|
-
* @returns {Promise<void>} A promise that resolves when the put operation is complete.
|
|
60
|
-
*/
|
|
61
|
-
async put(writes) {
|
|
62
|
-
return new Promise((resolve, reject) => {
|
|
63
|
-
this.queue.push({ resolve, reject, op: { writes } });
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Start running the batched processing of operations.
|
|
68
|
-
* This process will run continuously until the store is stopped,
|
|
69
|
-
* which can be done by calling the `stop()` method.
|
|
70
|
-
*/
|
|
71
|
-
start() {
|
|
72
|
-
this.running = true;
|
|
73
|
-
void this.processBatchQueue();
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Stops the batched processing of operations.
|
|
77
|
-
*/
|
|
78
|
-
stop() {
|
|
79
|
-
this.running = false;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Runs the task that processes queued operations in batches.
|
|
83
|
-
* This method runs continuously until the store is stopped,
|
|
84
|
-
* or the process is terminated.
|
|
85
|
-
* @returns {Promise<void>} A promise that resolves when the task is complete.
|
|
86
|
-
*/
|
|
87
|
-
async processBatchQueue() {
|
|
88
|
-
while (this.running) {
|
|
89
|
-
await new Promise((resolve) => {
|
|
90
|
-
setTimeout(resolve, 0);
|
|
91
|
-
});
|
|
92
|
-
if (this.queue.length === 0)
|
|
93
|
-
continue;
|
|
94
|
-
const taken = this.queue.splice(0);
|
|
95
|
-
const lists = taken.filter((item) => "prefixes" in item.op);
|
|
96
|
-
if (lists.length > 0) {
|
|
97
|
-
try {
|
|
98
|
-
const allPrefixes = lists.flatMap((item) => item.op.prefixes);
|
|
99
|
-
const results = await this.store.list(allPrefixes);
|
|
100
|
-
lists.forEach((item) => {
|
|
101
|
-
const { prefixes } = item.op;
|
|
102
|
-
item.resolve(Object.fromEntries(prefixes.map((p) => [p, results[p] || {}])));
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
catch (e) {
|
|
106
|
-
lists.forEach((item) => item.reject(e));
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
const puts = taken.filter((item) => "writes" in item.op);
|
|
110
|
-
if (puts.length > 0) {
|
|
111
|
-
try {
|
|
112
|
-
const allWrites = puts.flatMap((item) => item.op.writes);
|
|
113
|
-
await this.store.put(allWrites);
|
|
114
|
-
puts.forEach((item) => item.resolve());
|
|
115
|
-
}
|
|
116
|
-
catch (e) {
|
|
117
|
-
puts.forEach((item) => item.reject(e));
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
package/dist/store/index.cjs
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./base.cjs"), exports);
|
|
18
|
-
__exportStar(require("./batch.cjs"), exports);
|
|
19
|
-
__exportStar(require("./memory.cjs"), exports);
|
package/dist/store/index.d.ts
DELETED
package/dist/store/index.js
DELETED
package/dist/store/memory.cjs
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MemoryStore = void 0;
|
|
4
|
-
const base_js_1 = require("./base.cjs");
|
|
5
|
-
class MemoryStore extends base_js_1.BaseStore {
|
|
6
|
-
constructor() {
|
|
7
|
-
super(...arguments);
|
|
8
|
-
Object.defineProperty(this, "data", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
configurable: true,
|
|
11
|
-
writable: true,
|
|
12
|
-
value: new Map()
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
async list(prefixes) {
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
-
const result = {};
|
|
18
|
-
for (const prefix of prefixes) {
|
|
19
|
-
if (this.data.has(prefix)) {
|
|
20
|
-
result[prefix] = Object.fromEntries(this.data.get(prefix));
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
result[prefix] = {};
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return Promise.resolve(result);
|
|
27
|
-
}
|
|
28
|
-
async put(writes) {
|
|
29
|
-
for (const [namespace, key, value] of writes) {
|
|
30
|
-
if (!this.data.has(namespace)) {
|
|
31
|
-
this.data.set(namespace, new Map());
|
|
32
|
-
}
|
|
33
|
-
const namespaceMap = this.data.get(namespace);
|
|
34
|
-
if (value === null) {
|
|
35
|
-
namespaceMap.delete(key);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
namespaceMap.set(key, value);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.MemoryStore = MemoryStore;
|
package/dist/store/memory.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { BaseStore, type Values } from "./base.js";
|
|
2
|
-
export declare class MemoryStore extends BaseStore {
|
|
3
|
-
private data;
|
|
4
|
-
list(prefixes: string[]): Promise<Record<string, Record<string, Values>>>;
|
|
5
|
-
put(writes: Array<[string, string, Values | null]>): Promise<void>;
|
|
6
|
-
}
|
package/dist/store/memory.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { BaseStore } from "./base.js";
|
|
2
|
-
export class MemoryStore extends BaseStore {
|
|
3
|
-
constructor() {
|
|
4
|
-
super(...arguments);
|
|
5
|
-
Object.defineProperty(this, "data", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
configurable: true,
|
|
8
|
-
writable: true,
|
|
9
|
-
value: new Map()
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
async list(prefixes) {
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
-
const result = {};
|
|
15
|
-
for (const prefix of prefixes) {
|
|
16
|
-
if (this.data.has(prefix)) {
|
|
17
|
-
result[prefix] = Object.fromEntries(this.data.get(prefix));
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
result[prefix] = {};
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return Promise.resolve(result);
|
|
24
|
-
}
|
|
25
|
-
async put(writes) {
|
|
26
|
-
for (const [namespace, key, value] of writes) {
|
|
27
|
-
if (!this.data.has(namespace)) {
|
|
28
|
-
this.data.set(namespace, new Map());
|
|
29
|
-
}
|
|
30
|
-
const namespaceMap = this.data.get(namespace);
|
|
31
|
-
if (value === null) {
|
|
32
|
-
namespaceMap.delete(key);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
namespaceMap.set(key, value);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|