@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.
Files changed (49) hide show
  1. package/dist/{copilotkit-DcFo270Y.cjs → copilotkit-B4Jb1QEy.cjs} +582 -168
  2. package/dist/copilotkit-B4Jb1QEy.cjs.map +1 -0
  3. package/dist/{copilotkit--Jyzm6hS.d.mts → copilotkit-ChjzWqn6.d.mts} +34 -9
  4. package/dist/copilotkit-ChjzWqn6.d.mts.map +1 -0
  5. package/dist/{copilotkit-BLYaCGcz.d.cts → copilotkit-DCIXZawe.d.cts} +34 -9
  6. package/dist/copilotkit-DCIXZawe.d.cts.map +1 -0
  7. package/dist/{copilotkit-B1jSvZeb.mjs → copilotkit-snbJkMqQ.mjs} +583 -169
  8. package/dist/copilotkit-snbJkMqQ.mjs.map +1 -0
  9. package/dist/index.cjs +3 -3
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +1 -1
  12. package/dist/index.d.cts.map +1 -1
  13. package/dist/index.d.mts +1 -1
  14. package/dist/index.d.mts.map +1 -1
  15. package/dist/index.mjs +4 -4
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/index.umd.js +393 -153
  18. package/dist/index.umd.js.map +1 -1
  19. package/dist/v2/context.cjs +4 -0
  20. package/dist/v2/context.cjs.map +1 -1
  21. package/dist/v2/context.d.cts +3 -1
  22. package/dist/v2/context.d.cts.map +1 -1
  23. package/dist/v2/context.d.mts +3 -1
  24. package/dist/v2/context.d.mts.map +1 -1
  25. package/dist/v2/context.mjs +3 -1
  26. package/dist/v2/context.mjs.map +1 -1
  27. package/dist/v2/headless.cjs +57 -6
  28. package/dist/v2/headless.cjs.map +1 -1
  29. package/dist/v2/headless.d.cts +9 -4
  30. package/dist/v2/headless.d.cts.map +1 -1
  31. package/dist/v2/headless.d.mts +9 -4
  32. package/dist/v2/headless.d.mts.map +1 -1
  33. package/dist/v2/headless.mjs +58 -7
  34. package/dist/v2/headless.mjs.map +1 -1
  35. package/dist/v2/index.cjs +1 -1
  36. package/dist/v2/index.css +1 -1
  37. package/dist/v2/index.d.cts +1 -1
  38. package/dist/v2/index.d.mts +1 -1
  39. package/dist/v2/index.mjs +1 -1
  40. package/dist/v2/index.umd.js +708 -292
  41. package/dist/v2/index.umd.js.map +1 -1
  42. package/package.json +7 -7
  43. package/skills/react-core/SKILL.md +1 -1
  44. package/skills/react-core/references/agent-access.md +69 -26
  45. package/skills/react-core/references/chat-components.md +22 -5
  46. package/dist/copilotkit--Jyzm6hS.d.mts.map +0 -1
  47. package/dist/copilotkit-B1jSvZeb.mjs.map +0 -1
  48. package/dist/copilotkit-BLYaCGcz.d.cts.map +0 -1
  49. package/dist/copilotkit-DcFo270Y.cjs.map +0 -1
@@ -1,10 +1,11 @@
1
1
  import * as React$1 from "react";
2
- import React, { createContext, forwardRef, memo, useCallback, useContext, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
2
+ import React, { createContext, createElement, forwardRef, memo, useCallback, useContext, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
3
3
  import { CopilotKitCore, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, ProxiedCopilotRuntimeAgent, ToolCallStatus, emitInspectorActiveThread, emitInspectorViewThreadResult, isInspectorThreadBridgeEnabled, isRunCompletionAware, onInspectorStopViewing, onInspectorViewThread, ɵInterruptState, ɵcreateThreadStore, ɵselectFetchMoreError, ɵselectHasNextPage, ɵselectIsFetchingNextPage, ɵselectIsMutating, ɵselectMemories, ɵselectMemoriesAvailable, ɵselectMemoriesError, ɵselectMemoriesIsLoading, ɵselectMemoriesRealtimeStatus, ɵselectThreads, ɵselectThreadsError, ɵselectThreadsIsLoading } from "@copilotkit/core";
4
4
  import { HttpAgent, randomUUID } from "@ag-ui/client";
5
5
  import { extendTailwindMerge, twMerge } from "tailwind-merge";
6
- import { ArrowUp, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronRightIcon, Copy, Edit, Loader2, MessageCircle, Mic, PanelLeftOpen, Play, Plus, RefreshCw, Square, ThumbsDown, ThumbsUp, Upload, Volume2, X } from "lucide-react";
6
+ import { ArrowUp, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronRightIcon, Copy, Edit, EyeOff, Loader2, MessageCircle, Mic, PanelLeftOpen, Play, Plus, RefreshCw, Square, ThumbsDown, ThumbsUp, Upload, Volume2, Wrench, X } from "lucide-react";
7
7
  import { A2UI_DEFAULT_DESIGN_GUIDELINES, A2UI_DEFAULT_GENERATION_GUIDELINES, COPILOT_CLOUD_API_URL, COPILOT_CLOUD_CHAT_URL, COPILOT_CLOUD_PUBLIC_API_KEY_HEADER, ConfigurationError, CopilotKitAgentDiscoveryError, CopilotKitApiDiscoveryError, CopilotKitError, CopilotKitErrorCode, CopilotKitLowLevelError, CopilotKitRemoteEndpointDiscoveryError, DEFAULT_AGENT_ID, ErrorVisibility, MissingPublicApiKeyError, Severity, TranscriptionErrorCode, TranscriptionErrorCode as TranscriptionErrorCode$1, copyToClipboard, createLicenseContextValue, dataToUUID, exceedsMaxSize, formatFileSize, generateVideoThumbnail, getDocumentIcon, getModalityFromMimeType, getSourceUrl, matchesAcceptFilter, parseJson, partialJSONParse, randomId, randomUUID as randomUUID$1, readFileAsBase64, schemaToJsonSchema, shouldEnableInspector } from "@copilotkit/shared";
8
+ import { CopilotKitAgentIdContext, CopilotKitContext, LicenseContext, useCopilotKit, useCopilotKit as useCopilotKit$1, useDefaultAgentId, useLicenseContext, useLicenseContext as useLicenseContext$1 } from "@copilotkit/react-core/v2/context";
8
9
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
9
10
  import { Slot } from "@radix-ui/react-slot";
10
11
  import { cva } from "class-variance-authority";
@@ -12,9 +13,8 @@ import { clsx } from "clsx";
12
13
  import * as TooltipPrimitive from "@radix-ui/react-tooltip";
13
14
  import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
14
15
  import { Streamdown } from "streamdown";
15
- import { CopilotKitContext, LicenseContext, useCopilotKit, useCopilotKit as useCopilotKit$1, useLicenseContext, useLicenseContext as useLicenseContext$1 } from "@copilotkit/react-core/v2/context";
16
16
  import { z } from "zod";
17
- import { A2UIProvider, A2UIRenderer, A2UI_SCHEMA_CONTEXT_DESCRIPTION, Catalog, DEFAULT_SURFACE_ID, buildCatalogContextValue, extractCatalogComponentSchemas, filterCatalog, initializeDefaultCatalog, injectStyles, useA2UIActions, useA2UIError, viewerTheme } from "@copilotkit/a2ui-renderer";
17
+ import { A2UIProvider, A2UIRenderer, A2UI_SCHEMA_CONTEXT_DESCRIPTION, Catalog, DEFAULT_SURFACE_ID, ROOT_COMPONENT_ID, buildCatalogContextValue, extractCatalogComponentSchemas, filterCatalog, initializeDefaultCatalog, injectStyles, useA2UIActions, useA2UIError, viewerTheme } from "@copilotkit/a2ui-renderer";
18
18
  import { zodToJsonSchema } from "zod-to-json-schema";
19
19
  import { createPortal, flushSync } from "react-dom";
20
20
  import { useVirtualizer } from "@tanstack/react-virtual";
@@ -76,7 +76,12 @@ const CopilotChatDefaultLabels = {
76
76
  assistantMessageToolbarCopyCodeCopiedLabel: "Copied",
77
77
  assistantMessageToolbarCopyMessageLabel: "Copy",
78
78
  assistantMessageToolbarInspectorLabel: "View in Inspector",
79
- assistantMessageToolbarInspectorLocalOnlyLabel: "Development Only",
79
+ assistantMessageToolbarInspectorDescription: "Open this message in the Inspector",
80
+ assistantMessageToolbarInspectorLocalOnlyLabel: "Local only",
81
+ assistantMessageToolbarInspectorLocalOnlyDescription: "Only visible on localhost or loopback hosts in development. Never shown in production.",
82
+ assistantMessageToolbarInspectorTitle: "CopilotKit Inspector",
83
+ assistantMessageToolbarInspectorHideLabel: "Hide this icon",
84
+ assistantMessageToolbarInspectorHideDescription: "Until you reload this page",
80
85
  assistantMessageToolbarThumbsUpLabel: "Good response",
81
86
  assistantMessageToolbarThumbsDownLabel: "Bad response",
82
87
  assistantMessageToolbarReadAloudLabel: "Read aloud",
@@ -117,7 +122,8 @@ const CopilotChatConfigurationProvider = ({ children, labels, agentId, threadId,
117
122
  ...parentConfig?.labels,
118
123
  ...stableLabels
119
124
  }), [stableLabels, parentConfig?.labels]);
120
- const resolvedAgentId = agentId ?? parentConfig?.agentId ?? DEFAULT_AGENT_ID;
125
+ const providerAgentId = useDefaultAgentId();
126
+ const resolvedAgentId = agentId ?? parentConfig?.agentId ?? providerAgentId ?? DEFAULT_AGENT_ID;
121
127
  const threadIdPropIsAuthoritative = threadId !== void 0 && hasExplicitThreadId !== false;
122
128
  const isThreadIdControlled = threadIdPropIsAuthoritative;
123
129
  const [activeThreadOverride, setActiveThreadOverride] = useState(null);
@@ -474,6 +480,14 @@ function DropdownMenuItem({ className, inset, variant = "default", ...props }) {
474
480
  ...props
475
481
  });
476
482
  }
