@copilotkit/react-ui 1.10.4-next.1 → 1.10.4-next.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 (59) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/{chunk-SHPG2T4O.mjs → chunk-FJFWH5AF.mjs} +3 -3
  3. package/dist/{chunk-FWQRAZ5S.mjs → chunk-KCRWXHWT.mjs} +2 -2
  4. package/dist/{chunk-X5AO5A3L.mjs → chunk-PHH6DYUW.mjs} +5 -2
  5. package/dist/chunk-PHH6DYUW.mjs.map +1 -0
  6. package/dist/{chunk-7XIE7UOW.mjs → chunk-QQDCZRPA.mjs} +2 -2
  7. package/dist/chunk-SRY5COHG.mjs +63 -0
  8. package/dist/chunk-SRY5COHG.mjs.map +1 -0
  9. package/dist/{chunk-EL7NCWNZ.mjs → chunk-Z66Y3KRE.mjs} +51 -21
  10. package/dist/chunk-Z66Y3KRE.mjs.map +1 -0
  11. package/dist/components/chat/Chat.d.ts +24 -13
  12. package/dist/components/chat/Chat.js +144 -62
  13. package/dist/components/chat/Chat.js.map +1 -1
  14. package/dist/components/chat/Chat.mjs +3 -2
  15. package/dist/components/chat/Messages.d.ts +1 -1
  16. package/dist/components/chat/Messages.js +4 -1
  17. package/dist/components/chat/Messages.js.map +1 -1
  18. package/dist/components/chat/Messages.mjs +1 -1
  19. package/dist/components/chat/Modal.d.ts +1 -1
  20. package/dist/components/chat/Modal.js +158 -76
  21. package/dist/components/chat/Modal.js.map +1 -1
  22. package/dist/components/chat/Modal.mjs +4 -3
  23. package/dist/components/chat/Popup.d.ts +1 -1
  24. package/dist/components/chat/Popup.js +160 -78
  25. package/dist/components/chat/Popup.js.map +1 -1
  26. package/dist/components/chat/Popup.mjs +5 -4
  27. package/dist/components/chat/Sidebar.d.ts +1 -1
  28. package/dist/components/chat/Sidebar.js +162 -80
  29. package/dist/components/chat/Sidebar.js.map +1 -1
  30. package/dist/components/chat/Sidebar.mjs +5 -4
  31. package/dist/components/chat/index.d.ts +2 -2
  32. package/dist/components/chat/index.js +164 -82
  33. package/dist/components/chat/index.js.map +1 -1
  34. package/dist/components/chat/index.mjs +6 -5
  35. package/dist/components/chat/messages/ErrorMessage.d.ts +9 -0
  36. package/dist/components/chat/messages/ErrorMessage.js +711 -0
  37. package/dist/components/chat/messages/ErrorMessage.js.map +1 -0
  38. package/dist/components/chat/messages/ErrorMessage.mjs +13 -0
  39. package/dist/components/chat/messages/ErrorMessage.mjs.map +1 -0
  40. package/dist/components/chat/props.d.ts +26 -1
  41. package/dist/components/chat/props.js.map +1 -1
  42. package/dist/components/index.d.ts +2 -2
  43. package/dist/components/index.js +164 -82
  44. package/dist/components/index.js.map +1 -1
  45. package/dist/components/index.mjs +6 -5
  46. package/dist/index.d.ts +2 -2
  47. package/dist/index.js +166 -84
  48. package/dist/index.js.map +1 -1
  49. package/dist/index.mjs +7 -6
  50. package/package.json +4 -4
  51. package/src/components/chat/Chat.tsx +64 -26
  52. package/src/components/chat/Messages.tsx +3 -0
  53. package/src/components/chat/messages/ErrorMessage.tsx +59 -0
  54. package/src/components/chat/props.ts +31 -0
  55. package/dist/chunk-EL7NCWNZ.mjs.map +0 -1
  56. package/dist/chunk-X5AO5A3L.mjs.map +0 -1
  57. /package/dist/{chunk-SHPG2T4O.mjs.map → chunk-FJFWH5AF.mjs.map} +0 -0
  58. /package/dist/{chunk-FWQRAZ5S.mjs.map → chunk-KCRWXHWT.mjs.map} +0 -0
  59. /package/dist/{chunk-7XIE7UOW.mjs.map → chunk-QQDCZRPA.mjs.map} +0 -0
@@ -2,12 +2,12 @@ import "../chunk-MMVDU6DF.mjs";
2
2
  import "../chunk-SC6JRFAJ.mjs";
