@nac3/forge-cli 1.0.92 → 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.
- package/dist/chat/server.js +25 -4
- package/dist/chat/server.js.map +1 -1
- package/dist/core/limits_config.d.ts +6 -0
- package/dist/core/limits_config.d.ts.map +1 -1
- package/dist/core/limits_config.js +5 -0
- package/dist/core/limits_config.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/chat/server.js
CHANGED
|
@@ -7604,13 +7604,34 @@ function generateRequestId() {
|
|
|
7604
7604
|
}
|
|
7605
7605
|
return s;
|
|
7606
7606
|
}
|
|
7607
|
-
|
|
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
|
+
}
|
|
7608
7626
|
const chunks = [];
|
|
7627
|
+
let total = 0;
|
|
7609
7628
|
for await (const chunk of req) {
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
7629
|
+
const buf = chunk;
|
|
7630
|
+
total += buf.length;
|
|
7631
|
+
if (total > cap) {
|
|
7632
|
+
throw new Error('request body too large (>' + cap + ' bytes)');
|
|
7613
7633
|
}
|
|
7634
|
+
chunks.push(buf);
|
|
7614
7635
|
}
|
|
7615
7636
|
return Buffer.concat(chunks).toString('utf-8');
|
|
7616
7637
|
}
|