@copilotkit/react-ui 1.10.4-next.1 → 1.10.4-next.3

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 (57) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/{chunk-FWQRAZ5S.mjs → chunk-53C3S7R3.mjs} +2 -2
  3. package/dist/{chunk-7XIE7UOW.mjs → chunk-73V4ZLAN.mjs} +2 -2
  4. package/dist/{chunk-SHPG2T4O.mjs → chunk-AUCJZBT5.mjs} +3 -3
  5. package/dist/{chunk-X5AO5A3L.mjs → chunk-EELILZTD.mjs} +5 -2
  6. package/dist/chunk-EELILZTD.mjs.map +1 -0
  7. package/dist/{chunk-EL7NCWNZ.mjs → chunk-WOYNUDPM.mjs} +48 -21
  8. package/dist/chunk-WOYNUDPM.mjs.map +1 -0
  9. package/dist/components/chat/Chat.d.ts +24 -13
  10. package/dist/components/chat/Chat.js +50 -20
  11. package/dist/components/chat/Chat.js.map +1 -1
  12. package/dist/components/chat/Chat.mjs +2 -2
  13. package/dist/components/chat/Messages.d.ts +1 -1
  14. package/dist/components/chat/Messages.js +4 -1
  15. package/dist/components/chat/Messages.js.map +1 -1
  16. package/dist/components/chat/Messages.mjs +1 -1
  17. package/dist/components/chat/Modal.d.ts +1 -1
  18. package/dist/components/chat/Modal.js +50 -20
  19. package/dist/components/chat/Modal.js.map +1 -1
  20. package/dist/components/chat/Modal.mjs +3 -3
  21. package/dist/components/chat/Popup.d.ts +1 -1
  22. package/dist/components/chat/Popup.js +50 -20
  23. package/dist/components/chat/Popup.js.map +1 -1
  24. package/dist/components/chat/Popup.mjs +4 -4
  25. package/dist/components/chat/Sidebar.d.ts +1 -1
  26. package/dist/components/chat/Sidebar.js +50 -20
  27. package/dist/components/chat/Sidebar.js.map +1 -1
  28. package/dist/components/chat/Sidebar.mjs +4 -4
  29. package/dist/components/chat/index.d.ts +2 -2
  30. package/dist/components/chat/index.js +50 -20
  31. package/dist/components/chat/index.js.map +1 -1
  32. package/dist/components/chat/index.mjs +5 -5
  33. package/dist/components/chat/messages/ErrorMessage.d.ts +9 -0
  34. package/dist/components/chat/messages/ErrorMessage.js +711 -0
  35. package/dist/components/chat/messages/ErrorMessage.js.map +1 -0
  36. package/dist/components/chat/messages/ErrorMessage.mjs +66 -0
  37. package/dist/components/chat/messages/ErrorMessage.mjs.map +1 -0
  38. package/dist/components/chat/props.d.ts +26 -1
  39. package/dist/components/chat/props.js.map +1 -1
  40. package/dist/components/index.d.ts +2 -2
  41. package/dist/components/index.js +50 -20
  42. package/dist/components/index.js.map +1 -1
  43. package/dist/components/index.mjs +5 -5
  44. package/dist/index.d.ts +2 -2
  45. package/dist/index.js +50 -20
  46. package/dist/index.js.map +1 -1
  47. package/dist/index.mjs +6 -6
  48. package/package.json +4 -4
  49. package/src/components/chat/Chat.tsx +63 -26
  50. package/src/components/chat/Messages.tsx +3 -0
  51. package/src/components/chat/messages/ErrorMessage.tsx +59 -0
  52. package/src/components/chat/props.ts +31 -0
  53. package/dist/chunk-EL7NCWNZ.mjs.map +0 -1
  54. package/dist/chunk-X5AO5A3L.mjs.map +0 -1
  55. /package/dist/{chunk-FWQRAZ5S.mjs.map → chunk-53C3S7R3.mjs.map} +0 -0
  56. /package/dist/{chunk-7XIE7UOW.mjs.map → chunk-73V4ZLAN.mjs.map} +0 -0
  57. /package/dist/{chunk-SHPG2T4O.mjs.map → chunk-AUCJZBT5.mjs.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CopilotModal
3
- } from "../../chunk-SHPG2T4O.mjs";
3
+ } from "../../chunk-AUCJZBT5.mjs";
4
4
  import "../../chunk-C3GSYRC3.mjs";
5
5
  import "../../chunk-GDSZGYCE.mjs";
6
6
  import "../../chunk-V7W6IM2V.mjs";
@@ -11,14 +11,14 @@ 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-WOYNUDPM.mjs";
15
15
  import "../../chunk-226ZMOE3.mjs";
16
16
  import "../../chunk-W26XFBEG.mjs";
17
17
  import "../../chunk-PLHTVHUW.mjs";
