@hyperbrowser/sdk 0.47.0 → 0.48.1

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.
@@ -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),
@@ -123,6 +123,9 @@ class CrawlService extends base_1.BaseService {
123
123
  if (tmpJobResponse.data) {
124
124
  jobResponse.data?.push(...tmpJobResponse.data);
125
125
  }
126
+ if (tmpJobResponse.error) {
127
+ jobResponse.error = tmpJobResponse.error;
128
+ }
126
129
  jobResponse.currentPageBatch = tmpJobResponse.currentPageBatch;
127
130
  jobResponse.totalCrawledPages = tmpJobResponse.totalCrawledPages;
128
131
  jobResponse.totalPageBatches = tmpJobResponse.totalPageBatches;
@@ -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
  }
@@ -123,6 +123,9 @@ class BatchScrapeService extends base_1.BaseService {
123
123
  if (tmpJobResponse.data) {
124
124
  jobResponse.data?.push(...tmpJobResponse.data);
125
125
  }
126
+ if (tmpJobResponse.error) {
127
+ jobResponse.error = tmpJobResponse.error;
128
+ }
126
129
  jobResponse.currentPageBatch = tmpJobResponse.currentPageBatch;
127
130
  jobResponse.totalScrapedPages = tmpJobResponse.totalScrapedPages;
128
131
  jobResponse.totalPageBatches = tmpJobResponse.totalPageBatches;
@@ -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
  }
@@ -6,7 +6,7 @@ export { StartBrowserUseTaskParams, StartBrowserUseTaskResponse, BrowserUseTaskS
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
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, GetSessionRecordingUrlResponse, ImageCaptchaParam, } from "./session";
9
+ export { BasicResponse, SessionStatus, Session, SessionDetail, SessionListParams, SessionListResponse, ScreenConfig, CreateSessionParams, GetSessionDownloadsUrlResponse, GetSessionVideoRecordingUrlResponse, GetSessionRecordingUrlResponse, ImageCaptchaParam, } from "./session";
10
10
  export { CreateProfileParams, ProfileResponse, CreateProfileResponse, ProfileListParams, ProfileListResponse, } from "./profile";
11
11
  export { CreateExtensionParams, CreateExtensionResponse, ListExtensionsResponse, } from "./extension";
12
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.47.0",
3
+ "version": "0.48.1",
4
4
  "description": "Node SDK for Hyperbrowser API",
5
5
  "author": "",
6
6
  "main": "dist/index.js",