@copilotkit/react-core 1.69.1 → 1.69.2
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-Dr0speVK.cjs → copilotkit-Ba7qwYt3.cjs} +34 -288
- package/dist/copilotkit-Ba7qwYt3.cjs.map +1 -0
- package/dist/{copilotkit-Dr6g885f.mjs → copilotkit-BmW2sFH6.mjs} +35 -289
- package/dist/copilotkit-BmW2sFH6.mjs.map +1 -0
- package/dist/{copilotkit-Hl1t9Y1v.d.cts → copilotkit-CF1Pm2VG.d.cts} +2 -7
- package/dist/copilotkit-CF1Pm2VG.d.cts.map +1 -0
- package/dist/{copilotkit-DYKpg4pD.d.mts → copilotkit-TdM-5onZ.d.mts} +2 -7
- package/dist/copilotkit-TdM-5onZ.d.mts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +5 -46
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/headless.cjs +0 -1
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.d.cts +0 -1
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/headless.d.mts +0 -1
- package/dist/v2/headless.d.mts.map +1 -1
- package/dist/v2/headless.mjs +0 -1
- 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 +33 -287
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +7 -7
- package/skills/react-core/SKILL.md +1 -1
- package/dist/copilotkit-DYKpg4pD.d.mts.map +0 -1
- package/dist/copilotkit-Dr0speVK.cjs.map +0 -1
- package/dist/copilotkit-Dr6g885f.mjs.map +0 -1
- package/dist/copilotkit-Hl1t9Y1v.d.cts.map +0 -1
|
@@ -3,7 +3,7 @@ import React, { createContext, forwardRef, memo, useCallback, useContext, useEff
|
|
|
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,
|
|
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";
|
|
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 } from "@copilotkit/shared";
|
|
8
8
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { Slot } from "@radix-ui/react-slot";
|
|
@@ -78,7 +78,6 @@ const CopilotChatDefaultLabels = {
|
|
|
78
78
|
assistantMessageToolbarCopyMessageLabel: "Copy",
|
|
79
79
|
assistantMessageToolbarInspectorLabel: "View in Inspector",
|
|
80
80
|
assistantMessageToolbarInspectorLocalOnlyLabel: "Local Only",
|
|
81
|
-
assistantMessageToolbarSaveSnippetLabel: "Save as snippet",
|
|
82
81
|
assistantMessageToolbarThumbsUpLabel: "Good response",
|
|
83
82
|
assistantMessageToolbarThumbsDownLabel: "Bad response",
|
|
84
83
|
assistantMessageToolbarReadAloudLabel: "Read aloud",
|
|
@@ -1531,8 +1530,7 @@ CopilotKitInspector.displayName = "CopilotKitInspector";
|
|
|
1531
1530
|
//#region src/v2/components/CopilotKitInspectorContext.tsx
|
|
1532
1531
|
const CopilotKitInspectorContext = React$1.createContext({
|
|
1533
1532
|
isLocalInspectorEnabled: false,
|
|
1534
|
-
openInspector: () => void 0
|
|
1535
|
-
saveEventSnippet: async () => void 0
|
|
1533
|
+
openInspector: () => void 0
|
|
1536
1534
|
});
|
|
1537
1535
|
const CopilotKitInspectorContextProvider = CopilotKitInspectorContext.Provider;
|
|
1538
1536
|
function useCopilotKitInspector() {
|
|
@@ -2346,7 +2344,6 @@ function injectCssIntoHtml(html, css) {
|
|
|
2346
2344
|
const OpenGenerativeUIActivityRendererInner = React.memo(function OpenGenerativeUIActivityRendererInner({ content }) {
|
|
2347
2345
|
const initialHeight = content.initialHeight ?? 200;
|
|
2348
2346
|
const [autoHeight, setAutoHeight] = useState(null);
|
|
2349
|
-
const [sandboxReady, setSandboxReady] = useState(false);
|
|
2350
2347
|
const sandboxFunctions = useSandboxFunctions();
|
|
2351
2348
|
const localApi = useMemo(() => {
|
|
2352
2349
|
const api = {};
|
|
@@ -2448,7 +2445,6 @@ const OpenGenerativeUIActivityRendererInner = React.memo(function OpenGenerative
|
|
|
2448
2445
|
sandbox.promise.then(() => {
|
|
2449
2446
|
if (cancelled) return;
|
|
2450
2447
|
sandboxReadyRef.current = true;
|
|
2451
|
-
setSandboxReady(true);
|
|
2452
2448
|
sandbox.run(`
|
|
2453
2449
|
var s = document.createElement('style');
|
|
2454
2450
|
s.textContent = 'html, body { overflow: hidden !important; }';
|
|
@@ -2473,7 +2469,6 @@ const OpenGenerativeUIActivityRendererInner = React.memo(function OpenGenerative
|
|
|
2473
2469
|
sandboxRef.current = null;
|
|
2474
2470
|
}
|
|
2475
2471
|
sandboxReadyRef.current = false;
|
|
2476
|
-
setSandboxReady(false);
|
|
2477
2472
|
setAutoHeight(null);
|
|
2478
2473
|
};
|
|
2479
2474
|
}, [
|
|
@@ -2504,7 +2499,7 @@ const OpenGenerativeUIActivityRendererInner = React.memo(function OpenGenerative
|
|
|
2504
2499
|
const generationDone = content.generating === false;
|
|
2505
2500
|
useEffect(() => {
|
|
2506
2501
|
const sandbox = sandboxRef.current;
|
|
2507
|
-
if (!generationDone || !
|
|
2502
|
+
if (!generationDone || !sandbox) return;
|
|
2508
2503
|
let handled = false;
|
|
2509
2504
|
const onMessage = (e) => {
|
|
2510
2505
|
if (handled) return;
|
|
@@ -2533,7 +2528,7 @@ const OpenGenerativeUIActivityRendererInner = React.memo(function OpenGenerative
|
|
|
2533
2528
|
return () => {
|
|
2534
2529
|
window.removeEventListener("message", onMessage);
|
|
2535
2530
|
};
|
|
2536
|
-
}, [generationDone
|
|
2531
|
+
}, [generationDone]);
|
|
2537
2532
|
const height = autoHeight ?? initialHeight;
|
|
2538
2533
|
const isGenerating = content.generating !== false;
|
|
2539
2534
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -3517,46 +3512,10 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3517
3512
|
const requestInspectorOpen = useCallback((request) => {
|
|
3518
3513
|
setInspectorOpenRequest({ ...request });
|
|
3519
3514
|
}, []);
|
|
3520
|
-
const saveEventSnippet = useCallback(async (request) => {
|
|
3521
|
-
try {
|
|
3522
|
-
const mod = await import("@copilotkit/web-inspector");
|
|
3523
|
-
const threadId = request.threadId ?? "inspector-snippet";
|
|
3524
|
-
const runId = `inspector-snippet-${Date.now()}`;
|
|
3525
|
-
const compiled = mod.compileChatSnippet({
|
|
3526
|
-
...request,
|
|
3527
|
-
threadId,
|
|
3528
|
-
runId
|
|
3529
|
-
});
|
|
3530
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3531
|
-
const snippet = {
|
|
3532
|
-
id: crypto.randomUUID(),
|
|
3533
|
-
name: compiled.name,
|
|
3534
|
-
recipe: compiled.recipe,
|
|
3535
|
-
events: compiled.events,
|
|
3536
|
-
createdAt: now,
|
|
3537
|
-
updatedAt: now
|
|
3538
|
-
};
|
|
3539
|
-
mod.upsertEventSnippet(snippet);
|
|
3540
|
-
requestInspectorOpen({
|
|
3541
|
-
messageId: request.messageId,
|
|
3542
|
-
threadId: request.threadId,
|
|
3543
|
-
agentId: request.agentId,
|
|
3544
|
-
menu: "event-snippets",
|
|
3545
|
-
snippetId: snippet.id
|
|
3546
|
-
});
|
|
3547
|
-
} catch (error) {
|
|
3548
|
-
console.error("[CopilotKit] Could not save the event snippet.", error);
|
|
3549
|
-
}
|
|
3550
|
-
}, [requestInspectorOpen]);
|
|
3551
3515
|
const inspectorContextValue = useMemo(() => ({
|
|
3552
3516
|
isLocalInspectorEnabled,
|
|
3553
|
-
openInspector: requestInspectorOpen
|
|
3554
|
-
|
|
3555
|
-
}), [
|
|
3556
|
-
isLocalInspectorEnabled,
|
|
3557
|
-
requestInspectorOpen,
|
|
3558
|
-
saveEventSnippet
|
|
3559
|
-
]);
|
|
3517
|
+
openInspector: requestInspectorOpen
|
|
3518
|
+
}), [isLocalInspectorEnabled, requestInspectorOpen]);
|
|
3560
3519
|
const renderToolCallsList = useStableArrayProp(renderToolCalls, "renderToolCalls must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead.", (initial, next) => {
|
|
3561
3520
|
const key = (rc) => `${rc?.agentId ?? ""}:${rc?.name ?? ""}`;
|
|
3562
3521
|
const setFrom = (arr) => new Set(arr.map(key));
|
|
@@ -5933,191 +5892,25 @@ function useLearningContainersInCurrentThread({ learningContainers }) {
|
|
|
5933
5892
|
});
|
|
5934
5893
|
}
|
|
5935
5894
|
|
|
5936
|
-
//#endregion
|
|
5937
|
-
//#region src/v2/components/chat/save-snippet-beside.ts
|
|
5938
|
-
const SAVE_SNIPPET_ICON_SLOT_PX = 36;
|
|
5939
|
-
const SAVE_SNIPPET_BESIDE_WRAP_CLASS = "cpk:relative cpk:w-full cpk:overflow-visible";
|
|
5940
|
-
const SAVE_SNIPPET_BESIDE_BODY_CLASS = "cpk:w-full";
|
|
5941
|
-
const SAVE_SNIPPET_BESIDE_SAVE_CLASS = "cpk:absolute cpk:top-0 cpk:z-10";
|
|
5942
|
-
function saveSnippetBesideStyle(side) {
|
|
5943
|
-
if (side === "left") return {
|
|
5944
|
-
left: "auto",
|
|
5945
|
-
right: "100%",
|
|
5946
|
-
marginLeft: 0,
|
|
5947
|
-
marginRight: 4
|
|
5948
|
-
};
|
|
5949
|
-
return {
|
|
5950
|
-
left: "100%",
|
|
5951
|
-
right: "auto",
|
|
5952
|
-
marginLeft: 4,
|
|
5953
|
-
marginRight: 0
|
|
5954
|
-
};
|
|
5955
|
-
}
|
|
5956
|
-
function pickSaveSnippetSide(roomRight, roomLeft, slotPx = SAVE_SNIPPET_ICON_SLOT_PX) {
|
|
5957
|
-
if (roomRight >= slotPx) return "right";
|
|
5958
|
-
if (roomLeft >= slotPx) return "left";
|
|
5959
|
-
return "right";
|
|
5960
|
-
}
|
|
5961
|
-
function findOverflowAncestor(el) {
|
|
5962
|
-
let node = el.parentElement;
|
|
5963
|
-
while (node) {
|
|
5964
|
-
const style = getComputedStyle(node);
|
|
5965
|
-
const overflowX = style.overflowX;
|
|
5966
|
-
const overflow = style.overflow;
|
|
5967
|
-
if (overflowX === "hidden" || overflowX === "auto" || overflowX === "scroll" || overflow === "hidden" || overflow === "auto" || overflow === "scroll") return node;
|
|
5968
|
-
node = node.parentElement;
|
|
5969
|
-
}
|
|
5970
|
-
return document.documentElement;
|
|
5971
|
-
}
|
|
5972
|
-
function measurableBox(el) {
|
|
5973
|
-
let node = el;
|
|
5974
|
-
while (node && getComputedStyle(node).display === "contents") node = node.firstElementChild;
|
|
5975
|
-
return node ?? el;
|
|
5976
|
-
}
|
|
5977
|
-
function measureSaveSnippetSide(wrap, body) {
|
|
5978
|
-
const clipRect = findOverflowAncestor(wrap).getBoundingClientRect();
|
|
5979
|
-
const bodyRect = measurableBox(body.firstElementChild ?? body).getBoundingClientRect();
|
|
5980
|
-
return pickSaveSnippetSide(clipRect.right - bodyRect.right, bodyRect.left - clipRect.left);
|
|
5981
|
-
}
|
|
5982
|
-
|
|
5983
|
-
//#endregion
|
|
5984
|
-
//#region src/v2/components/chat/SaveSnippetIconButton.tsx
|
|
5985
|
-
function SaveSnippetIconButton({ title, className, ...props }) {
|
|
5986
|
-
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
5987
|
-
const primaryLabel = title || labels.assistantMessageToolbarSaveSnippetLabel;
|
|
5988
|
-
const localOnlyLabel = labels.assistantMessageToolbarInspectorLocalOnlyLabel;
|
|
5989
|
-
const accessibleLabel = `${primaryLabel} (${localOnlyLabel})`;
|
|
5990
|
-
return /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
5991
|
-
asChild: true,
|
|
5992
|
-
children: /* @__PURE__ */ jsx(Button, {
|
|
5993
|
-
type: "button",
|
|
5994
|
-
variant: "assistantMessageToolbarButton",
|
|
5995
|
-
"aria-label": accessibleLabel,
|
|
5996
|
-
title: accessibleLabel,
|
|
5997
|
-
className,
|
|
5998
|
-
...props,
|
|
5999
|
-
children: /* @__PURE__ */ jsx(Bookmark, { className: "cpk:size-[18px]" })
|
|
6000
|
-
})
|
|
6001
|
-
}), /* @__PURE__ */ jsx(TooltipContent, {
|
|
6002
|
-
side: "bottom",
|
|
6003
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
6004
|
-
className: "cpk:flex cpk:flex-col cpk:gap-0.5",
|
|
6005
|
-
children: [/* @__PURE__ */ jsx("span", { children: primaryLabel }), /* @__PURE__ */ jsx("span", {
|
|
6006
|
-
className: "cpk:text-[10px] cpk:opacity-65",
|
|
6007
|
-
children: localOnlyLabel
|
|
6008
|
-
})]
|
|
6009
|
-
})
|
|
6010
|
-
})] });
|
|
6011
|
-
}
|
|
6012
|
-
function SaveSnippetBesideChrome({ children, showSave, saveButton }) {
|
|
6013
|
-
const wrapRef = useRef(null);
|
|
6014
|
-
const bodyRef = useRef(null);
|
|
6015
|
-
const [side, setSide] = useState("right");
|
|
6016
|
-
useLayoutEffect(() => {
|
|
6017
|
-
if (!showSave) return;
|
|
6018
|
-
const wrap = wrapRef.current;
|
|
6019
|
-
const body = bodyRef.current;
|
|
6020
|
-
if (!wrap || !body) return;
|
|
6021
|
-
const measure = () => {
|
|
6022
|
-
setSide(measureSaveSnippetSide(wrap, body));
|
|
6023
|
-
};
|
|
6024
|
-
measure();
|
|
6025
|
-
if (typeof ResizeObserver === "undefined") return;
|
|
6026
|
-
const observer = new ResizeObserver(measure);
|
|
6027
|
-
observer.observe(wrap);
|
|
6028
|
-
observer.observe(body);
|
|
6029
|
-
const clip = findOverflowAncestor(wrap);
|
|
6030
|
-
if (clip !== wrap) observer.observe(clip);
|
|
6031
|
-
window.addEventListener("resize", measure);
|
|
6032
|
-
return () => {
|
|
6033
|
-
observer.disconnect();
|
|
6034
|
-
window.removeEventListener("resize", measure);
|
|
6035
|
-
};
|
|
6036
|
-
}, [showSave]);
|
|
6037
|
-
if (!showSave) return children;
|
|
6038
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
6039
|
-
ref: wrapRef,
|
|
6040
|
-
className: SAVE_SNIPPET_BESIDE_WRAP_CLASS,
|
|
6041
|
-
"data-save-snippet-side": side,
|
|
6042
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
6043
|
-
ref: bodyRef,
|
|
6044
|
-
className: SAVE_SNIPPET_BESIDE_BODY_CLASS,
|
|
6045
|
-
children
|
|
6046
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
6047
|
-
className: SAVE_SNIPPET_BESIDE_SAVE_CLASS,
|
|
6048
|
-
style: saveSnippetBesideStyle(side),
|
|
6049
|
-
children: saveButton
|
|
6050
|
-
})]
|
|
6051
|
-
});
|
|
6052
|
-
}
|
|
6053
|
-
|
|
6054
5895
|
//#endregion
|
|
6055
5896
|
//#region src/v2/components/chat/CopilotChatToolCallsView.tsx
|
|
6056
5897
|
function CopilotChatToolCallsView({ message, messages = [] }) {
|
|
6057
5898
|
const renderToolCall = useRenderToolCall();
|
|
6058
|
-
const { isLocalInspectorEnabled, saveEventSnippet } = useCopilotKitInspector();
|
|
6059
|
-
const chatConfiguration = useCopilotChatConfiguration();
|
|
6060
|
-
const labels = chatConfiguration?.labels ?? CopilotChatDefaultLabels;
|
|
6061
5899
|
if (!message.toolCalls || message.toolCalls.length === 0) return null;
|
|
6062
5900
|
return /* @__PURE__ */ jsx(Fragment$1, { children: message.toolCalls.map((toolCall) => {
|
|
6063
|
-
const
|
|
5901
|
+
const toolMessage = messages.find((m) => m.role === "tool" && m.toolCallId === toolCall.id);
|
|
5902
|
+
return /* @__PURE__ */ jsx(React.Fragment, { children: renderToolCall({
|
|
6064
5903
|
toolCall,
|
|
6065
|
-
toolMessage
|
|
6066
|
-
});
|
|
6067
|
-
if (!isLocalInspectorEnabled || !hasCompleteArgs(toolCall.function.arguments)) return /* @__PURE__ */ jsx(React.Fragment, { children: rendered }, toolCall.id);
|
|
6068
|
-
const primaryLabel = labels.assistantMessageToolbarSaveSnippetLabel;
|
|
6069
|
-
return /* @__PURE__ */ jsx(ToolCallSnippetChrome, {
|
|
6070
|
-
label: primaryLabel,
|
|
6071
|
-
onSave: () => void saveEventSnippet({
|
|
6072
|
-
kind: "tool-call",
|
|
6073
|
-
messageId: message.id,
|
|
6074
|
-
toolCallId: toolCall.id,
|
|
6075
|
-
toolName: toolCall.function.name,
|
|
6076
|
-
argsJson: toolCall.function.arguments || "{}",
|
|
6077
|
-
threadId: chatConfiguration?.threadId,
|
|
6078
|
-
agentId: chatConfiguration?.agentId
|
|
6079
|
-
}),
|
|
6080
|
-
children: rendered
|
|
6081
|
-
}, toolCall.id);
|
|
5904
|
+
toolMessage
|
|
5905
|
+
}) }, toolCall.id);
|
|
6082
5906
|
}) });
|
|
6083
5907
|
}
|
|
6084
|
-
function hasCompleteArgs(args) {
|
|
6085
|
-
const trimmed = (args ?? "").trim();
|
|
6086
|
-
if (!trimmed) return true;
|
|
6087
|
-
try {
|
|
6088
|
-
JSON.parse(trimmed);
|
|
6089
|
-
return true;
|
|
6090
|
-
} catch {
|
|
6091
|
-
return false;
|
|
6092
|
-
}
|
|
6093
|
-
}
|
|
6094
|
-
function ToolCallSnippetChrome({ children, label, onSave }) {
|
|
6095
|
-
const bodyRef = useRef(null);
|
|
6096
|
-
const [showSave, setShowSave] = useState(false);
|
|
6097
|
-
useLayoutEffect(() => {
|
|
6098
|
-
const el = bodyRef.current;
|
|
6099
|
-
setShowSave(!!el && el.childElementCount > 0);
|
|
6100
|
-
});
|
|
6101
|
-
return /* @__PURE__ */ jsx(SaveSnippetBesideChrome, {
|
|
6102
|
-
showSave,
|
|
6103
|
-
saveButton: /* @__PURE__ */ jsx(SaveSnippetIconButton, {
|
|
6104
|
-
"data-testid": "copilot-tool-save-snippet-button",
|
|
6105
|
-
title: label,
|
|
6106
|
-
onClick: onSave
|
|
6107
|
-
}),
|
|
6108
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
6109
|
-
ref: bodyRef,
|
|
6110
|
-
className: "cpk:contents",
|
|
6111
|
-
children
|
|
6112
|
-
})
|
|
6113
|
-
});
|
|
6114
|
-
}
|
|
6115
5908
|
|
|
6116
5909
|
//#endregion
|
|
6117
5910
|
//#region src/v2/components/chat/CopilotChatAssistantMessage.tsx
|
|
6118
|
-
function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp, onThumbsDown, onReadAloud, onRegenerate, additionalToolbarItems, toolbarVisible = true, markdownRenderer, toolbar, copyButton, inspectorButton,
|
|
5911
|
+
function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp, onThumbsDown, onReadAloud, onRegenerate, additionalToolbarItems, toolbarVisible = true, markdownRenderer, toolbar, copyButton, inspectorButton, thumbsUpButton, thumbsDownButton, readAloudButton, regenerateButton, toolCallsView, children, className, ...props }) {
|
|
6119
5912
|
useKatexStyles();
|
|
6120
|
-
const { isLocalInspectorEnabled, openInspector
|
|
5913
|
+
const { isLocalInspectorEnabled, openInspector } = useCopilotKitInspector();
|
|
6121
5914
|
const chatConfiguration = useCopilotChatConfiguration();
|
|
6122
5915
|
const boundMarkdownRenderer = renderSlot(markdownRenderer, CopilotChatAssistantMessage.MarkdownRenderer, { content: message.content || "" });
|
|
6123
5916
|
const boundCopyButton = renderSlot(copyButton, CopilotChatAssistantMessage.CopyButton, { onClick: async () => {
|
|
@@ -6130,17 +5923,6 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp,
|
|
|
6130
5923
|
threadId: chatConfiguration?.threadId,
|
|
6131
5924
|
agentId: chatConfiguration?.agentId
|
|
6132
5925
|
}) });
|
|
6133
|
-
const hasContent = !!(message.content && message.content.trim().length > 0);
|
|
6134
|
-
const boundSaveSnippetButton = renderSlot(saveSnippetButton, CopilotChatAssistantMessage.SaveSnippetButton, { onClick: () => {
|
|
6135
|
-
if (!hasContent) return;
|
|
6136
|
-
saveEventSnippet({
|
|
6137
|
-
kind: "text",
|
|
6138
|
-
messageId: message.id,
|
|
6139
|
-
content: message.content ?? "",
|
|
6140
|
-
threadId: chatConfiguration?.threadId,
|
|
6141
|
-
agentId: chatConfiguration?.agentId
|
|
6142
|
-
});
|
|
6143
|
-
} });
|
|
6144
5926
|
const boundThumbsDownButton = renderSlot(thumbsDownButton, CopilotChatAssistantMessage.ThumbsDownButton, { onClick: onThumbsDown ? () => onThumbsDown(message) : void 0 });
|
|
6145
5927
|
const boundReadAloudButton = renderSlot(readAloudButton, CopilotChatAssistantMessage.ReadAloudButton, { onClick: onReadAloud ? () => onReadAloud(message) : void 0 });
|
|
6146
5928
|
const boundRegenerateButton = renderSlot(regenerateButton, CopilotChatAssistantMessage.RegenerateButton, { onClick: onRegenerate ? () => onRegenerate(message) : void 0 });
|
|
@@ -6149,7 +5931,6 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp,
|
|
|
6149
5931
|
children: [
|
|
6150
5932
|
boundCopyButton,
|
|
6151
5933
|
isLocalInspectorEnabled && boundInspectorButton,
|
|
6152
|
-
isLocalInspectorEnabled && hasContent && boundSaveSnippetButton,
|
|
6153
5934
|
(onThumbsUp || thumbsUpButton) && boundThumbsUpButton,
|
|
6154
5935
|
(onThumbsDown || thumbsDownButton) && boundThumbsDownButton,
|
|
6155
5936
|
(onReadAloud || readAloudButton) && boundReadAloudButton,
|
|
@@ -6161,6 +5942,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp,
|
|
|
6161
5942
|
message,
|
|
6162
5943
|
messages
|
|
6163
5944
|
});
|
|
5945
|
+
const hasContent = !!(message.content && message.content.trim().length > 0);
|
|
6164
5946
|
const isLatestAssistantMessage = message.role === "assistant" && messages?.[messages.length - 1]?.id === message.id;
|
|
6165
5947
|
const shouldShowToolbar = toolbarVisible && (hasContent || isLocalInspectorEnabled) && !(isRunning && isLatestAssistantMessage);
|
|
6166
5948
|
if (children) return /* @__PURE__ */ jsx("div", {
|
|
@@ -6172,7 +5954,6 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp,
|
|
|
6172
5954
|
toolCallsView: boundToolCallsView,
|
|
6173
5955
|
copyButton: boundCopyButton,
|
|
6174
5956
|
inspectorButton: boundInspectorButton,
|
|
6175
|
-
saveSnippetButton: boundSaveSnippetButton,
|
|
6176
5957
|
thumbsUpButton: boundThumbsUpButton,
|
|
6177
5958
|
thumbsDownButton: boundThumbsDownButton,
|
|
6178
5959
|
readAloudButton: boundReadAloudButton,
|
|
@@ -6319,7 +6100,7 @@ function CopilotKitColoredIcon() {
|
|
|
6319
6100
|
className: twMerge("cpk:w-full cpk:bg-transparent cpk:flex cpk:items-center cpk:-ml-[5px] cpk:-mt-[0px]", className),
|
|
6320
6101
|
...props
|
|
6321
6102
|
});
|
|
6322
|
-
const ToolbarButton = _CopilotChatAssistantMessage.ToolbarButton = ({ title, tooltip, children, ...props }) => {
|
|
6103
|
+
const ToolbarButton = _CopilotChatAssistantMessage.ToolbarButton = ({ title, tooltip, tooltipClassName, children, ...props }) => {
|
|
6323
6104
|
return /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
6324
6105
|
asChild: true,
|
|
6325
6106
|
children: /* @__PURE__ */ jsx(Button, {
|
|
@@ -6331,6 +6112,7 @@ function CopilotKitColoredIcon() {
|
|
|
6331
6112
|
})
|
|
6332
6113
|
}), /* @__PURE__ */ jsx(TooltipContent, {
|
|
6333
6114
|
side: "bottom",
|
|
6115
|
+
className: tooltipClassName,
|
|
6334
6116
|
children: tooltip ?? /* @__PURE__ */ jsx("p", { children: title })
|
|
6335
6117
|
})] });
|
|
6336
6118
|
};
|
|
@@ -6364,29 +6146,30 @@ function CopilotKitColoredIcon() {
|
|
|
6364
6146
|
children: copied ? /* @__PURE__ */ jsx(Check, { className: "cpk:size-[18px]" }) : /* @__PURE__ */ jsx(Copy, { className: "cpk:size-[18px]" })
|
|
6365
6147
|
});
|
|
6366
6148
|
};
|
|
6367
|
-
_CopilotChatAssistantMessage.InspectorButton = ({ title, ...props }) => {
|
|
6149
|
+
_CopilotChatAssistantMessage.InspectorButton = ({ title, className, ...props }) => {
|
|
6368
6150
|
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
6369
6151
|
const primaryLabel = title || labels.assistantMessageToolbarInspectorLabel;
|
|
6370
|
-
const
|
|
6371
|
-
|
|
6372
|
-
return /* @__PURE__ */ jsx(ToolbarButton, {
|
|
6152
|
+
const accessibleLabel = `${primaryLabel} (local only)`;
|
|
6153
|
+
return /* @__PURE__ */ jsxs(ToolbarButton, {
|
|
6373
6154
|
"data-testid": "copilot-inspector-button",
|
|
6374
6155
|
title: accessibleLabel,
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
className: "cpk:text-[10px] cpk:opacity-65",
|
|
6379
|
-
children: localOnlyLabel
|
|
6380
|
-
})]
|
|
6381
|
-
}),
|
|
6156
|
+
className: twMerge("cpk:w-auto cpk:gap-1.5 cpk:px-2", className),
|
|
6157
|
+
tooltipClassName: "cpk:max-w-64 cpk:text-left cpk:leading-4",
|
|
6158
|
+
tooltip: "View this message in the Inspector to get more information. This button and the inspector only display during local development (localhost, dev env).",
|
|
6382
6159
|
...props,
|
|
6383
|
-
children:
|
|
6160
|
+
children: [
|
|
6161
|
+
/* @__PURE__ */ jsx(CopilotKitColoredIcon, {}),
|
|
6162
|
+
/* @__PURE__ */ jsx("span", {
|
|
6163
|
+
className: "cpk:font-medium",
|
|
6164
|
+
children: primaryLabel
|
|
6165
|
+
}),
|
|
6166
|
+
/* @__PURE__ */ jsx("span", {
|
|
6167
|
+
className: "cpk:text-xs cpk:text-muted-foreground",
|
|
6168
|
+
children: "(local only)"
|
|
6169
|
+
})
|
|
6170
|
+
]
|
|
6384
6171
|
});
|
|
6385
6172
|
};
|
|
6386
|
-
_CopilotChatAssistantMessage.SaveSnippetButton = (props) => /* @__PURE__ */ jsx(SaveSnippetIconButton, {
|
|
6387
|
-
"data-testid": "copilot-save-snippet-button",
|
|
6388
|
-
...props
|
|
6389
|
-
});
|
|
6390
6173
|
_CopilotChatAssistantMessage.ThumbsUpButton = ({ title, ...props }) => {
|
|
6391
6174
|
const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
|
|
6392
6175
|
return /* @__PURE__ */ jsx(ToolbarButton, {
|
|
@@ -6428,7 +6211,6 @@ CopilotChatAssistantMessage.MarkdownRenderer.displayName = "CopilotChatAssistant
|
|
|
6428
6211
|
CopilotChatAssistantMessage.Toolbar.displayName = "CopilotChatAssistantMessage.Toolbar";
|
|
6429
6212
|
CopilotChatAssistantMessage.CopyButton.displayName = "CopilotChatAssistantMessage.CopyButton";
|
|
6430
6213
|
CopilotChatAssistantMessage.InspectorButton.displayName = "CopilotChatAssistantMessage.InspectorButton";
|
|
6431
|
-
CopilotChatAssistantMessage.SaveSnippetButton.displayName = "CopilotChatAssistantMessage.SaveSnippetButton";
|
|
6432
6214
|
CopilotChatAssistantMessage.ThumbsUpButton.displayName = "CopilotChatAssistantMessage.ThumbsUpButton";
|
|
6433
6215
|
CopilotChatAssistantMessage.ThumbsDownButton.displayName = "CopilotChatAssistantMessage.ThumbsDownButton";
|
|
6434
6216
|
CopilotChatAssistantMessage.ReadAloudButton.displayName = "CopilotChatAssistantMessage.ReadAloudButton";
|
|
@@ -6799,8 +6581,6 @@ function CopilotChatReasoningMessage({ message, messages, isRunning, header, con
|
|
|
6799
6581
|
const isLatest = messages?.[messages.length - 1]?.id === message.id;
|
|
6800
6582
|
const isStreaming = !!(isRunning && isLatest);
|
|
6801
6583
|
const hasContent = !!(message.content && message.content.length > 0);
|
|
6802
|
-
const { isLocalInspectorEnabled, saveEventSnippet } = useCopilotKitInspector();
|
|
6803
|
-
const chatConfiguration = useCopilotChatConfiguration();
|
|
6804
6584
|
const startTimeRef = useRef(null);
|
|
6805
6585
|
const [elapsed, setElapsed] = useState(0);
|
|
6806
6586
|
useEffect(() => {
|
|
@@ -6860,16 +6640,7 @@ function CopilotChatReasoningMessage({ message, messages, isRunning, header, con
|
|
|
6860
6640
|
className: twMerge("cpk:my-1", className),
|
|
6861
6641
|
"data-message-id": message.id,
|
|
6862
6642
|
...props,
|
|
6863
|
-
children: [
|
|
6864
|
-
className: "cpk:flex cpk:items-center cpk:gap-1",
|
|
6865
|
-
children: [boundHeader, isLocalInspectorEnabled && hasContent && /* @__PURE__ */ jsx(CopilotChatAssistantMessage_default.SaveSnippetButton, { onClick: () => void saveEventSnippet({
|
|
6866
|
-
kind: "reasoning",
|
|
6867
|
-
messageId: message.id,
|
|
6868
|
-
content: message.content ?? "",
|
|
6869
|
-
threadId: chatConfiguration?.threadId,
|
|
6870
|
-
agentId: chatConfiguration?.agentId
|
|
6871
|
-
}) })]
|
|
6872
|
-
}), boundToggle]
|
|
6643
|
+
children: [boundHeader, boundToggle]
|
|
6873
6644
|
});
|
|
6874
6645
|
}
|
|
6875
6646
|
(function(_CopilotChatReasoningMessage) {
|
|
@@ -7388,33 +7159,8 @@ const MemoizedUserMessage = React.memo(function MemoizedUserMessage({ message, U
|
|
|
7388
7159
|
/**
|
|
7389
7160
|
* Memoized wrapper for activity messages to prevent re-renders when other messages change.
|
|
7390
7161
|
*/
|
|
7391
|
-
function ActivitySnippetChrome({ message, children }) {
|
|
7392
|
-
const { isLocalInspectorEnabled, saveEventSnippet } = useCopilotKitInspector();
|
|
7393
|
-
const chatConfiguration = useCopilotChatConfiguration();
|
|
7394
|
-
if (!(isLocalInspectorEnabled && (message.activityType === "a2ui-surface" || message.activityType === "open-generative-ui"))) return children;
|
|
7395
|
-
const primaryLabel = (chatConfiguration?.labels ?? CopilotChatDefaultLabels).assistantMessageToolbarSaveSnippetLabel;
|
|
7396
|
-
return /* @__PURE__ */ jsx(SaveSnippetBesideChrome, {
|
|
7397
|
-
showSave: true,
|
|
7398
|
-
saveButton: /* @__PURE__ */ jsx(SaveSnippetIconButton, {
|
|
7399
|
-
"data-testid": "copilot-activity-save-snippet-button",
|
|
7400
|
-
title: primaryLabel,
|
|
7401
|
-
onClick: () => void saveEventSnippet({
|
|
7402
|
-
kind: "activity",
|
|
7403
|
-
messageId: message.id,
|
|
7404
|
-
activityType: message.activityType,
|
|
7405
|
-
content: message.content,
|
|
7406
|
-
threadId: chatConfiguration?.threadId,
|
|
7407
|
-
agentId: chatConfiguration?.agentId
|
|
7408
|
-
})
|
|
7409
|
-
}),
|
|
7410
|
-
children
|
|
7411
|
-
});
|
|
7412
|
-
}
|
|
7413
7162
|
const MemoizedActivityMessage = React.memo(function MemoizedActivityMessage({ message, renderActivityMessage }) {
|
|
7414
|
-
return
|
|
7415
|
-
message,
|
|
7416
|
-
children: renderActivityMessage(message)
|
|
7417
|
-
});
|
|
7163
|
+
return renderActivityMessage(message);
|
|
7418
7164
|
}, (prevProps, nextProps) => {
|
|
7419
7165
|
if (prevProps.message.id !== nextProps.message.id) return false;
|
|
7420
7166
|
if (prevProps.message.activityType !== nextProps.message.activityType) return false;
|
|
@@ -12337,4 +12083,4 @@ function validateProps(props) {
|
|
|
12337
12083
|
|
|
12338
12084
|
//#endregion
|
|
12339
12085
|
export { useCapabilities as $, CopilotChatMessageView as A, CopilotChatAudioRecorder as At, CopilotChatAssistantMessage_default as B, CopilotModalHeader as C, MCPAppsActivityRenderer as Ct, CopilotChat as D, useRenderToolCall as Dt, DefaultOpenIcon as E, CopilotKitInspector 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, useCopilotChatConfiguration as Mt, getIntelligenceTurnAnchors as N, CopilotChatView_default as O, CopilotChatInput_default as Ot, IntelligenceIndicatorView as P, useAgentContext as Q, CopilotChatUserMessage_default as R, CopilotSidebarView as S, MCPAppsActivityContentSchema as St, DefaultCloseIcon as T, ɵrunMcpFollowUp as Tt, useLearningContainers as U, CopilotChatToolCallsView as V, useAttachments as W, useConfigureSuggestions as X, useInterrupt as Y, useSuggestions as Z, WildcardToolCallRender as _, OpenGenerativeUIActivityType as _t, ThreadsProvider as a, useComponent as at, CopilotSidebar as b, SandboxFunctionsContext as bt, CoAgentStateRendersProvider as c, useRenderCustomMessages as ct, shouldShowDevConsole as d, useLicenseContext$1 as dt, UseAgentUpdate as et, useToast as f, CopilotKitCoreReact as ft, useCopilotContext as g, OpenGenerativeUIActivityRenderer as gt, CopilotContext as h, GenerateSandboxedUiArgsSchema as ht, ThreadsContext as i, useRenderTool as it, INTELLIGENCE_TURN_HEAD as j, CopilotChatConfigurationProvider as jt, CopilotChatAttachmentQueue as k, AudioRecorderError as kt, useCoAgentStateRenders as l, CopilotKitProvider as lt, useCopilotMessagesContext as m, createA2UIMessageRenderer as mt, defaultCopilotContextCategories as n, useHumanInTheLoop as nt, useThreads as o, useFrontendTool as ot, CopilotMessagesContext as p, defineToolCallRenderer as pt, useMemories as q, CoAgentStateRenderBridge as r, useDefaultRenderTool as rt, CoAgentStateRendersContext as s, useRenderActivityMessage as st, CopilotKit as t, useAgent as tt, useAsyncCallback as u, useCopilotKit$1 as ut, CopilotThreadsDrawer as v, OpenGenerativeUIContentSchema as vt, CopilotChatToggleButton as w, MCPAppsActivityType as wt, CopilotPopupView as x, useSandboxFunctions as xt, CopilotPopup as y, OpenGenerativeUIToolRenderer as yt, CopilotChatAttachmentRenderer as z };
|
|
12340
|
-
//# sourceMappingURL=copilotkit-
|
|
12086
|
+
//# sourceMappingURL=copilotkit-BmW2sFH6.mjs.map
|