18
18
  import "../../chunk-DTRPPNSA.mjs";
19
19
  import "../../chunk-CGEAG65D.mjs";
20
20
  import "../../chunk-QIOJXTIQ.mjs";
21
- import "../../chunk-X5AO5A3L.mjs";
21
+ import "../../chunk-EELILZTD.mjs";
22
22
  import "../../chunk-YO63WHVQ.mjs";
23
23
  import "../../chunk-LJAYSRCB.mjs";
24
24
  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';
@@ -1872,12 +1872,14 @@ var Messages = ({
1872
1872
  RenderMessage: RenderMessage2,
1873
1873
  AssistantMessage: AssistantMessage2,
1874
1874
  UserMessage: UserMessage2,
1875
+ ErrorMessage,
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 && ErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ErrorMessage, { error: chatError, isCurrentMessage: true })
1942
1945
  ] }),
1943
1946
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("footer", { className: "copilotKitMessagesFooter", ref: messagesEndRef, children })
1944
1947
  ] });
@@ -2470,11 +2473,13 @@ function CopilotChat({
2470
2473
  AssistantMessage: AssistantMessage2 = AssistantMessage,
2471
2474
  UserMessage: UserMessage2 = UserMessage,
2472
2475
  ImageRenderer: ImageRenderer2 = ImageRenderer,
2476
+ ErrorMessage,
2473
2477
  imageUploadsEnabled,
2474
2478
  inputFileAccept = "image/*",
2475
2479
  hideStopButton,
2476
2480
  observabilityHooks,
2477
2481
  renderError,
2482
+ onError,
2478
2483
  // Legacy props - deprecated
2479
2484
  RenderTextMessage,
2480
2485
  RenderActionExecutionMessage,
@@ -2482,7 +2487,14 @@ function CopilotChat({
2482
2487
  RenderResultMessage,
2483
2488
  RenderImageMessage
2484
2489
  }) {
2485
- const { additionalInstructions, setChatInstructions, copilotApiConfig, setBannerError } = (0, import_react_core9.useCopilotContext)();
2490
+ const {
2491
+ additionalInstructions,
2492
+ setChatInstructions,
2493
+ copilotApiConfig,
2494
+ setBannerError,
2495
+ setInternalErrorHandler,
2496
+ removeInternalErrorHandler
2497
+ } = (0, import_react_core9.useCopilotContext)();
2486
2498
  const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
2487
2499
  const [selectedImages, setSelectedImages] = (0, import_react14.useState)([]);
2488
2500
  const [chatError, setChatError] = (0, import_react14.useState)(null);
@@ -2514,25 +2526,28 @@ function CopilotChat({
2514
2526
  operation,
2515
2527
  timestamp: Date.now()
2516
2528
  });
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
- }
2529
+ const errorEvent = {
2530
+ type: "error",
2531
+ timestamp: Date.now(),
2532
+ context: {
2533
+ source: "ui",
2534
+ request: {
2535
+ operation,
2536
+ url: chatApiEndpoint,
2537
+ startTime: Date.now()
2533
2538
  },
2534
- error
2535
- };
2539
+ technical: {
2540
+ environment: "browser",
2541
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
2542
+ stackTrace: originalError instanceof Error ? originalError.stack : void 0
2543
+ }
2544
+ },
2545
+ error
2546
+ };
2547
+ if (onError) {
2548
+ onError(errorEvent);
2549
+ }
2550
+ if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks.onError)) {
2536
2551
  observabilityHooks.onError(errorEvent);
2537
2552
  }
2538
2553
  if ((observabilityHooks == null ? void 0 : observabilityHooks.onError) && !publicApiKey) {
@@ -2549,6 +2564,19 @@ function CopilotChat({
2549
2564
  },
2550
2565
  [publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
2551
2566
  );
2567
+ (0, import_react14.useEffect)(() => {
2568
+ const id = "chat-component";
2569
+ setInternalErrorHandler({
2570
+ [id]: (error) => {
2571
+ if (!error)
2572
+ return;
2573
+ triggerChatError(error.error, "sendMessage");
2574
+ }
2575
+ });
2576
+ return () => {
2577
+ removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
2578
+ };
2579
+ }, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
2552
2580
  (0, import_react14.useEffect)(() => {
2553
2581
  if (!imageUploadsEnabled)
2554
2582
  return;
@@ -2726,6 +2754,8 @@ function CopilotChat({
2726
2754
  onThumbsDown: handleThumbsDown,
2727
2755
  markdownTagRenderers,
2728
2756
  ImageRenderer: ImageRenderer2,
2757
+ ErrorMessage,
2758
+ chatError,
2729
2759
  RenderTextMessage,
2730
2760
  RenderActionExecutionMessage,
2731
2761
  RenderAgentStateMessage,