@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
@@ -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-53C3S7R3.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-73V4ZLAN.mjs";
10
+ import "../chunk-AUCJZBT5.mjs";
11
11
  import "../chunk-C3GSYRC3.mjs";
12
12
  import "../chunk-GDSZGYCE.mjs";
13
13
  import "../chunk-V7W6IM2V.mjs";
@@ -24,7 +24,7 @@ import "../chunk-BH6PCAAL.mjs";
24
24
  import "../chunk-UFN2VWSR.mjs";
25
25
  import {
26
26
  CopilotChat
27
- } from "../chunk-EL7NCWNZ.mjs";
27
+ } from "../chunk-WOYNUDPM.mjs";
28
28
  import {
29
29
  Suggestions
30
30
  } from "../chunk-226ZMOE3.mjs";
@@ -35,7 +35,7 @@ import "../chunk-PLHTVHUW.mjs";
35
35
  import "../chunk-DTRPPNSA.mjs";
36
36
  import "../chunk-CGEAG65D.mjs";
37
37
  import "../chunk-QIOJXTIQ.mjs";
38
- import "../chunk-X5AO5A3L.mjs";
38
+ import "../chunk-EELILZTD.mjs";
39
39
  import "../chunk-YO63WHVQ.mjs";
40
40
  import "../chunk-LJAYSRCB.mjs";
41
41
  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
@@ -1885,12 +1885,14 @@ var Messages = ({
1885
1885
  RenderMessage: RenderMessage2,
1886
1886
  AssistantMessage: AssistantMessage2,
1887
1887
  UserMessage: UserMessage2,
1888
+ ErrorMessage,
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 && ErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ErrorMessage, { error: chatError, isCurrentMessage: true })
1955
1958
  ] }),
1956
1959
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("footer", { className: "copilotKitMessagesFooter", ref: messagesEndRef, children })
1957
1960
  ] });
@@ -2483,11 +2486,13 @@ function CopilotChat({
2483
2486
  AssistantMessage: AssistantMessage2 = AssistantMessage,
2484
2487
  UserMessage: UserMessage2 = UserMessage,
2485
2488
  ImageRenderer: ImageRenderer2 = ImageRenderer,
2489
+ ErrorMessage,
2486
2490
  imageUploadsEnabled,
2487
2491
  inputFileAccept = "image/*",
2488
2492
  hideStopButton,
2489
2493
  observabilityHooks,
2490
2494
  renderError,
2495
+ onError,
2491
2496
  // Legacy props - deprecated
2492
2497
  RenderTextMessage,
2493
2498
  RenderActionExecutionMessage,
@@ -2495,7 +2500,14 @@ function CopilotChat({
2495
2500
  RenderResultMessage,
2496
2501
  RenderImageMessage
2497
2502
  }) {
2498
- const { additionalInstructions, setChatInstructions, copilotApiConfig, setBannerError } = (0, import_react_core9.useCopilotContext)();
2503
+ const {
2504
+ additionalInstructions,
2505
+ setChatInstructions,
2506
+ copilotApiConfig,
2507
+ setBannerError,
2508
+ setInternalErrorHandler,
2509
+ removeInternalErrorHandler
2510
+ } = (0, import_react_core9.useCopilotContext)();
2499
2511
  const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
2500
2512
  const [selectedImages, setSelectedImages] = (0, import_react14.useState)([]);
2501
2513
  const [chatError, setChatError] = (0, import_react14.useState)(null);
@@ -2527,25 +2539,28 @@ function CopilotChat({
2527
2539
  operation,
2528
2540
  timestamp: Date.now()
2529
2541
  });
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
- }
2542
+ const errorEvent = {
2543
+ type: "error",
2544
+ timestamp: Date.now(),
2545
+ context: {
2546
+ source: "ui",
2547
+ request: {
2548
+ operation,
2549
+ url: chatApiEndpoint,
2550
+ startTime: Date.now()
2546
2551
  },
2547
- error
2548
- };
2552
+ technical: {
2553
+ environment: "browser",
2554
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
2555
+ stackTrace: originalError instanceof Error ? originalError.stack : void 0
2556
+ }
2557
+ },
2558
+ error
2559
+ };
2560
+ if (onError) {
2561
+ onError(errorEvent);
2562
+ }
2563
+ if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks.onError)) {
2549
2564
  observabilityHooks.onError(errorEvent);
2550
2565
  }
2551
2566
  if ((observabilityHooks == null ? void 0 : observabilityHooks.onError) && !publicApiKey) {
@@ -2562,6 +2577,19 @@ function CopilotChat({
2562
2577
  },
2563
2578
  [publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
2564
2579
  );
2580
+ (0, import_react14.useEffect)(() => {
2581
+ const id = "chat-component";
2582
+ setInternalErrorHandler({
2583
+ [id]: (error) => {
2584
+ if (!error)
2585
+ return;
2586
+ triggerChatError(error.error, "sendMessage");
2587
+ }
2588
+ });
2589
+ return () => {
2590
+ removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
2591
+ };
2592
+ }, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
2565
2593
  (0, import_react14.useEffect)(() => {
2566
2594
  if (!imageUploadsEnabled)
2567
2595
  return;
@@ -2739,6 +2767,8 @@ function CopilotChat({
2739
2767
  onThumbsDown: handleThumbsDown,
2740
2768
  markdownTagRenderers,
2741
2769
  ImageRenderer: ImageRenderer2,
2770
+ ErrorMessage,
2771
+ chatError,
2742
2772
  RenderTextMessage,
2743
2773
  RenderActionExecutionMessage,
2744
2774
  RenderAgentStateMessage,