@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
|
CopilotPopup
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-QQDCZRPA.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";
|
|
@@ -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-59740e82';
|
|
11
11
|
import '@copilotkit/react-core/dist/types/coagent-action';
|
|
12
12
|
import '@copilotkit/react-core';
|
|
13
13
|
import '@copilotkit/runtime-client-gql';
|
|
@@ -82,10 +82,10 @@ __export(Sidebar_exports, {
|
|
|
82
82
|
CopilotSidebar: () => CopilotSidebar
|
|
83
83
|
});
|
|
84
84
|
module.exports = __toCommonJS(Sidebar_exports);
|
|
85
|
-
var
|
|
85
|
+
var import_react17 = require("react");
|
|
86
86
|
|
|
87
87
|
// src/components/chat/Modal.tsx
|
|
88
|
-
var
|
|
88
|
+
var import_react16 = __toESM(require("react"));
|
|
89
89
|
|
|
90
90
|
// src/components/chat/ChatContext.tsx
|
|
91
91
|
var import_react = __toESM(require("react"));
|
|
@@ -1873,12 +1873,14 @@ var Messages = ({
|
|
|
1873
1873
|
RenderMessage: RenderMessage2,
|
|
1874
1874
|
AssistantMessage: AssistantMessage2,
|
|
1875
1875
|
UserMessage: UserMessage2,
|
|
1876
|
+
ErrorMessage: ErrorMessage2,
|
|
1876
1877
|
ImageRenderer: ImageRenderer2,
|
|
1877
1878
|
onRegenerate,
|
|
1878
1879
|
onCopy,
|
|
1879
1880
|
onThumbsUp,
|
|
1880
1881
|
onThumbsDown,
|
|
1881
1882
|
markdownTagRenderers,
|
|
1883
|
+
chatError,
|
|
1882
1884
|
// Legacy props
|
|
1883
1885
|
RenderTextMessage,
|
|
1884
1886
|
RenderActionExecutionMessage,
|
|
@@ -1939,7 +1941,8 @@ var Messages = ({
|
|
|
1939
1941
|
index
|
|
1940
1942
|
);
|
|
1941
1943
|
}),
|
|
1942
|
-
interrupt
|
|
1944
|
+
interrupt,
|
|
1945
|
+
chatError && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ErrorMessage2, { error: chatError, isCurrentMessage: true })
|
|
1943
1946
|
] }),
|
|
1944
1947
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("footer", { className: "copilotKitMessagesFooter", ref: messagesEndRef, children })
|
|
1945
1948
|
] });
|
|
@@ -2322,15 +2325,67 @@ var Input = ({
|
|
|
2322
2325
|
] });
|
|
2323
2326
|
};
|
|
2324
2327
|
|
|
2328
|
+
// src/components/chat/messages/ErrorMessage.tsx
|
|
2329
|
+
var import_react14 = require("react");
|
|
2330
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2331
|
+
var ErrorMessage = (props) => {
|
|
2332
|
+
const { icons, labels } = useChatContext();
|
|
2333
|
+
const { error, onRegenerate, onCopy, isCurrentMessage } = props;
|
|
2334
|
+
const [copied, setCopied] = (0, import_react14.useState)(false);
|
|
2335
|
+
const handleCopy = () => {
|
|
2336
|
+
const content = error.message;
|
|
2337
|
+
if (content && onCopy) {
|
|
2338
|
+
navigator.clipboard.writeText(content);
|
|
2339
|
+
setCopied(true);
|
|
2340
|
+
onCopy(content);
|
|
2341
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
2342
|
+
} else if (content) {
|
|
2343
|
+
navigator.clipboard.writeText(content);
|
|
2344
|
+
setCopied(true);
|
|
2345
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
2346
|
+
}
|
|
2347
|
+
};
|
|
2348
|
+
const handleRegenerate = () => {
|
|
2349
|
+
if (onRegenerate)
|
|
2350
|
+
onRegenerate();
|
|
2351
|
+
};
|
|
2352
|
+
console.log(error);
|
|
2353
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "copilotKitMessage copilotKitAssistantMessage", children: [
|
|
2354
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Markdown, { content: error.message }),
|
|
2355
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: `copilotKitMessageControls ${isCurrentMessage ? "currentMessage" : ""}`, children: [
|
|
2356
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2357
|
+
"button",
|
|
2358
|
+
{
|
|
2359
|
+
className: "copilotKitMessageControlButton",
|
|
2360
|
+
onClick: handleRegenerate,
|
|
2361
|
+
"aria-label": labels.regenerateResponse,
|
|
2362
|
+
title: labels.regenerateResponse,
|
|
2363
|
+
children: icons.regenerateIcon
|
|
2364
|
+
}
|
|
2365
|
+
),
|
|
2366
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2367
|
+
"button",
|
|
2368
|
+
{
|
|
2369
|
+
className: "copilotKitMessageControlButton",
|
|
2370
|
+
onClick: handleCopy,
|
|
2371
|
+
"aria-label": labels.copyToClipboard,
|
|
2372
|
+
title: labels.copyToClipboard,
|
|
2373
|
+
children: copied ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { style: { fontSize: "10px", fontWeight: "bold" }, children: "\u2713" }) : icons.copyIcon
|
|
2374
|
+
}
|
|
2375
|
+
)
|
|
2376
|
+
] })
|
|
2377
|
+
] });
|
|
2378
|
+
};
|
|
2379
|
+
|
|
2325
2380
|
// src/components/chat/Chat.tsx
|
|
2326
|
-
var
|
|
2381
|
+
var import_react15 = __toESM(require("react"));
|
|
2327
2382
|
var import_react_core9 = require("@copilotkit/react-core");
|
|
2328
2383
|
var import_shared3 = require("@copilotkit/shared");
|
|
2329
2384
|
var import_shared4 = require("@copilotkit/shared");
|
|
2330
2385
|
var import_react_core10 = require("@copilotkit/react-core");
|
|
2331
2386
|
|
|
2332
2387
|
// src/components/chat/ImageUploadQueue.tsx
|
|
2333
|
-
var
|
|
2388
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2334
2389
|
var ImageUploadQueue = ({
|
|
2335
2390
|
images,
|
|
2336
2391
|
onRemoveImage,
|
|
@@ -2338,7 +2393,7 @@ var ImageUploadQueue = ({
|
|
|
2338
2393
|
}) => {
|
|
2339
2394
|
if (images.length === 0)
|
|
2340
2395
|
return null;
|
|
2341
|
-
return /* @__PURE__ */ (0,
|
|
2396
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2342
2397
|
"div",
|
|
2343
2398
|
{
|
|
2344
2399
|
className: `copilotKitImageUploadQueue ${className}`,
|
|
@@ -2349,7 +2404,7 @@ var ImageUploadQueue = ({
|
|
|
2349
2404
|
margin: "8px",
|
|
2350
2405
|
padding: "8px"
|
|
2351
2406
|
},
|
|
2352
|
-
children: images.map((image, index) => /* @__PURE__ */ (0,
|
|
2407
|
+
children: images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
2353
2408
|
"div",
|
|
2354
2409
|
{
|
|
2355
2410
|
className: "copilotKitImageUploadQueueItem",
|
|
@@ -2362,7 +2417,7 @@ var ImageUploadQueue = ({
|
|
|
2362
2417
|
overflow: "hidden"
|
|
2363
2418
|
},
|
|
2364
2419
|
children: [
|
|
2365
|
-
/* @__PURE__ */ (0,
|
|
2420
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2366
2421
|
"img",
|
|
2367
2422
|
{
|
|
2368
2423
|
src: `data:${image.contentType};base64,${image.bytes}`,
|
|
@@ -2374,7 +2429,7 @@ var ImageUploadQueue = ({
|
|
|
2374
2429
|
}
|
|
2375
2430
|
}
|
|
2376
2431
|
),
|
|
2377
|
-
/* @__PURE__ */ (0,
|
|
2432
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2378
2433
|
"button",
|
|
2379
2434
|
{
|
|
2380
2435
|
onClick: () => onRemoveImage(index),
|
|
@@ -2409,12 +2464,12 @@ var ImageUploadQueue = ({
|
|
|
2409
2464
|
|
|
2410
2465
|
// src/components/chat/Suggestion.tsx
|
|
2411
2466
|
var import_react_core8 = require("@copilotkit/react-core");
|
|
2412
|
-
var
|
|
2467
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2413
2468
|
function Suggestion({ title, onClick, partial, className }) {
|
|
2414
2469
|
if (!title)
|
|
2415
2470
|
return null;
|
|
2416
2471
|
const { isLoading } = (0, import_react_core8.useCopilotChatInternal)();
|
|
2417
|
-
return /* @__PURE__ */ (0,
|
|
2472
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2418
2473
|
"button",
|
|
2419
2474
|
{
|
|
2420
2475
|
disabled: partial || isLoading,
|
|
@@ -2424,15 +2479,15 @@ function Suggestion({ title, onClick, partial, className }) {
|
|
|
2424
2479
|
},
|
|
2425
2480
|
className: className || (partial ? "suggestion loading" : "suggestion"),
|
|
2426
2481
|
"data-test-id": "suggestion",
|
|
2427
|
-
children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0,
|
|
2482
|
+
children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: title })
|
|
2428
2483
|
}
|
|
2429
2484
|
);
|
|
2430
2485
|
}
|
|
2431
2486
|
|
|
2432
2487
|
// src/components/chat/Suggestions.tsx
|
|
2433
|
-
var
|
|
2488
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2434
2489
|
function Suggestions({ suggestions, onSuggestionClick }) {
|
|
2435
|
-
return /* @__PURE__ */ (0,
|
|
2490
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "suggestions", children: suggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2436
2491
|
Suggestion,
|
|
2437
2492
|
{
|
|
2438
2493
|
title: suggestion.title,
|
|
@@ -2446,7 +2501,7 @@ function Suggestions({ suggestions, onSuggestionClick }) {
|
|
|
2446
2501
|
}
|
|
2447
2502
|
|
|
2448
2503
|
// src/components/chat/Chat.tsx
|
|
2449
|
-
var
|
|
2504
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2450
2505
|
function CopilotChat({
|
|
2451
2506
|
instructions,
|
|
2452
2507
|
suggestions = "auto",
|
|
@@ -2471,11 +2526,13 @@ function CopilotChat({
|
|
|
2471
2526
|
AssistantMessage: AssistantMessage2 = AssistantMessage,
|
|
2472
2527
|
UserMessage: UserMessage2 = UserMessage,
|
|
2473
2528
|
ImageRenderer: ImageRenderer2 = ImageRenderer,
|
|
2529
|
+
ErrorMessage: ErrorMessage2 = ErrorMessage,
|
|
2474
2530
|
imageUploadsEnabled,
|
|
2475
2531
|
inputFileAccept = "image/*",
|
|
2476
2532
|
hideStopButton,
|
|
2477
2533
|
observabilityHooks,
|
|
2478
2534
|
renderError,
|
|
2535
|
+
onError,
|
|
2479
2536
|
// Legacy props - deprecated
|
|
2480
2537
|
RenderTextMessage,
|
|
2481
2538
|
RenderActionExecutionMessage,
|
|
@@ -2483,12 +2540,19 @@ function CopilotChat({
|
|
|
2483
2540
|
RenderResultMessage,
|
|
2484
2541
|
RenderImageMessage
|
|
2485
2542
|
}) {
|
|
2486
|
-
const {
|
|
2543
|
+
const {
|
|
2544
|
+
additionalInstructions,
|
|
2545
|
+
setChatInstructions,
|
|
2546
|
+
copilotApiConfig,
|
|
2547
|
+
setBannerError,
|
|
2548
|
+
setInternalErrorHandler,
|
|
2549
|
+
removeInternalErrorHandler
|
|
2550
|
+
} = (0, import_react_core9.useCopilotContext)();
|
|
2487
2551
|
const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
|
|
2488
|
-
const [selectedImages, setSelectedImages] = (0,
|
|
2489
|
-
const [chatError, setChatError] = (0,
|
|
2490
|
-
const fileInputRef = (0,
|
|
2491
|
-
const triggerObservabilityHook = (0,
|
|
2552
|
+
const [selectedImages, setSelectedImages] = (0, import_react15.useState)([]);
|
|
2553
|
+
const [chatError, setChatError] = (0, import_react15.useState)(null);
|
|
2554
|
+
const fileInputRef = (0, import_react15.useRef)(null);
|
|
2555
|
+
const triggerObservabilityHook = (0, import_react15.useCallback)(
|
|
2492
2556
|
(hookName, ...args) => {
|
|
2493
2557
|
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2494
2558
|
observabilityHooks[hookName](...args);
|
|
@@ -2507,7 +2571,7 @@ function CopilotChat({
|
|
|
2507
2571
|
},
|
|
2508
2572
|
[publicApiKey, observabilityHooks, setBannerError]
|
|
2509
2573
|
);
|
|
2510
|
-
const triggerChatError = (0,
|
|
2574
|
+
const triggerChatError = (0, import_react15.useCallback)(
|
|
2511
2575
|
(error, operation, originalError) => {
|
|
2512
2576
|
const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
|
|
2513
2577
|
setChatError({
|
|
@@ -2515,25 +2579,28 @@ function CopilotChat({
|
|
|
2515
2579
|
operation,
|
|
2516
2580
|
timestamp: Date.now()
|
|
2517
2581
|
});
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
startTime: Date.now()
|
|
2528
|
-
},
|
|
2529
|
-
technical: {
|
|
2530
|
-
environment: "browser",
|
|
2531
|
-
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
|
|
2532
|
-
stackTrace: originalError instanceof Error ? originalError.stack : void 0
|
|
2533
|
-
}
|
|
2582
|
+
const errorEvent = {
|
|
2583
|
+
type: "error",
|
|
2584
|
+
timestamp: Date.now(),
|
|
2585
|
+
context: {
|
|
2586
|
+
source: "ui",
|
|
2587
|
+
request: {
|
|
2588
|
+
operation,
|
|
2589
|
+
url: chatApiEndpoint,
|
|
2590
|
+
startTime: Date.now()
|
|
2534
2591
|
},
|
|
2535
|
-
|
|
2536
|
-
|
|
2592
|
+
technical: {
|
|
2593
|
+
environment: "browser",
|
|
2594
|
+
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
|
|
2595
|
+
stackTrace: originalError instanceof Error ? originalError.stack : void 0
|
|
2596
|
+
}
|
|
2597
|
+
},
|
|
2598
|
+
error
|
|
2599
|
+
};
|
|
2600
|
+
if (onError) {
|
|
2601
|
+
onError(errorEvent);
|
|
2602
|
+
}
|
|
2603
|
+
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks.onError)) {
|
|
2537
2604
|
observabilityHooks.onError(errorEvent);
|
|
2538
2605
|
}
|
|
2539
2606
|
if ((observabilityHooks == null ? void 0 : observabilityHooks.onError) && !publicApiKey) {
|
|
@@ -2550,7 +2617,20 @@ function CopilotChat({
|
|
|
2550
2617
|
},
|
|
2551
2618
|
[publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
|
|
2552
2619
|
);
|
|
2553
|
-
(0,
|
|
2620
|
+
(0, import_react15.useEffect)(() => {
|
|
2621
|
+
const id = "chat-component";
|
|
2622
|
+
setInternalErrorHandler({
|
|
2623
|
+
[id]: (error) => {
|
|
2624
|
+
if (!error)
|
|
2625
|
+
return;
|
|
2626
|
+
triggerChatError(error.error, "sendMessage");
|
|
2627
|
+
}
|
|
2628
|
+
});
|
|
2629
|
+
return () => {
|
|
2630
|
+
removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
|
|
2631
|
+
};
|
|
2632
|
+
}, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
|
|
2633
|
+
(0, import_react15.useEffect)(() => {
|
|
2554
2634
|
if (!imageUploadsEnabled)
|
|
2555
2635
|
return;
|
|
2556
2636
|
const handlePaste = (e) => __async(this, null, function* () {
|
|
@@ -2596,7 +2676,7 @@ function CopilotChat({
|
|
|
2596
2676
|
document.addEventListener("paste", handlePaste);
|
|
2597
2677
|
return () => document.removeEventListener("paste", handlePaste);
|
|
2598
2678
|
}, [imageUploadsEnabled, triggerChatError]);
|
|
2599
|
-
(0,
|
|
2679
|
+
(0, import_react15.useEffect)(() => {
|
|
2600
2680
|
if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
|
|
2601
2681
|
setChatInstructions(instructions || "");
|
|
2602
2682
|
return;
|
|
@@ -2624,8 +2704,8 @@ function CopilotChat({
|
|
|
2624
2704
|
onStopGeneration,
|
|
2625
2705
|
onReloadMessages
|
|
2626
2706
|
);
|
|
2627
|
-
const prevIsLoading = (0,
|
|
2628
|
-
(0,
|
|
2707
|
+
const prevIsLoading = (0, import_react15.useRef)(isLoading);
|
|
2708
|
+
(0, import_react15.useEffect)(() => {
|
|
2629
2709
|
if (prevIsLoading.current !== isLoading) {
|
|
2630
2710
|
if (isLoading) {
|
|
2631
2711
|
triggerObservabilityHook("onChatStarted");
|
|
@@ -2644,7 +2724,7 @@ function CopilotChat({
|
|
|
2644
2724
|
triggerObservabilityHook("onMessageSent", text);
|
|
2645
2725
|
return sendMessage(text, images);
|
|
2646
2726
|
};
|
|
2647
|
-
const chatContext =
|
|
2727
|
+
const chatContext = import_react15.default.useContext(ChatContext);
|
|
2648
2728
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2649
2729
|
const handleRegenerate = (messageId) => {
|
|
2650
2730
|
if (onRegenerate) {
|
|
@@ -2706,14 +2786,14 @@ function CopilotChat({
|
|
|
2706
2786
|
}
|
|
2707
2787
|
triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsDown");
|
|
2708
2788
|
};
|
|
2709
|
-
return /* @__PURE__ */ (0,
|
|
2789
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
2710
2790
|
chatError && renderError && renderError(__spreadProps(__spreadValues({}, chatError), {
|
|
2711
2791
|
onDismiss: () => setChatError(null),
|
|
2712
2792
|
onRetry: () => {
|
|
2713
2793
|
setChatError(null);
|
|
2714
2794
|
}
|
|
2715
2795
|
})),
|
|
2716
|
-
/* @__PURE__ */ (0,
|
|
2796
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2717
2797
|
Messages2,
|
|
2718
2798
|
{
|
|
2719
2799
|
AssistantMessage: AssistantMessage2,
|
|
@@ -2727,12 +2807,14 @@ function CopilotChat({
|
|
|
2727
2807
|
onThumbsDown: handleThumbsDown,
|
|
2728
2808
|
markdownTagRenderers,
|
|
2729
2809
|
ImageRenderer: ImageRenderer2,
|
|
2810
|
+
ErrorMessage: ErrorMessage2,
|
|
2811
|
+
chatError,
|
|
2730
2812
|
RenderTextMessage,
|
|
2731
2813
|
RenderActionExecutionMessage,
|
|
2732
2814
|
RenderAgentStateMessage,
|
|
2733
2815
|
RenderResultMessage,
|
|
2734
2816
|
RenderImageMessage,
|
|
2735
|
-
children: currentSuggestions.length > 0 && /* @__PURE__ */ (0,
|
|
2817
|
+
children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2736
2818
|
RenderSuggestionsList,
|
|
2737
2819
|
{
|
|
2738
2820
|
onSuggestionClick: handleSendMessage,
|
|
@@ -2741,9 +2823,9 @@ function CopilotChat({
|
|
|
2741
2823
|
)
|
|
2742
2824
|
}
|
|
2743
2825
|
),
|
|
2744
|
-
imageUploadsEnabled && /* @__PURE__ */ (0,
|
|
2745
|
-
/* @__PURE__ */ (0,
|
|
2746
|
-
/* @__PURE__ */ (0,
|
|
2826
|
+
imageUploadsEnabled && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
2827
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ImageUploadQueue, { images: selectedImages, onRemoveImage: removeSelectedImage }),
|
|
2828
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2747
2829
|
"input",
|
|
2748
2830
|
{
|
|
2749
2831
|
type: "file",
|
|
@@ -2755,7 +2837,7 @@ function CopilotChat({
|
|
|
2755
2837
|
}
|
|
2756
2838
|
)
|
|
2757
2839
|
] }),
|
|
2758
|
-
/* @__PURE__ */ (0,
|
|
2840
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2759
2841
|
Input2,
|
|
2760
2842
|
{
|
|
2761
2843
|
inProgress: isLoading,
|
|
@@ -2777,12 +2859,12 @@ function WrappedCopilotChat({
|
|
|
2777
2859
|
labels,
|
|
2778
2860
|
className
|
|
2779
2861
|
}) {
|
|
2780
|
-
const chatContext =
|
|
2862
|
+
const chatContext = import_react15.default.useContext(ChatContext);
|
|
2781
2863
|
if (!chatContext) {
|
|
2782
|
-
return /* @__PURE__ */ (0,
|
|
2783
|
-
}, children: /* @__PURE__ */ (0,
|
|
2864
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
|
|
2865
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
|
|
2784
2866
|
}
|
|
2785
|
-
return /* @__PURE__ */ (0,
|
|
2867
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children });
|
|
2786
2868
|
}
|
|
2787
2869
|
var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
|
|
2788
2870
|
var _a;
|
|
@@ -2806,15 +2888,15 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2806
2888
|
const generalContext = (0, import_react_core9.useCopilotContext)();
|
|
2807
2889
|
const messagesContext = (0, import_react_core9.useCopilotMessagesContext)();
|
|
2808
2890
|
const { actions } = generalContext;
|
|
2809
|
-
const [suggestionsFailed, setSuggestionsFailed] = (0,
|
|
2810
|
-
const hasGeneratedInitialSuggestions = (0,
|
|
2811
|
-
(0,
|
|
2891
|
+
const [suggestionsFailed, setSuggestionsFailed] = (0, import_react15.useState)(false);
|
|
2892
|
+
const hasGeneratedInitialSuggestions = (0, import_react15.useRef)(false);
|
|
2893
|
+
(0, import_react15.useEffect)(() => {
|
|
2812
2894
|
if (Array.isArray(chatSuggestions)) {
|
|
2813
2895
|
setSuggestions(chatSuggestions);
|
|
2814
2896
|
hasGeneratedInitialSuggestions.current = true;
|
|
2815
2897
|
}
|
|
2816
2898
|
}, [JSON.stringify(chatSuggestions), setSuggestions]);
|
|
2817
|
-
const generateSuggestionsWithErrorHandling = (0,
|
|
2899
|
+
const generateSuggestionsWithErrorHandling = (0, import_react15.useCallback)(
|
|
2818
2900
|
(context) => __async(void 0, null, function* () {
|
|
2819
2901
|
try {
|
|
2820
2902
|
yield generateSuggestions();
|
|
@@ -2825,7 +2907,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2825
2907
|
}),
|
|
2826
2908
|
[generateSuggestions]
|
|
2827
2909
|
);
|
|
2828
|
-
(0,
|
|
2910
|
+
(0, import_react15.useEffect)(() => {
|
|
2829
2911
|
if (chatSuggestions !== "auto" || isLoadingSuggestions || suggestionsFailed) {
|
|
2830
2912
|
return;
|
|
2831
2913
|
}
|
|
@@ -2855,13 +2937,13 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2855
2937
|
// Use stable string instead of object reference
|
|
2856
2938
|
generateSuggestionsWithErrorHandling
|
|
2857
2939
|
]);
|
|
2858
|
-
(0,
|
|
2940
|
+
(0, import_react15.useEffect)(() => {
|
|
2859
2941
|
if (chatSuggestions !== "auto") {
|
|
2860
2942
|
hasGeneratedInitialSuggestions.current = false;
|
|
2861
2943
|
setSuggestionsFailed(false);
|
|
2862
2944
|
}
|
|
2863
2945
|
}, [chatSuggestions]);
|
|
2864
|
-
const stableContext = (0,
|
|
2946
|
+
const stableContext = (0, import_react15.useMemo)(
|
|
2865
2947
|
() => __spreadValues(__spreadValues({}, generalContext), messagesContext),
|
|
2866
2948
|
[
|
|
2867
2949
|
// Only include stable dependencies
|
|
@@ -2870,12 +2952,12 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2870
2952
|
generalContext.isLoading
|
|
2871
2953
|
]
|
|
2872
2954
|
);
|
|
2873
|
-
const resetSuggestions = (0,
|
|
2955
|
+
const resetSuggestions = (0, import_react15.useCallback)(() => {
|
|
2874
2956
|
resetSuggestionsFromHook();
|
|
2875
2957
|
setSuggestionsFailed(false);
|
|
2876
2958
|
hasGeneratedInitialSuggestions.current = false;
|
|
2877
2959
|
}, [resetSuggestionsFromHook]);
|
|
2878
|
-
(0,
|
|
2960
|
+
(0, import_react15.useEffect)(() => {
|
|
2879
2961
|
onInProgress == null ? void 0 : onInProgress(isLoading);
|
|
2880
2962
|
}, [onInProgress, isLoading]);
|
|
2881
2963
|
const safelySendMessage = (messageContent, imagesToUse) => __async(void 0, null, function* () {
|
|
@@ -3021,7 +3103,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
3021
3103
|
// src/components/chat/Modal.tsx
|
|
3022
3104
|
var import_react_core11 = require("@copilotkit/react-core");
|
|
3023
3105
|
var import_shared5 = require("@copilotkit/shared");
|
|
3024
|
-
var
|
|
3106
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3025
3107
|
var CopilotModalInner = (_a) => {
|
|
3026
3108
|
var _b = _a, {
|
|
3027
3109
|
observabilityHooks,
|
|
@@ -3048,7 +3130,7 @@ var CopilotModalInner = (_a) => {
|
|
|
3048
3130
|
]);
|
|
3049
3131
|
const { copilotApiConfig, setBannerError } = (0, import_react_core11.useCopilotContext)();
|
|
3050
3132
|
const { publicApiKey } = copilotApiConfig;
|
|
3051
|
-
const triggerObservabilityHook = (0,
|
|
3133
|
+
const triggerObservabilityHook = (0, import_react16.useCallback)(
|
|
3052
3134
|
(hookName, ...args) => {
|
|
3053
3135
|
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
3054
3136
|
observabilityHooks[hookName](...args);
|
|
@@ -3068,8 +3150,8 @@ var CopilotModalInner = (_a) => {
|
|
|
3068
3150
|
[publicApiKey, observabilityHooks, setBannerError]
|
|
3069
3151
|
);
|
|
3070
3152
|
const { open } = useChatContext();
|
|
3071
|
-
const prevOpen = (0,
|
|
3072
|
-
(0,
|
|
3153
|
+
const prevOpen = (0, import_react16.useRef)(open);
|
|
3154
|
+
(0, import_react16.useEffect)(() => {
|
|
3073
3155
|
if (prevOpen.current !== open) {
|
|
3074
3156
|
onSetOpen == null ? void 0 : onSetOpen(open);
|
|
3075
3157
|
if (open) {
|
|
@@ -3080,13 +3162,13 @@ var CopilotModalInner = (_a) => {
|
|
|
3080
3162
|
prevOpen.current = open;
|
|
3081
3163
|
}
|
|
3082
3164
|
}, [open, onSetOpen, triggerObservabilityHook]);
|
|
3083
|
-
const memoizedHeader = (0,
|
|
3084
|
-
const memoizedChildren = (0,
|
|
3085
|
-
return /* @__PURE__ */ (0,
|
|
3165
|
+
const memoizedHeader = (0, import_react16.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Header2, {}), [Header2]);
|
|
3166
|
+
const memoizedChildren = (0, import_react16.useMemo)(() => children, [children]);
|
|
3167
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
|
|
3086
3168
|
memoizedChildren,
|
|
3087
|
-
/* @__PURE__ */ (0,
|
|
3088
|
-
/* @__PURE__ */ (0,
|
|
3089
|
-
/* @__PURE__ */ (0,
|
|
3169
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className, children: [
|
|
3170
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Button2, {}),
|
|
3171
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
3090
3172
|
Window2,
|
|
3091
3173
|
{
|
|
3092
3174
|
clickOutsideToClose,
|
|
@@ -3094,7 +3176,7 @@ var CopilotModalInner = (_a) => {
|
|
|
3094
3176
|
hitEscapeToClose,
|
|
3095
3177
|
children: [
|
|
3096
3178
|
memoizedHeader,
|
|
3097
|
-
/* @__PURE__ */ (0,
|
|
3179
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CopilotChat, __spreadProps(__spreadValues({}, chatProps), { observabilityHooks }))
|
|
3098
3180
|
]
|
|
3099
3181
|
}
|
|
3100
3182
|
)
|
|
@@ -3161,8 +3243,8 @@ var CopilotModal = (_a) => {
|
|
|
3161
3243
|
"children",
|
|
3162
3244
|
"observabilityHooks"
|
|
3163
3245
|
]);
|
|
3164
|
-
const [openState, setOpenState] =
|
|
3165
|
-
return /* @__PURE__ */ (0,
|
|
3246
|
+
const [openState, setOpenState] = import_react16.default.useState(defaultOpen);
|
|
3247
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3166
3248
|
CopilotModalInner,
|
|
3167
3249
|
__spreadProps(__spreadValues({
|
|
3168
3250
|
observabilityHooks,
|
|
@@ -3196,12 +3278,12 @@ var CopilotModal = (_a) => {
|
|
|
3196
3278
|
};
|
|
3197
3279
|
|
|
3198
3280
|
// src/components/chat/Sidebar.tsx
|
|
3199
|
-
var
|
|
3281
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
3200
3282
|
function CopilotSidebar(props) {
|
|
3201
3283
|
props = __spreadProps(__spreadValues({}, props), {
|
|
3202
3284
|
className: props.className ? props.className + " copilotKitSidebar" : "copilotKitSidebar"
|
|
3203
3285
|
});
|
|
3204
|
-
const [expandedClassName, setExpandedClassName] = (0,
|
|
3286
|
+
const [expandedClassName, setExpandedClassName] = (0, import_react17.useState)(
|
|
3205
3287
|
props.defaultOpen ? "sidebarExpanded" : ""
|
|
3206
3288
|
);
|
|
3207
3289
|
const onSetOpen = (open) => {
|
|
@@ -3209,7 +3291,7 @@ function CopilotSidebar(props) {
|
|
|
3209
3291
|
(_a = props.onSetOpen) == null ? void 0 : _a.call(props, open);
|
|
3210
3292
|
setExpandedClassName(open ? "sidebarExpanded" : "");
|
|
3211
3293
|
};
|
|
3212
|
-
return /* @__PURE__ */ (0,
|
|
3294
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: `copilotKitSidebarContentWrapper ${expandedClassName}`, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CopilotModal, __spreadProps(__spreadValues(__spreadValues({}, props), { onSetOpen }), { children: props.children })) });
|
|
3213
3295
|
}
|
|
3214
3296
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3215
3297
|
0 && (module.exports = {
|