483
+ function DropdownMenuLabel({ className, inset, ...props }) {
484
+ return /* @__PURE__ */ jsx(DropdownMenuPrimitive.Label, {
485
+ "data-slot": "dropdown-menu-label",
486
+ "data-inset": inset,
487
+ className: cn("cpk:px-2 cpk:py-1.5 cpk:text-sm cpk:font-medium cpk:data-[inset]:pl-8", className),
488
+ ...props
489
+ });
490
+ }
477
491
  function DropdownMenuSeparator({ className, ...props }) {
478
492
  return /* @__PURE__ */ jsx(DropdownMenuPrimitive.Separator, {
479
493
  "data-slot": "dropdown-menu-separator",
@@ -1519,6 +1533,29 @@ const ToolCallRenderer = React.memo(function ToolCallRenderer({ toolCall, toolMe
1519
1533
  if (prevProps.RenderComponent !== nextProps.RenderComponent) return false;
1520
1534
  return true;
1521
1535
  });
1536
+ const IS_DEVELOPMENT$1 = process.env.NODE_ENV !== "production";
1537
+ /**
1538
+ * Reports tool calls that resolved to no renderer.
1539
+ *
1540
+ * A tool call with no renderer paints an empty message container and says
1541
+ * nothing else, so the only signal a developer gets today is a blank space in
1542
+ * the chat. This names the call and the renderers that *are* registered, which
1543
+ * is the whole diagnosis when the cause is a name that does not match.
1544
+ *
1545
+ * @param toolNames - The unmatched tool names collected during render.
1546
+ * @param registered - The registry as it stands now, re-read at report time.
1547
+ * @param alreadyWarned - Names already reported, mutated to keep this once per name.
1548
+ */
1549
+ function warnAboutUnrenderedToolCalls(toolNames, registered, alreadyWarned) {
1550
+ const registeredNames = Array.from(new Set(registered.map((rc) => rc.name)));
1551
+ const hasWildcard = registeredNames.includes("*");
1552
+ for (const toolName of toolNames) {
1553
+ if (hasWildcard || registeredNames.includes(toolName)) continue;
1554
+ if (alreadyWarned.has(toolName)) continue;
1555
+ alreadyWarned.add(toolName);
1556
+ 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.`);
1557
+ }
1558
+ }
1522
1559
  /**
1523
1560
  * Hook that returns a function to render tool calls based on the render functions
1524
1561
  * defined in CopilotKitProvider.
@@ -1528,13 +1565,18 @@ const ToolCallRenderer = React.memo(function ToolCallRenderer({ toolCall, toolMe
1528
1565
  function useRenderToolCall() {
1529
1566
  const { copilotkit, executingToolCallIds } = useCopilotKit();
1530
1567
  const agentId = useCopilotChatConfiguration()?.agentId ?? DEFAULT_AGENT_ID;
1568
+ const unrenderedToolNames = useRef(/* @__PURE__ */ new Set());
1569
+ const warnedToolNames = useRef(/* @__PURE__ */ new Set());
1531
1570
  const renderToolCalls = useSyncExternalStore((callback) => {
1532
1571
  return copilotkit.subscribe({ onRenderToolCallsChanged: callback }).unsubscribe;
1533
1572
  }, () => copilotkit.renderToolCalls, () => copilotkit.renderToolCalls);
1534
- return useCallback(({ toolCall, toolMessage }) => {
1573
+ const renderToolCall = useCallback(({ toolCall, toolMessage }) => {
1535
1574
  const exactMatches = renderToolCalls.filter((rc) => rc.name === toolCall.function.name);
1536
1575
  const renderConfig = exactMatches.find((rc) => rc.agentId === agentId) || exactMatches.find((rc) => !rc.agentId) || exactMatches[0] || renderToolCalls.find((rc) => rc.name === "*");
1537
- if (!renderConfig) return null;
1576
+ if (!renderConfig) {
1577
+ if (IS_DEVELOPMENT$1) unrenderedToolNames.current.add(toolCall.function.name);
1578
+ return null;
1579
+ }
1538
1580
  const RenderComponent = renderConfig.render;
1539
1581
  return /* @__PURE__ */ jsx(ToolCallRenderer, {
1540
1582
  toolCall,
@@ -1547,25 +1589,43 @@ function useRenderToolCall() {
1547
1589
  executingToolCallIds,
1548
1590
  agentId
1549
1591
  ]);
1592
+ useEffect(() => {
1593
+ if (!IS_DEVELOPMENT$1) return;
1594
+ if (unrenderedToolNames.current.size === 0) return;
1595
+ const timer = setTimeout(() => {
1596
+ const pending = Array.from(unrenderedToolNames.current);
1597
+ unrenderedToolNames.current.clear();
1598
+ warnAboutUnrenderedToolCalls(pending, copilotkit.renderToolCalls, warnedToolNames.current);
1599
+ }, 0);
1600
+ return () => clearTimeout(timer);
1601
+ });
1602
+ return renderToolCall;
1550
1603
  }
1551
1604
 
1552
1605
  //#endregion
1553
1606
  //#region src/v2/components/CopilotKitInspector.tsx
1554
- const CopilotKitInspector = ({ core, openRequest }) => {
1607
+ const CopilotKitInspector = ({ core, openRequest, onVisibilityChange }) => {
1555
1608
  const mountRef = React$1.useRef(null);
1556
1609
  const inspectorRef = React$1.useRef(null);
1557
1610
  const latestCoreRef = React$1.useRef(core ?? null);
1558
1611
  const latestOpenRequestRef = React$1.useRef(openRequest);
1612
+ const visibilityCallbackRef = React$1.useRef(onVisibilityChange);
1613
+ visibilityCallbackRef.current = onVisibilityChange;
1559
1614
  latestCoreRef.current = core ?? null;
1560
1615
  latestOpenRequestRef.current = openRequest;
1561
1616
  React$1.useEffect(() => {
1562
1617
  let mounted = true;
1563
1618
  let inspector = null;
1619
+ const handleVisibilityChange = (event) => {
1620
+ const visible = event.detail?.visible;
1621
+ visibilityCallbackRef.current?.(visible === true);
1622
+ };
1564
1623
  import("@copilotkit/web-inspector").then((mod) => {
1565
1624
  if (!mounted || !mountRef.current) return;
1566
1625
  mod.defineWebInspector?.();
1567
1626
  inspector = mountRef.current.ownerDocument.createElement(mod.WEB_INSPECTOR_TAG);
1568
1627
  mod.configureWebInspectorElement(inspector, latestCoreRef.current);
1628
+ inspector.addEventListener("cpk-inspector-visibility-change", handleVisibilityChange);
1569
1629
  mountRef.current.appendChild(inspector);
1570
1630
  inspectorRef.current = inspector;
1571
1631
  const request = latestOpenRequestRef.current;
@@ -1575,7 +1635,9 @@ const CopilotKitInspector = ({ core, openRequest }) => {
1575
1635
  });
1576
1636
  return () => {
1577
1637
  mounted = false;
1638
+ inspector?.removeEventListener("cpk-inspector-visibility-change", handleVisibilityChange);
1578
1639
  inspector?.remove();
1640
+ visibilityCallbackRef.current?.(false);
1579
1641
  if (inspectorRef.current === inspector) inspectorRef.current = null;
1580
1642
  };
1581
1643
  }, []);
@@ -3025,6 +3087,95 @@ const A2UISurfaceContentSchema = z.object({
3025
3087
  a2ui_operations: z.array(z.any()).optional(),
3026
3088
  ...A2UILifecycleFields
3027
3089
  }).passthrough();
3090
+ const IS_DEVELOPMENT = process.env.NODE_ENV !== "production";
3091
+ /**
3092
+ * How long to wait for a surface to report its first paint before giving up on
3093
+ * the loader cross-over. Reaching it also means `onReady` never fired, which is
3094
+ * the signal the warning below reports.
3095
+ */
3096
+ const PAINT_FALLBACK_MS = 8e3;
3097
+ /**
3098
+ * Names the operation kinds a surface received, for a warning that has to say
3099
+ * what did arrive as well as what did not.
3100
+ *
3101
+ * @param operations - The operations grouped under one surface.
3102
+ * @returns A comma-separated list of operation keys, or "none".
3103
+ */
3104
+ function describeOperationKinds(operations) {
3105
+ const kinds = /* @__PURE__ */ new Set();
3106
+ for (const operation of operations) {
3107
+ if (!operation || typeof operation !== "object") continue;
3108
+ for (const key of Object.keys(operation)) if (key !== "version") kinds.add(key);
3109
+ }
3110
+ return kinds.size === 0 ? "none" : Array.from(kinds).join(", ");
3111
+ }
3112
+ /**
3113
+ * Reports surfaces that received operations and never painted.
3114
+ *
3115
+ * Reaching {@link PAINT_FALLBACK_MS} with no `onReady` means the operations were
3116
+ * accepted, were not malformed enough to raise the provider's error state, and
3117
+ * still put nothing on screen. Left alone that is invisible: the loader drops,
3118
+ * the turn finishes, and the only trace is an empty placeholder above the reply.
3119
+ *
3120
+ * `surfaceHasRenderableContent` already knows which half is missing, so the
3121
+ * warning says which rather than making the reader re-derive it.
3122
+ *
3123
+ * @param grouped - Operations grouped by surface id.
3124
+ */
3125
+ function warnAboutUnpaintedSurfaces(grouped) {
3126
+ for (const [surfaceId, operations] of grouped) {
3127
+ if (surfaceHasRenderableContent(operations)) continue;
3128
+ 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";
3129
+ 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.`);
3130
+ }
3131
+ }
3132
+ /**
3133
+ * Names the component ids a surface was sent, for a warning about the one id
3134
+ * that is missing.
3135
+ *
3136
+ * @param operations - The operations grouped under one surface.
3137
+ * @returns A quoted, comma-separated list of ids, or "none".
3138
+ */
3139
+ function describeComponentIds(operations) {
3140
+ const ids = [];
3141
+ for (const operation of operations) {
3142
+ const components = operation?.updateComponents?.components;
3143
+ if (!Array.isArray(components)) continue;
3144
+ for (const component of components) {
3145
+ const id = component?.id;
3146
+ if (typeof id === "string" && !ids.includes(id)) ids.push(id);
3147
+ }
3148
+ }
3149
+ return ids.length === 0 ? "none" : ids.map((id) => `"${id}"`).join(", ");
3150
+ }
3151
+ /**
3152
+ * Reports a surface that is still waiting for its {@link ROOT_COMPONENT_ID}
3153
+ * component once its operations have stopped arriving.
3154
+ *
3155
+ * Both renderers begin walking a surface at that one id, and treat an id they
3156
+ * cannot find as not arrived yet — an animated placeholder. That is right while
3157
+ * operations stream. Once they have stopped it is not waiting, it is stuck, and
3158
+ * every other check calls it healthy: the surface exists, `processMessages` did
3159
+ * not throw, the component types were never reached, and
3160
+ * `surfaceHasRenderableContent` says yes on the strength of components plus a
3161
+ * data model, so `onReady` fires and the never-painted report is suppressed.
3162
+ * A complete, accepted payload therefore animates a grey box forever in silence.
3163
+ *
3164
+ * Reads the live components model rather than scanning the operations for the
3165
+ * id, so it covers every way the root can fail to resolve — not only a payload
3166
+ * that never named one.
3167
+ *
3168
+ * @param surfaceId - The surface the operations were addressed to.
3169
+ * @param operations - The operations processed for that surface.
3170
+ * @param surface - The live surface model, already known to exist.
3171
+ */
3172
+ function warnAboutUnresolvedRoot(surfaceId, operations, surface) {
3173
+ if (surface?.componentsModel?.get?.(ROOT_COMPONENT_ID)) return;
3174
+ const componentOps = operations.filter((o) => o?.updateComponents);
3175
+ if (componentOps.length === 0) return;
3176
+ const cause = componentOps.some((o) => o.updateComponents?.components?.some?.((c) => c?.id === ROOT_COMPONENT_ID)) ? `a component with id "${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 "${ROOT_COMPONENT_ID}" — rename the entry-point component to "${ROOT_COMPONENT_ID}", and make every other component reachable from it through child/children`;
3177
+ console.warn(`[CopilotKit] A2UI surface "${surfaceId}" has no "${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.`);
3178
+ }
3028
3179
  function createA2UIMessageRenderer(options) {
3029
3180
  const { theme, catalog, loadingComponent, recovery, onAction } = options;
3030
3181
  const showAfterMs = recovery?.showAfterMs ?? 2e3;
@@ -3058,6 +3209,8 @@ function createA2UIMessageRenderer(options) {
3058
3209
  return groups;
3059
3210
  }, [operations]);
3060
3211
  const hasOps = groupedOperations.size > 0;
3212
+ const groupedOperationsRef = useRef(groupedOperations);
3213
+ groupedOperationsRef.current = groupedOperations;
3061
3214
  const renderLifecycle = (c) => {
3062
3215
  const status = c?.status;
3063
3216
  const debugExposure = resolveDebugExposure(c, optionDebugExposure);
@@ -3089,7 +3242,10 @@ function createA2UIMessageRenderer(options) {
3089
3242
  readyRef.current = false;
3090
3243
  return;
3091
3244
  }
3092
- const t = setTimeout(() => setSurfaceReady(true), 8e3);
3245
+ const t = setTimeout(() => {
3246
+ setSurfaceReady(true);
3247
+ if (IS_DEVELOPMENT && !readyRef.current) warnAboutUnpaintedSurfaces(groupedOperationsRef.current);
3248
+ }, PAINT_FALLBACK_MS);
3093
3249
  return () => clearTimeout(t);
3094
3250
  }, [hasOps]);
3095
3251
  if (!hasOps) return renderLifecycle(content);
@@ -3213,8 +3369,21 @@ function SurfaceMessageProcessor({ surfaceId, operations, onReady }) {
3213
3369
  const hash = JSON.stringify(operations);
3214
3370
  if (hash === lastHashRef.current) return;
3215
3371
  lastHashRef.current = hash;
3216
- processMessages(getSurface(surfaceId) ? operations.filter((op) => !op?.createSurface) : operations);
3372
+ const ops = getSurface(surfaceId) ? operations.filter((op) => !op?.createSurface) : operations;
3373
+ processMessages(ops);
3217
3374
  if (onReady && surfaceHasRenderableContent(operations)) onReady();
3375
+ if (!IS_DEVELOPMENT) return;
3376
+ if (!getSurface(surfaceId)) {
3377
+ const missingSurfaceCheck = setTimeout(() => {
3378
+ if (getSurface(surfaceId)) return;
3379
+ 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.`);
3380
+ }, 0);
3381
+ return () => clearTimeout(missingSurfaceCheck);
3382
+ }
3383
+ const unresolvedRootCheck = setTimeout(() => {
3384
+ warnAboutUnresolvedRoot(surfaceId, operations, getSurface(surfaceId));
3385
+ }, PAINT_FALLBACK_MS);
3386
+ return () => clearTimeout(unresolvedRootCheck);
3218
3387
  }, [
3219
3388
  processMessages,
3220
3389
  getSurface,
@@ -3241,10 +3410,26 @@ function surfaceHasRenderableContent(operations) {
3241
3410
  return Object.values(v).some((x) => Array.isArray(x) ? x.length > 0 : x !== null && x !== void 0 && x !== "");
3242
3411
  });
3243
3412
  }
3413
+ /**
3414
+ * Resolves the surface an operation addresses.
3415
+ *
3416
+ * The nested v0.9 `surfaceId` wins, because that is the id `MessageProcessor`
3417
+ * creates the surface under. Grouping by a top-level `surfaceId` instead files
3418
+ * the operations against a surface that never exists, which paints nothing —
3419
+ * the silence the missing-surface report above now names. A top-level
3420
+ * `surfaceId` is not the v0.9 shape, so it is honoured only when no nested id is
3421
+ * present. `getSurfaceId` in `@copilotkit/a2ui-renderer`'s web-components path
3422
+ * resolves it in the same order; the two disagreeing is what OSS-1048 recorded.
3423
+ *
3424
+ * @param operation - One A2UI operation, of any shape.
3425
+ * @returns The surface id, or null when the operation names none.
3426
+ */
3244
3427
  function getOperationSurfaceId(operation) {
3245
3428
  if (!operation || typeof operation !== "object") return null;
3429
+ const nested = operation?.createSurface?.surfaceId ?? operation?.updateComponents?.surfaceId ?? operation?.updateDataModel?.surfaceId ?? operation?.deleteSurface?.surfaceId;
3430
+ if (typeof nested === "string") return nested;
3246
3431
  if (typeof operation.surfaceId === "string") return operation.surfaceId;
3247
- return operation?.createSurface?.surfaceId ?? operation?.updateComponents?.surfaceId ?? operation?.updateDataModel?.surfaceId ?? operation?.deleteSurface?.surfaceId ?? null;
3432
+ return null;
3248
3433
  }
3249
3434
 
3250
3435
  //#endregion
@@ -3458,6 +3643,9 @@ const COPILOT_CLOUD_CHAT_URL$1 = "https://api.cloud.copilotkit.ai/copilotkit/v1"
3458
3643
  const EMPTY_HEADERS = Object.freeze({});
3459
3644
  const EMPTY_PROPERTIES = Object.freeze({});
3460
3645
  const EMPTY_AGENTS = Object.freeze({});
3646
+ /** Registration name of a catch-all tool: handles any otherwise-unhandled call. */
3647
+ const WILDCARD_TOOL_NAME$1 = "*";
3648
+ const HUMAN_IN_THE_LOOP_ABORTED_MESSAGE = "Human-in-the-loop interaction aborted";
3461
3649
  const DEFAULT_DESIGN_SKILL = `When generating UI with generateSandboxedUi, follow these design principles inspired by shadcn/ui:
3462
3650
 
3463
3651
  - Use a minimal, flat aesthetic. Avoid drop shadows and gradients — rely on subtle borders (1px solid, light gray like #e5e7eb) to define surfaces.
@@ -3478,14 +3666,19 @@ function useStableArrayProp(prop, warningMessage, isMeaningfulChange) {
3478
3666
  }, [value, warningMessage]);
3479
3667
  return value;
3480
3668
  }
3481
- 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 }) => {
3669
+ 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 }) => {
3482
3670
  const [shouldRenderInspector, setShouldRenderInspector] = useState(false);
3671
+ const [inspectorVisible, setInspectorVisible] = useState(false);
3483
3672
  useEffect(() => {
3484
3673
  setShouldRenderInspector(shouldEnableInspector({
3485
3674
  enableInspector,
3486
3675
  isBrowser: true,
3487
3676
  isDevelopment: process.env.NODE_ENV === "development"
3488
- }));
3677
+ }) && [
3678
+ "localhost",
3679
+ "127.0.0.1",
3680
+ "[::1]"
3681
+ ].includes(window.location.hostname));
3489
3682
  }, [enableInspector]);
