@hyperbrowser/sdk 0.81.1 → 0.82.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/dist/client.d.ts CHANGED
@@ -12,6 +12,7 @@ import { HyperAgentService } from "./services/agents/hyper-agent";
12
12
  import { TeamService } from "./services/team";
13
13
  import { ComputerActionService } from "./services/computer-action";
14
14
  import { GeminiComputerUseService } from "./services/agents/gemini-computer-use";
15
+ import { WebService } from "./services/web";
15
16
  export declare class HyperbrowserError extends Error {
16
17
  statusCode?: number | undefined;
17
18
  constructor(message: string, statusCode?: number | undefined);
@@ -23,6 +24,7 @@ export declare class HyperbrowserClient {
23
24
  readonly extract: ExtractService;
24
25
  readonly profiles: ProfilesService;
25
26
  readonly extensions: ExtensionService;
27
+ readonly web: WebService;
26
28
  readonly agents: {
27
29
  browserUse: BrowserUseService;
28
30
  claudeComputerUse: ClaudeComputerUseService;
package/dist/client.js CHANGED
@@ -14,6 +14,7 @@ const hyper_agent_1 = require("./services/agents/hyper-agent");
14
14
  const team_1 = require("./services/team");
15
15
  const computer_action_1 = require("./services/computer-action");
16
16
  const gemini_computer_use_1 = require("./services/agents/gemini-computer-use");
17
+ const web_1 = require("./services/web");
17
18
  class HyperbrowserError extends Error {
18
19
  constructor(message, statusCode) {
19
20
  super(`[Hyperbrowser]: ${message}`);
@@ -36,6 +37,7 @@ class HyperbrowserClient {
36
37
  this.extract = new extract_1.ExtractService(apiKey, baseUrl, timeout);
37
38
  this.profiles = new profiles_1.ProfilesService(apiKey, baseUrl, timeout);
38
39
  this.extensions = new extensions_1.ExtensionService(apiKey, baseUrl, timeout);
40
+ this.web = new web_1.WebService(apiKey, baseUrl, timeout);
39
41
  this.team = new team_1.TeamService(apiKey, baseUrl, timeout);
40
42
  this.computerAction = new computer_action_1.ComputerActionService(apiKey, baseUrl, timeout);
41
43
  this.agents = {
@@ -1,4 +1,4 @@
1
- import { BasicResponse, CreateSessionParams, GetActiveSessionsCountResponse, GetSessionDownloadsUrlResponse, GetSessionRecordingUrlResponse, GetSessionVideoRecordingUrlResponse, SessionDetail, SessionListParams, SessionListResponse, SessionRecording, UploadFileOptions, UploadFileResponse, SessionEventLogListParams, SessionEventLogListResponse, UpdateSessionProfileParams } from "../types/session";
1
+ import { BasicResponse, CreateSessionParams, GetActiveSessionsCountResponse, GetSessionDownloadsUrlResponse, GetSessionRecordingUrlResponse, GetSessionVideoRecordingUrlResponse, SessionDetail, SessionListParams, SessionListResponse, SessionRecording, UploadFileOptions, UploadFileResponse, SessionEventLogListParams, SessionEventLogListResponse, UpdateSessionProfileParams, SessionGetParams } from "../types/session";
2
2
  import { BaseService } from "./base";
3
3
  /**
4
4
  * Service for managing session event logs
@@ -23,7 +23,7 @@ export declare class SessionsService extends BaseService {
23
23
  * Get details of an existing session
24
24
  * @param id The ID of the session to get
25
25
  */
26
- get(id: string): Promise<SessionDetail>;
26
+ get(id: string, params?: SessionGetParams): Promise<SessionDetail>;
27
27
  /**
28
28
  * Stop a running session
29
29
  * @param id The ID of the session to stop
@@ -83,9 +83,11 @@ class SessionsService extends base_1.BaseService {
83
83
  * Get details of an existing session
84
84
  * @param id The ID of the session to get
85
85
  */
86
- async get(id) {
86
+ async get(id, params = {}) {
87
87
  try {
88
- return await this.request(`/session/${id}`);
88
+ return await this.request(`/session/${id}`, undefined, {
89
+ liveViewTtlSeconds: params.liveViewTtlSeconds,
90
+ });
89
91
  }
90
92
  catch (error) {
91
93
  if (error instanceof client_1.HyperbrowserError) {
@@ -0,0 +1,15 @@
1
+ import { BaseService } from "../base";
2
+ import { FetchParams, FetchResponse } from "../../types/web/fetch";
3
+ import { WebSearchParams, WebSearchResponse } from "../../types/web/search";
4
+ export declare class WebService extends BaseService {
5
+ /**
6
+ * Fetch a URL and extract content
7
+ * @param params The parameters for the fetch request
8
+ */
9
+ fetch(params: FetchParams): Promise<FetchResponse>;
10
+ /**
11
+ * Search the web
12
+ * @param params The parameters for the search request
13
+ */
14
+ search(params: WebSearchParams): Promise<WebSearchResponse>;
15
+ }
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.WebService = void 0;
7
+ const zod_1 = require("zod");
8
+ const zod_to_json_schema_1 = __importDefault(require("zod-to-json-schema"));
9
+ const base_1 = require("../base");
10
+ const client_1 = require("../../client");
11
+ const utils_1 = require("../../utils");
12
+ class WebService extends base_1.BaseService {
13
+ /**
14
+ * Fetch a URL and extract content
15
+ * @param params The parameters for the fetch request
16
+ */
17
+ async fetch(params) {
18
+ try {
19
+ // Handle JSON schema serialization if needed (similar to Python SDK)
20
+ if (params.outputs?.formats) {
21
+ for (const output of params.outputs.formats) {
22
+ if (typeof output === "object" && "type" in output && output.type === "json") {
23
+ const jsonOutput = output;
24
+ if (jsonOutput.schema) {
25
+ if ((0, utils_1.isZodSchema)(jsonOutput.schema)) {
26
+ try {
27
+ output.schema = (0, zod_1.toJSONSchema)(jsonOutput.schema);
28
+ }
29
+ catch {
30
+ output.schema = (0, zod_to_json_schema_1.default)(jsonOutput.schema);
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }
36
+ }
37
+ return await this.request("/web/fetch", {
38
+ method: "POST",
39
+ body: JSON.stringify(params),
40
+ });
41
+ }
42
+ catch (error) {
43
+ if (error instanceof client_1.HyperbrowserError) {
44
+ throw error;
45
+ }
46
+ throw new client_1.HyperbrowserError("Failed to fetch URL", undefined);
47
+ }
48
+ }
49
+ /**
50
+ * Search the web
51
+ * @param params The parameters for the search request
52
+ */
53
+ async search(params) {
54
+ try {
55
+ return await this.request("/web/search", {
56
+ method: "POST",
57
+ body: JSON.stringify(params),
58
+ });
59
+ }
60
+ catch (error) {
61
+ if (error instanceof client_1.HyperbrowserError) {
62
+ throw error;
63
+ }
64
+ throw new client_1.HyperbrowserError("Failed to search web", undefined);
65
+ }
66
+ }
67
+ }
68
+ exports.WebService = WebService;
@@ -7,9 +7,12 @@ 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, SessionListParams, SessionListResponse, ScreenConfig, CreateSessionParams, GetSessionDownloadsUrlResponse, GetSessionVideoRecordingUrlResponse, GetSessionRecordingUrlResponse, ImageCaptchaParam, UploadFileResponse, UploadFileOptions, GetActiveSessionsCountResponse, SessionEventLogListParams, SessionEventLogListResponse, SessionEventLog, SessionProfile, SessionLaunchState, UpdateSessionProfileParams, } from "./session";
10
+ export { BasicResponse, SessionStatus, Session, SessionDetail, SessionGetParams, SessionListParams, SessionListResponse, ScreenConfig, CreateSessionParams, GetSessionDownloadsUrlResponse, GetSessionVideoRecordingUrlResponse, GetSessionRecordingUrlResponse, ImageCaptchaParam, UploadFileResponse, UploadFileOptions, GetActiveSessionsCountResponse, SessionEventLogListParams, SessionEventLogListResponse, SessionEventLog, SessionProfile, SessionLaunchState, UpdateSessionProfileParams, } from "./session";
11
11
  export { CreateProfileParams, ProfileResponse, CreateProfileResponse, ProfileListParams, ProfileListResponse, } from "./profile";
12
12
  export { CreateExtensionParams, CreateExtensionResponse, ListExtensionsResponse, } from "./extension";
13
13
  export { ExtractJobStatus, BrowserUseTaskStatus, BrowserUseLlm, ClaudeComputerUseLlm, 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";
14
14
  export { TeamCreditInfo } from "./team";
15
15
  export { ComputerAction, Coordinate, ClickActionParams, DragActionParams, PressKeysActionParams, MoveMouseActionParams, ScreenshotActionParams, ScrollActionParams, TypeTextActionParams, ComputerActionParams, ComputerActionResponse, ComputerActionMouseButton, ComputerActionResponseData, HoldKeyActionParams, MouseDownActionParams, MouseUpActionParams, GetClipboardTextActionParams, PutSelectionTextActionParams, ComputerActionResponseDataClipboardText, } from "./computer-action";
16
+ export { FetchParams, FetchResponse, FetchResponseData, FetchStatus } from "./web/fetch";
17
+ export { WebSearchParams, WebSearchResponse, WebSearchResponseData, WebSearchResultItem, WebSearchFilters, WebSearchLocation, WebSearchFiletype, WebSearchStatus, } from "./web/search";
18
+ export { FetchStealthMode, FetchSanitizeMode, FetchWaitUntil, FetchScreenshotFormat, PageStatus, FetchOutputScreenshotOptions, FetchStorageStateOptions, FetchBrowserLocationOptions, PageData, FetchOutputMarkdown, FetchOutputHtml, FetchOutputLinks, FetchOutputScreenshot, FetchOutputJsonOptions, FetchOutputJson, FetchOutputFormat, FetchOutputOptions, FetchBrowserOptions, FetchNavigationOptions, FetchCacheOptions, } from "./web/common";
@@ -50,6 +50,9 @@ export interface SessionDetail extends Session {
50
50
  liveUrl?: string;
51
51
  token: string;
52
52
  }
53
+ export interface SessionGetParams {
54
+ liveViewTtlSeconds?: number;
55
+ }
53
56
  export interface SessionListParams {
54
57
  status?: SessionStatus;
55
58
  page?: number;
@@ -114,6 +117,7 @@ export interface CreateSessionParams {
114
117
  enableAlwaysOpenPdfExternally?: boolean;
115
118
  appendTimestampToDownloads?: boolean;
116
119
  showScrollbars?: boolean;
120
+ liveViewTtlSeconds?: number;
117
121
  replaceNativeElements?: boolean;
118
122
  }
119
123
  export interface SessionRecording {
@@ -0,0 +1,74 @@
1
+ import { Country, State } from "../constants";
2
+ import { ScreenConfig } from "../session";
3
+ export type FetchStealthMode = "none" | "auto" | "ultra";
4
+ export type FetchSanitizeMode = "none" | "basic" | "advanced";
5
+ export type FetchWaitUntil = "load" | "domcontentloaded" | "networkidle";
6
+ export type FetchScreenshotFormat = "jpeg" | "png" | "webp";
7
+ export type PageStatus = "completed" | "failed" | "pending" | "running";
8
+ export interface FetchOutputScreenshotOptions {
9
+ fullPage?: boolean;
10
+ format?: FetchScreenshotFormat;
11
+ cropToContent?: boolean;
12
+ cropToContentMaxHeight?: number;
13
+ cropToContentMinHeight?: number;
14
+ }
15
+ export interface FetchStorageStateOptions {
16
+ localStorage?: Record<string, string>;
17
+ sessionStorage?: Record<string, string>;
18
+ }
19
+ export interface FetchBrowserLocationOptions {
20
+ country?: Country;
21
+ state?: State;
22
+ city?: string;
23
+ }
24
+ export interface PageData {
25
+ url: string;
26
+ status: PageStatus;
27
+ error?: string;
28
+ metadata?: Record<string, string | string[]>;
29
+ markdown?: string;
30
+ html?: string;
31
+ links?: string[];
32
+ screenshot?: string;
33
+ json?: Record<string, any>;
34
+ }
35
+ export interface FetchOutputMarkdown {
36
+ type: "markdown";
37
+ }
38
+ export interface FetchOutputHtml {
39
+ type: "html";
40
+ }
41
+ export interface FetchOutputLinks {
42
+ type: "links";
43
+ }
44
+ export interface FetchOutputScreenshot extends FetchOutputScreenshotOptions {
45
+ type: "screenshot";
46
+ }
47
+ export interface FetchOutputJsonOptions {
48
+ schema?: any;
49
+ }
50
+ export interface FetchOutputJson extends FetchOutputJsonOptions {
51
+ type: "json";
52
+ }
53
+ export type FetchOutputFormat = FetchOutputMarkdown | FetchOutputHtml | FetchOutputLinks | FetchOutputScreenshot | FetchOutputJson | "markdown" | "html" | "links" | "screenshot";
54
+ export interface FetchOutputOptions {
55
+ formats?: FetchOutputFormat[];
56
+ sanitize?: FetchSanitizeMode;
57
+ includeSelectors?: string[];
58
+ excludeSelectors?: string[];
59
+ storageState?: FetchStorageStateOptions;
60
+ }
61
+ export interface FetchBrowserOptions {
62
+ screen?: ScreenConfig;
63
+ profileId?: string;
64
+ solveCaptchas?: string;
65
+ location?: FetchBrowserLocationOptions;
66
+ }
67
+ export interface FetchNavigationOptions {
68
+ waitUntil?: FetchWaitUntil;
69
+ timeoutMs?: number;
70
+ waitFor?: number;
71
+ }
72
+ export interface FetchCacheOptions {
73
+ maxAgeSeconds?: number;
74
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,24 @@
1
+ import { FetchStealthMode, FetchOutputOptions, FetchBrowserOptions, FetchNavigationOptions, FetchCacheOptions } from "./common";
2
+ export type FetchStatus = "completed" | "failed" | "pending" | "running";
3
+ export interface FetchParams {
4
+ url: string;
5
+ stealth?: FetchStealthMode;
6
+ outputs?: FetchOutputOptions;
7
+ browser?: FetchBrowserOptions;
8
+ navigation?: FetchNavigationOptions;
9
+ cache?: FetchCacheOptions;
10
+ }
11
+ export interface FetchResponseData {
12
+ metadata?: Record<string, string | string[]>;
13
+ html?: string;
14
+ markdown?: string;
15
+ links?: string[];
16
+ screenshot?: string;
17
+ json?: Record<string, any>;
18
+ }
19
+ export interface FetchResponse {
20
+ jobId: string;
21
+ status: FetchStatus;
22
+ error?: string;
23
+ data?: FetchResponseData;
24
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,41 @@
1
+ import { Country, State } from "../constants";
2
+ export type WebSearchFiletype = "pdf" | "doc" | "docx" | "xls" | "xlsx" | "ppt" | "pptx" | "html";
3
+ export type WebSearchStatus = "completed" | "failed" | "pending" | "running";
4
+ export interface WebSearchFilters {
5
+ exactPhrase?: boolean;
6
+ semanticPhrase?: boolean;
7
+ excludeTerms?: string[];
8
+ boostTerms?: string[];
9
+ filetype?: WebSearchFiletype;
10
+ site?: string;
11
+ excludeSite?: string;
12
+ intitle?: string;
13
+ inurl?: string;
14
+ }
15
+ export interface WebSearchLocation {
16
+ country?: Country;
17
+ state?: State;
18
+ city?: string;
19
+ }
20
+ export interface WebSearchParams {
21
+ query: string;
22
+ page?: number;
23
+ maxAgeSeconds?: number;
24
+ location?: WebSearchLocation;
25
+ filters?: WebSearchFilters;
26
+ }
27
+ export interface WebSearchResultItem {
28
+ title: string;
29
+ url: string;
30
+ description: string;
31
+ }
32
+ export interface WebSearchResponseData {
33
+ query: string;
34
+ results: WebSearchResultItem[];
35
+ }
36
+ export interface WebSearchResponse {
37
+ jobId: string;
38
+ status: WebSearchStatus;
39
+ error?: string;
40
+ data?: WebSearchResponseData;
41
+ }
@@ -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": "0.81.1",
3
+ "version": "0.82.0",
4
4
  "description": "Node SDK for Hyperbrowser API",
5
5
  "author": "",
6
6
  "main": "dist/index.js",