@jackwener/browsermcp 0.0.34-embedded.3 → 0.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/CHANGELOG.md +2 -24
  2. package/README.md +1 -92
  3. package/dist/docs/api-reference.md +10 -4
  4. package/dist/docs/errors.md +24 -0
  5. package/dist/docs/js-tool.md +10 -2
  6. package/dist/docs/tab-lifecycle.md +1 -1
  7. package/dist/src/api/api.js +2 -1
  8. package/dist/src/api/api.js.map +1 -1
  9. package/dist/src/api/browser.js +7 -1
  10. package/dist/src/api/browser.js.map +1 -1
  11. package/dist/src/api/tab.js +9 -6
  12. package/dist/src/api/tab.js.map +1 -1
  13. package/dist/src/backends/extension-page.js +8 -1
  14. package/dist/src/backends/extension-page.js.map +1 -1
  15. package/dist/src/docs/manifest.js +3 -6
  16. package/dist/src/docs/manifest.js.map +1 -1
  17. package/dist/src/mcp/js-session.js +29 -18
  18. package/dist/src/mcp/js-session.js.map +1 -1
  19. package/dist/src/mcp/js-worker.mjs +46 -15
  20. package/dist/src/protocol.js +1 -1
  21. package/dist/src/protocol.js.map +1 -1
  22. package/dist/src/shared/api-contract.js +117 -0
  23. package/dist/src/shared/api-contract.js.map +1 -0
  24. package/docs/api-reference.md +10 -4
  25. package/docs/errors.md +24 -0
  26. package/docs/js-tool.md +10 -2
  27. package/docs/tab-lifecycle.md +1 -1
  28. package/extension/dist/background.js +20043 -274
  29. package/package.json +3 -12
  30. package/dist/src/api/action-input.d.ts +0 -47
  31. package/dist/src/api/agent.d.ts +0 -10
  32. package/dist/src/api/api.d.ts +0 -50
  33. package/dist/src/api/browser.d.ts +0 -90
  34. package/dist/src/api/context.d.ts +0 -7
  35. package/dist/src/api/diff.d.ts +0 -8
  36. package/dist/src/api/errors.d.ts +0 -12
  37. package/dist/src/api/network.d.ts +0 -10
  38. package/dist/src/api/observation.d.ts +0 -4
  39. package/dist/src/api/streams.d.ts +0 -13
  40. package/dist/src/api/tab.d.ts +0 -315
  41. package/dist/src/api/webmcp.d.ts +0 -19
  42. package/dist/src/backends/backend.d.ts +0 -14
  43. package/dist/src/backends/browser-helpers.d.ts +0 -17
  44. package/dist/src/backends/extension-page.d.ts +0 -5
  45. package/dist/src/backends/managed-page.d.ts +0 -59
  46. package/dist/src/backends/page-transport.d.ts +0 -10
  47. package/dist/src/backends/page-types.d.ts +0 -82
  48. package/dist/src/docs/embedded.d.ts +0 -2
  49. package/dist/src/docs/embedded.js +0 -39
  50. package/dist/src/docs/embedded.js.map +0 -1
  51. package/dist/src/docs/manifest.d.ts +0 -23
  52. package/dist/src/docs/surface.d.ts +0 -12
  53. package/dist/src/electron/backend.d.ts +0 -50
  54. package/dist/src/electron/backend.js +0 -371
  55. package/dist/src/electron/backend.js.map +0 -1
  56. package/dist/src/electron/chrome.d.ts +0 -24
  57. package/dist/src/electron/chrome.js +0 -133
  58. package/dist/src/electron/chrome.js.map +0 -1
  59. package/dist/src/electron/driver.d.ts +0 -42
  60. package/dist/src/electron/driver.js +0 -238
  61. package/dist/src/electron/driver.js.map +0 -1
  62. package/dist/src/electron/event-buffer.d.ts +0 -16
  63. package/dist/src/electron/event-buffer.js +0 -59
  64. package/dist/src/electron/event-buffer.js.map +0 -1
  65. package/dist/src/electron/page.js +0 -834
  66. package/dist/src/electron/registry.d.ts +0 -104
  67. package/dist/src/electron/registry.js +0 -316
  68. package/dist/src/electron/registry.js.map +0 -1
  69. package/dist/src/electron/streams.d.ts +0 -16
  70. package/dist/src/electron/streams.js +0 -48
  71. package/dist/src/electron/streams.js.map +0 -1
  72. package/dist/src/embedded/index.d.ts +0 -39
  73. package/dist/src/embedded/index.js +0 -71
  74. package/dist/src/embedded/index.js.map +0 -1
  75. package/dist/src/host/bridge.d.ts +0 -50
  76. package/dist/src/host/doctor.d.ts +0 -34
  77. package/dist/src/host/extension.d.ts +0 -3
  78. package/dist/src/host/host.d.ts +0 -3
  79. package/dist/src/host/ipc.d.ts +0 -14
  80. package/dist/src/host/jsonc-config.d.ts +0 -1
  81. package/dist/src/host/launch.d.ts +0 -11
  82. package/dist/src/host/native-messaging.d.ts +0 -28
  83. package/dist/src/host/opencode.d.ts +0 -6
  84. package/dist/src/host/pi.d.ts +0 -6
  85. package/dist/src/host/registration.d.ts +0 -24
  86. package/dist/src/host/setup.d.ts +0 -7
  87. package/dist/src/host/socket.d.ts +0 -25
  88. package/dist/src/host/state.d.ts +0 -39
  89. package/dist/src/launcher/stdio.d.ts +0 -3
  90. package/dist/src/lib/paths.d.ts +0 -1
  91. package/dist/src/lib/sources.d.ts +0 -5
  92. package/dist/src/main.d.ts +0 -2
  93. package/dist/src/mcp/catalog.d.ts +0 -202
  94. package/dist/src/mcp/js-session.d.ts +0 -63
  95. package/dist/src/mcp/server.d.ts +0 -15
  96. package/dist/src/protocol.d.ts +0 -318
  97. package/dist/src/recon/analyzer.d.ts +0 -43
  98. package/dist/src/recon/discover.d.ts +0 -48
  99. package/dist/src/runtime/runtime.d.ts +0 -148
  100. package/dist/src/shared/aria-tree.d.ts +0 -2
  101. package/dist/src/shared/element-ref.d.ts +0 -4
  102. package/dist/src/shared/engine.d.ts +0 -50
  103. package/dist/src/shared/injected-source.d.ts +0 -2
  104. package/dist/src/shared/page-contract.d.ts +0 -256
  105. package/dist/src/sites/define.d.ts +0 -28
  106. package/dist/src/sites/drafts.d.ts +0 -39
  107. package/dist/src/sites/executor.d.ts +0 -34
  108. package/dist/src/sites/loader.d.ts +0 -84
  109. package/dist/src/sites/schema.d.ts +0 -11
  110. package/dist/src/version.d.ts +0 -2
