@langchain/langgraph 0.0.1

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.
Files changed (84) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +588 -0
  3. package/dist/channels/base.cjs +58 -0
  4. package/dist/channels/base.d.ts +46 -0
  5. package/dist/channels/base.js +50 -0
  6. package/dist/channels/binop.cjs +70 -0
  7. package/dist/channels/binop.d.ts +16 -0
  8. package/dist/channels/binop.js +66 -0
  9. package/dist/channels/index.cjs +9 -0
  10. package/dist/channels/index.d.ts +1 -0
  11. package/dist/channels/index.js +1 -0
  12. package/dist/channels/last_value.cjs +53 -0
  13. package/dist/channels/last_value.d.ts +12 -0
  14. package/dist/channels/last_value.js +49 -0
  15. package/dist/channels/topic.cjs +90 -0
  16. package/dist/channels/topic.d.ts +19 -0
  17. package/dist/channels/topic.js +86 -0
  18. package/dist/checkpoint/base.cjs +32 -0
  19. package/dist/checkpoint/base.d.ts +47 -0
  20. package/dist/checkpoint/base.js +27 -0
  21. package/dist/checkpoint/index.cjs +8 -0
  22. package/dist/checkpoint/index.d.ts +2 -0
  23. package/dist/checkpoint/index.js +2 -0
  24. package/dist/checkpoint/memory.cjs +35 -0
  25. package/dist/checkpoint/memory.d.ts +8 -0
  26. package/dist/checkpoint/memory.js +31 -0
  27. package/dist/constants.cjs +5 -0
  28. package/dist/constants.d.ts +2 -0
  29. package/dist/constants.js +2 -0
  30. package/dist/graph/graph.cjs +175 -0
  31. package/dist/graph/graph.d.ts +30 -0
  32. package/dist/graph/graph.js +171 -0
  33. package/dist/graph/index.cjs +9 -0
  34. package/dist/graph/index.d.ts +2 -0
  35. package/dist/graph/index.js +2 -0
  36. package/dist/graph/state.cjs +108 -0
  37. package/dist/graph/state.d.ts +17 -0
  38. package/dist/graph/state.js +104 -0
  39. package/dist/index.cjs +8 -0
  40. package/dist/index.d.ts +1 -0
  41. package/dist/index.js +1 -0
  42. package/dist/prebuilt/agent_executor.cjs +96 -0
  43. package/dist/prebuilt/agent_executor.d.ts +12 -0
  44. package/dist/prebuilt/agent_executor.js +92 -0
  45. package/dist/prebuilt/chat_agent_executor.cjs +130 -0
  46. package/dist/prebuilt/chat_agent_executor.d.ts +6 -0
  47. package/dist/prebuilt/chat_agent_executor.js +126 -0
  48. package/dist/prebuilt/index.cjs +9 -0
  49. package/dist/prebuilt/index.d.ts +3 -0
  50. package/dist/prebuilt/index.js +3 -0
  51. package/dist/prebuilt/tool_executor.cjs +63 -0
  52. package/dist/prebuilt/tool_executor.d.ts +27 -0
  53. package/dist/prebuilt/tool_executor.js +59 -0
  54. package/dist/pregel/debug.cjs +46 -0
  55. package/dist/pregel/debug.d.ts +4 -0
  56. package/dist/pregel/debug.js +41 -0
  57. package/dist/pregel/index.cjs +475 -0
  58. package/dist/pregel/index.d.ts +75 -0
  59. package/dist/pregel/index.js +469 -0
  60. package/dist/pregel/io.cjs +57 -0
  61. package/dist/pregel/io.d.ts +9 -0
  62. package/dist/pregel/io.js +52 -0
  63. package/dist/pregel/read.cjs +217 -0
  64. package/dist/pregel/read.d.ts +43 -0
  65. package/dist/pregel/read.js +211 -0
  66. package/dist/pregel/reserved.cjs +7 -0
  67. package/dist/pregel/reserved.d.ts +3 -0
  68. package/dist/pregel/reserved.js +4 -0
  69. package/dist/pregel/validate.cjs +90 -0
  70. package/dist/pregel/validate.d.ts +15 -0
  71. package/dist/pregel/validate.js +85 -0
  72. package/dist/pregel/write.cjs +54 -0
  73. package/dist/pregel/write.d.ts +13 -0
  74. package/dist/pregel/write.js +50 -0
  75. package/index.cjs +1 -0
  76. package/index.d.ts +1 -0
  77. package/index.js +1 -0
  78. package/package.json +100 -0
  79. package/prebuilt.cjs +1 -0
  80. package/prebuilt.d.ts +1 -0
  81. package/prebuilt.js +1 -0
  82. package/pregel.cjs +1 -0
  83. package/pregel.d.ts +1 -0
  84. package/pregel.js +1 -0
