@copilotkit/react-ui 1.10.0-next.8 → 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.
- package/CHANGELOG.md +14 -0
- package/dist/{chunk-3DVMCBME.mjs → chunk-2KG77MAY.mjs} +61 -8
- package/dist/chunk-2KG77MAY.mjs.map +1 -0
- package/dist/{chunk-APLX7E54.mjs → chunk-6C3YVF5W.mjs} +2 -2
- package/dist/{chunk-BPU3FDT4.mjs → chunk-7K2X77PW.mjs} +24 -5
- package/dist/chunk-7K2X77PW.mjs.map +1 -0
- package/dist/{chunk-KLV4ERV6.mjs → chunk-TW4LLLTE.mjs} +2 -2
- package/dist/components/chat/Chat.d.ts +12 -1
- package/dist/components/chat/Chat.js +60 -7
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +1 -1
- package/dist/components/chat/Modal.js +76 -10
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +2 -2
- package/dist/components/chat/Popup.js +76 -10
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +3 -3
- package/dist/components/chat/Sidebar.js +76 -10
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +3 -3
- package/dist/components/chat/index.js +76 -10
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +4 -4
- package/dist/components/chat/props.d.ts +6 -1
- package/dist/components/chat/props.js.map +1 -1
- package/dist/components/index.js +76 -10
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +4 -4
- package/dist/index.js +78 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/package.json +4 -4
- package/src/components/chat/Chat.tsx +94 -7
- package/src/components/chat/Modal.tsx +24 -3
- package/src/components/chat/props.ts +7 -1
- package/dist/chunk-3DVMCBME.mjs.map +0 -1
- package/dist/chunk-BPU3FDT4.mjs.map +0 -1
- /package/dist/{chunk-APLX7E54.mjs.map → chunk-6C3YVF5W.mjs.map} +0 -0
- /package/dist/{chunk-KLV4ERV6.mjs.map → chunk-TW4LLLTE.mjs.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotPopup
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-6C3YVF5W.mjs";
|
|
4
|
+
import "../../chunk-7K2X77PW.mjs";
|
|
5
5
|
import "../../chunk-C3GSYRC3.mjs";
|
|
6
6
|
import "../../chunk-GDSZGYCE.mjs";
|
|
7
7
|
import "../../chunk-V7W6IM2V.mjs";
|
|
@@ -12,7 +12,7 @@ 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-
|
|
15
|
+
import "../../chunk-2KG77MAY.mjs";
|
|
16
16
|
import "../../chunk-JHUTTP5C.mjs";
|
|
17
17
|
import "../../chunk-GCKKSSBU.mjs";
|
|
18
18
|
import "../../chunk-DBKRAOH7.mjs";
|
|
@@ -2316,17 +2316,20 @@ function CopilotChat({
|
|
|
2316
2316
|
imageUploadsEnabled,
|
|
2317
2317
|
inputFileAccept = "image/*",
|
|
2318
2318
|
hideStopButton,
|
|
2319
|
-
observabilityHooks
|
|
2319
|
+
observabilityHooks,
|
|
2320
|
+
renderError
|
|
2320
2321
|
}) {
|
|
2321
2322
|
const { additionalInstructions, setChatInstructions, copilotApiConfig, setBannerError } = (0, import_react_core9.useCopilotContext)();
|
|
2323
|
+
const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
|
|
2322
2324
|
const [selectedImages, setSelectedImages] = (0, import_react14.useState)([]);
|
|
2325
|
+
const [chatError, setChatError] = (0, import_react14.useState)(null);
|
|
2323
2326
|
const fileInputRef = (0, import_react14.useRef)(null);
|
|
2324
2327
|
const triggerObservabilityHook = (0, import_react14.useCallback)(
|
|
2325
2328
|
(hookName, ...args) => {
|
|
2326
|
-
if (
|
|
2329
|
+
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2327
2330
|
observabilityHooks[hookName](...args);
|
|
2328
2331
|
}
|
|
2329
|
-
if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !
|
|
2332
|
+
if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !publicApiKey) {
|
|
2330
2333
|
setBannerError(
|
|
2331
2334
|
new import_shared3.CopilotKitError({
|
|
2332
2335
|
message: "observabilityHooks requires a publicApiKey to function.",
|
|
@@ -2338,7 +2341,50 @@ function CopilotChat({
|
|
|
2338
2341
|
import_shared3.styledConsole.publicApiKeyRequired("observabilityHooks");
|
|
2339
2342
|
}
|
|
2340
2343
|
},
|
|
2341
|
-
[
|
|
2344
|
+
[publicApiKey, observabilityHooks, setBannerError]
|
|
2345
|
+
);
|
|
2346
|
+
const triggerChatError = (0, import_react14.useCallback)(
|
|
2347
|
+
(error, operation, originalError) => {
|
|
2348
|
+
const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
|
|
2349
|
+
setChatError({
|
|
2350
|
+
message: errorMessage,
|
|
2351
|
+
operation,
|
|
2352
|
+
timestamp: Date.now()
|
|
2353
|
+
});
|
|
2354
|
+
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks.onError)) {
|
|
2355
|
+
const errorEvent = {
|
|
2356
|
+
type: "error",
|
|
2357
|
+
timestamp: Date.now(),
|
|
2358
|
+
context: {
|
|
2359
|
+
source: "ui",
|
|
2360
|
+
request: {
|
|
2361
|
+
operation,
|
|
2362
|
+
url: chatApiEndpoint,
|
|
2363
|
+
startTime: Date.now()
|
|
2364
|
+
},
|
|
2365
|
+
technical: {
|
|
2366
|
+
environment: "browser",
|
|
2367
|
+
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
|
|
2368
|
+
stackTrace: originalError instanceof Error ? originalError.stack : void 0
|
|
2369
|
+
}
|
|
2370
|
+
},
|
|
2371
|
+
error
|
|
2372
|
+
};
|
|
2373
|
+
observabilityHooks.onError(errorEvent);
|
|
2374
|
+
}
|
|
2375
|
+
if ((observabilityHooks == null ? void 0 : observabilityHooks.onError) && !publicApiKey) {
|
|
2376
|
+
setBannerError(
|
|
2377
|
+
new import_shared3.CopilotKitError({
|
|
2378
|
+
message: "observabilityHooks.onError requires a publicApiKey to function.",
|
|
2379
|
+
code: import_shared3.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
|
|
2380
|
+
severity: import_shared3.Severity.CRITICAL,
|
|
2381
|
+
visibility: import_shared3.ErrorVisibility.BANNER
|
|
2382
|
+
})
|
|
2383
|
+
);
|
|
2384
|
+
import_shared3.styledConsole.publicApiKeyRequired("observabilityHooks.onError");
|
|
2385
|
+
}
|
|
2386
|
+
},
|
|
2387
|
+
[publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
|
|
2342
2388
|
);
|
|
2343
2389
|
(0, import_react14.useEffect)(() => {
|
|
2344
2390
|
if (!imageUploadsEnabled)
|
|
@@ -2379,12 +2425,13 @@ function CopilotChat({
|
|
|
2379
2425
|
const loadedImages = (yield Promise.all(imagePromises)).filter((img) => img !== null);
|
|
2380
2426
|
setSelectedImages((prev) => [...prev, ...loadedImages]);
|
|
2381
2427
|
} catch (error) {
|
|
2428
|
+
triggerChatError(error, "processClipboardImages", error);
|
|
2382
2429
|
console.error("Error processing pasted images:", error);
|
|
2383
2430
|
}
|
|
2384
2431
|
});
|
|
2385
2432
|
document.addEventListener("paste", handlePaste);
|
|
2386
2433
|
return () => document.removeEventListener("paste", handlePaste);
|
|
2387
|
-
}, [imageUploadsEnabled]);
|
|
2434
|
+
}, [imageUploadsEnabled, triggerChatError]);
|
|
2388
2435
|
(0, import_react14.useEffect)(() => {
|
|
2389
2436
|
if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
|
|
2390
2437
|
setChatInstructions(instructions || "");
|
|
@@ -2475,6 +2522,7 @@ function CopilotChat({
|
|
|
2475
2522
|
const loadedImages = yield Promise.all(fileReadPromises);
|
|
2476
2523
|
setSelectedImages((prev) => [...prev, ...loadedImages]);
|
|
2477
2524
|
} catch (error) {
|
|
2525
|
+
triggerChatError(error, "processUploadedImages", error);
|
|
2478
2526
|
console.error("Error reading files:", error);
|
|
2479
2527
|
}
|
|
2480
2528
|
});
|
|
@@ -2494,6 +2542,12 @@ function CopilotChat({
|
|
|
2494
2542
|
triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsDown");
|
|
2495
2543
|
};
|
|
2496
2544
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
2545
|
+
chatError && renderError && renderError(__spreadProps(__spreadValues({}, chatError), {
|
|
2546
|
+
onDismiss: () => setChatError(null),
|
|
2547
|
+
onRetry: () => {
|
|
2548
|
+
setChatError(null);
|
|
2549
|
+
}
|
|
2550
|
+
})),
|
|
2497
2551
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2498
2552
|
Messages2,
|
|
2499
2553
|
{
|
|
@@ -2727,8 +2781,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2727
2781
|
stableContext,
|
|
2728
2782
|
messagesContext.messages,
|
|
2729
2783
|
appendMessage,
|
|
2730
|
-
runChatCompletion
|
|
2731
|
-
hint
|
|
2784
|
+
runChatCompletion
|
|
2732
2785
|
);
|
|
2733
2786
|
}
|
|
2734
2787
|
});
|
|
@@ -2798,6 +2851,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2798
2851
|
|
|
2799
2852
|
// src/components/chat/Modal.tsx
|
|
2800
2853
|
var import_react_core11 = require("@copilotkit/react-core");
|
|
2854
|
+
var import_shared5 = require("@copilotkit/shared");
|
|
2801
2855
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2802
2856
|
var CopilotModalInner = (_a) => {
|
|
2803
2857
|
var _b = _a, {
|
|
@@ -2823,14 +2877,26 @@ var CopilotModalInner = (_a) => {
|
|
|
2823
2877
|
"Button",
|
|
2824
2878
|
"Header"
|
|
2825
2879
|
]);
|
|
2826
|
-
const { copilotApiConfig } = (0, import_react_core11.useCopilotContext)();
|
|
2880
|
+
const { copilotApiConfig, setBannerError } = (0, import_react_core11.useCopilotContext)();
|
|
2881
|
+
const { publicApiKey } = copilotApiConfig;
|
|
2827
2882
|
const triggerObservabilityHook = (0, import_react15.useCallback)(
|
|
2828
2883
|
(hookName, ...args) => {
|
|
2829
|
-
if (
|
|
2884
|
+
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2830
2885
|
observabilityHooks[hookName](...args);
|
|
2831
2886
|
}
|
|
2887
|
+
if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !publicApiKey) {
|
|
2888
|
+
setBannerError(
|
|
2889
|
+
new import_shared5.CopilotKitError({
|
|
2890
|
+
message: "observabilityHooks requires a publicApiKey to function.",
|
|
2891
|
+
code: import_shared5.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
|
|
2892
|
+
severity: import_shared5.Severity.CRITICAL,
|
|
2893
|
+
visibility: import_shared5.ErrorVisibility.BANNER
|
|
2894
|
+
})
|
|
2895
|
+
);
|
|
2896
|
+
import_shared5.styledConsole.publicApiKeyRequired("observabilityHooks");
|
|
2897
|
+
}
|
|
2832
2898
|
},
|
|
2833
|
-
[
|
|
2899
|
+
[publicApiKey, observabilityHooks, setBannerError]
|
|
2834
2900
|
);
|
|
2835
2901
|
const { open } = useChatContext();
|
|
2836
2902
|
const prevOpen = (0, import_react15.useRef)(open);
|