@langchain/langgraph 0.2.17 → 0.2.18
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/graph/graph.cjs +1 -0
- package/dist/graph/graph.js +1 -0
- package/dist/graph/state.cjs +15 -2
- package/dist/graph/state.js +16 -3
- package/dist/prebuilt/react_agent_executor.cjs +1 -1
- package/dist/prebuilt/react_agent_executor.js +1 -1
- package/dist/prebuilt/tool_node.cjs +6 -0
- package/dist/prebuilt/tool_node.d.ts +1 -0
- package/dist/prebuilt/tool_node.js +6 -0
- package/dist/pregel/index.cjs +4 -3
- package/dist/pregel/index.js +4 -3
- package/dist/pregel/read.cjs +2 -0
- package/dist/pregel/read.js +2 -0
- package/dist/pregel/write.cjs +1 -0
- package/dist/pregel/write.d.ts +2 -2
- package/dist/pregel/write.js +1 -0
- package/dist/utils.cjs +4 -3
- package/dist/utils.js +4 -3
- package/package.json +2 -2
package/dist/graph/graph.cjs
CHANGED
package/dist/graph/graph.js
CHANGED
package/dist/graph/state.cjs
CHANGED
|
@@ -217,9 +217,22 @@ class StateGraph extends graph_js_1.Graph {
|
|
|
217
217
|
if (options?.input !== undefined) {
|
|
218
218
|
this._addSchema(options.input.spec);
|
|
219
219
|
}
|
|
220
|
-
|
|
220
|
+
let runnable;
|
|
221
|
+
if (runnables_1.Runnable.isRunnable(action)) {
|
|
222
|
+
runnable = action;
|
|
223
|
+
}
|
|
224
|
+
else if (typeof action === "function") {
|
|
225
|
+
runnable = new utils_js_1.RunnableCallable({
|
|
226
|
+
func: action,
|
|
227
|
+
name: key,
|
|
228
|
+
trace: false,
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
runnable = (0, runnables_1._coerceToRunnable)(action);
|
|
233
|
+
}
|
|
221
234
|
const nodeSpec = {
|
|
222
|
-
runnable,
|
|
235
|
+
runnable: runnable,
|
|
223
236
|
retryPolicy: options?.retryPolicy,
|
|
224
237
|
metadata: options?.metadata,
|
|
225
238
|
input: options?.input?.spec ?? this._schemaDefinition,
|
package/dist/graph/state.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
2
|
-
import { _coerceToRunnable, } from "@langchain/core/runnables";
|
|
2
|
+
import { _coerceToRunnable, Runnable, } from "@langchain/core/runnables";
|
|
3
3
|
import { isBaseChannel } from "../channels/base.js";
|
|
4
4
|
import { END, CompiledGraph, Graph, START, } from "./graph.js";
|
|
5
5
|
import { ChannelWrite, PASSTHROUGH, SKIP_WRITE, } from "../pregel/write.js";
|
|
@@ -214,9 +214,22 @@ export class StateGraph extends Graph {
|
|
|
214
214
|
if (options?.input !== undefined) {
|
|
215
215
|
this._addSchema(options.input.spec);
|
|
216
216
|
}
|
|
217
|
-
|
|
217
|
+
let runnable;
|
|
218
|
+
if (Runnable.isRunnable(action)) {
|
|
219
|
+
runnable = action;
|
|
220
|
+
}
|
|
221
|
+
else if (typeof action === "function") {
|
|
222
|
+
runnable = new RunnableCallable({
|
|
223
|
+
func: action,
|
|
224
|
+
name: key,
|
|
225
|
+
trace: false,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
runnable = _coerceToRunnable(action);
|
|
230
|
+
}
|
|
218
231
|
const nodeSpec = {
|
|
219
|
-
runnable,
|
|
232
|
+
runnable: runnable,
|
|
220
233
|
retryPolicy: options?.retryPolicy,
|
|
221
234
|
metadata: options?.metadata,
|
|
222
235
|
input: options?.input?.spec ?? this._schemaDefinition,
|
|
@@ -95,7 +95,7 @@ function createReactAgent(params) {
|
|
|
95
95
|
const workflow = new index_js_1.StateGraph({
|
|
96
96
|
channels: schema,
|
|
97
97
|
})
|
|
98
|
-
.addNode("agent",
|
|
98
|
+
.addNode("agent", callModel)
|
|
99
99
|
.addNode("tools", new tool_node_js_1.ToolNode(toolClasses))
|
|
100
100
|
.addEdge(index_js_1.START, "agent")
|
|
101
101
|
.addConditionalEdges("agent", shouldContinue, {
|
|
@@ -92,7 +92,7 @@ export function createReactAgent(params) {
|
|
|
92
92
|
const workflow = new StateGraph({
|
|
93
93
|
channels: schema,
|
|
94
94
|
})
|
|
95
|
-
.addNode("agent",
|
|
95
|
+
.addNode("agent", callModel)
|
|
96
96
|
.addNode("tools", new ToolNode(toolClasses))
|
|
97
97
|
.addEdge(START, "agent")
|
|
98
98
|
.addConditionalEdges("agent", shouldContinue, {
|
|
@@ -138,6 +138,12 @@ class ToolNode extends utils_js_1.RunnableCallable {
|
|
|
138
138
|
writable: true,
|
|
139
139
|
value: true
|
|
140
140
|
});
|
|
141
|
+
Object.defineProperty(this, "trace", {
|
|
142
|
+
enumerable: true,
|
|
143
|
+
configurable: true,
|
|
144
|
+
writable: true,
|
|
145
|
+
value: false
|
|
146
|
+
});
|
|
141
147
|
this.tools = tools;
|
|
142
148
|
this.handleToolErrors = handleToolErrors ?? this.handleToolErrors;
|
|
143
149
|
}
|
|
@@ -129,6 +129,7 @@ export type ToolNodeOptions = {
|
|
|
129
129
|
export declare class ToolNode<T = any> extends RunnableCallable<T, T> {
|
|
130
130
|
tools: (StructuredToolInterface | RunnableToolLike)[];
|
|
131
131
|
handleToolErrors: boolean;
|
|
132
|
+
trace: boolean;
|
|
132
133
|
constructor(tools: (StructuredToolInterface | RunnableToolLike)[], options?: ToolNodeOptions);
|
|
133
134
|
protected run(input: any, config: RunnableConfig): Promise<T>;
|
|
134
135
|
}
|
|
@@ -135,6 +135,12 @@ export class ToolNode extends RunnableCallable {
|
|
|
135
135
|
writable: true,
|
|
136
136
|
value: true
|
|
137
137
|
});
|
|
138
|
+
Object.defineProperty(this, "trace", {
|
|
139
|
+
enumerable: true,
|
|
140
|
+
configurable: true,
|
|
141
|
+
writable: true,
|
|
142
|
+
value: false
|
|
143
|
+
});
|
|
138
144
|
this.tools = tools;
|
|
139
145
|
this.handleToolErrors = handleToolErrors ?? this.handleToolErrors;
|
|
140
146
|
}
|
package/dist/pregel/index.cjs
CHANGED
|
@@ -524,9 +524,10 @@ class Pregel extends runnables_1.Runnable {
|
|
|
524
524
|
const task = {
|
|
525
525
|
name: asNode,
|
|
526
526
|
input: values,
|
|
527
|
-
proc:
|
|
528
|
-
|
|
529
|
-
|
|
527
|
+
proc: writers.length > 1
|
|
528
|
+
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
529
|
+
runnables_1.RunnableSequence.from(writers, { omitSequenceTags: true })
|
|
530
|
+
: writers[0],
|
|
530
531
|
writes: [],
|
|
531
532
|
triggers: [constants_js_1.INTERRUPT],
|
|
532
533
|
id: (0, langgraph_checkpoint_1.uuid5)(constants_js_1.INTERRUPT, checkpoint.id),
|
package/dist/pregel/index.js
CHANGED
|
@@ -517,9 +517,10 @@ export class Pregel extends Runnable {
|
|
|
517
517
|
const task = {
|
|
518
518
|
name: asNode,
|
|
519
519
|
input: values,
|
|
520
|
-
proc:
|
|
521
|
-
|
|
522
|
-
|
|
520
|
+
proc: writers.length > 1
|
|
521
|
+
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
522
|
+
RunnableSequence.from(writers, { omitSequenceTags: true })
|
|
523
|
+
: writers[0],
|
|
523
524
|
writes: [],
|
|
524
525
|
triggers: [INTERRUPT],
|
|
525
526
|
id: uuid5(INTERRUPT, checkpoint.id),
|
package/dist/pregel/read.cjs
CHANGED
|
@@ -185,6 +185,7 @@ class PregelNode extends runnables_1.RunnableBinding {
|
|
|
185
185
|
first: writers[0],
|
|
186
186
|
middle: writers.slice(1, writers.length - 1),
|
|
187
187
|
last: writers[writers.length - 1],
|
|
188
|
+
omitSequenceTags: true,
|
|
188
189
|
});
|
|
189
190
|
}
|
|
190
191
|
else if (writers.length > 0) {
|
|
@@ -192,6 +193,7 @@ class PregelNode extends runnables_1.RunnableBinding {
|
|
|
192
193
|
first: this.bound,
|
|
193
194
|
middle: writers.slice(0, writers.length - 1),
|
|
194
195
|
last: writers[writers.length - 1],
|
|
196
|
+
omitSequenceTags: true,
|
|
195
197
|
});
|
|
196
198
|
}
|
|
197
199
|
else {
|
package/dist/pregel/read.js
CHANGED
|
@@ -181,6 +181,7 @@ export class PregelNode extends RunnableBinding {
|
|
|
181
181
|
first: writers[0],
|
|
182
182
|
middle: writers.slice(1, writers.length - 1),
|
|
183
183
|
last: writers[writers.length - 1],
|
|
184
|
+
omitSequenceTags: true,
|
|
184
185
|
});
|
|
185
186
|
}
|
|
186
187
|
else if (writers.length > 0) {
|
|
@@ -188,6 +189,7 @@ export class PregelNode extends RunnableBinding {
|
|
|
188
189
|
first: this.bound,
|
|
189
190
|
middle: writers.slice(0, writers.length - 1),
|
|
190
191
|
last: writers[writers.length - 1],
|
|
192
|
+
omitSequenceTags: true,
|
|
191
193
|
});
|
|
192
194
|
}
|
|
193
195
|
else {
|
package/dist/pregel/write.cjs
CHANGED
|
@@ -88,6 +88,7 @@ class ChannelWrite extends utils_js_1.RunnableCallable {
|
|
|
88
88
|
async _write(input, config) {
|
|
89
89
|
const values = await this._getWriteValues(input, config);
|
|
90
90
|
ChannelWrite.doWrite(config, values);
|
|
91
|
+
return input;
|
|
91
92
|
}
|
|
92
93
|
// TODO: Support requireAtLeastOneOf
|
|
93
94
|
static doWrite(config, values) {
|
package/dist/pregel/write.d.ts
CHANGED
|
@@ -15,9 +15,9 @@ export declare class ChannelWrite<RunInput = any> extends RunnableCallable {
|
|
|
15
15
|
writes: Array<ChannelWriteEntry | Send>;
|
|
16
16
|
constructor(writes: Array<ChannelWriteEntry | Send>, tags?: string[]);
|
|
17
17
|
_getWriteValues(input: unknown, config: RunnableConfig): Promise<[string, unknown][]>;
|
|
18
|
-
_write(input: unknown, config: RunnableConfig): Promise<
|
|
18
|
+
_write(input: unknown, config: RunnableConfig): Promise<unknown>;
|
|
19
19
|
static doWrite(config: RunnableConfig, values: [string, unknown][]): void;
|
|
20
|
-
static isWriter(runnable: RunnableLike):
|
|
20
|
+
static isWriter(runnable: RunnableLike): runnable is ChannelWrite;
|
|
21
21
|
static registerWriter<T extends Runnable>(runnable: T): T;
|
|
22
22
|
}
|
|
23
23
|
export interface ChannelWriteEntry {
|
package/dist/pregel/write.js
CHANGED
|
@@ -85,6 +85,7 @@ export class ChannelWrite extends RunnableCallable {
|
|
|
85
85
|
async _write(input, config) {
|
|
86
86
|
const values = await this._getWriteValues(input, config);
|
|
87
87
|
ChannelWrite.doWrite(config, values);
|
|
88
|
+
return input;
|
|
88
89
|
}
|
|
89
90
|
// TODO: Support requireAtLeastOneOf
|
|
90
91
|
static doWrite(config, values) {
|
package/dist/utils.cjs
CHANGED
|
@@ -74,14 +74,15 @@ class RunnableCallable extends runnables_1.Runnable {
|
|
|
74
74
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
75
75
|
let returnValue;
|
|
76
76
|
const config = (0, config_js_1.ensureLangGraphConfig)(options);
|
|
77
|
+
const mergedConfig = (0, runnables_1.mergeConfigs)(this.config, config);
|
|
77
78
|
if (this.trace) {
|
|
78
|
-
returnValue = await this._callWithConfig(this._tracedInvoke, input,
|
|
79
|
+
returnValue = await this._callWithConfig(this._tracedInvoke, input, mergedConfig);
|
|
79
80
|
}
|
|
80
81
|
else {
|
|
81
|
-
returnValue = await
|
|
82
|
+
returnValue = await singletons_1.AsyncLocalStorageProviderSingleton.runWithConfig(mergedConfig, async () => this.func(input, mergedConfig));
|
|
82
83
|
}
|
|
83
84
|
if (runnables_1.Runnable.isRunnable(returnValue) && this.recurse) {
|
|
84
|
-
return await returnValue.invoke(input,
|
|
85
|
+
return await singletons_1.AsyncLocalStorageProviderSingleton.runWithConfig(mergedConfig, async () => returnValue.invoke(input, mergedConfig));
|
|
85
86
|
}
|
|
86
87
|
return returnValue;
|
|
87
88
|
}
|
package/dist/utils.js
CHANGED
|
@@ -71,14 +71,15 @@ export class RunnableCallable extends Runnable {
|
|
|
71
71
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
72
72
|
let returnValue;
|
|
73
73
|
const config = ensureLangGraphConfig(options);
|
|
74
|
+
const mergedConfig = mergeConfigs(this.config, config);
|
|
74
75
|
if (this.trace) {
|
|
75
|
-
returnValue = await this._callWithConfig(this._tracedInvoke, input,
|
|
76
|
+
returnValue = await this._callWithConfig(this._tracedInvoke, input, mergedConfig);
|
|
76
77
|
}
|
|
77
78
|
else {
|
|
78
|
-
returnValue = await
|
|
79
|
+
returnValue = await AsyncLocalStorageProviderSingleton.runWithConfig(mergedConfig, async () => this.func(input, mergedConfig));
|
|
79
80
|
}
|
|
80
81
|
if (Runnable.isRunnable(returnValue) && this.recurse) {
|
|
81
|
-
return await returnValue.invoke(input,
|
|
82
|
+
return await AsyncLocalStorageProviderSingleton.runWithConfig(mergedConfig, async () => returnValue.invoke(input, mergedConfig));
|
|
82
83
|
}
|
|
83
84
|
return returnValue;
|
|
84
85
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/langgraph",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.18",
|
|
4
4
|
"description": "LangGraph",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@jest/globals": "^29.5.0",
|
|
44
44
|
"@langchain/anthropic": "^0.3.0",
|
|
45
45
|
"@langchain/community": "^0.3.0",
|
|
46
|
-
"@langchain/core": "^0.3.
|
|
46
|
+
"@langchain/core": "^0.3.14",
|
|
47
47
|
"@langchain/langgraph-checkpoint-postgres": "workspace:*",
|
|
48
48
|
"@langchain/langgraph-checkpoint-sqlite": "workspace:*",
|
|
49
49
|
"@langchain/openai": "^0.3.0",
|