@hyperbrowser/sdk 0.46.0 → 0.48.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
@@ -8,6 +8,7 @@ import { ExtractService } from "./services/extract";
8
8
  import { BrowserUseService } from "./services/agents/browser-use";
9
9
  import { CuaService } from "./services/agents/cua";
10
10
  import { ClaudeComputerUseService } from "./services/agents/claude-computer-use";
11
+ import { HyperAgentService } from "./services/agents/hyper-agent";
11
12
  export declare class HyperbrowserError extends Error {
12
13
  statusCode?: number | undefined;
13
14
  constructor(message: string, statusCode?: number | undefined);
@@ -23,6 +24,7 @@ export declare class HyperbrowserClient {
23
24
  browserUse: BrowserUseService;
24
25
  claudeComputerUse: ClaudeComputerUseService;
25
26
  cua: CuaService;
27
+ hyperAgent: HyperAgentService;
26
28
  };
27
29
  constructor(config?: HyperbrowserConfig);
28
30
  }
package/dist/client.js CHANGED
@@ -10,6 +10,7 @@ const extract_1 = require("./services/extract");
10
10
  const browser_use_1 = require("./services/agents/browser-use");
11
11
  const cua_1 = require("./services/agents/cua");
12
12
  const claude_computer_use_1 = require("./services/agents/claude-computer-use");
13
+ const hyper_agent_1 = require("./services/agents/hyper-agent");
13
14
  class HyperbrowserError extends Error {
14
15
  constructor(message, statusCode) {
15
16
  super(`[Hyperbrowser]: ${message}`);
@@ -36,6 +37,7 @@ class HyperbrowserClient {
36
37
  browserUse: new browser_use_1.BrowserUseService(apiKey, baseUrl, timeout),
37
38
  claudeComputerUse: new claude_computer_use_1.ClaudeComputerUseService(apiKey, baseUrl, timeout),
38
39
  cua: new cua_1.CuaService(apiKey, baseUrl, timeout),
40
+ hyperAgent: new hyper_agent_1.HyperAgentService(apiKey, baseUrl, timeout),
39
41
  };
40
42
  }
41
43
  }
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.BrowserUseService = void 0;
7
+ const zod_to_json_schema_1 = __importDefault(require("zod-to-json-schema"));
4
8
  const client_1 = require("../../client");
5
9
  const constants_1 = require("../../types/constants");
6
10
  const utils_1 = require("../../utils");
