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/snapshot.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/domains/snapshot.ts') diff --git a/src/domains/snapshot.ts b/src/domains/snapshot.ts index bfc475c..ec5c894 100644 --- a/src/domains/snapshot.ts +++ b/src/domains/snapshot.ts @@ -4,6 +4,7 @@ import { Container, Image, type ImageTheme, Markdown, Text, truncateToWidth, vis import { getMarkdownTheme, keyHint } from "@mariozechner/pi-coding-agent"; import type { CdpSession } from "../cdp/session"; import { type Box, boxOf } from "./box"; +import { cdpCall } from "./cdp-call"; import { type Result, err, ok } from "../util/result"; import { defineBrowserTool, type ToolErr, type ToolOk } from "../util/tool"; import { applyTruncation } from "../util/truncate"; @@ -319,8 +320,8 @@ export const snapshotTool = defineBrowserTool({ const session = client.session(); // 1. AX tree - const axRes = await session.call("Accessibility.getFullAXTree", {}); - if (!axRes.success) return err({ kind: "cdp_error", message: axRes.error.message }); + const axRes = await cdpCall(client, "Accessibility.getFullAXTree", {}); + if (!axRes.success) return axRes; const rawNodes = (axRes.data as { nodes: ReadonlyArray }).nodes; // 2. Page url/title -- cgit v1.2.3