chromeflow 0.1.24 → 0.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +2 -1
- package/dist/setup.js +3 -1
- package/dist/tools/browser.js +39 -1
- package/package.json +1 -1
package/CLAUDE.md
CHANGED
|
@@ -63,7 +63,8 @@ Do NOT ask "should I open the browser?" — just do it. The user expects seamles
|
|
|
63
63
|
[if fails] get_elements() — get EXACT DOM coords, use these in highlight_region
|
|
64
64
|
highlight_region(x,y,w,h,msg) — use exact coords from get_elements, not estimates
|
|
65
65
|
[after wait_for_click] get_page_text() — confirm result, NOT take_screenshot
|
|
66
|
-
[last resort only] take_screenshot() —
|
|
66
|
+
[last resort only] take_screenshot() — returns image to Claude only (no file, no clipboard)
|
|
67
|
+
take_and_copy_screenshot() — same as above BUT also saves PNG + copies to clipboard
|
|
67
68
|
d. Pause for the user when needed:
|
|
68
69
|
find_and_highlight(text, msg) — show the user what to do
|
|
69
70
|
wait_for_click() — wait for user interaction
|
package/dist/setup.js
CHANGED
|
@@ -163,7 +163,9 @@ const CHROMEFLOW_TOOLS = [
|
|
|
163
163
|
"get_form_fields",
|
|
164
164
|
"scroll_to_element",
|
|
165
165
|
"save_page_state",
|
|
166
|
-
"restore_page_state"
|
|
166
|
+
"restore_page_state",
|
|
167
|
+
// v0.1.25+
|
|
168
|
+
"take_and_copy_screenshot"
|
|
167
169
|
].map((t) => `mcp__chromeflow__${t}`);
|
|
168
170
|
function patchSettingsLocalJson(cwd) {
|
|
169
171
|
const claudeDir = join(cwd, ".claude");
|
package/dist/tools/browser.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { writeFileSync, copyFileSync } from "fs";
|
|
3
|
+
import { tmpdir, homedir } from "os";
|
|
4
|
+
import { join } from "path";
|
|
5
|
+
import { execSync } from "child_process";
|
|
2
6
|
function registerBrowserTools(server, bridge) {
|
|
3
7
|
server.tool(
|
|
4
8
|
"open_page",
|
|
@@ -46,7 +50,7 @@ ${lines.join("\n")}` }]
|
|
|
46
50
|
);
|
|
47
51
|
server.tool(
|
|
48
52
|
"take_screenshot",
|
|
49
|
-
"Capture a screenshot
|
|
53
|
+
"Capture a screenshot and return it to Claude only \u2014 no file is saved, nothing goes to the clipboard. Use ONLY when you need to visually inspect the page layout or get pixel coordinates for highlight_region. DO NOT use to check page state or confirm actions \u2014 use get_page_text for that. To also save or copy the image, use take_and_copy_screenshot instead.",
|
|
50
54
|
{},
|
|
51
55
|
async () => {
|
|
52
56
|
const response = await bridge.request({ type: "screenshot" });
|
|
@@ -68,6 +72,40 @@ ${lines.join("\n")}` }]
|
|
|
68
72
|
};
|
|
69
73
|
}
|
|
70
74
|
);
|
|
75
|
+
server.tool(
|
|
76
|
+
"take_and_copy_screenshot",
|
|
77
|
+
`Take a screenshot, return it to Claude, copy it to the system clipboard, and save it as a PNG file.
|
|
78
|
+
Use this instead of take_screenshot when you need the image outside of Claude \u2014 to paste into a chat, upload to a form, or keep as a file.
|
|
79
|
+
Unlike take_screenshot (Claude-only), this also puts the image on the clipboard and saves it to disk.
|
|
80
|
+
save_to controls where the PNG is saved: "downloads" (default) saves to ~/Downloads, "cwd" saves to Claude's current working directory.`,
|
|
81
|
+
{
|
|
82
|
+
save_to: z.enum(["downloads", "cwd"]).optional().describe(`Where to save the PNG file: "downloads" (~/Downloads, default) or "cwd" (Claude's current working directory)`)
|
|
83
|
+
},
|
|
84
|
+
async ({ save_to = "downloads" }) => {
|
|
85
|
+
const response = await bridge.request({ type: "screenshot" });
|
|
86
|
+
if (response.type !== "screenshot_response") throw new Error("Unexpected response from extension");
|
|
87
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19);
|
|
88
|
+
const filename = `chromeflow-${timestamp}.png`;
|
|
89
|
+
const imageBuffer = Buffer.from(response.image, "base64");
|
|
90
|
+
const tmpPath = join(tmpdir(), filename);
|
|
91
|
+
writeFileSync(tmpPath, imageBuffer);
|
|
92
|
+
const savePath = save_to === "cwd" ? join(process.cwd(), filename) : join(homedir(), "Downloads", filename);
|
|
93
|
+
copyFileSync(tmpPath, savePath);
|
|
94
|
+
let clipboardNote = "";
|
|
95
|
+
try {
|
|
96
|
+
execSync(`osascript -e 'set the clipboard to (read (POSIX file "${tmpPath}") as \xABclass PNGf\xBB)'`);
|
|
97
|
+
clipboardNote = "Copied to clipboard. ";
|
|
98
|
+
} catch {
|
|
99
|
+
clipboardNote = "";
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
content: [
|
|
103
|
+
{ type: "image", data: response.image, mimeType: "image/png" },
|
|
104
|
+
{ type: "text", text: `${clipboardNote}Saved to ${savePath}` }
|
|
105
|
+
]
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
);
|
|
71
109
|
server.tool(
|
|
72
110
|
"clear_overlays",
|
|
73
111
|
"Remove all highlights and callout annotations from the current page. Does NOT remove the guide panel \u2014 the guide panel persists until the next flow starts.",
|
package/package.json
CHANGED