@copilotkit/react-core 1.85.0 → 1.87.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-Dn4PbHJV.d.mts → copilotkit-BNPEXnEE.d.mts} +11 -6
- package/dist/{copilotkit-Dn4PbHJV.d.mts.map → copilotkit-BNPEXnEE.d.mts.map} +1 -1
- package/dist/{copilotkit-CuTAoQF2.d.cts → copilotkit-Bop-sY6y.d.cts} +9 -4
- package/dist/{copilotkit-CuTAoQF2.d.cts.map → copilotkit-Bop-sY6y.d.cts.map} +1 -1
- package/dist/{copilotkit-BpKHgURs.cjs → copilotkit-CZ9tI_J1.cjs} +203 -452
- package/dist/copilotkit-CZ9tI_J1.cjs.map +1 -0
- package/dist/{copilotkit-D6mTCuNU.mjs → copilotkit-ChqQa52S.mjs} +131 -380
- package/dist/{copilotkit-BpKHgURs.cjs.map → copilotkit-ChqQa52S.mjs.map} +1 -1
- package/dist/hooks-CEFWIeKR.d.cts +89 -0
- package/dist/hooks-CEFWIeKR.d.cts.map +1 -0
- package/dist/hooks-DFgYRjj3.d.mts +89 -0
- package/dist/hooks-DFgYRjj3.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 +769 -165
- 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 +378 -457
- package/dist/v2/generative-ui.d.cts.map +1 -1
- package/dist/v2/generative-ui.d.mts +378 -457
- 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 +769 -165
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +14 -10
- package/dist/MarkdownSurfaces-3cGU5_0H.cjs.map +0 -1
- package/dist/MarkdownSurfaces-D-W4f9Dy.mjs.map +0 -1
- package/dist/copilotkit-D6mTCuNU.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.87.0";
|
|
1330
1330
|
|
|
1331
1331
|
//#endregion
|
|
1332
1332
|
//#region src/v2/components/CopilotKitInspector.tsx
|
|
@@ -2554,7 +2554,7 @@ function describeOperationKinds(operations) {
|
|
|
2554
2554
|
function warnAboutUnpaintedSurfaces(grouped) {
|
|
2555
2555
|
for (const [surfaceId, operations] of grouped) {
|
|
2556
2556
|
if (surfaceHasRenderableContent(operations)) continue;
|
|
2557
|
-
const cause = operations.
|
|
2557
|
+
const cause = operations.flatMap(getOperationComponents).length === 0 ? "no updateComponents operation arrived, so the surface was never given anything to draw" : "its components address their values by \"path\" and no updateDataModel carried a non-empty value, so every bound component drew empty";
|
|
2558
2558
|
console.warn(`[CopilotKit] A2UI surface "${surfaceId}" received operations and never painted after ${String(PAINT_FALLBACK_MS)}ms: ${cause}. Operations received: ${describeOperationKinds(operations)}. The payload was accepted, so check what the agent sent rather than the client wiring. This warning is development-only.`);
|
|
2559
2559
|
}
|
|
2560
2560
|
}
|
|
@@ -2567,13 +2567,9 @@ function warnAboutUnpaintedSurfaces(grouped) {
|
|
|
2567
2567
|
*/
|
|
2568
2568
|
function describeComponentIds(operations) {
|
|
2569
2569
|
const ids = [];
|
|
2570
|
-
for (const operation of operations) {
|
|
2571
|
-
const
|
|
2572
|
-
if (!
|
|
2573
|
-
for (const component of components) {
|
|
2574
|
-
const id = component?.id;
|
|
2575
|
-
if (typeof id === "string" && !ids.includes(id)) ids.push(id);
|
|
2576
|
-
}
|
|
2570
|
+
for (const operation of operations) for (const component of getOperationComponents(operation)) {
|
|
2571
|
+
const id = component?.id;
|
|
2572
|
+
if (typeof id === "string" && !ids.includes(id)) ids.push(id);
|
|
2577
2573
|
}
|
|
2578
2574
|
return ids.length === 0 ? "none" : ids.map((id) => `"${id}"`).join(", ");
|
|
2579
2575
|
}
|
|
@@ -2600,9 +2596,9 @@ function describeComponentIds(operations) {
|
|
|
2600
2596
|
*/
|
|
2601
2597
|
function warnAboutUnresolvedRoot(surfaceId, operations, surface) {
|
|
2602
2598
|
if (surface?.componentsModel?.get?.(_copilotkit_a2ui_renderer.ROOT_COMPONENT_ID)) return;
|
|
2603
|
-
const
|
|
2604
|
-
if (
|
|
2605
|
-
const cause =
|
|
2599
|
+
const components = operations.flatMap(getOperationComponents);
|
|
2600
|
+
if (components.length === 0) return;
|
|
2601
|
+
const cause = components.some((c) => c?.id === _copilotkit_a2ui_renderer.ROOT_COMPONENT_ID) ? `a component with id "${_copilotkit_a2ui_renderer.ROOT_COMPONENT_ID}" WAS sent, so the components did not reach the surface's model — check for an A2UI render error above, or a catalog that took none of them` : `the components it received are named ${describeComponentIds(operations)}, and none of them is "${_copilotkit_a2ui_renderer.ROOT_COMPONENT_ID}" — rename the entry-point component to "${_copilotkit_a2ui_renderer.ROOT_COMPONENT_ID}", and make every other component reachable from it through child/children`;
|
|
2606
2602
|
console.warn(`[CopilotKit] A2UI surface "${surfaceId}" has no "${_copilotkit_a2ui_renderer.ROOT_COMPONENT_ID}" component ${String(PAINT_FALLBACK_MS)}ms after its last operations were processed, so it is showing the placeholder for a component that has not arrived yet and will keep showing it: ${cause}. Operations received: ${describeOperationKinds(operations)}. This warning is development-only.`);
|
|
2607
2603
|
}
|
|
2608
2604
|
function createA2UIMessageRenderer(options) {
|
|
@@ -2768,7 +2764,10 @@ function ReactSurfaceHost({ surfaceId, operations, theme, agent, copilotkit, cat
|
|
|
2768
2764
|
surfaceId,
|
|
2769
2765
|
operations,
|
|
2770
2766
|
onReady
|
|
2771
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(A2UISurfaceOrError, {
|
|
2767
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(A2UISurfaceOrError, {
|
|
2768
|
+
surfaceId,
|
|
2769
|
+
onReady
|
|
2770
|
+
})]
|
|
2772
2771
|
})
|
|
2773
2772
|
});
|
|
2774
2773
|
}
|
|
@@ -2776,15 +2775,60 @@ function ReactSurfaceHost({ surfaceId, operations, theme, agent, copilotkit, cat
|
|
|
2776
2775
|
* Renders the A2UI surface, or an error message if processing failed.
|
|
2777
2776
|
* Must be a child of A2UIProvider to access the error state.
|
|
2778
2777
|
*/
|
|
2779
|
-
function A2UISurfaceOrError({ surfaceId }) {
|
|
2778
|
+
function A2UISurfaceOrError({ surfaceId, onReady }) {
|
|
2780
2779
|
const error = (0, _copilotkit_a2ui_renderer.useA2UIError)();
|
|
2781
|
-
|
|
2780
|
+
(0, react.useEffect)(() => {
|
|
2781
|
+
if (error) onReady?.();
|
|
2782
|
+
}, [error, onReady]);
|
|
2783
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [error && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2784
|
+
role: "alert",
|
|
2782
2785
|
className: "cpk:rounded-lg cpk:border cpk:border-red-200 cpk:bg-red-50 cpk:p-3 cpk:text-sm cpk:text-red-700",
|
|
2783
2786
|
children: ["A2UI render error: ", error]
|
|
2784
|
-
})
|
|
2785
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_a2ui_renderer.A2UIRenderer, {
|
|
2787
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_a2ui_renderer.A2UIRenderer, {
|
|
2786
2788
|
surfaceId,
|
|
2787
2789
|
className: "cpk:flex cpk:flex-1"
|
|
2790
|
+
})] });
|
|
2791
|
+
}
|
|
2792
|
+
/**
|
|
2793
|
+
* Full activity snapshots repeat creation. Native 1.0 can carry the current
|
|
2794
|
+
* components and data inline there, so replay changed initialization data and
|
|
2795
|
+
* components as updates for an existing surface. Compare against the previous
|
|
2796
|
+
* wire snapshot, rather than the SDK's mutable data model, to retain local edits.
|
|
2797
|
+
* Retain invalid or version-changing creates for the
|
|
2798
|
+
* provider/SDK to reject, instead of sanitizing them while replaying.
|
|
2799
|
+
*/
|
|
2800
|
+
function replaySnapshotOperations(operations, existing, previousOperations) {
|
|
2801
|
+
if (!existing) return operations;
|
|
2802
|
+
let nativeSurfaceDeleted = false;
|
|
2803
|
+
return operations.flatMap((operation) => {
|
|
2804
|
+
if (operation?.version === "1.0" && operation.deleteSurface?.surfaceId === existing.id) nativeSurfaceDeleted = true;
|
|
2805
|
+
if (nativeSurfaceDeleted) return [operation];
|
|
2806
|
+
if (!operation?.createSurface) return [operation];
|
|
2807
|
+
const version = String(operation.version ?? "v0.9").replace(/^v/, "");
|
|
2808
|
+
if (version !== String(existing.protocolVersion).replace(/^v/, "")) return [operation];
|
|
2809
|
+
if (version === "0.9") return [];
|
|
2810
|
+
if (operation.version !== "1.0") return [operation];
|
|
2811
|
+
const validation = _copilotkit_a2ui_renderer.CreateSurfaceMessageSchemaV1.safeParse(operation);
|
|
2812
|
+
if (!validation.success) return [operation];
|
|
2813
|
+
const create = validation.data.createSurface;
|
|
2814
|
+
if (create.catalogId !== void 0 && create.catalogId !== existing.catalog?.id) return [operation];
|
|
2815
|
+
const updates = [];
|
|
2816
|
+
const previousCreate = previousOperations.find((previous) => previous?.version === "1.0" && previous.createSurface?.surfaceId === create.surfaceId)?.createSurface;
|
|
2817
|
+
if (Object.hasOwn(create, "dataModel") && (!previousCreate || !Object.hasOwn(previousCreate, "dataModel") || JSON.stringify(create.dataModel) !== JSON.stringify(previousCreate.dataModel))) updates.push({
|
|
2818
|
+
version: "1.0",
|
|
2819
|
+
updateDataModel: {
|
|
2820
|
+
surfaceId: create.surfaceId,
|
|
2821
|
+
value: create.dataModel
|
|
2822
|
+
}
|
|
2823
|
+
});
|
|
2824
|
+
if (Object.hasOwn(create, "components")) updates.push({
|
|
2825
|
+
version: "1.0",
|
|
2826
|
+
updateComponents: {
|
|
2827
|
+
surfaceId: create.surfaceId,
|
|
2828
|
+
components: create.components
|
|
2829
|
+
}
|
|
2830
|
+
});
|
|
2831
|
+
return updates;
|
|
2788
2832
|
});
|
|
2789
2833
|
}
|
|
2790
2834
|
/**
|
|
@@ -2797,10 +2841,11 @@ function SurfaceMessageProcessor({ surfaceId, operations, onReady }) {
|
|
|
2797
2841
|
(0, react.useEffect)(() => {
|
|
2798
2842
|
const hash = JSON.stringify(operations);
|
|
2799
2843
|
if (hash === lastHashRef.current) return;
|
|
2844
|
+
const previousOperations = lastHashRef.current ? JSON.parse(lastHashRef.current) : [];
|
|
2800
2845
|
lastHashRef.current = hash;
|
|
2801
|
-
const ops = getSurface(surfaceId)
|
|
2846
|
+
const ops = replaySnapshotOperations(operations, getSurface(surfaceId), previousOperations);
|
|
2802
2847
|
processMessages(ops.map(stripRoutingSurfaceId));
|
|
2803
|
-
if (onReady && surfaceHasRenderableContent(operations)) onReady();
|
|
2848
|
+
if (onReady && getSurface(surfaceId)?.componentsModel.get(_copilotkit_a2ui_renderer.ROOT_COMPONENT_ID) && surfaceHasRenderableContent(operations)) onReady();
|
|
2804
2849
|
if (!IS_DEVELOPMENT) return;
|
|
2805
2850
|
if (!getSurface(surfaceId)) {
|
|
2806
2851
|
const missingSurfaceCheck = setTimeout(() => {
|
|
@@ -2830,15 +2875,26 @@ function SurfaceMessageProcessor({ surfaceId, operations, onReady }) {
|
|
|
2830
2875
|
* arrival rather than a fixed delay. (OSS-162)
|
|
2831
2876
|
*/
|
|
2832
2877
|
function surfaceHasRenderableContent(operations) {
|
|
2833
|
-
const
|
|
2834
|
-
if (!
|
|
2835
|
-
|
|
2878
|
+
const components = operations.flatMap(getOperationComponents);
|
|
2879
|
+
if (!components.length) return false;
|
|
2880
|
+
const serialized = JSON.stringify(components);
|
|
2881
|
+
if (!(serialized.includes("\"path\"") || serialized.includes("\"@path\""))) return true;
|
|
2836
2882
|
return operations.some((o) => {
|
|
2837
|
-
const v = o?.updateDataModel?.value;
|
|
2883
|
+
const v = o?.updateDataModel?.value ?? (o?.version === "1.0" ? o?.createSurface?.dataModel : void 0);
|
|
2884
|
+
if (typeof v === "string" || typeof v === "number" || typeof v === "boolean") {
|
|
2885
|
+
const path = o?.updateDataModel?.path ?? "/";
|
|
2886
|
+
const key = o?.version === "1.0" ? "@path" : "path";
|
|
2887
|
+
return v !== "" && serialized.includes(JSON.stringify({ [key]: path }));
|
|
2888
|
+
}
|
|
2838
2889
|
if (!v || typeof v !== "object") return false;
|
|
2839
2890
|
return Object.values(v).some((x) => Array.isArray(x) ? x.length > 0 : x !== null && x !== void 0 && x !== "");
|
|
2840
2891
|
});
|
|
2841
2892
|
}
|
|
2893
|
+
/** Component definitions can arrive in an update or a native inline create. */
|
|
2894
|
+
function getOperationComponents(operation) {
|
|
2895
|
+
const components = operation?.updateComponents?.components ?? (operation?.version === "1.0" ? operation?.createSurface?.components : void 0);
|
|
2896
|
+
return Array.isArray(components) ? components : [];
|
|
2897
|
+
}
|
|
2842
2898
|
const V0_9_ACTION_KEYS = [
|
|
2843
2899
|
"createSurface",
|
|
2844
2900
|
"updateComponents",
|
|
@@ -2861,7 +2917,7 @@ const V0_9_ACTION_KEYS = [
|
|
|
2861
2917
|
* message, otherwise the operation unchanged.
|
|
2862
2918
|
*/
|
|
2863
2919
|
function stripRoutingSurfaceId(operation) {
|
|
2864
|
-
if (!operation || typeof operation !== "object" || !("surfaceId" in operation) || !V0_9_ACTION_KEYS.some((key) => key in operation)) return operation;
|
|
2920
|
+
if (!operation || typeof operation !== "object" || !(operation.version === void 0 || operation.version === "v0.9") || !("surfaceId" in operation) || !V0_9_ACTION_KEYS.some((key) => key in operation)) return operation;
|
|
2865
2921
|
const { surfaceId: _routingId, ...message } = operation;
|
|
2866
2922
|
return message;
|
|
2867
2923
|
}
|
|
@@ -2910,7 +2966,7 @@ const RENDER_A2UI_TOOL_NAME = "render_a2ui";
|
|
|
2910
2966
|
function A2UIBuiltInToolCallRenderer() {
|
|
2911
2967
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
2912
2968
|
(0, react.useEffect)(() => {
|
|
2913
|
-
const renderer =
|
|
2969
|
+
const renderer = require_chat.defineToolCallRenderer({
|
|
2914
2970
|
name: RENDER_A2UI_TOOL_NAME,
|
|
2915
2971
|
args: zod.z.any(),
|
|
2916
2972
|
render: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, {})
|
|
@@ -2921,6 +2977,47 @@ function A2UIBuiltInToolCallRenderer() {
|
|
|
2921
2977
|
return null;
|
|
2922
2978
|
}
|
|
2923
2979
|
|
|
2980
|
+
//#endregion
|
|
2981
|
+
//#region src/v2/a2ui/generation-guidelines.ts
|
|
2982
|
+
/** Native 1.0 tool guidance. Structural template paths retain their own syntax. */
|
|
2983
|
+
const A2UI_V1_GENERATION_GUIDELINES = `Generate A2UI 1.0 JSON.
|
|
2984
|
+
|
|
2985
|
+
Call render_a2ui with a unique surfaceId, the required components array, and optional
|
|
2986
|
+
root data object. Use only component names, properties and functions declared in
|
|
2987
|
+
the supplied catalog. Match its protocolVersion, catalogId and schemas.
|
|
2988
|
+
|
|
2989
|
+
Every component has a unique id and a component type. Exactly one component has
|
|
2990
|
+
id="root", the surface entry point. All other components must be reachable from
|
|
2991
|
+
root through child/children; never reference the same component as its own child,
|
|
2992
|
+
and never create a cycle.
|
|
2993
|
+
|
|
2994
|
+
Use literal values unless the property's catalog schema permits a dynamic value.
|
|
2995
|
+
Native value binding uses { "@path": "/form/name" }. A plain property schema does
|
|
2996
|
+
not accept a binding object. Pre-fill editable values via the data argument:
|
|
2997
|
+
"data": { "form": { "name": "Alice" } }
|
|
2998
|
+
"value": { "@path": "/form/name" }
|
|
2999
|
+
|
|
3000
|
+
Native function expressions use { "@call": "functionName", "args": { ... } },
|
|
3001
|
+
with only the parameters declared by the catalog; do not add returnType.
|
|
3002
|
+
|
|
3003
|
+
REPEATING CONTENT uses a structural children format, distinct from value binding:
|
|
3004
|
+
children: { componentId: "card-id", path: "/items" }
|
|
3005
|
+
The structural key remains path. Initialize its data array with real items before
|
|
3006
|
+
expecting a visible list. Components inside a template use relative value bindings:
|
|
3007
|
+
"text": { "@path": "name" }
|
|
3008
|
+
An absolute binding such as { "@path": "/name" } reads from the root instead.
|
|
3009
|
+
|
|
3010
|
+
Buttons send nested event actions, with bound context to capture edited values:
|
|
3011
|
+
"action": { "event": { "name": "submit", "context": { "name": { "@path": "/form/name" } } } }
|
|
3012
|
+
Local function actions use { "functionCall": { "@call": "functionName", "args": { ... } } }.
|
|
3013
|
+
Do not rename literal objects' path keys: only @path denotes native value binding.
|
|
3014
|
+
Keep an existing surface's protocol and catalog when updating it; create a new
|
|
3015
|
+
surface to use a different protocol.`;
|
|
3016
|
+
/** Preserve legacy prompt text exactly unless the selected catalog opts into 1.0. */
|
|
3017
|
+
function a2uiGenerationGuidelines(protocolVersion) {
|
|
3018
|
+
return protocolVersion === "1.0" ? A2UI_V1_GENERATION_GUIDELINES : _copilotkit_shared.A2UI_DEFAULT_GENERATION_GUIDELINES;
|
|
3019
|
+
}
|
|
3020
|
+
|
|
2924
3021
|
//#endregion
|
|
2925
3022
|
//#region src/v2/a2ui/A2UICatalogContext.tsx
|
|
2926
3023
|
/**
|
|
@@ -2940,6 +3037,7 @@ function A2UICatalogContext({ catalog, includeSchema }) {
|
|
|
2940
3037
|
const capabilitiesValue = (0, react.useMemo)(() => (0, _copilotkit_a2ui_renderer.buildCatalogContextValue)(catalog, { includeSchema: includeSchema !== false }), [catalog, includeSchema]);
|
|
2941
3038
|
const schemaValue = (0, react.useMemo)(() => includeSchema !== false ? JSON.stringify((0, _copilotkit_a2ui_renderer.extractCatalogComponentSchemas)(catalog)) : null, [catalog, includeSchema]);
|
|
2942
3039
|
const a2uiAgentsKey = copilotkit?.a2uiAgents?.join(",");
|
|
3040
|
+
const generationGuidelines = a2uiGenerationGuidelines(catalog?.protocolVersion);
|
|
2943
3041
|
(0, react.useLayoutEffect)(() => {
|
|
2944
3042
|
if (!copilotkit) return;
|
|
2945
3043
|
const agentIds = copilotkit.a2uiAgents;
|
|
@@ -2958,7 +3056,7 @@ function A2UICatalogContext({ catalog, includeSchema }) {
|
|
|
2958
3056
|
}));
|
|
2959
3057
|
ids.push(copilotkit.addContext({
|
|
2960
3058
|
description: "A2UI generation guidelines — protocol rules, tool arguments, path rules, data model format, and form/two-way-binding instructions.",
|
|
2961
|
-
value:
|
|
3059
|
+
value: generationGuidelines,
|
|
2962
3060
|
...scope
|
|
2963
3061
|
}));
|
|
2964
3062
|
ids.push(copilotkit.addContext({
|
|
@@ -2974,359 +3072,12 @@ function A2UICatalogContext({ catalog, includeSchema }) {
|
|
|
2974
3072
|
copilotkit,
|
|
2975
3073
|
capabilitiesValue,
|
|
2976
3074
|
schemaValue,
|
|
2977
|
-
a2uiAgentsKey
|
|
3075
|
+
a2uiAgentsKey,
|
|
3076
|
+
generationGuidelines
|
|
2978
3077
|
]);
|
|
2979
3078
|
return null;
|
|
2980
3079
|
}
|
|
2981
3080
|
|
|
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
3081
|
//#endregion
|
|
3331
3082
|
//#region src/v2/lib/react-core.ts
|
|
3332
3083
|
var CopilotKitCoreReact = class extends _copilotkit_core.CopilotKitCore {
|
|
@@ -3545,7 +3296,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3545
3296
|
loadingComponent: a2ui?.loadingComponent,
|
|
3546
3297
|
recovery: a2ui?.recovery
|
|
3547
3298
|
}));
|
|
3548
|
-
if (generativeUIActive) renderers.push(
|
|
3299
|
+
if (generativeUIActive) renderers.push(require_chat.createGenerativeUIActivityRenderer(), require_chat.createGenerativeUIFunctionCallActivityRenderer());
|
|
3549
3300
|
return renderers;
|
|
3550
3301
|
}, [
|
|
3551
3302
|
a2uiActive,
|
|
@@ -3717,7 +3468,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3717
3468
|
if (defaultThrottleMs !== void 0) copilotkitRef.current.setDefaultThrottleMs(defaultThrottleMs);
|
|
3718
3469
|
}
|
|
3719
3470
|
const copilotkit = copilotkitRef.current;
|
|
3720
|
-
const generativeUIRuntime = useGenerativeUIRoot(copilotkit, generativeUI);
|
|
3471
|
+
const generativeUIRuntime = require_use_generative_ui_root.useGenerativeUIRoot(copilotkit, generativeUI);
|
|
3721
3472
|
(0, react.useEffect)(() => {
|
|
3722
3473
|
if (!rawCatalog) return;
|
|
3723
3474
|
if (!(rawCatalog instanceof _copilotkit_a2ui_renderer.Catalog)) return;
|
|
@@ -3956,7 +3707,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3956
3707
|
value: licenseContextValue,
|
|
3957
3708
|
children: [
|
|
3958
3709
|
a2uiActive && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(A2UIBuiltInToolCallRenderer, {}),
|
|
3959
|
-
generativeUIActive && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
3710
|
+
generativeUIActive && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_chat.GenerativeUIToolCallRenderer, {}),
|
|
3960
3711
|
a2uiActive && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(A2UICatalogContext, {
|
|
3961
3712
|
catalog: filteredCatalog,
|
|
3962
3713
|
includeSchema: a2ui?.includeSchema
|
|
@@ -3965,7 +3716,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3965
3716
|
value: inspectorContextValue,
|
|
3966
3717
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_react_core_v2_context.CopilotKitAgentIdContext.Provider, {
|
|
3967
3718
|
value: agentId,
|
|
3968
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
3719
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_chat.GenerativeUIRuntimeContext.Provider, {
|
|
3969
3720
|
value: generativeUIRuntime,
|
|
3970
3721
|
children
|
|
3971
3722
|
})
|
|
@@ -3989,7 +3740,7 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3989
3740
|
//#region src/v2/hooks/use-render-custom-messages.tsx
|
|
3990
3741
|
function useRenderCustomMessages() {
|
|
3991
3742
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
3992
|
-
const config =
|
|
3743
|
+
const config = require_chat.useCopilotChatConfiguration();
|
|
3993
3744
|
if (!config) return null;
|
|
3994
3745
|
const { agentId, threadId } = config;
|
|
3995
3746
|
const customMessageRenderers = copilotkit.renderCustomMessages.filter((renderer) => renderer.agentId === void 0 || renderer.agentId === agentId).sort((a, b) => {
|
|
@@ -4034,7 +3785,7 @@ function useRenderCustomMessages() {
|
|
|
4034
3785
|
//#region src/v2/hooks/use-render-activity-message.tsx
|
|
4035
3786
|
function useRenderActivityMessage() {
|
|
4036
3787
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
4037
|
-
const agentId =
|
|
3788
|
+
const agentId = require_chat.useCopilotChatConfiguration()?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
4038
3789
|
const renderers = copilotkit.renderActivityMessages;
|
|
4039
3790
|
const findRenderer = (0, react.useCallback)((activityType) => {
|
|
4040
3791
|
if (!renderers.length) return null;
|
|
@@ -4392,7 +4143,7 @@ function useRenderTool(config, deps) {
|
|
|
4392
4143
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
4393
4144
|
const depsVersion = useDepsVersion(deps);
|
|
4394
4145
|
(0, react.useEffect)(() => {
|
|
4395
|
-
const renderer = config.name === "*" && !config.parameters ?
|
|
4146
|
+
const renderer = config.name === "*" && !config.parameters ? require_chat.defineToolCallRenderer({
|
|
4396
4147
|
name: "*",
|
|
4397
4148
|
render: (props) => config.render({
|
|
4398
4149
|
...props,
|
|
@@ -4400,7 +4151,7 @@ function useRenderTool(config, deps) {
|
|
|
4400
4151
|
}),
|
|
4401
4152
|
...config.agentId ? { agentId: config.agentId } : {},
|
|
4402
4153
|
group: config.group
|
|
4403
|
-
}) :
|
|
4154
|
+
}) : require_chat.defineToolCallRenderer({
|
|
4404
4155
|
name: config.name,
|
|
4405
4156
|
args: config.parameters,
|
|
4406
4157
|
render: (props) => {
|
|
@@ -5135,7 +4886,7 @@ function useAgent({ agentId, threadId, runtimeAgentId, updates, throttleMs } = {
|
|
|
5135
4886
|
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
4887
|
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
4888
|
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 =
|
|
4889
|
+
const chatConfig = require_chat.useCopilotChatConfiguration();
|
|
5139
4890
|
const providerAgentId = (0, _copilotkit_react_core_v2_context.useDefaultAgentId)();
|
|
5140
4891
|
const resolvedAgentId = agentId ?? chatConfig?.agentId ?? providerAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
5141
4892
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
@@ -5365,7 +5116,7 @@ function useAgentContext(context) {
|
|
|
5365
5116
|
//#region src/v2/hooks/use-suggestions.tsx
|
|
5366
5117
|
function useSuggestions({ agentId } = {}) {
|
|
5367
5118
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
5368
|
-
const config =
|
|
5119
|
+
const config = require_chat.useCopilotChatConfiguration();
|
|
5369
5120
|
const providerAgentId = (0, _copilotkit_react_core_v2_context.useDefaultAgentId)();
|
|
5370
5121
|
const resolvedAgentId = (0, react.useMemo)(() => agentId ?? config?.agentId ?? providerAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID, [
|
|
5371
5122
|
agentId,
|
|
@@ -5423,7 +5174,7 @@ function useSuggestions({ agentId } = {}) {
|
|
|
5423
5174
|
//#region src/v2/hooks/use-configure-suggestions.tsx
|
|
5424
5175
|
function useConfigureSuggestions(config, deps) {
|
|
5425
5176
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
5426
|
-
const chatConfig =
|
|
5177
|
+
const chatConfig = require_chat.useCopilotChatConfiguration();
|
|
5427
5178
|
const extraDeps = deps ?? [];
|
|
5428
5179
|
const resolvedConsumerAgentId = (0, react.useMemo)(() => chatConfig?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID, [chatConfig?.agentId]);
|
|
5429
5180
|
const rawConsumerAgentId = (0, react.useMemo)(() => config ? config.consumerAgentId : void 0, [config]);
|
|
@@ -6277,7 +6028,7 @@ function useLearnFromUserAction() {
|
|
|
6277
6028
|
* ```
|
|
6278
6029
|
*/
|
|
6279
6030
|
function useLearnFromUserActionInCurrentThread() {
|
|
6280
|
-
const config =
|
|
6031
|
+
const config = require_chat.useCopilotChatConfiguration();
|
|
6281
6032
|
const learnFromUserAction = useLearnFromUserAction();
|
|
6282
6033
|
return (0, react.useCallback)(async (input) => {
|
|
6283
6034
|
const threadId = config?.threadId;
|
|
@@ -6647,7 +6398,7 @@ function useLearningContainers({ threadId, learningContainers }) {
|
|
|
6647
6398
|
* Intelligence runtimes.
|
|
6648
6399
|
*/
|
|
6649
6400
|
function useLearningContainersInCurrentThread({ learningContainers }) {
|
|
6650
|
-
const threadId =
|
|
6401
|
+
const threadId = require_chat.useCopilotChatConfiguration()?.threadId;
|
|
6651
6402
|
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
6403
|
useLearningContainers({
|
|
6653
6404
|
threadId,
|
|
@@ -6999,7 +6750,7 @@ function InspectorKiteIcon({ className, ...props }) {
|
|
|
6999
6750
|
});
|
|
7000
6751
|
}
|
|
7001
6752
|
function CopilotChatInspectorButton({ title, className, onClick, onPointerDown, onPointerEnter, onPointerLeave, onKeyDown, disabled, ...props }) {
|
|
7002
|
-
const labels =
|
|
6753
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
7003
6754
|
const { isInspectorEnabled } = useCopilotKitInspector();
|
|
7004
6755
|
const hidden = useInspectorShortcutsHidden();
|
|
7005
6756
|
const [open, setOpen] = (0, react.useState)(false);
|
|
@@ -7470,7 +7221,7 @@ function WorkText({ messageId, children }) {
|
|
|
7470
7221
|
* assistant message subscribe to chat configuration changes.
|
|
7471
7222
|
*/
|
|
7472
7223
|
function BoundInspectorButton({ inspectorButton, messageId, openInspector, ...props }) {
|
|
7473
|
-
const chatConfiguration =
|
|
7224
|
+
const chatConfiguration = require_chat.useCopilotChatConfiguration();
|
|
7474
7225
|
return renderSlot(inspectorButton, CopilotChatAssistantMessage.InspectorButton, {
|
|
7475
7226
|
...props,
|
|
7476
7227
|
onClick: () => openInspector({
|
|
@@ -7515,7 +7266,7 @@ function nextFocusable(element, skip) {
|
|
|
7515
7266
|
* control after the thumb, and Enter or Escape inside it returns to the thumb.
|
|
7516
7267
|
*/
|
|
7517
7268
|
function FeedbackCommentPopover({ feedbackComment, comment, savedComment, rating, anchor, messageId }) {
|
|
7518
|
-
const labels =
|
|
7269
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
7519
7270
|
const contentRef = (0, react.useRef)(null);
|
|
7520
7271
|
const focusInside = () => contentRef.current?.contains(document.activeElement) ?? false;
|
|
7521
7272
|
const { focusRequest, takeFocusRequest, inputRef } = comment;
|
|
@@ -7774,7 +7525,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, o
|
|
|
7774
7525
|
}
|
|
7775
7526
|
(function(_CopilotChatAssistantMessage) {
|
|
7776
7527
|
_CopilotChatAssistantMessage.MarkdownRenderer = ({ content, className, messageId, ...props }) => {
|
|
7777
|
-
if (
|
|
7528
|
+
if (require_chat.useGenerativeUIRuntime()?.transport === "markdown" && messageId !== void 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownSurfaces.MarkdownSurfaces, {
|
|
7778
7529
|
content: content ?? "",
|
|
7779
7530
|
messageId,
|
|
7780
7531
|
className,
|
|
@@ -7815,7 +7566,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, o
|
|
|
7815
7566
|
});
|
|
7816
7567
|
};
|
|
7817
7568
|
_CopilotChatAssistantMessage.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
7818
|
-
const labels =
|
|
7569
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
7819
7570
|
const [copied, setCopied] = (0, react.useState)(false);
|
|
7820
7571
|
const timerRef = (0, react.useRef)(null);
|
|
7821
7572
|
(0, react.useEffect)(() => {
|
|
@@ -7846,7 +7597,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, o
|
|
|
7846
7597
|
};
|
|
7847
7598
|
_CopilotChatAssistantMessage.InspectorButton = CopilotChatInspectorButton;
|
|
7848
7599
|
_CopilotChatAssistantMessage.ThumbsUpButton = ({ title, ...props }) => {
|
|
7849
|
-
const labels =
|
|
7600
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
7850
7601
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
7851
7602
|
"data-testid": "copilot-thumbs-up-button",
|
|
7852
7603
|
title: title || labels.assistantMessageToolbarThumbsUpLabel,
|
|
@@ -7858,7 +7609,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, o
|
|
|
7858
7609
|
});
|
|
7859
7610
|
};
|
|
7860
7611
|
_CopilotChatAssistantMessage.ThumbsDownButton = ({ title, ...props }) => {
|
|
7861
|
-
const labels =
|
|
7612
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
7862
7613
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
7863
7614
|
"data-testid": "copilot-thumbs-down-button",
|
|
7864
7615
|
title: title || labels.assistantMessageToolbarThumbsDownLabel,
|
|
@@ -7870,7 +7621,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, o
|
|
|
7870
7621
|
});
|
|
7871
7622
|
};
|
|
7872
7623
|
_CopilotChatAssistantMessage.FeedbackComment = ({ value, savedComment, inputRef, onChange, onSubmit, onEditingChange, onLeave, className }) => {
|
|
7873
|
-
const labels =
|
|
7624
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
7874
7625
|
const changed = value.trim() !== savedComment;
|
|
7875
7626
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
|
|
7876
7627
|
"data-testid": "copilot-feedback-comment",
|
|
@@ -7905,7 +7656,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, o
|
|
|
7905
7656
|
});
|
|
7906
7657
|
};
|
|
7907
7658
|
_CopilotChatAssistantMessage.ReadAloudButton = ({ title, ...props }) => {
|
|
7908
|
-
const labels =
|
|
7659
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
7909
7660
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
7910
7661
|
"data-testid": "copilot-read-aloud-button",
|
|
7911
7662
|
title: title || labels.assistantMessageToolbarReadAloudLabel,
|
|
@@ -7914,7 +7665,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, o
|
|
|
7914
7665
|
});
|
|
7915
7666
|
};
|
|
7916
7667
|
_CopilotChatAssistantMessage.RegenerateButton = ({ title, ...props }) => {
|
|
7917
|
-
const labels =
|
|
7668
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
7918
7669
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
7919
7670
|
"data-testid": "copilot-regenerate-button",
|
|
7920
7671
|
title: title || labels.assistantMessageToolbarRegenerateLabel,
|
|
@@ -7942,7 +7693,7 @@ var CopilotChatAssistantMessage_default = CopilotChatAssistantMessage;
|
|
|
7942
7693
|
* `labels.attachmentPreviewCloseButtonLabel`.
|
|
7943
7694
|
*/
|
|
7944
7695
|
function Lightbox({ onClose, children }) {
|
|
7945
|
-
const labels =
|
|
7696
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
7946
7697
|
(0, react.useEffect)(() => {
|
|
7947
7698
|
const handleKey = (e) => {
|
|
7948
7699
|
if (e.key === "Escape") onClose();
|
|
@@ -8211,7 +7962,7 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
8211
7962
|
})] });
|
|
8212
7963
|
};
|
|
8213
7964
|
_CopilotChatUserMessage.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
8214
|
-
const labels =
|
|
7965
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
8215
7966
|
const [copied, setCopied] = (0, react.useState)(false);
|
|
8216
7967
|
const handleClick = async (event) => {
|
|
8217
7968
|
let success = false;
|
|
@@ -8231,7 +7982,7 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
8231
7982
|
});
|
|
8232
7983
|
};
|
|
8233
7984
|
_CopilotChatUserMessage.EditButton = ({ className, title, ...props }) => {
|
|
8234
|
-
const labels =
|
|
7985
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
8235
7986
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
8236
7987
|
"data-testid": "copilot-edit-button",
|
|
8237
7988
|
title: title || labels.userMessageToolbarEditMessageLabel,
|
|
@@ -8241,7 +7992,7 @@ function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfB
|
|
|
8241
7992
|
});
|
|
8242
7993
|
};
|
|
8243
7994
|
_CopilotChatUserMessage.BranchNavigation = ({ className, currentBranch = 0, numberOfBranches = 1, onSwitchToBranch, message, ...props }) => {
|
|
8244
|
-
const labels =
|
|
7995
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
8245
7996
|
if (!numberOfBranches || numberOfBranches <= 1 || !onSwitchToBranch) return null;
|
|
8246
7997
|
const canGoPrev = currentBranch > 0;
|
|
8247
7998
|
const canGoNext = currentBranch < numberOfBranches - 1;
|
|
@@ -8317,7 +8068,7 @@ function formatDuration$1(seconds) {
|
|
|
8317
8068
|
* `header` slot also receives `elapsedSeconds`.
|
|
8318
8069
|
*/
|
|
8319
8070
|
function CopilotChatReasoningMessage({ message, messages, isRunning, isLatest: isLatestProp, header, contentView, toggle, children, className, ...props }) {
|
|
8320
|
-
const labels =
|
|
8071
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
8321
8072
|
const isLatest = isLatestProp ?? messages?.[messages.length - 1]?.id === message.id;
|
|
8322
8073
|
const isStreaming = !!(isRunning && isLatest);
|
|
8323
8074
|
const hasContent = !!(message.content && message.content.length > 0);
|
|
@@ -8870,7 +8621,7 @@ const isToolCallLikeMessage = (m) => {
|
|
|
8870
8621
|
function IntelligenceIndicator(props) {
|
|
8871
8622
|
const { message, agentId, label = "CopilotKit Intelligence", intelligenceIndicator } = props;
|
|
8872
8623
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
8873
|
-
const config =
|
|
8624
|
+
const config = require_chat.useCopilotChatConfiguration();
|
|
8874
8625
|
const { agent } = useAgent({
|
|
8875
8626
|
agentId,
|
|
8876
8627
|
updates: [UseAgentUpdate.OnRunStatusChanged, UseAgentUpdate.OnMessagesChanged]
|
|
@@ -9126,7 +8877,7 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
9126
8877
|
const renderCustomMessage = useRenderCustomMessages();
|
|
9127
8878
|
const { renderActivityMessage } = useRenderActivityMessage();
|
|
9128
8879
|
const { copilotkit, showIntelligenceIndicator = true } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
9129
|
-
const config =
|
|
8880
|
+
const config = require_chat.useCopilotChatConfiguration();
|
|
9130
8881
|
const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
|
|
9131
8882
|
(0, react.useEffect)(() => {
|
|
9132
8883
|
if (!config?.agentId) return;
|
|
@@ -9773,7 +9524,7 @@ CopilotChatMessageView.Cursor = function Cursor({ className, ...props }) {
|
|
|
9773
9524
|
* button named by `labels.attachmentRemoveButtonLabel`.
|
|
9774
9525
|
*/
|
|
9775
9526
|
const CopilotChatAttachmentQueue = ({ attachments, onRemoveAttachment, className }) => {
|
|
9776
|
-
const labels =
|
|
9527
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
9777
9528
|
if (attachments.length === 0) return null;
|
|
9778
9529
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
9779
9530
|
"data-testid": "copilot-attachment-queue",
|
|
@@ -9850,7 +9601,7 @@ function AudioPreview({ attachment }) {
|
|
|
9850
9601
|
* lightbox.
|
|
9851
9602
|
*/
|
|
9852
9603
|
function VideoPreview({ attachment }) {
|
|
9853
|
-
const labels =
|
|
9604
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
9854
9605
|
const src = (0, _copilotkit_shared.getSourceUrl)(attachment.source);
|
|
9855
9606
|
const { thumbnailRef, vtName, open, openLightbox, closeLightbox } = useLightbox();
|
|
9856
9607
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
@@ -10155,7 +9906,7 @@ function DropOverlay() {
|
|
|
10155
9906
|
});
|
|
10156
9907
|
}
|
|
10157
9908
|
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 =
|
|
9909
|
+
const configuredThreadId = require_chat.useCopilotChatConfiguration()?.threadId;
|
|
10159
9910
|
const [fallbackThreadId, setFallbackThreadId] = (0, react.useState)(messages[0]?.id);
|
|
10160
9911
|
const previousMessageIds = (0, react.useRef)(/* @__PURE__ */ new Set());
|
|
10161
9912
|
(0, react.useEffect)(() => {
|
|
@@ -10601,7 +10352,7 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
10601
10352
|
});
|
|
10602
10353
|
};
|
|
10603
10354
|
_CopilotChatView.ScrollToBottomButton = ({ className, ...props }) => {
|
|
10604
|
-
const labels =
|
|
10355
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
10605
10356
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
10606
10357
|
"data-testid": "copilot-scroll-to-bottom",
|
|
10607
10358
|
variant: "outline",
|
|
@@ -10617,7 +10368,7 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
10617
10368
|
...props
|
|
10618
10369
|
});
|
|
10619
10370
|
_CopilotChatView.ConnectingIndicator = ({ className, ...props }) => {
|
|
10620
|
-
const labels =
|
|
10371
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
10621
10372
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
10622
10373
|
"data-testid": "copilot-connecting-indicator",
|
|
10623
10374
|
role: "status",
|
|
@@ -10633,7 +10384,7 @@ function CopilotChatView({ messageView, input, scrollView, suggestionView, welco
|
|
|
10633
10384
|
});
|
|
10634
10385
|
};
|
|
10635
10386
|
_CopilotChatView.WelcomeMessage = ({ className, ...props }) => {
|
|
10636
|
-
const labels =
|
|
10387
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
10637
10388
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
|
|
10638
10389
|
className: cn("cpk:text-xl cpk:sm:text-2xl cpk:font-medium cpk:text-foreground cpk:text-center", className),
|
|
10639
10390
|
...props,
|
|
@@ -10884,7 +10635,7 @@ function useInspectorThreadOverride(args) {
|
|
|
10884
10635
|
//#endregion
|
|
10885
10636
|
//#region src/v2/components/chat/CopilotChat.tsx
|
|
10886
10637
|
function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isModalDefaultOpen, attachments: attachmentsConfig, onError, throttleMs, generativeUISurface, ...props }) {
|
|
10887
|
-
const existingConfig =
|
|
10638
|
+
const existingConfig = require_chat.useCopilotChatConfiguration();
|
|
10888
10639
|
const inspector = useCopilotKitInspector();
|
|
10889
10640
|
const inspectorContextValue = (0, react.useMemo)(() => ({
|
|
10890
10641
|
...inspector,
|
|
@@ -11475,8 +11226,8 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
|
|
|
11475
11226
|
return () => clearTimeout(timer);
|
|
11476
11227
|
}
|
|
11477
11228
|
}, [transcriptionError]);
|
|
11478
|
-
const stableMessageView =
|
|
11479
|
-
const stableSuggestionView =
|
|
11229
|
+
const stableMessageView = require_chat.useShallowStableRef(typeof providedMessageView === "string" ? { className: providedMessageView } : providedMessageView);
|
|
11230
|
+
const stableSuggestionView = require_chat.useShallowStableRef(providedSuggestionView);
|
|
11480
11231
|
const handleAddFile = (0, react.useCallback)(() => {
|
|
11481
11232
|
setTimeout(() => {
|
|
11482
11233
|
fileInputRef.current?.click();
|
|
@@ -11537,7 +11288,7 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
|
|
|
11537
11288
|
isConnecting,
|
|
11538
11289
|
hasExplicitThreadId
|
|
11539
11290
|
});
|
|
11540
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
11291
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_chat.CopilotChatConfigurationProvider, {
|
|
11541
11292
|
agentId: resolvedAgentId,
|
|
11542
11293
|
threadId: resolvedThreadId,
|
|
11543
11294
|
hasExplicitThreadId,
|
|
@@ -11575,7 +11326,7 @@ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isMo
|
|
|
11575
11326
|
value: lastUserMessageState,
|
|
11576
11327
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitInspectorContextProvider, {
|
|
11577
11328
|
value: inspectorContextValue,
|
|
11578
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
11329
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_chat.GenerativeUIChatSlotContext.Provider, {
|
|
11579
11330
|
value: generativeUISurface,
|
|
11580
11331
|
children: RenderedChatView
|
|
11581
11332
|
})
|
|
@@ -11609,8 +11360,8 @@ const ICON_WRAPPER_BASE = "cpk:pointer-events-none cpk:absolute cpk:inset-0 cpk:
|
|
|
11609
11360
|
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
11361
|
const CopilotChatToggleButton = react.default.forwardRef(function CopilotChatToggleButton({ openIcon, closeIcon, className, ...buttonProps }, ref) {
|
|
11611
11362
|
const { onClick, type, disabled, ...restProps } = buttonProps;
|
|
11612
|
-
const configuration =
|
|
11613
|
-
const labels = configuration?.labels ??
|
|
11363
|
+
const configuration = require_chat.useCopilotChatConfiguration();
|
|
11364
|
+
const labels = configuration?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
11614
11365
|
const [fallbackOpen, setFallbackOpen] = (0, react.useState)(false);
|
|
11615
11366
|
const isOpen = configuration?.isModalOpen ?? fallbackOpen;
|
|
11616
11367
|
const setModalOpen = configuration?.setModalOpen ?? setFallbackOpen;
|
|
@@ -11726,8 +11477,8 @@ function useIsMobileViewport() {
|
|
|
11726
11477
|
return isMobile;
|
|
11727
11478
|
}
|
|
11728
11479
|
function CopilotModalHeader({ title, titleContent, closeButton, drawerLauncher, children, className, ...rest }) {
|
|
11729
|
-
const configuration =
|
|
11730
|
-
const fallbackTitle = configuration?.labels.modalHeaderTitle ??
|
|
11480
|
+
const configuration = require_chat.useCopilotChatConfiguration();
|
|
11481
|
+
const fallbackTitle = configuration?.labels.modalHeaderTitle ?? require_chat.CopilotChatDefaultLabels.modalHeaderTitle;
|
|
11731
11482
|
const resolvedTitle = title ?? fallbackTitle;
|
|
11732
11483
|
const isMobile = useIsMobileViewport();
|
|
11733
11484
|
const drawerRegistered = (configuration?.drawerRegistered ?? false) && isMobile;
|
|
@@ -11783,7 +11534,7 @@ CopilotModalHeader.displayName = "CopilotModalHeader";
|
|
|
11783
11534
|
children
|
|
11784
11535
|
});
|
|
11785
11536
|
_CopilotModalHeader.CloseButton = ({ className, ...props }) => {
|
|
11786
|
-
const labels =
|
|
11537
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
11787
11538
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
11788
11539
|
type: "button",
|
|
11789
11540
|
"data-testid": "copilot-close-button",
|
|
@@ -11797,7 +11548,7 @@ CopilotModalHeader.displayName = "CopilotModalHeader";
|
|
|
11797
11548
|
});
|
|
11798
11549
|
};
|
|
11799
11550
|
_CopilotModalHeader.DrawerLauncher = ({ className, ...props }) => {
|
|
11800
|
-
const labels =
|
|
11551
|
+
const labels = require_chat.useCopilotChatConfiguration()?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
11801
11552
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
11802
11553
|
type: "button",
|
|
11803
11554
|
"data-testid": "copilot-threads-drawer-launcher",
|
|
@@ -11833,9 +11584,9 @@ function CopilotSidebarView({ header, toggleButton, width, defaultOpen = true, p
|
|
|
11833
11584
|
position,
|
|
11834
11585
|
...props
|
|
11835
11586
|
});
|
|
11836
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
11587
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_chat.CopilotChatConfigurationProvider, {
|
|
11837
11588
|
isModalDefaultOpen: open ?? defaultOpen,
|
|
11838
|
-
children: hasOpenControl ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
11589
|
+
children: hasOpenControl ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_chat.ControlledModalOpenScope, {
|
|
11839
11590
|
open,
|
|
11840
11591
|
onOpenChange,
|
|
11841
11592
|
children: internal
|
|
@@ -11843,7 +11594,7 @@ function CopilotSidebarView({ header, toggleButton, width, defaultOpen = true, p
|
|
|
11843
11594
|
});
|
|
11844
11595
|
}
|
|
11845
11596
|
function CopilotSidebarViewInternal({ header, toggleButton, width, position = "right", ...props }) {
|
|
11846
|
-
const configuration =
|
|
11597
|
+
const configuration = require_chat.useCopilotChatConfiguration();
|
|
11847
11598
|
const isSidebarOpen = configuration?.isModalOpen ?? false;
|
|
11848
11599
|
const sidebarRef = (0, react.useRef)(null);
|
|
11849
11600
|
const [sidebarWidth, setSidebarWidth] = (0, react.useState)(width ?? DEFAULT_SIDEBAR_WIDTH);
|
|
@@ -11909,7 +11660,7 @@ function CopilotSidebarViewInternal({ header, toggleButton, width, position = "r
|
|
|
11909
11660
|
paddingBottom: "env(safe-area-inset-bottom)"
|
|
11910
11661
|
},
|
|
11911
11662
|
"aria-hidden": !isSidebarOpen,
|
|
11912
|
-
"aria-label": configuration?.labels.sidebarLabel ??
|
|
11663
|
+
"aria-label": configuration?.labels.sidebarLabel ?? require_chat.CopilotChatDefaultLabels.sidebarLabel,
|
|
11913
11664
|
role: "complementary",
|
|
11914
11665
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
11915
11666
|
className: "cpk:flex cpk:h-full cpk:w-full cpk:flex-col cpk:overflow-hidden",
|
|
@@ -11977,9 +11728,9 @@ function CopilotPopupView({ header, toggleButton, width, height, clickOutsideToC
|
|
|
11977
11728
|
className,
|
|
11978
11729
|
...restProps
|
|
11979
11730
|
});
|
|
11980
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
11731
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_chat.CopilotChatConfigurationProvider, {
|
|
11981
11732
|
isModalDefaultOpen: open ?? defaultOpen,
|
|
11982
|
-
children: hasOpenControl ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
11733
|
+
children: hasOpenControl ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_chat.ControlledModalOpenScope, {
|
|
11983
11734
|
open,
|
|
11984
11735
|
onOpenChange,
|
|
11985
11736
|
children: internal
|
|
@@ -11987,10 +11738,10 @@ function CopilotPopupView({ header, toggleButton, width, height, clickOutsideToC
|
|
|
11987
11738
|
});
|
|
11988
11739
|
}
|
|
11989
11740
|
function CopilotPopupViewInternal({ header, toggleButton, width, height, clickOutsideToClose, className, ...restProps }) {
|
|
11990
|
-
const configuration =
|
|
11741
|
+
const configuration = require_chat.useCopilotChatConfiguration();
|
|
11991
11742
|
const isPopupOpen = configuration?.isModalOpen ?? false;
|
|
11992
11743
|
const setModalOpen = configuration?.setModalOpen;
|
|
11993
|
-
const labels = configuration?.labels ??
|
|
11744
|
+
const labels = configuration?.labels ?? require_chat.CopilotChatDefaultLabels;
|
|
11994
11745
|
const containerRef = (0, react.useRef)(null);
|
|
11995
11746
|
const [isRendered, setIsRendered] = (0, react.useState)(isPopupOpen);
|
|
11996
11747
|
const [isAnimatingOut, setIsAnimatingOut] = (0, react.useState)(false);
|
|
@@ -12293,7 +12044,7 @@ function findChatInput(origin) {
|
|
|
12293
12044
|
* ```
|
|
12294
12045
|
*/
|
|
12295
12046
|
function CopilotThreadsDrawer({ agentId, onThreadSelect, onNewThread, onLicensed, licenseUrl, renderRow, label, recentLabel, collapsible, onCollapseChange, limit, "data-testid": dataTestId = "copilot-threads-drawer" }) {
|
|
12296
|
-
const configuration =
|
|
12047
|
+
const configuration = require_chat.useCopilotChatConfiguration();
|
|
12297
12048
|
const { status, checkFeature } = (0, _copilotkit_react_core_v2_context.useLicenseContext)();
|
|
12298
12049
|
const licensePresent = status === "valid" || status === "expiring";
|
|
12299
12050
|
const featureLicensed = checkFeature("threads");
|
|
@@ -12552,7 +12303,7 @@ CopilotThreadsDrawer.displayName = "CopilotThreadsDrawer";
|
|
|
12552
12303
|
* Catch-all (`"*"`) tool-call renderer that shows CopilotKit's default
|
|
12553
12304
|
* tool-call card for any tool without a dedicated renderer.
|
|
12554
12305
|
*/
|
|
12555
|
-
const WildcardToolCallRender =
|
|
12306
|
+
const WildcardToolCallRender = require_chat.defineToolCallRenderer({
|
|
12556
12307
|
name: "*",
|
|
12557
12308
|
group: true,
|
|
12558
12309
|
render: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultToolCallRenderer, { ...adaptRendererProps(props) })
|
|
@@ -14169,7 +13920,7 @@ const usePredictStateSubscription = (agent) => {
|
|
|
14169
13920
|
};
|
|
14170
13921
|
function CopilotListenersAgentSubscription() {
|
|
14171
13922
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
14172
|
-
const configAgentId =
|
|
13923
|
+
const configAgentId = require_chat.useCopilotChatConfiguration()?.agentId;
|
|
14173
13924
|
const { agent } = useAgent({ agentId: (0, react.useMemo)(() => {
|
|
14174
13925
|
const requested = configAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
14175
13926
|
const registered = copilotkit.agents ?? {};
|
|
@@ -14681,7 +14432,7 @@ function CopilotKitInternal(cpkProps) {
|
|
|
14681
14432
|
setInternalErrorHandler,
|
|
14682
14433
|
removeInternalErrorHandler
|
|
14683
14434
|
]);
|
|
14684
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
14435
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_chat.CopilotChatConfigurationProvider, {
|
|
14685
14436
|
agentId: props.agent ?? "default",
|
|
14686
14437
|
threadId,
|
|
14687
14438
|
hasExplicitThreadId: isThreadIdExplicit,
|
|
@@ -15242,4 +14993,4 @@ Object.defineProperty(exports, 'useToast', {
|
|
|
15242
14993
|
return useToast;
|
|
15243
14994
|
}
|
|
15244
14995
|
});
|
|
15245
|
-
//# sourceMappingURL=copilotkit-
|
|
14996
|
+
//# sourceMappingURL=copilotkit-CZ9tI_J1.cjs.map
|