@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,7 +1,7 @@
1
1
  import {
2
2
  CopilotSidebar
3
- } from "../../chunk-FWQRAZ5S.mjs";
4
- import "../../chunk-SHPG2T4O.mjs";
3
+ } from "../../chunk-53C3S7R3.mjs";
4
+ import "../../chunk-AUCJZBT5.mjs";
5
5
  import "../../chunk-C3GSYRC3.mjs";
6
6
  import "../../chunk-GDSZGYCE.mjs";
7
7
  import "../../chunk-V7W6IM2V.mjs";
@@ -12,14 +12,14 @@ import "../../chunk-KXE2JCUH.mjs";
12
12
  import "../../chunk-NRA3CFEE.mjs";
13
13
  import "../../chunk-BH6PCAAL.mjs";
14
14
  import "../../chunk-UFN2VWSR.mjs";
15
- import "../../chunk-EL7NCWNZ.mjs";
15
+ import "../../chunk-WOYNUDPM.mjs";
16
16
  import "../../chunk-226ZMOE3.mjs";
17
17
  import "../../chunk-W26XFBEG.mjs";
18
18
  import "../../chunk-PLHTVHUW.mjs";
19
19
  import "../../chunk-DTRPPNSA.mjs";
20
20
  import "../../chunk-CGEAG65D.mjs";
21
21
  import "../../chunk-QIOJXTIQ.mjs";
22
- import "../../chunk-X5AO5A3L.mjs";
22
+ import "../../chunk-EELILZTD.mjs";
23
23
  import "../../chunk-YO63WHVQ.mjs";
24
24
  import "../../chunk-LJAYSRCB.mjs";
25
25
  import "../../chunk-X477GDGZ.mjs";
@@ -1,4 +1,4 @@
1
- export { AssistantMessageProps, ButtonProps, ComponentsMap, CopilotObservabilityHooks, HeaderProps, ImageRendererProps, InputProps, MessagesProps, RenderMessageProps, RenderSuggestionsListProps, Renderer, SuggestionsProps, UserMessageProps, WindowProps } from './props.js';
1
+ export { AssistantMessageProps, ButtonProps, ChatError, ComponentsMap, CopilotObservabilityHooks, ErrorMessageProps, HeaderProps, ImageRendererProps, InputProps, MessagesProps, RenderMessageProps, RenderSuggestionsListProps, Renderer, SuggestionsProps, UserMessageProps, WindowProps } from './props.js';
2
2
  export { CopilotPopup } from './Popup.js';
3
3
  export { CopilotSidebar } from './Sidebar.js';
4
4
  export { CopilotChat } from './Chat.js';
@@ -16,7 +16,7 @@ import 'react/jsx-runtime';
16
16
  import './Modal.js';
17
17
  import '@copilotkit/react-core/dist/types/coagent-state';
18
18
  import '@copilotkit/react-core/dist/hooks/use-tree';
19
- import '@copilotkit/react-core/dist/copilot-context-256f9020';
19
+ import '@copilotkit/react-core/dist/copilot-context-59740e82';
20
20
  import '@copilotkit/react-core/dist/types/coagent-action';
21
21
  import '@copilotkit/react-core';
22
22
  import '@copilotkit/runtime-client-gql';
@@ -1881,12 +1881,14 @@ var Messages = ({
1881
1881
  RenderMessage: RenderMessage2,
1882
1882
  AssistantMessage: AssistantMessage2,
1883
1883
  UserMessage: UserMessage2,
1884
+ ErrorMessage,
1884
1885
  ImageRenderer: ImageRenderer2,
1885
1886
  onRegenerate,
1886
1887
  onCopy,
1887
1888
  onThumbsUp,
1888
1889
  onThumbsDown,
1889
1890
  markdownTagRenderers,
1891
+ chatError,
1890
1892
  // Legacy props
1891
1893
  RenderTextMessage,
1892
1894
  RenderActionExecutionMessage,
@@ -1947,7 +1949,8 @@ var Messages = ({
1947
1949
  index
1948
1950
  );
1949
1951
  }),
1950
- interrupt
1952
+ interrupt,
1953
+ chatError && ErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ErrorMessage, { error: chatError, isCurrentMessage: true })
1951
1954
  ] }),
1952
1955
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("footer", { className: "copilotKitMessagesFooter", ref: messagesEndRef, children })
1953
1956
  ] });