3490
3683
  const [inspectorOpenRequest, setInspectorOpenRequest] = useState(null);
3491
3684
  const [runtimeA2UIEnabled, setRuntimeA2UIEnabled] = useState(false);
@@ -3501,9 +3694,15 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3501
3694
  setInspectorOpenRequest({ ...request });
3502
3695
  }, []);
3503
3696
  const inspectorContextValue = useMemo(() => ({
3504
- isInspectorEnabled: shouldRenderInspector,
3697
+ providerEnableInspector: enableInspector,
3698
+ isInspectorEnabled: shouldRenderInspector && inspectorVisible,
3505
3699
  openInspector: requestInspectorOpen
3506
- }), [shouldRenderInspector, requestInspectorOpen]);
3700
+ }), [
3701
+ enableInspector,
3702
+ shouldRenderInspector,
3703
+ inspectorVisible,
3704
+ requestInspectorOpen
3705
+ ]);
3507
3706
  const renderToolCallsList = useStableArrayProp(renderToolCalls, "renderToolCalls must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead.", (initial, next) => {
3508
3707
  const key = (rc) => `${rc?.agentId ?? ""}:${rc?.name ?? ""}`;
3509
3708
  const setFrom = (arr) => new Set(arr.map(key));
@@ -3576,6 +3775,11 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3576
3775
  }
3577
3776
  const chatApiEndpoint = runtimeUrl ?? (resolvedPublicKey ? COPILOT_CLOUD_CHAT_URL$1 : void 0);
3578
3777
  const frontendToolsList = useStableArrayProp(frontendTools, "frontendTools must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead.");
3778
+ /**
3779
+ * A `humanInTheLoop` prop tool call that is parked, waiting on the user.
3780
+ * Keyed by tool call id, so parallel calls of one tool stay independent.
3781
+ */
3782
+ const pendingHumanInTheLoopRef = useRef(/* @__PURE__ */ new Map());
3579
3783
  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.");
3580
3784
  const sandboxFunctionsList = useStableArrayProp(openGenerativeUI?.sandboxFunctions, "openGenerativeUI.sandboxFunctions must be a stable array.");
3581
3785
  const processedHumanInTheLoopTools = useMemo(() => {
@@ -3588,20 +3792,52 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3588
3792
  parameters: tool.parameters,
3589
3793
  followUp: tool.followUp,
3590
3794
  ...tool.agentId && { agentId: tool.agentId },
3591
- handler: async () => {
3592
- return new Promise((resolve) => {
3593
- console.warn(`Human-in-the-loop tool '${tool.name}' called but no interactive handler is set up.`);
3594
- resolve(void 0);
3795
+ handler: async (_args, context) => {
3796
+ const signal = context?.signal;
3797
+ const key = context?.toolCall?.id ?? tool.name;
3798
+ return new Promise((resolve, reject) => {
3799
+ if (signal?.aborted) {
3800
+ reject(new Error(HUMAN_IN_THE_LOOP_ABORTED_MESSAGE));
3801
+ return;
3802
+ }
3803
+ const pending = { resolve };
3804
+ pendingHumanInTheLoopRef.current.set(key, pending);
3805
+ if (signal) {
3806
+ const onAbort = () => {
3807
+ pendingHumanInTheLoopRef.current.delete(key);
3808
+ reject(new Error(HUMAN_IN_THE_LOOP_ABORTED_MESSAGE));
3809
+ };
3810
+ signal.addEventListener("abort", onAbort, { once: true });
3811
+ pending.detachAbort = () => {
3812
+ signal.removeEventListener("abort", onAbort);
3813
+ };
3814
+ }
3595
3815
  });
3596
3816
  }
3597
3817
  };
3598
3818
  processedTools.push(frontendTool);
3599
- if (tool.render) processedRenderToolCalls.push({
3600
- name: tool.name,
3601
- args: tool.parameters,
3602
- render: tool.render,
3603
- ...tool.agentId && { agentId: tool.agentId }
3604
- });
3819
+ if (tool.render) {
3820
+ const ToolComponent = tool.render;
3821
+ const RenderComponent = (props) => createElement(ToolComponent, {
3822
+ ...props,
3823
+ name: tool.name === WILDCARD_TOOL_NAME$1 ? props.name : tool.name,
3824
+ description: tool.description || "",
3825
+ agentId: tool.agentId,
3826
+ respond: props.status === ToolCallStatus.Executing ? async (result) => {
3827
+ const pending = pendingHumanInTheLoopRef.current.get(props.toolCallId);
3828
+ if (!pending) return;
3829
+ pending.detachAbort?.();
3830
+ pendingHumanInTheLoopRef.current.delete(props.toolCallId);
3831
+ pending.resolve(result);
3832
+ } : void 0
3833
+ });
3834
+ processedRenderToolCalls.push({
3835
+ name: tool.name,
3836
+ args: tool.parameters,
3837
+ render: RenderComponent,
3838
+ ...tool.agentId && { agentId: tool.agentId }
3839
+ });
3840
+ }
3605
3841
  });
3606
3842
  return {
3607
3843
  tools: processedTools,
@@ -3863,9 +4099,13 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3863
4099
  }),
3864
4100
  /* @__PURE__ */ jsxs(CopilotKitInspectorContextProvider, {
3865
4101
  value: inspectorContextValue,
3866
- children: [children, shouldRenderInspector ? /* @__PURE__ */ jsx(CopilotKitInspector, {
4102
+ children: [/* @__PURE__ */ jsx(CopilotKitAgentIdContext.Provider, {
4103
+ value: agentId,
4104
+ children
4105
+ }), shouldRenderInspector ? /* @__PURE__ */ jsx(CopilotKitInspector, {
3867
4106
  core: copilotkit,
3868
- openRequest: inspectorOpenRequest
4107
+ openRequest: inspectorOpenRequest,
4108
+ onVisibilityChange: setInspectorVisible
3869
4109
  }) : null]
3870
4110
  }),
3871
4111
  runtimeLicenseWarningStatus === "none" && !resolvedPublicKey && /* @__PURE__ */ jsx(LicenseWarningBanner, { type: "no_license" }),
@@ -4447,7 +4687,8 @@ function useAgent({ agentId, threadId, runtimeAgentId, updates, throttleMs } = {
4447
4687
  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}" }).`);
4448
4688
  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 "${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 }).`);
4449
4689
  const chatConfig = useCopilotChatConfiguration();
4450
- const resolvedAgentId = agentId ?? chatConfig?.agentId ?? DEFAULT_AGENT_ID;
4690
+ const providerAgentId = useDefaultAgentId();
4691
+ const resolvedAgentId = agentId ?? chatConfig?.agentId ?? providerAgentId ?? DEFAULT_AGENT_ID;
4451
4692
  const { copilotkit } = useCopilotKit();
4452
4693
  const providerThrottleMs = copilotkit.defaultThrottleMs;
4453
4694
  const [, forceUpdate] = useReducer((x) => x + 1, 0);
@@ -4675,7 +4916,12 @@ function useAgentContext(context) {
4675
4916
  function useSuggestions({ agentId } = {}) {
4676
4917
  const { copilotkit } = useCopilotKit();
4677
4918
  const config = useCopilotChatConfiguration();
4678
- const resolvedAgentId = useMemo(() => agentId ?? config?.agentId ?? DEFAULT_AGENT_ID, [agentId, config?.agentId]);
4919
+ const providerAgentId = useDefaultAgentId();
4920
+ const resolvedAgentId = useMemo(() => agentId ?? config?.agentId ?? providerAgentId ?? DEFAULT_AGENT_ID, [
4921
+ agentId,
4922
+ config?.agentId,
4923
+ providerAgentId
4924
+ ]);
4679
4925
  const [suggestions, setSuggestions] = useState(() => {
4680
4926
  return copilotkit.getSuggestions(resolvedAgentId).suggestions;
4681
4927
  });
@@ -5979,6 +6225,289 @@ function CopilotChatToolCallsView({ message, messages = [] }) {
5979
6225
  }) });
5980
6226
  }
5981
6227
 
6228
+ //#endregion
6229
+ //#region src/v2/components/chat/CopilotChatInspectorButton.tsx
6230
+ let shortcutsHidden = false;
6231
+ const listeners = /* @__PURE__ */ new Set();
6232
+ const subscribe = (listener) => {
6233
+ listeners.add(listener);
6234
+ return () => {
6235
+ listeners.delete(listener);
6236
+ };
6237
+ };
6238
+ const getSnapshot = () => shortcutsHidden;
6239
+ const getServerSnapshot = () => false;
6240
+ function useInspectorShortcutsHidden() {
6241
+ return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
6242
+ }
6243
+ function hideShortcuts() {
6244
+ shortcutsHidden = true;
6245
+ listeners.forEach((listener) => listener());
6246
+ }
6247
+ function InspectorKiteIcon({ className, ...props }) {
6248
+ const id = useId();
6249
+ return /* @__PURE__ */ jsxs("svg", {
6250
+ ...props,
6251
+ "aria-hidden": "true",
6252
+ className: twMerge("cpk:size-4", className),
6253
+ viewBox: "4.57 3.36 17.8 17.8",
6254
+ fill: "none",
6255
+ children: [
6256
+ /* @__PURE__ */ jsx("path", {
6257
+ 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",
6258
+ fill: `url(#${id}-paint0_linear)`
6259
+ }),
6260
+ /* @__PURE__ */ jsx("path", {
6261
+ 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",
6262
+ fill: `url(#${id}-paint1_linear)`
6263
+ }),
6264
+ /* @__PURE__ */ jsx("path", {
6265
+ 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",
6266
+ fill: `url(#${id}-paint2_linear)`
6267
+ }),
6268
+ /* @__PURE__ */ jsx("path", {
6269
+ d: "M10.7145 3.79041L17.8305 20.7659",
6270
+ stroke: "#513C9F",
6271
+ strokeWidth: "0.17284",
6272
+ strokeLinecap: "round"
6273
+ }),
6274
+ /* @__PURE__ */ jsx("path", {
6275
+ 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",
6276
+ stroke: "#513C9F",
6277
+ strokeWidth: "0.17284",
6278
+ strokeLinecap: "round"
6279
+ }),
6280
+ /* @__PURE__ */ jsx("path", {
6281
+ d: "M11.6914 5.93518L9.05534 14.7068M9.05534 14.7068H15.3203M9.05534 14.7068L0.15625 26.3646",
6282
+ stroke: "#ABABAB",
6283
+ strokeWidth: "0.302474",
6284
+ strokeLinecap: "round"
6285
+ }),
6286
+ /* @__PURE__ */ jsx("path", {
6287
+ 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",
6288
+ fill: `url(#${id}-paint3_linear)`
6289
+ }),
6290
+ /* @__PURE__ */ jsxs("defs", { children: [
6291
+ /* @__PURE__ */ jsxs("linearGradient", {
6292
+ id: `${id}-paint0_linear`,
6293
+ x1: "15.5372",
6294
+ y1: "5.0278",
6295
+ x2: "12.0802",
6296
+ y2: "14.534",
6297
+ gradientUnits: "userSpaceOnUse",
6298
+ children: [/* @__PURE__ */ jsx("stop", { stopColor: "#6430AB" }), /* @__PURE__ */ jsx("stop", {
6299
+ offset: "1",
6300
+ stopColor: "#AA89D8"
6301
+ })]
6302
+ }),
6303
+ /* @__PURE__ */ jsxs("linearGradient", {
6304
+ id: `${id}-paint1_linear`,
6305
+ x1: "12.8583",
6306
+ y1: "10.3858",
6307
+ x2: "8.40764",
6308
+ y2: "18.9846",
6309
+ gradientUnits: "userSpaceOnUse",
6310
+ children: [/* @__PURE__ */ jsx("stop", { stopColor: "#005DBB" }), /* @__PURE__ */ jsx("stop", {
6311
+ offset: "1",
6312
+ stopColor: "#3D92E8"
6313
+ })]
6314
+ }),
6315
+ /* @__PURE__ */ jsxs("linearGradient", {
6316
+ id: `${id}-paint2_linear`,
6317
+ x1: "14.8452",
6318
+ y1: "5.02774",
6319
+ x2: "13.5047",
6320
+ y2: "9.21911",
6321
+ gradientUnits: "userSpaceOnUse",
6322
+ children: [/* @__PURE__ */ jsx("stop", { stopColor: "#1B70C4" }), /* @__PURE__ */ jsx("stop", {
6323
+ offset: "1",
6324
+ stopColor: "#54A4F2"
6325
+ })]
6326
+ }),
6327
+ /* @__PURE__ */ jsxs("linearGradient", {
6328
+ id: `${id}-paint3_linear`,
6329
+ x1: "4.85806",
6330
+ y1: "24.2455",
6331
+ x2: "18.9963",
6332
+ y2: "24.2455",
6333
+ gradientUnits: "userSpaceOnUse",
6334
+ children: [
6335
+ /* @__PURE__ */ jsx("stop", { stopColor: "#4497EA" }),
6336
+ /* @__PURE__ */ jsx("stop", {
6337
+ offset: "0.254755",
6338
+ stopColor: "#1463B2"
6339
+ }),
6340
+ /* @__PURE__ */ jsx("stop", {
6341
+ offset: "0.498725",
6342
+ stopColor: "#0A437D"
6343
+ }),
6344
+ /* @__PURE__ */ jsx("stop", {
6345
+ offset: "0.666667",
6346
+ stopColor: "#2476C8"
6347
+ }),
6348
+ /* @__PURE__ */ jsx("stop", {
6349
+ offset: "0.972542",
6350
+ stopColor: "#0C549A"
6351
+ })
6352
+ ]
6353
+ })
6354
+ ] })
6355
+ ]
6356
+ });
6357
+ }
6358
+ function CopilotChatInspectorButton({ title, className, onClick, onPointerDown, onPointerEnter, onPointerLeave, onKeyDown, disabled, ...props }) {
6359
+ const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
6360
+ const { isInspectorEnabled } = useCopilotKitInspector();
6361
+ const hidden = useInspectorShortcutsHidden();
6362
+ const [open, setOpen] = useState(false);
6363
+ const [dark, setDark] = useState(false);
6364
+ const trigger = useRef(null);
6365
+ const closeTimer = useRef(null);
6366
+ const openedByHover = useRef(false);
6367
+ const primaryLabel = title || labels.assistantMessageToolbarInspectorLabel;
6368
+ const cancelClose = () => {
6369
+ if (closeTimer.current !== null) clearTimeout(closeTimer.current);
6370
+ closeTimer.current = null;
6371
+ };
6372
+ useEffect(() => cancelClose, []);
6373
+ const changeOpen = (next) => {
6374
+ cancelClose();
6375
+ if (next) setDark(!!trigger.current?.closest(".dark"));
6376
+ setOpen(next);
6377
+ };
6378
+ const scheduleClose = () => {
6379
+ cancelClose();
6380
+ closeTimer.current = setTimeout(() => {
6381
+ if (openedByHover.current) setOpen(false);
6382
+ }, 180);
6383
+ };
6384
+ if (!isInspectorEnabled || hidden) return null;
6385
+ return /* @__PURE__ */ jsxs(DropdownMenu, {
6386
+ open,
6387
+ onOpenChange: changeOpen,
6388
+ modal: false,
6389
+ children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
6390
+ asChild: true,
6391
+ children: /* @__PURE__ */ jsx(Button, {
6392
+ ...props,
6393
+ ref: trigger,
6394
+ type: "button",
6395
+ disabled,
6396
+ variant: "assistantMessageToolbarButton",
6397
+ size: "icon",
6398
+ "data-testid": "copilot-inspector-button",
6399
+ "aria-label": `${labels.assistantMessageToolbarInspectorTitle} (${labels.assistantMessageToolbarInspectorLocalOnlyLabel.toLowerCase()})`,
6400
+ className: twMerge("cpk:size-8 cpk:p-1.5", className),
6401
+ onPointerEnter: (event) => {
6402
+ onPointerEnter?.(event);
6403
+ if (!disabled && event.pointerType !== "touch") {
6404
+ openedByHover.current = true;
6405
+ changeOpen(true);
6406
+ }
6407
+ },
6408
+ onPointerLeave: (event) => {
6409
+ onPointerLeave?.(event);
6410
+ scheduleClose();
6411
+ },
6412
+ onPointerDown: (event) => {
6413
+ onPointerDown?.(event);
6414
+ event.preventDefault();
6415
+ },
6416
+ onClick: (event) => {
6417
+ changeOpen(false);
6418
+ onClick?.(event);
6419
+ },
6420
+ onKeyDown: (event) => {
6421
+ openedByHover.current = false;
6422
+ onKeyDown?.(event);
6423
+ if (!event.defaultPrevented && (event.key === "Enter" || event.key === " ")) {
6424
+ event.preventDefault();
6425
+ event.currentTarget.click();
6426
+ }
6427
+ },
6428
+ children: /* @__PURE__ */ jsx(Wrench, {
6429
+ "aria-hidden": "true",
6430
+ className: "cpk:size-4",
6431
+ "data-testid": "copilot-inspector-icon"
6432
+ })
6433
+ })
6434
+ }), /* @__PURE__ */ jsxs(DropdownMenuContent, {
6435
+ align: "start",
6436
+ side: "top",
6437
+ sideOffset: 6,
6438
+ className: twMerge("cpk:w-64 cpk:p-1 cpk:text-sm", dark && "dark"),
6439
+ onPointerEnter: cancelClose,
6440
+ onPointerLeave: scheduleClose,
6441
+ onKeyDown: () => {
6442
+ openedByHover.current = false;
6443
+ },
6444
+ onOpenAutoFocus: (event) => {
6445
+ if (openedByHover.current) event.preventDefault();
6446
+ },
6447
+ onCloseAutoFocus: (event) => {
6448
+ if (openedByHover.current) event.preventDefault();
6449
+ },
6450
+ onFocusOutside: () => changeOpen(false),
6451
+ children: [
6452
+ /* @__PURE__ */ jsxs(DropdownMenuLabel, {
6453
+ className: "cpk:flex cpk:items-center cpk:justify-between cpk:gap-3 cpk:px-2 cpk:py-2",
6454
+ children: [/* @__PURE__ */ jsx("span", {
6455
+ className: "cpk:text-xs cpk:font-medium",
6456
+ children: labels.assistantMessageToolbarInspectorTitle
6457
+ }), /* @__PURE__ */ jsxs(Tooltip, {
6458
+ delayDuration: 1e3,
6459
+ children: [/* @__PURE__ */ jsx(TooltipTrigger, {
6460
+ asChild: true,
6461
+ children: /* @__PURE__ */ jsx("span", {
6462
+ tabIndex: 0,
6463
+ 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",
6464
+ children: labels.assistantMessageToolbarInspectorLocalOnlyLabel
6465
+ })
6466
+ }), /* @__PURE__ */ jsx(TooltipContent, {
6467
+ side: "top",
6468
+ sideOffset: 6,
6469
+ className: twMerge("cpk:max-w-48 cpk:text-wrap", dark && "dark"),
6470
+ onPointerEnter: cancelClose,
6471
+ onPointerLeave: scheduleClose,
6472
+ children: labels.assistantMessageToolbarInspectorLocalOnlyDescription
6473
+ })]
6474
+ })]
6475
+ }),
6476
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
6477
+ /* @__PURE__ */ jsx(DropdownMenuItem, {
6478
+ asChild: true,
6479
+ children: /* @__PURE__ */ jsxs("button", {
6480
+ type: "button",
6481
+ onClick,
6482
+ className: "cpk:w-full cpk:cursor-pointer cpk:items-start cpk:text-left",
6483
+ children: [/* @__PURE__ */ jsx(InspectorKiteIcon, { className: "cpk:mt-0.5" }), /* @__PURE__ */ jsxs("span", { children: [/* @__PURE__ */ jsx("span", {
6484
+ className: "cpk:block",
6485
+ children: primaryLabel
6486
+ }), /* @__PURE__ */ jsx("span", {
6487
+ className: "cpk:block cpk:text-xs cpk:text-muted-foreground",
6488
+ children: labels.assistantMessageToolbarInspectorDescription
6489
+ })] })]
6490
+ })
6491
+ }),
6492
+ /* @__PURE__ */ jsxs(DropdownMenuItem, {
6493
+ onSelect: hideShortcuts,
6494
+ className: "cpk:cursor-pointer cpk:items-start",
6495
+ children: [/* @__PURE__ */ jsx(EyeOff, {
6496
+ "aria-hidden": "true",
6497
+ className: "cpk:mt-0.5"
6498
+ }), /* @__PURE__ */ jsxs("span", { children: [/* @__PURE__ */ jsx("span", {
6499
+ className: "cpk:block",
6500
+ children: labels.assistantMessageToolbarInspectorHideLabel
6501
+ }), /* @__PURE__ */ jsx("span", {
6502
+ className: "cpk:block cpk:text-xs cpk:text-muted-foreground",
6503
+ children: labels.assistantMessageToolbarInspectorHideDescription
6504
+ })] })]
6505
+ })
6506
+ ]
6507
+ })]
6508
+ });
6509
+ }
6510
+
5982
6511
  //#endregion
5983
6512
  //#region src/v2/components/chat/CopilotChatAssistantMessage.tsx
5984
6513
  /**
@@ -5999,30 +6528,32 @@ function BoundInspectorButton({ inspectorButton, messageId, openInspector, ...pr
5999
6528
  function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp, onThumbsDown, onReadAloud, onRegenerate, additionalToolbarItems, toolbarVisible = true, markdownRenderer, toolbar, copyButton, inspectorButton, thumbsUpButton, thumbsDownButton, readAloudButton, regenerateButton, toolCallsView, children, className, ...props }) {
6000
6529
  useKatexStyles();
6001
6530
  const { isInspectorEnabled, openInspector } = useCopilotKitInspector();
6531
+ const shortcutsHidden = useInspectorShortcutsHidden();
6532
+ const showInspectorShortcut = isInspectorEnabled && !shortcutsHidden;
6002
6533
  const boundMarkdownRenderer = renderSlot(markdownRenderer, CopilotChatAssistantMessage.MarkdownRenderer, { content: message.content || "" });
6003
6534
  const boundCopyButton = renderSlot(copyButton, CopilotChatAssistantMessage.CopyButton, { onClick: async () => {
6004
6535
  if (message.content) return await copyToClipboard(message.content);
6005
6536
  return false;
6006
6537
  } });
6007
6538
  const boundThumbsUpButton = renderSlot(thumbsUpButton, CopilotChatAssistantMessage.ThumbsUpButton, { onClick: onThumbsUp ? () => onThumbsUp(message) : void 0 });
6008
- const boundInspectorButton = /* @__PURE__ */ jsx(BoundInspectorButton, {
6539
+ const boundInspectorButton = showInspectorShortcut ? /* @__PURE__ */ jsx(BoundInspectorButton, {
6009
6540
  inspectorButton,
6010
6541
  messageId: message.id,
6011
6542
  openInspector
6012
- });
6543
+ }) : /* @__PURE__ */ jsx(Fragment$1, {});
6013
6544
  const boundThumbsDownButton = renderSlot(thumbsDownButton, CopilotChatAssistantMessage.ThumbsDownButton, { onClick: onThumbsDown ? () => onThumbsDown(message) : void 0 });
6014
6545
  const boundReadAloudButton = renderSlot(readAloudButton, CopilotChatAssistantMessage.ReadAloudButton, { onClick: onReadAloud ? () => onReadAloud(message) : void 0 });
6015
6546
  const boundRegenerateButton = renderSlot(regenerateButton, CopilotChatAssistantMessage.RegenerateButton, { onClick: onRegenerate ? () => onRegenerate(message) : void 0 });
6016
6547
  const boundToolbar = renderSlot(toolbar, CopilotChatAssistantMessage.Toolbar, { children: /* @__PURE__ */ jsxs("div", {
6017
- className: "cpk:flex cpk:items-center cpk:gap-1",
6548
+ className: "cpk:flex cpk:w-full cpk:items-center cpk:gap-1",
6018
6549
  children: [
6019
6550
  boundCopyButton,
6020
- isInspectorEnabled && boundInspectorButton,
6021
6551
  (onThumbsUp || thumbsUpButton) && boundThumbsUpButton,
6022
6552
  (onThumbsDown || thumbsDownButton) && boundThumbsDownButton,
6023
6553
  (onReadAloud || readAloudButton) && boundReadAloudButton,
6024
6554
  (onRegenerate || regenerateButton) && boundRegenerateButton,
6025
- additionalToolbarItems
6555
+ additionalToolbarItems,
6556
+ showInspectorShortcut && boundInspectorButton
6026
6557
  ]
6027
6558
  }) });
6028
6559
  const boundToolCallsView = renderSlot(toolCallsView, CopilotChatToolCallsView, {
@@ -6031,7 +6562,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp,
6031
6562
  });
6032
6563
  const hasContent = !!(message.content && message.content.trim().length > 0);
6033
6564
  const isLatestAssistantMessage = message.role === "assistant" && messages?.[messages.length - 1]?.id === message.id;
6034
- const shouldShowToolbar = toolbarVisible && (hasContent || isInspectorEnabled) && !(isRunning && isLatestAssistantMessage);
6565
+ const shouldShowToolbar = toolbarVisible && (hasContent || showInspectorShortcut) && !(isRunning && isLatestAssistantMessage);
6035
6566
  if (children) return /* @__PURE__ */ jsx("div", {
6036
6567
  "data-copilotkit": true,
6037
6568
  style: { display: "contents" },
@@ -6072,110 +6603,6 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp,
6072
6603
  ]
6073
6604
  });