3
3
  import {
4
4
  CopilotSidebar
5
- } from "../chunk-FWQRAZ5S.mjs";
5
+ } from "../chunk-KCRWXHWT.mjs";
6
6
  import "../chunk-WB3YULQ4.mjs";
7
7
  import {
8
8
  CopilotPopup
9
- } from "../chunk-7XIE7UOW.mjs";
10
- import "../chunk-SHPG2T4O.mjs";
9
+ } from "../chunk-QQDCZRPA.mjs";
10
+ import "../chunk-FJFWH5AF.mjs";
11
11
  import "../chunk-C3GSYRC3.mjs";
12
12
  import "../chunk-GDSZGYCE.mjs";
13
13
  import "../chunk-V7W6IM2V.mjs";
@@ -24,7 +24,8 @@ import "../chunk-BH6PCAAL.mjs";
24
24
  import "../chunk-UFN2VWSR.mjs";
25
25
  import {
26
26
  CopilotChat
27
- } from "../chunk-EL7NCWNZ.mjs";
27
+ } from "../chunk-Z66Y3KRE.mjs";
28
+ import "../chunk-SRY5COHG.mjs";
28
29
  import {
29
30
  Suggestions
30
31
  } from "../chunk-226ZMOE3.mjs";
@@ -35,7 +36,7 @@ import "../chunk-PLHTVHUW.mjs";
35
36
  import "../chunk-DTRPPNSA.mjs";
36
37
  import "../chunk-CGEAG65D.mjs";
37
38
  import "../chunk-QIOJXTIQ.mjs";
38
- import "../chunk-X5AO5A3L.mjs";
39
+ import "../chunk-PHH6DYUW.mjs";
39
40
  import "../chunk-YO63WHVQ.mjs";
40
41
  import "../chunk-LJAYSRCB.mjs";
41
42
  import {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { AssistantMessageProps, ButtonProps, ComponentsMap, CopilotObservabilityHooks, HeaderProps, ImageRendererProps, InputProps, MessagesProps, RenderMessageProps, RenderSuggestionsListProps, Renderer, SuggestionsProps, UserMessageProps, WindowProps } from './components/chat/props.js';
1
+ export { AssistantMessageProps, ButtonProps, ChatError, ComponentsMap, CopilotObservabilityHooks, ErrorMessageProps, HeaderProps, ImageRendererProps, InputProps, MessagesProps, RenderMessageProps, RenderSuggestionsListProps, Renderer, SuggestionsProps, UserMessageProps, WindowProps } from './components/chat/props.js';
2
2
  export { CopilotPopup } from './components/chat/Popup.js';
3
3
  export { CopilotSidebar } from './components/chat/Sidebar.js';
4
4
  export { CopilotChat } from './components/chat/Chat.js';
@@ -20,7 +20,7 @@ import 'react/jsx-runtime';
20
20
  import './components/chat/Modal.js';
21
21
  import '@copilotkit/react-core/dist/types/coagent-state';
22
22
  import '@copilotkit/react-core/dist/hooks/use-tree';
23
- import '@copilotkit/react-core/dist/copilot-context-256f9020';
23
+ import '@copilotkit/react-core/dist/copilot-context-59740e82';
24
24
  import '@copilotkit/react-core/dist/types/coagent-action';
25
25
  import '@copilotkit/runtime-client-gql';
26
26
  import 'react-markdown';
package/dist/index.js CHANGED
@@ -97,7 +97,7 @@ __export(src_exports, {
97
97
  module.exports = __toCommonJS(src_exports);
98
98
 
99
99
  // src/components/chat/Modal.tsx
100
- var import_react15 = __toESM(require("react"));
100
+ var import_react16 = __toESM(require("react"));
101
101
 
102
102
  // src/components/chat/ChatContext.tsx
103
103
  var import_react = __toESM(require("react"));
@@ -1885,12 +1885,14 @@ var Messages = ({
1885
1885
  RenderMessage: RenderMessage2,
1886
1886
  AssistantMessage: AssistantMessage2,
1887
1887
  UserMessage: UserMessage2,
1888
+ ErrorMessage: ErrorMessage2,
1888
1889
  ImageRenderer: ImageRenderer2,
1889
1890
  onRegenerate,
1890
1891
  onCopy,
1891
1892
  onThumbsUp,
1892
1893
  onThumbsDown,
1893
1894
  markdownTagRenderers,
1895
+ chatError,
1894
1896
  // Legacy props
1895
1897
  RenderTextMessage,
1896
1898
  RenderActionExecutionMessage,
@@ -1951,7 +1953,8 @@ var Messages = ({
1951
1953
  index
1952
1954
  );
1953
1955
  }),
1954
- interrupt
1956
+ interrupt,
1957
+ chatError && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ErrorMessage2, { error: chatError, isCurrentMessage: true })
1955
1958
  ] }),
