@hyperbrowser/sdk 0.34.0 → 0.35.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
@@ -5,7 +5,7 @@ import { CrawlService } from "./services/crawl";
5
5
  import { ProfilesService } from "./services/profiles";
6
6
  import { ExtensionService } from "./services/extensions";
7
7
  import { ExtractService } from "./services/extract";
8
- import { BrowserUseService } from "./services/beta/agents/browser-use";
8
+ import { BrowserUseService } from "./services/agents/browser-use";
9
9
  export declare class HyperbrowserError extends Error {
10
10
  statusCode?: number | undefined;
11
11
  constructor(message: string, statusCode?: number | undefined);
@@ -17,10 +17,8 @@ export declare class HyperbrowserClient {
17
17
  readonly extract: ExtractService;
18
18
  readonly profiles: ProfilesService;
19
19
  readonly extensions: ExtensionService;
20
- readonly beta: {
21
- agents: {
22
- browserUse: BrowserUseService;
23
- };
20
+ readonly agents: {
21
+ browserUse: BrowserUseService;
24
22
  };
25
23
  constructor(config: HyperbrowserConfig);
26
24
  }
package/dist/client.js CHANGED
@@ -7,7 +7,7 @@ const crawl_1 = require("./services/crawl");
7
7
  const profiles_1 = require("./services/profiles");
8
8
  const extensions_1 = require("./services/extensions");
9
9
  const extract_1 = require("./services/extract");
10
- const browser_use_1 = require("./services/beta/agents/browser-use");
10
+ const browser_use_1 = require("./services/agents/browser-use");
11
11
  class HyperbrowserError extends Error {
12
12
  constructor(message, statusCode) {
13
13
  super(`[Hyperbrowser]: ${message}`);
@@ -30,10 +30,8 @@ class HyperbrowserClient {
30
30
  this.extract = new extract_1.ExtractService(apiKey, baseUrl, timeout);
31
31
  this.profiles = new profiles_1.ProfilesService(apiKey, baseUrl, timeout);
32
32
  this.extensions = new extensions_1.ExtensionService(apiKey, baseUrl, timeout);
33
- this.beta = {
34
- agents: {
35
- browserUse: new browser_use_1.BrowserUseService(apiKey, baseUrl, timeout),
36
- },
33
+ this.agents = {
34
+ browserUse: new browser_use_1.BrowserUseService(apiKey, baseUrl, timeout),
37
35
  };
38
36
  }
39
37
  }
@@ -1,6 +1,6 @@
1
- import { BasicResponse } from "../../../types";
2
- import { StartBrowserUseTaskParams, StartBrowserUseTaskResponse, BrowserUseTaskResponse, BrowserUseTaskStatusResponse } from "../../../types/beta/agents/browser-use";
3
- import { BaseService } from "../../base";
1
+ import { BasicResponse } from "../../types";
2
+ import { StartBrowserUseTaskParams, StartBrowserUseTaskResponse, BrowserUseTaskResponse, BrowserUseTaskStatusResponse } from "../../types/agents/browser-use";
3
+ import { BaseService } from "../base";
4
4
  export declare class BrowserUseService extends BaseService {
5
5
  /**
6
6
  * Start a new browser-use task job
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BrowserUseService = 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");
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
8
  class BrowserUseService extends base_1.BaseService {
9
9
  /**
10
10
  * Start a new browser-use task job
@@ -1,4 +1,4 @@
1
- import { CrawlJobResponse, GetCrawlJobParams, StartCrawlJobParams, StartCrawlJobResponse } from "../types/crawl";
1
+ import { CrawlJobResponse, CrawlJobStatusResponse, GetCrawlJobParams, StartCrawlJobParams, StartCrawlJobResponse } from "../types/crawl";
2
2
  import { BaseService } from "./base";
3
3
  export declare class CrawlService extends BaseService {
4
4
  /**
@@ -6,6 +6,11 @@ export declare class CrawlService extends BaseService {
6
6
  * @param params The parameters for the crawl job
7
7
  */
8
8
  start(params: StartCrawlJobParams): Promise<StartCrawlJobResponse>;
9
+ /**
10
+ * Get the status of a crawl job
11
+ * @param id The ID of the crawl job to get
12
+ */
13
+ getStatus(id: string): Promise<CrawlJobStatusResponse>;
9
14
  /**
10
15
  * Get the status of a crawl job
11
16
  * @param id The ID of the crawl job to get
@@ -24,6 +24,21 @@ class CrawlService extends base_1.BaseService {
24
24
  throw new client_1.HyperbrowserError("Failed to start crawl job", undefined);
25
25
  }
26
26
  }
27
+ /**
28
+ * Get the status of a crawl job
29
+ * @param id The ID of the crawl job to get
30
+ */
31
+ async getStatus(id) {
32
+ try {
33
+ return await this.request(`/crawl/${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 crawl job status ${id}`, undefined);
40
+ }
41
+ }
27
42
  /**
28
43
  * Get the status of a crawl job
29
44
  * @param id The ID of the crawl job to get
@@ -33,6 +48,7 @@ class CrawlService extends base_1.BaseService {
33
48
  try {
34
49
  return await this.request(`/crawl/${id}`, undefined, {
35
50
  page: params?.page,
51
+ batchSize: params?.batchSize,
36
52
  });
37
53
  }
38
54
  catch (error) {
@@ -53,12 +69,13 @@ class CrawlService extends base_1.BaseService {
53
69
  if (!jobId) {
54
70
  throw new client_1.HyperbrowserError("Failed to start crawl job, could not get job ID");
55
71
  }
56
- let jobResponse;
57
72
  let failures = 0;
73
+ let jobStatus = "pending";
58
74
  while (true) {
59
75
  try {
60
- jobResponse = await this.get(jobId, { batchSize: 1 });
61
- if (jobResponse.status === "completed" || jobResponse.status === "failed") {
76
+ const { status } = await this.getStatus(jobId);
77
+ if (status === "completed" || status === "failed") {
78
+ jobStatus = status;
62
79
  break;
63
80
  }
64
81
  failures = 0;
@@ -75,8 +92,7 @@ class CrawlService extends base_1.BaseService {
75
92
  if (!returnAllPages) {
76
93
  while (true) {
77
94
  try {
78
- jobResponse = await this.get(jobId);
79
- return jobResponse;
95
+ return await this.get(jobId);
80
96
  }
81
97
  catch (error) {
82
98
  failures++;
@@ -87,10 +103,18 @@ class CrawlService extends base_1.BaseService {
87
103
  await (0, utils_1.sleep)(500);
88
104
  }
89
105
  }
90
- jobResponse.currentPageBatch = 0;
91
- jobResponse.data = [];
92
106
  failures = 0;
93
- while (jobResponse.currentPageBatch < jobResponse.totalPageBatches) {
107
+ const jobResponse = {
108
+ jobId,
109
+ status: jobStatus,
110
+ data: [],
111
+ currentPageBatch: 0,
112
+ totalPageBatches: 0,
113
+ totalCrawledPages: 0,
114
+ batchSize: 100,
115
+ };
116
+ let firstCheck = true;
117
+ while (firstCheck || jobResponse.currentPageBatch < jobResponse.totalPageBatches) {
94
118
  try {
95
119
  const tmpJobResponse = await this.get(jobId, {
96
120
  page: jobResponse.currentPageBatch + 1,
@@ -104,6 +128,7 @@ class CrawlService extends base_1.BaseService {
104
128
  jobResponse.totalPageBatches = tmpJobResponse.totalPageBatches;
105
129
  jobResponse.batchSize = tmpJobResponse.batchSize;
106
130
  failures = 0;
131
+ firstCheck = false;
107
132
  }
108
133
  catch (error) {
109
134
  failures++;
@@ -1,5 +1,5 @@
1
1
  import { BaseService } from "./base";
2
- import { ExtractJobResponse, StartExtractJobResponse } from "../types/extract";
2
+ import { ExtractJobResponse, ExtractJobStatusResponse, StartExtractJobResponse } from "../types/extract";
3
3
  import { StartExtractJobParams } from "../types/extract";
4
4
  export declare class ExtractService extends BaseService {
5
5
  /**
@@ -11,6 +11,11 @@ export declare class ExtractService extends BaseService {
11
11
  * Get the status of an extract job
12
12
  * @param id The ID of the extract job to get
13
13
  */
14
+ getStatus(id: string): Promise<ExtractJobStatusResponse>;
15
+ /**
16
+ * Get the details of an extract job
17
+ * @param id The ID of the extract job to get
18
+ */
14
19
  get(id: string): Promise<ExtractJobResponse>;
15
20
  /**
16
21
  * Start an extract job and wait for it to complete
@@ -44,6 +44,21 @@ class ExtractService extends base_1.BaseService {
44
44
  * Get the status of an extract job
45
45
  * @param id The ID of the extract job to get
46
46
  */
47
+ async getStatus(id) {
48
+ try {
49
+ return await this.request(`/extract/${id}/status`);
50
+ }
51
+ catch (error) {
52
+ if (error instanceof client_1.HyperbrowserError) {
53
+ throw error;
54
+ }
55
+ throw new client_1.HyperbrowserError(`Failed to get extract job status ${id}`, undefined);
56
+ }
57
+ }
58
+ /**
59
+ * Get the details of an extract job
60
+ * @param id The ID of the extract job to get
61
+ */
47
62
  async get(id) {
48
63
  try {
49
64
  return await this.request(`/extract/${id}`);
@@ -65,13 +80,12 @@ class ExtractService extends base_1.BaseService {
65
80
  if (!jobId) {
66
81
  throw new client_1.HyperbrowserError("Failed to start extract job, could not get job ID");
67
82
  }
68
- let jobResponse;
69
83
  let failures = 0;
70
84
  while (true) {
71
85
  try {
72
- jobResponse = await this.get(jobId);
73
- if (jobResponse.status === "completed" || jobResponse.status === "failed") {
74
- break;
86
+ const { status } = await this.getStatus(jobId);
87
+ if (status === "completed" || status === "failed") {
88
+ return await this.get(jobId);
75
89
  }
76
90
  failures = 0;
77
91
  }
@@ -83,7 +97,6 @@ class ExtractService extends base_1.BaseService {
83
97
  }
84
98
  await (0, utils_1.sleep)(2000);
85
99
  }
86
- return jobResponse;
87
100
  }
88
101
  }
89
102
  exports.ExtractService = ExtractService;
@@ -1,4 +1,4 @@
1
- import { BatchScrapeJobResponse, GetBatchScrapeJobParams, ScrapeJobResponse, StartBatchScrapeJobParams, StartBatchScrapeJobResponse, StartScrapeJobParams, StartScrapeJobResponse } from "../types/scrape";
1
+ import { BatchScrapeJobResponse, BatchScrapeJobStatusResponse, GetBatchScrapeJobParams, ScrapeJobResponse, ScrapeJobStatusResponse, StartBatchScrapeJobParams, StartBatchScrapeJobResponse, StartScrapeJobParams, StartScrapeJobResponse } from "../types/scrape";
2
2
  import { BaseService } from "./base";
3
3
  export declare class BatchScrapeService extends BaseService {
4
4
  /**
@@ -9,6 +9,11 @@ export declare class BatchScrapeService extends BaseService {
9
9
  /**
10
10
  * Get the status of a batch scrape job
11
11
  * @param id The ID of the batch scrape job to get
12
+ */
13
+ getStatus(id: string): Promise<BatchScrapeJobStatusResponse>;
14
+ /**
15
+ * Get the details of a batch scrape job
16
+ * @param id The ID of the batch scrape job to get
12
17
  * @param params Optional parameters to filter the batch scrape job
13
18
  */
14
19
  get(id: string, params?: GetBatchScrapeJobParams): Promise<BatchScrapeJobResponse>;
@@ -31,6 +36,11 @@ export declare class ScrapeService extends BaseService {
31
36
  * Get the status of a scrape job
32
37
  * @param id The ID of the scrape job to get
33
38
  */
39
+ getStatus(id: string): Promise<ScrapeJobStatusResponse>;
40
+ /**
41
+ * Get the details of a scrape job
42
+ * @param id The ID of the scrape job to get
43
+ */
34
44
  get(id: string): Promise<ScrapeJobResponse>;
35
45
  /**
36
46
  * Start a scrape job and wait for it to complete
@@ -27,12 +27,28 @@ class BatchScrapeService extends base_1.BaseService {
27
27
  /**
28
28
  * Get the status of a batch scrape job
29
29
  * @param id The ID of the batch scrape job to get
30
+ */
31
+ async getStatus(id) {
32
+ try {
33
+ return await this.request(`/scrape/batch/${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 batch scrape job ${id} status`, undefined);
40
+ }
41
+ }
42
+ /**
43
+ * Get the details of a batch scrape job
44
+ * @param id The ID of the batch scrape job to get
30
45
  * @param params Optional parameters to filter the batch scrape job
31
46
  */
32
47
  async get(id, params) {
33
48
  try {
34
49
  return await this.request(`/scrape/batch/${id}`, undefined, {
35
50
  page: params?.page,
51
+ batchSize: params?.batchSize,
36
52
  });
37
53
  }
38
54
  catch (error) {
@@ -53,12 +69,13 @@ class BatchScrapeService extends base_1.BaseService {
53
69
  if (!jobId) {
54
70
  throw new client_1.HyperbrowserError("Failed to start batch scrape job, could not get job ID");
55
71
  }
56
- let jobResponse;
57
72
  let failures = 0;
73
+ let jobStatus = "pending";
58
74
  while (true) {
59
75
  try {
60
- jobResponse = await this.get(jobId, { batchSize: 1 });
61
- if (jobResponse.status === "completed" || jobResponse.status === "failed") {
76
+ const { status } = await this.getStatus(jobId);
77
+ if (status === "completed" || status === "failed") {
78
+ jobStatus = status;
62
79
  break;
63
80
  }
64
81
  failures = 0;
@@ -75,8 +92,7 @@ class BatchScrapeService extends base_1.BaseService {
75
92
  if (!returnAllPages) {
76
93
  while (true) {
77
94
  try {
78
- jobResponse = await this.get(jobId);
79
- return jobResponse;
95
+ return await this.get(jobId);
80
96
  }
81
97
  catch (error) {
82
98
  failures++;
@@ -87,10 +103,18 @@ class BatchScrapeService extends base_1.BaseService {
87
103
  await (0, utils_1.sleep)(500);
88
104
  }
89
105
  }
90
- jobResponse.currentPageBatch = 0;
91
- jobResponse.data = [];
92
106
  failures = 0;
93
- while (jobResponse.currentPageBatch < jobResponse.totalPageBatches) {
107
+ const jobResponse = {
108
+ jobId,
109
+ status: jobStatus,
110
+ data: [],
111
+ currentPageBatch: 0,
112
+ totalPageBatches: 0,
113
+ totalScrapedPages: 0,
114
+ batchSize: 100,
115
+ };
116
+ let firstCheck = true;
117
+ while (firstCheck || jobResponse.currentPageBatch < jobResponse.totalPageBatches) {
94
118
  try {
95
119
  const tmpJobResponse = await this.get(jobId, {
96
120
  page: jobResponse.currentPageBatch + 1,
@@ -104,6 +128,7 @@ class BatchScrapeService extends base_1.BaseService {
104
128
  jobResponse.totalPageBatches = tmpJobResponse.totalPageBatches;
105
129
  jobResponse.batchSize = tmpJobResponse.batchSize;
106
130
  failures = 0;
131
+ firstCheck = false;
107
132
  }
108
133
  catch (error) {
109
134
  failures++;
@@ -144,6 +169,21 @@ class ScrapeService extends base_1.BaseService {
144
169
  * Get the status of a scrape job
145
170
  * @param id The ID of the scrape job to get
146
171
  */
172
+ async getStatus(id) {
173
+ try {
174
+ return await this.request(`/scrape/${id}/status`);
175
+ }
176
+ catch (error) {
177
+ if (error instanceof client_1.HyperbrowserError) {
178
+ throw error;
179
+ }
180
+ throw new client_1.HyperbrowserError(`Failed to get scrape job status ${id}`, undefined);
181
+ }
182
+ }
183
+ /**
184
+ * Get the details of a scrape job
185
+ * @param id The ID of the scrape job to get
186
+ */
147
187
  async get(id) {
148
188
  try {
149
189
  return await this.request(`/scrape/${id}`);
@@ -165,13 +205,12 @@ class ScrapeService extends base_1.BaseService {
165
205
  if (!jobId) {
166
206
  throw new client_1.HyperbrowserError("Failed to start scrape job, could not get job ID");
167
207
  }
168
- let jobResponse;
169
208
  let failures = 0;
170
209
  while (true) {
171
210
  try {
172
- jobResponse = await this.get(jobId);
173
- if (jobResponse.status === "completed" || jobResponse.status === "failed") {
174
- break;
211
+ const { status } = await this.getStatus(jobId);
212
+ if (status === "completed" || status === "failed") {
213
+ return await this.get(jobId);
175
214
  }
176
215
  failures = 0;
177
216
  }
@@ -183,7 +222,6 @@ class ScrapeService extends base_1.BaseService {
183
222
  }
184
223
  await (0, utils_1.sleep)(2000);
185
224
  }
186
- return jobResponse;
187
225
  }
188
226
  }
189
227
  exports.ScrapeService = ScrapeService;
@@ -34,3 +34,4 @@ export interface Tool {
34
34
  export declare const SCRAPE_TOOL_ANTHROPIC: Tool;
35
35
  export declare const CRAWL_TOOL_ANTHROPIC: Tool;
36
36
  export declare const EXTRACT_TOOL_ANTHROPIC: Tool;
37
+ export declare const BROWSER_USE_TOOL_ANTHROPIC: Tool;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EXTRACT_TOOL_ANTHROPIC = exports.CRAWL_TOOL_ANTHROPIC = exports.SCRAPE_TOOL_ANTHROPIC = void 0;
3
+ exports.BROWSER_USE_TOOL_ANTHROPIC = exports.EXTRACT_TOOL_ANTHROPIC = exports.CRAWL_TOOL_ANTHROPIC = exports.SCRAPE_TOOL_ANTHROPIC = void 0;
4
4
  const schema_1 = require("./schema");
5
5
  exports.SCRAPE_TOOL_ANTHROPIC = {
6
6
  input_schema: schema_1.SCRAPE_SCHEMA,
@@ -17,3 +17,8 @@ exports.EXTRACT_TOOL_ANTHROPIC = {
17
17
  name: "extract_data",
18
18
  description: "Extract data in a structured format from multiple URLs in a single function call. IMPORTANT: When information must be gathered from multiple sources (such as comparing items, researching topics across sites, or answering questions that span multiple webpages), ALWAYS include all relevant URLs in ONE function call. This enables comprehensive answers with cross-referenced information. Returns data as a json string.",
19
19
  };
20
+ exports.BROWSER_USE_TOOL_ANTHROPIC = {
21
+ input_schema: schema_1.BROWSER_USE_SCHEMA,
22
+ name: "browser_use",
23
+ description: "Have an AI agent use a browser to perform a task on the web.",
24
+ };
@@ -1,5 +1,5 @@
1
1
  import { HyperbrowserClient } from "../client";
2
- import { StartScrapeJobParams, StartCrawlJobParams } from "../types";
2
+ import { StartScrapeJobParams, StartCrawlJobParams, StartBrowserUseTaskParams } from "../types";
3
3
  import { StartExtractJobParams } from "../types/extract";
4
4
  export declare class WebsiteScrapeTool {
5
5
  static openaiToolDefinition: import("./openai").ChatCompletionTool;
@@ -16,3 +16,8 @@ export declare class WebsiteExtractTool {
16
16
  static anthropicToolDefinition: import("./anthropic").Tool;
17
17
  static runnable(hb: HyperbrowserClient, params: StartExtractJobParams): Promise<string>;
18
18
  }
19
+ export declare class BrowserUseTool {
20
+ static openaiToolDefinition: import("./openai").ChatCompletionTool;
21
+ static anthropicToolDefinition: import("./anthropic").Tool;
22
+ static runnable(hb: HyperbrowserClient, params: StartBrowserUseTaskParams): Promise<string>;
23
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebsiteExtractTool = exports.WebsiteCrawlTool = exports.WebsiteScrapeTool = void 0;
3
+ exports.BrowserUseTool = exports.WebsiteExtractTool = exports.WebsiteCrawlTool = exports.WebsiteScrapeTool = void 0;
4
4
  const openai_1 = require("./openai");
5
5
  const anthropic_1 = require("./anthropic");
6
6
  class WebsiteScrapeTool {
@@ -41,3 +41,12 @@ class WebsiteExtractTool {
41
41
  exports.WebsiteExtractTool = WebsiteExtractTool;
42
42
  WebsiteExtractTool.openaiToolDefinition = openai_1.EXTRACT_TOOL_OPENAI;
43
43
  WebsiteExtractTool.anthropicToolDefinition = anthropic_1.EXTRACT_TOOL_ANTHROPIC;
44
+ class BrowserUseTool {
45
+ static async runnable(hb, params) {
46
+ const resp = await hb.agents.browserUse.startAndWait(params);
47
+ return resp.data?.finalResult || "";
48
+ }
49
+ }
50
+ exports.BrowserUseTool = BrowserUseTool;
51
+ BrowserUseTool.openaiToolDefinition = openai_1.BROWSER_USE_TOOL_OPENAI;
52
+ BrowserUseTool.anthropicToolDefinition = anthropic_1.BROWSER_USE_TOOL_ANTHROPIC;
@@ -39,3 +39,4 @@ export interface ChatCompletionTool {
39
39
  export declare const SCRAPE_TOOL_OPENAI: ChatCompletionTool;
40
40
  export declare const CRAWL_TOOL_OPENAI: ChatCompletionTool;
41
41
  export declare const EXTRACT_TOOL_OPENAI: ChatCompletionTool;
42
+ export declare const BROWSER_USE_TOOL_OPENAI: ChatCompletionTool;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EXTRACT_TOOL_OPENAI = exports.CRAWL_TOOL_OPENAI = exports.SCRAPE_TOOL_OPENAI = void 0;
3
+ exports.BROWSER_USE_TOOL_OPENAI = exports.EXTRACT_TOOL_OPENAI = exports.CRAWL_TOOL_OPENAI = exports.SCRAPE_TOOL_OPENAI = void 0;
4
4
  const schema_1 = require("./schema");
5
5
  exports.SCRAPE_TOOL_OPENAI = {
6
6
  type: "function",
@@ -29,3 +29,12 @@ exports.EXTRACT_TOOL_OPENAI = {
29
29
  strict: true,
30
30
  },
31
31
  };
32
+ exports.BROWSER_USE_TOOL_OPENAI = {
33
+ type: "function",
34
+ function: {
35
+ name: "browser_use",
36
+ description: "Have an AI agent use a browser to perform a task on the web.",
37
+ parameters: schema_1.BROWSER_USE_SCHEMA,
38
+ strict: true,
39
+ },
40
+ };
@@ -150,3 +150,36 @@ export declare const EXTRACT_SCHEMA: {
150
150
  required: string[];
151
151
  additionalProperties: boolean;
152
152
  };
153
+ export declare const BROWSER_USE_SCHEMA: {
154
+ type: "object";
155
+ properties: {
156
+ task: {
157
+ type: string;
158
+ description: string;
159
+ };
160
+ llm: {
161
+ description: string;
162
+ type: string;
163
+ enum: string[];
164
+ default: string;
165
+ };
166
+ plannerLlm: {
167
+ description: string;
168
+ type: string;
169
+ enum: string[];
170
+ default: string;
171
+ };
172
+ pageExtractionLlm: {
173
+ description: string;
174
+ type: string;
175
+ enum: string[];
176
+ default: string;
177
+ };
178
+ keepBrowserOpen: {
179
+ type: string;
180
+ description: string;
181
+ };
182
+ };
183
+ required: string[];
184
+ additionalProperties: boolean;
185
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EXTRACT_SCHEMA = exports.CRAWL_SCHEMA = exports.SCRAPE_SCHEMA = exports.SCRAPE_OPTIONS = void 0;
3
+ exports.BROWSER_USE_SCHEMA = exports.EXTRACT_SCHEMA = exports.CRAWL_SCHEMA = exports.SCRAPE_SCHEMA = exports.SCRAPE_OPTIONS = void 0;
4
4
  exports.SCRAPE_OPTIONS = {
5
5
  type: "object",
6
6
  description: "The options for the scrape",
@@ -111,3 +111,42 @@ exports.EXTRACT_SCHEMA = {
111
111
  required: ["urls", "prompt", "schema", "maxLinks"],
112
112
  additionalProperties: false,
113
113
  };
114
+ const BROWSER_USE_LLM_SCHEMA = {
115
+ type: "string",
116
+ enum: [
117
+ "gpt-4o",
118
+ "gpt-4o-mini",
119
+ "claude-3-7-sonnet-20250219",
120
+ "claude-3-5-sonnet-20241022",
121
+ "claude-3-5-haiku-20241022",
122
+ "gemini-2.0-flash",
123
+ ],
124
+ default: "gemini-2.0-flash",
125
+ };
126
+ exports.BROWSER_USE_SCHEMA = {
127
+ type: "object",
128
+ properties: {
129
+ task: {
130
+ type: "string",
131
+ description: "The text description of the task to be performed by the agent.",
132
+ },
133
+ llm: {
134
+ ...BROWSER_USE_LLM_SCHEMA,
135
+ description: "The language model (LLM) instance to use for generating actions. Default to gemini-2.0-flash.",
136
+ },
137
+ plannerLlm: {
138
+ ...BROWSER_USE_LLM_SCHEMA,
139
+ description: "The language model to use specifically for planning future actions, can differ from the main LLM. Default to gemini-2.0-flash.",
140
+ },
141
+ pageExtractionLlm: {
142
+ ...BROWSER_USE_LLM_SCHEMA,
143
+ description: "The language model to use for extracting structured data from webpages. Default to gemini-2.0-flash.",
144
+ },
145
+ keepBrowserOpen: {
146
+ type: "boolean",
147
+ description: "When enabled, keeps the browser session open after task completion.",
148
+ },
149
+ },
150
+ required: ["task", "llm", "plannerLlm", "pageExtractionLlm", "keepBrowserOpen"],
151
+ additionalProperties: false,
152
+ };
@@ -1,5 +1,5 @@
1
- import { BrowserUseLlm, BrowserUseTaskStatus } from "../../constants";
2
- import { CreateSessionParams } from "../../session";
1
+ import { BrowserUseLlm, BrowserUseTaskStatus } from "../constants";
2
+ import { CreateSessionParams } from "../session";
3
3
  export interface StartBrowserUseTaskParams {
4
4
  task: string;
5
5
  llm?: BrowserUseLlm;
@@ -28,6 +28,9 @@ export interface CrawledPage {
28
28
  links?: string[];
29
29
  screenshot?: string;
30
30
  }
31
+ export interface CrawlJobStatusResponse {
32
+ status: CrawlJobStatus;
33
+ }
31
34
  export interface CrawlJobResponse {
32
35
  jobId: string;
33
36
  status: CrawlJobStatus;
@@ -13,6 +13,9 @@ export interface StartExtractJobParams {
13
13
  export interface StartExtractJobResponse {
14
14
  jobId: string;
15
15
  }
16
+ export interface ExtractJobStatusResponse {
17
+ status: ExtractJobStatus;
18
+ }
16
19
  export interface ExtractJobResponse {
17
20
  jobId: string;
18
21
  status: ExtractJobStatus;
@@ -1,8 +1,8 @@
1
1
  export { HyperbrowserConfig } from "./config";
2
- export { StartCrawlJobParams, StartCrawlJobResponse, CrawledPage, CrawlJobResponse, GetCrawlJobParams, } from "./crawl";
3
- export { StartScrapeJobParams, StartScrapeJobResponse, ScrapeJobData, ScrapeJobResponse, ScrapeOptions, } from "./scrape";
4
- export { StartExtractJobParams, StartExtractJobResponse, ExtractJobResponse } from "./extract";
5
- export { StartBrowserUseTaskParams, StartBrowserUseTaskResponse, BrowserUseTaskStatusResponse, BrowserUseTaskResponse, BrowserUseTaskData, } from "./beta/agents/browser-use";
2
+ export { StartCrawlJobParams, StartCrawlJobResponse, CrawledPage, CrawlJobResponse, GetCrawlJobParams, CrawlJobStatusResponse, } from "./crawl";
3
+ export { StartScrapeJobParams, StartScrapeJobResponse, ScrapeJobData, ScrapeJobResponse, ScrapeOptions, ScrapeJobStatusResponse, BatchScrapeJobStatusResponse, } from "./scrape";
4
+ export { StartExtractJobParams, StartExtractJobResponse, ExtractJobResponse, ExtractJobStatusResponse, } from "./extract";
5
+ export { StartBrowserUseTaskParams, StartBrowserUseTaskResponse, BrowserUseTaskStatusResponse, BrowserUseTaskResponse, BrowserUseTaskData, } from "./agents/browser-use";
6
6
  export { BasicResponse, SessionStatus, Session, SessionDetail, SessionListParams, SessionListResponse, ScreenConfig, CreateSessionParams, } from "./session";
7
7
  export { ProfileResponse, CreateProfileResponse, ProfileListParams, ProfileListResponse, } from "./profile";
8
8
  export { CreateExtensionParams, CreateExtensionResponse, ListExtensionsResponse, } from "./extension";
@@ -22,6 +22,9 @@ export interface StartScrapeJobParams {
22
22
  export interface StartScrapeJobResponse {
23
23
  jobId: string;
24
24
  }
25
+ export interface ScrapeJobStatusResponse {
26
+ status: ScrapeJobStatus;
27
+ }
25
28
  export interface ScrapeJobData {
26
29
  metadata?: Record<string, string | string[]>;
27
30
  markdown?: string;
@@ -57,6 +60,9 @@ export interface GetBatchScrapeJobParams {
57
60
  export interface StartBatchScrapeJobResponse {
58
61
  jobId: string;
59
62
  }
63
+ export interface BatchScrapeJobStatusResponse {
64
+ status: ScrapeJobStatus;
65
+ }
60
66
  export interface BatchScrapeJobResponse {
61
67
  jobId: string;
62
68
  status: ScrapeJobStatus;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperbrowser/sdk",
3
- "version": "0.34.0",
3
+ "version": "0.35.0",
4
4
  "description": "Node SDK for Hyperbrowser API",
5
5
  "author": "",
6
6
  "main": "dist/index.js",