@langchain/langgraph 0.2.74 → 0.3.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 (105) hide show
  1. package/dist/channels/any_value.cjs +3 -0
  2. package/dist/channels/any_value.d.ts +1 -0
  3. package/dist/channels/any_value.js +3 -0
  4. package/dist/channels/any_value.js.map +1 -1
  5. package/dist/channels/base.cjs +31 -2
  6. package/dist/channels/base.d.ts +17 -2
  7. package/dist/channels/base.js +31 -2
  8. package/dist/channels/base.js.map +1 -1
  9. package/dist/channels/binop.cjs +3 -0
  10. package/dist/channels/binop.d.ts +1 -0
  11. package/dist/channels/binop.js +3 -0
  12. package/dist/channels/binop.js.map +1 -1
  13. package/dist/channels/dynamic_barrier_value.cjs +119 -9
  14. package/dist/channels/dynamic_barrier_value.d.ts +29 -0
  15. package/dist/channels/dynamic_barrier_value.js +117 -8
  16. package/dist/channels/dynamic_barrier_value.js.map +1 -1
  17. package/dist/channels/ephemeral_value.cjs +3 -0
  18. package/dist/channels/ephemeral_value.d.ts +1 -0
  19. package/dist/channels/ephemeral_value.js +3 -0
  20. package/dist/channels/ephemeral_value.js.map +1 -1
  21. package/dist/channels/last_value.cjs +82 -4
  22. package/dist/channels/last_value.d.ts +21 -0
  23. package/dist/channels/last_value.js +80 -3
  24. package/dist/channels/last_value.js.map +1 -1
  25. package/dist/channels/named_barrier_value.cjs +94 -1
  26. package/dist/channels/named_barrier_value.d.ts +23 -0
  27. package/dist/channels/named_barrier_value.js +92 -0
  28. package/dist/channels/named_barrier_value.js.map +1 -1
  29. package/dist/channels/topic.cjs +3 -0
  30. package/dist/channels/topic.d.ts +1 -0
  31. package/dist/channels/topic.js +3 -0
  32. package/dist/channels/topic.js.map +1 -1
  33. package/dist/constants.cjs +29 -8
  34. package/dist/constants.d.ts +47 -26
  35. package/dist/constants.js +27 -7
  36. package/dist/constants.js.map +1 -1
  37. package/dist/func/index.cjs +17 -4
  38. package/dist/func/index.d.ts +14 -5
  39. package/dist/func/index.js +17 -4
  40. package/dist/func/index.js.map +1 -1
  41. package/dist/func/types.d.ts +1 -1
  42. package/dist/graph/graph.d.ts +4 -2
  43. package/dist/graph/graph.js.map +1 -1
  44. package/dist/graph/index.cjs +2 -1
  45. package/dist/graph/index.d.ts +1 -1
  46. package/dist/graph/index.js +1 -1
  47. package/dist/graph/index.js.map +1 -1
  48. package/dist/graph/messages_annotation.cjs +3 -0
  49. package/dist/graph/messages_annotation.js +3 -0
  50. package/dist/graph/messages_annotation.js.map +1 -1
  51. package/dist/graph/state.cjs +67 -22
  52. package/dist/graph/state.d.ts +22 -8
  53. package/dist/graph/state.js +68 -24
  54. package/dist/graph/state.js.map +1 -1
  55. package/dist/graph/zod/schema.cjs +12 -61
  56. package/dist/graph/zod/schema.js +12 -61
  57. package/dist/graph/zod/schema.js.map +1 -1
  58. package/dist/graph/zod/state.cjs +63 -0
  59. package/dist/graph/zod/state.d.ts +10 -1
  60. package/dist/graph/zod/state.js +61 -0
  61. package/dist/graph/zod/state.js.map +1 -1
  62. package/dist/prebuilt/react_agent_executor.cjs +99 -45
  63. package/dist/prebuilt/react_agent_executor.d.ts +20 -4
  64. package/dist/prebuilt/react_agent_executor.js +99 -45
  65. package/dist/prebuilt/react_agent_executor.js.map +1 -1
  66. package/dist/pregel/algo.cjs +60 -20
  67. package/dist/pregel/algo.d.ts +1 -1
  68. package/dist/pregel/algo.js +61 -21
  69. package/dist/pregel/algo.js.map +1 -1
  70. package/dist/pregel/call.cjs +2 -1
  71. package/dist/pregel/call.d.ts +3 -2
  72. package/dist/pregel/call.js +2 -1
  73. package/dist/pregel/call.js.map +1 -1
  74. package/dist/pregel/debug.test.cjs +6 -0
  75. package/dist/pregel/debug.test.js +6 -0
  76. package/dist/pregel/debug.test.js.map +1 -1
  77. package/dist/pregel/index.cjs +99 -29
  78. package/dist/pregel/index.d.ts +19 -6
  79. package/dist/pregel/index.js +100 -30
  80. package/dist/pregel/index.js.map +1 -1
  81. package/dist/pregel/loop.cjs +126 -26
  82. package/dist/pregel/loop.d.ts +29 -2
  83. package/dist/pregel/loop.js +127 -27
  84. package/dist/pregel/loop.js.map +1 -1
  85. package/dist/pregel/read.cjs +12 -1
  86. package/dist/pregel/read.d.ts +3 -1
  87. package/dist/pregel/read.js +12 -1
  88. package/dist/pregel/read.js.map +1 -1
  89. package/dist/pregel/retry.cjs +2 -6
  90. package/dist/pregel/retry.js +2 -6
  91. package/dist/pregel/retry.js.map +1 -1
  92. package/dist/pregel/runner.cjs +1 -0
  93. package/dist/pregel/runner.js +1 -0
  94. package/dist/pregel/runner.js.map +1 -1
  95. package/dist/pregel/types.cjs +8 -1
  96. package/dist/pregel/types.d.ts +64 -8
  97. package/dist/pregel/types.js +8 -1
  98. package/dist/pregel/types.js.map +1 -1
  99. package/dist/pregel/utils/index.d.ts +15 -0
  100. package/dist/pregel/utils/index.js.map +1 -1
  101. package/dist/web.cjs +4 -1
  102. package/dist/web.d.ts +3 -3
  103. package/dist/web.js +2 -2
  104. package/dist/web.js.map +1 -1
  105. package/package.json +5 -5
