fix(managed): budget decoding before representation expansion

Validation: integrated changes passed formatting, typecheck, lint, resolved module-boundary verification and git diff --check. Tests and real-provider workflows were not run.
This commit is contained in:
morluto
2026-10-11 00:03:19 +08:00
parent 6d4cefc4f7
commit 0f0d6e4d43
18 changed files with 705 additions and 362 deletions
+2
View File
@@ -4,6 +4,7 @@ import type { FileHandle } from "node:fs/promises";
export const readBoundedFileBytes = async (
handle: FileHandle,
maxBytes: number,
signal?: AbortSignal,
): Promise<Buffer | undefined> => {
if (!Number.isSafeInteger(maxBytes) || maxBytes < 0)
throw new RangeError("File byte limit must be a nonnegative safe integer");
@@ -11,6 +12,7 @@ export const readBoundedFileBytes = async (
const buffer = Buffer.allocUnsafe(Math.min(64 * 1_024, maxBytes + 1));
let total = 0;
for (;;) {
signal?.throwIfAborted();
const { bytesRead } = await handle.read(
buffer,
0,