@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
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CopilotModal
3
- } from "../../chunk-SHPG2T4O.mjs";
3
+ } from "../../chunk-FJFWH5AF.mjs";
4
4
  import "../../chunk-C3GSYRC3.mjs";
5
5
  import "../../chunk-GDSZGYCE.mjs";
6
6
  import "../../chunk-V7W6IM2V.mjs";
@@ -11,14 +11,15 @@ import "../../chunk-KXE2JCUH.mjs";
11
11
  import "../../chunk-NRA3CFEE.mjs";
12
12
  import "../../chunk-BH6PCAAL.mjs";
13
13
  import "../../chunk-UFN2VWSR.mjs";
14
- import "../../chunk-EL7NCWNZ.mjs";
14
+ import "../../chunk-Z66Y3KRE.mjs";
15
+ import "../../chunk-SRY5COHG.mjs";
15
16
  import "../../chunk-226ZMOE3.mjs";
16
17
  import "../../chunk-W26XFBEG.mjs";
17
18
  import "../../chunk-PLHTVHUW.mjs";
18
19
  import "../../chunk-DTRPPNSA.mjs";
19
20
  import "../../chunk-CGEAG65D.mjs";
20
21
  import "../../chunk-QIOJXTIQ.mjs";
21
- import "../../chunk-X5AO5A3L.mjs";
22
+ import "../../chunk-PHH6DYUW.mjs";
22
23
  import "../../chunk-YO63WHVQ.mjs";
23
24
  import "../../chunk-LJAYSRCB.mjs";
24
25
  import "../../chunk-X477GDGZ.mjs";
@@ -7,7 +7,7 @@ import '../../types/suggestions.js';
7
7
  import './Chat.js';
8
8
  import '@copilotkit/react-core/dist/types/coagent-state';
9
9
  import '@copilotkit/react-core/dist/hooks/use-tree';
10
- import '@copilotkit/react-core/dist/copilot-context-256f9020';
10
+ import '@copilotkit/react-core/dist/copilot-context-59740e82';
11
11
  import '@copilotkit/react-core/dist/types/coagent-action';
12
12
  import '@copilotkit/react-core';
13
13
  import '@copilotkit/runtime-client-gql';
@@ -84,7 +84,7 @@ __export(Popup_exports, {
84
84
  module.exports = __toCommonJS(Popup_exports);
85
85
 
86
86
  // src/components/chat/Modal.tsx
87
- var import_react15 = __toESM(require("react"));
87
+ var import_react16 = __toESM(require("react"));
88
88
 
89
89
  // src/components/chat/ChatContext.tsx
90
90
  var import_react = __toESM(require("react"));
@@ -1872,12 +1872,14 @@ var Messages = ({
1872
1872
  RenderMessage: RenderMessage2,
1873
1873
  AssistantMessage: AssistantMessage2,
1874
1874
  UserMessage: UserMessage2,
1875
+ ErrorMessage: ErrorMessage2,
1875
1876
  ImageRenderer: ImageRenderer2,
1876
1877
  onRegenerate,
1877
1878
  onCopy,
1878
1879
  onThumbsUp,
1879
1880
  onThumbsDown,
1880
1881
  markdownTagRenderers,
1882
+ chatError,
1881
1883
  // Legacy props
1882
1884
  RenderTextMessage,
1883
1885
  RenderActionExecutionMessage,
@@ -1938,7 +1940,8 @@ var Messages = ({
1938
1940
  index
1939
1941
  );
1940
1942
  }),
1941
- interrupt
1943
+ interrupt,
1944
+ chatError && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ErrorMessage2, { error: chatError, isCurrentMessage: true })
1942
1945
  ] }),
1943
1946
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("footer", { className: "copilotKitMessagesFooter", ref: messagesEndRef, children })
1944
1947
  ] });
@@ -2321,15 +2324,67 @@ var Input = ({
2321
2324
  ] });
2322
2325
  };
2323
2326
 
