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/dist/cli.js CHANGED
@@ -591,6 +591,15 @@ var init_leases = __esm(() => {
591
591
  LEASE_FILE_RE = new RegExp(`^lease-(${BACKEND_KEY_SOURCE})-(.+)\\.json$`);
592
592
  });
593
593
 
594
+ // src/focusPolicy.ts
595
+ function focusDenied() {
596
+ return TRUTHY.has((process.env.CDP_DENY_FOCUS ?? "").trim().toLowerCase());
597
+ }
598
+ var TRUTHY;
599
+ var init_focusPolicy = __esm(() => {
600
+ TRUTHY = new Set(["1", "true", "yes", "on"]);
601
+ });
602
+
594
603
  // src/origins.ts
595
604
  import { mkdir as mkdir2, readFile as readFile2, readdir as readdir2, unlink as unlink2, writeFile as writeFile2 } from "node:fs/promises";
596
605
  import { join as join2 } from "node:path";
@@ -690,7 +699,7 @@ async function originIndex(backend, liveIds) {
690
699
  return index;
691
700
  }
692
701
  async function newTrackedPage(driver, backend, opts = {}) {
693
- const page = await driver.newPage(opts.url, { focus: opts.focus === true });
702
+ const page = await driver.newPage(opts.url, { focus: opts.focus === true && !focusDenied() });
694
703
  await recordOrigin(backend, page.id, { label: opts.label });
695
704
  return page;
696
705
  }
@@ -717,6 +726,7 @@ async function resolveLiveLabel(backend, label, liveIds) {
717
726
  }
718
727
  var ORIGIN_FILE_RE;
719
728
  var init_origins = __esm(() => {
729
+ init_focusPolicy();
720
730
  init_leases();
721
731
  ORIGIN_FILE_RE = new RegExp(`^origin-(${BACKEND_KEY_SOURCE})-(.+)\\.json$`);
722
732
  });
