@copilotkit/react-ui 1.10.0-next.7 → 1.10.0-next.9

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 (52) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/{chunk-K344MVUT.mjs → chunk-2KG77MAY.mjs} +62 -8
  3. package/dist/chunk-2KG77MAY.mjs.map +1 -0
  4. package/dist/{chunk-EDWWF7QY.mjs → chunk-6C3YVF5W.mjs} +2 -2
  5. package/dist/{chunk-YH3DHANT.mjs → chunk-7K2X77PW.mjs} +25 -6
  6. package/dist/chunk-7K2X77PW.mjs.map +1 -0
  7. package/dist/{chunk-WBPBTTQD.mjs → chunk-FFJHOZX6.mjs} +4 -4
  8. package/dist/{chunk-V6DDX4LH.mjs → chunk-GDSZGYCE.mjs} +2 -2
  9. package/dist/{chunk-DSY4ZRMN.mjs → chunk-TW4LLLTE.mjs} +2 -2
  10. package/dist/components/chat/Chat.d.ts +23 -12
  11. package/dist/components/chat/Chat.js +61 -7
  12. package/dist/components/chat/Chat.js.map +1 -1
  13. package/dist/components/chat/Chat.mjs +1 -1
  14. package/dist/components/chat/Header.mjs +4 -4
  15. package/dist/components/chat/Modal.d.ts +1 -1
  16. package/dist/components/chat/Modal.js +77 -10
  17. package/dist/components/chat/Modal.js.map +1 -1
  18. package/dist/components/chat/Modal.mjs +6 -6
  19. package/dist/components/chat/Popup.d.ts +1 -1
  20. package/dist/components/chat/Popup.js +77 -10
  21. package/dist/components/chat/Popup.js.map +1 -1
  22. package/dist/components/chat/Popup.mjs +7 -7
  23. package/dist/components/chat/Sidebar.d.ts +1 -1
  24. package/dist/components/chat/Sidebar.js +77 -10
  25. package/dist/components/chat/Sidebar.js.map +1 -1
  26. package/dist/components/chat/Sidebar.mjs +7 -7
  27. package/dist/components/chat/index.d.ts +1 -1
  28. package/dist/components/chat/index.js +77 -10
  29. package/dist/components/chat/index.js.map +1 -1
  30. package/dist/components/chat/index.mjs +8 -8
  31. package/dist/components/chat/props.d.ts +6 -1
  32. package/dist/components/chat/props.js.map +1 -1
  33. package/dist/components/dev-console/console.mjs +3 -3
  34. package/dist/components/dev-console/index.mjs +4 -4
  35. package/dist/components/index.d.ts +1 -1
  36. package/dist/components/index.js +77 -10
  37. package/dist/components/index.js.map +1 -1
  38. package/dist/components/index.mjs +9 -9
  39. package/dist/index.d.ts +1 -1
  40. package/dist/index.js +79 -12
  41. package/dist/index.js.map +1 -1
  42. package/dist/index.mjs +9 -9
  43. package/package.json +4 -4
  44. package/src/components/chat/Chat.tsx +95 -7
  45. package/src/components/chat/Modal.tsx +24 -3
  46. package/src/components/chat/props.ts +7 -1
  47. package/dist/chunk-K344MVUT.mjs.map +0 -1
  48. package/dist/chunk-YH3DHANT.mjs.map +0 -1
  49. /package/dist/{chunk-EDWWF7QY.mjs.map → chunk-6C3YVF5W.mjs.map} +0 -0
  50. /package/dist/{chunk-WBPBTTQD.mjs.map → chunk-FFJHOZX6.mjs.map} +0 -0
  51. /package/dist/{chunk-V6DDX4LH.mjs.map → chunk-GDSZGYCE.mjs.map} +0 -0
  52. /package/dist/{chunk-DSY4ZRMN.mjs.map → chunk-TW4LLLTE.mjs.map} +0 -0
@@ -1,25 +1,25 @@
1
1
  import "../../chunk-SC6JRFAJ.mjs";
2
2
  import {
3
3
  CopilotSidebar
4
- } from "../../chunk-DSY4ZRMN.mjs";
4
+ } from "../../chunk-TW4LLLTE.mjs";
5
5
  import "../../chunk-WB3YULQ4.mjs";
