@langchain/langgraph 0.2.41 → 0.2.43-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 (86) hide show
  1. package/README.md +237 -154
  2. package/dist/channels/any_value.cjs +10 -10
  3. package/dist/channels/any_value.d.ts +1 -1
  4. package/dist/channels/any_value.js +10 -10
  5. package/dist/channels/ephemeral_value.cjs +10 -9
  6. package/dist/channels/ephemeral_value.d.ts +1 -1
  7. package/dist/channels/ephemeral_value.js +10 -9
  8. package/dist/channels/last_value.cjs +8 -7
  9. package/dist/channels/last_value.d.ts +1 -1
  10. package/dist/channels/last_value.js +8 -7
  11. package/dist/constants.cjs +33 -6
  12. package/dist/constants.d.ts +17 -2
  13. package/dist/constants.js +32 -5
  14. package/dist/errors.d.ts +3 -3
  15. package/dist/func/index.cjs +272 -0
  16. package/dist/func/index.d.ts +310 -0
  17. package/dist/func/index.js +267 -0
  18. package/dist/func/types.cjs +15 -0
  19. package/dist/func/types.d.ts +59 -0
  20. package/dist/func/types.js +11 -0
  21. package/dist/graph/graph.cjs +31 -35
  22. package/dist/graph/graph.d.ts +1 -5
  23. package/dist/graph/graph.js +1 -5
  24. package/dist/graph/index.cjs +1 -3
  25. package/dist/graph/index.d.ts +1 -1
  26. package/dist/graph/index.js +1 -1
  27. package/dist/graph/message.d.ts +1 -1
  28. package/dist/graph/state.cjs +17 -17
  29. package/dist/graph/state.d.ts +2 -1
  30. package/dist/graph/state.js +2 -2
  31. package/dist/index.cjs +8 -0
  32. package/dist/index.d.ts +3 -0
  33. package/dist/index.js +3 -0
  34. package/dist/interrupt.cjs +21 -34
  35. package/dist/interrupt.d.ts +1 -1
  36. package/dist/interrupt.js +22 -35
  37. package/dist/prebuilt/agent_executor.cjs +3 -3
  38. package/dist/prebuilt/agent_executor.d.ts +1 -1
  39. package/dist/prebuilt/agent_executor.js +1 -1
  40. package/dist/prebuilt/chat_agent_executor.cjs +3 -3
  41. package/dist/prebuilt/chat_agent_executor.d.ts +1 -1
  42. package/dist/prebuilt/chat_agent_executor.js +1 -1
  43. package/dist/prebuilt/react_agent_executor.cjs +33 -8
  44. package/dist/prebuilt/react_agent_executor.d.ts +4 -1
  45. package/dist/prebuilt/react_agent_executor.js +31 -6
  46. package/dist/prebuilt/tool_node.cjs +1 -2
  47. package/dist/prebuilt/tool_node.d.ts +1 -1
  48. package/dist/prebuilt/tool_node.js +1 -2
  49. package/dist/pregel/algo.cjs +121 -12
  50. package/dist/pregel/algo.d.ts +8 -6
  51. package/dist/pregel/algo.js +122 -13
  52. package/dist/pregel/call.cjs +77 -0
  53. package/dist/pregel/call.d.ts +15 -0
  54. package/dist/pregel/call.js +71 -0
  55. package/dist/pregel/index.cjs +59 -96
  56. package/dist/pregel/index.d.ts +1 -10
  57. package/dist/pregel/index.js +61 -98
  58. package/dist/pregel/io.cjs +6 -1
  59. package/dist/pregel/io.js +7 -2
  60. package/dist/pregel/loop.cjs +109 -75
  61. package/dist/pregel/loop.d.ts +17 -23
  62. package/dist/pregel/loop.js +110 -75
  63. package/dist/pregel/messages.d.ts +1 -1
  64. package/dist/pregel/retry.cjs +22 -50
  65. package/dist/pregel/retry.d.ts +6 -6
  66. package/dist/pregel/retry.js +22 -50
  67. package/dist/pregel/runner.cjs +275 -0
  68. package/dist/pregel/runner.d.ts +64 -0
  69. package/dist/pregel/runner.js +271 -0
  70. package/dist/pregel/stream.cjs +71 -0
  71. package/dist/pregel/stream.d.ts +17 -0
  72. package/dist/pregel/stream.js +67 -0
  73. package/dist/pregel/types.cjs +54 -0
  74. package/dist/pregel/types.d.ts +78 -6
  75. package/dist/pregel/types.js +51 -1
  76. package/dist/pregel/utils/config.cjs +26 -1
  77. package/dist/pregel/utils/config.d.ts +14 -0
  78. package/dist/pregel/utils/config.js +22 -0
  79. package/dist/pregel/write.d.ts +1 -1
  80. package/dist/utils.cjs +15 -1
  81. package/dist/utils.d.ts +3 -1
  82. package/dist/utils.js +12 -0
  83. package/dist/web.cjs +7 -5
  84. package/dist/web.d.ts +4 -4
  85. package/dist/web.js +3 -3
  86. package/package.json +8 -8
