@langchain/langgraph-sdk 0.0.59 → 0.0.61
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/client.cjs +11 -24
- package/dist/client.d.ts +26 -15
- package/dist/client.js +11 -24
- package/dist/react/stream.cjs +2 -2
- package/dist/react/stream.js +2 -2
- package/dist/react-ui/client.cjs +14 -1
- package/dist/react-ui/client.d.ts +3 -0
- package/dist/react-ui/client.js +12 -0
- package/dist/react-ui/index.cjs +2 -1
- package/dist/react-ui/index.d.ts +1 -1
- package/dist/react-ui/index.js +1 -1
- package/dist/schema.d.ts +4 -4
- package/package.json +1 -1
package/dist/client.cjs
CHANGED
|
@@ -352,9 +352,19 @@ class ThreadsClient extends BaseClient {
|
|
|
352
352
|
return this.fetch(`/threads`, {
|
|
353
353
|
method: "POST",
|
|
354
354
|
json: {
|
|
355
|
-
metadata:
|
|
355
|
+
metadata: {
|
|
356
|
+
...payload?.metadata,
|
|
357
|
+
graph_id: payload?.graphId,
|
|
358
|
+
},
|
|
356
359
|
thread_id: payload?.threadId,
|
|
357
360
|
if_exists: payload?.ifExists,
|
|
361
|
+
supersteps: payload?.supersteps?.map((s) => ({
|
|
362
|
+
updates: s.updates.map((u) => ({
|
|
363
|
+
values: u.values,
|
|
364
|
+
command: u.command,
|
|
365
|
+
as_node: u.asNode,
|
|
366
|
+
})),
|
|
367
|
+
})),
|
|
358
368
|
},
|
|
359
369
|
});
|
|
360
370
|
}
|
|
@@ -446,29 +456,6 @@ class ThreadsClient extends BaseClient {
|
|
|
446
456
|
},
|
|
447
457
|
});
|
|
448
458
|
}
|
|
449
|
-
/**
|
|
450
|
-
* Create a new thread from a batch states.
|
|
451
|
-
*/
|
|
452
|
-
async bulkUpdateState(supersteps, options) {
|
|
453
|
-
return this.fetch("/threads/state/batch", {
|
|
454
|
-
method: "POST",
|
|
455
|
-
json: {
|
|
456
|
-
supersteps: supersteps.map((s) => ({
|
|
457
|
-
updates: s.updates.map((u) => ({
|
|
458
|
-
values: u.values,
|
|
459
|
-
command: u.command,
|
|
460
|
-
as_node: u.asNode,
|
|
461
|
-
})),
|
|
462
|
-
})),
|
|
463
|
-
thread_id: options?.threadId,
|
|
464
|
-
metadata: {
|
|
465
|
-
...options?.metadata,
|
|
466
|
-
graph_id: options?.graphId,
|
|
467
|
-
},
|
|
468
|
-
if_exists: options?.ifExists,
|
|
469
|
-
},
|
|
470
|
-
});
|
|
471
|
-
}
|
|
472
459
|
/**
|
|
473
460
|
* Patch the metadata of a thread.
|
|
474
461
|
*
|
package/dist/client.d.ts
CHANGED
|
@@ -187,8 +187,34 @@ export declare class ThreadsClient<TStateType = DefaultValues, TUpdateType = TSt
|
|
|
187
187
|
* Metadata for the thread.
|
|
188
188
|
*/
|
|
189
189
|
metadata?: Metadata;
|
|
190
|
+
/**
|
|
191
|
+
* ID of the thread to create.
|
|
192
|
+
*
|
|
193
|
+
* If not provided, a random UUID will be generated.
|
|
194
|
+
*/
|
|
190
195
|
threadId?: string;
|
|
196
|
+
/**
|
|
197
|
+
* How to handle duplicate creation.
|
|
198
|
+
*
|
|
199
|
+
* @default "raise"
|
|
200
|
+
*/
|
|
191
201
|
ifExists?: OnConflictBehavior;
|
|
202
|
+
/**
|
|
203
|
+
* Graph ID to associate with the thread.
|
|
204
|
+
*/
|
|
205
|
+
graphId?: string;
|
|
206
|
+
/**
|
|
207
|
+
* Apply a list of supersteps when creating a thread, each containing a sequence of updates.
|
|
208
|
+
*
|
|
209
|
+
* Used for copying a thread between deployments.
|
|
210
|
+
*/
|
|
211
|
+
supersteps?: Array<{
|
|
212
|
+
updates: Array<{
|
|
213
|
+
values: unknown;
|
|
214
|
+
command?: Command;
|
|
215
|
+
asNode: string;
|
|
216
|
+
}>;
|
|
217
|
+
}>;
|
|
192
218
|
}): Promise<Thread<TStateType>>;
|
|
193
219
|
/**
|
|
194
220
|
* Copy an existing thread
|
|
@@ -262,21 +288,6 @@ export declare class ThreadsClient<TStateType = DefaultValues, TUpdateType = TSt
|
|
|
262
288
|
checkpointId?: string;
|
|
263
289
|
asNode?: string;
|
|
264
290
|
}): Promise<Pick<Config, "configurable">>;
|
|
265
|
-
/**
|
|
266
|
-
* Create a new thread from a batch states.
|
|
267
|
-
*/
|
|
268
|
-
bulkUpdateState(supersteps: Array<{
|
|
269
|
-
updates: Array<{
|
|
270
|
-
values: unknown;
|
|
271
|
-
command?: Command;
|
|
272
|
-
asNode: string;
|
|
273
|
-
}>;
|
|
274
|
-
}>, options?: {
|
|
275
|
-
graphId?: string;
|
|
276
|
-
threadId?: string;
|
|
277
|
-
metadata?: Metadata;
|
|
278
|
-
ifExists?: OnConflictBehavior;
|
|
279
|
-
}): Promise<Thread<TStateType>>;
|
|
280
291
|
/**
|
|
281
292
|
* Patch the metadata of a thread.
|
|
282
293
|
*
|
package/dist/client.js
CHANGED
|
@@ -346,9 +346,19 @@ export class ThreadsClient extends BaseClient {
|
|
|
346
346
|
return this.fetch(`/threads`, {
|
|
347
347
|
method: "POST",
|
|
348
348
|
json: {
|
|
349
|
-
metadata:
|
|
349
|
+
metadata: {
|
|
350
|
+
...payload?.metadata,
|
|
351
|
+
graph_id: payload?.graphId,
|
|
352
|
+
},
|
|
350
353
|
thread_id: payload?.threadId,
|
|
351
354
|
if_exists: payload?.ifExists,
|
|
355
|
+
supersteps: payload?.supersteps?.map((s) => ({
|
|
356
|
+
updates: s.updates.map((u) => ({
|
|
357
|
+
values: u.values,
|
|
358
|
+
command: u.command,
|
|
359
|
+
as_node: u.asNode,
|
|
360
|
+
})),
|
|
361
|
+
})),
|
|
352
362
|
},
|
|
353
363
|
});
|
|
354
364
|
}
|
|
@@ -440,29 +450,6 @@ export class ThreadsClient extends BaseClient {
|
|
|
440
450
|
},
|
|
441
451
|
});
|
|
442
452
|
}
|
|
443
|
-
/**
|
|
444
|
-
* Create a new thread from a batch states.
|
|
445
|
-
*/
|
|
446
|
-
async bulkUpdateState(supersteps, options) {
|
|
447
|
-
return this.fetch("/threads/state/batch", {
|
|
448
|
-
method: "POST",
|
|
449
|
-
json: {
|
|
450
|
-
supersteps: supersteps.map((s) => ({
|
|
451
|
-
updates: s.updates.map((u) => ({
|
|
452
|
-
values: u.values,
|
|
453
|
-
command: u.command,
|
|
454
|
-
as_node: u.asNode,
|
|
455
|
-
})),
|
|
456
|
-
})),
|
|
457
|
-
thread_id: options?.threadId,
|
|
458
|
-
metadata: {
|
|
459
|
-
...options?.metadata,
|
|
460
|
-
graph_id: options?.graphId,
|
|
461
|
-
},
|
|
462
|
-
if_exists: options?.ifExists,
|
|
463
|
-
},
|
|
464
|
-
});
|
|
465
|
-
}
|
|
466
453
|
/**
|
|
467
454
|
* Patch the metadata of a thread.
|
|
468
455
|
*
|
package/dist/react/stream.cjs
CHANGED
|
@@ -335,7 +335,7 @@ function useStream(options) {
|
|
|
335
335
|
// @ts-expect-error
|
|
336
336
|
if (checkpoint != null)
|
|
337
337
|
delete checkpoint.thread_id;
|
|
338
|
-
const run =
|
|
338
|
+
const run = client.runs.stream(usableThreadId, assistantId, {
|
|
339
339
|
input: values,
|
|
340
340
|
config: submitOptions?.config,
|
|
341
341
|
command: submitOptions?.command,
|
|
@@ -348,7 +348,7 @@ function useStream(options) {
|
|
|
348
348
|
signal: abortRef.current.signal,
|
|
349
349
|
checkpoint,
|
|
350
350
|
streamMode,
|
|
351
|
-
})
|
|
351
|
+
});
|
|
352
352
|
// Unbranch things
|
|
353
353
|
const newPath = submitOptions?.checkpoint?.checkpoint_id
|
|
354
354
|
? branchByCheckpoint[submitOptions?.checkpoint?.checkpoint_id]?.branch
|
package/dist/react/stream.js
CHANGED
|
@@ -332,7 +332,7 @@ export function useStream(options) {
|
|
|
332
332
|
// @ts-expect-error
|
|
333
333
|
if (checkpoint != null)
|
|
334
334
|
delete checkpoint.thread_id;
|
|
335
|
-
const run =
|
|
335
|
+
const run = client.runs.stream(usableThreadId, assistantId, {
|
|
336
336
|
input: values,
|
|
337
337
|
config: submitOptions?.config,
|
|
338
338
|
command: submitOptions?.command,
|
|
@@ -345,7 +345,7 @@ export function useStream(options) {
|
|
|
345
345
|
signal: abortRef.current.signal,
|
|
346
346
|
checkpoint,
|
|
347
347
|
streamMode,
|
|
348
|
-
})
|
|
348
|
+
});
|
|
349
349
|
// Unbranch things
|
|
350
350
|
const newPath = submitOptions?.checkpoint?.checkpoint_id
|
|
351
351
|
? branchByCheckpoint[submitOptions?.checkpoint?.checkpoint_id]?.branch
|
package/dist/react-ui/client.cjs
CHANGED
|
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
return result;
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.bootstrapUiContext = exports.LoadExternalComponent = exports.useStreamContext = void 0;
|
|
27
|
+
exports.bootstrapUiContext = exports.experimental_loadShare = exports.LoadExternalComponent = exports.useStreamContext = void 0;
|
|
28
28
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
29
29
|
const index_js_1 = require("../react/index.cjs");
|
|
30
30
|
const React = __importStar(require("react"));
|
|
@@ -87,6 +87,7 @@ class ComponentStore {
|
|
|
87
87
|
const COMPONENT_STORE = new ComponentStore();
|
|
88
88
|
const EXT_STORE_SYMBOL = Symbol.for("LGUI_EXT_STORE");
|
|
89
89
|
const REQUIRE_SYMBOL = Symbol.for("LGUI_REQUIRE");
|
|
90
|
+
const REQUIRE_EXTRA_SYMBOL = Symbol.for("LGUI_REQUIRE_EXTRA");
|
|
90
91
|
function LoadExternalComponent({ stream, namespace, message, meta, fallback, components, ...props }) {
|
|
91
92
|
const ref = React.useRef(null);
|
|
92
93
|
const id = React.useId();
|
|
@@ -119,6 +120,13 @@ function LoadExternalComponent({ stream, namespace, message, meta, fallback, com
|
|
|
119
120
|
: fallback })] }));
|
|
120
121
|
}
|
|
121
122
|
exports.LoadExternalComponent = LoadExternalComponent;
|
|
123
|
+
function experimental_loadShare(name, module) {
|
|
124
|
+
if (typeof window === "undefined")
|
|
125
|
+
return;
|
|
126
|
+
window[REQUIRE_EXTRA_SYMBOL] ??= {};
|
|
127
|
+
window[REQUIRE_EXTRA_SYMBOL][name] = module;
|
|
128
|
+
}
|
|
129
|
+
exports.experimental_loadShare = experimental_loadShare;
|
|
122
130
|
function bootstrapUiContext() {
|
|
123
131
|
if (typeof window === "undefined") {
|
|
124
132
|
console.warn("Attempting to bootstrap UI context outside of browser environment. " +
|
|
@@ -143,6 +151,11 @@ function bootstrapUiContext() {
|
|
|
143
151
|
},
|
|
144
152
|
};
|
|
145
153
|
}
|
|
154
|
+
if (window[REQUIRE_EXTRA_SYMBOL] != null &&
|
|
155
|
+
typeof window[REQUIRE_EXTRA_SYMBOL] === "object" &&
|
|
156
|
+
name in window[REQUIRE_EXTRA_SYMBOL]) {
|
|
157
|
+
return window[REQUIRE_EXTRA_SYMBOL][name];
|
|
158
|
+
}
|
|
146
159
|
throw new Error(`Unknown module...: ${name}`);
|
|
147
160
|
};
|
|
148
161
|
}
|
|
@@ -48,6 +48,7 @@ declare class ComponentStore {
|
|
|
48
48
|
}
|
|
49
49
|
declare const EXT_STORE_SYMBOL: unique symbol;
|
|
50
50
|
declare const REQUIRE_SYMBOL: unique symbol;
|
|
51
|
+
declare const REQUIRE_EXTRA_SYMBOL: unique symbol;
|
|
51
52
|
interface LoadExternalComponentProps extends Pick<React.HTMLAttributes<HTMLDivElement>, "style" | "className"> {
|
|
52
53
|
/** Stream of the assistant */
|
|
53
54
|
stream: ReturnType<typeof useStream>;
|
|
@@ -70,7 +71,9 @@ declare global {
|
|
|
70
71
|
interface Window {
|
|
71
72
|
[EXT_STORE_SYMBOL]: ComponentStore;
|
|
72
73
|
[REQUIRE_SYMBOL]: (name: string) => unknown;
|
|
74
|
+
[REQUIRE_EXTRA_SYMBOL]: Record<string, unknown>;
|
|
73
75
|
}
|
|
74
76
|
}
|
|
77
|
+
export declare function experimental_loadShare(name: string, module: unknown): void;
|
|
75
78
|
export declare function bootstrapUiContext(): void;
|
|
76
79
|
export {};
|
package/dist/react-ui/client.js
CHANGED
|
@@ -60,6 +60,7 @@ class ComponentStore {
|
|
|
60
60
|
const COMPONENT_STORE = new ComponentStore();
|
|
61
61
|
const EXT_STORE_SYMBOL = Symbol.for("LGUI_EXT_STORE");
|
|
62
62
|
const REQUIRE_SYMBOL = Symbol.for("LGUI_REQUIRE");
|
|
63
|
+
const REQUIRE_EXTRA_SYMBOL = Symbol.for("LGUI_REQUIRE_EXTRA");
|
|
63
64
|
export function LoadExternalComponent({ stream, namespace, message, meta, fallback, components, ...props }) {
|
|
64
65
|
const ref = React.useRef(null);
|
|
65
66
|
const id = React.useId();
|
|
@@ -91,6 +92,12 @@ export function LoadExternalComponent({ stream, namespace, message, meta, fallba
|
|
|
91
92
|
? ReactDOM.createPortal(React.createElement(state.comp, message.props), state.target)
|
|
92
93
|
: fallback })] }));
|
|
93
94
|
}
|
|
95
|
+
export function experimental_loadShare(name, module) {
|
|
96
|
+
if (typeof window === "undefined")
|
|
97
|
+
return;
|
|
98
|
+
window[REQUIRE_EXTRA_SYMBOL] ??= {};
|
|
99
|
+
window[REQUIRE_EXTRA_SYMBOL][name] = module;
|
|
100
|
+
}
|
|
94
101
|
export function bootstrapUiContext() {
|
|
95
102
|
if (typeof window === "undefined") {
|
|
96
103
|
console.warn("Attempting to bootstrap UI context outside of browser environment. " +
|
|
@@ -115,6 +122,11 @@ export function bootstrapUiContext() {
|
|
|
115
122
|
},
|
|
116
123
|
};
|
|
117
124
|
}
|
|
125
|
+
if (window[REQUIRE_EXTRA_SYMBOL] != null &&
|
|
126
|
+
typeof window[REQUIRE_EXTRA_SYMBOL] === "object" &&
|
|
127
|
+
name in window[REQUIRE_EXTRA_SYMBOL]) {
|
|
128
|
+
return window[REQUIRE_EXTRA_SYMBOL][name];
|
|
129
|
+
}
|
|
118
130
|
throw new Error(`Unknown module...: ${name}`);
|
|
119
131
|
};
|
|
120
132
|
}
|
package/dist/react-ui/index.cjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.uiMessageReducer = exports.LoadExternalComponent = exports.useStreamContext = void 0;
|
|
3
|
+
exports.uiMessageReducer = exports.experimental_loadShare = exports.LoadExternalComponent = exports.useStreamContext = void 0;
|
|
4
4
|
const client_js_1 = require("./client.cjs");
|
|
5
5
|
(0, client_js_1.bootstrapUiContext)();
|
|
6
6
|
var client_js_2 = require("./client.cjs");
|
|
7
7
|
Object.defineProperty(exports, "useStreamContext", { enumerable: true, get: function () { return client_js_2.useStreamContext; } });
|
|
8
8
|
Object.defineProperty(exports, "LoadExternalComponent", { enumerable: true, get: function () { return client_js_2.LoadExternalComponent; } });
|
|
9
|
+
Object.defineProperty(exports, "experimental_loadShare", { enumerable: true, get: function () { return client_js_2.experimental_loadShare; } });
|
|
9
10
|
var types_js_1 = require("./types.cjs");
|
|
10
11
|
Object.defineProperty(exports, "uiMessageReducer", { enumerable: true, get: function () { return types_js_1.uiMessageReducer; } });
|
package/dist/react-ui/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { useStreamContext, LoadExternalComponent } from "./client.js";
|
|
1
|
+
export { useStreamContext, LoadExternalComponent, experimental_loadShare, } from "./client.js";
|
|
2
2
|
export { uiMessageReducer, type UIMessage, type RemoveUIMessage, } from "./types.js";
|
package/dist/react-ui/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { bootstrapUiContext } from "./client.js";
|
|
2
2
|
bootstrapUiContext();
|
|
3
|
-
export { useStreamContext, LoadExternalComponent } from "./client.js";
|
|
3
|
+
export { useStreamContext, LoadExternalComponent, experimental_loadShare, } from "./client.js";
|
|
4
4
|
export { uiMessageReducer, } from "./types.js";
|
package/dist/schema.d.ts
CHANGED
|
@@ -39,22 +39,22 @@ export interface GraphSchema {
|
|
|
39
39
|
* The schema for the input state.
|
|
40
40
|
* Missing if unable to generate JSON schema from graph.
|
|
41
41
|
*/
|
|
42
|
-
input_schema?: JSONSchema7;
|
|
42
|
+
input_schema?: JSONSchema7 | null | undefined;
|
|
43
43
|
/**
|
|
44
44
|
* The schema for the output state.
|
|
45
45
|
* Missing if unable to generate JSON schema from graph.
|
|
46
46
|
*/
|
|
47
|
-
output_schema?: JSONSchema7;
|
|
47
|
+
output_schema?: JSONSchema7 | null | undefined;
|
|
48
48
|
/**
|
|
49
49
|
* The schema for the graph state.
|
|
50
50
|
* Missing if unable to generate JSON schema from graph.
|
|
51
51
|
*/
|
|
52
|
-
state_schema?: JSONSchema7;
|
|
52
|
+
state_schema?: JSONSchema7 | null | undefined;
|
|
53
53
|
/**
|
|
54
54
|
* The schema for the graph config.
|
|
55
55
|
* Missing if unable to generate JSON schema from graph.
|
|
56
56
|
*/
|
|
57
|
-
config_schema?: JSONSchema7;
|
|
57
|
+
config_schema?: JSONSchema7 | null | undefined;
|
|
58
58
|
}
|
|
59
59
|
export type Subgraphs = Record<string, GraphSchema>;
|
|
60
60
|
export type Metadata = Optional<{
|