@copilotkit/react-core 1.70.2 → 1.71.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/{copilotkit-DcFo270Y.cjs → copilotkit-B4Jb1QEy.cjs} +582 -168
- package/dist/copilotkit-B4Jb1QEy.cjs.map +1 -0
- package/dist/{copilotkit--Jyzm6hS.d.mts → copilotkit-ChjzWqn6.d.mts} +34 -9
- package/dist/copilotkit-ChjzWqn6.d.mts.map +1 -0
- package/dist/{copilotkit-BLYaCGcz.d.cts → copilotkit-DCIXZawe.d.cts} +34 -9
- package/dist/copilotkit-DCIXZawe.d.cts.map +1 -0
- package/dist/{copilotkit-B1jSvZeb.mjs → copilotkit-snbJkMqQ.mjs} +583 -169
- package/dist/copilotkit-snbJkMqQ.mjs.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +393 -153
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/context.cjs +4 -0
- package/dist/v2/context.cjs.map +1 -1
- package/dist/v2/context.d.cts +3 -1
- package/dist/v2/context.d.cts.map +1 -1
- package/dist/v2/context.d.mts +3 -1
- package/dist/v2/context.d.mts.map +1 -1
- package/dist/v2/context.mjs +3 -1
- package/dist/v2/context.mjs.map +1 -1
- package/dist/v2/headless.cjs +57 -6
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.d.cts +9 -4
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/headless.d.mts +9 -4
- package/dist/v2/headless.d.mts.map +1 -1
- package/dist/v2/headless.mjs +58 -7
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.css +1 -1
- package/dist/v2/index.d.cts +1 -1
- package/dist/v2/index.d.mts +1 -1
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +708 -292
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +7 -7
- package/skills/react-core/SKILL.md +1 -1
- package/skills/react-core/references/agent-access.md +69 -26
- package/skills/react-core/references/chat-components.md +22 -5
- package/dist/copilotkit--Jyzm6hS.d.mts.map +0 -1
- package/dist/copilotkit-B1jSvZeb.mjs.map +0 -1
- package/dist/copilotkit-BLYaCGcz.d.cts.map +0 -1
- package/dist/copilotkit-DcFo270Y.cjs.map +0 -1
|
@@ -32,6 +32,7 @@ let _ag_ui_client = require("@ag-ui/client");
|
|
|
32
32
|
let tailwind_merge = require("tailwind-merge");
|
|
33
33
|
let lucide_react = require("lucide-react");
|
|
34
34
|
let _copilotkit_shared = require("@copilotkit/shared");
|
|
35
|
+
let _copilotkit_react_core_v2_context = require("@copilotkit/react-core/v2/context");
|
|
35
36
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
36
37
|
let _radix_ui_react_slot = require("@radix-ui/react-slot");
|
|
37
38
|
let class_variance_authority = require("class-variance-authority");
|
|
@@ -41,7 +42,6 @@ _radix_ui_react_tooltip = __toESM(_radix_ui_react_tooltip);
|
|
|
41
42
|
let _radix_ui_react_dropdown_menu = require("@radix-ui/react-dropdown-menu");
|
|
42
43
|
_radix_ui_react_dropdown_menu = __toESM(_radix_ui_react_dropdown_menu);
|
|
43
44
|
let streamdown = require("streamdown");
|
|
44
|
-
let _copilotkit_react_core_v2_context = require("@copilotkit/react-core/v2/context");
|
|
45
45
|
let zod = require("zod");
|
|
46
46
|
let _copilotkit_a2ui_renderer = require("@copilotkit/a2ui-renderer");
|
|
47
47
|
let zod_to_json_schema = require("zod-to-json-schema");
|
|
@@ -106,7 +106,12 @@ const CopilotChatDefaultLabels = {
|
|
|
106
106
|
assistantMessageToolbarCopyCodeCopiedLabel: "Copied",
|
|
107
107
|
assistantMessageToolbarCopyMessageLabel: "Copy",
|
|
108
108
|
assistantMessageToolbarInspectorLabel: "View in Inspector",
|
|
109
|
-
|
|
109
|
+
assistantMessageToolbarInspectorDescription: "Open this message in the Inspector",
|
|
110
|
+
assistantMessageToolbarInspectorLocalOnlyLabel: "Local only",
|
|
111
|
+
assistantMessageToolbarInspectorLocalOnlyDescription: "Only visible on localhost or loopback hosts in development. Never shown in production.",
|
|
112
|
+
assistantMessageToolbarInspectorTitle: "CopilotKit Inspector",
|
|
113
|
+
assistantMessageToolbarInspectorHideLabel: "Hide this icon",
|
|
114
|
+
assistantMessageToolbarInspectorHideDescription: "Until you reload this page",
|
|
110
115
|
assistantMessageToolbarThumbsUpLabel: "Good response",
|
|
111
116
|
assistantMessageToolbarThumbsDownLabel: "Bad response",
|
|
112
117
|
assistantMessageToolbarReadAloudLabel: "Read aloud",
|
|
@@ -147,7 +152,8 @@ const CopilotChatConfigurationProvider = ({ children, labels, agentId, threadId,
|
|
|
147
152
|
...parentConfig?.labels,
|
|
148
153
|
...stableLabels
|
|
149
154
|
}), [stableLabels, parentConfig?.labels]);
|
|
150
|
-
const
|
|
155
|
+
const providerAgentId = (0, _copilotkit_react_core_v2_context.useDefaultAgentId)();
|
|
156
|
+
const resolvedAgentId = agentId ?? parentConfig?.agentId ?? providerAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
151
157
|
const threadIdPropIsAuthoritative = threadId !== void 0 && hasExplicitThreadId !== false;
|
|
152
158
|
const isThreadIdControlled = threadIdPropIsAuthoritative;
|
|
153
159
|
const [activeThreadOverride, setActiveThreadOverride] = (0, react.useState)(null);
|
|
@@ -357,9 +363,9 @@ ControlledModalOpenScope.displayName = "ControlledModalOpenScope";
|
|
|
357
363
|
|
|
358
364
|
//#endregion
|
|
359
365
|
//#region src/v2/lib/utils.ts
|
|
360
|
-
const twMerge$
|
|
366
|
+
const twMerge$10 = (0, tailwind_merge.extendTailwindMerge)({ prefix: "cpk" });
|
|
361
367
|
function cn(...inputs) {
|
|
362
|
-
return twMerge$
|
|
368
|
+
return twMerge$10((0, clsx.clsx)(inputs));
|
|
363
369
|
}
|
|
364
370
|
|
|
365
371
|
//#endregion
|
|
@@ -504,6 +510,14 @@ function DropdownMenuItem({ className, inset, variant = "default", ...props }) {
|
|
|
504
510
|
...props
|
|
505
511
|
});
|
|
506
512
|
}
|
|
513
|
+
function DropdownMenuLabel({ className, inset, ...props }) {
|
|
514
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.Label, {
|
|
515
|
+
"data-slot": "dropdown-menu-label",
|
|
516
|
+
"data-inset": inset,
|
|
517
|
+
className: cn("cpk:px-2 cpk:py-1.5 cpk:text-sm cpk:font-medium cpk:data-[inset]:pl-8", className),
|
|
518
|
+
...props
|
|
519
|
+
});
|
|
520
|
+
}
|
|
507
521
|
function DropdownMenuSeparator({ className, ...props }) {
|
|
508
522
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_dropdown_menu.Separator, {
|
|
509
523
|
"data-slot": "dropdown-menu-separator",
|
|
@@ -1549,6 +1563,29 @@ const ToolCallRenderer = react.default.memo(function ToolCallRenderer({ toolCall
|
|
|
1549
1563
|
if (prevProps.RenderComponent !== nextProps.RenderComponent) return false;
|
|
1550
1564
|
return true;
|
|
1551
1565
|
});
|
|
1566
|
+
const IS_DEVELOPMENT$1 = process.env.NODE_ENV !== "production";
|
|
1567
|
+
/**
|
|
1568
|
+
* Reports tool calls that resolved to no renderer.
|
|
1569
|
+
*
|
|
1570
|
+
* A tool call with no renderer paints an empty message container and says
|
|
1571
|
+
* nothing else, so the only signal a developer gets today is a blank space in
|
|
1572
|
+
* the chat. This names the call and the renderers that *are* registered, which
|
|
1573
|
+
* is the whole diagnosis when the cause is a name that does not match.
|
|
1574
|
+
*
|
|
1575
|
+
* @param toolNames - The unmatched tool names collected during render.
|
|
1576
|
+
* @param registered - The registry as it stands now, re-read at report time.
|
|
1577
|
+
* @param alreadyWarned - Names already reported, mutated to keep this once per name.
|
|
1578
|
+
*/
|
|
1579
|
+
function warnAboutUnrenderedToolCalls(toolNames, registered, alreadyWarned) {
|
|
1580
|
+
const registeredNames = Array.from(new Set(registered.map((rc) => rc.name)));
|
|
1581
|
+
const hasWildcard = registeredNames.includes("*");
|
|
1582
|
+
for (const toolName of toolNames) {
|
|
1583
|
+
if (hasWildcard || registeredNames.includes(toolName)) continue;
|
|
1584
|
+
if (alreadyWarned.has(toolName)) continue;
|
|
1585
|
+
alreadyWarned.add(toolName);
|
|
1586
|
+
console.warn(`[CopilotKit] The agent called the tool "${toolName}", and no renderer is registered for it, so that message rendered nothing. ` + (registeredNames.length === 0 ? "No tool-call renderers are registered. " : `Registered renderers: ${registeredNames.map((name) => `"${name}"`).join(", ")}. `) + `Register one with useRenderTool({ name: "${toolName}", ... }), or call useDefaultRenderTool() for a built-in card that covers every tool the agent calls. This warning is development-only.`);
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1552
1589
|
/**
|
|
1553
1590
|
* Hook that returns a function to render tool calls based on the render functions
|
|
1554
1591
|
* defined in CopilotKitProvider.
|
|
@@ -1558,13 +1595,18 @@ const ToolCallRenderer = react.default.memo(function ToolCallRenderer({ toolCall
|
|
|
1558
1595
|
function useRenderToolCall() {
|
|
1559
1596
|
const { copilotkit, executingToolCallIds } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
1560
1597
|
const agentId = useCopilotChatConfiguration()?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
1598
|
+
const unrenderedToolNames = (0, react.useRef)(/* @__PURE__ */ new Set());
|
|
1599
|
+
const warnedToolNames = (0, react.useRef)(/* @__PURE__ */ new Set());
|
|
1561
1600
|
const renderToolCalls = (0, react.useSyncExternalStore)((callback) => {
|
|
1562
1601
|
return copilotkit.subscribe({ onRenderToolCallsChanged: callback }).unsubscribe;
|
|
1563
1602
|
}, () => copilotkit.renderToolCalls, () => copilotkit.renderToolCalls);
|
|
1564
|
-
|
|
1603
|
+
const renderToolCall = (0, react.useCallback)(({ toolCall, toolMessage }) => {
|
|
1565
1604
|
const exactMatches = renderToolCalls.filter((rc) => rc.name === toolCall.function.name);
|
|
1566
1605
|
const renderConfig = exactMatches.find((rc) => rc.agentId === agentId) || exactMatches.find((rc) => !rc.agentId) || exactMatches[0] || renderToolCalls.find((rc) => rc.name === "*");
|
|
1567
|
-
if (!renderConfig)
|
|
1606
|
+
if (!renderConfig) {
|
|
1607
|
+
if (IS_DEVELOPMENT$1) unrenderedToolNames.current.add(toolCall.function.name);
|
|
1608
|
+
return null;
|
|
1609
|
+
}
|
|
1568
1610
|
const RenderComponent = renderConfig.render;
|
|
1569
1611
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolCallRenderer, {
|
|
1570
1612
|
toolCall,
|
|
@@ -1577,25 +1619,43 @@ function useRenderToolCall() {
|
|
|
1577
1619
|
executingToolCallIds,
|
|
1578
1620
|
agentId
|
|
1579
1621
|
]);
|
|
1622
|
+
(0, react.useEffect)(() => {
|
|
1623
|
+
if (!IS_DEVELOPMENT$1) return;
|
|
1624
|
+
if (unrenderedToolNames.current.size === 0) return;
|
|
1625
|
+
const timer = setTimeout(() => {
|
|
1626
|
+
const pending = Array.from(unrenderedToolNames.current);
|
|
1627
|
+
unrenderedToolNames.current.clear();
|
|
1628
|
+
warnAboutUnrenderedToolCalls(pending, copilotkit.renderToolCalls, warnedToolNames.current);
|
|
1629
|
+
}, 0);
|
|
1630
|
+
return () => clearTimeout(timer);
|
|
1631
|
+
});
|
|
1632
|
+
return renderToolCall;
|
|
1580
1633
|
}
|
|
1581
1634
|
|
|
1582
1635
|
//#endregion
|
|
1583
1636
|
//#region src/v2/components/CopilotKitInspector.tsx
|
|
1584
|
-
const CopilotKitInspector = ({ core, openRequest }) => {
|
|
1637
|
+
const CopilotKitInspector = ({ core, openRequest, onVisibilityChange }) => {
|
|
1585
1638
|
const mountRef = react.useRef(null);
|
|
1586
1639
|
const inspectorRef = react.useRef(null);
|
|
1587
1640
|
const latestCoreRef = react.useRef(core ?? null);
|
|
1588
1641
|
const latestOpenRequestRef = react.useRef(openRequest);
|
|
1642
|
+
const visibilityCallbackRef = react.useRef(onVisibilityChange);
|
|
1643
|
+
visibilityCallbackRef.current = onVisibilityChange;
|
|
1589
1644
|
latestCoreRef.current = core ?? null;
|
|
1590
1645
|
latestOpenRequestRef.current = openRequest;
|
|
1591
1646
|
react.useEffect(() => {
|
|
1592
1647
|
let mounted = true;
|
|
1593
1648
|
let inspector = null;
|
|
1649
|
+
const handleVisibilityChange = (event) => {
|
|
1650
|
+
const visible = event.detail?.visible;
|
|
1651
|
+
visibilityCallbackRef.current?.(visible === true);
|
|
1652
|
+
};
|
|
1594
1653
|
import("@copilotkit/web-inspector").then((mod) => {
|
|
1595
1654
|
if (!mounted || !mountRef.current) return;
|
|
1596
1655
|
mod.defineWebInspector?.();
|
|
1597
1656
|
inspector = mountRef.current.ownerDocument.createElement(mod.WEB_INSPECTOR_TAG);
|
|
1598
1657
|
mod.configureWebInspectorElement(inspector, latestCoreRef.current);
|
|
1658
|
+
inspector.addEventListener("cpk-inspector-visibility-change", handleVisibilityChange);
|
|
1599
1659
|
mountRef.current.appendChild(inspector);
|
|
1600
1660
|
inspectorRef.current = inspector;
|
|
1601
1661
|
const request = latestOpenRequestRef.current;
|
|
@@ -1605,7 +1665,9 @@ const CopilotKitInspector = ({ core, openRequest }) => {
|
|
|
1605
1665
|
});
|
|
1606
1666
|
return () => {
|
|
1607
1667
|
mounted = false;
|
|
1668
|
+
inspector?.removeEventListener("cpk-inspector-visibility-change", handleVisibilityChange);
|
|
1608
1669
|
inspector?.remove();
|
|
1670
|
+
visibilityCallbackRef.current?.(false);
|
|
1609
1671
|
if (inspectorRef.current === inspector) inspectorRef.current = null;
|
|
1610
1672
|
};
|
|
1611
1673
|
}, []);
|
|
@@ -3055,6 +3117,95 @@ const A2UISurfaceContentSchema = zod.z.object({
|
|
|
3055
3117
|
a2ui_operations: zod.z.array(zod.z.any()).optional(),
|
|
3056
3118
|
...A2UILifecycleFields
|
|
3057
3119
|
}).passthrough();
|
|
3120
|
+
const IS_DEVELOPMENT = process.env.NODE_ENV !== "production";
|
|
3121
|
+
/**
|
|
3122
|
+
* How long to wait for a surface to report its first paint before giving up on
|
|
3123
|
+
* the loader cross-over. Reaching it also means `onReady` never fired, which is
|
|
3124
|
+
* the signal the warning below reports.
|
|
3125
|
+
*/
|
|
3126
|
+
const PAINT_FALLBACK_MS = 8e3;
|
|
3127
|
+
/**
|
|
3128
|
+
* Names the operation kinds a surface received, for a warning that has to say
|
|
3129
|
+
* what did arrive as well as what did not.
|
|
3130
|
+
*
|
|
3131
|
+
* @param operations - The operations grouped under one surface.
|
|
3132
|
+
* @returns A comma-separated list of operation keys, or "none".
|
|
3133
|
+
*/
|
|
3134
|
+
function describeOperationKinds(operations) {
|
|
3135
|
+
const kinds = /* @__PURE__ */ new Set();
|
|
3136
|
+
for (const operation of operations) {
|
|
3137
|
+
if (!operation || typeof operation !== "object") continue;
|
|
3138
|
+
for (const key of Object.keys(operation)) if (key !== "version") kinds.add(key);
|
|
3139
|
+
}
|
|
3140
|
+
return kinds.size === 0 ? "none" : Array.from(kinds).join(", ");
|
|
3141
|
+
}
|
|
3142
|
+
/**
|
|
3143
|
+
* Reports surfaces that received operations and never painted.
|
|
3144
|
+
*
|
|
3145
|
+
* Reaching {@link PAINT_FALLBACK_MS} with no `onReady` means the operations were
|
|
3146
|
+
* accepted, were not malformed enough to raise the provider's error state, and
|
|
3147
|
+
* still put nothing on screen. Left alone that is invisible: the loader drops,
|
|
3148
|
+
* the turn finishes, and the only trace is an empty placeholder above the reply.
|
|
3149
|
+
*
|
|
3150
|
+
* `surfaceHasRenderableContent` already knows which half is missing, so the
|
|
3151
|
+
* warning says which rather than making the reader re-derive it.
|
|
3152
|
+
*
|
|
3153
|
+
* @param grouped - Operations grouped by surface id.
|
|
3154
|
+
*/
|
|
3155
|
+
function warnAboutUnpaintedSurfaces(grouped) {
|
|
3156
|
+
for (const [surfaceId, operations] of grouped) {
|
|
3157
|
+
if (surfaceHasRenderableContent(operations)) continue;
|
|
3158
|
+
const cause = operations.filter((o) => o?.updateComponents).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";
|
|
3159
|
+
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.`);
|
|
3160
|
+
}
|
|
3161
|
+
}
|
|
3162
|
+
/**
|
|
3163
|
+
* Names the component ids a surface was sent, for a warning about the one id
|
|
3164
|
+
* that is missing.
|
|
3165
|
+
*
|
|
3166
|
+
* @param operations - The operations grouped under one surface.
|
|
3167
|
+
* @returns A quoted, comma-separated list of ids, or "none".
|
|
3168
|
+
*/
|
|
3169
|
+
function describeComponentIds(operations) {
|
|
3170
|
+
const ids = [];
|
|
3171
|
+
for (const operation of operations) {
|
|
3172
|
+
const components = operation?.updateComponents?.components;
|
|
3173
|
+
if (!Array.isArray(components)) continue;
|
|
3174
|
+
for (const component of components) {
|
|
3175
|
+
const id = component?.id;
|
|
3176
|
+
if (typeof id === "string" && !ids.includes(id)) ids.push(id);
|
|
3177
|
+
}
|
|
3178
|
+
}
|
|
3179
|
+
return ids.length === 0 ? "none" : ids.map((id) => `"${id}"`).join(", ");
|
|
3180
|
+
}
|
|
3181
|
+
/**
|
|
3182
|
+
* Reports a surface that is still waiting for its {@link ROOT_COMPONENT_ID}
|
|
3183
|
+
* component once its operations have stopped arriving.
|
|
3184
|
+
*
|
|
3185
|
+
* Both renderers begin walking a surface at that one id, and treat an id they
|
|
3186
|
+
* cannot find as not arrived yet — an animated placeholder. That is right while
|
|
3187
|
+
* operations stream. Once they have stopped it is not waiting, it is stuck, and
|
|
3188
|
+
* every other check calls it healthy: the surface exists, `processMessages` did
|
|
3189
|
+
* not throw, the component types were never reached, and
|
|
3190
|
+
* `surfaceHasRenderableContent` says yes on the strength of components plus a
|
|
3191
|
+
* data model, so `onReady` fires and the never-painted report is suppressed.
|
|
3192
|
+
* A complete, accepted payload therefore animates a grey box forever in silence.
|
|
3193
|
+
*
|
|
3194
|
+
* Reads the live components model rather than scanning the operations for the
|
|
3195
|
+
* id, so it covers every way the root can fail to resolve — not only a payload
|
|
3196
|
+
* that never named one.
|
|
3197
|
+
*
|
|
3198
|
+
* @param surfaceId - The surface the operations were addressed to.
|
|
3199
|
+
* @param operations - The operations processed for that surface.
|
|
3200
|
+
* @param surface - The live surface model, already known to exist.
|
|
3201
|
+
*/
|
|
3202
|
+
function warnAboutUnresolvedRoot(surfaceId, operations, surface) {
|
|
3203
|
+
if (surface?.componentsModel?.get?.(_copilotkit_a2ui_renderer.ROOT_COMPONENT_ID)) return;
|
|
3204
|
+
const componentOps = operations.filter((o) => o?.updateComponents);
|
|
3205
|
+
if (componentOps.length === 0) return;
|
|
3206
|
+
const cause = componentOps.some((o) => o.updateComponents?.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`;
|
|
3207
|
+
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.`);
|
|
3208
|
+
}
|
|
3058
3209
|
function createA2UIMessageRenderer(options) {
|
|
3059
3210
|
const { theme, catalog, loadingComponent, recovery, onAction } = options;
|
|
3060
3211
|
const showAfterMs = recovery?.showAfterMs ?? 2e3;
|
|
@@ -3088,6 +3239,8 @@ function createA2UIMessageRenderer(options) {
|
|
|
3088
3239
|
return groups;
|
|
3089
3240
|
}, [operations]);
|
|
3090
3241
|
const hasOps = groupedOperations.size > 0;
|
|
3242
|
+
const groupedOperationsRef = (0, react.useRef)(groupedOperations);
|
|
3243
|
+
groupedOperationsRef.current = groupedOperations;
|
|
3091
3244
|
const renderLifecycle = (c) => {
|
|
3092
3245
|
const status = c?.status;
|
|
3093
3246
|
const debugExposure = resolveDebugExposure(c, optionDebugExposure);
|
|
@@ -3119,7 +3272,10 @@ function createA2UIMessageRenderer(options) {
|
|
|
3119
3272
|
readyRef.current = false;
|
|
3120
3273
|
return;
|
|
3121
3274
|
}
|
|
3122
|
-
const t = setTimeout(() =>
|
|
3275
|
+
const t = setTimeout(() => {
|
|
3276
|
+
setSurfaceReady(true);
|
|
3277
|
+
if (IS_DEVELOPMENT && !readyRef.current) warnAboutUnpaintedSurfaces(groupedOperationsRef.current);
|
|
3278
|
+
}, PAINT_FALLBACK_MS);
|
|
3123
3279
|
return () => clearTimeout(t);
|
|
3124
3280
|
}, [hasOps]);
|
|
3125
3281
|
if (!hasOps) return renderLifecycle(content);
|
|
@@ -3243,8 +3399,21 @@ function SurfaceMessageProcessor({ surfaceId, operations, onReady }) {
|
|
|
3243
3399
|
const hash = JSON.stringify(operations);
|
|
3244
3400
|
if (hash === lastHashRef.current) return;
|
|
3245
3401
|
lastHashRef.current = hash;
|
|
3246
|
-
|
|
3402
|
+
const ops = getSurface(surfaceId) ? operations.filter((op) => !op?.createSurface) : operations;
|
|
3403
|
+
processMessages(ops);
|
|
3247
3404
|
if (onReady && surfaceHasRenderableContent(operations)) onReady();
|
|
3405
|
+
if (!IS_DEVELOPMENT) return;
|
|
3406
|
+
if (!getSurface(surfaceId)) {
|
|
3407
|
+
const missingSurfaceCheck = setTimeout(() => {
|
|
3408
|
+
if (getSurface(surfaceId)) return;
|
|
3409
|
+
console.warn(`[CopilotKit] A2UI processed ${String(ops.length)} operation(s) addressed to surface "${surfaceId}" and no surface by that id exists, so this card rendered nothing. Operations received: ${describeOperationKinds(ops)}. A createSurface for "${surfaceId}" has to arrive before, or with, the operations that target it. This warning is development-only.`);
|
|
3410
|
+
}, 0);
|
|
3411
|
+
return () => clearTimeout(missingSurfaceCheck);
|
|
3412
|
+
}
|
|
3413
|
+
const unresolvedRootCheck = setTimeout(() => {
|
|
3414
|
+
warnAboutUnresolvedRoot(surfaceId, operations, getSurface(surfaceId));
|
|
3415
|
+
}, PAINT_FALLBACK_MS);
|
|
3416
|
+
return () => clearTimeout(unresolvedRootCheck);
|
|
3248
3417
|
}, [
|
|
3249
3418
|
processMessages,
|
|
3250
3419
|
getSurface,
|
|
@@ -3271,10 +3440,26 @@ function surfaceHasRenderableContent(operations) {
|
|
|
3271
3440
|
return Object.values(v).some((x) => Array.isArray(x) ? x.length > 0 : x !== null && x !== void 0 && x !== "");
|
|
3272
3441
|
});
|
|
3273
3442
|
}
|
|
3443
|
+
/**
|
|
3444
|
+
* Resolves the surface an operation addresses.
|
|
3445
|
+
*
|
|
3446
|
+
* The nested v0.9 `surfaceId` wins, because that is the id `MessageProcessor`
|
|
3447
|
+
* creates the surface under. Grouping by a top-level `surfaceId` instead files
|
|
3448
|
+
* the operations against a surface that never exists, which paints nothing —
|
|
3449
|
+
* the silence the missing-surface report above now names. A top-level
|
|
3450
|
+
* `surfaceId` is not the v0.9 shape, so it is honoured only when no nested id is
|
|
3451
|
+
* present. `getSurfaceId` in `@copilotkit/a2ui-renderer`'s web-components path
|
|
3452
|
+
* resolves it in the same order; the two disagreeing is what OSS-1048 recorded.
|
|
3453
|
+
*
|
|
3454
|
+
* @param operation - One A2UI operation, of any shape.
|
|
3455
|
+
* @returns The surface id, or null when the operation names none.
|
|
3456
|
+
*/
|
|
3274
3457
|
function getOperationSurfaceId(operation) {
|
|
3275
3458
|
if (!operation || typeof operation !== "object") return null;
|
|
3459
|
+
const nested = operation?.createSurface?.surfaceId ?? operation?.updateComponents?.surfaceId ?? operation?.updateDataModel?.surfaceId ?? operation?.deleteSurface?.surfaceId;
|
|
3460
|
+
if (typeof nested === "string") return nested;
|
|
3276
3461
|
if (typeof operation.surfaceId === "string") return operation.surfaceId;
|
|
3277
|
-
return
|
|
3462
|
+
return null;
|
|
3278
3463
|
}
|
|
3279
3464
|
|
|
3280
3465
|
//#endregion
|
|
@@ -3488,6 +3673,9 @@ const COPILOT_CLOUD_CHAT_URL$1 = "https://api.cloud.copilotkit.ai/copilotkit/v1"
|
|
|
3488
3673
|
const EMPTY_HEADERS = Object.freeze({});
|
|
3489
3674
|
const EMPTY_PROPERTIES = Object.freeze({});
|
|
3490
3675
|
const EMPTY_AGENTS = Object.freeze({});
|
|
3676
|
+
/** Registration name of a catch-all tool: handles any otherwise-unhandled call. */
|
|
3677
|
+
const WILDCARD_TOOL_NAME$1 = "*";
|
|
3678
|
+
const HUMAN_IN_THE_LOOP_ABORTED_MESSAGE = "Human-in-the-loop interaction aborted";
|
|
3491
3679
|
const DEFAULT_DESIGN_SKILL = `When generating UI with generateSandboxedUi, follow these design principles inspired by shadcn/ui:
|
|
3492
3680
|
|
|
3493
3681
|
- Use a minimal, flat aesthetic. Avoid drop shadows and gradients — rely on subtle borders (1px solid, light gray like #e5e7eb) to define surfaces.
|
|
@@ -3508,14 +3696,19 @@ function useStableArrayProp(prop, warningMessage, isMeaningfulChange) {
|
|
|
3508
3696
|
}, [value, warningMessage]);
|
|
3509
3697
|
return value;
|
|
3510
3698
|
}
|
|
3511
|
-
const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY_HEADERS, credentials, publicApiKey, publicLicenseKey, licenseToken, properties = EMPTY_PROPERTIES, agents__unsafe_dev_only: agents = EMPTY_AGENTS, selfManagedAgents = EMPTY_AGENTS, renderToolCalls, renderActivityMessages, renderCustomMessages, frontendTools, humanInTheLoop, openGenerativeUI, enableInspector, useSingleEndpoint, onError, a2ui, defaultThrottleMs, debug }) => {
|
|
3699
|
+
const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY_HEADERS, credentials, publicApiKey, publicLicenseKey, licenseToken, properties = EMPTY_PROPERTIES, agents__unsafe_dev_only: agents = EMPTY_AGENTS, selfManagedAgents = EMPTY_AGENTS, renderToolCalls, renderActivityMessages, renderCustomMessages, frontendTools, humanInTheLoop, openGenerativeUI, enableInspector, agentId, useSingleEndpoint, onError, a2ui, defaultThrottleMs, debug }) => {
|
|
3512
3700
|
const [shouldRenderInspector, setShouldRenderInspector] = (0, react.useState)(false);
|
|
3701
|
+
const [inspectorVisible, setInspectorVisible] = (0, react.useState)(false);
|
|
3513
3702
|
(0, react.useEffect)(() => {
|
|
3514
3703
|
setShouldRenderInspector((0, _copilotkit_shared.shouldEnableInspector)({
|
|
3515
3704
|
enableInspector,
|
|
3516
3705
|
isBrowser: true,
|
|
3517
3706
|
isDevelopment: process.env.NODE_ENV === "development"
|
|
3518
|
-
})
|
|
3707
|
+
}) && [
|
|
3708
|
+
"localhost",
|
|
3709
|
+
"127.0.0.1",
|
|
3710
|
+
"[::1]"
|
|
3711
|
+
].includes(window.location.hostname));
|
|
3519
3712
|
}, [enableInspector]);
|
|
3520
3713
|
const [inspectorOpenRequest, setInspectorOpenRequest] = (0, react.useState)(null);
|
|
3521
3714
|
const [runtimeA2UIEnabled, setRuntimeA2UIEnabled] = (0, react.useState)(false);
|
|
@@ -3531,9 +3724,15 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3531
3724
|
setInspectorOpenRequest({ ...request });
|
|
3532
3725
|
}, []);
|
|
3533
3726
|
const inspectorContextValue = (0, react.useMemo)(() => ({
|
|
3534
|
-
|
|
3727
|
+
providerEnableInspector: enableInspector,
|
|
3728
|
+
isInspectorEnabled: shouldRenderInspector && inspectorVisible,
|
|
3535
3729
|
openInspector: requestInspectorOpen
|
|
3536
|
-
}), [
|
|
3730
|
+
}), [
|
|
3731
|
+
enableInspector,
|
|
3732
|
+
shouldRenderInspector,
|
|
3733
|
+
inspectorVisible,
|
|
3734
|
+
requestInspectorOpen
|
|
3735
|
+
]);
|
|
3537
3736
|
const renderToolCallsList = useStableArrayProp(renderToolCalls, "renderToolCalls must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead.", (initial, next) => {
|
|
3538
3737
|
const key = (rc) => `${rc?.agentId ?? ""}:${rc?.name ?? ""}`;
|
|
3539
3738
|
const setFrom = (arr) => new Set(arr.map(key));
|
|
@@ -3606,6 +3805,11 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3606
3805
|
}
|
|
3607
3806
|
const chatApiEndpoint = runtimeUrl ?? (resolvedPublicKey ? COPILOT_CLOUD_CHAT_URL$1 : void 0);
|
|
3608
3807
|
const frontendToolsList = useStableArrayProp(frontendTools, "frontendTools must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead.");
|
|
3808
|
+
/**
|
|
3809
|
+
* A `humanInTheLoop` prop tool call that is parked, waiting on the user.
|
|
3810
|
+
* Keyed by tool call id, so parallel calls of one tool stay independent.
|
|
3811
|
+
*/
|
|
3812
|
+
const pendingHumanInTheLoopRef = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
3609
3813
|
const humanInTheLoopList = useStableArrayProp(humanInTheLoop, "humanInTheLoop must be a stable array. If you want to dynamically add or remove human-in-the-loop tools, use `useHumanInTheLoop` instead.");
|
|
3610
3814
|
const sandboxFunctionsList = useStableArrayProp(openGenerativeUI?.sandboxFunctions, "openGenerativeUI.sandboxFunctions must be a stable array.");
|
|
3611
3815
|
const processedHumanInTheLoopTools = (0, react.useMemo)(() => {
|
|
@@ -3618,20 +3822,52 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3618
3822
|
parameters: tool.parameters,
|
|
3619
3823
|
followUp: tool.followUp,
|
|
3620
3824
|
...tool.agentId && { agentId: tool.agentId },
|
|
3621
|
-
handler: async () => {
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3825
|
+
handler: async (_args, context) => {
|
|
3826
|
+
const signal = context?.signal;
|
|
3827
|
+
const key = context?.toolCall?.id ?? tool.name;
|
|
3828
|
+
return new Promise((resolve, reject) => {
|
|
3829
|
+
if (signal?.aborted) {
|
|
3830
|
+
reject(new Error(HUMAN_IN_THE_LOOP_ABORTED_MESSAGE));
|
|
3831
|
+
return;
|
|
3832
|
+
}
|
|
3833
|
+
const pending = { resolve };
|
|
3834
|
+
pendingHumanInTheLoopRef.current.set(key, pending);
|
|
3835
|
+
if (signal) {
|
|
3836
|
+
const onAbort = () => {
|
|
3837
|
+
pendingHumanInTheLoopRef.current.delete(key);
|
|
3838
|
+
reject(new Error(HUMAN_IN_THE_LOOP_ABORTED_MESSAGE));
|
|
3839
|
+
};
|
|
3840
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
3841
|
+
pending.detachAbort = () => {
|
|
3842
|
+
signal.removeEventListener("abort", onAbort);
|
|
3843
|
+
};
|
|
3844
|
+
}
|
|
3625
3845
|
});
|
|
3626
3846
|
}
|
|
3627
3847
|
};
|
|
3628
3848
|
processedTools.push(frontendTool);
|
|
3629
|
-
if (tool.render)
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3849
|
+
if (tool.render) {
|
|
3850
|
+
const ToolComponent = tool.render;
|
|
3851
|
+
const RenderComponent = (props) => (0, react.createElement)(ToolComponent, {
|
|
3852
|
+
...props,
|
|
3853
|
+
name: tool.name === WILDCARD_TOOL_NAME$1 ? props.name : tool.name,
|
|
3854
|
+
description: tool.description || "",
|
|
3855
|
+
agentId: tool.agentId,
|
|
3856
|
+
respond: props.status === _copilotkit_core.ToolCallStatus.Executing ? async (result) => {
|
|
3857
|
+
const pending = pendingHumanInTheLoopRef.current.get(props.toolCallId);
|
|
3858
|
+
if (!pending) return;
|
|
3859
|
+
pending.detachAbort?.();
|
|
3860
|
+
pendingHumanInTheLoopRef.current.delete(props.toolCallId);
|
|
3861
|
+
pending.resolve(result);
|
|
3862
|
+
} : void 0
|
|
3863
|
+
});
|
|
3864
|
+
processedRenderToolCalls.push({
|
|
3865
|
+
name: tool.name,
|
|
3866
|
+
args: tool.parameters,
|
|
3867
|
+
render: RenderComponent,
|
|
3868
|
+
...tool.agentId && { agentId: tool.agentId }
|
|
3869
|
+
});
|
|
3870
|
+
}
|
|
3635
3871
|
});
|
|
3636
3872
|
return {
|
|
3637
3873
|
tools: processedTools,
|
|
@@ -3893,9 +4129,13 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3893
4129
|
}),
|
|
3894
4130
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(CopilotKitInspectorContextProvider, {
|
|
3895
4131
|
value: inspectorContextValue,
|
|
3896
|
-
children: [
|
|
4132
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_react_core_v2_context.CopilotKitAgentIdContext.Provider, {
|
|
4133
|
+
value: agentId,
|
|
4134
|
+
children
|
|
4135
|
+
}), shouldRenderInspector ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitInspector, {
|
|
3897
4136
|
core: copilotkit,
|
|
3898
|
-
openRequest: inspectorOpenRequest
|
|
4137
|
+
openRequest: inspectorOpenRequest,
|
|
4138
|
+
onVisibilityChange: setInspectorVisible
|
|
3899
4139
|
}) : null]
|
|
3900
4140
|
}),
|
|
3901
4141
|
runtimeLicenseWarningStatus === "none" && !resolvedPublicKey && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "no_license" }),
|
|
@@ -4477,7 +4717,8 @@ function useAgent({ agentId, threadId, runtimeAgentId, updates, throttleMs } = {
|
|
|
4477
4717
|
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}" }).`);
|
|
4478
4718
|
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 }).`);
|
|
4479
4719
|
const chatConfig = useCopilotChatConfiguration();
|
|
4480
|
-
const
|
|
4720
|
+
const providerAgentId = (0, _copilotkit_react_core_v2_context.useDefaultAgentId)();
|
|
4721
|
+
const resolvedAgentId = agentId ?? chatConfig?.agentId ?? providerAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
4481
4722
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
4482
4723
|
const providerThrottleMs = copilotkit.defaultThrottleMs;
|
|
4483
4724
|
const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
|
|
@@ -4705,7 +4946,12 @@ function useAgentContext(context) {
|
|
|
4705
4946
|
function useSuggestions({ agentId } = {}) {
|
|
4706
4947
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
4707
4948
|
const config = useCopilotChatConfiguration();
|
|
4708
|
-
const
|
|
4949
|
+
const providerAgentId = (0, _copilotkit_react_core_v2_context.useDefaultAgentId)();
|
|
4950
|
+
const resolvedAgentId = (0, react.useMemo)(() => agentId ?? config?.agentId ?? providerAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID, [
|
|
4951
|
+
agentId,
|
|
4952
|
+
config?.agentId,
|
|
4953
|
+
providerAgentId
|
|
4954
|
+
]);
|
|
4709
4955
|
const [suggestions, setSuggestions] = (0, react.useState)(() => {
|
|
4710
4956
|
return copilotkit.getSuggestions(resolvedAgentId).suggestions;
|
|
4711
4957
|
});
|
|
@@ -6009,6 +6255,289 @@ function CopilotChatToolCallsView({ message, messages = [] }) {
|
|
|
6009
6255
|
}) });
|
|
6010
6256
|
}
|
|
6011
6257
|
|
|
6258
|
+
//#endregion
|
|
6259
|
+
//#region src/v2/components/chat/CopilotChatInspectorButton.tsx
|
|
6260
|
+
let shortcutsHidden = false;
|
|
6261
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
6262
|
+
const subscribe = (listener) => {
|
|
6263
|
+
listeners.add(listener);
|
|
6264
|
+
return () => {
|
|
6265
|
+
listeners.delete(listener);
|
|
6266
|
+
};
|
|
6267
|
+
};
|
|
6268
|
+
const getSnapshot = () => shortcutsHidden;
|
|
6269
|
+
const getServerSnapshot = () => false;
|
|
6270
|
+
function useInspectorShortcutsHidden() {
|
|
6271
|
+
return (0, react.useSyncExternalStore)(subscribe, getSnapshot, getServerSnapshot);
|
|
6272
|
+
}
|
|
6273
|
+
function hideShortcuts() {
|
|
6274
|
+
shortcutsHidden = true;
|
|
6275
|
+
listeners.forEach((listener) => listener());
|
|
6276
|
+
}
|
|
6277
|
+
function InspectorKiteIcon({ className, ...props }) {
|
|
6278
|
+
const id = (0, react.useId)();
|
|
6279
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
6280
|
+
...props,
|
|
6281
|
+
"aria-hidden": "true",
|
|
6282
|
+
className: (0, tailwind_merge.twMerge)("cpk:size-4", className),
|
|
6283
|
+
viewBox: "4.57 3.36 17.8 17.8",
|
|
6284
|
+
fill: "none",
|
|
6285
|
+
children: [
|
|
6286
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6287
|
+
d: "M6.36084 10.9855C8.34277 8.393 9.98843 5.82939 10.6204 3.75914C10.6382 3.70281 10.7043 3.67888 10.7534 3.7114C12.9536 5.16894 16.9635 6.12833 20.5086 6.15085C20.5703 6.15124 20.6124 6.2114 20.5895 6.26829C19.4109 9.25938 17.9705 14.6189 17.9148 20.7392C17.9148 20.8301 17.7873 20.8627 17.7419 20.7837C15.7236 17.2522 9.26021 12.2898 6.39414 11.1186C6.34112 11.0968 6.32556 11.0313 6.36084 10.9855Z",
|
|
6288
|
+
fill: `url(#${id}-paint0_linear)`
|
|
6289
|
+
}),
|
|
6290
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6291
|
+
d: "M13.0475 9.39974C9.95016 10.3806 7.11935 10.9259 6.44331 11.0498C6.40027 11.0577 6.39115 11.1172 6.43152 11.134C9.3203 12.3347 15.7516 17.2826 17.7511 20.7998C17.7551 20.8075 17.7647 20.8103 17.7728 20.8068C17.7809 20.803 17.7853 20.793 17.7819 20.7844L13.0475 9.39974Z",
|
|
6292
|
+
fill: `url(#${id}-paint1_linear)`
|
|
6293
|
+
}),
|
|
6294
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6295
|
+
d: "M10.762 3.705C13.4137 5.15161 16.4787 5.80132 20.545 6.14367C20.5703 6.14585 20.5787 6.18008 20.5557 6.19197C20.0359 6.45923 17.0574 7.97512 14.8455 8.78701C14.2524 9.00453 13.6564 9.20632 13.0692 9.39249C13.0562 9.39656 13.0419 9.39015 13.0369 9.37774L10.7005 3.75979C10.6849 3.72196 10.7257 3.68538 10.762 3.705Z",
|
|
6296
|
+
fill: `url(#${id}-paint2_linear)`
|
|
6297
|
+
}),
|
|
6298
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6299
|
+
d: "M10.7145 3.79041L17.8305 20.7659",
|
|
6300
|
+
stroke: "#513C9F",
|
|
6301
|
+
strokeWidth: "0.17284",
|
|
6302
|
+
strokeLinecap: "round"
|
|
6303
|
+
}),
|
|
6304
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6305
|
+
d: "M6.44531 11.0476C6.44531 11.0476 10.375 10.3422 14.0686 9.06804C17.7623 7.7939 20.5122 6.23373 20.5122 6.23373",
|
|
6306
|
+
stroke: "#513C9F",
|
|
6307
|
+
strokeWidth: "0.17284",
|
|
6308
|
+
strokeLinecap: "round"
|
|
6309
|
+
}),
|
|
6310
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6311
|
+
d: "M11.6914 5.93518L9.05534 14.7068M9.05534 14.7068H15.3203M9.05534 14.7068L0.15625 26.3646",
|
|
6312
|
+
stroke: "#ABABAB",
|
|
6313
|
+
strokeWidth: "0.302474",
|
|
6314
|
+
strokeLinecap: "round"
|
|
6315
|
+
}),
|
|
6316
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6317
|
+
d: "M6.02539 23.9646L4.85806 24.1287C5.46272 25.7287 6.70381 26.4276 8.18528 26.4276C11.8147 26.4276 10.707 22.3227 12.8103 22.3227C14.3358 22.3227 13.7155 25.6498 16.9992 25.6498C19.0029 25.6498 19.2028 23.631 18.8607 22.7625C18.8589 22.7572 18.8568 22.7524 18.8538 22.7476L18.3166 21.9253C18.2817 21.8706 18.1968 21.8912 18.1907 21.9562L18.0908 22.9529C18.0838 23.0222 18.0857 23.0913 18.0936 23.1605C18.1764 23.8491 18.2291 25.5202 16.9992 25.5202C15.7015 25.5202 15.3895 22.2362 12.8103 22.2362C9.78393 22.2362 10.1726 26.298 8.31487 26.298C7.08938 26.298 6.15447 24.9153 6.02539 23.9646Z",
|
|
6318
|
+
fill: `url(#${id}-paint3_linear)`
|
|
6319
|
+
}),
|
|
6320
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("defs", { children: [
|
|
6321
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("linearGradient", {
|
|
6322
|
+
id: `${id}-paint0_linear`,
|
|
6323
|
+
x1: "15.5372",
|
|
6324
|
+
y1: "5.0278",
|
|
6325
|
+
x2: "12.0802",
|
|
6326
|
+
y2: "14.534",
|
|
6327
|
+
gradientUnits: "userSpaceOnUse",
|
|
6328
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", { stopColor: "#6430AB" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6329
|
+
offset: "1",
|
|
6330
|
+
stopColor: "#AA89D8"
|
|
6331
|
+
})]
|
|
6332
|
+
}),
|
|
6333
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("linearGradient", {
|
|
6334
|
+
id: `${id}-paint1_linear`,
|
|
6335
|
+
x1: "12.8583",
|
|
6336
|
+
y1: "10.3858",
|
|
6337
|
+
x2: "8.40764",
|
|
6338
|
+
y2: "18.9846",
|
|
6339
|
+
gradientUnits: "userSpaceOnUse",
|
|
6340
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", { stopColor: "#005DBB" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6341
|
+
offset: "1",
|
|
6342
|
+
stopColor: "#3D92E8"
|
|
6343
|
+
})]
|
|
6344
|
+
}),
|
|
6345
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("linearGradient", {
|
|
6346
|
+
id: `${id}-paint2_linear`,
|
|
6347
|
+
x1: "14.8452",
|
|
6348
|
+
y1: "5.02774",
|
|
6349
|
+
x2: "13.5047",
|
|
6350
|
+
y2: "9.21911",
|
|
6351
|
+
gradientUnits: "userSpaceOnUse",
|
|
6352
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", { stopColor: "#1B70C4" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6353
|
+
offset: "1",
|
|
6354
|
+
stopColor: "#54A4F2"
|
|
6355
|
+
})]
|
|
6356
|
+
}),
|
|
6357
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("linearGradient", {
|
|
6358
|
+
id: `${id}-paint3_linear`,
|
|
6359
|
+
x1: "4.85806",
|
|
6360
|
+
y1: "24.2455",
|
|
6361
|
+
x2: "18.9963",
|
|
6362
|
+
y2: "24.2455",
|
|
6363
|
+
gradientUnits: "userSpaceOnUse",
|
|
6364
|
+
children: [
|
|
6365
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", { stopColor: "#4497EA" }),
|
|
6366
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6367
|
+
offset: "0.254755",
|
|
6368
|
+
stopColor: "#1463B2"
|
|
6369
|
+
}),
|
|
6370
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6371
|
+
offset: "0.498725",
|
|
6372
|
+
stopColor: "#0A437D"
|
|
6373
|
+
}),
|
|
6374
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6375
|
+
offset: "0.666667",
|
|
6376
|
+
stopColor: "#2476C8"
|
|
6377
|
+
}),
|
|
6378
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6379
|
+
offset: "0.972542",
|
|
6380
|
+
stopColor: "#0C549A"
|
|
6381
|
+
})
|
|
6382
|
+
]
|
|
6383
|
+
})
|
|
6384
|
+
] })
|
|
6385
|
+
]
|
|
6386
|
+
});
|
|
6387
|
+
}
|
|
6388
|
+
function CopilotChatInspectorButton({ title, className, onClick, onPointerDown, onPointerEnter, onPointerLeave, onKeyDown, disabled, ...props }) {
|
|
6389
|
+
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
6390
|
+
const { isInspectorEnabled } = useCopilotKitInspector();
|
|
6391
|
+
const hidden = useInspectorShortcutsHidden();
|
|
6392
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
6393
|
+
const [dark, setDark] = (0, react.useState)(false);
|
|
6394
|
+
const trigger = (0, react.useRef)(null);
|
|
6395
|
+
const closeTimer = (0, react.useRef)(null);
|
|
6396
|
+
const openedByHover = (0, react.useRef)(false);
|
|
6397
|
+
const primaryLabel = title || labels.assistantMessageToolbarInspectorLabel;
|
|
6398
|
+
const cancelClose = () => {
|
|
6399
|
+
if (closeTimer.current !== null) clearTimeout(closeTimer.current);
|
|
6400
|
+
closeTimer.current = null;
|
|
6401
|
+
};
|
|
6402
|
+
(0, react.useEffect)(() => cancelClose, []);
|
|
6403
|
+
const changeOpen = (next) => {
|
|
6404
|
+
cancelClose();
|
|
6405
|
+
if (next) setDark(!!trigger.current?.closest(".dark"));
|
|
6406
|
+
setOpen(next);
|
|
6407
|
+
};
|
|
6408
|
+
const scheduleClose = () => {
|
|
6409
|
+
cancelClose();
|
|
6410
|
+
closeTimer.current = setTimeout(() => {
|
|
6411
|
+
if (openedByHover.current) setOpen(false);
|
|
6412
|
+
}, 180);
|
|
6413
|
+
};
|
|
6414
|
+
if (!isInspectorEnabled || hidden) return null;
|
|
6415
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DropdownMenu, {
|
|
6416
|
+
open,
|
|
6417
|
+
onOpenChange: changeOpen,
|
|
6418
|
+
modal: false,
|
|
6419
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuTrigger, {
|
|
6420
|
+
asChild: true,
|
|
6421
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
6422
|
+
...props,
|
|
6423
|
+
ref: trigger,
|
|
6424
|
+
type: "button",
|
|
6425
|
+
disabled,
|
|
6426
|
+
variant: "assistantMessageToolbarButton",
|
|
6427
|
+
size: "icon",
|
|
6428
|
+
"data-testid": "copilot-inspector-button",
|
|
6429
|
+
"aria-label": `${labels.assistantMessageToolbarInspectorTitle} (${labels.assistantMessageToolbarInspectorLocalOnlyLabel.toLowerCase()})`,
|
|
6430
|
+
className: (0, tailwind_merge.twMerge)("cpk:size-8 cpk:p-1.5", className),
|
|
6431
|
+
onPointerEnter: (event) => {
|
|
6432
|
+
onPointerEnter?.(event);
|
|
6433
|
+
if (!disabled && event.pointerType !== "touch") {
|
|
6434
|
+
openedByHover.current = true;
|
|
6435
|
+
changeOpen(true);
|
|
6436
|
+
}
|
|
6437
|
+
},
|
|
6438
|
+
onPointerLeave: (event) => {
|
|
6439
|
+
onPointerLeave?.(event);
|
|
6440
|
+
scheduleClose();
|
|
6441
|
+
},
|
|
6442
|
+
onPointerDown: (event) => {
|
|
6443
|
+
onPointerDown?.(event);
|
|
6444
|
+
event.preventDefault();
|
|
6445
|
+
},
|
|
6446
|
+
onClick: (event) => {
|
|
6447
|
+
changeOpen(false);
|
|
6448
|
+
onClick?.(event);
|
|
6449
|
+
},
|
|
6450
|
+
onKeyDown: (event) => {
|
|
6451
|
+
openedByHover.current = false;
|
|
6452
|
+
onKeyDown?.(event);
|
|
6453
|
+
if (!event.defaultPrevented && (event.key === "Enter" || event.key === " ")) {
|
|
6454
|
+
event.preventDefault();
|
|
6455
|
+
event.currentTarget.click();
|
|
6456
|
+
}
|
|
6457
|
+
},
|
|
6458
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Wrench, {
|
|
6459
|
+
"aria-hidden": "true",
|
|
6460
|
+
className: "cpk:size-4",
|
|
6461
|
+
"data-testid": "copilot-inspector-icon"
|
|
6462
|
+
})
|
|
6463
|
+
})
|
|
6464
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DropdownMenuContent, {
|
|
6465
|
+
align: "start",
|
|
6466
|
+
side: "top",
|
|
6467
|
+
sideOffset: 6,
|
|
6468
|
+
className: (0, tailwind_merge.twMerge)("cpk:w-64 cpk:p-1 cpk:text-sm", dark && "dark"),
|
|
6469
|
+
onPointerEnter: cancelClose,
|
|
6470
|
+
onPointerLeave: scheduleClose,
|
|
6471
|
+
onKeyDown: () => {
|
|
6472
|
+
openedByHover.current = false;
|
|
6473
|
+
},
|
|
6474
|
+
onOpenAutoFocus: (event) => {
|
|
6475
|
+
if (openedByHover.current) event.preventDefault();
|
|
6476
|
+
},
|
|
6477
|
+
onCloseAutoFocus: (event) => {
|
|
6478
|
+
if (openedByHover.current) event.preventDefault();
|
|
6479
|
+
},
|
|
6480
|
+
onFocusOutside: () => changeOpen(false),
|
|
6481
|
+
children: [
|
|
6482
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DropdownMenuLabel, {
|
|
6483
|
+
className: "cpk:flex cpk:items-center cpk:justify-between cpk:gap-3 cpk:px-2 cpk:py-2",
|
|
6484
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6485
|
+
className: "cpk:text-xs cpk:font-medium",
|
|
6486
|
+
children: labels.assistantMessageToolbarInspectorTitle
|
|
6487
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Tooltip, {
|
|
6488
|
+
delayDuration: 1e3,
|
|
6489
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipTrigger, {
|
|
6490
|
+
asChild: true,
|
|
6491
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6492
|
+
tabIndex: 0,
|
|
6493
|
+
className: "cpk:cursor-help cpk:rounded cpk:bg-muted cpk:px-1.5 cpk:py-0.5 cpk:text-[10px] cpk:font-normal cpk:text-muted-foreground",
|
|
6494
|
+
children: labels.assistantMessageToolbarInspectorLocalOnlyLabel
|
|
6495
|
+
})
|
|
6496
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipContent, {
|
|
6497
|
+
side: "top",
|
|
6498
|
+
sideOffset: 6,
|
|
6499
|
+
className: (0, tailwind_merge.twMerge)("cpk:max-w-48 cpk:text-wrap", dark && "dark"),
|
|
6500
|
+
onPointerEnter: cancelClose,
|
|
6501
|
+
onPointerLeave: scheduleClose,
|
|
6502
|
+
children: labels.assistantMessageToolbarInspectorLocalOnlyDescription
|
|
6503
|
+
})]
|
|
6504
|
+
})]
|
|
6505
|
+
}),
|
|
6506
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuSeparator, {}),
|
|
6507
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownMenuItem, {
|
|
6508
|
+
asChild: true,
|
|
6509
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
6510
|
+
type: "button",
|
|
6511
|
+
onClick,
|
|
6512
|
+
className: "cpk:w-full cpk:cursor-pointer cpk:items-start cpk:text-left",
|
|
6513
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(InspectorKiteIcon, { className: "cpk:mt-0.5" }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6514
|
+
className: "cpk:block",
|
|
6515
|
+
children: primaryLabel
|
|
6516
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6517
|
+
className: "cpk:block cpk:text-xs cpk:text-muted-foreground",
|
|
6518
|
+
children: labels.assistantMessageToolbarInspectorDescription
|
|
6519
|
+
})] })]
|
|
6520
|
+
})
|
|
6521
|
+
}),
|
|
6522
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(DropdownMenuItem, {
|
|
6523
|
+
onSelect: hideShortcuts,
|
|
6524
|
+
className: "cpk:cursor-pointer cpk:items-start",
|
|
6525
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.EyeOff, {
|
|
6526
|
+
"aria-hidden": "true",
|
|
6527
|
+
className: "cpk:mt-0.5"
|
|
6528
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6529
|
+
className: "cpk:block",
|
|
6530
|
+
children: labels.assistantMessageToolbarInspectorHideLabel
|
|
6531
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6532
|
+
className: "cpk:block cpk:text-xs cpk:text-muted-foreground",
|
|
6533
|
+
children: labels.assistantMessageToolbarInspectorHideDescription
|
|
6534
|
+
})] })]
|
|
6535
|
+
})
|
|
6536
|
+
]
|
|
6537
|
+
})]
|
|
6538
|
+
});
|
|
6539
|
+
}
|
|
6540
|
+
|
|
6012
6541
|
//#endregion
|
|
6013
6542
|
//#region src/v2/components/chat/CopilotChatAssistantMessage.tsx
|
|
6014
6543
|
/**
|
|
@@ -6029,30 +6558,32 @@ function BoundInspectorButton({ inspectorButton, messageId, openInspector, ...pr
|
|
|
6029
6558
|
function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp, onThumbsDown, onReadAloud, onRegenerate, additionalToolbarItems, toolbarVisible = true, markdownRenderer, toolbar, copyButton, inspectorButton, thumbsUpButton, thumbsDownButton, readAloudButton, regenerateButton, toolCallsView, children, className, ...props }) {
|
|
6030
6559
|
useKatexStyles();
|
|
6031
6560
|
const { isInspectorEnabled, openInspector } = useCopilotKitInspector();
|
|
6561
|
+
const shortcutsHidden = useInspectorShortcutsHidden();
|
|
6562
|
+
const showInspectorShortcut = isInspectorEnabled && !shortcutsHidden;
|
|
6032
6563
|
const boundMarkdownRenderer = renderSlot(markdownRenderer, CopilotChatAssistantMessage.MarkdownRenderer, { content: message.content || "" });
|
|
6033
6564
|
const boundCopyButton = renderSlot(copyButton, CopilotChatAssistantMessage.CopyButton, { onClick: async () => {
|
|
6034
6565
|
if (message.content) return await (0, _copilotkit_shared.copyToClipboard)(message.content);
|
|
6035
6566
|
return false;
|
|
6036
6567
|
} });
|
|
6037
6568
|
const boundThumbsUpButton = renderSlot(thumbsUpButton, CopilotChatAssistantMessage.ThumbsUpButton, { onClick: onThumbsUp ? () => onThumbsUp(message) : void 0 });
|
|
6038
|
-
const boundInspectorButton = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BoundInspectorButton, {
|
|
6569
|
+
const boundInspectorButton = showInspectorShortcut ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BoundInspectorButton, {
|
|
6039
6570
|
inspectorButton,
|
|
6040
6571
|
messageId: message.id,
|
|
6041
6572
|
openInspector
|
|
6042
|
-
});
|
|
6573
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, {});
|
|
6043
6574
|
const boundThumbsDownButton = renderSlot(thumbsDownButton, CopilotChatAssistantMessage.ThumbsDownButton, { onClick: onThumbsDown ? () => onThumbsDown(message) : void 0 });
|
|
6044
6575
|
const boundReadAloudButton = renderSlot(readAloudButton, CopilotChatAssistantMessage.ReadAloudButton, { onClick: onReadAloud ? () => onReadAloud(message) : void 0 });
|
|
6045
6576
|
const boundRegenerateButton = renderSlot(regenerateButton, CopilotChatAssistantMessage.RegenerateButton, { onClick: onRegenerate ? () => onRegenerate(message) : void 0 });
|
|
6046
6577
|
const boundToolbar = renderSlot(toolbar, CopilotChatAssistantMessage.Toolbar, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
6047
|
-
className: "cpk:flex cpk:items-center cpk:gap-1",
|
|
6578
|
+
className: "cpk:flex cpk:w-full cpk:items-center cpk:gap-1",
|
|
6048
6579
|
children: [
|
|
6049
6580
|
boundCopyButton,
|
|
6050
|
-
isInspectorEnabled && boundInspectorButton,
|
|
6051
6581
|
(onThumbsUp || thumbsUpButton) && boundThumbsUpButton,
|
|
6052
6582
|
(onThumbsDown || thumbsDownButton) && boundThumbsDownButton,
|
|
6053
6583
|
(onReadAloud || readAloudButton) && boundReadAloudButton,
|
|
6054
6584
|
(onRegenerate || regenerateButton) && boundRegenerateButton,
|
|
6055
|
-
additionalToolbarItems
|
|
6585
|
+
additionalToolbarItems,
|
|
6586
|
+
showInspectorShortcut && boundInspectorButton
|
|
6056
6587
|
]
|
|
6057
6588
|
}) });
|
|
6058
6589
|
const boundToolCallsView = renderSlot(toolCallsView, CopilotChatToolCallsView, {
|
|
@@ -6061,7 +6592,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp,
|
|
|
6061
6592
|
});
|
|
6062
6593
|
const hasContent = !!(message.content && message.content.trim().length > 0);
|
|
6063
6594
|
const isLatestAssistantMessage = message.role === "assistant" && messages?.[messages.length - 1]?.id === message.id;
|
|
6064
|
-
const shouldShowToolbar = toolbarVisible && (hasContent ||
|
|
6595
|
+
const shouldShowToolbar = toolbarVisible && (hasContent || showInspectorShortcut) && !(isRunning && isLatestAssistantMessage);
|
|
6065
6596
|
if (children) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6066
6597
|
"data-copilotkit": true,
|
|
6067
6598
|
style: { display: "contents" },
|
|
@@ -6102,110 +6633,6 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp,
|
|
|
6102
6633
|
]
|
|
6103
6634
|
});
|
|
6104
6635
|
}
|
|
6105
|
-
function CopilotKitColoredIcon() {
|
|
6106
|
-
const gradientId = (0, react.useId)().replace(/:/g, "");
|
|
6107
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
6108
|
-
"aria-hidden": "true",
|
|
6109
|
-
className: "cpk:size-5",
|
|
6110
|
-
"data-testid": "copilot-inspector-icon",
|
|
6111
|
-
viewBox: "0 0 24 24",
|
|
6112
|
-
children: [
|
|
6113
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6114
|
-
d: "M8.162 7.758c2.093-2.738 3.831-5.445 4.498-7.63a.093.093 0 01.14-.051c2.324 1.539 6.558 2.552 10.301 2.576a.09.09 0 01.085.124c-1.243 3.158-2.765 8.817-2.823 15.28-.001.095-.135.13-.183.046-2.131-3.729-8.955-8.968-11.982-10.205a.09.09 0 01-.036-.14z",
|
|
6115
|
-
fill: `url(#${gradientId}-purple)`
|
|
6116
|
-
}),
|
|
6117
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6118
|
-
d: "M15.223 6.083A61.492 61.492 0 018.25 7.827c-.045.008-.055.071-.012.089 3.05 1.267 9.84 6.492 11.952 10.206a.017.017 0 00.022.007.018.018 0 00.01-.024l-4.999-12.02z",
|
|
6119
|
-
fill: `url(#${gradientId}-blue)`
|
|
6120
|
-
}),
|
|
6121
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6122
|
-
d: "M12.81.07c2.8 1.528 6.037 2.214 10.33 2.575.028.002.036.039.012.051-.55.282-3.695 1.883-6.03 2.74-.626.23-1.256.443-1.876.64a.028.028 0 01-.033-.016L12.746.128c-.017-.04.027-.078.065-.058z",
|
|
6123
|
-
fill: `url(#${gradientId}-light-blue)`
|
|
6124
|
-
}),
|
|
6125
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6126
|
-
className: "cpk:fill-[#513C9F] cpk:dark:fill-[#B99AE8]",
|
|
6127
|
-
d: "M12.725.075c.046-.019.1.003.119.05l7.514 17.923a.091.091 0 01-.148.1l-.02-.03L12.675.195a.091.091 0 01.049-.12z"
|
|
6128
|
-
}),
|
|
6129
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6130
|
-
className: "cpk:fill-[#513C9F] cpk:dark:fill-[#B99AE8]",
|
|
6131
|
-
d: "M23.06 2.66c.044-.025.1-.01.125.034.025.044.009.1-.035.124v.001l-.008.004-.025.015-.1.054a41.384 41.384 0 01-1.811.92A47.05 47.05 0 0116.33 5.82c-1.954.674-3.97 1.197-5.497 1.552a66.27 66.27 0 01-2.38.507l-.138.026-.036.007h-.01l-.002.002a.091.091 0 11-.033-.18l.016.09-.015-.09h.002l.01-.002.035-.007.137-.025a66.16 66.16 0 002.373-.506c1.524-.354 3.533-.876 5.479-1.547a46.857 46.857 0 006.276-2.709c.166-.087.295-.156.381-.204l.099-.054.024-.014.008-.004z"
|
|
6132
|
-
}),
|
|
6133
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6134
|
-
className: "cpk:fill-[#ABABAB] cpk:dark:fill-[#D4D4D4]",
|
|
6135
|
-
d: "M13.838 2.272a.16.16 0 01.107.2l-2.72 9.055h6.4l.061.013a.16.16 0 010 .295l-.061.013h-6.541L.679 24.099l-.05.04a.16.16 0 01-.194-.245l10.43-12.285 2.773-9.23a.16.16 0 01.2-.107z"
|
|
6136
|
-
}),
|
|
6137
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
6138
|
-
d: "M7.809 21.461l-1.232.173c.638 1.69 1.949 2.427 3.514 2.427 3.831 0 2.661-4.334 4.883-4.334 1.61 0 .956 3.513 4.423 3.513 2.116 0 2.326-2.131 1.966-3.048l-.008-.016-.567-.868c-.037-.058-.127-.036-.133.032l-.106 1.053a1.01 1.01 0 00.003.219c.088.727.144 2.491-1.155 2.491-1.37 0-1.7-3.467-4.423-3.467-3.196 0-2.785 4.289-4.747 4.289-1.294 0-2.28-1.46-2.418-2.464z",
|
|
6139
|
-
fill: `url(#${gradientId}-tail)`
|
|
6140
|
-
}),
|
|
6141
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("defs", { children: [
|
|
6142
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("linearGradient", {
|
|
6143
|
-
gradientUnits: "userSpaceOnUse",
|
|
6144
|
-
id: `${gradientId}-purple`,
|
|
6145
|
-
x1: "17.852",
|
|
6146
|
-
x2: "14.202",
|
|
6147
|
-
y1: "1.467",
|
|
6148
|
-
y2: "11.504",
|
|
6149
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", { className: "cpk:[stop-color:#6430AB] cpk:dark:[stop-color:#B792F0]" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6150
|
-
className: "cpk:[stop-color:#AA89D8] cpk:dark:[stop-color:#D3BDF7]",
|
|
6151
|
-
offset: "1"
|
|
6152
|
-
})]
|
|
6153
|
-
}),
|
|
6154
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("linearGradient", {
|
|
6155
|
-
gradientUnits: "userSpaceOnUse",
|
|
6156
|
-
id: `${gradientId}-blue`,
|
|
6157
|
-
x1: "15.024",
|
|
6158
|
-
x2: "10.324",
|
|
6159
|
-
y1: "7.125",
|
|
6160
|
-
y2: "16.204",
|
|
6161
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", { className: "cpk:[stop-color:#005DBB] cpk:dark:[stop-color:#4D9FEF]" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6162
|
-
className: "cpk:[stop-color:#3D92E8] cpk:dark:[stop-color:#84C0FA]",
|
|
6163
|
-
offset: "1"
|
|
6164
|
-
})]
|
|
6165
|
-
}),
|
|
6166
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("linearGradient", {
|
|
6167
|
-
gradientUnits: "userSpaceOnUse",
|
|
6168
|
-
id: `${gradientId}-light-blue`,
|
|
6169
|
-
x1: "17.122",
|
|
6170
|
-
x2: "15.707",
|
|
6171
|
-
y1: "1.467",
|
|
6172
|
-
y2: "5.892",
|
|
6173
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", { className: "cpk:[stop-color:#1B70C4] cpk:dark:[stop-color:#61ACF2]" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6174
|
-
className: "cpk:[stop-color:#54A4F2] cpk:dark:[stop-color:#9ACDFF]",
|
|
6175
|
-
offset: "1"
|
|
6176
|
-
})]
|
|
6177
|
-
}),
|
|
6178
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("linearGradient", {
|
|
6179
|
-
gradientUnits: "userSpaceOnUse",
|
|
6180
|
-
id: `${gradientId}-tail`,
|
|
6181
|
-
x1: "6.577",
|
|
6182
|
-
x2: "21.506",
|
|
6183
|
-
y1: "21.758",
|
|
6184
|
-
y2: "21.758",
|
|
6185
|
-
children: [
|
|
6186
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", { className: "cpk:[stop-color:#4497EA] cpk:dark:[stop-color:#79BCF5]" }),
|
|
6187
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6188
|
-
className: "cpk:[stop-color:#1463B2] cpk:dark:[stop-color:#4594D8]",
|
|
6189
|
-
offset: ".255"
|
|
6190
|
-
}),
|
|
6191
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6192
|
-
className: "cpk:[stop-color:#0A437D] cpk:dark:[stop-color:#347CB7]",
|
|
6193
|
-
offset: ".499"
|
|
6194
|
-
}),
|
|
6195
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6196
|
-
className: "cpk:[stop-color:#2476C8] cpk:dark:[stop-color:#58A4E5]",
|
|
6197
|
-
offset: ".667"
|
|
6198
|
-
}),
|
|
6199
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
6200
|
-
className: "cpk:[stop-color:#0C549A] cpk:dark:[stop-color:#3C87C7]",
|
|
6201
|
-
offset: ".973"
|
|
6202
|
-
})
|
|
6203
|
-
]
|
|
6204
|
-
})
|
|
6205
|
-
] })
|
|
6206
|
-
]
|
|
6207
|
-
});
|
|
6208
|
-
}
|
|
6209
6636
|
(function(_CopilotChatAssistantMessage) {
|
|
6210
6637
|
_CopilotChatAssistantMessage.MarkdownRenderer = ({ content, className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(streamdown.Streamdown, {
|
|
6211
6638
|
className,
|
|
@@ -6263,30 +6690,7 @@ function CopilotKitColoredIcon() {
|
|
|
6263
6690
|
children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, { className: "cpk:size-[18px]" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Copy, { className: "cpk:size-[18px]" })
|
|
6264
6691
|
});
|
|
6265
6692
|
};
|
|
6266
|
-
_CopilotChatAssistantMessage.InspectorButton =
|
|
6267
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
6268
|
-
const primaryLabel = title || labels.assistantMessageToolbarInspectorLabel;
|
|
6269
|
-
const accessibleLabel = `${primaryLabel} (local only)`;
|
|
6270
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ToolbarButton, {
|
|
6271
|
-
"data-testid": "copilot-inspector-button",
|
|
6272
|
-
title: accessibleLabel,
|
|
6273
|
-
className: (0, tailwind_merge.twMerge)("cpk:w-auto cpk:gap-1.5 cpk:px-2", className),
|
|
6274
|
-
tooltipClassName: "cpk:max-w-64 cpk:text-left cpk:leading-4",
|
|
6275
|
-
tooltip: "View this message in the Inspector to get more information. This button and the inspector only display during local development (localhost, dev env).",
|
|
6276
|
-
...props,
|
|
6277
|
-
children: [
|
|
6278
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitColoredIcon, {}),
|
|
6279
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6280
|
-
className: "cpk:font-medium",
|
|
6281
|
-
children: primaryLabel
|
|
6282
|
-
}),
|
|
6283
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
6284
|
-
className: "cpk:text-xs cpk:text-muted-foreground",
|
|
6285
|
-
children: "(local only)"
|
|
6286
|
-
})
|
|
6287
|
-
]
|
|
6288
|
-
});
|
|
6289
|
-
};
|
|
6693
|
+
_CopilotChatAssistantMessage.InspectorButton = CopilotChatInspectorButton;
|
|
6290
6694
|
_CopilotChatAssistantMessage.ThumbsUpButton = ({ title, ...props }) => {
|
|
6291
6695
|
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
6292
6696
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
|
|
@@ -8536,9 +8940,15 @@ function useInspectorThreadOverride(args) {
|
|
|
8536
8940
|
|
|
8537
8941
|
//#endregion
|
|
8538
8942
|
//#region src/v2/components/chat/CopilotChat.tsx
|
|
8539
|
-
function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen, attachments: attachmentsConfig, onError, throttleMs, ...props }) {
|
|
8943
|
+
function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isModalDefaultOpen, attachments: attachmentsConfig, onError, throttleMs, ...props }) {
|
|
8540
8944
|
const existingConfig = useCopilotChatConfiguration();
|
|
8541
|
-
const
|
|
8945
|
+
const inspector = useCopilotKitInspector();
|
|
8946
|
+
const inspectorContextValue = (0, react.useMemo)(() => ({
|
|
8947
|
+
...inspector,
|
|
8948
|
+
isInspectorEnabled: inspector.isInspectorEnabled && (inspector.providerEnableInspector ?? inspectorTools ?? true)
|
|
8949
|
+
}), [inspector, inspectorTools]);
|
|
8950
|
+
const providerAgentId = (0, _copilotkit_react_core_v2_context.useDefaultAgentId)();
|
|
8951
|
+
const resolvedAgentId = agentId ?? existingConfig?.agentId ?? providerAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
8542
8952
|
const providedThreadId = threadId ?? existingConfig?.threadId;
|
|
8543
8953
|
const baseThreadId = (0, react.useMemo)(() => providedThreadId ?? (0, _copilotkit_shared.randomUUID)(), [providedThreadId]);
|
|
8544
8954
|
const baseHasExplicitThreadId = !!threadId || !!existingConfig?.hasExplicitThreadId;
|
|
@@ -9111,7 +9521,10 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
9111
9521
|
}),
|
|
9112
9522
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(LastUserMessageContext.Provider, {
|
|
9113
9523
|
value: lastUserMessageState,
|
|
9114
|
-
children:
|
|
9524
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitInspectorContextProvider, {
|
|
9525
|
+
value: inspectorContextValue,
|
|
9526
|
+
children: RenderedChatView
|
|
9527
|
+
})
|
|
9115
9528
|
})
|
|
9116
9529
|
]
|
|
9117
9530
|
})
|
|
@@ -9819,7 +10232,8 @@ function CopilotThreadsDrawer({ agentId, onThreadSelect, onNewThread, onLicensed
|
|
|
9819
10232
|
const featureLicensed = checkFeature("threads");
|
|
9820
10233
|
const licensed = licensePresent && featureLicensed;
|
|
9821
10234
|
const licensePending = status === null;
|
|
9822
|
-
const
|
|
10235
|
+
const providerAgentId = (0, _copilotkit_react_core_v2_context.useDefaultAgentId)();
|
|
10236
|
+
const resolvedAgentId = agentId ?? configuration?.agentId ?? providerAgentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
9823
10237
|
const activeThreadId = configuration?.threadId ?? null;
|
|
9824
10238
|
const { threads, isLoading, listError, fetchMoreError, hasMoreThreads, isFetchingMoreThreads, archiveThread, unarchiveThread, deleteThread, fetchMoreThreads, refetchThreads, startNewThread } = useThreads$1({
|
|
9825
10239
|
agentId: resolvedAgentId,
|
|
@@ -12793,4 +13207,4 @@ Object.defineProperty(exports, 'ɵrunMcpFollowUp', {
|
|
|
12793
13207
|
return ɵrunMcpFollowUp;
|
|
12794
13208
|
}
|
|
12795
13209
|
});
|
|
12796
|
-
//# sourceMappingURL=copilotkit-
|
|
13210
|
+
//# sourceMappingURL=copilotkit-B4Jb1QEy.cjs.map
|