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