@hyperbrowser/sdk 0.15.0 → 0.16.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.js CHANGED
@@ -16,11 +16,11 @@ class HyperbrowserError extends Error {
16
16
  exports.HyperbrowserError = HyperbrowserError;
17
17
  class HyperbrowserClient {
18
18
  constructor(config) {
19
- const apiKey = config.apiKey;
19
+ const apiKey = config.apiKey || process.env["HYPERBROWSER_API_KEY"];
20
20
  const baseUrl = config.baseUrl || "https://app.hyperbrowser.ai";
21
21
  const timeout = config.timeout || 30000;
22
22
  if (!apiKey) {
23
- throw new HyperbrowserError("API key is required");
23
+ throw new HyperbrowserError("API key is required - either pass it in config or set HYPERBROWSER_API_KEY environment variable");
24
24
  }
25
25
  this.sessions = new sessions_1.SessionsService(apiKey, baseUrl, timeout);
26
26
  this.scrape = new scrape_1.ScrapeService(apiKey, baseUrl, timeout);
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { HyperbrowserClient } from "./client";
2
- export * from "./types";
3
2
  export { HyperbrowserError } from "./client";
4
3
  export declare const Hyperbrowser: typeof HyperbrowserClient;
5
4
  export default HyperbrowserClient;
package/dist/index.js CHANGED
@@ -1,22 +1,7 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
2
  Object.defineProperty(exports, "__esModule", { value: true });
17
3
  exports.Hyperbrowser = exports.HyperbrowserError = void 0;
18
4
  const client_1 = require("./client");
19
- __exportStar(require("./types"), exports);
20
5
  var client_2 = require("./client");
21
6
  Object.defineProperty(exports, "HyperbrowserError", { enumerable: true, get: function () { return client_2.HyperbrowserError; } });
22
7
  // Export HyperbrowserClient as Hyperbrowser for named imports
@@ -0,0 +1,35 @@
1
+ export interface CacheControlEphemeral {
2
+ type: "ephemeral";
3
+ }
4
+ export interface InputSchema {
5
+ type: "object";
6
+ properties?: unknown | null;
7
+ [k: string]: unknown;
8
+ }
9
+ export interface Tool {
10
+ /**
11
+ * [JSON schema](https://json-schema.org/) for this tool's input.
12
+ *
13
+ * This defines the shape of the `input` that your tool accepts and that the model
14
+ * will produce.
15
+ */
16
+ input_schema: InputSchema;
17
+ /**
18
+ * Name of the tool.
19
+ *
20
+ * This is how the tool will be called by the model and in tool_use blocks.
21
+ */
22
+ name: string;
23
+ cache_control?: CacheControlEphemeral | null;
24
+ /**
25
+ * Description of what this tool does.
26
+ *
27
+ * Tool descriptions should be as detailed as possible. The more information that
28
+ * the model has about what the tool is and how to use it, the better it will
29
+ * perform. You can use natural language descriptions to reinforce important
30
+ * aspects of the tool input JSON schema.
31
+ */
32
+ description?: string;
33
+ }
34
+ export declare const SCRAPE_TOOL_ANTHROPIC: Tool;
35
+ export declare const CRAWL_TOOL_ANTHROPIC: Tool;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CRAWL_TOOL_ANTHROPIC = exports.SCRAPE_TOOL_ANTHROPIC = void 0;
4
+ const schema_1 = require("./schema");
5
+ exports.SCRAPE_TOOL_ANTHROPIC = {
6
+ input_schema: schema_1.SCRAPE_SCHEMA,
7
+ name: "scrape_webpage",
8
+ description: "Scrape content from a webpage and return the content in markdown format",
9
+ };
10
+ exports.CRAWL_TOOL_ANTHROPIC = {
11
+ input_schema: schema_1.CRAWL_SCHEMA,
12
+ name: "crawl_website",
13
+ description: "Crawl a website and return the content in markdown format",
14
+ };
@@ -0,0 +1,2 @@
1
+ export { SCRAPE_TOOL_OPENAI, CRAWL_TOOL_OPENAI } from "./openai";
2
+ export { SCRAPE_TOOL_ANTHROPIC, CRAWL_TOOL_ANTHROPIC } from "./anthropic";
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CRAWL_TOOL_ANTHROPIC = exports.SCRAPE_TOOL_ANTHROPIC = exports.CRAWL_TOOL_OPENAI = exports.SCRAPE_TOOL_OPENAI = void 0;
4
+ var openai_1 = require("./openai");
5
+ Object.defineProperty(exports, "SCRAPE_TOOL_OPENAI", { enumerable: true, get: function () { return openai_1.SCRAPE_TOOL_OPENAI; } });
6
+ Object.defineProperty(exports, "CRAWL_TOOL_OPENAI", { enumerable: true, get: function () { return openai_1.CRAWL_TOOL_OPENAI; } });
7
+ var anthropic_1 = require("./anthropic");
8
+ Object.defineProperty(exports, "SCRAPE_TOOL_ANTHROPIC", { enumerable: true, get: function () { return anthropic_1.SCRAPE_TOOL_ANTHROPIC; } });
9
+ Object.defineProperty(exports, "CRAWL_TOOL_ANTHROPIC", { enumerable: true, get: function () { return anthropic_1.CRAWL_TOOL_ANTHROPIC; } });
@@ -0,0 +1,40 @@
1
+ export type FunctionParameters = Record<string, unknown>;
2
+ export interface FunctionDefinition {
3
+ /**
4
+ * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain
5
+ * underscores and dashes, with a maximum length of 64.
6
+ */
7
+ name: string;
8
+ /**
9
+ * A description of what the function does, used by the model to choose when and
10
+ * how to call the function.
11
+ */
12
+ description?: string;
13
+ /**
14
+ * The parameters the functions accepts, described as a JSON Schema object. See the
15
+ * [guide](https://platform.openai.com/docs/guides/function-calling) for examples,
16
+ * and the
17
+ * [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for
18
+ * documentation about the format.
19
+ *
20
+ * Omitting `parameters` defines a function with an empty parameter list.
21
+ */
22
+ parameters?: FunctionParameters;
23
+ /**
24
+ * Whether to enable strict schema adherence when generating the function call. If
25
+ * set to true, the model will follow the exact schema defined in the `parameters`
26
+ * field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn
27
+ * more about Structured Outputs in the
28
+ * [function calling guide](docs/guides/function-calling).
29
+ */
30
+ strict?: boolean | null;
31
+ }
32
+ export interface ChatCompletionTool {
33
+ function: FunctionDefinition;
34
+ /**
35
+ * The type of the tool. Currently, only `function` is supported.
36
+ */
37
+ type: "function";
38
+ }
39
+ export declare const SCRAPE_TOOL_OPENAI: ChatCompletionTool;
40
+ export declare const CRAWL_TOOL_OPENAI: ChatCompletionTool;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CRAWL_TOOL_OPENAI = exports.SCRAPE_TOOL_OPENAI = void 0;
4
+ const schema_1 = require("./schema");
5
+ exports.SCRAPE_TOOL_OPENAI = {
6
+ type: "function",
7
+ function: {
8
+ name: "scrape_webpage",
9
+ description: "Scrape content from a webpage and return the content in markdown format",
10
+ parameters: schema_1.SCRAPE_SCHEMA,
11
+ },
12
+ };
13
+ exports.CRAWL_TOOL_OPENAI = {
14
+ type: "function",
15
+ function: {
16
+ name: "crawl_website",
17
+ description: "Crawl a website and return the content in markdown format",
18
+ parameters: schema_1.CRAWL_SCHEMA,
19
+ },
20
+ };
@@ -0,0 +1,119 @@
1
+ export declare const SCRAPE_OPTIONS: {
2
+ type: string;
3
+ description: string;
4
+ properties: {
5
+ include_tags: {
6
+ type: string;
7
+ items: {
8
+ type: string;
9
+ };
10
+ description: string;
11
+ };
12
+ exclude_tags: {
13
+ type: string;
14
+ items: {
15
+ type: string;
16
+ };
17
+ description: string;
18
+ };
19
+ only_main_content: {
20
+ type: string;
21
+ description: string;
22
+ };
23
+ };
24
+ };
25
+ export declare const SCRAPE_SCHEMA: {
26
+ type: "object";
27
+ properties: {
28
+ url: {
29
+ type: string;
30
+ description: string;
31
+ };
32
+ scrape_options: {
33
+ type: string;
34
+ description: string;
35
+ properties: {
36
+ include_tags: {
37
+ type: string;
38
+ items: {
39
+ type: string;
40
+ };
41
+ description: string;
42
+ };
43
+ exclude_tags: {
44
+ type: string;
45
+ items: {
46
+ type: string;
47
+ };
48
+ description: string;
49
+ };
50
+ only_main_content: {
51
+ type: string;
52
+ description: string;
53
+ };
54
+ };
55
+ };
56
+ };
57
+ required: string[];
58
+ };
59
+ export declare const CRAWL_SCHEMA: {
60
+ type: "object";
61
+ properties: {
62
+ url: {
63
+ type: string;
64
+ description: string;
65
+ };
66
+ max_pages: {
67
+ type: string;
68
+ default: number;
69
+ description: string;
70
+ };
71
+ follow_links: {
72
+ type: string;
73
+ description: string;
74
+ };
75
+ ignore_sitemap: {
76
+ type: string;
77
+ description: string;
78
+ };
79
+ exclude_patterns: {
80
+ type: string;
81
+ items: {
82
+ type: string;
83
+ };
84
+ description: string;
85
+ };
86
+ include_patterns: {
87
+ type: string;
88
+ items: {
89
+ type: string;
90
+ };
91
+ description: string;
92
+ };
93
+ scrape_options: {
94
+ type: string;
95
+ description: string;
96
+ properties: {
97
+ include_tags: {
98
+ type: string;
99
+ items: {
100
+ type: string;
101
+ };
102
+ description: string;
103
+ };
104
+ exclude_tags: {
105
+ type: string;
106
+ items: {
107
+ type: string;
108
+ };
109
+ description: string;
110
+ };
111
+ only_main_content: {
112
+ type: string;
113
+ description: string;
114
+ };
115
+ };
116
+ };
117
+ };
118
+ required: string[];
119
+ };
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ 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
+ include_tags: {
9
+ type: "array",
10
+ items: {
11
+ type: "string",
12
+ },
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
+ exclude_tags: {
16
+ type: "array",
17
+ items: {
18
+ type: "string",
19
+ },
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
+ },
22
+ only_main_content: {
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.",
25
+ },
26
+ },
27
+ };
28
+ exports.SCRAPE_SCHEMA = {
29
+ type: "object",
30
+ properties: {
31
+ url: {
32
+ type: "string",
33
+ description: "The URL of the website to scrape",
34
+ },
35
+ scrape_options: exports.SCRAPE_OPTIONS,
36
+ },
37
+ required: ["url"],
38
+ };
39
+ exports.CRAWL_SCHEMA = {
40
+ type: "object",
41
+ properties: {
42
+ url: {
43
+ type: "string",
44
+ description: "The URL of the website to crawl",
45
+ },
46
+ max_pages: {
47
+ type: "number",
48
+ default: 10,
49
+ description: "The maximum number of pages to crawl",
50
+ },
51
+ follow_links: {
52
+ type: "boolean",
53
+ description: "Whether to follow links on the page",
54
+ },
55
+ ignore_sitemap: {
56
+ type: "boolean",
57
+ description: "Whether to ignore the sitemap",
58
+ },
59
+ exclude_patterns: {
60
+ type: "array",
61
+ items: {
62
+ type: "string",
63
+ },
64
+ 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/*']",
65
+ },
66
+ include_patterns: {
67
+ type: "array",
68
+ items: {
69
+ type: "string",
70
+ },
71
+ 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/*']",
72
+ },
73
+ scrape_options: exports.SCRAPE_OPTIONS,
74
+ },
75
+ required: ["url"],
76
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperbrowser/sdk",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "Node SDK for Hyperbrowser API",
5
5
  "author": "",
6
6
  "main": "dist/index.js",
@@ -38,5 +38,25 @@
38
38
  "prettier": "^3.3.3",
39
39
  "ts-node": "^10.9.2",
40
40
  "typescript": "^5.6.3"
41
+ },
42
+ "exports": {
43
+ ".": {
44
+ "types": "./dist/index.d.ts",
45
+ "default": "./dist/index.js"
46
+ },
47
+ "./types": {
48
+ "types": "./dist/types/index.d.ts",
49
+ "default": "./dist/types/index.js"
50
+ },
51
+ "./tools": {
52
+ "types": "./dist/tools/index.d.ts",
53
+ "default": "./dist/tools/index.js"
54
+ }
55
+ },
56
+ "typesVersions": {
57
+ "*": {
58
+ "types": ["./dist/types/index.d.ts"],
59
+ "tools": ["./dist/tools/index.d.ts"]
60
+ }
41
61
  }
42
62
  }