From 9f2f75dd9281153888776e5d39d4926655c15f2a Mon Sep 17 00:00:00 2001 From: amankumarsingh77 Date: Mon, 27 Jul 2026 23:26:50 +0530 Subject: refactor(domains): drop CDP casts, share the box-model unwrap ref-resolve.ts and snapshot.ts had the same box-model unwrap, both using data.model! to work around an untyped response. Extracted to domains/box.ts; the typed schema makes the assertions unnecessary. Both derived the centre identically (quad corner + half the model width/height), so centreOf keeps that derivation; the shared zero-size rejection moved into boxOf, and snapshot keeps its own off-viewport (x/y < 0) filter. evalInIsolatedTab now goes through evaluateJson with the tab's own sessionId and a caller-supplied guard; both callers evaluate expressions ending in JSON.stringify, so they pass isJsonText rather than a check that checks nothing. Runtime.evaluate/callFunctionOn result casts in form.ts, forms.ts and keyboard.ts are replaced by named guards over the in-page result shapes. Runtime.callFunctionOn's params schema gained arguments/returnByValue/ awaitPromise/userGesture: four domain call sites legitimately pass them and typebox's additionalProperties:true does not widen the static type, so the params type was rejecting valid CDP fields. Params schemas are type-only (only results are compiled), so this is a compile-time widening with no runtime effect. tsc is green again for both tsconfigs. Co-Authored-By: Claude Opus 5 (1M context) --- src/domains/network.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/domains/network.ts') diff --git a/src/domains/network.ts b/src/domains/network.ts index f13b1e7..ca46664 100644 --- a/src/domains/network.ts +++ b/src/domains/network.ts @@ -202,7 +202,7 @@ export const networkRequestsTool = defineBrowserTool({ r.body = null; return; } - const b = bodyRes.data as { body: string; base64Encoded?: boolean }; + const b = bodyRes.data; let body = b.base64Encoded ? Buffer.from(b.body, "base64").toString("utf8") : b.body; if (body.length > PER_BODY_CAP) body = body.slice(0, PER_BODY_CAP) + "…"; r.body = body; -- cgit v1.2.3