wcz-layout 10.2.1 → 10.2.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/dist/{ChatLayout-BpRj5rlH.mjs → ChatLayout-CkS9oyPp.mjs} +557 -270
- package/dist/ChatLayout-CkS9oyPp.mjs.map +1 -0
- package/dist/{Employee-C8xIlBxY.d.mts → ExtractFile-ClTc-e1H.d.mts} +20 -3
- package/dist/RouterListItemButton-CF-8w-08.mjs.map +1 -1
- package/dist/Translate-Ad784Dps.d.mts +24 -0
- package/dist/{Approval-D1TfISUL.mjs → Translate-BiCjnlyx.mjs} +22 -2
- package/dist/Translate-BiCjnlyx.mjs.map +1 -0
- package/dist/ai.d.mts +31 -4
- package/dist/ai.mjs +154 -10
- package/dist/ai.mjs.map +1 -1
- package/dist/auth.d.mts +4 -3
- package/dist/auth.mjs +5 -5
- package/dist/authMiddleware-D4GSt7m9.mjs +50 -0
- package/dist/authMiddleware-D4GSt7m9.mjs.map +1 -0
- package/dist/components.mjs +13 -5
- package/dist/components.mjs.map +1 -1
- package/dist/{createApi-BXjkj4fM.mjs → createApi-CF4ZL82B.mjs} +3 -4
- package/dist/createApi-CF4ZL82B.mjs.map +1 -0
- package/dist/data/client.d.mts +17 -1
- package/dist/data/client.mjs +11 -5
- package/dist/data/client.mjs.map +1 -1
- package/dist/data/server.d.mts +18 -3
- package/dist/data/server.mjs +5 -5
- package/dist/{env-BwFl7nWc.mjs → env-Cddts_dn.mjs} +2 -1
- package/dist/env-Cddts_dn.mjs.map +1 -0
- package/dist/{file-BQ-Bu2g8.mjs → file-D4kSR_lC.mjs} +5 -6
- package/dist/file-D4kSR_lC.mjs.map +1 -0
- package/dist/{file-DZ0KYhoB.mjs → file-DcwYjofa.mjs} +5 -6
- package/dist/file-DcwYjofa.mjs.map +1 -0
- package/dist/generatedChart-k7NEdi5Z.mjs.map +1 -1
- package/dist/hooks.d.mts +2 -2
- package/dist/hooks.mjs +294 -192
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.mjs +224 -173
- package/dist/index.mjs.map +1 -1
- package/dist/{approval-B3ZQn9aH.mjs → layout-6We_KFgN.mjs} +28 -4
- package/dist/layout-6We_KFgN.mjs.map +1 -0
- package/dist/middleware.mjs +1 -45
- package/dist/middleware.mjs.map +1 -1
- package/dist/models.d.mts +3 -3
- package/dist/models.mjs +2 -2
- package/dist/{peoplesoft-CvwdApCK.mjs → peoplesoft-DH31FCMC.mjs} +3 -3
- package/dist/{peoplesoft-CvwdApCK.mjs.map → peoplesoft-DH31FCMC.mjs.map} +1 -1
- package/dist/{peoplesoft-C-zPdRVj.d.mts → peoplesoft-DXukeeFr.d.mts} +2 -2
- package/dist/{providers-BfFg_3eo.mjs → providers-DOFje2P6.mjs} +7 -7
- package/dist/providers-DOFje2P6.mjs.map +1 -0
- package/dist/{tokens-CkWpu7Qp.mjs → tokens-DNe_Qifk.mjs} +63 -9
- package/dist/tokens-DNe_Qifk.mjs.map +1 -0
- package/dist/user-Bc2nLjAG.mjs +136 -0
- package/dist/user-Bc2nLjAG.mjs.map +1 -0
- package/dist/utils-CgabUlDD.mjs +131 -0
- package/dist/utils-CgabUlDD.mjs.map +1 -0
- package/dist/utils.mjs +1 -1
- package/package.json +34 -13
- package/skills/ai/SKILL.md +108 -75
- package/skills/general/references/auth.md +7 -3
- package/skills/services/SKILL.md +41 -7
- package/skills/services/docs/layout.md +130 -0
- package/skills/start/steps/03-apm-setup.md +8 -1
- package/dist/Approval-D1TfISUL.mjs.map +0 -1
- package/dist/ChatLayout-BpRj5rlH.mjs.map +0 -1
- package/dist/Email-Dz5k0UWE.d.mts +0 -15
- package/dist/approval-B3ZQn9aH.mjs.map +0 -1
- package/dist/createApi-BXjkj4fM.mjs.map +0 -1
- package/dist/env-BwFl7nWc.mjs.map +0 -1
- package/dist/file-BQ-Bu2g8.mjs.map +0 -1
- package/dist/file-DZ0KYhoB.mjs.map +0 -1
- package/dist/providers-BfFg_3eo.mjs.map +0 -1
- package/dist/session-B_jK90RC.mjs +0 -23
- package/dist/session-B_jK90RC.mjs.map +0 -1
- package/dist/tokens-CkWpu7Qp.mjs.map +0 -1
- package/dist/utils-DJx-7b4M.mjs +0 -244
- package/dist/utils-DJx-7b4M.mjs.map +0 -1
|
@@ -8,6 +8,8 @@ import { z as z$1 } from "zod";
|
|
|
8
8
|
import { keyframes } from "@mui/material/styles";
|
|
9
9
|
import { CatchBoundary, createLink } from "@tanstack/react-router";
|
|
10
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { useDropzone } from "react-dropzone";
|
|
12
|
+
import AttachFile from "@mui/icons-material/AttachFile";
|
|
11
13
|
import { formatForDisplay } from "@tanstack/react-hotkeys";
|
|
12
14
|
import { defaultRangeExtractor } from "@tanstack/react-virtual";
|
|
13
15
|
import { aggregationFn_count, aggregationFn_extent, aggregationFn_first, aggregationFn_last, aggregationFn_max, aggregationFn_mean, aggregationFn_median, aggregationFn_min, aggregationFn_sum, aggregationFn_unique, aggregationFn_uniqueCount, createExpandedRowModel, createFacetedMinMaxValues, createFacetedRowModel, createFacetedUniqueValues, createFilteredRowModel, createGroupedRowModel, createPaginatedRowModel, createSortedRowModel, createTableHookContexts, filterFn_arrHas, filterFn_arrIncludes, filterFn_arrIncludesAll, filterFn_arrIncludesSome, filterFn_between, filterFn_betweenInclusive, filterFn_empty, filterFn_endsWith, filterFn_equals, filterFn_equalsString, filterFn_equalsStringSensitive, filterFn_greaterThan, filterFn_greaterThanOrEqualTo, filterFn_inDateRange, filterFn_inNumberRange, filterFn_includesString, filterFn_includesStringSensitive, filterFn_lessThan, filterFn_lessThanOrEqualTo, filterFn_notEmpty, filterFn_startsWith, filterFn_weakEquals, metaHelper, sortFn_alphanumeric, sortFn_alphanumericCaseSensitive, sortFn_basic, sortFn_datetime, sortFn_text, sortFn_textCaseSensitive, stockFeatures, tableFeatures } from "@tanstack/react-table";
|
|
@@ -15,9 +17,10 @@ import Add from "@mui/icons-material/Add";
|
|
|
15
17
|
import ArrowUpward from "@mui/icons-material/ArrowUpward";
|
|
16
18
|
import Refresh from "@mui/icons-material/Refresh";
|
|
17
19
|
import Stop from "@mui/icons-material/Stop";
|
|
20
|
+
import { visuallyHidden } from "@mui/utils";
|
|
21
|
+
import { parsePartialJSON } from "@tanstack/ai-react";
|
|
18
22
|
import { streamingMarkdownExtension } from "@tanstack/markdown/extensions/streaming";
|
|
19
23
|
import { Markdown } from "@tanstack/markdown/react";
|
|
20
|
-
import { parsePartialJSON } from "@tanstack/ai-react";
|
|
21
24
|
import { toolDefinition } from "@tanstack/ai/client";
|
|
22
25
|
// src/hooks/useDialogs.tsx
|
|
23
26
|
function AlertDialog(t0) {
|
|
@@ -997,6 +1000,68 @@ function _temp$1(t0) {
|
|
|
997
1000
|
const [name_0, value_0] = t0;
|
|
998
1001
|
return `${name_0}: ${String(value_0)}`;
|
|
999
1002
|
}
|
|
1003
|
+
// src/lib/ai/attachments.ts
|
|
1004
|
+
const MAX_BYTES = 10485760;
|
|
1005
|
+
const MAX_IMAGE_SIDE = 1568;
|
|
1006
|
+
const DOCUMENTS = {
|
|
1007
|
+
pdf: "application/pdf",
|
|
1008
|
+
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
1009
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
1010
|
+
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
1011
|
+
rtf: "application/rtf",
|
|
1012
|
+
csv: "text/csv",
|
|
1013
|
+
md: "text/markdown",
|
|
1014
|
+
json: "application/json",
|
|
1015
|
+
html: "text/html",
|
|
1016
|
+
txt: "text/plain"
|
|
1017
|
+
};
|
|
1018
|
+
const base64 = (file) => new Promise((resolve, reject) => {
|
|
1019
|
+
const reader = new FileReader();
|
|
1020
|
+
reader.onload = () => resolve(reader.result.split(",")[1]);
|
|
1021
|
+
reader.onerror = () => reject(reader.error ?? /* @__PURE__ */ new Error("Cannot read the file"));
|
|
1022
|
+
reader.readAsDataURL(file);
|
|
1023
|
+
});
|
|
1024
|
+
/** An image as the model sees it: a JPEG no larger than it reads, base64. */
|
|
1025
|
+
async function readImage(file) {
|
|
1026
|
+
const image = await createImageBitmap(file);
|
|
1027
|
+
const scale = Math.min(1, MAX_IMAGE_SIDE / Math.max(image.width, image.height));
|
|
1028
|
+
const canvas = document.createElement("canvas");
|
|
1029
|
+
canvas.width = Math.round(image.width * scale);
|
|
1030
|
+
canvas.height = Math.round(image.height * scale);
|
|
1031
|
+
const context = canvas.getContext("2d");
|
|
1032
|
+
if (!context) throw new Error("No canvas");
|
|
1033
|
+
context.fillStyle = "#fff";
|
|
1034
|
+
context.fillRect(0, 0, canvas.width, canvas.height);
|
|
1035
|
+
context.drawImage(image, 0, 0, canvas.width, canvas.height);
|
|
1036
|
+
return canvas.toDataURL("image/jpeg", .85).split(",")[1];
|
|
1037
|
+
}
|
|
1038
|
+
/**
|
|
1039
|
+
* A file as one part of a user message, kept in the conversation and never uploaded to the file
|
|
1040
|
+
* service. The model reads it as it is: an image of any kind the browser shows, and a document
|
|
1041
|
+
* (PDF, Word, Excel, PowerPoint, CSV or text). Throws for a file it cannot read or a large one.
|
|
1042
|
+
*/
|
|
1043
|
+
async function fileToPart(file) {
|
|
1044
|
+
if (file.type.startsWith("image/")) return {
|
|
1045
|
+
type: "image",
|
|
1046
|
+
source: {
|
|
1047
|
+
type: "data",
|
|
1048
|
+
value: await readImage(file),
|
|
1049
|
+
mimeType: "image/jpeg"
|
|
1050
|
+
}
|
|
1051
|
+
};
|
|
1052
|
+
const extension = file.name.split(".").at(-1)?.toLowerCase() ?? "";
|
|
1053
|
+
const mimeType = DOCUMENTS[extension] ?? (file.type.startsWith("text/") ? "text/plain" : "");
|
|
1054
|
+
if (!mimeType || file.size > MAX_BYTES) throw new Error(`Cannot attach ${file.name}`);
|
|
1055
|
+
return {
|
|
1056
|
+
type: "document",
|
|
1057
|
+
source: {
|
|
1058
|
+
type: "data",
|
|
1059
|
+
value: await base64(file),
|
|
1060
|
+
mimeType
|
|
1061
|
+
},
|
|
1062
|
+
metadata: { filename: file.name }
|
|
1063
|
+
};
|
|
1064
|
+
}
|
|
1000
1065
|
// src/components/chat/ChatLayout.tsx
|
|
1001
1066
|
/** One centered reading column, like ChatGPT: full width on a phone, 48rem on a desktop. */
|
|
1002
1067
|
const columnSx = {
|
|
@@ -1147,7 +1212,6 @@ function Reasoning() {
|
|
|
1147
1212
|
let t1;
|
|
1148
1213
|
if ($[2] !== t0) {
|
|
1149
1214
|
t1 = /* @__PURE__ */ jsx(Typography, {
|
|
1150
|
-
role: "status",
|
|
1151
1215
|
className: statusClass,
|
|
1152
1216
|
sx: shimmerSx,
|
|
1153
1217
|
children: t0
|
|
@@ -1195,6 +1259,15 @@ const activities = {
|
|
|
1195
1259
|
"PressedKey"
|
|
1196
1260
|
]
|
|
1197
1261
|
};
|
|
1262
|
+
/** A tool's name as words: external_create_device is "create device". */
|
|
1263
|
+
const words = (name) => name.replace(/^external_/, "").replaceAll("_", " ");
|
|
1264
|
+
/** The functions a program calls, or a lookup asks for, as words: "list devices, create device". */
|
|
1265
|
+
function functionsOf({ input, arguments: json }) {
|
|
1266
|
+
const { typescriptCode, toolNames } = input ?? parsePartialJSON(json) ?? {};
|
|
1267
|
+
const called = typeof typescriptCode === "string" ? Array.from(typescriptCode.matchAll(/external_(\w+)/g), ([, name]) => name) : [];
|
|
1268
|
+
const asked = Array.isArray(toolNames) ? toolNames.filter((name) => typeof name === "string") : [];
|
|
1269
|
+
return [...new Set([...asked, ...called].map(words))].join(", ");
|
|
1270
|
+
}
|
|
1198
1271
|
/** What a page tool acted on, for its line: the element clicked, the values filled, the key. */
|
|
1199
1272
|
function targetOf({ input }) {
|
|
1200
1273
|
const { name, key, fields } = input ?? {};
|
|
@@ -1211,135 +1284,158 @@ function activityOf({ name, state, output }, live) {
|
|
|
1211
1284
|
if (!live) return "ToolStopped";
|
|
1212
1285
|
return state === "awaiting-input" || state === "input-streaming" ? writing : running;
|
|
1213
1286
|
}
|
|
1287
|
+
/** A tool's line in words, e.g. "Running code… · list devices". */
|
|
1288
|
+
const activityText = (t, part, live) => [t(`Layout.Chat.${activityOf(part, live)}`, {
|
|
1289
|
+
name: words(part.name),
|
|
1290
|
+
target: targetOf(part)
|
|
1291
|
+
}), functionsOf(part)].filter(Boolean).join(" · ");
|
|
1214
1292
|
/** A tool without UI of its own, as one line: what it does while it runs, then what it did. */
|
|
1215
1293
|
function ToolActivity(t0) {
|
|
1216
|
-
const $ = c(
|
|
1294
|
+
const $ = c(9);
|
|
1217
1295
|
const { part, live } = t0;
|
|
1218
1296
|
const { t } = useTranslation();
|
|
1219
1297
|
const running = live && part.output === void 0;
|
|
1220
|
-
|
|
1221
|
-
let t2;
|
|
1298
|
+
let t1;
|
|
1222
1299
|
if ($[0] !== running) {
|
|
1223
|
-
|
|
1300
|
+
t1 = running ? shimmerSx : { color: "text.secondary" };
|
|
1224
1301
|
$[0] = running;
|
|
1225
|
-
$[1] =
|
|
1226
|
-
} else
|
|
1227
|
-
let
|
|
1228
|
-
if ($[2] !== live || $[3] !== part) {
|
|
1229
|
-
|
|
1302
|
+
$[1] = t1;
|
|
1303
|
+
} else t1 = $[1];
|
|
1304
|
+
let t2;
|
|
1305
|
+
if ($[2] !== live || $[3] !== part || $[4] !== t) {
|
|
1306
|
+
t2 = activityText(t, part, live);
|
|
1230
1307
|
$[2] = live;
|
|
1231
1308
|
$[3] = part;
|
|
1232
|
-
$[4] =
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
let
|
|
1236
|
-
if ($[
|
|
1237
|
-
|
|
1238
|
-
name: part.name,
|
|
1239
|
-
target: targetOf(part)
|
|
1240
|
-
});
|
|
1241
|
-
$[5] = part;
|
|
1242
|
-
$[6] = t;
|
|
1243
|
-
$[7] = t4;
|
|
1244
|
-
$[8] = t5;
|
|
1245
|
-
} else t5 = $[8];
|
|
1246
|
-
let t6;
|
|
1247
|
-
if ($[9] !== t1 || $[10] !== t2 || $[11] !== t5) {
|
|
1248
|
-
t6 = /* @__PURE__ */ jsx(Typography, {
|
|
1309
|
+
$[4] = t;
|
|
1310
|
+
$[5] = t2;
|
|
1311
|
+
} else t2 = $[5];
|
|
1312
|
+
let t3;
|
|
1313
|
+
if ($[6] !== t1 || $[7] !== t2) {
|
|
1314
|
+
t3 = /* @__PURE__ */ jsx(Typography, {
|
|
1249
1315
|
variant: "body2",
|
|
1250
|
-
role: t1,
|
|
1251
1316
|
className: statusClass,
|
|
1252
|
-
sx:
|
|
1253
|
-
children:
|
|
1317
|
+
sx: t1,
|
|
1318
|
+
children: t2
|
|
1254
1319
|
});
|
|
1255
|
-
$[
|
|
1256
|
-
$[
|
|
1257
|
-
$[
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
return t6;
|
|
1320
|
+
$[6] = t1;
|
|
1321
|
+
$[7] = t2;
|
|
1322
|
+
$[8] = t3;
|
|
1323
|
+
} else t3 = $[8];
|
|
1324
|
+
return t3;
|
|
1261
1325
|
}
|
|
1326
|
+
/** The name a document was attached under. */
|
|
1327
|
+
const fileNameOf = (part) => part.type === "document" ? part.metadata?.filename ?? "document" : void 0;
|
|
1328
|
+
const srcOf = ({ source }) => source.type === "data" ? `data:${source.mimeType};base64,${source.value}` : source.value;
|
|
1262
1329
|
function ChatMessage(t0) {
|
|
1263
|
-
const $ = c(
|
|
1330
|
+
const $ = c(12);
|
|
1264
1331
|
const { message, live, canAnswer, addToolResult } = t0;
|
|
1265
1332
|
if (message.role === "user") {
|
|
1266
1333
|
let t1;
|
|
1267
|
-
if ($[0]
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
$[
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1334
|
+
if ($[0] !== message.parts) {
|
|
1335
|
+
const typed = message.parts.flatMap(_temp);
|
|
1336
|
+
const files = message.parts.filter(_temp2);
|
|
1337
|
+
let t2;
|
|
1338
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1339
|
+
t2 = {
|
|
1340
|
+
alignSelf: "flex-end",
|
|
1341
|
+
alignItems: "flex-end",
|
|
1342
|
+
maxWidth: "80%"
|
|
1343
|
+
};
|
|
1344
|
+
$[2] = t2;
|
|
1345
|
+
} else t2 = $[2];
|
|
1346
|
+
t1 = /* @__PURE__ */ jsxs(Stack, {
|
|
1347
|
+
spacing: 1,
|
|
1348
|
+
sx: t2,
|
|
1349
|
+
children: [files.length > 0 && /* @__PURE__ */ jsx(Stack, {
|
|
1350
|
+
direction: "row",
|
|
1351
|
+
sx: {
|
|
1352
|
+
flexWrap: "wrap",
|
|
1353
|
+
justifyContent: "flex-end",
|
|
1354
|
+
gap: .5
|
|
1355
|
+
},
|
|
1356
|
+
children: files.map(_temp3)
|
|
1357
|
+
}), typed.length > 0 && /* @__PURE__ */ jsx(Typography, {
|
|
1358
|
+
sx: {
|
|
1359
|
+
px: 2,
|
|
1360
|
+
py: 1.25,
|
|
1361
|
+
borderRadius: 4.5,
|
|
1362
|
+
bgcolor: "action.hover",
|
|
1363
|
+
whiteSpace: "pre-wrap",
|
|
1364
|
+
overflowWrap: "anywhere"
|
|
1365
|
+
},
|
|
1366
|
+
children: typed.join("\n")
|
|
1367
|
+
})]
|
|
1291
1368
|
});
|
|
1292
|
-
$[
|
|
1293
|
-
$[
|
|
1294
|
-
} else
|
|
1295
|
-
return
|
|
1369
|
+
$[0] = message.parts;
|
|
1370
|
+
$[1] = t1;
|
|
1371
|
+
} else t1 = $[1];
|
|
1372
|
+
return t1;
|
|
1296
1373
|
}
|
|
1297
1374
|
let t1;
|
|
1298
|
-
if ($[
|
|
1375
|
+
if ($[3] !== addToolResult || $[4] !== canAnswer || $[5] !== live || $[6] !== message.parts) {
|
|
1299
1376
|
let t2;
|
|
1300
|
-
if ($[
|
|
1301
|
-
t2 = (
|
|
1302
|
-
if (
|
|
1377
|
+
if ($[8] !== addToolResult || $[9] !== canAnswer || $[10] !== live) {
|
|
1378
|
+
t2 = (part_1, index_0) => {
|
|
1379
|
+
if (part_1.type === "text") return part_1.content ? /* @__PURE__ */ jsx(Box, {
|
|
1303
1380
|
sx: markdownSx,
|
|
1304
1381
|
children: /* @__PURE__ */ jsx(Markdown, {
|
|
1305
1382
|
extensions: markdownExtensions,
|
|
1306
1383
|
components: markdownComponents,
|
|
1307
|
-
children:
|
|
1384
|
+
children: part_1.content
|
|
1308
1385
|
})
|
|
1309
|
-
},
|
|
1310
|
-
if (
|
|
1311
|
-
if ((
|
|
1312
|
-
if (
|
|
1313
|
-
if (
|
|
1314
|
-
part:
|
|
1315
|
-
disabled: !canAnswer ||
|
|
1386
|
+
}, index_0) : null;
|
|
1387
|
+
if (part_1.type !== "tool-call") return null;
|
|
1388
|
+
if ((part_1.name === "show_ui" || part_1.name === "ask_user") && part_1.state === "error") return null;
|
|
1389
|
+
if (part_1.name === "show_ui") return /* @__PURE__ */ jsx(GeneratedUi, { part: part_1 }, part_1.id);
|
|
1390
|
+
if (part_1.name === "ask_user") return /* @__PURE__ */ jsx(AskUser, {
|
|
1391
|
+
part: part_1,
|
|
1392
|
+
disabled: !canAnswer || part_1.output !== void 0,
|
|
1316
1393
|
onAnswer: (output) => void addToolResult({
|
|
1317
|
-
toolCallId:
|
|
1318
|
-
tool:
|
|
1394
|
+
toolCallId: part_1.id,
|
|
1395
|
+
tool: part_1.name,
|
|
1319
1396
|
output
|
|
1320
1397
|
})
|
|
1321
|
-
},
|
|
1398
|
+
}, part_1.id);
|
|
1322
1399
|
return /* @__PURE__ */ jsx(ToolActivity, {
|
|
1323
|
-
part:
|
|
1400
|
+
part: part_1,
|
|
1324
1401
|
live
|
|
1325
|
-
},
|
|
1402
|
+
}, part_1.id);
|
|
1326
1403
|
};
|
|
1327
|
-
$[
|
|
1328
|
-
$[
|
|
1329
|
-
$[
|
|
1330
|
-
$[
|
|
1331
|
-
} else t2 = $[
|
|
1404
|
+
$[8] = addToolResult;
|
|
1405
|
+
$[9] = canAnswer;
|
|
1406
|
+
$[10] = live;
|
|
1407
|
+
$[11] = t2;
|
|
1408
|
+
} else t2 = $[11];
|
|
1332
1409
|
t1 = message.parts.map(t2);
|
|
1333
|
-
$[
|
|
1334
|
-
$[
|
|
1335
|
-
$[
|
|
1336
|
-
$[
|
|
1337
|
-
$[
|
|
1338
|
-
} else t1 = $[
|
|
1410
|
+
$[3] = addToolResult;
|
|
1411
|
+
$[4] = canAnswer;
|
|
1412
|
+
$[5] = live;
|
|
1413
|
+
$[6] = message.parts;
|
|
1414
|
+
$[7] = t1;
|
|
1415
|
+
} else t1 = $[7];
|
|
1339
1416
|
return t1;
|
|
1340
1417
|
}
|
|
1418
|
+
function _temp3(part_0, index) {
|
|
1419
|
+
return part_0.type === "image" ? /* @__PURE__ */ jsx(Box, {
|
|
1420
|
+
component: "img",
|
|
1421
|
+
src: srcOf(part_0),
|
|
1422
|
+
alt: "Attached image",
|
|
1423
|
+
sx: {
|
|
1424
|
+
maxWidth: "100%",
|
|
1425
|
+
maxHeight: 160,
|
|
1426
|
+
borderRadius: 3
|
|
1427
|
+
}
|
|
1428
|
+
}, index) : /* @__PURE__ */ jsx(Chip, {
|
|
1429
|
+
variant: "outlined",
|
|
1430
|
+
label: fileNameOf(part_0)
|
|
1431
|
+
}, index);
|
|
1432
|
+
}
|
|
1433
|
+
function _temp2(t0) {
|
|
1434
|
+
const { type } = t0;
|
|
1435
|
+
return type === "image" || type === "document";
|
|
1436
|
+
}
|
|
1341
1437
|
function _temp(part) {
|
|
1342
|
-
return part.type === "text" ? part.content :
|
|
1438
|
+
return part.type === "text" ? [part.content] : [];
|
|
1343
1439
|
}
|
|
1344
1440
|
/** Confirms a server tool marked `needsApproval`; the model has said what it is about to do. */
|
|
1345
1441
|
function Approvals(t0) {
|
|
@@ -1388,252 +1484,443 @@ const roundButtonSx = {
|
|
|
1388
1484
|
color: "background.paper",
|
|
1389
1485
|
"&:hover": { bgcolor: "text.secondary" }
|
|
1390
1486
|
};
|
|
1487
|
+
/** A message waiting for the reply to end, as one line: what was typed, or the files' names. */
|
|
1488
|
+
function queuedText(queued) {
|
|
1489
|
+
const content = typeof queued === "string" ? queued : queued.content;
|
|
1490
|
+
if (typeof content === "string") return content;
|
|
1491
|
+
return content.flatMap((part) => part.type === "text" ? [part.content] : fileNameOf(part) ?? []).join(" · ") || "…";
|
|
1492
|
+
}
|
|
1391
1493
|
function ChatInput(t0) {
|
|
1392
|
-
const $ = c(
|
|
1393
|
-
const { chat, onSend } = t0;
|
|
1494
|
+
const $ = c(69);
|
|
1495
|
+
const { chat, files, setFiles, pick, onSend } = t0;
|
|
1394
1496
|
const { t } = useTranslation();
|
|
1395
1497
|
const { confirm } = useDialogs();
|
|
1396
1498
|
const [draft, setDraft] = useState("");
|
|
1397
1499
|
let t1;
|
|
1398
|
-
if ($[0] !==
|
|
1399
|
-
t1 = (
|
|
1500
|
+
if ($[0] !== draft || $[1] !== files.length) {
|
|
1501
|
+
t1 = draft.trim() !== "" || files.length > 0;
|
|
1502
|
+
$[0] = draft;
|
|
1503
|
+
$[1] = files.length;
|
|
1504
|
+
$[2] = t1;
|
|
1505
|
+
} else t1 = $[2];
|
|
1506
|
+
const ready = t1;
|
|
1507
|
+
let t2;
|
|
1508
|
+
if ($[3] !== chat || $[4] !== draft || $[5] !== files || $[6] !== onSend || $[7] !== ready || $[8] !== setFiles) {
|
|
1509
|
+
t2 = (event) => {
|
|
1400
1510
|
event.preventDefault();
|
|
1401
|
-
if (!
|
|
1511
|
+
if (!ready) return;
|
|
1402
1512
|
onSend();
|
|
1403
|
-
|
|
1513
|
+
const parts = files.map(_temp4);
|
|
1514
|
+
if (draft.trim()) parts.push({
|
|
1515
|
+
type: "text",
|
|
1516
|
+
content: draft.trim()
|
|
1517
|
+
});
|
|
1518
|
+
chat.sendMessage(files.length ? { content: parts } : draft.trim());
|
|
1404
1519
|
setDraft("");
|
|
1520
|
+
setFiles([]);
|
|
1405
1521
|
};
|
|
1406
|
-
$[
|
|
1407
|
-
$[
|
|
1408
|
-
$[
|
|
1409
|
-
$[
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1522
|
+
$[3] = chat;
|
|
1523
|
+
$[4] = draft;
|
|
1524
|
+
$[5] = files;
|
|
1525
|
+
$[6] = onSend;
|
|
1526
|
+
$[7] = ready;
|
|
1527
|
+
$[8] = setFiles;
|
|
1528
|
+
$[9] = t2;
|
|
1529
|
+
} else t2 = $[9];
|
|
1530
|
+
const send = t2;
|
|
1531
|
+
const sendOnEnter = _temp5;
|
|
1532
|
+
let t3;
|
|
1533
|
+
if ($[10] !== chat || $[11] !== confirm || $[12] !== t) {
|
|
1534
|
+
t3 = async () => {
|
|
1416
1535
|
if (await confirm(t("Layout.Chat.NewChatConfirm"))) chat.clear();
|
|
1417
1536
|
};
|
|
1418
|
-
$[
|
|
1419
|
-
$[
|
|
1420
|
-
$[
|
|
1421
|
-
$[
|
|
1422
|
-
} else
|
|
1423
|
-
const newChat =
|
|
1424
|
-
let
|
|
1425
|
-
if ($[
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1537
|
+
$[10] = chat;
|
|
1538
|
+
$[11] = confirm;
|
|
1539
|
+
$[12] = t;
|
|
1540
|
+
$[13] = t3;
|
|
1541
|
+
} else t3 = $[13];
|
|
1542
|
+
const newChat = t3;
|
|
1543
|
+
let t4;
|
|
1544
|
+
if ($[14] !== chat) {
|
|
1545
|
+
t4 = chat.queue.map((t5) => {
|
|
1546
|
+
const { id, content } = t5;
|
|
1547
|
+
return /* @__PURE__ */ jsx(Chip, {
|
|
1548
|
+
variant: "outlined",
|
|
1549
|
+
label: queuedText(content),
|
|
1550
|
+
onDelete: () => chat.cancelQueued(id),
|
|
1551
|
+
sx: {
|
|
1552
|
+
alignSelf: "flex-end",
|
|
1553
|
+
maxWidth: "80%"
|
|
1554
|
+
}
|
|
1555
|
+
}, id);
|
|
1556
|
+
});
|
|
1557
|
+
$[14] = chat;
|
|
1558
|
+
$[15] = t4;
|
|
1559
|
+
} else t4 = $[15];
|
|
1560
|
+
let t5;
|
|
1561
|
+
if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1562
|
+
t5 = {
|
|
1430
1563
|
p: 1,
|
|
1431
1564
|
borderRadius: 7,
|
|
1432
1565
|
boxShadow: 2
|
|
1433
1566
|
};
|
|
1434
|
-
$[
|
|
1435
|
-
} else
|
|
1436
|
-
let
|
|
1437
|
-
if ($[
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
children: t7
|
|
1460
|
-
}) });
|
|
1461
|
-
$[14] = t5;
|
|
1462
|
-
$[15] = t6;
|
|
1463
|
-
$[16] = t8;
|
|
1464
|
-
} else t8 = $[16];
|
|
1465
|
-
let t9;
|
|
1466
|
-
if ($[17] !== t4 || $[18] !== t8) {
|
|
1467
|
-
t9 = /* @__PURE__ */ jsx(Tooltip, {
|
|
1468
|
-
title: t4,
|
|
1469
|
-
children: t8
|
|
1567
|
+
$[16] = t5;
|
|
1568
|
+
} else t5 = $[16];
|
|
1569
|
+
let t6;
|
|
1570
|
+
if ($[17] !== files || $[18] !== setFiles) {
|
|
1571
|
+
t6 = files.length > 0 && /* @__PURE__ */ jsx(Stack, {
|
|
1572
|
+
direction: "row",
|
|
1573
|
+
sx: {
|
|
1574
|
+
flexWrap: "wrap",
|
|
1575
|
+
gap: .5,
|
|
1576
|
+
px: 1,
|
|
1577
|
+
pb: 1
|
|
1578
|
+
},
|
|
1579
|
+
children: files.map((t7, index) => {
|
|
1580
|
+
const { name, part: part_0 } = t7;
|
|
1581
|
+
return /* @__PURE__ */ jsx(Chip, {
|
|
1582
|
+
size: "small",
|
|
1583
|
+
label: name,
|
|
1584
|
+
avatar: part_0.type === "image" ? /* @__PURE__ */ jsx(Avatar, {
|
|
1585
|
+
variant: "rounded",
|
|
1586
|
+
src: srcOf(part_0),
|
|
1587
|
+
alt: ""
|
|
1588
|
+
}) : void 0,
|
|
1589
|
+
onDelete: () => setFiles(files.filter((_, at) => at !== index))
|
|
1590
|
+
}, index);
|
|
1591
|
+
})
|
|
1470
1592
|
});
|
|
1471
|
-
$[17] =
|
|
1472
|
-
$[18] =
|
|
1473
|
-
$[19] =
|
|
1474
|
-
} else
|
|
1475
|
-
let
|
|
1593
|
+
$[17] = files;
|
|
1594
|
+
$[18] = setFiles;
|
|
1595
|
+
$[19] = t6;
|
|
1596
|
+
} else t6 = $[19];
|
|
1597
|
+
let t7;
|
|
1476
1598
|
if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1477
|
-
|
|
1478
|
-
$[20] =
|
|
1479
|
-
} else
|
|
1480
|
-
let
|
|
1599
|
+
t7 = { alignItems: "flex-end" };
|
|
1600
|
+
$[20] = t7;
|
|
1601
|
+
} else t7 = $[20];
|
|
1602
|
+
let t8;
|
|
1481
1603
|
if ($[21] !== t) {
|
|
1482
|
-
|
|
1604
|
+
t8 = t("Layout.Chat.NewChat");
|
|
1483
1605
|
$[21] = t;
|
|
1484
|
-
$[22] =
|
|
1485
|
-
} else
|
|
1606
|
+
$[22] = t8;
|
|
1607
|
+
} else t8 = $[22];
|
|
1608
|
+
let t9;
|
|
1609
|
+
if ($[23] !== newChat) {
|
|
1610
|
+
t9 = () => void newChat();
|
|
1611
|
+
$[23] = newChat;
|
|
1612
|
+
$[24] = t9;
|
|
1613
|
+
} else t9 = $[24];
|
|
1614
|
+
const t10 = !chat.messages.length;
|
|
1615
|
+
let t11;
|
|
1616
|
+
if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1617
|
+
t11 = /* @__PURE__ */ jsx(Add, {});
|
|
1618
|
+
$[25] = t11;
|
|
1619
|
+
} else t11 = $[25];
|
|
1486
1620
|
let t12;
|
|
1487
|
-
if ($[
|
|
1488
|
-
t12 =
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1621
|
+
if ($[26] !== t10 || $[27] !== t9) {
|
|
1622
|
+
t12 = /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(IconButton, {
|
|
1623
|
+
"aria-label": "New chat",
|
|
1624
|
+
onClick: t9,
|
|
1625
|
+
disabled: t10,
|
|
1626
|
+
children: t11
|
|
1627
|
+
}) });
|
|
1628
|
+
$[26] = t10;
|
|
1629
|
+
$[27] = t9;
|
|
1630
|
+
$[28] = t12;
|
|
1631
|
+
} else t12 = $[28];
|
|
1492
1632
|
let t13;
|
|
1493
|
-
if ($[
|
|
1494
|
-
t13 =
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1633
|
+
if ($[29] !== t12 || $[30] !== t8) {
|
|
1634
|
+
t13 = /* @__PURE__ */ jsx(Tooltip, {
|
|
1635
|
+
title: t8,
|
|
1636
|
+
children: t12
|
|
1637
|
+
});
|
|
1638
|
+
$[29] = t12;
|
|
1639
|
+
$[30] = t8;
|
|
1640
|
+
$[31] = t13;
|
|
1641
|
+
} else t13 = $[31];
|
|
1498
1642
|
let t14;
|
|
1499
|
-
if ($[
|
|
1500
|
-
t14 =
|
|
1643
|
+
if ($[32] !== t) {
|
|
1644
|
+
t14 = t("Layout.Chat.Attach");
|
|
1645
|
+
$[32] = t;
|
|
1646
|
+
$[33] = t14;
|
|
1647
|
+
} else t14 = $[33];
|
|
1648
|
+
let t15;
|
|
1649
|
+
if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1650
|
+
t15 = /* @__PURE__ */ jsx(AttachFile, {});
|
|
1651
|
+
$[34] = t15;
|
|
1652
|
+
} else t15 = $[34];
|
|
1653
|
+
let t16;
|
|
1654
|
+
if ($[35] !== pick) {
|
|
1655
|
+
t16 = /* @__PURE__ */ jsx(IconButton, {
|
|
1656
|
+
"aria-label": "Attach files",
|
|
1657
|
+
onClick: pick,
|
|
1658
|
+
children: t15
|
|
1659
|
+
});
|
|
1660
|
+
$[35] = pick;
|
|
1661
|
+
$[36] = t16;
|
|
1662
|
+
} else t16 = $[36];
|
|
1663
|
+
let t17;
|
|
1664
|
+
if ($[37] !== t14 || $[38] !== t16) {
|
|
1665
|
+
t17 = /* @__PURE__ */ jsx(Tooltip, {
|
|
1666
|
+
title: t14,
|
|
1667
|
+
children: t16
|
|
1668
|
+
});
|
|
1669
|
+
$[37] = t14;
|
|
1670
|
+
$[38] = t16;
|
|
1671
|
+
$[39] = t17;
|
|
1672
|
+
} else t17 = $[39];
|
|
1673
|
+
let t18;
|
|
1674
|
+
if ($[40] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1675
|
+
t18 = (event_1) => setDraft(event_1.target.value);
|
|
1676
|
+
$[40] = t18;
|
|
1677
|
+
} else t18 = $[40];
|
|
1678
|
+
let t19;
|
|
1679
|
+
if ($[41] !== t) {
|
|
1680
|
+
t19 = t("Layout.Chat.Message");
|
|
1681
|
+
$[41] = t;
|
|
1682
|
+
$[42] = t19;
|
|
1683
|
+
} else t19 = $[42];
|
|
1684
|
+
let t20;
|
|
1685
|
+
let t21;
|
|
1686
|
+
if ($[43] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1687
|
+
t20 = { input: { "aria-label": "Ask anything" } };
|
|
1688
|
+
t21 = {
|
|
1501
1689
|
flex: 1,
|
|
1502
|
-
py: 1
|
|
1690
|
+
py: 1,
|
|
1691
|
+
pl: .5
|
|
1503
1692
|
};
|
|
1504
|
-
$[
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1693
|
+
$[43] = t20;
|
|
1694
|
+
$[44] = t21;
|
|
1695
|
+
} else {
|
|
1696
|
+
t20 = $[43];
|
|
1697
|
+
t21 = $[44];
|
|
1698
|
+
}
|
|
1699
|
+
let t22;
|
|
1700
|
+
if ($[45] !== draft || $[46] !== t19) {
|
|
1701
|
+
t22 = /* @__PURE__ */ jsx(InputBase, {
|
|
1509
1702
|
value: draft,
|
|
1510
|
-
onChange:
|
|
1511
|
-
placeholder:
|
|
1703
|
+
onChange: t18,
|
|
1704
|
+
placeholder: t19,
|
|
1512
1705
|
multiline: true,
|
|
1513
1706
|
maxRows: 8,
|
|
1514
|
-
slotProps:
|
|
1515
|
-
sx:
|
|
1707
|
+
slotProps: t20,
|
|
1708
|
+
sx: t21
|
|
1516
1709
|
});
|
|
1517
|
-
$[
|
|
1518
|
-
$[
|
|
1519
|
-
$[
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
t16 = chat.isLoading ? /* @__PURE__ */ jsx(Tooltip, {
|
|
1710
|
+
$[45] = draft;
|
|
1711
|
+
$[46] = t19;
|
|
1712
|
+
$[47] = t22;
|
|
1713
|
+
} else t22 = $[47];
|
|
1714
|
+
let t23;
|
|
1715
|
+
if ($[48] !== chat.isLoading || $[49] !== chat.stop || $[50] !== t) {
|
|
1716
|
+
t23 = chat.isLoading && /* @__PURE__ */ jsx(Tooltip, {
|
|
1525
1717
|
title: t("Layout.Chat.Stop"),
|
|
1526
1718
|
children: /* @__PURE__ */ jsx(IconButton, {
|
|
1719
|
+
"aria-label": "Stop",
|
|
1527
1720
|
onClick: chat.stop,
|
|
1528
1721
|
sx: roundButtonSx,
|
|
1529
1722
|
children: /* @__PURE__ */ jsx(Stop, {})
|
|
1530
1723
|
})
|
|
1531
|
-
})
|
|
1724
|
+
});
|
|
1725
|
+
$[48] = chat.isLoading;
|
|
1726
|
+
$[49] = chat.stop;
|
|
1727
|
+
$[50] = t;
|
|
1728
|
+
$[51] = t23;
|
|
1729
|
+
} else t23 = $[51];
|
|
1730
|
+
let t24;
|
|
1731
|
+
if ($[52] !== chat.isLoading || $[53] !== ready || $[54] !== t) {
|
|
1732
|
+
t24 = (!chat.isLoading || ready) && /* @__PURE__ */ jsx(Tooltip, {
|
|
1532
1733
|
title: t("Layout.Chat.Send"),
|
|
1533
1734
|
children: /* @__PURE__ */ jsx(IconButton, {
|
|
1735
|
+
"aria-label": "Send",
|
|
1534
1736
|
type: "submit",
|
|
1535
1737
|
sx: roundButtonSx,
|
|
1536
1738
|
children: /* @__PURE__ */ jsx(ArrowUpward, {})
|
|
1537
1739
|
})
|
|
1538
1740
|
});
|
|
1539
|
-
$[
|
|
1540
|
-
$[
|
|
1541
|
-
$[
|
|
1542
|
-
$[
|
|
1543
|
-
} else
|
|
1544
|
-
let
|
|
1545
|
-
if ($[
|
|
1546
|
-
|
|
1741
|
+
$[52] = chat.isLoading;
|
|
1742
|
+
$[53] = ready;
|
|
1743
|
+
$[54] = t;
|
|
1744
|
+
$[55] = t24;
|
|
1745
|
+
} else t24 = $[55];
|
|
1746
|
+
let t25;
|
|
1747
|
+
if ($[56] !== t13 || $[57] !== t17 || $[58] !== t22 || $[59] !== t23 || $[60] !== t24) {
|
|
1748
|
+
t25 = /* @__PURE__ */ jsxs(Stack, {
|
|
1749
|
+
direction: "row",
|
|
1750
|
+
spacing: .5,
|
|
1751
|
+
sx: t7,
|
|
1752
|
+
children: [
|
|
1753
|
+
t13,
|
|
1754
|
+
t17,
|
|
1755
|
+
t22,
|
|
1756
|
+
t23,
|
|
1757
|
+
t24
|
|
1758
|
+
]
|
|
1759
|
+
});
|
|
1760
|
+
$[56] = t13;
|
|
1761
|
+
$[57] = t17;
|
|
1762
|
+
$[58] = t22;
|
|
1763
|
+
$[59] = t23;
|
|
1764
|
+
$[60] = t24;
|
|
1765
|
+
$[61] = t25;
|
|
1766
|
+
} else t25 = $[61];
|
|
1767
|
+
let t26;
|
|
1768
|
+
if ($[62] !== send || $[63] !== t25 || $[64] !== t6) {
|
|
1769
|
+
t26 = /* @__PURE__ */ jsxs(Paper, {
|
|
1547
1770
|
component: "form",
|
|
1548
1771
|
variant: "outlined",
|
|
1549
1772
|
onSubmit: send,
|
|
1550
1773
|
onKeyDown: sendOnEnter,
|
|
1551
|
-
sx:
|
|
1552
|
-
children: [
|
|
1553
|
-
t9,
|
|
1554
|
-
t15,
|
|
1555
|
-
t16
|
|
1556
|
-
]
|
|
1774
|
+
sx: t5,
|
|
1775
|
+
children: [t6, t25]
|
|
1557
1776
|
});
|
|
1558
|
-
$[
|
|
1559
|
-
$[
|
|
1560
|
-
$[
|
|
1561
|
-
$[
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1777
|
+
$[62] = send;
|
|
1778
|
+
$[63] = t25;
|
|
1779
|
+
$[64] = t6;
|
|
1780
|
+
$[65] = t26;
|
|
1781
|
+
} else t26 = $[65];
|
|
1782
|
+
let t27;
|
|
1783
|
+
if ($[66] !== t26 || $[67] !== t4) {
|
|
1784
|
+
t27 = /* @__PURE__ */ jsxs(Stack, {
|
|
1785
|
+
spacing: 1,
|
|
1786
|
+
children: [t4, t26]
|
|
1787
|
+
});
|
|
1788
|
+
$[66] = t26;
|
|
1789
|
+
$[67] = t4;
|
|
1790
|
+
$[68] = t27;
|
|
1791
|
+
} else t27 = $[68];
|
|
1792
|
+
return t27;
|
|
1565
1793
|
}
|
|
1566
|
-
function
|
|
1794
|
+
function _temp5(event_0) {
|
|
1567
1795
|
if (event_0.key !== "Enter" || event_0.shiftKey || event_0.nativeEvent.isComposing) return;
|
|
1568
1796
|
if (!(event_0.target instanceof HTMLTextAreaElement)) return;
|
|
1569
1797
|
event_0.preventDefault();
|
|
1570
1798
|
event_0.currentTarget.requestSubmit();
|
|
1571
1799
|
}
|
|
1800
|
+
function _temp4(t0) {
|
|
1801
|
+
const { part } = t0;
|
|
1802
|
+
return part;
|
|
1803
|
+
}
|
|
1572
1804
|
/** The chat screen. Give it a parent with a height (e.g. `Fullscreen`). */
|
|
1573
1805
|
function ChatLayout({ chat, sx }) {
|
|
1574
1806
|
const { t } = useTranslation();
|
|
1807
|
+
const { alert } = useDialogs();
|
|
1575
1808
|
const { ref, following } = useFollowContent();
|
|
1809
|
+
const [files, setFiles] = useState([]);
|
|
1576
1810
|
const last = chat.messages.at(-1);
|
|
1811
|
+
const attach = async (added) => {
|
|
1812
|
+
for (const file of added) try {
|
|
1813
|
+
const part = await fileToPart(file);
|
|
1814
|
+
setFiles((current) => [...current, {
|
|
1815
|
+
name: file.name,
|
|
1816
|
+
part
|
|
1817
|
+
}]);
|
|
1818
|
+
} catch {
|
|
1819
|
+
await alert(t("Layout.Chat.FileNotRead", { name: file.name }));
|
|
1820
|
+
}
|
|
1821
|
+
};
|
|
1822
|
+
const { getRootProps, getInputProps, isDragActive, open } = useDropzone({
|
|
1823
|
+
noClick: true,
|
|
1824
|
+
noKeyboard: true,
|
|
1825
|
+
onDrop: (dropped) => void attach(dropped)
|
|
1826
|
+
});
|
|
1577
1827
|
const live = chat.isLoading || chat.interrupts.some(({ status }) => status === "pending");
|
|
1828
|
+
const runningTool = live ? last?.parts.findLast((part) => part.type === "tool-call" && part.output === void 0 && part.name !== "show_ui" && part.name !== "ask_user") : void 0;
|
|
1829
|
+
const status = isReasoning(chat) ? t("Layout.Chat.Reasoning") : runningTool ? activityText(t, runningTool, true) : "";
|
|
1578
1830
|
return /* @__PURE__ */ jsxs(Box, {
|
|
1579
|
-
className: "LayoutChat-root",
|
|
1831
|
+
...getRootProps({ className: "LayoutChat-root" }),
|
|
1580
1832
|
sx: [{
|
|
1833
|
+
position: "relative",
|
|
1581
1834
|
display: "flex",
|
|
1582
1835
|
flexDirection: "column",
|
|
1583
1836
|
flex: 1,
|
|
1584
1837
|
minHeight: 0,
|
|
1585
1838
|
height: "100%"
|
|
1586
1839
|
}, ...Array.isArray(sx) ? sx : [sx]],
|
|
1587
|
-
children: [
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1840
|
+
children: [
|
|
1841
|
+
/* @__PURE__ */ jsx("input", { ...getInputProps() }),
|
|
1842
|
+
/* @__PURE__ */ jsx(Box, {
|
|
1843
|
+
ref,
|
|
1844
|
+
sx: {
|
|
1845
|
+
flex: 1,
|
|
1846
|
+
minHeight: 0,
|
|
1847
|
+
overflowY: "auto"
|
|
1848
|
+
},
|
|
1849
|
+
children: /* @__PURE__ */ jsxs(Stack, {
|
|
1850
|
+
spacing: 2.5,
|
|
1851
|
+
sx: {
|
|
1852
|
+
...columnSx,
|
|
1853
|
+
py: 3,
|
|
1854
|
+
[`& > .${statusClass} + .${statusClass}`]: { mt: .5 }
|
|
1855
|
+
},
|
|
1856
|
+
children: [
|
|
1857
|
+
chat.messages.map((message) => /* @__PURE__ */ jsx(ChatMessage, {
|
|
1858
|
+
message,
|
|
1859
|
+
live: live && message === last,
|
|
1860
|
+
canAnswer: !chat.isLoading && message === last,
|
|
1861
|
+
addToolResult: chat.addToolResult
|
|
1862
|
+
}, message.id)),
|
|
1863
|
+
/* @__PURE__ */ jsx(Approvals, { chat }),
|
|
1864
|
+
isReasoning(chat) && /* @__PURE__ */ jsx(Reasoning, {}),
|
|
1865
|
+
chat.error && /* @__PURE__ */ jsx(Alert, {
|
|
1866
|
+
severity: "error",
|
|
1867
|
+
action: /* @__PURE__ */ jsx(Tooltip, {
|
|
1868
|
+
title: t("Layout.Chat.Regenerate"),
|
|
1869
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
1870
|
+
"aria-label": "Regenerate",
|
|
1871
|
+
color: "inherit",
|
|
1872
|
+
size: "small",
|
|
1873
|
+
onClick: () => void chat.reload(),
|
|
1874
|
+
children: /* @__PURE__ */ jsx(Refresh, { fontSize: "small" })
|
|
1875
|
+
})
|
|
1876
|
+
}),
|
|
1877
|
+
children: chat.error.message
|
|
1878
|
+
})
|
|
1879
|
+
]
|
|
1880
|
+
})
|
|
1881
|
+
}),
|
|
1882
|
+
/* @__PURE__ */ jsx(Box, {
|
|
1596
1883
|
sx: {
|
|
1597
1884
|
...columnSx,
|
|
1598
|
-
|
|
1599
|
-
[`& > .${statusClass} + .${statusClass}`]: { mt: .5 }
|
|
1885
|
+
pb: 2
|
|
1600
1886
|
},
|
|
1601
|
-
children:
|
|
1602
|
-
chat
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
},
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1887
|
+
children: /* @__PURE__ */ jsx(ChatInput, {
|
|
1888
|
+
chat,
|
|
1889
|
+
files,
|
|
1890
|
+
setFiles,
|
|
1891
|
+
pick: open,
|
|
1892
|
+
onSend: () => following.current = true
|
|
1893
|
+
})
|
|
1894
|
+
}),
|
|
1895
|
+
isDragActive && /* @__PURE__ */ jsx(Box, {
|
|
1896
|
+
sx: {
|
|
1897
|
+
position: "absolute",
|
|
1898
|
+
inset: 8,
|
|
1899
|
+
zIndex: 2,
|
|
1900
|
+
display: "flex",
|
|
1901
|
+
alignItems: "center",
|
|
1902
|
+
justifyContent: "center",
|
|
1903
|
+
border: 2,
|
|
1904
|
+
borderStyle: "dashed",
|
|
1905
|
+
borderColor: "primary.main",
|
|
1906
|
+
borderRadius: 4,
|
|
1907
|
+
bgcolor: "background.paper",
|
|
1908
|
+
opacity: .92,
|
|
1909
|
+
pointerEvents: "none"
|
|
1910
|
+
},
|
|
1911
|
+
children: /* @__PURE__ */ jsx(Typography, {
|
|
1912
|
+
color: "primary",
|
|
1913
|
+
children: t("Layout.Chat.DropFiles")
|
|
1914
|
+
})
|
|
1915
|
+
}),
|
|
1916
|
+
/* @__PURE__ */ jsx(Box, {
|
|
1917
|
+
role: "status",
|
|
1918
|
+
sx: visuallyHidden,
|
|
1919
|
+
children: status
|
|
1633
1920
|
})
|
|
1634
|
-
|
|
1921
|
+
]
|
|
1635
1922
|
});
|
|
1636
1923
|
}
|
|
1637
1924
|
export { tableContext as C, RouterLink as D, useTableContext as E, useDialogs as O, layoutTableFeatures as S, useHeaderContext as T, toClipboardText as _, cellSelectionSx as a, cellContext as b, columnFlex as c, layoutTableClasses as d, lookaheadRange as f, shortcutLabel as g, pinnedSx as h, formatValue as i, columnLabel as l, pinnedClass as m, createUiTools as n, classNames as o, moveColumn as p, AggregatedCell as r, columnAlign as s, ChatLayout as t, hasColumnLabel as u, DEFAULT_PAGE_SIZE_OPTIONS as v, useCellContext as w, headerContext as x, Pagination as y };
|
|
1638
1925
|
|
|
1639
|
-
//# sourceMappingURL=ChatLayout-
|
|
1926
|
+
//# sourceMappingURL=ChatLayout-CkS9oyPp.mjs.map
|