@copilotkit/react-core 1.70.3 → 1.71.1

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 (60) hide show
  1. package/dist/{copilotkit-BU3OvveB.cjs → copilotkit-BkVEkUS0.cjs} +369 -154
  2. package/dist/copilotkit-BkVEkUS0.cjs.map +1 -0
  3. package/dist/{copilotkit-Bs98akp9.d.mts → copilotkit-ChjzWqn6.d.mts} +33 -8
  4. package/dist/copilotkit-ChjzWqn6.d.mts.map +1 -0
  5. package/dist/{copilotkit-Ap_yisA5.mjs → copilotkit-D5BTo0YG.mjs} +368 -153
  6. package/dist/copilotkit-D5BTo0YG.mjs.map +1 -0
  7. package/dist/{copilotkit-X2eGbOwf.d.cts → copilotkit-DCIXZawe.d.cts} +33 -8
  8. package/dist/copilotkit-DCIXZawe.d.cts.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.mts +1 -1
  13. package/dist/index.mjs +4 -4
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/index.umd.js +180 -139
  16. package/dist/index.umd.js.map +1 -1
  17. package/dist/v2/context.cjs +4 -0
  18. package/dist/v2/context.cjs.map +1 -1
  19. package/dist/v2/context.d.cts +3 -1
  20. package/dist/v2/context.d.cts.map +1 -1
  21. package/dist/v2/context.d.mts +3 -1
  22. package/dist/v2/context.d.mts.map +1 -1
  23. package/dist/v2/context.mjs +3 -1
  24. package/dist/v2/context.mjs.map +1 -1
  25. package/dist/v2/headless.cjs +20 -5
  26. package/dist/v2/headless.cjs.map +1 -1
  27. package/dist/v2/headless.d.cts +9 -4
  28. package/dist/v2/headless.d.cts.map +1 -1
  29. package/dist/v2/headless.d.mts +9 -4
  30. package/dist/v2/headless.d.mts.map +1 -1
  31. package/dist/v2/headless.mjs +21 -6
  32. package/dist/v2/headless.mjs.map +1 -1
  33. package/dist/v2/index.cjs +1 -1
  34. package/dist/v2/index.css +1 -1
  35. package/dist/v2/index.d.cts +1 -1
  36. package/dist/v2/index.d.mts +1 -1
  37. package/dist/v2/index.mjs +1 -1
  38. package/dist/v2/index.umd.js +495 -278
  39. package/dist/v2/index.umd.js.map +1 -1
  40. package/package.json +8 -9
  41. package/dist/copilotkit-Ap_yisA5.mjs.map +0 -1
  42. package/dist/copilotkit-BU3OvveB.cjs.map +0 -1
  43. package/dist/copilotkit-Bs98akp9.d.mts.map +0 -1
  44. package/dist/copilotkit-X2eGbOwf.d.cts.map +0 -1
  45. package/skills/react-core/SKILL.md +0 -110
  46. package/skills/react-core/references/agent-access.md +0 -355
  47. package/skills/react-core/references/attachments.md +0 -311
  48. package/skills/react-core/references/capabilities.md +0 -138
  49. package/skills/react-core/references/chat-components.md +0 -229
  50. package/skills/react-core/references/client-side-tools.md +0 -358
  51. package/skills/react-core/references/custom-message-renderers.md +0 -223
  52. package/skills/react-core/references/debug-mode.md +0 -140
  53. package/skills/react-core/references/human-in-the-loop.md +0 -312
  54. package/skills/react-core/references/provider-setup.md +0 -358
  55. package/skills/react-core/references/rendering-activity-messages.md +0 -201
  56. package/skills/react-core/references/rendering-tool-calls.md +0 -319
  57. package/skills/react-core/references/suggestions.md +0 -211
  58. package/skills/react-core/references/switching-agents-recipes.md +0 -161
  59. package/skills/react-core/references/switching-agents.md +0 -240
  60. package/skills/react-core/references/threads.md +0 -289