@@ -0,0 +1,17 @@
1
+ import { IterableReadableStream } from "@langchain/core/utils/stream";
2
+ import { StreamMode } from "./types.js";
3
+ export type StreamChunk = [string[], StreamMode, unknown];
4
+ export declare class IterableReadableWritableStream extends IterableReadableStream<StreamChunk> {
5
+ modes: Set<StreamMode>;
6
+ private controller;
7
+ private passthroughFn?;
8
+ private _closed;
9
+ get closed(): boolean;
10
+ constructor(params: {
11
+ passthroughFn?: (chunk: StreamChunk) => void;
12
+ modes: Set<StreamMode>;
13
+ });
14
+ push(chunk: StreamChunk): void;
15
+ close(): void;
16
+ error(e: any): void;
17
+ }
@@ -0,0 +1,67 @@
1
+ import { IterableReadableStream } from "@langchain/core/utils/stream";
2
+ export class IterableReadableWritableStream extends IterableReadableStream {
3
+ get closed() {
4
+ return this._closed;
5
+ }
6
+ constructor(params) {
7
+ let streamControllerPromiseResolver;
8
+ const streamControllerPromise = new Promise((resolve) => {
9
+ streamControllerPromiseResolver = resolve;
10
+ });
11
+ super({
12
+ start: (controller) => {
13
+ streamControllerPromiseResolver(controller);
14
+ },
15
+ });
16
+ Object.defineProperty(this, "modes", {
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true,
20
+ value: void 0
21
+ });
22
+ Object.defineProperty(this, "controller", {
23
+ enumerable: true,
24
+ configurable: true,
25
+ writable: true,
26
+ value: void 0
27
+ });
28
+ Object.defineProperty(this, "passthroughFn", {
29
+ enumerable: true,
30
+ configurable: true,
31
+ writable: true,
32
+ value: void 0
33
+ });
34
+ Object.defineProperty(this, "_closed", {
35
+ enumerable: true,
36
+ configurable: true,
37
+ writable: true,
38
+ value: false
39
+ });
40
+ // .start() will always be called before the stream can be interacted
41
+ // with anyway
42
+ void streamControllerPromise.then((controller) => {
43
+ this.controller = controller;
44
+ });
45
+ this.passthroughFn = params.passthroughFn;
46
+ this.modes = params.modes;
47
+ }
48
+ push(chunk) {
49
+ this.passthroughFn?.(chunk);
50
+ this.controller.enqueue(chunk);
51
+ }
52
+ close() {
53
+ try {
54
+ this.controller.close();
55
+ }
56
+ catch (e) {
57
+ // pass
58
+ }
59
+ finally {
60
+ this._closed = true;
61
+ }
62
+ }
63
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
64
+ error(e) {
65
+ this.controller.error(e);
66
+ }
67
+ }
@@ -1,2 +1,56 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isCall = exports.Call = void 0;
4
+ class Call {
5
+ constructor({ func, name, input, retry, callbacks }) {
6
+ Object.defineProperty(this, "func", {
7
+ enumerable: true,
8
+ configurable: true,
9
+ writable: true,
10
+ value: void 0
11
+ });
12
+ Object.defineProperty(this, "name", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: void 0
17
+ });
18
+ Object.defineProperty(this, "input", {
19
+ enumerable: true,
20
+ configurable: true,
21
+ writable: true,
22
+ value: void 0
23
+ });
24
+ Object.defineProperty(this, "retry", {
25
+ enumerable: true,
26
+ configurable: true,
27
+ writable: true,
28
+ value: void 0
29
+ });
30
+ Object.defineProperty(this, "callbacks", {
31
+ enumerable: true,
32
+ configurable: true,
33
+ writable: true,
34
+ value: void 0
35
+ });
36
+ Object.defineProperty(this, "__lg_type", {
37
+ enumerable: true,
38
+ configurable: true,
39
+ writable: true,
40
+ value: "call"
41
+ });
42
+ this.func = func;
43
+ this.name = name;
44
+ this.input = input;
45
+ this.retry = retry;
46
+ this.callbacks = callbacks;
47
+ }
48
+ }
49
+ exports.Call = Call;
50
+ function isCall(value) {
51
+ return (typeof value === "object" &&
52
+ value !== null &&
53
+ "__lg_type" in value &&
54
+ value.__lg_type === "call");
55
+ }
56
+ exports.isCall = isCall;
@@ -8,6 +8,9 @@ import { RetryPolicy } from "./utils/index.js";
8
8
  import { Interrupt } from "../constants.js";
