@hyperbrowser/sdk 0.89.7 → 0.90.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.
@@ -51,9 +51,10 @@ class BaseService {
51
51
  }
52
52
  const headerKeys = Object.keys(init?.headers || {});
53
53
  const contentTypeKey = headerKeys.find((key) => key.toLowerCase() === "content-type");
54
+ const requestTimeout = init?.timeout ?? this.timeout;
54
55
  const response = await (0, node_fetch_1.default)(url.toString(), {
55
56
  ...init,
56
- timeout: this.timeout,
57
+ timeout: requestTimeout,
57
58
  headers: {
58
59
  "x-api-key": this.apiKey,
59
60
  ...(contentTypeKey && init?.headers
@@ -15,4 +15,5 @@ export declare class ComputerActionService extends BaseService {
15
15
  mouseUp(session: SessionDetail | string, button?: ComputerActionMouseButton, returnScreenshot?: boolean): Promise<ComputerActionResponse>;
16
16
  getClipboardText(session: SessionDetail | string, returnScreenshot?: boolean): Promise<ComputerActionResponse>;
17
17
  putSelectionText(session: SessionDetail | string, text: string, returnScreenshot?: boolean): Promise<ComputerActionResponse>;
18
+ listWindows(session: SessionDetail | string, returnScreenshot?: boolean): Promise<ComputerActionResponse>;
18
19
  }
@@ -118,5 +118,11 @@ class ComputerActionService extends base_1.BaseService {
118
118
  returnScreenshot,
119
119
  });
120
120
  }
121
+ async listWindows(session, returnScreenshot = false) {
122
+ return this.executeRequest(session, {
123
+ action: computer_action_1.ComputerAction.LIST_WINDOWS,
124
+ returnScreenshot,
125
+ });
126
+ }
121
127
  }
122
128
  exports.ComputerActionService = ComputerActionService;
@@ -1,4 +1,4 @@
1
- import { BasicResponse, CreateSessionParams, GetActiveSessionsCountResponse, GetSessionDownloadsUrlResponse, GetSessionRecordingUrlResponse, GetSessionVideoRecordingUrlResponse, SessionDetail, SessionListParams, SessionListResponse, SessionRecording, UploadFileOptions, UploadFileResponse, SessionEventLogListParams, SessionEventLogListResponse, UpdateSessionProfileParams, UpdateSessionProxyParams, UpdateSessionScreenParams, SessionGetParams } from "../types/session";
1
+ import { BasicResponse, CaptchaEvaluationParams, CaptchaEvaluationResponse, CreateSessionParams, 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
3
  /**
4
4
  * Service for managing session event logs
@@ -29,6 +29,12 @@ export declare class SessionsService extends BaseService {
29
29
  * @param id The ID of the session to stop
30
30
  */
31
31
  stop(id: string): Promise<BasicResponse>;
32
+ /**
33
+ * Manually evaluate captchas in a running session.
34
+ * @param id The ID of the session to evaluate
35
+ * @param params Optional captcha evaluation parameters
36
+ */
37
+ evaluateCaptcha(id: string, params?: CaptchaEvaluationParams): Promise<CaptchaEvaluationResponse>;
32
38
  /**
33
39
  * List all sessions with optional filtering
34
40
  * @param params Optional parameters to filter the sessions
@@ -81,6 +87,17 @@ export declare class SessionsService extends BaseService {
81
87
  updateProfileParams(id: string, persistChanges: boolean): Promise<BasicResponse>;
82
88
  updateProxyParams(id: string, params: UpdateSessionProxyParams): Promise<BasicResponse>;
83
89
  updateScreenSize(id: string, params: UpdateSessionScreenParams): Promise<BasicResponse>;
90
+ /**
91
+ * Start automatic captcha solving for a running session.
92
+ * @param id The ID of the session to update
93
+ * @param params Optional captcha solver parameters
94
+ */
95
+ startCaptchaSolving(id: string, params?: UpdateSessionSolveCaptchasParams): Promise<UpdateSessionSolveCaptchasResponse>;
96
+ /**
97
+ * Stop automatic captcha solving for a running session.
98
+ * @param id The ID of the session to update
99
+ */
100
+ stopCaptchaSolving(id: string): Promise<UpdateSessionSolveCaptchasResponse>;
84
101
  private static hasWarnedUpdateSessionProfileParamsBooleanDeprecated;
85
102
  private warnUpdateSessionProfileParamsBooleanDeprecated;
86
103
  }
@@ -32,6 +32,7 @@ const path = __importStar(require("path"));
32
32
  const form_data_1 = __importDefault(require("form-data"));
33
33
  const base_1 = require("./base");
34
34
  const client_1 = require("../client");
35
+ const CAPTCHA_EVALUATION_REQUEST_TIMEOUT_MS = 185000;
35
36
  /**
36
37
  * Service for managing session event logs
37
38
  */
@@ -113,6 +114,26 @@ class SessionsService extends base_1.BaseService {
113
114
  throw new client_1.HyperbrowserError(`Failed to stop session ${id}`, undefined);
114
115
  }
115
116
  }
