aboutsummaryrefslogtreecommitdiff
path: root/src/domains/click.ts
diff options
context:
space:
mode:
authoramankumarsingh77 <amankumarsingh7702@gmal.com>2026-05-02 16:20:09 +0530
committeramankumarsingh77 <amankumarsingh7702@gmal.com>2026-05-02 16:20:09 +0530
commit6708da54b1805756908dea84bf65fe73ab03426a (patch)
tree95e144b83d69af9918321f2e3faf29c5a8bfad17 /src/domains/click.ts
parent9ead6a0577b750bc3ae3f36a7e8bfe108e979925 (diff)
feat(domains): migrate screenshot, add typed sharp shim, restore click crosshair overlay
Diffstat (limited to 'src/domains/click.ts')
-rw-r--r--src/domains/click.ts16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/domains/click.ts b/src/domains/click.ts
index b3aa80a..c269dd8 100644
--- a/src/domains/click.ts
+++ b/src/domains/click.ts
@@ -1,11 +1,10 @@
-import { writeFile } from "node:fs/promises";
import { Type, type Static } from "typebox";
import { Text } from "@mariozechner/pi-tui";
import type { BrowserClient } from "../client";
import { Coords, MouseButton } from "../schemas/common";
-import { screenshotPath } from "../util/paths";
import { type Result, err, ok } from "../util/result";
import { defineBrowserTool, type ToolErr } from "../util/tool";
+import { captureWithCrosshair } from "./screenshot";
const ClickArgs = Type.Object({
...Coords.properties,
@@ -58,16 +57,11 @@ export const clickTool = defineBrowserTool({
const clicked = await dispatchClick(client, args);
if (!clicked.success) return clicked;
if (process.env["BH_DEBUG_CLICKS"]) {
- // Plain screenshot for now; the crosshair overlay returns in Task 14
- // (domains/screenshot.ts) once sharp-shim lands.
- const path = screenshotPath(client.namespace, "png");
- const shot = await client.session().call("Page.captureScreenshot", { format: "png" });
- if (shot.success) {
- const data = (shot.data as { data: string }).data;
- await writeFile(path, Buffer.from(data, "base64"));
+ const debug = await captureWithCrosshair(client, { x: args.x, y: args.y });
+ if (debug.success) {
return ok({
- text: `Clicked at (${args.x}, ${args.y})\n[DEBUG] Screenshot: ${path}`,
- details: { debugScreenshotPath: path, x: args.x, y: args.y },
+ text: `Clicked at (${args.x}, ${args.y})\n[DEBUG] Overlay screenshot: ${debug.data.path}`,
+ details: { debugScreenshotPath: debug.data.path, x: args.x, y: args.y },
});
}
}