@langchain/langgraph 0.2.7 → 0.2.9
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 +12 -2
- package/dist/constants.d.ts +7 -1
- package/dist/constants.js +11 -1
- package/dist/errors.cjs +5 -4
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +5 -4
- package/dist/graph/graph.cjs +7 -2
- package/dist/graph/graph.js +8 -3
- package/dist/graph/message.cjs +2 -0
- package/dist/graph/message.js +2 -0
- package/dist/graph/state.cjs +9 -7
- package/dist/graph/state.d.ts +2 -2
- package/dist/graph/state.js +10 -8
- package/dist/managed/shared_value.cjs +1 -1
- package/dist/managed/shared_value.js +1 -1
- package/dist/pregel/algo.cjs +119 -54
- package/dist/pregel/algo.d.ts +5 -2
- package/dist/pregel/algo.js +117 -53
- package/dist/pregel/debug.cjs +15 -18
- package/dist/pregel/debug.d.ts +3 -2
- package/dist/pregel/debug.js +16 -19
- package/dist/pregel/index.cjs +295 -123
- package/dist/pregel/index.d.ts +16 -5
- package/dist/pregel/index.js +292 -123
- package/dist/pregel/io.cjs +15 -8
- package/dist/pregel/io.d.ts +2 -2
- package/dist/pregel/io.js +15 -8
- package/dist/pregel/loop.cjs +256 -111
- package/dist/pregel/loop.d.ts +21 -5
- package/dist/pregel/loop.js +256 -109
- package/dist/pregel/read.cjs +9 -2
- package/dist/pregel/read.d.ts +2 -1
- package/dist/pregel/read.js +9 -2
- package/dist/pregel/retry.d.ts +1 -1
- package/dist/pregel/types.d.ts +5 -2
- package/dist/pregel/utils/config.cjs +72 -0
- package/dist/pregel/utils/config.d.ts +2 -0
- package/dist/pregel/utils/config.js +68 -0
- package/dist/pregel/{utils.cjs → utils/index.cjs} +33 -10
- package/dist/pregel/{utils.d.ts → utils/index.d.ts} +4 -7
- package/dist/pregel/{utils.js → utils/index.js} +30 -8
- package/dist/utils.cjs +5 -3
- package/dist/utils.js +5 -3
- package/dist/web.d.ts +2 -1
- package/package.json +1 -1
package/dist/pregel/io.cjs
CHANGED
|
@@ -79,12 +79,14 @@ function* mapOutputValues(outputChannels, pendingWrites, channels
|
|
|
79
79
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
80
80
|
) {
|
|
81
81
|
if (Array.isArray(outputChannels)) {
|
|
82
|
-
if (pendingWrites
|
|
82
|
+
if (pendingWrites === true ||
|
|
83
|
+
pendingWrites.find(([chan, _]) => outputChannels.includes(chan))) {
|
|
83
84
|
yield readChannels(channels, outputChannels);
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
else {
|
|
87
|
-
if (pendingWrites
|
|
88
|
+
if (pendingWrites === true ||
|
|
89
|
+
pendingWrites.some(([chan, _]) => chan === outputChannels)) {
|
|
88
90
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
89
91
|
yield readChannel(channels, outputChannels);
|
|
90
92
|
}
|
|
@@ -94,30 +96,32 @@ exports.mapOutputValues = mapOutputValues;
|
|
|
94
96
|
/**
|
|
95
97
|
* Map pending writes (a sequence of tuples (channel, value)) to output chunk.
|
|
96
98
|
*/
|
|
97
|
-
function* mapOutputUpdates(outputChannels, tasks
|
|
99
|
+
function* mapOutputUpdates(outputChannels, tasks, cached
|
|
98
100
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
101
|
) {
|
|
100
|
-
const outputTasks = tasks.filter((task) =>
|
|
102
|
+
const outputTasks = tasks.filter(([task]) => {
|
|
103
|
+
return task.config === undefined || !task.config.tags?.includes(constants_js_1.TAG_HIDDEN);
|
|
104
|
+
});
|
|
101
105
|
if (!outputTasks.length) {
|
|
102
106
|
return;
|
|
103
107
|
}
|
|
104
108
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
105
109
|
let updated;
|
|
106
110
|
if (!Array.isArray(outputChannels)) {
|
|
107
|
-
updated = outputTasks.flatMap((task) => task.writes
|
|
111
|
+
updated = outputTasks.flatMap(([task]) => task.writes
|
|
108
112
|
.filter(([chan, _]) => chan === outputChannels)
|
|
109
113
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
110
114
|
.map(([_, value]) => [task.name, value]));
|
|
111
115
|
}
|
|
112
116
|
else {
|
|
113
117
|
updated = outputTasks
|
|
114
|
-
.filter((task) => task.writes.some(([chan]) => outputChannels.includes(chan)))
|
|
115
|
-
.map((task) => [
|
|
118
|
+
.filter(([task]) => task.writes.some(([chan]) => outputChannels.includes(chan)))
|
|
119
|
+
.map(([task]) => [
|
|
116
120
|
task.name,
|
|
117
121
|
Object.fromEntries(task.writes.filter(([chan]) => outputChannels.includes(chan))),
|
|
118
122
|
]);
|
|
119
123
|
}
|
|
120
|
-
const grouped = Object.fromEntries(outputTasks.map((t) => [t.name, []])
|
|
124
|
+
const grouped = Object.fromEntries(outputTasks.map(([t]) => [t.name, []])
|
|
121
125
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
122
126
|
);
|
|
123
127
|
for (const [node, value] of updated) {
|
|
@@ -133,6 +137,9 @@ function* mapOutputUpdates(outputChannels, tasks
|
|
|
133
137
|
grouped[node] = value[0];
|
|
134
138
|
}
|
|
135
139
|
}
|
|
140
|
+
if (cached) {
|
|
141
|
+
grouped["__metadata__"] = { cached };
|
|
142
|
+
}
|
|
136
143
|
yield grouped;
|
|
137
144
|
}
|
|
138
145
|
exports.mapOutputUpdates = mapOutputUpdates;
|
package/dist/pregel/io.d.ts
CHANGED
|
@@ -10,9 +10,9 @@ export declare function mapInput<C extends PropertyKey>(inputChannels: C | Array
|
|
|
10
10
|
/**
|
|
11
11
|
* Map pending writes (a sequence of tuples (channel, value)) to output chunk.
|
|
12
12
|
*/
|
|
13
|
-
export declare function mapOutputValues<C extends PropertyKey>(outputChannels: C | Array<C>, pendingWrites: readonly PendingWrite<C>[], channels: Record<C, BaseChannel>): Generator<Record<string, any>, any>;
|
|
13
|
+
export declare function mapOutputValues<C extends PropertyKey>(outputChannels: C | Array<C>, pendingWrites: readonly PendingWrite<C>[] | true, channels: Record<C, BaseChannel>): Generator<Record<string, any>, any>;
|
|
14
14
|
/**
|
|
15
15
|
* Map pending writes (a sequence of tuples (channel, value)) to output chunk.
|
|
16
16
|
*/
|
|
17
|
-
export declare function mapOutputUpdates<N extends PropertyKey, C extends PropertyKey>(outputChannels: C | Array<C>, tasks: readonly PregelExecutableTask<N, C>[]): Generator<Record<N, Record<string, any> |
|
|
17
|
+
export declare function mapOutputUpdates<N extends PropertyKey, C extends PropertyKey>(outputChannels: C | Array<C>, tasks: readonly [PregelExecutableTask<N, C>, PendingWrite<C>[]][], cached?: boolean): Generator<Record<N, Record<string, any> | any>>;
|
|
18
18
|
export declare function single<T>(iter: IterableIterator<T>): T | null;
|
package/dist/pregel/io.js
CHANGED
|
@@ -73,12 +73,14 @@ export function* mapOutputValues(outputChannels, pendingWrites, channels
|
|
|
73
73
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
74
|
) {
|
|
75
75
|
if (Array.isArray(outputChannels)) {
|
|
76
|
-
if (pendingWrites
|
|
76
|
+
if (pendingWrites === true ||
|
|
77
|
+
pendingWrites.find(([chan, _]) => outputChannels.includes(chan))) {
|
|
77
78
|
yield readChannels(channels, outputChannels);
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
else {
|
|
81
|
-
if (pendingWrites
|
|
82
|
+
if (pendingWrites === true ||
|
|
83
|
+
pendingWrites.some(([chan, _]) => chan === outputChannels)) {
|
|
82
84
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
83
85
|
yield readChannel(channels, outputChannels);
|
|
84
86
|
}
|
|
@@ -87,30 +89,32 @@ export function* mapOutputValues(outputChannels, pendingWrites, channels
|
|
|
87
89
|
/**
|
|
88
90
|
* Map pending writes (a sequence of tuples (channel, value)) to output chunk.
|
|
89
91
|
*/
|
|
90
|
-
export function* mapOutputUpdates(outputChannels, tasks
|
|
92
|
+
export function* mapOutputUpdates(outputChannels, tasks, cached
|
|
91
93
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
94
|
) {
|
|
93
|
-
const outputTasks = tasks.filter((task) =>
|
|
95
|
+
const outputTasks = tasks.filter(([task]) => {
|
|
96
|
+
return task.config === undefined || !task.config.tags?.includes(TAG_HIDDEN);
|
|
97
|
+
});
|
|
94
98
|
if (!outputTasks.length) {
|
|
95
99
|
return;
|
|
96
100
|
}
|
|
97
101
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
98
102
|
let updated;
|
|
99
103
|
if (!Array.isArray(outputChannels)) {
|
|
100
|
-
updated = outputTasks.flatMap((task) => task.writes
|
|
104
|
+
updated = outputTasks.flatMap(([task]) => task.writes
|
|
101
105
|
.filter(([chan, _]) => chan === outputChannels)
|
|
102
106
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
103
107
|
.map(([_, value]) => [task.name, value]));
|
|
104
108
|
}
|
|
105
109
|
else {
|
|
106
110
|
updated = outputTasks
|
|
107
|
-
.filter((task) => task.writes.some(([chan]) => outputChannels.includes(chan)))
|
|
108
|
-
.map((task) => [
|
|
111
|
+
.filter(([task]) => task.writes.some(([chan]) => outputChannels.includes(chan)))
|
|
112
|
+
.map(([task]) => [
|
|
109
113
|
task.name,
|
|
110
114
|
Object.fromEntries(task.writes.filter(([chan]) => outputChannels.includes(chan))),
|
|
111
115
|
]);
|
|
112
116
|
}
|
|
113
|
-
const grouped = Object.fromEntries(outputTasks.map((t) => [t.name, []])
|
|
117
|
+
const grouped = Object.fromEntries(outputTasks.map(([t]) => [t.name, []])
|
|
114
118
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
115
119
|
);
|
|
116
120
|
for (const [node, value] of updated) {
|
|
@@ -126,6 +130,9 @@ export function* mapOutputUpdates(outputChannels, tasks
|
|
|
126
130
|
grouped[node] = value[0];
|
|
127
131
|
}
|
|
128
132
|
}
|
|
133
|
+
if (cached) {
|
|
134
|
+
grouped["__metadata__"] = { cached };
|
|
135
|
+
}
|
|
129
136
|
yield grouped;
|
|
130
137
|
}
|
|
131
138
|
export function single(iter) {
|