@@ -2479,11 +2482,13 @@ function CopilotChat({
2479
2482
  AssistantMessage: AssistantMessage2 = AssistantMessage,
2480
2483
  UserMessage: UserMessage2 = UserMessage,
2481
2484
  ImageRenderer: ImageRenderer2 = ImageRenderer,
2485
+ ErrorMessage,
2482
2486
  imageUploadsEnabled,
2483
2487
  inputFileAccept = "image/*",
2484
2488
  hideStopButton,
2485
2489
  observabilityHooks,
2486
2490
  renderError,
2491
+ onError,
2487
2492
  // Legacy props - deprecated
2488
2493
  RenderTextMessage,
2489
2494
  RenderActionExecutionMessage,
@@ -2491,7 +2496,14 @@ function CopilotChat({
2491
2496
  RenderResultMessage,
2492
2497
  RenderImageMessage
2493
2498
  }) {
2494
- const { additionalInstructions, setChatInstructions, copilotApiConfig, setBannerError } = (0, import_react_core9.useCopilotContext)();
2499
+ const {
2500
+ additionalInstructions,
2501
+ setChatInstructions,
2502
+ copilotApiConfig,
2503
+ setBannerError,
2504
+ setInternalErrorHandler,
2505
+ removeInternalErrorHandler
2506
+ } = (0, import_react_core9.useCopilotContext)();
2495
2507
  const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
2496
2508
  const [selectedImages, setSelectedImages] = (0, import_react14.useState)([]);
2497
2509
  const [chatError, setChatError] = (0, import_react14.useState)(null);
@@ -2523,25 +2535,28 @@ function CopilotChat({
2523
2535
  operation,
2524
2536
  timestamp: Date.now()
2525
2537
  });
2526
- if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks.onError)) {
2527
- const errorEvent = {
2528
- type: "error",
2529
- timestamp: Date.now(),
2530
- context: {
2531
- source: "ui",
2532
- request: {
2533
- operation,
2534
- url: chatApiEndpoint,
2535
- startTime: Date.now()
2536
- },
2537
- technical: {
2538
- environment: "browser",
2539
- userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
2540
- stackTrace: originalError instanceof Error ? originalError.stack : void 0
2541
- }
2538
+ const errorEvent = {
2539
+ type: "error",
2540
+ timestamp: Date.now(),
2541
+ context: {
2542
+ source: "ui",
2543
+ request: {
2544
+ operation,
2545
+ url: chatApiEndpoint,
2546
+ startTime: Date.now()
2542
2547
  },
2543
- error
2544
- };
2548
+ technical: {
2549
+ environment: "browser",
2550
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
2551
+ stackTrace: originalError instanceof Error ? originalError.stack : void 0
2552
+ }
2553
+ },
2554
+ error
2555
+ };
2556
+ if (onError) {
2557
+ onError(errorEvent);
2558
+ }
2559
+ if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks.onError)) {
2545
2560
  observabilityHooks.onError(errorEvent);
2546
2561
  }
2547
2562
  if ((observabilityHooks == null ? void 0 : observabilityHooks.onError) && !publicApiKey) {
@@ -2558,6 +2573,19 @@ function CopilotChat({
2558
2573
  },
2559
2574
  [publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
2560
2575
  );
2576
+ (0, import_react14.useEffect)(() => {
2577
+ const id = "chat-component";
2578
+ setInternalErrorHandler({
2579
+ [id]: (error) => {
2580
+ if (!error)
2581
+ return;
2582
+ triggerChatError(error.error, "sendMessage");
2583
+ }
2584
+ });
2585
+ return () => {
2586
+ removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
2587
+ };
2588
+ }, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
2561
2589
  (0, import_react14.useEffect)(() => {
2562
2590
  if (!imageUploadsEnabled)
2563
2591
  return;
@@ -2735,6 +2763,8 @@ function CopilotChat({
2735
2763
  onThumbsDown: handleThumbsDown,
2736
2764
  markdownTagRenderers,
2737
2765
  ImageRenderer: ImageRenderer2,
2766
+ ErrorMessage,
2767
+ chatError,
2738
2768
  RenderTextMessage,
2739
2769
  RenderActionExecutionMessage,
2740
2770
  RenderAgentStateMessage,