@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.
- package/CHANGELOG.md +23 -0
- package/dist/{chunk-K344MVUT.mjs → chunk-2KG77MAY.mjs} +62 -8
- package/dist/chunk-2KG77MAY.mjs.map +1 -0
- package/dist/{chunk-EDWWF7QY.mjs → chunk-6C3YVF5W.mjs} +2 -2
- package/dist/{chunk-YH3DHANT.mjs → chunk-7K2X77PW.mjs} +25 -6
- package/dist/chunk-7K2X77PW.mjs.map +1 -0
- package/dist/{chunk-WBPBTTQD.mjs → chunk-FFJHOZX6.mjs} +4 -4
- package/dist/{chunk-V6DDX4LH.mjs → chunk-GDSZGYCE.mjs} +2 -2
- package/dist/{chunk-DSY4ZRMN.mjs → chunk-TW4LLLTE.mjs} +2 -2
- package/dist/components/chat/Chat.d.ts +23 -12
- package/dist/components/chat/Chat.js +61 -7
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +1 -1
- package/dist/components/chat/Header.mjs +4 -4
- package/dist/components/chat/Modal.d.ts +1 -1
- package/dist/components/chat/Modal.js +77 -10
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +6 -6
- package/dist/components/chat/Popup.d.ts +1 -1
- package/dist/components/chat/Popup.js +77 -10
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +7 -7
- package/dist/components/chat/Sidebar.d.ts +1 -1
- package/dist/components/chat/Sidebar.js +77 -10
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +7 -7
- package/dist/components/chat/index.d.ts +1 -1
- package/dist/components/chat/index.js +77 -10
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +8 -8
- package/dist/components/chat/props.d.ts +6 -1
- package/dist/components/chat/props.js.map +1 -1
- package/dist/components/dev-console/console.mjs +3 -3
- package/dist/components/dev-console/index.mjs +4 -4
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +77 -10
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +9 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.js +79 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -9
- package/package.json +4 -4
- package/src/components/chat/Chat.tsx +95 -7
- package/src/components/chat/Modal.tsx +24 -3
- package/src/components/chat/props.ts +7 -1
- package/dist/chunk-K344MVUT.mjs.map +0 -1
- package/dist/chunk-YH3DHANT.mjs.map +0 -1
- /package/dist/{chunk-EDWWF7QY.mjs.map → chunk-6C3YVF5W.mjs.map} +0 -0
- /package/dist/{chunk-WBPBTTQD.mjs.map → chunk-FFJHOZX6.mjs.map} +0 -0
- /package/dist/{chunk-V6DDX4LH.mjs.map → chunk-GDSZGYCE.mjs.map} +0 -0
- /package/dist/{chunk-DSY4ZRMN.mjs.map → chunk-TW4LLLTE.mjs.map} +0 -0
|
@@ -1,18 +1,18 @@
|
|
|
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
|
-
import "../../chunk-
|
|
6
|
+
import "../../chunk-GDSZGYCE.mjs";
|
|
7
7
|
import "../../chunk-V7W6IM2V.mjs";
|
|
8
|
-
import "../../chunk-
|
|
8
|
+
import "../../chunk-FFJHOZX6.mjs";
|
|
9
|
+
import "../../chunk-Q5V6S67N.mjs";
|
|
10
|
+
import "../../chunk-JY2CSDKN.mjs";
|
|
9
11
|
import "../../chunk-KXE2JCUH.mjs";
|
|
10
12
|
import "../../chunk-NRA3CFEE.mjs";
|
|
11
13
|
import "../../chunk-BH6PCAAL.mjs";
|
|
12
|
-
import "../../chunk-Q5V6S67N.mjs";
|
|
13
|
-
import "../../chunk-JY2CSDKN.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";
|
|
@@ -7,7 +7,7 @@ import '../../types/suggestions.js';
|
|
|
7
7
|
import './Chat.js';
|
|
8
8
|
import '@copilotkit/react-core/dist/types/coagent-state';
|
|
9
9
|
import '@copilotkit/react-core/dist/hooks/use-tree';
|
|
10
|
-
import '@copilotkit/react-core/dist/copilot-context-
|
|
10
|
+
import '@copilotkit/react-core/dist/copilot-context-256f9020';
|
|
11
11
|
import '@copilotkit/react-core/dist/types/coagent-action';
|
|
12
12
|
import '@copilotkit/react-core';
|
|
13
13
|
import '@copilotkit/runtime-client-gql';
|
|
@@ -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
|
{
|
|
@@ -2725,9 +2779,9 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2725
2779
|
yield (0, import_react_core10.runAgent)(
|
|
2726
2780
|
generalContext.agentSession.agentName,
|
|
2727
2781
|
stableContext,
|
|
2782
|
+
messagesContext.messages,
|
|
2728
2783
|
appendMessage,
|
|
2729
|
-
runChatCompletion
|
|
2730
|
-
hint
|
|
2784
|
+
runChatCompletion
|
|
2731
2785
|
);
|
|
2732
2786
|
}
|
|
2733
2787
|
});
|
|
@@ -2797,6 +2851,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2797
2851
|
|
|
2798
2852
|
// src/components/chat/Modal.tsx
|
|
2799
2853
|
var import_react_core11 = require("@copilotkit/react-core");
|
|
2854
|
+
var import_shared5 = require("@copilotkit/shared");
|
|
2800
2855
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2801
2856
|
var CopilotModalInner = (_a) => {
|
|
2802
2857
|
var _b = _a, {
|
|
@@ -2822,14 +2877,26 @@ var CopilotModalInner = (_a) => {
|
|
|
2822
2877
|
"Button",
|
|
2823
2878
|
"Header"
|
|
2824
2879
|
]);
|
|
2825
|
-
const { copilotApiConfig } = (0, import_react_core11.useCopilotContext)();
|
|
2880
|
+
const { copilotApiConfig, setBannerError } = (0, import_react_core11.useCopilotContext)();
|
|
2881
|
+
const { publicApiKey } = copilotApiConfig;
|
|
2826
2882
|
const triggerObservabilityHook = (0, import_react15.useCallback)(
|
|
2827
2883
|
(hookName, ...args) => {
|
|
2828
|
-
if (
|
|
2884
|
+
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2829
2885
|
observabilityHooks[hookName](...args);
|
|
2830
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
|
+
}
|
|
2831
2898
|
},
|
|
2832
|
-
[
|
|
2899
|
+
[publicApiKey, observabilityHooks, setBannerError]
|
|
2833
2900
|
);
|
|
2834
2901
|
const { open } = useChatContext();
|
|
2835
2902
|
const prevOpen = (0, import_react15.useRef)(open);
|