@langchain/langgraph-sdk 0.1.5 → 0.1.7
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/CHANGELOG.md +14 -0
- package/dist/react/index.cjs +3 -1
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.js +1 -0
- package/dist/react/stream.cjs +12 -460
- package/dist/react/stream.custom.cjs +148 -0
- package/dist/react/stream.custom.d.ts +41 -0
- package/dist/react/stream.custom.js +142 -0
- package/dist/react/stream.d.ts +61 -1
- package/dist/react/stream.js +13 -460
- package/dist/react/stream.lgp.cjs +499 -0
- package/dist/react/stream.lgp.d.ts +7 -0
- package/dist/react/stream.lgp.js +495 -0
- package/dist/react/thread.cjs +19 -0
- package/dist/react/thread.d.ts +4 -0
- package/dist/react/thread.js +15 -0
- package/dist/react/types.d.ts +25 -1
- package/dist/ui/branching.test.cjs +370 -0
- package/dist/ui/branching.test.d.ts +1 -0
- package/dist/ui/branching.test.js +368 -0
- package/dist/{react → ui}/manager.cjs +8 -4
- package/dist/{react → ui}/manager.d.ts +1 -0
- package/dist/{react → ui}/manager.js +8 -4
- package/package.json +1 -1
- /package/dist/{react → ui}/branching.cjs +0 -0
- /package/dist/{react → ui}/branching.d.ts +0 -0
- /package/dist/{react → ui}/branching.js +0 -0
- /package/dist/{react → ui}/errors.cjs +0 -0
- /package/dist/{react → ui}/errors.d.ts +0 -0
- /package/dist/{react → ui}/errors.js +0 -0
- /package/dist/{react → ui}/messages.cjs +0 -0
- /package/dist/{react → ui}/messages.d.ts +0 -0
- /package/dist/{react → ui}/messages.js +0 -0
- /package/dist/{react → ui}/utils.cjs +0 -0
- /package/dist/{react → ui}/utils.d.ts +0 -0
- /package/dist/{react → ui}/utils.js +0 -0
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const branching_js_1 = require("./branching.cjs");
|
|
5
|
+
const history = [
|
|
6
|
+
{
|
|
7
|
+
values: {
|
|
8
|
+
messages: [
|
|
9
|
+
{
|
|
10
|
+
content: "Fork: Hello",
|
|
11
|
+
additional_kwargs: {},
|
|
12
|
+
response_metadata: {},
|
|
13
|
+
id: "33357aea-9c2d-4718-92f4-20038d5a2d29",
|
|
14
|
+
type: "human",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
content: "Hey",
|
|
18
|
+
additional_kwargs: {},
|
|
19
|
+
response_metadata: {},
|
|
20
|
+
tool_call_chunks: [],
|
|
21
|
+
id: "run-782a2f90-2e39-4c21-9ee6-0f38585a0ae6",
|
|
22
|
+
tool_calls: [],
|
|
23
|
+
invalid_tool_calls: [],
|
|
24
|
+
type: "ai",
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
next: [],
|
|
29
|
+
tasks: [],
|
|
30
|
+
metadata: {
|
|
31
|
+
source: "loop",
|
|
32
|
+
step: 2,
|
|
33
|
+
parents: {},
|
|
34
|
+
thread_id: "efa80f4d-725f-4903-b19f-216309f060bc",
|
|
35
|
+
},
|
|
36
|
+
created_at: "2025-08-21T12:47:12.640Z",
|
|
37
|
+
checkpoint: {
|
|
38
|
+
thread_id: "efa80f4d-725f-4903-b19f-216309f060bc",
|
|
39
|
+
checkpoint_id: "1f07e8cf-56a7-6000-8002-5e272b1d5285",
|
|
40
|
+
checkpoint_ns: "",
|
|
41
|
+
checkpoint_map: null,
|
|
42
|
+
},
|
|
43
|
+
parent_checkpoint: {
|
|
44
|
+
thread_id: "efa80f4d-725f-4903-b19f-216309f060bc",
|
|
45
|
+
checkpoint_id: "1f07e8cf-53aa-6d70-8001-2096b0bbf835",
|
|
46
|
+
checkpoint_ns: "",
|
|
47
|
+
checkpoint_map: null,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
values: {
|
|
52
|
+
messages: [
|
|
53
|
+
{
|
|
54
|
+
content: "Fork: Hello",
|
|
55
|
+
additional_kwargs: {},
|
|
56
|
+
response_metadata: {},
|
|
57
|
+
id: "33357aea-9c2d-4718-92f4-20038d5a2d29",
|
|
58
|
+
type: "human",
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
next: ["agent"],
|
|
63
|
+
tasks: [
|
|
64
|
+
{
|
|
65
|
+
id: "680ee831-4d10-50f9-956f-e0d937321614",
|
|
66
|
+
name: "agent",
|
|
67
|
+
error: null,
|
|
68
|
+
interrupts: [],
|
|
69
|
+
path: ["__pregel_pull", "agent"],
|
|
70
|
+
checkpoint: null,
|
|
71
|
+
state: null,
|
|
72
|
+
result: {
|
|
73
|
+
messages: [
|
|
74
|
+
{
|
|
75
|
+
content: "Hey",
|
|
76
|
+
additional_kwargs: {},
|
|
77
|
+
response_metadata: {},
|
|
78
|
+
tool_call_chunks: [],
|
|
79
|
+
id: "run-782a2f90-2e39-4c21-9ee6-0f38585a0ae6",
|
|
80
|
+
tool_calls: [],
|
|
81
|
+
invalid_tool_calls: [],
|
|
82
|
+
type: "ai",
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
metadata: {
|
|
89
|
+
source: "loop",
|
|
90
|
+
step: 1,
|
|
91
|
+
parents: {},
|
|
92
|
+
thread_id: "efa80f4d-725f-4903-b19f-216309f060bc",
|
|
93
|
+
},
|
|
94
|
+
created_at: "2025-08-21T12:47:12.327Z",
|
|
95
|
+
checkpoint: {
|
|
96
|
+
thread_id: "efa80f4d-725f-4903-b19f-216309f060bc",
|
|
97
|
+
checkpoint_id: "1f07e8cf-53aa-6d70-8001-2096b0bbf835",
|
|
98
|
+
checkpoint_ns: "",
|
|
99
|
+
checkpoint_map: null,
|
|
100
|
+
},
|
|
101
|
+
parent_checkpoint: {
|
|
102
|
+
thread_id: "efa80f4d-725f-4903-b19f-216309f060bc",
|
|
103
|
+
checkpoint_id: "1f07e8cf-53a8-6660-8000-f157c9cf7d66",
|
|
104
|
+
checkpoint_ns: "",
|
|
105
|
+
checkpoint_map: null,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
values: { messages: [] },
|
|
110
|
+
next: ["__start__"],
|
|
111
|
+
tasks: [
|
|
112
|
+
{
|
|
113
|
+
id: "4233f4c0-5ea2-5117-9153-95e5fe59eee3",
|
|
114
|
+
name: "__start__",
|
|
115
|
+
error: null,
|
|
116
|
+
interrupts: [],
|
|
117
|
+
path: ["__pregel_pull", "__start__"],
|
|
118
|
+
checkpoint: null,
|
|
119
|
+
state: null,
|
|
120
|
+
result: { messages: [{ type: "human", content: "Fork: Hello" }] },
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
metadata: {
|
|
124
|
+
source: "input",
|
|
125
|
+
step: 0,
|
|
126
|
+
parents: {},
|
|
127
|
+
thread_id: "efa80f4d-725f-4903-b19f-216309f060bc",
|
|
128
|
+
},
|
|
129
|
+
created_at: "2025-08-21T12:47:12.326Z",
|
|
130
|
+
checkpoint: {
|
|
131
|
+
thread_id: "efa80f4d-725f-4903-b19f-216309f060bc",
|
|
132
|
+
checkpoint_id: "1f07e8cf-53a8-6660-8000-f157c9cf7d66",
|
|
133
|
+
checkpoint_ns: "",
|
|
134
|
+
checkpoint_map: null,
|
|
135
|
+
},
|
|
136
|
+
parent_checkpoint: {
|
|
137
|
+
thread_id: "efa80f4d-725f-4903-b19f-216309f060bc",
|
|
138
|
+
checkpoint_id: "1f07e8cf-4cea-6530-ffff-0995a53299c5",
|
|
139
|
+
checkpoint_ns: "",
|
|
140
|
+
checkpoint_map: null,
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
values: {
|
|
145
|
+
messages: [
|
|
146
|
+
{
|
|
147
|
+
content: "Hello",
|
|
148
|
+
additional_kwargs: {},
|
|
149
|
+
response_metadata: {},
|
|
150
|
+
id: "ec300e63-1494-4ef6-936c-60d02d7bdce1",
|
|
151
|
+
type: "human",
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
content: "Hey",
|
|
155
|
+
additional_kwargs: {},
|
|
156
|
+
response_metadata: {},
|
|
157
|
+
tool_call_chunks: [],
|
|
158
|
+
id: "run-593064bd-dd07-4ed3-99c0-a918625f4884",
|
|
159
|
+
tool_calls: [],
|
|
160
|
+
invalid_tool_calls: [],
|
|
161
|
+
type: "ai",
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
},
|
|
165
|
+
next: [],
|
|
166
|
+
tasks: [],
|
|
167
|
+
metadata: {
|
|
168
|
+
source: "loop",
|
|
169
|
+
step: 1,
|
|
170
|
+
parents: {},
|
|
171
|
+
thread_id: "efa80f4d-725f-4903-b19f-216309f060bc",
|
|
172
|
+
},
|
|
173
|
+
created_at: "2025-08-21T12:47:12.285Z",
|
|
174
|
+
checkpoint: {
|
|
175
|
+
thread_id: "efa80f4d-725f-4903-b19f-216309f060bc",
|
|
176
|
+
checkpoint_id: "1f07e8cf-5344-64d0-8001-8a176e91d12f",
|
|
177
|
+
checkpoint_ns: "",
|
|
178
|
+
checkpoint_map: null,
|
|
179
|
+
},
|
|
180
|
+
parent_checkpoint: {
|
|
181
|
+
thread_id: "efa80f4d-725f-4903-b19f-216309f060bc",
|
|
182
|
+
checkpoint_id: "1f07e8cf-4cf8-6f90-8000-7707fd155a8a",
|
|
183
|
+
checkpoint_ns: "",
|
|
184
|
+
checkpoint_map: null,
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
values: {
|
|
189
|
+
messages: [
|
|
190
|
+
{
|
|
191
|
+
content: "Hello",
|
|
192
|
+
additional_kwargs: {},
|
|
193
|
+
response_metadata: {},
|
|
194
|
+
id: "ec300e63-1494-4ef6-936c-60d02d7bdce1",
|
|
195
|
+
type: "human",
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
content: "Hey",
|
|
199
|
+
additional_kwargs: {},
|
|
200
|
+
response_metadata: {},
|
|
201
|
+
tool_call_chunks: [],
|
|
202
|
+
id: "run-b86ef558-eaff-4838-bc03-218f20554a9f",
|
|
203
|
+
tool_calls: [],
|
|
204
|
+
invalid_tool_calls: [],
|
|
205
|
+
type: "ai",
|
|
206
|
+
},
|
|
207
|
+
],
|
|
208
|
+
},
|
|
209
|
+
next: [],
|
|
210
|
+
tasks: [],
|
|
211
|
+
metadata: {
|
|
212
|
+
source: "loop",
|
|
213
|
+
step: 1,
|
|
214
|
+
parents: {},
|
|
215
|
+
thread_id: "efa80f4d-725f-4903-b19f-216309f060bc",
|
|
216
|
+
},
|
|
217
|
+
created_at: "2025-08-21T12:47:11.936Z",
|
|
218
|
+
checkpoint: {
|
|
219
|
+
thread_id: "efa80f4d-725f-4903-b19f-216309f060bc",
|
|
220
|
+
checkpoint_id: "1f07e8cf-4ff0-6400-8001-a54aedf52a76",
|
|
221
|
+
checkpoint_ns: "",
|
|
222
|
+
checkpoint_map: null,
|
|
223
|
+
},
|
|
224
|
+
parent_checkpoint: {
|
|
225
|
+
thread_id: "efa80f4d-725f-4903-b19f-216309f060bc",
|
|
226
|
+
checkpoint_id: "1f07e8cf-4cf8-6f90-8000-7707fd155a8a",
|
|
227
|
+
checkpoint_ns: "",
|
|
228
|
+
checkpoint_map: null,
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
values: {
|
|
233
|
+
messages: [
|
|
234
|
+
{
|
|
235
|
+
content: "Hello",
|
|
236
|
+
additional_kwargs: {},
|
|
237
|
+
response_metadata: {},
|
|
238
|
+
id: "ec300e63-1494-4ef6-936c-60d02d7bdce1",
|
|
239
|
+
type: "human",
|
|
240
|
+
},
|
|
241
|
+
],
|
|
242
|
+
},
|
|
243
|
+
next: ["agent"],
|
|
244
|
+
tasks: [
|
|
245
|
+
{
|
|
246
|
+
id: "e3f503f1-73bc-5db1-8b4d-13f660ad1b51",
|
|
247
|
+
name: "agent",
|
|
248
|
+
error: null,
|
|
249
|
+
interrupts: [],
|
|
250
|
+
path: ["__pregel_pull", "agent"],
|
|
251
|
+
checkpoint: null,
|
|
252
|
+
state: null,
|
|
253
|
+
result: {
|
|
254
|
+
messages: [
|
|
255
|
+
{
|
|
256
|
+
content: "Hey",
|
|
257
|
+
additional_kwargs: {},
|
|
258
|
+
response_metadata: {},
|
|
259
|
+
tool_call_chunks: [],
|
|
260
|
+
id: "run-b86ef558-eaff-4838-bc03-218f20554a9f",
|
|
261
|
+
tool_calls: [],
|
|
262
|
+
invalid_tool_calls: [],
|
|
263
|
+
type: "ai",
|
|
264
|
+
},
|
|
265
|
+
],
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
],
|
|
269
|
+
metadata: {
|
|
270
|
+
source: "loop",
|
|
271
|
+
step: 0,
|
|
272
|
+
parents: {},
|
|
273
|
+
thread_id: "efa80f4d-725f-4903-b19f-216309f060bc",
|
|
274
|
+
},
|
|
275
|
+
created_at: "2025-08-21T12:47:11.625Z",
|
|
276
|
+
checkpoint: {
|
|
277
|
+
thread_id: "efa80f4d-725f-4903-b19f-216309f060bc",
|
|
278
|
+
checkpoint_id: "1f07e8cf-4cf8-6f90-8000-7707fd155a8a",
|
|
279
|
+
checkpoint_ns: "",
|
|
280
|
+
checkpoint_map: null,
|
|
281
|
+
},
|
|
282
|
+
parent_checkpoint: {
|
|
283
|
+
thread_id: "efa80f4d-725f-4903-b19f-216309f060bc",
|
|
284
|
+
checkpoint_id: "1f07e8cf-4cea-6530-ffff-0995a53299c5",
|
|
285
|
+
checkpoint_ns: "",
|
|
286
|
+
checkpoint_map: null,
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
values: { messages: [] },
|
|
291
|
+
next: ["__start__"],
|
|
292
|
+
tasks: [
|
|
293
|
+
{
|
|
294
|
+
id: "cddede95-d276-59f1-bc08-8051d6448734",
|
|
295
|
+
name: "__start__",
|
|
296
|
+
error: null,
|
|
297
|
+
interrupts: [],
|
|
298
|
+
path: ["__pregel_pull", "__start__"],
|
|
299
|
+
checkpoint: null,
|
|
300
|
+
state: null,
|
|
301
|
+
result: { messages: [{ type: "human", content: "Hello" }] },
|
|
302
|
+
},
|
|
303
|
+
],
|
|
304
|
+
metadata: {
|
|
305
|
+
source: "input",
|
|
306
|
+
step: -1,
|
|
307
|
+
parents: {},
|
|
308
|
+
thread_id: "efa80f4d-725f-4903-b19f-216309f060bc",
|
|
309
|
+
},
|
|
310
|
+
created_at: "2025-08-21T12:47:11.619Z",
|
|
311
|
+
checkpoint: {
|
|
312
|
+
thread_id: "efa80f4d-725f-4903-b19f-216309f060bc",
|
|
313
|
+
checkpoint_id: "1f07e8cf-4cea-6530-ffff-0995a53299c5",
|
|
314
|
+
checkpoint_ns: "",
|
|
315
|
+
checkpoint_map: null,
|
|
316
|
+
},
|
|
317
|
+
parent_checkpoint: null,
|
|
318
|
+
},
|
|
319
|
+
];
|
|
320
|
+
const node = (value, paths = []) => ({
|
|
321
|
+
type: "node",
|
|
322
|
+
value: typeof value === "number" ? history.at(value) : value,
|
|
323
|
+
path: paths.map((v) => {
|
|
324
|
+
if (typeof v === "number") {
|
|
325
|
+
return history.at(v)?.checkpoint?.checkpoint_id;
|
|
326
|
+
}
|
|
327
|
+
return v?.checkpoint?.checkpoint_id;
|
|
328
|
+
}),
|
|
329
|
+
});
|
|
330
|
+
const fork = (...items) => ({ type: "fork", items });
|
|
331
|
+
const sequence = (...items) => ({ type: "sequence", items });
|
|
332
|
+
(0, vitest_1.it)("full tree", async () => {
|
|
333
|
+
const { rootSequence, paths } = (0, branching_js_1.getBranchSequence)(history);
|
|
334
|
+
vitest_1.expect
|
|
335
|
+
.soft(paths)
|
|
336
|
+
.toMatchObject(vitest_1.expect.arrayContaining([[5], [5, 4], [5, 3], [2]].map((p) => p.map((i) => history.at(i)?.checkpoint?.checkpoint_id))));
|
|
337
|
+
vitest_1.expect
|
|
338
|
+
.soft(rootSequence)
|
|
339
|
+
.toMatchObject(sequence(node(6), fork(sequence(node(5, [5]), fork(sequence(node(4, [5, 4])), sequence(node(3, [5, 3])))), sequence(node(2, [2]), node(1, [2]), node(0, [2])))));
|
|
340
|
+
});
|
|
341
|
+
(0, vitest_1.it)("partial tree", async () => {
|
|
342
|
+
(0, vitest_1.expect)((0, branching_js_1.getBranchSequence)(history.slice(0, 1))).toMatchObject({
|
|
343
|
+
paths: [],
|
|
344
|
+
rootSequence: sequence(node(0)),
|
|
345
|
+
});
|
|
346
|
+
(0, vitest_1.expect)((0, branching_js_1.getBranchSequence)(history.slice(0, 2))).toMatchObject({
|
|
347
|
+
paths: [],
|
|
348
|
+
rootSequence: sequence(node(1), node(0)),
|
|
349
|
+
});
|
|
350
|
+
(0, vitest_1.expect)((0, branching_js_1.getBranchSequence)(history.slice(0, 3))).toMatchObject({
|
|
351
|
+
paths: [],
|
|
352
|
+
rootSequence: sequence(node(2), node(1), node(0)),
|
|
353
|
+
});
|
|
354
|
+
(0, vitest_1.expect)((0, branching_js_1.getBranchSequence)(history.slice(0, 4))).toMatchObject({
|
|
355
|
+
paths: [],
|
|
356
|
+
rootSequence: sequence(node(2), node(1), node(0)),
|
|
357
|
+
});
|
|
358
|
+
(0, vitest_1.expect)((0, branching_js_1.getBranchSequence)(history.slice(0, 5))).toMatchObject({
|
|
359
|
+
paths: [],
|
|
360
|
+
rootSequence: sequence(node(2), node(1), node(0)),
|
|
361
|
+
});
|
|
362
|
+
(0, vitest_1.expect)((0, branching_js_1.getBranchSequence)(history.slice(0, 6))).toMatchObject({
|
|
363
|
+
paths: vitest_1.expect.arrayContaining([[5], [5, 4], [5, 3], [2]].map((p) => p.map((i) => history.at(i)?.checkpoint?.checkpoint_id))),
|
|
364
|
+
rootSequence: sequence(fork(sequence(node(5, [5]), fork(sequence(node(4, [5, 4])), sequence(node(3, [5, 3])))), sequence(node(2, [2]), node(1, [2]), node(0, [2])))),
|
|
365
|
+
});
|
|
366
|
+
(0, vitest_1.expect)((0, branching_js_1.getBranchSequence)(history.slice(0, 7))).toMatchObject({
|
|
367
|
+
paths: vitest_1.expect.arrayContaining([[5], [5, 4], [5, 3], [2]].map((p) => p.map((i) => history.at(i)?.checkpoint?.checkpoint_id))),
|
|
368
|
+
rootSequence: sequence(node(6), fork(sequence(node(5, [5]), fork(sequence(node(4, [5, 4])), sequence(node(3, [5, 3])))), sequence(node(2, [2]), node(1, [2]), node(0, [2])))),
|
|
369
|
+
});
|
|
370
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|