@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/dist/index.cjs CHANGED
@@ -34,6 +34,7 @@ __export(src_exports, {
34
34
  APP_MAX_HEIGHT: () => APP_MAX_HEIGHT,
35
35
  APP_MIN_HEIGHT: () => APP_MIN_HEIGHT,
36
36
  ASK_USER_TOOL_NAME: () => ASK_USER_TOOL_NAME,
37
+ ATTACHMENT_BOUNDS: () => ATTACHMENT_BOUNDS,
37
38
  AgentChat: () => AgentChat,
38
39
  AgentComposer: () => AgentComposer,
39
40
  AgentLabelsProvider: () => AgentLabelsProvider,
@@ -128,7 +129,9 @@ __export(src_exports, {
128
129
  askUserOutputKept: () => askUserOutputKept,
129
130
  askUserWith: () => askUserWith,
130
131
  attachmentKindOf: () => attachmentKindOf,
132
+ attachmentOverLimit: () => attachmentOverLimit,
131
133
  attachmentRefusal: () => attachmentRefusal,
134
+ attachmentTransformOf: () => attachmentTransformOf,
132
135
  buildMcpAppDocument: () => buildMcpAppDocument,
133
136
  buildMcpAppSandboxShell: () => buildMcpAppSandboxShell,
134
137
  buildSandboxedDocument: () => buildSandboxedDocument,
@@ -163,6 +166,7 @@ __export(src_exports, {
163
166
  formatElapsed: () => formatElapsed,
164
167
  grantedAppCsp: () => grantedAppCsp,
165
168
  imageExtensionOf: () => imageExtensionOf,
169
+ imageSizeOf: () => imageSizeOf,
166
170
  isMcpAppSandboxMessage: () => isMcpAppSandboxMessage,
167
171
  isWebGPUAvailable: () => import_agent_web8.isWebGPUAvailable,
168
172
  lessonsOf: () => lessonsOf,
@@ -180,6 +184,7 @@ __export(src_exports, {
180
184
  menuSections: () => menuSections,
181
185
  mergeChatRecord: () => mergeChatRecord,
182
186
  mergeLabels: () => mergeLabels,
187
+ messageOverLimit: () => messageOverLimit,
183
188
  newChatId: () => newChatId,
184
189
  noticesOf: () => noticesOf,
185
190
  onStorageChange: () => import_agent_web8.onStorageChange,
@@ -667,6 +672,13 @@ var mediaOf = (event, withStep) => ({
667
672
  mediaType: event.mediaType,
668
673
  bytes: event.bytes,
669
674
  model: event.model,
675
+ ...event.references ? {
676
+ references: {
677
+ used: event.references.used === true,
678
+ count: event.references.count,
679
+ paths: [...event.references.paths]
680
+ }
681
+ } : {},
670
682
  ...withStep && event.step ? { stepId: event.step.id } : {}
671
683
  });
672
684
  var addApp = (state, event, by) => {
@@ -1396,7 +1408,7 @@ var applyEvent = (state, event, ctx) => {
1396
1408
  ...ctx.goal ? {
1397
1409
  queued: [
1398
1410
  ...state.queued.filter((q) => q.id !== WAITING_ID),
1399
- { id: WAITING_ID, text: ctx.goal }
1411
+ { id: WAITING_ID, text: ctx.goal, session: event.heldBy }
1400
1412
  ]
1401
1413
  } : {}
1402
1414
  };
@@ -1424,11 +1436,11 @@ var applyEvent = (state, event, ctx) => {
1424
1436
  (q) => q.status === "pending" ? { ...q, status: "stopped", automatic: true, reason: "stopped" } : q
1425
1437
  )
1426
1438
  } : {},
1427
- messages: finalizeAssistant(
1428
- state.messages,
1429
- state.finalText || "Stopped.",
1430
- runDuration(state, ctx.at)
1431
- )
1439
+ // What it had written, or nothing - the chat says "stopped" through its labels.
1440
+ messages: finalizeAssistant(state.messages, state.finalText, {
1441
+ ...runDuration(state, ctx.at),
1442
+ stopped: true
1443
+ })
1432
1444
  };
1433
1445
  case "error":
1434
1446
  if (event.phase === "replan") {
@@ -2044,21 +2056,43 @@ var ChatHistoryStore = class {
2044
2056
  if (opts.memory || typeof indexedDB === "undefined") this.memory = /* @__PURE__ */ new Map();
2045
2057
  this.dbName = this.memory ? void 0 : this.name;
2046
2058
  }
2059
+ /**
2060
+ * The store's connection, opened on first use. Never in another tab's way: when another
2061
+ * connection asks to delete or upgrade the database (`versionchange` - another tab's
2062
+ * `indexedDB.deleteDatabase`, a newer copy of this package), it is closed at once, so that
2063
+ * request goes ahead instead of waiting for this tab to close; one the browser closed by itself
2064
+ * (site data cleared) is let go too. The next use opens the database again - after a deletion a
2065
+ * new, empty one (no chats: `list()` is empty, a save starts it again); after an upgrade by a
2066
+ * newer copy, the open fails until the page is reloaded with that copy.
2067
+ */
2047
2068
  open() {
2048
- this.db ??= new Promise((resolve, reject) => {
2069
+ if (this.db) return this.db;
2070
+ const opening = new Promise((resolve, reject) => {
2049
2071
  const r = indexedDB.open(this.name, DB_VERSION);
2050
2072
  r.onupgradeneeded = () => {
2051
2073
  if (!r.result.objectStoreNames.contains(this.storeName)) {
2052
2074
  r.result.createObjectStore(this.storeName, { keyPath: "id" });
2053
2075
  }
2054
2076
  };
2055
- r.onsuccess = () => resolve(r.result);
2077
+ r.onsuccess = () => {
2078
+ const db = r.result;
2079
+ const forget = () => {
2080
+ if (this.db === opening) this.db = void 0;
2081
+ };
2082
+ db.addEventListener("versionchange", () => {
2083
+ forget();
2084
+ db.close();
2085
+ });
2086
+ db.addEventListener("close", forget);
2087
+ resolve(db);
2088
+ };
2056
2089
  r.onerror = () => reject(r.error);
2057
2090
  }).catch((err) => {
2058
- this.db = void 0;
2091
+ if (this.db === opening) this.db = void 0;
2059
2092
  throw err;
2060
2093
  });
2061
- return this.db;
2094
+ this.db = opening;
2095
+ return opening;
2062
2096
  }
2063
2097
  async tx(mode) {
2064
2098
  const db = await this.open();
@@ -2673,7 +2707,8 @@ var attachmentKindOf = (mediaType, name) => {
2673
2707
  };
2674
2708
  var withAttachments = (text2, files) => {
2675
2709
  const texts = files.filter((f) => f.kind === "text" && f.text !== void 0);
2676
- if (texts.length === 0) return text2;
2710
+ const saved = files.filter((f) => f.kind !== "text" && f.path);
2711
+ if (texts.length === 0 && saved.length === 0) return text2;
2677
2712
  const blocks = texts.map((f) => {
2678
2713
  const body = f.text;
2679
2714
  const fence = body.includes("```") ? "~~~" : "```";
@@ -2683,10 +2718,46 @@ ${fence}
2683
2718
  ${body}
2684
2719
  ${fence}`;
2685
2720
  });
2686
- return `${text2}
2687
-
2688
- Attached file(s):
2689
- ${blocks.join("\n\n")}`;
2721
+ const kind = (f) => f.kind === "image" ? "picture" : f.kind === "pdf" ? "PDF" : "file";
2722
+ const lines = saved.map(
2723
+ (f) => `- ${kind(f)} "${f.name.replace(/["\s]+/g, " ").trim()}" (also saved as ${f.path})`
2724
+ );
2725
+ return [
2726
+ text2,
2727
+ ...blocks.length ? [`Attached file(s):
2728
+ ${blocks.join("\n\n")}`] : [],
2729
+ ...lines.length ? [`Also attached:
2730
+ ${lines.join("\n")}`] : []
2731
+ ].join("\n\n");
2732
+ };
2733
+ var ATTACHMENT_BOUNDS = {
2734
+ maxBytes: 20 * 1024 * 1024,
2735
+ // The largest JPEGs a phone writes (a 200 MP shot: ~20-40 MB) pass, and a long PDF with its
2736
+ // pictures; past this it is read into memory for nothing the model would get.
2737
+ maxSourceBytes: 50 * 1024 * 1024,
2738
+ // The largest phone sensor (200 MP: 16320 × 12240) passes, ~800 MB decoded; past this is a
2739
+ // scan, a render or a decompression bomb (a PNG of a few KB can declare 30000 × 30000 px).
2740
+ imageMaxSourcePixels: 2e8,
2741
+ // Under what the providers take in one request (Anthropic: 100 pictures, 32 MB; OpenAI: 50 MB).
2742
+ maxImages: 20,
2743
+ maxTotalBytes: 20 * 1024 * 1024
2744
+ };
2745
+ var attachmentTransformOf = (input) => input.converts ? "convert" : input.kind === "image" && input.imageMaxDimension !== false && input.mediaType !== "image/gif" && input.mediaType !== "image/svg+xml" ? "downscale" : "none";
2746
+ var attachmentOverLimit = (file, stage, transform, bounds) => {
2747
+ if (stage === "original" && transform !== "none") {
2748
+ const sourceBytes = Math.max(bounds.maxSourceBytes, bounds.maxBytes);
2749
+ if (file.bytes > sourceBytes) return { bound: "bytes", limit: sourceBytes };
2750
+ if (transform === "downscale" && file.pixels !== void 0 && file.pixels > bounds.imageMaxSourcePixels)
2751
+ return { bound: "pixels", limit: bounds.imageMaxSourcePixels };
2752
+ return void 0;
2753
+ }
2754
+ return file.bytes > bounds.maxBytes ? { bound: "bytes", limit: bounds.maxBytes } : void 0;
2755
+ };
2756
+ var messageOverLimit = (inMessage, next, bounds) => {
2757
+ if (next.kind === "image" && inMessage.filter((a) => a.kind === "image").length >= bounds.maxImages)
2758
+ return "images";
2759
+ const total = inMessage.reduce((n, a) => n + a.bytes, 0);
2760
+ return total + next.bytes > bounds.maxTotalBytes ? "bytes" : void 0;
2690
2761
  };
2691
2762
  var attachmentRefusal = (kind, caps, canConvertPdf = false) => {
2692
2763
  if (kind === "text" || !caps) return void 0;
@@ -2796,6 +2867,7 @@ var defaultLabels = {
2796
2867
  fetches: (n) => plural(n, "web request", "web requests"),
2797
2868
  fetchRefused: (reason) => `refused: ${reason}`,
2798
2869
  answerThoughts: "Thinking about the answer",
2870
+ answerStopped: "Stopped.",
2799
2871
  stepThoughts: "Thoughts",
2800
2872
  usageTitle: "Tokens this answer spent, by kind",
2801
2873
  attachments: "Attachments",
@@ -2845,7 +2917,12 @@ var defaultLabels = {
2845
2917
  attachmentsOnly: "(attachments)",
2846
2918
  seeAttachments: "See the attachments.",
2847
2919
  tooLarge: (name, mb) => `${name} is larger than ${mb} MB.`,
2920
+ tooManyPixels: (name, megapixels) => `${name} has more than ${megapixels} megapixels \u2014 too large a picture to attach.`,
2848
2921
  binaryText: (name) => `${name} looks binary \u2014 it can't be attached as text.`,
2922
+ downscaledFrom: (size) => `downscaled from ${size}`,
2923
+ convertedFrom: (name) => `converted from ${name}`,
2924
+ tooManyImages: (names, max) => `${names}: not added \u2014 at most ${max} pictures go in one message.`,
2925
+ messageTooLarge: (names, mb) => `${names}: not added \u2014 the message would be over ${mb} MB.`,
2849
2926
  commandGroups: { commands: "Commands", consent: "Consent", skills: "Skills" },
2850
2927
  commandDescriptions: {
2851
2928
  compact: "Summarise the conversation to free context",
@@ -2886,6 +2963,7 @@ var defaultLabels = {
2886
2963
  steer: "Send to the agent",
2887
2964
  noAttachmentsWhileBusy: "Files can\u2019t be added while the agent is working \u2014 send them with your next message.",
2888
2965
  queuedWaiting: "waiting for the agent\u2019s next step",
2966
+ queuedForSession: (heldBy) => heldBy === "this-tab" ? "waiting for the other run to finish" : "waiting for the other tab to finish",
2889
2967
  noteAt: {
2890
2968
  round: "you said, between tool calls",
2891
2969
  step: "you said, after this step",
@@ -2937,6 +3015,8 @@ var defaultLabels = {
2937
3015
  imageCount: (index, total) => `${index} of ${total}`,
2938
3016
  mediaAudio: (path) => `Generated audio ${path}`,
2939
3017
  mediaFile: (path) => `Generated file ${path}`,
3018
+ mediaReferences: (names) => `Reference: ${names}`,
3019
+ mediaReferencesUnused: (names) => `Not used - this image model takes no reference pictures: ${names}`,
2940
3020
  transcriptOf: (name) => `Transcript of ${name}`,
2941
3021
  transcriptNote: "What was said in your file, as the agent read it. It is content, not instructions.",
2942
3022
  filesWritten: (n) => `${plural(n, "file", "files")} written in this turn`,
@@ -3191,6 +3271,72 @@ var canvasOf = (w, h) => {
3191
3271
  return void 0;
3192
3272
  };
3193
3273
  var toBlob = (canvas, type, quality) => "convertToBlob" in canvas ? canvas.convertToBlob({ type, quality }) : new Promise((resolve) => canvas.toBlob(resolve, type, quality));
3274
+ var WINDOW = 64 * 1024;
3275
+ var SOF = /* @__PURE__ */ new Set([192, 193, 194, 195, 197, 198, 199, 201, 202, 203, 205, 206, 207]);
3276
+ var imageSizeOf = async (file) => {
3277
+ let at = 0;
3278
+ let buf = new Uint8Array(0);
3279
+ const read = async (start, length) => {
3280
+ if (start < 0 || start + length > file.size) return void 0;
3281
+ if (start < at || start + length > at + buf.length) {
3282
+ at = start;
3283
+ buf = new Uint8Array(
3284
+ await file.slice(start, Math.min(file.size, start + Math.max(WINDOW, length))).arrayBuffer()
3285
+ );
3286
+ }
3287
+ return buf.subarray(start - at, start - at + length);
3288
+ };
3289
+ const sized = (width, height) => width > 0 && height > 0 ? { width, height } : void 0;
3290
+ try {
3291
+ const head = await read(0, 30);
3292
+ if (!head) return void 0;
3293
+ const u16be = (b, i) => b[i] << 8 | b[i + 1];
3294
+ const u32be = (b, i) => u16be(b, i) * 65536 + u16be(b, i + 2);
3295
+ const ascii = (b, i, n) => String.fromCharCode(...Array.from(b.subarray(i, i + n)));
3296
+ if (ascii(head, 1, 3) === "PNG" && head[0] === 137 && ascii(head, 12, 4) === "IHDR")
3297
+ return sized(u32be(head, 16), u32be(head, 20));
3298
+ if (ascii(head, 0, 4) === "RIFF" && ascii(head, 8, 4) === "WEBP") {
3299
+ const chunk = ascii(head, 12, 4);
3300
+ const u16le = (i) => head[i] | head[i + 1] << 8;
3301
+ const u24le = (i) => u16le(i) | head[i + 2] << 16;
3302
+ if (chunk === "VP8X") return sized(u24le(24) + 1, u24le(27) + 1);
3303
+ if (chunk === "VP8L" && head[20] === 47) {
3304
+ const bits = (u16le(21) | u16le(23) << 16) >>> 0;
3305
+ return sized((bits & 16383) + 1, (bits >>> 14 & 16383) + 1);
3306
+ }
3307
+ if (chunk === "VP8 " && head[23] === 157 && head[24] === 1 && head[25] === 42)
3308
+ return sized(u16le(26) & 16383, u16le(28) & 16383);
3309
+ return void 0;
3310
+ }
3311
+ if (head[0] === 255 && head[1] === 216) {
3312
+ let p = 2;
3313
+ for (let segments = 0; segments < 4096; segments++) {
3314
+ const m = await read(p, 4);
3315
+ if (!m || m[0] !== 255) return void 0;
3316
+ const marker = m[1];
3317
+ if (marker === 255) {
3318
+ p += 1;
3319
+ continue;
3320
+ }
3321
+ if (marker === 1 || marker >= 208 && marker <= 216) {
3322
+ p += 2;
3323
+ continue;
3324
+ }
3325
+ if (marker === 217 || marker === 218) return void 0;
3326
+ const length = u16be(m, 2);
3327
+ if (length < 2) return void 0;
3328
+ if (SOF.has(marker)) {
3329
+ const frame = await read(p + 4, 5);
3330
+ return frame ? sized(u16be(frame, 3), u16be(frame, 1)) : void 0;
3331
+ }
3332
+ p += 2 + length;
3333
+ }
3334
+ }
3335
+ return void 0;
3336
+ } catch {
3337
+ return void 0;
3338
+ }
3339
+ };
3194
3340
  var downscaleImage = async (file, opts = {}) => {
3195
3341
  const maxDimension = opts.maxDimension ?? 1568;
3196
3342
  const maxPixels = opts.maxPixels ?? 115e4;
@@ -5646,7 +5792,12 @@ var AgentComposer = ({
5646
5792
  const MODE_CHIP = L.modes;
5647
5793
  const DEFAULT_THINKING = thinkingDefaults(L);
5648
5794
  const [text2, setText] = (0, import_react12.useState)("");
5649
- const [pending, setPending] = (0, import_react12.useState)([]);
5795
+ const [pending, setPendingState] = (0, import_react12.useState)([]);
5796
+ const pendingRef = (0, import_react12.useRef)([]);
5797
+ const setPending = (next) => {
5798
+ pendingRef.current = typeof next === "function" ? next(pendingRef.current) : next;
5799
+ setPendingState(pendingRef.current);
5800
+ };
5650
5801
  const [menu, setMenu] = (0, import_react12.useState)(void 0);
5651
5802
  const [active, setActive] = (0, import_react12.useState)(0);
5652
5803
  const [dismissed, setDismissed] = (0, import_react12.useState)(() => /* @__PURE__ */ new Set());
@@ -5811,17 +5962,44 @@ ${draftText}` : draftText);
5811
5962
  void cmd.run?.(args);
5812
5963
  };
5813
5964
  const attachCfg = typeof attachments === "object" ? attachments : {};
5814
- const maxBytes = attachCfg.maxBytes ?? 20 * 1024 * 1024;
5965
+ const bounds = {
5966
+ maxBytes: attachCfg.maxBytes ?? ATTACHMENT_BOUNDS.maxBytes,
5967
+ maxSourceBytes: attachCfg.maxSourceBytes ?? ATTACHMENT_BOUNDS.maxSourceBytes,
5968
+ imageMaxSourcePixels: attachCfg.imageMaxSourcePixels ?? ATTACHMENT_BOUNDS.imageMaxSourcePixels,
5969
+ maxImages: attachCfg.maxImages ?? ATTACHMENT_BOUNDS.maxImages,
5970
+ maxTotalBytes: attachCfg.maxTotalBytes ?? ATTACHMENT_BOUNDS.maxTotalBytes
5971
+ };
5815
5972
  const imageMax = attachCfg.imageMaxDimension ?? 1568;
5973
+ const overLimitText = (name, over) => over.bound === "pixels" ? L.tooManyPixels(name, Math.round(over.limit / 1e6)) : L.tooLarge(name, Math.round(over.limit / 1024 / 1024));
5816
5974
  const addFiles = async (list) => {
5817
- const added = [];
5818
5975
  let problem;
5976
+ const noRoom = { images: [], bytes: [] };
5977
+ const add = (name, a) => {
5978
+ const full = messageOverLimit(pendingRef.current, a, bounds);
5979
+ if (full) noRoom[full].push(name);
5980
+ else setPending((cur) => [...cur, a]);
5981
+ };
5819
5982
  for (const f of list) {
5820
5983
  const mediaType = f.type || "application/octet-stream";
5821
5984
  const name = f.name || `pasted-${Date.now()}.${mediaType.split("/")[1] ?? "bin"}`;
5822
5985
  const kind = attachmentKindOf(mediaType, name);
5823
- if (f.size > maxBytes) {
5824
- problem = L.tooLarge(name, Math.round(maxBytes / 1024 / 1024));
5986
+ const refusal = attachmentRefusal(kind, caps);
5987
+ const converts = Boolean(convertFile && (refusal || kind === "pdf" && convert === "always"));
5988
+ const transform = attachmentTransformOf({
5989
+ kind,
5990
+ mediaType,
5991
+ imageMaxDimension: imageMax,
5992
+ converts
5993
+ });
5994
+ const size = transform === "downscale" ? await imageSizeOf(f) : void 0;
5995
+ const pixels = size && size.width * size.height;
5996
+ const over = attachmentOverLimit({ bytes: f.size, pixels }, "original", transform, bounds);
5997
+ if (over) {
5998
+ problem = overLimitText(name, over);
5999
+ continue;
6000
+ }
6001
+ if (kind === "image" && transform !== "convert" && messageOverLimit(pendingRef.current, { kind, bytes: 0 }, bounds) === "images") {
6002
+ noRoom.images.push(name);
5825
6003
  continue;
5826
6004
  }
5827
6005
  try {
@@ -5832,22 +6010,26 @@ ${draftText}` : draftText);
5832
6010
  problem = L.binaryText(name);
5833
6011
  continue;
5834
6012
  }
5835
- added.push({ id, name, kind, mediaType, text: content, bytes: f.size });
6013
+ add(name, { id, name, kind, mediaType, text: content, bytes: f.size });
5836
6014
  continue;
5837
6015
  }
5838
- const refusal = attachmentRefusal(kind, caps);
5839
- const wantConvert = convertFile && (refusal || kind === "pdf" && convert === "always");
5840
- if (wantConvert && convertFile) {
6016
+ if (converts && convertFile) {
5841
6017
  const converted = await convertFile(f);
5842
6018
  if (converted) {
5843
- added.push({
6019
+ const bytes = new Blob([converted.text]).size;
6020
+ const sentOver2 = attachmentOverLimit({ bytes }, "sent", transform, bounds);
6021
+ if (sentOver2) {
6022
+ problem = overLimitText(name, sentOver2);
6023
+ continue;
6024
+ }
6025
+ add(name, {
5844
6026
  id,
5845
6027
  name: converted.name ?? `${name}.md`,
5846
6028
  kind: "text",
5847
6029
  mediaType: "text/markdown",
5848
6030
  text: converted.text,
5849
- bytes: converted.text.length,
5850
- note: `converted from ${name}`
6031
+ bytes,
6032
+ note: L.convertedFrom(name)
5851
6033
  });
5852
6034
  continue;
5853
6035
  }
@@ -5856,25 +6038,35 @@ ${draftText}` : draftText);
5856
6038
  problem = refusal;
5857
6039
  continue;
5858
6040
  }
5859
- const blob = kind === "image" && imageMax !== false ? await downscaleImage(f, {
6041
+ const blob = transform === "downscale" ? await downscaleImage(f, {
5860
6042
  maxDimension: imageMax,
5861
6043
  maxPixels: attachCfg.imageMaxPixels
5862
6044
  }) : f;
5863
- added.push({
6045
+ const sentOver = attachmentOverLimit({ bytes: blob.size }, "sent", transform, bounds);
6046
+ if (sentOver) {
6047
+ problem = overLimitText(name, sentOver);
6048
+ continue;
6049
+ }
6050
+ add(name, {
5864
6051
  id,
5865
6052
  name,
5866
6053
  kind,
5867
6054
  mediaType: blob.type || mediaType,
5868
6055
  dataUrl: await readDataUrl2(blob),
5869
6056
  bytes: blob.size,
5870
- ...blob !== f ? { note: `downscaled from ${L.bytes(f.size)}` } : {}
6057
+ ...blob !== f ? { note: L.downscaledFrom(L.bytes(f.size)) } : {}
5871
6058
  });
5872
6059
  } catch (err) {
5873
6060
  problem = `${name}: ${err instanceof Error ? err.message : String(err)}`;
5874
6061
  }
5875
6062
  }
5876
- setAttachError(problem);
5877
- if (added.length) setPending((cur) => [...cur, ...added]);
6063
+ const names = (list2) => list2.length > 3 ? `${list2.slice(0, 3).join(", ")}, \u2026` : list2.join(", ");
6064
+ const said = [
6065
+ problem,
6066
+ noRoom.images.length ? L.tooManyImages(names(noRoom.images), bounds.maxImages) : "",
6067
+ noRoom.bytes.length ? L.messageTooLarge(names(noRoom.bytes), Math.round(bounds.maxTotalBytes / 1024 / 1024)) : ""
6068
+ ];
6069
+ setAttachError(said.filter(Boolean).join(" ") || void 0);
5878
6070
  if (fileRef.current) fileRef.current.value = "";
5879
6071
  };
5880
6072
  const onPaste = (e) => {
@@ -6068,7 +6260,7 @@ ${draftText}` : draftText);
6068
6260
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ClockIcon, { size: 13, className: "awr-queued__icon" }),
6069
6261
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-queued__text", title: q.text, children: q.text }),
6070
6262
  q.origin === "another-tab" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-queued__origin", children: L.fromAnotherTab }),
6071
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-queued__state", children: L.queuedWaiting })
6263
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-queued__state", children: q.session ? L.queuedForSession(q.session) : L.queuedWaiting })
6072
6264
  ] }, q.id)),
6073
6265
  agent.undelivered.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "awr-queued__item awr-queued__item--undelivered", role: "status", children: [
6074
6266
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AlertIcon, { size: 13, className: "awr-queued__icon" }),
@@ -6143,7 +6335,10 @@ ${draftText}` : draftText);
6143
6335
  if (renderAttachment) return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: renderAttachment(a, remove) }, a.id);
6144
6336
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "awr-chip awr-file", title: a.note ?? a.mediaType, children: [
6145
6337
  a.kind === "image" && a.dataUrl ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("img", { className: "awr-file__thumb", src: a.dataUrl, alt: a.name }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FileIcon, { size: 14 }),
6146
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-file__name", children: a.name }),
6338
+ a.note ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "awr-file__text", children: [
6339
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-file__name", children: a.name }),
6340
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-file__note", children: a.note })
6341
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "awr-file__name", children: a.name }),
6147
6342
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
6148
6343
  "button",
6149
6344
  {
@@ -7435,13 +7630,14 @@ var useFileUrl = (files, path, mediaType) => {
7435
7630
  }, [files, path, mediaType]);
7436
7631
  return url;
7437
7632
  };
7633
+ var baseName = (path) => path.split(/[\\/]/).filter(Boolean).pop() ?? path;
7438
7634
  var GeneratedMedia = ({ media, files, labels }) => {
7439
7635
  const L = useLabels(labels);
7440
7636
  const family = mediaFamilyOf(media.mediaType);
7441
7637
  const type = family ? media.mediaType.toLowerCase().split(";")[0].trim() : void 0;
7442
7638
  const url = useFileUrl(files, media.path, type);
7443
7639
  if (url && family === "image") {
7444
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
7640
+ const thumb = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
7445
7641
  ImageThumb,
7446
7642
  {
7447
7643
  className: "awr-media awr-media--image",
@@ -7453,6 +7649,20 @@ var GeneratedMedia = ({ media, files, labels }) => {
7453
7649
  labels
7454
7650
  }
7455
7651
  );
7652
+ const refs = media.references;
7653
+ if (!refs || refs.paths.length === 0) return thumb;
7654
+ const names = refs.paths.map(baseName).join(", ");
7655
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "awr-media-refs", children: [
7656
+ thumb,
7657
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
7658
+ "span",
7659
+ {
7660
+ className: `awr-media__refs${refs.used ? "" : " awr-media__refs--unused"}`,
7661
+ title: refs.paths.join("\n"),
7662
+ children: refs.used ? L.mediaReferences(names) : L.mediaReferencesUnused(names)
7663
+ }
7664
+ )
7665
+ ] });
7456
7666
  }
7457
7667
  if (url && family === "audio") {
7458
7668
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "awr-media awr-media--audio", title: media.path, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
@@ -8423,7 +8633,7 @@ var MessageList = ({
8423
8633
  showApps && renderApp && m.role === "assistant" && m.apps?.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__apps", children: m.apps.map((app) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__app", children: renderApp(app, m) }, app.id)) }) : null,
8424
8634
  showMedia && m.transcripts?.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__transcripts", children: m.transcripts.map((t, i) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TranscriptBlock, { transcript: t, labels }, i)) }) : null,
8425
8635
  (m.content || m.pending || !m.attachments?.length) && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "awr-msg__bubble", children: [
8426
- m.content ? renderContent ? renderContent(m) : m.content : null,
8636
+ m.content ? renderContent ? renderContent(m) : m.content : m.stopped && !m.pending ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "awr-msg__stopped", children: L.answerStopped }) : null,
8427
8637
  m.pending && !m.content && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SpinnerIcon, { size: 14, className: "awr-msg__pending" })
8428
8638
  ] }),
8429
8639
  showMedia && m.media?.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "awr-msg__media", children: m.media.map((item, i) => {
@@ -9703,6 +9913,7 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
9703
9913
  APP_MAX_HEIGHT,
9704
9914
  APP_MIN_HEIGHT,
9705
9915
  ASK_USER_TOOL_NAME,
9916
+ ATTACHMENT_BOUNDS,
9706
9917
  AgentChat,
9707
9918
  AgentComposer,
9708
9919
  AgentLabelsProvider,
@@ -9797,7 +10008,9 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
9797
10008
  askUserOutputKept,
9798
10009
  askUserWith,
9799
10010
  attachmentKindOf,
10011
+ attachmentOverLimit,
9800
10012
  attachmentRefusal,
10013
+ attachmentTransformOf,
9801
10014
  buildMcpAppDocument,
9802
10015
  buildMcpAppSandboxShell,
9803
10016
  buildSandboxedDocument,
@@ -9832,6 +10045,7 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
9832
10045
  formatElapsed,
9833
10046
  grantedAppCsp,
9834
10047
  imageExtensionOf,
10048
+ imageSizeOf,
9835
10049
  isMcpAppSandboxMessage,
9836
10050
  isWebGPUAvailable,
9837
10051
  lessonsOf,
@@ -9849,6 +10063,7 @@ var import_agent_web8 = require("@dudko.dev/agent-web");
9849
10063
  menuSections,
9850
10064
  mergeChatRecord,
9851
10065
  mergeLabels,
10066
+ messageOverLimit,
9852
10067
  newChatId,
9853
10068
  noticesOf,
9854
10069
  onStorageChange,