@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,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Header
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-GDSZGYCE.mjs";
|
|
4
4
|
import "../../chunk-V7W6IM2V.mjs";
|
|
5
|
-
import "../../chunk-
|
|
5
|
+
import "../../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-IEMQ2SQW.mjs";
|
|
12
12
|
import "../../chunk-XWG3L6QC.mjs";
|
|
13
13
|
import "../../chunk-MRXNTQOX.mjs";
|
|
@@ -6,7 +6,7 @@ import '@copilotkit/shared';
|
|
|
6
6
|
import '../../types/suggestions.js';
|
|
7
7
|
import '@copilotkit/react-core/dist/types/coagent-state';
|
|
8
8
|
import '@copilotkit/react-core/dist/hooks/use-tree';
|
|
9
|
-
import '@copilotkit/react-core/dist/copilot-context-
|
|
9
|
+
import '@copilotkit/react-core/dist/copilot-context-256f9020';
|
|
10
10
|
import '@copilotkit/react-core/dist/types/coagent-action';
|
|
11
11
|
import '@copilotkit/react-core';
|
|
12
12
|
import '@copilotkit/runtime-client-gql';
|
|
@@ -2313,17 +2313,20 @@ function CopilotChat({
|
|
|
2313
2313
|
imageUploadsEnabled,
|
|
2314
2314
|
inputFileAccept = "image/*",
|
|
2315
2315
|
hideStopButton,
|
|
2316
|
-
observabilityHooks
|
|
2316
|
+
observabilityHooks,
|
|
2317
|
+
renderError
|
|
2317
2318
|
}) {
|
|
2318
2319
|
const { additionalInstructions, setChatInstructions, copilotApiConfig, setBannerError } = (0, import_react_core9.useCopilotContext)();
|
|
2320
|
+
const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
|
|
2319
2321
|
const [selectedImages, setSelectedImages] = (0, import_react14.useState)([]);
|
|
2322
|
+
const [chatError, setChatError] = (0, import_react14.useState)(null);
|
|
2320
2323
|
const fileInputRef = (0, import_react14.useRef)(null);
|
|
2321
2324
|
const triggerObservabilityHook = (0, import_react14.useCallback)(
|
|
2322
2325
|
(hookName, ...args) => {
|
|
2323
|
-
if (
|
|
2326
|
+
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2324
2327
|
observabilityHooks[hookName](...args);
|
|
2325
2328
|
}
|
|
2326
|
-
if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !
|
|
2329
|
+
if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !publicApiKey) {
|
|
2327
2330
|
setBannerError(
|
|
2328
2331
|
new import_shared3.CopilotKitError({
|
|
2329
2332
|
message: "observabilityHooks requires a publicApiKey to function.",
|
|
@@ -2335,7 +2338,50 @@ function CopilotChat({
|
|
|
2335
2338
|
import_shared3.styledConsole.publicApiKeyRequired("observabilityHooks");
|
|
2336
2339
|
}
|
|
2337
2340
|
},
|
|
2338
|
-
[
|
|
2341
|
+
[publicApiKey, observabilityHooks, setBannerError]
|
|
2342
|
+
);
|
|
2343
|
+
const triggerChatError = (0, import_react14.useCallback)(
|
|
2344
|
+
(error, operation, originalError) => {
|
|
2345
|
+
const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
|
|
2346
|
+
setChatError({
|
|
2347
|
+
message: errorMessage,
|
|
2348
|
+
operation,
|
|
2349
|
+
timestamp: Date.now()
|
|
2350
|
+
});
|
|
2351
|
+
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks.onError)) {
|
|
2352
|
+
const errorEvent = {
|
|
2353
|
+
type: "error",
|
|
2354
|
+
timestamp: Date.now(),
|
|
2355
|
+
context: {
|
|
2356
|
+
source: "ui",
|
|
2357
|
+
request: {
|
|
2358
|
+
operation,
|
|
2359
|
+
url: chatApiEndpoint,
|
|
2360
|
+
startTime: Date.now()
|
|
2361
|
+
},
|
|
2362
|
+
technical: {
|
|
2363
|
+
environment: "browser",
|
|
2364
|
+
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
|
|
2365
|
+
stackTrace: originalError instanceof Error ? originalError.stack : void 0
|
|
2366
|
+
}
|
|
2367
|
+
},
|
|
2368
|
+
error
|
|
2369
|
+
};
|
|
2370
|
+
observabilityHooks.onError(errorEvent);
|
|
2371
|
+
}
|
|
2372
|
+
if ((observabilityHooks == null ? void 0 : observabilityHooks.onError) && !publicApiKey) {
|
|
2373
|
+
setBannerError(
|
|
2374
|
+
new import_shared3.CopilotKitError({
|
|
2375
|
+
message: "observabilityHooks.onError requires a publicApiKey to function.",
|
|
2376
|
+
code: import_shared3.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
|
|
2377
|
+
severity: import_shared3.Severity.CRITICAL,
|
|
2378
|
+
visibility: import_shared3.ErrorVisibility.BANNER
|
|
2379
|
+
})
|
|
2380
|
+
);
|
|
2381
|
+
import_shared3.styledConsole.publicApiKeyRequired("observabilityHooks.onError");
|
|
2382
|
+
}
|
|
2383
|
+
},
|
|
2384
|
+
[publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
|
|
2339
2385
|
);
|
|
2340
2386
|
(0, import_react14.useEffect)(() => {
|
|
2341
2387
|
if (!imageUploadsEnabled)
|
|
@@ -2376,12 +2422,13 @@ function CopilotChat({
|
|
|
2376
2422
|
const loadedImages = (yield Promise.all(imagePromises)).filter((img) => img !== null);
|
|
2377
2423
|
setSelectedImages((prev) => [...prev, ...loadedImages]);
|
|
2378
2424
|
} catch (error) {
|
|
2425
|
+
triggerChatError(error, "processClipboardImages", error);
|
|
2379
2426
|
console.error("Error processing pasted images:", error);
|
|
2380
2427
|
}
|
|
2381
2428
|
});
|
|
2382
2429
|
document.addEventListener("paste", handlePaste);
|
|
2383
2430
|
return () => document.removeEventListener("paste", handlePaste);
|
|
2384
|
-
}, [imageUploadsEnabled]);
|
|
2431
|
+
}, [imageUploadsEnabled, triggerChatError]);
|
|
2385
2432
|
(0, import_react14.useEffect)(() => {
|
|
2386
2433
|
if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
|
|
2387
2434
|
setChatInstructions(instructions || "");
|
|
@@ -2472,6 +2519,7 @@ function CopilotChat({
|
|
|
2472
2519
|
const loadedImages = yield Promise.all(fileReadPromises);
|
|
2473
2520
|
setSelectedImages((prev) => [...prev, ...loadedImages]);
|
|
2474
2521
|
} catch (error) {
|
|
2522
|
+
triggerChatError(error, "processUploadedImages", error);
|
|
2475
2523
|
console.error("Error reading files:", error);
|
|
2476
2524
|
}
|
|
2477
2525
|
});
|
|
@@ -2491,6 +2539,12 @@ function CopilotChat({
|
|
|
2491
2539
|
triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsDown");
|
|
2492
2540
|
};
|
|
2493
2541
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
2542
|
+
chatError && renderError && renderError(__spreadProps(__spreadValues({}, chatError), {
|
|
2543
|
+
onDismiss: () => setChatError(null),
|
|
2544
|
+
onRetry: () => {
|
|
2545
|
+
setChatError(null);
|
|
2546
|
+
}
|
|
2547
|
+
})),
|
|
2494
2548
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2495
2549
|
Messages2,
|
|
2496
2550
|
{
|
|
@@ -2722,9 +2776,9 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2722
2776
|
yield (0, import_react_core10.runAgent)(
|
|
2723
2777
|
generalContext.agentSession.agentName,
|
|
2724
2778
|
stableContext,
|
|
2779
|
+
messagesContext.messages,
|
|
2725
2780
|
appendMessage,
|
|
2726
|
-
runChatCompletion
|
|
2727
|
-
hint
|
|
2781
|
+
runChatCompletion
|
|
2728
2782
|
);
|
|
2729
2783
|
}
|
|
2730
2784
|
});
|
|
@@ -2794,6 +2848,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2794
2848
|
|
|
2795
2849
|
// src/components/chat/Modal.tsx
|
|
2796
2850
|
var import_react_core11 = require("@copilotkit/react-core");
|
|
2851
|
+
var import_shared5 = require("@copilotkit/shared");
|
|
2797
2852
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2798
2853
|
var CopilotModalInner = (_a) => {
|
|
2799
2854
|
var _b = _a, {
|
|
@@ -2819,14 +2874,26 @@ var CopilotModalInner = (_a) => {
|
|
|
2819
2874
|
"Button",
|
|
2820
2875
|
"Header"
|
|
2821
2876
|
]);
|
|
2822
|
-
const { copilotApiConfig } = (0, import_react_core11.useCopilotContext)();
|
|
2877
|
+
const { copilotApiConfig, setBannerError } = (0, import_react_core11.useCopilotContext)();
|
|
2878
|
+
const { publicApiKey } = copilotApiConfig;
|
|
2823
2879
|
const triggerObservabilityHook = (0, import_react15.useCallback)(
|
|
2824
2880
|
(hookName, ...args) => {
|
|
2825
|
-
if (
|
|
2881
|
+
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2826
2882
|
observabilityHooks[hookName](...args);
|
|
2827
2883
|
}
|
|
2884
|
+
if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !publicApiKey) {
|
|
2885
|
+
setBannerError(
|
|
2886
|
+
new import_shared5.CopilotKitError({
|
|
2887
|
+
message: "observabilityHooks requires a publicApiKey to function.",
|
|
2888
|
+
code: import_shared5.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
|
|
2889
|
+
severity: import_shared5.Severity.CRITICAL,
|
|
2890
|
+
visibility: import_shared5.ErrorVisibility.BANNER
|
|
2891
|
+
})
|
|
2892
|
+
);
|
|
2893
|
+
import_shared5.styledConsole.publicApiKeyRequired("observabilityHooks");
|
|
2894
|
+
}
|
|
2828
2895
|
},
|
|
2829
|
-
[
|
|
2896
|
+
[publicApiKey, observabilityHooks, setBannerError]
|
|
2830
2897
|
);
|
|
2831
2898
|
const { open } = useChatContext();
|
|
2832
2899
|
const prevOpen = (0, import_react15.useRef)(open);
|