@langchain/langgraph-sdk 0.0.50 → 0.0.51
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/react/stream.cjs +11 -1
- package/dist/react/stream.d.ts +3 -1
- package/dist/react/stream.js +11 -1
- package/dist/react-ui/index.cjs +3 -1
- package/dist/react-ui/index.d.ts +1 -1
- package/dist/react-ui/index.js +1 -0
- package/dist/react-ui/server/server.cjs +23 -18
- package/dist/react-ui/server/server.d.ts +14 -4
- package/dist/react-ui/server/server.js +23 -18
- package/dist/react-ui/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/react/stream.cjs
CHANGED
|
@@ -378,7 +378,17 @@ function useStream(options) {
|
|
|
378
378
|
if (event === "updates")
|
|
379
379
|
options.onUpdateEvent?.(data);
|
|
380
380
|
if (event === "custom")
|
|
381
|
-
options.onCustomEvent?.(data
|
|
381
|
+
options.onCustomEvent?.(data, {
|
|
382
|
+
mutate: (update) => setStreamValues((prev) => {
|
|
383
|
+
// should not happen
|
|
384
|
+
if (prev == null)
|
|
385
|
+
return prev;
|
|
386
|
+
return {
|
|
387
|
+
...prev,
|
|
388
|
+
...(typeof update === "function" ? update(prev) : update),
|
|
389
|
+
};
|
|
390
|
+
}),
|
|
391
|
+
});
|
|
382
392
|
if (event === "metadata")
|
|
383
393
|
options.onMetadataEvent?.(data);
|
|
384
394
|
if (event === "values")
|
package/dist/react/stream.d.ts
CHANGED
|
@@ -96,7 +96,9 @@ interface UseStreamOptions<StateType extends Record<string, unknown> = Record<st
|
|
|
96
96
|
/**
|
|
97
97
|
* Callback that is called when a custom event is received.
|
|
98
98
|
*/
|
|
99
|
-
onCustomEvent?: (data: CustomStreamEvent<GetCustomEventType<Bag>>["data"]
|
|
99
|
+
onCustomEvent?: (data: CustomStreamEvent<GetCustomEventType<Bag>>["data"], options: {
|
|
100
|
+
mutate: (update: Partial<StateType> | ((prev: StateType) => Partial<StateType>)) => void;
|
|
101
|
+
}) => void;
|
|
100
102
|
/**
|
|
101
103
|
* Callback that is called when a metadata event is received.
|
|
102
104
|
*/
|
package/dist/react/stream.js
CHANGED
|
@@ -375,7 +375,17 @@ export function useStream(options) {
|
|
|
375
375
|
if (event === "updates")
|
|
376
376
|
options.onUpdateEvent?.(data);
|
|
377
377
|
if (event === "custom")
|
|
378
|
-
options.onCustomEvent?.(data
|
|
378
|
+
options.onCustomEvent?.(data, {
|
|
379
|
+
mutate: (update) => setStreamValues((prev) => {
|
|
380
|
+
// should not happen
|
|
381
|
+
if (prev == null)
|
|
382
|
+
return prev;
|
|
383
|
+
return {
|
|
384
|
+
...prev,
|
|
385
|
+
...(typeof update === "function" ? update(prev) : update),
|
|
386
|
+
};
|
|
387
|
+
}),
|
|
388
|
+
});
|
|
379
389
|
if (event === "metadata")
|
|
380
390
|
options.onMetadataEvent?.(data);
|
|
381
391
|
if (event === "values")
|
package/dist/react-ui/index.cjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LoadExternalComponent = exports.useStreamContext = void 0;
|
|
3
|
+
exports.uiMessageReducer = 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
|
+
var types_js_1 = require("./types.cjs");
|
|
10
|
+
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
1
|
export { useStreamContext, LoadExternalComponent } from "./client.js";
|
|
2
|
-
export type
|
|
2
|
+
export { uiMessageReducer, type UIMessage, type RemoveUIMessage, } from "./types.js";
|
package/dist/react-ui/index.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.typedUi = void 0;
|
|
4
4
|
const uuid_1 = require("uuid");
|
|
5
5
|
const typedUi = (config) => {
|
|
6
|
-
let
|
|
6
|
+
let items = [];
|
|
7
7
|
const runId = config.metadata?.run_id ?? config.runId;
|
|
8
8
|
if (!runId)
|
|
9
9
|
throw new Error("run_id is required");
|
|
@@ -13,23 +13,28 @@ const typedUi = (config) => {
|
|
|
13
13
|
name: config.runName,
|
|
14
14
|
run_id: runId,
|
|
15
15
|
};
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
config.writer?.(evt);
|
|
32
|
-
},
|
|
16
|
+
const handlePush = (message, options) => {
|
|
17
|
+
const evt = {
|
|
18
|
+
type: "ui",
|
|
19
|
+
id: message?.id ?? (0, uuid_1.v4)(),
|
|
20
|
+
name: message?.name,
|
|
21
|
+
content: message?.content,
|
|
22
|
+
additional_kwargs: {
|
|
23
|
+
...metadata,
|
|
24
|
+
...message?.additional_kwargs,
|
|
25
|
+
...(options?.message ? { message_id: options.message.id } : null),
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
items.push(evt);
|
|
29
|
+
config.writer?.(evt);
|
|
30
|
+
return evt;
|
|
33
31
|
};
|
|
32
|
+
const handleDelete = (id) => {
|
|
33
|
+
const evt = { type: "remove-ui", id };
|
|
34
|
+
items.push(evt);
|
|
35
|
+
config.writer?.(evt);
|
|
36
|
+
return evt;
|
|
37
|
+
};
|
|
38
|
+
return { push: handlePush, delete: handleDelete, items };
|
|
34
39
|
};
|
|
35
40
|
exports.typedUi = typedUi;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { ComponentPropsWithoutRef, ElementType } from "react";
|
|
2
2
|
import type { RemoveUIMessage, UIMessage } from "../types.js";
|
|
3
|
+
interface MessageLike {
|
|
4
|
+
id?: string;
|
|
5
|
+
}
|
|
3
6
|
export declare const typedUi: <Decl extends Record<string, ElementType>>(config: {
|
|
4
7
|
writer?: (chunk: unknown) => void;
|
|
5
8
|
runId?: string;
|
|
@@ -7,8 +10,15 @@ export declare const typedUi: <Decl extends Record<string, ElementType>>(config:
|
|
|
7
10
|
tags?: string[];
|
|
8
11
|
runName?: string;
|
|
9
12
|
}) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
push: <K extends keyof Decl & string>(message: {
|
|
14
|
+
id?: string | undefined;
|
|
15
|
+
name: K;
|
|
16
|
+
content: { [K_1 in keyof Decl]: ComponentPropsWithoutRef<Decl[K_1]>; }[K];
|
|
17
|
+
additional_kwargs?: Record<string, unknown> | undefined;
|
|
18
|
+
}, options?: {
|
|
19
|
+
message?: MessageLike;
|
|
20
|
+
}) => UIMessage;
|
|
21
|
+
delete: (id: string) => RemoveUIMessage;
|
|
22
|
+
items: (UIMessage | RemoveUIMessage)[];
|
|
14
23
|
};
|
|
24
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from "uuid";
|
|
2
2
|
export const typedUi = (config) => {
|
|
3
|
-
let
|
|
3
|
+
let items = [];
|
|
4
4
|
const runId = config.metadata?.run_id ?? config.runId;
|
|
5
5
|
if (!runId)
|
|
6
6
|
throw new Error("run_id is required");
|
|
@@ -10,22 +10,27 @@ export const typedUi = (config) => {
|
|
|
10
10
|
name: config.runName,
|
|
11
11
|
run_id: runId,
|
|
12
12
|
};
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
config.writer?.(evt);
|
|
29
|
-
},
|
|
13
|
+
const handlePush = (message, options) => {
|
|
14
|
+
const evt = {
|
|
15
|
+
type: "ui",
|
|
16
|
+
id: message?.id ?? uuidv4(),
|
|
17
|
+
name: message?.name,
|
|
18
|
+
content: message?.content,
|
|
19
|
+
additional_kwargs: {
|
|
20
|
+
...metadata,
|
|
21
|
+
...message?.additional_kwargs,
|
|
22
|
+
...(options?.message ? { message_id: options.message.id } : null),
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
items.push(evt);
|
|
26
|
+
config.writer?.(evt);
|
|
27
|
+
return evt;
|
|
30
28
|
};
|
|
29
|
+
const handleDelete = (id) => {
|
|
30
|
+
const evt = { type: "remove-ui", id };
|
|
31
|
+
items.push(evt);
|
|
32
|
+
config.writer?.(evt);
|
|
33
|
+
return evt;
|
|
34
|
+
};
|
|
35
|
+
return { push: handlePush, delete: handleDelete, items };
|
|
31
36
|
};
|
package/dist/react-ui/types.d.ts
CHANGED