@@ -22,9 +22,6 @@ const config_js_1 = require("./utils/config.cjs");
22
22
  const messages_js_1 = require("./messages.cjs");
23
23
  const runner_js_1 = require("./runner.cjs");
24
24
  const stream_js_1 = require("./stream.cjs");
25
- function isString(value) {
26
- return typeof value === "string";
27
- }
28
25
  /**
29
26
  * Utility class for working with channels in the Pregel system.
30
27
  * Provides static methods for subscribing to channels and writing to them.
@@ -43,7 +40,7 @@ class Channel {
43
40
  throw new Error("Can't specify a key when subscribing to multiple channels");
44
41
  }
45
42
  let channelMappingOrArray;
46
- if (isString(channels)) {
43
+ if (typeof channels === "string") {
47
44
  if (key) {
48
45
  channelMappingOrArray = { [key]: channels };
49
46
  }
@@ -116,6 +113,36 @@ class Channel {
116
113
  }
117
114
  }
118
115
  exports.Channel = Channel;
116
+ // This is a workaround to allow Pregel to override `invoke` / `stream` and `withConfig`
117
+ // without having to adhere to the types in the `Runnable` class (thanks to `any`).
118
+ // Alternatively we could mark those methods with @ts-ignore / @ts-expect-error,
119
+ // but these do not get carried over when building via `tsc`.
120
+ class PartialRunnable extends runnables_1.Runnable {
121
+ constructor() {
122
+ super(...arguments);
123
+ Object.defineProperty(this, "lc_namespace", {
124
+ enumerable: true,
125
+ configurable: true,
126
+ writable: true,
127
+ value: ["langgraph", "pregel"]
128
+ });
129
+ }
130
+ invoke(_input, _options
131
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
132
+ ) {
133
+ throw new Error("Not implemented");
134
+ }
135
+ // Overriden by `Pregel`
136
+ withConfig(_config) {
137
+ return super.withConfig(_config);
138
+ }
139
+ // Overriden by `Pregel`
140
+ stream(input, options
141
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
142
+ ) {
143
+ return super.stream(input, options);
144
+ }
145
+ }
119
146
  /**
120
147
  * The Pregel class is the core runtime engine of LangGraph, implementing a message-passing graph computation model
121
148
  * inspired by [Google's Pregel system](https://research.google/pubs/pregel-a-system-for-large-scale-graph-processing/).
@@ -175,7 +202,7 @@ exports.Channel = Channel;
175
202
  * @typeParam InputType - Type of input values accepted by the graph
176
203
  * @typeParam OutputType - Type of output values produced by the graph
177
204
  */