@@ -12,6 +16,11 @@ class BrowserUseService extends base_1.BaseService {
12
16
  */
13
17
  async start(params) {
14
18
  try {
19
+ if (params.outputModelSchema) {
20
+ if ((0, utils_1.isZodSchema)(params.outputModelSchema)) {
21
+ params.outputModelSchema = (0, zod_to_json_schema_1.default)(params.outputModelSchema);
22
+ }
23
+ }
15
24
  return await this.request("/task/browser-use", {
16
25
  method: "POST",
17
26
  body: JSON.stringify(params),
@@ -0,0 +1,30 @@
1
+ import { BasicResponse } from "../../types";
2
+ import { BaseService } from "../base";
3
+ import { HyperAgentTaskResponse, HyperAgentTaskStatusResponse, StartHyperAgentTaskParams, StartHyperAgentTaskResponse } from "../../types/agents/hyper-agent";
4
+ export declare class HyperAgentService extends BaseService {
5
+ /**
6
+ * Start a new HyperAgent task job
7
+ * @param params The parameters for the task job
8
+ */
9
+ start(params: StartHyperAgentTaskParams): Promise<StartHyperAgentTaskResponse>;
10
+ /**
11
+ * Get the status of a HyperAgent task job
12
+ * @param id The ID of the task job to get
13
+ */
14
+ getStatus(id: string): Promise<HyperAgentTaskStatusResponse>;
15
+ /**
16
+ * Get the result of a HyperAgent task job
17
+ * @param id The ID of the task job to get
18
+ */
19
+ get(id: string): Promise<HyperAgentTaskResponse>;
20
+ /**
21
+ * Stop a HyperAgent task job
22
+ * @param id The ID of the task job to stop
23
+ */
24
+ stop(id: string): Promise<BasicResponse>;
25
+ /**
26
+ * Start a HyperAgent task job and wait for it to complete
27
+ * @param params The parameters for the task job
28
+ */
29
+ startAndWait(params: StartHyperAgentTaskParams): Promise<HyperAgentTaskResponse>;
30
+ }
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HyperAgentService = void 0;
4
+ const client_1 = require("../../client");
5
+ const constants_1 = require("../../types/constants");
6
+ const utils_1 = require("../../utils");
7
+ const base_1 = require("../base");
8
+ class HyperAgentService extends base_1.BaseService {
9
+ /**
10
+ * Start a new HyperAgent task job
11
+ * @param params The parameters for the task job
12
+ */
13
+ async start(params) {
14
+ try {
15
+ return await this.request("/task/hyper-agent", {
16
+ method: "POST",
17
+ body: JSON.stringify(params),
18
+ });
19
+ }
20
+ catch (error) {
21
+ if (error instanceof client_1.HyperbrowserError) {
22
+ throw error;
23
+ }
24
+ throw new client_1.HyperbrowserError("Failed to start HyperAgent task job", undefined);
25
+ }
26
+ }
27
+ /**
28
+ * Get the status of a HyperAgent task job
29
+ * @param id The ID of the task job to get
30
+ */
31
+ async getStatus(id) {
32
+ try {
33
+ return await this.request(`/task/hyper-agent/${id}/status`);
34
+ }
35
+ catch (error) {
36
+ if (error instanceof client_1.HyperbrowserError) {
37
+ throw error;
38
+ }
39
+ throw new client_1.HyperbrowserError(`Failed to get HyperAgent task job ${id} status`, undefined);
40
+ }
41
+ }
42
+ /**
43
+ * Get the result of a HyperAgent task job
44
+ * @param id The ID of the task job to get
45
+ */
46
+ async get(id) {
47
+ try {
48
+ return await this.request(`/task/hyper-agent/${id}`);
49
+ }
50
+ catch (error) {
51
+ if (error instanceof client_1.HyperbrowserError) {
52
+ throw error;
53
+ }
54
+ throw new client_1.HyperbrowserError(`Failed to get HyperAgent task job ${id}`, undefined);
55
+ }
56
+ }
57
+ /**
58
+ * Stop a HyperAgent task job
59
+ * @param id The ID of the task job to stop
60
+ */
61
+ async stop(id) {
62
+ try {
63
+ return await this.request(`/task/hyper-agent/${id}/stop`, {
64
+ method: "PUT",
65
+ });
66
+ }
67
+ catch (error) {
68
+ if (error instanceof client_1.HyperbrowserError) {
69
+ throw error;
70
+ }
71
+ throw new client_1.HyperbrowserError(`Failed to stop HyperAgent task job ${id}`, undefined);
72
+ }
73
+ }
74
+ /**
75
+ * Start a HyperAgent task job and wait for it to complete
76
+ * @param params The parameters for the task job
77
+ */
78
+ async startAndWait(params) {
79
+ const job = await this.start(params);
80
+ const jobId = job.jobId;
81
+ if (!jobId) {
82
+ throw new client_1.HyperbrowserError("Failed to start HyperAgent task job, could not get job ID");
83
+ }
84
+ let failures = 0;
85
+ while (true) {
86
+ try {
87
+ const { status } = await this.getStatus(jobId);
88
+ if (status === "completed" || status === "failed" || status === "stopped") {
89
+ return await this.get(jobId);
90
+ }
91
+ failures = 0;
92
+ }
93
+ catch (error) {
94
+ failures++;
95
+ if (failures >= constants_1.POLLING_ATTEMPTS) {
96
+ throw new client_1.HyperbrowserError(`Failed to poll HyperAgent task job ${jobId} after ${constants_1.POLLING_ATTEMPTS} attempts: ${error}`);
97
+ }
98
+ }
99
+ await (0, utils_1.sleep)(2000);
100
+ }
101
+ }
102
+ }
103
+ exports.HyperAgentService = HyperAgentService;
@@ -6,13 +6,6 @@ const base_1 = require("./base");
6
6
  const utils_1 = require("../utils");
7
7
  const client_1 = require("../client");
8
8
  const constants_1 = require("../types/constants");
9
- const isZodSchema = (schema) => {
10
- return (schema &&
11
- typeof schema === "object" &&
12
- "_def" in schema &&
13
- "parse" in schema &&
14
- typeof schema.parse === "function");
15
- };
16
9
  class ExtractService extends base_1.BaseService {
17
10
  /**
18
11
  * Start a new extract job
@@ -24,7 +17,7 @@ class ExtractService extends base_1.BaseService {
24
17
  throw new client_1.HyperbrowserError("Either schema or prompt must be provided");
25
18
  }
26
19
  if (params.schema) {
27
- if (isZodSchema(params.schema)) {
20
+ if ((0, utils_1.isZodSchema)(params.schema)) {
28
21
  params.schema = (0, zod_to_json_schema_1.zodToJsonSchema)(params.schema);
29
22
  }
30
23
  }
@@ -1,4 +1,4 @@
1
- import { BasicResponse, CreateSessionParams, GetSessionDownloadsUrlResponse, GetSessionRecordingUrlResponse, SessionDetail, SessionListParams, SessionListResponse, SessionRecording } from "../types/session";
1
+ import { BasicResponse, CreateSessionParams, GetSessionDownloadsUrlResponse, GetSessionRecordingUrlResponse, GetSessionVideoRecordingUrlResponse, SessionDetail, SessionListParams, SessionListResponse, SessionRecording } from "../types/session";
2
2
  import { BaseService } from "./base";
3
3
  export declare class SessionsService extends BaseService {
4
4
  /**
@@ -31,6 +31,11 @@ export declare class SessionsService extends BaseService {
31
31
  * @param id The ID of the session to get the recording URL from
32
32
  */
33
33
  getRecordingURL(id: string): Promise<GetSessionRecordingUrlResponse>;
34
+ /**
35
+ * Get the video recording URL of a session
36
+ * @param id The ID of the session to get the video recording URL from
37
+ */
38
+ getVideoRecordingURL(id: string): Promise<GetSessionVideoRecordingUrlResponse>;
34
39
  /**
35
40
  * Get the downloads URL of a session
36
41
  * @param id The ID of the session to get the downloads URL from
@@ -103,6 +103,21 @@ class SessionsService extends base_1.BaseService {
103
103
  throw new client_1.HyperbrowserError(`Failed to get recording url for session ${id}`, undefined);
104
104
  }
105
105
  }
106
+ /**
107
+ * Get the video recording URL of a session
108
+ * @param id The ID of the session to get the video recording URL from
109
+ */
110
+ async getVideoRecordingURL(id) {
111
+ try {
112
+ return await this.request(`/session/${id}/video-recording-url`);
113
+ }
114
+ catch (error) {
115
+ if (error instanceof client_1.HyperbrowserError) {
116
+ throw error;
117
+ }
118
+ throw new client_1.HyperbrowserError(`Failed to get video recording url for session ${id}`, undefined);
119
+ }
120
+ }
106
121
  /**
107
122
  * Get the downloads URL of a session
108
123
  * @param id The ID of the session to get the downloads URL from
@@ -1,3 +1,4 @@
1
+ import { z } from "zod";
1
2
  import { BrowserUseLlm, BrowserUseTaskStatus } from "../constants";
2
3
  import { CreateSessionParams } from "../session";
3
4
  export interface StartBrowserUseTaskParams {
@@ -15,6 +16,9 @@ export interface StartBrowserUseTaskParams {
15
16
  maxSteps?: number;
16
17
  maxFailures?: number;
17
18
  initialActions?: Array<Record<string, Record<string, any>>>;
19
+ sensitiveData?: Record<string, string>;
20
+ messageContext?: string;
21
+ outputModelSchema?: z.ZodSchema | object;
18
22
  keepBrowserOpen?: boolean;
19
23
  sessionOptions?: CreateSessionParams;
20
24
  }
@@ -0,0 +1,46 @@
1
+ import { HyperAgentLlm, HyperAgentTaskStatus } from "../constants";
2
+ import { CreateSessionParams } from "../session";
3
+ export interface StartHyperAgentTaskParams {
4
+ task: string;
5
+ llm?: HyperAgentLlm;
6
+ sessionId?: string;
7
+ maxSteps?: number;
8
+ keepBrowserOpen?: boolean;
9
+ sessionOptions?: CreateSessionParams;
10
+ }
11
+ export interface StartHyperAgentTaskResponse {
12
+ jobId: string;
13
+ liveUrl: string | null;
14
+ }
15
+ export interface HyperAgentTaskStatusResponse {
16
+ status: HyperAgentTaskStatus;
17
+ }
18
+ export interface HyperAgentActionOutput {
19
+ success: boolean;
20
+ message: string;
21
+ extract?: object;
22
+ }
23
+ export interface HyperAgentOutput {
24
+ thoughts: string;
25
+ memory: string;
26
+ nextGoal: string;
27
+ actions: {
28
+ [x: string]: any;
29
+ }[];
30
+ }
31
+ export interface HyperAgentStep {
32
+ idx: number;
33
+ agentOutput: HyperAgentOutput;
34
+ actionOutputs: HyperAgentActionOutput[];
35
+ }
36
+ export interface HyperAgentTaskData {
37
+ steps: HyperAgentStep[];
38
+ finalResult: string | null;
39
+ }
40
+ export interface HyperAgentTaskResponse {
41
+ jobId: string;
42
+ status: HyperAgentTaskStatus;
43
+ data?: HyperAgentTaskData | null;
44
+ error?: string | null;
45
+ liveUrl: string | null;
46
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -4,6 +4,7 @@ export type ExtractJobStatus = "pending" | "running" | "completed" | "failed";
4
4
  export type CrawlJobStatus = "pending" | "running" | "completed" | "failed";
5
5
  export type BrowserUseTaskStatus = "pending" | "running" | "completed" | "failed" | "stopped";
6
6
  export type CuaTaskStatus = "pending" | "running" | "completed" | "failed" | "stopped";
7
+ export type HyperAgentTaskStatus = "pending" | "running" | "completed" | "failed" | "stopped";
7
8
  export type ClaudeComputerUseTaskStatus = "pending" | "running" | "completed" | "failed" | "stopped";
8
9
  export type ScrapePageStatus = "completed" | "failed" | "pending" | "running";
9
10
  export type CrawlPageStatus = "completed" | "failed";
@@ -13,6 +14,7 @@ export type RecordingStatus = "not_enabled" | "pending" | "in_progress" | "compl
13
14
  export type DownloadsStatus = "not_enabled" | "pending" | "in_progress" | "completed" | "failed";
14
15
  export declare const POLLING_ATTEMPTS = 5;
15
16
  export type BrowserUseLlm = "gpt-4o" | "gpt-4o-mini" | "claude-3-7-sonnet-20250219" | "claude-3-5-sonnet-20241022" | "claude-3-5-haiku-20241022" | "gemini-2.0-flash";
17
+ export type HyperAgentLlm = "gpt-4o" | "gpt-4o-mini" | "gpt-4.1" | "gpt-4.1-mini" | "gpt-4.1-nano";
16
18
  export type Country = "AD" | "AE" | "AF" | "AL" | "AM" | "AO" | "AR" | "AT" | "AU" | "AW" | "AZ" | "BA" | "BD" | "BE" | "BG" | "BH" | "BJ" | "BO" | "BR" | "BS" | "BT" | "BY" | "BZ" | "CA" | "CF" | "CH" | "CI" | "CL" | "CM" | "CN" | "CO" | "CR" | "CU" | "CY" | "CZ" | "DE" | "DJ" | "DK" | "DM" | "EC" | "EE" | "EG" | "ES" | "ET" | "EU" | "FI" | "FJ" | "FR" | "GB" | "GE" | "GH" | "GM" | "GR" | "HK" | "HN" | "HR" | "HT" | "HU" | "ID" | "IE" | "IL" | "IN" | "IQ" | "IR" | "IS" | "IT" | "JM" | "JO" | "JP" | "KE" | "KH" | "KR" | "KW" | "KZ" | "LB" | "LI" | "LR" | "LT" | "LU" | "LV" | "MA" | "MC" | "MD" | "ME" | "MG" | "MK" | "ML" | "MM" | "MN" | "MR" | "MT" | "MU" | "MV" | "MX" | "MY" | "MZ" | "NG" | "NL" | "NO" | "NZ" | "OM" | "PA" | "PE" | "PH" | "PK" | "PL" | "PR" | "PT" | "PY" | "QA" | "RANDOM_COUNTRY" | "RO" | "RS" | "RU" | "SA" | "SC" | "SD" | "SE" | "SG" | "SI" | "SK" | "SN" | "SS" | "TD" | "TG" | "TH" | "TM" | "TN" | "TR" | "TT" | "TW" | "UA" | "UG" | "US" | "UY" | "UZ" | "VE" | "VG" | "VN" | "YE" | "ZA" | "ZM" | "ZW" | "ad" | "ae" | "af" | "al" | "am" | "ao" | "ar" | "at" | "au" | "aw" | "az" | "ba" | "bd" | "be" | "bg" | "bh" | "bj" | "bo" | "br" | "bs" | "bt" | "by" | "bz" | "ca" | "cf" | "ch" | "ci" | "cl" | "cm" | "cn" | "co" | "cr" | "cu" | "cy" | "cz" | "de" | "dj" | "dk" | "dm" | "ec" | "ee" | "eg" | "es" | "et" | "eu" | "fi" | "fj" | "fr" | "gb" | "ge" | "gh" | "gm" | "gr" | "hk" | "hn" | "hr" | "ht" | "hu" | "id" | "ie" | "il" | "in" | "iq" | "ir" | "is" | "it" | "jm" | "jo" | "jp" | "ke" | "kh" | "kr" | "kw" | "kz" | "lb" | "li" | "lr" | "lt" | "lu" | "lv" | "ma" | "mc" | "md" | "me" | "mg" | "mk" | "ml" | "mm" | "mn" | "mr" | "mt" | "mu" | "mv" | "mx" | "my" | "mz" | "ng" | "nl" | "no" | "nz" | "om" | "pa" | "pe" | "ph" | "pk" | "pl" | "pr" | "pt" | "py" | "qa" | "ro" | "rs" | "ru" | "sa" | "sc" | "sd" | "se" | "sg" | "si" | "sk" | "sn" | "ss" | "td" | "tg" | "th" | "tm" | "tn" | "tr" | "tt" | "tw" | "ua" | "ug" | "us" | "uy" | "uz" | "ve" | "vg" | "vn" | "ye" | "za" | "zm" | "zw";
17
19
  export type OperatingSystem = "windows" | "android" | "macos" | "linux" | "ios";
18
20
  export type Platform = "chrome" | "firefox" | "safari" | "edge";
@@ -5,7 +5,8 @@ export { StartExtractJobParams, StartExtractJobResponse, ExtractJobResponse, Ext
5
5
  export { StartBrowserUseTaskParams, StartBrowserUseTaskResponse, BrowserUseTaskStatusResponse, BrowserUseTaskResponse, BrowserUseTaskData, } from "./agents/browser-use";
6
6
  export { StartClaudeComputerUseTaskParams, StartClaudeComputerUseTaskResponse, ClaudeComputerUseTaskStatusResponse, ClaudeComputerUseTaskResponse, ClaudeComputerUseTaskData, ClaudeComputerUseStepResponse, } from "./agents/claude-computer-use";
7
7
  export { StartCuaTaskParams, StartCuaTaskResponse, CuaTaskStatusResponse, CuaTaskResponse, CuaTaskData, CuaStepResponse, } from "./agents/cua";
8
- export { BasicResponse, SessionStatus, Session, SessionDetail, SessionListParams, SessionListResponse, ScreenConfig, CreateSessionParams, GetSessionDownloadsUrlResponse, GetSessionRecordingUrlResponse, ImageCaptchaParam, } from "./session";
8
+ export { StartHyperAgentTaskParams, StartHyperAgentTaskResponse, HyperAgentTaskStatusResponse, HyperAgentTaskResponse, HyperAgentTaskData, HyperAgentStep, HyperAgentOutput, HyperAgentActionOutput, } from "./agents/hyper-agent";
9
+ export { BasicResponse, SessionStatus, Session, SessionDetail, SessionListParams, SessionListResponse, ScreenConfig, CreateSessionParams, GetSessionDownloadsUrlResponse, GetSessionVideoRecordingUrlResponse, GetSessionRecordingUrlResponse, ImageCaptchaParam, } from "./session";
9
10
  export { CreateProfileParams, ProfileResponse, CreateProfileResponse, ProfileListParams, ProfileListResponse, } from "./profile";
10
11
  export { CreateExtensionParams, CreateExtensionResponse, ListExtensionsResponse, } from "./extension";
11
- export { ExtractJobStatus, BrowserUseTaskStatus, BrowserUseLlm, ScrapeScreenshotFormat, ScrapeJobStatus, CrawlJobStatus, Country, State, ISO639_1, OperatingSystem, Platform, ScrapeFormat, ScrapeWaitUntil, ScrapePageStatus, CrawlPageStatus, RecordingStatus, DownloadsStatus, } from "./constants";
12
+ export { ExtractJobStatus, BrowserUseTaskStatus, BrowserUseLlm, ScrapeScreenshotFormat, ScrapeJobStatus, CrawlJobStatus, Country, State, ISO639_1, OperatingSystem, Platform, ScrapeFormat, ScrapeWaitUntil, ScrapePageStatus, CrawlPageStatus, RecordingStatus, DownloadsStatus, HyperAgentLlm, HyperAgentTaskStatus, ClaudeComputerUseTaskStatus, CuaTaskStatus, } from "./constants";
@@ -60,6 +60,7 @@ export interface CreateSessionParams {
60
60
  trackers?: boolean;
61
61
  annoyances?: boolean;
62
62
  enableWebRecording?: boolean;
63
+ enableVideoWebRecording?: boolean;
63
64
  profile?: CreateSessionProfile;
64
65
  extensionIds?: Array<string>;
65
66
  staticIpId?: string;
@@ -81,6 +82,11 @@ export interface GetSessionRecordingUrlResponse {
81
82
  recordingUrl?: string | null;
82
83
  error?: string | null;
83
84
  }
85
+ export interface GetSessionVideoRecordingUrlResponse {
86
+ status: RecordingStatus;
87
+ recordingUrl?: string | null;
88
+ error?: string | null;
89
+ }
84
90
  export interface GetSessionDownloadsUrlResponse {
85
91
  status: DownloadsStatus;
86
92
  downloadsUrl?: string | null;
package/dist/utils.d.ts CHANGED
@@ -1 +1,3 @@
1
+ import { z } from "zod";
1
2
  export declare const sleep: (ms: number) => Promise<unknown>;
3
+ export declare const isZodSchema: (schema: z.ZodSchema | object) => schema is z.ZodType;
package/dist/utils.js CHANGED
@@ -1,5 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sleep = void 0;
3
+ exports.isZodSchema = exports.sleep = void 0;
4
4
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
5
5
  exports.sleep = sleep;
6
+ const isZodSchema = (schema) => {
7
+ return (schema &&
8
+ typeof schema === "object" &&
9
+ "_def" in schema &&
10
+ "parse" in schema &&
11
+ typeof schema.parse === "function");
12
+ };
13
+ exports.isZodSchema = isZodSchema;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperbrowser/sdk",
3
- "version": "0.46.0",
3
+ "version": "0.48.0",
4
4
  "description": "Node SDK for Hyperbrowser API",
5
5
  "author": "",
6
6
  "main": "dist/index.js",