claude-browser-bridge 3.0.4 → 4.0.1
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/index.js +118 -4
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -220,15 +220,17 @@ establish();
|
|
|
220
220
|
const HELP_TOOL = {
|
|
221
221
|
name: "browser_bridge_help",
|
|
222
222
|
description:
|
|
223
|
-
"Returns the complete usage guide for all
|
|
223
|
+
"Returns the complete usage guide for all 65 browser-bridge tools. Call this ONCE at the start of any session where you need to use browser tools, to learn the optimal workflows and avoid slow anti-patterns.",
|
|
224
224
|
inputSchema: { type: "object", properties: {} },
|
|
225
225
|
};
|
|
226
226
|
|
|
227
|
-
const HELP_TEXT = `# Claude Browser Bridge —
|
|
227
|
+
const HELP_TEXT = `# Claude Browser Bridge — 65 Tools
|
|
228
228
|
|
|
229
229
|
## WHICH TOOL FIRST? (decision tree)
|
|
230
230
|
- Investigating a bug → diagnose (gives snapshot + errors + network + API responses in ONE call)
|
|
231
231
|
- Fixing CSS/visual → batch([screenshot, get_styles({selector:".target"}), get_html({selector:".target"})])
|
|
232
|
+
- Debugging image layers/z-index → batch([get_element_rect({selector:".container", include_children:true}), annotate({annotations:[...]})])
|
|
233
|
+
- Checking pixel colors on images → inspect_pixel({selector:"img", x:50, y:50, percent:true})
|
|
232
234
|
- Performance check → batch([performance_trace, get_load_timeline, heap_snapshot_summary])
|
|
233
235
|
- Accessibility audit → batch([get_accessibility_tree, check_contrast({selector:".text"})])
|
|
234
236
|
- Reading page content → eval (specific data) or get_page_text (all text)
|
|
@@ -274,7 +276,19 @@ Regression Testing:
|
|
|
274
276
|
Before/After Comparison:
|
|
275
277
|
screenshot (save dataUrl) → make changes → visual_diff({before_dataUrl:"..."})
|
|
276
278
|
|
|
277
|
-
|
|
279
|
+
Image/Layer Debugging:
|
|
280
|
+
annotate({annotations:[{selector:".base",label:"Base",color:"red"},{selector:".overlay",label:"Overlay",color:"blue"}]}) → screenshot → clear_annotations
|
|
281
|
+
inspect_pixel({selector:".garment-img", x:50, y:30, percent:true}) → check if transparent or opaque
|
|
282
|
+
get_element_rect({selector:".container", include_children:true}) → see all child positions + z-indexes
|
|
283
|
+
capture_canvas({selector:".composer"}) → flatten all stacked images into one PNG
|
|
284
|
+
|
|
285
|
+
Cross-Product Comparison:
|
|
286
|
+
new_tab({url:"product-A"}) → new_tab({url:"product-B"}) → compare_tabs({tab_id_1:A, tab_id_2:B})
|
|
287
|
+
|
|
288
|
+
State Management Testing:
|
|
289
|
+
set_storage({key:"cache", action:"remove"}) → reload → verify fresh state
|
|
290
|
+
|
|
291
|
+
## ALL 65 TOOLS BY CATEGORY:
|
|
278
292
|
Core: diagnose, batch, select_tab, snapshot, eval, screenshot, full_page_screenshot, get_page_text, get_html, get_page_info, browser_bridge_help
|
|
279
293
|
Interaction: click, fill, hover, scroll, press_key, select_option, upload_file, highlight_element
|
|
280
294
|
Navigation: navigate, new_tab, close_tab, go_back, go_forward, reload, list_tabs, wait_for
|
|
@@ -284,6 +298,8 @@ Accessibility: get_accessibility_tree, check_contrast
|
|
|
284
298
|
Emulation: emulate_device, network_throttle, set_geolocation, toggle_dark_mode
|
|
285
299
|
Testing: visual_diff, inject_css, mock_network, record_actions, replay_actions, handle_dialog
|
|
286
300
|
Productivity: save_form_profile, load_form_profile, save_tab_session, restore_tab_session, edit_cookie, export_pdf
|
|
301
|
+
Visual Debugging: inspect_pixel, get_element_rect, compare_tabs, annotate, clear_annotations, capture_canvas
|
|
302
|
+
Storage: set_storage
|
|
287
303
|
`;
|
|
288
304
|
|
|
289
305
|
const BATCH_TOOL = {
|
|
@@ -877,10 +893,89 @@ const TOOLS = [
|
|
|
877
893
|
required: ["query"],
|
|
878
894
|
},
|
|
879
895
|
},
|
|
896
|
+
// =================== SESSION-REQUESTED TOOLS ===================
|
|
897
|
+
{
|
|
898
|
+
name: "inspect_pixel",
|
|
899
|
+
description: "Sample RGBA color at a specific pixel coordinate on any rendered element. Bypasses CORS restrictions on images. Use percent=true to specify x/y as percentages of the element's size (e.g. x:50, y:50 = center). Returns hex color, opacity, and element bounding box.",
|
|
900
|
+
inputSchema: {
|
|
901
|
+
type: "object",
|
|
902
|
+
properties: {
|
|
903
|
+
selector: { type: "string" }, ref: { type: "string" },
|
|
904
|
+
x: { type: "number", description: "X coordinate (pixels from element left, or percentage if percent=true)" },
|
|
905
|
+
y: { type: "number", description: "Y coordinate (pixels from element top, or percentage if percent=true)" },
|
|
906
|
+
percent: { type: "boolean", description: "If true, x/y are percentages (0-100) of the element size" },
|
|
907
|
+
...TAB_ID,
|
|
908
|
+
},
|
|
909
|
+
},
|
|
910
|
+
},
|
|
911
|
+
{
|
|
912
|
+
name: "get_element_rect",
|
|
913
|
+
description: "Get exact computed position (viewport + offset + scroll), size, z-index, visibility, opacity, and parent info for any element. Use include_children=true to also get bounding boxes of all child elements — essential for debugging stacking/layering issues.",
|
|
914
|
+
inputSchema: {
|
|
915
|
+
type: "object",
|
|
916
|
+
properties: {
|
|
917
|
+
selector: { type: "string" }, ref: { type: "string" },
|
|
918
|
+
include_children: { type: "boolean", description: "Also return child element rects (default false)" },
|
|
919
|
+
...TAB_ID,
|
|
920
|
+
},
|
|
921
|
+
},
|
|
922
|
+
},
|
|
923
|
+
{
|
|
924
|
+
name: "compare_tabs",
|
|
925
|
+
description: "Screenshot two tabs side by side and compute a pixel diff between them. Returns both screenshots plus a diff image with changes in red. Use for comparing the same page across products, environments (prod vs staging), or before/after states.",
|
|
926
|
+
inputSchema: {
|
|
927
|
+
type: "object",
|
|
928
|
+
properties: {
|
|
929
|
+
tab_id_1: { type: "number", description: "First tab to screenshot" },
|
|
930
|
+
tab_id_2: { type: "number", description: "Second tab to screenshot" },
|
|
931
|
+
},
|
|
932
|
+
required: ["tab_id_1", "tab_id_2"],
|
|
933
|
+
},
|
|
934
|
+
},
|
|
935
|
+
{
|
|
936
|
+
name: "annotate",
|
|
937
|
+
description: "Draw persistent colored borders + labels on elements for visual debugging. Annotations stay visible across screenshots — use to identify layers, z-index stacking, or mark multiple elements at once. Call clear_annotations to remove them.",
|
|
938
|
+
inputSchema: {
|
|
939
|
+
type: "object",
|
|
940
|
+
properties: {
|
|
941
|
+
selector: { type: "string" }, ref: { type: "string" },
|
|
942
|
+
label: { type: "string", description: "Text label shown above the element" },
|
|
943
|
+
color: { type: "string", description: "Border/label color (default '#D97757')" },
|
|
944
|
+
annotations: { type: "array", items: { type: "object" }, description: "Array of {selector, ref, label, color} for annotating multiple elements at once" },
|
|
945
|
+
...TAB_ID,
|
|
946
|
+
},
|
|
947
|
+
},
|
|
948
|
+
},
|
|
949
|
+
{
|
|
950
|
+
name: "clear_annotations",
|
|
951
|
+
description: "Remove all annotations drawn by the annotate tool.",
|
|
952
|
+
inputSchema: { type: "object", properties: { ...TAB_ID } },
|
|
953
|
+
},
|
|
954
|
+
{
|
|
955
|
+
name: "capture_canvas",
|
|
956
|
+
description: "Flatten stacked child images inside a container element into a single canvas capture (like the browser renders them). Returns a PNG. Use for inspecting composited garment/image layers where individual images stack via z-index.",
|
|
957
|
+
inputSchema: {
|
|
958
|
+
type: "object",
|
|
959
|
+
properties: { selector: { type: "string" }, ref: { type: "string" }, ...TAB_ID },
|
|
960
|
+
},
|
|
961
|
+
},
|
|
962
|
+
{
|
|
963
|
+
name: "set_storage",
|
|
964
|
+
description: "Write to localStorage or sessionStorage. Handles complex JSON objects safely. Use action='remove' to delete a key, action='clear' to clear all storage.",
|
|
965
|
+
inputSchema: {
|
|
966
|
+
type: "object",
|
|
967
|
+
properties: {
|
|
968
|
+
key: { type: "string" }, value: { description: "Value to set (string or JSON object)" },
|
|
969
|
+
storage_type: { type: "string", enum: ["local", "session"], description: "Default: local" },
|
|
970
|
+
action: { type: "string", enum: ["set", "remove", "clear"], description: "Default: set" },
|
|
971
|
+
...TAB_ID,
|
|
972
|
+
},
|
|
973
|
+
},
|
|
974
|
+
},
|
|
880
975
|
];
|
|
881
976
|
|
|
882
977
|
const server = new Server(
|
|
883
|
-
{ name: "browser-bridge", version: "
|
|
978
|
+
{ name: "browser-bridge", version: "4.0.0" },
|
|
884
979
|
{ capabilities: { tools: {} } }
|
|
885
980
|
);
|
|
886
981
|
|
|
@@ -906,6 +1001,25 @@ function formatResult(name, result) {
|
|
|
906
1001
|
],
|
|
907
1002
|
};
|
|
908
1003
|
}
|
|
1004
|
+
if (name === "capture_canvas" && result?.dataUrl) {
|
|
1005
|
+
const base64 = result.dataUrl.replace(/^data:image\/png;base64,/, "");
|
|
1006
|
+
const { dataUrl, ...rest } = result;
|
|
1007
|
+
return {
|
|
1008
|
+
content: [
|
|
1009
|
+
{ type: "image", data: base64, mimeType: "image/png" },
|
|
1010
|
+
{ type: "text", text: JSON.stringify(rest, null, 2) },
|
|
1011
|
+
],
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
if (name === "compare_tabs" && result?.diffImage) {
|
|
1015
|
+
const diffBase64 = result.diffImage.replace(/^data:image\/png;base64,/, "");
|
|
1016
|
+
return {
|
|
1017
|
+
content: [
|
|
1018
|
+
{ type: "text", text: `Diff: ${result.diffPercent}% changed (${result.diffPixels} pixels)` },
|
|
1019
|
+
{ type: "image", data: diffBase64, mimeType: "image/png" },
|
|
1020
|
+
],
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
909
1023
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
910
1024
|
}
|
|
911
1025
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-browser-bridge",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Connect your live Chrome tabs to Claude Code —
|
|
3
|
+
"version": "4.0.1",
|
|
4
|
+
"description": "Connect your live Chrome tabs to Claude Code — 65 tools for debugging, performance, accessibility, visual inspection, and browser automation.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"claude-browser-bridge": "./bin/cli.js"
|