@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
package/dist/components/index.js
CHANGED
|
@@ -95,7 +95,7 @@ __export(components_exports, {
|
|
|
95
95
|
module.exports = __toCommonJS(components_exports);
|
|
96
96
|
|
|
97
97
|
// src/components/chat/Modal.tsx
|
|
98
|
-
var
|
|
98
|
+
var import_react16 = __toESM(require("react"));
|
|
99
99
|
|
|
100
100
|
// src/components/chat/ChatContext.tsx
|
|
101
101
|
var import_react = __toESM(require("react"));
|
|
@@ -1883,12 +1883,14 @@ var Messages = ({
|
|
|
1883
1883
|
RenderMessage: RenderMessage2,
|
|
1884
1884
|
AssistantMessage: AssistantMessage2,
|
|
1885
1885
|
UserMessage: UserMessage2,
|
|
1886
|
+
ErrorMessage: ErrorMessage2,
|
|
1886
1887
|
ImageRenderer: ImageRenderer2,
|
|
1887
1888
|
onRegenerate,
|
|
1888
1889
|
onCopy,
|
|
1889
1890
|
onThumbsUp,
|
|
1890
1891
|
onThumbsDown,
|
|
1891
1892
|
markdownTagRenderers,
|
|
1893
|
+
chatError,
|
|
1892
1894
|
// Legacy props
|
|
1893
1895
|
RenderTextMessage,
|
|
1894
1896
|
RenderActionExecutionMessage,
|
|
@@ -1949,7 +1951,8 @@ var Messages = ({
|
|
|
1949
1951
|
index
|
|
1950
1952
|
);
|
|
1951
1953
|
}),
|
|
1952
|
-
interrupt
|
|
1954
|
+
interrupt,
|
|
1955
|
+
chatError && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ErrorMessage2, { error: chatError, isCurrentMessage: true })
|
|
1953
1956
|
] }),
|
|
1954
1957
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("footer", { className: "copilotKitMessagesFooter", ref: messagesEndRef, children })
|
|
1955
1958
|
] });
|
|
@@ -2332,15 +2335,67 @@ var Input = ({
|
|
|
2332
2335
|
] });
|
|
2333
2336
|
};
|
|
2334
2337
|
|
|
2338
|
+
// src/components/chat/messages/ErrorMessage.tsx
|
|
2339
|
+
var import_react14 = require("react");
|
|
2340
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2341
|
+
var ErrorMessage = (props) => {
|
|
2342
|
+
const { icons, labels } = useChatContext();
|
|
2343
|
+
const { error, onRegenerate, onCopy, isCurrentMessage } = props;
|
|
2344
|
+
const [copied, setCopied] = (0, import_react14.useState)(false);
|
|
2345
|
+
const handleCopy = () => {
|
|
2346
|
+
const content = error.message;
|
|
2347
|
+
if (content && onCopy) {
|
|
2348
|
+
navigator.clipboard.writeText(content);
|
|
2349
|
+
setCopied(true);
|
|
2350
|
+
onCopy(content);
|
|
2351
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
2352
|
+
} else if (content) {
|
|
2353
|
+
navigator.clipboard.writeText(content);
|
|
2354
|
+
setCopied(true);
|
|
2355
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
2356
|
+
}
|
|
2357
|
+
};
|
|
2358
|
+
const handleRegenerate = () => {
|
|
2359
|
+
if (onRegenerate)
|
|
2360
|
+
onRegenerate();
|
|
2361
|
+
};
|
|
2362
|
+
console.log(error);
|
|
2363
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "copilotKitMessage copilotKitAssistantMessage", children: [
|
|
2364
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Markdown, { content: error.message }),
|
|
2365
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: `copilotKitMessageControls ${isCurrentMessage ? "currentMessage" : ""}`, children: [
|
|
2366
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2367
|
+
"button",
|
|
2368
|
+
{
|
|
2369
|
+
className: "copilotKitMessageControlButton",
|
|
2370
|
+
onClick: handleRegenerate,
|
|
2371
|
+
"aria-label": labels.regenerateResponse,
|
|
2372
|
+
title: labels.regenerateResponse,
|
|
2373
|
+
children: icons.regenerateIcon
|
|
2374
|
+
}
|
|
2375
|
+
),
|
|
2376
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2377
|
+
"button",
|
|
2378
|
+
{
|
|
2379
|
+
className: "copilotKitMessageControlButton",
|
|
2380
|
+
onClick: handleCopy,
|
|
2381
|
+
"aria-label": labels.copyToClipboard,
|
|
2382
|
+
title: labels.copyToClipboard,
|
|
2383
|
+
children: copied ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { style: { fontSize: "10px", fontWeight: "bold" }, children: "\u2713" }) : icons.copyIcon
|
|
2384
|
+
}
|
|
2385
|
+
)
|
|
2386
|
+
] })
|
|
2387
|
+
] });
|
|
2388
|
+
};
|
|
2389
|
+
|
|
2335
2390
|
// src/components/chat/Chat.tsx
|
|
2336
|
-
var
|
|
2391
|
+
var import_react15 = __toESM(require("react"));
|
|
2337
2392
|
var import_react_core9 = require("@copilotkit/react-core");
|
|
2338
2393
|
var import_shared3 = require("@copilotkit/shared");
|
|
2339
2394
|
var import_shared4 = require("@copilotkit/shared");
|
|
2340
2395
|
var import_react_core10 = require("@copilotkit/react-core");
|
|
2341
2396
|
|
|
2342
2397
|
// src/components/chat/ImageUploadQueue.tsx
|
|
2343
|
-
var
|
|
2398
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2344
2399
|
var ImageUploadQueue = ({
|
|
2345
2400
|
images,
|
|
2346
2401
|
onRemoveImage,
|
|
@@ -2348,7 +2403,7 @@ var ImageUploadQueue = ({
|
|
|
2348
2403
|
}) => {
|
|
2349
2404
|
if (images.length === 0)
|
|
2350
2405
|
return null;
|
|
2351
|
-
return /* @__PURE__ */ (0,
|
|
2406
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2352
2407
|
"div",
|
|
2353
2408
|
{
|
|
2354
2409
|
className: `copilotKitImageUploadQueue ${className}`,
|
|
@@ -2359,7 +2414,7 @@ var ImageUploadQueue = ({
|
|
|
2359
2414
|
margin: "8px",
|
|
2360
2415
|
padding: "8px"
|
|
2361
2416
|
},
|
|
2362
|
-
children: images.map((image, index) => /* @__PURE__ */ (0,
|
|
2417
|
+
children: images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
2363
2418
|
"div",
|
|
2364
2419
|
{
|
|
2365
2420
|
className: "copilotKitImageUploadQueueItem",
|
|
@@ -2372,7 +2427,7 @@ var ImageUploadQueue = ({
|
|
|
2372
2427
|
overflow: "hidden"
|
|
2373
2428
|
},
|
|
2374
2429
|
children: [
|
|
2375
|
-
/* @__PURE__ */ (0,
|
|
2430
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2376
2431
|
"img",
|
|
2377
2432
|
{
|
|
2378
2433
|
src: `data:${image.contentType};base64,${image.bytes}`,
|
|
@@ -2384,7 +2439,7 @@ var ImageUploadQueue = ({
|
|
|
2384
2439
|
}
|
|
2385
2440
|
}
|
|
2386
2441
|
),
|
|
2387
|
-
/* @__PURE__ */ (0,
|
|
2442
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2388
2443
|
"button",
|
|
2389
2444
|
{
|
|
2390
2445
|
onClick: () => onRemoveImage(index),
|
|
@@ -2419,12 +2474,12 @@ var ImageUploadQueue = ({
|
|
|
2419
2474
|
|
|
2420
2475
|
// src/components/chat/Suggestion.tsx
|
|
2421
2476
|
var import_react_core8 = require("@copilotkit/react-core");
|
|
2422
|
-
var
|
|
2477
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2423
2478
|
function Suggestion({ title, onClick, partial, className }) {
|
|
2424
2479
|
if (!title)
|
|
2425
2480
|
return null;
|
|
2426
2481
|
const { isLoading } = (0, import_react_core8.useCopilotChatInternal)();
|
|
2427
|
-
return /* @__PURE__ */ (0,
|
|
2482
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2428
2483
|
"button",
|
|
2429
2484
|
{
|
|
2430
2485
|
disabled: partial || isLoading,
|
|
@@ -2434,15 +2489,15 @@ function Suggestion({ title, onClick, partial, className }) {
|
|
|
2434
2489
|
},
|
|
2435
2490
|
className: className || (partial ? "suggestion loading" : "suggestion"),
|
|
2436
2491
|
"data-test-id": "suggestion",
|
|
2437
|
-
children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0,
|
|
2492
|
+
children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: title })
|
|
2438
2493
|
}
|
|
2439
2494
|
);
|
|
2440
2495
|
}
|
|
2441
2496
|
|
|
2442
2497
|
// src/components/chat/Suggestions.tsx
|
|
2443
|
-
var
|
|
2498
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2444
2499
|
function Suggestions({ suggestions, onSuggestionClick }) {
|
|
2445
|
-
return /* @__PURE__ */ (0,
|
|
2500
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "suggestions", children: suggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2446
2501
|
Suggestion,
|
|
2447
2502
|
{
|
|
2448
2503
|
title: suggestion.title,
|
|
@@ -2456,7 +2511,7 @@ function Suggestions({ suggestions, onSuggestionClick }) {
|
|
|
2456
2511
|
}
|
|
2457
2512
|
|
|
2458
2513
|
// src/components/chat/Chat.tsx
|
|
2459
|
-
var
|
|
2514
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2460
2515
|
function CopilotChat({
|
|
2461
2516
|
instructions,
|
|
2462
2517
|
suggestions = "auto",
|
|
@@ -2481,11 +2536,13 @@ function CopilotChat({
|
|
|
2481
2536
|
AssistantMessage: AssistantMessage2 = AssistantMessage,
|
|
2482
2537
|
UserMessage: UserMessage2 = UserMessage,
|
|
2483
2538
|
ImageRenderer: ImageRenderer2 = ImageRenderer,
|
|
2539
|
+
ErrorMessage: ErrorMessage2 = ErrorMessage,
|
|
2484
2540
|
imageUploadsEnabled,
|
|
2485
2541
|
inputFileAccept = "image/*",
|
|
2486
2542
|
hideStopButton,
|
|
2487
2543
|
observabilityHooks,
|
|
2488
2544
|
renderError,
|
|
2545
|
+
onError,
|
|
2489
2546
|
// Legacy props - deprecated
|
|
2490
2547
|
RenderTextMessage,
|
|
2491
2548
|
RenderActionExecutionMessage,
|
|
@@ -2493,12 +2550,19 @@ function CopilotChat({
|
|
|
2493
2550
|
RenderResultMessage,
|
|
2494
2551
|
RenderImageMessage
|
|
2495
2552
|
}) {
|
|
2496
|
-
const {
|
|
2553
|
+
const {
|
|
2554
|
+
additionalInstructions,
|
|
2555
|
+
setChatInstructions,
|
|
2556
|
+
copilotApiConfig,
|
|
2557
|
+
setBannerError,
|
|
2558
|
+
setInternalErrorHandler,
|
|
2559
|
+
removeInternalErrorHandler
|
|
2560
|
+
} = (0, import_react_core9.useCopilotContext)();
|
|
2497
2561
|
const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
|
|
2498
|
-
const [selectedImages, setSelectedImages] = (0,
|
|
2499
|
-
const [chatError, setChatError] = (0,
|
|
2500
|
-
const fileInputRef = (0,
|
|
2501
|
-
const triggerObservabilityHook = (0,
|
|
2562
|
+
const [selectedImages, setSelectedImages] = (0, import_react15.useState)([]);
|
|
2563
|
+
const [chatError, setChatError] = (0, import_react15.useState)(null);
|
|
2564
|
+
const fileInputRef = (0, import_react15.useRef)(null);
|
|
2565
|
+
const triggerObservabilityHook = (0, import_react15.useCallback)(
|
|
2502
2566
|
(hookName, ...args) => {
|
|
2503
2567
|
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2504
2568
|
observabilityHooks[hookName](...args);
|
|
@@ -2517,7 +2581,7 @@ function CopilotChat({
|
|
|
2517
2581
|
},
|
|
2518
2582
|
[publicApiKey, observabilityHooks, setBannerError]
|
|
2519
2583
|
);
|
|
2520
|
-
const triggerChatError = (0,
|
|
2584
|
+
const triggerChatError = (0, import_react15.useCallback)(
|
|
2521
2585
|
(error, operation, originalError) => {
|
|
2522
2586
|
const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
|
|
2523
2587
|
setChatError({
|
|
@@ -2525,25 +2589,28 @@ function CopilotChat({
|
|
|
2525
2589
|
operation,
|
|
2526
2590
|
timestamp: Date.now()
|
|
2527
2591
|
});
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
startTime: Date.now()
|
|
2538
|
-
},
|
|
2539
|
-
technical: {
|
|
2540
|
-
environment: "browser",
|
|
2541
|
-
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
|
|
2542
|
-
stackTrace: originalError instanceof Error ? originalError.stack : void 0
|
|
2543
|
-
}
|
|
2592
|
+
const errorEvent = {
|
|
2593
|
+
type: "error",
|
|
2594
|
+
timestamp: Date.now(),
|
|
2595
|
+
context: {
|
|
2596
|
+
source: "ui",
|
|
2597
|
+
request: {
|
|
2598
|
+
operation,
|
|
2599
|
+
url: chatApiEndpoint,
|
|
2600
|
+
startTime: Date.now()
|
|
2544
2601
|
},
|
|
2545
|
-
|
|
2546
|
-
|
|
2602
|
+
technical: {
|
|
2603
|
+
environment: "browser",
|
|
2604
|
+
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
|
|
2605
|
+
stackTrace: originalError instanceof Error ? originalError.stack : void 0
|
|
2606
|
+
}
|
|
2607
|
+
},
|
|
2608
|
+
error
|
|
2609
|
+
};
|
|
2610
|
+
if (onError) {
|
|
2611
|
+
onError(errorEvent);
|
|
2612
|
+
}
|
|
2613
|
+
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks.onError)) {
|
|
2547
2614
|
observabilityHooks.onError(errorEvent);
|
|
2548
2615
|
}
|
|
2549
2616
|
if ((observabilityHooks == null ? void 0 : observabilityHooks.onError) && !publicApiKey) {
|
|
@@ -2560,7 +2627,20 @@ function CopilotChat({
|
|
|
2560
2627
|
},
|
|
2561
2628
|
[publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
|
|
2562
2629
|
);
|
|
2563
|
-
(0,
|
|
2630
|
+
(0, import_react15.useEffect)(() => {
|
|
2631
|
+
const id = "chat-component";
|
|
2632
|
+
setInternalErrorHandler({
|
|
2633
|
+
[id]: (error) => {
|
|
2634
|
+
if (!error)
|
|
2635
|
+
return;
|
|
2636
|
+
triggerChatError(error.error, "sendMessage");
|
|
2637
|
+
}
|
|
2638
|
+
});
|
|
2639
|
+
return () => {
|
|
2640
|
+
removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
|
|
2641
|
+
};
|
|
2642
|
+
}, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
|
|
2643
|
+
(0, import_react15.useEffect)(() => {
|
|
2564
2644
|
if (!imageUploadsEnabled)
|
|
2565
2645
|
return;
|
|
2566
2646
|
const handlePaste = (e) => __async(this, null, function* () {
|
|
@@ -2606,7 +2686,7 @@ function CopilotChat({
|
|
|
2606
2686
|
document.addEventListener("paste", handlePaste);
|
|
2607
2687
|
return () => document.removeEventListener("paste", handlePaste);
|
|
2608
2688
|
}, [imageUploadsEnabled, triggerChatError]);
|
|
2609
|
-
(0,
|
|
2689
|
+
(0, import_react15.useEffect)(() => {
|
|
2610
2690
|
if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
|
|
2611
2691
|
setChatInstructions(instructions || "");
|
|
2612
2692
|
return;
|
|
@@ -2634,8 +2714,8 @@ function CopilotChat({
|
|
|
2634
2714
|
onStopGeneration,
|
|
2635
2715
|
onReloadMessages
|
|
2636
2716
|
);
|
|
2637
|
-
const prevIsLoading = (0,
|
|
2638
|
-
(0,
|
|
2717
|
+
const prevIsLoading = (0, import_react15.useRef)(isLoading);
|
|
2718
|
+
(0, import_react15.useEffect)(() => {
|
|
2639
2719
|
if (prevIsLoading.current !== isLoading) {
|
|
2640
2720
|
if (isLoading) {
|
|
2641
2721
|
triggerObservabilityHook("onChatStarted");
|
|
@@ -2654,7 +2734,7 @@ function CopilotChat({
|
|
|
2654
2734
|
triggerObservabilityHook("onMessageSent", text);
|
|
2655
2735
|
return sendMessage(text, images);
|
|
2656
2736
|
};
|
|
2657
|
-
const chatContext =
|
|
2737
|
+
const chatContext = import_react15.default.useContext(ChatContext);
|
|
2658
2738
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2659
2739
|
const handleRegenerate = (messageId) => {
|
|
2660
2740
|
if (onRegenerate) {
|
|
@@ -2716,14 +2796,14 @@ function CopilotChat({
|
|
|
2716
2796
|
}
|
|
2717
2797
|
triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsDown");
|
|
2718
2798
|
};
|
|
2719
|
-
return /* @__PURE__ */ (0,
|
|
2799
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
2720
2800
|
chatError && renderError && renderError(__spreadProps(__spreadValues({}, chatError), {
|
|
2721
2801
|
onDismiss: () => setChatError(null),
|
|
2722
2802
|
onRetry: () => {
|
|
2723
2803
|
setChatError(null);
|
|
2724
2804
|
}
|
|
2725
2805
|
})),
|
|
2726
|
-
/* @__PURE__ */ (0,
|
|
2806
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2727
2807
|
Messages2,
|
|
2728
2808
|
{
|
|
2729
2809
|
AssistantMessage: AssistantMessage2,
|
|
@@ -2737,12 +2817,14 @@ function CopilotChat({
|
|
|
2737
2817
|
onThumbsDown: handleThumbsDown,
|
|
2738
2818
|
markdownTagRenderers,
|
|
2739
2819
|
ImageRenderer: ImageRenderer2,
|
|
2820
|
+
ErrorMessage: ErrorMessage2,
|
|
2821
|
+
chatError,
|
|
2740
2822
|
RenderTextMessage,
|
|
2741
2823
|
RenderActionExecutionMessage,
|
|
2742
2824
|
RenderAgentStateMessage,
|
|
2743
2825
|
RenderResultMessage,
|
|
2744
2826
|
RenderImageMessage,
|
|
2745
|
-
children: currentSuggestions.length > 0 && /* @__PURE__ */ (0,
|
|
2827
|
+
children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2746
2828
|
RenderSuggestionsList,
|
|
2747
2829
|
{
|
|
2748
2830
|
onSuggestionClick: handleSendMessage,
|
|
@@ -2751,9 +2833,9 @@ function CopilotChat({
|
|
|
2751
2833
|
)
|
|
2752
2834
|
}
|
|
2753
2835
|
),
|
|
2754
|
-
imageUploadsEnabled && /* @__PURE__ */ (0,
|
|
2755
|
-
/* @__PURE__ */ (0,
|
|
2756
|
-
/* @__PURE__ */ (0,
|
|
2836
|
+
imageUploadsEnabled && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
2837
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ImageUploadQueue, { images: selectedImages, onRemoveImage: removeSelectedImage }),
|
|
2838
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2757
2839
|
"input",
|
|
2758
2840
|
{
|
|
2759
2841
|
type: "file",
|
|
@@ -2765,7 +2847,7 @@ function CopilotChat({
|
|
|
2765
2847
|
}
|
|
2766
2848
|
)
|
|
2767
2849
|
] }),
|
|
2768
|
-
/* @__PURE__ */ (0,
|
|
2850
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2769
2851
|
Input2,
|
|
2770
2852
|
{
|
|
2771
2853
|
inProgress: isLoading,
|
|
@@ -2787,12 +2869,12 @@ function WrappedCopilotChat({
|
|
|
2787
2869
|
labels,
|
|
2788
2870
|
className
|
|
2789
2871
|
}) {
|
|
2790
|
-
const chatContext =
|
|
2872
|
+
const chatContext = import_react15.default.useContext(ChatContext);
|
|
2791
2873
|
if (!chatContext) {
|
|
2792
|
-
return /* @__PURE__ */ (0,
|
|
2793
|
-
}, children: /* @__PURE__ */ (0,
|
|
2874
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
|
|
2875
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
|
|
2794
2876
|
}
|
|
2795
|
-
return /* @__PURE__ */ (0,
|
|
2877
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children });
|
|
2796
2878
|
}
|
|
2797
2879
|
var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
|
|
2798
2880
|
var _a;
|
|
@@ -2816,15 +2898,15 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2816
2898
|
const generalContext = (0, import_react_core9.useCopilotContext)();
|
|
2817
2899
|
const messagesContext = (0, import_react_core9.useCopilotMessagesContext)();
|
|
2818
2900
|
const { actions } = generalContext;
|
|
2819
|
-
const [suggestionsFailed, setSuggestionsFailed] = (0,
|
|
2820
|
-
const hasGeneratedInitialSuggestions = (0,
|
|
2821
|
-
(0,
|
|
2901
|
+
const [suggestionsFailed, setSuggestionsFailed] = (0, import_react15.useState)(false);
|
|
2902
|
+
const hasGeneratedInitialSuggestions = (0, import_react15.useRef)(false);
|
|
2903
|
+
(0, import_react15.useEffect)(() => {
|
|
2822
2904
|
if (Array.isArray(chatSuggestions)) {
|
|
2823
2905
|
setSuggestions(chatSuggestions);
|
|
2824
2906
|
hasGeneratedInitialSuggestions.current = true;
|
|
2825
2907
|
}
|
|
2826
2908
|
}, [JSON.stringify(chatSuggestions), setSuggestions]);
|
|
2827
|
-
const generateSuggestionsWithErrorHandling = (0,
|
|
2909
|
+
const generateSuggestionsWithErrorHandling = (0, import_react15.useCallback)(
|
|
2828
2910
|
(context) => __async(void 0, null, function* () {
|
|
2829
2911
|
try {
|
|
2830
2912
|
yield generateSuggestions();
|
|
@@ -2835,7 +2917,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2835
2917
|
}),
|
|
2836
2918
|
[generateSuggestions]
|
|
2837
2919
|
);
|
|
2838
|
-
(0,
|
|
2920
|
+
(0, import_react15.useEffect)(() => {
|
|
2839
2921
|
if (chatSuggestions !== "auto" || isLoadingSuggestions || suggestionsFailed) {
|
|
2840
2922
|
return;
|
|
2841
2923
|
}
|
|
@@ -2865,13 +2947,13 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2865
2947
|
// Use stable string instead of object reference
|
|
2866
2948
|
generateSuggestionsWithErrorHandling
|
|
2867
2949
|
]);
|
|
2868
|
-
(0,
|
|
2950
|
+
(0, import_react15.useEffect)(() => {
|
|
2869
2951
|
if (chatSuggestions !== "auto") {
|
|
2870
2952
|
hasGeneratedInitialSuggestions.current = false;
|
|
2871
2953
|
setSuggestionsFailed(false);
|
|
2872
2954
|
}
|
|
2873
2955
|
}, [chatSuggestions]);
|
|
2874
|
-
const stableContext = (0,
|
|
2956
|
+
const stableContext = (0, import_react15.useMemo)(
|
|
2875
2957
|
() => __spreadValues(__spreadValues({}, generalContext), messagesContext),
|
|
2876
2958
|
[
|
|
2877
2959
|
// Only include stable dependencies
|
|
@@ -2880,12 +2962,12 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2880
2962
|
generalContext.isLoading
|
|
2881
2963
|
]
|
|
2882
2964
|
);
|
|
2883
|
-
const resetSuggestions = (0,
|
|
2965
|
+
const resetSuggestions = (0, import_react15.useCallback)(() => {
|
|
2884
2966
|
resetSuggestionsFromHook();
|
|
2885
2967
|
setSuggestionsFailed(false);
|
|
2886
2968
|
hasGeneratedInitialSuggestions.current = false;
|
|
2887
2969
|
}, [resetSuggestionsFromHook]);
|
|
2888
|
-
(0,
|
|
2970
|
+
(0, import_react15.useEffect)(() => {
|
|
2889
2971
|
onInProgress == null ? void 0 : onInProgress(isLoading);
|
|
2890
2972
|
}, [onInProgress, isLoading]);
|
|
2891
2973
|
const safelySendMessage = (messageContent, imagesToUse) => __async(void 0, null, function* () {
|
|
@@ -3031,7 +3113,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
3031
3113
|
// src/components/chat/Modal.tsx
|
|
3032
3114
|
var import_react_core11 = require("@copilotkit/react-core");
|
|
3033
3115
|
var import_shared5 = require("@copilotkit/shared");
|
|
3034
|
-
var
|
|
3116
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3035
3117
|
var CopilotModalInner = (_a) => {
|
|
3036
3118
|
var _b = _a, {
|
|
3037
3119
|
observabilityHooks,
|
|
@@ -3058,7 +3140,7 @@ var CopilotModalInner = (_a) => {
|
|
|
3058
3140
|
]);
|
|
3059
3141
|
const { copilotApiConfig, setBannerError } = (0, import_react_core11.useCopilotContext)();
|
|
3060
3142
|
const { publicApiKey } = copilotApiConfig;
|
|
3061
|
-
const triggerObservabilityHook = (0,
|
|
3143
|
+
const triggerObservabilityHook = (0, import_react16.useCallback)(
|
|
3062
3144
|
(hookName, ...args) => {
|
|
3063
3145
|
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
3064
3146
|
observabilityHooks[hookName](...args);
|
|
@@ -3078,8 +3160,8 @@ var CopilotModalInner = (_a) => {
|
|
|
3078
3160
|
[publicApiKey, observabilityHooks, setBannerError]
|
|
3079
3161
|
);
|
|
3080
3162
|
const { open } = useChatContext();
|
|
3081
|
-
const prevOpen = (0,
|
|
3082
|
-
(0,
|
|
3163
|
+
const prevOpen = (0, import_react16.useRef)(open);
|
|
3164
|
+
(0, import_react16.useEffect)(() => {
|
|
3083
3165
|
if (prevOpen.current !== open) {
|
|
3084
3166
|
onSetOpen == null ? void 0 : onSetOpen(open);
|
|
3085
3167
|
if (open) {
|
|
@@ -3090,13 +3172,13 @@ var CopilotModalInner = (_a) => {
|
|
|
3090
3172
|
prevOpen.current = open;
|
|
3091
3173
|
}
|
|
3092
3174
|
}, [open, onSetOpen, triggerObservabilityHook]);
|
|
3093
|
-
const memoizedHeader = (0,
|
|
3094
|
-
const memoizedChildren = (0,
|
|
3095
|
-
return /* @__PURE__ */ (0,
|
|
3175
|
+
const memoizedHeader = (0, import_react16.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Header2, {}), [Header2]);
|
|
3176
|
+
const memoizedChildren = (0, import_react16.useMemo)(() => children, [children]);
|
|
3177
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
|
|
3096
3178
|
memoizedChildren,
|
|
3097
|
-
/* @__PURE__ */ (0,
|
|
3098
|
-
/* @__PURE__ */ (0,
|
|
3099
|
-
/* @__PURE__ */ (0,
|
|
3179
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className, children: [
|
|
3180
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Button2, {}),
|
|
3181
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
3100
3182
|
Window2,
|
|
3101
3183
|
{
|
|
3102
3184
|
clickOutsideToClose,
|
|
@@ -3104,7 +3186,7 @@ var CopilotModalInner = (_a) => {
|
|
|
3104
3186
|
hitEscapeToClose,
|
|
3105
3187
|
children: [
|
|
3106
3188
|
memoizedHeader,
|
|
3107
|
-
/* @__PURE__ */ (0,
|
|
3189
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CopilotChat, __spreadProps(__spreadValues({}, chatProps), { observabilityHooks }))
|
|
3108
3190
|
]
|
|
3109
3191
|
}
|
|
3110
3192
|
)
|
|
@@ -3171,8 +3253,8 @@ var CopilotModal = (_a) => {
|
|
|
3171
3253
|
"children",
|
|
3172
3254
|
"observabilityHooks"
|
|
3173
3255
|
]);
|
|
3174
|
-
const [openState, setOpenState] =
|
|
3175
|
-
return /* @__PURE__ */ (0,
|
|
3256
|
+
const [openState, setOpenState] = import_react16.default.useState(defaultOpen);
|
|
3257
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3176
3258
|
CopilotModalInner,
|
|
3177
3259
|
__spreadProps(__spreadValues({
|
|
3178
3260
|
observabilityHooks,
|
|
@@ -3206,22 +3288,22 @@ var CopilotModal = (_a) => {
|
|
|
3206
3288
|
};
|
|
3207
3289
|
|
|
3208
3290
|
// src/components/chat/Popup.tsx
|
|
3209
|
-
var
|
|
3291
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
3210
3292
|
function CopilotPopup(props) {
|
|
3211
3293
|
props = __spreadProps(__spreadValues({}, props), {
|
|
3212
3294
|
className: props.className ? props.className + " copilotKitPopup" : "copilotKitPopup"
|
|
3213
3295
|
});
|
|
3214
|
-
return /* @__PURE__ */ (0,
|
|
3296
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CopilotModal, __spreadProps(__spreadValues({}, props), { children: props.children }));
|
|
3215
3297
|
}
|
|
3216
3298
|
|
|
3217
3299
|
// src/components/chat/Sidebar.tsx
|
|
3218
|
-
var
|
|
3219
|
-
var
|
|
3300
|
+
var import_react17 = require("react");
|
|
3301
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
3220
3302
|
function CopilotSidebar(props) {
|
|
3221
3303
|
props = __spreadProps(__spreadValues({}, props), {
|
|
3222
3304
|
className: props.className ? props.className + " copilotKitSidebar" : "copilotKitSidebar"
|
|
3223
3305
|
});
|
|
3224
|
-
const [expandedClassName, setExpandedClassName] = (0,
|
|
3306
|
+
const [expandedClassName, setExpandedClassName] = (0, import_react17.useState)(
|
|
3225
3307
|
props.defaultOpen ? "sidebarExpanded" : ""
|
|
3226
3308
|
);
|
|
3227
3309
|
const onSetOpen = (open) => {
|
|
@@ -3229,7 +3311,7 @@ function CopilotSidebar(props) {
|
|
|
3229
3311
|
(_a = props.onSetOpen) == null ? void 0 : _a.call(props, open);
|
|
3230
3312
|
setExpandedClassName(open ? "sidebarExpanded" : "");
|
|
3231
3313
|
};
|
|
3232
|
-
return /* @__PURE__ */ (0,
|
|
3314
|
+
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 })) });
|
|
3233
3315
|
}
|
|
3234
3316
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3235
3317
|
0 && (module.exports = {
|