@jackwener/browsermcp 0.0.37-embedded.1 → 0.0.37
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 +2 -40
- package/README.md +0 -91
- package/dist/docs/api-reference.md +5 -5
- package/dist/docs/api-use.md +2 -2
- package/dist/docs/js-tool.md +11 -1
- package/dist/src/api/action-input.js +1 -1
- package/dist/src/api/action-input.js.map +1 -1
- package/dist/src/api/commands.js +3 -3
- package/dist/src/api/commands.js.map +1 -1
- package/dist/src/api/errors.js +46 -2
- package/dist/src/api/errors.js.map +1 -1
- package/dist/src/api/observation.js +5 -0
- package/dist/src/api/observation.js.map +1 -1
- package/dist/src/api/tab.js +28 -3
- package/dist/src/api/tab.js.map +1 -1
- package/dist/src/docs/manifest.js +3 -6
- package/dist/src/docs/manifest.js.map +1 -1
- package/dist/src/mcp/js-session.js +22 -3
- package/dist/src/mcp/js-session.js.map +1 -1
- package/dist/src/mcp/server.js +1 -1
- package/dist/src/mcp/server.js.map +1 -1
- package/dist/src/shared/aria-tree.js +29 -12
- package/dist/src/shared/aria-tree.js.map +1 -1
- package/docs/api-reference.md +5 -5
- package/docs/api-use.md +2 -2
- package/docs/js-tool.md +11 -1
- package/extension/dist/background.js +42 -1
- package/package.json +3 -12
- package/dist/src/api/action-input.d.ts +0 -62
- package/dist/src/api/agent.d.ts +0 -10
- package/dist/src/api/api.d.ts +0 -54
- package/dist/src/api/browser.d.ts +0 -93
- package/dist/src/api/commands.d.ts +0 -452
- package/dist/src/api/context.d.ts +0 -7
- package/dist/src/api/diff.d.ts +0 -8
- package/dist/src/api/errors.d.ts +0 -12
- package/dist/src/api/network.d.ts +0 -10
- package/dist/src/api/observation.d.ts +0 -4
- package/dist/src/api/streams.d.ts +0 -13
- package/dist/src/api/tab.d.ts +0 -312
- package/dist/src/api/webmcp.d.ts +0 -19
- package/dist/src/backends/backend.d.ts +0 -14
- package/dist/src/backends/browser-helpers.d.ts +0 -17
- package/dist/src/backends/extension-page.d.ts +0 -5
- package/dist/src/backends/managed-page.d.ts +0 -50
- package/dist/src/backends/page-transport.d.ts +0 -10
- package/dist/src/backends/page-types.d.ts +0 -82
- package/dist/src/docs/embedded.d.ts +0 -2
- package/dist/src/docs/embedded.js +0 -40
- package/dist/src/docs/embedded.js.map +0 -1
- package/dist/src/docs/manifest.d.ts +0 -23
- package/dist/src/docs/surface.d.ts +0 -12
- package/dist/src/electron/backend.d.ts +0 -50
- package/dist/src/electron/backend.js +0 -375
- package/dist/src/electron/backend.js.map +0 -1
- package/dist/src/electron/chrome.d.ts +0 -24
- package/dist/src/electron/chrome.js +0 -133
- package/dist/src/electron/chrome.js.map +0 -1
- package/dist/src/electron/driver.d.ts +0 -43
- package/dist/src/electron/driver.js +0 -241
- package/dist/src/electron/driver.js.map +0 -1
- package/dist/src/electron/event-buffer.d.ts +0 -16
- package/dist/src/electron/event-buffer.js +0 -59
- package/dist/src/electron/event-buffer.js.map +0 -1
- package/dist/src/electron/page.js +0 -834
- package/dist/src/electron/registry.d.ts +0 -104
- package/dist/src/electron/registry.js +0 -316
- package/dist/src/electron/registry.js.map +0 -1
- package/dist/src/electron/streams.d.ts +0 -16
- package/dist/src/electron/streams.js +0 -48
- package/dist/src/electron/streams.js.map +0 -1
- package/dist/src/embedded/index.d.ts +0 -39
- package/dist/src/embedded/index.js +0 -72
- package/dist/src/embedded/index.js.map +0 -1
- package/dist/src/host/bridge.d.ts +0 -50
- package/dist/src/host/doctor.d.ts +0 -34
- package/dist/src/host/extension.d.ts +0 -3
- package/dist/src/host/host.d.ts +0 -3
- package/dist/src/host/ipc.d.ts +0 -14
- package/dist/src/host/jsonc-config.d.ts +0 -1
- package/dist/src/host/launch.d.ts +0 -11
- package/dist/src/host/native-messaging.d.ts +0 -28
- package/dist/src/host/opencode.d.ts +0 -6
- package/dist/src/host/pi.d.ts +0 -6
- package/dist/src/host/registration.d.ts +0 -24
- package/dist/src/host/setup.d.ts +0 -7
- package/dist/src/host/socket.d.ts +0 -25
- package/dist/src/host/state.d.ts +0 -39
- package/dist/src/launcher/stdio.d.ts +0 -3
- package/dist/src/lib/paths.d.ts +0 -1
- package/dist/src/lib/sources.d.ts +0 -5
- package/dist/src/main.d.ts +0 -2
- package/dist/src/mcp/catalog.d.ts +0 -202
- package/dist/src/mcp/js-session.d.ts +0 -64
- package/dist/src/mcp/server.d.ts +0 -15
- package/dist/src/protocol.d.ts +0 -320
- package/dist/src/recon/analyzer.d.ts +0 -43
- package/dist/src/recon/discover.d.ts +0 -48
- package/dist/src/runtime/runtime.d.ts +0 -148
- package/dist/src/shared/api-contract.d.ts +0 -86
- package/dist/src/shared/aria-tree.d.ts +0 -2
- package/dist/src/shared/element-ref.d.ts +0 -4
- package/dist/src/shared/engine.d.ts +0 -50
- package/dist/src/shared/injected-source.d.ts +0 -2
- package/dist/src/shared/page-contract.d.ts +0 -256
- package/dist/src/sites/define.d.ts +0 -28
- package/dist/src/sites/drafts.d.ts +0 -39
- package/dist/src/sites/executor.d.ts +0 -34
- package/dist/src/sites/loader.d.ts +0 -84
- package/dist/src/sites/schema.d.ts +0 -11
- package/dist/src/version.d.ts +0 -2
package/dist/src/protocol.d.ts
DELETED
|
@@ -1,320 +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 literal title or URL substring; paginated discovery envelope. */
|
|
44
|
-
offset?: number;
|
|
45
|
-
query?: string;
|
|
46
|
-
levels?: string[];
|
|
47
|
-
filter?: string;
|
|
48
|
-
domain?: string;
|
|
49
|
-
format?: 'png' | 'jpeg';
|
|
50
|
-
quality?: number;
|
|
51
|
-
fullPage?: boolean;
|
|
52
|
-
width?: number;
|
|
53
|
-
height?: number;
|
|
54
|
-
text?: string;
|
|
55
|
-
pattern?: string;
|
|
56
|
-
timeoutMs?: number;
|
|
57
|
-
cdpMethod?: string;
|
|
58
|
-
cdpParams?: Record<string, unknown>;
|
|
59
|
-
/** Engine and Main World calls use the same frame path as actions. */
|
|
60
|
-
frame?: FrameStep | FrameStep[];
|
|
61
|
-
deadlineAt?: number;
|
|
62
|
-
/** session-name */
|
|
63
|
-
name?: string;
|
|
64
|
-
/** claim: tabId/active choose a tab; url/title find a unique tab; expectedUrl/expectedTitle verify its current identity. */
|
|
65
|
-
claim?: {
|
|
66
|
-
tabId?: number;
|
|
67
|
-
active?: boolean;
|
|
68
|
-
title?: string;
|
|
69
|
-
url?: string;
|
|
70
|
-
expectedUrl?: string;
|
|
71
|
-
expectedTitle?: string;
|
|
72
|
-
};
|
|
73
|
-
/** close-user-tabs: numeric Chrome ids, without adopting the tabs into the session. */
|
|
74
|
-
tabIds?: number[];
|
|
75
|
-
/** mark / finalize */
|
|
76
|
-
mark?: 'deliverable' | 'handoff' | null;
|
|
77
|
-
closing?: boolean;
|
|
78
|
-
keep?: Array<{
|
|
79
|
-
page: string;
|
|
80
|
-
status: 'deliverable' | 'handoff';
|
|
81
|
-
}>;
|
|
82
|
-
/** cursor */
|
|
83
|
-
x?: number;
|
|
84
|
-
y?: number;
|
|
85
|
-
waitForArrival?: boolean;
|
|
86
|
-
/** visibility */
|
|
87
|
-
visible?: boolean;
|
|
88
|
-
/** act */
|
|
89
|
-
act?: ActSpec;
|
|
90
|
-
}
|
|
91
|
-
export type ActKind = 'click' | 'dblclick' | 'hover' | 'focus' | 'fill' | 'type' | 'press' | 'check' | 'uncheck' | 'select' | 'scroll' | 'upload' | 'drag';
|
|
92
|
-
export interface ActTarget {
|
|
93
|
-
ref?: number | string; /** raw Playwright selector, e.g. the `selector` returned by find */
|
|
94
|
-
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) */
|
|
95
|
-
within?: string;
|
|
96
|
-
nth?: number;
|
|
97
|
-
role?: string;
|
|
98
|
-
name?: string;
|
|
99
|
-
label?: string;
|
|
100
|
-
text?: string;
|
|
101
|
-
testid?: string;
|
|
102
|
-
x?: number;
|
|
103
|
-
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 */
|
|
104
|
-
frame?: FrameStep | FrameStep[];
|
|
105
|
-
}
|
|
106
|
-
export type FrameStep = string | number;
|
|
107
|
-
export interface ActSpec {
|
|
108
|
-
kind: ActKind;
|
|
109
|
-
target: ActTarget;
|
|
110
|
-
value?: string;
|
|
111
|
-
timeoutMs?: number;
|
|
112
|
-
settleMs?: number;
|
|
113
|
-
cursor?: boolean;
|
|
114
|
-
force?: boolean;
|
|
115
|
-
/**
|
|
116
|
-
* click only. `cdp` (default) is a real mouse event and fails if the page did not receive it.
|
|
117
|
-
* `dom` runs HTMLElement.click() and sends no mouse event — only when the event was not delivered or the element has no box.
|
|
118
|
-
*/
|
|
119
|
-
method?: 'cdp' | 'dom';
|
|
120
|
-
/** scroll */
|
|
121
|
-
direction?: 'up' | 'down' | 'left' | 'right';
|
|
122
|
-
amount?: number;
|
|
123
|
-
/** upload */
|
|
124
|
-
files?: string[];
|
|
125
|
-
/** drag */
|
|
126
|
-
to?: ActTarget;
|
|
127
|
-
}
|
|
128
|
-
/** A native JavaScript dialog currently blocking a tab. */
|
|
129
|
-
export interface DialogInfo {
|
|
130
|
-
type: 'alert' | 'confirm' | 'prompt' | 'beforeunload';
|
|
131
|
-
message: string;
|
|
132
|
-
defaultPrompt?: string;
|
|
133
|
-
url?: string;
|
|
134
|
-
openedAt: number;
|
|
135
|
-
}
|
|
136
|
-
export interface ConsoleEntry {
|
|
137
|
-
seq: number;
|
|
138
|
-
level: 'debug' | 'info' | 'log' | 'warn' | 'error';
|
|
139
|
-
message: string;
|
|
140
|
-
timestamp: string;
|
|
141
|
-
url?: string;
|
|
142
|
-
line?: number;
|
|
143
|
-
}
|
|
144
|
-
export interface ActResult {
|
|
145
|
-
ok: true;
|
|
146
|
-
kind: ActKind;
|
|
147
|
-
ref?: string | null;
|
|
148
|
-
matches_n: number;
|
|
149
|
-
visible_n: number;
|
|
150
|
-
match_level: 'exact';
|
|
151
|
-
point: {
|
|
152
|
-
x: number;
|
|
153
|
-
y: number;
|
|
154
|
-
};
|
|
155
|
-
method: 'cdp' | 'dom';
|
|
156
|
-
hit: 'target' | 'ancestor' | 'other';
|
|
157
|
-
tag: string;
|
|
158
|
-
/** ms spent resolving the target (visible/enabled/stable/hit-test) */
|
|
159
|
-
waitedMs: number;
|
|
160
|
-
/** end-to-end ms and its breakdown: resolve → dispatch (input events + verification) → settle (DOM quiet wait) */
|
|
161
|
-
elapsedMs?: number;
|
|
162
|
-
timings?: {
|
|
163
|
-
resolveMs: number;
|
|
164
|
-
actionMs: number;
|
|
165
|
-
settleMs: number;
|
|
166
|
-
};
|
|
167
|
-
/** Playwright-generated selector for locating the same element again. */
|
|
168
|
-
selector?: string;
|
|
169
|
-
/** set when the action triggered a navigation that has now finished */
|
|
170
|
-
navigated?: boolean;
|
|
171
|
-
url?: string;
|
|
172
|
-
filled?: boolean;
|
|
173
|
-
verified?: boolean;
|
|
174
|
-
actual?: string;
|
|
175
|
-
checked?: boolean;
|
|
176
|
-
changed?: boolean;
|
|
177
|
-
key?: string;
|
|
178
|
-
/** options actually selected; upload count */
|
|
179
|
-
selected?: string[];
|
|
180
|
-
files?: number;
|
|
181
|
-
/** Child tabs from this source tab while the action ran; each is claimed into the same session. */
|
|
182
|
-
openedTabs?: Array<{
|
|
183
|
-
page?: string;
|
|
184
|
-
tabId: number;
|
|
185
|
-
url?: string;
|
|
186
|
-
title?: string;
|
|
187
|
-
pending?: true;
|
|
188
|
-
}>;
|
|
189
|
-
/** Page.downloadWillBegin events observed while this action ran; completion is checked separately. */
|
|
190
|
-
download?: {
|
|
191
|
-
afterSequence: number;
|
|
192
|
-
started: Array<{
|
|
193
|
-
seq: number;
|
|
194
|
-
guid?: string;
|
|
195
|
-
url: string;
|
|
196
|
-
suggestedFilename: string;
|
|
197
|
-
}>;
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
export interface DownloadWaitResult {
|
|
201
|
-
downloaded: boolean;
|
|
202
|
-
started: boolean;
|
|
203
|
-
sequence?: number;
|
|
204
|
-
suggestedFilename?: string;
|
|
205
|
-
/** Chrome has no source-tab field for files; this new download was paired with the tab's Page event by URL. */
|
|
206
|
-
association?: 'url+event';
|
|
207
|
-
candidates?: number;
|
|
208
|
-
id?: number;
|
|
209
|
-
filename?: string;
|
|
210
|
-
url?: string;
|
|
211
|
-
finalUrl?: string;
|
|
212
|
-
mime?: string;
|
|
213
|
-
totalBytes?: number;
|
|
214
|
-
state?: string;
|
|
215
|
-
danger?: string;
|
|
216
|
-
error?: string;
|
|
217
|
-
elapsedMs: number;
|
|
218
|
-
}
|
|
219
|
-
export interface CloseUserTabsResult {
|
|
220
|
-
complete: boolean;
|
|
221
|
-
closed: number[];
|
|
222
|
-
failed: Array<{
|
|
223
|
-
tabId: number;
|
|
224
|
-
reason: string;
|
|
225
|
-
}>;
|
|
226
|
-
}
|
|
227
|
-
export interface Result {
|
|
228
|
-
id: string;
|
|
229
|
-
ok: boolean;
|
|
230
|
-
/** result payload on success; structured error details (e.g. candidates) on failure */
|
|
231
|
-
data?: unknown;
|
|
232
|
-
error?: string;
|
|
233
|
-
errorCode?: string;
|
|
234
|
-
errorHint?: string;
|
|
235
|
-
page?: string;
|
|
236
|
-
}
|
|
237
|
-
export type BrowserEvent = {
|
|
238
|
-
kind: 'tab_created' | 'tab_acquired' | 'tab_closed' | 'tab_released' | 'tab_navigated' | 'tab_detached' | 'tab_attached';
|
|
239
|
-
session: string;
|
|
240
|
-
page?: string;
|
|
241
|
-
tabId: number;
|
|
242
|
-
url?: string;
|
|
243
|
-
title?: string;
|
|
244
|
-
origin?: 'agent' | 'user';
|
|
245
|
-
} | {
|
|
246
|
-
kind: 'download';
|
|
247
|
-
state: string;
|
|
248
|
-
filename?: string;
|
|
249
|
-
url?: string;
|
|
250
|
-
} | {
|
|
251
|
-
kind: 'dialog';
|
|
252
|
-
page?: string;
|
|
253
|
-
dialogType: string;
|
|
254
|
-
message?: string;
|
|
255
|
-
} | {
|
|
256
|
-
kind: 'webmcp_changed';
|
|
257
|
-
page?: string;
|
|
258
|
-
} | {
|
|
259
|
-
kind: 'session_released';
|
|
260
|
-
session: string;
|
|
261
|
-
reason: string;
|
|
262
|
-
};
|
|
263
|
-
export type HostToExt = {
|
|
264
|
-
type: 'command';
|
|
265
|
-
command: Command;
|
|
266
|
-
} | {
|
|
267
|
-
type: 'ready';
|
|
268
|
-
version: string;
|
|
269
|
-
};
|
|
270
|
-
/** Advisory contract revision; individual capabilities and command results decide what works. */
|
|
271
|
-
export declare const PROTOCOL_REVISION = 5;
|
|
272
|
-
export type BrowserFeature = 'chrome-api' | 'streams' | 'extension-logs' | 'page-evaluate' | 'frame-evaluate' | 'cdp' | 'network' | 'frames' | 'dialogs' | 'console' | 'downloads' | 'viewport' | 'visibility' | 'webmcp';
|
|
273
|
-
export type ExtToHost = {
|
|
274
|
-
type: 'hello';
|
|
275
|
-
browserId: string;
|
|
276
|
-
extensionVersion: string;
|
|
277
|
-
protocolRevision?: number;
|
|
278
|
-
features?: BrowserFeature[];
|
|
279
|
-
} | {
|
|
280
|
-
type: 'result';
|
|
281
|
-
result: Result;
|
|
282
|
-
} | {
|
|
283
|
-
type: 'event';
|
|
284
|
-
event: BrowserEvent;
|
|
285
|
-
};
|
|
286
|
-
export declare const NATIVE_HOST_NAME = "com.browsermcp.host";
|
|
287
|
-
/** Chrome caps host → extension frames at 1 MiB. */
|
|
288
|
-
export declare const MAX_FRAME_BYTES: number;
|
|
289
|
-
/** Opaque cursors identify both a buffer generation and a sequence. */
|
|
290
|
-
export interface StreamReadOptions {
|
|
291
|
-
cursor?: string;
|
|
292
|
-
limit?: number;
|
|
293
|
-
levels?: string[];
|
|
294
|
-
filter?: string;
|
|
295
|
-
}
|
|
296
|
-
export interface StreamOptions {
|
|
297
|
-
capacity?: number; /** Chrome addListener filter arguments, after the listener. */
|
|
298
|
-
args?: unknown[];
|
|
299
|
-
}
|
|
300
|
-
export interface StreamEntry {
|
|
301
|
-
seq: number;
|
|
302
|
-
timestamp: string;
|
|
303
|
-
event?: string;
|
|
304
|
-
args?: unknown[];
|
|
305
|
-
params?: unknown;
|
|
306
|
-
level?: string;
|
|
307
|
-
message?: string;
|
|
308
|
-
url?: string;
|
|
309
|
-
line?: number;
|
|
310
|
-
truncated?: boolean;
|
|
311
|
-
}
|
|
312
|
-
export interface StreamBatch {
|
|
313
|
-
entries: StreamEntry[];
|
|
314
|
-
cursor: string;
|
|
315
|
-
hasMore: boolean;
|
|
316
|
-
dropped: number;
|
|
317
|
-
reset: boolean;
|
|
318
|
-
closed?: boolean;
|
|
319
|
-
reason?: string;
|
|
320
|
-
}
|
|
@@ -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,86 +0,0 @@
|
|
|
1
|
-
/** Executable contracts shared by the public API, backend discovery and documentation. */
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
/** Internal RPC function source; user data objects cannot impersonate this marker. */
|
|
4
|
-
export declare class PageFunction {
|
|
5
|
-
readonly source: string;
|
|
6
|
-
constructor(source: string);
|
|
7
|
-
}
|
|
8
|
-
export declare function parseInput<T>(method: string, schema: z.ZodType<T>, input: unknown): T;
|
|
9
|
-
export declare function checkArity(method: string, count: number, min: number, max: number): void;
|
|
10
|
-
export declare const evaluateOptions: z.ZodObject<{
|
|
11
|
-
arg: z.ZodOptional<z.ZodUnknown>;
|
|
12
|
-
frame: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>]>>;
|
|
13
|
-
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
14
|
-
}, z.core.$strict>;
|
|
15
|
-
export type EvaluateOptions = z.infer<typeof evaluateOptions>;
|
|
16
|
-
/** Reject values that JSON would silently drop or alter. Undefined is only allowed as the root argument. */
|
|
17
|
-
export declare function pageArgument(value: unknown): string;
|
|
18
|
-
export declare const discoveryOptions: z.ZodObject<{
|
|
19
|
-
query: z.ZodOptional<z.ZodString>;
|
|
20
|
-
limit: z.ZodOptional<z.ZodNumber>;
|
|
21
|
-
offset: z.ZodOptional<z.ZodNumber>;
|
|
22
|
-
}, z.core.$strict>;
|
|
23
|
-
export type TabDiscoveryOptions = z.infer<typeof discoveryOptions>;
|
|
24
|
-
export declare const userTabInfo: z.ZodObject<{
|
|
25
|
-
tabId: z.ZodNumber;
|
|
26
|
-
title: z.ZodOptional<z.ZodString>;
|
|
27
|
-
url: z.ZodOptional<z.ZodString>;
|
|
28
|
-
windowId: z.ZodNumber;
|
|
29
|
-
active: z.ZodBoolean;
|
|
30
|
-
groupId: z.ZodOptional<z.ZodNumber>;
|
|
31
|
-
lastAccessed: z.ZodOptional<z.ZodNumber>;
|
|
32
|
-
lifecycle: z.ZodOptional<z.ZodEnum<{
|
|
33
|
-
ready: "ready";
|
|
34
|
-
dormant: "dormant";
|
|
35
|
-
loading: "loading";
|
|
36
|
-
}>>;
|
|
37
|
-
availability: z.ZodOptional<z.ZodEnum<{
|
|
38
|
-
ready: "ready";
|
|
39
|
-
load_required: "load_required";
|
|
40
|
-
host_attachment_required: "host_attachment_required";
|
|
41
|
-
}>>;
|
|
42
|
-
}, z.core.$strict>;
|
|
43
|
-
export type UserTabInfo = z.infer<typeof userTabInfo>;
|
|
44
|
-
export declare const discoveryResult: z.ZodObject<{
|
|
45
|
-
scope: z.ZodLiteral<"unclaimed">;
|
|
46
|
-
query: z.ZodString;
|
|
47
|
-
matching: z.ZodLiteral<"case-insensitive-substring">;
|
|
48
|
-
totalVisible: z.ZodNumber;
|
|
49
|
-
totalInScope: z.ZodNumber;
|
|
50
|
-
excluded: z.ZodObject<{
|
|
51
|
-
owned: z.ZodNumber;
|
|
52
|
-
unsupported: z.ZodNumber;
|
|
53
|
-
}, z.core.$strict>;
|
|
54
|
-
matched: z.ZodNumber;
|
|
55
|
-
offset: z.ZodNumber;
|
|
56
|
-
limit: z.ZodNumber;
|
|
57
|
-
hasMore: z.ZodBoolean;
|
|
58
|
-
nextOffset: z.ZodOptional<z.ZodNumber>;
|
|
59
|
-
items: z.ZodArray<z.ZodObject<{
|
|
60
|
-
tabId: z.ZodNumber;
|
|
61
|
-
title: z.ZodOptional<z.ZodString>;
|
|
62
|
-
url: z.ZodOptional<z.ZodString>;
|
|
63
|
-
windowId: z.ZodNumber;
|
|
64
|
-
active: z.ZodBoolean;
|
|
65
|
-
groupId: z.ZodOptional<z.ZodNumber>;
|
|
66
|
-
lastAccessed: z.ZodOptional<z.ZodNumber>;
|
|
67
|
-
lifecycle: z.ZodOptional<z.ZodEnum<{
|
|
68
|
-
ready: "ready";
|
|
69
|
-
dormant: "dormant";
|
|
70
|
-
loading: "loading";
|
|
71
|
-
}>>;
|
|
72
|
-
availability: z.ZodOptional<z.ZodEnum<{
|
|
73
|
-
ready: "ready";
|
|
74
|
-
load_required: "load_required";
|
|
75
|
-
host_attachment_required: "host_attachment_required";
|
|
76
|
-
}>>;
|
|
77
|
-
}, z.core.$strict>>;
|
|
78
|
-
}, z.core.$strict>;
|
|
79
|
-
export type TabDiscoveryResult = z.infer<typeof discoveryResult>;
|
|
80
|
-
export type TabInventoryEntry = {
|
|
81
|
-
tab: UserTabInfo;
|
|
82
|
-
owned: boolean;
|
|
83
|
-
supported: boolean;
|
|
84
|
-
};
|
|
85
|
-
/** One snapshot, then scope → literal query → recency order → pagination. Never loads or claims a tab. */
|
|
86
|
-
export declare function discoverTabs(inventory: TabInventoryEntry[], input?: TabDiscoveryOptions): TabDiscoveryResult;
|