9
9
  import { type ManagedValueSpec } from "../managed/base.js";
10
10
  import { LangGraphRunnableConfig } from "./runnable_types.js";
11
+ /**
12
+ * Selects the type of output you'll receive when streaming from the graph. See [Streaming](/langgraphjs/how-tos/#streaming) for more details.
13
+ */
11
14
  export type StreamMode = "values" | "updates" | "debug" | "messages" | "custom";
12
15
  export type PregelInputType = any;
13
16
  export type PregelOutputType = any;
@@ -15,8 +18,12 @@ export type PregelOutputType = any;
15
18
  * Config for executing the graph.
16
19
  */
17
20
  export interface PregelOptions<Nn extends StrRecord<string, PregelNode>, Cc extends StrRecord<string, BaseChannel | ManagedValueSpec>, ConfigurableFieldType extends Record<string, any> = Record<string, any>> extends RunnableConfig<ConfigurableFieldType> {
18
- /** The stream mode for the graph run. Default is ["values"]. */
21
+ /**
22
+ * The stream mode for the graph run. See [Streaming](/langgraphjs/how-tos/#streaming) for more details.
23
+ * @default ["values"]
24
+ */
19
25
  streamMode?: StreamMode | StreamMode[];
26
+ /** The input keys to retrieve from the checkpoint on resume. You generally don't need to set this. */
20
27
  inputKeys?: keyof Cc | Array<keyof Cc>;
21
28
  /** The output keys to retrieve from the graph run. */
22
29
  outputKeys?: keyof Cc | Array<keyof Cc>;
@@ -54,27 +61,57 @@ export interface PregelInterface<Nn extends StrRecord<string, PregelNode>, Cc ex
54
61
  stream(input: PregelInputType, options?: Partial<PregelOptions<Nn, Cc, ConfigurableFieldType>>): Promise<IterableReadableStream<PregelOutputType>>;
55
62
  invoke(input: PregelInputType, options?: Partial<PregelOptions<Nn, Cc, ConfigurableFieldType>>): Promise<PregelOutputType>;
56
63
  }
64
+ /**
65
+ * Parameters for creating a Pregel graph.
66
+ * @internal
67
+ */
57
68
  export type PregelParams<Nn extends StrRecord<string, PregelNode>, Cc extends StrRecord<string, BaseChannel | ManagedValueSpec>> = {
69
+ /**
70
+ * The name of the graph. @see {@link Runnable.name}
71
+ */
72
+ name?: string;
73
+ /**
74
+ * The nodes in the graph.
75
+ */
58
76
  nodes: Nn;
77
+ /**
78
+ * The channels in the graph.
79
+ */
59
80
  channels: Cc;
60
81
  /**
82
+ * Whether to validate the graph.
83
+ *
61
84
  * @default true
62
85
  */
63
86
  autoValidate?: boolean;
64
87
  /**
65
- * @default "values"
88
+ * The stream mode for the graph run. See [Streaming](/langgraphjs/how-tos/#streaming) for more details.
89
+ *
90
+ * @default ["values"]
66
91
  */
67
92
  streamMode?: StreamMode | StreamMode[];
93
+ /**
94
+ * The input channels for the graph run.
95
+ */
68
96
  inputChannels: keyof Cc | Array<keyof Cc>;
97
+ /**
98
+ * The output channels for the graph run.
99
+ */
69
100
  outputChannels: keyof Cc | Array<keyof Cc>;
70
101
  /**
102
+ * After processing one of the nodes named in this list, the graph will be interrupted and a resume {@link Command} must be provided to proceed with the execution of this thread.
71
103
  * @default []
72
104
  */
73
105
  interruptAfter?: Array<keyof Nn> | All;
74
106
  /**
107
+ * Before processing one of the nodes named in this list, the graph will be interrupted and a resume {@link Command} must be provided to proceed with the execution of this thread.
75
108
  * @default []
76
109
  */
77
110
  interruptBefore?: Array<keyof Nn> | All;
111
+ /**
112
+ * The channels to stream from the graph run.
113
+ * @default []
114
+ */
78
115
  streamChannels?: keyof Cc | Array<keyof Cc>;
79
116
  /**
80
117
  * @default undefined
@@ -84,8 +121,17 @@ export type PregelParams<Nn extends StrRecord<string, PregelNode>, Cc extends St
84
121
  * @default false
85
122
  */
86
123
  debug?: boolean;
124
+ /**
125
+ * The {@link BaseCheckpointSaver | checkpointer} to use for the graph run.
126
+ */
87
127
  checkpointer?: BaseCheckpointSaver | false;
128
+ /**
129
+ * The default retry policy for this graph. For defaults, see {@link RetryPolicy}.
130
+ */
88
131
  retryPolicy?: RetryPolicy;
132
+ /**
133
+ * The configuration for the graph run.
134
+ */
89
135
  config?: LangGraphRunnableConfig;
90
136
  /**
91
137
  * Memory store to use for SharedValues.
@@ -98,7 +144,7 @@ export interface PregelTaskDescription {
98
144
  readonly error?: unknown;
99
145
  readonly interrupts: Interrupt[];
100
146
  readonly state?: LangGraphRunnableConfig | StateSnapshot;
101
- readonly path?: [string, ...(string | number)[]];
147
+ readonly path?: TaskPath;
102
148
  }
103
149
  export interface PregelExecutableTask<N extends PropertyKey, C extends PropertyKey> {
104
150
  readonly name: N;
@@ -109,7 +155,7 @@ export interface PregelExecutableTask<N extends PropertyKey, C extends PropertyK
109
155
  readonly triggers: Array<string>;
110
156
  readonly retry_policy?: RetryPolicy;
111
157
  readonly id: string;
112
- readonly path?: [string, ...(string | number)[]];
158
+ readonly path?: TaskPath;
113
159
  readonly subgraphs?: Runnable[];
114
160
  readonly writers: Runnable[];
115
161
  }
@@ -144,9 +190,35 @@ export interface StateSnapshot {
144
190
  */
145
191
  readonly tasks: PregelTaskDescription[];
146
192
  }