@@ -1006,7 +1016,7 @@ var init_session = __esm(() => {
1006
1016
 
1007
1017
  // src/cdp/hiddenTabs.ts
1008
1018
  function hiddenTabsRequested() {
1009
- return TRUTHY.has((process.env.CDP_HIDDEN_TABS ?? "").trim().toLowerCase());
1019
+ return TRUTHY2.has((process.env.CDP_HIDDEN_TABS ?? "").trim().toLowerCase());
1010
1020
  }
1011
1021
  function hiddenTabsMax() {
1012
1022
  const raw = Number(process.env.CDP_HIDDEN_TABS_MAX);
@@ -1145,10 +1155,10 @@ async function disposeHiddenTabs() {
1145
1155
  owners.clear();
1146
1156
  await Promise.all(all.map((o) => o.dispose()));
1147
1157
  }
1148
- var DEFAULT_HIDDEN_TABS_MAX = 20, HIDDEN_TAB_VIEWPORT, FALLBACK_DEVICE_SCALE_FACTOR = 2, OWNER_COMMAND_TIMEOUT_MS = 5000, TRUTHY, HiddenTabCapError, owners;
1158
+ var DEFAULT_HIDDEN_TABS_MAX = 20, HIDDEN_TAB_VIEWPORT, FALLBACK_DEVICE_SCALE_FACTOR = 2, OWNER_COMMAND_TIMEOUT_MS = 5000, TRUTHY2, HiddenTabCapError, owners;
1149
1159
  var init_hiddenTabs = __esm(() => {
1150
1160
  HIDDEN_TAB_VIEWPORT = { width: 1280, height: 800 };
1151
- TRUTHY = new Set(["1", "true", "yes", "on"]);
1161
+ TRUTHY2 = new Set(["1", "true", "yes", "on"]);
1152
1162
  HiddenTabCapError = class HiddenTabCapError extends Error {
1153
1163
  max;
1154
1164
  openIds;
@@ -1892,7 +1902,10 @@ var init_driver = __esm(() => {
1892
1902
  focus_emulation: ["emulate.focus"],
1893
1903
  click_focus_gated: ["emulate.focus"],
1894
1904
  wait_for_download: ["browser.downloads"],
1895
- grant_permissions: ["browser.permissions"]
1905
+ grant_permissions: ["browser.permissions"],
1906
+ list_tab_groups: ["browser.tabGroups"],
1907
+ group_tabs: ["browser.tabGroups"],
1908
+ ungroup_tabs: ["browser.tabGroups"]
1896
1909
  };
1897
1910
  });
1898
1911
 
@@ -2410,16 +2423,16 @@ var init_client2 = __esm(() => {
2410
2423
  });
2411
2424
 
2412
2425
  // src/bidi/session-lease.ts
2413
- import { mkdir as mkdir13, readFile as readFile9, rename as rename3, unlink as unlink5, writeFile as writeFile10 } from "node:fs/promises";
2414
- import { join as join12 } from "node:path";
2426
+ import { mkdir as mkdir14, readFile as readFile10, rename as rename3, unlink as unlink5, writeFile as writeFile11 } from "node:fs/promises";
2427
+ import { join as join13 } from "node:path";
2415
2428
  function safeEndpoint(endpoint) {
2416
2429
  return endpoint.replace(/[^A-Za-z0-9._-]/g, "_");
2417
2430
  }
2418
2431
  function sessionSlotFile(endpoint) {
2419
- return join12(leaseDir(), `ff-session-${safeEndpoint(endpoint)}.json`);
2432
+ return join13(leaseDir(), `ff-session-${safeEndpoint(endpoint)}.json`);
2420
2433
  }
2421
2434
  function muxDaemonLogFile(endpoint) {
2422
- return join12(leaseDir(), `ff-mux-${safeEndpoint(endpoint)}.log`);
2435
+ return join13(leaseDir(), `ff-mux-${safeEndpoint(endpoint)}.log`);
2423
2436
  }
2424
2437
  function sessionWaitMs() {
2425
2438
  const raw = Number(process.env.CDP_FIREFOX_SESSION_WAIT_MS);
@@ -2428,7 +2441,7 @@ function sessionWaitMs() {
2428
2441
  async function readSessionSlot(endpoint) {
2429
2442
  let raw;
2430
2443
  try {
2431
- raw = await readFile9(sessionSlotFile(endpoint), "utf8");
2444
+ raw = await readFile10(sessionSlotFile(endpoint), "utf8");
2432
2445
  } catch (err) {
2433
2446
  if (err.code === "ENOENT")
2434
2447
  return;
@@ -2457,7 +2470,7 @@ async function acquireSessionSlot(endpoint, opts) {
2457
2470
  record.marionettePort = opts.marionettePort;
2458
2471
  const handle = { endpoint, pid: process.pid, createdAt };
2459
2472
  const payload = JSON.stringify(record);
2460
- await mkdir13(leaseDir(), { recursive: true });
2473
+ await mkdir14(leaseDir(), { recursive: true });
2461
2474
  const deadline = Date.now() + waitMs;
2462
2475
  const maxAttempts = Math.max(100, Math.ceil(waitMs / pollMs) + 100);
2463
2476
  let attempts = 0;
@@ -2467,7 +2480,7 @@ async function acquireSessionSlot(endpoint, opts) {
2467
2480
  throw new SessionSlotBusyError(endpoint, lastLiveHolder);
2468
2481
  attempts++;
2469
2482
  try {
2470
- await writeFile10(file, payload, { flag: "wx" });
2483
+ await writeFile11(file, payload, { flag: "wx" });
2471
2484
  return { handle };
2472
2485
  } catch (err) {
2473
2486
  if (err.code !== "EEXIST")
@@ -2481,7 +2494,7 @@ async function acquireSessionSlot(endpoint, opts) {
2481
2494
  return;
2482
2495
  });
2483
2496
  try {
2484
- await writeFile10(file, payload, { flag: "wx" });
2497
+ await writeFile11(file, payload, { flag: "wx" });
2485
2498
  return { handle, staleHolder: holder };
2486
2499
  } catch (err) {
2487
2500
  if (err.code !== "EEXIST")
@@ -2509,7 +2522,7 @@ async function advertiseMux(handle, muxEndpoint) {
2509
2522
  const tmp = `${file}.tmp-${process.pid}`;
2510
2523
  const next = { ...current, muxEndpoint };
2511
2524
  try {
2512
- await writeFile10(tmp, JSON.stringify(next), "utf8");
2525
+ await writeFile11(tmp, JSON.stringify(next), "utf8");
2513
2526
  await rename3(tmp, file);
2514
2527
  } catch {
2515
2528
  await unlink5(tmp).catch(() => {
@@ -2555,9 +2568,9 @@ var init_session_lease = __esm(() => {
2555
2568
 
2556
2569
  // src/bidi/mux.ts
2557
2570
  import { createServer } from "node:net";
2558
- import { createHash } from "node:crypto";
2571
+ import { createHash as createHash2 } from "node:crypto";
2559
2572
  function acceptKey(key) {
2560
- return createHash("sha1").update(key + WS_GUID).digest("base64");
2573
+ return createHash2("sha1").update(key + WS_GUID).digest("base64");
2561
2574
  }
2562
2575
  function encodeFrame(opcode, payload) {
2563
2576
  const len = payload.length;
@@ -5207,6 +5220,7 @@ var CDP_CAPABILITIES = new Set([
5207
5220
  "emulate.focus",
5208
5221
  "browser.downloads",
5209
5222
  "browser.permissions",
5223
+ "browser.tabGroups",
5210
5224
  "worker.targets",
5211
5225
  "frame.targets"
5212
5226
  ]);
@@ -6119,6 +6133,7 @@ async function reapStaleAgentTabs(driver, backend) {
6119
6133
  }
6120
6134
 
6121
6135
  // src/shared-tools.ts
6136
+ init_focusPolicy();
6122
6137
  init_driver();
6123
6138
  import { mkdir as mkdir5, writeFile as writeFile4 } from "node:fs/promises";
6124
6139
  import { dirname as dirname2, join as join5 } from "node:path";
@@ -6802,7 +6817,10 @@ async function listPagesOne(driver, args = {}) {
6802
6817
  async function newPage(driver, args = {}) {
6803
6818
  const label = typeof args.label === "string" && args.label.length ? args.label : defaultLabel();
6804
6819
  const p = await newTrackedPage(driver, backendOf(driver), { url: args.url, label, focus: args.focus === true });
6805
- const hidden = p.hidden === true ? { hidden: true } : {};
6820
+ const hidden = {
6821
+ ...p.hidden === true ? { hidden: true } : {},
6822
+ ...args.focus === true && focusDenied() ? { focusDenied: true } : {}
6823
+ };
6806
6824
  const explicit = args.claim === true;
6807
6825
  if (!explicit && !requireLease())
6808
6826
  return { targetId: p.id, url: p.url, ...hidden };
@@ -6833,9 +6851,9 @@ async function selectPage(driver, args) {
6833
6851
  if (args.target === undefined || args.target === "")
6834
6852
  throw new SharedToolError("select_page requires an explicit target");
6835
6853
  const p = await resolvePage(driver, args.target);
6836
- if (args.focus !== true) {
6854
+ if (args.focus !== true || focusDenied()) {
6837
6855
  await writeSelectedFile(p.id);
6838
- return { selected: p.id, focused: false };
6856
+ return { selected: p.id, focused: false, ...args.focus === true ? { focusDenied: true } : {} };
6839
6857
  }
6840
6858
  const shown = await driver.activatePage(p.id);
6841
6859
  if (shown.revealedFrom === undefined || shown.id === p.id) {
@@ -7270,7 +7288,7 @@ async function pressKey(driver, args) {
7270
7288
  pressed: args.key,
7271
7289
  modifiers,
7272
7290
  delivered: false,
7273
- 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."
7291
+ 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."
7274
7292
  };
7275
7293
  }
7276
7294
  return { pressed: args.key, modifiers };
@@ -8272,6 +8290,7 @@ async function performanceAnalyzeInsight(args = {}) {
8272
8290
  }
8273
8291
 
8274
8292
  // src/tools/screencast.ts
8293
+ init_focusPolicy();
8275
8294
  init_client();
8276
8295
  import { spawn } from "node:child_process";
8277
8296
  import { mkdir as mkdir8, rm as rm2, stat as stat2, writeFile as writeFile7 } from "node:fs/promises";
@@ -8572,7 +8591,7 @@ async function startScreenRecording(args = {}) {
8572
8591
  });
8573
8592
  try {
8574
8593
  await conn.send("Page.enable");
8575
- if (args.bringToFront)
8594
+ if (args.bringToFront && !focusDenied())
8576
8595
  await conn.send("Page.bringToFront").catch(() => {});
8577
8596
  const params = { format };
8578
8597
  if (format === "jpeg" && args.quality !== undefined)
@@ -9218,11 +9237,302 @@ async function grantPermissions(args = {}) {
9218
9237
  return { granted: [...permissions], origin, ...reset ? { reset: true } : {}, target };
9219
9238
  }
9220
9239
 
9221
- // src/tools/extract.ts
9240
+ // src/tools/tab-groups.ts
9222
9241
  init_client();
9223
- import { mkdir as mkdir12, writeFile as writeFile9 } from "node:fs/promises";
9224
- import { dirname as dirname3, join as join11 } from "node:path";
9242
+ import { createHash } from "node:crypto";
9243
+ import { mkdir as mkdir12, readFile as readFile9, writeFile as writeFile9 } from "node:fs/promises";
9244
+ import { join as join11 } from "node:path";
9225
9245
  var ARTIFACT_DIR7 = process.env.CDP_ARTIFACT_DIR ?? "/tmp/cdp-toolkit";
9246
+ var HELPER_DIR = join11(ARTIFACT_DIR7, "tab-groups-helper");
9247
+ var TAB_GROUP_COLORS = ["grey", "blue", "red", "yellow", "green", "pink", "purple", "cyan", "orange"];
9248
+ var HELPER_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqesYyi7LmBxzWP7VFJGlH2khinCz0uU2z3KNDvZ3Kb8gTLPpthgRWp27pu5/Wk2nvQJdcrunf6u5vqomH2xhvXIqjgXtth2o1GrE6oJMWRUqEoC7I4YUXdSieRpxAxtG37KiSFOyFOU59Som3gGOM2j1qlQIsID0QwRCeRs095SLoTtkA6YwZxtOETgvZAhbbpkmYwkXjTzgY85sS1JfMYj67cmfyz/Nt6yfORSJYEmWAfGCjQnvtOn9TjCazZvmoASUhsKZNZVWckAg+Md+ZKBPbl14/UUwLmWHQ7SDcJozHZtFeLFXySwvmBm3NhP1rK5vd/v+modsQY3M3DbqLQIDAQAB";
9249
+ var HELPER_MANIFEST = {
9250
+ manifest_version: 3,
9251
+ name: "cdp-toolkit tab groups",
9252
+ description: "Helper installed by cdp-toolkit's tab-group tools (list_tab_groups, group_tabs, ungroup_tabs). No UI, no state.",
9253
+ version: "1.0.0",
9254
+ key: HELPER_KEY,
9255
+ permissions: ["tabs", "tabGroups", "debugger"],
9256
+ background: { service_worker: "sw.js" }
9257
+ };
9258
+ function extensionIdFromKey(keyBase64) {
9259
+ const hex = createHash("sha256").update(Buffer.from(keyBase64, "base64")).digest("hex").slice(0, 32);
9260
+ return [...hex].map((c) => String.fromCharCode(97 + parseInt(c, 16))).join("");
9261
+ }
9262
+ var HELPER_EXTENSION_ID = extensionIdFromKey(HELPER_KEY);
9263
+ var HELPER_SW_BODY = String.raw`
9264
+ const NONE = -1;
9265
+
9266
+ async function targetIdsByTab() {
9267
+ const m = new Map();
9268
+ try {
9269
+ for (const t of await chrome.debugger.getTargets()) {
9270
+ if (t.type === "page" && typeof t.tabId === "number") m.set(t.tabId, t.id);
9271
+ }
9272
+ } catch (e) {
9273
+ // No mapping is a degraded answer (rows lack targetId), not a failure of the listing.
9274
+ }
9275
+ return m;
9276
+ }
9277
+
9278
+ function row(t, m) {
9279
+ return { tabId: t.id, targetId: m.get(t.id), index: t.index, url: t.url || t.pendingUrl || "", title: t.title || "" };
9280
+ }
9281
+
9282
+ const byPlace = (a, b) => a.windowId - b.windowId || a.index - b.index;
9283
+
9284
+ async function list(args) {
9285
+ const q = args && args.windowId !== undefined ? { windowId: args.windowId } : {};
9286
+ const [tabs, groups, m] = await Promise.all([chrome.tabs.query(q), chrome.tabGroups.query(q), targetIdsByTab()]);
9287
+ const wins = new Map();
9288
+ for (const t of tabs.slice().sort(byPlace)) {
9289
+ let w = wins.get(t.windowId);
9290
+ if (!w) wins.set(t.windowId, (w = { windowId: t.windowId, tabCount: 0, ungrouped: 0, groups: [] }));
9291
+ w.tabCount++;
9292
+ if (t.groupId === NONE || t.groupId === undefined) {
9293
+ w.ungrouped++;
9294
+ if (args && args.includeUngrouped) (w.ungroupedTabs || (w.ungroupedTabs = [])).push(row(t, m));
9295
+ continue;
9296
+ }
9297
+ let g = w.groups.find((x) => x.groupId === t.groupId);
9298
+ if (!g) {
9299
+ const info = groups.find((x) => x.id === t.groupId) || {};
9300
+ g = { groupId: t.groupId, title: info.title || "", color: info.color, collapsed: !!info.collapsed, tabs: [] };
9301
+ w.groups.push(g);
9302
+ }
9303
+ g.tabs.push(row(t, m));
9304
+ }
9305
+ const windows = [...wins.values()];
9306
+ return {
9307
+ windows,
9308
+ groupCount: windows.reduce((n, w) => n + w.groups.length, 0),
9309
+ tabCount: tabs.length,
9310
+ };
9311
+ }
9312
+
9313
+ async function selectTabs(args, m) {
9314
+ if (Array.isArray(args.tabIds)) {
9315
+ const out = [];
9316
+ for (const id of args.tabIds) {
9317
+ try { out.push(await chrome.tabs.get(id)); }
9318
+ catch (e) { throw new Error("no tab with tabId " + id + " (tab ids come from list_tab_groups)"); }
9319
+ }
9320
+ return out;
9321
+ }
9322
+ if (Array.isArray(args.targetIds)) {
9323
+ const byTarget = new Map([...m].map(([tabId, targetId]) => [targetId, tabId]));
9324
+ const out = [];
9325
+ for (const tid of args.targetIds) {
9326
+ const id = byTarget.get(tid);
9327
+ if (id === undefined) throw new Error("no tab with targetId " + tid + " (a page's CDP target id, as list_pages shows it)");
9328
+ out.push(await chrome.tabs.get(id));
9329
+ }
9330
+ return out;
9331
+ }
9332
+ const all = (await chrome.tabs.query({})).sort(byPlace);
9333
+ if (typeof args.urlMatch === "string") {
9334
+ const hit = all.filter((t) => (t.url || "").includes(args.urlMatch) || (t.pendingUrl || "").includes(args.urlMatch));
9335
+ if (!hit.length) throw new Error("urlMatch " + JSON.stringify(args.urlMatch) + " matched no tab");
9336
+ return hit;
9337
+ }
9338
+ if (typeof args.groupId === "number") {
9339
+ await chrome.tabGroups.get(args.groupId).catch(() => { throw new Error("no tab group with groupId " + args.groupId); });
9340
+ return all.filter((t) => t.groupId === args.groupId);
9341
+ }
9342
+ throw new Error("no tab selector given");
9343
+ }
9344
+
9345
+ async function group(args) {
9346
+ const m = await targetIdsByTab();
9347
+ const tabs = await selectTabs(args, m);
9348
+ let win;
9349
+ if (args.groupId !== undefined) {
9350
+ win = (await chrome.tabGroups.get(args.groupId).catch(() => { throw new Error("no tab group with groupId " + args.groupId); })).windowId;
9351
+ } else if (args.windowId !== undefined) {
9352
+ win = args.windowId;
9353
+ } else {
9354
+ const ws = [...new Set(tabs.map((t) => t.windowId))];
9355
+ if (ws.length > 1) {
9356
+ throw new Error(
9357
+ "the selected tabs are in " + ws.length + " windows (" + ws.join(", ") + "); pass windowId to name the window the group goes in " +
9358
+ "(tabs from other windows are moved there). Without it Chrome would move them all into the last-focused window.",
9359
+ );
9360
+ }
9361
+ win = ws[0];
9362
+ }
9363
+ const moved = tabs.filter((t) => t.windowId !== win).map((t) => ({ tabId: t.id, fromWindowId: t.windowId }));
9364
+ const opts = { tabIds: tabs.map((t) => t.id) };
9365
+ if (args.groupId !== undefined) opts.groupId = args.groupId;
9366
+ else opts.createProperties = { windowId: win };
9367
+ const gid = await chrome.tabs.group(opts);
9368
+ const upd = {};
9369
+ if (args.title !== undefined) upd.title = args.title;
9370
+ if (args.color !== undefined) upd.color = args.color;
9371
+ if (args.collapsed !== undefined) upd.collapsed = args.collapsed;
9372
+ const g = Object.keys(upd).length ? await chrome.tabGroups.update(gid, upd) : await chrome.tabGroups.get(gid);
9373
+ const members = g.windowId > 0 ? (await chrome.tabs.query({ windowId: g.windowId })).filter((t) => t.groupId === gid).sort(byPlace) : [];
9374
+ if (members.length === 0) {
9375
+ // Vivaldi answers chrome.tabs.group with an id but keeps its own tab stacks: the "group" has
9376
+ // windowId -1 and no tabs. Fail loudly rather than report a group that does not exist.
9377
+ throw new Error("the browser accepted chrome.tabs.group but created no visible group (windowId " + g.windowId + ", 0 tabs); this browser does not support Chrome tab groups (Vivaldi uses its own tab stacks)");
9378
+ }
9379
+ return { groupId: gid, windowId: g.windowId, title: g.title || "", color: g.color, collapsed: !!g.collapsed, tabs: members.map((t) => row(t, m)), moved };
9380
+ }
9381
+
9382
+ async function ungroup(args) {
9383
+ const m = await targetIdsByTab();
9384
+ const tabs = await selectTabs(args, m);
9385
+ const grouped = tabs.filter((t) => t.groupId !== NONE && t.groupId !== undefined);
9386
+ if (grouped.length) await chrome.tabs.ungroup(grouped.map((t) => t.id));
9387
+ return {
9388
+ ungrouped: grouped.map((t) => Object.assign(row(t, m), { fromGroupId: t.groupId })),
9389
+ alreadyUngrouped: tabs.filter((t) => !grouped.includes(t)).map((t) => t.id),
9390
+ };
9391
+ }
9392
+
9393
+ self.cdpToolkitTabGroups = { version: VERSION, list, group, ungroup };
9394
+ `;
9395
+ var HELPER_VERSION = createHash("sha256").update(HELPER_SW_BODY).digest("hex").slice(0, 12);
9396
+ var HELPER_SW_SOURCE = `"use strict";
9397
+ const VERSION = ${JSON.stringify(HELPER_VERSION)};
9398
+ ${HELPER_SW_BODY}`;
9399
+ var isInt = (v) => typeof v === "number" && Number.isInteger(v);
9400
+ function checkInt(tool, name, v) {
9401
+ if (v !== undefined && !isInt(v))
9402
+ throw new Error(`${tool}: '${name}' must be an integer (got ${JSON.stringify(v)})`);
9403
+ }
9404
+ function checkSelector(tool, a, withGroupId) {
9405
+ const given = [
9406
+ a.tabIds !== undefined && "tabIds",
9407
+ a.targetIds !== undefined && "targetIds",
9408
+ typeof a.urlMatch === "string" && a.urlMatch !== "" && "urlMatch",
9409
+ withGroupId && a.groupId !== undefined && "groupId"
9410
+ ].filter(Boolean);
9411
+ const names = withGroupId ? "tabIds, targetIds, urlMatch or groupId" : "tabIds, targetIds or urlMatch";
9412
+ if (given.length !== 1)
9413
+ throw new Error(`${tool}: give exactly one of ${names} (got ${given.length ? given.join(" + ") : "none"})`);
9414
+ if (a.tabIds !== undefined) {
9415
+ if (!Array.isArray(a.tabIds) || a.tabIds.length === 0 || !a.tabIds.every(isInt)) {
9416
+ throw new Error(`${tool}: 'tabIds' must be a non-empty array of integer chrome tab ids (got ${JSON.stringify(a.tabIds)})`);
9417
+ }
9418
+ }
9419
+ if (a.targetIds !== undefined) {
9420
+ if (!Array.isArray(a.targetIds) || a.targetIds.length === 0 || !a.targetIds.every((t) => typeof t === "string" && t !== "")) {
9421
+ throw new Error(`${tool}: 'targetIds' must be a non-empty array of CDP target id strings (got ${JSON.stringify(a.targetIds)})`);
9422
+ }
9423
+ }
9424
+ }
9425
+ function validateListTabGroupsArgs(a) {
9426
+ checkInt("list_tab_groups", "windowId", a.windowId);
9427
+ if (a.includeUngrouped !== undefined && typeof a.includeUngrouped !== "boolean") {
9428
+ throw new Error("list_tab_groups: 'includeUngrouped' must be a boolean");
9429
+ }
9430
+ }
9431
+ function validateGroupTabsArgs(a) {
9432
+ const tool = "group_tabs";
9433
+ checkSelector(tool, a, false);
9434
+ checkInt(tool, "groupId", a.groupId);
9435
+ checkInt(tool, "windowId", a.windowId);
9436
+ if (a.groupId !== undefined && a.windowId !== undefined) {
9437
+ throw new Error(`${tool}: give groupId (add to that group, in its window) or windowId (new group in that window), not both`);
9438
+ }
9439
+ if (a.title !== undefined && typeof a.title !== "string")
9440
+ throw new Error(`${tool}: 'title' must be a string`);
9441
+ if (a.collapsed !== undefined && typeof a.collapsed !== "boolean")
9442
+ throw new Error(`${tool}: 'collapsed' must be a boolean`);
9443
+ if (a.color !== undefined && !TAB_GROUP_COLORS.includes(a.color)) {
9444
+ throw new Error(`${tool}: 'color' must be one of ${TAB_GROUP_COLORS.join(", ")} (got ${JSON.stringify(a.color)})`);
9445
+ }
9446
+ }
9447
+ function validateUngroupTabsArgs(a) {
9448
+ checkSelector("ungroup_tabs", a, true);
9449
+ checkInt("ungroup_tabs", "groupId", a.groupId);
9450
+ }
9451
+ var SW_URL_PREFIX = `chrome-extension://${HELPER_EXTENSION_ID}/`;
9452
+ var WORKER_WAIT_MS = 5000;
9453
+ async function helperWorker() {
9454
+ return (await listTargets()).find((t) => t.type === "service_worker" && t.url.startsWith(SW_URL_PREFIX));
9455
+ }
9456
+ async function writeHelper() {
9457
+ await mkdir12(HELPER_DIR, { recursive: true });
9458
+ const files = {
9459
+ "manifest.json": JSON.stringify(HELPER_MANIFEST, null, 2),
9460
+ "sw.js": HELPER_SW_SOURCE
9461
+ };
9462
+ for (const [name, body] of Object.entries(files)) {
9463
+ const path = join11(HELPER_DIR, name);
9464
+ const current = await readFile9(path, "utf8").catch(() => {
9465
+ return;
9466
+ });
9467
+ if (current !== body)
9468
+ await writeFile9(path, body);
9469
+ }
9470
+ }
9471
+ async function evalIn(workerId, expression) {
9472
+ return withPage(workerId, async (conn) => {
9473
+ const r = await conn.send("Runtime.evaluate", { expression, awaitPromise: true, returnByValue: true });
9474
+ if (r.exceptionDetails) {
9475
+ const d = r.exceptionDetails.exception?.description ?? r.exceptionDetails.text ?? "error";
9476
+ throw new Error(d.split(`
9477
+ `)[0].replace(/^Error: /, ""));
9478
+ }
9479
+ return r.result?.value;
9480
+ });
9481
+ }
9482
+ async function currentHelperWorker() {
9483
+ const w = await helperWorker();
9484
+ if (!w)
9485
+ return;
9486
+ const v = await evalIn(w.id, "self.cdpToolkitTabGroups && self.cdpToolkitTabGroups.version").catch(() => {
9487
+ return;
9488
+ });
9489
+ return v === HELPER_VERSION ? w.id : undefined;
9490
+ }
9491
+ async function ensureHelper() {
9492
+ const existing = await currentHelperWorker();
9493
+ if (existing)
9494
+ return existing;
9495
+ await writeHelper();
9496
+ const conn = await openBrowser();
9497
+ try {
9498
+ await conn.send("Extensions.loadUnpacked", { path: HELPER_DIR });
9499
+ } catch (e) {
9500
+ const msg = e instanceof Error ? e.message : String(e);
9501
+ throw new CdpError(`tab-group tools could not install their helper extension (Extensions.loadUnpacked: ${msg}). ` + `They need a Chromium that allows loadUnpacked over CDP, with ${HELPER_DIR} on the browser's own machine.`);
9502
+ } finally {
9503
+ conn.close();
9504
+ }
9505
+ const deadline = Date.now() + WORKER_WAIT_MS;
9506
+ while (Date.now() < deadline) {
9507
+ const id = await currentHelperWorker();
9508
+ if (id)
9509
+ return id;
9510
+ await new Promise((r) => setTimeout(r, 100));
9511
+ }
9512
+ throw new CdpError(`the tab-groups helper extension installed but its service worker did not start within ${WORKER_WAIT_MS} ms`);
9513
+ }
9514
+ async function callHelper(op, args) {
9515
+ const id = await ensureHelper();
9516
+ return await evalIn(id, `self.cdpToolkitTabGroups.${op}(${JSON.stringify(args)})`);
9517
+ }
9518
+ async function listTabGroups(args = {}) {
9519
+ validateListTabGroupsArgs(args);
9520
+ return callHelper("list", { windowId: args.windowId, includeUngrouped: args.includeUngrouped });
9521
+ }
9522
+ async function groupTabs(args = {}) {
9523
+ validateGroupTabsArgs(args);
9524
+ return callHelper("group", args);
9525
+ }
9526
+ async function ungroupTabs(args = {}) {
9527
+ validateUngroupTabsArgs(args);
9528
+ return callHelper("ungroup", args);
9529
+ }
9530
+
9531
+ // src/tools/extract.ts
9532
+ init_client();
9533
+ import { mkdir as mkdir13, writeFile as writeFile10 } from "node:fs/promises";
9534
+ import { dirname as dirname3, join as join12 } from "node:path";
9535
+ var ARTIFACT_DIR8 = process.env.CDP_ARTIFACT_DIR ?? "/tmp/cdp-toolkit";
9226
9536
  var DEFAULT_BASE_URL = "http://127.0.0.1:8090/v1";
9227
9537
  var DEFAULT_MODEL = "schematron";
9228
9538
  var DEFAULT_TIMEOUT_MS2 = 90000;
@@ -9622,10 +9932,10 @@ async function extractPage(driver, args) {
9622
9932
  };
9623
9933
  if (args.savePath === undefined || args.savePath === "")
9624
9934
  return result;
9625
- const path = args.savePath.startsWith("/") ? args.savePath : join11(ARTIFACT_DIR7, args.savePath);
9626
- await mkdir12(dirname3(path), { recursive: true });
9935
+ const path = args.savePath.startsWith("/") ? args.savePath : join12(ARTIFACT_DIR8, args.savePath);
9936
+ await mkdir13(dirname3(path), { recursive: true });
9627
9937
  const json = JSON.stringify(result, null, 2);
9628
- await writeFile9(path, json, "utf8");
9938
+ await writeFile10(path, json, "utf8");
9629
9939
  const saved = {
9630
9940
  path,
9631
9941
  bytes: Buffer.byteLength(json, "utf8"),
@@ -9688,6 +9998,9 @@ var TOOLS = {
9688
9998
  click_focus_gated: clickFocusGated,
9689
9999
  wait_for_download: waitForDownload,
9690
10000
  grant_permissions: grantPermissions,
10001
+ list_tab_groups: listTabGroups,
10002
+ group_tabs: groupTabs,
10003
+ ungroup_tabs: ungroupTabs,
9691
10004
  extract_page: onCdp(extractPage),
9692
10005
  claim_page: onCdp(LEASE_TOOLS.claim_page),
9693
10006
  release_page: onCdp(LEASE_TOOLS.release_page),
@@ -9703,7 +10016,7 @@ import { spawn as spawn4 } from "node:child_process";
9703
10016
  import { existsSync as existsSync2, mkdtempSync, readFileSync as readFileSync2, rmSync, writeFileSync } from "node:fs";
9704
10017
  import { createConnection, createServer as createServer2 } from "node:net";
9705
10018
  import { tmpdir } from "node:os";
9706
- import { join as join13 } from "node:path";
10019
+ import { join as join14 } from "node:path";
9707
10020
  function resolveBinary() {
9708
10021
  const candidates = [
9709
10022
  process.env.FIREFOX_BIN,
@@ -9783,7 +10096,7 @@ var LAUNCH_USER_JS_PREFS = {
9783
10096
  "dom.file.createInChild": true
9784
10097
  };
9785
10098
  function writeLaunchUserJs(profilePath) {
9786
- const target = join13(profilePath, "user.js");
10099
+ const target = join14(profilePath, "user.js");
9787
10100
  const existing = existsSync2(target) ? readFileSync2(target, "utf8") : "";
9788
10101
  const present = new Set;
9789
10102
  for (const line of existing.split(`
@@ -9805,7 +10118,7 @@ async function launchFirefox(opts = {}) {
9805
10118
  const binary = resolveBinary();
9806
10119
  const port = await pickPort(opts.port);
9807
10120
  const isThrowaway = opts.profilePath === undefined;
9808
- const profilePath = opts.profilePath ?? mkdtempSync(join13(tmpdir(), "cdp-toolkit-ff-profile-"));
10121
+ const profilePath = opts.profilePath ?? mkdtempSync(join14(tmpdir(), "cdp-toolkit-ff-profile-"));
9809
10122
  if (isThrowaway)
9810
10123
  writeLaunchUserJs(profilePath);
9811
10124
  const args = ["--profile", profilePath, "--remote-debugging-port", String(port), "--no-remote"];
@@ -10175,8 +10488,8 @@ var BIDI_ONLY_TOOLS = {
10175
10488
 
10176
10489
  // src/bidi-browser-tools.ts
10177
10490
  init_driver2();
10178
- import { mkdir as mkdir14, readdir as readdir4, realpath, rename as rename4, stat as stat5 } from "node:fs/promises";
10179
- import { basename as basename2, dirname as dirname4, join as join14, resolve } from "node:path";
10491
+ import { mkdir as mkdir15, readdir as readdir4, realpath, rename as rename4, stat as stat5 } from "node:fs/promises";
10492
+ import { basename as basename2, dirname as dirname4, join as join15, resolve } from "node:path";
10180
10493
  function unsupported(message) {
10181
10494
  return Object.assign(new Error(message), { code: "unsupported" });
10182
10495
  }
@@ -10195,7 +10508,7 @@ async function targetOf(driver, target) {
10195
10508
  await page.release();
10196
10509
  }
10197
10510
  }
10198
- var FIREFOX_DOWNLOAD_STAGING_DIR = join14(dirname4(DOWNLOADS_DIR), "downloads-firefox-staging");
10511
+ var FIREFOX_DOWNLOAD_STAGING_DIR = join15(dirname4(DOWNLOADS_DIR), "downloads-firefox-staging");
10199
10512
  var downloadStates = new WeakMap;
10200
10513
  function downloadId(p) {
10201
10514
  const v = p.download ?? p.navigation;
@@ -10239,7 +10552,7 @@ function downloadStateFor(conn) {
10239
10552
  if (!state.stagingDirs.has(resolve(dirname4(p.filepath))))
10240
10553
  return;
10241
10554
  rec.url ??= p.url;
10242
- const held = join14(dirname4(p.filepath), `${id.replace(/[^A-Za-z0-9-]/g, "_")}.download`);
10555
+ const held = join15(dirname4(p.filepath), `${id.replace(/[^A-Za-z0-9-]/g, "_")}.download`);
10243
10556
  rename4(p.filepath, held).then(() => {
10244
10557
  rec.filePath = held;
10245
10558
  }, () => {
@@ -10249,8 +10562,8 @@ function downloadStateFor(conn) {
10249
10562
  return state;
10250
10563
  }
10251
10564
  async function armFirefoxDownloads(conn, s, scope) {
10252
- await mkdir14(FIREFOX_DOWNLOAD_STAGING_DIR, { recursive: true });
10253
- await mkdir14(DOWNLOADS_DIR, { recursive: true });
10565
+ await mkdir15(FIREFOX_DOWNLOAD_STAGING_DIR, { recursive: true });
10566
+ await mkdir15(DOWNLOADS_DIR, { recursive: true });
10254
10567
  s.stagingDirs.add(resolve(await realpath(FIREFOX_DOWNLOAD_STAGING_DIR)));
10255
10568
  scope.setDisposeHook("browser.downloads", async (c) => {
10256
10569
  await c.send("browser.setDownloadBehavior", { downloadBehavior: null });
@@ -10308,7 +10621,7 @@ async function waitForDownloadFirefox(driver, args = {}) {
10308
10621
  const taken = new Set(await readdir4(DOWNLOADS_DIR).catch(() => []));
10309
10622
  taken.delete(basename2(rec.filePath));
10310
10623
  const finalName = nextFreeName(suggestedFilename, taken);
10311
- const path = join14(DOWNLOADS_DIR, finalName);
10624
+ const path = join15(DOWNLOADS_DIR, finalName);
10312
10625
  await rename4(rec.filePath, path);
10313
10626
  const bytes = (await stat5(path)).size;
10314
10627
  return { path, suggestedFilename, bytes, ...rec.url ? { url: rec.url } : {}, target };
@@ -11208,6 +11521,130 @@ var MANIFEST = [
11208
11521
  additionalProperties: false
11209
11522
  }
11210
11523
  },
11524
+ {
11525
+ name: "list_tab_groups",
11526
+ description: "List tab groups per window with member tabs (Chrome only, via a helper extension).",
11527
+ inputSchema: {
11528
+ type: "object",
11529
+ properties: {
11530
+ endpoint: {
11531
+ type: "string",
11532
+ description: "Named CDP endpoint (CDP_ENDPOINTS); default endpoint when omitted."
11533
+ },
11534
+ windowId: {
11535
+ type: "integer",
11536
+ description: "Only this window."
11537
+ },
11538
+ includeUngrouped: {
11539
+ type: "boolean",
11540
+ description: "Also list ungrouped tabs per window."
11541
+ }
11542
+ },
11543
+ required: [],
11544
+ additionalProperties: false
11545
+ }
11546
+ },
11547
+ {
11548
+ name: "group_tabs",
11549
+ description: "Group tabs (new or existing group) and set title/color/collapsed (Chrome only).",
11550
+ inputSchema: {
11551
+ type: "object",
11552
+ properties: {
11553
+ endpoint: {
11554
+ type: "string",
11555
+ description: "Named CDP endpoint (CDP_ENDPOINTS); default endpoint when omitted."
11556
+ },
11557
+ tabIds: {
11558
+ type: "array",
11559
+ items: {
11560
+ type: "integer"
11561
+ },
11562
+ description: "Chrome tab ids (from list_tab_groups)."
11563
+ },
11564
+ targetIds: {
11565
+ type: "array",
11566
+ items: {
11567
+ type: "string"
11568
+ },
11569
+ description: "CDP target ids (list_pages ids)."
11570
+ },
11571
+ urlMatch: {
11572
+ type: "string",
11573
+ description: "URL substring; matches tabs in every window."
11574
+ },
11575
+ title: {
11576
+ type: "string",
11577
+ description: "Group title."
11578
+ },
11579
+ color: {
11580
+ type: "string",
11581
+ enum: [
11582
+ "grey",
11583
+ "blue",
11584
+ "red",
11585
+ "yellow",
11586
+ "green",
11587
+ "pink",
11588
+ "purple",
11589
+ "cyan",
11590
+ "orange"
11591
+ ],
11592
+ description: "Group color."
11593
+ },
11594
+ collapsed: {
11595
+ type: "boolean",
11596
+ description: "Collapse the group."
11597
+ },
11598
+ groupId: {
11599
+ type: "integer",
11600
+ description: "Add to this existing group."
11601
+ },
11602
+ windowId: {
11603
+ type: "integer",
11604
+ description: "Window for the new group; tabs elsewhere move there."
11605
+ }
11606
+ },
11607
+ required: [],
11608
+ additionalProperties: false
11609
+ }
11610
+ },
11611
+ {
11612
+ name: "ungroup_tabs",
11613
+ description: "Remove tabs from their tab groups (Chrome only).",
11614
+ inputSchema: {
11615
+ type: "object",
11616
+ properties: {
11617
+ endpoint: {
11618
+ type: "string",
11619
+ description: "Named CDP endpoint (CDP_ENDPOINTS); default endpoint when omitted."
11620
+ },
11621
+ tabIds: {
11622
+ type: "array",
11623
+ items: {
11624
+ type: "integer"
11625
+ },
11626
+ description: "Chrome tab ids (from list_tab_groups)."
11627
+ },
11628
+ targetIds: {
11629
+ type: "array",
11630
+ items: {
11631
+ type: "string"
11632
+ },
11633
+ description: "CDP target ids (list_pages ids)."
11634
+ },
11635
+ urlMatch: {
11636
+ type: "string",
11637
+ description: "URL substring; matches tabs in every window."
11638
+ },
11639
+ groupId: {
11640
+ type: "integer",
11641
+ description: "Ungroup every tab of this group."
11642
+ }
11643
+ },
11644
+ required: [],
11645
+ additionalProperties: false
11646
+ }
11647
+ },
11211
11648
  {
11212
11649
  name: "fill",
11213
11650
  description: "Replace an element contents; provide exactly one of UID or selector.",
@@ -12303,6 +12740,9 @@ var MUTATING_TOOLS = new Set([
12303
12740
  "click_focus_gated",
12304
12741
  "wait_for_download",
12305
12742
  "grant_permissions",
12743
+ "list_tab_groups",
12744
+ "group_tabs",
12745
+ "ungroup_tabs",
12306
12746
  "claim_page",
12307
12747
  "release_page"
12308
12748
  ]);
@@ -12352,13 +12792,13 @@ function toolAnnotations(name) {
12352
12792
  // src/install/wizard.ts
12353
12793
  import { createInterface } from "node:readline";
12354
12794
  import { homedir as homedir3 } from "node:os";
12355
- import { join as join17 } from "node:path";
12795
+ import { join as join18 } from "node:path";
12356
12796
 
12357
12797
  // src/install/browser.ts
12358
12798
  import { existsSync as existsSync3 } from "node:fs";
12359
- import { mkdir as mkdir15, readFile as readFile10, writeFile as writeFile11 } from "node:fs/promises";
12799
+ import { mkdir as mkdir16, readFile as readFile11, writeFile as writeFile12 } from "node:fs/promises";
12360
12800
  import { homedir } from "node:os";
12361
- import { delimiter, dirname as dirname5, join as join15 } from "node:path";
12801
+ import { delimiter, dirname as dirname5, join as join16 } from "node:path";
12362
12802
  var CANDIDATE_BUILDERS = {
12363
12803
  chrome: () => [
12364
12804
  process.env.CHROME_BIN,
@@ -12388,7 +12828,7 @@ function existsOnPath(cmd) {
12388
12828
  for (const dir of pathEnv.split(delimiter)) {
12389
12829
  if (!dir)
12390
12830
  continue;
12391
- if (existsSync3(join15(dir, cmd)))
12831
+ if (existsSync3(join16(dir, cmd)))
12392
12832
  return true;
12393
12833
  }
12394
12834
  return false;
@@ -12438,10 +12878,10 @@ function aliasLine(o) {
12438
12878
  function detectShellRc() {
12439
12879
  const shell = process.env.SHELL ?? "";
12440
12880
  if (shell.endsWith("zsh"))
12441
- return join15(homedir(), ".zshrc");
12881
+ return join16(homedir(), ".zshrc");
12442
12882
  if (shell.endsWith("bash"))
12443
- return join15(homedir(), ".bashrc");
12444
- return join15(homedir(), process.platform === "darwin" ? ".zshrc" : ".bashrc");
12883
+ return join16(homedir(), ".bashrc");
12884
+ return join16(homedir(), process.platform === "darwin" ? ".zshrc" : ".bashrc");
12445
12885
  }
12446
12886
  var MARKER_START = "# >>> cdp-toolkit alias >>>";
12447
12887
  var MARKER_END = "# <<< cdp-toolkit alias <<<";
@@ -12453,7 +12893,7 @@ function ensureTrailingNewline(s) {
12453
12893
  async function appendAliasToRc(rcPath, aliasBlockBody) {
12454
12894
  let existing = "";
12455
12895
  try {
12456
- existing = await readFile10(rcPath, "utf8");
12896
+ existing = await readFile11(rcPath, "utf8");
12457
12897
  } catch (err) {
12458
12898
  if (err.code !== "ENOENT")
12459
12899
  throw err;
@@ -12474,24 +12914,24 @@ ${MARKER_END}`;
12474
12914
  }
12475
12915
  const next = ensureTrailingNewline(`${before}${block}
12476
12916
  ${after}`);
12477
- await writeFile11(rcPath, next, "utf8");
12917
+ await writeFile12(rcPath, next, "utf8");
12478
12918
  return { rcPath, action: "replaced-block" };
12479
12919
  }
12480
- await mkdir15(dirname5(rcPath), { recursive: true });
12920
+ await mkdir16(dirname5(rcPath), { recursive: true });
12481
12921
  const sep = existing.length === 0 || existing.endsWith(`
12482
12922
  `) ? "" : `
12483
12923
  `;
12484
12924
  const next = `${existing}${sep}${block}
12485
12925
  `;
12486
- await writeFile11(rcPath, next, "utf8");
12926
+ await writeFile12(rcPath, next, "utf8");
12487
12927
  return { rcPath, action: "created-block" };
12488
12928
  }
12489
12929
 
12490
12930
  // src/install/harness.ts
12491
12931
  import { spawnSync } from "node:child_process";
12492
- import { mkdir as mkdir16, readFile as readFile11, writeFile as writeFile12 } from "node:fs/promises";
12932
+ import { mkdir as mkdir17, readFile as readFile12, writeFile as writeFile13 } from "node:fs/promises";
12493
12933
  import { homedir as homedir2 } from "node:os";
12494
- import { dirname as dirname6, join as join16 } from "node:path";
12934
+ import { dirname as dirname6, join as join17 } from "node:path";
12495
12935
  async function installMcpServer(harness, name, cfg, opts = {}) {
12496
12936
  switch (harness) {
12497
12937
  case "claude":
@@ -12507,11 +12947,11 @@ async function installMcpServer(harness, name, cfg, opts = {}) {
12507
12947
  }
12508
12948
  }
12509
12949
  async function installClaude(name, cfg, opts) {
12510
- const path = opts.configPath ?? join16(opts.homeDir ?? homedir2(), ".claude.json");
12950
+ const path = opts.configPath ?? join17(opts.homeDir ?? homedir2(), ".claude.json");
12511
12951
  let root;
12512
12952
  let fileExisted;
12513
12953
  try {
12514
- const text = await readFile11(path, "utf8");
12954
+ const text = await readFile12(path, "utf8");
12515
12955
  const parsed = JSON.parse(text);
12516
12956
  if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
12517
12957
  throw new Error(`${path} does not contain a JSON object at its top level`);
@@ -12538,8 +12978,8 @@ async function installClaude(name, cfg, opts) {
12538
12978
  if (action === "unchanged") {
12539
12979
  return { harness: "claude", method: "file", path, action, detail: "no change needed" };
12540
12980
  }
12541
- await mkdir16(dirname6(path), { recursive: true });
12542
- await writeFile12(path, JSON.stringify(root, null, 2) + `
12981
+ await mkdir17(dirname6(path), { recursive: true });
12982
+ await writeFile13(path, JSON.stringify(root, null, 2) + `
12543
12983
  `, "utf8");
12544
12984
  return {
12545
12985
  harness: "claude",
@@ -12775,7 +13215,7 @@ async function promptPort(def) {
12775
13215
  }
12776
13216
  function harnessTargetDesc(harness, io) {
12777
13217
  if (harness === "claude") {
12778
- return io.configPath ?? join17(io.homeDir ?? homedir3(), ".claude.json");
13218
+ return io.configPath ?? join18(io.homeDir ?? homedir3(), ".claude.json");
12779
13219
  }
12780
13220
  return `via \`${harness} mcp add\``;
12781
13221
  }