@dudko.dev/agent-web-react 0.0.36 → 0.0.38
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/README.md +13 -7
- package/dist/{elicitation-xMLll5W9.d.cts → elicitation-BgSf-xzh.d.cts} +25 -1
- package/dist/{elicitation-xMLll5W9.d.ts → elicitation-BgSf-xzh.d.ts} +25 -1
- package/dist/index.cjs +251 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +130 -6
- package/dist/index.d.ts +130 -6
- package/dist/index.js +246 -36
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.cts +2 -2
- package/dist/mcp.d.ts +2 -2
- package/dist/styles.css +30 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -509,6 +509,13 @@ var mediaOf = (event, withStep) => ({
|
|
|
509
509
|
mediaType: event.mediaType,
|
|
510
510
|
bytes: event.bytes,
|
|
511
511
|
model: event.model,
|
|
512
|
+
...event.references ? {
|
|
513
|
+
references: {
|
|
514
|
+
used: event.references.used === true,
|
|
515
|
+
count: event.references.count,
|
|
516
|
+
paths: [...event.references.paths]
|
|
517
|
+
}
|
|
518
|
+
} : {},
|
|
512
519
|
...withStep && event.step ? { stepId: event.step.id } : {}
|
|
513
520
|
});
|
|
514
521
|
var addApp = (state, event, by) => {
|
|
@@ -1238,7 +1245,7 @@ var applyEvent = (state, event, ctx) => {
|
|
|
1238
1245
|
...ctx.goal ? {
|
|
1239
1246
|
queued: [
|
|
1240
1247
|
...state.queued.filter((q) => q.id !== WAITING_ID),
|
|
1241
|
-
{ id: WAITING_ID, text: ctx.goal }
|
|
1248
|
+
{ id: WAITING_ID, text: ctx.goal, session: event.heldBy }
|
|
1242
1249
|
]
|
|
1243
1250
|
} : {}
|
|
1244
1251
|
};
|
|
@@ -1266,11 +1273,11 @@ var applyEvent = (state, event, ctx) => {
|
|
|
1266
1273
|
(q) => q.status === "pending" ? { ...q, status: "stopped", automatic: true, reason: "stopped" } : q
|
|
1267
1274
|
)
|
|
1268
1275
|
} : {},
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
state
|
|
1272
|
-
|
|
1273
|
-
)
|
|
1276
|
+
// What it had written, or nothing - the chat says "stopped" through its labels.
|
|
1277
|
+
messages: finalizeAssistant(state.messages, state.finalText, {
|
|
1278
|
+
...runDuration(state, ctx.at),
|
|
1279
|
+
stopped: true
|
|
1280
|
+
})
|
|
1274
1281
|
};
|
|
1275
1282
|
case "error":
|
|
1276
1283
|
if (event.phase === "replan") {
|
|
@@ -1856,21 +1863,43 @@ var ChatHistoryStore = class {
|
|
|
1856
1863
|
if (opts.memory || typeof indexedDB === "undefined") this.memory = /* @__PURE__ */ new Map();
|
|
1857
1864
|
this.dbName = this.memory ? void 0 : this.name;
|
|
1858
1865
|
}
|
|
1866
|
+
/**
|
|
1867
|
+
* The store's connection, opened on first use. Never in another tab's way: when another
|
|
1868
|
+
* connection asks to delete or upgrade the database (`versionchange` - another tab's
|
|
1869
|
+
* `indexedDB.deleteDatabase`, a newer copy of this package), it is closed at once, so that
|
|
1870
|
+
* request goes ahead instead of waiting for this tab to close; one the browser closed by itself
|
|
1871
|
+
* (site data cleared) is let go too. The next use opens the database again - after a deletion a
|
|
1872
|
+
* new, empty one (no chats: `list()` is empty, a save starts it again); after an upgrade by a
|
|
1873
|
+
* newer copy, the open fails until the page is reloaded with that copy.
|
|
1874
|
+
*/
|
|
1859
1875
|
open() {
|
|
1860
|
-
this.db
|
|
1876
|
+
if (this.db) return this.db;
|
|
1877
|
+
const opening = new Promise((resolve, reject) => {
|
|
1861
1878
|
const r = indexedDB.open(this.name, DB_VERSION);
|
|
1862
1879
|
r.onupgradeneeded = () => {
|
|
1863
1880
|
if (!r.result.objectStoreNames.contains(this.storeName)) {
|
|
1864
1881
|
r.result.createObjectStore(this.storeName, { keyPath: "id" });
|
|
1865
1882
|
}
|
|
1866
1883
|
};
|
|
1867
|
-
r.onsuccess = () =>
|
|
1884
|
+
r.onsuccess = () => {
|
|
1885
|
+
const db = r.result;
|
|
1886
|
+
const forget = () => {
|
|
1887
|
+
if (this.db === opening) this.db = void 0;
|
|
1888
|
+
};
|
|
1889
|
+
db.addEventListener("versionchange", () => {
|
|
1890
|
+
forget();
|
|
1891
|
+
db.close();
|
|
1892
|
+
});
|
|
1893
|
+
db.addEventListener("close", forget);
|
|
1894
|
+
resolve(db);
|
|
1895
|
+
};
|
|
1868
1896
|
r.onerror = () => reject(r.error);
|
|
1869
1897
|
}).catch((err) => {
|
|
1870
|
-
this.db = void 0;
|
|
1898
|
+
if (this.db === opening) this.db = void 0;
|
|
1871
1899
|
throw err;
|
|
1872
1900
|
});
|
|
1873
|
-
|
|
1901
|
+
this.db = opening;
|
|
1902
|
+
return opening;
|
|
1874
1903
|
}
|
|
1875
1904
|
async tx(mode) {
|
|
1876
1905
|
const db = await this.open();
|
|
@@ -2491,7 +2520,8 @@ var attachmentKindOf = (mediaType, name) => {
|
|
|
2491
2520
|
};
|
|
2492
2521
|
var withAttachments = (text, files) => {
|
|
2493
2522
|
const texts = files.filter((f) => f.kind === "text" && f.text !== void 0);
|
|
2494
|
-
|
|
2523
|
+
const saved = files.filter((f) => f.kind !== "text" && f.path);
|
|
2524
|
+
if (texts.length === 0 && saved.length === 0) return text;
|
|
2495
2525
|
const blocks = texts.map((f) => {
|
|
2496
2526
|
const body = f.text;
|
|
2497
2527
|
const fence = body.includes("```") ? "~~~" : "```";
|
|
@@ -2501,10 +2531,46 @@ ${fence}
|
|
|
2501
2531
|
${body}
|
|
2502
2532
|
${fence}`;
|
|
2503
2533
|
});
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2534
|
+
const kind = (f) => f.kind === "image" ? "picture" : f.kind === "pdf" ? "PDF" : "file";
|
|
2535
|
+
const lines = saved.map(
|
|
2536
|
+
(f) => `- ${kind(f)} "${f.name.replace(/["\s]+/g, " ").trim()}" (also saved as ${f.path})`
|
|
2537
|
+
);
|
|
2538
|
+
return [
|
|
2539
|
+
text,
|
|
2540
|
+
...blocks.length ? [`Attached file(s):
|
|
2541
|
+
${blocks.join("\n\n")}`] : [],
|
|
2542
|
+
...lines.length ? [`Also attached:
|
|
2543
|
+
${lines.join("\n")}`] : []
|
|
2544
|
+
].join("\n\n");
|
|
2545
|
+
};
|
|
2546
|
+
var ATTACHMENT_BOUNDS = {
|
|
2547
|
+
maxBytes: 20 * 1024 * 1024,
|
|
2548
|
+
// The largest JPEGs a phone writes (a 200 MP shot: ~20-40 MB) pass, and a long PDF with its
|
|
2549
|
+
// pictures; past this it is read into memory for nothing the model would get.
|
|
2550
|
+
maxSourceBytes: 50 * 1024 * 1024,
|
|
2551
|
+
// The largest phone sensor (200 MP: 16320 × 12240) passes, ~800 MB decoded; past this is a
|
|
2552
|
+
// scan, a render or a decompression bomb (a PNG of a few KB can declare 30000 × 30000 px).
|
|
2553
|
+
imageMaxSourcePixels: 2e8,
|
|
2554
|
+
// Under what the providers take in one request (Anthropic: 100 pictures, 32 MB; OpenAI: 50 MB).
|
|
2555
|
+
maxImages: 20,
|
|
2556
|
+
maxTotalBytes: 20 * 1024 * 1024
|
|
2557
|
+
};
|
|
2558
|
+
var attachmentTransformOf = (input) => input.converts ? "convert" : input.kind === "image" && input.imageMaxDimension !== false && input.mediaType !== "image/gif" && input.mediaType !== "image/svg+xml" ? "downscale" : "none";
|
|
2559
|
+
var attachmentOverLimit = (file, stage, transform, bounds) => {
|
|
2560
|
+
if (stage === "original" && transform !== "none") {
|
|
2561
|
+
const sourceBytes = Math.max(bounds.maxSourceBytes, bounds.maxBytes);
|
|
2562
|
+
if (file.bytes > sourceBytes) return { bound: "bytes", limit: sourceBytes };
|
|
2563
|
+
if (transform === "downscale" && file.pixels !== void 0 && file.pixels > bounds.imageMaxSourcePixels)
|
|
2564
|
+
return { bound: "pixels", limit: bounds.imageMaxSourcePixels };
|
|
2565
|
+
return void 0;
|
|
2566
|
+
}
|
|
2567
|
+
return file.bytes > bounds.maxBytes ? { bound: "bytes", limit: bounds.maxBytes } : void 0;
|
|
2568
|
+
};
|
|
2569
|
+
var messageOverLimit = (inMessage, next, bounds) => {
|
|
2570
|
+
if (next.kind === "image" && inMessage.filter((a) => a.kind === "image").length >= bounds.maxImages)
|
|
2571
|
+
return "images";
|
|
2572
|
+
const total = inMessage.reduce((n, a) => n + a.bytes, 0);
|
|
2573
|
+
return total + next.bytes > bounds.maxTotalBytes ? "bytes" : void 0;
|
|
2508
2574
|
};
|
|
2509
2575
|
var attachmentRefusal = (kind, caps, canConvertPdf = false) => {
|
|
2510
2576
|
if (kind === "text" || !caps) return void 0;
|
|
@@ -2614,6 +2680,7 @@ var defaultLabels = {
|
|
|
2614
2680
|
fetches: (n) => plural(n, "web request", "web requests"),
|
|
2615
2681
|
fetchRefused: (reason) => `refused: ${reason}`,
|
|
2616
2682
|
answerThoughts: "Thinking about the answer",
|
|
2683
|
+
answerStopped: "Stopped.",
|
|
2617
2684
|
stepThoughts: "Thoughts",
|
|
2618
2685
|
usageTitle: "Tokens this answer spent, by kind",
|
|
2619
2686
|
attachments: "Attachments",
|
|
@@ -2663,7 +2730,12 @@ var defaultLabels = {
|
|
|
2663
2730
|
attachmentsOnly: "(attachments)",
|
|
2664
2731
|
seeAttachments: "See the attachments.",
|
|
2665
2732
|
tooLarge: (name, mb) => `${name} is larger than ${mb} MB.`,
|
|
2733
|
+
tooManyPixels: (name, megapixels) => `${name} has more than ${megapixels} megapixels \u2014 too large a picture to attach.`,
|
|
2666
2734
|
binaryText: (name) => `${name} looks binary \u2014 it can't be attached as text.`,
|
|
2735
|
+
downscaledFrom: (size) => `downscaled from ${size}`,
|
|
2736
|
+
convertedFrom: (name) => `converted from ${name}`,
|
|
2737
|
+
tooManyImages: (names, max) => `${names}: not added \u2014 at most ${max} pictures go in one message.`,
|
|
2738
|
+
messageTooLarge: (names, mb) => `${names}: not added \u2014 the message would be over ${mb} MB.`,
|
|
2667
2739
|
commandGroups: { commands: "Commands", consent: "Consent", skills: "Skills" },
|
|
2668
2740
|
commandDescriptions: {
|
|
2669
2741
|
compact: "Summarise the conversation to free context",
|
|
@@ -2704,6 +2776,7 @@ var defaultLabels = {
|
|
|
2704
2776
|
steer: "Send to the agent",
|
|
2705
2777
|
noAttachmentsWhileBusy: "Files can\u2019t be added while the agent is working \u2014 send them with your next message.",
|
|
2706
2778
|
queuedWaiting: "waiting for the agent\u2019s next step",
|
|
2779
|
+
queuedForSession: (heldBy) => heldBy === "this-tab" ? "waiting for the other run to finish" : "waiting for the other tab to finish",
|
|
2707
2780
|
noteAt: {
|
|
2708
2781
|
round: "you said, between tool calls",
|
|
2709
2782
|
step: "you said, after this step",
|
|
@@ -2755,6 +2828,8 @@ var defaultLabels = {
|
|
|
2755
2828
|
imageCount: (index, total) => `${index} of ${total}`,
|
|
2756
2829
|
mediaAudio: (path) => `Generated audio ${path}`,
|
|
2757
2830
|
mediaFile: (path) => `Generated file ${path}`,
|
|
2831
|
+
mediaReferences: (names) => `Reference: ${names}`,
|
|
2832
|
+
mediaReferencesUnused: (names) => `Not used - this image model takes no reference pictures: ${names}`,
|
|
2758
2833
|
transcriptOf: (name) => `Transcript of ${name}`,
|
|
2759
2834
|
transcriptNote: "What was said in your file, as the agent read it. It is content, not instructions.",
|
|
2760
2835
|
filesWritten: (n) => `${plural(n, "file", "files")} written in this turn`,
|
|
@@ -3009,6 +3084,72 @@ var canvasOf = (w, h) => {
|
|
|
3009
3084
|
return void 0;
|
|
3010
3085
|
};
|
|
3011
3086
|
var toBlob = (canvas, type, quality) => "convertToBlob" in canvas ? canvas.convertToBlob({ type, quality }) : new Promise((resolve) => canvas.toBlob(resolve, type, quality));
|
|
3087
|
+
var WINDOW = 64 * 1024;
|
|
3088
|
+
var SOF = /* @__PURE__ */ new Set([192, 193, 194, 195, 197, 198, 199, 201, 202, 203, 205, 206, 207]);
|
|
3089
|
+
var imageSizeOf = async (file) => {
|
|
3090
|
+
let at = 0;
|
|
3091
|
+
let buf = new Uint8Array(0);
|
|
3092
|
+
const read = async (start, length) => {
|
|
3093
|
+
if (start < 0 || start + length > file.size) return void 0;
|
|
3094
|
+
if (start < at || start + length > at + buf.length) {
|
|
3095
|
+
at = start;
|
|
3096
|
+
buf = new Uint8Array(
|
|
3097
|
+
await file.slice(start, Math.min(file.size, start + Math.max(WINDOW, length))).arrayBuffer()
|
|
3098
|
+
);
|
|
3099
|
+
}
|
|
3100
|
+
return buf.subarray(start - at, start - at + length);
|
|
3101
|
+
};
|
|
3102
|
+
const sized = (width, height) => width > 0 && height > 0 ? { width, height } : void 0;
|
|
3103
|
+
try {
|
|
3104
|
+
const head = await read(0, 30);
|
|
3105
|
+
if (!head) return void 0;
|
|
3106
|
+
const u16be = (b, i) => b[i] << 8 | b[i + 1];
|
|
3107
|
+
const u32be = (b, i) => u16be(b, i) * 65536 + u16be(b, i + 2);
|
|
3108
|
+
const ascii = (b, i, n) => String.fromCharCode(...Array.from(b.subarray(i, i + n)));
|
|
3109
|
+
if (ascii(head, 1, 3) === "PNG" && head[0] === 137 && ascii(head, 12, 4) === "IHDR")
|
|
3110
|
+
return sized(u32be(head, 16), u32be(head, 20));
|
|
3111
|
+
if (ascii(head, 0, 4) === "RIFF" && ascii(head, 8, 4) === "WEBP") {
|
|
3112
|
+
const chunk = ascii(head, 12, 4);
|
|
3113
|
+
const u16le = (i) => head[i] | head[i + 1] << 8;
|
|
3114
|
+
const u24le = (i) => u16le(i) | head[i + 2] << 16;
|
|
3115
|
+
if (chunk === "VP8X") return sized(u24le(24) + 1, u24le(27) + 1);
|
|
3116
|
+
if (chunk === "VP8L" && head[20] === 47) {
|
|
3117
|
+
const bits = (u16le(21) | u16le(23) << 16) >>> 0;
|
|
3118
|
+
return sized((bits & 16383) + 1, (bits >>> 14 & 16383) + 1);
|
|
3119
|
+
}
|
|
3120
|
+
if (chunk === "VP8 " && head[23] === 157 && head[24] === 1 && head[25] === 42)
|
|
3121
|
+
return sized(u16le(26) & 16383, u16le(28) & 16383);
|
|
3122
|
+
return void 0;
|
|
3123
|
+
}
|
|
3124
|
+
if (head[0] === 255 && head[1] === 216) {
|
|
3125
|
+
let p = 2;
|
|
3126
|
+
for (let segments = 0; segments < 4096; segments++) {
|
|
3127
|
+
const m = await read(p, 4);
|
|
3128
|
+
if (!m || m[0] !== 255) return void 0;
|
|
3129
|
+
const marker = m[1];
|
|
3130
|
+
if (marker === 255) {
|
|
3131
|
+
p += 1;
|
|
3132
|
+
continue;
|
|
3133
|
+
}
|
|
3134
|
+
if (marker === 1 || marker >= 208 && marker <= 216) {
|
|
3135
|
+
p += 2;
|
|
3136
|
+
continue;
|
|
3137
|
+
}
|
|
3138
|
+
if (marker === 217 || marker === 218) return void 0;
|
|
3139
|
+
const length = u16be(m, 2);
|
|
3140
|
+
if (length < 2) return void 0;
|
|
3141
|
+
if (SOF.has(marker)) {
|
|
3142
|
+
const frame = await read(p + 4, 5);
|
|
3143
|
+
return frame ? sized(u16be(frame, 3), u16be(frame, 1)) : void 0;
|
|
3144
|
+
}
|
|
3145
|
+
p += 2 + length;
|
|
3146
|
+
}
|
|
3147
|
+
}
|
|
3148
|
+
return void 0;
|
|
3149
|
+
} catch {
|
|
3150
|
+
return void 0;
|
|
3151
|
+
}
|
|
3152
|
+
};
|
|
3012
3153
|
var downscaleImage = async (file, opts = {}) => {
|
|
3013
3154
|
const maxDimension = opts.maxDimension ?? 1568;
|
|
3014
3155
|
const maxPixels = opts.maxPixels ?? 115e4;
|
|
@@ -5093,7 +5234,12 @@ var AgentComposer = ({
|
|
|
5093
5234
|
const MODE_CHIP = L.modes;
|
|
5094
5235
|
const DEFAULT_THINKING = thinkingDefaults(L);
|
|
5095
5236
|
const [text, setText] = useState9("");
|
|
5096
|
-
const [pending,
|
|
5237
|
+
const [pending, setPendingState] = useState9([]);
|
|
5238
|
+
const pendingRef = useRef8([]);
|
|
5239
|
+
const setPending = (next) => {
|
|
5240
|
+
pendingRef.current = typeof next === "function" ? next(pendingRef.current) : next;
|
|
5241
|
+
setPendingState(pendingRef.current);
|
|
5242
|
+
};
|
|
5097
5243
|
const [menu, setMenu] = useState9(void 0);
|
|
5098
5244
|
const [active, setActive] = useState9(0);
|
|
5099
5245
|
const [dismissed, setDismissed] = useState9(() => /* @__PURE__ */ new Set());
|
|
@@ -5258,17 +5404,44 @@ ${draftText}` : draftText);
|
|
|
5258
5404
|
void cmd.run?.(args);
|
|
5259
5405
|
};
|
|
5260
5406
|
const attachCfg = typeof attachments === "object" ? attachments : {};
|
|
5261
|
-
const
|
|
5407
|
+
const bounds = {
|
|
5408
|
+
maxBytes: attachCfg.maxBytes ?? ATTACHMENT_BOUNDS.maxBytes,
|
|
5409
|
+
maxSourceBytes: attachCfg.maxSourceBytes ?? ATTACHMENT_BOUNDS.maxSourceBytes,
|
|
5410
|
+
imageMaxSourcePixels: attachCfg.imageMaxSourcePixels ?? ATTACHMENT_BOUNDS.imageMaxSourcePixels,
|
|
5411
|
+
maxImages: attachCfg.maxImages ?? ATTACHMENT_BOUNDS.maxImages,
|
|
5412
|
+
maxTotalBytes: attachCfg.maxTotalBytes ?? ATTACHMENT_BOUNDS.maxTotalBytes
|
|
5413
|
+
};
|
|
5262
5414
|
const imageMax = attachCfg.imageMaxDimension ?? 1568;
|
|
5415
|
+
const overLimitText = (name, over) => over.bound === "pixels" ? L.tooManyPixels(name, Math.round(over.limit / 1e6)) : L.tooLarge(name, Math.round(over.limit / 1024 / 1024));
|
|
5263
5416
|
const addFiles = async (list) => {
|
|
5264
|
-
const added = [];
|
|
5265
5417
|
let problem;
|
|
5418
|
+
const noRoom = { images: [], bytes: [] };
|
|
5419
|
+
const add = (name, a) => {
|
|
5420
|
+
const full = messageOverLimit(pendingRef.current, a, bounds);
|
|
5421
|
+
if (full) noRoom[full].push(name);
|
|
5422
|
+
else setPending((cur) => [...cur, a]);
|
|
5423
|
+
};
|
|
5266
5424
|
for (const f of list) {
|
|
5267
5425
|
const mediaType = f.type || "application/octet-stream";
|
|
5268
5426
|
const name = f.name || `pasted-${Date.now()}.${mediaType.split("/")[1] ?? "bin"}`;
|
|
5269
5427
|
const kind = attachmentKindOf(mediaType, name);
|
|
5270
|
-
|
|
5271
|
-
|
|
5428
|
+
const refusal = attachmentRefusal(kind, caps);
|
|
5429
|
+
const converts = Boolean(convertFile && (refusal || kind === "pdf" && convert === "always"));
|
|
5430
|
+
const transform = attachmentTransformOf({
|
|
5431
|
+
kind,
|
|
5432
|
+
mediaType,
|
|
5433
|
+
imageMaxDimension: imageMax,
|
|
5434
|
+
converts
|
|
5435
|
+
});
|
|
5436
|
+
const size = transform === "downscale" ? await imageSizeOf(f) : void 0;
|
|
5437
|
+
const pixels = size && size.width * size.height;
|
|
5438
|
+
const over = attachmentOverLimit({ bytes: f.size, pixels }, "original", transform, bounds);
|
|
5439
|
+
if (over) {
|
|
5440
|
+
problem = overLimitText(name, over);
|
|
5441
|
+
continue;
|
|
5442
|
+
}
|
|
5443
|
+
if (kind === "image" && transform !== "convert" && messageOverLimit(pendingRef.current, { kind, bytes: 0 }, bounds) === "images") {
|
|
5444
|
+
noRoom.images.push(name);
|
|
5272
5445
|
continue;
|
|
5273
5446
|
}
|
|
5274
5447
|
try {
|
|
@@ -5279,22 +5452,26 @@ ${draftText}` : draftText);
|
|
|
5279
5452
|
problem = L.binaryText(name);
|
|
5280
5453
|
continue;
|
|
5281
5454
|
}
|
|
5282
|
-
|
|
5455
|
+
add(name, { id, name, kind, mediaType, text: content, bytes: f.size });
|
|
5283
5456
|
continue;
|
|
5284
5457
|
}
|
|
5285
|
-
|
|
5286
|
-
const wantConvert = convertFile && (refusal || kind === "pdf" && convert === "always");
|
|
5287
|
-
if (wantConvert && convertFile) {
|
|
5458
|
+
if (converts && convertFile) {
|
|
5288
5459
|
const converted = await convertFile(f);
|
|
5289
5460
|
if (converted) {
|
|
5290
|
-
|
|
5461
|
+
const bytes = new Blob([converted.text]).size;
|
|
5462
|
+
const sentOver2 = attachmentOverLimit({ bytes }, "sent", transform, bounds);
|
|
5463
|
+
if (sentOver2) {
|
|
5464
|
+
problem = overLimitText(name, sentOver2);
|
|
5465
|
+
continue;
|
|
5466
|
+
}
|
|
5467
|
+
add(name, {
|
|
5291
5468
|
id,
|
|
5292
5469
|
name: converted.name ?? `${name}.md`,
|
|
5293
5470
|
kind: "text",
|
|
5294
5471
|
mediaType: "text/markdown",
|
|
5295
5472
|
text: converted.text,
|
|
5296
|
-
bytes
|
|
5297
|
-
note:
|
|
5473
|
+
bytes,
|
|
5474
|
+
note: L.convertedFrom(name)
|
|
5298
5475
|
});
|
|
5299
5476
|
continue;
|
|
5300
5477
|
}
|
|
@@ -5303,25 +5480,35 @@ ${draftText}` : draftText);
|
|
|
5303
5480
|
problem = refusal;
|
|
5304
5481
|
continue;
|
|
5305
5482
|
}
|
|
5306
|
-
const blob =
|
|
5483
|
+
const blob = transform === "downscale" ? await downscaleImage(f, {
|
|
5307
5484
|
maxDimension: imageMax,
|
|
5308
5485
|
maxPixels: attachCfg.imageMaxPixels
|
|
5309
5486
|
}) : f;
|
|
5310
|
-
|
|
5487
|
+
const sentOver = attachmentOverLimit({ bytes: blob.size }, "sent", transform, bounds);
|
|
5488
|
+
if (sentOver) {
|
|
5489
|
+
problem = overLimitText(name, sentOver);
|
|
5490
|
+
continue;
|
|
5491
|
+
}
|
|
5492
|
+
add(name, {
|
|
5311
5493
|
id,
|
|
5312
5494
|
name,
|
|
5313
5495
|
kind,
|
|
5314
5496
|
mediaType: blob.type || mediaType,
|
|
5315
5497
|
dataUrl: await readDataUrl2(blob),
|
|
5316
5498
|
bytes: blob.size,
|
|
5317
|
-
...blob !== f ? { note:
|
|
5499
|
+
...blob !== f ? { note: L.downscaledFrom(L.bytes(f.size)) } : {}
|
|
5318
5500
|
});
|
|
5319
5501
|
} catch (err) {
|
|
5320
5502
|
problem = `${name}: ${err instanceof Error ? err.message : String(err)}`;
|
|
5321
5503
|
}
|
|
5322
5504
|
}
|
|
5323
|
-
|
|
5324
|
-
|
|
5505
|
+
const names = (list2) => list2.length > 3 ? `${list2.slice(0, 3).join(", ")}, \u2026` : list2.join(", ");
|
|
5506
|
+
const said = [
|
|
5507
|
+
problem,
|
|
5508
|
+
noRoom.images.length ? L.tooManyImages(names(noRoom.images), bounds.maxImages) : "",
|
|
5509
|
+
noRoom.bytes.length ? L.messageTooLarge(names(noRoom.bytes), Math.round(bounds.maxTotalBytes / 1024 / 1024)) : ""
|
|
5510
|
+
];
|
|
5511
|
+
setAttachError(said.filter(Boolean).join(" ") || void 0);
|
|
5325
5512
|
if (fileRef.current) fileRef.current.value = "";
|
|
5326
5513
|
};
|
|
5327
5514
|
const onPaste = (e) => {
|
|
@@ -5515,7 +5702,7 @@ ${draftText}` : draftText);
|
|
|
5515
5702
|
/* @__PURE__ */ jsx5(ClockIcon, { size: 13, className: "awr-queued__icon" }),
|
|
5516
5703
|
/* @__PURE__ */ jsx5("span", { className: "awr-queued__text", title: q.text, children: q.text }),
|
|
5517
5704
|
q.origin === "another-tab" && /* @__PURE__ */ jsx5("span", { className: "awr-queued__origin", children: L.fromAnotherTab }),
|
|
5518
|
-
/* @__PURE__ */ jsx5("span", { className: "awr-queued__state", children: L.queuedWaiting })
|
|
5705
|
+
/* @__PURE__ */ jsx5("span", { className: "awr-queued__state", children: q.session ? L.queuedForSession(q.session) : L.queuedWaiting })
|
|
5519
5706
|
] }, q.id)),
|
|
5520
5707
|
agent.undelivered.length > 0 && /* @__PURE__ */ jsxs3("div", { className: "awr-queued__item awr-queued__item--undelivered", role: "status", children: [
|
|
5521
5708
|
/* @__PURE__ */ jsx5(AlertIcon, { size: 13, className: "awr-queued__icon" }),
|
|
@@ -5590,7 +5777,10 @@ ${draftText}` : draftText);
|
|
|
5590
5777
|
if (renderAttachment) return /* @__PURE__ */ jsx5("span", { children: renderAttachment(a, remove) }, a.id);
|
|
5591
5778
|
return /* @__PURE__ */ jsxs3("span", { className: "awr-chip awr-file", title: a.note ?? a.mediaType, children: [
|
|
5592
5779
|
a.kind === "image" && a.dataUrl ? /* @__PURE__ */ jsx5("img", { className: "awr-file__thumb", src: a.dataUrl, alt: a.name }) : /* @__PURE__ */ jsx5(FileIcon, { size: 14 }),
|
|
5593
|
-
/* @__PURE__ */
|
|
5780
|
+
a.note ? /* @__PURE__ */ jsxs3("span", { className: "awr-file__text", children: [
|
|
5781
|
+
/* @__PURE__ */ jsx5("span", { className: "awr-file__name", children: a.name }),
|
|
5782
|
+
/* @__PURE__ */ jsx5("span", { className: "awr-file__note", children: a.note })
|
|
5783
|
+
] }) : /* @__PURE__ */ jsx5("span", { className: "awr-file__name", children: a.name }),
|
|
5594
5784
|
/* @__PURE__ */ jsx5(
|
|
5595
5785
|
"button",
|
|
5596
5786
|
{
|
|
@@ -6800,13 +6990,14 @@ var useFileUrl = (files, path, mediaType) => {
|
|
|
6800
6990
|
}, [files, path, mediaType]);
|
|
6801
6991
|
return url;
|
|
6802
6992
|
};
|
|
6993
|
+
var baseName = (path) => path.split(/[\\/]/).filter(Boolean).pop() ?? path;
|
|
6803
6994
|
var GeneratedMedia = ({ media, files, labels }) => {
|
|
6804
6995
|
const L = useLabels(labels);
|
|
6805
6996
|
const family = mediaFamilyOf(media.mediaType);
|
|
6806
6997
|
const type = family ? media.mediaType.toLowerCase().split(";")[0].trim() : void 0;
|
|
6807
6998
|
const url = useFileUrl(files, media.path, type);
|
|
6808
6999
|
if (url && family === "image") {
|
|
6809
|
-
|
|
7000
|
+
const thumb = /* @__PURE__ */ jsx11(
|
|
6810
7001
|
ImageThumb,
|
|
6811
7002
|
{
|
|
6812
7003
|
className: "awr-media awr-media--image",
|
|
@@ -6818,6 +7009,20 @@ var GeneratedMedia = ({ media, files, labels }) => {
|
|
|
6818
7009
|
labels
|
|
6819
7010
|
}
|
|
6820
7011
|
);
|
|
7012
|
+
const refs = media.references;
|
|
7013
|
+
if (!refs || refs.paths.length === 0) return thumb;
|
|
7014
|
+
const names = refs.paths.map(baseName).join(", ");
|
|
7015
|
+
return /* @__PURE__ */ jsxs9("span", { className: "awr-media-refs", children: [
|
|
7016
|
+
thumb,
|
|
7017
|
+
/* @__PURE__ */ jsx11(
|
|
7018
|
+
"span",
|
|
7019
|
+
{
|
|
7020
|
+
className: `awr-media__refs${refs.used ? "" : " awr-media__refs--unused"}`,
|
|
7021
|
+
title: refs.paths.join("\n"),
|
|
7022
|
+
children: refs.used ? L.mediaReferences(names) : L.mediaReferencesUnused(names)
|
|
7023
|
+
}
|
|
7024
|
+
)
|
|
7025
|
+
] });
|
|
6821
7026
|
}
|
|
6822
7027
|
if (url && family === "audio") {
|
|
6823
7028
|
return /* @__PURE__ */ jsx11("span", { className: "awr-media awr-media--audio", title: media.path, children: /* @__PURE__ */ jsx11(
|
|
@@ -7788,7 +7993,7 @@ var MessageList = ({
|
|
|
7788
7993
|
showApps && renderApp && m.role === "assistant" && m.apps?.length ? /* @__PURE__ */ jsx16("div", { className: "awr-msg__apps", children: m.apps.map((app) => /* @__PURE__ */ jsx16("div", { className: "awr-msg__app", children: renderApp(app, m) }, app.id)) }) : null,
|
|
7789
7994
|
showMedia && m.transcripts?.length ? /* @__PURE__ */ jsx16("div", { className: "awr-msg__transcripts", children: m.transcripts.map((t, i) => /* @__PURE__ */ jsx16(TranscriptBlock, { transcript: t, labels }, i)) }) : null,
|
|
7790
7995
|
(m.content || m.pending || !m.attachments?.length) && /* @__PURE__ */ jsxs14("div", { className: "awr-msg__bubble", children: [
|
|
7791
|
-
m.content ? renderContent ? renderContent(m) : m.content : null,
|
|
7996
|
+
m.content ? renderContent ? renderContent(m) : m.content : m.stopped && !m.pending ? /* @__PURE__ */ jsx16("span", { className: "awr-msg__stopped", children: L.answerStopped }) : null,
|
|
7792
7997
|
m.pending && !m.content && /* @__PURE__ */ jsx16(SpinnerIcon, { size: 14, className: "awr-msg__pending" })
|
|
7793
7998
|
] }),
|
|
7794
7999
|
showMedia && m.media?.length ? /* @__PURE__ */ jsx16("div", { className: "awr-msg__media", children: m.media.map((item, i) => {
|
|
@@ -9097,6 +9302,7 @@ export {
|
|
|
9097
9302
|
APP_MAX_HEIGHT,
|
|
9098
9303
|
APP_MIN_HEIGHT,
|
|
9099
9304
|
ASK_USER_TOOL_NAME,
|
|
9305
|
+
ATTACHMENT_BOUNDS,
|
|
9100
9306
|
AgentChat,
|
|
9101
9307
|
AgentComposer,
|
|
9102
9308
|
AgentLabelsProvider,
|
|
@@ -9191,7 +9397,9 @@ export {
|
|
|
9191
9397
|
askUserOutputKept,
|
|
9192
9398
|
askUserWith,
|
|
9193
9399
|
attachmentKindOf,
|
|
9400
|
+
attachmentOverLimit,
|
|
9194
9401
|
attachmentRefusal,
|
|
9402
|
+
attachmentTransformOf,
|
|
9195
9403
|
buildMcpAppDocument,
|
|
9196
9404
|
buildMcpAppSandboxShell,
|
|
9197
9405
|
buildSandboxedDocument,
|
|
@@ -9226,6 +9434,7 @@ export {
|
|
|
9226
9434
|
formatElapsed,
|
|
9227
9435
|
grantedAppCsp,
|
|
9228
9436
|
imageExtensionOf,
|
|
9437
|
+
imageSizeOf,
|
|
9229
9438
|
isMcpAppSandboxMessage,
|
|
9230
9439
|
isWebGPUAvailable2 as isWebGPUAvailable,
|
|
9231
9440
|
lessonsOf,
|
|
@@ -9243,6 +9452,7 @@ export {
|
|
|
9243
9452
|
menuSections,
|
|
9244
9453
|
mergeChatRecord,
|
|
9245
9454
|
mergeLabels,
|
|
9455
|
+
messageOverLimit,
|
|
9246
9456
|
newChatId,
|
|
9247
9457
|
noticesOf,
|
|
9248
9458
|
onStorageChange,
|