@langchain/langgraph 0.2.8 → 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.
Files changed (63) hide show
  1. package/dist/constants.cjs +11 -2
  2. package/dist/constants.d.ts +6 -1
  3. package/dist/constants.js +10 -1
  4. package/dist/errors.cjs +5 -4
  5. package/dist/errors.d.ts +1 -1
  6. package/dist/errors.js +5 -4
  7. package/dist/graph/graph.cjs +7 -2
  8. package/dist/graph/graph.js +8 -3
  9. package/dist/graph/message.cjs +2 -0
  10. package/dist/graph/message.js +2 -0
  11. package/dist/graph/state.cjs +8 -3
  12. package/dist/graph/state.d.ts +2 -3
  13. package/dist/graph/state.js +9 -4
  14. package/dist/managed/shared_value.cjs +12 -10
  15. package/dist/managed/shared_value.d.ts +6 -5
  16. package/dist/managed/shared_value.js +12 -10
  17. package/dist/pregel/algo.cjs +124 -54
  18. package/dist/pregel/algo.d.ts +13 -3
  19. package/dist/pregel/algo.js +122 -53
  20. package/dist/pregel/debug.cjs +15 -18
  21. package/dist/pregel/debug.d.ts +3 -2
  22. package/dist/pregel/debug.js +16 -19
  23. package/dist/pregel/index.cjs +307 -116
  24. package/dist/pregel/index.d.ts +21 -6
  25. package/dist/pregel/index.js +305 -117
  26. package/dist/pregel/io.cjs +15 -8
  27. package/dist/pregel/io.d.ts +2 -2
  28. package/dist/pregel/io.js +15 -8
  29. package/dist/pregel/loop.cjs +258 -113
  30. package/dist/pregel/loop.d.ts +24 -9
  31. package/dist/pregel/loop.js +258 -111
  32. package/dist/pregel/read.cjs +9 -2
  33. package/dist/pregel/read.d.ts +3 -2
  34. package/dist/pregel/read.js +9 -2
  35. package/dist/pregel/retry.d.ts +1 -1
  36. package/dist/pregel/runnable_types.cjs +2 -0
  37. package/dist/pregel/runnable_types.d.ts +5 -0
  38. package/dist/pregel/runnable_types.js +1 -0
  39. package/dist/pregel/types.d.ts +8 -4
  40. package/dist/pregel/utils/config.cjs +73 -0
  41. package/dist/pregel/utils/config.d.ts +3 -0
  42. package/dist/pregel/utils/config.js +69 -0
  43. package/dist/pregel/{utils.cjs → utils/index.cjs} +33 -10
  44. package/dist/pregel/{utils.d.ts → utils/index.d.ts} +4 -7
  45. package/dist/pregel/{utils.js → utils/index.js} +30 -8
  46. package/dist/utils.cjs +5 -3
  47. package/dist/utils.js +5 -3
  48. package/dist/web.cjs +4 -2
  49. package/dist/web.d.ts +4 -3
  50. package/dist/web.js +1 -2
  51. package/package.json +1 -1
  52. package/dist/store/base.cjs +0 -12
  53. package/dist/store/base.d.ts +0 -7
  54. package/dist/store/base.js +0 -8
  55. package/dist/store/batch.cjs +0 -126
  56. package/dist/store/batch.d.ts +0 -55
  57. package/dist/store/batch.js +0 -122
  58. package/dist/store/index.cjs +0 -19
  59. package/dist/store/index.d.ts +0 -3
  60. package/dist/store/index.js +0 -3
  61. package/dist/store/memory.cjs +0 -43
  62. package/dist/store/memory.d.ts +0 -6
  63. package/dist/store/memory.js +0 -39
@@ -1,7 +1,7 @@
1
1
  import { RunnableConfig } from "@langchain/core/runnables";
2
2
  import { CheckpointMetadata, CheckpointPendingWrite, PendingWrite } from "@langchain/langgraph-checkpoint";
3
3
  import { BaseChannel } from "../channels/base.js";
4
- import { PregelExecutableTask, PregelTaskDescription } from "./types.js";
4
+ import { PregelExecutableTask, PregelTaskDescription, StateSnapshot } from "./types.js";
5
5
  export declare function printCheckpoint<Value>(step: number, channels: Record<string, BaseChannel<Value>>): void;
6
6
  export declare function mapDebugTasks<N extends PropertyKey, C extends PropertyKey>(step: number, tasks: readonly PregelExecutableTask<N, C>[]): Generator<{
7
7
  type: string;
@@ -23,6 +23,7 @@ export declare function mapDebugTaskResults<N extends PropertyKey, C extends Pro
23
23
  id: string;
24
24
  name: N;
25
25
  result: PendingWrite<C>[];
26
+ interrupts: PendingWrite<C>[];
26
27
  };
27
28
  }, void, unknown>;
28
29
  export declare function mapDebugCheckpoint<N extends PropertyKey, C extends PropertyKey>(step: number, config: RunnableConfig, channels: Record<string, BaseChannel>, streamChannels: string | string[], metadata: CheckpointMetadata, tasks: readonly PregelExecutableTask<N, C>[], pendingWrites: CheckpointPendingWrite[]): Generator<{
@@ -37,7 +38,7 @@ export declare function mapDebugCheckpoint<N extends PropertyKey, C extends Prop
37
38
  tasks: PregelTaskDescription[];
38
39
  };