@@ -3,8 +3,9 @@ import React, { createContext, createElement, forwardRef, memo, useCallback, use
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,7 +13,6 @@ 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
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";
@@ -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",
@@ -1590,21 +1604,28 @@ function useRenderToolCall() {
1590
1604
 
1591
1605
  //#endregion
1592
1606
  //#region src/v2/components/CopilotKitInspector.tsx
1593
- const CopilotKitInspector = ({ core, openRequest }) => {
1607
+ const CopilotKitInspector = ({ core, openRequest, onVisibilityChange }) => {
1594
1608
  const mountRef = React$1.useRef(null);
1595
1609
  const inspectorRef = React$1.useRef(null);
1596
1610
  const latestCoreRef = React$1.useRef(core ?? null);
1597
1611
  const latestOpenRequestRef = React$1.useRef(openRequest);
1612
+ const visibilityCallbackRef = React$1.useRef(onVisibilityChange);
1613
+ visibilityCallbackRef.current = onVisibilityChange;
1598
1614
  latestCoreRef.current = core ?? null;
1599
1615
  latestOpenRequestRef.current = openRequest;
1600
1616
  React$1.useEffect(() => {
1601
1617
  let mounted = true;
1602
1618
  let inspector = null;
1619
+ const handleVisibilityChange = (event) => {
1620
+ const visible = event.detail?.visible;
1621
+ visibilityCallbackRef.current?.(visible === true);
1622
+ };
1603
1623
  import("@copilotkit/web-inspector").then((mod) => {
1604
1624
  if (!mounted || !mountRef.current) return;
1605
1625
  mod.defineWebInspector?.();
1606
1626
  inspector = mountRef.current.ownerDocument.createElement(mod.WEB_INSPECTOR_TAG);
1607
1627
  mod.configureWebInspectorElement(inspector, latestCoreRef.current);
1628
+ inspector.addEventListener("cpk-inspector-visibility-change", handleVisibilityChange);
1608
1629
  mountRef.current.appendChild(inspector);
1609
1630
  inspectorRef.current = inspector;
1610
1631
  const request = latestOpenRequestRef.current;
@@ -1614,7 +1635,9 @@ const CopilotKitInspector = ({ core, openRequest }) => {
1614
1635
  });
1615
1636
  return () => {
1616
1637
  mounted = false;
1638
+ inspector?.removeEventListener("cpk-inspector-visibility-change", handleVisibilityChange);
1617
1639
  inspector?.remove();
1640
+ visibilityCallbackRef.current?.(false);
1618
1641
  if (inspectorRef.current === inspector) inspectorRef.current = null;
1619
1642
  };
1620
1643
  }, []);
@@ -3643,14 +3666,19 @@ function useStableArrayProp(prop, warningMessage, isMeaningfulChange) {
3643
3666
  }, [value, warningMessage]);
3644
3667
  return value;
3645
3668
  }
3646
- 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 }) => {
3647
3670
  const [shouldRenderInspector, setShouldRenderInspector] = useState(false);
3671
+ const [inspectorVisible, setInspectorVisible] = useState(false);
3648
3672
  useEffect(() => {
3649
3673
  setShouldRenderInspector(shouldEnableInspector({
3650
3674
  enableInspector,
3651
3675
  isBrowser: true,
3652
3676
  isDevelopment: process.env.NODE_ENV === "development"
3653
- }));
3677
+ }) && [
3678
+ "localhost",
3679
+ "127.0.0.1",
3680
+ "[::1]"
3681
+ ].includes(window.location.hostname));
3654
3682
  }, [enableInspector]);
3655
3683
  const [inspectorOpenRequest, setInspectorOpenRequest] = useState(null);
3656
3684
  const [runtimeA2UIEnabled, setRuntimeA2UIEnabled] = useState(false);
@@ -3666,9 +3694,15 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3666
3694
  setInspectorOpenRequest({ ...request });
3667
3695
  }, []);
3668
3696
  const inspectorContextValue = useMemo(() => ({
3669
- isInspectorEnabled: shouldRenderInspector,
3697
+ providerEnableInspector: enableInspector,
3698
+ isInspectorEnabled: shouldRenderInspector && inspectorVisible,
3670
3699
  openInspector: requestInspectorOpen
3671
- }), [shouldRenderInspector, requestInspectorOpen]);
3700
+ }), [
3701
+ enableInspector,
3702
+ shouldRenderInspector,
3703
+ inspectorVisible,
3704
+ requestInspectorOpen
3705
+ ]);
3672
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) => {
3673
3707
  const key = (rc) => `${rc?.agentId ?? ""}:${rc?.name ?? ""}`;
3674
3708
  const setFrom = (arr) => new Set(arr.map(key));
@@ -4065,9 +4099,13 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
4065
4099
  }),