@@ -0,0 +1,46 @@
1
+ import { Checkpoint } from "../checkpoint/index.js";
2
+ export declare abstract class BaseChannel<Value = unknown, Update = unknown, C = unknown> {
3
+ /**
4
+ * The name of the channel.
5
+ */
6
+ abstract lc_graph_name: string;
7
+ /**
8
+ * Return a new identical channel, optionally initialized from a checkpoint.
9
+ *
10
+ * @param {C | undefined} checkpoint
11
+ * @param {C | undefined} initialValue
12
+ * @returns {this}
13
+ */
14
+ abstract empty(checkpoint?: C, initialValueFactory?: () => C): BaseChannel<Value, Update, C>;
15
+ /**
16
+ * Update the channel's value with the given sequence of updates.
17
+ * The order of the updates in the sequence is arbitrary.
18
+ *
19
+ * @throws {InvalidUpdateError} if the sequence of updates is invalid.
20
+ * @param {Array<Update>} values
21
+ * @returns {void}
22
+ */
23
+ abstract update(values: Update[]): void;
24
+ /**
25
+ * Return the current value of the channel.
26
+ *
27
+ * @throws {EmptyChannelError} if the channel is empty (never updated yet).
28
+ * @returns {Value}
29
+ */
30
+ abstract get(): Value;
31
+ /**
32
+ * Return a string representation of the channel's current state.
33
+ *
34
+ * @throws {EmptyChannelError} if the channel is empty (never updated yet), or doesn't support checkpoints.
35
+ * @returns {C | undefined}
36
+ */
37
+ abstract checkpoint(): C | undefined;
38
+ }
39
+ export declare class EmptyChannelError extends Error {
40
+ constructor(message?: string);
41
+ }
42
+ export declare class InvalidUpdateError extends Error {
43
+ constructor(message?: string);
44
+ }
45
+ export declare function emptyChannels(channels: Record<string, BaseChannel>, checkpoint: Checkpoint): Record<string, BaseChannel>;
46
+ export declare function createCheckpoint<Value>(checkpoint: Checkpoint, channels: Record<string, BaseChannel<Value>>): Promise<Checkpoint>;
@@ -0,0 +1,50 @@
1
+ export class BaseChannel {
2
+ }
3
+ export class EmptyChannelError extends Error {
4
+ constructor(message) {
5
+ super(message);
6
+ this.name = "EmptyChannelError";
7
+ }
8
+ }
9
+ export class InvalidUpdateError extends Error {
10
+ constructor(message) {
11
+ super(message);
12
+ this.name = "InvalidUpdateError";
13
+ }
14
+ }
15
+ export function emptyChannels(channels, checkpoint) {
16
+ const newChannels = {};
17
+ for (const k in channels) {
18
+ if (Object.prototype.hasOwnProperty.call(channels, k)) {
19
+ const channelValue = checkpoint.channelValues[k];
20
+ newChannels[k] = channels[k].empty(channelValue);
21
+ }
22
+ }
23
+ return newChannels;
24
+ }
25
+ export async function createCheckpoint(checkpoint, channels) {
26
+ const newCheckpoint = {
27
+ v: 1,
28
+ ts: new Date().toISOString(),
29
+ channelValues: { ...checkpoint.channelValues },
30
+ channelVersions: { ...checkpoint.channelVersions },
31
+ versionsSeen: { ...checkpoint.versionsSeen },
32
+ };
33
+ for (const k in channels) {
34
+ if (newCheckpoint.channelValues[k] === undefined) {
35
+ try {
36
+ newCheckpoint.channelValues[k] = await channels[k].checkpoint();
37
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
+ }
39
+ catch (error) {
40
+ if ("name" in error && error.name === EmptyChannelError.name) {
41
+ // no-op
42
+ }
43
+ else {
44
+ throw error; // Rethrow unexpected errors
45
+ }
46
+ }
47
+ }
48
+ }
49
+ return newCheckpoint;
50
+ }
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BinaryOperatorAggregate = void 0;
4
+ const index_js_1 = require("./index.cjs");
5
+ /**
6
+ * Stores the result of applying a binary operator to the current value and each new value.
7
+ */
8
+ class BinaryOperatorAggregate extends index_js_1.BaseChannel {
9
+ constructor(operator, initialValueFactory) {
10
+ super();
11
+ Object.defineProperty(this, "lc_graph_name", {
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true,
15
+ value: "BinaryOperatorAggregate"
16
+ });
17
+ Object.defineProperty(this, "value", {
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true,
21
+ value: void 0
22
+ });
23
+ Object.defineProperty(this, "operator", {
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true,
27
+ value: void 0
28
+ });
29
+ Object.defineProperty(this, "initialValueFactory", {
30
+ enumerable: true,
31
+ configurable: true,
32
+ writable: true,
33
+ value: void 0
34
+ });
35
+ this.operator = operator;
36
+ this.initialValueFactory = initialValueFactory;
37
+ this.value = initialValueFactory?.();
38
+ }
39
+ empty(_) {
40
+ const empty = new BinaryOperatorAggregate(this.operator, this.initialValueFactory);
41
+ return empty;
42
+ }
43
+ update(values) {
44
+ let newValues = values;
45
+ if (!newValues.length)
46
+ return;
47
+ if (this.value === undefined) {
48
+ [this.value] = newValues;
49
+ newValues = newValues.slice(1);
50
+ }
51
+ for (const value of newValues) {
52
+ if (this.value !== undefined) {
53
+ this.value = this.operator(this.value, value);
54
+ }
55
+ }
56
+ }
57
+ get() {
58
+ if (this.value === undefined) {
59
+ throw new index_js_1.EmptyChannelError();
60
+ }
61
+ return this.value;
62
+ }
63
+ checkpoint() {
64
+ if (!this.value) {
65
+ throw new index_js_1.EmptyChannelError();
66
+ }
67
+ return this.value;
68
+ }
69
+ }
70
+ exports.BinaryOperatorAggregate = BinaryOperatorAggregate;
@@ -0,0 +1,16 @@
1
+ import { BaseChannel } from "./index.js";
2
+ export type BinaryOperator<Value> = (a: Value, b: Value) => Value;
3
+ /**
4
+ * Stores the result of applying a binary operator to the current value and each new value.
5
+ */
6
+ export declare class BinaryOperatorAggregate<Value> extends BaseChannel<Value, Value, Value> {
7
+ lc_graph_name: string;
8
+ value: Value | undefined;
9
+ operator: BinaryOperator<Value>;
10
+ initialValueFactory?: () => Value;
11
+ constructor(operator: BinaryOperator<Value>, initialValueFactory?: () => Value);
12
+ empty(_?: Value): BinaryOperatorAggregate<Value>;
13
+ update(values: Value[]): void;
14
+ get(): Value;
15
+ checkpoint(): Value;
16
+ }
@@ -0,0 +1,66 @@
1
+ import { BaseChannel, EmptyChannelError } from "./index.js";
2
+ /**
3
+ * Stores the result of applying a binary operator to the current value and each new value.
4
+ */
5
+ export class BinaryOperatorAggregate extends BaseChannel {
6
+ constructor(operator, initialValueFactory) {
7
+ super();
8
+ Object.defineProperty(this, "lc_graph_name", {
9
+ enumerable: true,
10
+ configurable: true,
11
+ writable: true,
12
+ value: "BinaryOperatorAggregate"
13
+ });
14
+ Object.defineProperty(this, "value", {
15
+ enumerable: true,
16
+ configurable: true,
17
+ writable: true,
18
+ value: void 0
19
+ });
20
+ Object.defineProperty(this, "operator", {
21
+ enumerable: true,
22
+ configurable: true,
23
+ writable: true,
24
+ value: void 0
25
+ });
26
+ Object.defineProperty(this, "initialValueFactory", {
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true,
30
+ value: void 0
31
+ });
32
+ this.operator = operator;
33
+ this.initialValueFactory = initialValueFactory;
34
+ this.value = initialValueFactory?.();
35
+ }
36
+ empty(_) {
37
+ const empty = new BinaryOperatorAggregate(this.operator, this.initialValueFactory);
38
+ return empty;
39
+ }
40
+ update(values) {
41
+ let newValues = values;
42
+ if (!newValues.length)
43
+ return;
44
+ if (this.value === undefined) {
45
+ [this.value] = newValues;
46
+ newValues = newValues.slice(1);
47
+ }
48
+ for (const value of newValues) {
49
+ if (this.value !== undefined) {
50
+ this.value = this.operator(this.value, value);
51
+ }
52
+ }
53
+ }
54
+ get() {
55
+ if (this.value === undefined) {
56
+ throw new EmptyChannelError();
57
+ }
58
+ return this.value;
59
+ }
60
+ checkpoint() {
61
+ if (!this.value) {
62
+ throw new EmptyChannelError();
63
+ }
64
+ return this.value;
65
+ }
66
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.empty = exports.createCheckpoint = exports.InvalidUpdateError = exports.EmptyChannelError = exports.BaseChannel = void 0;
4
+ var base_js_1 = require("./base.cjs");
5
+ Object.defineProperty(exports, "BaseChannel", { enumerable: true, get: function () { return base_js_1.BaseChannel; } });
6
+ Object.defineProperty(exports, "EmptyChannelError", { enumerable: true, get: function () { return base_js_1.EmptyChannelError; } });
7
+ Object.defineProperty(exports, "InvalidUpdateError", { enumerable: true, get: function () { return base_js_1.InvalidUpdateError; } });
8
+ Object.defineProperty(exports, "createCheckpoint", { enumerable: true, get: function () { return base_js_1.createCheckpoint; } });
9
+ Object.defineProperty(exports, "empty", { enumerable: true, get: function () { return base_js_1.emptyChannels; } });
@@ -0,0 +1 @@
1
+ export { BaseChannel, EmptyChannelError, InvalidUpdateError, createCheckpoint, emptyChannels as empty, } from "./base.js";
@@ -0,0 +1 @@
1
+ export { BaseChannel, EmptyChannelError, InvalidUpdateError, createCheckpoint, emptyChannels as empty, } from "./base.js";
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LastValue = void 0;
4
+ const index_js_1 = require("./index.cjs");
5
+ /**
6
+ * Stores the last value received, can receive at most one value per step.
7
+ */
8
+ class LastValue extends index_js_1.BaseChannel {
9
+ constructor() {
10
+ super(...arguments);
11
+ Object.defineProperty(this, "lc_graph_name", {
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true,
15
+ value: "LastValue"
16
+ });
17
+ Object.defineProperty(this, "value", {
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true,
21
+ value: void 0
22
+ });
23
+ }
24
+ empty(checkpoint) {
25
+ const empty = new LastValue();
26
+ if (checkpoint) {
27
+ empty.value = checkpoint;
28
+ }
29
+ return empty;
30
+ }
31
+ update(values) {
32
+ if (values.length === 0) {
33
+ return;
34
+ }
35
+ if (values.length !== 1) {
36
+ throw new index_js_1.InvalidUpdateError();
37
+ }
38
+ [this.value] = values;
39
+ }
40
+ get() {
41
+ if (this.value === undefined) {
42
+ throw new index_js_1.EmptyChannelError();
43
+ }
44
+ return this.value;
45
+ }
46
+ checkpoint() {
47
+ if (this.value === undefined) {
48
+ throw new index_js_1.EmptyChannelError();
49
+ }
50
+ return this.value;
51
+ }
52
+ }
53
+ exports.LastValue = LastValue;
@@ -0,0 +1,12 @@
1
+ import { BaseChannel } from "./index.js";
2
+ /**
3
+ * Stores the last value received, can receive at most one value per step.
4
+ */
5
+ export declare class LastValue<Value> extends BaseChannel<Value, Value, Value> {
6
+ lc_graph_name: string;
7
+ value?: Value;
8
+ empty(checkpoint?: Value): LastValue<Value>;
9
+ update(values: Value[]): void;
10
+ get(): Value;
11
+ checkpoint(): Value;
12
+ }
@@ -0,0 +1,49 @@
1
+ import { BaseChannel, EmptyChannelError, InvalidUpdateError } from "./index.js";
2
+ /**
3
+ * Stores the last value received, can receive at most one value per step.
4
+ */
5
+ export class LastValue extends BaseChannel {
6
+ constructor() {
7
+ super(...arguments);
8
+ Object.defineProperty(this, "lc_graph_name", {
9
+ enumerable: true,
10
+ configurable: true,
11
+ writable: true,
12
+ value: "LastValue"
13
+ });
14
+ Object.defineProperty(this, "value", {
15
+ enumerable: true,
16
+ configurable: true,
17
+ writable: true,
18
+ value: void 0
19
+ });
20
+ }
21
+ empty(checkpoint) {
22
+ const empty = new LastValue();
23
+ if (checkpoint) {
24
+ empty.value = checkpoint;
25
+ }
26
+ return empty;
27
+ }
28
+ update(values) {
29
+ if (values.length === 0) {
30
+ return;
31
+ }
32
+ if (values.length !== 1) {
33
+ throw new InvalidUpdateError();
34
+ }
35
+ [this.value] = values;
36
+ }
37
+ get() {
38
+ if (this.value === undefined) {
39
+ throw new EmptyChannelError();
40
+ }
41
+ return this.value;
42
+ }
43
+ checkpoint() {
44
+ if (this.value === undefined) {
45
+ throw new EmptyChannelError();
46
+ }
47
+ return this.value;
48
+ }
49
+ }
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Topic = void 0;
4
+ const base_js_1 = require("./base.cjs");
5
+ function* flatten(values) {
6
+ for (const value of values) {
7
+ if (Array.isArray(value)) {
8
+ yield* value;
9
+ }
10
+ else {
11
+ yield value;
12
+ }
13
+ }
14
+ }
15
+ class Topic extends base_js_1.BaseChannel {
16
+ constructor(fields) {
17
+ super();
18
+ Object.defineProperty(this, "lc_graph_name", {
19
+ enumerable: true,
20
+ configurable: true,
21
+ writable: true,
22
+ value: "Topic"
23
+ });
24
+ Object.defineProperty(this, "unique", {
25
+ enumerable: true,
26
+ configurable: true,
27
+ writable: true,
28
+ value: false
29
+ });
30
+ Object.defineProperty(this, "accumulate", {
31
+ enumerable: true,
32
+ configurable: true,
33
+ writable: true,
34
+ value: false
35
+ });
36
+ Object.defineProperty(this, "seen", {
37
+ enumerable: true,
38
+ configurable: true,
39
+ writable: true,
40
+ value: void 0
41
+ });
42
+ Object.defineProperty(this, "values", {
43
+ enumerable: true,
44
+ configurable: true,
45
+ writable: true,
46
+ value: void 0
47
+ });
48
+ this.unique = fields?.unique ?? this.unique;
49
+ this.accumulate = fields?.accumulate ?? this.accumulate;
50
+ // State
51
+ this.seen = new Set();
52
+ this.values = [];
53
+ }
54
+ empty(checkpoint) {
55
+ const empty = new Topic({
56
+ unique: this.unique,
57
+ accumulate: this.accumulate,
58
+ });
59
+ if (checkpoint) {
60
+ [empty.seen, empty.values] = checkpoint;
61
+ }
62
+ return empty;
63
+ }
64
+ update(values) {
65
+ if (!this.accumulate) {
66
+ this.values = [];
67
+ }
68
+ const flatValues = flatten(values);
69
+ if (flatValues) {
70
+ if (this.unique) {
71
+ for (const value of flatValues) {
72
+ if (!this.seen.has(value)) {
73
+ this.seen.add(value);
74
+ this.values.push(value);
75
+ }
76
+ }
77
+ }
78
+ else {
79
+ this.values.push(...flatValues);
80
+ }
81
+ }
82
+ }
83
+ get() {
84
+ return this.values;
85
+ }
86
+ checkpoint() {
87
+ return [this.seen, this.values];
88
+ }
89
+ }
90
+ exports.Topic = Topic;
@@ -0,0 +1,19 @@
1
+ import { BaseChannel } from "./base.js";
2
+ export declare class Topic<Value> extends BaseChannel<Array<Value>, Value | Value[], [
3
+ Set<Value>,
4
+ Value[]
5
+ ]> {
6
+ lc_graph_name: string;
7
+ unique: boolean;
8
+ accumulate: boolean;
9
+ seen: Set<Value>;
10
+ values: Value[];
11
+ constructor(fields?: {
12
+ unique?: boolean;
13
+ accumulate?: boolean;
14
+ });
15
+ empty(checkpoint?: [Set<Value>, Value[]]): Topic<Value>;
16
+ update(values: Array<Value | Value[]>): void;
17
+ get(): Array<Value>;
18
+ checkpoint(): [Set<Value>, Array<Value>];
19
+ }
@@ -0,0 +1,86 @@
1
+ import { BaseChannel } from "./base.js";
2
+ function* flatten(values) {
3
+ for (const value of values) {
4
+ if (Array.isArray(value)) {
5
+ yield* value;
6
+ }
7
+ else {
8
+ yield value;
9
+ }
10
+ }
11
+ }
12
+ export class Topic extends BaseChannel {
13
+ constructor(fields) {
14
+ super();
15
+ Object.defineProperty(this, "lc_graph_name", {
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true,
19
+ value: "Topic"
20
+ });
21
+ Object.defineProperty(this, "unique", {
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true,
25
+ value: false
26
+ });
27
+ Object.defineProperty(this, "accumulate", {
28
+ enumerable: true,
29
+ configurable: true,
30
+ writable: true,
31
+ value: false
32
+ });
33
+ Object.defineProperty(this, "seen", {
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true,
37
+ value: void 0
38
+ });
39
+ Object.defineProperty(this, "values", {
40
+ enumerable: true,
41
+ configurable: true,
42
+ writable: true,
43
+ value: void 0
44
+ });
45
+ this.unique = fields?.unique ?? this.unique;
46
+ this.accumulate = fields?.accumulate ?? this.accumulate;
47
+ // State
48
+ this.seen = new Set();
49
+ this.values = [];
50
+ }
51
+ empty(checkpoint) {
52
+ const empty = new Topic({
53
+ unique: this.unique,
54
+ accumulate: this.accumulate,
55
+ });
56
+ if (checkpoint) {
57
+ [empty.seen, empty.values] = checkpoint;
58
+ }
59
+ return empty;
60
+ }
61
+ update(values) {
62
+ if (!this.accumulate) {
63
+ this.values = [];
64
+ }
65
+ const flatValues = flatten(values);
66
+ if (flatValues) {
67
+ if (this.unique) {
68
+ for (const value of flatValues) {
69
+ if (!this.seen.has(value)) {
70
+ this.seen.add(value);
71
+ this.values.push(value);
72
+ }
73
+ }
74
+ }
75
+ else {
76
+ this.values.push(...flatValues);
77
+ }
78
+ }
79
+ }
80
+ get() {
81
+ return this.values;
82
+ }
83
+ checkpoint() {
84
+ return [this.seen, this.values];
85
+ }
86
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseCheckpointSaver = exports.CheckpointAt = exports.emptyCheckpoint = void 0;
4
+ function emptyCheckpoint() {
5
+ return {
6
+ v: 1,
7
+ ts: new Date().toISOString(),
8
+ channelValues: {},
9
+ channelVersions: {},
10
+ versionsSeen: {},
11
+ };
12
+ }
13
+ exports.emptyCheckpoint = emptyCheckpoint;
14
+ var CheckpointAt;
15
+ (function (CheckpointAt) {
16
+ CheckpointAt["END_OF_STEP"] = "end_of_step";
17
+ CheckpointAt["END_OF_RUN"] = "end_of_run";
18
+ })(CheckpointAt || (exports.CheckpointAt = CheckpointAt = {}));
19
+ class BaseCheckpointSaver {
20
+ constructor() {
21
+ Object.defineProperty(this, "at", {
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true,
25
+ value: CheckpointAt.END_OF_RUN
26
+ });
27
+ }
28
+ get configSpecs() {
29
+ return [];
30
+ }
31
+ }
32
+ exports.BaseCheckpointSaver = BaseCheckpointSaver;
@@ -0,0 +1,47 @@
1
+ import { RunnableConfig } from "@langchain/core/runnables";
2
+ /** A field that can be configured by the user. It is a specification of a field. */
3
+ export interface ConfigurableFieldSpec {
4
+ id: string;
5
+ annotation: any;
6
+ name: string | null;
7
+ description: string | null;
8
+ default: any;
9
+ /**
10
+ * @default false
11
+ */
12
+ isShared?: boolean;
13
+ dependencies: Array<string> | null;
14
+ }
15
+ export interface Checkpoint {
16
+ /**
17
+ * Version number
18
+ */
19
+ v: number;
20
+ /**
21
+ * Timestamp {new Date().toISOString()}
22
+ */
23
+ ts: string;
24
+ /**
25
+ * @default {}
26
+ */
27
+ channelValues: Record<string, any>;
28
+ /**
29
+ * @default {}
30
+ */
31
+ channelVersions: Record<string, number>;
32
+ /**
33
+ * @default {}
34
+ */
35
+ versionsSeen: Record<string, Record<string, number>>;
36
+ }
37
+ export declare function emptyCheckpoint(): Checkpoint;
38
+ export declare enum CheckpointAt {
39
+ END_OF_STEP = "end_of_step",
40
+ END_OF_RUN = "end_of_run"
41
+ }
42
+ export declare abstract class BaseCheckpointSaver {
43
+ at: CheckpointAt;
44
+ get configSpecs(): Array<ConfigurableFieldSpec>;
45
+ abstract get(config: RunnableConfig): Checkpoint | undefined;
46
+ abstract put(config: RunnableConfig, checkpoint: Checkpoint): void;
47
+ }
@@ -0,0 +1,27 @@
1
+ export function emptyCheckpoint() {
2
+ return {
3
+ v: 1,
4
+ ts: new Date().toISOString(),
5
+ channelValues: {},
6
+ channelVersions: {},
7
+ versionsSeen: {},
8
+ };
9
+ }
10
+ export var CheckpointAt;
11
+ (function (CheckpointAt) {
12
+ CheckpointAt["END_OF_STEP"] = "end_of_step";
13
+ CheckpointAt["END_OF_RUN"] = "end_of_run";
14
+ })(CheckpointAt || (CheckpointAt = {}));
15
+ export class BaseCheckpointSaver {
16
+ constructor() {
17
+ Object.defineProperty(this, "at", {
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true,
21
+ value: CheckpointAt.END_OF_RUN
22
+ });
23
+ }
24
+ get configSpecs() {
25
+ return [];
26
+ }
27
+ }