From bfba73fa2f1373abd8a5a704c9c833d6fce1b44f Mon Sep 17 00:00:00 2001 From: amankumarsingh77 Date: Tue, 28 Jul 2026 00:17:13 +0530 Subject: refactor(domains): share target resolution and CDP error mapping The ref-vs-x/y branch turned out to exist in one tool, not four; it is now one helper with tests covering the half-specified-coordinate and stale-ref cases. cdpCall folds the repeated cdp_error mapping at 24 active-session call sites; target-scoped callOnTarget/callBrowser sites are left alone. Co-Authored-By: Claude Opus 5 (1M context) --- src/domains/cdp-call.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/domains/cdp-call.ts (limited to 'src/domains/cdp-call.ts') diff --git a/src/domains/cdp-call.ts b/src/domains/cdp-call.ts new file mode 100644 index 0000000..3316633 --- /dev/null +++ b/src/domains/cdp-call.ts @@ -0,0 +1,14 @@ +import type { BrowserClient } from "../client"; +import type { CdpMethod, ParamsOf, ResultOf } from "../cdp/commands"; +import { type Result, err } from "../util/result"; +import type { ToolErr } from "../util/tool"; + +export const cdpCall = async ( + client: BrowserClient, + method: M, + params: ParamsOf, +): Promise, ToolErr>> => { + const r = await client.session().call(method, params); + if (!r.success) return err({ kind: "cdp_error", message: r.error.message, details: { method } }); + return r; +}; -- cgit v1.2.3