@langchain/langgraph-sdk 1.7.0 → 1.7.2
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/_virtual/_rolldown/runtime.cjs +7 -13
- package/dist/auth/error.cjs +1 -2
- package/dist/auth/error.cjs.map +1 -1
- package/dist/auth/error.js +1 -1
- package/dist/auth/index.cjs +3 -4
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.js +1 -2
- package/dist/auth/index.js.map +1 -1
- package/dist/client.cjs +7 -8
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +1 -2
- package/dist/client.js.map +1 -1
- package/dist/index.cjs +5 -6
- package/dist/index.js +1 -2
- package/dist/logging/index.cjs +2 -3
- package/dist/logging/index.cjs.map +1 -1
- package/dist/logging/index.js +1 -1
- package/dist/react/index.cjs +11 -48
- package/dist/react/index.d.cts +11 -14
- package/dist/react/index.d.ts +11 -14
- package/dist/react/index.js +3 -14
- package/dist/react/stream.cjs +17 -0
- package/dist/react/stream.cjs.map +1 -0
- package/dist/react/stream.custom.cjs +162 -0
- package/dist/react/stream.custom.cjs.map +1 -0
- package/dist/react/stream.custom.d.cts +40 -0
- package/dist/react/stream.custom.d.cts.map +1 -0
- package/dist/react/stream.custom.d.ts +39 -0
- package/dist/react/stream.custom.d.ts.map +1 -0
- package/dist/react/stream.custom.js +160 -0
- package/dist/react/stream.custom.js.map +1 -0
- package/dist/react/stream.d.cts +10 -0
- package/dist/react/stream.d.cts.map +1 -0
- package/dist/react/stream.d.ts +9 -0
- package/dist/react/stream.d.ts.map +1 -0
- package/dist/react/stream.js +16 -0
- package/dist/react/stream.js.map +1 -0
- package/dist/react/stream.lgp.cjs +550 -0
- package/dist/react/stream.lgp.cjs.map +1 -0
- package/dist/react/stream.lgp.js +549 -0
- package/dist/react/stream.lgp.js.map +1 -0
- package/dist/react/thread.cjs +19 -0
- package/dist/react/thread.cjs.map +1 -0
- package/dist/react/thread.js +18 -0
- package/dist/react/thread.js.map +1 -0
- package/dist/react/types.d.cts +79 -0
- package/dist/react/types.d.cts.map +1 -0
- package/dist/react/types.d.ts +79 -0
- package/dist/react/types.d.ts.map +1 -0
- package/dist/react-ui/client.cjs +136 -0
- package/dist/react-ui/client.cjs.map +1 -0
- package/dist/react-ui/client.d.cts +67 -0
- package/dist/react-ui/client.d.cts.map +1 -0
- package/dist/react-ui/client.d.ts +67 -0
- package/dist/react-ui/client.d.ts.map +1 -0
- package/dist/react-ui/client.js +130 -0
- package/dist/react-ui/client.js.map +1 -0
- package/dist/react-ui/index.cjs +13 -39
- package/dist/react-ui/index.cjs.map +1 -0
- package/dist/react-ui/index.d.cts +2 -1
- package/dist/react-ui/index.d.ts +2 -1
- package/dist/react-ui/index.js +7 -2
- package/dist/react-ui/index.js.map +1 -0
- package/dist/react-ui/server/index.cjs +5 -16
- package/dist/react-ui/server/index.d.cts +2 -1
- package/dist/react-ui/server/index.d.ts +2 -1
- package/dist/react-ui/server/index.js +3 -3
- package/dist/react-ui/server/server.cjs +56 -0
- package/dist/react-ui/server/server.cjs.map +1 -0
- package/dist/react-ui/server/server.d.cts +54 -0
- package/dist/react-ui/server/server.d.cts.map +1 -0
- package/dist/react-ui/server/server.d.ts +54 -0
- package/dist/react-ui/server/server.d.ts.map +1 -0
- package/dist/react-ui/server/server.js +55 -0
- package/dist/react-ui/server/server.js.map +1 -0
- package/dist/react-ui/types.cjs +37 -0
- package/dist/react-ui/types.cjs.map +1 -0
- package/dist/react-ui/types.d.cts +25 -0
- package/dist/react-ui/types.d.cts.map +1 -0
- package/dist/react-ui/types.d.ts +25 -0
- package/dist/react-ui/types.d.ts.map +1 -0
- package/dist/react-ui/types.js +35 -0
- package/dist/react-ui/types.js.map +1 -0
- package/dist/singletons/fetch.cjs +1 -2
- package/dist/singletons/fetch.cjs.map +1 -1
- package/dist/singletons/fetch.js +1 -1
- package/dist/singletons/fetch.js.map +1 -1
- package/dist/ui/branching.cjs +2 -3
- package/dist/ui/branching.cjs.map +1 -1
- package/dist/ui/branching.js +1 -2
- package/dist/ui/branching.js.map +1 -1
- package/dist/ui/errors.cjs +1 -2
- package/dist/ui/errors.cjs.map +1 -1
- package/dist/ui/errors.js +1 -1
- package/dist/ui/index.cjs +12 -12
- package/dist/ui/index.d.cts +3 -3
- package/dist/ui/index.d.ts +3 -3
- package/dist/ui/index.js +2 -3
- package/dist/ui/interrupts.cjs +1 -2
- package/dist/ui/interrupts.cjs.map +1 -1
- package/dist/ui/interrupts.js +1 -1
- package/dist/ui/interrupts.js.map +1 -1
- package/dist/ui/manager.cjs +5 -12
- package/dist/ui/manager.cjs.map +1 -1
- package/dist/ui/manager.js +2 -9
- package/dist/ui/manager.js.map +1 -1
- package/dist/ui/messages.cjs +21 -3
- package/dist/ui/messages.cjs.map +1 -1
- package/dist/ui/messages.d.cts +21 -1
- package/dist/ui/messages.d.cts.map +1 -1
- package/dist/ui/messages.d.ts +21 -1
- package/dist/ui/messages.d.ts.map +1 -1
- package/dist/ui/messages.js +20 -3
- package/dist/ui/messages.js.map +1 -1
- package/dist/ui/queue.cjs +1 -2
- package/dist/ui/queue.cjs.map +1 -1
- package/dist/ui/queue.js +1 -1
- package/dist/ui/queue.js.map +1 -1
- package/dist/ui/subagents.cjs +3 -4
- package/dist/ui/subagents.cjs.map +1 -1
- package/dist/ui/subagents.js +1 -2
- package/dist/ui/subagents.js.map +1 -1
- package/dist/ui/transport.cjs +3 -4
- package/dist/ui/transport.cjs.map +1 -1
- package/dist/ui/transport.js +1 -2
- package/dist/ui/transport.js.map +1 -1
- package/dist/ui/types.d.cts +1 -1
- package/dist/ui/types.d.ts +1 -1
- package/dist/ui/utils.cjs +1 -2
- package/dist/ui/utils.cjs.map +1 -1
- package/dist/ui/utils.js +1 -1
- package/dist/utils/async_caller.cjs +3 -4
- package/dist/utils/async_caller.cjs.map +1 -1
- package/dist/utils/async_caller.js +1 -2
- package/dist/utils/async_caller.js.map +1 -1
- package/dist/utils/env.cjs +1 -2
- package/dist/utils/env.cjs.map +1 -1
- package/dist/utils/env.js +1 -1
- package/dist/utils/env.js.map +1 -1
- package/dist/utils/error.cjs +1 -2
- package/dist/utils/error.cjs.map +1 -1
- package/dist/utils/error.js +1 -1
- package/dist/utils/index.cjs +5 -6
- package/dist/utils/index.js +1 -2
- package/dist/utils/signals.cjs +1 -2
- package/dist/utils/signals.cjs.map +1 -1
- package/dist/utils/signals.js +1 -1
- package/dist/utils/signals.js.map +1 -1
- package/dist/utils/sse.cjs +1 -2
- package/dist/utils/sse.cjs.map +1 -1
- package/dist/utils/sse.js +1 -1
- package/dist/utils/sse.js.map +1 -1
- package/dist/utils/stream.cjs +2 -3
- package/dist/utils/stream.cjs.map +1 -1
- package/dist/utils/stream.js +1 -2
- package/dist/utils/stream.js.map +1 -1
- package/dist/utils/tools.cjs +1 -2
- package/dist/utils/tools.cjs.map +1 -1
- package/dist/utils/tools.js +1 -1
- package/dist/utils/tools.js.map +1 -1
- package/package.json +11 -3
- package/dist/react/index.cjs.map +0 -1
- package/dist/react/index.d.cts.map +0 -1
- package/dist/react/index.d.ts.map +0 -1
- package/dist/react/index.js.map +0 -1
package/dist/react-ui/index.cjs
CHANGED
|
@@ -1,40 +1,14 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
2
|
-
const
|
|
3
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_client = require("./client.cjs");
|
|
3
|
+
const require_types = require("./types.cjs");
|
|
4
|
+
//#region src/react-ui/index.ts
|
|
5
|
+
require_client.bootstrapUiContext();
|
|
6
|
+
//#endregion
|
|
7
|
+
exports.LoadExternalComponent = require_client.LoadExternalComponent;
|
|
8
|
+
exports.experimental_loadShare = require_client.experimental_loadShare;
|
|
9
|
+
exports.isRemoveUIMessage = require_types.isRemoveUIMessage;
|
|
10
|
+
exports.isUIMessage = require_types.isUIMessage;
|
|
11
|
+
exports.uiMessageReducer = require_types.uiMessageReducer;
|
|
12
|
+
exports.useStreamContext = require_client.useStreamContext;
|
|
4
13
|
|
|
5
|
-
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function () {
|
|
8
|
-
return _langchain_react_react_ui.LoadExternalComponent;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
Object.defineProperty(exports, 'experimental_loadShare', {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function () {
|
|
14
|
-
return _langchain_react_react_ui.experimental_loadShare;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, 'isRemoveUIMessage', {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () {
|
|
20
|
-
return _langchain_react_react_ui.isRemoveUIMessage;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
Object.defineProperty(exports, 'isUIMessage', {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
get: function () {
|
|
26
|
-
return _langchain_react_react_ui.isUIMessage;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
Object.defineProperty(exports, 'uiMessageReducer', {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
get: function () {
|
|
32
|
-
return _langchain_react_react_ui.uiMessageReducer;
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
Object.defineProperty(exports, 'useStreamContext', {
|
|
36
|
-
enumerable: true,
|
|
37
|
-
get: function () {
|
|
38
|
-
return _langchain_react_react_ui.useStreamContext;
|
|
39
|
-
}
|
|
40
|
-
});
|
|
14
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["bootstrapUiContext"],"sources":["../../src/react-ui/index.ts"],"sourcesContent":["import { bootstrapUiContext } from \"./client.js\";\n\nbootstrapUiContext();\n\nexport {\n useStreamContext,\n LoadExternalComponent,\n experimental_loadShare,\n} from \"./client.js\";\nexport {\n uiMessageReducer,\n isUIMessage,\n isRemoveUIMessage,\n type UIMessage,\n type RemoveUIMessage,\n} from \"./types.js\";\n"],"mappings":";;;;AAEAA,eAAAA,oBAAoB"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RemoveUIMessage, UIMessage, isRemoveUIMessage, isUIMessage, uiMessageReducer } from "./types.cjs";
|
|
2
|
+
import { LoadExternalComponent, experimental_loadShare, useStreamContext } from "./client.cjs";
|
|
2
3
|
export { LoadExternalComponent, type RemoveUIMessage, type UIMessage, experimental_loadShare, isRemoveUIMessage, isUIMessage, uiMessageReducer, useStreamContext };
|
package/dist/react-ui/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RemoveUIMessage, UIMessage, isRemoveUIMessage, isUIMessage, uiMessageReducer } from "./types.js";
|
|
2
|
+
import { LoadExternalComponent, experimental_loadShare, useStreamContext } from "./client.js";
|
|
2
3
|
export { LoadExternalComponent, type RemoveUIMessage, type UIMessage, experimental_loadShare, isRemoveUIMessage, isUIMessage, uiMessageReducer, useStreamContext };
|
package/dist/react-ui/index.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
import { LoadExternalComponent,
|
|
1
|
+
import { LoadExternalComponent, bootstrapUiContext, experimental_loadShare, useStreamContext } from "./client.js";
|
|
2
|
+
import { isRemoveUIMessage, isUIMessage, uiMessageReducer } from "./types.js";
|
|
3
|
+
//#region src/react-ui/index.ts
|
|
4
|
+
bootstrapUiContext();
|
|
5
|
+
//#endregion
|
|
6
|
+
export { LoadExternalComponent, experimental_loadShare, isRemoveUIMessage, isUIMessage, uiMessageReducer, useStreamContext };
|
|
2
7
|
|
|
3
|
-
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/react-ui/index.ts"],"sourcesContent":["import { bootstrapUiContext } from \"./client.js\";\n\nbootstrapUiContext();\n\nexport {\n useStreamContext,\n LoadExternalComponent,\n experimental_loadShare,\n} from \"./client.js\";\nexport {\n uiMessageReducer,\n isUIMessage,\n isRemoveUIMessage,\n type UIMessage,\n type RemoveUIMessage,\n} from \"./types.js\";\n"],"mappings":";;;AAEA,oBAAoB"}
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function () {
|
|
8
|
-
return _langchain_react_react_ui_server.typedUi;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
Object.defineProperty(exports, 'uiMessageReducer', {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function () {
|
|
14
|
-
return _langchain_react_react_ui_server.uiMessageReducer;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_types = require("../types.cjs");
|
|
3
|
+
const require_server = require("./server.cjs");
|
|
4
|
+
exports.typedUi = require_server.typedUi;
|
|
5
|
+
exports.uiMessageReducer = require_types.uiMessageReducer;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { RemoveUIMessage, UIMessage,
|
|
1
|
+
import { RemoveUIMessage, UIMessage, uiMessageReducer } from "../types.cjs";
|
|
2
|
+
import { typedUi } from "./server.cjs";
|
|
2
3
|
export { type RemoveUIMessage, type UIMessage, typedUi, uiMessageReducer };
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { RemoveUIMessage, UIMessage,
|
|
1
|
+
import { RemoveUIMessage, UIMessage, uiMessageReducer } from "../types.js";
|
|
2
|
+
import { typedUi } from "./server.js";
|
|
2
3
|
export { type RemoveUIMessage, type UIMessage, typedUi, uiMessageReducer };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export { typedUi, uiMessageReducer };
|
|
1
|
+
import { uiMessageReducer } from "../types.js";
|
|
2
|
+
import { typedUi } from "./server.js";
|
|
3
|
+
export { typedUi, uiMessageReducer };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let uuid = require("uuid");
|
|
3
|
+
//#region src/react-ui/server/server.ts
|
|
4
|
+
/**
|
|
5
|
+
* Helper to send and persist UI messages. Accepts a map of component names to React components
|
|
6
|
+
* as type argument to provide type safety. Will also write to the `options?.stateKey` state.
|
|
7
|
+
*
|
|
8
|
+
* @param config LangGraphRunnableConfig
|
|
9
|
+
* @param options
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
const typedUi = (config, options) => {
|
|
13
|
+
const items = [];
|
|
14
|
+
const stateKey = options?.stateKey ?? "ui";
|
|
15
|
+
const runId = config.metadata?.run_id ?? config.runId;
|
|
16
|
+
if (!runId) throw new Error("run_id is required");
|
|
17
|
+
function handlePush(message, options) {
|
|
18
|
+
const evt = {
|
|
19
|
+
type: "ui",
|
|
20
|
+
id: message?.id ?? (0, uuid.v4)(),
|
|
21
|
+
name: message?.name,
|
|
22
|
+
props: message?.props,
|
|
23
|
+
metadata: {
|
|
24
|
+
merge: options?.merge || void 0,
|
|
25
|
+
run_id: runId,
|
|
26
|
+
tags: config.tags,
|
|
27
|
+
name: config.runName,
|
|
28
|
+
...message?.metadata,
|
|
29
|
+
...options?.message ? { message_id: options.message.id } : null
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
items.push(evt);
|
|
33
|
+
config.writer?.(evt);
|
|
34
|
+
config.configurable?.__pregel_send?.([[stateKey, evt]]);
|
|
35
|
+
return evt;
|
|
36
|
+
}
|
|
37
|
+
const handleDelete = (id) => {
|
|
38
|
+
const evt = {
|
|
39
|
+
type: "remove-ui",
|
|
40
|
+
id
|
|
41
|
+
};
|
|
42
|
+
items.push(evt);
|
|
43
|
+
config.writer?.(evt);
|
|
44
|
+
config.configurable?.__pregel_send?.([[stateKey, evt]]);
|
|
45
|
+
return evt;
|
|
46
|
+
};
|
|
47
|
+
return {
|
|
48
|
+
push: handlePush,
|
|
49
|
+
delete: handleDelete,
|
|
50
|
+
items
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
//#endregion
|
|
54
|
+
exports.typedUi = typedUi;
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=server.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.cjs","names":[],"sources":["../../../src/react-ui/server/server.ts"],"sourcesContent":["import { v4 as uuidv4 } from \"uuid\";\nimport type { ComponentPropsWithoutRef, ElementType } from \"react\";\nimport type { RemoveUIMessage, UIMessage } from \"../types.js\";\n\ninterface MessageLike {\n id?: string;\n}\n\n/**\n * Helper to send and persist UI messages. Accepts a map of component names to React components\n * as type argument to provide type safety. Will also write to the `options?.stateKey` state.\n *\n * @param config LangGraphRunnableConfig\n * @param options\n * @returns\n */\nexport const typedUi = <Decl extends Record<string, ElementType>>(\n config: {\n writer?: (chunk: unknown) => void;\n runId?: string;\n metadata?: Record<string, unknown>;\n tags?: string[];\n runName?: string;\n configurable?: {\n __pregel_send?: (writes_: [string, unknown][]) => void;\n [key: string]: unknown;\n };\n },\n options?: {\n /** The key to write the UI messages to. Defaults to `ui`. */\n stateKey?: string;\n }\n) => {\n type PropMap = { [K in keyof Decl]: ComponentPropsWithoutRef<Decl[K]> };\n const items: (UIMessage | RemoveUIMessage)[] = [];\n const stateKey = options?.stateKey ?? \"ui\";\n\n const runId = (config.metadata?.run_id as string | undefined) ?? config.runId;\n if (!runId) throw new Error(\"run_id is required\");\n\n function handlePush<K extends keyof PropMap & string>(\n message: {\n id?: string;\n name: K;\n props: PropMap[K];\n metadata?: Record<string, unknown>;\n },\n options?: { message?: MessageLike; merge?: boolean }\n ): UIMessage<K, PropMap[K]>;\n\n function handlePush<K extends keyof PropMap & string>(\n message: {\n id?: string;\n name: K;\n props: Partial<PropMap[K]>;\n metadata?: Record<string, unknown>;\n },\n options: { message?: MessageLike; merge: true }\n ): UIMessage<K, Partial<PropMap[K]>>;\n\n function handlePush<K extends keyof PropMap & string>(\n message: {\n id?: string;\n name: K;\n props: PropMap[K] | Partial<PropMap[K]>;\n metadata?: Record<string, unknown>;\n },\n options?: { message?: MessageLike; merge?: boolean }\n ): UIMessage<K, PropMap[K] | Partial<PropMap[K]>> {\n const evt: UIMessage<K, PropMap[K] | Partial<PropMap[K]>> = {\n type: \"ui\" as const,\n id: message?.id ?? uuidv4(),\n name: message?.name,\n props: message?.props,\n metadata: {\n merge: options?.merge || undefined,\n run_id: runId,\n tags: config.tags,\n name: config.runName,\n ...message?.metadata,\n ...(options?.message ? { message_id: options.message.id } : null),\n },\n };\n items.push(evt);\n config.writer?.(evt);\n config.configurable?.__pregel_send?.([[stateKey, evt]]);\n return evt;\n }\n\n const handleDelete = (id: string): RemoveUIMessage => {\n const evt: RemoveUIMessage = { type: \"remove-ui\", id };\n items.push(evt);\n config.writer?.(evt);\n config.configurable?.__pregel_send?.([[stateKey, evt]]);\n return evt;\n };\n\n return { push: handlePush, delete: handleDelete, items };\n};\n"],"mappings":";;;;;;;;;;;AAgBA,MAAa,WACX,QAWA,YAIG;CAEH,MAAM,QAAyC,EAAE;CACjD,MAAM,WAAW,SAAS,YAAY;CAEtC,MAAM,QAAS,OAAO,UAAU,UAAiC,OAAO;AACxE,KAAI,CAAC,MAAO,OAAM,IAAI,MAAM,qBAAqB;CAsBjD,SAAS,WACP,SAMA,SACgD;EAChD,MAAM,MAAsD;GAC1D,MAAM;GACN,IAAI,SAAS,OAAA,GAAA,KAAA,KAAc;GAC3B,MAAM,SAAS;GACf,OAAO,SAAS;GAChB,UAAU;IACR,OAAO,SAAS,SAAS,KAAA;IACzB,QAAQ;IACR,MAAM,OAAO;IACb,MAAM,OAAO;IACb,GAAG,SAAS;IACZ,GAAI,SAAS,UAAU,EAAE,YAAY,QAAQ,QAAQ,IAAI,GAAG;IAC7D;GACF;AACD,QAAM,KAAK,IAAI;AACf,SAAO,SAAS,IAAI;AACpB,SAAO,cAAc,gBAAgB,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC;AACvD,SAAO;;CAGT,MAAM,gBAAgB,OAAgC;EACpD,MAAM,MAAuB;GAAE,MAAM;GAAa;GAAI;AACtD,QAAM,KAAK,IAAI;AACf,SAAO,SAAS,IAAI;AACpB,SAAO,cAAc,gBAAgB,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC;AACvD,SAAO;;AAGT,QAAO;EAAE,MAAM;EAAY,QAAQ;EAAc;EAAO"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { RemoveUIMessage, UIMessage } from "../types.cjs";
|
|
2
|
+
import { ComponentPropsWithoutRef, ElementType } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/react-ui/server/server.d.ts
|
|
5
|
+
interface MessageLike {
|
|
6
|
+
id?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Helper to send and persist UI messages. Accepts a map of component names to React components
|
|
10
|
+
* as type argument to provide type safety. Will also write to the `options?.stateKey` state.
|
|
11
|
+
*
|
|
12
|
+
* @param config LangGraphRunnableConfig
|
|
13
|
+
* @param options
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
declare const typedUi: <Decl extends Record<string, ElementType>>(config: {
|
|
17
|
+
writer?: ((chunk: unknown) => void) | undefined;
|
|
18
|
+
runId?: string | undefined;
|
|
19
|
+
metadata?: Record<string, unknown> | undefined;
|
|
20
|
+
tags?: string[] | undefined;
|
|
21
|
+
runName?: string | undefined;
|
|
22
|
+
configurable?: {
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
__pregel_send?: ((writes_: [string, unknown][]) => void) | undefined;
|
|
25
|
+
} | undefined;
|
|
26
|
+
}, options?: {
|
|
27
|
+
/** The key to write the UI messages to. Defaults to `ui`. */stateKey?: string | undefined;
|
|
28
|
+
} | undefined) => {
|
|
29
|
+
push: {
|
|
30
|
+
<K extends keyof Decl & string>(message: {
|
|
31
|
+
id?: string | undefined;
|
|
32
|
+
name: K;
|
|
33
|
+
props: { [K_1 in keyof Decl]: ComponentPropsWithoutRef<Decl[K_1]> }[K];
|
|
34
|
+
metadata?: Record<string, unknown> | undefined;
|
|
35
|
+
}, options?: {
|
|
36
|
+
message?: MessageLike | undefined;
|
|
37
|
+
merge?: boolean | undefined;
|
|
38
|
+
} | undefined): UIMessage<K, { [K_1 in keyof Decl]: ComponentPropsWithoutRef<Decl[K_1]> }[K]>;
|
|
39
|
+
<K extends keyof Decl & string>(message: {
|
|
40
|
+
id?: string | undefined;
|
|
41
|
+
name: K;
|
|
42
|
+
props: Partial<{ [K_1 in keyof Decl]: ComponentPropsWithoutRef<Decl[K_1]> }[K]>;
|
|
43
|
+
metadata?: Record<string, unknown> | undefined;
|
|
44
|
+
}, options: {
|
|
45
|
+
message?: MessageLike | undefined;
|
|
46
|
+
merge: true;
|
|
47
|
+
}): UIMessage<K, Partial<{ [K_1 in keyof Decl]: ComponentPropsWithoutRef<Decl[K_1]> }[K]>>;
|
|
48
|
+
};
|
|
49
|
+
delete: (id: string) => RemoveUIMessage;
|
|
50
|
+
items: (RemoveUIMessage | UIMessage<string, Record<string, unknown>>)[];
|
|
51
|
+
};
|
|
52
|
+
//#endregion
|
|
53
|
+
export { typedUi };
|
|
54
|
+
//# sourceMappingURL=server.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.cts","names":[],"sources":["../../../src/react-ui/server/server.ts"],"mappings":";;;;UAIU,WAAA;EACR,EAAA;AAAA;;;;;AAWF;;;;cAAa,OAAA,gBAAe,MAAA,SAAA,WAAA,GAAA,MAAA;;;;;;;;;;;;;;qBAwBL,IAAA,WAAA,OAAA;;;;;;;;;qBAUA,IAAA,WAAA,OAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { RemoveUIMessage, UIMessage } from "../types.js";
|
|
2
|
+
import { ComponentPropsWithoutRef, ElementType } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/react-ui/server/server.d.ts
|
|
5
|
+
interface MessageLike {
|
|
6
|
+
id?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Helper to send and persist UI messages. Accepts a map of component names to React components
|
|
10
|
+
* as type argument to provide type safety. Will also write to the `options?.stateKey` state.
|
|
11
|
+
*
|
|
12
|
+
* @param config LangGraphRunnableConfig
|
|
13
|
+
* @param options
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
declare const typedUi: <Decl extends Record<string, ElementType>>(config: {
|
|
17
|
+
writer?: ((chunk: unknown) => void) | undefined;
|
|
18
|
+
runId?: string | undefined;
|
|
19
|
+
metadata?: Record<string, unknown> | undefined;
|
|
20
|
+
tags?: string[] | undefined;
|
|
21
|
+
runName?: string | undefined;
|
|
22
|
+
configurable?: {
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
__pregel_send?: ((writes_: [string, unknown][]) => void) | undefined;
|
|
25
|
+
} | undefined;
|
|
26
|
+
}, options?: {
|
|
27
|
+
/** The key to write the UI messages to. Defaults to `ui`. */stateKey?: string | undefined;
|
|
28
|
+
} | undefined) => {
|
|
29
|
+
push: {
|
|
30
|
+
<K extends keyof Decl & string>(message: {
|
|
31
|
+
id?: string | undefined;
|
|
32
|
+
name: K;
|
|
33
|
+
props: { [K_1 in keyof Decl]: ComponentPropsWithoutRef<Decl[K_1]> }[K];
|
|
34
|
+
metadata?: Record<string, unknown> | undefined;
|
|
35
|
+
}, options?: {
|
|
36
|
+
message?: MessageLike | undefined;
|
|
37
|
+
merge?: boolean | undefined;
|
|
38
|
+
} | undefined): UIMessage<K, { [K_1 in keyof Decl]: ComponentPropsWithoutRef<Decl[K_1]> }[K]>;
|
|
39
|
+
<K extends keyof Decl & string>(message: {
|
|
40
|
+
id?: string | undefined;
|
|
41
|
+
name: K;
|
|
42
|
+
props: Partial<{ [K_1 in keyof Decl]: ComponentPropsWithoutRef<Decl[K_1]> }[K]>;
|
|
43
|
+
metadata?: Record<string, unknown> | undefined;
|
|
44
|
+
}, options: {
|
|
45
|
+
message?: MessageLike | undefined;
|
|
46
|
+
merge: true;
|
|
47
|
+
}): UIMessage<K, Partial<{ [K_1 in keyof Decl]: ComponentPropsWithoutRef<Decl[K_1]> }[K]>>;
|
|
48
|
+
};
|
|
49
|
+
delete: (id: string) => RemoveUIMessage;
|
|
50
|
+
items: (RemoveUIMessage | UIMessage<string, Record<string, unknown>>)[];
|
|
51
|
+
};
|
|
52
|
+
//#endregion
|
|
53
|
+
export { typedUi };
|
|
54
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","names":[],"sources":["../../../src/react-ui/server/server.ts"],"mappings":";;;;UAIU,WAAA;EACR,EAAA;AAAA;;;;;AAWF;;;;cAAa,OAAA,gBAAe,MAAA,SAAA,WAAA,GAAA,MAAA;;;;;;;;;;;;;;qBAwBL,IAAA,WAAA,OAAA;;;;;;;;;qBAUA,IAAA,WAAA,OAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { v4 } from "uuid";
|
|
2
|
+
//#region src/react-ui/server/server.ts
|
|
3
|
+
/**
|
|
4
|
+
* Helper to send and persist UI messages. Accepts a map of component names to React components
|
|
5
|
+
* as type argument to provide type safety. Will also write to the `options?.stateKey` state.
|
|
6
|
+
*
|
|
7
|
+
* @param config LangGraphRunnableConfig
|
|
8
|
+
* @param options
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
const typedUi = (config, options) => {
|
|
12
|
+
const items = [];
|
|
13
|
+
const stateKey = options?.stateKey ?? "ui";
|
|
14
|
+
const runId = config.metadata?.run_id ?? config.runId;
|
|
15
|
+
if (!runId) throw new Error("run_id is required");
|
|
16
|
+
function handlePush(message, options) {
|
|
17
|
+
const evt = {
|
|
18
|
+
type: "ui",
|
|
19
|
+
id: message?.id ?? v4(),
|
|
20
|
+
name: message?.name,
|
|
21
|
+
props: message?.props,
|
|
22
|
+
metadata: {
|
|
23
|
+
merge: options?.merge || void 0,
|
|
24
|
+
run_id: runId,
|
|
25
|
+
tags: config.tags,
|
|
26
|
+
name: config.runName,
|
|
27
|
+
...message?.metadata,
|
|
28
|
+
...options?.message ? { message_id: options.message.id } : null
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
items.push(evt);
|
|
32
|
+
config.writer?.(evt);
|
|
33
|
+
config.configurable?.__pregel_send?.([[stateKey, evt]]);
|
|
34
|
+
return evt;
|
|
35
|
+
}
|
|
36
|
+
const handleDelete = (id) => {
|
|
37
|
+
const evt = {
|
|
38
|
+
type: "remove-ui",
|
|
39
|
+
id
|
|
40
|
+
};
|
|
41
|
+
items.push(evt);
|
|
42
|
+
config.writer?.(evt);
|
|
43
|
+
config.configurable?.__pregel_send?.([[stateKey, evt]]);
|
|
44
|
+
return evt;
|
|
45
|
+
};
|
|
46
|
+
return {
|
|
47
|
+
push: handlePush,
|
|
48
|
+
delete: handleDelete,
|
|
49
|
+
items
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
//#endregion
|
|
53
|
+
export { typedUi };
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","names":["uuidv4"],"sources":["../../../src/react-ui/server/server.ts"],"sourcesContent":["import { v4 as uuidv4 } from \"uuid\";\nimport type { ComponentPropsWithoutRef, ElementType } from \"react\";\nimport type { RemoveUIMessage, UIMessage } from \"../types.js\";\n\ninterface MessageLike {\n id?: string;\n}\n\n/**\n * Helper to send and persist UI messages. Accepts a map of component names to React components\n * as type argument to provide type safety. Will also write to the `options?.stateKey` state.\n *\n * @param config LangGraphRunnableConfig\n * @param options\n * @returns\n */\nexport const typedUi = <Decl extends Record<string, ElementType>>(\n config: {\n writer?: (chunk: unknown) => void;\n runId?: string;\n metadata?: Record<string, unknown>;\n tags?: string[];\n runName?: string;\n configurable?: {\n __pregel_send?: (writes_: [string, unknown][]) => void;\n [key: string]: unknown;\n };\n },\n options?: {\n /** The key to write the UI messages to. Defaults to `ui`. */\n stateKey?: string;\n }\n) => {\n type PropMap = { [K in keyof Decl]: ComponentPropsWithoutRef<Decl[K]> };\n const items: (UIMessage | RemoveUIMessage)[] = [];\n const stateKey = options?.stateKey ?? \"ui\";\n\n const runId = (config.metadata?.run_id as string | undefined) ?? config.runId;\n if (!runId) throw new Error(\"run_id is required\");\n\n function handlePush<K extends keyof PropMap & string>(\n message: {\n id?: string;\n name: K;\n props: PropMap[K];\n metadata?: Record<string, unknown>;\n },\n options?: { message?: MessageLike; merge?: boolean }\n ): UIMessage<K, PropMap[K]>;\n\n function handlePush<K extends keyof PropMap & string>(\n message: {\n id?: string;\n name: K;\n props: Partial<PropMap[K]>;\n metadata?: Record<string, unknown>;\n },\n options: { message?: MessageLike; merge: true }\n ): UIMessage<K, Partial<PropMap[K]>>;\n\n function handlePush<K extends keyof PropMap & string>(\n message: {\n id?: string;\n name: K;\n props: PropMap[K] | Partial<PropMap[K]>;\n metadata?: Record<string, unknown>;\n },\n options?: { message?: MessageLike; merge?: boolean }\n ): UIMessage<K, PropMap[K] | Partial<PropMap[K]>> {\n const evt: UIMessage<K, PropMap[K] | Partial<PropMap[K]>> = {\n type: \"ui\" as const,\n id: message?.id ?? uuidv4(),\n name: message?.name,\n props: message?.props,\n metadata: {\n merge: options?.merge || undefined,\n run_id: runId,\n tags: config.tags,\n name: config.runName,\n ...message?.metadata,\n ...(options?.message ? { message_id: options.message.id } : null),\n },\n };\n items.push(evt);\n config.writer?.(evt);\n config.configurable?.__pregel_send?.([[stateKey, evt]]);\n return evt;\n }\n\n const handleDelete = (id: string): RemoveUIMessage => {\n const evt: RemoveUIMessage = { type: \"remove-ui\", id };\n items.push(evt);\n config.writer?.(evt);\n config.configurable?.__pregel_send?.([[stateKey, evt]]);\n return evt;\n };\n\n return { push: handlePush, delete: handleDelete, items };\n};\n"],"mappings":";;;;;;;;;;AAgBA,MAAa,WACX,QAWA,YAIG;CAEH,MAAM,QAAyC,EAAE;CACjD,MAAM,WAAW,SAAS,YAAY;CAEtC,MAAM,QAAS,OAAO,UAAU,UAAiC,OAAO;AACxE,KAAI,CAAC,MAAO,OAAM,IAAI,MAAM,qBAAqB;CAsBjD,SAAS,WACP,SAMA,SACgD;EAChD,MAAM,MAAsD;GAC1D,MAAM;GACN,IAAI,SAAS,MAAMA,IAAQ;GAC3B,MAAM,SAAS;GACf,OAAO,SAAS;GAChB,UAAU;IACR,OAAO,SAAS,SAAS,KAAA;IACzB,QAAQ;IACR,MAAM,OAAO;IACb,MAAM,OAAO;IACb,GAAG,SAAS;IACZ,GAAI,SAAS,UAAU,EAAE,YAAY,QAAQ,QAAQ,IAAI,GAAG;IAC7D;GACF;AACD,QAAM,KAAK,IAAI;AACf,SAAO,SAAS,IAAI;AACpB,SAAO,cAAc,gBAAgB,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC;AACvD,SAAO;;CAGT,MAAM,gBAAgB,OAAgC;EACpD,MAAM,MAAuB;GAAE,MAAM;GAAa;GAAI;AACtD,QAAM,KAAK,IAAI;AACf,SAAO,SAAS,IAAI;AACpB,SAAO,cAAc,gBAAgB,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC;AACvD,SAAO;;AAGT,QAAO;EAAE,MAAM;EAAY,QAAQ;EAAc;EAAO"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region src/react-ui/types.ts
|
|
2
|
+
function isUIMessage(message) {
|
|
3
|
+
if (typeof message !== "object" || message == null) return false;
|
|
4
|
+
if (!("type" in message)) return false;
|
|
5
|
+
return message.type === "ui";
|
|
6
|
+
}
|
|
7
|
+
function isRemoveUIMessage(message) {
|
|
8
|
+
if (typeof message !== "object" || message == null) return false;
|
|
9
|
+
if (!("type" in message)) return false;
|
|
10
|
+
return message.type === "remove-ui";
|
|
11
|
+
}
|
|
12
|
+
function uiMessageReducer(state, update) {
|
|
13
|
+
const events = Array.isArray(update) ? update : [update];
|
|
14
|
+
let newState = state.slice();
|
|
15
|
+
for (const event of events) {
|
|
16
|
+
if (event.type === "remove-ui") {
|
|
17
|
+
newState = newState.filter((ui) => ui.id !== event.id);
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const index = state.findIndex((ui) => ui.id === event.id);
|
|
21
|
+
if (index !== -1) newState[index] = typeof event.metadata === "object" && event.metadata != null && event.metadata.merge ? {
|
|
22
|
+
...event,
|
|
23
|
+
props: {
|
|
24
|
+
...state[index].props,
|
|
25
|
+
...event.props
|
|
26
|
+
}
|
|
27
|
+
} : event;
|
|
28
|
+
else newState.push(event);
|
|
29
|
+
}
|
|
30
|
+
return newState;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
exports.isRemoveUIMessage = isRemoveUIMessage;
|
|
34
|
+
exports.isUIMessage = isUIMessage;
|
|
35
|
+
exports.uiMessageReducer = uiMessageReducer;
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=types.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.cjs","names":[],"sources":["../../src/react-ui/types.ts"],"sourcesContent":["export interface UIMessage<\n TName extends string = string,\n TProps extends Record<string, unknown> = Record<string, unknown>\n> {\n type: \"ui\";\n\n id: string;\n name: TName;\n props: TProps;\n metadata?: {\n merge?: boolean;\n run_id?: string;\n name?: string;\n tags?: string[];\n message_id?: string;\n [key: string]: unknown;\n };\n}\n\nexport interface RemoveUIMessage {\n type: \"remove-ui\";\n id: string;\n}\n\nexport function isUIMessage(message: unknown): message is UIMessage {\n if (typeof message !== \"object\" || message == null) return false;\n if (!(\"type\" in message)) return false;\n return message.type === \"ui\";\n}\n\nexport function isRemoveUIMessage(\n message: unknown\n): message is RemoveUIMessage {\n if (typeof message !== \"object\" || message == null) return false;\n if (!(\"type\" in message)) return false;\n return message.type === \"remove-ui\";\n}\n\nexport function uiMessageReducer(\n state: UIMessage[],\n update: UIMessage | RemoveUIMessage | (UIMessage | RemoveUIMessage)[]\n) {\n const events = Array.isArray(update) ? update : [update];\n let newState = state.slice();\n\n for (const event of events) {\n if (event.type === \"remove-ui\") {\n newState = newState.filter((ui) => ui.id !== event.id);\n continue;\n }\n\n const index = state.findIndex((ui) => ui.id === event.id);\n if (index !== -1) {\n newState[index] =\n typeof event.metadata === \"object\" &&\n event.metadata != null &&\n event.metadata.merge\n ? { ...event, props: { ...state[index].props, ...event.props } }\n : event;\n } else {\n newState.push(event);\n }\n }\n\n return newState;\n}\n"],"mappings":";AAwBA,SAAgB,YAAY,SAAwC;AAClE,KAAI,OAAO,YAAY,YAAY,WAAW,KAAM,QAAO;AAC3D,KAAI,EAAE,UAAU,SAAU,QAAO;AACjC,QAAO,QAAQ,SAAS;;AAG1B,SAAgB,kBACd,SAC4B;AAC5B,KAAI,OAAO,YAAY,YAAY,WAAW,KAAM,QAAO;AAC3D,KAAI,EAAE,UAAU,SAAU,QAAO;AACjC,QAAO,QAAQ,SAAS;;AAG1B,SAAgB,iBACd,OACA,QACA;CACA,MAAM,SAAS,MAAM,QAAQ,OAAO,GAAG,SAAS,CAAC,OAAO;CACxD,IAAI,WAAW,MAAM,OAAO;AAE5B,MAAK,MAAM,SAAS,QAAQ;AAC1B,MAAI,MAAM,SAAS,aAAa;AAC9B,cAAW,SAAS,QAAQ,OAAO,GAAG,OAAO,MAAM,GAAG;AACtD;;EAGF,MAAM,QAAQ,MAAM,WAAW,OAAO,GAAG,OAAO,MAAM,GAAG;AACzD,MAAI,UAAU,GACZ,UAAS,SACP,OAAO,MAAM,aAAa,YAC1B,MAAM,YAAY,QAClB,MAAM,SAAS,QACX;GAAE,GAAG;GAAO,OAAO;IAAE,GAAG,MAAM,OAAO;IAAO,GAAG,MAAM;IAAO;GAAE,GAC9D;MAEN,UAAS,KAAK,MAAM;;AAIxB,QAAO"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/react-ui/types.d.ts
|
|
2
|
+
interface UIMessage<TName extends string = string, TProps extends Record<string, unknown> = Record<string, unknown>> {
|
|
3
|
+
type: "ui";
|
|
4
|
+
id: string;
|
|
5
|
+
name: TName;
|
|
6
|
+
props: TProps;
|
|
7
|
+
metadata?: {
|
|
8
|
+
merge?: boolean;
|
|
9
|
+
run_id?: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
tags?: string[];
|
|
12
|
+
message_id?: string;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
interface RemoveUIMessage {
|
|
17
|
+
type: "remove-ui";
|
|
18
|
+
id: string;
|
|
19
|
+
}
|
|
20
|
+
declare function isUIMessage(message: unknown): message is UIMessage;
|
|
21
|
+
declare function isRemoveUIMessage(message: unknown): message is RemoveUIMessage;
|
|
22
|
+
declare function uiMessageReducer(state: UIMessage[], update: UIMessage | RemoveUIMessage | (UIMessage | RemoveUIMessage)[]): UIMessage<string, Record<string, unknown>>[];
|
|
23
|
+
//#endregion
|
|
24
|
+
export { RemoveUIMessage, UIMessage, isRemoveUIMessage, isUIMessage, uiMessageReducer };
|
|
25
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/react-ui/types.ts"],"mappings":";UAAiB,SAAA,+CAEA,MAAA,oBAA0B,MAAA;EAEzC,IAAA;EAEA,EAAA;EACA,IAAA,EAAM,KAAA;EACN,KAAA,EAAO,MAAA;EACP,QAAA;IACE,KAAA;IACA,MAAA;IACA,IAAA;IACA,IAAA;IACA,UAAA;IAAA,CACC,GAAA;EAAA;AAAA;AAAA,UAIY,eAAA;EACf,IAAA;EACA,EAAA;AAAA;AAAA,iBAGc,WAAA,CAAY,OAAA,YAAmB,OAAA,IAAW,SAAA;AAAA,iBAM1C,iBAAA,CACd,OAAA,YACC,OAAA,IAAW,eAAA;AAAA,iBAME,gBAAA,CACd,KAAA,EAAO,SAAA,IACP,MAAA,EAAQ,SAAA,GAAY,eAAA,IAAmB,SAAA,GAAY,eAAA,MAAkB,SAAA,SAAA,MAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/react-ui/types.d.ts
|
|
2
|
+
interface UIMessage<TName extends string = string, TProps extends Record<string, unknown> = Record<string, unknown>> {
|
|
3
|
+
type: "ui";
|
|
4
|
+
id: string;
|
|
5
|
+
name: TName;
|
|
6
|
+
props: TProps;
|
|
7
|
+
metadata?: {
|
|
8
|
+
merge?: boolean;
|
|
9
|
+
run_id?: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
tags?: string[];
|
|
12
|
+
message_id?: string;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
interface RemoveUIMessage {
|
|
17
|
+
type: "remove-ui";
|
|
18
|
+
id: string;
|
|
19
|
+
}
|
|
20
|
+
declare function isUIMessage(message: unknown): message is UIMessage;
|
|
21
|
+
declare function isRemoveUIMessage(message: unknown): message is RemoveUIMessage;
|
|
22
|
+
declare function uiMessageReducer(state: UIMessage[], update: UIMessage | RemoveUIMessage | (UIMessage | RemoveUIMessage)[]): UIMessage<string, Record<string, unknown>>[];
|
|
23
|
+
//#endregion
|
|
24
|
+
export { RemoveUIMessage, UIMessage, isRemoveUIMessage, isUIMessage, uiMessageReducer };
|
|
25
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/react-ui/types.ts"],"mappings":";UAAiB,SAAA,+CAEA,MAAA,oBAA0B,MAAA;EAEzC,IAAA;EAEA,EAAA;EACA,IAAA,EAAM,KAAA;EACN,KAAA,EAAO,MAAA;EACP,QAAA;IACE,KAAA;IACA,MAAA;IACA,IAAA;IACA,IAAA;IACA,UAAA;IAAA,CACC,GAAA;EAAA;AAAA;AAAA,UAIY,eAAA;EACf,IAAA;EACA,EAAA;AAAA;AAAA,iBAGc,WAAA,CAAY,OAAA,YAAmB,OAAA,IAAW,SAAA;AAAA,iBAM1C,iBAAA,CACd,OAAA,YACC,OAAA,IAAW,eAAA;AAAA,iBAME,gBAAA,CACd,KAAA,EAAO,SAAA,IACP,MAAA,EAAQ,SAAA,GAAY,eAAA,IAAmB,SAAA,GAAY,eAAA,MAAkB,SAAA,SAAA,MAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region src/react-ui/types.ts
|
|
2
|
+
function isUIMessage(message) {
|
|
3
|
+
if (typeof message !== "object" || message == null) return false;
|
|
4
|
+
if (!("type" in message)) return false;
|
|
5
|
+
return message.type === "ui";
|
|
6
|
+
}
|
|
7
|
+
function isRemoveUIMessage(message) {
|
|
8
|
+
if (typeof message !== "object" || message == null) return false;
|
|
9
|
+
if (!("type" in message)) return false;
|
|
10
|
+
return message.type === "remove-ui";
|
|
11
|
+
}
|
|
12
|
+
function uiMessageReducer(state, update) {
|
|
13
|
+
const events = Array.isArray(update) ? update : [update];
|
|
14
|
+
let newState = state.slice();
|
|
15
|
+
for (const event of events) {
|
|
16
|
+
if (event.type === "remove-ui") {
|
|
17
|
+
newState = newState.filter((ui) => ui.id !== event.id);
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const index = state.findIndex((ui) => ui.id === event.id);
|
|
21
|
+
if (index !== -1) newState[index] = typeof event.metadata === "object" && event.metadata != null && event.metadata.merge ? {
|
|
22
|
+
...event,
|
|
23
|
+
props: {
|
|
24
|
+
...state[index].props,
|
|
25
|
+
...event.props
|
|
26
|
+
}
|
|
27
|
+
} : event;
|
|
28
|
+
else newState.push(event);
|
|
29
|
+
}
|
|
30
|
+
return newState;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { isRemoveUIMessage, isUIMessage, uiMessageReducer };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../src/react-ui/types.ts"],"sourcesContent":["export interface UIMessage<\n TName extends string = string,\n TProps extends Record<string, unknown> = Record<string, unknown>\n> {\n type: \"ui\";\n\n id: string;\n name: TName;\n props: TProps;\n metadata?: {\n merge?: boolean;\n run_id?: string;\n name?: string;\n tags?: string[];\n message_id?: string;\n [key: string]: unknown;\n };\n}\n\nexport interface RemoveUIMessage {\n type: \"remove-ui\";\n id: string;\n}\n\nexport function isUIMessage(message: unknown): message is UIMessage {\n if (typeof message !== \"object\" || message == null) return false;\n if (!(\"type\" in message)) return false;\n return message.type === \"ui\";\n}\n\nexport function isRemoveUIMessage(\n message: unknown\n): message is RemoveUIMessage {\n if (typeof message !== \"object\" || message == null) return false;\n if (!(\"type\" in message)) return false;\n return message.type === \"remove-ui\";\n}\n\nexport function uiMessageReducer(\n state: UIMessage[],\n update: UIMessage | RemoveUIMessage | (UIMessage | RemoveUIMessage)[]\n) {\n const events = Array.isArray(update) ? update : [update];\n let newState = state.slice();\n\n for (const event of events) {\n if (event.type === \"remove-ui\") {\n newState = newState.filter((ui) => ui.id !== event.id);\n continue;\n }\n\n const index = state.findIndex((ui) => ui.id === event.id);\n if (index !== -1) {\n newState[index] =\n typeof event.metadata === \"object\" &&\n event.metadata != null &&\n event.metadata.merge\n ? { ...event, props: { ...state[index].props, ...event.props } }\n : event;\n } else {\n newState.push(event);\n }\n }\n\n return newState;\n}\n"],"mappings":";AAwBA,SAAgB,YAAY,SAAwC;AAClE,KAAI,OAAO,YAAY,YAAY,WAAW,KAAM,QAAO;AAC3D,KAAI,EAAE,UAAU,SAAU,QAAO;AACjC,QAAO,QAAQ,SAAS;;AAG1B,SAAgB,kBACd,SAC4B;AAC5B,KAAI,OAAO,YAAY,YAAY,WAAW,KAAM,QAAO;AAC3D,KAAI,EAAE,UAAU,SAAU,QAAO;AACjC,QAAO,QAAQ,SAAS;;AAG1B,SAAgB,iBACd,OACA,QACA;CACA,MAAM,SAAS,MAAM,QAAQ,OAAO,GAAG,SAAS,CAAC,OAAO;CACxD,IAAI,WAAW,MAAM,OAAO;AAE5B,MAAK,MAAM,SAAS,QAAQ;AAC1B,MAAI,MAAM,SAAS,aAAa;AAC9B,cAAW,SAAS,QAAQ,OAAO,GAAG,OAAO,MAAM,GAAG;AACtD;;EAGF,MAAM,QAAQ,MAAM,WAAW,OAAO,GAAG,OAAO,MAAM,GAAG;AACzD,MAAI,UAAU,GACZ,UAAS,SACP,OAAO,MAAM,aAAa,YAC1B,MAAM,YAAY,QAClB,MAAM,SAAS,QACX;GAAE,GAAG;GAAO,OAAO;IAAE,GAAG,MAAM,OAAO;IAAO,GAAG,MAAM;IAAO;GAAE,GAC9D;MAEN,UAAS,KAAK,MAAM;;AAIxB,QAAO"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
//#region src/singletons/fetch.ts
|
|
3
2
|
const DEFAULT_FETCH_IMPLEMENTATION = (...args) => fetch(...args);
|
|
4
3
|
const LANGSMITH_FETCH_IMPLEMENTATION_KEY = Symbol.for("lg:fetch_implementation");
|
|
@@ -17,8 +16,8 @@ const overrideFetchImplementation = (fetch) => {
|
|
|
17
16
|
const _getFetchImplementation = () => {
|
|
18
17
|
return globalThis[LANGSMITH_FETCH_IMPLEMENTATION_KEY] ?? DEFAULT_FETCH_IMPLEMENTATION;
|
|
19
18
|
};
|
|
20
|
-
|
|
21
19
|
//#endregion
|
|
22
20
|
exports._getFetchImplementation = _getFetchImplementation;
|
|
23
21
|
exports.overrideFetchImplementation = overrideFetchImplementation;
|
|
22
|
+
|
|
24
23
|
//# sourceMappingURL=fetch.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.cjs","names":[],"sources":["../../src/singletons/fetch.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n// Wrap the default fetch call due to issues with illegal invocations\n// in some environments:\n// https://stackoverflow.com/questions/69876859/why-does-bind-fix-failed-to-execute-fetch-on-window-illegal-invocation-err\n// @ts-expect-error Broad typing to support a range of fetch implementations\nconst DEFAULT_FETCH_IMPLEMENTATION = (...args: any[]) => fetch(...args);\n\nconst LANGSMITH_FETCH_IMPLEMENTATION_KEY = Symbol.for(\n \"lg:fetch_implementation\"\n);\n\n/**\n * Overrides the fetch implementation used for LangSmith calls.\n * You should use this if you need to use an implementation of fetch\n * other than the default global (e.g. for dealing with proxies).\n * @param fetch The new fetch function to use.\n */\nexport const overrideFetchImplementation = (fetch: (...args: any[]) => any) => {\n (globalThis as any)[LANGSMITH_FETCH_IMPLEMENTATION_KEY] = fetch;\n};\n\n/**\n * @internal\n */\nexport const _getFetchImplementation: () => (...args: any[]) => any = () => {\n return (\n (globalThis as any)[LANGSMITH_FETCH_IMPLEMENTATION_KEY] ??\n DEFAULT_FETCH_IMPLEMENTATION\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetch.cjs","names":[],"sources":["../../src/singletons/fetch.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n// Wrap the default fetch call due to issues with illegal invocations\n// in some environments:\n// https://stackoverflow.com/questions/69876859/why-does-bind-fix-failed-to-execute-fetch-on-window-illegal-invocation-err\n// @ts-expect-error Broad typing to support a range of fetch implementations\nconst DEFAULT_FETCH_IMPLEMENTATION = (...args: any[]) => fetch(...args);\n\nconst LANGSMITH_FETCH_IMPLEMENTATION_KEY = Symbol.for(\n \"lg:fetch_implementation\"\n);\n\n/**\n * Overrides the fetch implementation used for LangSmith calls.\n * You should use this if you need to use an implementation of fetch\n * other than the default global (e.g. for dealing with proxies).\n * @param fetch The new fetch function to use.\n */\nexport const overrideFetchImplementation = (fetch: (...args: any[]) => any) => {\n (globalThis as any)[LANGSMITH_FETCH_IMPLEMENTATION_KEY] = fetch;\n};\n\n/**\n * @internal\n */\nexport const _getFetchImplementation: () => (...args: any[]) => any = () => {\n return (\n (globalThis as any)[LANGSMITH_FETCH_IMPLEMENTATION_KEY] ??\n DEFAULT_FETCH_IMPLEMENTATION\n );\n};\n"],"mappings":";AAKA,MAAM,gCAAgC,GAAG,SAAgB,MAAM,GAAG,KAAK;AAEvE,MAAM,qCAAqC,OAAO,IAChD,0BACD;;;;;;;AAQD,MAAa,+BAA+B,UAAmC;AAC5E,YAAmB,sCAAsC;;;;;AAM5D,MAAa,gCAA+D;AAC1E,QACG,WAAmB,uCACpB"}
|
package/dist/singletons/fetch.js
CHANGED
|
@@ -16,7 +16,7 @@ const overrideFetchImplementation = (fetch) => {
|
|
|
16
16
|
const _getFetchImplementation = () => {
|
|
17
17
|
return globalThis[LANGSMITH_FETCH_IMPLEMENTATION_KEY] ?? DEFAULT_FETCH_IMPLEMENTATION;
|
|
18
18
|
};
|
|
19
|
-
|
|
20
19
|
//#endregion
|
|
21
20
|
export { _getFetchImplementation, overrideFetchImplementation };
|
|
21
|
+
|
|
22
22
|
//# sourceMappingURL=fetch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","names":[],"sources":["../../src/singletons/fetch.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n// Wrap the default fetch call due to issues with illegal invocations\n// in some environments:\n// https://stackoverflow.com/questions/69876859/why-does-bind-fix-failed-to-execute-fetch-on-window-illegal-invocation-err\n// @ts-expect-error Broad typing to support a range of fetch implementations\nconst DEFAULT_FETCH_IMPLEMENTATION = (...args: any[]) => fetch(...args);\n\nconst LANGSMITH_FETCH_IMPLEMENTATION_KEY = Symbol.for(\n \"lg:fetch_implementation\"\n);\n\n/**\n * Overrides the fetch implementation used for LangSmith calls.\n * You should use this if you need to use an implementation of fetch\n * other than the default global (e.g. for dealing with proxies).\n * @param fetch The new fetch function to use.\n */\nexport const overrideFetchImplementation = (fetch: (...args: any[]) => any) => {\n (globalThis as any)[LANGSMITH_FETCH_IMPLEMENTATION_KEY] = fetch;\n};\n\n/**\n * @internal\n */\nexport const _getFetchImplementation: () => (...args: any[]) => any = () => {\n return (\n (globalThis as any)[LANGSMITH_FETCH_IMPLEMENTATION_KEY] ??\n DEFAULT_FETCH_IMPLEMENTATION\n );\n};\n"],"mappings":";AAKA,MAAM,gCAAgC,GAAG,SAAgB,MAAM,GAAG,KAAK;AAEvE,MAAM,qCAAqC,OAAO,IAChD,0BACD;;;;;;;AAQD,MAAa,+BAA+B,UAAmC;
|
|
1
|
+
{"version":3,"file":"fetch.js","names":[],"sources":["../../src/singletons/fetch.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n// Wrap the default fetch call due to issues with illegal invocations\n// in some environments:\n// https://stackoverflow.com/questions/69876859/why-does-bind-fix-failed-to-execute-fetch-on-window-illegal-invocation-err\n// @ts-expect-error Broad typing to support a range of fetch implementations\nconst DEFAULT_FETCH_IMPLEMENTATION = (...args: any[]) => fetch(...args);\n\nconst LANGSMITH_FETCH_IMPLEMENTATION_KEY = Symbol.for(\n \"lg:fetch_implementation\"\n);\n\n/**\n * Overrides the fetch implementation used for LangSmith calls.\n * You should use this if you need to use an implementation of fetch\n * other than the default global (e.g. for dealing with proxies).\n * @param fetch The new fetch function to use.\n */\nexport const overrideFetchImplementation = (fetch: (...args: any[]) => any) => {\n (globalThis as any)[LANGSMITH_FETCH_IMPLEMENTATION_KEY] = fetch;\n};\n\n/**\n * @internal\n */\nexport const _getFetchImplementation: () => (...args: any[]) => any = () => {\n return (\n (globalThis as any)[LANGSMITH_FETCH_IMPLEMENTATION_KEY] ??\n DEFAULT_FETCH_IMPLEMENTATION\n );\n};\n"],"mappings":";AAKA,MAAM,gCAAgC,GAAG,SAAgB,MAAM,GAAG,KAAK;AAEvE,MAAM,qCAAqC,OAAO,IAChD,0BACD;;;;;;;AAQD,MAAa,+BAA+B,UAAmC;AAC5E,YAAmB,sCAAsC;;;;;AAM5D,MAAa,gCAA+D;AAC1E,QACG,WAAmB,uCACpB"}
|
package/dist/ui/branching.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
const require_utils = require(
|
|
2
|
-
|
|
1
|
+
const require_utils = require("./utils.cjs");
|
|
3
2
|
//#region src/ui/branching.ts
|
|
4
3
|
function getBranchSequence(history) {
|
|
5
4
|
const nodeIds = /* @__PURE__ */ new Set();
|
|
@@ -170,8 +169,8 @@ function getMessagesMetadataMap(options) {
|
|
|
170
169
|
};
|
|
171
170
|
});
|
|
172
171
|
}
|
|
173
|
-
|
|
174
172
|
//#endregion
|
|
175
173
|
exports.getBranchContext = getBranchContext;
|
|
176
174
|
exports.getMessagesMetadataMap = getMessagesMetadataMap;
|
|
175
|
+
|
|
177
176
|
//# sourceMappingURL=branching.cjs.map
|