@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.
Files changed (35) hide show
  1. package/dist/{copilotkit-Dr0speVK.cjs → copilotkit-Ba7qwYt3.cjs} +34 -288
  2. package/dist/copilotkit-Ba7qwYt3.cjs.map +1 -0
  3. package/dist/{copilotkit-Dr6g885f.mjs → copilotkit-BmW2sFH6.mjs} +35 -289
  4. package/dist/copilotkit-BmW2sFH6.mjs.map +1 -0
  5. package/dist/{copilotkit-Hl1t9Y1v.d.cts → copilotkit-CF1Pm2VG.d.cts} +2 -7
  6. package/dist/copilotkit-CF1Pm2VG.d.cts.map +1 -0
  7. package/dist/{copilotkit-DYKpg4pD.d.mts → copilotkit-TdM-5onZ.d.mts} +2 -7
  8. package/dist/copilotkit-TdM-5onZ.d.mts.map +1 -0
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.d.cts +1 -1
  11. package/dist/index.d.mts +1 -1
  12. package/dist/index.mjs +1 -1
  13. package/dist/index.umd.js +5 -46
  14. package/dist/index.umd.js.map +1 -1
  15. package/dist/v2/headless.cjs +0 -1
  16. package/dist/v2/headless.cjs.map +1 -1
  17. package/dist/v2/headless.d.cts +0 -1
  18. package/dist/v2/headless.d.cts.map +1 -1
  19. package/dist/v2/headless.d.mts +0 -1
  20. package/dist/v2/headless.d.mts.map +1 -1
  21. package/dist/v2/headless.mjs +0 -1
  22. package/dist/v2/headless.mjs.map +1 -1
  23. package/dist/v2/index.cjs +1 -1
  24. package/dist/v2/index.css +1 -1
  25. package/dist/v2/index.d.cts +1 -1
  26. package/dist/v2/index.d.mts +1 -1
  27. package/dist/v2/index.mjs +1 -1
  28. package/dist/v2/index.umd.js +33 -287
  29. package/dist/v2/index.umd.js.map +1 -1
  30. package/package.json +7 -7
  31. package/skills/react-core/SKILL.md +1 -1
  32. package/dist/copilotkit-DYKpg4pD.d.mts.map +0 -1
  33. package/dist/copilotkit-Dr0speVK.cjs.map +0 -1
  34. package/dist/copilotkit-Dr6g885f.mjs.map +0 -1
  35. package/dist/copilotkit-Hl1t9Y1v.d.cts.map +0 -1
