@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
|
CopilotSidebar
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-TW4LLLTE.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";
|
|
@@ -16,7 +16,7 @@ import 'react/jsx-runtime';
|
|
|
16
16
|
import './Modal.js';
|
|
17
17
|
import '@copilotkit/react-core/dist/types/coagent-state';
|
|
18
18
|
import '@copilotkit/react-core/dist/hooks/use-tree';
|
|
19
|
-
import '@copilotkit/react-core/dist/copilot-context-
|
|
19
|
+
import '@copilotkit/react-core/dist/copilot-context-256f9020';
|
|
20
20
|
import '@copilotkit/react-core/dist/types/coagent-action';
|
|
21
21
|
import '@copilotkit/react-core';
|
|
22
22
|
import '@copilotkit/runtime-client-gql';
|
|
@@ -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
|
{
|
|
@@ -2733,9 +2787,9 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2733
2787
|
yield (0, import_react_core10.runAgent)(
|
|
2734
2788
|
generalContext.agentSession.agentName,
|
|
2735
2789
|
stableContext,
|
|
2790
|
+
messagesContext.messages,
|
|
2736
2791
|
appendMessage,
|
|
2737
|
-
runChatCompletion
|
|
2738
|
-
hint
|
|
2792
|
+
runChatCompletion
|
|
2739
2793
|
);
|
|
2740
2794
|
}
|
|
2741
2795
|
});
|
|
@@ -2805,6 +2859,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2805
2859
|
|
|
2806
2860
|
// src/components/chat/Modal.tsx
|
|
2807
2861
|
var import_react_core11 = require("@copilotkit/react-core");
|
|
2862
|
+
var import_shared5 = require("@copilotkit/shared");
|
|
2808
2863
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2809
2864
|
var CopilotModalInner = (_a) => {
|
|
2810
2865
|
var _b = _a, {
|
|
@@ -2830,14 +2885,26 @@ var CopilotModalInner = (_a) => {
|
|
|
2830
2885
|
"Button",
|
|
2831
2886
|
"Header"
|
|
2832
2887
|
]);
|
|
2833
|
-
const { copilotApiConfig } = (0, import_react_core11.useCopilotContext)();
|
|
2888
|
+
const { copilotApiConfig, setBannerError } = (0, import_react_core11.useCopilotContext)();
|
|
2889
|
+
const { publicApiKey } = copilotApiConfig;
|
|
2834
2890
|
const triggerObservabilityHook = (0, import_react15.useCallback)(
|
|
2835
2891
|
(hookName, ...args) => {
|
|
2836
|
-
if (
|
|
2892
|
+
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2837
2893
|
observabilityHooks[hookName](...args);
|
|
2838
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
|
+
}
|
|
2839
2906
|
},
|
|
2840
|
-
[
|
|
2907
|
+
[publicApiKey, observabilityHooks, setBannerError]
|
|
2841
2908
|
);
|
|
2842
2909
|
const { open } = useChatContext();
|
|
2843
2910
|
const prevOpen = (0, import_react15.useRef)(open);
|