4066
4100
  /* @__PURE__ */ jsxs(CopilotKitInspectorContextProvider, {
4067
4101
  value: inspectorContextValue,
4068
- children: [children, shouldRenderInspector ? /* @__PURE__ */ jsx(CopilotKitInspector, {
4102
+ children: [/* @__PURE__ */ jsx(CopilotKitAgentIdContext.Provider, {
4103
+ value: agentId,
4104
+ children
4105
+ }), shouldRenderInspector ? /* @__PURE__ */ jsx(CopilotKitInspector, {
4069
4106
  core: copilotkit,
4070
- openRequest: inspectorOpenRequest
4107
+ openRequest: inspectorOpenRequest,
4108
+ onVisibilityChange: setInspectorVisible
4071
4109
  }) : null]
4072
4110
  }),
4073
4111
  runtimeLicenseWarningStatus === "none" && !resolvedPublicKey && /* @__PURE__ */ jsx(LicenseWarningBanner, { type: "no_license" }),
@@ -4649,7 +4687,8 @@ function useAgent({ agentId, threadId, runtimeAgentId, updates, throttleMs } = {
4649
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}" }).`);
4650
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 }).`);
4651
4689
  const chatConfig = useCopilotChatConfiguration();
4652
- const resolvedAgentId = agentId ?? chatConfig?.agentId ?? DEFAULT_AGENT_ID;
4690
+ const providerAgentId = useDefaultAgentId();
4691
+ const resolvedAgentId = agentId ?? chatConfig?.agentId ?? providerAgentId ?? DEFAULT_AGENT_ID;
4653
4692
  const { copilotkit } = useCopilotKit();
4654
4693
  const providerThrottleMs = copilotkit.defaultThrottleMs;
4655
4694
  const [, forceUpdate] = useReducer((x) => x + 1, 0);
@@ -4877,7 +4916,12 @@ function useAgentContext(context) {
4877
4916
  function useSuggestions({ agentId } = {}) {
4878
4917
  const { copilotkit } = useCopilotKit();
4879
4918
  const config = useCopilotChatConfiguration();
4880
- 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
+ ]);
4881
4925
  const [suggestions, setSuggestions] = useState(() => {
4882
4926
  return copilotkit.getSuggestions(resolvedAgentId).suggestions;
4883
4927
  });
@@ -5131,7 +5175,10 @@ function toLegacyEvent(pending) {
5131
5175
  */
5132
5176
  function useInterrupt(config) {
5133
5177
  const { copilotkit } = useCopilotKit();
5134
- const { agent } = useAgent({ agentId: config.agentId });
5178
+ const { agent } = useAgent({
5179
+ agentId: config.agentId,
5180
+ updates: []
5181
+ });
5135
5182
  const [pending, setPending] = useState(null);
5136
5183
  const pendingRef = useRef(pending);
5137
5184
  pendingRef.current = pending;
@@ -6181,6 +6228,289 @@ function CopilotChatToolCallsView({ message, messages = [] }) {
6181
6228
  }) });
6182
6229
  }
6183
6230
 
6231
+ //#endregion
6232
+ //#region src/v2/components/chat/CopilotChatInspectorButton.tsx
6233
+ let shortcutsHidden = false;
6234
+ const listeners = /* @__PURE__ */ new Set();
6235
+ const subscribe = (listener) => {
6236
+ listeners.add(listener);
6237
+ return () => {
6238
+ listeners.delete(listener);
6239
+ };
6240
+ };
6241
+ const getSnapshot = () => shortcutsHidden;
6242
+ const getServerSnapshot = () => false;
6243
+ function useInspectorShortcutsHidden() {
6244
+ return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
6245
+ }
6246
+ function hideShortcuts() {
6247
+ shortcutsHidden = true;
6248
+ listeners.forEach((listener) => listener());
6249
+ }
6250
+ function InspectorKiteIcon({ className, ...props }) {
6251
+ const id = useId();
6252
+ return /* @__PURE__ */ jsxs("svg", {
6253
+ ...props,
6254
+ "aria-hidden": "true",
6255
+ className: twMerge("cpk:size-4", className),
6256
+ viewBox: "4.57 3.36 17.8 17.8",
6257
+ fill: "none",
6258
+ children: [
6259
+ /* @__PURE__ */ jsx("path", {
6260
+ 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",
6261
+ fill: `url(#${id}-paint0_linear)`
6262
+ }),
6263
+ /* @__PURE__ */ jsx("path", {
6264
+ 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",
6265
+ fill: `url(#${id}-paint1_linear)`
6266
+ }),
6267
+ /* @__PURE__ */ jsx("path", {
6268
+ 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",
6269
+ fill: `url(#${id}-paint2_linear)`
6270
+ }),
6271
+ /* @__PURE__ */ jsx("path", {
6272
+ d: "M10.7145 3.79041L17.8305 20.7659",
6273
+ stroke: "#513C9F",
6274
+ strokeWidth: "0.17284",
6275
+ strokeLinecap: "round"
6276
+ }),
6277
+ /* @__PURE__ */ jsx("path", {
6278
+ 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",
6279
+ stroke: "#513C9F",
6280
+ strokeWidth: "0.17284",
6281
+ strokeLinecap: "round"
6282
+ }),
6283
+ /* @__PURE__ */ jsx("path", {
6284
+ d: "M11.6914 5.93518L9.05534 14.7068M9.05534 14.7068H15.3203M9.05534 14.7068L0.15625 26.3646",
6285
+ stroke: "#ABABAB",
6286
+ strokeWidth: "0.302474",
6287
+ strokeLinecap: "round"
6288
+ }),
6289
+ /* @__PURE__ */ jsx("path", {
6290
+ 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",
6291
+ fill: `url(#${id}-paint3_linear)`
6292
+ }),
6293
+ /* @__PURE__ */ jsxs("defs", { children: [
6294
+ /* @__PURE__ */ jsxs("linearGradient", {
6295
+ id: `${id}-paint0_linear`,
6296
+ x1: "15.5372",
6297
+ y1: "5.0278",
6298
+ x2: "12.0802",
6299
+ y2: "14.534",
6300
+ gradientUnits: "userSpaceOnUse",
6301
+ children: [/* @__PURE__ */ jsx("stop", { stopColor: "#6430AB" }), /* @__PURE__ */ jsx("stop", {
6302
+ offset: "1",
6303
+ stopColor: "#AA89D8"
6304
+ })]
6305
+ }),
6306
+ /* @__PURE__ */ jsxs("linearGradient", {
6307
+ id: `${id}-paint1_linear`,
6308
+ x1: "12.8583",
6309
+ y1: "10.3858",
6310
+ x2: "8.40764",
6311
+ y2: "18.9846",
6312
+ gradientUnits: "userSpaceOnUse",
6313
+ children: [/* @__PURE__ */ jsx("stop", { stopColor: "#005DBB" }), /* @__PURE__ */ jsx("stop", {
6314
+ offset: "1",
6315
+ stopColor: "#3D92E8"
6316
+ })]
6317
+ }),
6318
+ /* @__PURE__ */ jsxs("linearGradient", {
6319
+ id: `${id}-paint2_linear`,
6320
+ x1: "14.8452",
6321
+ y1: "5.02774",
6322
+ x2: "13.5047",
6323
+ y2: "9.21911",
6324
+ gradientUnits: "userSpaceOnUse",
6325
+ children: [/* @__PURE__ */ jsx("stop", { stopColor: "#1B70C4" }), /* @__PURE__ */ jsx("stop", {
6326
+ offset: "1",
6327
+ stopColor: "#54A4F2"
6328
+ })]
6329
+ }),
6330
+ /* @__PURE__ */ jsxs("linearGradient", {
6331
+ id: `${id}-paint3_linear`,
6332
+ x1: "4.85806",
6333
+ y1: "24.2455",
6334
+ x2: "18.9963",
6335
+ y2: "24.2455",
6336
+ gradientUnits: "userSpaceOnUse",
6337
+ children: [
6338
+ /* @__PURE__ */ jsx("stop", { stopColor: "#4497EA" }),
6339
+ /* @__PURE__ */ jsx("stop", {
6340
+ offset: "0.254755",
6341
+ stopColor: "#1463B2"
6342
+ }),
6343
+ /* @__PURE__ */ jsx("stop", {
6344
+ offset: "0.498725",
6345
+ stopColor: "#0A437D"
6346
+ }),
6347
+ /* @__PURE__ */ jsx("stop", {
6348
+ offset: "0.666667",
6349
+ stopColor: "#2476C8"
6350
+ }),
6351
+ /* @__PURE__ */ jsx("stop", {
6352
+ offset: "0.972542",
6353
+ stopColor: "#0C549A"
6354
+ })
6355
+ ]
6356
+ })
6357
+ ] })
6358
+ ]
6359
+ });
6360
+ }
6361
+ function CopilotChatInspectorButton({ title, className, onClick, onPointerDown, onPointerEnter, onPointerLeave, onKeyDown, disabled, ...props }) {
6362
+ const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
6363
+ const { isInspectorEnabled } = useCopilotKitInspector();
6364
+ const hidden = useInspectorShortcutsHidden();
6365
+ const [open, setOpen] = useState(false);
6366
+ const [dark, setDark] = useState(false);
6367
+ const trigger = useRef(null);
6368
+ const closeTimer = useRef(null);
6369
+ const openedByHover = useRef(false);
6370
+ const primaryLabel = title || labels.assistantMessageToolbarInspectorLabel;
6371
+ const cancelClose = () => {
6372
+ if (closeTimer.current !== null) clearTimeout(closeTimer.current);
6373
+ closeTimer.current = null;
6374
+ };
6375
+ useEffect(() => cancelClose, []);
6376
+ const changeOpen = (next) => {
6377
+ cancelClose();
6378
+ if (next) setDark(!!trigger.current?.closest(".dark"));
6379
+ setOpen(next);
6380
+ };
6381
+ const scheduleClose = () => {
6382
+ cancelClose();
6383
+ closeTimer.current = setTimeout(() => {
6384
+ if (openedByHover.current) setOpen(false);
6385
+ }, 180);
6386
+ };
6387
+ if (!isInspectorEnabled || hidden) return null;
6388
+ return /* @__PURE__ */ jsxs(DropdownMenu, {
6389
+ open,
6390
+ onOpenChange: changeOpen,
6391
+ modal: false,
6392
+ children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
6393
+ asChild: true,
6394
+ children: /* @__PURE__ */ jsx(Button, {
6395
+ ...props,
6396
+ ref: trigger,
6397
+ type: "button",
6398
+ disabled,
6399
+ variant: "assistantMessageToolbarButton",
6400
+ size: "icon",
6401
+ "data-testid": "copilot-inspector-button",
6402
+ "aria-label": `${labels.assistantMessageToolbarInspectorTitle} (${labels.assistantMessageToolbarInspectorLocalOnlyLabel.toLowerCase()})`,
6403
+ className: twMerge("cpk:size-8 cpk:p-1.5", className),
6404
+ onPointerEnter: (event) => {
6405
+ onPointerEnter?.(event);
6406
+ if (!disabled && event.pointerType !== "touch") {
6407
+ openedByHover.current = true;
6408
+ changeOpen(true);
6409
+ }
6410
+ },
6411
+ onPointerLeave: (event) => {
6412
+ onPointerLeave?.(event);
6413
+ scheduleClose();
6414
+ },
6415
+ onPointerDown: (event) => {
6416
+ onPointerDown?.(event);
6417
+ event.preventDefault();
6418
+ },
6419
+ onClick: (event) => {
6420
+ changeOpen(false);
6421
+ onClick?.(event);
6422
+ },
6423
+ onKeyDown: (event) => {
6424
+ openedByHover.current = false;
6425
+ onKeyDown?.(event);
6426
+ if (!event.defaultPrevented && (event.key === "Enter" || event.key === " ")) {
6427
+ event.preventDefault();
6428
+ event.currentTarget.click();
6429
+ }
6430
+ },
6431
+ children: /* @__PURE__ */ jsx(Wrench, {
6432
+ "aria-hidden": "true",
6433
+ className: "cpk:size-4",
6434
+ "data-testid": "copilot-inspector-icon"
6435
+ })
6436
+ })
6437
+ }), /* @__PURE__ */ jsxs(DropdownMenuContent, {
6438
+ align: "start",
6439
+ side: "top",
6440
+ sideOffset: 6,
6441
+ className: twMerge("cpk:w-64 cpk:p-1 cpk:text-sm", dark && "dark"),
6442
+ onPointerEnter: cancelClose,
6443
+ onPointerLeave: scheduleClose,
6444
+ onKeyDown: () => {
6445
+ openedByHover.current = false;
6446
+ },
6447
+ onOpenAutoFocus: (event) => {
6448
+ if (openedByHover.current) event.preventDefault();
6449
+ },
6450
+ onCloseAutoFocus: (event) => {
6451
+ if (openedByHover.current) event.preventDefault();
6452
+ },
6453
+ onFocusOutside: () => changeOpen(false),
6454
+ children: [
6455
+ /* @__PURE__ */ jsxs(DropdownMenuLabel, {
6456
+ className: "cpk:flex cpk:items-center cpk:justify-between cpk:gap-3 cpk:px-2 cpk:py-2",
6457
+ children: [/* @__PURE__ */ jsx("span", {
6458
+ className: "cpk:text-xs cpk:font-medium",
6459
+ children: labels.assistantMessageToolbarInspectorTitle
6460
+ }), /* @__PURE__ */ jsxs(Tooltip, {
6461
+ delayDuration: 1e3,
6462
+ children: [/* @__PURE__ */ jsx(TooltipTrigger, {
6463
+ asChild: true,
6464
+ children: /* @__PURE__ */ jsx("span", {
6465
+ tabIndex: 0,
6466
+ 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",
6467
+ children: labels.assistantMessageToolbarInspectorLocalOnlyLabel
6468
+ })
6469
+ }), /* @__PURE__ */ jsx(TooltipContent, {
6470
+ side: "top",
6471
+ sideOffset: 6,
6472
+ className: twMerge("cpk:max-w-48 cpk:text-wrap", dark && "dark"),
6473
+ onPointerEnter: cancelClose,
6474
+ onPointerLeave: scheduleClose,
6475
+ children: labels.assistantMessageToolbarInspectorLocalOnlyDescription
6476
+ })]
6477
+ })]
6478
+ }),
6479
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
6480
+ /* @__PURE__ */ jsx(DropdownMenuItem, {
6481
+ asChild: true,
6482
+ children: /* @__PURE__ */ jsxs("button", {
6483
+ type: "button",
6484
+ onClick,
6485
+ className: "cpk:w-full cpk:cursor-pointer cpk:items-start cpk:text-left",
6486
+ children: [/* @__PURE__ */ jsx(InspectorKiteIcon, { className: "cpk:mt-0.5" }), /* @__PURE__ */ jsxs("span", { children: [/* @__PURE__ */ jsx("span", {
6487
+ className: "cpk:block",
6488
+ children: primaryLabel
6489
+ }), /* @__PURE__ */ jsx("span", {
6490
+ className: "cpk:block cpk:text-xs cpk:text-muted-foreground",
6491
+ children: labels.assistantMessageToolbarInspectorDescription
6492
+ })] })]
6493
+ })
6494
+ }),
6495
+ /* @__PURE__ */ jsxs(DropdownMenuItem, {
6496
+ onSelect: hideShortcuts,
6497
+ className: "cpk:cursor-pointer cpk:items-start",
6498
+ children: [/* @__PURE__ */ jsx(EyeOff, {
6499
+ "aria-hidden": "true",
6500
+ className: "cpk:mt-0.5"
6501
+ }), /* @__PURE__ */ jsxs("span", { children: [/* @__PURE__ */ jsx("span", {
6502
+ className: "cpk:block",
6503
+ children: labels.assistantMessageToolbarInspectorHideLabel
6504
+ }), /* @__PURE__ */ jsx("span", {
6505
+ className: "cpk:block cpk:text-xs cpk:text-muted-foreground",
6506
+ children: labels.assistantMessageToolbarInspectorHideDescription
6507
+ })] })]
6508
+ })
6509
+ ]
6510
+ })]
6511
+ });
6512
+ }
6513
+
6184
6514
  //#endregion