@@ -108,7 +108,6 @@ const CopilotChatDefaultLabels = {
108
108
  assistantMessageToolbarCopyMessageLabel: "Copy",
109
109
  assistantMessageToolbarInspectorLabel: "View in Inspector",
110
110
  assistantMessageToolbarInspectorLocalOnlyLabel: "Local Only",
111
- assistantMessageToolbarSaveSnippetLabel: "Save as snippet",
112
111
  assistantMessageToolbarThumbsUpLabel: "Good response",
113
112
  assistantMessageToolbarThumbsDownLabel: "Bad response",
114
113
  assistantMessageToolbarReadAloudLabel: "Read aloud",
@@ -1561,8 +1560,7 @@ CopilotKitInspector.displayName = "CopilotKitInspector";
1561
1560
  //#region src/v2/components/CopilotKitInspectorContext.tsx
1562
1561
  const CopilotKitInspectorContext = react.createContext({
1563
1562
  isLocalInspectorEnabled: false,
1564
- openInspector: () => void 0,
1565
- saveEventSnippet: async () => void 0
1563
+ openInspector: () => void 0
1566
1564
  });
1567
1565
  const CopilotKitInspectorContextProvider = CopilotKitInspectorContext.Provider;
1568
1566
  function useCopilotKitInspector() {
@@ -2376,7 +2374,6 @@ function injectCssIntoHtml(html, css) {
2376
2374
  const OpenGenerativeUIActivityRendererInner = react.default.memo(function OpenGenerativeUIActivityRendererInner({ content }) {
2377
2375
  const initialHeight = content.initialHeight ?? 200;
2378
2376
  const [autoHeight, setAutoHeight] = (0, react.useState)(null);
2379
- const [sandboxReady, setSandboxReady] = (0, react.useState)(false);
2380
2377
  const sandboxFunctions = useSandboxFunctions();
2381
2378
  const localApi = (0, react.useMemo)(() => {
2382
2379
  const api = {};
@@ -2478,7 +2475,6 @@ const OpenGenerativeUIActivityRendererInner = react.default.memo(function OpenGe
2478
2475
  sandbox.promise.then(() => {
2479
2476
  if (cancelled) return;
2480
2477
  sandboxReadyRef.current = true;
2481
- setSandboxReady(true);
2482
2478
  sandbox.run(`
2483
2479
  var s = document.createElement('style');
2484
2480
  s.textContent = 'html, body { overflow: hidden !important; }';
@@ -2503,7 +2499,6 @@ const OpenGenerativeUIActivityRendererInner = react.default.memo(function OpenGe
2503
2499
  sandboxRef.current = null;
2504
2500
  }
2505
2501
  sandboxReadyRef.current = false;
2506
- setSandboxReady(false);
2507
2502
  setAutoHeight(null);
2508
2503
  };
2509
2504
  }, [
@@ -2534,7 +2529,7 @@ const OpenGenerativeUIActivityRendererInner = react.default.memo(function OpenGe
2534
2529
  const generationDone = content.generating === false;
2535
2530
  (0, react.useEffect)(() => {
2536
2531
  const sandbox = sandboxRef.current;
2537
- if (!generationDone || !sandboxReady || !sandbox) return;
2532
+ if (!generationDone || !sandbox) return;
2538
2533
  let handled = false;
2539
2534
  const onMessage = (e) => {
2540
2535
  if (handled) return;
@@ -2563,7 +2558,7 @@ const OpenGenerativeUIActivityRendererInner = react.default.memo(function OpenGe
2563
2558
  return () => {
2564
2559
  window.removeEventListener("message", onMessage);
2565
2560
  };
2566
- }, [generationDone, sandboxReady]);
2561
+ }, [generationDone]);
2567
2562
  const height = autoHeight ?? initialHeight;
2568
2563
  const isGenerating = content.generating !== false;
2569
2564
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -3547,46 +3542,10 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3547
3542
  const requestInspectorOpen = (0, react.useCallback)((request) => {
3548
3543
  setInspectorOpenRequest({ ...request });
3549
3544
  }, []);
3550
- const saveEventSnippet = (0, react.useCallback)(async (request) => {
3551
- try {
3552
- const mod = await import("@copilotkit/web-inspector");
3553
- const threadId = request.threadId ?? "inspector-snippet";
3554
- const runId = `inspector-snippet-${Date.now()}`;
3555
- const compiled = mod.compileChatSnippet({
3556
- ...request,
3557
- threadId,
3558
- runId
3559
- });
3560
- const now = (/* @__PURE__ */ new Date()).toISOString();
3561
- const snippet = {
3562
- id: crypto.randomUUID(),
3563
- name: compiled.name,
3564
- recipe: compiled.recipe,
3565
- events: compiled.events,
3566
- createdAt: now,
3567
- updatedAt: now
3568
- };
3569
- mod.upsertEventSnippet(snippet);
3570
- requestInspectorOpen({
3571
- messageId: request.messageId,
3572
- threadId: request.threadId,
3573
- agentId: request.agentId,
3574
- menu: "event-snippets",
3575
- snippetId: snippet.id
3576
- });
3577
- } catch (error) {
3578
- console.error("[CopilotKit] Could not save the event snippet.", error);
3579
- }
3580
- }, [requestInspectorOpen]);
3581
3545
  const inspectorContextValue = (0, react.useMemo)(() => ({
3582
3546
  isLocalInspectorEnabled,
3583
- openInspector: requestInspectorOpen,
3584
- saveEventSnippet
3585
- }), [
3586
- isLocalInspectorEnabled,
3587
- requestInspectorOpen,
3588
- saveEventSnippet
3589
- ]);
3547
+ openInspector: requestInspectorOpen
3548
+ }), [isLocalInspectorEnabled, requestInspectorOpen]);
3590
3549
  const renderToolCallsList = useStableArrayProp(renderToolCalls, "renderToolCalls must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead.", (initial, next) => {
3591
3550
  const key = (rc) => `${rc?.agentId ?? ""}:${rc?.name ?? ""}`;
3592
3551
  const setFrom = (arr) => new Set(arr.map(key));
@@ -5963,191 +5922,25 @@ function useLearningContainersInCurrentThread({ learningContainers }) {
5963
5922
  });
5964
5923
  }
5965
5924
 
5966
- //#endregion
5967
- //#region src/v2/components/chat/save-snippet-beside.ts
5968
- const SAVE_SNIPPET_ICON_SLOT_PX = 36;
5969
- const SAVE_SNIPPET_BESIDE_WRAP_CLASS = "cpk:relative cpk:w-full cpk:overflow-visible";
5970
- const SAVE_SNIPPET_BESIDE_BODY_CLASS = "cpk:w-full";
5971
- const SAVE_SNIPPET_BESIDE_SAVE_CLASS = "cpk:absolute cpk:top-0 cpk:z-10";
5972
- function saveSnippetBesideStyle(side) {
5973
- if (side === "left") return {
5974
- left: "auto",
5975
- right: "100%",
5976
- marginLeft: 0,
5977
- marginRight: 4
5978
- };
5979
- return {
5980
- left: "100%",
5981
- right: "auto",
5982
- marginLeft: 4,
5983
- marginRight: 0
5984
- };
5985
- }
5986
- function pickSaveSnippetSide(roomRight, roomLeft, slotPx = SAVE_SNIPPET_ICON_SLOT_PX) {
5987
- if (roomRight >= slotPx) return "right";
5988
- if (roomLeft >= slotPx) return "left";
5989
- return "right";
5990
- }
5991
- function findOverflowAncestor(el) {
5992
- let node = el.parentElement;
5993
- while (node) {
5994
- const style = getComputedStyle(node);
5995
- const overflowX = style.overflowX;
5996
- const overflow = style.overflow;
5997
- if (overflowX === "hidden" || overflowX === "auto" || overflowX === "scroll" || overflow === "hidden" || overflow === "auto" || overflow === "scroll") return node;
5998
- node = node.parentElement;
5999
- }
6000
- return document.documentElement;
6001
- }
6002
- function measurableBox(el) {
6003
- let node = el;
6004
- while (node && getComputedStyle(node).display === "contents") node = node.firstElementChild;
6005
- return node ?? el;
6006
- }
6007
- function measureSaveSnippetSide(wrap, body) {
6008
- const clipRect = findOverflowAncestor(wrap).getBoundingClientRect();
6009
- const bodyRect = measurableBox(body.firstElementChild ?? body).getBoundingClientRect();
6010
- return pickSaveSnippetSide(clipRect.right - bodyRect.right, bodyRect.left - clipRect.left);
6011
- }
6012
-
6013
- //#endregion
6014
- //#region src/v2/components/chat/SaveSnippetIconButton.tsx
6015
- function SaveSnippetIconButton({ title, className, ...props }) {
6016
- const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
6017
- const primaryLabel = title || labels.assistantMessageToolbarSaveSnippetLabel;
6018
- const localOnlyLabel = labels.assistantMessageToolbarInspectorLocalOnlyLabel;
6019
- const accessibleLabel = `${primaryLabel} (${localOnlyLabel})`;
6020
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Tooltip, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipTrigger, {
6021
- asChild: true,
6022
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
6023
- type: "button",
6024
- variant: "assistantMessageToolbarButton",
6025
- "aria-label": accessibleLabel,
6026
- title: accessibleLabel,
6027
- className,
6028
- ...props,
6029
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Bookmark, { className: "cpk:size-[18px]" })
6030
- })
6031
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipContent, {
6032
- side: "bottom",
6033
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6034
- className: "cpk:flex cpk:flex-col cpk:gap-0.5",
6035
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: primaryLabel }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
6036
- className: "cpk:text-[10px] cpk:opacity-65",
6037
- children: localOnlyLabel
6038
- })]
6039
- })
6040
- })] });
6041
- }
6042
- function SaveSnippetBesideChrome({ children, showSave, saveButton }) {
6043
- const wrapRef = (0, react.useRef)(null);
6044
- const bodyRef = (0, react.useRef)(null);
6045
- const [side, setSide] = (0, react.useState)("right");
6046
- (0, react.useLayoutEffect)(() => {
6047
- if (!showSave) return;
6048
- const wrap = wrapRef.current;
6049
- const body = bodyRef.current;
6050
- if (!wrap || !body) return;
6051
- const measure = () => {
6052
- setSide(measureSaveSnippetSide(wrap, body));
6053
- };
6054
- measure();
6055
- if (typeof ResizeObserver === "undefined") return;
6056
- const observer = new ResizeObserver(measure);
6057
- observer.observe(wrap);
6058
- observer.observe(body);
6059
- const clip = findOverflowAncestor(wrap);
6060
- if (clip !== wrap) observer.observe(clip);
6061
- window.addEventListener("resize", measure);
6062
- return () => {
6063
- observer.disconnect();
6064
- window.removeEventListener("resize", measure);
6065
- };
6066
- }, [showSave]);
6067
- if (!showSave) return children;
6068
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6069
- ref: wrapRef,
6070
- className: SAVE_SNIPPET_BESIDE_WRAP_CLASS,
6071
- "data-save-snippet-side": side,
6072
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6073
- ref: bodyRef,
6074
- className: SAVE_SNIPPET_BESIDE_BODY_CLASS,
6075
- children
6076
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6077
- className: SAVE_SNIPPET_BESIDE_SAVE_CLASS,
6078
- style: saveSnippetBesideStyle(side),
6079
- children: saveButton
6080
- })]
6081
- });
6082
- }
6083
-
6084
5925
  //#endregion
6085
5926
  //#region src/v2/components/chat/CopilotChatToolCallsView.tsx
6086
5927
  function CopilotChatToolCallsView({ message, messages = [] }) {
6087
5928
  const renderToolCall = useRenderToolCall();
6088
- const { isLocalInspectorEnabled, saveEventSnippet } = useCopilotKitInspector();
6089
- const chatConfiguration = useCopilotChatConfiguration();
6090
- const labels = chatConfiguration?.labels ?? CopilotChatDefaultLabels;
6091
5929
  if (!message.toolCalls || message.toolCalls.length === 0) return null;
6092
5930
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: message.toolCalls.map((toolCall) => {
6093
- const rendered = renderToolCall({
5931
+ const toolMessage = messages.find((m) => m.role === "tool" && m.toolCallId === toolCall.id);
5932
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.default.Fragment, { children: renderToolCall({
6094
5933
  toolCall,
6095
- toolMessage: messages.find((m) => m.role === "tool" && m.toolCallId === toolCall.id)
6096
- });
6097
- if (!isLocalInspectorEnabled || !hasCompleteArgs(toolCall.function.arguments)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.default.Fragment, { children: rendered }, toolCall.id);
6098
- const primaryLabel = labels.assistantMessageToolbarSaveSnippetLabel;
6099
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolCallSnippetChrome, {
6100
- label: primaryLabel,
6101
- onSave: () => void saveEventSnippet({
6102
- kind: "tool-call",
6103
- messageId: message.id,
6104
- toolCallId: toolCall.id,
6105
- toolName: toolCall.function.name,
6106
- argsJson: toolCall.function.arguments || "{}",
6107
- threadId: chatConfiguration?.threadId,
6108
- agentId: chatConfiguration?.agentId
6109
- }),
6110
- children: rendered
6111
- }, toolCall.id);
5934
+ toolMessage
5935
+ }) }, toolCall.id);
6112
5936
  }) });
6113
5937
  }
6114
- function hasCompleteArgs(args) {
6115
- const trimmed = (args ?? "").trim();
6116
- if (!trimmed) return true;
6117
- try {
6118
- JSON.parse(trimmed);
6119
- return true;
6120
- } catch {
6121
- return false;
6122
- }
6123
- }
6124
- function ToolCallSnippetChrome({ children, label, onSave }) {
6125
- const bodyRef = (0, react.useRef)(null);
6126
- const [showSave, setShowSave] = (0, react.useState)(false);
6127
- (0, react.useLayoutEffect)(() => {
6128
- const el = bodyRef.current;
6129
- setShowSave(!!el && el.childElementCount > 0);
6130
- });
6131
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SaveSnippetBesideChrome, {
6132
- showSave,
6133
- saveButton: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SaveSnippetIconButton, {
6134
- "data-testid": "copilot-tool-save-snippet-button",
6135
- title: label,
6136
- onClick: onSave
6137
- }),
6138
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
6139
- ref: bodyRef,
6140
- className: "cpk:contents",
6141
- children
6142
- })
6143
- });
6144
- }
6145
5938
 
6146
5939
  //#endregion
6147
5940
  //#region src/v2/components/chat/CopilotChatAssistantMessage.tsx
6148
- function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp, onThumbsDown, onReadAloud, onRegenerate, additionalToolbarItems, toolbarVisible = true, markdownRenderer, toolbar, copyButton, inspectorButton, saveSnippetButton, thumbsUpButton, thumbsDownButton, readAloudButton, regenerateButton, toolCallsView, children, className, ...props }) {
5941
+ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp, onThumbsDown, onReadAloud, onRegenerate, additionalToolbarItems, toolbarVisible = true, markdownRenderer, toolbar, copyButton, inspectorButton, thumbsUpButton, thumbsDownButton, readAloudButton, regenerateButton, toolCallsView, children, className, ...props }) {
6149
5942
  useKatexStyles();
6150
- const { isLocalInspectorEnabled, openInspector, saveEventSnippet } = useCopilotKitInspector();
5943
+ const { isLocalInspectorEnabled, openInspector } = useCopilotKitInspector();
6151
5944
  const chatConfiguration = useCopilotChatConfiguration();
6152
5945
  const boundMarkdownRenderer = renderSlot(markdownRenderer, CopilotChatAssistantMessage.MarkdownRenderer, { content: message.content || "" });
6153
5946
  const boundCopyButton = renderSlot(copyButton, CopilotChatAssistantMessage.CopyButton, { onClick: async () => {
@@ -6160,17 +5953,6 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp,
6160
5953
  threadId: chatConfiguration?.threadId,
6161
5954
  agentId: chatConfiguration?.agentId
6162
5955
  }) });
6163
- const hasContent = !!(message.content && message.content.trim().length > 0);
6164
- const boundSaveSnippetButton = renderSlot(saveSnippetButton, CopilotChatAssistantMessage.SaveSnippetButton, { onClick: () => {
6165
- if (!hasContent) return;
6166
- saveEventSnippet({
6167
- kind: "text",
6168
- messageId: message.id,
6169
- content: message.content ?? "",
6170
- threadId: chatConfiguration?.threadId,
6171
- agentId: chatConfiguration?.agentId
6172
- });
6173
- } });
6174
5956
  const boundThumbsDownButton = renderSlot(thumbsDownButton, CopilotChatAssistantMessage.ThumbsDownButton, { onClick: onThumbsDown ? () => onThumbsDown(message) : void 0 });
6175
5957
  const boundReadAloudButton = renderSlot(readAloudButton, CopilotChatAssistantMessage.ReadAloudButton, { onClick: onReadAloud ? () => onReadAloud(message) : void 0 });
6176
5958
  const boundRegenerateButton = renderSlot(regenerateButton, CopilotChatAssistantMessage.RegenerateButton, { onClick: onRegenerate ? () => onRegenerate(message) : void 0 });
@@ -6179,7 +5961,6 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp,
6179
5961
  children: [
6180
5962
  boundCopyButton,
6181
5963
  isLocalInspectorEnabled && boundInspectorButton,
6182
- isLocalInspectorEnabled && hasContent && boundSaveSnippetButton,
6183
5964
  (onThumbsUp || thumbsUpButton) && boundThumbsUpButton,
6184
5965
  (onThumbsDown || thumbsDownButton) && boundThumbsDownButton,
6185
5966
  (onReadAloud || readAloudButton) && boundReadAloudButton,
@@ -6191,6 +5972,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp,
6191
5972
  message,
6192
5973
  messages
6193
5974
  });
5975
+ const hasContent = !!(message.content && message.content.trim().length > 0);
6194
5976
  const isLatestAssistantMessage = message.role === "assistant" && messages?.[messages.length - 1]?.id === message.id;
6195
5977
  const shouldShowToolbar = toolbarVisible && (hasContent || isLocalInspectorEnabled) && !(isRunning && isLatestAssistantMessage);
6196
5978
  if (children) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -6202,7 +5984,6 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp,
6202
5984
  toolCallsView: boundToolCallsView,
6203
5985
  copyButton: boundCopyButton,
6204
5986
  inspectorButton: boundInspectorButton,
6205
- saveSnippetButton: boundSaveSnippetButton,
6206
5987
  thumbsUpButton: boundThumbsUpButton,
6207
5988
  thumbsDownButton: boundThumbsDownButton,
6208
5989
  readAloudButton: boundReadAloudButton,
@@ -6349,7 +6130,7 @@ function CopilotKitColoredIcon() {
6349
6130
  className: (0, tailwind_merge.twMerge)("cpk:w-full cpk:bg-transparent cpk:flex cpk:items-center cpk:-ml-[5px] cpk:-mt-[0px]", className),
6350
6131
  ...props
6351
6132
  });
6352
- const ToolbarButton = _CopilotChatAssistantMessage.ToolbarButton = ({ title, tooltip, children, ...props }) => {
6133
+ const ToolbarButton = _CopilotChatAssistantMessage.ToolbarButton = ({ title, tooltip, tooltipClassName, children, ...props }) => {
6353
6134
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Tooltip, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipTrigger, {
6354
6135
  asChild: true,
6355
6136
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
@@ -6361,6 +6142,7 @@ function CopilotKitColoredIcon() {
6361
6142
  })
6362
6143
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipContent, {
6363
6144
  side: "bottom",
6145
+ className: tooltipClassName,
6364
6146
  children: tooltip ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: title })
6365
6147
  })] });
6366
6148
  };
@@ -6394,29 +6176,30 @@ function CopilotKitColoredIcon() {
6394
6176
  children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, { className: "cpk:size-[18px]" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Copy, { className: "cpk:size-[18px]" })
6395
6177
  });
6396
6178
  };
6397
- _CopilotChatAssistantMessage.InspectorButton = ({ title, ...props }) => {
6179
+ _CopilotChatAssistantMessage.InspectorButton = ({ title, className, ...props }) => {
6398
6180
  const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
6399
6181
  const primaryLabel = title || labels.assistantMessageToolbarInspectorLabel;
6400
- const localOnlyLabel = labels.assistantMessageToolbarInspectorLocalOnlyLabel;
6401
- const accessibleLabel = `${primaryLabel} (${localOnlyLabel})`;
6402
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
6182
+ const accessibleLabel = `${primaryLabel} (local only)`;
6183
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ToolbarButton, {
6403
6184
  "data-testid": "copilot-inspector-button",
6404
6185
  title: accessibleLabel,
6405
- tooltip: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6406
- className: "cpk:flex cpk:flex-col cpk:gap-0.5",
6407
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: primaryLabel }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
6408
- className: "cpk:text-[10px] cpk:opacity-65",
6409
- children: localOnlyLabel
6410
- })]
6411
- }),
6186
+ className: (0, tailwind_merge.twMerge)("cpk:w-auto cpk:gap-1.5 cpk:px-2", className),
6187
+ tooltipClassName: "cpk:max-w-64 cpk:text-left cpk:leading-4",
6188
+ tooltip: "View this message in the Inspector to get more information. This button and the inspector only display during local development (localhost, dev env).",
6412
6189
  ...props,
6413
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitColoredIcon, {})
6190
+ children: [
6191
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotKitColoredIcon, {}),
6192
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
6193
+ className: "cpk:font-medium",
6194
+ children: primaryLabel
6195
+ }),
6196
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
6197
+ className: "cpk:text-xs cpk:text-muted-foreground",
6198
+ children: "(local only)"
6199
+ })
6200
+ ]
6414
6201
  });
6415
6202
  };
6416
- _CopilotChatAssistantMessage.SaveSnippetButton = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SaveSnippetIconButton, {
6417
- "data-testid": "copilot-save-snippet-button",
6418
- ...props
6419
- });
6420
6203
  _CopilotChatAssistantMessage.ThumbsUpButton = ({ title, ...props }) => {
6421
6204
  const labels = useCopilotChatConfiguration()?.labels ?? CopilotChatDefaultLabels;
6422
6205
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolbarButton, {
@@ -6458,7 +6241,6 @@ CopilotChatAssistantMessage.MarkdownRenderer.displayName = "CopilotChatAssistant
6458
6241
  CopilotChatAssistantMessage.Toolbar.displayName = "CopilotChatAssistantMessage.Toolbar";
6459
6242
  CopilotChatAssistantMessage.CopyButton.displayName = "CopilotChatAssistantMessage.CopyButton";
6460
6243
  CopilotChatAssistantMessage.InspectorButton.displayName = "CopilotChatAssistantMessage.InspectorButton";
6461
- CopilotChatAssistantMessage.SaveSnippetButton.displayName = "CopilotChatAssistantMessage.SaveSnippetButton";
6462
6244
  CopilotChatAssistantMessage.ThumbsUpButton.displayName = "CopilotChatAssistantMessage.ThumbsUpButton";
6463
6245
  CopilotChatAssistantMessage.ThumbsDownButton.displayName = "CopilotChatAssistantMessage.ThumbsDownButton";
6464
6246
  CopilotChatAssistantMessage.ReadAloudButton.displayName = "CopilotChatAssistantMessage.ReadAloudButton";
@@ -6829,8 +6611,6 @@ function CopilotChatReasoningMessage({ message, messages, isRunning, header, con
6829
6611
  const isLatest = messages?.[messages.length - 1]?.id === message.id;
6830
6612
  const isStreaming = !!(isRunning && isLatest);
6831
6613
  const hasContent = !!(message.content && message.content.length > 0);
6832
- const { isLocalInspectorEnabled, saveEventSnippet } = useCopilotKitInspector();
6833
- const chatConfiguration = useCopilotChatConfiguration();
6834
6614
  const startTimeRef = (0, react.useRef)(null);
6835
6615
  const [elapsed, setElapsed] = (0, react.useState)(0);
6836
6616
  (0, react.useEffect)(() => {
@@ -6890,16 +6670,7 @@ function CopilotChatReasoningMessage({ message, messages, isRunning, header, con
6890
6670
  className: (0, tailwind_merge.twMerge)("cpk:my-1", className),
6891
6671
  "data-message-id": message.id,
6892
6672
  ...props,
6893
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
6894
- className: "cpk:flex cpk:items-center cpk:gap-1",
6895
- children: [boundHeader, isLocalInspectorEnabled && hasContent && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotChatAssistantMessage_default.SaveSnippetButton, { onClick: () => void saveEventSnippet({
6896
- kind: "reasoning",
6897
- messageId: message.id,
6898
- content: message.content ?? "",
6899
- threadId: chatConfiguration?.threadId,
6900
- agentId: chatConfiguration?.agentId
6901
- }) })]
6902
- }), boundToggle]
6673
+ children: [boundHeader, boundToggle]
6903
6674
  });
6904
6675
  }
6905
6676
  (function(_CopilotChatReasoningMessage) {
@@ -7418,33 +7189,8 @@ const MemoizedUserMessage = react.default.memo(function MemoizedUserMessage({ me
7418
7189
  /**
7419
7190
  * Memoized wrapper for activity messages to prevent re-renders when other messages change.
7420
7191
  */
7421
- function ActivitySnippetChrome({ message, children }) {
7422
- const { isLocalInspectorEnabled, saveEventSnippet } = useCopilotKitInspector();
7423
- const chatConfiguration = useCopilotChatConfiguration();
7424
- if (!(isLocalInspectorEnabled && (message.activityType === "a2ui-surface" || message.activityType === "open-generative-ui"))) return children;
7425
- const primaryLabel = (chatConfiguration?.labels ?? CopilotChatDefaultLabels).assistantMessageToolbarSaveSnippetLabel;
7426
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SaveSnippetBesideChrome, {
7427
- showSave: true,
7428
- saveButton: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SaveSnippetIconButton, {
7429
- "data-testid": "copilot-activity-save-snippet-button",
7430
- title: primaryLabel,
7431
- onClick: () => void saveEventSnippet({
7432
- kind: "activity",
7433
- messageId: message.id,
7434
- activityType: message.activityType,
7435
- content: message.content,
7436
- threadId: chatConfiguration?.threadId,
7437
- agentId: chatConfiguration?.agentId
7438
- })
7439
- }),
7440
- children
7441
- });
7442
- }
7443
7192
  const MemoizedActivityMessage = react.default.memo(function MemoizedActivityMessage({ message, renderActivityMessage }) {
7444
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActivitySnippetChrome, {
7445
- message,
7446
- children: renderActivityMessage(message)
7447
- });
7193
+ return renderActivityMessage(message);
7448
7194
  }, (prevProps, nextProps) => {
7449
7195
  if (prevProps.message.id !== nextProps.message.id) return false;
7450
7196
  if (prevProps.message.activityType !== nextProps.message.activityType) return false;
@@ -12876,4 +12622,4 @@ Object.defineProperty(exports, 'ɵrunMcpFollowUp', {
12876
12622
  return ɵrunMcpFollowUp;
12877
12623
  }
12878
12624
  });
12879
- //# sourceMappingURL=copilotkit-Dr0speVK.cjs.map
12625
+ //# sourceMappingURL=copilotkit-Ba7qwYt3.cjs.map