@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jackwener/browsermcp",
3
- "version": "0.0.34-embedded.3",
3
+ "version": "0.0.34",
4
4
  "description": "Chrome-backed MCP browser service with optional site adapters.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,7 @@
19
19
  "browsermcp": "dist/src/main.js"
20
20
  },
21
21
  "scripts": {
22
- "build": "node scripts/clean.mjs && node scripts/extract-playwright-injected.mjs && tsc -p tsconfig.json && node scripts/gen-api-reference.mjs && node scripts/render-icons.mjs && node scripts/build-extension.mjs && node scripts/copy-assets.mjs && node scripts/build-embedded.mjs",
22
+ "build": "node scripts/clean.mjs && node scripts/extract-playwright-injected.mjs && tsc -p tsconfig.json && node scripts/gen-api-reference.mjs && node scripts/render-icons.mjs && node scripts/build-extension.mjs && node scripts/copy-assets.mjs",
23
23
  "build:ext": "node scripts/render-icons.mjs && node scripts/build-extension.mjs",
24
24
  "dev": "tsx src/main.ts",
25
25
  "test": "vitest run",
@@ -32,10 +32,7 @@
32
32
  "pack:store": "npm run build && node scripts/pack-extension.mjs store",
33
33
  "pack:manual": "npm run build && node scripts/pack-extension.mjs manual",
34
34
  "smoke:native": "node scripts/smoke-native-capabilities.mjs",
35
- "generate:chrome": "node scripts/gen-chrome-reference.mjs",
36
- "build:embedded": "tsc -p tsconfig.json && node scripts/build-embedded.mjs && node scripts/copy-assets.mjs",
37
- "smoke:embedded": "npm run build:embedded && node scripts/run-embedded-smoke.mjs",
38
- "smoke:embedded:package": "npm run build:embedded && node scripts/smoke-embedded-package.mjs"
35
+ "generate:chrome": "node scripts/gen-chrome-reference.mjs"
39
36
  },
40
37
  "files": [
41
38
  "dist/",
@@ -63,11 +60,9 @@
63
60
  "zod": "^4.6.5"
64
61
  },
65
62
  "devDependencies": {
66
- "@electron/asar": "^4.3.1",
67
63
  "@resvg/resvg-js": "^2.6.2",
68
64
  "@types/chrome": "^0.3.0",
69
65
  "@types/node": "^22.20.3",
70
- "electron": "^44.9.0",
71
66
  "esbuild": "^0.28.2",
72
67
  "playwright-core": "^1.63.0",
73
68
  "tsx": "^4.23.13",
@@ -78,10 +73,6 @@
78
73
  "./adapter-sdk": {
79
74
  "types": "./adapter-sdk/index.d.ts",
80
75
  "default": "./adapter-sdk/index.js"
81
- },
82
- "./embedded": {
83
- "types": "./dist/src/embedded/index.d.ts",
84
- "default": "./dist/src/embedded/index.js"
85
76
  }
86
77
  }
87
78
  }