6185
6515
  //#region src/v2/components/chat/CopilotChatAssistantMessage.tsx
6186
6516
  /**
@@ -6201,30 +6531,32 @@ function BoundInspectorButton({ inspectorButton, messageId, openInspector, ...pr
6201
6531
  function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp, onThumbsDown, onReadAloud, onRegenerate, additionalToolbarItems, toolbarVisible = true, markdownRenderer, toolbar, copyButton, inspectorButton, thumbsUpButton, thumbsDownButton, readAloudButton, regenerateButton, toolCallsView, children, className, ...props }) {
6202
6532
  useKatexStyles();
6203
6533
  const { isInspectorEnabled, openInspector } = useCopilotKitInspector();
6534
+ const shortcutsHidden = useInspectorShortcutsHidden();
6535
+ const showInspectorShortcut = isInspectorEnabled && !shortcutsHidden;
6204
6536
  const boundMarkdownRenderer = renderSlot(markdownRenderer, CopilotChatAssistantMessage.MarkdownRenderer, { content: message.content || "" });
6205
6537
  const boundCopyButton = renderSlot(copyButton, CopilotChatAssistantMessage.CopyButton, { onClick: async () => {
6206
6538
  if (message.content) return await copyToClipboard(message.content);
6207
6539
  return false;
6208
6540
  } });
6209
6541
  const boundThumbsUpButton = renderSlot(thumbsUpButton, CopilotChatAssistantMessage.ThumbsUpButton, { onClick: onThumbsUp ? () => onThumbsUp(message) : void 0 });
6210
- const boundInspectorButton = /* @__PURE__ */ jsx(BoundInspectorButton, {
6542
+ const boundInspectorButton = showInspectorShortcut ? /* @__PURE__ */ jsx(BoundInspectorButton, {
6211
6543
  inspectorButton,
6212
6544
  messageId: message.id,
6213
6545
  openInspector
6214
- });
6546
+ }) : /* @__PURE__ */ jsx(Fragment$1, {});
6215
6547
  const boundThumbsDownButton = renderSlot(thumbsDownButton, CopilotChatAssistantMessage.ThumbsDownButton, { onClick: onThumbsDown ? () => onThumbsDown(message) : void 0 });
