cdp-toolkit 3.5.0 → 3.6.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cdp-toolkit",
3
- "version": "3.5.0",
4
- "description": "A lightweight chrome-devtools-mcp alternative: an MCP server + CLI that drives the tabs you name, one target per call over one direct WebSocket, with a bounded timeout on every call, so a stuck page can't wedge your agent or force a /mcp restart. Chrome over CDP and Firefox over WebDriver BiDi, with tools a backend can't run absent from tools/list rather than throwing mid-task. 48 tools (only 5 core tools listed by default, plus search_tools/call_tool to reach the rest) including built-in network mocking, a cookie group, tab leases with human-activity detection, real HTML5 drag-and-drop, raw mouse/scroll dispatch, downloads, permission grants, and tab-to-video screen recording so several agents can drive one browser without stealing each other's tabs or a human's. No Puppeteer, no all-target fan-out.",
3
+ "version": "3.6.0",
4
+ "description": "A lightweight chrome-devtools-mcp alternative: an MCP server + CLI that drives the tabs you name, one target per call over one direct WebSocket, with a bounded timeout on every call, so a stuck page can't wedge your agent or force a /mcp restart. Chrome over CDP and Firefox over WebDriver BiDi, with tools a backend can't run absent from tools/list rather than throwing mid-task. 51 tools (only 5 core tools listed by default, plus search_tools/call_tool to reach the rest) including built-in network mocking, a cookie group, tab leases with human-activity detection, real HTML5 drag-and-drop, raw mouse/scroll dispatch, downloads, permission grants, tab-to-video screen recording, and native tab groups so several agents can drive one browser without stealing each other's tabs or a human's. No Puppeteer, no all-target fan-out.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": {
@@ -91,7 +91,8 @@
91
91
  "extract:smoke": "bun run ./test/extract-smoke.ts",
92
92
  "browser-ws:smoke": "bun run ./test/browser-ws-smoke.ts",
93
93
  "browser-ws:wedge": "bun run ./test/browser-ws-wedge.ts",
94
- "gateway:smoke": "bun run ./test/gateway-smoke.ts"
94
+ "gateway:smoke": "bun run ./test/gateway-smoke.ts",
95
+ "tab-groups:smoke": "bun run ./test/tab-groups-smoke.ts"
95
96
  },
