@tangle-network/agent-app 0.45.55 → 0.45.56

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.
@@ -2,13 +2,13 @@ import {
2
2
  ChatComposer,
3
3
  ChatEmptyState,
4
4
  ChatMessages
5
- } from "../chunk-MQO5ML66.js";
5
+ } from "../chunk-KJ2Q27U7.js";
6
6
  import "../chunk-FBVLEGEG.js";
7
7
  import "../chunk-ENLRJYVW.js";
8
8
  import "../chunk-GEYACSFW.js";
9
9
  import {
10
10
  ModelPicker
11
- } from "../chunk-PVP57G3S.js";
11
+ } from "../chunk-2IFGVBNI.js";
12
12
  import "../chunk-MLG6XKPV.js";
13
13
  import "../chunk-BATKJP3P.js";
14
14
  import {
@@ -16,7 +16,7 @@ import {
16
16
  } from "../chunk-3UBAO3N5.js";
17
17
  import "../chunk-PC2WYTK7.js";
18
18
  import "../chunk-QY4BRKRJ.js";
19
- import "../chunk-CCVG2TL6.js";
19
+ import "../chunk-YNMPMW3G.js";
20
20
  import "../chunk-5ZTFZBS6.js";
21
21
  import "../chunk-ZVEEWGDK.js";
22
22
  import "../chunk-KWXUBMXU.js";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  AgentSessionControls,
3
3
  useComposerAttachments
4
- } from "../chunk-PVP57G3S.js";
4
+ } from "../chunk-2IFGVBNI.js";
5
5
  import "../chunk-MLG6XKPV.js";
6
6
  import {
7
7
  ATTACHMENT_ACCEPT
8
- } from "../chunk-CCVG2TL6.js";
8
+ } from "../chunk-YNMPMW3G.js";
9
9
  import "../chunk-KWXUBMXU.js";
10
10
  import "../chunk-TH7L265V.js";
11
11
 
@@ -3,8 +3,9 @@
3
3
  * route: a two-phase atomic batch (every file is validated before any file is
4
4
  * written — a batch never partially lands), a content-sniffed type gate
5
5
  * (`checkAttachmentType` over `sniffBinary`'s magic-byte read, not the
6
- * extension or the browser-reported MIME), per-kind + aggregate byte caps,
7
- * and sanitized filenames. Storage is fully seamed through the injected
6
+ * extension or the browser-reported MIME), binary/text caps with optional
7
+ * per-sniffed-mime overrides, an aggregate byte cap, and sanitized filenames.
8
+ * Storage is fully seamed through the injected
8
9
  * `WriteAttachmentFn` (`./attachment-store`) — no default store, the product
9
10
  * owns where bytes actually live (vault, object store, …) — and auth/rate
10
11
  * limiting is entirely the injected `authorize` seam's job: this factory
@@ -56,6 +57,10 @@ export interface CreateAttachmentUploadRouteOptions {
56
57
  maxCount?: number;
57
58
  /** Ceiling on a binary file's raw size. Default {@link MAX_BINARY_ATTACHMENT_BYTES}. */
58
59
  maxBinaryBytes?: number;
60
+ /** Optional binary-file ceilings keyed by the content-sniffed mime. A
61
+ * missing mime falls back to `maxBinaryBytes`; text files continue to use
62
+ * `maxTextBytes`. */
63
+ maxBytesBySniffedMime?: ReadonlyMap<string, number>;
59
64
  /** Ceiling on a text file's raw size. Default {@link MAX_TEXT_ATTACHMENT_BYTES}. */
60
65
  maxTextBytes?: number;
61
66
  /** Aggregate raw-byte ceiling across the batch. Default {@link MAX_ATTACHMENT_TOTAL_BYTES}. */
@@ -5,10 +5,10 @@
5
5
  * the client. Extension-based allowlists lie (a renamed `.docx`, a PNG saved
6
6
  * as `.txt`), so classification reads the actual bytes: a magic-byte table
7
7
  * for common binary formats first, then a UTF-8 decode attempt for
8
- * everything else. Two families need more than a fixed-offset signature and
9
- * get a reader of their own — ISO-BMFF brands (`sniffFtyp`) and OOXML Office
10
- * packages, whose PKZIP container is shared with every other `.zip`
11
- * (`sniffOoxml`).
8
+ * everything else. Three families need more than a fixed-offset signature and
9
+ * get a reader of their own — ISO-BMFF brands (`sniffFtyp`), EBML containers
10
+ * (`sniffEbml`), and OOXML Office packages, whose PKZIP container is shared
11
+ * with every other `.zip` (`sniffOoxml`).
12
12
  *
13
13
  * Lifted near-verbatim from gtm-agent's `src/lib/binary-sniff.ts` (the
14
14
  * source PRs hardened this against real corruption/gate bugs: gtm#584,
@@ -21,7 +21,7 @@ import {
21
21
  checkAttachmentType,
22
22
  sanitizeAttachmentFileName,
23
23
  sniffBinary
24
- } from "../chunk-CCVG2TL6.js";
24
+ } from "../chunk-YNMPMW3G.js";
25
25
  import {
26
26
  createInteractionAnswerRoute
27
27
  } from "../chunk-ZSSCVT6H.js";
@@ -2539,6 +2539,7 @@ function attachmentUploadError(status, code, message, path) {
2539
2539
  function createAttachmentUploadRoute(options) {
2540
2540
  const maxCount = options.limits?.maxCount ?? ATTACHMENT_MAX_COUNT;
2541
2541
  const maxBinaryBytes = options.limits?.maxBinaryBytes ?? MAX_BINARY_ATTACHMENT_BYTES;
2542
+ const maxBytesBySniffedMime = options.limits?.maxBytesBySniffedMime;
2542
2543
  const maxTextBytes = options.limits?.maxTextBytes ?? MAX_TEXT_ATTACHMENT_BYTES;
2543
2544
  const maxTotalBytes = options.limits?.maxTotalBytes ?? MAX_ATTACHMENT_TOTAL_BYTES;
2544
2545
  const allowedKinds = options.allowedKinds ?? ["image", "file"];
@@ -2601,7 +2602,10 @@ function createAttachmentUploadRoute(options) {
2601
2602
  `${name} is a "${kind}" attachment, which this upload route does not accept`
2602
2603
  );
2603
2604
  }
2604
- const limit = sniff.binary ? maxBinaryBytes : maxTextBytes;
2605
+ let limit = maxTextBytes;
2606
+ if (sniff.binary) {
2607
+ limit = sniff.mime === null ? maxBinaryBytes : maxBytesBySniffedMime?.get(sniff.mime) ?? maxBinaryBytes;
2608
+ }
2605
2609
  if (bytes.length > limit) {
2606
2610
  return attachmentUploadError(
2607
2611
  413,