117
+ /**
118
+ * Manually evaluate captchas in a running session.
119
+ * @param id The ID of the session to evaluate
120
+ * @param params Optional captcha evaluation parameters
121
+ */
122
+ async evaluateCaptcha(id, params = {}) {
123
+ try {
124
+ return await this.request(`/session/${id}/captcha/evaluate`, {
125
+ method: "POST",
126
+ timeout: Math.max(this.timeout, CAPTCHA_EVALUATION_REQUEST_TIMEOUT_MS),
127
+ body: JSON.stringify(params),
128
+ });
129
+ }
130
+ catch (error) {
131
+ if (error instanceof client_1.HyperbrowserError) {
132
+ throw error;
133
+ }
134
+ throw new client_1.HyperbrowserError(`Failed to evaluate captcha for session ${id}`, undefined);
135
+ }
136
+ }
116
137
  /**
117
138
  * List all sessions with optional filtering
118
139
  * @param params Optional parameters to filter the sessions
@@ -373,6 +394,54 @@ class SessionsService extends base_1.BaseService {
373
394
  throw new client_1.HyperbrowserError(`Failed to update screen for session ${id}`, undefined);
374
395
  }
375
396
  }
397
+ /**
398
+ * Start automatic captcha solving for a running session.
399
+ * @param id The ID of the session to update
400
+ * @param params Optional captcha solver parameters
401
+ */
402
+ async startCaptchaSolving(id, params = {}) {
403
+ try {
404
+ return await this.request(`/session/${id}/update`, {
405
+ method: "PUT",
406
+ body: JSON.stringify({
407
+ type: "solveCaptchas",
408
+ params: {
409
+ enabled: true,
410
+ ...params,
411
+ },
412
+ }),
413
+ });
414
+ }
415
+ catch (error) {
416
+ if (error instanceof client_1.HyperbrowserError) {
417
+ throw error;
418
+ }
419
+ throw new client_1.HyperbrowserError(`Failed to start captcha solving for session ${id}`, undefined);
420
+ }
421
+ }
422
+ /**
423
+ * Stop automatic captcha solving for a running session.
424
+ * @param id The ID of the session to update
425
+ */
426
+ async stopCaptchaSolving(id) {
427
+ try {
428
+ return await this.request(`/session/${id}/update`, {
429
+ method: "PUT",
430
+ body: JSON.stringify({
431
+ type: "solveCaptchas",
432
+ params: {
433
+ enabled: false,
434
+ },
435
+ }),
436
+ });
437
+ }
438
+ catch (error) {
439
+ if (error instanceof client_1.HyperbrowserError) {
440
+ throw error;
441
+ }
442
+ throw new client_1.HyperbrowserError(`Failed to stop captcha solving for session ${id}`, undefined);
443
+ }
444
+ }
376
445
  warnUpdateSessionProfileParamsBooleanDeprecated() {
377
446
  if (SessionsService.hasWarnedUpdateSessionProfileParamsBooleanDeprecated) {
378
447
  return;
@@ -13,7 +13,8 @@ export declare enum ComputerAction {
13
13
  SCROLL = "scroll",
14
14
  TYPE_TEXT = "type_text",
15
15
  GET_CLIPBOARD_TEXT = "get_clipboard_text",
16
- PUT_SELECTION_TEXT = "put_selection_text"
16
+ PUT_SELECTION_TEXT = "put_selection_text",
17
+ LIST_WINDOWS = "list_windows"
17
18
  }
18
19
  export type ComputerActionMouseButton = "left" | "right" | "middle" | "back" | "forward" | "wheel";
19
20
  /**
@@ -118,14 +119,36 @@ export interface PutSelectionTextActionParams {
118
119
  text: string;
119
120
  returnScreenshot?: boolean;
120
121
  }
122
+ /**
123
+ * Parameters for list windows action.
124
+ */
125
+ export interface ListWindowsActionParams {
126
+ action: ComputerAction.LIST_WINDOWS;
127
+ returnScreenshot?: boolean;
128
+ }
121
129
  /**
122
130
  * Union type for all computer action parameters
123
131
  */
124
- export type ComputerActionParams = ClickActionParams | DragActionParams | PressKeysActionParams | MoveMouseActionParams | ScreenshotActionParams | ScrollActionParams | TypeTextActionParams | HoldKeyActionParams | MouseDownActionParams | MouseUpActionParams | GetClipboardTextActionParams | PutSelectionTextActionParams;
132
+ export type ComputerActionParams = ClickActionParams | DragActionParams | PressKeysActionParams | MoveMouseActionParams | ScreenshotActionParams | ScrollActionParams | TypeTextActionParams | HoldKeyActionParams | MouseDownActionParams | MouseUpActionParams | GetClipboardTextActionParams | PutSelectionTextActionParams | ListWindowsActionParams;
125
133
  export interface ComputerActionResponseDataClipboardText {
126
134
  clipboardText?: string;
127
135
  }
128
- export type ComputerActionResponseData = ComputerActionResponseDataClipboardText;
136
+ /**
137
+ * A single visible top-level X11/native window entry.
138
+ */
139
+ export interface ComputerActionWindow {
140
+ id: string;
141
+ name: string;
142
+ active: boolean;
143
+ }
144
+ /**
145
+ * Response data for the list windows action.
146
+ */
147
+ export interface ComputerActionResponseDataListWindows {
148
+ activeWindowId: string;
149
+ windows: ComputerActionWindow[];
150
+ }
151
+ export type ComputerActionResponseData = ComputerActionResponseDataClipboardText | ComputerActionResponseDataListWindows;
129
152
  /**
130
153
  * Response from computer action API
131
154
  */
@@ -18,4 +18,5 @@ var ComputerAction;
18
18
  ComputerAction["TYPE_TEXT"] = "type_text";
19
19
  ComputerAction["GET_CLIPBOARD_TEXT"] = "get_clipboard_text";
20
20
  ComputerAction["PUT_SELECTION_TEXT"] = "put_selection_text";
21
+ ComputerAction["LIST_WINDOWS"] = "list_windows";
21
22
  })(ComputerAction || (exports.ComputerAction = ComputerAction = {}));