39
40
  }, void, unknown>;
40
- export declare function tasksWithWrites<N extends PropertyKey, C extends PropertyKey>(tasks: PregelTaskDescription[] | readonly PregelExecutableTask<N, C>[], pendingWrites: CheckpointPendingWrite[]): PregelTaskDescription[];
41
+ export declare function tasksWithWrites<N extends PropertyKey, C extends PropertyKey>(tasks: PregelTaskDescription[] | readonly PregelExecutableTask<N, C>[], pendingWrites: CheckpointPendingWrite[], states?: Record<string, RunnableConfig | StateSnapshot>): PregelTaskDescription[];
41
42
  export declare function printStepCheckpoint(step: number, channels: Record<string, BaseChannel<unknown>>, whitelist: string[]): void;
42
43
  export declare function printStepTasks<N extends PropertyKey, C extends PropertyKey>(step: number, nextTasks: readonly PregelExecutableTask<N, C>[]): void;
43
44
  export declare function printStepWrites(step: number, writes: PendingWrite[], whitelist: string[]): void;
@@ -1,8 +1,6 @@
1
- import { uuid5, } from "@langchain/langgraph-checkpoint";
2
- import { ERROR, INTERRUPT, TAG_HIDDEN, TASK_NAMESPACE, } from "../constants.js";
1
+ import { ERROR, INTERRUPT, TAG_HIDDEN } from "../constants.js";
3
2
  import { EmptyChannelError } from "../errors.js";
4
3
  import { readChannels } from "./io.js";
5
- import { _getIdMetadata } from "./utils.js";
6
4
  const COLORS_MAP = {
7
5
  blue: {
8
6
  start: "\x1b[34m",
@@ -52,13 +50,6 @@ export function* mapDebugTasks(step, tasks) {
52
50
  for (const { id, name, input, config, triggers, writes } of tasks) {
53
51
  if (config?.tags?.includes(TAG_HIDDEN))
54
52
  continue;
55
- const metadata = { ...config?.metadata };
56
- const idMetadata = _getIdMetadata({
57
- langgraph_step: metadata.langgraph_step,
58
- langgraph_node: metadata.langgraph_node,
59
- langgraph_triggers: metadata.langgraph_triggers,
60
- langgraph_task_idx: metadata.langgraph_task_idx,
61
- });
62
53
  const interrupts = writes
63
54
  .filter(([writeId, n]) => {
64
55
  return writeId === id && n === INTERRUPT;
@@ -71,7 +62,7 @@ export function* mapDebugTasks(step, tasks) {
71
62
  timestamp: ts,
72
63
  step,
73
64
  payload: {
74
- id: uuid5(JSON.stringify([name, step, idMetadata]), TASK_NAMESPACE),
65
+ id,
75
66
  name,
76
67
  input,
77
68
  triggers,
@@ -82,21 +73,24 @@ export function* mapDebugTasks(step, tasks) {
82
73
  }
83
74
  export function* mapDebugTaskResults(step, tasks, streamChannels) {
84
75
  const ts = new Date().toISOString();
85
- for (const [{ name, config }, writes] of tasks) {
76
+ for (const [{ id, name, config }, writes] of tasks) {
86
77
  if (config?.tags?.includes(TAG_HIDDEN))
87
78
  continue;
88
- const metadata = { ...config?.metadata };
89
- const idMetadata = _getIdMetadata(metadata);
90
79
  yield {
91
80
  type: "task_result",
92
81
  timestamp: ts,
93
82
  step,
94
83
  payload: {
95
- id: uuid5(JSON.stringify([name, step, idMetadata]), TASK_NAMESPACE),
84
+ id,
96
85
  name,
97
- result: writes.filter(([channel]) => Array.isArray(streamChannels)
98
- ? streamChannels.includes(channel)
99
- : channel === streamChannels),
86
+ result: writes.filter(([channel]) => {
87
+ return Array.isArray(streamChannels)
88
+ ? streamChannels.includes(channel)
89
+ : channel === streamChannels;
90
+ }),
91
+ interrupts: writes.filter(([channel]) => {
92
+ return channel === INTERRUPT;
93
+ }),
100
94
  },
101
95
  };
102
96
  }
@@ -141,7 +135,7 @@ export function* mapDebugCheckpoint(step, config, channels, streamChannels, meta
141
135
  },
142
136
  };
143
137
  }
144
- export function tasksWithWrites(tasks, pendingWrites) {
138
+ export function tasksWithWrites(tasks, pendingWrites, states) {
145
139
  return tasks.map((task) => {
146
140
  const error = pendingWrites.find(([id, n]) => id === task.id && n === ERROR)?.[2];
147
141
  const interrupts = pendingWrites
@@ -155,6 +149,7 @@ export function tasksWithWrites(tasks, pendingWrites) {
155
149
  return {
156
150
  id: task.id,
157
151
  name: task.name,
152
+ path: task.path,
158
153
  error,
159
154
  interrupts,
160
155
  };
@@ -162,7 +157,9 @@ export function tasksWithWrites(tasks, pendingWrites) {
162
157
  return {
163
158
  id: task.id,
164
159
  name: task.name,
160
+ path: task.path,
165
161
  interrupts,
162
+ state: states?.[task.id],
166
163
  };
167
164
  });
168
165
  }