1956
1959
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("footer", { className: "copilotKitMessagesFooter", ref: messagesEndRef, children })
1957
1960
  ] });
@@ -2334,15 +2337,67 @@ var Input = ({
2334
2337
  ] });
2335
2338
  };
2336
2339
 
2340
+ // src/components/chat/messages/ErrorMessage.tsx
2341
+ var import_react14 = require("react");
2342
+ var import_jsx_runtime21 = require("react/jsx-runtime");
2343
+ var ErrorMessage = (props) => {
2344
+ const { icons, labels } = useChatContext();
2345
+ const { error, onRegenerate, onCopy, isCurrentMessage } = props;
2346
+ const [copied, setCopied] = (0, import_react14.useState)(false);
2347
+ const handleCopy = () => {
2348
+ const content = error.message;
2349
+ if (content && onCopy) {
2350
+ navigator.clipboard.writeText(content);
2351
+ setCopied(true);
2352
+ onCopy(content);
2353
+ setTimeout(() => setCopied(false), 2e3);
2354
+ } else if (content) {
2355
+ navigator.clipboard.writeText(content);
2356
+ setCopied(true);
2357
+ setTimeout(() => setCopied(false), 2e3);
2358
+ }
2359
+ };
2360
+ const handleRegenerate = () => {
2361
+ if (onRegenerate)
2362
+ onRegenerate();
2363
+ };
2364
+ console.log(error);
2365
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "copilotKitMessage copilotKitAssistantMessage", children: [
2366
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Markdown, { content: error.message }),
2367
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: `copilotKitMessageControls ${isCurrentMessage ? "currentMessage" : ""}`, children: [
2368
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2369
+ "button",
2370
+ {
2371
+ className: "copilotKitMessageControlButton",
2372
+ onClick: handleRegenerate,
2373
+ "aria-label": labels.regenerateResponse,
2374
+ title: labels.regenerateResponse,
2375
+ children: icons.regenerateIcon
2376
+ }
2377
+ ),
2378
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2379
+ "button",
2380
+ {
2381
+ className: "copilotKitMessageControlButton",
2382
+ onClick: handleCopy,
2383
+ "aria-label": labels.copyToClipboard,
2384
+ title: labels.copyToClipboard,
2385
+ children: copied ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { style: { fontSize: "10px", fontWeight: "bold" }, children: "\u2713" }) : icons.copyIcon
2386
+ }
2387
+ )
2388
+ ] })
2389
+ ] });
2390
+ };
2391
+
2337
2392
  // src/components/chat/Chat.tsx
2338
- var import_react14 = __toESM(require("react"));
2393
+ var import_react15 = __toESM(require("react"));
2339
2394
  var import_react_core9 = require("@copilotkit/react-core");
2340
2395
  var import_shared3 = require("@copilotkit/shared");
2341
2396
  var import_shared4 = require("@copilotkit/shared");
2342
2397
  var import_react_core10 = require("@copilotkit/react-core");
2343
2398
 
2344
2399
  // src/components/chat/ImageUploadQueue.tsx
