@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
|
@@ -2,12 +2,12 @@ import "../chunk-MMVDU6DF.mjs";
|
|
|
2
2
|
import "../chunk-SC6JRFAJ.mjs";
|
|
3
3
|
import {
|
|
4
4
|
CopilotSidebar
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-TW4LLLTE.mjs";
|
|
6
6
|
import "../chunk-WB3YULQ4.mjs";
|
|
7
7
|
import {
|
|
8
8
|
CopilotPopup
|
|
9
|
-
} from "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
} from "../chunk-6C3YVF5W.mjs";
|
|
10
|
+
import "../chunk-7K2X77PW.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-
|
|
27
|
+
} from "../chunk-2KG77MAY.mjs";
|
|
28
28
|
import "../chunk-JHUTTP5C.mjs";
|
|
29
29
|
import {
|
|
30
30
|
AssistantMessage
|
package/dist/index.js
CHANGED
|
@@ -2328,17 +2328,20 @@ function CopilotChat({
|
|
|
2328
2328
|
imageUploadsEnabled,
|
|
2329
2329
|
inputFileAccept = "image/*",
|
|
2330
2330
|
hideStopButton,
|
|
2331
|
-
observabilityHooks
|
|
2331
|
+
observabilityHooks,
|
|
2332
|
+
renderError
|
|
2332
2333
|
}) {
|
|
2333
2334
|
const { additionalInstructions, setChatInstructions, copilotApiConfig, setBannerError } = (0, import_react_core9.useCopilotContext)();
|
|
2335
|
+
const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
|
|
2334
2336
|
const [selectedImages, setSelectedImages] = (0, import_react14.useState)([]);
|
|
2337
|
+
const [chatError, setChatError] = (0, import_react14.useState)(null);
|
|
2335
2338
|
const fileInputRef = (0, import_react14.useRef)(null);
|
|
2336
2339
|
const triggerObservabilityHook = (0, import_react14.useCallback)(
|
|
2337
2340
|
(hookName, ...args) => {
|
|
2338
|
-
if (
|
|
2341
|
+
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2339
2342
|
observabilityHooks[hookName](...args);
|
|
2340
2343
|
}
|
|
2341
|
-
if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !
|
|
2344
|
+
if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !publicApiKey) {
|
|
2342
2345
|
setBannerError(
|
|
2343
2346
|
new import_shared3.CopilotKitError({
|
|
2344
2347
|
message: "observabilityHooks requires a publicApiKey to function.",
|
|
@@ -2350,7 +2353,50 @@ function CopilotChat({
|
|
|
2350
2353
|
import_shared3.styledConsole.publicApiKeyRequired("observabilityHooks");
|
|
2351
2354
|
}
|
|
2352
2355
|
},
|
|
2353
|
-
[
|
|
2356
|
+
[publicApiKey, observabilityHooks, setBannerError]
|
|
2357
|
+
);
|
|
2358
|
+
const triggerChatError = (0, import_react14.useCallback)(
|
|
2359
|
+
(error, operation, originalError) => {
|
|
2360
|
+
const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
|
|
2361
|
+
setChatError({
|
|
2362
|
+
message: errorMessage,
|
|
2363
|
+
operation,
|
|
2364
|
+
timestamp: Date.now()
|
|
2365
|
+
});
|
|
2366
|
+
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks.onError)) {
|
|
2367
|
+
const errorEvent = {
|
|
2368
|
+
type: "error",
|
|
2369
|
+
timestamp: Date.now(),
|
|
2370
|
+
context: {
|
|
2371
|
+
source: "ui",
|
|
2372
|
+
request: {
|
|
2373
|
+
operation,
|
|
2374
|
+
url: chatApiEndpoint,
|
|
2375
|
+
startTime: Date.now()
|
|
2376
|
+
},
|
|
2377
|
+
technical: {
|
|
2378
|
+
environment: "browser",
|
|
2379
|
+
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
|
|
2380
|
+
stackTrace: originalError instanceof Error ? originalError.stack : void 0
|
|
2381
|
+
}
|
|
2382
|
+
},
|
|
2383
|
+
error
|
|
2384
|
+
};
|
|
2385
|
+
observabilityHooks.onError(errorEvent);
|
|
2386
|
+
}
|
|
2387
|
+
if ((observabilityHooks == null ? void 0 : observabilityHooks.onError) && !publicApiKey) {
|
|
2388
|
+
setBannerError(
|
|
2389
|
+
new import_shared3.CopilotKitError({
|
|
2390
|
+
message: "observabilityHooks.onError requires a publicApiKey to function.",
|
|
2391
|
+
code: import_shared3.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
|
|
2392
|
+
severity: import_shared3.Severity.CRITICAL,
|
|
2393
|
+
visibility: import_shared3.ErrorVisibility.BANNER
|
|
2394
|
+
})
|
|
2395
|
+
);
|
|
2396
|
+
import_shared3.styledConsole.publicApiKeyRequired("observabilityHooks.onError");
|
|
2397
|
+
}
|
|
2398
|
+
},
|
|
2399
|
+
[publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
|
|
2354
2400
|
);
|
|
2355
2401
|
(0, import_react14.useEffect)(() => {
|
|
2356
2402
|
if (!imageUploadsEnabled)
|
|
@@ -2391,12 +2437,13 @@ function CopilotChat({
|
|
|
2391
2437
|
const loadedImages = (yield Promise.all(imagePromises)).filter((img) => img !== null);
|
|
2392
2438
|
setSelectedImages((prev) => [...prev, ...loadedImages]);
|
|
2393
2439
|
} catch (error) {
|
|
2440
|
+
triggerChatError(error, "processClipboardImages", error);
|
|
2394
2441
|
console.error("Error processing pasted images:", error);
|
|
2395
2442
|
}
|
|
2396
2443
|
});
|
|
2397
2444
|
document.addEventListener("paste", handlePaste);
|
|
2398
2445
|
return () => document.removeEventListener("paste", handlePaste);
|
|
2399
|
-
}, [imageUploadsEnabled]);
|
|
2446
|
+
}, [imageUploadsEnabled, triggerChatError]);
|
|
2400
2447
|
(0, import_react14.useEffect)(() => {
|
|
2401
2448
|
if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
|
|
2402
2449
|
setChatInstructions(instructions || "");
|
|
@@ -2487,6 +2534,7 @@ function CopilotChat({
|
|
|
2487
2534
|
const loadedImages = yield Promise.all(fileReadPromises);
|
|
2488
2535
|
setSelectedImages((prev) => [...prev, ...loadedImages]);
|
|
2489
2536
|
} catch (error) {
|
|
2537
|
+
triggerChatError(error, "processUploadedImages", error);
|
|
2490
2538
|
console.error("Error reading files:", error);
|
|
2491
2539
|
}
|
|
2492
2540
|
});
|
|
@@ -2506,6 +2554,12 @@ function CopilotChat({
|
|
|
2506
2554
|
triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsDown");
|
|
2507
2555
|
};
|
|
2508
2556
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
2557
|
+
chatError && renderError && renderError(__spreadProps(__spreadValues({}, chatError), {
|
|
2558
|
+
onDismiss: () => setChatError(null),
|
|
2559
|
+
onRetry: () => {
|
|
2560
|
+
setChatError(null);
|
|
2561
|
+
}
|
|
2562
|
+
})),
|
|
2509
2563
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2510
2564
|
Messages2,
|
|
2511
2565
|
{
|
|
@@ -2739,8 +2793,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2739
2793
|
stableContext,
|
|
2740
2794
|
messagesContext.messages,
|
|
2741
2795
|
appendMessage,
|
|
2742
|
-
runChatCompletion
|
|
2743
|
-
hint
|
|
2796
|
+
runChatCompletion
|
|
2744
2797
|
);
|
|
2745
2798
|
}
|
|
2746
2799
|
});
|
|
@@ -2810,6 +2863,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2810
2863
|
|
|
2811
2864
|
// src/components/chat/Modal.tsx
|
|
2812
2865
|
var import_react_core11 = require("@copilotkit/react-core");
|
|
2866
|
+
var import_shared5 = require("@copilotkit/shared");
|
|
2813
2867
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2814
2868
|
var CopilotModalInner = (_a) => {
|
|
2815
2869
|
var _b = _a, {
|
|
@@ -2835,14 +2889,26 @@ var CopilotModalInner = (_a) => {
|
|
|
2835
2889
|
"Button",
|
|
2836
2890
|
"Header"
|
|
2837
2891
|
]);
|
|
2838
|
-
const { copilotApiConfig } = (0, import_react_core11.useCopilotContext)();
|
|
2892
|
+
const { copilotApiConfig, setBannerError } = (0, import_react_core11.useCopilotContext)();
|
|
2893
|
+
const { publicApiKey } = copilotApiConfig;
|
|
2839
2894
|
const triggerObservabilityHook = (0, import_react15.useCallback)(
|
|
2840
2895
|
(hookName, ...args) => {
|
|
2841
|
-
if (
|
|
2896
|
+
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2842
2897
|
observabilityHooks[hookName](...args);
|
|
2843
2898
|
}
|
|
2899
|
+
if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !publicApiKey) {
|
|
2900
|
+
setBannerError(
|
|
2901
|
+
new import_shared5.CopilotKitError({
|
|
2902
|
+
message: "observabilityHooks requires a publicApiKey to function.",
|
|
2903
|
+
code: import_shared5.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
|
|
2904
|
+
severity: import_shared5.Severity.CRITICAL,
|
|
2905
|
+
visibility: import_shared5.ErrorVisibility.BANNER
|
|
2906
|
+
})
|
|
2907
|
+
);
|
|
2908
|
+
import_shared5.styledConsole.publicApiKeyRequired("observabilityHooks");
|
|
2909
|
+
}
|
|
2844
2910
|
},
|
|
2845
|
-
[
|
|
2911
|
+
[publicApiKey, observabilityHooks, setBannerError]
|
|
2846
2912
|
);
|
|
2847
2913
|
const { open } = useChatContext();
|
|
2848
2914
|
const prevOpen = (0, import_react15.useRef)(open);
|
|
@@ -3002,7 +3068,7 @@ function CopilotSidebar(props) {
|
|
|
3002
3068
|
// src/hooks/use-copilot-chat-suggestions.tsx
|
|
3003
3069
|
var import_react17 = require("react");
|
|
3004
3070
|
var import_react_core12 = require("@copilotkit/react-core");
|
|
3005
|
-
var
|
|
3071
|
+
var import_shared6 = require("@copilotkit/shared");
|
|
3006
3072
|
function useCopilotChatSuggestions({
|
|
3007
3073
|
available = "enabled",
|
|
3008
3074
|
instructions,
|
|
@@ -3014,7 +3080,7 @@ function useCopilotChatSuggestions({
|
|
|
3014
3080
|
(0, import_react17.useEffect)(() => {
|
|
3015
3081
|
if (available === "disabled")
|
|
3016
3082
|
return;
|
|
3017
|
-
const id = (0,
|
|
3083
|
+
const id = (0, import_shared6.randomId)();
|
|
3018
3084
|
context.addChatSuggestionConfiguration(id, {
|
|
3019
3085
|
instructions,
|
|
3020
3086
|
minSuggestions,
|