147
- export type PregelScratchpad<Resume> = {
193
+ export type PregelScratchpad<Resume = unknown> = {
194
+ /** Counter for tracking call invocations */
195
+ callCounter: number;
196
+ /** Counter for tracking interrupts */
148
197
  interruptCounter: number;
149
- usedNullResume: boolean;
198
+ /** List of resume values */
150
199
  resume: Resume[];
200
+ /** Single resume value for null task ID */
201
+ nullResume: Resume;
202
+ };
203
+ export type CallOptions = {
204
+ func: (...args: unknown[]) => unknown | Promise<unknown>;
205
+ name: string;
206
+ input: unknown;
207
+ retry?: RetryPolicy;
208
+ callbacks?: unknown;
151
209
  };
210
+ export declare class Call {
211
+ func: (...args: unknown[]) => unknown | Promise<unknown>;
212
+ name: string;
213
+ input: unknown;
214
+ retry?: RetryPolicy;
215
+ callbacks?: unknown;
216
+ readonly __lg_type = "call";
217
+ constructor({ func, name, input, retry, callbacks }: CallOptions);
218
+ }
219
+ export declare function isCall(value: unknown): value is Call;
220
+ export type SimpleTaskPath = [string, string | number];
221
+ export type VariadicTaskPath = [string, ...(string | number)[]];
222
+ export type CallTaskPath = [string, ...(string | number)[], Call] | [string, TaskPath, ...(string | number)[], Call];
223
+ export type TaskPath = SimpleTaskPath | CallTaskPath | VariadicTaskPath;
152
224
  export {};
@@ -1 +1,51 @@
1
- export {};
1
+ export class Call {
2
+ constructor({ func, name, input, retry, callbacks }) {
3
+ Object.defineProperty(this, "func", {
4
+ enumerable: true,
5
+ configurable: true,
6
+ writable: true,
7
+ value: void 0
8
+ });
9
+ Object.defineProperty(this, "name", {
10
+ enumerable: true,
11
+ configurable: true,
12
+ writable: true,
13
+ value: void 0
14
+ });
15
+ Object.defineProperty(this, "input", {
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true,
19
+ value: void 0
20
+ });
21
+ Object.defineProperty(this, "retry", {
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true,
25
+ value: void 0
26
+ });
27
+ Object.defineProperty(this, "callbacks", {
28
+ enumerable: true,
29
+ configurable: true,
30
+ writable: true,
31
+ value: void 0
32
+ });
33
+ Object.defineProperty(this, "__lg_type", {
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true,
37
+ value: "call"
38
+ });
39
+ this.func = func;
40
+ this.name = name;
41
+ this.input = input;
42
+ this.retry = retry;
43
+ this.callbacks = callbacks;
44
+ }
45
+ }
46
+ export function isCall(value) {
47
+ return (typeof value === "object" &&
48
+ value !== null &&
49
+ "__lg_type" in value &&
50
+ value.__lg_type === "call");
51
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ensureLangGraphConfig = void 0;
3
+ exports.getConfig = exports.getWriter = exports.getStore = exports.ensureLangGraphConfig = void 0;
4
4
  const singletons_1 = require("@langchain/core/singletons");
5
5
  const COPIABLE_KEYS = ["tags", "metadata", "callbacks", "configurable"];
6
6
  const CONFIG_KEYS = [
@@ -18,6 +18,7 @@ const CONFIG_KEYS = [
18
18
  "writer",
19
19
  "interruptBefore",
20
20
  "interruptAfter",
21
+ "signal",
21
22
  ];
22
23
  const DEFAULT_RECURSION_LIMIT = 25;
23
24
  function ensureLangGraphConfig(...configs) {
@@ -81,3 +82,27 @@ function ensureLangGraphConfig(...configs) {
81
82
  return empty;
82
83
  }
83
84
  exports.ensureLangGraphConfig = ensureLangGraphConfig;
85
+ /**
86
+ * A helper utility function that returns the {@link BaseStore} that was set when the graph was initialized
87
+ *
88
+ * @returns a reference to the {@link BaseStore} that was set when the graph was initialized
89
+ */
90
+ function getStore() {
91
+ const config = singletons_1.AsyncLocalStorageProviderSingleton.getRunnableConfig();
92
+ return config?.store;
93
+ }
94
+ exports.getStore = getStore;
95
+ /**
96
+ * A helper utility function that returns the {@link LangGraphRunnableConfig#writer} if "custom" stream mode is enabled, otherwise undefined
97
+ *
98
+ * @returns a reference to the {@link LangGraphRunnableConfig#writer} if "custom" stream mode is enabled, otherwise undefined
99
+ */
100
+ function getWriter() {
101
+ const config = singletons_1.AsyncLocalStorageProviderSingleton.getRunnableConfig();
102
+ return config?.configurable?.writer;
103
+ }
104
+ exports.getWriter = getWriter;
105
+ function getConfig() {
106
+ return singletons_1.AsyncLocalStorageProviderSingleton.getRunnableConfig();
107
+ }
108
+ exports.getConfig = getConfig;
@@ -1,3 +1,17 @@
1
1
  import { RunnableConfig } from "@langchain/core/runnables";
2
+ import { BaseStore } from "@langchain/langgraph-checkpoint";
2
3
  import { LangGraphRunnableConfig } from "../runnable_types.js";
3
4
  export declare function ensureLangGraphConfig(...configs: (LangGraphRunnableConfig | undefined)[]): RunnableConfig;
5
+ /**
6
+ * A helper utility function that returns the {@link BaseStore} that was set when the graph was initialized
7
+ *
8
+ * @returns a reference to the {@link BaseStore} that was set when the graph was initialized
9
+ */
10
+ export declare function getStore(): BaseStore | undefined;
11
+ /**
12
+ * A helper utility function that returns the {@link LangGraphRunnableConfig#writer} if "custom" stream mode is enabled, otherwise undefined
13
+ *
14
+ * @returns a reference to the {@link LangGraphRunnableConfig#writer} if "custom" stream mode is enabled, otherwise undefined
15
+ */
16
+ export declare function getWriter(): ((chunk: unknown) => void) | undefined;
17
+ export declare function getConfig(): LangGraphRunnableConfig;
@@ -15,6 +15,7 @@ const CONFIG_KEYS = [
15
15
  "writer",
16
16
  "interruptBefore",
17
17
  "interruptAfter",
18
+ "signal",
18
19
  ];
19
20
  const DEFAULT_RECURSION_LIMIT = 25;
20
21
  export function ensureLangGraphConfig(...configs) {
@@ -77,3 +78,24 @@ export function ensureLangGraphConfig(...configs) {
77
78
  }
78
79
  return empty;
79
80
  }
81
+ /**
82
+ * A helper utility function that returns the {@link BaseStore} that was set when the graph was initialized
83
+ *
84
+ * @returns a reference to the {@link BaseStore} that was set when the graph was initialized
85
+ */
86
+ export function getStore() {
87
+ const config = AsyncLocalStorageProviderSingleton.getRunnableConfig();
88
+ return config?.store;
89
+ }
90
+ /**
91
+ * A helper utility function that returns the {@link LangGraphRunnableConfig#writer} if "custom" stream mode is enabled, otherwise undefined
92
+ *
93
+ * @returns a reference to the {@link LangGraphRunnableConfig#writer} if "custom" stream mode is enabled, otherwise undefined
94
+ */
95
+ export function getWriter() {
96
+ const config = AsyncLocalStorageProviderSingleton.getRunnableConfig();
97
+ return config?.configurable?.writer;
98
+ }
99
+ export function getConfig() {
100
+ return AsyncLocalStorageProviderSingleton.getRunnableConfig();
101
+ }
@@ -11,7 +11,7 @@ export declare const PASSTHROUGH: {
11
11
  * Mapping of write channels to Runnables that return the value to be written,
12
12
  * or None to skip writing.
13
13
  */
14
- export declare class ChannelWrite<RunInput = any> extends RunnableCallable {
14
+ export declare class ChannelWrite<RunInput = any> extends RunnableCallable<RunInput, RunInput> {
15
15
  writes: Array<ChannelWriteEntry | ChannelWriteTupleEntry | Send>;
16
16
  constructor(writes: Array<ChannelWriteEntry | ChannelWriteTupleEntry | Send>, tags?: string[]);
17
17
  _write(input: unknown, config: RunnableConfig): Promise<unknown>;
package/dist/utils.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.patchConfigurable = exports.gatherIteratorSync = exports.gatherIterator = exports.prefixGenerator = exports.RunnableCallable = void 0;
3
+ exports.isGeneratorFunction = exports.isAsyncGeneratorFunction = exports.patchConfigurable = exports.gatherIteratorSync = exports.gatherIterator = exports.prefixGenerator = exports.RunnableCallable = void 0;
4
4
  const runnables_1 = require("@langchain/core/runnables");
5
5
  const singletons_1 = require("@langchain/core/singletons");
6
6
  const config_js_1 = require("./pregel/utils/config.cjs");
@@ -141,3 +141,17 @@ patch) {
141
141
  }
142
142
  }
143
143
  exports.patchConfigurable = patchConfigurable;
144
+ function isAsyncGeneratorFunction(val) {
145
+ return (val != null &&
146
+ typeof val === "function" &&
147
+ // eslint-disable-next-line no-instanceof/no-instanceof
148
+ val instanceof Object.getPrototypeOf(async function* () { }).constructor);
149
+ }
150
+ exports.isAsyncGeneratorFunction = isAsyncGeneratorFunction;
151
+ function isGeneratorFunction(val) {
152
+ return (val != null &&
153
+ typeof val === "function" &&
154
+ // eslint-disable-next-line no-instanceof/no-instanceof
155
+ val instanceof Object.getPrototypeOf(function* () { }).constructor);
156
+ }
157
+ exports.isGeneratorFunction = isGeneratorFunction;
package/dist/utils.d.ts CHANGED
@@ -16,7 +16,7 @@ export declare class RunnableCallable<I = unknown, O = unknown> extends Runnable
16
16
  recurse: boolean;
17
17
  constructor(fields: RunnableCallableArgs);
18
18
  protected _tracedInvoke(input: I, config?: Partial<RunnableConfig>, runManager?: CallbackManagerForChainRun): Promise<O>;
19
- invoke(input: any, options?: Partial<RunnableConfig> | undefined): Promise<any>;
19
+ invoke(input: I, options?: Partial<RunnableConfig> | undefined): Promise<O>;
20
20
  }
21
21
  export declare function prefixGenerator<T, Prefix extends string>(generator: Generator<T>, prefix: Prefix): Generator<[Prefix, T]>;
22
22
  export declare function prefixGenerator<T>(generator: Generator<T>, prefix?: undefined): Generator<T>;
@@ -24,3 +24,5 @@ export declare function prefixGenerator<T, Prefix extends string | undefined = u
24
24
  export declare function gatherIterator<T>(i: AsyncIterable<T> | Promise<AsyncIterable<T>> | Iterable<T> | Promise<Iterable<T>>): Promise<Array<T>>;
25
25
  export declare function gatherIteratorSync<T>(i: Iterable<T>): Array<T>;
26
26
  export declare function patchConfigurable(config: RunnableConfig | undefined, patch: Record<string, any>): RunnableConfig;
27
+ export declare function isAsyncGeneratorFunction(val: unknown): val is AsyncGeneratorFunction;
28
+ export declare function isGeneratorFunction(val: unknown): val is GeneratorFunction;
package/dist/utils.js CHANGED
@@ -133,3 +133,15 @@ patch) {
133
133
  };
134
134
  }
135
135
  }
136
+ export function isAsyncGeneratorFunction(val) {
137
+ return (val != null &&
138
+ typeof val === "function" &&
139
+ // eslint-disable-next-line no-instanceof/no-instanceof
140
+ val instanceof Object.getPrototypeOf(async function* () { }).constructor);
141
+ }
142
+ export function isGeneratorFunction(val) {
143
+ return (val != null &&
144
+ typeof val === "function" &&
145
+ // eslint-disable-next-line no-instanceof/no-instanceof
146
+ val instanceof Object.getPrototypeOf(function* () { }).constructor);
147
+ }
package/dist/web.cjs CHANGED
@@ -14,15 +14,14 @@ 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.MessagesAnnotation = exports.InMemoryStore = exports.AsyncBatchedStore = exports.BaseStore = exports.BaseCheckpointSaver = exports.emptyCheckpoint = exports.copyCheckpoint = exports.MemorySaver = exports.interrupt = exports.isCommand = exports.Command = exports.Send = exports.BinaryOperatorAggregate = exports.BaseChannel = exports.Annotation = exports.messagesStateReducer = exports.MessageGraph = exports.CompiledStateGraph = exports.StateGraph = exports.START = exports.Graph = exports.END = void 0;
17
+ exports.MessagesAnnotation = exports.task = exports.entrypoint = exports.InMemoryStore = exports.AsyncBatchedStore = exports.BaseStore = exports.BaseCheckpointSaver = exports.emptyCheckpoint = exports.copyCheckpoint = exports.MemorySaver = exports.END = exports.START = exports.isCommand = exports.Command = exports.Send = exports.BinaryOperatorAggregate = exports.BaseChannel = exports.Annotation = exports.addMessages = exports.messagesStateReducer = exports.MessageGraph = exports.CompiledStateGraph = exports.StateGraph = exports.Graph = void 0;
18
18
  var index_js_1 = require("./graph/index.cjs");
19
- Object.defineProperty(exports, "END", { enumerable: true, get: function () { return index_js_1.END; } });
20
19
  Object.defineProperty(exports, "Graph", { enumerable: true, get: function () { return index_js_1.Graph; } });
21
- Object.defineProperty(exports, "START", { enumerable: true, get: function () { return index_js_1.START; } });
22
20
  Object.defineProperty(exports, "StateGraph", { enumerable: true, get: function () { return index_js_1.StateGraph; } });
23
21
  Object.defineProperty(exports, "CompiledStateGraph", { enumerable: true, get: function () { return index_js_1.CompiledStateGraph; } });
24
22
  Object.defineProperty(exports, "MessageGraph", { enumerable: true, get: function () { return index_js_1.MessageGraph; } });
25
23
  Object.defineProperty(exports, "messagesStateReducer", { enumerable: true, get: function () { return index_js_1.messagesStateReducer; } });
24
+ Object.defineProperty(exports, "addMessages", { enumerable: true, get: function () { return index_js_1.messagesStateReducer; } });
26
25
  Object.defineProperty(exports, "Annotation", { enumerable: true, get: function () { return index_js_1.Annotation; } });
27
26
  __exportStar(require("./errors.cjs"), exports);
28
27
  var index_js_2 = require("./channels/index.cjs");
@@ -32,8 +31,8 @@ var constants_js_1 = require("./constants.cjs");
32
31
  Object.defineProperty(exports, "Send", { enumerable: true, get: function () { return constants_js_1.Send; } });
33
32
  Object.defineProperty(exports, "Command", { enumerable: true, get: function () { return constants_js_1.Command; } });
34
33
  Object.defineProperty(exports, "isCommand", { enumerable: true, get: function () { return constants_js_1.isCommand; } });
35
- var interrupt_js_1 = require("./interrupt.cjs");
36
- Object.defineProperty(exports, "interrupt", { enumerable: true, get: function () { return interrupt_js_1.interrupt; } });
34
+ Object.defineProperty(exports, "START", { enumerable: true, get: function () { return constants_js_1.START; } });
35
+ Object.defineProperty(exports, "END", { enumerable: true, get: function () { return constants_js_1.END; } });
37
36
  var langgraph_checkpoint_1 = require("@langchain/langgraph-checkpoint");
38
37
  Object.defineProperty(exports, "MemorySaver", { enumerable: true, get: function () { return langgraph_checkpoint_1.MemorySaver; } });
39
38
  Object.defineProperty(exports, "copyCheckpoint", { enumerable: true, get: function () { return langgraph_checkpoint_1.copyCheckpoint; } });
@@ -43,5 +42,8 @@ Object.defineProperty(exports, "BaseStore", { enumerable: true, get: function ()
43
42
  Object.defineProperty(exports, "AsyncBatchedStore", { enumerable: true, get: function () { return langgraph_checkpoint_1.AsyncBatchedStore; } });
44
43
  Object.defineProperty(exports, "InMemoryStore", { enumerable: true, get: function () { return langgraph_checkpoint_1.InMemoryStore; } });
45
44
  __exportStar(require("./managed/index.cjs"), exports);
45
+ var index_js_3 = require("./func/index.cjs");
46
+ Object.defineProperty(exports, "entrypoint", { enumerable: true, get: function () { return index_js_3.entrypoint; } });
47
+ Object.defineProperty(exports, "task", { enumerable: true, get: function () { return index_js_3.task; } });
46
48
  var messages_annotation_js_1 = require("./graph/messages_annotation.cjs");
47
49
  Object.defineProperty(exports, "MessagesAnnotation", { enumerable: true, get: function () { return messages_annotation_js_1.MessagesAnnotation; } });
package/dist/web.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- export { END, Graph, type StateGraphArgs, START, StateGraph, CompiledStateGraph, MessageGraph, messagesStateReducer, type Messages, Annotation, type StateType, type UpdateType, type NodeType, type StateDefinition, type SingleReducer, type CompiledGraph, } from "./graph/index.js";
2
- export type { StateSnapshot } from "./pregel/types.js";
1
+ export { Graph, type StateGraphArgs, StateGraph, CompiledStateGraph, MessageGraph, messagesStateReducer, messagesStateReducer as addMessages, type Messages, Annotation, type StateType, type UpdateType, type NodeType, type StateDefinition, type SingleReducer, type CompiledGraph, } from "./graph/index.js";
2
+ export type { StateSnapshot, StreamMode, PregelParams, PregelOptions, } from "./pregel/types.js";
3
3
  export * from "./errors.js";
4
4
  export { BaseChannel, type BinaryOperator, BinaryOperatorAggregate, type AnyValue, type WaitForNames, type DynamicBarrierValue, type LastValue, type NamedBarrierValue, type Topic, } from "./channels/index.js";
5
5
  export { type AnnotationRoot as _INTERNAL_ANNOTATION_ROOT } from "./graph/index.js";
6
6
  export { type RetryPolicy } from "./pregel/utils/index.js";
7
- export { Send, Command, type CommandParams, isCommand, type Interrupt, } from "./constants.js";
8
- export { interrupt } from "./interrupt.js";
7
+ export { Send, Command, type CommandParams, isCommand, START, END, type Interrupt, } from "./constants.js";
9
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, InMemoryStore, type NameSpacePath, type NamespaceMatchType, type MatchCondition, type ListNamespacesOperation, } from "@langchain/langgraph-checkpoint";
10
9
  export * from "./managed/index.js";
10
+ export { entrypoint, type EntrypointOptions, task, type TaskOptions, } from "./func/index.js";
11
11
  export { MessagesAnnotation } from "./graph/messages_annotation.js";
12
12
  export { type LangGraphRunnableConfig } from "./pregel/runnable_types.js";
package/dist/web.js CHANGED
@@ -1,8 +1,8 @@
1
- export { END, Graph, START, StateGraph, CompiledStateGraph, MessageGraph, messagesStateReducer, Annotation, } from "./graph/index.js";
1
+ export { Graph, StateGraph, CompiledStateGraph, MessageGraph, messagesStateReducer, messagesStateReducer as addMessages, Annotation, } from "./graph/index.js";
2
2
  export * from "./errors.js";
3
3
  export { BaseChannel, BinaryOperatorAggregate, } from "./channels/index.js";
4
- export { Send, Command, isCommand, } from "./constants.js";
5
- export { interrupt } from "./interrupt.js";
4
+ export { Send, Command, isCommand, START, END, } from "./constants.js";
6
5
  export { MemorySaver, copyCheckpoint, emptyCheckpoint, BaseCheckpointSaver, BaseStore, AsyncBatchedStore, InMemoryStore, } from "@langchain/langgraph-checkpoint";
7
6
  export * from "./managed/index.js";
7
+ export { entrypoint, task, } from "./func/index.js";
8
8
  export { MessagesAnnotation } from "./graph/messages_annotation.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph",
3
- "version": "0.2.41",
3
+ "version": "0.2.43-rc.0",
4
4
  "description": "LangGraph",
5
5
  "type": "module",
6
6
  "engines": {
@@ -31,7 +31,7 @@
31
31
  "author": "LangChain",
32
32
  "license": "MIT",
33
33
  "dependencies": {
34
- "@langchain/langgraph-checkpoint": "~0.0.13",
34
+ "@langchain/langgraph-checkpoint": "~0.0.14",
35
35
  "@langchain/langgraph-sdk": "~0.0.32",
36
36
  "uuid": "^10.0.0",
37
37
  "zod": "^3.23.8"
@@ -41,12 +41,12 @@
41
41
  },
42
42
  "devDependencies": {
43
43
  "@jest/globals": "^29.5.0",
44
- "@langchain/anthropic": "^0.3.5",
45
- "@langchain/community": "^0.3.9",
46
- "@langchain/core": "^0.3.24",
44
+ "@langchain/anthropic": "^0.3.12",
45
+ "@langchain/community": "^0.3.27",
46
+ "@langchain/core": "^0.3.36",
47
47
  "@langchain/langgraph-checkpoint-postgres": "workspace:*",
48
48
  "@langchain/langgraph-checkpoint-sqlite": "workspace:*",
49
- "@langchain/openai": "^0.3.11",
49
+ "@langchain/openai": "^0.4.0",
50
50
  "@langchain/scripts": ">=0.1.3 <0.2.0",
51
51
  "@swc/core": "^1.3.90",
52
52
  "@swc/jest": "^0.2.29",
@@ -68,11 +68,11 @@
68
68
  "eslint-plugin-prettier": "^4.2.1",
69
69
  "jest": "^29.5.0",
70
70
  "jest-environment-node": "^29.6.4",
71
- "langchain": "^0.3.4",
71
+ "langchain": "^0.3.13",
72
72
  "pg": "^8.13.0",
73
73
  "prettier": "^2.8.3",
74
74
  "release-it": "^17.6.0",
75
- "rollup": "^4.29.0",
75
+ "rollup": "^4.29.2",
76
76
  "ts-jest": "^29.1.0",
77
77
  "tsx": "^4.7.0",
78
78
  "typescript": "^4.9.5 || ^5.4.5",