2327
+ // src/components/chat/messages/ErrorMessage.tsx
2328
+ var import_react14 = require("react");
2329
+ var import_jsx_runtime21 = require("react/jsx-runtime");
2330
+ var ErrorMessage = (props) => {
2331
+ const { icons, labels } = useChatContext();
2332
+ const { error, onRegenerate, onCopy, isCurrentMessage } = props;
2333
+ const [copied, setCopied] = (0, import_react14.useState)(false);
2334
+ const handleCopy = () => {
2335
+ const content = error.message;
2336
+ if (content && onCopy) {
2337
+ navigator.clipboard.writeText(content);
2338
+ setCopied(true);
2339
+ onCopy(content);
2340
+ setTimeout(() => setCopied(false), 2e3);
2341
+ } else if (content) {
2342
+ navigator.clipboard.writeText(content);
2343
+ setCopied(true);
2344
+ setTimeout(() => setCopied(false), 2e3);
2345
+ }
2346
+ };
2347
+ const handleRegenerate = () => {
2348
+ if (onRegenerate)
2349
+ onRegenerate();
2350
+ };
2351
+ console.log(error);
2352
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "copilotKitMessage copilotKitAssistantMessage", children: [
2353
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Markdown, { content: error.message }),
2354
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: `copilotKitMessageControls ${isCurrentMessage ? "currentMessage" : ""}`, children: [
2355
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2356
+ "button",
2357
+ {
2358
+ className: "copilotKitMessageControlButton",
2359
+ onClick: handleRegenerate,
2360
+ "aria-label": labels.regenerateResponse,
2361
+ title: labels.regenerateResponse,
2362
+ children: icons.regenerateIcon
2363
+ }
2364
+ ),
2365
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2366
+ "button",
2367
+ {
2368
+ className: "copilotKitMessageControlButton",
2369
+ onClick: handleCopy,
2370
+ "aria-label": labels.copyToClipboard,
2371
+ title: labels.copyToClipboard,
2372
+ children: copied ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { style: { fontSize: "10px", fontWeight: "bold" }, children: "\u2713" }) : icons.copyIcon
2373
+ }
2374
+ )
2375
+ ] })
2376
+ ] });
2377
+ };
2378
+
2324
2379
  // src/components/chat/Chat.tsx
2325
- var import_react14 = __toESM(require("react"));
2380
+ var import_react15 = __toESM(require("react"));
2326
2381
  var import_react_core9 = require("@copilotkit/react-core");
2327
2382
  var import_shared3 = require("@copilotkit/shared");
2328
2383
  var import_shared4 = require("@copilotkit/shared");
2329
2384
  var import_react_core10 = require("@copilotkit/react-core");
2330
2385
 
2331
2386
  // src/components/chat/ImageUploadQueue.tsx