6
6
  import {
7
7
  CopilotPopup
8
- } from "../../chunk-EDWWF7QY.mjs";
9
- import "../../chunk-YH3DHANT.mjs";
8
+ } from "../../chunk-6C3YVF5W.mjs";
9
+ import "../../chunk-7K2X77PW.mjs";
10
10
  import "../../chunk-C3GSYRC3.mjs";
11
- import "../../chunk-V6DDX4LH.mjs";
11
+ import "../../chunk-GDSZGYCE.mjs";
12
12
  import "../../chunk-V7W6IM2V.mjs";
13
- import "../../chunk-WBPBTTQD.mjs";
13
+ import "../../chunk-FFJHOZX6.mjs";
14
+ import "../../chunk-Q5V6S67N.mjs";
15
+ import "../../chunk-JY2CSDKN.mjs";
14
16
  import "../../chunk-KXE2JCUH.mjs";
15
17
  import "../../chunk-NRA3CFEE.mjs";
16
18
  import "../../chunk-BH6PCAAL.mjs";
17
- import "../../chunk-Q5V6S67N.mjs";
18
- import "../../chunk-JY2CSDKN.mjs";
19
19
  import "../../chunk-UFN2VWSR.mjs";
20
20
  import {
21
21
  CopilotChat
22
- } from "../../chunk-K344MVUT.mjs";
22
+ } from "../../chunk-2KG77MAY.mjs";
23
23
  import "../../chunk-JHUTTP5C.mjs";
