@hyperbrowser/sdk 0.35.0 → 0.36.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.
@@ -32,6 +32,7 @@ export interface Tool {
32
32
  description?: string;
33
33
  }
34
34
  export declare const SCRAPE_TOOL_ANTHROPIC: Tool;
35
+ export declare const SCREENSHOT_TOOL_ANTHROPIC: Tool;
35
36
  export declare const CRAWL_TOOL_ANTHROPIC: Tool;
36
37
  export declare const EXTRACT_TOOL_ANTHROPIC: Tool;
37
38
  export declare const BROWSER_USE_TOOL_ANTHROPIC: Tool;
@@ -1,12 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BROWSER_USE_TOOL_ANTHROPIC = 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.SCREENSHOT_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,
7
7
  name: "scrape_webpage",
8
8
  description: "Scrape content from a webpage and return the content in markdown format",
9
9
  };
10
+ exports.SCREENSHOT_TOOL_ANTHROPIC = {
11
+ name: "screenshot_webpage",
12
+ description: "Take a screenshot of a webpage and return the screenshot in screenshot format as a url",
13
+ input_schema: schema_1.SCREENSHOT_SCHEMA,
14
+ };
10
15
  exports.CRAWL_TOOL_ANTHROPIC = {
11
16
  input_schema: schema_1.CRAWL_SCHEMA,
12
17
  name: "crawl_website",
@@ -6,6 +6,11 @@ export declare class WebsiteScrapeTool {
6
6
  static anthropicToolDefinition: import("./anthropic").Tool;
7
7
  static runnable(hb: HyperbrowserClient, params: StartScrapeJobParams): Promise<string>;
8
8
  }
9
+ export declare class WebsiteScreenshotTool {
10
+ static openaiToolDefinition: import("./openai").ChatCompletionTool;
11
+ static anthropicToolDefinition: import("./anthropic").Tool;
12
+ static runnable(hb: HyperbrowserClient, params: StartScrapeJobParams): Promise<string>;
13
+ }
9
14
  export declare class WebsiteCrawlTool {
10
15
  static openaiToolDefinition: import("./openai").ChatCompletionTool;
11
16
  static anthropicToolDefinition: import("./anthropic").Tool;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BrowserUseTool = exports.WebsiteExtractTool = exports.WebsiteCrawlTool = exports.WebsiteScrapeTool = void 0;
3
+ exports.BrowserUseTool = exports.WebsiteExtractTool = exports.WebsiteCrawlTool = exports.WebsiteScreenshotTool = exports.WebsiteScrapeTool = void 0;
4
4
  const openai_1 = require("./openai");
5
5
  const anthropic_1 = require("./anthropic");
6
6
  class WebsiteScrapeTool {
@@ -12,6 +12,15 @@ class WebsiteScrapeTool {
12
12
  exports.WebsiteScrapeTool = WebsiteScrapeTool;
13
13
  WebsiteScrapeTool.openaiToolDefinition = openai_1.SCRAPE_TOOL_OPENAI;
14
14
  WebsiteScrapeTool.anthropicToolDefinition = anthropic_1.SCRAPE_TOOL_ANTHROPIC;
15
+ class WebsiteScreenshotTool {
16
+ static async runnable(hb, params) {
17
+ const resp = await hb.scrape.startAndWait(params);
18
+ return resp.data?.screenshot || "";
19
+ }
20
+ }
21
+ exports.WebsiteScreenshotTool = WebsiteScreenshotTool;
22
+ WebsiteScreenshotTool.openaiToolDefinition = openai_1.SCREENSHOT_TOOL_OPENAI;
23
+ WebsiteScreenshotTool.anthropicToolDefinition = anthropic_1.SCREENSHOT_TOOL_ANTHROPIC;
15
24
  class WebsiteCrawlTool {
16
25
  static async runnable(hb, params) {
17
26
  const resp = await hb.crawl.startAndWait(params);
@@ -37,6 +37,7 @@ export interface ChatCompletionTool {
37
37
  type: "function";
38
38
  }
39
39
  export declare const SCRAPE_TOOL_OPENAI: ChatCompletionTool;
40
+ export declare const SCREENSHOT_TOOL_OPENAI: ChatCompletionTool;
40
41
  export declare const CRAWL_TOOL_OPENAI: ChatCompletionTool;
41
42
  export declare const EXTRACT_TOOL_OPENAI: ChatCompletionTool;
42
43
  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.BROWSER_USE_TOOL_OPENAI = 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.SCREENSHOT_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",
@@ -11,6 +11,15 @@ exports.SCRAPE_TOOL_OPENAI = {
11
11
  strict: true,
12
12
  },
13
13
  };
14
+ exports.SCREENSHOT_TOOL_OPENAI = {
15
+ type: "function",
16
+ function: {
17
+ name: "screenshot_webpage",
18
+ description: "Take a screenshot of a webpage and return the screenshot in screenshot format as a url",
19
+ parameters: schema_1.SCREENSHOT_SCHEMA,
20
+ strict: true,
21
+ },
22
+ };
14
23
  exports.CRAWL_TOOL_OPENAI = {
15
24
  type: "function",
16
25
  function: {
@@ -1,30 +1,49 @@
1
- export declare const SCRAPE_OPTIONS: {
2
- type: string;
3
- description: string;
1
+ export declare const SCRAPE_SCHEMA: {
2
+ type: "object";
4
3
  properties: {
5
- includeTags: {
6
- type: string;
7
- items: {
8
- type: string;
9
- };
10
- description: string;
11
- };
12
- excludeTags: {
4
+ url: {
13
5
  type: string;
14
- items: {
15
- type: string;
16
- };
17
6
  description: string;
18
7
  };
19
- onlyMainContent: {
8
+ scrapeOptions: {
20
9
  type: string;
21
10
  description: string;
11
+ properties: {
12
+ formats: {
13
+ type: string;
14
+ description: string;
15
+ items: {
16
+ type: string;
17
+ enum: ("markdown" | "screenshot")[];
18
+ };
19
+ };
20
+ includeTags: {
21
+ type: string;
22
+ items: {
23
+ type: string;
24
+ };
25
+ description: string;
26
+ };
27
+ excludeTags: {
28
+ type: string;
29
+ items: {
30
+ type: string;
31
+ };
32
+ description: string;
33
+ };
34
+ onlyMainContent: {
35
+ type: string;
36
+ description: string;
37
+ };
38
+ };
39
+ required: string[];
40
+ additionalProperties: boolean;
22
41
  };
23
42
  };
24
43
  required: string[];
25
44
  additionalProperties: boolean;
26
45
  };
27
- export declare const SCRAPE_SCHEMA: {
46
+ export declare const SCREENSHOT_SCHEMA: {
28
47
  type: "object";
29
48
  properties: {
30
49
  url: {
@@ -35,6 +54,14 @@ export declare const SCRAPE_SCHEMA: {
35
54
  type: string;
36
55
  description: string;
37
56
  properties: {
57
+ formats: {
58
+ type: string;
59
+ description: string;
60
+ items: {
61
+ type: string;
62
+ enum: ("markdown" | "screenshot")[];
63
+ };
64
+ };
38
65
  includeTags: {
39
66
  type: string;
40
67
  items: {
@@ -98,6 +125,14 @@ export declare const CRAWL_SCHEMA: {
98
125
  type: string;
99
126
  description: string;
100
127
  properties: {
128
+ formats: {
129
+ type: string;
130
+ description: string;
131
+ items: {
132
+ type: string;
133
+ enum: ("markdown" | "screenshot")[];
134
+ };
135
+ };
101
136
  includeTags: {
102
137
  type: string;
103
138
  items: {
@@ -1,40 +1,62 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BROWSER_USE_SCHEMA = exports.EXTRACT_SCHEMA = exports.CRAWL_SCHEMA = exports.SCRAPE_SCHEMA = exports.SCRAPE_OPTIONS = void 0;
4
- exports.SCRAPE_OPTIONS = {
5
- type: "object",
6
- description: "The options for the scrape",
7
- properties: {
8
- includeTags: {
9
- type: "array",
10
- items: {
11
- type: "string",
3
+ exports.BROWSER_USE_SCHEMA = exports.EXTRACT_SCHEMA = exports.CRAWL_SCHEMA = exports.SCREENSHOT_SCHEMA = exports.SCRAPE_SCHEMA = void 0;
4
+ function getScrapeOptions(formats = ["markdown"]) {
5
+ return {
6
+ type: "object",
7
+ description: "The options for the scrape",
8
+ properties: {
9
+ formats: {
10
+ type: "array",
11
+ description: "The format of the content to scrape",
12
+ items: {
13
+ type: "string",
14
+ enum: formats,
15
+ },
12
16
  },
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
- },
15
- excludeTags: {
16
- type: "array",
17
- items: {
18
- type: "string",
17
+ includeTags: {
18
+ type: "array",
19
+ items: {
20
+ type: "string",
21
+ },
22
+ description: "An array of HTML tags, classes, or IDs to include in the scraped content. Only elements matching these selectors will be returned.",
23
+ },
24
+ excludeTags: {
25
+ type: "array",
26
+ items: {
27
+ type: "string",
28
+ },
29
+ 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.",
30
+ },
31
+ onlyMainContent: {
32
+ type: "boolean",
33
+ 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.",
19
34
  },
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
35
  },
22
- onlyMainContent: {
23
- type: "boolean",
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.",
36
+ required: ["includeTags", "excludeTags", "onlyMainContent", "formats"],
37
+ additionalProperties: false,
38
+ };
39
+ }
40
+ exports.SCRAPE_SCHEMA = {
41
+ type: "object",
42
+ properties: {
43
+ url: {
44
+ type: "string",
45
+ description: "The URL of the website to scrape",
25
46
  },
47
+ scrapeOptions: getScrapeOptions(),
26
48
  },
27
- required: ["includeTags", "excludeTags", "onlyMainContent"],
49
+ required: ["url", "scrapeOptions"],
28
50
  additionalProperties: false,
29
51
  };
30
- exports.SCRAPE_SCHEMA = {
52
+ exports.SCREENSHOT_SCHEMA = {
31
53
  type: "object",
32
54
  properties: {
33
55
  url: {
34
56
  type: "string",
35
57
  description: "The URL of the website to scrape",
36
58
  },
37
- scrapeOptions: exports.SCRAPE_OPTIONS,
59
+ scrapeOptions: getScrapeOptions(["screenshot"]),
38
60
  },
39
61
  required: ["url", "scrapeOptions"],
40
62
  additionalProperties: false,
@@ -72,7 +94,7 @@ exports.CRAWL_SCHEMA = {
72
94
  },
73
95
  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
96
  },
75
- scrapeOptions: exports.SCRAPE_OPTIONS,
97
+ scrapeOptions: getScrapeOptions(),
76
98
  },
77
99
  required: [
78
100
  "url",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperbrowser/sdk",
3
- "version": "0.35.0",
3
+ "version": "0.36.0",
4
4
  "description": "Node SDK for Hyperbrowser API",
5
5
  "author": "",
6
6
  "main": "dist/index.js",