cdp-toolkit 3.4.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/CHANGELOG.md +22 -0
- package/CONTRACT.md +1 -0
- package/README.md +54 -18
- package/dist/bidi/mux-daemon.js +184 -5
- package/dist/cli.js +732 -60
- package/dist/index.js +566 -21
- package/dist/mcp.js +763 -51
- package/package.json +4 -3
- package/src/cdp/driver.ts +75 -7
- package/src/cdp/hiddenTabs.ts +285 -0
- package/src/client.ts +12 -3
- package/src/driver.ts +11 -1
- package/src/focusPolicy.ts +16 -0
- package/src/index.ts +8 -1
- package/src/leases-tools.ts +6 -0
- package/src/leases.ts +6 -0
- package/src/manifest.ts +124 -0
- package/src/mcp.ts +4 -0
- package/src/origins.ts +4 -2
- package/src/policy.ts +4 -0
- package/src/shared-tools.ts +46 -10
- package/src/toolDocs.ts +38 -6
- package/src/toolGroups.ts +2 -1
- package/src/tools/screencast.ts +3 -1
- package/src/tools/tab-groups.ts +435 -0
- package/src/types.ts +3 -0
- package/src/version.ts +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cdp-toolkit",
|
|
3
|
-
"version": "3.
|
|
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.
|
|
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
|
@@ -9,7 +9,8 @@ import { CdpConnection, CdpError, listTargets, openBrowser, openPage, resolveTar
|
|
|
9
9
|
import { openSession } from "./session.ts";
|
|
10
10
|
import { keepFrontApp } from "../frontApp.ts";
|
|
11
11
|
import type { Target, TargetSelector } from "../types.ts";
|
|
12
|
-
import { chromeLeaseBackend, LeaseConflictError } from "../leases.ts";
|
|
12
|
+
import { chromeLeaseBackend, isLongLivedProcess, LeaseConflictError } from "../leases.ts";
|
|
13
|
+
import { disposeHiddenTabs, existingHiddenTabOwner, hiddenTabOwner, hiddenTabsRequested, type HiddenTabOwner } from "./hiddenTabs.ts";
|
|
13
14
|
import { currentEndpoint } from "../endpoints.ts";
|
|
14
15
|
import { BEACON_READ_EXPRESSION, BEACON_SOURCE, BeaconSessions, RENDERER_PROBE_EXPRESSION, RENDERER_PROBE_TIMEOUT_MS, sendInput } from "../activity.ts";
|
|
15
16
|
import { resolveUid } from "../tools/snapshot.ts";
|
|
@@ -745,7 +746,7 @@ const CDP_CAPABILITIES: ReadonlySet<Capability> = new Set<Capability>([
|
|
|
745
746
|
"screenshot.fullPage", "screenshot.element", "screenshot.scale", "screenshot.renderSize", "screenshot.tile", "network.intercept",
|
|
746
747
|
"snapshot.accessibilityTree", "input.insertTextAtomic", "locate.text", "locate.xpath",
|
|
747
748
|
"capture.screencast", "input.raw", "input.modifierClick", "input.html5Drag", "emulate.focus",
|
|
748
|
-
"browser.downloads", "browser.permissions", "worker.targets", "frame.targets",
|
|
749
|
+
"browser.downloads", "browser.permissions", "browser.tabGroups", "worker.targets", "frame.targets",
|
|
749
750
|
]);
|
|
750
751
|
/* ---------------------------------- PageDriver ---------------------------------- */
|
|
751
752
|
class CdpPageDriver implements PageDriver {
|
|
@@ -1829,12 +1830,18 @@ export const NEW_TARGET_SETTLE_MS = 2000;
|
|
|
1829
1830
|
* The tab opens with background:true unless opts.focus is true: a tab the
|
|
1830
1831
|
* toolkit opens must not switch the user's visible tab or take keyboard focus.
|
|
1831
1832
|
* Without the flag Chromium (Vivaldi included) foregrounds every new tab.
|
|
1833
|
+
*
|
|
1834
|
+
* opts.hidden (the CDP_HIDDEN_TABS path, see ./hiddenTabs.ts) sends {background:true,
|
|
1835
|
+
* hidden:true} instead and skips keepFrontApp: a hidden target activates nothing, so there is no
|
|
1836
|
+
* front app to put back. A hidden target emits its first targetInfoChanged like any other
|
|
1837
|
+
* (measured ~46ms on Vivaldi 156), so the settle wait is unchanged. Without opts.hidden the
|
|
1838
|
+
* params are exactly what they were before hidden tabs existed.
|
|
1832
1839
|
*/
|
|
1833
1840
|
export async function createSettledTarget(
|
|
1834
1841
|
conn: Pick<CdpConnection, "send" | "on">,
|
|
1835
1842
|
url: string,
|
|
1836
1843
|
settleMs = NEW_TARGET_SETTLE_MS,
|
|
1837
|
-
opts: { focus?: boolean } = {},
|
|
1844
|
+
opts: { focus?: boolean; hidden?: boolean } = {},
|
|
1838
1845
|
): Promise<string> {
|
|
1839
1846
|
const changed = new Set<string>();
|
|
1840
1847
|
let id = "";
|
|
@@ -1847,9 +1854,12 @@ export async function createSettledTarget(
|
|
|
1847
1854
|
});
|
|
1848
1855
|
try {
|
|
1849
1856
|
await conn.send("Target.setDiscoverTargets", { discover: true }).catch(() => undefined);
|
|
1850
|
-
const
|
|
1857
|
+
const hidden = opts.hidden === true;
|
|
1858
|
+
const params = hidden ? { url, background: true, hidden: true } : { url, background: opts.focus !== true };
|
|
1859
|
+
const create = () => conn.send<{ targetId: string }>("Target.createTarget", params);
|
|
1851
1860
|
// A background createTarget still brings the browser app forward on macOS: put the user's app back.
|
|
1852
|
-
|
|
1861
|
+
// A hidden one does not, and a foreground one is meant to.
|
|
1862
|
+
const { targetId } = opts.focus === true || hidden ? await create() : await keepFrontApp(create);
|
|
1853
1863
|
if (!targetId) throw driverError("page-error", "Target.createTarget returned no targetId");
|
|
1854
1864
|
id = targetId;
|
|
1855
1865
|
if (!changed.has(targetId)) {
|
|
@@ -1863,6 +1873,29 @@ export async function createSettledTarget(
|
|
|
1863
1873
|
off();
|
|
1864
1874
|
}
|
|
1865
1875
|
}
|
|
1876
|
+
/**
|
|
1877
|
+
* Hidden tabs are on: CDP_HIDDEN_TABS is set AND this is the long-lived MCP server. Under the
|
|
1878
|
+
* one-shot CLI a hidden tab would die with the process that created it at exit, so the CLI keeps
|
|
1879
|
+
* the visible path whatever the env says, the same carve-out requireLease makes (../leases.ts).
|
|
1880
|
+
*/
|
|
1881
|
+
export function hiddenTabsEnabled(): boolean {
|
|
1882
|
+
return hiddenTabsRequested() && isLongLivedProcess();
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
/** The current endpoint's hidden-tab owner, created on first use. */
|
|
1886
|
+
function currentHiddenOwner(): HiddenTabOwner {
|
|
1887
|
+
return hiddenTabOwner(currentEndpoint().base, () => ({
|
|
1888
|
+
connect: () => openBrowser(),
|
|
1889
|
+
createSettled: (conn, url, opts) => createSettledTarget(conn, url, NEW_TARGET_SETTLE_MS, opts),
|
|
1890
|
+
}));
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
/** The current endpoint's owner when `id` is one of its live hidden tabs. Never creates one. */
|
|
1894
|
+
function hiddenOwnerOf(id: string): HiddenTabOwner | undefined {
|
|
1895
|
+
const owner = existingHiddenTabOwner(currentEndpoint().base);
|
|
1896
|
+
return owner?.has(id) ? owner : undefined;
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1866
1899
|
class CdpBrowserDriver implements BrowserDriver {
|
|
1867
1900
|
readonly scheme = "cdp";
|
|
1868
1901
|
readonly lifetime: LifetimeModel = "per-call";
|
|
@@ -1874,9 +1907,16 @@ class CdpBrowserDriver implements BrowserDriver {
|
|
|
1874
1907
|
async listPages(opts?: { all?: boolean }): Promise<PageInfo[]> {
|
|
1875
1908
|
const targets = await listTargets();
|
|
1876
1909
|
const filtered = opts?.all ? targets : targets.filter((t) => t.type === "page");
|
|
1877
|
-
|
|
1910
|
+
// `hidden` is set by listTargets on this process's hidden tabs only (./hiddenTabs.ts).
|
|
1911
|
+
return filtered.map((t) => ({ id: t.id, url: t.url, title: t.title, type: t.type, ...(t.hidden ? { hidden: true } : {}) }));
|
|
1878
1912
|
}
|
|
1879
1913
|
async newPage(url?: string, opts?: { focus?: boolean }): Promise<PageInfo> {
|
|
1914
|
+
// CDP_HIDDEN_TABS (MCP server only): a hidden target on the held owner connection, which
|
|
1915
|
+
// never brings the browser app forward. focus:true keeps the visible path below.
|
|
1916
|
+
if (opts?.focus !== true && hiddenTabsEnabled()) {
|
|
1917
|
+
const id = await currentHiddenOwner().create(url ?? "about:blank");
|
|
1918
|
+
return { id, url: url ?? "about:blank", title: "", hidden: true };
|
|
1919
|
+
}
|
|
1880
1920
|
return withBrowserConn(async (conn) => {
|
|
1881
1921
|
const targetId = await createSettledTarget(conn, url ?? "about:blank", NEW_TARGET_SETTLE_MS, { focus: opts?.focus === true });
|
|
1882
1922
|
return { id: targetId, url: url ?? "about:blank", title: "" };
|
|
@@ -1886,6 +1926,14 @@ class CdpBrowserDriver implements BrowserDriver {
|
|
|
1886
1926
|
* propagated (defaulting true only when the response omits it, matching newer Chromium
|
|
1887
1927
|
* builds), never hardcoded. */
|
|
1888
1928
|
async closePage(id: string): Promise<{ success: boolean }> {
|
|
1929
|
+
// A hidden tab is closed over its owner (closing it raises nothing, so no keepFrontApp).
|
|
1930
|
+
// Checked regardless of the env, so a tab opened before the env changed still closes cleanly.
|
|
1931
|
+
const owner = hiddenOwnerOf(id);
|
|
1932
|
+
if (owner) {
|
|
1933
|
+
const res = await owner.close(id);
|
|
1934
|
+
if (res.success) beaconSessions.drop(beaconKey(id));
|
|
1935
|
+
return res;
|
|
1936
|
+
}
|
|
1889
1937
|
return withBrowserConn(async (conn) => {
|
|
1890
1938
|
// Closing a tab also brings the browser app forward on macOS (measured): put the user's app back.
|
|
1891
1939
|
const res = await keepFrontApp(() => conn.send<{ success?: boolean }>("Target.closeTarget", { targetId: id }));
|
|
@@ -1896,8 +1944,24 @@ class CdpBrowserDriver implements BrowserDriver {
|
|
|
1896
1944
|
return { success: res.success ?? true };
|
|
1897
1945
|
});
|
|
1898
1946
|
}
|
|
1947
|
+
/**
|
|
1948
|
+
* On a hidden tab this REVEALS rather than activates: Target.activateTarget and
|
|
1949
|
+
* Page.bringToFront return ok on a hidden target and show nothing (measured), so it cannot be
|
|
1950
|
+
* brought forward in place. Instead its current URL opens in a new VISIBLE, foreground tab (the
|
|
1951
|
+
* flash is the point: the caller asked to show it), then the hidden tab is closed, and the new
|
|
1952
|
+
* tab's id is returned with `revealedFrom` naming the old one. In-page state that a URL does
|
|
1953
|
+
* not carry (form input, scroll, sessionStorage, a POST result) does not survive the move.
|
|
1954
|
+
*/
|
|
1899
1955
|
async activatePage(id: string): Promise<PageInfo> {
|
|
1900
1956
|
const target = await resolveTarget(id).catch(noSuchTarget);
|
|
1957
|
+
const owner = hiddenOwnerOf(target.id);
|
|
1958
|
+
if (owner) {
|
|
1959
|
+
const url = target.url || "about:blank";
|
|
1960
|
+
const newId = await withBrowserConn((conn) => createSettledTarget(conn, url, NEW_TARGET_SETTLE_MS, { focus: true }));
|
|
1961
|
+
await owner.close(target.id).catch(() => undefined);
|
|
1962
|
+
beaconSessions.drop(beaconKey(target.id));
|
|
1963
|
+
return { id: newId, url, title: target.title, revealedFrom: target.id };
|
|
1964
|
+
}
|
|
1901
1965
|
await withBrowserConn((conn) => conn.send("Target.activateTarget", { targetId: target.id }));
|
|
1902
1966
|
return { id: target.id, url: target.url, title: target.title };
|
|
1903
1967
|
}
|
|
@@ -2027,13 +2091,17 @@ class CdpBrowserDriver implements BrowserDriver {
|
|
|
2027
2091
|
* path and the CLI's exit path; a tool must never call it (see ../driver.ts). */
|
|
2028
2092
|
async dispose(): Promise<void> {
|
|
2029
2093
|
beaconSessions.clear();
|
|
2094
|
+
// Hidden tabs die with their owner anyway; closing them first is explicit and bounded.
|
|
2095
|
+
await disposeHiddenTabs();
|
|
2030
2096
|
}
|
|
2031
2097
|
}
|
|
2032
2098
|
/** Construct the CDP implementation of the frozen Driver contract. */
|
|
2033
2099
|
export function createCdpDriver(): BrowserDriver { return new CdpBrowserDriver(); }
|
|
2034
2100
|
export { CdpBrowserDriver, CdpPageDriver };
|
|
2035
2101
|
/* ------------------------------------------------------------------------------
|
|
2036
|
-
* CDP methods/domains used: Target.createTarget/closeTarget/activateTarget
|
|
2102
|
+
* CDP methods/domains used: Target.createTarget/closeTarget/activateTarget, plus
|
|
2103
|
+
* Target.attachToTarget, targetDestroyed and Emulation.setDeviceMetricsOverride on the hidden-tab
|
|
2104
|
+
* owner (./hiddenTabs.ts); Page.enable/
|
|
2037
2105
|
* navigate/reload/getFrameTree/loadEventFired/domContentEventFired/frameStoppedLoading/
|
|
2038
2106
|
* captureScreenshot/getLayoutMetrics/javascriptDialogOpening/handleJavaScriptDialog/
|
|
2039
2107
|
* addScriptToEvaluateOnNewDocument (the activity beacon, see ../activity.ts);
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hidden tabs (CDP_HIDDEN_TABS=1, MCP server only): new_page without focus:true opens a
|
|
3
|
+
* `Target.createTarget {background:true, hidden:true}` target that never becomes visible, so the
|
|
4
|
+
* browser APP never comes to the front of the user's screen.
|
|
5
|
+
*
|
|
6
|
+
* WHY. Measured on Vivaldi (Chromium 156) by sampling `lsappinfo front` around raw CDP calls:
|
|
7
|
+
* createTarget with {background:true}, {background:true, focus:false}, {newWindow:true,
|
|
8
|
+
* background:true} and a minimized new window all bring the browser app to the front for a
|
|
9
|
+
* moment (keepFrontApp in ../frontApp.ts puts the user's app back AFTER that flash). Only
|
|
10
|
+
* {background:true, hidden:true} leaves the front app alone. Target.closeTarget and
|
|
11
|
+
* Page.navigate on an existing tab are also clean.
|
|
12
|
+
*
|
|
13
|
+
* WHAT A HIDDEN TARGET IS, measured on the same browser:
|
|
14
|
+
* - It dies when the CDP connection that created it closes. So this module holds ONE owner
|
|
15
|
+
* browser connection per endpoint, for the life of the process. That is also why the feature
|
|
16
|
+
* is MCP-server only: under the one-shot CLI the tab would die at process exit, so the CLI
|
|
17
|
+
* keeps the visible path even with the env set (see hiddenTabsEnabled).
|
|
18
|
+
* - While the owner lives, the target is in /json/list and Target.getTargets, and any other
|
|
19
|
+
* connection can attach, evaluate, navigate and screenshot it. Its listing type is "other",
|
|
20
|
+
* not "page", so markHiddenTargets relabels the ids this process owns (see there).
|
|
21
|
+
* - Its viewport is 0x0: Page.captureScreenshot hangs and clicks land nowhere. The owner
|
|
22
|
+
* attaches (flatten), sets Emulation.setDeviceMetricsOverride and KEEPS that session, and then
|
|
23
|
+
* every other per-call connection sees the emulated viewport. A second connection that sets
|
|
24
|
+
* and clears its own override, or disconnects without clearing, leaves the owner's override
|
|
25
|
+
* in force once it is gone (measured). The device pixel ratio is read from the tab itself
|
|
26
|
+
* before the override: a hidden tab reports the real screen's devicePixelRatio (2 on a Retina
|
|
27
|
+
* Mac) even at 0x0.
|
|
28
|
+
* - It shares the default browser context, so cookies and logins carry over.
|
|
29
|
+
* - Target.activateTarget / Page.bringToFront return ok and show nothing, and window.open from
|
|
30
|
+
* it opens nothing. So a hidden tab cannot be revealed in place; see the driver's activatePage.
|
|
31
|
+
*
|
|
32
|
+
* OWNER LOSS (server restart, browser restart, socket drop) kills every hidden tab. The registry
|
|
33
|
+
* notices on the next access (the owner's `isOpen` is false) and forgets them all, and the next
|
|
34
|
+
* new_page reconnects lazily. A dead hidden id is then an ordinary missing target, so every tool
|
|
35
|
+
* fails it with the existing `no-such-target` error from target resolution, never a hang.
|
|
36
|
+
*
|
|
37
|
+
* LEAK BOUND. The user can neither see nor close these tabs, so at most CDP_HIDDEN_TABS_MAX
|
|
38
|
+
* (default 20) live at once per endpoint. At the cap new_page REFUSES with an error naming the
|
|
39
|
+
* open hidden ids, rather than closing the oldest: silently closing a tab another call may still
|
|
40
|
+
* be driving (or holds a lease on) is the one thing list_pages' reap is also never allowed to do
|
|
41
|
+
* without saying so. dispose() (the MCP server's shutdown) closes them all.
|
|
42
|
+
*
|
|
43
|
+
* THIS MODULE IMPORTS NOTHING AT RUNTIME FROM ../client.ts: client.ts imports it (listTargets
|
|
44
|
+
* calls markHiddenTargets), and the owner's connection factory is injected by ./driver.ts.
|
|
45
|
+
*/
|
|
46
|
+
import type { Target } from "../types.ts";
|
|
47
|
+
|
|
48
|
+
/** Default cap on live hidden tabs per endpoint. */
|
|
49
|
+
export const DEFAULT_HIDDEN_TABS_MAX = 20;
|
|
50
|
+
/** Emulated viewport for a hidden tab, in CSS px. */
|
|
51
|
+
export const HIDDEN_TAB_VIEWPORT = { width: 1280, height: 800 } as const;
|
|
52
|
+
/** Used when the tab cannot report its own devicePixelRatio. */
|
|
53
|
+
export const FALLBACK_DEVICE_SCALE_FACTOR = 2;
|
|
54
|
+
/** Bound on each owner-side command, so a wedged browser costs seconds, never a hang. */
|
|
55
|
+
const OWNER_COMMAND_TIMEOUT_MS = 5_000;
|
|
56
|
+
|
|
57
|
+
const TRUTHY = new Set(["1", "true", "yes", "on"]);
|
|
58
|
+
|
|
59
|
+
/** CDP_HIDDEN_TABS is set to a truthy value. Read per call, so a test can flip it. */
|
|
60
|
+
export function hiddenTabsRequested(): boolean {
|
|
61
|
+
return TRUTHY.has((process.env.CDP_HIDDEN_TABS ?? "").trim().toLowerCase());
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** CDP_HIDDEN_TABS_MAX, else DEFAULT_HIDDEN_TABS_MAX. A non-positive or non-numeric value is ignored. */
|
|
65
|
+
export function hiddenTabsMax(): number {
|
|
66
|
+
const raw = Number(process.env.CDP_HIDDEN_TABS_MAX);
|
|
67
|
+
return Number.isFinite(raw) && raw >= 1 ? Math.floor(raw) : DEFAULT_HIDDEN_TABS_MAX;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The slice of CdpConnection the owner needs. */
|
|
71
|
+
export interface OwnerConnection {
|
|
72
|
+
send<T = Record<string, unknown>>(method: string, params?: Record<string, unknown>, opts?: { timeoutMs?: number; sessionId?: string }): Promise<T>;
|
|
73
|
+
on(method: string, handler: (params: Record<string, unknown>, sessionId?: string) => void): () => void;
|
|
74
|
+
close(): void;
|
|
75
|
+
readonly isOpen: boolean;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface HiddenTabOwnerDeps {
|
|
79
|
+
/** Opens a fresh browser-endpoint connection (openBrowser in production). */
|
|
80
|
+
connect(): Promise<OwnerConnection>;
|
|
81
|
+
/** Creates the target with the settle wait (createSettledTarget in production). */
|
|
82
|
+
createSettled(conn: OwnerConnection, url: string, opts: { hidden: true }): Promise<string>;
|
|
83
|
+
/** Live cap; hiddenTabsMax by default. */
|
|
84
|
+
max?: () => number;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Thrown at the cap. `code` makes it pass through noSuchTarget and the MCP error mapping typed. */
|
|
88
|
+
export class HiddenTabCapError extends Error {
|
|
89
|
+
readonly code = "page-error" as const;
|
|
90
|
+
constructor(readonly max: number, readonly openIds: string[]) {
|
|
91
|
+
super(
|
|
92
|
+
`hidden-tab cap reached: ${openIds.length} hidden tabs are open (CDP_HIDDEN_TABS_MAX=${max}). ` +
|
|
93
|
+
`Close one with close_page (open hidden tabs, oldest first: ${openIds.join(", ")}), ` +
|
|
94
|
+
`or pass focus:true to open a visible tab instead.`,
|
|
95
|
+
);
|
|
96
|
+
this.name = "HiddenTabCapError";
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** One endpoint's owner connection and the hidden tabs it keeps alive. */
|
|
101
|
+
export class HiddenTabOwner {
|
|
102
|
+
private conn: OwnerConnection | undefined;
|
|
103
|
+
private connecting: Promise<OwnerConnection> | undefined;
|
|
104
|
+
/** targetId -> the owner's session on it. Insertion order is age (oldest first). */
|
|
105
|
+
private readonly tabs = new Map<string, string>();
|
|
106
|
+
/** Creates in flight, counted against the cap so concurrent new_page calls cannot overshoot it. */
|
|
107
|
+
private reserved = 0;
|
|
108
|
+
|
|
109
|
+
constructor(private readonly deps: HiddenTabOwnerDeps) {}
|
|
110
|
+
|
|
111
|
+
/** Forget everything if the owner socket died: its hidden tabs died with it. */
|
|
112
|
+
private sweep(): void {
|
|
113
|
+
if (this.conn && !this.conn.isOpen) {
|
|
114
|
+
this.conn = undefined;
|
|
115
|
+
this.tabs.clear();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** True when `id` is a live hidden tab this owner holds. */
|
|
120
|
+
has(id: string): boolean {
|
|
121
|
+
this.sweep();
|
|
122
|
+
return this.tabs.has(id);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Live hidden ids, oldest first. */
|
|
126
|
+
ids(): string[] {
|
|
127
|
+
this.sweep();
|
|
128
|
+
return [...this.tabs.keys()];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** The owner connection, opened lazily and single-flight: concurrent callers share one connect. */
|
|
132
|
+
private async owner(): Promise<OwnerConnection> {
|
|
133
|
+
this.sweep();
|
|
134
|
+
if (this.conn) return this.conn;
|
|
135
|
+
if (!this.connecting) {
|
|
136
|
+
this.connecting = (async () => {
|
|
137
|
+
const conn = await this.deps.connect();
|
|
138
|
+
// A hidden tab closed by anyone (another process's close_page, the browser itself) drops
|
|
139
|
+
// out of the registry here; setDiscoverTargets is sent by createSettled.
|
|
140
|
+
conn.on("Target.targetDestroyed", (params) => {
|
|
141
|
+
const id = (params as { targetId?: unknown }).targetId;
|
|
142
|
+
if (typeof id === "string") this.tabs.delete(id);
|
|
143
|
+
});
|
|
144
|
+
this.conn = conn;
|
|
145
|
+
return conn;
|
|
146
|
+
})().finally(() => {
|
|
147
|
+
this.connecting = undefined;
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
return this.connecting;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** Create a hidden tab at `url`, attach the owner to it and give it a real viewport. */
|
|
154
|
+
async create(url: string): Promise<string> {
|
|
155
|
+
this.sweep();
|
|
156
|
+
const max = (this.deps.max ?? hiddenTabsMax)();
|
|
157
|
+
if (this.tabs.size + this.reserved >= max) throw new HiddenTabCapError(max, [...this.tabs.keys()]);
|
|
158
|
+
this.reserved++;
|
|
159
|
+
try {
|
|
160
|
+
const conn = await this.owner();
|
|
161
|
+
const id = await this.deps.createSettled(conn, url, { hidden: true });
|
|
162
|
+
try {
|
|
163
|
+
const { sessionId } = await conn.send<{ sessionId: string }>(
|
|
164
|
+
"Target.attachToTarget",
|
|
165
|
+
{ targetId: id, flatten: true },
|
|
166
|
+
{ timeoutMs: OWNER_COMMAND_TIMEOUT_MS },
|
|
167
|
+
);
|
|
168
|
+
const dpr = await conn
|
|
169
|
+
.send<{ result?: { value?: unknown } }>(
|
|
170
|
+
"Runtime.evaluate",
|
|
171
|
+
{ expression: "devicePixelRatio", returnByValue: true },
|
|
172
|
+
{ sessionId, timeoutMs: OWNER_COMMAND_TIMEOUT_MS },
|
|
173
|
+
)
|
|
174
|
+
.then((r) => r.result?.value)
|
|
175
|
+
.catch(() => undefined);
|
|
176
|
+
await conn.send(
|
|
177
|
+
"Emulation.setDeviceMetricsOverride",
|
|
178
|
+
{
|
|
179
|
+
width: HIDDEN_TAB_VIEWPORT.width,
|
|
180
|
+
height: HIDDEN_TAB_VIEWPORT.height,
|
|
181
|
+
deviceScaleFactor: typeof dpr === "number" && Number.isFinite(dpr) && dpr > 0 ? dpr : FALLBACK_DEVICE_SCALE_FACTOR,
|
|
182
|
+
mobile: false,
|
|
183
|
+
},
|
|
184
|
+
{ sessionId, timeoutMs: OWNER_COMMAND_TIMEOUT_MS },
|
|
185
|
+
);
|
|
186
|
+
this.tabs.set(id, sessionId);
|
|
187
|
+
return id;
|
|
188
|
+
} catch (e) {
|
|
189
|
+
// A hidden tab without a viewport cannot be screenshotted or clicked: do not hand it out.
|
|
190
|
+
await conn.send("Target.closeTarget", { targetId: id }, { timeoutMs: OWNER_COMMAND_TIMEOUT_MS }).catch(() => undefined);
|
|
191
|
+
throw e;
|
|
192
|
+
}
|
|
193
|
+
} finally {
|
|
194
|
+
this.reserved--;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Close a hidden tab over the owner. Closing the target ends the owner's session on it. When
|
|
200
|
+
* the owner is already gone the tab is too, so this reports success:false like a close of any
|
|
201
|
+
* missing target.
|
|
202
|
+
*/
|
|
203
|
+
async close(id: string): Promise<{ success: boolean }> {
|
|
204
|
+
this.sweep();
|
|
205
|
+
const conn = this.conn;
|
|
206
|
+
const held = this.tabs.delete(id);
|
|
207
|
+
if (!conn || !held) return { success: false };
|
|
208
|
+
const res = await conn.send<{ success?: boolean }>("Target.closeTarget", { targetId: id }, { timeoutMs: OWNER_COMMAND_TIMEOUT_MS });
|
|
209
|
+
return { success: res.success ?? true };
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** Close every hidden tab, then the owner. Best effort and bounded; never throws. */
|
|
213
|
+
async dispose(): Promise<void> {
|
|
214
|
+
const conn = this.conn;
|
|
215
|
+
const ids = [...this.tabs.keys()];
|
|
216
|
+
this.tabs.clear();
|
|
217
|
+
this.conn = undefined;
|
|
218
|
+
if (!conn) return;
|
|
219
|
+
if (conn.isOpen) {
|
|
220
|
+
await Promise.all(ids.map((targetId) => conn.send("Target.closeTarget", { targetId }, { timeoutMs: OWNER_COMMAND_TIMEOUT_MS }).catch(() => undefined)));
|
|
221
|
+
}
|
|
222
|
+
conn.close();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/* ------------------------------ process registry ------------------------------ */
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* One owner per endpoint base, MODULE SCOPE like ./driver.ts's beaconSessions: the state belongs
|
|
230
|
+
* to the process (the MCP server), and named endpoints are separate browsers whose target ids
|
|
231
|
+
* mean nothing to each other.
|
|
232
|
+
*/
|
|
233
|
+
const owners = new Map<string, HiddenTabOwner>();
|
|
234
|
+
|
|
235
|
+
/** The owner for `base`, created on first use with `deps`. */
|
|
236
|
+
export function hiddenTabOwner(base: string, deps: () => HiddenTabOwnerDeps): HiddenTabOwner {
|
|
237
|
+
let owner = owners.get(base);
|
|
238
|
+
if (!owner) {
|
|
239
|
+
owner = new HiddenTabOwner(deps());
|
|
240
|
+
owners.set(base, owner);
|
|
241
|
+
}
|
|
242
|
+
return owner;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** The owner for `base` if one was ever created. Never creates one. */
|
|
246
|
+
export function existingHiddenTabOwner(base: string): HiddenTabOwner | undefined {
|
|
247
|
+
return owners.get(base);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** True when `id` is a live hidden tab on endpoint `base`. */
|
|
251
|
+
export function isHiddenTab(base: string, id: string): boolean {
|
|
252
|
+
return owners.get(base)?.has(id) ?? false;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Relabel this process's hidden tabs in a target listing: type "other" becomes "page" with
|
|
257
|
+
* `hidden: true`, so every selector arm (index, url, title, label, the default) and list_pages
|
|
258
|
+
* see them as the pages they are. They move to the END of the listing, so the visible tabs keep
|
|
259
|
+
* their indexes and a call with no target still lands on the same visible tab as before.
|
|
260
|
+
*
|
|
261
|
+
* Returns the SAME array when this process holds no hidden tab on `base`, so with the feature off
|
|
262
|
+
* the listing is untouched. Only ids this process created are relabeled: another process's hidden
|
|
263
|
+
* tabs, and Vivaldi's own "other" targets, are left alone.
|
|
264
|
+
*/
|
|
265
|
+
export function markHiddenTargets(base: string, targets: Target[]): Target[] {
|
|
266
|
+
const owner = owners.get(base);
|
|
267
|
+
if (!owner) return targets;
|
|
268
|
+
const hidden = new Set(owner.ids());
|
|
269
|
+
if (hidden.size === 0) return targets;
|
|
270
|
+
const visible: Target[] = [];
|
|
271
|
+
const marked: Target[] = [];
|
|
272
|
+
for (const t of targets) {
|
|
273
|
+
if (hidden.has(t.id)) marked.push({ ...t, type: "page", hidden: true });
|
|
274
|
+
else visible.push(t);
|
|
275
|
+
}
|
|
276
|
+
return marked.length ? [...visible, ...marked] : targets;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/** Close every hidden tab on every endpoint and the owner connections. The MCP server's shutdown
|
|
280
|
+
* path (via the CDP driver's dispose). */
|
|
281
|
+
export async function disposeHiddenTabs(): Promise<void> {
|
|
282
|
+
const all = [...owners.values()];
|
|
283
|
+
owners.clear();
|
|
284
|
+
await Promise.all(all.map((o) => o.dispose()));
|
|
285
|
+
}
|
package/src/client.ts
CHANGED
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
|
|
28
28
|
import { detectEndpoint, resetEndpointCache, type CdpTransport } from "./cdp/endpoint.ts";
|
|
29
29
|
import { openSession, withBrowserSocket, type PageConnection } from "./cdp/session.ts";
|
|
30
|
+
import { markHiddenTargets } from "./cdp/hiddenTabs.ts";
|
|
30
31
|
export { SessionConnection, withBrowserSocket, type PageConnection } from "./cdp/session.ts";
|
|
31
32
|
/**
|
|
32
33
|
* Base HTTP origin of the DEFAULT DevTools endpoint, fixed at import (CDP_BASE, else
|
|
@@ -197,6 +198,12 @@ export class CdpConnection {
|
|
|
197
198
|
});
|
|
198
199
|
}
|
|
199
200
|
|
|
201
|
+
/** False once the socket closed (either side) or before connect(). The hidden-tab owner reads
|
|
202
|
+
* this to notice that the tabs it kept alive died with it. */
|
|
203
|
+
get isOpen(): boolean {
|
|
204
|
+
return !this.closed && this.ws !== undefined;
|
|
205
|
+
}
|
|
206
|
+
|
|
200
207
|
close(): void {
|
|
201
208
|
this.closed = true;
|
|
202
209
|
this.rejectAll(new CdpError("closed by caller"));
|
|
@@ -280,11 +287,13 @@ async function getTargetsOverBrowserWs(): Promise<Target[]> {
|
|
|
280
287
|
*/
|
|
281
288
|
export async function listTargets(): Promise<Target[]> {
|
|
282
289
|
const base = currentEndpoint().base;
|
|
283
|
-
|
|
290
|
+
// markHiddenTargets returns the listing untouched unless this process holds hidden tabs on this
|
|
291
|
+
// endpoint (CDP_HIDDEN_TABS, see cdp/hiddenTabs.ts).
|
|
292
|
+
if (knownTransports.get(base) === "browser-ws") return markHiddenTargets(base, await getTargetsOverBrowserWs());
|
|
284
293
|
try {
|
|
285
294
|
const listing = await httpJson<Target[]>("/json/list");
|
|
286
295
|
knownTransports.set(base, "http");
|
|
287
|
-
return listing;
|
|
296
|
+
return markHiddenTargets(base, listing);
|
|
288
297
|
} catch (httpError) {
|
|
289
298
|
// Switch only when detection says this endpoint really serves no `/json`.
|
|
290
299
|
// A Chrome that does serve it can still fail one `/json/list` (restarting,
|
|
@@ -301,7 +310,7 @@ export async function listTargets(): Promise<Target[]> {
|
|
|
301
310
|
throw httpError;
|
|
302
311
|
});
|
|
303
312
|
knownTransports.set(base, "browser-ws");
|
|
304
|
-
return targets;
|
|
313
|
+
return markHiddenTargets(base, targets);
|
|
305
314
|
}
|
|
306
315
|
}
|
|
307
316
|
|
package/src/driver.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ADR-001: one browser-neutral Driver interface behind the
|
|
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 --------------------------------- */
|
|
@@ -212,6 +216,12 @@ export interface PageInfo {
|
|
|
212
216
|
title: string;
|
|
213
217
|
/** CDP target type ("page", "iframe", "worker", ...), when the driver has one. Additive: BiDi leaves it unset. */
|
|
214
218
|
type?: string;
|
|
219
|
+
/** True for a hidden tab (CDP_HIDDEN_TABS=1, MCP server only): it is live and drivable, but it
|
|
220
|
+
* is in no browser window, so the user cannot see it. Absent otherwise. */
|
|
221
|
+
hidden?: boolean;
|
|
222
|
+
/** Set only by activatePage on a hidden tab: that tab cannot be shown in place, so the driver
|
|
223
|
+
* opened its URL in a new visible tab (`id`) and closed the hidden one, whose id this is. */
|
|
224
|
+
revealedFrom?: string;
|
|
215
225
|
}
|
|
216
226
|
|
|
217
227
|
/** How a caller points at an element. Exactly one field is set. */
|
|
@@ -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) =
|
|
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/leases-tools.ts
CHANGED
|
@@ -45,6 +45,9 @@ export interface ClaimPageResult {
|
|
|
45
45
|
* in the answer so a caller knows without a second lookup whether
|
|
46
46
|
* release_page will close the tab. */
|
|
47
47
|
opened: boolean;
|
|
48
|
+
/** true when the tab this call created is a hidden tab (CDP_HIDDEN_TABS): live and drivable,
|
|
49
|
+
* but in no window, so no human can see it. Absent otherwise. */
|
|
50
|
+
hidden?: true;
|
|
48
51
|
/**
|
|
49
52
|
* Milliseconds since the last input this server cannot account for — i.e.
|
|
50
53
|
* since a HUMAN last touched this tab. See src/activity.ts for how that
|
|
@@ -134,6 +137,7 @@ export async function claimPage(
|
|
|
134
137
|
let targetId: string;
|
|
135
138
|
let url: string;
|
|
136
139
|
let opened: boolean;
|
|
140
|
+
let hidden = false;
|
|
137
141
|
if (hasTarget) {
|
|
138
142
|
// Gate-free on purpose: see the header. No tab is created on this path,
|
|
139
143
|
// including when nothing matches.
|
|
@@ -161,6 +165,7 @@ export async function claimPage(
|
|
|
161
165
|
targetId = page.id;
|
|
162
166
|
url = page.url;
|
|
163
167
|
opened = true;
|
|
168
|
+
hidden = page.hidden === true;
|
|
164
169
|
}
|
|
165
170
|
// Gate-free, before the claim, and only for a takeover: a tab this call is
|
|
166
171
|
// about to CREATE cannot have a human in it, so asking would be theatre.
|
|
@@ -185,6 +190,7 @@ export async function claimPage(
|
|
|
185
190
|
ttlMs: record.ttlMs,
|
|
186
191
|
expiresAt: record.lastUsedAt + record.ttlMs,
|
|
187
192
|
opened,
|
|
193
|
+
...(hidden ? { hidden: true as const } : {}),
|
|
188
194
|
// Absent, not null, when the backend has no beacon at all: "cannot answer"
|
|
189
195
|
// and "answered, no data" are different facts (ADR-001's absent-over-
|
|
190
196
|
// throwing rule applied to a field rather than to a whole tool).
|
package/src/leases.ts
CHANGED
|
@@ -114,6 +114,12 @@ export function markLongLivedProcess(value = true): void {
|
|
|
114
114
|
longLived = value;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
/** Whether markLongLivedProcess ran: true in the MCP server, false under the CLI. Hidden tabs
|
|
118
|
+
* (cdp/hiddenTabs.ts) gate on it for the same reason requireLease does. */
|
|
119
|
+
export function isLongLivedProcess(): boolean {
|
|
120
|
+
return longLived;
|
|
121
|
+
}
|
|
122
|
+
|
|
117
123
|
/**
|
|
118
124
|
* Strict mode: every tool call acquires a lease for the tab it resolves, and
|
|
119
125
|
* stale agent tabs are reaped on read. Off by default, so 1.4.0 consumers are
|