24
24
  import {
25
25
  AssistantMessage
@@ -1,4 +1,4 @@
1
- import { Message, UserMessage, AIMessage, ImageData } from '@copilotkit/shared';
1
+ import { CopilotErrorEvent, Message, UserMessage, AIMessage, ImageData } from '@copilotkit/shared';
2
2
  import { CopilotChatSuggestion } from '../../types/suggestions.js';
3
3
  import { ReactNode } from 'react';
4
4
 
@@ -39,6 +39,11 @@ interface CopilotObservabilityHooks {
39
39
  * Called when chat generation stops
40
40
  */
41
41
  onChatStopped?: () => void;
42
+ /**
43
+ * Called when an error occurs in the chat
44
+ * This enables chat-specific error handling UX while preserving system-wide error monitoring
45
+ */
46
+ onError?: (errorEvent: CopilotErrorEvent) => void;
42
47
  }
43
48
  interface ButtonProps {
44
49
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/chat/props.ts"],"sourcesContent":["import { AIMessage, Message, UserMessage } from \"@copilotkit/shared\";\nimport { CopilotChatSuggestion } from \"../../types/suggestions\";\nimport { ReactNode } from \"react\";\nimport { ImageData } from \"@copilotkit/shared\";\n\n/**\n * Event hooks for CopilotKit chat events.\n * These hooks only work when publicApiKey is provided.\n */\nexport interface CopilotObservabilityHooks {\n /**\n * Called when a message is sent by the user\n */\n onMessageSent?: (message: string) => void;\n\n /**\n * Called when the chat is minimized/closed\n */\n onChatMinimized?: () => void;\n\n /**\n * Called when the chat is expanded/opened\n */\n onChatExpanded?: () => void;\n\n /**\n * Called when a message is regenerated\n */\n onMessageRegenerated?: (messageId: string) => void;\n\n /**\n * Called when a message is copied\n */\n onMessageCopied?: (content: string) => void;\n\n /**\n * Called when feedback is given (thumbs up/down)\n */\n onFeedbackGiven?: (messageId: string, type: \"thumbsUp\" | \"thumbsDown\") => void;\n\n /**\n * Called when chat generation starts\n */\n onChatStarted?: () => void;\n\n /**\n * Called when chat generation stops\n */\n onChatStopped?: () => void;\n}\n\nexport interface ButtonProps {}\n\nexport interface WindowProps {\n clickOutsideToClose: boolean;\n hitEscapeToClose: boolean;\n shortcut: string;\n children?: React.ReactNode;\n}\n\nexport interface HeaderProps {}\n\nexport interface SuggestionsProps {\n title: string;\n message: string;\n partial?: boolean;\n className?: string;\n onClick: (message: string) => void;\n}\n\nexport type ComponentsMap<T extends Record<string, object> = Record<string, object>> = {\n [K in keyof T]: React.FC<{ children?: ReactNode } & T[K]>;\n};\n\nexport interface MessagesProps {\n messages: Message[];\n inProgress: boolean;\n children?: React.ReactNode;\n AssistantMessage: React.ComponentType<AssistantMessageProps>;\n UserMessage: React.ComponentType<UserMessageProps>;\n RenderMessage: React.ComponentType<RenderMessageProps>;\n ImageRenderer: React.ComponentType<ImageRendererProps>;\n\n /**\n * Callback function to regenerate the assistant's response\n */\n onRegenerate?: (messageId: string) => void;\n\n /**\n * Callback function when the message is copied\n */\n onCopy?: (message: string) => void;\n\n /**\n * Callback function for thumbs up feedback\n */\n onThumbsUp?: (message: Message) => void;\n\n /**\n * Callback function for thumbs down feedback\n */\n onThumbsDown?: (message: Message) => void;\n\n /**\n * A list of markdown components to render in assistant message.\n * Useful when you want to render custom elements in the message (e.g a reference tag element)\n */\n markdownTagRenderers?: ComponentsMap;\n}\n\nexport interface Renderer {\n content: string;\n}\n\nexport interface UserMessageProps {\n message?: UserMessage;\n ImageRenderer: React.ComponentType<ImageRendererProps>;\n}\n\nexport interface AssistantMessageProps {\n /**\n * The message content from the assistant\n */\n\n message?: AIMessage;\n\n /**\n * Indicates if this is the last message\n */\n isCurrentMessage?: boolean;\n\n /**\n * Whether a response is loading, this is when the LLM is thinking of a response but hasn't finished yet.\n */\n isLoading: boolean;\n\n /**\n * Whether a response is generating, this is when the LLM is actively generating and streaming content.\n */\n isGenerating: boolean;\n\n /**\n * Callback function to regenerate the assistant's response\n */\n onRegenerate?: () => void;\n\n /**\n * Callback function when the message is copied\n */\n onCopy?: (message: string) => void;\n\n /**\n * Callback function for thumbs up feedback\n */\n onThumbsUp?: (message: Message) => void;\n\n /**\n * Callback function for thumbs down feedback\n */\n onThumbsDown?: (message: Message) => void;\n\n /**\n * A list of markdown components to render in assistant message.\n * Useful when you want to render custom elements in the message (e.g a reference tag element)\n */\n markdownTagRenderers?: ComponentsMap;\n\n /**\n * A custom image rendering component to use instead of the default.\n */\n ImageRenderer?: React.ComponentType<ImageRendererProps>;\n}\n\nexport interface RenderMessageProps {\n message: Message;\n inProgress: boolean;\n index: number;\n isCurrentMessage: boolean;\n actionResult?: string;\n AssistantMessage?: React.ComponentType<AssistantMessageProps>;\n UserMessage?: React.ComponentType<UserMessageProps>;\n ImageRenderer?: React.ComponentType<ImageRendererProps>;\n\n /**\n * Callback function to regenerate the assistant's response\n */\n onRegenerate?: (messageId: string) => void;\n\n /**\n * Callback function when the message is copied\n */\n onCopy?: (message: string) => void;\n\n /**\n * Callback function for thumbs up feedback\n */\n onThumbsUp?: (message: Message) => void;\n\n /**\n * Callback function for thumbs down feedback\n */\n onThumbsDown?: (message: Message) => void;\n\n /**\n * A list of markdown components to render in assistant message.\n * Useful when you want to render custom elements in the message (e.g a reference tag element)\n */\n markdownTagRenderers?: ComponentsMap;\n}\n\nexport interface InputProps {\n inProgress: boolean;\n onSend: (text: string) => Promise<Message>;\n isVisible?: boolean;\n onStop?: () => void;\n onUpload?: () => void;\n hideStopButton?: boolean;\n}\n\nexport interface RenderSuggestionsListProps {\n suggestions: CopilotChatSuggestion[];\n onSuggestionClick: (message: string) => void;\n}\n\nexport interface ImageRendererProps {\n /**\n * The image data containing format and bytes\n */\n image: ImageData;\n\n /**\n * Optional content to display alongside the image\n */\n content?: string;\n\n /**\n * Additional CSS class name for styling\n */\n className?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../../src/components/chat/props.ts"],"sourcesContent":["import { AIMessage, Message, UserMessage, CopilotErrorEvent } from \"@copilotkit/shared\";\nimport { CopilotChatSuggestion } from \"../../types/suggestions\";\nimport { ReactNode } from \"react\";\nimport { ImageData } from \"@copilotkit/shared\";\n\n/**\n * Event hooks for CopilotKit chat events.\n * These hooks only work when publicApiKey is provided.\n */\nexport interface CopilotObservabilityHooks {\n /**\n * Called when a message is sent by the user\n */\n onMessageSent?: (message: string) => void;\n\n /**\n * Called when the chat is minimized/closed\n */\n onChatMinimized?: () => void;\n\n /**\n * Called when the chat is expanded/opened\n */\n onChatExpanded?: () => void;\n\n /**\n * Called when a message is regenerated\n */\n onMessageRegenerated?: (messageId: string) => void;\n\n /**\n * Called when a message is copied\n */\n onMessageCopied?: (content: string) => void;\n\n /**\n * Called when feedback is given (thumbs up/down)\n */\n onFeedbackGiven?: (messageId: string, type: \"thumbsUp\" | \"thumbsDown\") => void;\n\n /**\n * Called when chat generation starts\n */\n onChatStarted?: () => void;\n\n /**\n * Called when chat generation stops\n */\n onChatStopped?: () => void;\n\n /**\n * Called when an error occurs in the chat\n * This enables chat-specific error handling UX while preserving system-wide error monitoring\n */\n onError?: (errorEvent: CopilotErrorEvent) => void;\n}\n\nexport interface ButtonProps {}\n\nexport interface WindowProps {\n clickOutsideToClose: boolean;\n hitEscapeToClose: boolean;\n shortcut: string;\n children?: React.ReactNode;\n}\n\nexport interface HeaderProps {}\n\nexport interface SuggestionsProps {\n title: string;\n message: string;\n partial?: boolean;\n className?: string;\n onClick: (message: string) => void;\n}\n\nexport type ComponentsMap<T extends Record<string, object> = Record<string, object>> = {\n [K in keyof T]: React.FC<{ children?: ReactNode } & T[K]>;\n};\n\nexport interface MessagesProps {\n messages: Message[];\n inProgress: boolean;\n children?: React.ReactNode;\n AssistantMessage: React.ComponentType<AssistantMessageProps>;\n UserMessage: React.ComponentType<UserMessageProps>;\n RenderMessage: React.ComponentType<RenderMessageProps>;\n ImageRenderer: React.ComponentType<ImageRendererProps>;\n\n /**\n * Callback function to regenerate the assistant's response\n */\n onRegenerate?: (messageId: string) => void;\n\n /**\n * Callback function when the message is copied\n */\n onCopy?: (message: string) => void;\n\n /**\n * Callback function for thumbs up feedback\n */\n onThumbsUp?: (message: Message) => void;\n\n /**\n * Callback function for thumbs down feedback\n */\n onThumbsDown?: (message: Message) => void;\n\n /**\n * A list of markdown components to render in assistant message.\n * Useful when you want to render custom elements in the message (e.g a reference tag element)\n */\n markdownTagRenderers?: ComponentsMap;\n}\n\nexport interface Renderer {\n content: string;\n}\n\nexport interface UserMessageProps {\n message?: UserMessage;\n ImageRenderer: React.ComponentType<ImageRendererProps>;\n}\n\nexport interface AssistantMessageProps {\n /**\n * The message content from the assistant\n */\n\n message?: AIMessage;\n\n /**\n * Indicates if this is the last message\n */\n isCurrentMessage?: boolean;\n\n /**\n * Whether a response is loading, this is when the LLM is thinking of a response but hasn't finished yet.\n */\n isLoading: boolean;\n\n /**\n * Whether a response is generating, this is when the LLM is actively generating and streaming content.\n */\n isGenerating: boolean;\n\n /**\n * Callback function to regenerate the assistant's response\n */\n onRegenerate?: () => void;\n\n /**\n * Callback function when the message is copied\n */\n onCopy?: (message: string) => void;\n\n /**\n * Callback function for thumbs up feedback\n */\n onThumbsUp?: (message: Message) => void;\n\n /**\n * Callback function for thumbs down feedback\n */\n onThumbsDown?: (message: Message) => void;\n\n /**\n * A list of markdown components to render in assistant message.\n * Useful when you want to render custom elements in the message (e.g a reference tag element)\n */\n markdownTagRenderers?: ComponentsMap;\n\n /**\n * A custom image rendering component to use instead of the default.\n */\n ImageRenderer?: React.ComponentType<ImageRendererProps>;\n}\n\nexport interface RenderMessageProps {\n message: Message;\n inProgress: boolean;\n index: number;\n isCurrentMessage: boolean;\n actionResult?: string;\n AssistantMessage?: React.ComponentType<AssistantMessageProps>;\n UserMessage?: React.ComponentType<UserMessageProps>;\n ImageRenderer?: React.ComponentType<ImageRendererProps>;\n\n /**\n * Callback function to regenerate the assistant's response\n */\n onRegenerate?: (messageId: string) => void;\n\n /**\n * Callback function when the message is copied\n */\n onCopy?: (message: string) => void;\n\n /**\n * Callback function for thumbs up feedback\n */\n onThumbsUp?: (message: Message) => void;\n\n /**\n * Callback function for thumbs down feedback\n */\n onThumbsDown?: (message: Message) => void;\n\n /**\n * A list of markdown components to render in assistant message.\n * Useful when you want to render custom elements in the message (e.g a reference tag element)\n */\n markdownTagRenderers?: ComponentsMap;\n}\n\nexport interface InputProps {\n inProgress: boolean;\n onSend: (text: string) => Promise<Message>;\n isVisible?: boolean;\n onStop?: () => void;\n onUpload?: () => void;\n hideStopButton?: boolean;\n}\n\nexport interface RenderSuggestionsListProps {\n suggestions: CopilotChatSuggestion[];\n onSuggestionClick: (message: string) => void;\n}\n\nexport interface ImageRendererProps {\n /**\n * The image data containing format and bytes\n */\n image: ImageData;\n\n /**\n * Optional content to display alongside the image\n */\n content?: string;\n\n /**\n * Additional CSS class name for styling\n */\n className?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -2,12 +2,12 @@
2
2
  import {
3
3
  CopilotDevConsole,
4
4
  DebugMenuButton
5
- } from "../../chunk-WBPBTTQD.mjs";
5
+ } from "../../chunk-FFJHOZX6.mjs";
6
+ import "../../chunk-Q5V6S67N.mjs";
7
+ import "../../chunk-JY2CSDKN.mjs";
6
8
  import "../../chunk-KXE2JCUH.mjs";
7
9
  import "../../chunk-NRA3CFEE.mjs";
8
10
  import "../../chunk-BH6PCAAL.mjs";
9
- import "../../chunk-Q5V6S67N.mjs";
10
- import "../../chunk-JY2CSDKN.mjs";
11
11
  import "../../chunk-XWG3L6QC.mjs";
12
12
  import "../../chunk-MRXNTQOX.mjs";
13
13
  export {
@@ -1,14 +1,14 @@
1
1
  import "../../chunk-V7W6IM2V.mjs";
2
2
  import {
3
3
  CopilotDevConsole
4
- } from "../../chunk-WBPBTTQD.mjs";
5
- import "../../chunk-KXE2JCUH.mjs";
6
- import "../../chunk-NRA3CFEE.mjs";
7
- import "../../chunk-BH6PCAAL.mjs";
4
+ } from "../../chunk-FFJHOZX6.mjs";
8
5
  import "../../chunk-Q5V6S67N.mjs";
9
6
  import {
10
7
  shouldShowDevConsole
11
8
  } from "../../chunk-JY2CSDKN.mjs";
9
+ import "../../chunk-KXE2JCUH.mjs";
10
+ import "../../chunk-NRA3CFEE.mjs";
11
+ import "../../chunk-BH6PCAAL.mjs";
12
12
  import "../../chunk-XWG3L6QC.mjs";
13
13
  import "../../chunk-MRXNTQOX.mjs";
14
14
  export {
@@ -18,7 +18,7 @@ import 'react/jsx-runtime';
18
18
  import './chat/Modal.js';
19
19
  import '@copilotkit/react-core/dist/types/coagent-state';
20
20
  import '@copilotkit/react-core/dist/hooks/use-tree';
21
- import '@copilotkit/react-core/dist/copilot-context-78fc727c';
21
+ import '@copilotkit/react-core/dist/copilot-context-256f9020';
22
22
  import '@copilotkit/react-core/dist/types/coagent-action';
23
23
  import '@copilotkit/runtime-client-gql';
24
24
  import 'react-markdown';
@@ -2326,17 +2326,20 @@ function CopilotChat({
2326
2326
  imageUploadsEnabled,
2327
2327
  inputFileAccept = "image/*",
2328
2328
  hideStopButton,
2329
- observabilityHooks
2329
+ observabilityHooks,
2330
+ renderError
2330
2331
  }) {
2331
2332
  const { additionalInstructions, setChatInstructions, copilotApiConfig, setBannerError } = (0, import_react_core9.useCopilotContext)();
2333
+ const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
2332
2334
  const [selectedImages, setSelectedImages] = (0, import_react14.useState)([]);
2335
+ const [chatError, setChatError] = (0, import_react14.useState)(null);
2333
2336
  const fileInputRef = (0, import_react14.useRef)(null);
2334
2337
  const triggerObservabilityHook = (0, import_react14.useCallback)(
2335
2338
  (hookName, ...args) => {
2336
- if (copilotApiConfig.publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
2339
+ if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
2337
2340
  observabilityHooks[hookName](...args);
2338
2341
  }
2339
- if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !copilotApiConfig.publicApiKey) {
2342
+ if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !publicApiKey) {
2340
2343
  setBannerError(
2341
2344
  new import_shared3.CopilotKitError({
2342
2345
  message: "observabilityHooks requires a publicApiKey to function.",
@@ -2348,7 +2351,50 @@ function CopilotChat({
2348
2351
  import_shared3.styledConsole.publicApiKeyRequired("observabilityHooks");
2349
2352
  }
2350
2353
  },
2351
- [copilotApiConfig.publicApiKey, observabilityHooks]
2354
+ [publicApiKey, observabilityHooks, setBannerError]
2355
+ );
2356
+ const triggerChatError = (0, import_react14.useCallback)(
2357
+ (error, operation, originalError) => {
2358
+ const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
2359
+ setChatError({
2360
+ message: errorMessage,
2361
+ operation,
2362
+ timestamp: Date.now()
2363
+ });
2364
+ if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks.onError)) {
2365
+ const errorEvent = {
2366
+ type: "error",
2367
+ timestamp: Date.now(),
2368
+ context: {
2369
+ source: "ui",
2370
+ request: {
2371
+ operation,
2372
+ url: chatApiEndpoint,
2373
+ startTime: Date.now()
2374
+ },
2375
+ technical: {
2376
+ environment: "browser",
2377
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
2378
+ stackTrace: originalError instanceof Error ? originalError.stack : void 0
2379
+ }
2380
+ },
2381
+ error
2382
+ };
2383
+ observabilityHooks.onError(errorEvent);
2384
+ }
2385
+ if ((observabilityHooks == null ? void 0 : observabilityHooks.onError) && !publicApiKey) {
2386
+ setBannerError(
2387
+ new import_shared3.CopilotKitError({
2388
+ message: "observabilityHooks.onError requires a publicApiKey to function.",
2389
+ code: import_shared3.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
2390
+ severity: import_shared3.Severity.CRITICAL,
2391
+ visibility: import_shared3.ErrorVisibility.BANNER
2392
+ })
2393
+ );
2394
+ import_shared3.styledConsole.publicApiKeyRequired("observabilityHooks.onError");
2395
+ }
2396
+ },
2397
+ [publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
2352
2398
  );
2353
2399
  (0, import_react14.useEffect)(() => {
2354
2400
  if (!imageUploadsEnabled)
@@ -2389,12 +2435,13 @@ function CopilotChat({
2389
2435
  const loadedImages = (yield Promise.all(imagePromises)).filter((img) => img !== null);
2390
2436
  setSelectedImages((prev) => [...prev, ...loadedImages]);
2391
2437
  } catch (error) {
2438
+ triggerChatError(error, "processClipboardImages", error);
2392
2439
  console.error("Error processing pasted images:", error);
2393
2440
  }
2394
2441
  });
2395
2442
  document.addEventListener("paste", handlePaste);
2396
2443
  return () => document.removeEventListener("paste", handlePaste);
2397
- }, [imageUploadsEnabled]);
2444
+ }, [imageUploadsEnabled, triggerChatError]);
2398
2445
  (0, import_react14.useEffect)(() => {
2399
2446
  if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
2400
2447
  setChatInstructions(instructions || "");
@@ -2485,6 +2532,7 @@ function CopilotChat({
2485
2532
  const loadedImages = yield Promise.all(fileReadPromises);
2486
2533
  setSelectedImages((prev) => [...prev, ...loadedImages]);
2487
2534
  } catch (error) {
2535
+ triggerChatError(error, "processUploadedImages", error);
2488
2536
  console.error("Error reading files:", error);
2489
2537
  }
2490
2538
  });
@@ -2504,6 +2552,12 @@ function CopilotChat({
2504
2552
  triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsDown");
2505
2553
  };
2506
2554
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
2555
+ chatError && renderError && renderError(__spreadProps(__spreadValues({}, chatError), {
2556
+ onDismiss: () => setChatError(null),
2557
+ onRetry: () => {
2558
+ setChatError(null);
2559
+ }
2560
+ })),
2507
2561
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2508
2562
  Messages2,
2509
2563
  {
@@ -2735,9 +2789,9 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
2735
2789
  yield (0, import_react_core10.runAgent)(
2736
2790
  generalContext.agentSession.agentName,
2737
2791
  stableContext,
2792
+ messagesContext.messages,
2738
2793
  appendMessage,
2739
- runChatCompletion,
2740
- hint
2794
+ runChatCompletion
2741
2795
  );
2742
2796
  }
2743
2797
  });
@@ -2807,6 +2861,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
2807
2861
 
2808
2862
  // src/components/chat/Modal.tsx
2809
2863
  var import_react_core11 = require("@copilotkit/react-core");
2864
+ var import_shared5 = require("@copilotkit/shared");
2810
2865
  var import_jsx_runtime24 = require("react/jsx-runtime");
2811
2866
  var CopilotModalInner = (_a) => {
2812
2867
  var _b = _a, {
@@ -2832,14 +2887,26 @@ var CopilotModalInner = (_a) => {
2832
2887
  "Button",
2833
2888
  "Header"
2834
2889
  ]);
2835
- const { copilotApiConfig } = (0, import_react_core11.useCopilotContext)();
2890
+ const { copilotApiConfig, setBannerError } = (0, import_react_core11.useCopilotContext)();
2891
+ const { publicApiKey } = copilotApiConfig;
2836
2892
  const triggerObservabilityHook = (0, import_react15.useCallback)(
2837
2893
  (hookName, ...args) => {
2838
- if (copilotApiConfig.publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
2894
+ if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
2839
2895
  observabilityHooks[hookName](...args);
2840
2896
  }
2897
+ if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !publicApiKey) {
2898
+ setBannerError(
2899
+ new import_shared5.CopilotKitError({
2900
+ message: "observabilityHooks requires a publicApiKey to function.",
2901
+ code: import_shared5.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
2902
+ severity: import_shared5.Severity.CRITICAL,
2903
+ visibility: import_shared5.ErrorVisibility.BANNER
2904
+ })
2905
+ );
2906
+ import_shared5.styledConsole.publicApiKeyRequired("observabilityHooks");
2907
+ }
2841
2908
  },
2842
- [copilotApiConfig.publicApiKey, observabilityHooks]
2909
+ [publicApiKey, observabilityHooks, setBannerError]
2843
2910
  );
2844
2911
  const { open } = useChatContext();
2845
2912
  const prevOpen = (0, import_react15.useRef)(open);