2332
- var import_jsx_runtime21 = require("react/jsx-runtime");
2387
+ var import_jsx_runtime22 = require("react/jsx-runtime");
2333
2388
  var ImageUploadQueue = ({
2334
2389
  images,
2335
2390
  onRemoveImage,
@@ -2337,7 +2392,7 @@ var ImageUploadQueue = ({
2337
2392
  }) => {
2338
2393
  if (images.length === 0)
2339
2394
  return null;
2340
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2395
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2341
2396
  "div",
2342
2397
  {
2343
2398
  className: `copilotKitImageUploadQueue ${className}`,
@@ -2348,7 +2403,7 @@ var ImageUploadQueue = ({
2348
2403
  margin: "8px",
2349
2404
  padding: "8px"
2350
2405
  },
2351
- children: images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
2406
+ children: images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
2352
2407
  "div",
2353
2408
  {
2354
2409
  className: "copilotKitImageUploadQueueItem",
@@ -2361,7 +2416,7 @@ var ImageUploadQueue = ({
2361
2416
  overflow: "hidden"
2362
2417
  },
2363
2418
  children: [
2364
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2419
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2365
2420
  "img",
2366
2421
  {
2367
2422
  src: `data:${image.contentType};base64,${image.bytes}`,
@@ -2373,7 +2428,7 @@ var ImageUploadQueue = ({
2373
2428
  }
2374
2429
  }
2375
2430
  ),
2376
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2431
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2377
2432
  "button",
2378
2433
  {
2379
2434
  onClick: () => onRemoveImage(index),
@@ -2408,12 +2463,12 @@ var ImageUploadQueue = ({
2408
2463
 
2409
2464
  // src/components/chat/Suggestion.tsx
2410
2465
  var import_react_core8 = require("@copilotkit/react-core");
2411
- var import_jsx_runtime22 = require("react/jsx-runtime");
2466
+ var import_jsx_runtime23 = require("react/jsx-runtime");
2412
2467
  function Suggestion({ title, onClick, partial, className }) {
2413
2468
  if (!title)
2414
2469
  return null;
2415
2470
  const { isLoading } = (0, import_react_core8.useCopilotChatInternal)();
2416
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2471
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2417
2472
  "button",
2418
2473
  {
2419
2474
  disabled: partial || isLoading,
@@ -2423,15 +2478,15 @@ function Suggestion({ title, onClick, partial, className }) {
2423
2478
  },
2424
2479
  className: className || (partial ? "suggestion loading" : "suggestion"),
2425
2480
  "data-test-id": "suggestion",
2426
- children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { children: title })
2481
+ children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: title })
2427
2482
  }
2428
2483
  );
2429
2484
  }
2430
2485
 
2431
2486
  // src/components/chat/Suggestions.tsx
2432
- var import_jsx_runtime23 = require("react/jsx-runtime");
2487
+ var import_jsx_runtime24 = require("react/jsx-runtime");
2433
2488
  function Suggestions({ suggestions, onSuggestionClick }) {
2434
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "suggestions", children: suggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2489
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "suggestions", children: suggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2435
2490
  Suggestion,
2436
2491
  {
2437
2492
  title: suggestion.title,
@@ -2445,7 +2500,7 @@ function Suggestions({ suggestions, onSuggestionClick }) {
2445
2500
  }
2446
2501
 
2447
2502
  // src/components/chat/Chat.tsx
2448
- var import_jsx_runtime24 = require("react/jsx-runtime");
2503
+ var import_jsx_runtime25 = require("react/jsx-runtime");
2449
2504
  function CopilotChat({
2450
2505
  instructions,
2451
2506
  suggestions = "auto",
@@ -2470,11 +2525,13 @@ function CopilotChat({
2470
2525
  AssistantMessage: AssistantMessage2 = AssistantMessage,
2471
2526
  UserMessage: UserMessage2 = UserMessage,
2472
2527
  ImageRenderer: ImageRenderer2 = ImageRenderer,
2528
+ ErrorMessage: ErrorMessage2 = ErrorMessage,
2473
2529
  imageUploadsEnabled,
2474
2530
  inputFileAccept = "image/*",
2475
2531
  hideStopButton,
2476
2532
  observabilityHooks,
2477
2533
  renderError,
2534
+ onError,
2478
2535
  // Legacy props - deprecated
2479
2536
  RenderTextMessage,
2480
2537
  RenderActionExecutionMessage,
@@ -2482,12 +2539,19 @@ function CopilotChat({
2482
2539
  RenderResultMessage,
2483
2540
  RenderImageMessage
2484
2541
  }) {
2485
- const { additionalInstructions, setChatInstructions, copilotApiConfig, setBannerError } = (0, import_react_core9.useCopilotContext)();
2542
+ const {
2543
+ additionalInstructions,
2544
+ setChatInstructions,
2545
+ copilotApiConfig,
2546
+ setBannerError,
2547
+ setInternalErrorHandler,
2548
+ removeInternalErrorHandler
2549
+ } = (0, import_react_core9.useCopilotContext)();
2486
2550
  const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
2487
- const [selectedImages, setSelectedImages] = (0, import_react14.useState)([]);
2488
- const [chatError, setChatError] = (0, import_react14.useState)(null);
2489
- const fileInputRef = (0, import_react14.useRef)(null);
2490
- const triggerObservabilityHook = (0, import_react14.useCallback)(
2551
+ const [selectedImages, setSelectedImages] = (0, import_react15.useState)([]);
2552
+ const [chatError, setChatError] = (0, import_react15.useState)(null);
2553
+ const fileInputRef = (0, import_react15.useRef)(null);
2554
+ const triggerObservabilityHook = (0, import_react15.useCallback)(
2491
2555
  (hookName, ...args) => {
2492
2556
  if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
2493
2557
  observabilityHooks[hookName](...args);
@@ -2506,7 +2570,7 @@ function CopilotChat({
2506
2570
  },
2507
2571
  [publicApiKey, observabilityHooks, setBannerError]
2508
2572
  );
2509
- const triggerChatError = (0, import_react14.useCallback)(
2573
+ const triggerChatError = (0, import_react15.useCallback)(
2510
2574
  (error, operation, originalError) => {
2511
2575
  const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
2512
2576
  setChatError({
@@ -2514,25 +2578,28 @@ function CopilotChat({
2514
2578
  operation,
2515
2579
  timestamp: Date.now()
2516
2580
  });
2517
- if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks.onError)) {
2518
- const errorEvent = {
2519
- type: "error",
2520
- timestamp: Date.now(),
2521
- context: {
2522
- source: "ui",
2523
- request: {
2524
- operation,
2525
- url: chatApiEndpoint,
2526
- startTime: Date.now()
2527
- },
2528
- technical: {
2529
- environment: "browser",
2530
- userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
2531
- stackTrace: originalError instanceof Error ? originalError.stack : void 0
2532
- }
2581
+ const errorEvent = {
2582
+ type: "error",
2583
+ timestamp: Date.now(),
2584
+ context: {
2585
+ source: "ui",
2586
+ request: {
2587
+ operation,
2588
+ url: chatApiEndpoint,
2589
+ startTime: Date.now()
2533
2590
  },
2534
- error
2535
- };
2591
+ technical: {
2592
+ environment: "browser",
2593
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
2594
+ stackTrace: originalError instanceof Error ? originalError.stack : void 0
2595
+ }
2596
+ },
2597
+ error
2598
+ };
2599
+ if (onError) {
2600
+ onError(errorEvent);
2601
+ }
2602
+ if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks.onError)) {
2536
2603
  observabilityHooks.onError(errorEvent);
2537
2604
  }
2538
2605
  if ((observabilityHooks == null ? void 0 : observabilityHooks.onError) && !publicApiKey) {
@@ -2549,7 +2616,20 @@ function CopilotChat({
2549
2616
  },
2550
2617
  [publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
2551
2618
  );
2552
- (0, import_react14.useEffect)(() => {
2619
+ (0, import_react15.useEffect)(() => {
2620
+ const id = "chat-component";
2621
+ setInternalErrorHandler({
2622
+ [id]: (error) => {
2623
+ if (!error)
2624
+ return;
2625
+ triggerChatError(error.error, "sendMessage");
2626
+ }
2627
+ });
2628
+ return () => {
2629
+ removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
2630
+ };
2631
+ }, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
2632
+ (0, import_react15.useEffect)(() => {
2553
2633
  if (!imageUploadsEnabled)
2554
2634
  return;
2555
2635
  const handlePaste = (e) => __async(this, null, function* () {
@@ -2595,7 +2675,7 @@ function CopilotChat({
2595
2675
  document.addEventListener("paste", handlePaste);
2596
2676
  return () => document.removeEventListener("paste", handlePaste);
2597
2677
  }, [imageUploadsEnabled, triggerChatError]);
2598
- (0, import_react14.useEffect)(() => {
2678
+ (0, import_react15.useEffect)(() => {
2599
2679
  if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
2600
2680
  setChatInstructions(instructions || "");
2601
2681
  return;
@@ -2623,8 +2703,8 @@ function CopilotChat({
2623
2703
  onStopGeneration,
2624
2704
  onReloadMessages
2625
2705
  );
2626
- const prevIsLoading = (0, import_react14.useRef)(isLoading);
2627
- (0, import_react14.useEffect)(() => {
2706
+ const prevIsLoading = (0, import_react15.useRef)(isLoading);
2707
+ (0, import_react15.useEffect)(() => {
2628
2708
  if (prevIsLoading.current !== isLoading) {
2629
2709
  if (isLoading) {
2630
2710
  triggerObservabilityHook("onChatStarted");
@@ -2643,7 +2723,7 @@ function CopilotChat({
2643
2723
  triggerObservabilityHook("onMessageSent", text);
2644
2724
  return sendMessage(text, images);
2645
2725
  };
2646
- const chatContext = import_react14.default.useContext(ChatContext);
2726
+ const chatContext = import_react15.default.useContext(ChatContext);
2647
2727
  const isVisible = chatContext ? chatContext.open : true;
2648
2728
  const handleRegenerate = (messageId) => {
2649
2729
  if (onRegenerate) {
@@ -2705,14 +2785,14 @@ function CopilotChat({
2705
2785
  }
2706
2786
  triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsDown");
2707
2787
  };
2708
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
2788
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
2709
2789
  chatError && renderError && renderError(__spreadProps(__spreadValues({}, chatError), {
2710
2790
  onDismiss: () => setChatError(null),
2711
2791
  onRetry: () => {
2712
2792
  setChatError(null);
2713
2793
  }
2714
2794
  })),
2715
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2795
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2716
2796
  Messages2,
2717
2797
  {
2718
2798
  AssistantMessage: AssistantMessage2,
@@ -2726,12 +2806,14 @@ function CopilotChat({
2726
2806
  onThumbsDown: handleThumbsDown,
2727
2807
  markdownTagRenderers,
2728
2808
  ImageRenderer: ImageRenderer2,
2809
+ ErrorMessage: ErrorMessage2,
2810
+ chatError,
2729
2811
  RenderTextMessage,
2730
2812
  RenderActionExecutionMessage,
2731
2813
  RenderAgentStateMessage,
2732
2814
  RenderResultMessage,
2733
2815
  RenderImageMessage,
2734
- children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2816
+ children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2735
2817
  RenderSuggestionsList,
2736
2818
  {
2737
2819
  onSuggestionClick: handleSendMessage,
@@ -2740,9 +2822,9 @@ function CopilotChat({
2740
2822
  )
2741
2823
  }
2742
2824
  ),
2743
- imageUploadsEnabled && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
2744
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ImageUploadQueue, { images: selectedImages, onRemoveImage: removeSelectedImage }),
2745
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2825
+ imageUploadsEnabled && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
2826
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ImageUploadQueue, { images: selectedImages, onRemoveImage: removeSelectedImage }),
2827
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2746
2828
  "input",
2747
2829
  {
2748
2830
  type: "file",
@@ -2754,7 +2836,7 @@ function CopilotChat({
2754
2836
  }
2755
2837
  )
2756
2838
  ] }),
2757
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2839
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2758
2840
  Input2,
2759
2841
  {
2760
2842
  inProgress: isLoading,
@@ -2776,12 +2858,12 @@ function WrappedCopilotChat({
2776
2858
  labels,
2777
2859
  className
2778
2860
  }) {
2779
- const chatContext = import_react14.default.useContext(ChatContext);
2861
+ const chatContext = import_react15.default.useContext(ChatContext);
2780
2862
  if (!chatContext) {
2781
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
2782
- }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
2863
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
2864
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
2783
2865
  }
2784
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children });
2866
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children });
2785
2867
  }
2786
2868
  var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
2787
2869
  var _a;
@@ -2805,15 +2887,15 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
2805
2887
  const generalContext = (0, import_react_core9.useCopilotContext)();
2806
2888
  const messagesContext = (0, import_react_core9.useCopilotMessagesContext)();
2807
2889
  const { actions } = generalContext;
2808
- const [suggestionsFailed, setSuggestionsFailed] = (0, import_react14.useState)(false);
2809
- const hasGeneratedInitialSuggestions = (0, import_react14.useRef)(false);
2810
- (0, import_react14.useEffect)(() => {
2890
+ const [suggestionsFailed, setSuggestionsFailed] = (0, import_react15.useState)(false);
2891
+ const hasGeneratedInitialSuggestions = (0, import_react15.useRef)(false);
2892
+ (0, import_react15.useEffect)(() => {
2811
2893
  if (Array.isArray(chatSuggestions)) {
2812
2894
  setSuggestions(chatSuggestions);
2813
2895
  hasGeneratedInitialSuggestions.current = true;
2814
2896
  }
2815
2897
  }, [JSON.stringify(chatSuggestions), setSuggestions]);
2816
- const generateSuggestionsWithErrorHandling = (0, import_react14.useCallback)(
2898
+ const generateSuggestionsWithErrorHandling = (0, import_react15.useCallback)(
2817
2899
  (context) => __async(void 0, null, function* () {
2818
2900
  try {
2819
2901
  yield generateSuggestions();
@@ -2824,7 +2906,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
2824
2906
  }),
2825
2907
  [generateSuggestions]
2826
2908
  );
2827
- (0, import_react14.useEffect)(() => {
2909
+ (0, import_react15.useEffect)(() => {
2828
2910
  if (chatSuggestions !== "auto" || isLoadingSuggestions || suggestionsFailed) {
2829
2911
  return;
2830
2912
  }
@@ -2854,13 +2936,13 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
2854
2936
  // Use stable string instead of object reference
2855
2937
  generateSuggestionsWithErrorHandling
2856
2938
  ]);
2857
- (0, import_react14.useEffect)(() => {
2939
+ (0, import_react15.useEffect)(() => {
2858
2940
  if (chatSuggestions !== "auto") {
2859
2941
  hasGeneratedInitialSuggestions.current = false;
2860
2942
  setSuggestionsFailed(false);
2861
2943
  }
2862
2944
  }, [chatSuggestions]);
2863
- const stableContext = (0, import_react14.useMemo)(
2945
+ const stableContext = (0, import_react15.useMemo)(
2864
2946
  () => __spreadValues(__spreadValues({}, generalContext), messagesContext),
2865
2947
  [
2866
2948
  // Only include stable dependencies
@@ -2869,12 +2951,12 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
2869
2951
  generalContext.isLoading
2870
2952
  ]
2871
2953
  );
2872
- const resetSuggestions = (0, import_react14.useCallback)(() => {
2954
+ const resetSuggestions = (0, import_react15.useCallback)(() => {
2873
2955
  resetSuggestionsFromHook();
2874
2956
  setSuggestionsFailed(false);
2875
2957
  hasGeneratedInitialSuggestions.current = false;
2876
2958
  }, [resetSuggestionsFromHook]);
2877
- (0, import_react14.useEffect)(() => {
2959
+ (0, import_react15.useEffect)(() => {
2878
2960
  onInProgress == null ? void 0 : onInProgress(isLoading);
2879
2961
  }, [onInProgress, isLoading]);
2880
2962
  const safelySendMessage = (messageContent, imagesToUse) => __async(void 0, null, function* () {
@@ -3020,7 +3102,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
3020
3102
  // src/components/chat/Modal.tsx
3021
3103
  var import_react_core11 = require("@copilotkit/react-core");
3022
3104
  var import_shared5 = require("@copilotkit/shared");
3023
- var import_jsx_runtime25 = require("react/jsx-runtime");
3105
+ var import_jsx_runtime26 = require("react/jsx-runtime");
3024
3106
  var CopilotModalInner = (_a) => {
3025
3107
  var _b = _a, {
3026
3108
  observabilityHooks,
@@ -3047,7 +3129,7 @@ var CopilotModalInner = (_a) => {
3047
3129
  ]);
3048
3130
  const { copilotApiConfig, setBannerError } = (0, import_react_core11.useCopilotContext)();
3049
3131
  const { publicApiKey } = copilotApiConfig;
3050
- const triggerObservabilityHook = (0, import_react15.useCallback)(
3132
+ const triggerObservabilityHook = (0, import_react16.useCallback)(
3051
3133
  (hookName, ...args) => {
3052
3134
  if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
3053
3135
  observabilityHooks[hookName](...args);
@@ -3067,8 +3149,8 @@ var CopilotModalInner = (_a) => {
3067
3149
  [publicApiKey, observabilityHooks, setBannerError]
3068
3150
  );
3069
3151
  const { open } = useChatContext();
3070
- const prevOpen = (0, import_react15.useRef)(open);
3071
- (0, import_react15.useEffect)(() => {
3152
+ const prevOpen = (0, import_react16.useRef)(open);
3153
+ (0, import_react16.useEffect)(() => {
3072
3154
  if (prevOpen.current !== open) {
3073
3155
  onSetOpen == null ? void 0 : onSetOpen(open);
3074
3156
  if (open) {
@@ -3079,13 +3161,13 @@ var CopilotModalInner = (_a) => {
3079
3161
  prevOpen.current = open;
3080
3162
  }
3081
3163
  }, [open, onSetOpen, triggerObservabilityHook]);
3082
- const memoizedHeader = (0, import_react15.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Header2, {}), [Header2]);
3083
- const memoizedChildren = (0, import_react15.useMemo)(() => children, [children]);
3084
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
3164
+ const memoizedHeader = (0, import_react16.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Header2, {}), [Header2]);
3165
+ const memoizedChildren = (0, import_react16.useMemo)(() => children, [children]);
3166
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
3085
3167
  memoizedChildren,
3086
- /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className, children: [
3087
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Button2, {}),
3088
- /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
3168
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className, children: [
3169
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Button2, {}),
3170
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
3089
3171
  Window2,
3090
3172
  {
3091
3173
  clickOutsideToClose,
@@ -3093,7 +3175,7 @@ var CopilotModalInner = (_a) => {
3093
3175
  hitEscapeToClose,
3094
3176
  children: [
3095
3177
  memoizedHeader,
3096
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(CopilotChat, __spreadProps(__spreadValues({}, chatProps), { observabilityHooks }))
3178
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CopilotChat, __spreadProps(__spreadValues({}, chatProps), { observabilityHooks }))
3097
3179
  ]
3098
3180
  }
3099
3181
  )
@@ -3160,8 +3242,8 @@ var CopilotModal = (_a) => {
3160
3242
  "children",
3161
3243
  "observabilityHooks"
3162
3244
  ]);
3163
- const [openState, setOpenState] = import_react15.default.useState(defaultOpen);
3164
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3245
+ const [openState, setOpenState] = import_react16.default.useState(defaultOpen);
3246
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3165
3247
  CopilotModalInner,
3166
3248
  __spreadProps(__spreadValues({
3167
3249
  observabilityHooks,
@@ -3195,12 +3277,12 @@ var CopilotModal = (_a) => {
3195
3277
  };
3196
3278
 
3197
3279
  // src/components/chat/Popup.tsx
3198
- var import_jsx_runtime26 = require("react/jsx-runtime");
3280
+ var import_jsx_runtime27 = require("react/jsx-runtime");
3199
3281
  function CopilotPopup(props) {
3200
3282
  props = __spreadProps(__spreadValues({}, props), {
3201
3283
  className: props.className ? props.className + " copilotKitPopup" : "copilotKitPopup"
3202
3284
  });
3203
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CopilotModal, __spreadProps(__spreadValues({}, props), { children: props.children }));
3285
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CopilotModal, __spreadProps(__spreadValues({}, props), { children: props.children }));
3204
3286
  }
3205
3287
  // Annotate the CommonJS export names for ESM import in node:
3206
3288
  0 && (module.exports = {