claude-browser-bridge 3.0.4 → 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.
Files changed (2) hide show
  1. package/index.js +99 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -877,10 +877,89 @@ const TOOLS = [
877
877
  required: ["query"],
878
878
  },
879
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
+ },
880
959
  ];
881
960
 
882
961
  const server = new Server(
883
- { name: "browser-bridge", version: "3.0.0" },
962
+ { name: "browser-bridge", version: "4.0.0" },
884
963
  { capabilities: { tools: {} } }
885
964
  );
886
965
 
@@ -906,6 +985,25 @@ function formatResult(name, result) {
906
985
  ],
907
986
  };
908
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
+ }
909
1007
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
910
1008
  }
911
1009
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-browser-bridge",
3
- "version": "3.0.4",
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": {