@nac3/forge-cli 1.0.93 → 1.0.94

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.
@@ -7604,22 +7604,32 @@ function generateRequestId() {
7604
7604
  }
7605
7605
  return s;
7606
7606
  }
7607
- /* Cap for JSON request bodies. Raised from the old hardcoded 1MB, which
7608
- * rejected legitimate large chat turns (long history + pasted docs)
7609
- * BEFORE they ever reached Claude -- the panel surfaced it as if the
7610
- * model failed. The panel<->server link is local and the relay path is
7611
- * authenticated, so a generous cap matching the Anthropic API ceiling
7612
- * (~32MB) is safe. Parameterizable so a specific endpoint can opt into a
7613
- * tighter limit if ever needed. (Pablo 2026-08-05) */
7614
- const MAX_JSON_BODY_BYTES = 32 * 1024 * 1024;
7615
- async function readBody(req, maxBytes = MAX_JSON_BODY_BYTES) {
7607
+ /* Fallback cap for JSON request bodies if the limits config can't be read.
7608
+ * The EFFECTIVE cap is limits.json -> max_request_body_bytes (default 32MB,
7609
+ * ~Anthropic ceiling), configurable via Ajustes > Limites, `yf limits set
7610
+ * max_request_body_bytes <n>`, or editing ~/.yujin-forge/limits.json (applies
7611
+ * within ~3s, no restart -- readLimitsConfig caches). The old hardcoded 1MB
7612
+ * rejected large chat turns (long history + pasted docs) before they reached
7613
+ * Claude. `maxBytes` lets a specific endpoint opt into a tighter cap. */
7614
+ const MAX_JSON_BODY_BYTES_FALLBACK = 32 * 1024 * 1024;
7615
+ async function readBody(req, maxBytes) {
7616
+ let cap = maxBytes;
7617
+ if (cap === undefined) {
7618
+ try {
7619
+ const { readLimitsConfig } = await import('../core/limits_config.js');
7620
+ cap = (await readLimitsConfig()).max_request_body_bytes;
7621
+ }
7622
+ catch {
7623
+ cap = MAX_JSON_BODY_BYTES_FALLBACK;
7624
+ }
7625
+ }
7616
7626
  const chunks = [];
7617
7627
  let total = 0;
7618
7628
  for await (const chunk of req) {
7619
7629
  const buf = chunk;
7620
7630
  total += buf.length;
7621
- if (total > maxBytes) {
7622
- throw new Error('request body too large (>' + maxBytes + ' bytes)');
7631
+ if (total > cap) {
7632
+ throw new Error('request body too large (>' + cap + ' bytes)');
7623
7633
  }
7624
7634
  chunks.push(buf);
7625
7635
  }