@copilotkit/react-ui 1.8.6-next.0 → 1.8.7-next.0
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 +19 -0
- package/dist/{chunk-Q2YY2NX3.mjs → chunk-24TDU7MY.mjs} +2 -2
- package/dist/{chunk-XNQO5AZZ.mjs → chunk-ABHUX6T6.mjs} +2 -2
- package/dist/{chunk-QJKMOGWN.mjs → chunk-BDNHZ3GW.mjs} +4 -3
- package/dist/chunk-BDNHZ3GW.mjs.map +1 -0
- package/dist/{chunk-NMNC4ROZ.mjs → chunk-DSQGQJI4.mjs} +2 -2
- package/dist/{chunk-HEIDCT7I.mjs → chunk-HWMFMBJC.mjs} +2 -2
- package/dist/chunk-HWMFMBJC.mjs.map +1 -0
- package/dist/{chunk-UN2E3HCK.mjs → chunk-IEMQ2SQW.mjs} +6 -4
- package/dist/chunk-IEMQ2SQW.mjs.map +1 -0
- package/dist/{chunk-ZY25LVYR.mjs → chunk-IJADIQAR.mjs} +20 -2
- package/dist/chunk-IJADIQAR.mjs.map +1 -0
- package/dist/{chunk-X6EFGEBJ.mjs → chunk-JOL7NS2W.mjs} +2 -2
- package/dist/{chunk-PCTCOQK2.mjs → chunk-KENCH7RN.mjs} +2 -2
- package/dist/{chunk-ZLRUNNS7.mjs → chunk-O34Z4XM2.mjs} +170 -30
- package/dist/chunk-O34Z4XM2.mjs.map +1 -0
- package/dist/{chunk-5M7ODWKH.mjs → chunk-OZXUB3V7.mjs} +3 -3
- package/dist/chunk-PLHTVHUW.mjs +82 -0
- package/dist/chunk-PLHTVHUW.mjs.map +1 -0
- package/dist/{chunk-62QMTKMJ.mjs → chunk-POWCBXRY.mjs} +3 -3
- package/dist/chunk-PXEVB7IK.mjs +1 -0
- package/dist/{chunk-HIORSNVD.mjs → chunk-Q2NFQTCQ.mjs} +2 -2
- package/dist/chunk-SLTG4L62.mjs +78 -0
- package/dist/chunk-SLTG4L62.mjs.map +1 -0
- package/dist/{chunk-SMJ3QQCE.mjs → chunk-T7N77F5Y.mjs} +2 -2
- package/dist/{chunk-YOEL33HG.mjs → chunk-UFN2VWSR.mjs} +2 -2
- package/dist/{chunk-2OTVZXDX.mjs → chunk-UH2UFL5W.mjs} +3 -3
- package/dist/{chunk-D5XIJNXQ.mjs → chunk-VGPQYMKJ.mjs} +8 -8
- package/dist/{chunk-WNC6OCIB.mjs → chunk-XFCMZH2H.mjs} +2 -2
- package/dist/{chunk-ORSMX3SE.mjs → chunk-XWG3L6QC.mjs} +15 -1
- package/dist/{chunk-ORSMX3SE.mjs.map → chunk-XWG3L6QC.mjs.map} +1 -1
- package/dist/{chunk-TOQ7P4DO.mjs → chunk-XZNY26GH.mjs} +2 -2
- package/dist/{chunk-GOAED4H6.mjs → chunk-Y7UO3RPW.mjs} +10 -10
- package/dist/components/chat/Button.js.map +1 -1
- package/dist/components/chat/Button.mjs +3 -3
- package/dist/components/chat/Chat.d.ts +23 -3
- package/dist/components/chat/Chat.js +341 -30
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +16 -14
- package/dist/components/chat/ChatContext.d.ts +5 -0
- package/dist/components/chat/ChatContext.js +15 -1
- package/dist/components/chat/ChatContext.js.map +1 -1
- package/dist/components/chat/ChatContext.mjs +2 -2
- package/dist/components/chat/CodeBlock.js.map +1 -1
- package/dist/components/chat/CodeBlock.mjs +2 -2
- package/dist/components/chat/Header.js.map +1 -1
- package/dist/components/chat/Header.mjs +5 -5
- package/dist/components/chat/Icons.d.ts +2 -1
- package/dist/components/chat/Icons.js +17 -2
- package/dist/components/chat/Icons.js.map +1 -1
- package/dist/components/chat/Icons.mjs +5 -3
- package/dist/components/chat/ImageUploadQueue.d.ts +13 -0
- package/dist/components/chat/ImageUploadQueue.js +106 -0
- package/dist/components/chat/ImageUploadQueue.js.map +1 -0
- package/dist/components/chat/ImageUploadQueue.mjs +8 -0
- package/dist/components/chat/ImageUploadQueue.mjs.map +1 -0
- package/dist/components/chat/Input.d.ts +1 -1
- package/dist/components/chat/Input.js +2 -1
- package/dist/components/chat/Input.js.map +1 -1
- package/dist/components/chat/Input.mjs +3 -3
- package/dist/components/chat/Markdown.js.map +1 -1
- package/dist/components/chat/Markdown.mjs +3 -3
- package/dist/components/chat/Messages.d.ts +1 -1
- package/dist/components/chat/Messages.js +18 -0
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +3 -3
- package/dist/components/chat/Modal.js +348 -37
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +22 -20
- package/dist/components/chat/Popup.js +350 -39
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +23 -21
- package/dist/components/chat/Sidebar.js +350 -39
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +23 -21
- package/dist/components/chat/Suggestion.js.map +1 -1
- package/dist/components/chat/Suggestion.mjs +2 -2
- package/dist/components/chat/Window.js.map +1 -1
- package/dist/components/chat/Window.mjs +3 -3
- package/dist/components/chat/index.d.ts +1 -0
- package/dist/components/chat/index.js +354 -41
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +30 -25
- package/dist/components/chat/messages/AssistantMessage.js.map +1 -1
- package/dist/components/chat/messages/AssistantMessage.mjs +5 -5
- package/dist/components/chat/messages/RenderActionExecutionMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderActionExecutionMessage.mjs +6 -6
- package/dist/components/chat/messages/RenderAgentStateMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderAgentStateMessage.mjs +6 -6
- package/dist/components/chat/messages/RenderImageMessage.d.ts +7 -0
- package/dist/components/chat/messages/RenderImageMessage.js +774 -0
- package/dist/components/chat/messages/RenderImageMessage.js.map +1 -0
- package/dist/components/chat/messages/RenderImageMessage.mjs +15 -0
- package/dist/components/chat/messages/RenderImageMessage.mjs.map +1 -0
- package/dist/components/chat/messages/RenderResultMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderResultMessage.mjs +6 -6
- package/dist/components/chat/messages/RenderTextMessage.js +1 -1
- package/dist/components/chat/messages/RenderTextMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderTextMessage.mjs +7 -7
- package/dist/components/chat/messages/UserMessage.js +1 -1
- package/dist/components/chat/messages/UserMessage.js.map +1 -1
- package/dist/components/chat/messages/UserMessage.mjs +1 -1
- package/dist/components/chat/props.d.ts +3 -0
- package/dist/components/chat/props.js.map +1 -1
- package/dist/components/dev-console/console.js.map +1 -1
- package/dist/components/dev-console/console.mjs +3 -3
- package/dist/components/dev-console/index.js.map +1 -1
- package/dist/components/dev-console/index.mjs +3 -3
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +354 -41
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +30 -25
- package/dist/index.d.ts +1 -0
- package/dist/index.js +354 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -26
- package/package.json +4 -4
- package/src/components/chat/Chat.tsx +198 -18
- package/src/components/chat/ChatContext.tsx +7 -0
- package/src/components/chat/Icons.tsx +14 -0
- package/src/components/chat/ImageUploadQueue.tsx +77 -0
- package/src/components/chat/Input.tsx +8 -1
- package/src/components/chat/Messages.tsx +17 -0
- package/src/components/chat/index.tsx +1 -0
- package/src/components/chat/messages/RenderImageMessage.tsx +64 -0
- package/src/components/chat/messages/UserMessage.tsx +5 -1
- package/src/components/chat/props.ts +3 -0
- package/dist/chunk-HEIDCT7I.mjs.map +0 -1
- package/dist/chunk-QJKMOGWN.mjs.map +0 -1
- package/dist/chunk-SQMEPWVT.mjs +0 -1
- package/dist/chunk-UN2E3HCK.mjs.map +0 -1
- package/dist/chunk-ZLRUNNS7.mjs.map +0 -1
- package/dist/chunk-ZY25LVYR.mjs.map +0 -1
- /package/dist/{chunk-Q2YY2NX3.mjs.map → chunk-24TDU7MY.mjs.map} +0 -0
- /package/dist/{chunk-XNQO5AZZ.mjs.map → chunk-ABHUX6T6.mjs.map} +0 -0
- /package/dist/{chunk-NMNC4ROZ.mjs.map → chunk-DSQGQJI4.mjs.map} +0 -0
- /package/dist/{chunk-X6EFGEBJ.mjs.map → chunk-JOL7NS2W.mjs.map} +0 -0
- /package/dist/{chunk-PCTCOQK2.mjs.map → chunk-KENCH7RN.mjs.map} +0 -0
- /package/dist/{chunk-5M7ODWKH.mjs.map → chunk-OZXUB3V7.mjs.map} +0 -0
- /package/dist/{chunk-62QMTKMJ.mjs.map → chunk-POWCBXRY.mjs.map} +0 -0
- /package/dist/{chunk-SQMEPWVT.mjs.map → chunk-PXEVB7IK.mjs.map} +0 -0
- /package/dist/{chunk-HIORSNVD.mjs.map → chunk-Q2NFQTCQ.mjs.map} +0 -0
- /package/dist/{chunk-SMJ3QQCE.mjs.map → chunk-T7N77F5Y.mjs.map} +0 -0
- /package/dist/{chunk-YOEL33HG.mjs.map → chunk-UFN2VWSR.mjs.map} +0 -0
- /package/dist/{chunk-2OTVZXDX.mjs.map → chunk-UH2UFL5W.mjs.map} +0 -0
- /package/dist/{chunk-D5XIJNXQ.mjs.map → chunk-VGPQYMKJ.mjs.map} +0 -0
- /package/dist/{chunk-WNC6OCIB.mjs.map → chunk-XFCMZH2H.mjs.map} +0 -0
- /package/dist/{chunk-TOQ7P4DO.mjs.map → chunk-XZNY26GH.mjs.map} +0 -0
- /package/dist/{chunk-GOAED4H6.mjs.map → chunk-Y7UO3RPW.mjs.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -86,6 +86,7 @@ __export(src_exports, {
|
|
|
86
86
|
CopilotPopup: () => CopilotPopup,
|
|
87
87
|
CopilotSidebar: () => CopilotSidebar,
|
|
88
88
|
Markdown: () => Markdown,
|
|
89
|
+
RenderImageMessage: () => RenderImageMessage,
|
|
89
90
|
UserMessage: () => UserMessage,
|
|
90
91
|
shouldShowDevConsole: () => shouldShowDevConsole,
|
|
91
92
|
useChatContext: () => useChatContext,
|
|
@@ -310,6 +311,19 @@ var DownloadIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
|
310
311
|
)
|
|
311
312
|
}
|
|
312
313
|
);
|
|
314
|
+
var UploadIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
315
|
+
"svg",
|
|
316
|
+
{
|
|
317
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
318
|
+
fill: "none",
|
|
319
|
+
viewBox: "0 0 24 24",
|
|
320
|
+
strokeWidth: "1.5",
|
|
321
|
+
stroke: "currentColor",
|
|
322
|
+
width: "24",
|
|
323
|
+
height: "24",
|
|
324
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 4.5v15m7.5-7.5h-15" })
|
|
325
|
+
}
|
|
326
|
+
);
|
|
313
327
|
var CheckIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
314
328
|
"svg",
|
|
315
329
|
{
|
|
@@ -375,7 +389,8 @@ var ChatContextProvider = ({
|
|
|
375
389
|
pushToTalkIcon: MicrophoneIcon,
|
|
376
390
|
copyIcon: CopyIcon,
|
|
377
391
|
thumbsUpIcon: ThumbsUpIcon,
|
|
378
|
-
thumbsDownIcon: ThumbsDownIcon
|
|
392
|
+
thumbsDownIcon: ThumbsDownIcon,
|
|
393
|
+
uploadIcon: UploadIcon
|
|
379
394
|
}), icons),
|
|
380
395
|
[icons]
|
|
381
396
|
);
|
|
@@ -1080,6 +1095,7 @@ var Messages = ({
|
|
|
1080
1095
|
RenderActionExecutionMessage: RenderActionExecutionMessage2,
|
|
1081
1096
|
RenderAgentStateMessage: RenderAgentStateMessage2,
|
|
1082
1097
|
RenderResultMessage: RenderResultMessage2,
|
|
1098
|
+
RenderImageMessage: RenderImageMessage2,
|
|
1083
1099
|
AssistantMessage: AssistantMessage2,
|
|
1084
1100
|
UserMessage: UserMessage2,
|
|
1085
1101
|
onRegenerate,
|
|
@@ -1168,6 +1184,23 @@ var Messages = ({
|
|
|
1168
1184
|
},
|
|
1169
1185
|
index
|
|
1170
1186
|
);
|
|
1187
|
+
} else if (message.isImageMessage && message.isImageMessage()) {
|
|
1188
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1189
|
+
RenderImageMessage2,
|
|
1190
|
+
{
|
|
1191
|
+
message,
|
|
1192
|
+
inProgress,
|
|
1193
|
+
index,
|
|
1194
|
+
isCurrentMessage,
|
|
1195
|
+
AssistantMessage: AssistantMessage2,
|
|
1196
|
+
UserMessage: UserMessage2,
|
|
1197
|
+
onRegenerate,
|
|
1198
|
+
onCopy,
|
|
1199
|
+
onThumbsUp,
|
|
1200
|
+
onThumbsDown
|
|
1201
|
+
},
|
|
1202
|
+
index
|
|
1203
|
+
);
|
|
1171
1204
|
}
|
|
1172
1205
|
}),
|
|
1173
1206
|
interrupt
|
|
@@ -1410,7 +1443,7 @@ var usePushToTalk = ({
|
|
|
1410
1443
|
// src/components/chat/Input.tsx
|
|
1411
1444
|
var import_react_core6 = require("@copilotkit/react-core");
|
|
1412
1445
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1413
|
-
var Input = ({ inProgress, onSend, isVisible = false, onStop }) => {
|
|
1446
|
+
var Input = ({ inProgress, onSend, isVisible = false, onStop, onUpload }) => {
|
|
1414
1447
|
const context = useChatContext();
|
|
1415
1448
|
const copilotContext = (0, import_react_core6.useCopilotContext)();
|
|
1416
1449
|
const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
|
|
@@ -1474,6 +1507,7 @@ var Input = ({ inProgress, onSend, isVisible = false, onStop }) => {
|
|
|
1474
1507
|
}
|
|
1475
1508
|
),
|
|
1476
1509
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "copilotKitInputControls", children: [
|
|
1510
|
+
onUpload && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { onClick: onUpload, className: "copilotKitInputControlButton", children: context.icons.uploadIcon }),
|
|
1477
1511
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { style: { flexGrow: 1 } }),
|
|
1478
1512
|
showPushToTalk && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1479
1513
|
"button",
|
|
@@ -1501,7 +1535,7 @@ var Input = ({ inProgress, onSend, isVisible = false, onStop }) => {
|
|
|
1501
1535
|
// src/components/chat/messages/UserMessage.tsx
|
|
1502
1536
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1503
1537
|
var UserMessage = (props) => {
|
|
1504
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "copilotKitMessage copilotKitUserMessage", children: props.message });
|
|
1538
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "copilotKitMessage copilotKitUserMessage", children: props.subComponent || props.message });
|
|
1505
1539
|
};
|
|
1506
1540
|
|
|
1507
1541
|
// src/components/chat/Markdown.tsx
|
|
@@ -2355,13 +2389,77 @@ function RenderAgentStateMessage(_a) {
|
|
|
2355
2389
|
}
|
|
2356
2390
|
}
|
|
2357
2391
|
|
|
2392
|
+
// src/components/chat/messages/RenderImageMessage.tsx
|
|
2393
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2394
|
+
function RenderImageMessage(_a) {
|
|
2395
|
+
var _b = _a, {
|
|
2396
|
+
UserMessage: UserMessage2 = UserMessage,
|
|
2397
|
+
AssistantMessage: AssistantMessage2 = AssistantMessage
|
|
2398
|
+
} = _b, props = __objRest(_b, [
|
|
2399
|
+
"UserMessage",
|
|
2400
|
+
"AssistantMessage"
|
|
2401
|
+
]);
|
|
2402
|
+
const {
|
|
2403
|
+
message,
|
|
2404
|
+
inProgress,
|
|
2405
|
+
index,
|
|
2406
|
+
isCurrentMessage,
|
|
2407
|
+
onRegenerate,
|
|
2408
|
+
onCopy,
|
|
2409
|
+
onThumbsUp,
|
|
2410
|
+
onThumbsDown
|
|
2411
|
+
} = props;
|
|
2412
|
+
if (message.isImageMessage()) {
|
|
2413
|
+
const imageData = `data:${message.format};base64,${message.bytes}`;
|
|
2414
|
+
const imageComponent = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "copilotKitImage", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2415
|
+
"img",
|
|
2416
|
+
{
|
|
2417
|
+
src: imageData,
|
|
2418
|
+
alt: "User uploaded image",
|
|
2419
|
+
style: { maxWidth: "100%", maxHeight: "300px", borderRadius: "8px" }
|
|
2420
|
+
}
|
|
2421
|
+
) });
|
|
2422
|
+
if (message.role === "user") {
|
|
2423
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2424
|
+
UserMessage2,
|
|
2425
|
+
{
|
|
2426
|
+
"data-message-role": "user",
|
|
2427
|
+
message: "",
|
|
2428
|
+
rawData: message,
|
|
2429
|
+
subComponent: imageComponent
|
|
2430
|
+
},
|
|
2431
|
+
index
|
|
2432
|
+
);
|
|
2433
|
+
} else if (message.role === "assistant") {
|
|
2434
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2435
|
+
AssistantMessage2,
|
|
2436
|
+
{
|
|
2437
|
+
"data-message-role": "assistant",
|
|
2438
|
+
message: "",
|
|
2439
|
+
rawData: message,
|
|
2440
|
+
subComponent: imageComponent,
|
|
2441
|
+
isLoading: inProgress && isCurrentMessage && !message.bytes,
|
|
2442
|
+
isGenerating: inProgress && isCurrentMessage && !!message.bytes,
|
|
2443
|
+
isCurrentMessage,
|
|
2444
|
+
onRegenerate: () => onRegenerate == null ? void 0 : onRegenerate(message.id),
|
|
2445
|
+
onCopy,
|
|
2446
|
+
onThumbsUp,
|
|
2447
|
+
onThumbsDown
|
|
2448
|
+
},
|
|
2449
|
+
index
|
|
2450
|
+
);
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2453
|
+
return null;
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2358
2456
|
// src/components/chat/Suggestion.tsx
|
|
2359
2457
|
var import_react_core9 = require("@copilotkit/react-core");
|
|
2360
2458
|
var import_shared2 = require("@copilotkit/shared");
|
|
2361
2459
|
var import_runtime_client_gql3 = require("@copilotkit/runtime-client-gql");
|
|
2362
|
-
var
|
|
2460
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2363
2461
|
function Suggestion({ title, message, onClick, partial, className }) {
|
|
2364
|
-
return /* @__PURE__ */ (0,
|
|
2462
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2365
2463
|
"button",
|
|
2366
2464
|
{
|
|
2367
2465
|
disabled: partial,
|
|
@@ -2371,7 +2469,7 @@ function Suggestion({ title, message, onClick, partial, className }) {
|
|
|
2371
2469
|
},
|
|
2372
2470
|
className: className || (partial ? "suggestion loading" : "suggestion"),
|
|
2373
2471
|
"data-test-id": "suggestion",
|
|
2374
|
-
children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0,
|
|
2472
|
+
children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { children: title })
|
|
2375
2473
|
}
|
|
2376
2474
|
);
|
|
2377
2475
|
}
|
|
@@ -2451,7 +2549,87 @@ var import_react_core10 = require("@copilotkit/react-core");
|
|
|
2451
2549
|
var import_runtime_client_gql4 = require("@copilotkit/runtime-client-gql");
|
|
2452
2550
|
var import_shared3 = require("@copilotkit/shared");
|
|
2453
2551
|
var import_react_core11 = require("@copilotkit/react-core");
|
|
2454
|
-
|
|
2552
|
+
|
|
2553
|
+
// src/components/chat/ImageUploadQueue.tsx
|
|
2554
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2555
|
+
var ImageUploadQueue = ({
|
|
2556
|
+
images,
|
|
2557
|
+
onRemoveImage,
|
|
2558
|
+
className = ""
|
|
2559
|
+
}) => {
|
|
2560
|
+
if (images.length === 0)
|
|
2561
|
+
return null;
|
|
2562
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2563
|
+
"div",
|
|
2564
|
+
{
|
|
2565
|
+
className: `copilotKitImageUploadQueue ${className}`,
|
|
2566
|
+
style: {
|
|
2567
|
+
display: "flex",
|
|
2568
|
+
flexWrap: "wrap",
|
|
2569
|
+
gap: "8px",
|
|
2570
|
+
margin: "8px",
|
|
2571
|
+
padding: "8px"
|
|
2572
|
+
},
|
|
2573
|
+
children: images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
2574
|
+
"div",
|
|
2575
|
+
{
|
|
2576
|
+
className: "copilotKitImageUploadQueueItem",
|
|
2577
|
+
style: {
|
|
2578
|
+
position: "relative",
|
|
2579
|
+
display: "inline-block",
|
|
2580
|
+
width: "60px",
|
|
2581
|
+
height: "60px",
|
|
2582
|
+
borderRadius: "4px",
|
|
2583
|
+
overflow: "hidden"
|
|
2584
|
+
},
|
|
2585
|
+
children: [
|
|
2586
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2587
|
+
"img",
|
|
2588
|
+
{
|
|
2589
|
+
src: `data:${image.contentType};base64,${image.bytes}`,
|
|
2590
|
+
alt: `Selected image ${index + 1}`,
|
|
2591
|
+
style: {
|
|
2592
|
+
width: "100%",
|
|
2593
|
+
height: "100%",
|
|
2594
|
+
objectFit: "cover"
|
|
2595
|
+
}
|
|
2596
|
+
}
|
|
2597
|
+
),
|
|
2598
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2599
|
+
"button",
|
|
2600
|
+
{
|
|
2601
|
+
onClick: () => onRemoveImage(index),
|
|
2602
|
+
className: "copilotKitImageUploadQueueRemoveButton",
|
|
2603
|
+
style: {
|
|
2604
|
+
position: "absolute",
|
|
2605
|
+
top: "2px",
|
|
2606
|
+
right: "2px",
|
|
2607
|
+
background: "rgba(0,0,0,0.6)",
|
|
2608
|
+
color: "white",
|
|
2609
|
+
border: "none",
|
|
2610
|
+
borderRadius: "50%",
|
|
2611
|
+
width: "18px",
|
|
2612
|
+
height: "18px",
|
|
2613
|
+
display: "flex",
|
|
2614
|
+
alignItems: "center",
|
|
2615
|
+
justifyContent: "center",
|
|
2616
|
+
cursor: "pointer",
|
|
2617
|
+
fontSize: "10px",
|
|
2618
|
+
padding: 0
|
|
2619
|
+
},
|
|
2620
|
+
children: "\u2715"
|
|
2621
|
+
}
|
|
2622
|
+
)
|
|
2623
|
+
]
|
|
2624
|
+
},
|
|
2625
|
+
index
|
|
2626
|
+
))
|
|
2627
|
+
}
|
|
2628
|
+
);
|
|
2629
|
+
};
|
|
2630
|
+
|
|
2631
|
+
// src/components/chat/Chat.tsx
|
|
2632
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2455
2633
|
function CopilotChat({
|
|
2456
2634
|
instructions,
|
|
2457
2635
|
onSubmitMessage,
|
|
@@ -2468,14 +2646,64 @@ function CopilotChat({
|
|
|
2468
2646
|
RenderActionExecutionMessage: RenderActionExecutionMessage2 = RenderActionExecutionMessage,
|
|
2469
2647
|
RenderAgentStateMessage: RenderAgentStateMessage2 = RenderAgentStateMessage,
|
|
2470
2648
|
RenderResultMessage: RenderResultMessage2 = RenderResultMessage,
|
|
2649
|
+
RenderImageMessage: RenderImageMessage2 = RenderImageMessage,
|
|
2471
2650
|
Input: Input2 = Input,
|
|
2472
2651
|
className,
|
|
2473
2652
|
icons,
|
|
2474
2653
|
labels,
|
|
2475
2654
|
AssistantMessage: AssistantMessage2 = AssistantMessage,
|
|
2476
|
-
UserMessage: UserMessage2 = UserMessage
|
|
2655
|
+
UserMessage: UserMessage2 = UserMessage,
|
|
2656
|
+
imageUploadsEnabled,
|
|
2657
|
+
inputFileAccept = "image/*"
|
|
2477
2658
|
}) {
|
|
2478
2659
|
const { additionalInstructions, setChatInstructions } = (0, import_react_core10.useCopilotContext)();
|
|
2660
|
+
const [selectedImages, setSelectedImages] = (0, import_react13.useState)([]);
|
|
2661
|
+
const fileInputRef = (0, import_react13.useRef)(null);
|
|
2662
|
+
(0, import_react13.useEffect)(() => {
|
|
2663
|
+
if (!imageUploadsEnabled)
|
|
2664
|
+
return;
|
|
2665
|
+
const handlePaste = (e) => __async(this, null, function* () {
|
|
2666
|
+
var _a, _b;
|
|
2667
|
+
const target = e.target;
|
|
2668
|
+
if (!((_a = target.parentElement) == null ? void 0 : _a.classList.contains("copilotKitInput")))
|
|
2669
|
+
return;
|
|
2670
|
+
const items = Array.from(((_b = e.clipboardData) == null ? void 0 : _b.items) || []);
|
|
2671
|
+
const imageItems = items.filter((item) => item.type.startsWith("image/"));
|
|
2672
|
+
if (imageItems.length === 0)
|
|
2673
|
+
return;
|
|
2674
|
+
e.preventDefault();
|
|
2675
|
+
const imagePromises = imageItems.map((item) => {
|
|
2676
|
+
const file = item.getAsFile();
|
|
2677
|
+
if (!file)
|
|
2678
|
+
return Promise.resolve(null);
|
|
2679
|
+
return new Promise((resolve, reject) => {
|
|
2680
|
+
const reader = new FileReader();
|
|
2681
|
+
reader.onload = (e2) => {
|
|
2682
|
+
var _a2, _b2;
|
|
2683
|
+
const base64String = (_b2 = (_a2 = e2.target) == null ? void 0 : _a2.result) == null ? void 0 : _b2.split(",")[1];
|
|
2684
|
+
if (base64String) {
|
|
2685
|
+
resolve({
|
|
2686
|
+
contentType: file.type,
|
|
2687
|
+
bytes: base64String
|
|
2688
|
+
});
|
|
2689
|
+
} else {
|
|
2690
|
+
resolve(null);
|
|
2691
|
+
}
|
|
2692
|
+
};
|
|
2693
|
+
reader.onerror = reject;
|
|
2694
|
+
reader.readAsDataURL(file);
|
|
2695
|
+
});
|
|
2696
|
+
});
|
|
2697
|
+
try {
|
|
2698
|
+
const loadedImages = (yield Promise.all(imagePromises)).filter((img) => img !== null);
|
|
2699
|
+
setSelectedImages((prev) => [...prev, ...loadedImages]);
|
|
2700
|
+
} catch (error) {
|
|
2701
|
+
console.error("Error processing pasted images:", error);
|
|
2702
|
+
}
|
|
2703
|
+
});
|
|
2704
|
+
document.addEventListener("paste", handlePaste);
|
|
2705
|
+
return () => document.removeEventListener("paste", handlePaste);
|
|
2706
|
+
}, [imageUploadsEnabled]);
|
|
2479
2707
|
(0, import_react13.useEffect)(() => {
|
|
2480
2708
|
if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
|
|
2481
2709
|
setChatInstructions(instructions || "");
|
|
@@ -2503,6 +2731,14 @@ function CopilotChat({
|
|
|
2503
2731
|
onStopGeneration,
|
|
2504
2732
|
onReloadMessages
|
|
2505
2733
|
);
|
|
2734
|
+
const handleSendMessage = (text) => {
|
|
2735
|
+
const images = selectedImages;
|
|
2736
|
+
setSelectedImages([]);
|
|
2737
|
+
if (fileInputRef.current) {
|
|
2738
|
+
fileInputRef.current.value = "";
|
|
2739
|
+
}
|
|
2740
|
+
return sendMessage(text, images);
|
|
2741
|
+
};
|
|
2506
2742
|
const chatContext = import_react13.default.useContext(ChatContext);
|
|
2507
2743
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2508
2744
|
const handleRegenerate = (messageId) => {
|
|
@@ -2516,8 +2752,42 @@ function CopilotChat({
|
|
|
2516
2752
|
onCopy(message);
|
|
2517
2753
|
}
|
|
2518
2754
|
};
|
|
2519
|
-
|
|
2520
|
-
|
|
2755
|
+
const handleImageUpload = (event) => __async(this, null, function* () {
|
|
2756
|
+
if (!event.target.files || event.target.files.length === 0) {
|
|
2757
|
+
return;
|
|
2758
|
+
}
|
|
2759
|
+
const files = Array.from(event.target.files).filter((file) => file.type.startsWith("image/"));
|
|
2760
|
+
if (files.length === 0)
|
|
2761
|
+
return;
|
|
2762
|
+
const fileReadPromises = files.map((file) => {
|
|
2763
|
+
return new Promise((resolve, reject) => {
|
|
2764
|
+
const reader = new FileReader();
|
|
2765
|
+
reader.onload = (e) => {
|
|
2766
|
+
var _a, _b;
|
|
2767
|
+
const base64String = ((_b = (_a = e.target) == null ? void 0 : _a.result) == null ? void 0 : _b.split(",")[1]) || "";
|
|
2768
|
+
if (base64String) {
|
|
2769
|
+
resolve({
|
|
2770
|
+
contentType: file.type,
|
|
2771
|
+
bytes: base64String
|
|
2772
|
+
});
|
|
2773
|
+
}
|
|
2774
|
+
};
|
|
2775
|
+
reader.onerror = reject;
|
|
2776
|
+
reader.readAsDataURL(file);
|
|
2777
|
+
});
|
|
2778
|
+
});
|
|
2779
|
+
try {
|
|
2780
|
+
const loadedImages = yield Promise.all(fileReadPromises);
|
|
2781
|
+
setSelectedImages((prev) => [...prev, ...loadedImages]);
|
|
2782
|
+
} catch (error) {
|
|
2783
|
+
console.error("Error reading files:", error);
|
|
2784
|
+
}
|
|
2785
|
+
});
|
|
2786
|
+
const removeSelectedImage = (index) => {
|
|
2787
|
+
setSelectedImages((prev) => prev.filter((_, i) => i !== index));
|
|
2788
|
+
};
|
|
2789
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
2790
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2521
2791
|
Messages2,
|
|
2522
2792
|
{
|
|
2523
2793
|
AssistantMessage: AssistantMessage2,
|
|
@@ -2526,32 +2796,51 @@ function CopilotChat({
|
|
|
2526
2796
|
RenderActionExecutionMessage: RenderActionExecutionMessage2,
|
|
2527
2797
|
RenderAgentStateMessage: RenderAgentStateMessage2,
|
|
2528
2798
|
RenderResultMessage: RenderResultMessage2,
|
|
2799
|
+
RenderImageMessage: RenderImageMessage2,
|
|
2529
2800
|
messages: visibleMessages,
|
|
2530
2801
|
inProgress: isLoading,
|
|
2531
2802
|
onRegenerate: handleRegenerate,
|
|
2532
2803
|
onCopy: handleCopy,
|
|
2533
2804
|
onThumbsUp,
|
|
2534
2805
|
onThumbsDown,
|
|
2535
|
-
children: currentSuggestions.length > 0 && /* @__PURE__ */ (0,
|
|
2806
|
+
children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "suggestions", children: currentSuggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2536
2807
|
Suggestion,
|
|
2537
2808
|
{
|
|
2538
2809
|
title: suggestion.title,
|
|
2539
2810
|
message: suggestion.message,
|
|
2540
2811
|
partial: suggestion.partial,
|
|
2541
2812
|
className: suggestion.className,
|
|
2542
|
-
onClick: (message) =>
|
|
2813
|
+
onClick: (message) => handleSendMessage(message)
|
|
2543
2814
|
},
|
|
2544
2815
|
index
|
|
2545
2816
|
)) })
|
|
2546
2817
|
}
|
|
2547
2818
|
),
|
|
2548
|
-
/* @__PURE__ */ (0,
|
|
2819
|
+
imageUploadsEnabled && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
2820
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ImageUploadQueue, { images: selectedImages, onRemoveImage: removeSelectedImage }),
|
|
2821
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2822
|
+
"input",
|
|
2823
|
+
{
|
|
2824
|
+
type: "file",
|
|
2825
|
+
multiple: true,
|
|
2826
|
+
ref: fileInputRef,
|
|
2827
|
+
onChange: handleImageUpload,
|
|
2828
|
+
accept: inputFileAccept,
|
|
2829
|
+
style: { display: "none" }
|
|
2830
|
+
}
|
|
2831
|
+
)
|
|
2832
|
+
] }),
|
|
2833
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2549
2834
|
Input2,
|
|
2550
2835
|
{
|
|
2551
2836
|
inProgress: isLoading,
|
|
2552
|
-
onSend:
|
|
2837
|
+
onSend: handleSendMessage,
|
|
2553
2838
|
isVisible,
|
|
2554
|
-
onStop: stopGeneration
|
|
2839
|
+
onStop: stopGeneration,
|
|
2840
|
+
onUpload: imageUploadsEnabled ? () => {
|
|
2841
|
+
var _a;
|
|
2842
|
+
return (_a = fileInputRef.current) == null ? void 0 : _a.click();
|
|
2843
|
+
} : void 0
|
|
2555
2844
|
}
|
|
2556
2845
|
)
|
|
2557
2846
|
] });
|
|
@@ -2564,10 +2853,10 @@ function WrappedCopilotChat({
|
|
|
2564
2853
|
}) {
|
|
2565
2854
|
const chatContext = import_react13.default.useContext(ChatContext);
|
|
2566
2855
|
if (!chatContext) {
|
|
2567
|
-
return /* @__PURE__ */ (0,
|
|
2568
|
-
}, children: /* @__PURE__ */ (0,
|
|
2856
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
|
|
2857
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: `copilotKitChat ${className}`, children }) });
|
|
2569
2858
|
}
|
|
2570
|
-
return /* @__PURE__ */ (0,
|
|
2859
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children });
|
|
2571
2860
|
}
|
|
2572
2861
|
var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
|
|
2573
2862
|
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
|
|
@@ -2621,22 +2910,45 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2621
2910
|
// global context
|
|
2622
2911
|
visibleMessages.length == 0
|
|
2623
2912
|
]);
|
|
2624
|
-
const sendMessage = (messageContent) => __async(void 0, null, function* () {
|
|
2913
|
+
const sendMessage = (messageContent, imagesToUse) => __async(void 0, null, function* () {
|
|
2914
|
+
const images = imagesToUse || [];
|
|
2625
2915
|
abortSuggestions();
|
|
2626
2916
|
setCurrentSuggestions([]);
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2917
|
+
let firstMessage = null;
|
|
2918
|
+
if (messageContent.trim().length > 0) {
|
|
2919
|
+
const textMessage = new import_runtime_client_gql4.TextMessage({
|
|
2920
|
+
content: messageContent,
|
|
2921
|
+
role: import_runtime_client_gql4.Role.User
|
|
2922
|
+
});
|
|
2923
|
+
if (onSubmitMessage) {
|
|
2924
|
+
try {
|
|
2925
|
+
yield onSubmitMessage(messageContent);
|
|
2926
|
+
} catch (error) {
|
|
2927
|
+
console.error("Error in onSubmitMessage:", error);
|
|
2928
|
+
}
|
|
2929
|
+
}
|
|
2930
|
+
yield appendMessage(textMessage, { followUp: images.length === 0 });
|
|
2931
|
+
if (!firstMessage) {
|
|
2932
|
+
firstMessage = textMessage;
|
|
2933
|
+
}
|
|
2934
|
+
}
|
|
2935
|
+
if (images.length > 0) {
|
|
2936
|
+
for (let i = 0; i < images.length; i++) {
|
|
2937
|
+
const imageMessage = new import_runtime_client_gql4.ImageMessage({
|
|
2938
|
+
format: images[i].contentType.replace("image/", ""),
|
|
2939
|
+
bytes: images[i].bytes,
|
|
2940
|
+
role: import_runtime_client_gql4.Role.User
|
|
2941
|
+
});
|
|
2942
|
+
yield appendMessage(imageMessage, { followUp: i === images.length - 1 });
|
|
2943
|
+
if (!firstMessage) {
|
|
2944
|
+
firstMessage = imageMessage;
|
|
2945
|
+
}
|
|
2636
2946
|
}
|
|
2637
2947
|
}
|
|
2638
|
-
|
|
2639
|
-
|
|
2948
|
+
if (!firstMessage) {
|
|
2949
|
+
return new import_runtime_client_gql4.TextMessage({ content: "", role: import_runtime_client_gql4.Role.User });
|
|
2950
|
+
}
|
|
2951
|
+
return firstMessage;
|
|
2640
2952
|
});
|
|
2641
2953
|
const messages = visibleMessages;
|
|
2642
2954
|
const { setMessages } = messagesContext;
|
|
@@ -2729,7 +3041,7 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2729
3041
|
};
|
|
2730
3042
|
|
|
2731
3043
|
// src/components/chat/Modal.tsx
|
|
2732
|
-
var
|
|
3044
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2733
3045
|
var CopilotModal = ({
|
|
2734
3046
|
instructions,
|
|
2735
3047
|
defaultOpen = false,
|
|
@@ -2763,19 +3075,19 @@ var CopilotModal = ({
|
|
|
2763
3075
|
onSetOpen == null ? void 0 : onSetOpen(open);
|
|
2764
3076
|
setOpenState(open);
|
|
2765
3077
|
};
|
|
2766
|
-
return /* @__PURE__ */ (0,
|
|
3078
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(ChatContextProvider, { icons, labels, open: openState, setOpen, children: [
|
|
2767
3079
|
children,
|
|
2768
|
-
/* @__PURE__ */ (0,
|
|
2769
|
-
/* @__PURE__ */ (0,
|
|
2770
|
-
/* @__PURE__ */ (0,
|
|
3080
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className, children: [
|
|
3081
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Button2, {}),
|
|
3082
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
2771
3083
|
Window2,
|
|
2772
3084
|
{
|
|
2773
3085
|
clickOutsideToClose,
|
|
2774
3086
|
shortcut,
|
|
2775
3087
|
hitEscapeToClose,
|
|
2776
3088
|
children: [
|
|
2777
|
-
/* @__PURE__ */ (0,
|
|
2778
|
-
/* @__PURE__ */ (0,
|
|
3089
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Header2, {}),
|
|
3090
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2779
3091
|
CopilotChat,
|
|
2780
3092
|
{
|
|
2781
3093
|
instructions,
|
|
@@ -2802,17 +3114,17 @@ var CopilotModal = ({
|
|
|
2802
3114
|
};
|
|
2803
3115
|
|
|
2804
3116
|
// src/components/chat/Popup.tsx
|
|
2805
|
-
var
|
|
3117
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
2806
3118
|
function CopilotPopup(props) {
|
|
2807
3119
|
props = __spreadProps(__spreadValues({}, props), {
|
|
2808
3120
|
className: props.className ? props.className + " copilotKitPopup" : "copilotKitPopup"
|
|
2809
3121
|
});
|
|
2810
|
-
return /* @__PURE__ */ (0,
|
|
3122
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CopilotModal, __spreadProps(__spreadValues({}, props), { children: props.children }));
|
|
2811
3123
|
}
|
|
2812
3124
|
|
|
2813
3125
|
// src/components/chat/Sidebar.tsx
|
|
2814
3126
|
var import_react15 = require("react");
|
|
2815
|
-
var
|
|
3127
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
2816
3128
|
function CopilotSidebar(props) {
|
|
2817
3129
|
props = __spreadProps(__spreadValues({}, props), {
|
|
2818
3130
|
className: props.className ? props.className + " copilotKitSidebar" : "copilotKitSidebar"
|
|
@@ -2825,7 +3137,7 @@ function CopilotSidebar(props) {
|
|
|
2825
3137
|
(_a = props.onSetOpen) == null ? void 0 : _a.call(props, open);
|
|
2826
3138
|
setExpandedClassName(open ? "sidebarExpanded" : "");
|
|
2827
3139
|
};
|
|
2828
|
-
return /* @__PURE__ */ (0,
|
|
3140
|
+
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 })) });
|
|
2829
3141
|
}
|
|
2830
3142
|
|
|
2831
3143
|
// src/hooks/use-copilot-chat-suggestions.tsx
|
|
@@ -2863,6 +3175,7 @@ function useCopilotChatSuggestions({
|
|
|
2863
3175
|
CopilotPopup,
|
|
2864
3176
|
CopilotSidebar,
|
|
2865
3177
|
Markdown,
|
|
3178
|
+
RenderImageMessage,
|
|
2866
3179
|
UserMessage,
|
|
2867
3180
|
shouldShowDevConsole,
|
|
2868
3181
|
useChatContext,
|