@@ -1,318 +0,0 @@
1
- /**
2
- * browsermcp host ⇄ extension protocol.
3
- *
4
- * Transport: Chrome Native Messaging (4-byte LE length + JSON) between the
5
- * Chrome-spawned host process and the extension service worker. The host is
6
- * the MCP server; the extension is the browser runtime that owns the
7
- * chrome.debugger session, tab leases, tab groups, and cursor overlay.
8
- *
9
- * Envelope kinds:
10
- * host → ext: { type: 'command', command: Command }
11
- * ext → host: { type: 'hello', ... } | { type: 'result', result: Result } | { type: 'event', event: BrowserEvent }
12
- */
13
- export type Action = 'chrome-call' | 'chrome-describe' | 'stream-watch' | 'stream-read' | 'stream-close' | 'streams-reset' | 'extension-logs' | 'exec' | 'navigate' | 'tabs' | 'cookies' | 'screenshot' | 'network-capture-start' | 'network-capture-read' | 'wait-download' | 'cdp' | 'frames' | 'session-name' | 'session-finalize' | 'user-tabs' | 'claim' | 'close-user-tabs' | 'mark' | 'dialog' | 'history' | 'console' | 'act' | 'cursor' | 'visibility' | 'ping';
14
- export interface Command {
15
- id: string;
16
- action: Action;
17
- /** Logical session (one MCP session ⇄ one named tab group). */
18
- session?: string;
19
- /** Surface policy: interactive browser session vs. background adapter run. */
20
- surface?: 'browser' | 'adapter';
21
- /** Stable Chrome tab id, encoded as a string; the extension checks session ownership. */
22
- page?: string;
23
- code?: string;
24
- chromeMethod?: string;
25
- chromeArgs?: unknown[];
26
- streamSource?: 'chrome' | 'cdp' | 'console' | 'extension';
27
- eventName?: string;
28
- streamId?: string;
29
- streamOptions?: StreamOptions;
30
- streamRead?: StreamReadOptions;
31
- cdpTarget?: {
32
- frameId: string;
33
- };
34
- /** exec: evaluate in the page's main world (default) or in the engine's isolated world */
35
- world?: 'main' | 'engine';
36
- url?: string;
37
- op?: 'list' | 'new' | 'close' | 'release';
38
- dialogOp?: 'get' | 'accept' | 'dismiss';
39
- historyOp?: 'reload' | 'back' | 'forward';
40
- /** console read: cursor paging */
41
- afterSequence?: number;
42
- limit?: number;
43
- /** user-tabs: case-insensitive title or URL search */
44
- query?: string;
45
- levels?: string[];
46
- filter?: string;
47
- domain?: string;
48
- format?: 'png' | 'jpeg';
49
- quality?: number;
50
- fullPage?: boolean;
51
- width?: number;
52
- height?: number;
53
- text?: string;
54
- pattern?: string;
55
- timeoutMs?: number;
56
- cdpMethod?: string;
57
- cdpParams?: Record<string, unknown>;
58
- /** Engine and Main World calls use the same frame path as actions. */
59
- frame?: FrameStep | FrameStep[];
60
- deadlineAt?: number;
61
- /** session-name */
62
- name?: string;
63
- /** claim: tabId/active choose a tab; url/title find a unique tab; expectedUrl/expectedTitle verify its current identity. */
64
- claim?: {
65
- tabId?: number;
66
- active?: boolean;
67
- title?: string;
68
- url?: string;
69
- expectedUrl?: string;
70
- expectedTitle?: string;
71
- };
72
- /** close-user-tabs: numeric Chrome ids, without adopting the tabs into the session. */
73
- tabIds?: number[];
74
- /** mark / finalize */
75
- mark?: 'deliverable' | 'handoff' | null;
76
- keep?: Array<{
77
- page: string;
78
- status: 'deliverable' | 'handoff';
79
- }>;
80
- /** cursor */
81
- x?: number;
82
- y?: number;
83
- waitForArrival?: boolean;
84
- /** visibility */
85
- visible?: boolean;
86
- /** act */
87
- act?: ActSpec;
88
- }
89
- export type ActKind = 'click' | 'dblclick' | 'hover' | 'focus' | 'fill' | 'type' | 'press' | 'check' | 'uncheck' | 'select' | 'scroll' | 'upload' | 'drag';
90
- export interface ActTarget {
91
- ref?: number | string; /** raw Playwright selector, e.g. the `selector` returned by find */
92
- selector?: string; /** scope: selector of a container, or an observed ref — the target is resolved inside it (generic labels are ambiguous by default; scope them) */
93
- within?: string;
94
- nth?: number;
95
- role?: string;
96
- name?: string;
97
- label?: string;
98
- text?: string;
99
- testid?: string;
100
- x?: number;
101
- y?: number; /** iframe(s) to enter first, outermost first: css selector of the <iframe> or its 0-based index; a string may chain with ' >> ' (Codex enter-frame); same- and cross-origin frames are handled alike */
102
- frame?: FrameStep | FrameStep[];
103
- }
104
- export type FrameStep = string | number;
105
- export interface ActSpec {
106
- kind: ActKind;
107
- target: ActTarget;
108
- value?: string;
109
- timeoutMs?: number;
110
- settleMs?: number;
111
- cursor?: boolean;
112
- force?: boolean;
113
- /**
114
- * click only. `cdp` (default) is a real mouse event and fails if the page did not receive it.
115
- * `dom` runs HTMLElement.click() and sends no mouse event — only when the event was not delivered or the element has no box.
116
- */
117
- method?: 'cdp' | 'dom';
118
- /** scroll */
119
- direction?: 'up' | 'down' | 'left' | 'right';
120
- amount?: number;
121
- /** upload */
122
- files?: string[];
123
- /** drag */
124
- to?: ActTarget;
125
- }
126
- /** A native JavaScript dialog currently blocking a tab. */
127
- export interface DialogInfo {
128
- type: 'alert' | 'confirm' | 'prompt' | 'beforeunload';
129
- message: string;
130
- defaultPrompt?: string;
131
- url?: string;
132
- openedAt: number;
133
- }
134
- export interface ConsoleEntry {
135
- seq: number;
136
- level: 'debug' | 'info' | 'log' | 'warn' | 'error';
137
- message: string;
138
- timestamp: string;
139
- url?: string;
140
- line?: number;
141
- }
142
- export interface ActResult {
143
- ok: true;
144
- kind: ActKind;
145
- ref?: string | null;
146
- matches_n: number;
147
- visible_n: number;
148
- match_level: 'exact';
149
- point: {
150
- x: number;
151
- y: number;
152
- };
153
- method: 'cdp' | 'dom';
154
- hit: 'target' | 'ancestor' | 'other';
155
- tag: string;
156
- /** ms spent resolving the target (visible/enabled/stable/hit-test) */
157
- waitedMs: number;
158
- /** end-to-end ms and its breakdown: resolve → dispatch (input events + verification) → settle (DOM quiet wait) */
159
- elapsedMs?: number;
160
- timings?: {
161
- resolveMs: number;
162
- actionMs: number;
163
- settleMs: number;
164
- };
165
- /** Playwright-generated selector for locating the same element again. */
166
- selector?: string;
167
- /** set when the action triggered a navigation that has now finished */
168
- navigated?: boolean;
169
- url?: string;
170
- filled?: boolean;
171
- verified?: boolean;
172
- actual?: string;
173
- checked?: boolean;
174
- changed?: boolean;
175
- key?: string;
176
- /** options actually selected; upload count */
177
- selected?: string[];
178
- files?: number;
179
- /** Child tabs from this source tab while the action ran; each is claimed into the same session. */
180
- openedTabs?: Array<{
181
- page?: string;
182
- tabId: number;
183
- url?: string;
184
- title?: string;
185
- pending?: true;
186
- }>;
187
- /** Page.downloadWillBegin events observed while this action ran; completion is checked separately. */
188
- download?: {
189
- afterSequence: number;
190
- started: Array<{
191
- seq: number;
192
- guid?: string;
193
- url: string;
194
- suggestedFilename: string;
195
- }>;
196
- };
197
- }
198
- export interface DownloadWaitResult {
199
- downloaded: boolean;
200
- started: boolean;
201
- sequence?: number;
202
- suggestedFilename?: string;
203
- /** Chrome has no source-tab field for files; this new download was paired with the tab's Page event by URL. */
204
- association?: 'url+event';
205
- candidates?: number;
206
- id?: number;
207
- filename?: string;
208
- url?: string;
209
- finalUrl?: string;
210
- mime?: string;
211
- totalBytes?: number;
212
- state?: string;
213
- danger?: string;
214
- error?: string;
215
- elapsedMs: number;
216
- }
217
- export interface CloseUserTabsResult {
218
- complete: boolean;
219
- closed: number[];
220
- failed: Array<{
221
- tabId: number;
222
- reason: string;
223
- }>;
224
- }
225
- export interface Result {
226
- id: string;
227
- ok: boolean;
228
- /** result payload on success; structured error details (e.g. candidates) on failure */
229
- data?: unknown;
230
- error?: string;
231
- errorCode?: string;
232
- errorHint?: string;
233
- page?: string;
234
- }
235
- export type BrowserEvent = {
236
- kind: 'tab_created' | 'tab_acquired' | 'tab_closed' | 'tab_released' | 'tab_navigated' | 'tab_detached' | 'tab_attached';
237
- session: string;
238
- page?: string;
239
- tabId: number;
240
- url?: string;
241
- title?: string;
242
- origin?: 'agent' | 'user';
243
- } | {
244
- kind: 'download';
245
- state: string;
246
- filename?: string;
247
- url?: string;
248
- } | {
249
- kind: 'dialog';
250
- page?: string;
251
- dialogType: string;
252
- message?: string;
253
- } | {
254
- kind: 'webmcp_changed';
255
- page?: string;
256
- } | {
257
- kind: 'session_released';
258
- session: string;
259
- reason: string;
260
- };
261
- export type HostToExt = {
262
- type: 'command';
263
- command: Command;
264
- } | {
265
- type: 'ready';
266
- version: string;
267
- };
268
- /** Advisory contract revision; individual capabilities and command results decide what works. */
269
- export declare const PROTOCOL_REVISION = 3;
270
- export type BrowserFeature = 'chrome-api' | 'streams' | 'extension-logs' | 'page-evaluate' | 'frame-evaluate' | 'cdp' | 'network' | 'frames' | 'dialogs' | 'console' | 'downloads' | 'viewport' | 'visibility' | 'webmcp';
271
- export type ExtToHost = {
272
- type: 'hello';
273
- browserId: string;
274
- extensionVersion: string;
275
- protocolRevision?: number;
276
- features?: BrowserFeature[];
277
- } | {
278
- type: 'result';
279
- result: Result;
280
- } | {
281
- type: 'event';
282
- event: BrowserEvent;
283
- };
284
- export declare const NATIVE_HOST_NAME = "com.browsermcp.host";
285
- /** Chrome caps host → extension frames at 1 MiB. */
286
- export declare const MAX_FRAME_BYTES: number;
287
- /** Opaque cursors identify both a buffer generation and a sequence. */
288
- export interface StreamReadOptions {
289
- cursor?: string;
290
- limit?: number;
291
- levels?: string[];
292
- filter?: string;
293
- }
294
- export interface StreamOptions {
295
- capacity?: number; /** Chrome addListener filter arguments, after the listener. */
296
- args?: unknown[];
297
- }
298
- export interface StreamEntry {
299
- seq: number;
300
- timestamp: string;
301
- event?: string;
302
- args?: unknown[];
303
- params?: unknown;
304
- level?: string;
305
- message?: string;
306
- url?: string;
307
- line?: number;
308
- truncated?: boolean;
309
- }
310
- export interface StreamBatch {
311
- entries: StreamEntry[];
312
- cursor: string;
313
- hasMore: boolean;
314
- dropped: number;
315
- reset: boolean;
316
- closed?: boolean;
317
- reason?: string;
318
- }
@@ -1,43 +0,0 @@
1
- import { type Node } from 'web-tree-sitter';
2
- export declare const EXPR = "EXPR";
3
- export interface UrlMatch {
4
- url: string;
5
- method: string;
6
- type: string;
7
- queryParams: string[];
8
- bodyParams: string[];
9
- headers?: Record<string, string>;
10
- contentType?: string;
11
- kind: 'api' | 'asset' | 'page' | 'unknown';
12
- line: number;
13
- source: string;
14
- filename?: string;
15
- }
16
- export interface AnalyzeResult {
17
- urls: UrlMatch[];
18
- parseErrors: boolean;
19
- }
20
- export declare function maybeUrl(s: string): boolean;
21
- export declare function decodeString(raw: string): string;
22
- export declare class JsAnalyzer {
23
- private readonly parser;
24
- private static langPromise;
25
- private constructor();
26
- static create(): Promise<JsAnalyzer>;
27
- analyze(source: string, opts?: {
28
- filename?: string;
29
- maxBytes?: number;
30
- }): AnalyzeResult;
31
- private walk;
32
- /** Resolve a node to a string, substituting EXPR for anything unknown. */
33
- resolve(n: Node | null): string;
34
- private objectKeys;
35
- private objectPairs;
36
- private bodyParams;
37
- private line;
38
- private src;
39
- private matchString;
40
- private matchCall;
41
- private matchNew;
42
- private matchAssignment;
43
- }
@@ -1,48 +0,0 @@
1
- /**
2
- * recon.discover — the "static candidates" leg of API discovery.
3
- * Collects the scripts a live page has loaded, runs the JsAnalyzer over them, and merges the
4
- * candidates with dynamic network evidence into a ledger: seen-in-network > api-shaped static > other.
5
- * Candidates are evidence, not contracts: `EXPR` marks unknown dynamic parts.
6
- */
7
- import { type UrlMatch } from './analyzer.js';
8
- import type { RuntimePage } from '../backends/page-types.js';
9
- export interface EndpointCandidate {
10
- url: string;
11
- method: string;
12
- type: string;
13
- kind: UrlMatch['kind'];
14
- queryParams: string[];
15
- bodyParams: string[];
16
- evidence: 'network+static' | 'network' | 'static';
17
- network?: {
18
- status?: number;
19
- contentType?: string;
20
- count: number;
21
- requestId?: string;
22
- };
23
- sources: Array<{
24
- script: string;
25
- line: number;
26
- snippet: string;
27
- }>;
28
- score: number;
29
- }
30
- export interface DiscoverResult {
31
- pageUrl: string | null;
32
- scripts: Array<{
33
- url: string;
34
- bytes: number;
35
- analyzed: boolean;
36
- error?: string;
37
- }>;
38
- endpoints: EndpointCandidate[];
39
- networkEntries: number;
40
- }
41
- export declare function discoverEndpoints(page: RuntimePage, opts?: {
42
- maxScripts?: number;
43
- includeStatic?: boolean;
44
- includeAssets?: boolean;
45
- includeInline?: boolean;
46
- fetchTimeoutMs?: number; /** network entries already harvested by the session (Tab.network); when given the page's capture is not drained */
47
- network?: Array<Record<string, unknown>>;
48
- }): Promise<DiscoverResult>;
@@ -1,148 +0,0 @@
1
- import type { BrowserBackend } from '../backends/backend.js';
2
- import type { ManagedRuntimePage } from '../backends/managed-page.js';
3
- /**
4
- * Runtime — the resident kernel: site registry, per-MCP-session state, and page backends.
5
- * Lives inside the Chrome-spawned host. The stdio launcher proxies to this runtime.
6
- */
7
- import type { ObserveResult } from '../api/tab.js';
8
- import { EventEmitter } from 'node:events';
9
- import type { ExtensionBridge } from '../host/bridge.js';
10
- import type { BrowserEvent } from '../protocol.js';
11
- import { type BrowserFeature } from '../protocol.js';
12
- import { SiteRegistry, type Source } from '../sites/loader.js';
13
- import { type CommandRunResult, type CommandRunError, type PageProvider } from '../sites/executor.js';
14
- import { listDefinedTools, type ToolDefinition } from '../sites/define.js';
15
- import { type DraftStore, type DraftExpectation } from '../sites/drafts.js';
16
- import type { RuntimePage } from '../backends/page-types.js';
17
- import { JsSession } from '../mcp/js-session.js';
18
- export type Backend = 'extension' | 'electron' | 'none';
19
- export interface RuntimeOptions {
20
- bridge?: ExtensionBridge | null;
21
- backend?: BrowserBackend;
22
- sources?: Source[];
23
- userAdaptersDir?: string | null;
24
- sites?: string[];
25
- sitesWrite?: string[];
26
- cursor?: boolean;
27
- log?: (msg: string) => void;
28
- }
29
- export interface SessionState {
30
- id: string;
31
- name?: string;
32
- createdAt: number;
33
- browserPage?: RuntimePage;
34
- browserPagePromise?: Promise<RuntimePage>;
35
- /** One page object per tab (same bridge, own identity); the session page above carries no tab and serves session-scope calls. */
36
- pages: Map<string, RuntimePage>;
37
- /** Per-tab serialization of page operations. */
38
- tabLocks: Map<string, Promise<void>>;
39
- enabledSites: Map<string, {
40
- write: boolean;
41
- }>;
42
- capabilities: Set<string>;
43
- js?: JsSession;
44
- observationSeq: number;
45
- /** Most recent immutable observation per tab; replaced on fresh capture, cleared on release. */
46
- observations: Map<string, ObserveResult>;
47
- webmcpCatalogs: Map<string, string>;
48
- /** Document namespace → frame route, shared by handles for the same tab. */
49
- refFrames: Map<string, Map<string, import('../protocol.js').FrameStep[]>>;
50
- lastObserve: Map<string, {
51
- id: string;
52
- text: string;
53
- }>;
54
- /** Network entries seen per tab, with monotonically increasing sequence numbers for cursor-based reads. */
55
- netLog: Map<string, {
56
- seq: number;
57
- entries: Array<Record<string, unknown> & {
58
- seq: number;
59
- }>;
60
- seen: Set<string>;
61
- bodyChars: number;
62
- }>;
63
- finalized: boolean;
64
- }
65
- export interface DoctorReport {
66
- backend: Backend;
67
- browser: {
68
- connected: boolean;
69
- features: BrowserFeature[];
70
- };
71
- extension: {
72
- connected: boolean;
73
- protocolMatches: boolean | null;
74
- protocolWarning: string | null;
75
- version: string | null;
76
- protocolRevision: number | null;
77
- hostProtocolRevision: number;
78
- features: BrowserFeature[];
79
- };
80
- sites: number;
81
- commands: number;
82
- definedTools: number;
83
- sessions: number;
84
- cursor: boolean;
85
- }
86
- export interface RuntimeEvents {
87
- 'browser-event': [BrowserEvent];
88
- 'features-changed': [BrowserFeature[]];
89
- 'tools-changed': [{
90
- site?: string;
91
- }];
92
- log: [string];
93
- }
94
- export declare class Runtime extends EventEmitter<RuntimeEvents> implements PageProvider {
95
- readonly registry: SiteRegistry;
96
- readonly userAdaptersDir: string | null;
97
- private readonly drafts;
98
- readonly sessions: Map<string, SessionState>;
99
- private readonly adapterRuns;
100
- private readonly adapterCallContext;
101
- private readonly siteApis;
102
- bridge: ExtensionBridge | null;
103
- private readonly browserBackend?;
104
- private readonly unsubscribeBackend?;
105
- readonly cursorEnabled: boolean;
106
- readonly configSites: string[];
107
- readonly configSitesWrite: string[];
108
- readonly startedAt: number;
109
- constructor(opts?: RuntimeOptions);
110
- init(): Promise<void>;
111
- backend(): Backend;
112
- browserCommand(action: import('../protocol.js').Command['action'], params?: Partial<import('../protocol.js').Command>): Promise<{
113
- data: unknown;
114
- }>;
115
- browserAvailable(): boolean;
116
- features(): BrowserFeature[];
117
- hasFeature(feature: BrowserFeature): boolean;
118
- session(id: string): SessionState;
119
- /** One interactive browser page per MCP session (tabs are page identities on it). */
120
- getBrowserPage(sessionId: string): Promise<RuntimePage>;
121
- /** The page object bound to one tab of a session: commands carry the tab's identity, nothing is switched or shared. */
122
- pageFor(sessionId: string, pageId: string): Promise<RuntimePage>;
123
- forgetPage(sessionId: string, pageId: string): void;
124
- /** Bind each adapter call to the site's current live tab; the extension owns that selection. */
125
- getAdapterPage(site: string): Promise<RuntimePage>;
126
- private createPage;
127
- /** Adapters run on the browser object model: a Tab bound to the adapter page, plus sites/recon. */
128
- toolContext(page: RuntimePage, site: string): Promise<Record<string, unknown>>;
129
- isManagedPage(page: RuntimePage): page is ManagedRuntimePage;
130
- runSite(site: string, name: string, args: Record<string, unknown>, opts?: {
131
- timeoutMs?: number;
132
- signal?: AbortSignal;
133
- sessionId?: string;
134
- }): Promise<CommandRunResult | CommandRunError>;
135
- private runCommand;
136
- private draftStore;
137
- listTools(): ReturnType<typeof listDefinedTools>;
138
- defineTool(def: ToolDefinition): ReturnType<DraftStore['createDraft']>;
139
- tryToolDraft(id: string, args: Record<string, unknown>, expect: DraftExpectation, sessionId?: string): ReturnType<DraftStore['tryDraft']>;
140
- activateToolDraft(id: string): Promise<ReturnType<DraftStore['activateDraft']>>;
141
- discardToolDraft(id: string): ReturnType<DraftStore['discardDraft']>;
142
- removeTool(site: string, name: string): Promise<boolean>;
143
- closeSession(id: string, opts?: {
144
- finalize?: boolean;
145
- }): Promise<void>;
146
- shutdown(): Promise<void>;
147
- doctor(): DoctorReport;
148
- }
@@ -1,2 +0,0 @@
1
- /** Remove only inert, unnamed wrappers; preserve addressable nodes and all their context. */
2
- export declare function compactAria(text: string): string;
@@ -1,4 +0,0 @@
1
- /** Public element refs are opaque; older connected extensions may still emit unscoped refs. */
2
- export declare const ELEMENT_REF_SOURCE: string;
3
- export declare const ELEMENT_REF: RegExp;
4
- export declare const ARIA_REF_LINE: RegExp;
@@ -1,50 +0,0 @@
1
- import type { ActSpec, ActResult, ActTarget, FrameStep } from '../protocol.js';
2
- export { ENGINE_GLOBAL, PAGE_GLOBAL } from './page-contract.js';
3
- /** Evaluate once per world: installs Playwright's InjectedScript as globalThis.__browsermcpInjected, then the page module. */
4
- export declare function installEngineJs(injectedSource: string, pageModuleSource: string): string;
5
- /** The expression the host evaluates in a world to call one page-module function with JSON arguments. */
6
- export declare function pageCallJs(fn: string, args: unknown): string;
7
- export declare class ActError extends Error {
8
- readonly code: string;
9
- readonly hint?: string | undefined;
10
- readonly extra?: Record<string, unknown> | undefined;
11
- constructor(code: string, message: string, hint?: string | undefined, extra?: Record<string, unknown> | undefined);
12
- }
13
- /** Restore page errors after the JSON boundary, including observation and frame-routing failures. */
14
- export declare function unwrapPageResult(value: unknown): unknown;
15
- /** Compile an agent target into a Playwright selector (the same engines the plugin uses). */
16
- export declare function targetToSelector(t: ActTarget): string | null;
17
- /** Secondary selector tried when the primary finds nothing (e.g. label → placeholder). */
18
- export declare function fallbackSelector(t: ActTarget): string | null;
19
- /** Normalize `target.frame` into ordered steps (outermost first); accepts arrays and Codex's `a >> internal:control=enter-frame >> b`. */
20
- export declare function frameSteps(frame: FrameStep | FrameStep[] | undefined): FrameStep[];
21
- type KeyDef = {
22
- key: string;
23
- code: string;
24
- keyCode: number;
25
- text?: string;
26
- };
27
- export declare function parseKey(spec: string): {
28
- def: KeyDef;
29
- modifiers: number;
30
- };
31
- /** What a runtime edge provides: page-module calls in the target world, raw CDP on the attached target, cursor, navigation wait. */
32
- export interface ActIO {
33
- /** Call `globalThis.__browsermcpPage.<fn>(args)` in the world the action targets. */
34
- call(fn: string, args?: unknown, timeoutMs?: number): Promise<unknown>;
35
- cdp(method: string, params?: Record<string, unknown>): Promise<unknown>;
36
- /** Set files on the remembered Element in its owning isolated world/session. */
37
- setFiles?(files: string[]): Promise<void>;
38
- cursor?(x: number, y: number): Promise<unknown>;
39
- /** Resolve after a navigation the action triggered has finished (or when none started within classifyMs). */
40
- waitForNavigation?(classifyMs: number, timeoutMs: number): Promise<{
41
- navigated: boolean;
42
- url?: string;
43
- }>;
44
- /** When the world is a child frame: the frame's position in the top viewport — input events are dispatched on the tab. */
45
- pointOffset?: {
46
- x: number;
47
- y: number;
48
- };
49
- }
50
- export declare function performAct(io: ActIO, spec: ActSpec): Promise<ActResult>;
@@ -1,2 +0,0 @@
1
- export declare const INJECTED_SOURCE: string;
2
- export declare const INJECTED_VERSION = "1.63.0";