2345
- var import_jsx_runtime21 = require("react/jsx-runtime");
2400
+ var import_jsx_runtime22 = require("react/jsx-runtime");
2346
2401
  var ImageUploadQueue = ({
2347
2402
  images,
2348
2403
  onRemoveImage,
@@ -2350,7 +2405,7 @@ var ImageUploadQueue = ({
2350
2405
  }) => {
2351
2406
  if (images.length === 0)
2352
2407
  return null;
2353
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2408
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2354
2409
  "div",
2355
2410
  {
2356
2411
  className: `copilotKitImageUploadQueue ${className}`,
@@ -2361,7 +2416,7 @@ var ImageUploadQueue = ({
2361
2416
  margin: "8px",
2362
2417
  padding: "8px"
2363
2418
  },
2364
- children: images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
2419
+ children: images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
2365
2420
  "div",
2366
2421
  {
2367
2422
  className: "copilotKitImageUploadQueueItem",
@@ -2374,7 +2429,7 @@ var ImageUploadQueue = ({
2374
2429
  overflow: "hidden"
2375
2430
  },
2376
2431
  children: [
2377
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2432
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2378
2433
  "img",
2379
2434
  {
2380
2435
  src: `data:${image.contentType};base64,${image.bytes}`,
@@ -2386,7 +2441,7 @@ var ImageUploadQueue = ({
2386
2441
  }
2387
2442
  }
2388
2443
  ),
2389
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2444
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2390
2445
  "button",
2391
2446
  {
2392
2447
  onClick: () => onRemoveImage(index),
@@ -2421,12 +2476,12 @@ var ImageUploadQueue = ({
2421
2476
 
2422
2477
  // src/components/chat/Suggestion.tsx
2423
2478
  var import_react_core8 = require("@copilotkit/react-core");
2424
- var import_jsx_runtime22 = require("react/jsx-runtime");
2479
+ var import_jsx_runtime23 = require("react/jsx-runtime");
2425
2480
  function Suggestion({ title, onClick, partial, className }) {
2426
2481
  if (!title)
2427
2482
  return null;
2428
2483
  const { isLoading } = (0, import_react_core8.useCopilotChatInternal)();
2429
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2484
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2430
2485
  "button",
2431
2486
  {
2432
2487
  disabled: partial || isLoading,
@@ -2436,15 +2491,15 @@ function Suggestion({ title, onClick, partial, className }) {
2436
2491
  },
2437
2492
  className: className || (partial ? "suggestion loading" : "suggestion"),
2438
2493
  "data-test-id": "suggestion",
2439
- children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { children: title })
2494
+ children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: title })
2440
2495
  }
2441
2496
  );
2442
2497
  }
2443
2498
 
2444
2499
  // src/components/chat/Suggestions.tsx
2445
- var import_jsx_runtime23 = require("react/jsx-runtime");
2500
+ var import_jsx_runtime24 = require("react/jsx-runtime");
2446
2501
  function Suggestions({ suggestions, onSuggestionClick }) {
2447
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "suggestions", children: suggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2502
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "suggestions", children: suggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2448
2503
  Suggestion,
2449
2504
  {
2450
2505
  title: suggestion.title,
@@ -2458,7 +2513,7 @@ function Suggestions({ suggestions, onSuggestionClick }) {
2458
2513
  }
2459
2514
 
2460
2515
  // src/components/chat/Chat.tsx
2461
- var import_jsx_runtime24 = require("react/jsx-runtime");
2516
+ var import_jsx_runtime25 = require("react/jsx-runtime");
2462
2517
  function CopilotChat({
2463
2518
  instructions,
2464
2519
  suggestions = "auto",
@@ -2483,11 +2538,13 @@ function CopilotChat({
2483
2538
  AssistantMessage: AssistantMessage2 = AssistantMessage,
2484
2539
  UserMessage: UserMessage2 = UserMessage,
2485
2540
  ImageRenderer: ImageRenderer2 = ImageRenderer,
2541
+ ErrorMessage: ErrorMessage2 = ErrorMessage,
2486
2542
  imageUploadsEnabled,
2487
2543
  inputFileAccept = "image/*",
2488
2544
  hideStopButton,
2489
2545
  observabilityHooks,
2490
2546
  renderError,
2547
+ onError,
2491
2548
  // Legacy props - deprecated
2492
2549
  RenderTextMessage,
2493
2550
  RenderActionExecutionMessage,
@@ -2495,12 +2552,19 @@ function CopilotChat({
2495
2552
  RenderResultMessage,
2496
2553
  RenderImageMessage
2497
2554
  }) {
2498
- const { additionalInstructions, setChatInstructions, copilotApiConfig, setBannerError } = (0, import_react_core9.useCopilotContext)();
2555
+ const {
2556
+ additionalInstructions,
2557
+ setChatInstructions,
2558
+ copilotApiConfig,
2559
+ setBannerError,
2560
+ setInternalErrorHandler,
2561
+ removeInternalErrorHandler
2562
+ } = (0, import_react_core9.useCopilotContext)();
2499
2563
  const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
2500
- const [selectedImages, setSelectedImages] = (0, import_react14.useState)([]);
2501
- const [chatError, setChatError] = (0, import_react14.useState)(null);
2502
- const fileInputRef = (0, import_react14.useRef)(null);
2503
- const triggerObservabilityHook = (0, import_react14.useCallback)(
2564
+ const [selectedImages, setSelectedImages] = (0, import_react15.useState)([]);
2565
+ const [chatError, setChatError] = (0, import_react15.useState)(null);
2566
+ const fileInputRef = (0, import_react15.useRef)(null);
2567
+ const triggerObservabilityHook = (0, import_react15.useCallback)(
2504
2568
  (hookName, ...args) => {
2505
2569
  if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
2506
2570
  observabilityHooks[hookName](...args);
@@ -2519,7 +2583,7 @@ function CopilotChat({
2519
2583
  },
2520
2584
  [publicApiKey, observabilityHooks, setBannerError]
2521
2585
  );
2522
- const triggerChatError = (0, import_react14.useCallback)(
2586
+ const triggerChatError = (0, import_react15.useCallback)(
2523
2587
  (error, operation, originalError) => {
2524
2588
  const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
2525
2589
  setChatError({
@@ -2527,25 +2591,28 @@ function CopilotChat({
2527
2591
  operation,
2528
2592
  timestamp: Date.now()
2529
2593
  });
2530
- if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks.onError)) {
2531
- const errorEvent = {
2532
- type: "error",
2533
- timestamp: Date.now(),
2534
- context: {
2535
- source: "ui",
2536
- request: {
2537
- operation,
2538
- url: chatApiEndpoint,
2539
- startTime: Date.now()
2540
- },
2541
- technical: {
2542
- environment: "browser",
2543
- userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
2544
- stackTrace: originalError instanceof Error ? originalError.stack : void 0
2545
- }
2594
+ const errorEvent = {
2595
+ type: "error",
2596
+ timestamp: Date.now(),
2597
+ context: {
2598
+ source: "ui",
2599
+ request: {
2600
+ operation,
2601
+ url: chatApiEndpoint,
2602
+ startTime: Date.now()
2546
2603
  },
2547
- error
2548
- };
2604
+ technical: {
2605
+ environment: "browser",
2606
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
2607
+ stackTrace: originalError instanceof Error ? originalError.stack : void 0
2608
+ }
2609
+ },
2610
+ error
2611
+ };
2612
+ if (onError) {
2613
+ onError(errorEvent);
2614
+ }
2615
+ if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks.onError)) {
2549
2616
  observabilityHooks.onError(errorEvent);
2550
2617
  }
2551
2618
  if ((observabilityHooks == null ? void 0 : observabilityHooks.onError) && !publicApiKey) {
@@ -2562,7 +2629,20 @@ function CopilotChat({
2562
2629
  },
2563
2630
  [publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
2564
2631
  );
2565
- (0, import_react14.useEffect)(() => {
2632
+ (0, import_react15.useEffect)(() => {
2633
+ const id = "chat-component";
2634
+ setInternalErrorHandler({
2635
+ [id]: (error) => {
2636
+ if (!error)
2637
+ return;
2638
+ triggerChatError(error.error, "sendMessage");
2639
+ }
2640
+ });
2641
+ return () => {
2642
+ removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
2643
+ };
2644
+ }, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
2645
+ (0, import_react15.useEffect)(() => {
2566
2646
  if (!imageUploadsEnabled)
2567
2647
  return;
2568
2648
  const handlePaste = (e) => __async(this, null, function* () {
@@ -2608,7 +2688,7 @@ function CopilotChat({
2608
2688
  document.addEventListener("paste", handlePaste);
2609
2689
  return () => document.removeEventListener("paste", handlePaste);
2610
2690
  }, [imageUploadsEnabled, triggerChatError]);
2611
- (0, import_react14.useEffect)(() => {
2691
+ (0, import_react15.useEffect)(() => {
2612
2692
  if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
2613
2693
  setChatInstructions(instructions || "");
2614
2694
  return;
@@ -2636,8 +2716,8 @@ function CopilotChat({
2636
2716
  onStopGeneration,
2637
2717
  onReloadMessages
2638
2718
  );
2639
- const prevIsLoading = (0, import_react14.useRef)(isLoading);
2640
- (0, import_react14.useEffect)(() => {
2719
+ const prevIsLoading = (0, import_react15.useRef)(isLoading);
2720
+ (0, import_react15.useEffect)(() => {
2641
2721
  if (prevIsLoading.current !== isLoading) {
2642
2722
  if (isLoading) {
2643
2723
  triggerObservabilityHook("onChatStarted");
@@ -2656,7 +2736,7 @@ function CopilotChat({
2656
2736
  triggerObservabilityHook("onMessageSent", text);
2657
2737
  return sendMessage(text, images);
2658
2738
  };
2659
- const chatContext = import_react14.default.useContext(ChatContext);
2739
+ const chatContext = import_react15.default.useContext(ChatContext);
2660
2740
  const isVisible = chatContext ? chatContext.open : true;
2661
2741
  const handleRegenerate = (messageId) => {
2662
2742
  if (onRegenerate) {
@@ -2718,14 +2798,14 @@ function CopilotChat({
2718
2798
  }
2719
2799
  triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsDown");
2720
2800
  };
2721
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
2801
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
2722
2802
  chatError && renderError && renderError(__spreadProps(__spreadValues({}, chatError), {
2723
2803
  onDismiss: () => setChatError(null),
2724
2804
  onRetry: () => {
2725
2805
  setChatError(null);
2726
2806
  }
2727
2807
  })),
2728
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2808
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2729
2809
  Messages2,
2730
2810
  {
2731
2811
  AssistantMessage: AssistantMessage2,
@@ -2739,12 +2819,14 @@ function CopilotChat({
2739
2819
  onThumbsDown: handleThumbsDown,
2740
2820
  markdownTagRenderers,
2741
2821
  ImageRenderer: ImageRenderer2,
2822
+ ErrorMessage: ErrorMessage2,
2823
+ chatError,
2742
2824
  RenderTextMessage,
2743
2825
  RenderActionExecutionMessage,
2744
2826
  RenderAgentStateMessage,
2745
2827
  RenderResultMessage,
2746
2828
  RenderImageMessage,
2747
- children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2829
+ children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2748
2830
  RenderSuggestionsList,
2749
2831
  {
2750
2832
  onSuggestionClick: handleSendMessage,
@@ -2753,9 +2835,9 @@ function CopilotChat({
2753
2835
  )
2754
2836
  }
2755
2837
  ),
2756
- imageUploadsEnabled && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
2757
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ImageUploadQueue, { images: selectedImages, onRemoveImage: removeSelectedImage }),
2758
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2838
+ imageUploadsEnabled && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
2839
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ImageUploadQueue, { images: selectedImages, onRemoveImage: removeSelectedImage }),
2840
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2759
2841
  "input",
2760
2842
  {
2761
2843
  type: "file",
@@ -2767,7 +2849,7 @@ function CopilotChat({
2767
2849
  }
2768
2850
  )
2769
2851
  ] }),
2770
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2852
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2771
2853
  Input2,
2772
2854
  {
2773
2855
  inProgress: isLoading,
@@ -2789,12 +2871,12 @@ function WrappedCopilotChat({
2789
2871
  labels,
2790
2872
  className
2791
2873
  }) {
2792
- const chatContext = import_react14.default.useContext(ChatContext);
2874
+ const chatContext = import_react15.default.useContext(ChatContext);
2793
2875
  if (!chatContext) {
2794
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
2795
- }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
2876
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
2877
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
2796
2878
  }
2797
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children });
2879
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children });
2798
2880
  }
2799
2881
  var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
2800
2882
  var _a;
@@ -2818,15 +2900,15 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
2818
2900
  const generalContext = (0, import_react_core9.useCopilotContext)();
2819
2901
  const messagesContext = (0, import_react_core9.useCopilotMessagesContext)();
2820
2902
  const { actions } = generalContext;
2821
- const [suggestionsFailed, setSuggestionsFailed] = (0, import_react14.useState)(false);
2822
- const hasGeneratedInitialSuggestions = (0, import_react14.useRef)(false);
2823
- (0, import_react14.useEffect)(() => {
2903
+ const [suggestionsFailed, setSuggestionsFailed] = (0, import_react15.useState)(false);
2904
+ const hasGeneratedInitialSuggestions = (0, import_react15.useRef)(false);
2905
+ (0, import_react15.useEffect)(() => {
2824
2906
  if (Array.isArray(chatSuggestions)) {
2825
2907
  setSuggestions(chatSuggestions);
2826
2908
  hasGeneratedInitialSuggestions.current = true;
2827
2909
  }
2828
2910
  }, [JSON.stringify(chatSuggestions), setSuggestions]);
2829
- const generateSuggestionsWithErrorHandling = (0, import_react14.useCallback)(
2911
+ const generateSuggestionsWithErrorHandling = (0, import_react15.useCallback)(
2830
2912
  (context) => __async(void 0, null, function* () {
2831
2913
  try {
2832
2914
  yield generateSuggestions();
@@ -2837,7 +2919,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
2837
2919
  }),
2838
2920
  [generateSuggestions]
2839
2921
  );
2840
- (0, import_react14.useEffect)(() => {
2922
+ (0, import_react15.useEffect)(() => {
2841
2923
  if (chatSuggestions !== "auto" || isLoadingSuggestions || suggestionsFailed) {
2842
2924
  return;
2843
2925
  }
@@ -2867,13 +2949,13 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
2867
2949
  // Use stable string instead of object reference
2868
2950
  generateSuggestionsWithErrorHandling
2869
2951
  ]);
2870
- (0, import_react14.useEffect)(() => {
2952
+ (0, import_react15.useEffect)(() => {
2871
2953
  if (chatSuggestions !== "auto") {
2872
2954
  hasGeneratedInitialSuggestions.current = false;
2873
2955
  setSuggestionsFailed(false);
2874
2956
  }
2875
2957
  }, [chatSuggestions]);
2876
- const stableContext = (0, import_react14.useMemo)(
2958
+ const stableContext = (0, import_react15.useMemo)(
2877
2959
  () => __spreadValues(__spreadValues({}, generalContext), messagesContext),
2878
2960
  [
2879
2961
  // Only include stable dependencies
@@ -2882,12 +2964,12 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
2882
2964
  generalContext.isLoading
2883
2965
  ]
2884
2966
  );
2885
- const resetSuggestions = (0, import_react14.useCallback)(() => {
2967
+ const resetSuggestions = (0, import_react15.useCallback)(() => {
2886
2968
  resetSuggestionsFromHook();
2887
2969
  setSuggestionsFailed(false);
2888
2970
  hasGeneratedInitialSuggestions.current = false;
2889
2971
  }, [resetSuggestionsFromHook]);
2890
- (0, import_react14.useEffect)(() => {
2972
+ (0, import_react15.useEffect)(() => {
2891
2973
  onInProgress == null ? void 0 : onInProgress(isLoading);
2892
2974
  }, [onInProgress, isLoading]);
2893
2975
  const safelySendMessage = (messageContent, imagesToUse) => __async(void 0, null, function* () {
@@ -3033,7 +3115,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
3033
3115
  // src/components/chat/Modal.tsx
3034
3116
  var import_react_core11 = require("@copilotkit/react-core");
3035
3117
  var import_shared5 = require("@copilotkit/shared");
3036
- var import_jsx_runtime25 = require("react/jsx-runtime");
3118
+ var import_jsx_runtime26 = require("react/jsx-runtime");
3037
3119
  var CopilotModalInner = (_a) => {
3038
3120
  var _b = _a, {
3039
3121
  observabilityHooks,
@@ -3060,7 +3142,7 @@ var CopilotModalInner = (_a) => {
3060
3142
  ]);
3061
3143
  const { copilotApiConfig, setBannerError } = (0, import_react_core11.useCopilotContext)();
3062
3144
  const { publicApiKey } = copilotApiConfig;
3063
- const triggerObservabilityHook = (0, import_react15.useCallback)(
3145
+ const triggerObservabilityHook = (0, import_react16.useCallback)(
3064
3146
  (hookName, ...args) => {
3065
3147
  if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
3066
3148
  observabilityHooks[hookName](...args);
@@ -3080,8 +3162,8 @@ var CopilotModalInner = (_a) => {
3080
3162
  [publicApiKey, observabilityHooks, setBannerError]
3081
3163
  );
3082
3164
  const { open } = useChatContext();
3083
- const prevOpen = (0, import_react15.useRef)(open);
3084
- (0, import_react15.useEffect)(() => {
3165
+ const prevOpen = (0, import_react16.useRef)(open);
3166
+ (0, import_react16.useEffect)(() => {
3085
3167
  if (prevOpen.current !== open) {
3086
3168
  onSetOpen == null ? void 0 : onSetOpen(open);
3087
3169
  if (open) {
@@ -3092,13 +3174,13 @@ var CopilotModalInner = (_a) => {
3092
3174
  prevOpen.current = open;
3093
3175
  }
3094
3176
  }, [open, onSetOpen, triggerObservabilityHook]);
3095
- const memoizedHeader = (0, import_react15.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Header2, {}), [Header2]);
3096
- const memoizedChildren = (0, import_react15.useMemo)(() => children, [children]);
3097
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
3177
+ const memoizedHeader = (0, import_react16.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Header2, {}), [Header2]);
3178
+ const memoizedChildren = (0, import_react16.useMemo)(() => children, [children]);
3179
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
3098
3180
  memoizedChildren,
3099
- /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className, children: [
3100
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Button2, {}),
3101
- /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
3181
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className, children: [
3182
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Button2, {}),
3183
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
3102
3184
  Window2,
3103
3185
  {
3104
3186
  clickOutsideToClose,
@@ -3106,7 +3188,7 @@ var CopilotModalInner = (_a) => {
3106
3188
  hitEscapeToClose,
3107
3189
  children: [
3108
3190
  memoizedHeader,
3109
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(CopilotChat, __spreadProps(__spreadValues({}, chatProps), { observabilityHooks }))
3191
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CopilotChat, __spreadProps(__spreadValues({}, chatProps), { observabilityHooks }))
3110
3192
  ]
3111
3193
  }
3112
3194
  )
@@ -3173,8 +3255,8 @@ var CopilotModal = (_a) => {
3173
3255
  "children",
3174
3256
  "observabilityHooks"
3175
3257
  ]);
3176
- const [openState, setOpenState] = import_react15.default.useState(defaultOpen);
3177
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3258
+ const [openState, setOpenState] = import_react16.default.useState(defaultOpen);
3259
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3178
3260
  CopilotModalInner,
3179
3261
  __spreadProps(__spreadValues({
3180
3262
  observabilityHooks,
@@ -3208,22 +3290,22 @@ var CopilotModal = (_a) => {
3208
3290
  };
3209
3291
 
3210
3292
  // src/components/chat/Popup.tsx
3211
- var import_jsx_runtime26 = require("react/jsx-runtime");
3293
+ var import_jsx_runtime27 = require("react/jsx-runtime");
3212
3294
  function CopilotPopup(props) {
3213
3295
  props = __spreadProps(__spreadValues({}, props), {
3214
3296
  className: props.className ? props.className + " copilotKitPopup" : "copilotKitPopup"
3215
3297
  });
3216
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CopilotModal, __spreadProps(__spreadValues({}, props), { children: props.children }));
3298
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CopilotModal, __spreadProps(__spreadValues({}, props), { children: props.children }));
3217
3299
  }
3218
3300
 
3219
3301
  // src/components/chat/Sidebar.tsx
3220
- var import_react16 = require("react");
3221
- var import_jsx_runtime27 = require("react/jsx-runtime");
3302
+ var import_react17 = require("react");
3303
+ var import_jsx_runtime28 = require("react/jsx-runtime");
3222
3304
  function CopilotSidebar(props) {
3223
3305
  props = __spreadProps(__spreadValues({}, props), {
3224
3306
  className: props.className ? props.className + " copilotKitSidebar" : "copilotKitSidebar"
3225
3307
  });
3226
- const [expandedClassName, setExpandedClassName] = (0, import_react16.useState)(
3308
+ const [expandedClassName, setExpandedClassName] = (0, import_react17.useState)(
3227
3309
  props.defaultOpen ? "sidebarExpanded" : ""
3228
3310
  );
3229
3311
  const onSetOpen = (open) => {
@@ -3231,11 +3313,11 @@ function CopilotSidebar(props) {
3231
3313
  (_a = props.onSetOpen) == null ? void 0 : _a.call(props, open);
3232
3314
  setExpandedClassName(open ? "sidebarExpanded" : "");
3233
3315
  };
3234
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: `copilotKitSidebarContentWrapper ${expandedClassName}`, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CopilotModal, __spreadProps(__spreadValues(__spreadValues({}, props), { onSetOpen }), { children: props.children })) });
3316
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: `copilotKitSidebarContentWrapper ${expandedClassName}`, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(CopilotModal, __spreadProps(__spreadValues(__spreadValues({}, props), { onSetOpen }), { children: props.children })) });
3235
3317
  }
3236
3318
 
3237
3319
  // src/hooks/use-copilot-chat-suggestions.tsx
3238
- var import_react17 = require("react");
3320
+ var import_react18 = require("react");
3239
3321
  var import_react_core12 = require("@copilotkit/react-core");
3240
3322
  var import_shared6 = require("@copilotkit/shared");
3241
3323
  function useCopilotChatSuggestions({
@@ -3246,7 +3328,7 @@ function useCopilotChatSuggestions({
3246
3328
  maxSuggestions = 3
3247
3329
  }, dependencies = []) {
3248
3330
  const context = (0, import_react_core12.useCopilotContext)();
3249
- (0, import_react17.useEffect)(() => {
3331
+ (0, import_react18.useEffect)(() => {
3250
3332
  if (available === "disabled")
3251
3333
  return;
3252
3334
  const id = (0, import_shared6.randomId)();