@@ -1,47 +0,0 @@
1
- import type { Expectation } from '../shared/page-contract.js';
2
- import type { ActAction, Target } from './tab.js';
3
- export interface RawTarget {
4
- ref?: string | number;
5
- selector?: string;
6
- within?: string;
7
- nth?: number;
8
- role?: string;
9
- name?: string;
10
- label?: string;
11
- text?: string;
12
- testid?: string;
13
- x?: number;
14
- y?: number;
15
- frame?: Target['frame'];
16
- }
17
- export interface ActToolInput {
18
- action: ActAction;
19
- target?: RawTarget;
20
- to?: RawTarget;
21
- value?: string;
22
- files?: string[];
23
- direction?: 'up' | 'down' | 'left' | 'right';
24
- amount?: number;
25
- method?: 'cdp' | 'dom';
26
- timeoutMs?: number;
27
- settleMs?: number;
28
- }
29
- type Need = 'required' | 'nonempty' | 'present' | 'optional' | 'forbidden';
30
- export declare const ACTION_RULES: Record<ActAction, {
31
- target: Need;
32
- value: Need;
33
- files: Need;
34
- to: Need;
35
- scroll: boolean;
36
- }>;
37
- /** What the model can copy into the next call. Wire shape is error.details.expected. */
38
- export declare function expectedAct(action: ActAction): Record<string, string>;
39
- export declare function pickTarget(t: RawTarget | undefined, action: ActAction, slot: 'target' | 'to'): Target | undefined;
40
- export declare function checkActInput(input: ActToolInput): {
41
- target?: Target;
42
- to?: Target;
43
- method?: 'cdp' | 'dom';
44
- };
45
- /** Validate the public contract before sending a compiled expectation to the page. */
46
- export declare function checkExpect(what: Expectation): void;
47
- export {};
@@ -1,10 +0,0 @@
1
- /**
2
- * The object model — the single surface behind both the typed MCP tools and the `js` session.
3
- * agent.browsers → browser.tabs / browser.user / browser.capabilities → tab.observe / tab.act / …
4
- * sites.<site>.<command>(args) · recon.discover(tab) · tools.define · browser.nameSession / browser.tabs.finalize
5
- * Split by object: tab.ts, browser.ts, api.ts (context.ts carries what they share). This file re-exports them.
6
- */
7
- export * from './tab.js';
8
- export * from './browser.js';
9
- export * from './api.js';
10
- export * from './context.js';
@@ -1,50 +0,0 @@
1
- /**
2
- * The object model's entry: agent.browsers · sites.<site>.<command>() · recon.discover(tab) · tools.define.
3
- * One surface behind both the typed entry tools and the `js` session.
4
- */
5
- import type { Runtime } from '../runtime/runtime.js';
6
- import { discoverEndpoints, type DiscoverResult } from '../recon/discover.js';
7
- import { listDefinedTools, type ToolDefinition } from '../sites/define.js';
8
- import type { DraftExpectation } from '../sites/drafts.js';
9
- import { Tab } from './tab.js';
10
- import { Browser } from './browser.js';
11
- export interface AgentApi {
12
- agent: {
13
- browsers: {
14
- getDefault(): Promise<Browser>;
15
- };
16
- browser: Browser;
17
- documentation: {
18
- get(name: string): Promise<string | null>;
19
- };
20
- };
21
- sites: Record<string, unknown> & {
22
- search(q: string, limit?: number): Promise<unknown>;
23
- list(): Promise<unknown>;
24
- enable(site: string, opts?: {
25
- write?: boolean;
26
- }): Promise<{
27
- site: string;
28
- tools: string[];
29
- }>;
30
- disable(site: string): Promise<boolean>;
31
- run(site: string, name: string, args?: Record<string, unknown>): Promise<unknown>;
32
- };
33
- recon: {
34
- discover(tab: Tab, opts?: Parameters<typeof discoverEndpoints>[1]): Promise<DiscoverResult>;
35
- };
36
- tools: {
37
- define(def: ToolDefinition | (Omit<ToolDefinition, 'func'> & {
38
- func?: string | ((ctx: Record<string, unknown>) => unknown);
39
- })): ReturnType<Runtime['defineTool']>;
40
- try(draftId: string, args: Record<string, unknown>, expect: DraftExpectation): ReturnType<Runtime['tryToolDraft']>;
41
- activate(draftId: string): ReturnType<Runtime['activateToolDraft']>;
42
- discard(draftId: string): Promise<ReturnType<Runtime['discardToolDraft']>>;
43
- list(): Promise<ReturnType<typeof listDefinedTools>>;
44
- remove(site: string, name: string): ReturnType<Runtime['removeTool']>;
45
- };
46
- session: {
47
- id: string;
48
- };
49
- }
50
- export declare function createAgentApi(rt: Runtime, sessionId: string): AgentApi;
@@ -1,90 +0,0 @@
1
- import type { StreamOptions, StreamReadOptions, StreamBatch } from '../protocol.js';
2
- import type { CloseUserTabsResult } from '../protocol.js';
3
- import type { UserTabInfo } from '../backends/managed-page.js';
4
- import { Tab } from './tab.js';
5
- import type { SessionContext } from './context.js';
6
- export declare class Browser {
7
- readonly id: string;
8
- readonly type: 'extension' | 'electron';
9
- private readonly ctx;
10
- constructor(id: string, type: 'extension' | 'electron', ctx: SessionContext);
11
- toJSON(): {
12
- type: 'Browser';
13
- id: string;
14
- backend: string;
15
- };
16
- private page;
17
- private ext;
18
- /** Chrome APIs through the connected backend. Electron supports an explicit compatibility subset. */
19
- readonly chrome: {
20
- call: (method: string, args?: unknown[]) => Promise<unknown>;
21
- describe: (member: string) => Promise<unknown>;
22
- watch: (event: string, options?: StreamOptions) => Promise<import("./streams.js").EventStream>;
23
- };
24
- /** This extension's own service-worker logs; not logs of other installed extensions. */
25
- readonly logs: {
26
- watch: (options?: StreamOptions) => Promise<import("./streams.js").EventStream>;
27
- read: (options?: StreamReadOptions) => Promise<StreamBatch>;
28
- };
29
- readonly tabs: {
30
- new: (url?: string) => Promise<Tab>;
31
- list: () => Promise<Array<{
32
- id?: string;
33
- tabId: number;
34
- pending?: true;
35
- url?: string;
36
- title?: string;
37
- active: boolean;
38
- selected: boolean;
39
- lifecycle?: "dormant" | "loading" | "ready";
40
- origin: "agent" | "user";
41
- state: "active" | "handoff";
42
- }>>;
43
- get: (tab: string | {
44
- tab?: string;
45
- tabId: number;
46
- }, opts?: {
47
- timeoutMs?: number;
48
- }) => Promise<Tab>;
49
- selected: () => Promise<Tab | undefined>;
50
- finalize: (opts?: {
51
- keep?: Array<{
52
- tab: string | Tab;
53
- status: "deliverable" | "handoff";
54
- }>;
55
- }) => Promise<{
56
- closed: string[];
57
- kept: string[];
58
- failed: Array<{
59
- page: string;
60
- reason: string;
61
- }>;
62
- }>;
63
- };
64
- readonly user: {
65
- openTabs: (options?: {
66
- query?: string;
67
- limit?: number;
68
- }) => Promise<UserTabInfo[]>;
69
- /** Claim by foreground, id, or unique url/title lookup; expected fields verify the tab's current identity. */
70
- claimTab: (tab: {
71
- tabId?: number;
72
- active?: boolean;
73
- title?: string;
74
- url?: string;
75
- expectedUrl?: string;
76
- expectedTitle?: string;
77
- }) => Promise<Tab>;
78
- /** Close user tabs by Chrome id without claiming or loading their pages. */
79
- closeTabs: (tabIds: number[]) => Promise<CloseUserTabsResult>;
80
- };
81
- nameSession(name: string): Promise<void>;
82
- readonly capabilities: {
83
- list: () => Promise<Array<{
84
- id: string;
85
- description: string;
86
- }>>;
87
- get: (id: string) => Promise<Record<string, unknown>>;
88
- };
89
- documentation(): Promise<string>;
90
- }
@@ -1,7 +0,0 @@
1
- /** What every object of the model carries: the runtime, the MCP session id, and that session's state. */
2
- import type { Runtime, SessionState } from '../runtime/runtime.js';
3
- export interface SessionContext {
4
- rt: Runtime;
5
- sessionId: string;
6
- state: SessionState;
7
- }
@@ -1,8 +0,0 @@
1
- export interface AriaDiff {
2
- changedRatio: number;
3
- text: string;
4
- added: number;
5
- removed: number;
6
- changed: number;
7
- }
8
- export declare function ariaDiff(prev: string, next: string): AriaDiff;
@@ -1,12 +0,0 @@
1
- /** Stable, branchable errors for the object API and typed tools. */
2
- export declare class ActionError extends Error {
3
- readonly code: string;
4
- readonly hint?: string | undefined;
5
- readonly data?: Record<string, unknown> | undefined;
6
- constructor(code: string, message: string, hint?: string | undefined, data?: Record<string, unknown> | undefined);
7
- toJSON(): Record<string, unknown>;
8
- }
9
- export declare function errorEnvelope(err: unknown): {
10
- ok: false;
11
- error: Record<string, unknown>;
12
- };
@@ -1,10 +0,0 @@
1
- /** Bounded, two-stage network evidence for agents. Raw captures stay in the session log. */
2
- export interface NetworkEntry extends Record<string, unknown> {
3
- seq: number;
4
- }
5
- export declare function networkSummary(e: NetworkEntry): Record<string, unknown>;
6
- export declare function networkDetail(e: NetworkEntry, opts?: {
7
- part?: 'request' | 'response';
8
- start?: number;
9
- maxChars?: number;
10
- }): Record<string, unknown>;
@@ -1,4 +0,0 @@
1
- import type { ObserveResult } from './tab.js';
2
- export declare const OBSERVATION_BUDGET = 10000;
3
- /** Page one immutable capture across documents. Offsets are text characters or DOM entries. */
4
- export declare function observationPage(capture: ObserveResult, cursor?: string): ObserveResult;
@@ -1,13 +0,0 @@
1
- import type { Command, StreamBatch, StreamOptions, StreamReadOptions } from '../protocol.js';
2
- import type { SessionContext } from './context.js';
3
- export interface EventStream {
4
- /** Reads after the handle's last read, or an explicit cursor. Filtering still advances the cursor. */
5
- read(options?: StreamReadOptions): Promise<StreamBatch>;
6
- /** Idempotently releases this subscription. */
7
- close(): Promise<void>;
8
- }
9
- export declare function browserCommand(ctx: SessionContext, feature: import('../protocol.js').BrowserFeature, action: Command['action'], params?: Partial<Command>): Promise<unknown>;
10
- export declare function watch(ctx: SessionContext, source: 'chrome' | 'cdp' | 'console' | 'extension', event?: string, options?: StreamOptions, page?: string, route?: {
11
- session: string;
12
- surface: 'browser' | 'adapter';
13
- }): Promise<EventStream>;
@@ -1,315 +0,0 @@
1
- import { type PageTool, type PageToolsUpdate } from './webmcp.js';
2
- import type { StreamOptions, StreamReadOptions } from '../protocol.js';
3
- /**
4
- * Tab — one browser tab of a session: observe (aria snapshot + semantic diff), find, act, expect, evaluate, screenshot,
5
- * network/console/dialog/webmcp/frames. A Tab owns the page object bound to its identity; operations are serialized per tab.
6
- */
7
- import type { RuntimePage } from '../backends/page-types.js';
8
- import type { Target, FindResult, QueryFindResult, ElementAtResult, Expectation, CheckResult, ReadTextResult, FrameOwner, DomSnapshot, ElementDetails } from '../shared/page-contract.js';
9
- import type { DialogInfo, DownloadWaitResult, FrameStep } from '../protocol.js';
10
- import type { SessionContext } from './context.js';
11
- export type { Target } from '../shared/page-contract.js';
12
- export type ActAction = 'click' | 'dblclick' | 'hover' | 'focus' | 'fill' | 'type' | 'press' | 'select' | 'check' | 'uncheck' | 'upload' | 'drag' | 'scroll' | 'back' | 'forward' | 'reload';
13
- export interface ActOptions {
14
- target?: Target;
15
- action: ActAction;
16
- value?: string;
17
- files?: string[];
18
- to?: Target;
19
- direction?: 'up' | 'down' | 'left' | 'right';
20
- amount?: number;
21
- timeoutMs?: number;
22
- settleMs?: number; /** click only. `dom` runs HTMLElement.click() and sends no mouse event. Default is a real mouse event. */
23
- method?: 'cdp' | 'dom';
24
- }
25
- /** Input delivery and control verification are separate from completion of the site's task. */
26
- export interface ActionOutcome {
27
- action: ActAction;
28
- delivery: 'applied' | 'received' | 'dispatched';
29
- controlState: 'verified' | 'unverified';
30
- network?: {
31
- afterSequence: number;
32
- cursor: number;
33
- };
34
- matches_n?: number;
35
- navigated?: boolean;
36
- url?: string;
37
- title?: string;
38
- timedOut?: boolean;
39
- ref?: string;
40
- /** For fill/type, true only when the settled value matches the requested result. */
41
- filled?: boolean;
42
- verified?: boolean;
43
- actual?: string;
44
- checked?: boolean;
45
- changed?: boolean;
46
- selected?: string[];
47
- files?: number;
48
- openedTabs?: Array<{
49
- tab?: string;
50
- tabId: number;
51
- url?: string;
52
- title?: string;
53
- pending?: true;
54
- }>;
55
- download?: {
56
- tab: string;
57
- afterSequence: number;
58
- started: Array<{
59
- seq: number;
60
- guid?: string;
61
- url: string;
62
- suggestedFilename: string;
63
- }>;
64
- };
65
- /** Present when the action used DOM activation or a native control setter. */
66
- method?: 'dom';
67
- }
68
- export interface ObserveOptions {
69
- /** Continue the previous immutable capture. Pass cursor alone; a fresh observation replaces it. */
70
- cursor?: string;
71
- mode?: 'state' | 'screenshot' | 'both';
72
- /** ARIA overview (default) or independent visible controls and live DOM attributes. */
73
- format?: 'aria' | 'dom';
74
- /** Frame path from an observation; identical to target.frame in act/find/read. */
75
- frame?: FrameStep | FrameStep[];
76
- /** Return a diff only against this exact snapshot id; otherwise return full state. ARIA only. */
77
- since?: string;
78
- /** ARIA defaults to the whole document; DOM defaults to the viewport. */
79
- viewport?: boolean;
80
- /** Open a branch in the selected frame. */
81
- ref?: string;
82
- /** Observe a known container using the same locator contract as read/act, without first obtaining a ref. */
83
- target?: Target;
84
- /** DOM pagination within the selected frame. The live page can change between calls. */
85
- start?: number;
86
- limit?: number;
87
- /** Include child frames, without scrolling. Default true. */
88
- includeFrames?: boolean;
89
- /** Overlay main-frame ref labels on the screenshot. */
90
- annotate?: boolean;
91
- fullPage?: boolean;
92
- }
93
- export interface ObservedContent {
94
- metadataTruncated?: boolean; /** A single oversized text line can span pages. Concatenate these fragments before interpreting it. */
95
- stateContinued?: boolean;
96
- stateContinues?: boolean;
97
- state?: string;
98
- dom?: DomSnapshot;
99
- warnings?: string[];
100
- diff?: boolean;
101
- changed?: {
102
- added: number;
103
- removed: number;
104
- changed?: number;
105
- };
106
- }
107
- export interface ObservedFrame extends ObservedContent {
108
- frame: FrameStep[];
109
- owner: FrameOwner;
110
- unavailable?: string;
111
- }
112
- export interface ObserveResult extends ObservedContent {
113
- /** Whether this is the final output page, not a claim that all dynamic page content was captured. */
114
- complete?: boolean;
115
- /** Page-provided tool catalog changes in the observed root frame; schemas are fetched explicitly. */
116
- webmcp?: PageToolsUpdate;
117
- /** Continue this captured state with observe({cursor: nextCursor}). */
118
- nextCursor?: string;
119
- /** Pass directly to tab.observe(result.next) to continue this capture. */
120
- next?: {
121
- cursor: string;
122
- };
123
- url: string | null;
124
- title: string | null;
125
- snapshotId?: string;
126
- image?: ImageValue;
127
- /** Child frames and explicit routes for semantic locators or document reads; refs route automatically. */
128
- frames?: ObservedFrame[];
129
- /** False if a discovered frame could not be captured or the bounded traversal stopped. */
130
- framesComplete?: boolean;
131
- }
132
- export interface ReadOptions {
133
- maxChars?: number; /** character offset returned as nextStart by a previous read */
134
- start?: number; /** capture id returned by that same read */
135
- readId?: string;
136
- frame?: FrameStep | FrameStep[];
137
- }
138
- export interface DocumentReadResult extends ReadTextResult {
139
- next?: ReadOptions;
140
- }
141
- export interface ReadElementOptions {
142
- target: Target;
143
- }
144
- export interface ImageValue {
145
- __image: true;
146
- mimeType: string;
147
- base64: string;
148
- }
149
- export declare class Tab {
150
- private readonly initialId;
151
- private readonly ctx;
152
- private readonly bound?;
153
- /** A Tab owns the page object bound to its identity; `bound` lets an adapter pass an existing page. */
154
- /** `id` is the stable backend page handle; `tabId` is the numeric backend id when claimed from a user tab. */
155
- readonly tabId?: number;
156
- constructor(initialId: string, ctx: SessionContext, bound?: RuntimePage | undefined, tabId?: number);
157
- get id(): string;
158
- toJSON(): {
159
- type: 'Tab';
160
- id: string;
161
- tabId?: number;
162
- };
163
- private closed;
164
- /** Run `fn` on this tab's own page object. Operations are serialized per tab, never across tabs. */
165
- use<T>(fn: (page: RuntimePage) => Promise<T>): Promise<T>;
166
- /** Reuse the document namespace already present in refs; no second element-id system. */
167
- private rememberRefs;
168
- private routeTarget;
169
- goto(url: string, opts?: {
170
- waitUntil?: 'load' | 'none';
171
- settleMs?: number;
172
- }): Promise<{
173
- url: string | null;
174
- title: string | null;
175
- }>;
176
- /**
177
- * Pull captured requests into the session's bounded network log. Best effort — never fails a step.
178
- */
179
- private harvest;
180
- private logNetwork;
181
- private info;
182
- /** Preserve this tab for the user when the session is finalized. */
183
- markDeliverable(): Promise<void>;
184
- /** Preserve this tab for a subsequent turn; it must be claimed again after finalization. */
185
- markHandoff(): Promise<void>;
186
- /** Restore default cleanup: close agent tabs, release borrowed user tabs. */
187
- clearRetention(): Promise<void>;
188
- private setRetention;
189
- url(): Promise<string | null>;
190
- title(): Promise<string | null>;
191
- back(): Promise<void>;
192
- forward(): Promise<void>;
193
- reload(): Promise<void>;
194
- /** Close this tab, whether it was opened or claimed by this session. */
195
- close(): Promise<void>;
196
- /** Keep this tab open and give up this session's control of it. */
197
- release(): Promise<void>;
198
- /** ARIA overview by default; format:'dom' reveals visible controls and live attributes. Observed refs automatically route to their frame. */
199
- observe(opts?: ObserveOptions): Promise<ObserveResult>;
200
- screenshot(opts?: {
201
- fullPage?: boolean;
202
- annotate?: boolean;
203
- format?: 'png' | 'jpeg';
204
- quality?: number;
205
- }): Promise<ImageValue>;
206
- private screenshotOn;
207
- find(target: (Target & {
208
- limit?: number;
209
- }) | {
210
- query: string;
211
- limit?: number;
212
- frame?: FrameStep | FrameStep[];
213
- }): Promise<FindResult | ElementAtResult | QueryFindResult>;
214
- /**
215
- * With target: exact current element text, attributes and live values, without scrolling.
216
- * Otherwise: bounded document text scan (including open shadow roots), restores scroll; pass result.next to continue.
217
- * A growing feed returns reason `unbounded`; the scan stops rather than chasing an endless bottom.
218
- */
219
- read(opts: ReadElementOptions): Promise<ElementDetails>;
220
- read(opts?: ReadOptions): Promise<DocumentReadResult>;
221
- /** wait + act in one call at the runtime edge: locate → wait actionable → hit-test → real input → settle. `method:'dom'` skips the mouse event. */
222
- act(opts: ActOptions): Promise<ActionOutcome>;
223
- /** WebMCP: tools the page itself registers via navigator.modelContext (page-provided tool source). */
224
- readonly webmcp: {
225
- /** List names/descriptions, or fetch one full schema by name. Scoped to the requested frame. */
226
- list: (options?: {
227
- name?: string;
228
- frame?: FrameStep | FrameStep[];
229
- }) => Promise<PageTool[]>;
230
- call: (name: string, input?: Record<string, unknown>, options?: {
231
- frame?: FrameStep | FrameStep[];
232
- }) => Promise<unknown>;
233
- };
234
- /** Assert what the page must show now (polled up to timeoutMs). */
235
- expect(what: Expectation, opts?: {
236
- timeoutMs?: number;
237
- }): Promise<CheckResult>;
238
- /** Main World page code; functions receive only opts.arg, never host closures. Dispatched scripts are never replayed. */
239
- evaluate(script: string | ((arg: any) => any), opts?: {
240
- arg?: unknown;
241
- frame?: FrameStep | FrameStep[];
242
- timeoutMs?: number;
243
- }): Promise<unknown>;
244
- /** Native CDP on this Tab's shared debugger attachment. Parameters are not rewritten. */
245
- readonly cdp: {
246
- send: (method: string, params?: Record<string, unknown>, target?: {
247
- frameId: string;
248
- }) => Promise<unknown>;
249
- watch: (event: string, options?: StreamOptions) => Promise<import("./streams.js").EventStream>;
250
- };
251
- /** Native alert/confirm/prompt dialogs block the page; commands fail with `dialog_open` until answered. */
252
- readonly dialog: {
253
- get: () => Promise<DialogInfo | null>;
254
- accept: (text?: string) => Promise<DialogInfo | null>;
255
- dismiss: () => Promise<DialogInfo | null>;
256
- };
257
- /** Console messages and uncaught exceptions since the tab was attached (the plugin's tab.dev.logs); cursor-paged like network.read. */
258
- readonly console: {
259
- read: (opts?: StreamReadOptions) => Promise<import("../protocol.js").StreamBatch>;
260
- watch: (options?: StreamOptions) => Promise<import("./streams.js").EventStream>;
261
- };
262
- readonly network: {
263
- start: (pattern?: string) => Promise<boolean>;
264
- list: (opts?: {
265
- filter?: string;
266
- limit?: number;
267
- afterSequence?: number;
268
- }) => Promise<{
269
- cursor: number;
270
- entries: Record<string, unknown>[];
271
- hasMore: boolean;
272
- }>;
273
- detail: (opts: {
274
- seq?: number;
275
- requestId?: string;
276
- part?: "request" | "response";
277
- start?: number;
278
- maxChars?: number;
279
- }) => Promise<Record<string, unknown>>;
280
- /**
281
- * Cursor-paged read: pass `afterSequence` from the previous result to get only new requests. Returns network rows
282
- * only; endpoint candidates come from the explicit `recon.discover(tab)` (not a hidden side effect of reading).
283
- */
284
- read: (opts?: {
285
- pattern?: string;
286
- limit?: number;
287
- includeStatic?: boolean;
288
- afterSequence?: number;
289
- }) => Promise<{
290
- cursor: number;
291
- entries: unknown[];
292
- hasMore: boolean;
293
- }>;
294
- };
295
- cookies(domain: string): Promise<unknown[]>;
296
- /**
297
- * Read one cookie's value at run time — useful for per-request tokens an adapter needs (csrf/ct0/
298
- * csrftoken/XSRF-TOKEN). Defaults to the current page's host. Returns undefined when the cookie is absent.
299
- */
300
- cookie(name: string, opts?: {
301
- domain?: string;
302
- }): Promise<string | undefined>;
303
- /** Fetch JSON through the page (its cookies and origin) after verifying the endpoint. */
304
- fetchJson(url: string, opts?: Record<string, unknown>): Promise<unknown>;
305
- frames(): Promise<Array<{
306
- index: number;
307
- frameId: string;
308
- url: string;
309
- name: string;
310
- crossOrigin?: boolean;
311
- oopif?: boolean;
312
- }>>;
313
- /** Wait for the page download begun after a tab.act cursor, then check Chrome's file state. */
314
- download(download: NonNullable<ActionOutcome['download']>, timeoutMs?: number): Promise<DownloadWaitResult>;
315
- }
@@ -1,19 +0,0 @@
1
- import type { RuntimePage } from '../backends/page-types.js';
2
- import type { FrameStep } from '../protocol.js';
3
- export interface PageTool {
4
- name: string;
5
- description?: string;
6
- inputSchema?: unknown;
7
- }
8
- export interface PageToolsUpdate {
9
- status: 'ready' | 'unavailable';
10
- frame: FrameStep[];
11
- tools: Array<{
12
- name: string;
13
- description?: string;
14
- }>;
15
- truncated?: boolean;
16
- }
17
- /** Discovery is read-only and bounded. Full schemas are returned only on explicit lookup. */
18
- export declare function pageTools(page: RuntimePage, frame?: FrameStep[]): Promise<PageTool[]>;
19
- export declare function pageToolsUpdate(page: RuntimePage, cache: Map<string, string>, key: string, frame: FrameStep[]): Promise<PageToolsUpdate | undefined>;
@@ -1,14 +0,0 @@
1
- import type { BrowserEvent, BrowserFeature, Command } from '../protocol.js';
2
- import type { PageOptions, ManagedRuntimePage } from './managed-page.js';
3
- /** Host-owned browser access. No discovery, installation, or process lifecycle. */
4
- export interface BrowserBackend {
5
- readonly kind: 'electron' | 'extension';
6
- readonly available: boolean;
7
- features(): BrowserFeature[];
8
- createPage(options: PageOptions): Promise<ManagedRuntimePage>;
9
- subscribe(listener: (event: BrowserEvent) => void): () => void;
10
- command?(action: Command['action'], params: Partial<Command>): Promise<{
11
- data: unknown;
12
- }>;
13
- dispose(): Promise<void>;
14
- }