6074
6605
  }
6075
- function CopilotKitColoredIcon() {
6076
- const gradientId = useId().replace(/:/g, "");
6077
- return /* @__PURE__ */ jsxs("svg", {
6078
- "aria-hidden": "true",
6079
- className: "cpk:size-5",
6080
- "data-testid": "copilot-inspector-icon",
6081
- viewBox: "0 0 24 24",
6082
- children: [
6083
- /* @__PURE__ */ jsx("path", {
6084
- 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",
6085
- fill: `url(#${gradientId}-purple)`
6086
- }),
6087
- /* @__PURE__ */ jsx("path", {
6088
- 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",
6089
- fill: `url(#${gradientId}-blue)`
6090
- }),
6091
- /* @__PURE__ */ jsx("path", {
6092
- 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",
6093
- fill: `url(#${gradientId}-light-blue)`
6094
- }),
6095
- /* @__PURE__ */ jsx("path", {
6096
- className: "cpk:fill-[#513C9F] cpk:dark:fill-[#B99AE8]",
6097
- 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"
6098
- }),
6099
- /* @__PURE__ */ jsx("path", {
6100
- className: "cpk:fill-[#513C9F] cpk:dark:fill-[#B99AE8]",
6101
- 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"
6102
- }),
6103
- /* @__PURE__ */ jsx("path", {
6104
- className: "cpk:fill-[#ABABAB] cpk:dark:fill-[#D4D4D4]",
6105
- 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"
6106
- }),
6107
- /* @__PURE__ */ jsx("path", {
6108
- 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",
6109
- fill: `url(#${gradientId}-tail)`
6110
- }),
6111
- /* @__PURE__ */ jsxs("defs", { children: [
6112
- /* @__PURE__ */ jsxs("linearGradient", {
6113
- gradientUnits: "userSpaceOnUse",
6114
- id: `${gradientId}-purple`,
6115
- x1: "17.852",
6116
- x2: "14.202",
6117
- y1: "1.467",
6118
- y2: "11.504",
6119
- children: [/* @__PURE__ */ jsx("stop", { className: "cpk:[stop-color:#6430AB] cpk:dark:[stop-color:#B792F0]" }), /* @__PURE__ */ jsx("stop", {
6120
- className: "cpk:[stop-color:#AA89D8] cpk:dark:[stop-color:#D3BDF7]",
6121
- offset: "1"
6122
- })]
6123
- }),
6124
- /* @__PURE__ */ jsxs("linearGradient", {
6125
- gradientUnits: "userSpaceOnUse",
6126
- id: `${gradientId}-blue`,
6127
- x1: "15.024",
6128
- x2: "10.324",
6129
- y1: "7.125",
6130
- y2: "16.204",
6131
- children: [/* @__PURE__ */ jsx("stop", { className: "cpk:[stop-color:#005DBB] cpk:dark:[stop-color:#4D9FEF]" }), /* @__PURE__ */ jsx("stop", {
6132
- className: "cpk:[stop-color:#3D92E8] cpk:dark:[stop-color:#84C0FA]",
6133
- offset: "1"
6134
- })]
6135
- }),
6136
- /* @__PURE__ */ jsxs("linearGradient", {
6137
- gradientUnits: "userSpaceOnUse",
6138
- id: `${gradientId}-light-blue`,
6139
- x1: "17.122",
6140
- x2: "15.707",
6141
- y1: "1.467",
6142
- y2: "5.892",
6143
- children: [/* @__PURE__ */ jsx("stop", { className: "cpk:[stop-color:#1B70C4] cpk:dark:[stop-color:#61ACF2]" }), /* @__PURE__ */ jsx("stop", {
6144
- className: "cpk:[stop-color:#54A4F2] cpk:dark:[stop-color:#9ACDFF]",
6145
- offset: "1"
6146
- })]
6147
- }),
6148
- /* @__PURE__ */ jsxs("linearGradient", {
6149
- gradientUnits: "userSpaceOnUse",
6150
- id: `${gradientId}-tail`,
6151
- x1: "6.577",
6152
- x2: "21.506",
6153
- y1: "21.758",
6154
- y2: "21.758",
6155
- children: [
6156
- /* @__PURE__ */ jsx("stop", { className: "cpk:[stop-color:#4497EA] cpk:dark:[stop-color:#79BCF5]" }),
6157
- /* @__PURE__ */ jsx("stop", {
6158
- className: "cpk:[stop-color:#1463B2] cpk:dark:[stop-color:#4594D8]",
6159
- offset: ".255"
6160
- }),
6161
- /* @__PURE__ */ jsx("stop", {
6162
- className: "cpk:[stop-color:#0A437D] cpk:dark:[stop-color:#347CB7]",
6163
- offset: ".499"
6164
- }),
6165
- /* @__PURE__ */ jsx("stop", {
6166
- className: "cpk:[stop-color:#2476C8] cpk:dark:[stop-color:#58A4E5]",
6167
- offset: ".667"
6168
- }),
6169
- /* @__PURE__ */ jsx("stop", {
6170
- className: "cpk:[stop-color:#0C549A] cpk:dark:[stop-color:#3C87C7]",
6171
- offset: ".973"
6172
- })
6173
- ]
6174
- })
6175
- ] })
6176
- ]
6177
- });
6178
- }
6179
6606
  (function(_CopilotChatAssistantMessage) {
6180
6607
  _CopilotChatAssistantMessage.MarkdownRenderer = ({ content, className, ...props }) => /* @__PURE__ */ jsx(Streamdown, {
6181
6608
  className,
@@ -6233,30 +6660,7 @@ function CopilotKitColoredIcon() {
6233
6660
  children: copied ? /* @__PURE__ */ jsx(Check, { className: "cpk:size-[18px]" }) : /* @__PURE__ */ jsx(Copy, { className: "cpk:size-[18px]" })
6234
6661
  });
6235
6662
  };
6236
- _CopilotChatAssistantMessage.InspectorButton = ({ title, className, ...props }) => {
6237
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
6238
- const primaryLabel = title || labels.assistantMessageToolbarInspectorLabel;
6239
- const accessibleLabel = `${primaryLabel} (local only)`;
6240
- return /* @__PURE__ */ jsxs(ToolbarButton, {
6241
- "data-testid": "copilot-inspector-button",
6242
- title: accessibleLabel,
6243
- className: twMerge("cpk:w-auto cpk:gap-1.5 cpk:px-2", className),
6244
- tooltipClassName: "cpk:max-w-64 cpk:text-left cpk:leading-4",
6245
- tooltip: "View this message in the Inspector to get more information. This button and the inspector only display during local development (localhost, dev env).",
6246
- ...props,
6247
- children: [
6248
- /* @__PURE__ */ jsx(CopilotKitColoredIcon, {}),
6249
- /* @__PURE__ */ jsx("span", {
6250
- className: "cpk:font-medium",
6251
- children: primaryLabel
6252
- }),
6253
- /* @__PURE__ */ jsx("span", {
6254
- className: "cpk:text-xs cpk:text-muted-foreground",
6255
- children: "(local only)"
6256
- })
6257
- ]
6258
- });
6259
- };
6663
+ _CopilotChatAssistantMessage.InspectorButton = CopilotChatInspectorButton;
6260
6664
  _CopilotChatAssistantMessage.ThumbsUpButton = ({ title, ...props }) => {
6261
6665
  const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
6262
6666
  return /* @__PURE__ */ jsx(ToolbarButton, {
@@ -8506,9 +8910,15 @@ function useInspectorThreadOverride(args) {
8506
8910
 
8507
8911
  //#endregion
8508
8912
  //#region src/v2/components/chat/CopilotChat.tsx
8509
- function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen, attachments: attachmentsConfig, onError, throttleMs, ...props }) {
8913
+ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isModalDefaultOpen, attachments: attachmentsConfig, onError, throttleMs, ...props }) {
8510
8914
  const existingConfig = useCopilotChatConfiguration();
8511
- const resolvedAgentId = agentId ?? existingConfig?.agentId ?? DEFAULT_AGENT_ID;
8915
+ const inspector = useCopilotKitInspector();
8916
+ const inspectorContextValue = useMemo(() => ({
8917
+ ...inspector,
8918
+ isInspectorEnabled: inspector.isInspectorEnabled && (inspector.providerEnableInspector ?? inspectorTools ?? true)
8919
+ }), [inspector, inspectorTools]);
8920
+ const providerAgentId = useDefaultAgentId();
8921
+ const resolvedAgentId = agentId ?? existingConfig?.agentId ?? providerAgentId ?? DEFAULT_AGENT_ID;
8512
8922
  const providedThreadId = threadId ?? existingConfig?.threadId;
8513
8923
  const baseThreadId = useMemo(() => providedThreadId ?? randomUUID$1(), [providedThreadId]);
8514
8924
  const baseHasExplicitThreadId = !!threadId || !!existingConfig?.hasExplicitThreadId;
@@ -9081,7 +9491,10 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
9081
9491
  }),
9082
9492
  /* @__PURE__ */ jsx(LastUserMessageContext.Provider, {
9083
9493
  value: lastUserMessageState,
9084
- children: RenderedChatView
9494
+ children: /* @__PURE__ */ jsx(CopilotKitInspectorContextProvider, {
9495
+ value: inspectorContextValue,
9496
+ children: RenderedChatView
9497
+ })
9085
9498
  })
9086
9499
  ]
9087
9500
  })