96
97
  "devDependencies": {
97
98
  "@modelcontextprotocol/client": "^2.0.0",
package/src/cdp/driver.ts CHANGED
@@ -746,7 +746,7 @@ const CDP_CAPABILITIES: ReadonlySet<Capability> = new Set<Capability>([
746
746
  "screenshot.fullPage", "screenshot.element", "screenshot.scale", "screenshot.renderSize", "screenshot.tile", "network.intercept",
747
747
  "snapshot.accessibilityTree", "input.insertTextAtomic", "locate.text", "locate.xpath",
748
748
  "capture.screencast", "input.raw", "input.modifierClick", "input.html5Drag", "emulate.focus",
749
- "browser.downloads", "browser.permissions", "worker.targets", "frame.targets",
749
+ "browser.downloads", "browser.permissions", "browser.tabGroups", "worker.targets", "frame.targets",
750
750
  ]);
751
751
  /* ---------------------------------- PageDriver ---------------------------------- */
752
752
  class CdpPageDriver implements PageDriver {
package/src/driver.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * ADR-001: one browser-neutral Driver interface behind the 45 tools.
2
+ * ADR-001: one browser-neutral Driver interface behind the tools.
3
3
  *
4
4
  * Context. Every tool in src/tools/ is a stateless one-shot on withPage():
5
5
  * open a socket, act, always close. That is only correct because a CDP `Uid`
@@ -154,6 +154,7 @@ export type Capability =
154
154
  | "emulate.focus" // fake page focus without moving the OS window (focus_emulation / click_focus_gated); Chrome only — BiDi's emulation module has no focus primitive
155
155
  | "browser.downloads" // capture a file download to a known path (wait_for_download); Chrome, Firefox 160+
156
156
  | "browser.permissions" // grant/reset browser permissions for an origin (grant_permissions); Chrome, Firefox 160+
157
+ | "browser.tabGroups" // list/create/remove tab groups through a helper extension (list_tab_groups, group_tabs, ungroup_tabs); Chrome only, BiDi cannot reach an extension background context
157
158
  | "worker.targets" // address a service/shared worker as a target ("worker:<substr>"), incl. waking an evicted MV3 worker; Chrome only
158
159
  | "frame.targets"; // address an out-of-process (cross-origin) iframe as a target ("frame:<substr>"); Chrome only — same-site iframes are not targets at all
159
160
 
@@ -179,6 +180,9 @@ export const REQUIRED_CAPABILITIES: Partial<Record<ToolName, readonly Capability
179
180
  click_focus_gated: ["emulate.focus"],
180
181
  wait_for_download: ["browser.downloads"],
181
182
  grant_permissions: ["browser.permissions"],
183
+ list_tab_groups: ["browser.tabGroups"],
184
+ group_tabs: ["browser.tabGroups"],
185
+ ungroup_tabs: ["browser.tabGroups"],
182
186
  } as const;
183
187
 
184
188
  /* --------------------------------- errors --------------------------------- */
@@ -0,0 +1,16 @@
1
+ /**
2
+ * CDP_DENY_FOCUS: a machine-level switch that stops every tab raise, even an explicit one.
3
+ *
4
+ * Since 3.4.0 nothing raises a tab implicitly, but three opt-ins still can: new_page / claim_page
5
+ * focus:true (foreground Target.createTarget), select_page focus:true (Target.activateTarget) and
6
+ * screencast bringToFront:true (Page.bringToFront). An agent told by a hint or a skill to "use
7
+ * focus:true" then pulls the shared browser over whatever the user is doing. With
8
+ * CDP_DENY_FOCUS=1 those requests are downgraded to the background path and the result says
9
+ * focusDenied:true where the tool has a result to say it in. Default off. Read per call so tests
10
+ * can flip it.
11
+ */
12
+ const TRUTHY = new Set(["1", "true", "yes", "on"]);
13
+
14
+ export function focusDenied(): boolean {
15
+ return TRUTHY.has((process.env.CDP_DENY_FOCUS ?? "").trim().toLowerCase());
16
+ }
package/src/index.ts CHANGED
@@ -48,6 +48,8 @@ import { focusEmulation, clickFocusGated } from "./tools/focus-emulation.ts";
48
48
  // --- downloads + permissions (browser-endpoint state on a standing connection) : chrome-only, 1.8.0 Track P3 ---
49
49
  import { waitForDownload } from "./tools/downloads.ts";
50
50
  import { grantPermissions } from "./tools/permissions.ts";
51
+ // --- tab groups (chrome.tabGroups through a helper extension) : chrome-only, capability "browser.tabGroups" ---
52
+ import { listTabGroups, groupTabs, ungroupTabs } from "./tools/tab-groups.ts";
51
53
  // --- structured extraction (cleaned page HTML -> OpenAI-compatible endpoint, both backends) ---
52
54
  import { extractPage } from "./tools/extract.ts";
53
55
 
@@ -85,7 +87,7 @@ function onCdp<A>(fn: (driver: ReturnType<typeof createCdpDriver>, args: A) => P
85
87
  * named path, and `grant_permissions`, which answers permission prompts for an origin; both
86
88
  * chrome-only and both driven from a standing browser-endpoint connection, see
87
89
  * tools/browser-session.ts).
88
- * 29 + 1 + 3 + 3 + 3 + 2 + 2 + 2 + 1 (extract_page) + 2 (focus pair) = 48 entries total. Listed explicitly so the mapping is auditable at a glance and
90
+ * 29 + 1 + 3 + 3 + 3 + 2 + 2 + 2 + 1 (extract_page) + 2 (focus pair) + 3 (tab groups, tools/tab-groups.ts) = 51 entries total. Listed explicitly so the mapping is auditable at a glance and
89
91
  * the CLI can `--list` it.
90
92
  *
91
93
  * 20 of the 29 MCP-parity tools (pages/navigation/evaluate/snapshot/interaction/
@@ -159,6 +161,11 @@ export const TOOLS = {
159
161
  // connection rather than a per-call socket : see that module's header for the measurements.
160
162
  wait_for_download: waitForDownload,
161
163
  grant_permissions: grantPermissions,
164
+ // tab groups (3) : #17. CDP has no tab-group domain, so these evaluate chrome.tabGroups in a helper
165
+ // extension's service worker (installed via Extensions.loadUnpacked). chrome-only (capability "browser.tabGroups")
166
+ list_tab_groups: listTabGroups,
167
+ group_tabs: groupTabs,
168
+ ungroup_tabs: ungroupTabs,
162
169
  // structured extraction (1) : toolkit addition, both backends — a page's cleaned HTML
163
170
  // POSTed to an OpenAI-compatible /chat/completions endpoint (default: loopback
164
171
  // llm-ferry) with the caller's JSON Schema as a strict response_format, returning
package/src/manifest.ts CHANGED
@@ -819,6 +819,130 @@ export const MANIFEST: ToolSpec[] = [
819
819
  "additionalProperties": false
820
820
  }
821
821
  },
822
+ {
823
+ "name": "list_tab_groups",
824
+ "description": "List tab groups per window with member tabs (Chrome only, via a helper extension).",
825
+ "inputSchema": {
826
+ "type": "object",
827
+ "properties": {
828
+ "endpoint": {
829
+ "type": "string",
830
+ "description": "Named CDP endpoint (CDP_ENDPOINTS); default endpoint when omitted."
831
+ },
832
+ "windowId": {
833
+ "type": "integer",
834
+ "description": "Only this window."
835
+ },
836
+ "includeUngrouped": {
837
+ "type": "boolean",
838
+ "description": "Also list ungrouped tabs per window."
839
+ }
840
+ },
841
+ "required": [],
842
+ "additionalProperties": false
843
+ }
844
+ },
845
+ {
846
+ "name": "group_tabs",
847
+ "description": "Group tabs (new or existing group) and set title/color/collapsed (Chrome only).",
848
+ "inputSchema": {
849
+ "type": "object",
850
+ "properties": {
851
+ "endpoint": {
852
+ "type": "string",
853
+ "description": "Named CDP endpoint (CDP_ENDPOINTS); default endpoint when omitted."
854
+ },
855
+ "tabIds": {
856
+ "type": "array",
857
+ "items": {
858
+ "type": "integer"
859
+ },
860
+ "description": "Chrome tab ids (from list_tab_groups)."
861
+ },
862
+ "targetIds": {
863
+ "type": "array",
864
+ "items": {
865
+ "type": "string"
866
+ },
867
+ "description": "CDP target ids (list_pages ids)."
868
+ },
869
+ "urlMatch": {
870
+ "type": "string",
871
+ "description": "URL substring; matches tabs in every window."
872
+ },
873
+ "title": {
874
+ "type": "string",
875
+ "description": "Group title."
876
+ },
877
+ "color": {
878
+ "type": "string",
879
+ "enum": [
880
+ "grey",
881
+ "blue",
882
+ "red",
883
+ "yellow",
884
+ "green",
885
+ "pink",
886
+ "purple",
887
+ "cyan",
888
+ "orange"
889
+ ],
890
+ "description": "Group color."
891
+ },
892
+ "collapsed": {
893
+ "type": "boolean",
894
+ "description": "Collapse the group."
895
+ },
896
+ "groupId": {
897
+ "type": "integer",
898
+ "description": "Add to this existing group."
899
+ },
900
+ "windowId": {
901
+ "type": "integer",
902
+ "description": "Window for the new group; tabs elsewhere move there."
903
+ }
904
+ },
905
+ "required": [],
906
+ "additionalProperties": false
907
+ }
908
+ },
909
+ {
910
+ "name": "ungroup_tabs",
911
+ "description": "Remove tabs from their tab groups (Chrome only).",
912
+ "inputSchema": {
913
+ "type": "object",
914
+ "properties": {
915
+ "endpoint": {
916
+ "type": "string",
917
+ "description": "Named CDP endpoint (CDP_ENDPOINTS); default endpoint when omitted."
918
+ },
919
+ "tabIds": {
920
+ "type": "array",
921
+ "items": {
922
+ "type": "integer"
923
+ },
924
+ "description": "Chrome tab ids (from list_tab_groups)."
925
+ },
926
+ "targetIds": {
927
+ "type": "array",
928
+ "items": {
929
+ "type": "string"
930
+ },
931
+ "description": "CDP target ids (list_pages ids)."
932
+ },
933
+ "urlMatch": {
934
+ "type": "string",
935
+ "description": "URL substring; matches tabs in every window."
936
+ },
937
+ "groupId": {
938
+ "type": "integer",
939
+ "description": "Ungroup every tab of this group."
940
+ }
941
+ },
942
+ "required": [],
943
+ "additionalProperties": false
944
+ }
945
+ },
822
946
  {
823
947
  "name": "fill",
824
948
  "description": "Replace an element contents; provide exactly one of UID or selector.",
package/src/origins.ts CHANGED
@@ -29,6 +29,7 @@
29
29
  * same way. That is why the annotation on list_pages says "unknown" and never
30
30
  * "human". Never add a "human" value here.
31
31
  */
32
+ import { focusDenied } from "./focusPolicy.ts";
32
33
  import { mkdir, readFile, readdir, unlink, writeFile } from "node:fs/promises";
33
34
  import { join } from "node:path";
34
35
  import type { BrowserDriver, PageInfo } from "./driver.ts";
@@ -263,8 +264,9 @@ export async function newTrackedPage(
263
264
  backend: LeaseBackend,
264
265
  opts: { url?: string; label?: string; focus?: boolean } = {},
265
266
  ): Promise<PageInfo> {
266
- // Background by default: only an explicit focus:true may switch the user's visible tab.
267
- const page = await driver.newPage(opts.url, { focus: opts.focus === true });
267
+ // Background by default: only an explicit focus:true may switch the user's visible tab,
268
+ // and not even that under CDP_DENY_FOCUS.
269
+ const page = await driver.newPage(opts.url, { focus: opts.focus === true && !focusDenied() });
268
270
  await recordOrigin(backend, page.id, { label: opts.label });
269
271
  return page;
270
272
  }
package/src/policy.ts CHANGED
@@ -98,6 +98,10 @@ export const MUTATING_TOOLS: ReadonlySet<string> = new Set([
98
98
  "click_focus_gated",
99
99
  "wait_for_download", // borderline: Browser.setDownloadBehavior / BiDi browser.setDownloadBehavior changes browser state
100
100
  "grant_permissions", // Browser.grantPermissions / BiDi permissions.setPermission
101
+ // tab groups: all three install the helper extension (Extensions.loadUnpacked), even the listing
102
+ "list_tab_groups",
103
+ "group_tabs",
104
+ "ungroup_tabs",
101
105
  // leases: claim installs an activity beacon in the page and writes a lease; release can close a tab
102
106
  "claim_page",
103
107
  "release_page",
@@ -33,6 +33,7 @@
33
33
  * format (new feature work, not a safety-preserving migration). Per the explicit instruction that
34
34
  * behavior outranks the abstraction, these 7 stay two implementations; see the migration report.
35
35
  */
36
+ import { focusDenied } from "./focusPolicy.ts";
36
37
  import { mkdir, writeFile } from "node:fs/promises";
37
38
  import { dirname, join } from "node:path";
38
39
  import type {
@@ -402,13 +403,17 @@ async function listPagesOne(
402
403
  export async function newPage(
403
404
  driver: BrowserDriver,
404
405
  args: { url?: string; claim?: boolean; label?: string; ttlMs?: number; focus?: boolean } = {},
405
- ): Promise<{ targetId: string; url: string; hidden?: true; lease?: LeaseToken; label?: string; expiresAt?: number }> {
406
+ ): Promise<{ targetId: string; url: string; hidden?: true; focusDenied?: true; lease?: LeaseToken; label?: string; expiresAt?: number }> {
406
407
  const label = typeof args.label === "string" && args.label.length ? args.label : defaultLabel();
407
408
  // Creates the tab AND writes its creation record. The record outlives any
408
409
  // lease taken below, which is the point: a released tab is still an agent's.
409
410
  const p = await newTrackedPage(driver, backendOf(driver), { url: args.url, label, focus: args.focus === true });
410
411
  // Present only for a hidden tab (CDP_HIDDEN_TABS), so the default output is byte-identical.
411
- const hidden = p.hidden === true ? { hidden: true as const } : {};
412
+ const hidden = {
413
+ ...(p.hidden === true ? { hidden: true as const } : {}),
414
+ // Present only when a focus:true was refused (CDP_DENY_FOCUS), so the default output is unchanged.
415
+ ...(args.focus === true && focusDenied() ? { focusDenied: true as const } : {}),
416
+ };
412
417
  // Under strict mode a tab nobody holds is a tab nobody may drive, so creating
413
418
  // one without claiming it would hand back a target the very next call has to
414
419
  // auto-acquire anyway. Doing it here means the tab is never briefly unowned
@@ -476,12 +481,12 @@ async function writeSelectedFile(id: string): Promise<void> {
476
481
  export async function selectPage(
477
482
  driver: BrowserDriver,
478
483
  args: { target?: TargetSelector; focus?: boolean },
479
- ): Promise<{ selected: string; focused: boolean; revealedFrom?: string; lease?: LeaseToken }> {
484
+ ): Promise<{ selected: string; focused: boolean; focusDenied?: true; revealedFrom?: string; lease?: LeaseToken }> {
480
485
  if (args.target === undefined || args.target === "") throw new SharedToolError("select_page requires an explicit target");
481
486
  const p = await resolvePage(driver, args.target);
482
- if (args.focus !== true) {
487
+ if (args.focus !== true || focusDenied()) {
483
488
  await writeSelectedFile(p.id);
484
- return { selected: p.id, focused: false };
489
+ return { selected: p.id, focused: false, ...(args.focus === true ? { focusDenied: true as const } : {}) };
485
490
  }
486
491
  const shown = await driver.activatePage(p.id);
487
492
  if (shown.revealedFrom === undefined || shown.id === p.id) {
@@ -1225,7 +1230,7 @@ export async function pressKey(driver: BrowserDriver, args: { target?: TargetSel
1225
1230
  if (res && res.delivered === false) {
1226
1231
  return {
1227
1232
  pressed: args.key, modifiers, delivered: false,
1228
- note: "the page saw no keydown: a background tab gets no trusted keyboard input. A click on the tab's page (click tool) usually gives it focus so keys land; or open the tab with new_page focus:true. A key handled inside a cross-origin iframe also reads as not delivered.",
1233
+ note: "the page saw no keydown: a background tab gets no trusted keyboard input. A click on the tab's page (click tool) usually gives it focus so keys land; or open the tab with new_page focus:true (which raises the browser over the user's work; refused under CDP_DENY_FOCUS). A key handled inside a cross-origin iframe also reads as not delivered.",
1229
1234
  };
1230
1235
  }
1231
1236
  return { pressed: args.key, modifiers };
package/src/toolDocs.ts CHANGED
@@ -217,6 +217,38 @@ export const TOOL_DOCS: Record<string, ToolDoc> = {
217
217
  "reset": "Clear this server's previous permission grants (Browser.resetPermissions). With 'permissions' it resets FIRST and then grants, so the result is exactly the listed permissions; on its own it is a reset-only call answering {reset:true}. Not scoped to 'origin': CDP resets every origin at once."
218
218
  }
219
219
  },
220
+ "list_tab_groups": {
221
+ "description": "Lists the browser's tab groups, per window: {windows:[{windowId,tabCount,ungrouped,groups:[{groupId,title,color,collapsed,tabs:[{tabId,targetId,index,url,title}]}]}],groupCount,tabCount}; includeUngrouped:true adds each window's ungroupedTabs rows. targetId is the tab's CDP target id (the id list_pages shows), so a row can be driven by the other tools directly. CDP has no tab-group domain, so the three tab-group tools run chrome.tabGroups inside a tiny helper extension: the first call writes it under the artifact dir (tab-groups-helper/) and installs it with Extensions.loadUnpacked, and it stays installed in the profile afterwards (no UI, no state). That needs the helper directory on the browser's own machine and a Chromium that allows loadUnpacked over CDP (measured: Chromium 156-158, Helium, Vivaldi). Classified as changing state for read-only endpoints because of that install. Chrome only (capability 'browser.tabGroups'): absent under Firefox, whose BiDi cannot reach an extension background context.",
222
+ "params": {
223
+ "endpoint": "Name of a CDP endpoint configured with CDP_ENDPOINTS (Chrome only); acts on that browser instead of the default. These tools take no target.",
224
+ "windowId": "Only this chrome window id (from an earlier listing).",
225
+ "includeUngrouped": "Also return each window's ungrouped tabs as ungroupedTabs rows (same shape as group members), not just the ungrouped count. Default false."
226
+ }
227
+ },
228
+ "group_tabs": {
229
+ "description": "Puts tabs in a tab group and names it. Select tabs with EXACTLY ONE of tabIds (chrome tab ids from list_tab_groups), targetIds (CDP target ids, as list_pages shows them) or urlMatch (URL substring, matched in every window); a selection that matches nothing, or an unknown id, is an error and nothing is grouped. Without groupId a NEW group is created; with groupId the tabs join that existing group (its title/color are kept unless given). WINDOWS: a group lives in one window. If the selected tabs span several windows the call is REFUSED unless windowId names the destination, because Chrome would otherwise move them all into the last-focused window; with windowId, tabs from other windows are moved there and listed in 'moved'. groupId and windowId are mutually exclusive. title, color (grey|blue|red|yellow|green|pink|purple|cyan|orange) and collapsed are applied after grouping. Returns {groupId,windowId,title,color,collapsed,tabs,moved}. Never raises or focuses a window. Does not consult tab leases: grouping moves a tab in the tab strip, not the page. Helper-extension install and limits: see list_tab_groups. Chrome only (capability 'browser.tabGroups').",
230
+ "params": {
231
+ "endpoint": "Name of a CDP endpoint configured with CDP_ENDPOINTS (Chrome only). These tools take no target.",
232
+ "tabIds": "Chrome tab ids to group, from list_tab_groups. Non-empty.",
233
+ "targetIds": "CDP target ids to group (the ids list_pages shows). Non-empty.",
234
+ "urlMatch": "Substring of the tab URL; every matching tab in every window is selected.",
235
+ "title": "Group title shown on the tab strip.",
236
+ "color": "One of grey, blue, red, yellow, green, pink, purple, cyan, orange.",
237
+ "collapsed": "Collapse (true) or expand (false) the group.",
238
+ "groupId": "Add the tabs to this existing group instead of creating one. Not with windowId.",
239
+ "windowId": "Window the new group goes in; selected tabs in other windows are moved there. Required when the selection spans windows. Not with groupId."
240
+ }
241
+ },
242
+ "ungroup_tabs": {
243
+ "description": "Removes tabs from their tab groups; a group left with no tabs disappears. Select with EXACTLY ONE of tabIds, targetIds, urlMatch (as group_tabs) or groupId (every tab of that group). Tabs stay where they are in the window. Returns {ungrouped:[{tabId,targetId,index,url,title,fromGroupId}],alreadyUngrouped:[tabId]}; selected tabs that were in no group are listed in alreadyUngrouped rather than treated as an error. Helper-extension install and limits: see list_tab_groups. Chrome only (capability 'browser.tabGroups').",
244
+ "params": {
245
+ "endpoint": "Name of a CDP endpoint configured with CDP_ENDPOINTS (Chrome only). These tools take no target.",
246
+ "tabIds": "Chrome tab ids to ungroup.",
247
+ "targetIds": "CDP target ids to ungroup.",
248
+ "urlMatch": "Substring of the tab URL; matching tabs in every window are ungrouped.",
249
+ "groupId": "Ungroup every tab of this group."
250
+ }
251
+ },
220
252
  "fill": {
221
253
  "description": "Fills an element by focusing it, clearing existing content, then inserting value via Input.insertText (atomic paste-like commit, not per-character keystrokes, so it won't fire per-keypress handlers). Give exactly one of uid or selector. Returns {filled,element,value}; element names the field (textbox \"Email\"). On a background tab (Chrome), which gets no trusted keyboard input, the commit is verified and falls back in-page (execCommand insertText, else the native value setter plus input/change events); the result then carries inputPath. The tab is never raised.",
222
254
  "params": {
package/src/toolGroups.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export const TOOL_GROUPS = [
2
2
  "core", "input", "cookies", "network", "console", "mocking",
3
3
  "emulation", "performance", "recording", "leases", "permissions",
4
- "dialogs", "downloads", "extraction",
4
+ "dialogs", "downloads", "extraction", "tabs",
5
5
  ] as const;
6
6
 
7
7
  export type ToolGroup = (typeof TOOL_GROUPS)[number];
@@ -32,6 +32,7 @@ export const GROUP_TOOLS: Record<ToolGroup, readonly string[]> = {
32
32
  dialogs: ["handle_dialog"],
33
33
  downloads: ["wait_for_download"],
34
34
  extraction: ["extract_page"],
35
+ tabs: ["list_tab_groups", "group_tabs", "ungroup_tabs"],
35
36
  } as const;
36
37
 
37
38
  export const TOOL_GROUP: Record<string, ToolGroup> = {};
@@ -50,6 +50,7 @@
50
50
  * shell-out shape lighthouse.ts uses. No Bun.* APIs anywhere (dist/ is bundled
51
51
  * to node ESM).
52
52
  */
53
+ import { focusDenied } from "../focusPolicy.ts";
53
54
  import { spawn } from "node:child_process";
54
55
  import { mkdir, rm, stat, writeFile } from "node:fs/promises";
55
56
  import { join } from "node:path";
@@ -597,7 +598,8 @@ export async function startScreenRecording(args: StartScreenRecordingArgs = {}):
597
598
 
598
599
  try {
599
600
  await conn.send("Page.enable");
600
- if (args.bringToFront) await conn.send("Page.bringToFront").catch(() => {});
601
+ // CDP_DENY_FOCUS refuses the raise; the 0-frame error below still explains a silent tab.
602
+ if (args.bringToFront && !focusDenied()) await conn.send("Page.bringToFront").catch(() => {});
601
603
  const params: Record<string, unknown> = { format };
602
604
  if (format === "jpeg" && args.quality !== undefined) params.quality = args.quality;
603
605
  if (args.maxWidth !== undefined) params.maxWidth = args.maxWidth;