@copilotkit/react-ui 1.10.4-next.1 → 1.10.4-next.2
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 +11 -0
- package/dist/{chunk-SHPG2T4O.mjs → chunk-FJFWH5AF.mjs} +3 -3
- package/dist/{chunk-FWQRAZ5S.mjs → chunk-KCRWXHWT.mjs} +2 -2
- package/dist/{chunk-X5AO5A3L.mjs → chunk-PHH6DYUW.mjs} +5 -2
- package/dist/chunk-PHH6DYUW.mjs.map +1 -0
- package/dist/{chunk-7XIE7UOW.mjs → chunk-QQDCZRPA.mjs} +2 -2
- package/dist/chunk-SRY5COHG.mjs +63 -0
- package/dist/chunk-SRY5COHG.mjs.map +1 -0
- package/dist/{chunk-EL7NCWNZ.mjs → chunk-Z66Y3KRE.mjs} +51 -21
- package/dist/chunk-Z66Y3KRE.mjs.map +1 -0
- package/dist/components/chat/Chat.d.ts +24 -13
- package/dist/components/chat/Chat.js +144 -62
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +3 -2
- package/dist/components/chat/Messages.d.ts +1 -1
- package/dist/components/chat/Messages.js +4 -1
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +1 -1
- package/dist/components/chat/Modal.d.ts +1 -1
- package/dist/components/chat/Modal.js +158 -76
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +4 -3
- package/dist/components/chat/Popup.d.ts +1 -1
- package/dist/components/chat/Popup.js +160 -78
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +5 -4
- package/dist/components/chat/Sidebar.d.ts +1 -1
- package/dist/components/chat/Sidebar.js +162 -80
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +5 -4
- package/dist/components/chat/index.d.ts +2 -2
- package/dist/components/chat/index.js +164 -82
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +6 -5
- package/dist/components/chat/messages/ErrorMessage.d.ts +9 -0
- package/dist/components/chat/messages/ErrorMessage.js +711 -0
- package/dist/components/chat/messages/ErrorMessage.js.map +1 -0
- package/dist/components/chat/messages/ErrorMessage.mjs +13 -0
- package/dist/components/chat/messages/ErrorMessage.mjs.map +1 -0
- package/dist/components/chat/props.d.ts +26 -1
- package/dist/components/chat/props.js.map +1 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +164 -82
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +6 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.js +166 -84
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -6
- package/package.json +4 -4
- package/src/components/chat/Chat.tsx +64 -26
- package/src/components/chat/Messages.tsx +3 -0
- package/src/components/chat/messages/ErrorMessage.tsx +59 -0
- package/src/components/chat/props.ts +31 -0
- package/dist/chunk-EL7NCWNZ.mjs.map +0 -1
- package/dist/chunk-X5AO5A3L.mjs.map +0 -1
- /package/dist/{chunk-SHPG2T4O.mjs.map → chunk-FJFWH5AF.mjs.map} +0 -0
- /package/dist/{chunk-FWQRAZ5S.mjs.map → chunk-KCRWXHWT.mjs.map} +0 -0
- /package/dist/{chunk-7XIE7UOW.mjs.map → chunk-QQDCZRPA.mjs.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotSidebar
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-KCRWXHWT.mjs";
|
|
4
|
+
import "../../chunk-FJFWH5AF.mjs";
|
|
5
5
|
import "../../chunk-C3GSYRC3.mjs";
|
|
6
6
|
import "../../chunk-GDSZGYCE.mjs";
|
|
7
7
|
import "../../chunk-V7W6IM2V.mjs";
|
|
@@ -12,14 +12,15 @@ import "../../chunk-KXE2JCUH.mjs";
|
|
|
12
12
|
import "../../chunk-NRA3CFEE.mjs";
|
|
13
13
|
import "../../chunk-BH6PCAAL.mjs";
|
|
14
14
|
import "../../chunk-UFN2VWSR.mjs";
|
|
15
|
-
import "../../chunk-
|
|
15
|
+
import "../../chunk-Z66Y3KRE.mjs";
|
|
16
|
+
import "../../chunk-SRY5COHG.mjs";
|
|
16
17
|
import "../../chunk-226ZMOE3.mjs";
|
|
17
18
|
import "../../chunk-W26XFBEG.mjs";
|
|
18
19
|
import "../../chunk-PLHTVHUW.mjs";
|
|
19
20
|
import "../../chunk-DTRPPNSA.mjs";
|
|
20
21
|
import "../../chunk-CGEAG65D.mjs";
|
|
21
22
|
import "../../chunk-QIOJXTIQ.mjs";
|
|
22
|
-
import "../../chunk-
|
|
23
|
+
import "../../chunk-PHH6DYUW.mjs";
|
|
23
24
|
import "../../chunk-YO63WHVQ.mjs";
|
|
24
25
|
import "../../chunk-LJAYSRCB.mjs";
|
|
25
26
|
import "../../chunk-X477GDGZ.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AssistantMessageProps, ButtonProps, ComponentsMap, CopilotObservabilityHooks, HeaderProps, ImageRendererProps, InputProps, MessagesProps, RenderMessageProps, RenderSuggestionsListProps, Renderer, SuggestionsProps, UserMessageProps, WindowProps } from './props.js';
|
|
1
|
+
export { AssistantMessageProps, ButtonProps, ChatError, ComponentsMap, CopilotObservabilityHooks, ErrorMessageProps, HeaderProps, ImageRendererProps, InputProps, MessagesProps, RenderMessageProps, RenderSuggestionsListProps, Renderer, SuggestionsProps, UserMessageProps, WindowProps } from './props.js';
|
|
2
2
|
export { CopilotPopup } from './Popup.js';
|
|
3
3
|
export { CopilotSidebar } from './Sidebar.js';
|
|
4
4
|
export { CopilotChat } from './Chat.js';
|
|
@@ -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-59740e82';
|
|
20
20
|
import '@copilotkit/react-core/dist/types/coagent-action';
|
|
21
21
|
import '@copilotkit/react-core';
|
|
22
22
|
import '@copilotkit/runtime-client-gql';
|
|
@@ -93,7 +93,7 @@ __export(chat_exports, {
|
|
|
93
93
|
module.exports = __toCommonJS(chat_exports);
|
|
94
94
|
|
|
95
95
|
// src/components/chat/Modal.tsx
|
|
96
|
-
var
|
|
96
|
+
var import_react16 = __toESM(require("react"));
|
|
97
97
|
|
|
98
98
|
// src/components/chat/ChatContext.tsx
|
|
99
99
|
var import_react = __toESM(require("react"));
|
|
@@ -1881,12 +1881,14 @@ var Messages = ({
|
|
|
1881
1881
|
RenderMessage: RenderMessage2,
|
|
1882
1882
|
AssistantMessage: AssistantMessage2,
|
|
1883
1883
|
UserMessage: UserMessage2,
|
|
1884
|
+
ErrorMessage: ErrorMessage2,
|
|
1884
1885
|
ImageRenderer: ImageRenderer2,
|
|
1885
1886
|
onRegenerate,
|
|
1886
1887
|
onCopy,
|
|
1887
1888
|
onThumbsUp,
|
|
1888
1889
|
onThumbsDown,
|
|
1889
1890
|
markdownTagRenderers,
|
|
1891
|
+
chatError,
|
|
1890
1892
|
// Legacy props
|
|
1891
1893
|
RenderTextMessage,
|
|
1892
1894
|
RenderActionExecutionMessage,
|
|
@@ -1947,7 +1949,8 @@ var Messages = ({
|
|
|
1947
1949
|
index
|
|
1948
1950
|
);
|
|
1949
1951
|
}),
|
|
1950
|
-
interrupt
|
|
1952
|
+
interrupt,
|
|
1953
|
+
chatError && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ErrorMessage2, { error: chatError, isCurrentMessage: true })
|
|
1951
1954
|
] }),
|
|
1952
1955
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("footer", { className: "copilotKitMessagesFooter", ref: messagesEndRef, children })
|
|
1953
1956
|
] });
|
|
@@ -2330,15 +2333,67 @@ var Input = ({
|
|
|
2330
2333
|
] });
|
|
2331
2334
|
};
|
|
2332
2335
|
|
|
2336
|
+
// src/components/chat/messages/ErrorMessage.tsx
|
|
2337
|
+
var import_react14 = require("react");
|
|
2338
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2339
|
+
var ErrorMessage = (props) => {
|
|
2340
|
+
const { icons, labels } = useChatContext();
|
|
2341
|
+
const { error, onRegenerate, onCopy, isCurrentMessage } = props;
|
|
2342
|
+
const [copied, setCopied] = (0, import_react14.useState)(false);
|
|
2343
|
+
const handleCopy = () => {
|
|
2344
|
+
const content = error.message;
|
|
2345
|
+
if (content && onCopy) {
|
|
2346
|
+
navigator.clipboard.writeText(content);
|
|
2347
|
+
setCopied(true);
|
|
2348
|
+
onCopy(content);
|
|
2349
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
2350
|
+
} else if (content) {
|
|
2351
|
+
navigator.clipboard.writeText(content);
|
|
2352
|
+
setCopied(true);
|
|
2353
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
2354
|
+
}
|
|
2355
|
+
};
|
|
2356
|
+
const handleRegenerate = () => {
|
|
2357
|
+
if (onRegenerate)
|
|
2358
|
+
onRegenerate();
|
|
2359
|
+
};
|
|
2360
|
+
console.log(error);
|
|
2361
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "copilotKitMessage copilotKitAssistantMessage", children: [
|
|
2362
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Markdown, { content: error.message }),
|
|
2363
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: `copilotKitMessageControls ${isCurrentMessage ? "currentMessage" : ""}`, children: [
|
|
2364
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2365
|
+
"button",
|
|
2366
|
+
{
|
|
2367
|
+
className: "copilotKitMessageControlButton",
|
|
2368
|
+
onClick: handleRegenerate,
|
|
2369
|
+
"aria-label": labels.regenerateResponse,
|
|
2370
|
+
title: labels.regenerateResponse,
|
|
2371
|
+
children: icons.regenerateIcon
|
|
2372
|
+
}
|
|
2373
|
+
),
|
|
2374
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2375
|
+
"button",
|
|
2376
|
+
{
|
|
2377
|
+
className: "copilotKitMessageControlButton",
|
|
2378
|
+
onClick: handleCopy,
|
|
2379
|
+
"aria-label": labels.copyToClipboard,
|
|
2380
|
+
title: labels.copyToClipboard,
|
|
2381
|
+
children: copied ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { style: { fontSize: "10px", fontWeight: "bold" }, children: "\u2713" }) : icons.copyIcon
|
|
2382
|
+
}
|
|
2383
|
+
)
|
|
2384
|
+
] })
|
|
2385
|
+
] });
|
|
2386
|
+
};
|
|
2387
|
+
|
|
2333
2388
|
// src/components/chat/Chat.tsx
|
|
2334
|
-
var
|
|
2389
|
+
var import_react15 = __toESM(require("react"));
|
|
2335
2390
|
var import_react_core9 = require("@copilotkit/react-core");
|
|
2336
2391
|
var import_shared3 = require("@copilotkit/shared");
|
|
2337
2392
|
var import_shared4 = require("@copilotkit/shared");
|
|
2338
2393
|
var import_react_core10 = require("@copilotkit/react-core");
|
|
2339
2394
|
|
|
2340
2395
|
// src/components/chat/ImageUploadQueue.tsx
|
|
2341
|
-
var
|
|
2396
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2342
2397
|
var ImageUploadQueue = ({
|
|
2343
2398
|
images,
|
|
2344
2399
|
onRemoveImage,
|
|
@@ -2346,7 +2401,7 @@ var ImageUploadQueue = ({
|
|
|
2346
2401
|
}) => {
|
|
2347
2402
|
if (images.length === 0)
|
|
2348
2403
|
return null;
|
|
2349
|
-
return /* @__PURE__ */ (0,
|
|
2404
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2350
2405
|
"div",
|
|
2351
2406
|
{
|
|
2352
2407
|
className: `copilotKitImageUploadQueue ${className}`,
|
|
@@ -2357,7 +2412,7 @@ var ImageUploadQueue = ({
|
|
|
2357
2412
|
margin: "8px",
|
|
2358
2413
|
padding: "8px"
|
|
2359
2414
|
},
|
|
2360
|
-
children: images.map((image, index) => /* @__PURE__ */ (0,
|
|
2415
|
+
children: images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
2361
2416
|
"div",
|
|
2362
2417
|
{
|
|
2363
2418
|
className: "copilotKitImageUploadQueueItem",
|
|
@@ -2370,7 +2425,7 @@ var ImageUploadQueue = ({
|
|
|
2370
2425
|
overflow: "hidden"
|
|
2371
2426
|
},
|
|
2372
2427
|
children: [
|
|
2373
|
-
/* @__PURE__ */ (0,
|
|
2428
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2374
2429
|
"img",
|
|
2375
2430
|
{
|
|
2376
2431
|
src: `data:${image.contentType};base64,${image.bytes}`,
|
|
@@ -2382,7 +2437,7 @@ var ImageUploadQueue = ({
|
|
|
2382
2437
|
}
|
|
2383
2438
|
}
|
|
2384
2439
|
),
|
|
2385
|
-
/* @__PURE__ */ (0,
|
|
2440
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2386
2441
|
"button",
|
|
2387
2442
|
{
|
|
2388
2443
|
onClick: () => onRemoveImage(index),
|
|
@@ -2417,12 +2472,12 @@ var ImageUploadQueue = ({
|
|
|
2417
2472
|
|
|
2418
2473
|
// src/components/chat/Suggestion.tsx
|
|
2419
2474
|
var import_react_core8 = require("@copilotkit/react-core");
|
|
2420
|
-
var
|
|
2475
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2421
2476
|
function Suggestion({ title, onClick, partial, className }) {
|
|
2422
2477
|
if (!title)
|
|
2423
2478
|
return null;
|
|
2424
2479
|
const { isLoading } = (0, import_react_core8.useCopilotChatInternal)();
|
|
2425
|
-
return /* @__PURE__ */ (0,
|
|
2480
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2426
2481
|
"button",
|
|
2427
2482
|
{
|
|
2428
2483
|
disabled: partial || isLoading,
|
|
@@ -2432,15 +2487,15 @@ function Suggestion({ title, onClick, partial, className }) {
|
|
|
2432
2487
|
},
|
|
2433
2488
|
className: className || (partial ? "suggestion loading" : "suggestion"),
|
|
2434
2489
|
"data-test-id": "suggestion",
|
|
2435
|
-
children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0,
|
|
2490
|
+
children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: title })
|
|
2436
2491
|
}
|
|
2437
2492
|
);
|
|
2438
2493
|
}
|
|
2439
2494
|
|
|
2440
2495
|
// src/components/chat/Suggestions.tsx
|
|
2441
|
-
var
|
|
2496
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2442
2497
|
function Suggestions({ suggestions, onSuggestionClick }) {
|
|
2443
|
-
return /* @__PURE__ */ (0,
|
|
2498
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "suggestions", children: suggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2444
2499
|
Suggestion,
|
|
2445
2500
|
{
|
|
2446
2501
|
title: suggestion.title,
|
|
@@ -2454,7 +2509,7 @@ function Suggestions({ suggestions, onSuggestionClick }) {
|
|
|
2454
2509
|
}
|
|
2455
2510
|
|
|
2456
2511
|
// src/components/chat/Chat.tsx
|
|
2457
|
-
var
|
|
2512
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2458
2513
|
function CopilotChat({
|
|
2459
2514
|
instructions,
|
|
2460
2515
|
suggestions = "auto",
|
|
@@ -2479,11 +2534,13 @@ function CopilotChat({
|
|
|
2479
2534
|
AssistantMessage: AssistantMessage2 = AssistantMessage,
|
|
2480
2535
|
UserMessage: UserMessage2 = UserMessage,
|
|
2481
2536
|
ImageRenderer: ImageRenderer2 = ImageRenderer,
|
|
2537
|
+
ErrorMessage: ErrorMessage2 = ErrorMessage,
|
|
2482
2538
|
imageUploadsEnabled,
|
|
2483
2539
|
inputFileAccept = "image/*",
|
|
2484
2540
|
hideStopButton,
|
|
2485
2541
|
observabilityHooks,
|
|
2486
2542
|
renderError,
|
|
2543
|
+
onError,
|
|
2487
2544
|
// Legacy props - deprecated
|
|
2488
2545
|
RenderTextMessage,
|
|
2489
2546
|
RenderActionExecutionMessage,
|
|
@@ -2491,12 +2548,19 @@ function CopilotChat({
|
|
|
2491
2548
|
RenderResultMessage,
|
|
2492
2549
|
RenderImageMessage
|
|
2493
2550
|
}) {
|
|
2494
|
-
const {
|
|
2551
|
+
const {
|
|
2552
|
+
additionalInstructions,
|
|
2553
|
+
setChatInstructions,
|
|
2554
|
+
copilotApiConfig,
|
|
2555
|
+
setBannerError,
|
|
2556
|
+
setInternalErrorHandler,
|
|
2557
|
+
removeInternalErrorHandler
|
|
2558
|
+
} = (0, import_react_core9.useCopilotContext)();
|
|
2495
2559
|
const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
|
|
2496
|
-
const [selectedImages, setSelectedImages] = (0,
|
|
2497
|
-
const [chatError, setChatError] = (0,
|
|
2498
|
-
const fileInputRef = (0,
|
|
2499
|
-
const triggerObservabilityHook = (0,
|
|
2560
|
+
const [selectedImages, setSelectedImages] = (0, import_react15.useState)([]);
|
|
2561
|
+
const [chatError, setChatError] = (0, import_react15.useState)(null);
|
|
2562
|
+
const fileInputRef = (0, import_react15.useRef)(null);
|
|
2563
|
+
const triggerObservabilityHook = (0, import_react15.useCallback)(
|
|
2500
2564
|
(hookName, ...args) => {
|
|
2501
2565
|
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2502
2566
|
observabilityHooks[hookName](...args);
|
|
@@ -2515,7 +2579,7 @@ function CopilotChat({
|
|
|
2515
2579
|
},
|
|
2516
2580
|
[publicApiKey, observabilityHooks, setBannerError]
|
|
2517
2581
|
);
|
|
2518
|
-
const triggerChatError = (0,
|
|
2582
|
+
const triggerChatError = (0, import_react15.useCallback)(
|
|
2519
2583
|
(error, operation, originalError) => {
|
|
2520
2584
|
const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
|
|
2521
2585
|
setChatError({
|
|
@@ -2523,25 +2587,28 @@ function CopilotChat({
|
|
|
2523
2587
|
operation,
|
|
2524
2588
|
timestamp: Date.now()
|
|
2525
2589
|
});
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
startTime: Date.now()
|
|
2536
|
-
},
|
|
2537
|
-
technical: {
|
|
2538
|
-
environment: "browser",
|
|
2539
|
-
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
|
|
2540
|
-
stackTrace: originalError instanceof Error ? originalError.stack : void 0
|
|
2541
|
-
}
|
|
2590
|
+
const errorEvent = {
|
|
2591
|
+
type: "error",
|
|
2592
|
+
timestamp: Date.now(),
|
|
2593
|
+
context: {
|
|
2594
|
+
source: "ui",
|
|
2595
|
+
request: {
|
|
2596
|
+
operation,
|
|
2597
|
+
url: chatApiEndpoint,
|
|
2598
|
+
startTime: Date.now()
|
|
2542
2599
|
},
|
|
2543
|
-
|
|
2544
|
-
|
|
2600
|
+
technical: {
|
|
2601
|
+
environment: "browser",
|
|
2602
|
+
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
|
|
2603
|
+
stackTrace: originalError instanceof Error ? originalError.stack : void 0
|
|
2604
|
+
}
|
|
2605
|
+
},
|
|
2606
|
+
error
|
|
2607
|
+
};
|
|
2608
|
+
if (onError) {
|
|
2609
|
+
onError(errorEvent);
|
|
2610
|
+
}
|
|
2611
|
+
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks.onError)) {
|
|
2545
2612
|
observabilityHooks.onError(errorEvent);
|
|
2546
2613
|
}
|
|
2547
2614
|
if ((observabilityHooks == null ? void 0 : observabilityHooks.onError) && !publicApiKey) {
|
|
@@ -2558,7 +2625,20 @@ function CopilotChat({
|
|
|
2558
2625
|
},
|
|
2559
2626
|
[publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
|
|
2560
2627
|
);
|
|
2561
|
-
(0,
|
|
2628
|
+
(0, import_react15.useEffect)(() => {
|
|
2629
|
+
const id = "chat-component";
|
|
2630
|
+
setInternalErrorHandler({
|
|
2631
|
+
[id]: (error) => {
|
|
2632
|
+
if (!error)
|
|
2633
|
+
return;
|
|
2634
|
+
triggerChatError(error.error, "sendMessage");
|
|
2635
|
+
}
|
|
2636
|
+
});
|
|
2637
|
+
return () => {
|
|
2638
|
+
removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
|
|
2639
|
+
};
|
|
2640
|
+
}, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
|
|
2641
|
+
(0, import_react15.useEffect)(() => {
|
|
2562
2642
|
if (!imageUploadsEnabled)
|
|
2563
2643
|
return;
|
|
2564
2644
|
const handlePaste = (e) => __async(this, null, function* () {
|
|
@@ -2604,7 +2684,7 @@ function CopilotChat({
|
|
|
2604
2684
|
document.addEventListener("paste", handlePaste);
|
|
2605
2685
|
return () => document.removeEventListener("paste", handlePaste);
|
|
2606
2686
|
}, [imageUploadsEnabled, triggerChatError]);
|
|
2607
|
-
(0,
|
|
2687
|
+
(0, import_react15.useEffect)(() => {
|
|
2608
2688
|
if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
|
|
2609
2689
|
setChatInstructions(instructions || "");
|
|
2610
2690
|
return;
|
|
@@ -2632,8 +2712,8 @@ function CopilotChat({
|
|
|
2632
2712
|
onStopGeneration,
|
|
2633
2713
|
onReloadMessages
|
|
2634
2714
|
);
|
|
2635
|
-
const prevIsLoading = (0,
|
|
2636
|
-
(0,
|
|
2715
|
+
const prevIsLoading = (0, import_react15.useRef)(isLoading);
|
|
2716
|
+
(0, import_react15.useEffect)(() => {
|
|
2637
2717
|
if (prevIsLoading.current !== isLoading) {
|
|
2638
2718
|
if (isLoading) {
|
|
2639
2719
|
triggerObservabilityHook("onChatStarted");
|
|
@@ -2652,7 +2732,7 @@ function CopilotChat({
|
|
|
2652
2732
|
triggerObservabilityHook("onMessageSent", text);
|
|
2653
2733
|
return sendMessage(text, images);
|
|
2654
2734
|
};
|
|
2655
|
-
const chatContext =
|
|
2735
|
+
const chatContext = import_react15.default.useContext(ChatContext);
|
|
2656
2736
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2657
2737
|
const handleRegenerate = (messageId) => {
|
|
2658
2738
|
if (onRegenerate) {
|
|
@@ -2714,14 +2794,14 @@ function CopilotChat({
|
|
|
2714
2794
|
}
|
|
2715
2795
|
triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsDown");
|
|
2716
2796
|
};
|
|
2717
|
-
return /* @__PURE__ */ (0,
|
|
2797
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
2718
2798
|
chatError && renderError && renderError(__spreadProps(__spreadValues({}, chatError), {
|
|
2719
2799
|
onDismiss: () => setChatError(null),
|
|
2720
2800
|
onRetry: () => {
|
|
2721
2801
|
setChatError(null);
|
|
2722
2802
|
}
|
|
2723
2803
|
})),
|
|
2724
|
-
/* @__PURE__ */ (0,
|
|
2804
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2725
2805
|
Messages2,
|
|
2726
2806
|
{
|
|
2727
2807
|
AssistantMessage: AssistantMessage2,
|
|
@@ -2735,12 +2815,14 @@ function CopilotChat({
|
|
|
2735
2815
|
onThumbsDown: handleThumbsDown,
|
|
2736
2816
|
markdownTagRenderers,
|
|
2737
2817
|
ImageRenderer: ImageRenderer2,
|
|
2818
|
+
ErrorMessage: ErrorMessage2,
|
|
2819
|
+
chatError,
|
|
2738
2820
|
RenderTextMessage,
|
|
2739
2821
|
RenderActionExecutionMessage,
|
|
2740
2822
|
RenderAgentStateMessage,
|
|
2741
2823
|
RenderResultMessage,
|
|
2742
2824
|
RenderImageMessage,
|
|
2743
|
-
children: currentSuggestions.length > 0 && /* @__PURE__ */ (0,
|
|
2825
|
+
children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2744
2826
|
RenderSuggestionsList,
|
|
2745
2827
|
{
|
|
2746
2828
|
onSuggestionClick: handleSendMessage,
|
|
@@ -2749,9 +2831,9 @@ function CopilotChat({
|
|
|
2749
2831
|
)
|
|
2750
2832
|
}
|
|
2751
2833
|
),
|
|
2752
|
-
imageUploadsEnabled && /* @__PURE__ */ (0,
|
|
2753
|
-
/* @__PURE__ */ (0,
|
|
2754
|
-
/* @__PURE__ */ (0,
|
|
2834
|
+
imageUploadsEnabled && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
2835
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ImageUploadQueue, { images: selectedImages, onRemoveImage: removeSelectedImage }),
|
|
2836
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2755
2837
|
"input",
|
|
2756
2838
|
{
|
|
2757
2839
|
type: "file",
|
|
@@ -2763,7 +2845,7 @@ function CopilotChat({
|
|
|
2763
2845
|
}
|
|
2764
2846
|
)
|
|
2765
2847
|
] }),
|
|
2766
|
-
/* @__PURE__ */ (0,
|
|
2848
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2767
2849
|
Input2,
|
|
2768
2850
|
{
|
|
2769
2851
|
inProgress: isLoading,
|
|
@@ -2785,12 +2867,12 @@ function WrappedCopilotChat({
|
|
|
2785
2867
|
labels,
|
|
2786
2868
|
className
|
|
2787
2869
|
}) {
|
|
2788
|
-
const chatContext =
|
|
2870
|
+
const chatContext = import_react15.default.useContext(ChatContext);
|
|
2789
2871
|
if (!chatContext) {
|
|
2790
|
-
return /* @__PURE__ */ (0,
|
|
2791
|
-
}, children: /* @__PURE__ */ (0,
|
|
2872
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
|
|
2873
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
|
|
2792
2874
|
}
|
|
2793
|
-
return /* @__PURE__ */ (0,
|
|
2875
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children });
|
|
2794
2876
|
}
|
|
2795
2877
|
var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
|
|
2796
2878
|
var _a;
|
|
@@ -2814,15 +2896,15 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2814
2896
|
const generalContext = (0, import_react_core9.useCopilotContext)();
|
|
2815
2897
|
const messagesContext = (0, import_react_core9.useCopilotMessagesContext)();
|
|
2816
2898
|
const { actions } = generalContext;
|
|
2817
|
-
const [suggestionsFailed, setSuggestionsFailed] = (0,
|
|
2818
|
-
const hasGeneratedInitialSuggestions = (0,
|
|
2819
|
-
(0,
|
|
2899
|
+
const [suggestionsFailed, setSuggestionsFailed] = (0, import_react15.useState)(false);
|
|
2900
|
+
const hasGeneratedInitialSuggestions = (0, import_react15.useRef)(false);
|
|
2901
|
+
(0, import_react15.useEffect)(() => {
|
|
2820
2902
|
if (Array.isArray(chatSuggestions)) {
|
|
2821
2903
|
setSuggestions(chatSuggestions);
|
|
2822
2904
|
hasGeneratedInitialSuggestions.current = true;
|
|
2823
2905
|
}
|
|
2824
2906
|
}, [JSON.stringify(chatSuggestions), setSuggestions]);
|
|
2825
|
-
const generateSuggestionsWithErrorHandling = (0,
|
|
2907
|
+
const generateSuggestionsWithErrorHandling = (0, import_react15.useCallback)(
|
|
2826
2908
|
(context) => __async(void 0, null, function* () {
|
|
2827
2909
|
try {
|
|
2828
2910
|
yield generateSuggestions();
|
|
@@ -2833,7 +2915,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2833
2915
|
}),
|
|
2834
2916
|
[generateSuggestions]
|
|
2835
2917
|
);
|
|
2836
|
-
(0,
|
|
2918
|
+
(0, import_react15.useEffect)(() => {
|
|
2837
2919
|
if (chatSuggestions !== "auto" || isLoadingSuggestions || suggestionsFailed) {
|
|
2838
2920
|
return;
|
|
2839
2921
|
}
|
|
@@ -2863,13 +2945,13 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2863
2945
|
// Use stable string instead of object reference
|
|
2864
2946
|
generateSuggestionsWithErrorHandling
|
|
2865
2947
|
]);
|
|
2866
|
-
(0,
|
|
2948
|
+
(0, import_react15.useEffect)(() => {
|
|
2867
2949
|
if (chatSuggestions !== "auto") {
|
|
2868
2950
|
hasGeneratedInitialSuggestions.current = false;
|
|
2869
2951
|
setSuggestionsFailed(false);
|
|
2870
2952
|
}
|
|
2871
2953
|
}, [chatSuggestions]);
|
|
2872
|
-
const stableContext = (0,
|
|
2954
|
+
const stableContext = (0, import_react15.useMemo)(
|
|
2873
2955
|
() => __spreadValues(__spreadValues({}, generalContext), messagesContext),
|
|
2874
2956
|
[
|
|
2875
2957
|
// Only include stable dependencies
|
|
@@ -2878,12 +2960,12 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2878
2960
|
generalContext.isLoading
|
|
2879
2961
|
]
|
|
2880
2962
|
);
|
|
2881
|
-
const resetSuggestions = (0,
|
|
2963
|
+
const resetSuggestions = (0, import_react15.useCallback)(() => {
|
|
2882
2964
|
resetSuggestionsFromHook();
|
|
2883
2965
|
setSuggestionsFailed(false);
|
|
2884
2966
|
hasGeneratedInitialSuggestions.current = false;
|
|
2885
2967
|
}, [resetSuggestionsFromHook]);
|
|
2886
|
-
(0,
|
|
2968
|
+
(0, import_react15.useEffect)(() => {
|
|
2887
2969
|
onInProgress == null ? void 0 : onInProgress(isLoading);
|
|
2888
2970
|
}, [onInProgress, isLoading]);
|
|
2889
2971
|
const safelySendMessage = (messageContent, imagesToUse) => __async(void 0, null, function* () {
|
|
@@ -3029,7 +3111,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
3029
3111
|
// src/components/chat/Modal.tsx
|
|
3030
3112
|
var import_react_core11 = require("@copilotkit/react-core");
|
|
3031
3113
|
var import_shared5 = require("@copilotkit/shared");
|
|
3032
|
-
var
|
|
3114
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3033
3115
|
var CopilotModalInner = (_a) => {
|
|
3034
3116
|
var _b = _a, {
|
|
3035
3117
|
observabilityHooks,
|
|
@@ -3056,7 +3138,7 @@ var CopilotModalInner = (_a) => {
|
|
|
3056
3138
|
]);
|
|
3057
3139
|
const { copilotApiConfig, setBannerError } = (0, import_react_core11.useCopilotContext)();
|
|
3058
3140
|
const { publicApiKey } = copilotApiConfig;
|
|
3059
|
-
const triggerObservabilityHook = (0,
|
|
3141
|
+
const triggerObservabilityHook = (0, import_react16.useCallback)(
|
|
3060
3142
|
(hookName, ...args) => {
|
|
3061
3143
|
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
3062
3144
|
observabilityHooks[hookName](...args);
|
|
@@ -3076,8 +3158,8 @@ var CopilotModalInner = (_a) => {
|
|
|
3076
3158
|
[publicApiKey, observabilityHooks, setBannerError]
|
|
3077
3159
|
);
|
|
3078
3160
|
const { open } = useChatContext();
|
|
3079
|
-
const prevOpen = (0,
|
|
3080
|
-
(0,
|
|
3161
|
+
const prevOpen = (0, import_react16.useRef)(open);
|
|
3162
|
+
(0, import_react16.useEffect)(() => {
|
|
3081
3163
|
if (prevOpen.current !== open) {
|
|
3082
3164
|
onSetOpen == null ? void 0 : onSetOpen(open);
|
|
3083
3165
|
if (open) {
|
|
@@ -3088,13 +3170,13 @@ var CopilotModalInner = (_a) => {
|
|
|
3088
3170
|
prevOpen.current = open;
|
|
3089
3171
|
}
|
|
3090
3172
|
}, [open, onSetOpen, triggerObservabilityHook]);
|
|
3091
|
-
const memoizedHeader = (0,
|
|
3092
|
-
const memoizedChildren = (0,
|
|
3093
|
-
return /* @__PURE__ */ (0,
|
|
3173
|
+
const memoizedHeader = (0, import_react16.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Header2, {}), [Header2]);
|
|
3174
|
+
const memoizedChildren = (0, import_react16.useMemo)(() => children, [children]);
|
|
3175
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
|
|
3094
3176
|
memoizedChildren,
|
|
3095
|
-
/* @__PURE__ */ (0,
|
|
3096
|
-
/* @__PURE__ */ (0,
|
|
3097
|
-
/* @__PURE__ */ (0,
|
|
3177
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className, children: [
|
|
3178
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Button2, {}),
|
|
3179
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
3098
3180
|
Window2,
|
|
3099
3181
|
{
|
|
3100
3182
|
clickOutsideToClose,
|
|
@@ -3102,7 +3184,7 @@ var CopilotModalInner = (_a) => {
|
|
|
3102
3184
|
hitEscapeToClose,
|
|
3103
3185
|
children: [
|
|
3104
3186
|
memoizedHeader,
|
|
3105
|
-
/* @__PURE__ */ (0,
|
|
3187
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CopilotChat, __spreadProps(__spreadValues({}, chatProps), { observabilityHooks }))
|
|
3106
3188
|
]
|
|
3107
3189
|
}
|
|
3108
3190
|
)
|
|
@@ -3169,8 +3251,8 @@ var CopilotModal = (_a) => {
|
|
|
3169
3251
|
"children",
|
|
3170
3252
|
"observabilityHooks"
|
|
3171
3253
|
]);
|
|
3172
|
-
const [openState, setOpenState] =
|
|
3173
|
-
return /* @__PURE__ */ (0,
|
|
3254
|
+
const [openState, setOpenState] = import_react16.default.useState(defaultOpen);
|
|
3255
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3174
3256
|
CopilotModalInner,
|
|
3175
3257
|
__spreadProps(__spreadValues({
|
|
3176
3258
|
observabilityHooks,
|
|
@@ -3204,22 +3286,22 @@ var CopilotModal = (_a) => {
|
|
|
3204
3286
|
};
|
|
3205
3287
|
|
|
3206
3288
|
// src/components/chat/Popup.tsx
|
|
3207
|
-
var
|
|
3289
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
3208
3290
|
function CopilotPopup(props) {
|
|
3209
3291
|
props = __spreadProps(__spreadValues({}, props), {
|
|
3210
3292
|
className: props.className ? props.className + " copilotKitPopup" : "copilotKitPopup"
|
|
3211
3293
|
});
|
|
3212
|
-
return /* @__PURE__ */ (0,
|
|
3294
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CopilotModal, __spreadProps(__spreadValues({}, props), { children: props.children }));
|
|
3213
3295
|
}
|
|
3214
3296
|
|
|
3215
3297
|
// src/components/chat/Sidebar.tsx
|
|
3216
|
-
var
|
|
3217
|
-
var
|
|
3298
|
+
var import_react17 = require("react");
|
|
3299
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
3218
3300
|
function CopilotSidebar(props) {
|
|
3219
3301
|
props = __spreadProps(__spreadValues({}, props), {
|
|
3220
3302
|
className: props.className ? props.className + " copilotKitSidebar" : "copilotKitSidebar"
|
|
3221
3303
|
});
|
|
3222
|
-
const [expandedClassName, setExpandedClassName] = (0,
|
|
3304
|
+
const [expandedClassName, setExpandedClassName] = (0, import_react17.useState)(
|
|
3223
3305
|
props.defaultOpen ? "sidebarExpanded" : ""
|
|
3224
3306
|
);
|
|
3225
3307
|
const onSetOpen = (open) => {
|
|
@@ -3227,7 +3309,7 @@ function CopilotSidebar(props) {
|
|
|
3227
3309
|
(_a = props.onSetOpen) == null ? void 0 : _a.call(props, open);
|
|
3228
3310
|
setExpandedClassName(open ? "sidebarExpanded" : "");
|
|
3229
3311
|
};
|
|
3230
|
-
return /* @__PURE__ */ (0,
|
|
3312
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: `copilotKitSidebarContentWrapper ${expandedClassName}`, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(CopilotModal, __spreadProps(__spreadValues(__spreadValues({}, props), { onSetOpen }), { children: props.children })) });
|
|
3231
3313
|
}
|
|
3232
3314
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3233
3315
|
0 && (module.exports = {
|