@copilotkit/react-core 1.84.2-canary.openbot-intel-fixes → 1.86.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-BCVdnDAk.cjs +161 -0
- package/dist/MarkdownSurfaces-BCVdnDAk.cjs.map +1 -0
- package/dist/MarkdownSurfaces-CjJduaJR.mjs +149 -0
- package/dist/MarkdownSurfaces-CjJduaJR.mjs.map +1 -0
- package/dist/{MarkdownSurfaces-3cGU5_0H.cjs → chat-BnsrQ0VS.cjs} +667 -320
- package/dist/chat-BnsrQ0VS.cjs.map +1 -0
- package/dist/{MarkdownSurfaces-D-W4f9Dy.mjs → chat-IWySXWXP.mjs} +647 -312
- package/dist/chat-IWySXWXP.mjs.map +1 -0
- package/dist/{copilotkit-UHD9sXsS.mjs → copilotkit-B1OLgEU8.mjs} +6 -354
- package/dist/copilotkit-B1OLgEU8.mjs.map +1 -0
- package/dist/{copilotkit-Dn4PbHJV.d.mts → copilotkit-C7G95NO-.d.mts} +4 -4
- package/dist/{copilotkit-Dn4PbHJV.d.mts.map → copilotkit-C7G95NO-.d.mts.map} +1 -1
- package/dist/{copilotkit-DYtl9zj0.cjs → copilotkit-Ca0IcTZU.cjs} +79 -427
- package/dist/copilotkit-Ca0IcTZU.cjs.map +1 -0
- package/dist/{copilotkit-CuTAoQF2.d.cts → copilotkit-DwD7D6jJ.d.cts} +2 -2
- package/dist/{copilotkit-CuTAoQF2.d.cts.map → copilotkit-DwD7D6jJ.d.cts.map} +1 -1
- package/dist/hooks-DMSkcNOl.d.cts +89 -0
- package/dist/hooks-DMSkcNOl.d.cts.map +1 -0
- package/dist/hooks-EwGvqYsW.d.mts +89 -0
- package/dist/hooks-EwGvqYsW.d.mts.map +1 -0
- package/dist/index.cjs +8 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/index.umd.js +645 -140
- package/dist/index.umd.js.map +1 -1
- package/dist/refs-DL7ITFFD.cjs +43 -0
- package/dist/refs-DL7ITFFD.cjs.map +1 -0
- package/dist/refs-DiZXJ63p.mjs +31 -0
- package/dist/refs-DiZXJ63p.mjs.map +1 -0
- package/dist/{runtime-context-Er5UIbZA.d.mts → runtime-context-B4fKyzo6.d.mts} +31 -9
- package/dist/runtime-context-B4fKyzo6.d.mts.map +1 -0
- package/dist/{runtime-context-DrVNUYLi.d.cts → runtime-context-Da7T5vy4.d.cts} +31 -9
- package/dist/runtime-context-Da7T5vy4.d.cts.map +1 -0
- package/dist/use-generative-ui-root-CaTyBFNR.cjs +390 -0
- package/dist/use-generative-ui-root-CaTyBFNR.cjs.map +1 -0
- package/dist/use-generative-ui-root-WI9ERMpo.mjs +385 -0
- package/dist/use-generative-ui-root-WI9ERMpo.mjs.map +1 -0
- package/dist/v2/generative-ui/native.cjs +66 -0
- package/dist/v2/generative-ui/native.cjs.map +1 -0
- package/dist/v2/generative-ui/native.d.cts +155 -0
- package/dist/v2/generative-ui/native.d.cts.map +1 -0
- package/dist/v2/generative-ui/native.d.mts +155 -0
- package/dist/v2/generative-ui/native.d.mts.map +1 -0
- package/dist/v2/generative-ui/native.mjs +24 -0
- package/dist/v2/generative-ui/native.mjs.map +1 -0
- package/dist/v2/generative-ui.cjs +45 -70
- package/dist/v2/generative-ui.cjs.map +1 -1
- package/dist/v2/generative-ui.d.cts +229 -308
- package/dist/v2/generative-ui.d.cts.map +1 -1
- package/dist/v2/generative-ui.d.mts +229 -308
- package/dist/v2/generative-ui.d.mts.map +1 -1
- package/dist/v2/generative-ui.mjs +4 -29
- package/dist/v2/generative-ui.mjs.map +1 -1
- package/dist/v2/headless.d.cts +185 -294
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/index.cjs +5 -5
- package/dist/v2/index.d.cts +2 -2
- package/dist/v2/index.d.mts +2 -2
- package/dist/v2/index.mjs +2 -2
- package/dist/v2/index.umd.js +645 -140
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +15 -11
- package/dist/MarkdownSurfaces-3cGU5_0H.cjs.map +0 -1
- package/dist/MarkdownSurfaces-D-W4f9Dy.mjs.map +0 -1
- package/dist/copilotkit-DYtl9zj0.cjs.map +0 -1
- package/dist/copilotkit-UHD9sXsS.mjs.map +0 -1
- package/dist/runtime-context-DrVNUYLi.d.cts.map +0 -1
- package/dist/runtime-context-Er5UIbZA.d.mts.map +0 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_chat = require('./chat-BnsrQ0VS.cjs');
|
|
2
|
+
const require_MarkdownSurfaces = require('./MarkdownSurfaces-BCVdnDAk.cjs');
|
|
3
|
+
const require_use_generative_ui_root = require('./use-generative-ui-root-CaTyBFNR.cjs');
|
|
2
4
|
let react = require("react");
|
|
3
|
-
react =
|
|
5
|
+
react = require_chat.__toESM(react);
|
|
4
6
|
let _copilotkit_core = require("@copilotkit/core");
|
|
5
7
|
let _ag_ui_client = require("@ag-ui/client");
|
|
6
8
|
let tailwind_merge = require("tailwind-merge");
|
|
@@ -12,25 +14,23 @@ let _radix_ui_react_slot = require("@radix-ui/react-slot");
|
|
|
12
14
|
let class_variance_authority = require("class-variance-authority");
|
|
13
15
|
let clsx = require("clsx");
|
|
14
16
|
let _radix_ui_react_tooltip = require("@radix-ui/react-tooltip");
|
|
15
|
-
_radix_ui_react_tooltip =
|
|
17
|
+
_radix_ui_react_tooltip = require_chat.__toESM(_radix_ui_react_tooltip);
|
|
16
18
|
let _radix_ui_react_dropdown_menu = require("@radix-ui/react-dropdown-menu");
|
|
17
|
-
_radix_ui_react_dropdown_menu =
|
|
19
|
+
_radix_ui_react_dropdown_menu = require_chat.__toESM(_radix_ui_react_dropdown_menu);
|
|
18
20
|
let streamdown = require("streamdown");
|
|
19
21
|
let _ag_ui_core = require("@ag-ui/core");
|
|
20
22
|
let zod = require("zod");
|
|
21
23
|
let _copilotkit_mcp_apps_renderer_activity = require("@copilotkit/mcp-apps-renderer/activity");
|
|
22
24
|
let _copilotkit_a2ui_renderer = require("@copilotkit/a2ui-renderer");
|
|
23
|
-
let _copilotkit_core_generative_ui = require("@copilotkit/core/generative-ui");
|
|
24
|
-
let _copilotkit_shared_generative_ui = require("@copilotkit/shared/generative-ui");
|
|
25
25
|
let zod_to_json_schema = require("zod-to-json-schema");
|
|
26
26
|
let _radix_ui_react_popover = require("@radix-ui/react-popover");
|
|
27
|
-
_radix_ui_react_popover =
|
|
27
|
+
_radix_ui_react_popover = require_chat.__toESM(_radix_ui_react_popover);
|
|
28
28
|
let react_dom = require("react-dom");
|
|
29
29
|
let _tanstack_react_virtual = require("@tanstack/react-virtual");
|
|
30
30
|
let use_stick_to_bottom = require("use-stick-to-bottom");
|
|
31
31
|
let _copilotkit_web_components_threads_drawer = require("@copilotkit/web-components/threads-drawer");
|
|
32
32
|
let react_markdown = require("react-markdown");
|
|
33
|
-
react_markdown =
|
|
33
|
+
react_markdown = require_chat.__toESM(react_markdown);
|
|
34
34
|
|
|
35
35
|
//#region src/v2/lib/utils.ts
|
|
36
36
|
const twMerge$12 = (0, tailwind_merge.extendTailwindMerge)({ prefix: "cpk" });
|
|
@@ -461,7 +461,7 @@ const MemoizedSlotWrapper = react.default.memo(react.default.forwardRef(function
|
|
|
461
461
|
if (prev.$component !== next.$component) return false;
|
|
462
462
|
const { $slot: _ps, $component: _pc, ...prevRest } = prev;
|
|
463
463
|
const { $slot: _ns, $component: _nc, ...nextRest } = next;
|
|
464
|
-
return
|
|
464
|
+
return require_chat.shallowEqual(prevRest, nextRest);
|
|
465
465
|
});
|
|
466
466
|
/**
|
|
467
467
|
* Renders a slot value as a memoized React element.
|
|
@@ -507,8 +507,8 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
|
|
|
507
507
|
const actionsContainerRef = (0, react.useRef)(null);
|
|
508
508
|
const audioRecorderRef = (0, react.useRef)(null);
|
|
509
509
|
const slashMenuRef = (0, react.useRef)(null);
|
|
510
|
-
const config =
|
|
511
|
-
const labels = config?.labels ??
|
|
510
|
+
const config = require_chat.useCopilotChatConfiguration();
|
|
511
|
+
const labels = config?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
512
512
|
const previousModalStateRef = (0, react.useRef)(void 0);
|
|
513
513
|
const measurementCanvasRef = (0, react.useRef)(null);
|
|
514
514
|
const measurementsRef = (0, react.useRef)({
|
|
@@ -1029,7 +1029,7 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
|
|
|
1029
1029
|
}
|
|
1030
1030
|
(function(_CopilotChatInput) {
|
|
1031
1031
|
_CopilotChatInput.SendButton = ({ className, children, ...props }) => {
|
|
1032
|
-
const labels =
|
|
1032
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
1033
1033
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1034
1034
|
className: "cpk:mr-[10px]",
|
|
1035
1035
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
@@ -1045,7 +1045,7 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
|
|
|
1045
1045
|
});
|
|
1046
1046
|
};
|
|
1047
1047
|
const ToolbarButton = _CopilotChatInput.ToolbarButton = ({ icon, labelKey, defaultClassName, className, ...props }) => {
|
|
1048
|
-
const labels =
|
|
1048
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
1049
1049
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Tooltip, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipTrigger, {
|
|
1050
1050
|
asChild: true,
|
|
1051
1051
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
@@ -1084,7 +1084,7 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
|
|
|
1084
1084
|
...props
|
|
1085
1085
|
});
|
|
1086
1086
|
_CopilotChatInput.AddMenuButton = ({ className, toolsMenu, onAddFile, disabled, ...props }) => {
|
|
1087
|
-
const labels =
|
|
1087
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
1088
1088
|
const [mounted, setMounted] = (0, react.useState)(false);
|
|
1089
1089
|
(0, react.useEffect)(() => setMounted(true), []);
|
|
1090
1090
|
const menuItems = (0, react.useMemo)(() => {
|
|
@@ -1152,7 +1152,7 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
|
|
|
1152
1152
|
};
|
|
1153
1153
|
_CopilotChatInput.TextArea = (0, react.forwardRef)(function TextArea({ style, className, autoFocus, placeholder, ...props }, ref) {
|
|
1154
1154
|
const internalTextareaRef = (0, react.useRef)(null);
|
|
1155
|
-
const labels =
|
|
1155
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
1156
1156
|
(0, react.useImperativeHandle)(ref, () => internalTextareaRef.current);
|
|
1157
1157
|
(0, react.useEffect)(() => {
|
|
1158
1158
|
if (autoFocus) internalTextareaRef.current?.focus({ preventScroll: true });
|
|
@@ -1173,7 +1173,7 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
|
|
|
1173
1173
|
});
|
|
1174
1174
|
_CopilotChatInput.AudioRecorder = CopilotChatAudioRecorder;
|
|
1175
1175
|
_CopilotChatInput.Disclaimer = ({ className, ...props }) => {
|
|
1176
|
-
const labels =
|
|
1176
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
1177
1177
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1178
1178
|
className: cn("cpk:text-center cpk:text-xs cpk:text-muted-foreground cpk:py-3 cpk:px-4 cpk:max-w-3xl cpk:mx-auto", className),
|
|
1179
1179
|
...props,
|
|
@@ -1288,7 +1288,7 @@ function useToolCallRendererNames() {
|
|
|
1288
1288
|
*/
|
|
1289
1289
|
function useRenderToolCall() {
|
|
1290
1290
|
const { copilotkit, executingToolCallIds } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
1291
|
-
const agentId =
|
|
1291
|
+
const agentId = require_chat.useCopilotChatConfiguration()?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
1292
1292
|
const unrenderedToolNames = (0, react.useRef)(/* @__PURE__ */ new Set());
|
|
1293
1293
|
const warnedToolNames = (0, react.useRef)(/* @__PURE__ */ new Set());
|
|
1294
1294
|
const renderToolCalls = useToolCallRenderers();
|
|
@@ -1326,7 +1326,7 @@ function useRenderToolCall() {
|
|
|
1326
1326
|
|
|
1327
1327
|
//#endregion
|
|
1328
1328
|
//#region package.json
|
|
1329
|
-
var version = "1.
|
|
1329
|
+
var version = "1.86.0";
|
|
1330
1330
|
|
|
1331
1331
|
//#endregion
|
|
1332
1332
|
//#region src/v2/components/CopilotKitInspector.tsx
|
|
@@ -2910,7 +2910,7 @@ const RENDER_A2UI_TOOL_NAME = "render_a2ui";
|
|
|
2910
2910
|
function A2UIBuiltInToolCallRenderer() {
|
|
2911
2911
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
2912
2912
|
(0, react.useEffect)(() => {
|
|
2913
|
-
const renderer =
|
|
2913
|
+
const renderer = require_chat.defineToolCallRenderer({
|
|
2914
2914
|
name: RENDER_A2UI_TOOL_NAME,
|
|
2915
2915
|
args: zod.z.any(),
|
|
2916
2916
|
render: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, {})
|
|
@@ -2979,354 +2979,6 @@ function A2UICatalogContext({ catalog, includeSchema }) {
|
|
|
2979
2979
|
return null;
|
|
2980
2980
|
}
|
|
2981
2981
|
|
|
2982
|
-
//#endregion
|
|
2983
|
-
//#region src/v2/generative-ui/markdown/context.ts
|
|
2984
|
-
/**
|
|
2985
|
-
* Registers the two context entries of the markdown transport: the compact
|
|
2986
|
-
* component schema and the fence guideline. Both go only to `agentIds`.
|
|
2987
|
-
*
|
|
2988
|
-
* The schema is built again at each run start and when a
|
|
2989
|
-
* `<GenerativeUISurface>` mounts, unmounts, or changes its description or
|
|
2990
|
-
* its components, so its targets, functions, and surfaces stay current. The surfaces are those of the running thread.
|
|
2991
|
-
*
|
|
2992
|
-
* @param copilotkit - The CopilotKit core of the provider.
|
|
2993
|
-
* @param runtime - The generative UI runtime parts, or null without one.
|
|
2994
|
-
* @param options - `enabled` and `agentIds`.
|
|
2995
|
-
*
|
|
2996
|
-
* @example
|
|
2997
|
-
* ```ts
|
|
2998
|
-
* useGenerativeUIMarkdownContext(copilotkit, core, {
|
|
2999
|
-
* enabled: config?.transport === "markdown" && config.sendContext !== false,
|
|
3000
|
-
* agentIds: config?.agentIds,
|
|
3001
|
-
* });
|
|
3002
|
-
* ```
|
|
3003
|
-
*/
|
|
3004
|
-
function useGenerativeUIMarkdownContext(copilotkit, runtime, options) {
|
|
3005
|
-
const { enabled, agentIds } = options;
|
|
3006
|
-
const agentIdsKey = agentIds === void 0 ? "" : JSON.stringify(agentIds);
|
|
3007
|
-
(0, react.useEffect)(() => {
|
|
3008
|
-
if (!runtime || !enabled) return;
|
|
3009
|
-
const scopedAgentIds = agentIdsKey ? JSON.parse(agentIdsKey) : void 0;
|
|
3010
|
-
const scope = scopedAgentIds ? { agentIds: scopedAgentIds } : {};
|
|
3011
|
-
let guidelineId;
|
|
3012
|
-
let guidelineValue;
|
|
3013
|
-
let schemaId;
|
|
3014
|
-
let schemaValue;
|
|
3015
|
-
const refreshSchema = (threadId) => {
|
|
3016
|
-
const manifest = (0, _copilotkit_core_generative_ui.buildGenerativeUIManifest)(runtime, threadId);
|
|
3017
|
-
const guideline = (0, _copilotkit_shared.buildGenerativeUIMarkdownGuidelines)((0, _copilotkit_shared.generativeUIGuideFeatures)(manifest));
|
|
3018
|
-
if (guideline !== guidelineValue) {
|
|
3019
|
-
if (guidelineId !== void 0) copilotkit.removeContext(guidelineId);
|
|
3020
|
-
guidelineValue = guideline;
|
|
3021
|
-
guidelineId = copilotkit.addContext({
|
|
3022
|
-
description: _copilotkit_shared.GENERATIVE_UI_MARKDOWN_GUIDELINES_DESCRIPTION,
|
|
3023
|
-
value: guideline,
|
|
3024
|
-
...scope
|
|
3025
|
-
});
|
|
3026
|
-
}
|
|
3027
|
-
const value = (0, _copilotkit_shared.renderGenerativeUISchema)(manifest, (0, _copilotkit_shared.defaultGenerativeUIPromptSpec)().schema.markdown);
|
|
3028
|
-
if (value === schemaValue) return;
|
|
3029
|
-
if (schemaId !== void 0) copilotkit.removeContext(schemaId);
|
|
3030
|
-
schemaValue = value;
|
|
3031
|
-
schemaId = copilotkit.addContext({
|
|
3032
|
-
description: _copilotkit_shared.GENERATIVE_UI_MARKDOWN_SCHEMA_CONTEXT_DESCRIPTION,
|
|
3033
|
-
value,
|
|
3034
|
-
...scope
|
|
3035
|
-
});
|
|
3036
|
-
};
|
|
3037
|
-
refreshSchema(runtime.manager.getActiveThread());
|
|
3038
|
-
let targetsKey = JSON.stringify(runtime.manager.getMountedTargets());
|
|
3039
|
-
const unsubscribeManager = runtime.manager.subscribe(() => {
|
|
3040
|
-
const nextKey = JSON.stringify(runtime.manager.getMountedTargets());
|
|
3041
|
-
if (nextKey === targetsKey) return;
|
|
3042
|
-
targetsKey = nextKey;
|
|
3043
|
-
refreshSchema(runtime.manager.getActiveThread());
|
|
3044
|
-
});
|
|
3045
|
-
const subscription = copilotkit.subscribe({ onAgentRunStarted: ({ agent }) => refreshSchema(agent.threadId) });
|
|
3046
|
-
return () => {
|
|
3047
|
-
subscription.unsubscribe();
|
|
3048
|
-
unsubscribeManager();
|
|
3049
|
-
if (guidelineId !== void 0) copilotkit.removeContext(guidelineId);
|
|
3050
|
-
if (schemaId !== void 0) copilotkit.removeContext(schemaId);
|
|
3051
|
-
};
|
|
3052
|
-
}, [
|
|
3053
|
-
copilotkit,
|
|
3054
|
-
runtime,
|
|
3055
|
-
enabled,
|
|
3056
|
-
agentIdsKey
|
|
3057
|
-
]);
|
|
3058
|
-
}
|
|
3059
|
-
|
|
3060
|
-
//#endregion
|
|
3061
|
-
//#region src/v2/generative-ui/use-generative-ui-root.ts
|
|
3062
|
-
const isDevelopment = () => process.env.NODE_ENV !== "production";
|
|
3063
|
-
function ingestMessages(manager, agent, messages) {
|
|
3064
|
-
if (!agent.threadId) return;
|
|
3065
|
-
for (const message of messages) if (message.role === "activity" && message.activityType === _copilotkit_shared.GENERATIVE_UI_ACTIVITY_TYPE) manager.ingest(agent.threadId, agent.agentId, message.content);
|
|
3066
|
-
}
|
|
3067
|
-
/** Provider-side wiring: manager, dispatcher, agent subscriptions, envelope. */
|
|
3068
|
-
function useGenerativeUIRoot(copilotkit, config) {
|
|
3069
|
-
const configRef = (0, react.useRef)(config);
|
|
3070
|
-
configRef.current = config;
|
|
3071
|
-
const ui = config?.ui;
|
|
3072
|
-
const transport = config?.transport ?? "tool";
|
|
3073
|
-
const theme = require_MarkdownSurfaces.useShallowStableRef(config?.theme);
|
|
3074
|
-
const core = (0, react.useMemo)(() => {
|
|
3075
|
-
if (!ui) return null;
|
|
3076
|
-
const reportError = (info) => {
|
|
3077
|
-
try {
|
|
3078
|
-
configRef.current?.errorBoundary?.onError?.(info);
|
|
3079
|
-
} catch (hostError) {
|
|
3080
|
-
if (isDevelopment()) console.error("[generativeUI] errorBoundary.onError threw:", hostError);
|
|
3081
|
-
}
|
|
3082
|
-
if (isDevelopment()) console.warn(`[generativeUI] ${info.kind} error in ${info.surfaceId}${info.componentId ? `/${info.componentId}` : ""}: ${info.error?.message}`);
|
|
3083
|
-
};
|
|
3084
|
-
const manager = new _copilotkit_core_generative_ui.GenerativeUISurfaceManager(ui, { onOperationRejected: ({ surfaceId, index, reason }) => reportError({
|
|
3085
|
-
kind: "operation",
|
|
3086
|
-
surfaceId,
|
|
3087
|
-
error: /* @__PURE__ */ new Error(`operation ${index} rejected: ${reason}`)
|
|
3088
|
-
}) });
|
|
3089
|
-
const dispatcher = (0, _copilotkit_core_generative_ui.createGenerativeUIDispatcher)({
|
|
3090
|
-
getDeclared: () => ui.functions,
|
|
3091
|
-
onError: ({ name, origin, error }) => {
|
|
3092
|
-
if ("functionCallId" in origin) {
|
|
3093
|
-
if (isDevelopment()) console.warn(`[generativeUI] function call ${origin.functionCallId} to "${name}" failed: ${error.message}`);
|
|
3094
|
-
return;
|
|
3095
|
-
}
|
|
3096
|
-
reportError({
|
|
3097
|
-
kind: "function",
|
|
3098
|
-
...origin,
|
|
3099
|
-
error
|
|
3100
|
-
});
|
|
3101
|
-
}
|
|
3102
|
-
});
|
|
3103
|
-
const functionCalls = (0, _copilotkit_core_generative_ui.createFunctionCallRunner)({
|
|
3104
|
-
core: copilotkit,
|
|
3105
|
-
dispatcher,
|
|
3106
|
-
manifest: {
|
|
3107
|
-
catalogId: ui.id,
|
|
3108
|
-
catalogIds: (0, _copilotkit_shared_generative_ui.catalogIdsOf)(ui),
|
|
3109
|
-
components: ui.manifestComponents
|
|
3110
|
-
},
|
|
3111
|
-
settle: () => copilotkit.waitForPendingFrameworkUpdates(),
|
|
3112
|
-
warn: (message, error) => {
|
|
3113
|
-
if (isDevelopment()) console.warn(message, error);
|
|
3114
|
-
}
|
|
3115
|
-
});
|
|
3116
|
-
const forwardingAgents = /* @__PURE__ */ new Set();
|
|
3117
|
-
/**
|
|
3118
|
-
* The action of a user event, as an envelope entry scoped to the agent
|
|
3119
|
-
* the user acted on, for the run that the event starts: the structured
|
|
3120
|
-
* form of the user message. It is set before the run starts and dropped
|
|
3121
|
-
* when the run is over, so a suggestion request or a follow-up run
|
|
3122
|
-
* (both read the properties with no run start) does not carry the same
|
|
3123
|
-
* action again, and another agent never gets a click meant for this one.
|
|
3124
|
-
* The entry comes after the shared envelope, so it wins for its agent;
|
|
3125
|
-
* `refreshActions` keeps it last when the shared envelope is set again.
|
|
3126
|
-
*/
|
|
3127
|
-
const actions = /* @__PURE__ */ new Map();
|
|
3128
|
-
const dropAction = (agent) => {
|
|
3129
|
-
const entry = actions.get(agent);
|
|
3130
|
-
if (!entry) return;
|
|
3131
|
-
entry.subscription.unsubscribe();
|
|
3132
|
-
copilotkit.removeScopedProperties(entry.id);
|
|
3133
|
-
actions.delete(agent);
|
|
3134
|
-
};
|
|
3135
|
-
const setAction = (agent, action) => {
|
|
3136
|
-
const previous = actions.get(agent);
|
|
3137
|
-
previous?.subscription.unsubscribe();
|
|
3138
|
-
if (previous) copilotkit.removeScopedProperties(previous.id);
|
|
3139
|
-
actions.delete(agent);
|
|
3140
|
-
const latest = configRef.current;
|
|
3141
|
-
if (!latest) return;
|
|
3142
|
-
const envelope = (0, _copilotkit_core_generative_ui.buildGenerativeUIEnvelope)({
|
|
3143
|
-
ui,
|
|
3144
|
-
manager,
|
|
3145
|
-
dispatcher
|
|
3146
|
-
}, agent.threadId, {
|
|
3147
|
-
...(0, _copilotkit_core_generative_ui.envelopeOptionsFor)(latest),
|
|
3148
|
-
action
|
|
3149
|
-
});
|
|
3150
|
-
const id = copilotkit.addScopedProperties({
|
|
3151
|
-
properties: { [_copilotkit_shared.COPILOTKIT_FORWARDED_PROPS_KEY]: { ui: envelope } },
|
|
3152
|
-
agentIds: agent.agentId === void 0 ? latest.agentIds : [agent.agentId]
|
|
3153
|
-
});
|
|
3154
|
-
const subscription = agent.subscribe({
|
|
3155
|
-
onRunFinalized: () => dropAction(agent),
|
|
3156
|
-
onRunFailed: () => dropAction(agent)
|
|
3157
|
-
});
|
|
3158
|
-
actions.set(agent, {
|
|
3159
|
-
id,
|
|
3160
|
-
action,
|
|
3161
|
-
subscription
|
|
3162
|
-
});
|
|
3163
|
-
};
|
|
3164
|
-
const refreshActions = () => {
|
|
3165
|
-
for (const [agent, { action }] of [...actions]) setAction(agent, action);
|
|
3166
|
-
};
|
|
3167
|
-
const dropAllActions = () => {
|
|
3168
|
-
for (const agent of [...actions.keys()]) dropAction(agent);
|
|
3169
|
-
};
|
|
3170
|
-
const forwardEvent = async (event, agentId) => {
|
|
3171
|
-
const fail = (message) => {
|
|
3172
|
-
const error = new _copilotkit_shared_generative_ui.GenerativeUIError("event_forward_failed", message);
|
|
3173
|
-
reportError({
|
|
3174
|
-
kind: "event",
|
|
3175
|
-
surfaceId: event.surfaceId,
|
|
3176
|
-
componentId: event.componentId,
|
|
3177
|
-
error
|
|
3178
|
-
});
|
|
3179
|
-
return {
|
|
3180
|
-
ok: false,
|
|
3181
|
-
error
|
|
3182
|
-
};
|
|
3183
|
-
};
|
|
3184
|
-
const agent = copilotkit.getAgent(agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID);
|
|
3185
|
-
if (!agent) return fail(`No agent "${agentId}" to receive "${event.name}"`);
|
|
3186
|
-
if (agent.isRunning || forwardingAgents.has(agent)) return {
|
|
3187
|
-
ok: false,
|
|
3188
|
-
error: new _copilotkit_shared_generative_ui.GenerativeUIError("agent_busy", `"${event.name}" was not sent: the agent is running`)
|
|
3189
|
-
};
|
|
3190
|
-
forwardingAgents.add(agent);
|
|
3191
|
-
try {
|
|
3192
|
-
const surface = agent.threadId ? manager.getSurface(agent.threadId, event.surfaceId) : void 0;
|
|
3193
|
-
const resolveLabel = surface ? (0, _copilotkit_core_generative_ui.surfaceLabelResolver)(surface) : void 0;
|
|
3194
|
-
agent.addMessage({
|
|
3195
|
-
id: (0, _copilotkit_shared.randomUUID)(),
|
|
3196
|
-
role: "user",
|
|
3197
|
-
content: (0, _copilotkit_core_generative_ui.buildActionMessageText)(event, resolveLabel)
|
|
3198
|
-
});
|
|
3199
|
-
setAction(agent, (0, _copilotkit_shared.toA2UIActionMessage)(event));
|
|
3200
|
-
await copilotkit.runAgent({ agent });
|
|
3201
|
-
return {
|
|
3202
|
-
ok: true,
|
|
3203
|
-
result: void 0
|
|
3204
|
-
};
|
|
3205
|
-
} catch (cause) {
|
|
3206
|
-
return fail(`Forwarding "${event.name}" failed: ${cause instanceof Error ? cause.message : String(cause)}`);
|
|
3207
|
-
} finally {
|
|
3208
|
-
forwardingAgents.delete(agent);
|
|
3209
|
-
dropAction(agent);
|
|
3210
|
-
}
|
|
3211
|
-
};
|
|
3212
|
-
return {
|
|
3213
|
-
manager,
|
|
3214
|
-
dispatcher,
|
|
3215
|
-
ui,
|
|
3216
|
-
forwardEvent,
|
|
3217
|
-
reportError,
|
|
3218
|
-
functionCalls,
|
|
3219
|
-
refreshActions,
|
|
3220
|
-
dropAllActions
|
|
3221
|
-
};
|
|
3222
|
-
}, [ui, copilotkit]);
|
|
3223
|
-
const runtime = (0, react.useMemo)(() => {
|
|
3224
|
-
if (!core) return null;
|
|
3225
|
-
const { manager, dispatcher, forwardEvent, reportError } = core;
|
|
3226
|
-
return {
|
|
3227
|
-
manager,
|
|
3228
|
-
dispatcher,
|
|
3229
|
-
ui: core.ui,
|
|
3230
|
-
forwardEvent,
|
|
3231
|
-
reportError,
|
|
3232
|
-
transport,
|
|
3233
|
-
theme,
|
|
3234
|
-
get config() {
|
|
3235
|
-
return configRef.current ?? { ui: core.ui };
|
|
3236
|
-
},
|
|
3237
|
-
get errorFallback() {
|
|
3238
|
-
return configRef.current?.errorBoundary?.fallback;
|
|
3239
|
-
}
|
|
3240
|
-
};
|
|
3241
|
-
}, [
|
|
3242
|
-
core,
|
|
3243
|
-
transport,
|
|
3244
|
-
theme
|
|
3245
|
-
]);
|
|
3246
|
-
(0, react.useEffect)(() => {
|
|
3247
|
-
if (!core) return;
|
|
3248
|
-
const watched = /* @__PURE__ */ new WeakSet();
|
|
3249
|
-
const agentSubscriptions = [];
|
|
3250
|
-
let envelopeId;
|
|
3251
|
-
const debug = (0, _copilotkit_core_generative_ui.createGenerativeUIDebugSource)(core, () => {
|
|
3252
|
-
const latest = configRef.current ?? { ui: core.ui };
|
|
3253
|
-
return {
|
|
3254
|
-
options: (0, _copilotkit_core_generative_ui.envelopeOptionsFor)(latest),
|
|
3255
|
-
agentIds: latest.agentIds
|
|
3256
|
-
};
|
|
3257
|
-
});
|
|
3258
|
-
copilotkit.ɵsetGenerativeUIDebugSource(debug.source);
|
|
3259
|
-
const removeEnvelope = () => {
|
|
3260
|
-
if (envelopeId === void 0) return;
|
|
3261
|
-
copilotkit.removeScopedProperties(envelopeId);
|
|
3262
|
-
envelopeId = void 0;
|
|
3263
|
-
};
|
|
3264
|
-
/**
|
|
3265
|
-
* Sets the shared envelope of the run. The action entries of the agents
|
|
3266
|
-
* with a user event under way (see `forwardEvent`) are set again after
|
|
3267
|
-
* it, so they stay the last entries and win for their agents.
|
|
3268
|
-
*/
|
|
3269
|
-
const setEnvelope = (agent, latest) => {
|
|
3270
|
-
removeEnvelope();
|
|
3271
|
-
const run = (0, _copilotkit_core_generative_ui.describeGenerativeUIRun)(core, agent.threadId, (0, _copilotkit_core_generative_ui.envelopeOptionsFor)(latest));
|
|
3272
|
-
envelopeId = copilotkit.addScopedProperties({
|
|
3273
|
-
properties: { [_copilotkit_shared.COPILOTKIT_FORWARDED_PROPS_KEY]: { ui: run.envelope } },
|
|
3274
|
-
agentIds: latest.agentIds
|
|
3275
|
-
});
|
|
3276
|
-
core.refreshActions();
|
|
3277
|
-
if (!latest.agentIds || latest.agentIds.includes(agent.agentId ?? "")) debug.recordRun({
|
|
3278
|
-
...run,
|
|
3279
|
-
agentId: agent.agentId,
|
|
3280
|
-
threadId: agent.threadId,
|
|
3281
|
-
startedAt: Date.now()
|
|
3282
|
-
});
|
|
3283
|
-
};
|
|
3284
|
-
/**
|
|
3285
|
-
* The tool transport reads the surface activity messages. The markdown
|
|
3286
|
-
* transport reads the ```a2ui fences of the assistant messages, and
|
|
3287
|
-
* builds the surfaces of the thread from them again on each change.
|
|
3288
|
-
* Both give their function calls to the one runner.
|
|
3289
|
-
*/
|
|
3290
|
-
const readMessages = (agent, messages, running) => {
|
|
3291
|
-
const requests = (0, _copilotkit_core_generative_ui.activityFunctionCalls)(messages);
|
|
3292
|
-
const { threadId } = agent;
|
|
3293
|
-
if (configRef.current?.transport !== "markdown") ingestMessages(core.manager, agent, messages);
|
|
3294
|
-
else if (threadId) {
|
|
3295
|
-
core.manager.setActiveThread(threadId);
|
|
3296
|
-
const calls = (0, _copilotkit_core_generative_ui.getMarkdownSurfaceSource)(core).sync(threadId, agent.agentId, messages, { running });
|
|
3297
|
-
requests.push(...(0, _copilotkit_core_generative_ui.markdownFunctionCalls)(calls));
|
|
3298
|
-
}
|
|
3299
|
-
core.functionCalls.run(agent, requests, messages, running);
|
|
3300
|
-
};
|
|
3301
|
-
const subscription = copilotkit.subscribe({ onAgentRunStarted: ({ agent }) => {
|
|
3302
|
-
core.manager.setActiveThread(agent.threadId);
|
|
3303
|
-
const latest = configRef.current;
|
|
3304
|
-
if (latest) setEnvelope(agent, latest);
|
|
3305
|
-
if (!watched.has(agent)) {
|
|
3306
|
-
watched.add(agent);
|
|
3307
|
-
agentSubscriptions.push(agent.subscribe({
|
|
3308
|
-
onMessagesChanged: ({ messages }) => readMessages(agent, messages, agent.isRunning),
|
|
3309
|
-
onRunFinalized: () => readMessages(agent, agent.messages, false),
|
|
3310
|
-
onRunFailed: () => readMessages(agent, agent.messages, false)
|
|
3311
|
-
}));
|
|
3312
|
-
}
|
|
3313
|
-
readMessages(agent, agent.messages, true);
|
|
3314
|
-
} });
|
|
3315
|
-
return () => {
|
|
3316
|
-
subscription.unsubscribe();
|
|
3317
|
-
for (const s of agentSubscriptions) s.unsubscribe();
|
|
3318
|
-
core.dropAllActions();
|
|
3319
|
-
removeEnvelope();
|
|
3320
|
-
if (copilotkit.ɵgenerativeUIDebugSource === debug.source) copilotkit.ɵsetGenerativeUIDebugSource(void 0);
|
|
3321
|
-
};
|
|
3322
|
-
}, [core, copilotkit]);
|
|
3323
|
-
useGenerativeUIMarkdownContext(copilotkit, core, {
|
|
3324
|
-
enabled: config?.transport === "markdown" && config.sendContext !== false,
|
|
3325
|
-
agentIds: config?.agentIds
|
|
3326
|
-
});
|
|
3327
|
-
return runtime;
|
|
3328
|
-
}
|
|
3329
|
-
|
|
3330
2982
|
//#endregion
|
|
3331
2983
|
//#region src/v2/lib/react-core.ts
|
|
3332
2984
|
var CopilotKitCoreReact = class extends _copilotkit_core.CopilotKitCore {
|
|
@@ -3545,7 +3197,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3545
3197
|
loadingComponent: a2ui?.loadingComponent,
|
|
3546
3198
|
recovery: a2ui?.recovery
|
|
3547
3199
|
}));
|
|
3548
|
-
if (generativeUIActive) renderers.push(
|
|
3200
|
+
if (generativeUIActive) renderers.push(require_chat.createGenerativeUIActivityRenderer(), require_chat.createGenerativeUIFunctionCallActivityRenderer());
|
|
3549
3201
|
return renderers;
|
|
3550
3202
|
}, [
|
|
3551
3203
|
a2uiActive,
|
|
@@ -3717,7 +3369,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3717
3369
|
if (defaultThrottleMs !== void 0) copilotkitRef.current.setDefaultThrottleMs(defaultThrottleMs);
|
|
3718
3370
|
}
|
|
3719
3371
|
const copilotkit = copilotkitRef.current;
|
|
3720
|
-
const generativeUIRuntime = useGenerativeUIRoot(copilotkit, generativeUI);
|
|
3372
|
+
const generativeUIRuntime = require_use_generative_ui_root.useGenerativeUIRoot(copilotkit, generativeUI);
|
|
3721
3373
|
(0, react.useEffect)(() => {
|
|
3722
3374
|
if (!rawCatalog) return;
|
|
3723
3375
|
if (!(rawCatalog instanceof _copilotkit_a2ui_renderer.Catalog)) return;
|
|
@@ -3956,7 +3608,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3956
3608
|
value: licenseContextValue,
|
|
3957
3609
|
children: [
|
|
3958
3610
|
a2uiActive && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(A2UIBuiltInToolCallRenderer, {}),
|
|
3959
|
-
generativeUIActive && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
3611
|
+
generativeUIActive && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_chat.GenerativeUIToolCallRenderer, {}),
|
|
3960
3612
|
a2uiActive && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(A2UICatalogContext, {
|
|
3961
3613
|
catalog: filteredCatalog,
|
|
3962
3614
|
includeSchema: a2ui?.includeSchema
|
|
@@ -3965,7 +3617,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3965
3617
|
value: inspectorContextValue,
|
|
3966
3618
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_react_core_v2_context.CopilotKitAgentIdContext.Provider, {
|
|
3967
3619
|
value: agentId,
|
|
3968
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
3620
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_chat.GenerativeUIRuntimeContext.Provider, {
|
|
3969
3621
|
value: generativeUIRuntime,
|
|
3970
3622
|
children
|
|
3971
3623
|
})
|
|
@@ -3989,7 +3641,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3989
3641
|
//#region src/v2/hooks/use-render-custom-messages.tsx
|
|
3990
3642
|
function useRenderCustomMessages() {
|
|
3991
3643
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
3992
|
-
const config =
|
|
3644
|
+
const config = require_chat.useCopilotChatConfiguration();
|
|
3993
3645
|
if (!config) return null;
|
|
3994
3646
|
const { agentId, threadId } = config;
|
|
3995
3647
|
const customMessageRenderers = copilotkit.renderCustomMessages.filter((renderer) => renderer.agentId === void 0 || renderer.agentId === agentId).sort((a, b) => {
|
|
@@ -4034,7 +3686,7 @@ function useRenderCustomMessages() {
|
|
|
4034
3686
|
//#region src/v2/hooks/use-render-activity-message.tsx
|
|
4035
3687
|
function useRenderActivityMessage() {
|
|
4036
3688
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
4037
|
-
const agentId =
|
|
3689
|
+
const agentId = require_chat.useCopilotChatConfiguration()?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
4038
3690
|
const renderers = copilotkit.renderActivityMessages;
|
|
4039
3691
|
const findRenderer = (0, react.useCallback)((activityType) => {
|
|
4040
3692
|
if (!renderers.length) return null;
|
|
@@ -4392,7 +4044,7 @@ function useRenderTool(config, deps) {
|
|
|
4392
4044
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
4393
4045
|
const depsVersion = useDepsVersion(deps);
|
|
4394
4046
|
(0, react.useEffect)(() => {
|
|
4395
|
-
const renderer = config.name === "*" && !config.parameters ?
|
|
4047
|
+
const renderer = config.name === "*" && !config.parameters ? require_chat.defineToolCallRenderer({
|
|
4396
4048
|
name: "*",
|
|
4397
4049
|
render: (props) => config.render({
|
|
4398
4050
|
...props,
|
|
@@ -4400,7 +4052,7 @@ function useRenderTool(config, deps) {
|
|
|
4400
4052
|
}),
|
|
4401
4053
|
...config.agentId ? { agentId: config.agentId } : {},
|
|
4402
4054
|
group: config.group
|
|
4403
|
-
}) :
|
|
4055
|
+
}) : require_chat.defineToolCallRenderer({
|
|
4404
4056
|
name: config.name,
|
|
4405
4057
|
args: config.parameters,
|
|
4406
4058
|
render: (props) => {
|
|
@@ -5135,7 +4787,7 @@ function useAgent({ agentId, threadId, runtimeAgentId, updates, throttleMs } = {
|
|
|
5135
4787
|
if (threadId != null && runtimeAgentId == null) throw new Error(`useAgent: \`threadId\` requires \`runtimeAgentId\`. A threadId is written onto a single agent, but an agent resolved by agentId alone is shared, so scoping a thread to it would clobber other useAgent callers. Pass a distinct local \`agentId\` and the runtime agent to route to, e.g. useAgent({ agentId: "chat-1", runtimeAgentId: "${agentId ?? "default"}", threadId }).`);
|
|
5136
4788
|
if (runtimeAgentId != null && threadId == null) throw new Error(`useAgent: \`runtimeAgentId\` requires \`threadId\`. A proxied agent exists to scope a thread to a private instance; without a threadId it behaves like the shared agent while adding a registration and a local agentId to keep unique. Either pass the thread, e.g. useAgent({ agentId: "${agentId ?? "chat-1"}", runtimeAgentId: "${runtimeAgentId}", threadId }), or bind to the agent directly with useAgent({ agentId: "${runtimeAgentId}" }).`);
|
|
5137
4789
|
if (runtimeAgentId != null && agentId == null) throw new Error(`useAgent: \`runtimeAgentId\` requires an explicit \`agentId\`. The proxied agent is registered under \`agentId\`, and the usual fallbacks (chat configuration, then "${_copilotkit_shared.DEFAULT_AGENT_ID}") name agents that already exist — registering over one throws or shadows it. Pick a local id for this hook, e.g. useAgent({ agentId: "chat-1", runtimeAgentId: "${runtimeAgentId}", threadId }).`);
|
|
5138
|
-
const chatConfig =
|
|
4790
|
+
const chatConfig = require_chat.useCopilotChatConfiguration();
|
|
5139
4791
|
const providerAgentId = (0, _copilotkit_react_core_v2_context.useDefaultAgentId)();
|
|
5140
4792
|
const resolvedAgentId = agentId ?? chatConfig?.agentId ?? providerAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
5141
4793
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
@@ -5365,7 +5017,7 @@ function useAgentContext(context) {
|
|
|
5365
5017
|
//#region src/v2/hooks/use-suggestions.tsx
|
|
5366
5018
|
function useSuggestions({ agentId } = {}) {
|
|
5367
5019
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
5368
|
-
const config =
|
|
5020
|
+
const config = require_chat.useCopilotChatConfiguration();
|
|
5369
5021
|
const providerAgentId = (0, _copilotkit_react_core_v2_context.useDefaultAgentId)();
|
|
5370
5022
|
const resolvedAgentId = (0, react.useMemo)(() => agentId ?? config?.agentId ?? providerAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID, [
|
|
5371
5023
|
agentId,
|
|
@@ -5423,7 +5075,7 @@ function useSuggestions({ agentId } = {}) {
|
|
|
5423
5075
|
//#region src/v2/hooks/use-configure-suggestions.tsx
|
|
5424
5076
|
function useConfigureSuggestions(config, deps) {
|
|
5425
5077
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
5426
|
-
const chatConfig =
|
|
5078
|
+
const chatConfig = require_chat.useCopilotChatConfiguration();
|
|
5427
5079
|
const extraDeps = deps ?? [];
|
|
5428
5080
|
const resolvedConsumerAgentId = (0, react.useMemo)(() => chatConfig?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID, [chatConfig?.agentId]);
|
|
5429
5081
|
const rawConsumerAgentId = (0, react.useMemo)(() => config ? config.consumerAgentId : void 0, [config]);
|
|
@@ -6277,7 +5929,7 @@ function useLearnFromUserAction() {
|
|
|
6277
5929
|
* ```
|
|
6278
5930
|
*/
|
|
6279
5931
|
function useLearnFromUserActionInCurrentThread() {
|
|
6280
|
-
const config =
|
|
5932
|
+
const config = require_chat.useCopilotChatConfiguration();
|
|
6281
5933
|
const learnFromUserAction = useLearnFromUserAction();
|
|
6282
5934
|
return (0, react.useCallback)(async (input) => {
|
|
6283
5935
|
const threadId = config?.threadId;
|
|
@@ -6647,7 +6299,7 @@ function useLearningContainers({ threadId, learningContainers }) {
|
|
|
6647
6299
|
* Intelligence runtimes.
|
|
6648
6300
|
*/
|
|
6649
6301
|
function useLearningContainersInCurrentThread({ learningContainers }) {
|
|
6650
|
-
const threadId =
|
|
6302
|
+
const threadId = require_chat.useCopilotChatConfiguration()?.threadId;
|
|
6651
6303
|
if (!threadId) throw new Error("useLearningContainersInCurrentThread must be used within a thread context (no active threadId). Wrap the component in <CopilotChat>, <CopilotSidebar>, or <CopilotChatConfigurationProvider>, or use `useLearningContainers()` and pass `threadId` explicitly.");
|
|
6652
6304
|
useLearningContainers({
|
|
6653
6305
|
threadId,
|
|
@@ -6999,7 +6651,7 @@ function InspectorKiteIcon({ className, ...props }) {
|
|
|
6999
6651
|
});
|
|
7000
6652
|
}
|
|
7001
6653
|
function CopilotChatInspectorButton({ title, className, onClick, onPointerDown, onPointerEnter, onPointerLeave, onKeyDown, disabled, ...props }) {
|
|
7002
|
-
const labels =
|
|
6654
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
7003
6655
|
const { isInspectorEnabled } = useCopilotKitInspector();
|
|
7004
6656
|
const hidden = useInspectorShortcutsHidden();
|
|
7005
6657
|
const [open, setOpen] = (0, react.useState)(false);
|
|
@@ -7470,7 +7122,7 @@ function WorkText({ messageId, children }) {
|
|
|
7470
7122
|
* assistant message subscribe to chat configuration changes.
|
|
7471
7123
|
*/
|
|
7472
7124
|
function BoundInspectorButton({ inspectorButton, messageId, openInspector, ...props }) {
|
|
7473
|
-
const chatConfiguration =
|
|
7125
|
+
const chatConfiguration = require_chat.useCopilotChatConfiguration();
|
|
7474
7126
|
return renderSlot(inspectorButton, CopilotChatAssistantMessage.InspectorButton, {
|
|
7475
7127
|
...props,
|
|
7476
7128
|
onClick: () => openInspector({
|
|
@@ -7515,7 +7167,7 @@ function nextFocusable(element, skip) {
|
|
|
7515
7167
|
* control after the thumb, and Enter or Escape inside it returns to the thumb.
|
|
7516
7168
|
*/
|
|
7517
7169
|
function FeedbackCommentPopover({ feedbackComment, comment, savedComment, rating, anchor, messageId }) {
|
|
7518
|
-
const labels =
|
|
7170
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
7519
7171
|
const contentRef = (0, react.useRef)(null);
|
|
7520
7172
|
const focusInside = () => contentRef.current?.contains(document.activeElement) ?? false;
|
|
7521
7173
|
const { focusRequest, takeFocusRequest, inputRef } = comment;
|
|
@@ -7774,7 +7426,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, o
|
|
|
7774
7426
|
}
|
|
7775
7427
|
(function(_CopilotChatAssistantMessage) {
|
|
7776
7428
|
_CopilotChatAssistantMessage.MarkdownRenderer = ({ content, className, messageId, ...props }) => {
|
|
7777
|
-
if (
|
|
7429
|
+
if (require_chat.useGenerativeUIRuntime()?.transport === "markdown" && messageId !== void 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.MarkdownSurfaces, {
|
|
7778
7430
|
content: content ?? "",
|
|
7779
7431
|
messageId,
|
|
7780
7432
|
className,
|
|
@@ -7815,7 +7467,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, o
|
|
|
7815
7467
|
});
|
|
7816
7468
|
};
|
|
7817
7469
|
_CopilotChatAssistantMessage.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
7818
|
-
const labels =
|
|
7470
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
7819
7471
|
const [copied, setCopied] = (0, react.useState)(false);
|
|
7820
7472
|
const timerRef = (0, react.useRef)(null);
|
|
7821
7473
|
(0, react.useEffect)(() => {
|
|
@@ -7846,7 +7498,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, o
|
|
|
7846
7498
|
};
|
|
7847
7499
|
_CopilotChatAssistantMessage.InspectorButton = CopilotChatInspectorButton;
|
|
7848
7500
|
_CopilotChatAssistantMessage.ThumbsUpButton = ({ title, ...props }) => {
|
|
7849
|
-
const labels =
|
|
7501
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
7850
7502
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
7851
7503
|
"data-testid": "copilot-thumbs-up-button",
|
|
7852
7504
|
title: title || labels.assistantMessageToolbarThumbsUpLabel,
|
|
@@ -7858,7 +7510,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, o
|
|
|
7858
7510
|
});
|
|
7859
7511
|
};
|
|
7860
7512
|
_CopilotChatAssistantMessage.ThumbsDownButton = ({ title, ...props }) => {
|
|
7861
|
-
const labels =
|
|
7513
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
7862
7514
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
7863
7515
|
"data-testid": "copilot-thumbs-down-button",
|
|
7864
7516
|
title: title || labels.assistantMessageToolbarThumbsDownLabel,
|
|
@@ -7870,7 +7522,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, o
|
|
|
7870
7522
|
});
|
|
7871
7523
|
};
|
|
7872
7524
|
_CopilotChatAssistantMessage.FeedbackComment = ({ value, savedComment, inputRef, onChange, onSubmit, onEditingChange, onLeave, className }) => {
|
|
7873
|
-
const labels =
|
|
7525
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
7874
7526
|
const changed = value.trim() !== savedComment;
|
|
7875
7527
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
|
|
7876
7528
|
"data-testid": "copilot-feedback-comment",
|
|
@@ -7905,7 +7557,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, o
|
|
|
7905
7557
|
});
|
|
7906
7558
|
};
|
|
7907
7559
|
_CopilotChatAssistantMessage.ReadAloudButton = ({ title, ...props }) => {
|
|
7908
|
-
const labels =
|
|
7560
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
7909
7561
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
7910
7562
|
"data-testid": "copilot-read-aloud-button",
|
|
7911
7563
|
title: title || labels.assistantMessageToolbarReadAloudLabel,
|
|
@@ -7914,7 +7566,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, o
|
|
|
7914
7566
|
});
|
|
7915
7567
|
};
|
|
7916
7568
|
_CopilotChatAssistantMessage.RegenerateButton = ({ title, ...props }) => {
|
|
7917
|
-
const labels =
|
|
7569
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
7918
7570
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
7919
7571
|
"data-testid": "copilot-regenerate-button",
|
|
7920
7572
|
title: title || labels.assistantMessageToolbarRegenerateLabel,
|
|
@@ -7942,7 +7594,7 @@ var CopilotChatAssistantMessage_default = CopilotChatAssistantMessage;
|
|
|
7942
7594
|
* `labels.attachmentPreviewCloseButtonLabel`.
|
|
7943
7595
|
*/
|
|
7944
7596
|
function Lightbox({ onClose, children }) {
|
|
7945
|
-
const labels =
|
|
7597
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
7946
7598
|
(0, react.useEffect)(() => {
|
|
7947
7599
|
const handleKey = (e) => {
|
|
7948
7600
|
if (e.key === "Escape") onClose();
|
|
@@ -8211,7 +7863,7 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
8211
7863
|
})] });
|
|
8212
7864
|
};
|
|
8213
7865
|
_CopilotChatUserMessage.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
8214
|
-
const labels =
|
|
7866
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
8215
7867
|
const [copied, setCopied] = (0, react.useState)(false);
|
|
8216
7868
|
const handleClick = async (event) => {
|
|
8217
7869
|
let success = false;
|
|
@@ -8231,7 +7883,7 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
8231
7883
|
});
|
|
8232
7884
|
};
|
|
8233
7885
|
_CopilotChatUserMessage.EditButton = ({ className, title, ...props }) => {
|
|
8234
|
-
const labels =
|
|
7886
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
8235
7887
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
8236
7888
|
"data-testid": "copilot-edit-button",
|
|
8237
7889
|
title: title || labels.userMessageToolbarEditMessageLabel,
|
|
@@ -8241,7 +7893,7 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
8241
7893
|
});
|
|
8242
7894
|
};
|
|
8243
7895
|
_CopilotChatUserMessage.BranchNavigation = ({ className, currentBranch = 0, numberOfBranches = 1, onSwitchToBranch, message, ...props }) => {
|
|
8244
|
-
const labels =
|
|
7896
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
8245
7897
|
if (!numberOfBranches || numberOfBranches <= 1 || !onSwitchToBranch) return null;
|
|
8246
7898
|
const canGoPrev = currentBranch > 0;
|
|
8247
7899
|
const canGoNext = currentBranch < numberOfBranches - 1;
|
|
@@ -8317,7 +7969,7 @@ function formatDuration$1(seconds) {
|
|
|
8317
7969
|
* `header` slot also receives `elapsedSeconds`.
|
|
8318
7970
|
*/
|
|
8319
7971
|
function CopilotChatReasoningMessage({ message, messages, isRunning, isLatest: isLatestProp, header, contentView, toggle, children, className, ...props }) {
|
|
8320
|
-
const labels =
|
|
7972
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
8321
7973
|
const isLatest = isLatestProp ?? messages?.[messages.length - 1]?.id === message.id;
|
|
8322
7974
|
const isStreaming = !!(isRunning && isLatest);
|
|
8323
7975
|
const hasContent = !!(message.content && message.content.length > 0);
|
|
@@ -8870,7 +8522,7 @@ const isToolCallLikeMessage = (m) => {
|
|
|
8870
8522
|
function IntelligenceIndicator(props) {
|
|
8871
8523
|
const { message, agentId, label = "CopilotKit Intelligence", intelligenceIndicator } = props;
|
|
8872
8524
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
8873
|
-
const config =
|
|
8525
|
+
const config = require_chat.useCopilotChatConfiguration();
|
|
8874
8526
|
const { agent } = useAgent({
|
|
8875
8527
|
agentId,
|
|
8876
8528
|
updates: [UseAgentUpdate.OnRunStatusChanged, UseAgentUpdate.OnMessagesChanged]
|
|
@@ -9126,7 +8778,7 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
9126
8778
|
const renderCustomMessage = useRenderCustomMessages();
|
|
9127
8779
|
const { renderActivityMessage } = useRenderActivityMessage();
|
|
9128
8780
|
const { copilotkit, showIntelligenceIndicator = true } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
9129
|
-
const config =
|
|
8781
|
+
const config = require_chat.useCopilotChatConfiguration();
|
|
9130
8782
|
const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
|
|
9131
8783
|
(0, react.useEffect)(() => {
|
|
9132
8784
|
if (!config?.agentId) return;
|
|
@@ -9773,7 +9425,7 @@ CopilotChatMessageView.Cursor = function Cursor({ className, ...props }) {
|
|
|
9773
9425
|
* button named by `labels.attachmentRemoveButtonLabel`.
|
|
9774
9426
|
*/
|
|
9775
9427
|
const CopilotChatAttachmentQueue = ({ attachments, onRemoveAttachment, className }) => {
|
|
9776
|
-
const labels =
|
|
9428
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
9777
9429
|
if (attachments.length === 0) return null;
|
|
9778
9430
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
9779
9431
|
"data-testid": "copilot-attachment-queue",
|
|
@@ -9850,7 +9502,7 @@ function AudioPreview({ attachment }) {
|
|
|
9850
9502
|
* lightbox.
|
|
9851
9503
|
*/
|
|
9852
9504
|
function VideoPreview({ attachment }) {
|
|
9853
|
-
const labels =
|
|
9505
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
9854
9506
|
const src = (0, _copilotkit_shared.getSourceUrl)(attachment.source);
|
|
9855
9507
|
const { thumbnailRef, vtName, open, openLightbox, closeLightbox } = useLightbox();
|
|
9856
9508
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
@@ -10155,7 +9807,7 @@ function DropOverlay() {
|
|
|
10155
9807
|
});
|
|
10156
9808
|
}
|
|
10157
9809
|
function CopilotChatView({ messageView, input, scrollView, suggestionView, welcomeScreen, messages = [], autoScroll = true, isRunning = false, suggestions, suggestionLoadingIndexes, onSelectSuggestion, onSubmitMessage, onStop, inputMode, inputValue, onInputChange, onStartTranscribe, onCancelTranscribe, onFinishTranscribe, onFinishTranscribeWithAudio, attachments, onRemoveAttachment, onAddFile, dragOver, onDragOver, onDragLeave, onDrop, isConnecting = false, connectingIndicator, hasExplicitThreadId = false, disclaimer, intelligenceIndicator, children, className, ...props }) {
|
|
10158
|
-
const configuredThreadId =
|
|
9810
|
+
const configuredThreadId = require_chat.useCopilotChatConfiguration()?.threadId;
|
|
10159
9811
|
const [fallbackThreadId, setFallbackThreadId] = (0, react.useState)(messages[0]?.id);
|
|
10160
9812
|
const previousMessageIds = (0, react.useRef)(/* @__PURE__ */ new Set());
|
|
10161
9813
|
(0, react.useEffect)(() => {
|
|
@@ -10601,7 +10253,7 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
10601
10253
|
});
|
|
10602
10254
|
};
|
|
10603
10255
|
_CopilotChatView.ScrollToBottomButton = ({ className, ...props }) => {
|
|
10604
|
-
const labels =
|
|
10256
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
10605
10257
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
10606
10258
|
"data-testid": "copilot-scroll-to-bottom",
|
|
10607
10259
|
variant: "outline",
|
|
@@ -10617,7 +10269,7 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
10617
10269
|
...props
|
|
10618
10270
|
});
|
|
10619
10271
|
_CopilotChatView.ConnectingIndicator = ({ className, ...props }) => {
|
|
10620
|
-
const labels =
|
|
10272
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
10621
10273
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
10622
10274
|
"data-testid": "copilot-connecting-indicator",
|
|
10623
10275
|
role: "status",
|
|
@@ -10633,7 +10285,7 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
10633
10285
|
});
|
|
10634
10286
|
};
|
|
10635
10287
|
_CopilotChatView.WelcomeMessage = ({ className, ...props }) => {
|
|
10636
|
-
const labels =
|
|
10288
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
10637
10289
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
|
|
10638
10290
|
className: cn("cpk:text-xl cpk:sm:text-2xl cpk:font-medium cpk:text-foreground cpk:text-center", className),
|
|
10639
10291
|
...props,
|
|
@@ -10884,7 +10536,7 @@ function useInspectorThreadOverride(args) {
|
|
|
10884
10536
|
//#endregion
|
|
10885
10537
|
//#region src/v2/components/chat/CopilotChat.tsx
|
|
10886
10538
|
function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isModalDefaultOpen, attachments: attachmentsConfig, onError, throttleMs, generativeUISurface, ...props }) {
|
|
10887
|
-
const existingConfig =
|
|
10539
|
+
const existingConfig = require_chat.useCopilotChatConfiguration();
|
|
10888
10540
|
const inspector = useCopilotKitInspector();
|
|
10889
10541
|
const inspectorContextValue = (0, react.useMemo)(() => ({
|
|
10890
10542
|
...inspector,
|
|
@@ -11475,8 +11127,8 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
|
|
|
11475
11127
|
return () => clearTimeout(timer);
|
|
11476
11128
|
}
|
|
11477
11129
|
}, [transcriptionError]);
|
|
11478
|
-
const stableMessageView =
|
|
11479
|
-
const stableSuggestionView =
|
|
11130
|
+
const stableMessageView = require_chat.useShallowStableRef(typeof providedMessageView === "string" ? { className: providedMessageView } : providedMessageView);
|
|
11131
|
+
const stableSuggestionView = require_chat.useShallowStableRef(providedSuggestionView);
|
|
11480
11132
|
const handleAddFile = (0, react.useCallback)(() => {
|
|
11481
11133
|
setTimeout(() => {
|
|
11482
11134
|
fileInputRef.current?.click();
|
|
@@ -11537,7 +11189,7 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
|
|
|
11537
11189
|
isConnecting,
|
|
11538
11190
|
hasExplicitThreadId
|
|
11539
11191
|
});
|
|
11540
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
11192
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_chat.CopilotChatConfigurationProvider, {
|
|
11541
11193
|
agentId: resolvedAgentId,
|
|
11542
11194
|
threadId: resolvedThreadId,
|
|
11543
11195
|
hasExplicitThreadId,
|
|
@@ -11575,7 +11227,7 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
|
|
|
11575
11227
|
value: lastUserMessageState,
|
|
11576
11228
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitInspectorContextProvider, {
|
|
11577
11229
|
value: inspectorContextValue,
|
|
11578
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
11230
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_chat.GenerativeUIChatSlotContext.Provider, {
|
|
11579
11231
|
value: generativeUISurface,
|
|
11580
11232
|
children: RenderedChatView
|
|
11581
11233
|
})
|
|
@@ -11609,8 +11261,8 @@ const ICON_WRAPPER_BASE = "cpk:pointer-events-none cpk:absolute cpk:inset-0 cpk:
|
|
|
11609
11261
|
const BUTTON_BASE_CLASSES = cn("copilotKitButton", "cpk:fixed cpk:bottom-6 cpk:right-6 cpk:z-[1100] cpk:flex cpk:h-14 cpk:w-14 cpk:items-center cpk:justify-center", "cpk:rounded-full cpk:border cpk:border-primary cpk:bg-primary cpk:text-primary-foreground", "cpk:shadow-sm cpk:transition-all cpk:duration-200 cpk:ease-out", "cpk:hover:scale-[1.04] cpk:hover:shadow-md", "cpk:cursor-pointer", "cpk:active:scale-[0.96]", "cpk:focus-visible:outline-none cpk:focus-visible:ring-2 cpk:focus-visible:ring-primary/50 cpk:focus-visible:ring-offset-2 cpk:focus-visible:ring-offset-background", "cpk:disabled:pointer-events-none cpk:disabled:opacity-60");
|
|
11610
11262
|
const CopilotChatToggleButton = react.default.forwardRef(function CopilotChatToggleButton({ openIcon, closeIcon, className, ...buttonProps }, ref) {
|
|
11611
11263
|
const { onClick, type, disabled, ...restProps } = buttonProps;
|
|
11612
|
-
const configuration =
|
|
11613
|
-
const labels = configuration?.labels ??
|
|
11264
|
+
const configuration = require_chat.useCopilotChatConfiguration();
|
|
11265
|
+
const labels = configuration?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
11614
11266
|
const [fallbackOpen, setFallbackOpen] = (0, react.useState)(false);
|
|
11615
11267
|
const isOpen = configuration?.isModalOpen ?? fallbackOpen;
|
|
11616
11268
|
const setModalOpen = configuration?.setModalOpen ?? setFallbackOpen;
|
|
@@ -11726,8 +11378,8 @@ function useIsMobileViewport() {
|
|
|
11726
11378
|
return isMobile;
|
|
11727
11379
|
}
|
|
11728
11380
|
function CopilotModalHeader({ title, titleContent, closeButton, drawerLauncher, children, className, ...rest }) {
|
|
11729
|
-
const configuration =
|
|
11730
|
-
const fallbackTitle = configuration?.labels.modalHeaderTitle ??
|
|
11381
|
+
const configuration = require_chat.useCopilotChatConfiguration();
|
|
11382
|
+
const fallbackTitle = configuration?.labels.modalHeaderTitle ?? require_chat.CopilotChatDefaultLabels.modalHeaderTitle;
|
|
11731
11383
|
const resolvedTitle = title ?? fallbackTitle;
|
|
11732
11384
|
const isMobile = useIsMobileViewport();
|
|
11733
11385
|
const drawerRegistered = (configuration?.drawerRegistered ?? false) && isMobile;
|
|
@@ -11783,7 +11435,7 @@ CopilotModalHeader.displayName = "CopilotModalHeader";
|
|
|
11783
11435
|
children
|
|
11784
11436
|
});
|
|
11785
11437
|
_CopilotModalHeader.CloseButton = ({ className, ...props }) => {
|
|
11786
|
-
const labels =
|
|
11438
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
11787
11439
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
11788
11440
|
type: "button",
|
|
11789
11441
|
"data-testid": "copilot-close-button",
|
|
@@ -11797,7 +11449,7 @@ CopilotModalHeader.displayName = "CopilotModalHeader";
|
|
|
11797
11449
|
});
|
|
11798
11450
|
};
|
|
11799
11451
|
_CopilotModalHeader.DrawerLauncher = ({ className, ...props }) => {
|
|
11800
|
-
const labels =
|
|
11452
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
11801
11453
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
11802
11454
|
type: "button",
|
|
11803
11455
|
"data-testid": "copilot-threads-drawer-launcher",
|
|
@@ -11833,9 +11485,9 @@ function CopilotSidebarView({ header, toggleButton, width, defaultOpen = true, p
|
|
|
11833
11485
|
position,
|
|
11834
11486
|
...props
|
|
11835
11487
|
});
|
|
11836
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
11488
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_chat.CopilotChatConfigurationProvider, {
|
|
11837
11489
|
isModalDefaultOpen: open ?? defaultOpen,
|
|
11838
|
-
children: hasOpenControl ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
11490
|
+
children: hasOpenControl ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_chat.ControlledModalOpenScope, {
|
|
11839
11491
|
open,
|
|
11840
11492
|
onOpenChange,
|
|
11841
11493
|
children: internal
|
|
@@ -11843,7 +11495,7 @@ function CopilotSidebarView({ header, toggleButton, width, defaultOpen = true, p
|
|
|
11843
11495
|
});
|
|
11844
11496
|
}
|
|
11845
11497
|
function CopilotSidebarViewInternal({ header, toggleButton, width, position = "right", ...props }) {
|
|
11846
|
-
const configuration =
|
|
11498
|
+
const configuration = require_chat.useCopilotChatConfiguration();
|
|
11847
11499
|
const isSidebarOpen = configuration?.isModalOpen ?? false;
|
|
11848
11500
|
const sidebarRef = (0, react.useRef)(null);
|
|
11849
11501
|
const [sidebarWidth, setSidebarWidth] = (0, react.useState)(width ?? DEFAULT_SIDEBAR_WIDTH);
|
|
@@ -11909,7 +11561,7 @@ function CopilotSidebarViewInternal({ header, toggleButton, width, position = "r
|
|
|
11909
11561
|
paddingBottom: "env(safe-area-inset-bottom)"
|
|
11910
11562
|
},
|
|
11911
11563
|
"aria-hidden": !isSidebarOpen,
|
|
11912
|
-
"aria-label": configuration?.labels.sidebarLabel ??
|
|
11564
|
+
"aria-label": configuration?.labels.sidebarLabel ?? require_chat.CopilotChatDefaultLabels.sidebarLabel,
|
|
11913
11565
|
role: "complementary",
|
|
11914
11566
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
11915
11567
|
className: "cpk:flex cpk:h-full cpk:w-full cpk:flex-col cpk:overflow-hidden",
|
|
@@ -11977,9 +11629,9 @@ function CopilotPopupView({ header, toggleButton, width, height, clickOutsideToC
|
|
|
11977
11629
|
className,
|
|
11978
11630
|
...restProps
|
|
11979
11631
|
});
|
|
11980
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
11632
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_chat.CopilotChatConfigurationProvider, {
|
|
11981
11633
|
isModalDefaultOpen: open ?? defaultOpen,
|
|
11982
|
-
children: hasOpenControl ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
11634
|
+
children: hasOpenControl ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_chat.ControlledModalOpenScope, {
|
|
11983
11635
|
open,
|
|
11984
11636
|
onOpenChange,
|
|
11985
11637
|
children: internal
|
|
@@ -11987,10 +11639,10 @@ function CopilotPopupView({ header, toggleButton, width, height, clickOutsideToC
|
|
|
11987
11639
|
});
|
|
11988
11640
|
}
|
|
11989
11641
|
function CopilotPopupViewInternal({ header, toggleButton, width, height, clickOutsideToClose, className, ...restProps }) {
|
|
11990
|
-
const configuration =
|
|
11642
|
+
const configuration = require_chat.useCopilotChatConfiguration();
|
|
11991
11643
|
const isPopupOpen = configuration?.isModalOpen ?? false;
|
|
11992
11644
|
const setModalOpen = configuration?.setModalOpen;
|
|
11993
|
-
const labels = configuration?.labels ??
|
|
11645
|
+
const labels = configuration?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
11994
11646
|
const containerRef = (0, react.useRef)(null);
|
|
11995
11647
|
const [isRendered, setIsRendered] = (0, react.useState)(isPopupOpen);
|
|
11996
11648
|
const [isAnimatingOut, setIsAnimatingOut] = (0, react.useState)(false);
|
|
@@ -12293,7 +11945,7 @@ function findChatInput(origin) {
|
|
|
12293
11945
|
* ```
|
|
12294
11946
|
*/
|
|
12295
11947
|
function CopilotThreadsDrawer({ agentId, onThreadSelect, onNewThread, onLicensed, licenseUrl, renderRow, label, recentLabel, collapsible, onCollapseChange, limit, "data-testid": dataTestId = "copilot-threads-drawer" }) {
|
|
12296
|
-
const configuration =
|
|
11948
|
+
const configuration = require_chat.useCopilotChatConfiguration();
|
|
12297
11949
|
const { status, checkFeature } = (0, _copilotkit_react_core_v2_context.useLicenseContext)();
|
|
12298
11950
|
const licensePresent = status === "valid" || status === "expiring";
|
|
12299
11951
|
const featureLicensed = checkFeature("threads");
|
|
@@ -12552,7 +12204,7 @@ CopilotThreadsDrawer.displayName = "CopilotThreadsDrawer";
|
|
|
12552
12204
|
* Catch-all (`"*"`) tool-call renderer that shows CopilotKit's default
|
|
12553
12205
|
* tool-call card for any tool without a dedicated renderer.
|
|
12554
12206
|
*/
|
|
12555
|
-
const WildcardToolCallRender =
|
|
12207
|
+
const WildcardToolCallRender = require_chat.defineToolCallRenderer({
|
|
12556
12208
|
name: "*",
|
|
12557
12209
|
group: true,
|
|
12558
12210
|
render: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultToolCallRenderer, { ...adaptRendererProps(props) })
|
|
@@ -14169,7 +13821,7 @@ const usePredictStateSubscription = (agent) => {
|
|
|
14169
13821
|
};
|
|
14170
13822
|
function CopilotListenersAgentSubscription() {
|
|
14171
13823
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
14172
|
-
const configAgentId =
|
|
13824
|
+
const configAgentId = require_chat.useCopilotChatConfiguration()?.agentId;
|
|
14173
13825
|
const { agent } = useAgent({ agentId: (0, react.useMemo)(() => {
|
|
14174
13826
|
const requested = configAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
14175
13827
|
const registered = copilotkit.agents ?? {};
|
|
@@ -14681,7 +14333,7 @@ function CopilotKitInternal(cpkProps) {
|
|
|
14681
14333
|
setInternalErrorHandler,
|
|
14682
14334
|
removeInternalErrorHandler
|
|
14683
14335
|
]);
|
|
14684
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
14336
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_chat.CopilotChatConfigurationProvider, {
|
|
14685
14337
|
agentId: props.agent ?? "default",
|
|
14686
14338
|
threadId,
|
|
14687
14339
|
hasExplicitThreadId: isThreadIdExplicit,
|
|
@@ -15242,4 +14894,4 @@ Object.defineProperty(exports, 'useToast', {
|
|
|
15242
14894
|
return useToast;
|
|
15243
14895
|
}
|
|
15244
14896
|
});
|
|
15245
|
-
//# sourceMappingURL=copilotkit-
|
|
14897
|
+
//# sourceMappingURL=copilotkit-Ca0IcTZU.cjs.map
|