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.
@@ -0,0 +1,435 @@
1
+ /**
2
+ * tab-groups.ts: `list_tab_groups`, `group_tabs`, `ungroup_tabs` (#17) — Chromium tab groups.
3
+ *
4
+ * WHY A HELPER EXTENSION, NOT CDP
5
+ * ===============================
6
+ * CDP has no tab-group domain: no Target/Browser command lists, creates, or names a group. The only
7
+ * API that does is the extension API (chrome.tabGroups + chrome.tabs.group), which runs in an
8
+ * extension context. So this module ships a tiny MV3 extension (HELPER_MANIFEST + HELPER_SW_SOURCE,
9
+ * embedded as strings so nothing extra has to survive the build), writes it under the artifact dir,
10
+ * installs it with the browser-endpoint command `Extensions.loadUnpacked`, and evaluates in its
11
+ * service worker over the worker's own CDP target — the same route `evaluate_script` takes for a
12
+ * 'worker:<substr>' selector.
13
+ *
14
+ * MEASURED, not assumed (Helium on Chromium 158 and Vivaldi on Chromium 156, macOS, 2026-11-20):
15
+ * - Extensions.loadUnpacked is accepted over a plain --remote-debugging-port WebSocket, without
16
+ * --enable-unsafe-extension-debugging, and the extension stays installed after the issuing
17
+ * connection closes (unlike Browser.grantPermissions, see browser-session.ts).
18
+ * - The manifest `key` fixes the extension id: two install directories gave the same id, so the
19
+ * worker's target is found by URL prefix without remembering anything between calls.
20
+ * - The worker is idle-evicted after ~30 s (its target disappears from /json/list). Re-issuing
21
+ * loadUnpacked on the same directory reloads the extension and the worker is back in ~5 ms, so
22
+ * every call checks for a live worker running THIS helper version and reloads only when needed.
23
+ * - chrome.debugger.getTargets() maps chrome tab ids to CDP target ids without attaching, so no
24
+ * "is debugging this browser" infobar appears; that is why the helper asks for "debugger".
25
+ * - chrome.tabs.group over tabs from SEVERAL windows, with no createProperties.windowId, silently
26
+ * moves them all into the LAST-FOCUSED window — not the window of any selected tab. The helper
27
+ * therefore always passes the window explicitly and refuses a multi-window selection unless the
28
+ * caller names the destination with `windowId`.
29
+ * - None of the calls raised or focused a window (frontmost app unchanged before/after).
30
+ *
31
+ * LIMITS, stated rather than hidden:
32
+ * - The helper directory must exist on the BROWSER's machine (loadUnpacked takes a local path),
33
+ * so a CDP endpoint on another host cannot run these tools.
34
+ * - The helper stays installed in the profile after the server exits (it holds no state and
35
+ * shows no UI); remove it from the browser's extensions page if unwanted.
36
+ * - These tools do not consult tab leases: grouping changes a tab's place in the tab strip, not
37
+ * the page, so a tab another agent holds can still be grouped.
38
+ * - Chrome backend only (capability "browser.tabGroups"). WebDriver BiDi has no way to evaluate
39
+ * in an extension's background context, so the tools are absent under Firefox.
40
+ */
41
+ import { createHash } from "node:crypto";
42
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
43
+ import { join } from "node:path";
44
+ import { CdpError, listTargets, openBrowser, withPage } from "../client.ts";
45
+
46
+ /** Artifact root, captured at import like every other module here (screencast, heap, ...). */
47
+ const ARTIFACT_DIR = process.env.CDP_ARTIFACT_DIR ?? "/tmp/cdp-toolkit";
48
+
49
+ /** Where the helper extension is written before Extensions.loadUnpacked reads it. */
50
+ export const HELPER_DIR = join(ARTIFACT_DIR, "tab-groups-helper");
51
+
52
+
53
+ /** Chrome's nine tab-group colors (chrome.tabGroups.Color). */
54
+ export const TAB_GROUP_COLORS = ["grey", "blue", "red", "yellow", "green", "pink", "purple", "cyan", "orange"] as const;
55
+ export type TabGroupColor = (typeof TAB_GROUP_COLORS)[number];
56
+
57
+ /** Public key only: it exists to pin the extension id. It authorizes nothing. */
58
+ const HELPER_KEY =
59
+ "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqesYyi7LmBxzWP7VFJGlH2khinCz0uU2z3KNDvZ3Kb8gTLPpthgRWp27pu5/Wk2nvQJdcrunf6u5vqomH2xhvXIqjgXtth2o1GrE6oJMWRUqEoC7I4YUXdSieRpxAxtG37KiSFOyFOU59Som3gGOM2j1qlQIsID0QwRCeRs095SLoTtkA6YwZxtOETgvZAhbbpkmYwkXjTzgY85sS1JfMYj67cmfyz/Nt6yfORSJYEmWAfGCjQnvtOn9TjCazZvmoASUhsKZNZVWckAg+Md+ZKBPbl14/UUwLmWHQ7SDcJozHZtFeLFXySwvmBm3NhP1rK5vd/v+modsQY3M3DbqLQIDAQAB";
60
+
61
+ export const HELPER_MANIFEST = {
62
+ manifest_version: 3,
63
+ name: "cdp-toolkit tab groups",
64
+ description: "Helper installed by cdp-toolkit's tab-group tools (list_tab_groups, group_tabs, ungroup_tabs). No UI, no state.",
65
+ version: "1.0.0",
66
+ key: HELPER_KEY,
67
+ permissions: ["tabs", "tabGroups", "debugger"],
68
+ background: { service_worker: "sw.js" },
69
+ } as const;
70
+
71
+ /**
72
+ * Chrome's extension id for a manifest key: the first 128 bits of SHA-256 over the DER public key,
73
+ * each hex digit mapped 0-f to a-p. Pure; pinned by a test against the id Chrome returned.
74
+ */
75
+ export function extensionIdFromKey(keyBase64: string): string {
76
+ const hex = createHash("sha256").update(Buffer.from(keyBase64, "base64")).digest("hex").slice(0, 32);
77
+ return [...hex].map((c) => String.fromCharCode(97 + parseInt(c, 16))).join("");
78
+ }
79
+
80
+ export const HELPER_EXTENSION_ID = extensionIdFromKey(HELPER_KEY);
81
+
82
+ /**
83
+ * The helper's service worker. Plain JS (it runs in the browser), loaded by the unit tests against
84
+ * a fake `chrome` through `new Function("self", "chrome", src)`, so its logic is tested without a
85
+ * browser. Every entry point takes ONE JSON-serializable object: callHelper passes it as a JSON
86
+ * literal, never by splicing strings into code.
87
+ */
88
+ const HELPER_SW_BODY = String.raw`
89
+ const NONE = -1;
90
+
91
+ async function targetIdsByTab() {
92
+ const m = new Map();
93
+ try {
94
+ for (const t of await chrome.debugger.getTargets()) {
95
+ if (t.type === "page" && typeof t.tabId === "number") m.set(t.tabId, t.id);
96
+ }
97
+ } catch (e) {
98
+ // No mapping is a degraded answer (rows lack targetId), not a failure of the listing.
99
+ }
100
+ return m;
101
+ }
102
+
103
+ function row(t, m) {
104
+ return { tabId: t.id, targetId: m.get(t.id), index: t.index, url: t.url || t.pendingUrl || "", title: t.title || "" };
105
+ }
106
+
107
+ const byPlace = (a, b) => a.windowId - b.windowId || a.index - b.index;
108
+
109
+ async function list(args) {
110
+ const q = args && args.windowId !== undefined ? { windowId: args.windowId } : {};
111
+ const [tabs, groups, m] = await Promise.all([chrome.tabs.query(q), chrome.tabGroups.query(q), targetIdsByTab()]);
112
+ const wins = new Map();
113
+ for (const t of tabs.slice().sort(byPlace)) {
114
+ let w = wins.get(t.windowId);
115
+ if (!w) wins.set(t.windowId, (w = { windowId: t.windowId, tabCount: 0, ungrouped: 0, groups: [] }));
116
+ w.tabCount++;
117
+ if (t.groupId === NONE || t.groupId === undefined) {
118
+ w.ungrouped++;
119
+ if (args && args.includeUngrouped) (w.ungroupedTabs || (w.ungroupedTabs = [])).push(row(t, m));
120
+ continue;
121
+ }
122
+ let g = w.groups.find((x) => x.groupId === t.groupId);
123
+ if (!g) {
124
+ const info = groups.find((x) => x.id === t.groupId) || {};
125
+ g = { groupId: t.groupId, title: info.title || "", color: info.color, collapsed: !!info.collapsed, tabs: [] };
126
+ w.groups.push(g);
127
+ }
128
+ g.tabs.push(row(t, m));
129
+ }
130
+ const windows = [...wins.values()];
131
+ return {
132
+ windows,
133
+ groupCount: windows.reduce((n, w) => n + w.groups.length, 0),
134
+ tabCount: tabs.length,
135
+ };
136
+ }
137
+
138
+ async function selectTabs(args, m) {
139
+ if (Array.isArray(args.tabIds)) {
140
+ const out = [];
141
+ for (const id of args.tabIds) {
142
+ try { out.push(await chrome.tabs.get(id)); }
143
+ catch (e) { throw new Error("no tab with tabId " + id + " (tab ids come from list_tab_groups)"); }
144
+ }
145
+ return out;
146
+ }
147
+ if (Array.isArray(args.targetIds)) {
148
+ const byTarget = new Map([...m].map(([tabId, targetId]) => [targetId, tabId]));
149
+ const out = [];
150
+ for (const tid of args.targetIds) {
151
+ const id = byTarget.get(tid);
152
+ if (id === undefined) throw new Error("no tab with targetId " + tid + " (a page's CDP target id, as list_pages shows it)");
153
+ out.push(await chrome.tabs.get(id));
154
+ }
155
+ return out;
156
+ }
157
+ const all = (await chrome.tabs.query({})).sort(byPlace);
158
+ if (typeof args.urlMatch === "string") {
159
+ const hit = all.filter((t) => (t.url || "").includes(args.urlMatch) || (t.pendingUrl || "").includes(args.urlMatch));
160
+ if (!hit.length) throw new Error("urlMatch " + JSON.stringify(args.urlMatch) + " matched no tab");
161
+ return hit;
162
+ }
163
+ if (typeof args.groupId === "number") {
164
+ await chrome.tabGroups.get(args.groupId).catch(() => { throw new Error("no tab group with groupId " + args.groupId); });
165
+ return all.filter((t) => t.groupId === args.groupId);
166
+ }
167
+ throw new Error("no tab selector given");
168
+ }
169
+
170
+ async function group(args) {
171
+ const m = await targetIdsByTab();
172
+ const tabs = await selectTabs(args, m);
173
+ let win;
174
+ if (args.groupId !== undefined) {
175
+ win = (await chrome.tabGroups.get(args.groupId).catch(() => { throw new Error("no tab group with groupId " + args.groupId); })).windowId;
176
+ } else if (args.windowId !== undefined) {
177
+ win = args.windowId;
178
+ } else {
179
+ const ws = [...new Set(tabs.map((t) => t.windowId))];
180
+ if (ws.length > 1) {
181
+ throw new Error(
182
+ "the selected tabs are in " + ws.length + " windows (" + ws.join(", ") + "); pass windowId to name the window the group goes in " +
183
+ "(tabs from other windows are moved there). Without it Chrome would move them all into the last-focused window.",
184
+ );
185
+ }
186
+ win = ws[0];
187
+ }
188
+ const moved = tabs.filter((t) => t.windowId !== win).map((t) => ({ tabId: t.id, fromWindowId: t.windowId }));
189
+ const opts = { tabIds: tabs.map((t) => t.id) };
190
+ if (args.groupId !== undefined) opts.groupId = args.groupId;
191
+ else opts.createProperties = { windowId: win };
192
+ const gid = await chrome.tabs.group(opts);
193
+ const upd = {};
194
+ if (args.title !== undefined) upd.title = args.title;
195
+ if (args.color !== undefined) upd.color = args.color;
196
+ if (args.collapsed !== undefined) upd.collapsed = args.collapsed;
197
+ const g = Object.keys(upd).length ? await chrome.tabGroups.update(gid, upd) : await chrome.tabGroups.get(gid);
198
+ const members = g.windowId > 0 ? (await chrome.tabs.query({ windowId: g.windowId })).filter((t) => t.groupId === gid).sort(byPlace) : [];
199
+ if (members.length === 0) {
200
+ // Vivaldi answers chrome.tabs.group with an id but keeps its own tab stacks: the "group" has
201
+ // windowId -1 and no tabs. Fail loudly rather than report a group that does not exist.
202
+ 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)");
203
+ }
204
+ return { groupId: gid, windowId: g.windowId, title: g.title || "", color: g.color, collapsed: !!g.collapsed, tabs: members.map((t) => row(t, m)), moved };
205
+ }
206
+
207
+ async function ungroup(args) {
208
+ const m = await targetIdsByTab();
209
+ const tabs = await selectTabs(args, m);
210
+ const grouped = tabs.filter((t) => t.groupId !== NONE && t.groupId !== undefined);
211
+ if (grouped.length) await chrome.tabs.ungroup(grouped.map((t) => t.id));
212
+ return {
213
+ ungrouped: grouped.map((t) => Object.assign(row(t, m), { fromGroupId: t.groupId })),
214
+ alreadyUngrouped: tabs.filter((t) => !grouped.includes(t)).map((t) => t.id),
215
+ };
216
+ }
217
+
218
+ self.cdpToolkitTabGroups = { version: VERSION, list, group, ungroup };
219
+ `;
220
+
221
+ /**
222
+ * Content hash of the worker body. A live worker reporting any other version (an older toolkit's
223
+ * helper) is reloaded, so a changed helper can never be skipped by a forgotten manual bump.
224
+ */
225
+ export const HELPER_VERSION = createHash("sha256").update(HELPER_SW_BODY).digest("hex").slice(0, 12);
226
+
227
+ export const HELPER_SW_SOURCE = `"use strict";\nconst VERSION = ${JSON.stringify(HELPER_VERSION)};\n${HELPER_SW_BODY}`;
228
+
229
+ /* -------------------------------- arguments -------------------------------- */
230
+
231
+ export interface ListTabGroupsArgs {
232
+ /** Only this window (a chrome window id from a previous listing). */
233
+ windowId?: number;
234
+ /** Also list each window's ungrouped tabs (rows), not just their count. */
235
+ includeUngrouped?: boolean;
236
+ }
237
+
238
+ interface TabSelector {
239
+ /** Chrome tab ids, as list_tab_groups reports them. */
240
+ tabIds?: number[];
241
+ /** CDP target ids (list_pages ids). */
242
+ targetIds?: string[];
243
+ /** Substring of the tab URL; matches across every window. */
244
+ urlMatch?: string;
245
+ }
246
+
247
+ export interface GroupTabsArgs extends TabSelector {
248
+ title?: string;
249
+ color?: TabGroupColor;
250
+ collapsed?: boolean;
251
+ /** Add to this existing group instead of creating one. */
252
+ groupId?: number;
253
+ /** Window the new group goes in; tabs from other windows are moved there. */
254
+ windowId?: number;
255
+ }
256
+
257
+ export interface UngroupTabsArgs extends TabSelector {
258
+ /** Ungroup every tab of this group. */
259
+ groupId?: number;
260
+ }
261
+
262
+ const isInt = (v: unknown): v is number => typeof v === "number" && Number.isInteger(v);
263
+
264
+ function checkInt(tool: string, name: string, v: unknown): void {
265
+ if (v !== undefined && !isInt(v)) throw new Error(`${tool}: '${name}' must be an integer (got ${JSON.stringify(v)})`);
266
+ }
267
+
268
+ /** Exactly one selector, each non-empty and well typed. `extra` adds ungroup's groupId selector. */
269
+ function checkSelector(tool: string, a: TabSelector & { groupId?: number }, withGroupId: boolean): void {
270
+ const given = [
271
+ a.tabIds !== undefined && "tabIds",
272
+ a.targetIds !== undefined && "targetIds",
273
+ typeof a.urlMatch === "string" && a.urlMatch !== "" && "urlMatch",
274
+ withGroupId && a.groupId !== undefined && "groupId",
275
+ ].filter(Boolean);
276
+ const names = withGroupId ? "tabIds, targetIds, urlMatch or groupId" : "tabIds, targetIds or urlMatch";
277
+ if (given.length !== 1) throw new Error(`${tool}: give exactly one of ${names} (got ${given.length ? given.join(" + ") : "none"})`);
278
+ if (a.tabIds !== undefined) {
279
+ if (!Array.isArray(a.tabIds) || a.tabIds.length === 0 || !a.tabIds.every(isInt)) {
280
+ throw new Error(`${tool}: 'tabIds' must be a non-empty array of integer chrome tab ids (got ${JSON.stringify(a.tabIds)})`);
281
+ }
282
+ }
283
+ if (a.targetIds !== undefined) {
284
+ if (!Array.isArray(a.targetIds) || a.targetIds.length === 0 || !a.targetIds.every((t) => typeof t === "string" && t !== "")) {
285
+ throw new Error(`${tool}: 'targetIds' must be a non-empty array of CDP target id strings (got ${JSON.stringify(a.targetIds)})`);
286
+ }
287
+ }
288
+ }
289
+
290
+ export function validateListTabGroupsArgs(a: ListTabGroupsArgs): void {
291
+ checkInt("list_tab_groups", "windowId", a.windowId);
292
+ if (a.includeUngrouped !== undefined && typeof a.includeUngrouped !== "boolean") {
293
+ throw new Error("list_tab_groups: 'includeUngrouped' must be a boolean");
294
+ }
295
+ }
296
+
297
+ export function validateGroupTabsArgs(a: GroupTabsArgs): void {
298
+ const tool = "group_tabs";
299
+ checkSelector(tool, a, false);
300
+ checkInt(tool, "groupId", a.groupId);
301
+ checkInt(tool, "windowId", a.windowId);
302
+ if (a.groupId !== undefined && a.windowId !== undefined) {
303
+ throw new Error(`${tool}: give groupId (add to that group, in its window) or windowId (new group in that window), not both`);
304
+ }
305
+ if (a.title !== undefined && typeof a.title !== "string") throw new Error(`${tool}: 'title' must be a string`);
306
+ if (a.collapsed !== undefined && typeof a.collapsed !== "boolean") throw new Error(`${tool}: 'collapsed' must be a boolean`);
307
+ if (a.color !== undefined && !(TAB_GROUP_COLORS as readonly string[]).includes(a.color)) {
308
+ throw new Error(`${tool}: 'color' must be one of ${TAB_GROUP_COLORS.join(", ")} (got ${JSON.stringify(a.color)})`);
309
+ }
310
+ }
311
+
312
+ export function validateUngroupTabsArgs(a: UngroupTabsArgs): void {
313
+ checkSelector("ungroup_tabs", a, true);
314
+ checkInt("ungroup_tabs", "groupId", a.groupId);
315
+ }
316
+
317
+ /* ------------------------------ helper plumbing ------------------------------ */
318
+
319
+ const SW_URL_PREFIX = `chrome-extension://${HELPER_EXTENSION_ID}/`;
320
+ const WORKER_WAIT_MS = 5_000;
321
+
322
+ async function helperWorker(): Promise<{ id: string } | undefined> {
323
+ return (await listTargets()).find((t) => t.type === "service_worker" && t.url.startsWith(SW_URL_PREFIX));
324
+ }
325
+
326
+ /** Write the helper files, rewriting only what differs (a stale helper from an older toolkit is replaced). */
327
+ async function writeHelper(): Promise<void> {
328
+ await mkdir(HELPER_DIR, { recursive: true });
329
+ const files: Record<string, string> = {
330
+ "manifest.json": JSON.stringify(HELPER_MANIFEST, null, 2),
331
+ "sw.js": HELPER_SW_SOURCE,
332
+ };
333
+ for (const [name, body] of Object.entries(files)) {
334
+ const path = join(HELPER_DIR, name);
335
+ const current = await readFile(path, "utf8").catch(() => undefined);
336
+ if (current !== body) await writeFile(path, body);
337
+ }
338
+ }
339
+
340
+ async function evalIn(workerId: string, expression: string): Promise<unknown> {
341
+ return withPage(workerId, async (conn) => {
342
+ const r = await conn.send<{
343
+ result?: { value?: unknown };
344
+ exceptionDetails?: { text?: string; exception?: { description?: string } };
345
+ }>("Runtime.evaluate", { expression, awaitPromise: true, returnByValue: true });
346
+ if (r.exceptionDetails) {
347
+ const d = r.exceptionDetails.exception?.description ?? r.exceptionDetails.text ?? "error";
348
+ // "Error: msg\n at ..." -> "msg"
349
+ throw new Error(d.split("\n")[0]!.replace(/^Error: /, ""));
350
+ }
351
+ return r.result?.value;
352
+ });
353
+ }
354
+
355
+ /**
356
+ * A live helper worker running this HELPER_VERSION: the existing one when it is current, else a
357
+ * fresh install (or reload) through Extensions.loadUnpacked.
358
+ */
359
+ async function currentHelperWorker(): Promise<string | undefined> {
360
+ const w = await helperWorker();
361
+ if (!w) return undefined;
362
+ const v = await evalIn(w.id, "self.cdpToolkitTabGroups && self.cdpToolkitTabGroups.version").catch(() => undefined);
363
+ return v === HELPER_VERSION ? w.id : undefined;
364
+ }
365
+
366
+ async function ensureHelper(): Promise<string> {
367
+ const existing = await currentHelperWorker();
368
+ if (existing) return existing;
369
+ await writeHelper();
370
+ const conn = await openBrowser();
371
+ try {
372
+ await conn.send("Extensions.loadUnpacked", { path: HELPER_DIR });
373
+ } catch (e) {
374
+ const msg = e instanceof Error ? e.message : String(e);
375
+ throw new CdpError(
376
+ `tab-group tools could not install their helper extension (Extensions.loadUnpacked: ${msg}). ` +
377
+ `They need a Chromium that allows loadUnpacked over CDP, with ${HELPER_DIR} on the browser's own machine.`,
378
+ );
379
+ } finally {
380
+ conn.close();
381
+ }
382
+ // Wait for a worker that reports THIS version: right after a reload over an older helper (or a
383
+ // foreign extension pinned to the same key), /json/list can still show the outgoing worker,
384
+ // whose script never defined the current API (seen live as "reading 'list' of undefined").
385
+ const deadline = Date.now() + WORKER_WAIT_MS;
386
+ while (Date.now() < deadline) {
387
+ const id = await currentHelperWorker();
388
+ if (id) return id;
389
+ await new Promise((r) => setTimeout(r, 100));
390
+ }
391
+ throw new CdpError(`the tab-groups helper extension installed but its service worker did not start within ${WORKER_WAIT_MS} ms`);
392
+ }
393
+
394
+ async function callHelper<T>(op: "list" | "group" | "ungroup", args: object): Promise<T> {
395
+ const id = await ensureHelper();
396
+ return (await evalIn(id, `self.cdpToolkitTabGroups.${op}(${JSON.stringify(args)})`)) as T;
397
+ }
398
+
399
+ /* ---------------------------------- tools ---------------------------------- */
400
+
401
+ export interface TabRow { tabId: number; targetId?: string; index: number; url: string; title: string }
402
+ export interface TabGroupRow { groupId: number; title: string; color: TabGroupColor; collapsed: boolean; tabs: TabRow[] }
403
+ export interface ListTabGroupsResult {
404
+ windows: Array<{ windowId: number; tabCount: number; ungrouped: number; groups: TabGroupRow[]; ungroupedTabs?: TabRow[] }>;
405
+ groupCount: number;
406
+ tabCount: number;
407
+ }
408
+ export interface GroupTabsResult extends TabGroupRow {
409
+ windowId: number;
410
+ /** Tabs that were moved from another window into windowId. */
411
+ moved: Array<{ tabId: number; fromWindowId: number }>;
412
+ }
413
+ export interface UngroupTabsResult {
414
+ ungrouped: Array<TabRow & { fromGroupId: number }>;
415
+ /** Selected tabs that were in no group (nothing to do for them). */
416
+ alreadyUngrouped: number[];
417
+ }
418
+
419
+ /** Every tab group, per window, with member tabs (tab id, CDP target id, url, title). */
420
+ export async function listTabGroups(args: ListTabGroupsArgs = {}): Promise<ListTabGroupsResult> {
421
+ validateListTabGroupsArgs(args);
422
+ return callHelper("list", { windowId: args.windowId, includeUngrouped: args.includeUngrouped });
423
+ }
424
+
425
+ /** Create a tab group (or add to one) from the selected tabs, then set title / color / collapsed. */
426
+ export async function groupTabs(args: GroupTabsArgs = {}): Promise<GroupTabsResult> {
427
+ validateGroupTabsArgs(args);
428
+ return callHelper("group", args);
429
+ }
430
+
431
+ /** Remove the selected tabs from their groups; a group left empty disappears. */
432
+ export async function ungroupTabs(args: UngroupTabsArgs = {}): Promise<UngroupTabsResult> {
433
+ validateUngroupTabsArgs(args);
434
+ return callHelper("ungroup", args);
435
+ }
package/src/version.ts CHANGED
@@ -6,4 +6,4 @@
6
6
  * ready line; keeping it in its own module means a release bump touches one
7
7
  * line here plus package.json, not a const buried in the server.
8
8
  */
9
- export const VERSION = "3.5.0";
9
+ export const VERSION = "3.6.0";