claude-browser-bridge 3.0.3 → 4.0.0
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 +159 -30
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -224,35 +224,66 @@ const HELP_TOOL = {
|
|
|
224
224
|
inputSchema: { type: "object", properties: {} },
|
|
225
225
|
};
|
|
226
226
|
|
|
227
|
-
const HELP_TEXT = `# Claude Browser Bridge —
|
|
228
|
-
|
|
229
|
-
##
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
227
|
+
const HELP_TEXT = `# Claude Browser Bridge — 58 Tools
|
|
228
|
+
|
|
229
|
+
## WHICH TOOL FIRST? (decision tree)
|
|
230
|
+
- Investigating a bug → diagnose (gives snapshot + errors + network + API responses in ONE call)
|
|
231
|
+
- Fixing CSS/visual → batch([screenshot, get_styles({selector:".target"}), get_html({selector:".target"})])
|
|
232
|
+
- Performance check → batch([performance_trace, get_load_timeline, heap_snapshot_summary])
|
|
233
|
+
- Accessibility audit → batch([get_accessibility_tree, check_contrast({selector:".text"})])
|
|
234
|
+
- Reading page content → eval (specific data) or get_page_text (all text)
|
|
235
|
+
- Interacting with page → diagnose first (get refs), then click/fill using refs
|
|
236
|
+
- Opening a URL for research → new_tab (NEVER navigate away from the app tab)
|
|
237
|
+
- Don't know → diagnose (covers 80% of needs)
|
|
238
|
+
|
|
239
|
+
## 10 CRITICAL RULES:
|
|
240
|
+
1. diagnose FIRST, always. ONE call replaces snapshot+get_console+get_network.
|
|
241
|
+
2. batch for parallel. 2+ independent calls → always batch. Every sequential call wastes 2-3 seconds.
|
|
242
|
+
3. select_tab once, never again. Pin target tab at start, stop passing tab_id.
|
|
243
|
+
4. new_tab for research. NEVER navigate the app tab to docs/Google.
|
|
244
|
+
5. screenshot after EVERY code edit. Never claim a fix works without seeing it.
|
|
245
|
+
6. inject_css before editing files. Test CSS live, confirm with screenshot, THEN write to file.
|
|
246
|
+
7. eval for state. React state, Redux store, variables — faster than parsing page text.
|
|
247
|
+
8. get_styles for CSS. Never guess computed values — read them.
|
|
248
|
+
9. 3 failed attempts = search web. new_tab + Google search. Stop guessing.
|
|
249
|
+
10. Use refs from diagnose/snapshot for click/fill. Never guess CSS selectors.
|
|
250
|
+
|
|
251
|
+
## KEY WORKFLOWS:
|
|
252
|
+
|
|
253
|
+
Visual/CSS Fix:
|
|
254
|
+
batch([screenshot, get_styles, get_html]) → inject_css({css:"..."}) → screenshot → if good, write to file
|
|
255
|
+
|
|
256
|
+
Bug Investigation:
|
|
257
|
+
diagnose → read errors → batch([get_grouped_console, get_network]) → fix → screenshot → verify
|
|
258
|
+
|
|
259
|
+
Performance Audit:
|
|
260
|
+
batch([performance_trace, get_load_timeline, heap_snapshot_summary])
|
|
261
|
+
|
|
262
|
+
Page Interaction:
|
|
263
|
+
diagnose → fill({ref:"ref_3", value:"..."}) → click({ref:"ref_0"}) → wait_for({text:"Success"})
|
|
264
|
+
|
|
265
|
+
Multi-tab Research:
|
|
266
|
+
select_tab(app) → new_tab(docs) → get_page_text → close_tab → continue on app
|
|
267
|
+
|
|
268
|
+
Error State Testing:
|
|
269
|
+
mock_network({url_pattern:"/api/cart", status_code:500}) → reload → screenshot
|
|
270
|
+
|
|
271
|
+
Regression Testing:
|
|
272
|
+
record_actions → reproduce → stop → fix → replay_actions → screenshot
|
|
273
|
+
|
|
274
|
+
Before/After Comparison:
|
|
275
|
+
screenshot (save dataUrl) → make changes → visual_diff({before_dataUrl:"..."})
|
|
276
|
+
|
|
277
|
+
## ALL 58 TOOLS BY CATEGORY:
|
|
278
|
+
Core: diagnose, batch, select_tab, snapshot, eval, screenshot, full_page_screenshot, get_page_text, get_html, get_page_info, browser_bridge_help
|
|
279
|
+
Interaction: click, fill, hover, scroll, press_key, select_option, upload_file, highlight_element
|
|
280
|
+
Navigation: navigate, new_tab, close_tab, go_back, go_forward, reload, list_tabs, wait_for
|
|
281
|
+
Debugging: get_console, get_grouped_console, get_network, search_network_bodies, get_styles, get_cookies, get_storage, get_clipboard, watch_dom_changes, generate_selector
|
|
282
|
+
Performance: performance_trace, heap_snapshot_summary, get_load_timeline
|
|
283
|
+
Accessibility: get_accessibility_tree, check_contrast
|
|
284
|
+
Emulation: emulate_device, network_throttle, set_geolocation, toggle_dark_mode
|
|
285
|
+
Testing: visual_diff, inject_css, mock_network, record_actions, replay_actions, handle_dialog
|
|
286
|
+
Productivity: save_form_profile, load_form_profile, save_tab_session, restore_tab_session, edit_cookie, export_pdf
|
|
256
287
|
`;
|
|
257
288
|
|
|
258
289
|
const BATCH_TOOL = {
|
|
@@ -846,10 +877,89 @@ const TOOLS = [
|
|
|
846
877
|
required: ["query"],
|
|
847
878
|
},
|
|
848
879
|
},
|
|
880
|
+
// =================== SESSION-REQUESTED TOOLS ===================
|
|
881
|
+
{
|
|
882
|
+
name: "inspect_pixel",
|
|
883
|
+
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.",
|
|
884
|
+
inputSchema: {
|
|
885
|
+
type: "object",
|
|
886
|
+
properties: {
|
|
887
|
+
selector: { type: "string" }, ref: { type: "string" },
|
|
888
|
+
x: { type: "number", description: "X coordinate (pixels from element left, or percentage if percent=true)" },
|
|
889
|
+
y: { type: "number", description: "Y coordinate (pixels from element top, or percentage if percent=true)" },
|
|
890
|
+
percent: { type: "boolean", description: "If true, x/y are percentages (0-100) of the element size" },
|
|
891
|
+
...TAB_ID,
|
|
892
|
+
},
|
|
893
|
+
},
|
|
894
|
+
},
|
|
895
|
+
{
|
|
896
|
+
name: "get_element_rect",
|
|
897
|
+
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.",
|
|
898
|
+
inputSchema: {
|
|
899
|
+
type: "object",
|
|
900
|
+
properties: {
|
|
901
|
+
selector: { type: "string" }, ref: { type: "string" },
|
|
902
|
+
include_children: { type: "boolean", description: "Also return child element rects (default false)" },
|
|
903
|
+
...TAB_ID,
|
|
904
|
+
},
|
|
905
|
+
},
|
|
906
|
+
},
|
|
907
|
+
{
|
|
908
|
+
name: "compare_tabs",
|
|
909
|
+
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.",
|
|
910
|
+
inputSchema: {
|
|
911
|
+
type: "object",
|
|
912
|
+
properties: {
|
|
913
|
+
tab_id_1: { type: "number", description: "First tab to screenshot" },
|
|
914
|
+
tab_id_2: { type: "number", description: "Second tab to screenshot" },
|
|
915
|
+
},
|
|
916
|
+
required: ["tab_id_1", "tab_id_2"],
|
|
917
|
+
},
|
|
918
|
+
},
|
|
919
|
+
{
|
|
920
|
+
name: "annotate",
|
|
921
|
+
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.",
|
|
922
|
+
inputSchema: {
|
|
923
|
+
type: "object",
|
|
924
|
+
properties: {
|
|
925
|
+
selector: { type: "string" }, ref: { type: "string" },
|
|
926
|
+
label: { type: "string", description: "Text label shown above the element" },
|
|
927
|
+
color: { type: "string", description: "Border/label color (default '#D97757')" },
|
|
928
|
+
annotations: { type: "array", items: { type: "object" }, description: "Array of {selector, ref, label, color} for annotating multiple elements at once" },
|
|
929
|
+
...TAB_ID,
|
|
930
|
+
},
|
|
931
|
+
},
|
|
932
|
+
},
|
|
933
|
+
{
|
|
934
|
+
name: "clear_annotations",
|
|
935
|
+
description: "Remove all annotations drawn by the annotate tool.",
|
|
936
|
+
inputSchema: { type: "object", properties: { ...TAB_ID } },
|
|
937
|
+
},
|
|
938
|
+
{
|
|
939
|
+
name: "capture_canvas",
|
|
940
|
+
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.",
|
|
941
|
+
inputSchema: {
|
|
942
|
+
type: "object",
|
|
943
|
+
properties: { selector: { type: "string" }, ref: { type: "string" }, ...TAB_ID },
|
|
944
|
+
},
|
|
945
|
+
},
|
|
946
|
+
{
|
|
947
|
+
name: "set_storage",
|
|
948
|
+
description: "Write to localStorage or sessionStorage. Handles complex JSON objects safely. Use action='remove' to delete a key, action='clear' to clear all storage.",
|
|
949
|
+
inputSchema: {
|
|
950
|
+
type: "object",
|
|
951
|
+
properties: {
|
|
952
|
+
key: { type: "string" }, value: { description: "Value to set (string or JSON object)" },
|
|
953
|
+
storage_type: { type: "string", enum: ["local", "session"], description: "Default: local" },
|
|
954
|
+
action: { type: "string", enum: ["set", "remove", "clear"], description: "Default: set" },
|
|
955
|
+
...TAB_ID,
|
|
956
|
+
},
|
|
957
|
+
},
|
|
958
|
+
},
|
|
849
959
|
];
|
|
850
960
|
|
|
851
961
|
const server = new Server(
|
|
852
|
-
{ name: "browser-bridge", version: "
|
|
962
|
+
{ name: "browser-bridge", version: "4.0.0" },
|
|
853
963
|
{ capabilities: { tools: {} } }
|
|
854
964
|
);
|
|
855
965
|
|
|
@@ -875,6 +985,25 @@ function formatResult(name, result) {
|
|
|
875
985
|
],
|
|
876
986
|
};
|
|
877
987
|
}
|
|
988
|
+
if (name === "capture_canvas" && result?.dataUrl) {
|
|
989
|
+
const base64 = result.dataUrl.replace(/^data:image\/png;base64,/, "");
|
|
990
|
+
const { dataUrl, ...rest } = result;
|
|
991
|
+
return {
|
|
992
|
+
content: [
|
|
993
|
+
{ type: "image", data: base64, mimeType: "image/png" },
|
|
994
|
+
{ type: "text", text: JSON.stringify(rest, null, 2) },
|
|
995
|
+
],
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
if (name === "compare_tabs" && result?.diffImage) {
|
|
999
|
+
const diffBase64 = result.diffImage.replace(/^data:image\/png;base64,/, "");
|
|
1000
|
+
return {
|
|
1001
|
+
content: [
|
|
1002
|
+
{ type: "text", text: `Diff: ${result.diffPercent}% changed (${result.diffPixels} pixels)` },
|
|
1003
|
+
{ type: "image", data: diffBase64, mimeType: "image/png" },
|
|
1004
|
+
],
|
|
1005
|
+
};
|
|
1006
|
+
}
|
|
878
1007
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
879
1008
|
}
|
|
880
1009
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-browser-bridge",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Connect your live Chrome tabs to Claude Code — 57 tools for debugging, performance, accessibility, device emulation, and browser automation.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|