@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
|
CopilotSidebar
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-TW4LLLTE.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";
|
|
@@ -2324,17 +2324,20 @@ function CopilotChat({
|
|
|
2324
2324
|
imageUploadsEnabled,
|
|
2325
2325
|
inputFileAccept = "image/*",
|
|
2326
2326
|
hideStopButton,
|
|
2327
|
-
observabilityHooks
|
|
2327
|
+
observabilityHooks,
|
|
2328
|
+
renderError
|
|
2328
2329
|
}) {
|
|
2329
2330
|
const { additionalInstructions, setChatInstructions, copilotApiConfig, setBannerError } = (0, import_react_core9.useCopilotContext)();
|
|
2331
|
+
const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
|
|
2330
2332
|
const [selectedImages, setSelectedImages] = (0, import_react14.useState)([]);
|
|
2333
|
+
const [chatError, setChatError] = (0, import_react14.useState)(null);
|
|
2331
2334
|
const fileInputRef = (0, import_react14.useRef)(null);
|
|
2332
2335
|
const triggerObservabilityHook = (0, import_react14.useCallback)(
|
|
2333
2336
|
(hookName, ...args) => {
|
|
2334
|
-
if (
|
|
2337
|
+
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2335
2338
|
observabilityHooks[hookName](...args);
|
|
2336
2339
|
}
|
|
2337
|
-
if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !
|
|
2340
|
+
if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !publicApiKey) {
|
|
2338
2341
|
setBannerError(
|
|
2339
2342
|
new import_shared3.CopilotKitError({
|
|
2340
2343
|
message: "observabilityHooks requires a publicApiKey to function.",
|
|
@@ -2346,7 +2349,50 @@ function CopilotChat({
|
|
|
2346
2349
|
import_shared3.styledConsole.publicApiKeyRequired("observabilityHooks");
|
|
2347
2350
|
}
|
|
2348
2351
|
},
|
|
2349
|
-
[
|
|
2352
|
+
[publicApiKey, observabilityHooks, setBannerError]
|
|
2353
|
+
);
|
|
2354
|
+
const triggerChatError = (0, import_react14.useCallback)(
|
|
2355
|
+
(error, operation, originalError) => {
|
|
2356
|
+
const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
|
|
2357
|
+
setChatError({
|
|
2358
|
+
message: errorMessage,
|
|
2359
|
+
operation,
|
|
2360
|
+
timestamp: Date.now()
|
|
2361
|
+
});
|
|
2362
|
+
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks.onError)) {
|
|
2363
|
+
const errorEvent = {
|
|
2364
|
+
type: "error",
|
|
2365
|
+
timestamp: Date.now(),
|
|
2366
|
+
context: {
|
|
2367
|
+
source: "ui",
|
|
2368
|
+
request: {
|
|
2369
|
+
operation,
|
|
2370
|
+
url: chatApiEndpoint,
|
|
2371
|
+
startTime: Date.now()
|
|
2372
|
+
},
|
|
2373
|
+
technical: {
|
|
2374
|
+
environment: "browser",
|
|
2375
|
+
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
|
|
2376
|
+
stackTrace: originalError instanceof Error ? originalError.stack : void 0
|
|
2377
|
+
}
|
|
2378
|
+
},
|
|
2379
|
+
error
|
|
2380
|
+
};
|
|
2381
|
+
observabilityHooks.onError(errorEvent);
|
|
2382
|
+
}
|
|
2383
|
+
if ((observabilityHooks == null ? void 0 : observabilityHooks.onError) && !publicApiKey) {
|
|
2384
|
+
setBannerError(
|
|
2385
|
+
new import_shared3.CopilotKitError({
|
|
2386
|
+
message: "observabilityHooks.onError requires a publicApiKey to function.",
|
|
2387
|
+
code: import_shared3.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
|
|
2388
|
+
severity: import_shared3.Severity.CRITICAL,
|
|
2389
|
+
visibility: import_shared3.ErrorVisibility.BANNER
|
|
2390
|
+
})
|
|
2391
|
+
);
|
|
2392
|
+
import_shared3.styledConsole.publicApiKeyRequired("observabilityHooks.onError");
|
|
2393
|
+
}
|
|
2394
|
+
},
|
|
2395
|
+
[publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
|
|
2350
2396
|
);
|
|
2351
2397
|
(0, import_react14.useEffect)(() => {
|
|
2352
2398
|
if (!imageUploadsEnabled)
|
|
@@ -2387,12 +2433,13 @@ function CopilotChat({
|
|
|
2387
2433
|
const loadedImages = (yield Promise.all(imagePromises)).filter((img) => img !== null);
|
|
2388
2434
|
setSelectedImages((prev) => [...prev, ...loadedImages]);
|
|
2389
2435
|
} catch (error) {
|
|
2436
|
+
triggerChatError(error, "processClipboardImages", error);
|
|
2390
2437
|
console.error("Error processing pasted images:", error);
|
|
2391
2438
|
}
|
|
2392
2439
|
});
|
|
2393
2440
|
document.addEventListener("paste", handlePaste);
|
|
2394
2441
|
return () => document.removeEventListener("paste", handlePaste);
|
|
2395
|
-
}, [imageUploadsEnabled]);
|
|
2442
|
+
}, [imageUploadsEnabled, triggerChatError]);
|
|
2396
2443
|
(0, import_react14.useEffect)(() => {
|
|
2397
2444
|
if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
|
|
2398
2445
|
setChatInstructions(instructions || "");
|
|
@@ -2483,6 +2530,7 @@ function CopilotChat({
|
|
|
2483
2530
|
const loadedImages = yield Promise.all(fileReadPromises);
|
|
2484
2531
|
setSelectedImages((prev) => [...prev, ...loadedImages]);
|
|
2485
2532
|
} catch (error) {
|
|
2533
|
+
triggerChatError(error, "processUploadedImages", error);
|
|
2486
2534
|
console.error("Error reading files:", error);
|
|
2487
2535
|
}
|
|
2488
2536
|
});
|
|
@@ -2502,6 +2550,12 @@ function CopilotChat({
|
|
|
2502
2550
|
triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsDown");
|
|
2503
2551
|
};
|
|
2504
2552
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
2553
|
+
chatError && renderError && renderError(__spreadProps(__spreadValues({}, chatError), {
|
|
2554
|
+
onDismiss: () => setChatError(null),
|
|
2555
|
+
onRetry: () => {
|
|
2556
|
+
setChatError(null);
|
|
2557
|
+
}
|
|
2558
|
+
})),
|
|
2505
2559
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2506
2560
|
Messages2,
|
|
2507
2561
|
{
|
|
@@ -2735,8 +2789,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2735
2789
|
stableContext,
|
|
2736
2790
|
messagesContext.messages,
|
|
2737
2791
|
appendMessage,
|
|
2738
|
-
runChatCompletion
|
|
2739
|
-
hint
|
|
2792
|
+
runChatCompletion
|
|
2740
2793
|
);
|
|
2741
2794
|
}
|
|
2742
2795
|
});
|
|
@@ -2806,6 +2859,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2806
2859
|
|
|
2807
2860
|
// src/components/chat/Modal.tsx
|
|
2808
2861
|
var import_react_core11 = require("@copilotkit/react-core");
|
|
2862
|
+
var import_shared5 = require("@copilotkit/shared");
|
|
2809
2863
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2810
2864
|
var CopilotModalInner = (_a) => {
|
|
2811
2865
|
var _b = _a, {
|
|
@@ -2831,14 +2885,26 @@ var CopilotModalInner = (_a) => {
|
|
|
2831
2885
|
"Button",
|
|
2832
2886
|
"Header"
|
|
2833
2887
|
]);
|
|
2834
|
-
const { copilotApiConfig } = (0, import_react_core11.useCopilotContext)();
|
|
2888
|
+
const { copilotApiConfig, setBannerError } = (0, import_react_core11.useCopilotContext)();
|
|
2889
|
+
const { publicApiKey } = copilotApiConfig;
|
|
2835
2890
|
const triggerObservabilityHook = (0, import_react15.useCallback)(
|
|
2836
2891
|
(hookName, ...args) => {
|
|
2837
|
-
if (
|
|
2892
|
+
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2838
2893
|
observabilityHooks[hookName](...args);
|
|
2839
2894
|
}
|
|
2895
|
+
if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !publicApiKey) {
|
|
2896
|
+
setBannerError(
|
|
2897
|
+
new import_shared5.CopilotKitError({
|
|
2898
|
+
message: "observabilityHooks requires a publicApiKey to function.",
|
|
2899
|
+
code: import_shared5.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
|
|
2900
|
+
severity: import_shared5.Severity.CRITICAL,
|
|
2901
|
+
visibility: import_shared5.ErrorVisibility.BANNER
|
|
2902
|
+
})
|
|
2903
|
+
);
|
|
2904
|
+
import_shared5.styledConsole.publicApiKeyRequired("observabilityHooks");
|
|
2905
|
+
}
|
|
2840
2906
|
},
|
|
2841
|
-
[
|
|
2907
|
+
[publicApiKey, observabilityHooks, setBannerError]
|
|
2842
2908
|
);
|
|
2843
2909
|
const { open } = useChatContext();
|
|
2844
2910
|
const prevOpen = (0, import_react15.useRef)(open);
|