@langchain/langgraph 0.2.32 → 0.2.34
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/constants.cjs +84 -5
- package/dist/constants.d.ts +64 -3
- package/dist/constants.js +82 -3
- package/dist/errors.cjs +11 -1
- package/dist/errors.d.ts +4 -0
- package/dist/errors.js +9 -0
- package/dist/graph/graph.cjs +9 -1
- package/dist/graph/graph.js +10 -2
- package/dist/graph/state.cjs +73 -31
- package/dist/graph/state.js +75 -33
- package/dist/prebuilt/react_agent_executor.cjs +2 -2
- package/dist/prebuilt/react_agent_executor.d.ts +5 -4
- package/dist/prebuilt/react_agent_executor.js +3 -3
- package/dist/prebuilt/tool_node.cjs +15 -2
- package/dist/prebuilt/tool_node.js +15 -2
- package/dist/pregel/loop.cjs +2 -2
- package/dist/pregel/loop.js +3 -3
- package/dist/pregel/messages.cjs +8 -0
- package/dist/pregel/messages.d.ts +1 -0
- package/dist/pregel/messages.js +8 -0
- package/dist/pregel/write.cjs +64 -30
- package/dist/pregel/write.d.ts +7 -3
- package/dist/pregel/write.js +64 -30
- package/dist/web.cjs +2 -1
- package/dist/web.d.ts +1 -1
- package/dist/web.js +1 -1
- package/package.json +2 -2
package/dist/pregel/write.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Runnable, } from "@langchain/core/runnables";
|
|
1
2
|
import { _isSend, CONFIG_KEY_SEND, TASKS } from "../constants.js";
|
|
2
3
|
import { RunnableCallable } from "../utils.js";
|
|
3
4
|
import { InvalidUpdateError } from "../errors.js";
|
|
@@ -26,7 +27,13 @@ export class ChannelWrite extends RunnableCallable {
|
|
|
26
27
|
constructor(writes, tags) {
|
|
27
28
|
const name = `ChannelWrite<${writes
|
|
28
29
|
.map((packet) => {
|
|
29
|
-
|
|
30
|
+
if (_isSend(packet)) {
|
|
31
|
+
return packet.node;
|
|
32
|
+
}
|
|
33
|
+
else if ("channel" in packet) {
|
|
34
|
+
return packet.channel;
|
|
35
|
+
}
|
|
36
|
+
return "...";
|
|
30
37
|
})
|
|
31
38
|
.join(",")}>`;
|
|
32
39
|
super({
|
|
@@ -45,7 +52,13 @@ export class ChannelWrite extends RunnableCallable {
|
|
|
45
52
|
}
|
|
46
53
|
async _write(input, config) {
|
|
47
54
|
const writes = this.writes.map((write) => {
|
|
48
|
-
if (
|
|
55
|
+
if (_isChannelWriteTupleEntry(write) && _isPassthrough(write.value)) {
|
|
56
|
+
return {
|
|
57
|
+
mapper: write.mapper,
|
|
58
|
+
value: input,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
else if (_isChannelWriteEntry(write) && _isPassthrough(write.value)) {
|
|
49
62
|
return {
|
|
50
63
|
channel: write.channel,
|
|
51
64
|
value: input,
|
|
@@ -62,36 +75,52 @@ export class ChannelWrite extends RunnableCallable {
|
|
|
62
75
|
}
|
|
63
76
|
// TODO: Support requireAtLeastOneOf
|
|
64
77
|
static async doWrite(config, writes) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
78
|
+
// validate
|
|
79
|
+
for (const w of writes) {
|
|
80
|
+
if (_isChannelWriteEntry(w)) {
|
|
81
|
+
if (w.channel === TASKS) {
|
|
82
|
+
throw new InvalidUpdateError("Cannot write to the reserved channel TASKS");
|
|
83
|
+
}
|
|
84
|
+
if (_isPassthrough(w.value)) {
|
|
85
|
+
throw new InvalidUpdateError("PASSTHROUGH value must be replaced");
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (_isChannelWriteTupleEntry(w)) {
|
|
89
|
+
if (_isPassthrough(w.value)) {
|
|
90
|
+
throw new InvalidUpdateError("PASSTHROUGH value must be replaced");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
95
|
+
const writeEntries = [];
|
|
96
|
+
for (const w of writes) {
|
|
97
|
+
if (_isSend(w)) {
|
|
98
|
+
writeEntries.push([TASKS, w]);
|
|
99
|
+
}
|
|
100
|
+
else if (_isChannelWriteTupleEntry(w)) {
|
|
101
|
+
const mappedResult = await w.mapper.invoke(w.value, config);
|
|
102
|
+
if (mappedResult != null && mappedResult.length > 0) {
|
|
103
|
+
writeEntries.push(...mappedResult);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else if (_isChannelWriteEntry(w)) {
|
|
107
|
+
const mappedValue = w.mapper !== undefined
|
|
108
|
+
? await w.mapper.invoke(w.value, config)
|
|
109
|
+
: w.value;
|
|
110
|
+
if (_isSkipWrite(mappedValue)) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (w.skipNone && mappedValue === undefined) {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
writeEntries.push([w.channel, mappedValue]);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
throw new Error(`Invalid write entry: ${JSON.stringify(w)}`);
|
|
120
|
+
}
|
|
76
121
|
}
|
|
77
|
-
const values = await Promise.all(entries.map(async (write) => {
|
|
78
|
-
const mappedValue = write.mapper
|
|
79
|
-
? await write.mapper.invoke(write.value, config)
|
|
80
|
-
: write.value;
|
|
81
|
-
return {
|
|
82
|
-
...write,
|
|
83
|
-
value: mappedValue,
|
|
84
|
-
};
|
|
85
|
-
})).then((writes) => {
|
|
86
|
-
return writes
|
|
87
|
-
.filter((write) => !write.skipNone || write.value !== null)
|
|
88
|
-
.map((write) => {
|
|
89
|
-
return [write.channel, write.value];
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
122
|
const write = config.configurable?.[CONFIG_KEY_SEND];
|
|
93
|
-
|
|
94
|
-
write([...sends, ...filtered]);
|
|
123
|
+
write(writeEntries);
|
|
95
124
|
}
|
|
96
125
|
static isWriter(runnable) {
|
|
97
126
|
return (
|
|
@@ -106,3 +135,8 @@ export class ChannelWrite extends RunnableCallable {
|
|
|
106
135
|
function _isChannelWriteEntry(x) {
|
|
107
136
|
return (x !== undefined && typeof x.channel === "string");
|
|
108
137
|
}
|
|
138
|
+
function _isChannelWriteTupleEntry(x) {
|
|
139
|
+
return (x !== undefined &&
|
|
140
|
+
!_isChannelWriteEntry(x) &&
|
|
141
|
+
Runnable.isRunnable(x.mapper));
|
|
142
|
+
}
|
package/dist/web.cjs
CHANGED
|
@@ -14,7 +14,7 @@ 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.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.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;
|
|
18
18
|
var index_js_1 = require("./graph/index.cjs");
|
|
19
19
|
Object.defineProperty(exports, "END", { enumerable: true, get: function () { return index_js_1.END; } });
|
|
20
20
|
Object.defineProperty(exports, "Graph", { enumerable: true, get: function () { return index_js_1.Graph; } });
|
|
@@ -31,6 +31,7 @@ Object.defineProperty(exports, "BinaryOperatorAggregate", { enumerable: true, ge
|
|
|
31
31
|
var constants_js_1 = require("./constants.cjs");
|
|
32
32
|
Object.defineProperty(exports, "Send", { enumerable: true, get: function () { return constants_js_1.Send; } });
|
|
33
33
|
Object.defineProperty(exports, "Command", { enumerable: true, get: function () { return constants_js_1.Command; } });
|
|
34
|
+
Object.defineProperty(exports, "isCommand", { enumerable: true, get: function () { return constants_js_1.isCommand; } });
|
|
34
35
|
var interrupt_js_1 = require("./interrupt.cjs");
|
|
35
36
|
Object.defineProperty(exports, "interrupt", { enumerable: true, get: function () { return interrupt_js_1.interrupt; } });
|
|
36
37
|
var langgraph_checkpoint_1 = require("@langchain/langgraph-checkpoint");
|
package/dist/web.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ 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, type Interrupt, } from "./constants.js";
|
|
7
|
+
export { Send, Command, type CommandParams, isCommand, type Interrupt, } from "./constants.js";
|
|
8
8
|
export { interrupt } from "./interrupt.js";
|
|
9
9
|
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
10
|
export * from "./managed/index.js";
|
package/dist/web.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { END, Graph, START, StateGraph, CompiledStateGraph, MessageGraph, messagesStateReducer, Annotation, } from "./graph/index.js";
|
|
2
2
|
export * from "./errors.js";
|
|
3
3
|
export { BaseChannel, BinaryOperatorAggregate, } from "./channels/index.js";
|
|
4
|
-
export { Send, Command, } from "./constants.js";
|
|
4
|
+
export { Send, Command, isCommand, } from "./constants.js";
|
|
5
5
|
export { interrupt } from "./interrupt.js";
|
|
6
6
|
export { MemorySaver, copyCheckpoint, emptyCheckpoint, BaseCheckpointSaver, BaseStore, AsyncBatchedStore, InMemoryStore, } from "@langchain/langgraph-checkpoint";
|
|
7
7
|
export * from "./managed/index.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/langgraph",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.34",
|
|
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.5",
|
|
45
45
|
"@langchain/community": "^0.3.9",
|
|
46
|
-
"@langchain/core": "^0.3.
|
|
46
|
+
"@langchain/core": "^0.3.24",
|
|
47
47
|
"@langchain/langgraph-checkpoint-postgres": "workspace:*",
|
|
48
48
|
"@langchain/langgraph-checkpoint-sqlite": "workspace:*",
|
|
49
49
|
"@langchain/openai": "^0.3.11",
|