@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
|
@@ -2,29 +2,29 @@ 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
|
-
import "../chunk-
|
|
12
|
+
import "../chunk-GDSZGYCE.mjs";
|
|
13
13
|
import "../chunk-V7W6IM2V.mjs";
|
|
14
14
|
import {
|
|
15
15
|
CopilotDevConsole
|
|
16
|
-
} from "../chunk-
|
|
17
|
-
import "../chunk-KXE2JCUH.mjs";
|
|
18
|
-
import "../chunk-NRA3CFEE.mjs";
|
|
19
|
-
import "../chunk-BH6PCAAL.mjs";
|
|
16
|
+
} from "../chunk-FFJHOZX6.mjs";
|
|
20
17
|
import "../chunk-Q5V6S67N.mjs";
|
|
21
18
|
import {
|
|
22
19
|
shouldShowDevConsole
|
|
23
20
|
} from "../chunk-JY2CSDKN.mjs";
|
|
21
|
+
import "../chunk-KXE2JCUH.mjs";
|
|
22
|
+
import "../chunk-NRA3CFEE.mjs";
|
|
23
|
+
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.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ import 'react/jsx-runtime';
|
|
|
20
20
|
import './components/chat/Modal.js';
|
|
21
21
|
import '@copilotkit/react-core/dist/types/coagent-state';
|
|
22
22
|
import '@copilotkit/react-core/dist/hooks/use-tree';
|
|
23
|
-
import '@copilotkit/react-core/dist/copilot-context-
|
|
23
|
+
import '@copilotkit/react-core/dist/copilot-context-256f9020';
|
|
24
24
|
import '@copilotkit/react-core/dist/types/coagent-action';
|
|
25
25
|
import '@copilotkit/runtime-client-gql';
|
|
26
26
|
import 'react-markdown';
|
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
|
{
|
|
@@ -2737,9 +2791,9 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2737
2791
|
yield (0, import_react_core10.runAgent)(
|
|
2738
2792
|
generalContext.agentSession.agentName,
|
|
2739
2793
|
stableContext,
|
|
2794
|
+
messagesContext.messages,
|
|
2740
2795
|
appendMessage,
|
|
2741
|
-
runChatCompletion
|
|
2742
|
-
hint
|
|
2796
|
+
runChatCompletion
|
|
2743
2797
|
);
|
|
2744
2798
|
}
|
|
2745
2799
|
});
|
|
@@ -2809,6 +2863,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2809
2863
|
|
|
2810
2864
|
// src/components/chat/Modal.tsx
|
|
2811
2865
|
var import_react_core11 = require("@copilotkit/react-core");
|
|
2866
|
+
var import_shared5 = require("@copilotkit/shared");
|
|
2812
2867
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2813
2868
|
var CopilotModalInner = (_a) => {
|
|
2814
2869
|
var _b = _a, {
|
|
@@ -2834,14 +2889,26 @@ var CopilotModalInner = (_a) => {
|
|
|
2834
2889
|
"Button",
|
|
2835
2890
|
"Header"
|
|
2836
2891
|
]);
|
|
2837
|
-
const { copilotApiConfig } = (0, import_react_core11.useCopilotContext)();
|
|
2892
|
+
const { copilotApiConfig, setBannerError } = (0, import_react_core11.useCopilotContext)();
|
|
2893
|
+
const { publicApiKey } = copilotApiConfig;
|
|
2838
2894
|
const triggerObservabilityHook = (0, import_react15.useCallback)(
|
|
2839
2895
|
(hookName, ...args) => {
|
|
2840
|
-
if (
|
|
2896
|
+
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2841
2897
|
observabilityHooks[hookName](...args);
|
|
2842
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
|
+
}
|
|
2843
2910
|
},
|
|
2844
|
-
[
|
|
2911
|
+
[publicApiKey, observabilityHooks, setBannerError]
|
|
2845
2912
|
);
|
|
2846
2913
|
const { open } = useChatContext();
|
|
2847
2914
|
const prevOpen = (0, import_react15.useRef)(open);
|
|
@@ -3001,7 +3068,7 @@ function CopilotSidebar(props) {
|
|
|
3001
3068
|
// src/hooks/use-copilot-chat-suggestions.tsx
|
|
3002
3069
|
var import_react17 = require("react");
|
|
3003
3070
|
var import_react_core12 = require("@copilotkit/react-core");
|
|
3004
|
-
var
|
|
3071
|
+
var import_shared6 = require("@copilotkit/shared");
|
|
3005
3072
|
function useCopilotChatSuggestions({
|
|
3006
3073
|
available = "enabled",
|
|
3007
3074
|
instructions,
|
|
@@ -3013,7 +3080,7 @@ function useCopilotChatSuggestions({
|
|
|
3013
3080
|
(0, import_react17.useEffect)(() => {
|
|
3014
3081
|
if (available === "disabled")
|
|
3015
3082
|
return;
|
|
3016
|
-
const id = (0,
|
|
3083
|
+
const id = (0, import_shared6.randomId)();
|
|
3017
3084
|
context.addChatSuggestionConfiguration(id, {
|
|
3018
3085
|
instructions,
|
|
3019
3086
|
minSuggestions,
|