178
- class Pregel extends runnables_1.Runnable {
205
+ class Pregel extends PartialRunnable {
179
206
  /**
180
207
  * Name of the class when serialized
181
208
  * @internal
@@ -330,7 +357,7 @@ class Pregel extends runnables_1.Runnable {
330
357
  value: void 0
331
358
  });
332
359
  /**
333
- * Optional long-term memory store for the graph, allows for persistance & retrieval of data across threads
360
+ * Optional long-term memory store for the graph, allows for persistence & retrieval of data across threads
334
361
  */
335
362
  Object.defineProperty(this, "store", {
336
363
  enumerable: true,
@@ -338,6 +365,21 @@ class Pregel extends runnables_1.Runnable {
338
365
  writable: true,
339
366
  value: void 0
340
367
  });
368
+ Object.defineProperty(this, "triggerToNodes", {
369
+ enumerable: true,
370
+ configurable: true,
371
+ writable: true,
372
+ value: {}
373
+ });
374
+ /**
375
+ * Optional cache for the graph, useful for caching tasks.
376
+ */
377
+ Object.defineProperty(this, "cache", {
378
+ enumerable: true,
379
+ configurable: true,
380
+ writable: true,
381
+ value: void 0
382
+ });
341
383
  let { streamMode } = fields;
342
384
  if (streamMode != null && !Array.isArray(streamMode)) {
343
385
  streamMode = [streamMode];
@@ -357,6 +399,7 @@ class Pregel extends runnables_1.Runnable {
357
399
  this.retryPolicy = fields.retryPolicy;
358
400
  this.config = fields.config;
359
401
  this.store = fields.store;
402
+ this.cache = fields.cache;
360
403
  this.name = fields.name;
361
404
  if (this.autoValidate) {
362
405
  this.validate();
@@ -381,8 +424,6 @@ class Pregel extends runnables_1.Runnable {
381
424
  * @param config - The configuration to merge with the current configuration
382
425
  * @returns A new Pregel instance with the merged configuration
383
426
  */
384
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
385
- // @ts-ignore Remove ignore when we remove support for 0.2 versions of core
386
427
  withConfig(config) {
387
428
  const mergedConfig = (0, runnables_1.mergeConfigs)(this.config, config);
388
429
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -408,6 +449,12 @@ class Pregel extends runnables_1.Runnable {
408
449
  interruptAfterNodes: this.interruptAfter,
409
450
  interruptBeforeNodes: this.interruptBefore,
410
451
  });
452
+ for (const [name, node] of Object.entries(this.nodes)) {
453
+ for (const trigger of node.triggers) {
454
+ this.triggerToNodes[trigger] ??= [];
455
+ this.triggerToNodes[trigger].push(name);
456
+ }
457
+ }
411
458
  return this;
412
459
  }
413
460
  /**
@@ -549,7 +596,7 @@ class Pregel extends runnables_1.Runnable {
549
596
  writes: nullWrites,
550
597
  triggers: [],
551
598
  },
552
- ]);
599
+ ], undefined, this.triggerToNodes);
553
600
  }
554
601
  }
555
602
  // Prepare next tasks
@@ -613,7 +660,7 @@ class Pregel extends runnables_1.Runnable {
613
660
  // Apply writes from tasks that have writes
614
661
  const tasksWithWrites = nextTasks.filter((task) => task.writes.length > 0);
615
662
  if (tasksWithWrites.length > 0) {
616
- (0, algo_js_1._applyWrites)(saved.checkpoint, channels, tasksWithWrites);
663
+ (0, algo_js_1._applyWrites)(saved.checkpoint, channels, tasksWithWrites, undefined, this.triggerToNodes);
617
664
  }
618
665
  }
619
666
  // Preserve thread_id from the config in metadata
@@ -829,7 +876,7 @@ class Pregel extends runnables_1.Runnable {
829
876
  writes: nullWrites,
830
877
  triggers: [],
831
878
  },
832
- ]);
879
+ ], undefined, this.triggerToNodes);
833
880
  }
834
881
  // apply writes from tasks that already ran
835
882
  for (const [taskId, k, v] of saved.pendingWrites || []) {
@@ -842,7 +889,7 @@ class Pregel extends runnables_1.Runnable {
842
889
  nextTasks[taskId].writes.push([k, v]);
843
890
  }
844
891
  // clear all current tasks
845
- (0, algo_js_1._applyWrites)(checkpoint, channels, Object.values(nextTasks));
892
+ (0, algo_js_1._applyWrites)(checkpoint, channels, Object.values(nextTasks), undefined, this.triggerToNodes);
846
893
  }
847
894
  // save checkpoint
848
895
  const nextConfig = await checkpointer.put(checkpointConfig, (0, base_js_1.createCheckpoint)(checkpoint, undefined, step), {
@@ -881,7 +928,7 @@ class Pregel extends runnables_1.Runnable {
881
928
  writes: inputWrites,
882
929
  triggers: [],
883
930
  },
884
- ], checkpointer.getNextVersion.bind(this.checkpointer));
931
+ ], checkpointer.getNextVersion.bind(this.checkpointer), this.triggerToNodes);
885
932
  // apply input write to channels
886
933
  const nextStep = saved?.metadata?.step != null ? saved.metadata.step + 1 : -1;
887
934
  const nextConfig = await checkpointer.put(checkpointConfig, (0, base_js_1.createCheckpoint)(checkpoint, channels, nextStep), {
@@ -910,13 +957,7 @@ class Pregel extends runnables_1.Runnable {
910
957
  .filter((w) => w[0] === constants_js_1.NULL_TASK_ID)
911
958
  .map((w) => w.slice(1));
912
959
  if (nullWrites.length > 0) {
913
- (0, algo_js_1._applyWrites)(saved.checkpoint, channels, [
914
- {
915
- name: constants_js_1.INPUT,
916
- writes: nullWrites,
917
- triggers: [],
918
- },
919
- ]);
960
+ (0, algo_js_1._applyWrites)(saved.checkpoint, channels, [{ name: constants_js_1.INPUT, writes: nullWrites, triggers: [] }], undefined, this.triggerToNodes);
920
961
  }
921
962
  // apply writes
922
963
  for (const [tid, k, v] of saved.pendingWrites) {
@@ -930,7 +971,7 @@ class Pregel extends runnables_1.Runnable {
930
971
  return task.writes.length > 0;
931
972
  });
932
973
  if (tasks.length > 0) {
933
- (0, algo_js_1._applyWrites)(checkpoint, channels, tasks);
974
+ (0, algo_js_1._applyWrites)(checkpoint, channels, tasks, undefined, this.triggerToNodes);
934
975
  }
935
976
  }
936
977
  const nonNullVersion = Object.values(checkpoint.versions_seen)
@@ -1038,7 +1079,7 @@ class Pregel extends runnables_1.Runnable {
1038
1079
  }
1039
1080
  // apply to checkpoint
1040
1081
  // TODO: Why does keyof StrRecord allow number and symbol?
1041
- (0, algo_js_1._applyWrites)(checkpoint, channels, tasks, checkpointer.getNextVersion.bind(this.checkpointer));
1082
+ (0, algo_js_1._applyWrites)(checkpoint, channels, tasks, checkpointer.getNextVersion.bind(this.checkpointer), this.triggerToNodes);
1042
1083
  const newVersions = (0, index_js_1.getNewChannelVersions)(checkpointPreviousVersions, checkpoint.channel_versions);
1043
1084
  const nextConfig = await checkpointer.put(checkpointConfig, (0, base_js_1.createCheckpoint)(checkpoint, channels, step + 1), {
1044
1085
  source: "update",
@@ -1145,6 +1186,7 @@ class Pregel extends runnables_1.Runnable {
1145
1186
  defaultCheckpointer = this.checkpointer;
1146
1187
  }
1147
1188
  const defaultStore = config.store ?? this.store;
1189
+ const defaultCache = config.cache ?? this.cache;
1148
1190
  return [
1149
1191
  defaultDebug,
1150
1192
  defaultStreamMode,
@@ -1156,6 +1198,7 @@ class Pregel extends runnables_1.Runnable {
1156
1198
  defaultCheckpointer,
1157
1199
  defaultStore,
1158
1200
  streamModeSingle,
1201
+ defaultCache,
1159
1202
  ];
1160
1203
  }
1161
1204
  /**
@@ -1188,7 +1231,7 @@ class Pregel extends runnables_1.Runnable {
1188
1231
  ? (0, index_js_1.combineAbortSignals)(options.signal, abortController.signal)
1189
1232
  : abortController.signal,
1190
1233
  };
1191
- return new stream_js_1.IterableReadableStreamWithAbortSignal(await super.stream(input, config), abortController);
1234
+ return new stream_js_1.IterableReadableStreamWithAbortSignal((await super.stream(input, config)), abortController);
1192
1235
  }
1193
1236
  streamEvents(input, options, streamOptions) {
1194
1237
  const abortController = new AbortController();
@@ -1301,7 +1344,7 @@ class Pregel extends runnables_1.Runnable {
1301
1344
  const validInput = await this._validateInput(input);
1302
1345
  const { runId, ...restConfig } = inputConfig;
1303
1346
  // assign defaults
1304
- const [debug, streamMode, , outputKeys, config, interruptBefore, interruptAfter, checkpointer, store, streamModeSingle,] = this._defaults(restConfig);
1347
+ const [debug, streamMode, , outputKeys, config, interruptBefore, interruptAfter, checkpointer, store, streamModeSingle, cache,] = this._defaults(restConfig);
1305
1348
  config.configurable = await this._validateConfigurable(config.configurable);
1306
1349
  const stream = new stream_js_1.IterableReadableWritableStream({
1307
1350
  modes: new Set(streamMode),
@@ -1358,11 +1401,13 @@ class Pregel extends runnables_1.Runnable {
1358
1401
  outputKeys,
1359
1402
  streamKeys: this.streamChannelsAsIs,
1360
1403
  store,
1404
+ cache: cache,
1361
1405
  stream,
1362
1406
  interruptAfter,
1363
1407
  interruptBefore,
1364
1408
  manager: runManager,
1365
1409
  debug: this.debug,
1410
+ triggerToNodes: this.triggerToNodes,
1366
1411
  });
1367
1412
  const runner = new runner_js_1.PregelRunner({
1368
1413
  loop,
@@ -1384,6 +1429,7 @@ class Pregel extends runnables_1.Runnable {
1384
1429
  // Call `.stop()` again incase it was not called in the loop, e.g due to an error.
1385
1430
  if (loop) {
1386
1431
  await loop.store?.stop();
1432
+ await loop.cache?.stop();
1387
1433
  }
1388
1434
  await Promise.all([
1389
1435
  ...(loop?.checkpointerPromises ?? []),
@@ -1458,11 +1504,31 @@ class Pregel extends runnables_1.Runnable {
1458
1504
  };
1459
1505
  const chunks = [];
1460
1506
  const stream = await this.stream(input, config);
1507
+ const interruptChunks = [];
1508
+ let latest;
1461
1509
  for await (const chunk of stream) {
1462
- chunks.push(chunk);
1510
+ if (streamMode === "values") {
1511
+ if ((0, constants_js_1.isInterrupted)(chunk)) {
1512
+ interruptChunks.push(chunk[constants_js_1.INTERRUPT]);
1513
+ }
1514
+ else {
1515
+ latest = chunk;
1516
+ }
1517
+ }
1518
+ else {
1519
+ chunks.push(chunk);
1520
+ }
1463
1521
  }
1464
1522
  if (streamMode === "values") {
1465
- return chunks[chunks.length - 1];
1523
+ if (interruptChunks.length > 0) {
1524
+ const interrupts = interruptChunks.flat(1);
1525
+ if (latest == null)
1526
+ return { [constants_js_1.INTERRUPT]: interrupts };
1527
+ if (typeof latest === "object") {
1528
+ return { ...latest, [constants_js_1.INTERRUPT]: interrupts };
1529
+ }
1530
+ }
1531
+ return latest;
1466
1532
  }
1467
1533
  return chunks;
1468
1534
  }
@@ -1470,9 +1536,10 @@ class Pregel extends runnables_1.Runnable {
1470
1536
  const { loop, runner, debug, config } = params;
1471
1537
  let tickError;
1472
1538
  try {
1473
- while (await loop.tick({
1474
- inputKeys: this.inputChannels,
1475
- })) {
1539
+ while (await loop.tick({ inputKeys: this.inputChannels })) {
1540
+ for (const { task } of await loop._matchCachedWrites()) {
1541
+ loop._outputWrites(task.id, task.writes, true);
1542
+ }
1476
1543
  if (debug) {
1477
1544
  (0, debug_js_1.printStepCheckpoint)(loop.checkpointMetadata.step, loop.channels, this.streamChannelsList);
1478
1545
  }
@@ -1514,6 +1581,9 @@ class Pregel extends runnables_1.Runnable {
1514
1581
  }
1515
1582
  }
1516
1583
  }
1584
+ async clearCache() {
1585
+ await this.cache?.clear([]);
1586
+ }
1517
1587
  }
1518
1588
  exports.Pregel = Pregel;
1519
1589
  //# sourceMappingURL=index.js.map
@@ -1,12 +1,12 @@
1
1
  import { Runnable, RunnableConfig, RunnableFunc } from "@langchain/core/runnables";
2
2
  import { IterableReadableStream } from "@langchain/core/utils/stream";
3
- import { All, BaseCheckpointSaver, BaseStore, CheckpointListOptions, CheckpointTuple } from "@langchain/langgraph-checkpoint";
3
+ import { All, BaseCheckpointSaver, BaseStore, CheckpointListOptions, CheckpointTuple, BaseCache } from "@langchain/langgraph-checkpoint";
4
4
  import type { StreamEvent } from "@langchain/core/tracers/log_stream";
5
5
  import { BaseChannel } from "../channels/base.js";
6
6
  import { PregelNode } from "./read.js";
7
7
  import { ChannelWrite } from "./write.js";
8
8
  import { Command } from "../constants.js";
9
- import { PregelInterface, PregelParams, StateSnapshot, StreamMode, PregelInputType, PregelOutputType, PregelOptions, SingleChannelSubscriptionOptions, MultipleChannelSubscriptionOptions, GetStateOptions } from "./types.js";
9
+ import { PregelInterface, PregelParams, StateSnapshot, StreamMode, PregelInputType, PregelOutputType, PregelOptions, SingleChannelSubscriptionOptions, MultipleChannelSubscriptionOptions, GetStateOptions, type StreamOutputMap } from "./types.js";
10
10
  import { StrRecord } from "./algo.js";
11
11
  import { RetryPolicy } from "./utils/index.js";
12
12
  import { ManagedValueMapping, type ManagedValueSpec } from "../managed/base.js";
@@ -93,6 +93,12 @@ export declare class Channel {
93
93
  static writeTo(channels: string[], writes?: Record<string, WriteValue>): ChannelWrite;
94
94
  }
95
95
  export type { PregelInputType, PregelOutputType, PregelOptions };
96
+ declare class PartialRunnable<RunInput, RunOutput, CallOptions extends RunnableConfig> extends Runnable<RunInput, RunOutput, CallOptions> {
97
+ lc_namespace: string[];
98
+ invoke(_input: RunInput, _options?: Partial<CallOptions>): Promise<any>;
99
+ withConfig(_config: CallOptions): typeof this;
100
+ stream(input: RunInput, options?: Partial<CallOptions>): Promise<IterableReadableStream<any>>;
101
+ }
96
102
  /**
97
103
  * The Pregel class is the core runtime engine of LangGraph, implementing a message-passing graph computation model
98
104
  * inspired by [Google's Pregel system](https://research.google/pubs/pregel-a-system-for-large-scale-graph-processing/).
@@ -152,7 +158,7 @@ export type { PregelInputType, PregelOutputType, PregelOptions };
152
158
  * @typeParam InputType - Type of input values accepted by the graph
153
159
  * @typeParam OutputType - Type of output values produced by the graph
154
160
  */
155
- export declare class Pregel<Nodes extends StrRecord<string, PregelNode>, Channels extends StrRecord<string, BaseChannel | ManagedValueSpec>, ConfigurableFieldType extends Record<string, any> = StrRecord<string, any>, InputType = PregelInputType, OutputType = PregelOutputType> extends Runnable<InputType | Command | null, OutputType, PregelOptions<Nodes, Channels, ConfigurableFieldType>> implements PregelInterface<Nodes, Channels, ConfigurableFieldType>, PregelParams<Nodes, Channels> {
161
+ export declare class Pregel<Nodes extends StrRecord<string, PregelNode>, Channels extends StrRecord<string, BaseChannel | ManagedValueSpec>, ConfigurableFieldType extends Record<string, any> = StrRecord<string, any>, InputType = PregelInputType, OutputType = PregelOutputType, StreamUpdatesType = InputType, StreamValuesType = OutputType> extends PartialRunnable<InputType | Command | null, OutputType, PregelOptions<Nodes, Channels, ConfigurableFieldType>> implements PregelInterface<Nodes, Channels, ConfigurableFieldType>, PregelParams<Nodes, Channels> {
156
162
  /**
157
163
  * Name of the class when serialized
158
164
  * @internal
@@ -222,9 +228,14 @@ export declare class Pregel<Nodes extends StrRecord<string, PregelNode>, Channel
222
228
  /** The default configuration for graph execution, can be overridden on a per-invocation basis */
223
229
  config?: LangGraphRunnableConfig;
224
230
  /**
225
- * Optional long-term memory store for the graph, allows for persistance & retrieval of data across threads
231
+ * Optional long-term memory store for the graph, allows for persistence & retrieval of data across threads
226
232
  */
227
233
  store?: BaseStore;
234
+ triggerToNodes: Record<string, string[]>;
235
+ /**
236
+ * Optional cache for the graph, useful for caching tasks.
237
+ */
238
+ cache?: BaseCache;
228
239
  /**
229
240
  * Constructor for Pregel - meant for internal use only.
230
241
  *
@@ -418,7 +429,8 @@ export declare class Pregel<Nodes extends StrRecord<string, PregelNode>, Channel
418
429
  // interrupt after
419
430
  BaseCheckpointSaver | undefined,
420
431
  BaseStore | undefined,
421
- boolean
432
+ boolean,
433
+ BaseCache | undefined
422
434
  ];
423
435
  /**
424
436
  * Streams the execution of the graph, emitting state updates as they occur.
@@ -436,7 +448,7 @@ export declare class Pregel<Nodes extends StrRecord<string, PregelNode>, Channel
436
448
  * @param options - Configuration options for streaming
437
449
  * @returns An async iterable stream of graph state updates
438
450
  */
439
- stream(input: InputType | Command | null, options?: Partial<PregelOptions<Nodes, Channels, ConfigurableFieldType>>): Promise<IterableReadableStream<PregelOutputType>>;
451
+ stream<TStreamMode extends StreamMode | StreamMode[] | undefined, TSubgraphs extends boolean>(input: InputType | Command | null, options?: Partial<PregelOptions<Nodes, Channels, ConfigurableFieldType, TStreamMode, TSubgraphs>>): Promise<IterableReadableStream<StreamOutputMap<TStreamMode, TSubgraphs, StreamUpdatesType, StreamValuesType, keyof Nodes>>>;
440
452
  /**
441
453
  * @inheritdoc
442
454
  */
@@ -495,4 +507,5 @@ export declare class Pregel<Nodes extends StrRecord<string, PregelNode>, Channel
495
507
  */
496
508
  invoke(input: InputType | Command | null, options?: Partial<PregelOptions<Nodes, Channels, ConfigurableFieldType>>): Promise<OutputType>;
497
509
  private _runLoop;
510
+ clearCache(): Promise<void>;
498
511
  }