@hyperbrowser/sdk 1.0.3 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -16,6 +16,40 @@ or
16
16
  yarn add @hyperbrowser/sdk
17
17
  ```
18
18
 
19
+ ## WebMCP page tools
20
+
21
+ Create a session with `enableWebMcp: true` (default: false), then navigate to a page
22
+ that exposes WebMCP tools using Playwright or Puppeteer. With that session open:
23
+
24
+ ```typescript
25
+ const discovery = await client.sessions.webmcp.listTools(session.id);
26
+ // Select a tool using its name, source page/frame, and input schema.
27
+ const tool = discovery.tools.find((tool) => tool.name === "search");
28
+ if (!tool) throw new Error("The page has no search tool");
29
+ const result = await client.sessions.webmcp.invoke(session.id, {
30
+ toolRef: tool.toolRef,
31
+ input: { query: "flights to Tokyo" }, // Match the selected tool's schema.
32
+ });
33
+ console.log(result.status, result.output);
34
+ ```
35
+
36
+ For long-running tools or forms awaiting human submission, use
37
+ `sessions.webmcp.start(sessionId, params)`, then
38
+ `sessions.webmcp.getResult(sessionId, invocationId, { waitSeconds: 30 })` until the
39
+ status is terminal. `sessions.webmcp.cancel(sessionId, invocationId)` requests
40
+ best-effort cancellation. Blocking invocation defaults to 60 seconds (maximum
41
+ 120); `start` defaults to 300 seconds (maximum 3,600) via `timeoutSeconds`.
42
+
43
+ Discover tools again after navigation. Invocations never automatically retry;
44
+ losing a response can leave an unknown outcome. Handles are ephemeral and
45
+ terminal results expire after 10 minutes or earlier eviction. Check result
46
+ status and truncation metadata before using output. Public types, including
47
+ `WebMCPTool`, `WebMCPInvocation`, and the request types, are exported from
48
+ `@hyperbrowser/sdk/types`.
49
+
50
+ See the [WebMCP guide](https://hyperbrowser.ai/docs/sessions/webmcp) for complete
51
+ examples, cancellation behavior, human submission, and limits.
52
+
19
53
  ## Usage
20
54
 
21
55
  ### Playwright
@@ -3,13 +3,16 @@ import { ComputerActionResponse, Coordinate, ComputerActionMouseButton } from ".
3
3
  import { BaseService } from "./base";
4
4
  export declare class ComputerActionService extends BaseService {
5
5
  private executeRequest;
6
- click(session: SessionDetail | string, x: number, y: number, button?: ComputerActionMouseButton, numClicks?: number, returnScreenshot?: boolean): Promise<ComputerActionResponse>;
6
+ click(session: SessionDetail | string, x: number, y: number, button?: ComputerActionMouseButton, numClicks?: number, returnScreenshot?: boolean, keys?: string[]): Promise<ComputerActionResponse>;
7
+ clickAtCursor(session: SessionDetail | string, button?: ComputerActionMouseButton, numClicks?: number, returnScreenshot?: boolean, keys?: string[]): Promise<ComputerActionResponse>;
7
8
  typeText(session: SessionDetail | string, text: string, returnScreenshot?: boolean): Promise<ComputerActionResponse>;
8
9
  screenshot(session: SessionDetail | string): Promise<ComputerActionResponse>;
10
+ cursorPosition(session: SessionDetail | string, returnScreenshot?: boolean): Promise<ComputerActionResponse>;
9
11
  pressKeys(session: SessionDetail | string, keys: string[], returnScreenshot?: boolean): Promise<ComputerActionResponse>;
10
- drag(session: SessionDetail | string, path: Coordinate[], returnScreenshot?: boolean): Promise<ComputerActionResponse>;
12
+ drag(session: SessionDetail | string, path: Coordinate[], returnScreenshot?: boolean, keys?: string[]): Promise<ComputerActionResponse>;
11
13
  moveMouse(session: SessionDetail | string, x: number, y: number, returnScreenshot?: boolean): Promise<ComputerActionResponse>;
12
- scroll(session: SessionDetail | string, x: number, y: number, scrollX: number, scrollY: number, returnScreenshot?: boolean): Promise<ComputerActionResponse>;
14
+ scroll(session: SessionDetail | string, x: number, y: number, scrollX: number, scrollY: number, returnScreenshot?: boolean, keys?: string[]): Promise<ComputerActionResponse>;
15
+ scrollAtCursor(session: SessionDetail | string, scrollX?: number, scrollY?: number, returnScreenshot?: boolean, keys?: string[]): Promise<ComputerActionResponse>;
13
16
  holdKey(session: SessionDetail | string, key: string, duration: number, returnScreenshot?: boolean): Promise<ComputerActionResponse>;
14
17
  mouseDown(session: SessionDetail | string, button?: ComputerActionMouseButton, returnScreenshot?: boolean): Promise<ComputerActionResponse>;
15
18
  mouseUp(session: SessionDetail | string, button?: ComputerActionMouseButton, returnScreenshot?: boolean): Promise<ComputerActionResponse>;
@@ -29,14 +29,24 @@ class ComputerActionService extends base_1.BaseService {
29
29
  throw new client_1.HyperbrowserError("Failed to execute computer action", undefined);
30
30
  }
31
31
  }
32
- async click(session, x, y, button = "left", numClicks = 1, returnScreenshot = false) {
32
+ async click(session, x, y, button = "left", numClicks = 1, returnScreenshot = false, keys) {
33
33
  return this.executeRequest(session, {
34
34
  action: computer_action_1.ComputerAction.CLICK,
35
35
  x,
36
36
  y,
37
37
  button,
38
38
  numClicks,
39
+ keys,
40
+ returnScreenshot,
41
+ });
42
+ }
43
+ async clickAtCursor(session, button = "left", numClicks = 1, returnScreenshot = false, keys) {
44
+ return this.executeRequest(session, {
45
+ action: computer_action_1.ComputerAction.CLICK,
46
+ button,
47
+ numClicks,
39
48
  returnScreenshot,
49
+ keys,
40
50
  });
41
51
  }
42
52
  async typeText(session, text, returnScreenshot = false) {
@@ -51,6 +61,12 @@ class ComputerActionService extends base_1.BaseService {
51
61
  action: computer_action_1.ComputerAction.SCREENSHOT,
52
62
  });
53
63
  }
64
+ async cursorPosition(session, returnScreenshot = false) {
65
+ return this.executeRequest(session, {
66
+ action: computer_action_1.ComputerAction.CURSOR_POSITION,
67
+ returnScreenshot,
68
+ });
69
+ }
54
70
  async pressKeys(session, keys, returnScreenshot = false) {
55
71
  return this.executeRequest(session, {
56
72
  action: computer_action_1.ComputerAction.PRESS_KEYS,
@@ -58,10 +74,11 @@ class ComputerActionService extends base_1.BaseService {
58
74
  returnScreenshot,
59
75
  });
60
76
  }
61
- async drag(session, path, returnScreenshot = false) {
77
+ async drag(session, path, returnScreenshot = false, keys) {
62
78
  return this.executeRequest(session, {
63
79
  action: computer_action_1.ComputerAction.DRAG,
64
80
  path,
81
+ keys,
65
82
  returnScreenshot,
66
83
  });
67
84
  }
@@ -73,16 +90,26 @@ class ComputerActionService extends base_1.BaseService {
73
90
  returnScreenshot,
74
91
  });
75
92
  }
76
- async scroll(session, x, y, scrollX, scrollY, returnScreenshot = false) {
93
+ async scroll(session, x, y, scrollX, scrollY, returnScreenshot = false, keys) {
77
94
  return this.executeRequest(session, {
78
95
  action: computer_action_1.ComputerAction.SCROLL,
79
96
  x,
80
97
  y,
81
98
  scrollX,
82
99
  scrollY,
100
+ keys,
83
101
  returnScreenshot,
84
102
  });
85
103
  }
104
+ async scrollAtCursor(session, scrollX = 0, scrollY = 0, returnScreenshot = false, keys) {
105
+ return this.executeRequest(session, {
106
+ action: computer_action_1.ComputerAction.SCROLL,
107
+ scrollX,
108
+ scrollY,
109
+ returnScreenshot,
110
+ keys,
111
+ });
112
+ }
86
113
  async holdKey(session, key, duration, returnScreenshot = false) {
87
114
  return this.executeRequest(session, {
88
115
  action: computer_action_1.ComputerAction.HOLD_KEY,
@@ -1,5 +1,6 @@
1
1
  import { BasicResponse, CaptchaEvaluationParams, CaptchaEvaluationResponse, CreateSessionParams, CreateSessionSnapshotResponse, GetActiveSessionsCountResponse, GetSessionDownloadsUrlResponse, GetSessionRecordingUrlResponse, GetSessionVideoRecordingUrlResponse, SessionDetail, SessionListParams, SessionListResponse, SessionRecording, UploadFileOptions, UploadFileResponse, SessionEventLogListParams, SessionEventLogListResponse, UpdateSessionProfileParams, UpdateSessionProxyParams, UpdateSessionScreenParams, UpdateSessionSolveCaptchasParams, UpdateSessionSolveCaptchasResponse, SessionGetParams } from "../types/session";
2
2
  import { BaseService } from "./base";
3
+ import { WebMCPService } from "./webmcp";
3
4
  /**
4
5
  * Service for managing session event logs
5
6
  */
@@ -13,6 +14,7 @@ declare class SessionEventLogsService extends BaseService {
13
14
  }
14
15
  export declare class SessionsService extends BaseService {
15
16
  readonly eventLogs: SessionEventLogsService;
17
+ readonly webmcp: WebMCPService;
16
18
  constructor(apiKey: string, baseUrl: string, timeout: number);
17
19
  /**
18
20
  * Create a new browser session
@@ -31,6 +31,7 @@ const fs_1 = require("fs");
31
31
  const path = __importStar(require("path"));
32
32
  const form_data_1 = __importDefault(require("form-data"));
33
33
  const base_1 = require("./base");
34
+ const webmcp_1 = require("./webmcp");
34
35
  const client_1 = require("../client");
35
36
  const CAPTCHA_EVALUATION_REQUEST_TIMEOUT_MS = 185000;
36
37
  /**
@@ -61,6 +62,7 @@ class SessionsService extends base_1.BaseService {
61
62
  constructor(apiKey, baseUrl, timeout) {
62
63
  super(apiKey, baseUrl, timeout);
63
64
  this.eventLogs = new SessionEventLogsService(apiKey, baseUrl, timeout);
65
+ this.webmcp = new webmcp_1.WebMCPService(apiKey, baseUrl, timeout);
64
66
  }
65
67
  /**
66
68
  * Create a new browser session
@@ -0,0 +1,16 @@
1
+ import { BaseService } from "./base";
2
+ import { WebMCPInvocation, WebMCPInvokeParams, WebMCPInvokeResult, WebMCPResultParams, WebMCPStartParams, WebMCPToolsResponse } from "../types/webmcp";
3
+ /** Page tools for sessions created with enableWebMcp: true. */
4
+ export declare class WebMCPService extends BaseService {
5
+ private path;
6
+ /** Discover current tools across the session's tabs and frames. */
7
+ listTools(sessionId: string): Promise<WebMCPToolsResponse>;
8
+ /** Invoke once. Transport failures never cause an automatic retry. */
9
+ invoke(sessionId: string, params: WebMCPInvokeParams): Promise<WebMCPInvokeResult>;
10
+ /** Start once and return a handle. A lost response may mean the tool already ran. */
11
+ start(sessionId: string, params: WebMCPStartParams): Promise<WebMCPInvocation>;
12
+ /** Read or long-poll a handle. Pending responses do not cancel or restart the tool. */
13
+ getResult(sessionId: string, invocationId: string, params?: WebMCPResultParams): Promise<WebMCPInvocation>;
14
+ /** Request cancellation; completion can win the race. Read getResult for the outcome. */
15
+ cancel(sessionId: string, invocationId: string): Promise<WebMCPInvocation>;
16
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WebMCPService = void 0;
4
+ const base_1 = require("./base");
5
+ function seconds(value, min, max, name) {
6
+ if (!Number.isInteger(value) || value < min || value > max) {
7
+ throw new RangeError(`${name} must be an integer between ${min} and ${max}`);
8
+ }
9
+ return value;
10
+ }
11
+ function invocationBody(params) {
12
+ if (typeof params.toolRef !== "string" || !params.toolRef.trim()) {
13
+ throw new TypeError("toolRef must be a non-empty string from listTools");
14
+ }
15
+ if (params.input !== undefined &&
16
+ (params.input === null || typeof params.input !== "object" || Array.isArray(params.input))) {
17
+ throw new TypeError("input must be a JSON object");
18
+ }
19
+ return JSON.stringify(params);
20
+ }
21
+ /** Page tools for sessions created with enableWebMcp: true. */
22
+ class WebMCPService extends base_1.BaseService {
23
+ path(sessionId) {
24
+ return `/session/${encodeURIComponent(sessionId)}/webmcp`;
25
+ }
26
+ /** Discover current tools across the session's tabs and frames. */
27
+ async listTools(sessionId) {
28
+ return this.request(`${this.path(sessionId)}/tools`, {
29
+ timeout: Math.max(this.timeout, 40000),
30
+ });
31
+ }
32
+ /** Invoke once. Transport failures never cause an automatic retry. */
33
+ async invoke(sessionId, params) {
34
+ const timeout = seconds(params.timeoutSeconds ?? 60, 1, 120, "timeoutSeconds");
35
+ return this.request(`${this.path(sessionId)}/invoke`, {
36
+ method: "POST",
37
+ body: invocationBody(params),
38
+ timeout: Math.max(this.timeout, (timeout + 35) * 1000),
39
+ });
40
+ }
41
+ /** Start once and return a handle. A lost response may mean the tool already ran. */
42
+ async start(sessionId, params) {
43
+ seconds(params.timeoutSeconds ?? 300, 1, 3600, "timeoutSeconds");
44
+ return this.request(`${this.path(sessionId)}/invocations`, {
45
+ method: "POST",
46
+ body: invocationBody(params),
47
+ timeout: Math.max(this.timeout, 40000),
48
+ });
49
+ }
50
+ /** Read or long-poll a handle. Pending responses do not cancel or restart the tool. */
51
+ async getResult(sessionId, invocationId, params = {}) {
52
+ const wait = seconds(params.waitSeconds ?? 0, 0, 30, "waitSeconds");
53
+ return this.request(`${this.path(sessionId)}/invocations/${encodeURIComponent(invocationId)}`, { timeout: Math.max(this.timeout, (wait + 20) * 1000) }, { waitSeconds: params.waitSeconds });
54
+ }
55
+ /** Request cancellation; completion can win the race. Read getResult for the outcome. */
56
+ async cancel(sessionId, invocationId) {
57
+ return this.request(`${this.path(sessionId)}/invocations/${encodeURIComponent(invocationId)}/cancel`, { method: "POST", timeout: Math.max(this.timeout, 20000) });
58
+ }
59
+ }
60
+ exports.WebMCPService = WebMCPService;
@@ -10,6 +10,7 @@ export declare enum ComputerAction {
10
10
  PRESS_KEYS = "press_keys",
11
11
  MOVE_MOUSE = "move_mouse",
12
12
  SCREENSHOT = "screenshot",
13
+ CURSOR_POSITION = "cursor_position",
13
14
  SCROLL = "scroll",
14
15
  TYPE_TEXT = "type_text",
15
16
  GET_CLIPBOARD_TEXT = "get_clipboard_text",
@@ -33,6 +34,7 @@ export interface ClickActionParams {
33
34
  y?: number;
34
35
  button?: ComputerActionMouseButton;
35
36
  numClicks?: number;
37
+ keys?: string[];
36
38
  returnScreenshot?: boolean;
37
39
  }
38
40
  /**
@@ -41,6 +43,7 @@ export interface ClickActionParams {
41
43
  export interface DragActionParams {
42
44
  action: ComputerAction.DRAG;
43
45
  path: Coordinate[];
46
+ keys?: string[];
44
47
  returnScreenshot?: boolean;
45
48
  }
46
49
  /**
@@ -66,6 +69,11 @@ export interface MoveMouseActionParams {
66
69
  export interface ScreenshotActionParams {
67
70
  action: ComputerAction.SCREENSHOT;
68
71
  }
72
+ /** Parameters for reading the desktop cursor position. */
73
+ export interface CursorPositionActionParams {
74
+ action: ComputerAction.CURSOR_POSITION;
75
+ returnScreenshot?: boolean;
76
+ }
69
77
  /**
70
78
  * Parameters for scroll action
71
79
  */
@@ -73,10 +81,13 @@ export interface ScrollActionParams {
73
81
  action: ComputerAction.SCROLL;
74
82
  x: number;
75
83
  y: number;
84
+ keys?: string[];
76
85
  scrollX: number;
77
86
  scrollY: number;
78
87
  returnScreenshot?: boolean;
79
88
  }
89
+ /** Parameters for scrolling without moving the desktop cursor. */
90
+ export type ScrollAtCursorActionParams = Omit<ScrollActionParams, "x" | "y">;
80
91
  /**
81
92
  * Parameters for type text action
82
93
  */
@@ -129,7 +140,7 @@ export interface ListWindowsActionParams {
129
140
  /**
130
141
  * Union type for all computer action parameters
131
142
  */
132
- export type ComputerActionParams = ClickActionParams | DragActionParams | PressKeysActionParams | MoveMouseActionParams | ScreenshotActionParams | ScrollActionParams | TypeTextActionParams | HoldKeyActionParams | MouseDownActionParams | MouseUpActionParams | GetClipboardTextActionParams | PutSelectionTextActionParams | ListWindowsActionParams;
143
+ export type ComputerActionParams = ClickActionParams | DragActionParams | PressKeysActionParams | MoveMouseActionParams | ScreenshotActionParams | CursorPositionActionParams | ScrollActionParams | ScrollAtCursorActionParams | TypeTextActionParams | HoldKeyActionParams | MouseDownActionParams | MouseUpActionParams | GetClipboardTextActionParams | PutSelectionTextActionParams | ListWindowsActionParams;
133
144
  export interface ComputerActionResponseDataClipboardText {
134
145
  clipboardText?: string;
135
146
  }
@@ -148,7 +159,12 @@ export interface ComputerActionResponseDataListWindows {
148
159
  activeWindowId: string;
149
160
  windows: ComputerActionWindow[];
150
161
  }
151
- export type ComputerActionResponseData = ComputerActionResponseDataClipboardText | ComputerActionResponseDataListWindows;
162
+ /** Desktop cursor coordinates in physical screen pixels. */
163
+ export interface ComputerActionResponseDataCursorPosition {
164
+ x: number;
165
+ y: number;
166
+ }
167
+ export type ComputerActionResponseData = ComputerActionResponseDataCursorPosition | ComputerActionResponseDataClipboardText | ComputerActionResponseDataListWindows;
152
168
  /**
153
169
  * Response from computer action API
154
170
  */
@@ -14,6 +14,7 @@ var ComputerAction;
14
14
  ComputerAction["PRESS_KEYS"] = "press_keys";
15
15
  ComputerAction["MOVE_MOUSE"] = "move_mouse";
16
16
  ComputerAction["SCREENSHOT"] = "screenshot";
17
+ ComputerAction["CURSOR_POSITION"] = "cursor_position";
17
18
  ComputerAction["SCROLL"] = "scroll";
18
19
  ComputerAction["TYPE_TEXT"] = "type_text";
19
20
  ComputerAction["GET_CLIPBOARD_TEXT"] = "get_clipboard_text";
@@ -1,4 +1,5 @@
1
1
  export { HyperbrowserConfig } from "./config";
2
+ export * from "./webmcp";
2
3
  export { StartCrawlJobParams, StartCrawlJobResponse, CrawledPage, CrawlJobResponse, GetCrawlJobParams, CrawlJobStatusResponse, } from "./crawl";
3
4
  export { StartScrapeJobParams, StartScrapeJobResponse, ScrapeJobData, ScrapeJobResponse, ScrapeOptions, ScrapeJobStatusResponse, BatchScrapeJobStatusResponse, StorageStateOptions, } from "./scrape";
4
5
  export { StartExtractJobParams, StartExtractJobResponse, ExtractJobResponse, ExtractJobStatusResponse, ExtractJobMetadata, } from "./extract";
@@ -17,7 +18,7 @@ export { CreateProfileParams, ForkProfileParams, ProfileResponse, CreateProfileR
17
18
  export { CreateExtensionParams, CreateExtensionResponse, ListExtensionsResponse, } from "./extension";
18
19
  export { ExtractJobStatus, BrowserUseTaskStatus, BrowserUseLlm, ClaudeComputerUseLlm, ClaudeComputerUseReasoningEffort, CuaLlm, CuaReasoningEffort, GeminiComputerUseLlm, GrokComputerUseLlm, GrokReasoningEffort, MetaComputerUseLlm, MetaReasoningEffort, JevComputerUseLlm, JevTextLlm, ScrapeScreenshotFormat, ScrapeJobStatus, CrawlJobStatus, Country, State, ISO639_1, OperatingSystem, Platform, ScrapeFormat, ScrapeWaitUntil, ScrapePageStatus, CrawlPageStatus, RecordingStatus, DownloadsStatus, HyperAgentLlm, HyperAgentTaskStatus, ClaudeComputerUseTaskStatus, CuaTaskStatus, GeminiComputerUseTaskStatus, GrokComputerUseTaskStatus, MetaComputerUseTaskStatus, JevComputerUseTaskStatus, SessionEventLogType, SessionRegion, BrowserUseVersion, HyperAgentVersion, } from "./constants";
19
20
  export { TeamCreditInfo } from "./team";
20
- export { ComputerAction, Coordinate, ClickActionParams, DragActionParams, PressKeysActionParams, MoveMouseActionParams, ScreenshotActionParams, ScrollActionParams, TypeTextActionParams, ComputerActionParams, ComputerActionResponse, ComputerActionMouseButton, ComputerActionResponseData, HoldKeyActionParams, MouseDownActionParams, MouseUpActionParams, GetClipboardTextActionParams, PutSelectionTextActionParams, ComputerActionResponseDataClipboardText, ListWindowsActionParams, ComputerActionWindow, ComputerActionResponseDataListWindows, } from "./computer-action";
21
+ export { ComputerAction, Coordinate, ClickActionParams, DragActionParams, PressKeysActionParams, MoveMouseActionParams, ScreenshotActionParams, CursorPositionActionParams, ScrollAtCursorActionParams, ScrollActionParams, TypeTextActionParams, ComputerActionParams, ComputerActionResponse, ComputerActionMouseButton, ComputerActionResponseData, HoldKeyActionParams, MouseDownActionParams, MouseUpActionParams, GetClipboardTextActionParams, PutSelectionTextActionParams, ComputerActionResponseDataClipboardText, ListWindowsActionParams, ComputerActionWindow, ComputerActionResponseDataListWindows, ComputerActionResponseDataCursorPosition, } from "./computer-action";
21
22
  export { FetchParams, FetchResponse, FetchResponseData, FetchStatus } from "./web/fetch";
22
23
  export { StartBatchFetchJobParams, GetBatchFetchJobParams, StartBatchFetchJobResponse, BatchFetchJobStatusResponse, BatchFetchJobResponse, BatchFetchJobStatus, } from "./web/batch-fetch";
23
24
  export { WebSearchParams, WebSearchResponse, WebSearchResponseData, WebSearchResultItem, WebSearchFilters, WebSearchLocation, WebSearchFiletype, WebSearchStatus, } from "./web/search";
@@ -1,5 +1,20 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  exports.ComputerAction = void 0;
18
+ __exportStar(require("./webmcp"), exports);
4
19
  var computer_action_1 = require("./computer-action");
5
20
  Object.defineProperty(exports, "ComputerAction", { enumerable: true, get: function () { return computer_action_1.ComputerAction; } });
@@ -10,6 +10,7 @@ export interface SessionProfile {
10
10
  persistChanges?: boolean;
11
11
  }
12
12
  export interface SessionLaunchState {
13
+ enableWebMcp?: boolean;
13
14
  useUltraStealth?: boolean;
14
15
  useStealth?: boolean;
15
16
  useProxy?: boolean;
@@ -128,6 +129,8 @@ export interface StartSessionFromSnapshotParams {
128
129
  snapshotId: string;
129
130
  }
130
131
  export interface CreateSessionParams {
132
+ /** Enable page-provided WebMCP tools. Defaults to false on the server. */
133
+ enableWebMcp?: boolean;
131
134
  useUltraStealth?: boolean;
132
135
  useStealth?: boolean;
133
136
  useProxy?: boolean;
@@ -0,0 +1,84 @@
1
+ /** Page-provided hints; these are not browser-enforced guarantees. */
2
+ export interface WebMCPAnnotations {
3
+ readOnly: boolean;
4
+ untrustedContent: boolean;
5
+ consequential: boolean;
6
+ autosubmit: boolean;
7
+ destructive?: boolean;
8
+ idempotent?: boolean;
9
+ openWorld?: boolean;
10
+ }
11
+ export interface WebMCPFrame {
12
+ id: string;
13
+ url: string;
14
+ isMainFrame: boolean;
15
+ }
16
+ export interface WebMCPSource {
17
+ provider: "native" | "polyfill";
18
+ tabId: string;
19
+ pageUrl: string;
20
+ pageTitle: string;
21
+ frame: WebMCPFrame;
22
+ }
23
+ export interface WebMCPTool {
24
+ /** Opaque reference to this document. Discover tools again after navigation. */
25
+ toolRef: string;
26
+ name: string;
27
+ title?: string;
28
+ description: string;
29
+ inputSchema?: Record<string, unknown>;
30
+ outputSchema?: Record<string, unknown>;
31
+ annotations: WebMCPAnnotations;
32
+ declarative: boolean;
33
+ /** Native DOM node identifier, when available, in the source target/frame. */
34
+ backendNodeId?: number;
35
+ source: WebMCPSource;
36
+ }
37
+ export interface WebMCPToolsResponse {
38
+ tools: WebMCPTool[];
39
+ nativeSupported: boolean;
40
+ truncated: boolean;
41
+ }
42
+ export interface WebMCPInvokeParams {
43
+ toolRef: string;
44
+ /** Page-defined keys are passed through unchanged. Defaults to {}. */
45
+ input?: Record<string, unknown>;
46
+ /** Execution deadline in seconds: 1–120, default 60. */
47
+ timeoutSeconds?: number;
48
+ }
49
+ export interface WebMCPStartParams extends WebMCPInvokeParams {
50
+ /** Execution deadline including human submission: 1–3600 seconds, default 300. */
51
+ timeoutSeconds?: number;
52
+ }
53
+ export interface WebMCPResultParams {
54
+ /** Wait 0–30 seconds, default 0. A pending response does not cancel the tool. */
55
+ waitSeconds?: number;
56
+ }
57
+ export type WebMCPInvokeStatus = "completed" | "error" | "canceled" | "awaiting_submission";
58
+ export type WebMCPInvocationStatus = WebMCPInvokeStatus | "running" | "outcome_unknown";
59
+ export interface WebMCPInvokeResult {
60
+ invocationId?: string;
61
+ status: WebMCPInvokeStatus;
62
+ output?: unknown;
63
+ errorText?: string;
64
+ outputBytes: number;
65
+ outputTruncated?: boolean;
66
+ outputPreview?: string;
67
+ untrustedContent: boolean;
68
+ durationMs: number;
69
+ }
70
+ export interface WebMCPInvocationError {
71
+ code: string;
72
+ message: string;
73
+ }
74
+ /** Session-local record; results expire and do not survive receiver restarts. */
75
+ export interface WebMCPInvocation {
76
+ invocationId: string;
77
+ toolRef: string;
78
+ status: WebMCPInvocationStatus;
79
+ cancellationRequested: boolean;
80
+ createdAt: string;
81
+ expiresAt?: string;
82
+ result?: WebMCPInvokeResult;
83
+ error?: WebMCPInvocationError;
84
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperbrowser/sdk",
3
- "version": "1.0.3",
3
+ "version": "1.2.0",
4
4
  "description": "Node SDK for Hyperbrowser API",
5
5
  "author": "",
6
6
  "repository": {