@@ -7,14 +7,14 @@ export { StartClaudeComputerUseTaskParams, StartClaudeComputerUseTaskResponse, C
7
7
  export { StartCuaTaskParams, StartCuaTaskResponse, CuaTaskStatusResponse, CuaTaskResponse, CuaTaskData, CuaStepResponse, CuaApiKeys, CuaTaskMetadata, } from "./agents/cua";
8
8
  export { StartHyperAgentTaskParams, StartHyperAgentTaskResponse, HyperAgentTaskStatusResponse, HyperAgentTaskResponse, HyperAgentTaskData, HyperAgentStep, HyperAgentOutput, HyperAgentActionOutput, HyperAgentApiKeys, HyperAgentTaskMetadata, HyperAgentOutputV110, HyperAgentStepV110, } from "./agents/hyper-agent";
9
9
  export { StartGeminiComputerUseTaskParams, StartGeminiComputerUseTaskResponse, GeminiComputerUseTaskStatusResponse, GeminiComputerUseTaskResponse, GeminiComputerUseTaskData, GeminiComputerUseStepResponse, GeminiComputerUseApiKeys, GeminiComputerUseTaskMetadata, } from "./agents/gemini-computer-use";
10
- export { BasicResponse, SessionStatus, Session, SessionDetail, SessionGetParams, SessionListParams, SessionListResponse, ScreenConfig, CreateSessionParams, GetSessionDownloadsUrlResponse, GetSessionVideoRecordingUrlResponse, GetSessionRecordingUrlResponse, ImageCaptchaParam, UploadFileResponse, UploadFileOptions, GetActiveSessionsCountResponse, SessionEventLogListParams, SessionEventLogListResponse, SessionEventLog, SessionProfile, SessionLaunchState, SessionCreditBreakdown, UpdateSessionProfileParams, UpdateSessionProxyLocationParams, UpdateSessionProxyParams, UpdateSessionScreenParams, } from "./session";
10
+ export { BasicResponse, SessionStatus, Session, SessionDetail, SessionGetParams, SessionListParams, SessionListResponse, ScreenConfig, CaptchaEvaluationPageResult, CaptchaEvaluationParams, CaptchaEvaluationResponse, CaptchaEvaluationTarget, CaptchaEvaluationType, CaptchaSolverType, CreateSessionParams, GetSessionDownloadsUrlResponse, GetSessionVideoRecordingUrlResponse, GetSessionRecordingUrlResponse, ImageCaptchaParam, UploadFileResponse, UploadFileOptions, GetActiveSessionsCountResponse, SessionEventLogListParams, SessionEventLogListResponse, SessionEventLog, SessionProfile, SessionLaunchState, SessionCreditBreakdown, UpdateSessionProfileParams, UpdateSessionProxyLocationParams, UpdateSessionProxyParams, UpdateSessionScreenParams, UpdateSessionSolveCaptchasParams, UpdateSessionSolveCaptchasResponse, } from "./session";
11
11
  export { SandboxStatus, SandboxRuntimeTarget, Sandbox, SandboxDetail, SandboxVolumeMountType, SandboxVolumeMount, SandboxListParams, SandboxListResponse, SandboxImageSummary, SandboxImageListResponse, SandboxSnapshotStatus, SandboxSnapshotSummary, SandboxSnapshotListParams, SandboxSnapshotListResponse, CreateSandboxParams, SandboxMemorySnapshotParams, SandboxMemorySnapshotResult, SandboxExposeParams, SandboxExposeResult, SandboxUnexposeResult, SandboxProcessStatus, SandboxExecParams, SandboxExecOptions, SandboxProcessSummary, SandboxProcessResult, SandboxProcessListParams, SandboxProcessListResponse, SandboxProcessWaitParams, SandboxProcessSignal, SandboxProcessStdinParams, SandboxProcessStreamEvent, SandboxFileType, SandboxFileInfo, SandboxFileWriteInfo, SandboxFileListOptions, SandboxFileReadFormat, SandboxFileReadOptions, SandboxFileWriteData, SandboxFileWriteEntry, SandboxFileTextWriteOptions, SandboxFileBytesWriteOptions, SandboxFileMakeDirOptions, SandboxFileCopyParams, SandboxFileChmodParams, SandboxFileChownParams, SandboxFileTransferResult, SandboxFileSystemEventType, SandboxFileSystemEvent, SandboxWatchDirOptions, SandboxPresignFileParams, SandboxPresignedUrl, SandboxTerminalCreateParams, SandboxTerminalOutputChunk, SandboxTerminalStatus, SandboxTerminalWaitParams, SandboxTerminalKillParams, SandboxTerminalEvent, } from "./sandbox";
12
12
  export { CreateVolumeParams, Volume, VolumeListResponse } from "./volume";
13
13
  export { CreateProfileParams, ProfileResponse, CreateProfileResponse, ProfileListParams, ProfileListResponse, } from "./profile";
14
14
  export { CreateExtensionParams, CreateExtensionResponse, ListExtensionsResponse, } from "./extension";
15
15
  export { ExtractJobStatus, BrowserUseTaskStatus, BrowserUseLlm, ClaudeComputerUseLlm, CuaLlm, GeminiComputerUseLlm, ScrapeScreenshotFormat, ScrapeJobStatus, CrawlJobStatus, Country, State, ISO639_1, OperatingSystem, Platform, ScrapeFormat, ScrapeWaitUntil, ScrapePageStatus, CrawlPageStatus, RecordingStatus, DownloadsStatus, HyperAgentLlm, HyperAgentTaskStatus, ClaudeComputerUseTaskStatus, CuaTaskStatus, GeminiComputerUseTaskStatus, SessionEventLogType, SessionRegion, BrowserUseVersion, HyperAgentVersion, } from "./constants";
16
16
  export { TeamCreditInfo } from "./team";
17
- export { ComputerAction, Coordinate, ClickActionParams, DragActionParams, PressKeysActionParams, MoveMouseActionParams, ScreenshotActionParams, ScrollActionParams, TypeTextActionParams, ComputerActionParams, ComputerActionResponse, ComputerActionMouseButton, ComputerActionResponseData, HoldKeyActionParams, MouseDownActionParams, MouseUpActionParams, GetClipboardTextActionParams, PutSelectionTextActionParams, ComputerActionResponseDataClipboardText, } from "./computer-action";
17
+ 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";
18
18
  export { FetchParams, FetchResponse, FetchResponseData, FetchStatus } from "./web/fetch";
19
19
  export { StartBatchFetchJobParams, GetBatchFetchJobParams, StartBatchFetchJobResponse, BatchFetchJobStatusResponse, BatchFetchJobResponse, BatchFetchJobStatus, } from "./web/batch-fetch";
20
20
  export { WebSearchParams, WebSearchResponse, WebSearchResponseData, WebSearchResultItem, WebSearchFilters, WebSearchLocation, WebSearchFiletype, WebSearchStatus, } from "./web/search";
@@ -21,6 +21,7 @@ export interface SessionLaunchState {
21
21
  enableVideoWebRecording?: boolean;
22
22
  enableLogCapture?: boolean;
23
23
  acceptCookies?: boolean;
24
+ solverType?: CaptchaSolverType;
24
25
  profile?: SessionProfile;
25
26
  staticIpId?: string;
26
27
  saveDownloads?: boolean;
@@ -85,6 +86,39 @@ export interface ImageCaptchaParam {
85
86
  imageSelector: string;
86
87
  inputSelector: string;
87
88
  }
89
+ export type CaptchaSolverType = "visual" | (string & {});
90
+ export type CaptchaEvaluationType = "turnstile" | "cloudflare-challenge" | "aliexpress" | "recaptcha" | "recaptcha-visual" | "amazon";
91
+ export type CaptchaEvaluationTarget = CaptchaEvaluationType;
92
+ export interface CaptchaEvaluationParams {
93
+ captcha?: CaptchaEvaluationTarget;
94
+ captchaType?: CaptchaEvaluationTarget;
95
+ text?: CaptchaEvaluationTarget;
96
+ iterations?: number;
97
+ maxIterations?: number;
98
+ solverType?: CaptchaSolverType;
99
+ imageCaptchaParams?: Array<ImageCaptchaParam>;
100
+ useGeminiCaptchaSolver?: boolean;
101
+ useUltraStealth?: boolean;
102
+ }
103
+ export interface CaptchaEvaluationPageResult {
104
+ url: string;
105
+ targetId: string | null;
106
+ iterationsRun: number;
107
+ solved: boolean;
108
+ solvedCaptchas: CaptchaEvaluationType[];
109
+ checkedCaptchas: CaptchaEvaluationType[];
110
+ captchaSolvedCounts: Record<string, number>;
111
+ lastSolveTime: Record<string, number>;
112
+ }
113
+ export interface CaptchaEvaluationResponse {
114
+ success: true;
115
+ captcha: CaptchaEvaluationType | null;
116
+ iterationsRequested: number;
117
+ iterationsRun: number;
118
+ solved: boolean;
119
+ solvedCaptchas: CaptchaEvaluationType[];
120
+ pages: CaptchaEvaluationPageResult[];
121
+ }
88
122
  export interface CreateSessionParams {
89
123
  useUltraStealth?: boolean;
90
124
  useStealth?: boolean;
@@ -101,6 +135,7 @@ export interface CreateSessionParams {
101
135
  locales?: ISO639_1[];
102
136
  screen?: ScreenConfig;
103
137
  solveCaptchas?: boolean;
138
+ solverType?: CaptchaSolverType;
104
139
  adblock?: boolean;
105
140
  trackers?: boolean;
106
141
  annoyances?: boolean;
@@ -206,3 +241,11 @@ export interface UpdateSessionScreenParams {
206
241
  width: number;
207
242
  height: number;
208
243
  }
244
+ export interface UpdateSessionSolveCaptchasParams {
245
+ solverType?: CaptchaSolverType;
246
+ }
247
+ export interface UpdateSessionSolveCaptchasResponse extends BasicResponse {
248
+ solveCaptchas?: boolean;
249
+ sessionId?: string;
250
+ telemetryReady?: boolean;
251
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperbrowser/sdk",
3
- "version": "0.89.7",
3
+ "version": "0.90.0",
4
4
  "description": "Node SDK for Hyperbrowser API",
5
5
  "author": "",
6
6
  "repository": {
@@ -21,6 +21,7 @@
21
21
  "prepare": "yarn build",
22
22
  "test": "vitest run",
23
23
  "test:e2e": "vitest run tests/sandbox/e2e",
24
+ "test:integration": "vitest run tests/integration",
24
25
  "test:watch": "vitest",
25
26
  "format": "prettier --write 'src/**/*.ts'"
26
27
  },