@@ -9789,7 +10202,8 @@ function CopilotThreadsDrawer({ agentId, onThreadSelect, onNewThread, onLicensed
9789
10202
  const featureLicensed = checkFeature("threads");
9790
10203
  const licensed = licensePresent && featureLicensed;
9791
10204
  const licensePending = status === null;
9792
- const resolvedAgentId = agentId ?? configuration?.agentId ?? DEFAULT_AGENT_ID;
10205
+ const providerAgentId = useDefaultAgentId();
10206
+ const resolvedAgentId = agentId ?? configuration?.agentId ?? providerAgentId ?? DEFAULT_AGENT_ID;
9793
10207
  const activeThreadId = configuration?.threadId ?? null;
9794
10208
  const { threads, isLoading, listError, fetchMoreError, hasMoreThreads, isFetchingMoreThreads, archiveThread, unarchiveThread, deleteThread, fetchMoreThreads, refetchThreads, startNewThread } = useThreads$1({
9795
10209
  agentId: resolvedAgentId,
@@ -12248,4 +12662,4 @@ function validateProps(props) {
12248
12662
 
12249
12663
  //#endregion
12250
12664
  export { useAgentContext as $, CopilotChatMessageView as A, AudioRecorderError as At, CopilotChatAssistantMessage_default as B, CopilotModalHeader as C, MCPAppsActivityContentSchema as Ct, CopilotChat as D, CopilotKitInspector as Dt, DefaultOpenIcon as E, ɵrunMcpFollowUp as Et, CopilotChatSuggestionView as F, useLearnFromUserActionInCurrentThread as G, useLearningContainersInCurrentThread as H, CopilotChatSuggestionPill as I, useThreads$1 as J, useLearnFromUserAction as K, CopilotChatReasoningMessage_default as L, IntelligenceIndicator as M, CopilotChatConfigurationProvider as Mt, getIntelligenceTurnAnchors as N, useCopilotChatConfiguration as Nt, CopilotChatView_default as O, useRenderToolCall as Ot, IntelligenceIndicatorView as P, useSuggestions as Q, CopilotChatUserMessage_default as R, CopilotSidebarView as S, useSandboxFunctions as St, DefaultCloseIcon as T, MCPAppsActivityType as Tt, useLearningContainers as U, CopilotChatToolCallsView as V, useAttachments as W, INTERRUPT_EVENT_NAME as X, useInterrupt as Y, useConfigureSuggestions as Z, WildcardToolCallRender as _, OpenGenerativeUIActivityRenderer as _t, ThreadsProvider as a, useRenderTool as at, CopilotSidebar as b, OpenGenerativeUIToolRenderer as bt, CoAgentStateRendersProvider as c, useRenderActivityMessage as ct, shouldShowDevConsole as d, useCopilotKit$1 as dt, useCapabilities as et, useToast as f, useLicenseContext$1 as ft, useCopilotContext as g, GenerateSandboxedUiArgsSchema as gt, CopilotContext as h, createA2UIMessageRenderer as ht, ThreadsContext as i, useDefaultRenderTool as it, INTELLIGENCE_TURN_HEAD as j, CopilotChatAudioRecorder as jt, CopilotChatAttachmentQueue as k, CopilotChatInput_default as kt, useCoAgentStateRenders as l, useRenderCustomMessages as lt, useCopilotMessagesContext as m, defineToolCallRenderer as mt, defaultCopilotContextCategories as n, useAgent as nt, useThreads as o, useComponent as ot, CopilotMessagesContext as p, CopilotKitCoreReact as pt, useMemories as q, CoAgentStateRenderBridge as r, useHumanInTheLoop as rt, CoAgentStateRendersContext as s, useFrontendTool as st, CopilotKit as t, UseAgentUpdate as tt, useAsyncCallback as u, CopilotKitProvider as ut, CopilotThreadsDrawer as v, OpenGenerativeUIActivityType as vt, CopilotChatToggleButton as w, MCPAppsActivityRenderer as wt, CopilotPopupView as x, SandboxFunctionsContext as xt, CopilotPopup as y, OpenGenerativeUIContentSchema as yt, CopilotChatAttachmentRenderer as z };
12251
- //# sourceMappingURL=copilotkit-B1jSvZeb.mjs.map
12665
+ //# sourceMappingURL=copilotkit-snbJkMqQ.mjs.map