6216
6548
  const boundReadAloudButton = renderSlot(readAloudButton, CopilotChatAssistantMessage.ReadAloudButton, { onClick: onReadAloud ? () => onReadAloud(message) : void 0 });
6217
6549
  const boundRegenerateButton = renderSlot(regenerateButton, CopilotChatAssistantMessage.RegenerateButton, { onClick: onRegenerate ? () => onRegenerate(message) : void 0 });
6218
6550
  const boundToolbar = renderSlot(toolbar, CopilotChatAssistantMessage.Toolbar, { children: /* @__PURE__ */ jsxs("div", {
6219
- className: "cpk:flex cpk:items-center cpk:gap-1",
6551
+ className: "cpk:flex cpk:w-full cpk:items-center cpk:gap-1",
6220
6552
  children: [
6221
6553
  boundCopyButton,
6222
- isInspectorEnabled && boundInspectorButton,
6223
6554
  (onThumbsUp || thumbsUpButton) && boundThumbsUpButton,
6224
6555
  (onThumbsDown || thumbsDownButton) && boundThumbsDownButton,
6225
6556
  (onReadAloud || readAloudButton) && boundReadAloudButton,
6226
6557
  (onRegenerate || regenerateButton) && boundRegenerateButton,
6227
- additionalToolbarItems
6558
+ additionalToolbarItems,
6559
+ showInspectorShortcut && boundInspectorButton
6228
6560
  ]
6229
6561
  }) });
