@copilotkit/react-core 1.70.3 → 1.71.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{copilotkit-BU3OvveB.cjs → copilotkit-B4Jb1QEy.cjs} +365 -153
- package/dist/copilotkit-B4Jb1QEy.cjs.map +1 -0
- package/dist/{copilotkit-Bs98akp9.d.mts → copilotkit-ChjzWqn6.d.mts} +33 -8
- package/dist/copilotkit-ChjzWqn6.d.mts.map +1 -0
- package/dist/{copilotkit-X2eGbOwf.d.cts → copilotkit-DCIXZawe.d.cts} +33 -8
- package/dist/copilotkit-DCIXZawe.d.cts.map +1 -0
- package/dist/{copilotkit-Ap_yisA5.mjs → copilotkit-snbJkMqQ.mjs} +364 -152
- package/dist/copilotkit-snbJkMqQ.mjs.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +176 -138
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/context.cjs +4 -0
- package/dist/v2/context.cjs.map +1 -1
- package/dist/v2/context.d.cts +3 -1
- package/dist/v2/context.d.cts.map +1 -1
- package/dist/v2/context.d.mts +3 -1
- package/dist/v2/context.d.mts.map +1 -1
- package/dist/v2/context.mjs +3 -1
- package/dist/v2/context.mjs.map +1 -1
- package/dist/v2/headless.cjs +16 -4
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.d.cts +9 -4
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/headless.d.mts +9 -4
- package/dist/v2/headless.d.mts.map +1 -1
- package/dist/v2/headless.mjs +17 -5
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.css +1 -1
- package/dist/v2/index.d.cts +1 -1
- package/dist/v2/index.d.mts +1 -1
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +491 -277
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +7 -7
- package/skills/react-core/SKILL.md +1 -1
- package/skills/react-core/references/agent-access.md +69 -26
- package/skills/react-core/references/chat-components.md +22 -5
- package/dist/copilotkit-Ap_yisA5.mjs.map +0 -1
- package/dist/copilotkit-BU3OvveB.cjs.map +0 -1
- package/dist/copilotkit-Bs98akp9.d.mts.map +0 -1
- package/dist/copilotkit-X2eGbOwf.d.cts.map +0 -1
|
@@ -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
|
-
|
|
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
|
|
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
|
-
|
|
3697
|
+
providerEnableInspector: enableInspector,
|
|
3698
|
+
isInspectorEnabled: shouldRenderInspector && inspectorVisible,
|
|
3670
3699
|
openInspector: requestInspectorOpen
|
|
3671
|
-
}), [
|
|
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: [
|
|
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
|
|
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
|
|
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
|
});
|
|
@@ -6181,6 +6225,289 @@ function CopilotChatToolCallsView({ message, messages = [] }) {
|
|
|
6181
6225
|
}) });
|
|
6182
6226
|
}
|
|
6183
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
|
+
|
|
6184
6511
|
//#endregion
|
|
6185
6512
|
//#region src/v2/components/chat/CopilotChatAssistantMessage.tsx
|
|
6186
6513
|
/**
|
|
@@ -6201,30 +6528,32 @@ function BoundInspectorButton({ inspectorButton, messageId, openInspector, ...pr
|
|
|
6201
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 }) {
|
|
6202
6529
|
useKatexStyles();
|
|
6203
6530
|
const { isInspectorEnabled, openInspector } = useCopilotKitInspector();
|
|
6531
|
+
const shortcutsHidden = useInspectorShortcutsHidden();
|
|
6532
|
+
const showInspectorShortcut = isInspectorEnabled && !shortcutsHidden;
|
|
6204
6533
|
const boundMarkdownRenderer = renderSlot(markdownRenderer, CopilotChatAssistantMessage.MarkdownRenderer, { content: message.content || "" });
|
|
6205
6534
|
const boundCopyButton = renderSlot(copyButton, CopilotChatAssistantMessage.CopyButton, { onClick: async () => {
|
|
6206
6535
|
if (message.content) return await copyToClipboard(message.content);
|
|
6207
6536
|
return false;
|
|
6208
6537
|
} });
|
|
6209
6538
|
const boundThumbsUpButton = renderSlot(thumbsUpButton, CopilotChatAssistantMessage.ThumbsUpButton, { onClick: onThumbsUp ? () => onThumbsUp(message) : void 0 });
|
|
6210
|
-
const boundInspectorButton = /* @__PURE__ */ jsx(BoundInspectorButton, {
|
|
6539
|
+
const boundInspectorButton = showInspectorShortcut ? /* @__PURE__ */ jsx(BoundInspectorButton, {
|
|
6211
6540
|
inspectorButton,
|
|
6212
6541
|
messageId: message.id,
|
|
6213
6542
|
openInspector
|
|
6214
|
-
});
|
|
6543
|
+
}) : /* @__PURE__ */ jsx(Fragment$1, {});
|
|
6215
6544
|
const boundThumbsDownButton = renderSlot(thumbsDownButton, CopilotChatAssistantMessage.ThumbsDownButton, { onClick: onThumbsDown ? () => onThumbsDown(message) : void 0 });
|
|
6216
6545
|
const boundReadAloudButton = renderSlot(readAloudButton, CopilotChatAssistantMessage.ReadAloudButton, { onClick: onReadAloud ? () => onReadAloud(message) : void 0 });
|
|
6217
6546
|
const boundRegenerateButton = renderSlot(regenerateButton, CopilotChatAssistantMessage.RegenerateButton, { onClick: onRegenerate ? () => onRegenerate(message) : void 0 });
|
|
6218
6547
|
const boundToolbar = renderSlot(toolbar, CopilotChatAssistantMessage.Toolbar, { children: /* @__PURE__ */ jsxs("div", {
|
|
6219
|
-
className: "cpk:flex cpk:items-center cpk:gap-1",
|
|
6548
|
+
className: "cpk:flex cpk:w-full cpk:items-center cpk:gap-1",
|
|
6220
6549
|
children: [
|
|
6221
6550
|
boundCopyButton,
|
|
6222
|
-
isInspectorEnabled && boundInspectorButton,
|
|
6223
6551
|
(onThumbsUp || thumbsUpButton) && boundThumbsUpButton,
|
|
6224
6552
|
(onThumbsDown || thumbsDownButton) && boundThumbsDownButton,
|
|
6225
6553
|
(onReadAloud || readAloudButton) && boundReadAloudButton,
|
|
6226
6554
|
(onRegenerate || regenerateButton) && boundRegenerateButton,
|
|
6227
|
-
additionalToolbarItems
|
|
6555
|
+
additionalToolbarItems,
|
|
6556
|
+
showInspectorShortcut && boundInspectorButton
|
|
6228
6557
|
]
|
|
6229
6558
|
}) });
|
|
6230
6559
|
const boundToolCallsView = renderSlot(toolCallsView, CopilotChatToolCallsView, {
|
|
@@ -6233,7 +6562,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp,
|
|
|
6233
6562
|
});
|
|
6234
6563
|
const hasContent = !!(message.content && message.content.trim().length > 0);
|
|
6235
6564
|
const isLatestAssistantMessage = message.role === "assistant" && messages?.[messages.length - 1]?.id === message.id;
|
|
6236
|
-
const shouldShowToolbar = toolbarVisible && (hasContent ||
|
|
6565
|
+
const shouldShowToolbar = toolbarVisible && (hasContent || showInspectorShortcut) && !(isRunning && isLatestAssistantMessage);
|
|
6237
6566
|
if (children) return /* @__PURE__ */ jsx("div", {
|
|
6238
6567
|
"data-copilotkit": true,
|
|
6239
6568
|
style: { display: "contents" },
|
|
@@ -6274,110 +6603,6 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp,
|
|
|
6274
6603
|
]
|
|
6275
6604
|
});
|
|
6276
6605
|
}
|
|
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
6606
|
(function(_CopilotChatAssistantMessage) {
|
|
6382
6607
|
_CopilotChatAssistantMessage.MarkdownRenderer = ({ content, className, ...props }) => /* @__PURE__ */ jsx(Streamdown, {
|
|
6383
6608
|
className,
|
|
@@ -6435,30 +6660,7 @@ function CopilotKitColoredIcon() {
|
|
|
6435
6660
|
children: copied ? /* @__PURE__ */ jsx(Check, { className: "cpk:size-[18px]" }) : /* @__PURE__ */ jsx(Copy, { className: "cpk:size-[18px]" })
|
|
6436
6661
|
});
|
|
6437
6662
|
};
|
|
6438
|
-
_CopilotChatAssistantMessage.InspectorButton =
|
|
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
|
-
};
|
|
6663
|
+
_CopilotChatAssistantMessage.InspectorButton = CopilotChatInspectorButton;
|
|
6462
6664
|
_CopilotChatAssistantMessage.ThumbsUpButton = ({ title, ...props }) => {
|
|
6463
6665
|
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
6464
6666
|
return /* @__PURE__ */ jsx(ToolbarButton, {
|
|
@@ -8708,9 +8910,15 @@ function useInspectorThreadOverride(args) {
|
|
|
8708
8910
|
|
|
8709
8911
|
//#endregion
|
|
8710
8912
|
//#region src/v2/components/chat/CopilotChat.tsx
|
|
8711
|
-
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 }) {
|
|
8712
8914
|
const existingConfig = useCopilotChatConfiguration();
|
|
8713
|
-
const
|
|
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;
|
|
8714
8922
|
const providedThreadId = threadId ?? existingConfig?.threadId;
|
|
8715
8923
|
const baseThreadId = useMemo(() => providedThreadId ?? randomUUID$1(), [providedThreadId]);
|
|
8716
8924
|
const baseHasExplicitThreadId = !!threadId || !!existingConfig?.hasExplicitThreadId;
|
|
@@ -9283,7 +9491,10 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
9283
9491
|
}),
|
|
9284
9492
|
/* @__PURE__ */ jsx(LastUserMessageContext.Provider, {
|
|
9285
9493
|
value: lastUserMessageState,
|
|
9286
|
-
children:
|
|
9494
|
+
children: /* @__PURE__ */ jsx(CopilotKitInspectorContextProvider, {
|
|
9495
|
+
value: inspectorContextValue,
|
|
9496
|
+
children: RenderedChatView
|
|
9497
|
+
})
|
|
9287
9498
|
})
|
|
9288
9499
|
]
|
|
9289
9500
|
})
|
|
@@ -9991,7 +10202,8 @@ function CopilotThreadsDrawer({ agentId, onThreadSelect, onNewThread, onLicensed
|
|
|
9991
10202
|
const featureLicensed = checkFeature("threads");
|
|
9992
10203
|
const licensed = licensePresent && featureLicensed;
|
|
9993
10204
|
const licensePending = status === null;
|
|
9994
|
-
const
|
|
10205
|
+
const providerAgentId = useDefaultAgentId();
|
|
10206
|
+
const resolvedAgentId = agentId ?? configuration?.agentId ?? providerAgentId ?? DEFAULT_AGENT_ID;
|
|
9995
10207
|
const activeThreadId = configuration?.threadId ?? null;
|
|
9996
10208
|
const { threads, isLoading, listError, fetchMoreError, hasMoreThreads, isFetchingMoreThreads, archiveThread, unarchiveThread, deleteThread, fetchMoreThreads, refetchThreads, startNewThread } = useThreads$1({
|
|
9997
10209
|
agentId: resolvedAgentId,
|
|
@@ -12450,4 +12662,4 @@ function validateProps(props) {
|
|
|
12450
12662
|
|
|
12451
12663
|
//#endregion
|
|
12452
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 };
|
|
12453
|
-
//# sourceMappingURL=copilotkit-
|
|
12665
|
+
//# sourceMappingURL=copilotkit-snbJkMqQ.mjs.map
|