@hyperbrowser/sdk 0.33.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;
@@ -33,3 +33,5 @@ export interface Tool {
33
33
  }
34
34
  export declare const SCRAPE_TOOL_ANTHROPIC: Tool;
35
35
  export declare const CRAWL_TOOL_ANTHROPIC: Tool;
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.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,
@@ -12,3 +12,13 @@ exports.CRAWL_TOOL_ANTHROPIC = {
12
12
  name: "crawl_website",
13
13
  description: "Crawl a website and return the content in markdown format",
14
14
  };
15
+ exports.EXTRACT_TOOL_ANTHROPIC = {
16
+ input_schema: schema_1.EXTRACT_SCHEMA,
17
+ name: "extract_data",
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
+ };
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,6 @@
1
1
  import { HyperbrowserClient } from "../client";
2
- import { StartScrapeJobParams, StartCrawlJobParams } from "../types";
2
+ import { StartScrapeJobParams, StartCrawlJobParams, StartBrowserUseTaskParams } from "../types";
3
+ import { StartExtractJobParams } from "../types/extract";
3
4
  export declare class WebsiteScrapeTool {
4
5
  static openaiToolDefinition: import("./openai").ChatCompletionTool;
5
6
  static anthropicToolDefinition: import("./anthropic").Tool;
@@ -10,3 +11,13 @@ export declare class WebsiteCrawlTool {
10
11
  static anthropicToolDefinition: import("./anthropic").Tool;
11
12
  static runnable(hb: HyperbrowserClient, params: StartCrawlJobParams): Promise<string>;
12
13
  }
14
+ export declare class WebsiteExtractTool {
15
+ static openaiToolDefinition: import("./openai").ChatCompletionTool;
16
+ static anthropicToolDefinition: import("./anthropic").Tool;
17
+ static runnable(hb: HyperbrowserClient, params: StartExtractJobParams): Promise<string>;
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.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 {
@@ -29,3 +29,24 @@ class WebsiteCrawlTool {
29
29
  exports.WebsiteCrawlTool = WebsiteCrawlTool;
30
30
  WebsiteCrawlTool.openaiToolDefinition = openai_1.CRAWL_TOOL_OPENAI;
31
31
  WebsiteCrawlTool.anthropicToolDefinition = anthropic_1.CRAWL_TOOL_ANTHROPIC;
32
+ class WebsiteExtractTool {
33
+ static async runnable(hb, params) {
34
+ if (params.schema && typeof params.schema === "string") {
35
+ params.schema = JSON.parse(params.schema);
36
+ }
37
+ const resp = await hb.extract.startAndWait(params);
38
+ return resp.data ? JSON.stringify(resp.data) : "";
39
+ }
40
+ }
41
+ exports.WebsiteExtractTool = WebsiteExtractTool;
42
+ WebsiteExtractTool.openaiToolDefinition = openai_1.EXTRACT_TOOL_OPENAI;
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;
@@ -38,3 +38,5 @@ export interface ChatCompletionTool {
38
38
  }
39
39
  export declare const SCRAPE_TOOL_OPENAI: ChatCompletionTool;
40
40
  export declare const CRAWL_TOOL_OPENAI: ChatCompletionTool;
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.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",
@@ -20,3 +20,21 @@ exports.CRAWL_TOOL_OPENAI = {
20
20
  strict: true,
21
21
  },
22
22
  };
23
+ exports.EXTRACT_TOOL_OPENAI = {
24
+ type: "function",
25
+ function: {
26
+ name: "extract_data",
27
+ 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.",
28
+ parameters: schema_1.EXTRACT_SCHEMA,
29
+ strict: true,
30
+ },
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
+ };
@@ -2,21 +2,21 @@ export declare const SCRAPE_OPTIONS: {
2
2
  type: string;
3
3
  description: string;
4
4
  properties: {
5
- include_tags: {
5
+ includeTags: {
6
6
  type: string;
7
7
  items: {
8
8
  type: string;
9
9
  };
10
10
  description: string;
11
11
  };
12
- exclude_tags: {
12
+ excludeTags: {
13
13
  type: string;
14
14
  items: {
15
15
  type: string;
16
16
  };
17
17
  description: string;
18
18
  };
19
- only_main_content: {
19
+ onlyMainContent: {
20
20
  type: string;
21
21
  description: string;
22
22
  };
@@ -31,25 +31,25 @@ export declare const SCRAPE_SCHEMA: {
31
31
  type: string;
32
32
  description: string;
33
33
  };
34
- scrape_options: {
34
+ scrapeOptions: {
35
35
  type: string;
36
36
  description: string;
37
37
  properties: {
38
- include_tags: {
38
+ includeTags: {
39
39
  type: string;
40
40
  items: {
41
41
  type: string;
42
42
  };
43
43
  description: string;
44
44
  };
45
- exclude_tags: {
45
+ excludeTags: {
46
46
  type: string;
47
47
  items: {
48
48
  type: string;
49
49
  };
50
50
  description: string;
51
51
  };
52
- only_main_content: {
52
+ onlyMainContent: {
53
53
  type: string;
54
54
  description: string;
55
55
  };
@@ -68,51 +68,51 @@ export declare const CRAWL_SCHEMA: {
68
68
  type: string;
69
69
  description: string;
70
70
  };
71
- max_pages: {
71
+ maxPages: {
72
72
  type: string;
73
73
  description: string;
74
74
  };
75
- follow_links: {
75
+ followLinks: {
76
76
  type: string;
77
77
  description: string;
78
78
  };
79
- ignore_sitemap: {
79
+ ignoreSitemap: {
80
80
  type: string;
81
81
  description: string;
82
82
  };
83
- exclude_patterns: {
83
+ excludePatterns: {
84
84
  type: string;
85
85
  items: {
86
86
  type: string;
87
87
  };
88
88
  description: string;
89
89
  };
90
- include_patterns: {
90
+ includePatterns: {
91
91
  type: string;
92
92
  items: {
93
93
  type: string;
94
94
  };
95
95
  description: string;
96
96
  };
97
- scrape_options: {
97
+ scrapeOptions: {
98
98
  type: string;
99
99
  description: string;
100
100
  properties: {
101
- include_tags: {
101
+ includeTags: {
102
102
  type: string;
103
103
  items: {
104
104
  type: string;
105
105
  };
106
106
  description: string;
107
107
  };
108
- exclude_tags: {
108
+ excludeTags: {
109
109
  type: string;
110
110
  items: {
111
111
  type: string;
112
112
  };
113
113
  description: string;
114
114
  };
115
- only_main_content: {
115
+ onlyMainContent: {
116
116
  type: string;
117
117
  description: string;
118
118
  };
@@ -124,3 +124,62 @@ export declare const CRAWL_SCHEMA: {
124
124
  required: string[];
125
125
  additionalProperties: boolean;
126
126
  };
127
+ export declare const EXTRACT_SCHEMA: {
128
+ type: "object";
129
+ properties: {
130
+ urls: {
131
+ type: string;
132
+ items: {
133
+ type: string;
134
+ };
135
+ description: string;
136
+ };
137
+ prompt: {
138
+ type: string;
139
+ description: string;
140
+ };
141
+ schema: {
142
+ type: string;
143
+ description: string;
144
+ };
145
+ maxLinks: {
146
+ type: string;
147
+ description: string;
148
+ };
149
+ };
150
+ required: string[];
151
+ additionalProperties: boolean;
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,30 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- 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",
7
7
  properties: {
8
- include_tags: {
8
+ includeTags: {
9
9
  type: "array",
10
10
  items: {
11
11
  type: "string",
12
12
  },
13
13
  description: "An array of HTML tags, classes, or IDs to include in the scraped content. Only elements matching these selectors will be returned.",
14
14
  },
15
- exclude_tags: {
15
+ excludeTags: {
16
16
  type: "array",
17
17
  items: {
18
18
  type: "string",
19
19
  },
20
20
  description: "An array of HTML tags, classes, or IDs to exclude from the scraped content. Elements matching these selectors will be omitted from the response.",
21
21
  },
22
- only_main_content: {
22
+ onlyMainContent: {
23
23
  type: "boolean",
24
24
  description: "Whether to only return the main content of the page. If true, only the main content of the page will be returned, excluding any headers, navigation menus,footers, or other non-main content.",
25
25
  },
26
26
  },
27
- required: ["include_tags", "exclude_tags", "only_main_content"],
27
+ required: ["includeTags", "excludeTags", "onlyMainContent"],
28
28
  additionalProperties: false,
29
29
  };
30
30
  exports.SCRAPE_SCHEMA = {
@@ -34,9 +34,9 @@ exports.SCRAPE_SCHEMA = {
34
34
  type: "string",
35
35
  description: "The URL of the website to scrape",
36
36
  },
37
- scrape_options: exports.SCRAPE_OPTIONS,
37
+ scrapeOptions: exports.SCRAPE_OPTIONS,
38
38
  },
39
- required: ["url", "scrape_options"],
39
+ required: ["url", "scrapeOptions"],
40
40
  additionalProperties: false,
41
41
  };
42
42
  exports.CRAWL_SCHEMA = {
@@ -46,42 +46,107 @@ exports.CRAWL_SCHEMA = {
46
46
  type: "string",
47
47
  description: "The URL of the website to crawl",
48
48
  },
49
- max_pages: {
49
+ maxPages: {
50
50
  type: "number",
51
51
  description: "The maximum number of pages to crawl",
52
52
  },
53
- follow_links: {
53
+ followLinks: {
54
54
  type: "boolean",
55
55
  description: "Whether to follow links on the page",
56
56
  },
57
- ignore_sitemap: {
57
+ ignoreSitemap: {
58
58
  type: "boolean",
59
59
  description: "Whether to ignore the sitemap",
60
60
  },
61
- exclude_patterns: {
61
+ excludePatterns: {
62
62
  type: "array",
63
63
  items: {
64
64
  type: "string",
65
65
  },
66
66
  description: "An array of regular expressions or wildcard patterns specifying which URLs should be excluded from the crawl. Any pages whose URLs' path match one of these patterns will be skipped. Example: ['/admin', '/careers/*']",
67
67
  },
68
- include_patterns: {
68
+ includePatterns: {
69
69
  type: "array",
70
70
  items: {
71
71
  type: "string",
72
72
  },
73
73
  description: "An array of regular expressions or wildcard patterns specifying which URLs should be included in the crawl. Only pages whose URLs' path match one of these path patterns will be visited. Example: ['/admin', '/careers/*']",
74
74
  },
75
- scrape_options: exports.SCRAPE_OPTIONS,
75
+ scrapeOptions: exports.SCRAPE_OPTIONS,
76
76
  },
77
77
  required: [
78
78
  "url",
79
- "max_pages",
80
- "follow_links",
81
- "ignore_sitemap",
82
- "exclude_patterns",
83
- "include_patterns",
84
- "scrape_options",
79
+ "maxPages",
80
+ "followLinks",
81
+ "ignoreSitemap",
82
+ "excludePatterns",
83
+ "includePatterns",
84
+ "scrapeOptions",
85
85
  ],
86
86
  additionalProperties: false,
87
87
  };
88
+ exports.EXTRACT_SCHEMA = {
89
+ type: "object",
90
+ properties: {
91
+ urls: {
92
+ type: "array",
93
+ items: {
94
+ type: "string",
95
+ },
96
+ description: "A required list of up to 10 urls you want to process IN A SINGLE EXTRACTION. When answering questions that involve multiple sources or topics, ALWAYS include ALL relevant URLs in this single array rather than making separate function calls. This enables cross-referencing information across multiple sources to provide comprehensive answers. To allow crawling for any of the urls provided in the list, simply add /* to the end of the url (https://hyperbrowser.ai/*). This will crawl other pages on the site with the same origin and find relevant pages to use for the extraction context.",
97
+ },
98
+ prompt: {
99
+ type: "string",
100
+ description: "A prompt describing how you want the data structured, or what you want to extract from the urls provided. Can also be used to guide the extraction process. For multi-source queries, structure this prompt to request unified, comparative, or aggregated information across all provided URLs.",
101
+ },
102
+ schema: {
103
+ type: "string",
104
+ description: "A strict json schema you want the returned data to be structured as. For multi-source extraction, design this schema to accommodate information from all URLs in a single structure. Ensure that this is a proper json schema, and the root level should be of type 'object'.",
105
+ },
106
+ maxLinks: {
107
+ type: "number",
108
+ description: "The maximum number of links to look for if performing a crawl for any given url in the urls list.",
109
+ },
110
+ },
111
+ required: ["urls", "prompt", "schema", "maxLinks"],
112
+ additionalProperties: false,
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,7 +1,9 @@
1
1
  export { HyperbrowserConfig } from "./config";
2
- export { StartCrawlJobParams, StartCrawlJobResponse, CrawledPage, CrawlJobResponse, GetCrawlJobParams, } from "./crawl";
3
- export { StartScrapeJobParams, StartScrapeJobResponse, ScrapeJobData, ScrapeJobResponse, ScrapeOptions, } from "./scrape";
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";
4
6
  export { BasicResponse, SessionStatus, Session, SessionDetail, SessionListParams, SessionListResponse, ScreenConfig, CreateSessionParams, } from "./session";
5
7
  export { ProfileResponse, CreateProfileResponse, ProfileListParams, ProfileListResponse, } from "./profile";
6
8
  export { CreateExtensionParams, CreateExtensionResponse, ListExtensionsResponse, } from "./extension";
7
- export { ScrapeJobStatus, CrawlJobStatus, Country, State, ISO639_1, OperatingSystem, Platform, ScrapeFormat, ScrapeWaitUntil, ScrapePageStatus, CrawlPageStatus, } from "./constants";
9
+ export { ExtractJobStatus, BrowserUseTaskStatus, BrowserUseLlm, ScrapeScreenshotFormat, ScrapeJobStatus, CrawlJobStatus, Country, State, ISO639_1, OperatingSystem, Platform, ScrapeFormat, ScrapeWaitUntil, ScrapePageStatus, CrawlPageStatus, } from "./constants";
@@ -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.33.0",
3
+ "version": "0.35.0",
4
4
  "description": "Node SDK for Hyperbrowser API",
5
5
  "author": "",
6
6
  "main": "dist/index.js",