6230
6562
  const boundToolCallsView = renderSlot(toolCallsView, CopilotChatToolCallsView, {
@@ -6233,7 +6565,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp,
6233
6565
  });
6234
6566
  const hasContent = !!(message.content && message.content.trim().length > 0);
6235
6567
  const isLatestAssistantMessage = message.role === "assistant" && messages?.[messages.length - 1]?.id === message.id;
6236
- const shouldShowToolbar = toolbarVisible && (hasContent || isInspectorEnabled) && !(isRunning && isLatestAssistantMessage);
6568
+ const shouldShowToolbar = toolbarVisible && (hasContent || showInspectorShortcut) && !(isRunning && isLatestAssistantMessage);
6237
6569
  if (children) return /* @__PURE__ */ jsx("div", {
6238
6570
  "data-copilotkit": true,
6239
6571
  style: { display: "contents" },
@@ -6274,110 +6606,6 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp,
6274
6606
  ]
6275
6607
  });
6276
6608
  }
6277
- function CopilotKitColoredIcon() {
6278
- const gradientId = useId().replace(/:/g, "");
6279
- return /* @__PURE__ */ jsxs("svg", {
6280
- "aria-hidden": "true",
6281
- className: "cpk:size-5",
6282
- "data-testid": "copilot-inspector-icon",
6283
- viewBox: "0 0 24 24",
6284
- children: [
6285
- /* @__PURE__ */ jsx("path", {
6286
- 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",
6287
- fill: `url(#${gradientId}-purple)`
6288
- }),
6289
- /* @__PURE__ */ jsx("path", {
6290
- 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",
6291
- fill: `url(#${gradientId}-blue)`
6292
- }),
6293
- /* @__PURE__ */ jsx("path", {
6294
- 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",
6295
- fill: `url(#${gradientId}-light-blue)`
6296
- }),
6297
- /* @__PURE__ */ jsx("path", {
6298
- className: "cpk:fill-[#513C9F] cpk:dark:fill-[#B99AE8]",
6299
- 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"
6300
- }),
6301
- /* @__PURE__ */ jsx("path", {
6302
- className: "cpk:fill-[#513C9F] cpk:dark:fill-[#B99AE8]",
6303
- 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"
6304
- }),
6305
- /* @__PURE__ */ jsx("path", {
6306
- className: "cpk:fill-[#ABABAB] cpk:dark:fill-[#D4D4D4]",
6307
- 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"
6308
- }),
6309
- /* @__PURE__ */ jsx("path", {
6310
- 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",
6311
- fill: `url(#${gradientId}-tail)`
6312
- }),
6313
- /* @__PURE__ */ jsxs("defs", { children: [
6314
- /* @__PURE__ */ jsxs("linearGradient", {
6315
- gradientUnits: "userSpaceOnUse",
6316
- id: `${gradientId}-purple`,
6317
- x1: "17.852",
6318
- x2: "14.202",
6319
- y1: "1.467",
6320
- y2: "11.504",
6321
- children: [/* @__PURE__ */ jsx("stop", { className: "cpk:[stop-color:#6430AB] cpk:dark:[stop-color:#B792F0]" }), /* @__PURE__ */ jsx("stop", {
6322
- className: "cpk:[stop-color:#AA89D8] cpk:dark:[stop-color:#D3BDF7]",
6323
- offset: "1"
6324
- })]
6325
- }),
6326
- /* @__PURE__ */ jsxs("linearGradient", {
6327
- gradientUnits: "userSpaceOnUse",
6328
- id: `${gradientId}-blue`,
6329
- x1: "15.024",
6330
- x2: "10.324",
6331
- y1: "7.125",
6332
- y2: "16.204",
6333
- children: [/* @__PURE__ */ jsx("stop", { className: "cpk:[stop-color:#005DBB] cpk:dark:[stop-color:#4D9FEF]" }), /* @__PURE__ */ jsx("stop", {
6334
- className: "cpk:[stop-color:#3D92E8] cpk:dark:[stop-color:#84C0FA]",
6335
- offset: "1"
6336
- })]
6337
- }),
6338
- /* @__PURE__ */ jsxs("linearGradient", {
6339
- gradientUnits: "userSpaceOnUse",
6340
- id: `${gradientId}-light-blue`,
6341
- x1: "17.122",
6342
- x2: "15.707",
6343
- y1: "1.467",
6344
- y2: "5.892",
6345
- children: [/* @__PURE__ */ jsx("stop", { className: "cpk:[stop-color:#1B70C4] cpk:dark:[stop-color:#61ACF2]" }), /* @__PURE__ */ jsx("stop", {
6346
- className: "cpk:[stop-color:#54A4F2] cpk:dark:[stop-color:#9ACDFF]",
6347
- offset: "1"
6348
- })]
6349
- }),
6350
- /* @__PURE__ */ jsxs("linearGradient", {
6351
- gradientUnits: "userSpaceOnUse",
6352
- id: `${gradientId}-tail`,
6353
- x1: "6.577",
6354
- x2: "21.506",
6355
- y1: "21.758",
6356
- y2: "21.758",
6357
- children: [
6358
- /* @__PURE__ */ jsx("stop", { className: "cpk:[stop-color:#4497EA] cpk:dark:[stop-color:#79BCF5]" }),
6359
- /* @__PURE__ */ jsx("stop", {
6360
- className: "cpk:[stop-color:#1463B2] cpk:dark:[stop-color:#4594D8]",
6361
- offset: ".255"
6362
- }),
6363
- /* @__PURE__ */ jsx("stop", {
6364
- className: "cpk:[stop-color:#0A437D] cpk:dark:[stop-color:#347CB7]",
6365
- offset: ".499"
6366
- }),
6367
- /* @__PURE__ */ jsx("stop", {
6368
- className: "cpk:[stop-color:#2476C8] cpk:dark:[stop-color:#58A4E5]",
6369
- offset: ".667"
6370
- }),
6371
- /* @__PURE__ */ jsx("stop", {
6372
- className: "cpk:[stop-color:#0C549A] cpk:dark:[stop-color:#3C87C7]",
6373
- offset: ".973"
6374
- })
6375
- ]
6376
- })
6377
- ] })
6378
- ]
6379
- });
6380
- }
6381
6609
  (function(_CopilotChatAssistantMessage) {
6382
6610
  _CopilotChatAssistantMessage.MarkdownRenderer = ({ content, className, ...props }) => /* @__PURE__ */ jsx(Streamdown, {
6383
6611
  className,
@@ -6435,30 +6663,7 @@ function CopilotKitColoredIcon() {
6435
6663
  children: copied ? /* @__PURE__ */ jsx(Check, { className: "cpk:size-[18px]" }) : /* @__PURE__ */ jsx(Copy, { className: "cpk:size-[18px]" })
6436
6664
  });
6437
6665
  };
6438
- _CopilotChatAssistantMessage.InspectorButton = ({ title, className, ...props }) => {
6439
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
6440
- const primaryLabel = title || labels.assistantMessageToolbarInspectorLabel;
6441
- const accessibleLabel = `${primaryLabel} (local only)`;
6442
- return /* @__PURE__ */ jsxs(ToolbarButton, {
6443
- "data-testid": "copilot-inspector-button",
6444
- title: accessibleLabel,
6445
- className: twMerge("cpk:w-auto cpk:gap-1.5 cpk:px-2", className),
6446
- tooltipClassName: "cpk:max-w-64 cpk:text-left cpk:leading-4",
6447
- tooltip: "View this message in the Inspector to get more information. This button and the inspector only display during local development (localhost, dev env).",
6448
- ...props,
6449
- children: [
6450
- /* @__PURE__ */ jsx(CopilotKitColoredIcon, {}),
6451
- /* @__PURE__ */ jsx("span", {
6452
- className: "cpk:font-medium",
6453
- children: primaryLabel
6454
- }),
6455
- /* @__PURE__ */ jsx("span", {
6456
- className: "cpk:text-xs cpk:text-muted-foreground",
6457
- children: "(local only)"
6458
- })
6459
- ]
6460
- });
6461
- };
6666
+ _CopilotChatAssistantMessage.InspectorButton = CopilotChatInspectorButton;
6462
6667
  _CopilotChatAssistantMessage.ThumbsUpButton = ({ title, ...props }) => {
6463
6668
  const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
6464
6669
  return /* @__PURE__ */ jsx(ToolbarButton, {
@@ -8708,9 +8913,15 @@ function useInspectorThreadOverride(args) {
8708
8913
 
8709
8914
  //#endregion
8710
8915
  //#region src/v2/components/chat/CopilotChat.tsx
8711
- function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen, attachments: attachmentsConfig, onError, throttleMs, ...props }) {
8916
+ function CopilotChat({ agentId, threadId, labels, inspectorTools, chatView, isModalDefaultOpen, attachments: attachmentsConfig, onError, throttleMs, ...props }) {
8712
8917
  const existingConfig = useCopilotChatConfiguration();
8713
- const resolvedAgentId = agentId ?? existingConfig?.agentId ?? DEFAULT_AGENT_ID;
8918
+ const inspector = useCopilotKitInspector();
8919
+ const inspectorContextValue = useMemo(() => ({
8920
+ ...inspector,
8921
+ isInspectorEnabled: inspector.isInspectorEnabled && (inspector.providerEnableInspector ?? inspectorTools ?? true)
8922
+ }), [inspector, inspectorTools]);
8923
+ const providerAgentId = useDefaultAgentId();
8924
+ const resolvedAgentId = agentId ?? existingConfig?.agentId ?? providerAgentId ?? DEFAULT_AGENT_ID;
8714
8925
  const providedThreadId = threadId ?? existingConfig?.threadId;
8715
8926
  const baseThreadId = useMemo(() => providedThreadId ?? randomUUID$1(), [providedThreadId]);
8716
8927
  const baseHasExplicitThreadId = !!threadId || !!existingConfig?.hasExplicitThreadId;
@@ -9283,7 +9494,10 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
9283
9494
  }),
9284
9495
  /* @__PURE__ */ jsx(LastUserMessageContext.Provider, {
9285
9496
  value: lastUserMessageState,
9286
- children: RenderedChatView
9497
+ children: /* @__PURE__ */ jsx(CopilotKitInspectorContextProvider, {
9498
+ value: inspectorContextValue,
9499
+ children: RenderedChatView
9500
+ })
9287
9501
  })
9288
9502
  ]
9289
9503
  })
@@ -9991,7 +10205,8 @@ function CopilotThreadsDrawer({ agentId, onThreadSelect, onNewThread, onLicensed
9991
10205
  const featureLicensed = checkFeature("threads");
9992
10206
  const licensed = licensePresent && featureLicensed;
9993
10207
  const licensePending = status === null;
9994
- const resolvedAgentId = agentId ?? configuration?.agentId ?? DEFAULT_AGENT_ID;
10208
+ const providerAgentId = useDefaultAgentId();
10209
+ const resolvedAgentId = agentId ?? configuration?.agentId ?? providerAgentId ?? DEFAULT_AGENT_ID;
9995
10210
  const activeThreadId = configuration?.threadId ?? null;
9996
10211
  const { threads, isLoading, listError, fetchMoreError, hasMoreThreads, isFetchingMoreThreads, archiveThread, unarchiveThread, deleteThread, fetchMoreThreads, refetchThreads, startNewThread } = useThreads$1({
9997
10212
  agentId: resolvedAgentId,
@@ -12450,4 +12665,4 @@ function validateProps(props) {
12450
12665
 
12451
12666
  //#endregion
12452
12667
  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 };
12453
- //# sourceMappingURL=copilotkit-Ap_yisA5.mjs.map
12668
+ //# sourceMappingURL=copilotkit-D5BTo0YG.mjs.map