@copilotkit/react-core 1.79.2-canary.1792172552 → 1.81.0
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/MarkdownSurfaces-D-OkjUpU.cjs +3807 -0
- package/dist/MarkdownSurfaces-D-OkjUpU.cjs.map +1 -0
- package/dist/MarkdownSurfaces-L67964_B.mjs +3522 -0
- package/dist/MarkdownSurfaces-L67964_B.mjs.map +1 -0
- package/dist/{copilotkit-kcYN96tM.d.mts → copilotkit-BEcaM4L4.d.mts} +300 -72
- package/dist/copilotkit-BEcaM4L4.d.mts.map +1 -0
- package/dist/{copilotkit-ConxFSB2.cjs → copilotkit-BjllYYjw.cjs} +3781 -801
- package/dist/copilotkit-BjllYYjw.cjs.map +1 -0
- package/dist/{copilotkit-BA0vyDds.d.cts → copilotkit-D9jIImy9.d.cts} +300 -72
- package/dist/copilotkit-D9jIImy9.d.cts.map +1 -0
- package/dist/{copilotkit-DcENKLnJ.mjs → copilotkit-fKrKqoiP.mjs} +3684 -666
- package/dist/copilotkit-fKrKqoiP.mjs.map +1 -0
- package/dist/index.cjs +22 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +16 -3
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +4667 -176
- package/dist/index.umd.js.map +1 -1
- package/dist/runtime-context-CrHq-iTf.d.mts +924 -0
- package/dist/runtime-context-CrHq-iTf.d.mts.map +1 -0
- package/dist/runtime-context-D3NcP9oE.d.cts +924 -0
- package/dist/runtime-context-D3NcP9oE.d.cts.map +1 -0
- package/dist/v2/context.d.cts +7 -0
- package/dist/v2/context.d.cts.map +1 -1
- package/dist/v2/context.d.mts +7 -0
- package/dist/v2/context.d.mts.map +1 -1
- package/dist/v2/generative-ui.cjs +8154 -0
- package/dist/v2/generative-ui.cjs.map +1 -0
- package/dist/v2/generative-ui.d.cts +4950 -0
- package/dist/v2/generative-ui.d.cts.map +1 -0
- package/dist/v2/generative-ui.d.mts +4950 -0
- package/dist/v2/generative-ui.d.mts.map +1 -0
- package/dist/v2/generative-ui.mjs +8140 -0
- package/dist/v2/generative-ui.mjs.map +1 -0
- package/dist/v2/headless.cjs +23 -6
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.d.cts +20 -2
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/headless.d.mts +20 -2
- package/dist/v2/headless.d.mts.map +1 -1
- package/dist/v2/headless.mjs +23 -6
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +67 -10
- package/dist/v2/index.css +1 -1
- package/dist/v2/index.d.cts +3 -2
- package/dist/v2/index.d.mts +3 -2
- package/dist/v2/index.mjs +3 -2
- package/dist/v2/index.umd.js +6510 -317
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +27 -11
- package/dist/copilotkit-BA0vyDds.d.cts.map +0 -1
- package/dist/copilotkit-ConxFSB2.cjs.map +0 -1
- package/dist/copilotkit-DcENKLnJ.mjs.map +0 -1
- package/dist/copilotkit-kcYN96tM.d.mts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const
|
|
4
|
+
const require_MarkdownSurfaces = require('./MarkdownSurfaces-D-OkjUpU.cjs');
|
|
5
|
+
const require_copilotkit = require('./copilotkit-BjllYYjw.cjs');
|
|
5
6
|
let react = require("react");
|
|
6
|
-
react =
|
|
7
|
+
react = require_MarkdownSurfaces.__toESM(react);
|
|
7
8
|
let _copilotkit_core = require("@copilotkit/core");
|
|
8
9
|
let _ag_ui_client = require("@ag-ui/client");
|
|
9
10
|
let _copilotkit_shared = require("@copilotkit/shared");
|
|
@@ -46,7 +47,7 @@ function useLazyToolRenderer() {
|
|
|
46
47
|
function useCopilotChatInternal({ suggestions, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages } = {}) {
|
|
47
48
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
48
49
|
const { threadId, agentSession } = require_copilotkit.useCopilotContext();
|
|
49
|
-
const existingConfig =
|
|
50
|
+
const existingConfig = require_MarkdownSurfaces.useCopilotChatConfiguration();
|
|
50
51
|
const [agentAvailable, setAgentAvailable] = (0, react.useState)(false);
|
|
51
52
|
const resolvedAgentId = existingConfig?.agentId ?? "default";
|
|
52
53
|
const { agent } = require_copilotkit.useAgent({ agentId: resolvedAgentId });
|
|
@@ -667,7 +668,7 @@ function useRenderToolCall(tool, dependencies) {
|
|
|
667
668
|
(0, react.useEffect)(() => {
|
|
668
669
|
const { name, parameters, render } = tool;
|
|
669
670
|
const zodParameters = (0, _copilotkit_shared.getZodParameters)(parameters);
|
|
670
|
-
const renderToolCall = name === "*" ?
|
|
671
|
+
const renderToolCall = name === "*" ? require_MarkdownSurfaces.defineToolCallRenderer({
|
|
671
672
|
name: "*",
|
|
672
673
|
render: ((args) => {
|
|
673
674
|
return render({
|
|
@@ -675,7 +676,7 @@ function useRenderToolCall(tool, dependencies) {
|
|
|
675
676
|
result: args.result ? (0, _copilotkit_shared.parseJson)(args.result, args.result) : args.result
|
|
676
677
|
});
|
|
677
678
|
})
|
|
678
|
-
}) :
|
|
679
|
+
}) : require_MarkdownSurfaces.defineToolCallRenderer({
|
|
679
680
|
name,
|
|
680
681
|
args: zodParameters,
|
|
681
682
|
render: ((args) => {
|
|
@@ -909,6 +910,14 @@ function useHumanInTheLoop(tool, dependencies) {
|
|
|
909
910
|
*
|
|
910
911
|
* This hooks enables you to dynamically generate UI elements and render them in the copilot chat. For more information, check out the [Generative UI](/guides/generative-ui) page.
|
|
911
912
|
*/
|
|
913
|
+
function toRenderToolCallArgs(action) {
|
|
914
|
+
const { render } = action;
|
|
915
|
+
if (typeof render === "string") return {
|
|
916
|
+
...action,
|
|
917
|
+
render: () => react.default.createElement(react.default.Fragment, null, render)
|
|
918
|
+
};
|
|
919
|
+
return action;
|
|
920
|
+
}
|
|
912
921
|
function getActionConfig(action) {
|
|
913
922
|
if (action.name === "*") {
|
|
914
923
|
const catchAll = action;
|
|
@@ -944,14 +953,18 @@ function getActionConfig(action) {
|
|
|
944
953
|
};
|
|
945
954
|
if (action.available === "frontend" || action.available === "disabled") return {
|
|
946
955
|
type: "render",
|
|
947
|
-
action
|
|
956
|
+
action: toRenderToolCallArgs(action)
|
|
948
957
|
};
|
|
949
958
|
}
|
|
950
959
|
if ("handler" in action) return {
|
|
951
960
|
type: "frontend",
|
|
952
961
|
action
|
|
953
962
|
};
|
|
954
|
-
|
|
963
|
+
if ("render" in action && action.render) return {
|
|
964
|
+
type: "render",
|
|
965
|
+
action: toRenderToolCallArgs(action)
|
|
966
|
+
};
|
|
967
|
+
throw new Error(`useCopilotAction(${JSON.stringify(action.name)}): this action has no handler and no render function. Add a handler to run the action in the browser, or a render function to render a tool call that the agent runs.`);
|
|
955
968
|
}
|
|
956
969
|
/**
|
|
957
970
|
* useCopilotAction is a legacy hook maintained for backwards compatibility.
|
|
@@ -1717,7 +1730,7 @@ function toV1Event(event) {
|
|
|
1717
1730
|
function useLangGraphInterrupt(action, _dependencies) {
|
|
1718
1731
|
const actionRef = (0, react.useRef)(action);
|
|
1719
1732
|
actionRef.current = action;
|
|
1720
|
-
const existingConfig =
|
|
1733
|
+
const existingConfig = require_MarkdownSurfaces.useCopilotChatConfiguration();
|
|
1721
1734
|
const resolvedAgentId = action.agentId ?? existingConfig?.agentId ?? "default";
|
|
1722
1735
|
const threadId = existingConfig?.threadId;
|
|
1723
1736
|
const nodeName = useAgentNodeName(resolvedAgentId);
|
|
@@ -1891,7 +1904,7 @@ function useDefaultTool(tool, dependencies) {
|
|
|
1891
1904
|
* removes it on unmount, ensuring a clean and efficient lifecycle management.
|
|
1892
1905
|
*/
|
|
1893
1906
|
function useCopilotChatSuggestions(config, dependencies = []) {
|
|
1894
|
-
const resolvedAgentId =
|
|
1907
|
+
const resolvedAgentId = require_MarkdownSurfaces.useCopilotChatConfiguration()?.agentId ?? "default";
|
|
1895
1908
|
const available = (config.available === "enabled" ? "always" : config.available) ?? "before-first-message";
|
|
1896
1909
|
require_copilotkit.useConfigureSuggestions({
|
|
1897
1910
|
...config,
|