refactor(browser): return complete observation evidence

This commit is contained in:
morluto
2026-09-29 13:56:49 +08:00
parent 9d1f88cbe8
commit 0e2738ffb6
69 changed files with 747 additions and 1206 deletions
+3 -6
View File
@@ -83,10 +83,7 @@ export const captureCdpScreenshot = async (
const encoded = stringValue(result?.data);
const bytes =
encoded === undefined ? undefined : decodeCanonicalBase64(encoded);
if (
bytes === undefined ||
bytes.byteLength > context.input.maximum_image_bytes
)
if (bytes === undefined)
throw new BrowserObservationError("inspect_web_page", "payload_limit");
const dimensions = pngDimensions(bytes);
if (navigation.leftScope)
@@ -155,8 +152,8 @@ const pngDimensions = (
throw new BrowserObservationError("inspect_web_page", "protocol_error");
const width = bytes.readUInt32BE(16);
const height = bytes.readUInt32BE(20);
if (width === 0 || height === 0 || width * height > 32_000_000)
throw new BrowserObservationError("inspect_web_page", "payload_limit");
if (width === 0 || height === 0)
throw new BrowserObservationError("inspect_web_page", "protocol_error");
return { width, height };
};